ssxv / react-dropdown-date Goto Github PK
View Code? Open in Web Editor NEWselect date from Day, Month and Year dropdown
License: MIT License
select date from Day, Month and Year dropdown
License: MIT License
Is it possible to add infinite scrolling for the year drop down?
The drop down list can still begin at the default value followed by the start date, but as the user continues to scroll up/down, new years will be added to the list by increasing the end year.
Having a constant end year may make the drop down list very large.
Its working fine in almost all browsers, except safari, in that year drop down show on default value only.
What is the point of having a 0 based index for the month field? Shouldn't it be the month number that it corresponds with?
<MonthPicker classes={'datePicker'} {...rest} defaultValue={'Month'} // default is 1900 start={1} // default is ASCENDING reverse // default is false value={value} // mandatory onChange={month => onChange(month)} required={true} />
For some reason in the react developer tools I see:
<option key='0' value{0} className={null}>1</option>
Then rendered in html :
<option value="0">1</option>
I just installed and tried to use it in react native 0.59, as:
<MonthPicker
defaultValue={'select month'}
year={'2019'}
// default is false
required={true}
// default is false
disabled={true}
// mandatory
value={'1'}
// mandatory
onChange={(month) => {
this.setState({ month })
console.log(month)
}}
id={'month'}
name={'month'}
classes={'classes'}
optionClasses={'option classes'}
/>
but I got error:
Invariant Violation: Text strings must be rendered within a <Text> component.
This error is located at:
in option (created by MonthPicker)
in select (created by MonthPicker)
in MonthPicker (at NewPaymentMethod.js:354)
in RCTView (at View.js:45)
in View (at NewPaymentMethod.js:353)
in RCTView (at View.js:45)
in View (at NewPaymentMethod.js:352)
in RCTView (at View.js:45)
in View (at NewPaymentMethod.js:350)
in RCTView (at View.js:45)
in View (at ScrollView.js:976)
in RCTScrollView (at ScrollView.js:1115)
in ScrollView (at NewPaymentMethod.js:319)
in RCTView (at View.js:45)
in View (at NewPaymentMethod.js:318)
in Formik (at NewPaymentMethod.js:192)
in RCTView (at View.js:45)
in View (at KeyboardAvoidingView.js:200)
in KeyboardAvoidingView (at NewPaymentMethod.js:186)
in NewPaymentMethodScreen (at withSetNavState.js:26)
in _class (created by Context.Consumer)
in Connect(_class) (at SceneView.js:9)
in SceneView (at StackViewLayout.tsx:888)
in RCTView (at View.js:45)
in View (at StackViewLayout.tsx:887)
in RCTView (at View.js:45)
in View (at StackViewLayout.tsx:886)
in RCTView (at View.js:45)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewCard.tsx:93)
in RCTView (at View.js:45)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at screens.native.js:71)
in Screen (at StackViewCard.tsx:80)
in Card (at createPointerEventsContainer.tsx:95)
in Container (at StackViewLayout.tsx:971)
in RCTView (at View.js:45)
in View (at screens.native.js:101)
in ScreenContainer (at StackViewLayout.tsx:383)
in RCTView (at View.js:45)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewLayout.tsx:379)
in PanGestureHandler (at StackViewLayout.tsx:372)
in StackViewLayout (at withOrientation.js:30)
in withOrientation (at StackView.tsx:103)
in RCTView (at View.js:45)
in View (at Transitioner.tsx:267)
in Transitioner (at StackView.tsx:40)
in StackView (at createNavigator.js:61)
in Navigator (at createKeyboardAwareNavigator.js:12)
in KeyboardAwareNavigator (at withResetOnTab.js:53)
in _class (at SceneView.js:9)
in SceneView (at createTabNavigator.js:39)
in RCTView (at View.js:45)
in View (at ResourceSavingScene.js:37)
in RCTView (at View.js:45)
in View (at ResourceSavingScene.js:26)
in ResourceSavingScene (at createBottomTabNavigator.js:121)
in RCTView (at View.js:45)
in View (at screens.native.js:101)
in ScreenContainer (at createBottomTabNavigator.js:111)
in RCTView (at View.js:45)
in View (at createBottomTabNavigator.js:110)
in TabNavigationView (at createTabNavigator.js:197)
in NavigationView (at createNavigator.js:61)
in Navigator (at SceneView.js:9)
in SceneView (at StackViewLayout.tsx:888)
in RCTView (at View.js:45)
in View (at StackViewLayout.tsx:887)
in RCTView (at View.js:45)
in View (at StackViewLayout.tsx:886)
in RCTView (at View.js:45)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewCard.tsx:93)
in RCTView (at View.js:45)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at screens.native.js:71)
in Screen (at StackViewCard.tsx:80)
in Card (at createPointerEventsContainer.tsx:95)
in Container (at StackViewLayout.tsx:971)
in RCTView (at View.js:45)
in View (at screens.native.js:101)
in ScreenContainer (at StackViewLayout.tsx:383)
in RCTView (at View.js:45)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewLayout.tsx:379)
in PanGestureHandler (at StackViewLayout.tsx:372)
in StackViewLayout (at withOrientation.js:30)
in withOrientation (at StackView.tsx:103)
in RCTView (at View.js:45)
in View (at Transitioner.tsx:267)
in Transitioner (at StackView.tsx:40)
in StackView (at createNavigator.js:61)
in Navigator (at createKeyboardAwareNavigator.js:12)
in KeyboardAwareNavigator (at createAppContainer.js:429)
in NavigationContainer (at RootScreen.js:164)
in RCTView (at View.js:45)
in View (at RootScreen.js:183)
in RootScreen (created by Context.Consumer)
in Connect(RootScreen) (at withPermissionsCheckConsumer.js:12)
in PermissionsConsumer (at withPermissionsCheckProvider.js:12)
in PermissionsProvider (created by Context.Consumer)
in Connect(PermissionsProvider) (at App.js:32)
in PersistGate (at App.js:30)
in Provider (at App.js:29)
in App (at renderApplication.js:35)
in RCTView (at View.js:45)
in View (at AppContainer.js:98)
in RCTView (at View.js:45)
in View (at AppContainer.js:115)
in AppContainer (at renderApplication.js:34)
createTextInstance
d195e8cf-3331-42df-ad5d-2bf60716c49a:23515:9
completeWork
d195e8cf-3331-42df-ad5d-2bf60716c49a:30645:46
completeUnitOfWork
d195e8cf-3331-42df-ad5d-2bf60716c49a:32762:32
performUnitOfWork
d195e8cf-3331-42df-ad5d-2bf60716c49a:32925:18
workLoop
d195e8cf-3331-42df-ad5d-2bf60716c49a:32935:30
renderRoot
d195e8cf-3331-42df-ad5d-2bf60716c49a:33001:13
performWorkOnRoot
d195e8cf-3331-42df-ad5d-2bf60716c49a:33739:13
performWork
d195e8cf-3331-42df-ad5d-2bf60716c49a:33666:13
performSyncWork
d195e8cf-3331-42df-ad5d-2bf60716c49a:33642:9
Hi can i disable the console log on day picker component?
just use window.parseInt!
When attempting to set an endDate with the same year as the startDate, the library has the unexpected behavior of displaying every month of the year. Example: if start date is 2021-02-01, and endDate is 2021-07-07, the drop down for month displays every month from February to December (expected behavior would just be displaying Feb - July). A quick fix would be to change the DropdownDate.prototype.generateMonthOptions function (line 320 in index.js) to include this at the top of the if else statements:
if (selectedYear === startYear && selectedYear === endYear) {
for (var i = startMonth; i <= endMonth; i++) {
months.push({
value: i,
month: monthByNumber[i]
});
}
}
I'm fairly new to this, so I'm not sure how to create a PR the appropriate way. If someone is willing to help me with this is would be much appreciated. Thanks!
I don't want to separate into year/month/date components. I want to use DropdownDate. Here's my code:
<DropdownDate
startDate={subYears(startOfToday(), 99)}
endDate={subYears(startOfToday(), 13)}
onMonthChange={this.onMonthChange}
onDayChange={this.onDayChange}
onYearChange={this.onYearChange}
onDateChange={this.onDateChange}
names={{year: 'year', month: 'month', day: 'day'}}
defaultValues={{year, month, day}}
options={{yearReverse: true, monthShort: true, monthCaps: false}}
/>
What happens: if the date is 1997-04-05, I convert month to say Apr and day to be 5. I supply them in defaultValues
but it makes a new entry at the top of the select, named Apr, rather than just selecting Apr from the list.
Hi!
I want to be able to control the height of the dropdown when on a mobile. Currently it takes up the full width and height of the viewport. I have tried to do it using CSS as follows:
maxHeight: '70vh',
overflow: 'scroll',
},
to no avail. How do I reduce the height on scroll when on a mobile? Thanks
When selecting a date, the value is being returned correctly but it displays as one day off. This is probably because when the date objects are built they accept a string that doesn't account for time zones.
Hi man, currently we are in react 16 and componentWillMount is deprecated, should be changed to UNSAFE_componentWillMount or adapt it to new lifecycle.
Is there any way of making this compatible with Semantic UI's select field?
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"^18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from [email protected]
npm ERR! node_modules/react-dropdown-date
npm ERR! react-dropdown-date@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\Admin\AppData\Local\npm-cache_logs\2023-12-07T07_23_04_573Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Local\npm-cache_logs\2023-12-07T07_23_04_573Z-debug-0.log
This tripped me up for a second. I was trying to use js native Date
in my code but it had been reassigned to the component class because i copied the example code. Maybe assign the import to DropdownDate
or something else
When I choose the dropdown MonthPicker value as 8 (August) or 3 (March) then the DayPicker does not show 31 as an option.
I want to change the default option value of month-picker, as it is starting from 0, I want to start the month value from 1. Is there any way of doing it?
can be exposed in DropdownDate props the monthByNumber and the actual one to be used as fallback?
How do I add refs to the picker? I want to focus it using useRef whenever it doesn't pass my validations. Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.