-
Notifications
You must be signed in to change notification settings - Fork 77
fix: use momentjs for calendar and datepicker #817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
BREAKING CHANGE: * removed className prop, new className props
|
Deploy preview for fundamental-react ready! Built with commit e60ec9b |
| return null; | ||
| } | ||
|
|
||
| //If range is enabled and the date from the parent component does not match the array dates of the states then states are updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was one of the hardest parts to deal with. Ideally, this would not be deriving state from props, but mainly wanted to focus on simplifying logic rather than try to overhaul the whole component at once. Hopefully it is at least a bit more readable.
| expect(wrapper.state('arrSelectedDates')).toEqual('undefined'); | ||
| }); | ||
|
|
||
| test('entering invalid range dates', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DatePicker used to arbitrarily set a limit of 3000 for the year. I do not think we need to impose this limitation now that moment is handling validation.
src/DatePicker/DatePicker.js
Outdated
| }); | ||
| let formatDate = date[0].format('MM/DD/YYYY'); | ||
| if (!!date[1]) { | ||
| formatDate += '-' + date[1].format('MM/DD/YYYY'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of hardcoding month/day/year could we use L and set the locale so it's always localized?
|
Bundle size has increased over the 150 KB limit which causes builds to fail.
Wonder if we should disable some locales, or revert back to consumers manually providing the month/day names. |
jbadan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add storybook examples for the logic you updated?
| disablePastDates, | ||
| disableFutureDates, | ||
| disabledDates | ||
| } = this.props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These props now accept Date objects again instead of moment objects so consumers don't need to worry about importing moment. The Dates are just wrapped in moment inside. This fixes the entire moment objects' props being listed out on the docs site, but the API might actually be better handled this way in the first place.
* fix: use momentjs * fix: next/prev handling * fix: use moment in datepicker * fix: simplify derived state logic * fix: simplify enabled date logic * fix: simplify validation logic * fix: tests * fix: localization * fix: increase size limit * fix: use date objects for props * chore: calendar stories * chore: datepicker stories * chore: locale * merge * fix: unnecessary diffs * fix: visual regression testing
* fix: use momentjs * fix: next/prev handling * fix: use moment in datepicker * fix: simplify derived state logic * fix: simplify enabled date logic * fix: simplify validation logic * fix: tests * fix: localization * fix: increase size limit * fix: use date objects for props * chore: calendar stories * chore: datepicker stories * chore: locale * merge * fix: unnecessary diffs * fix: visual regression testing


Description
Refactors
CalendarandDatePickerto use momentjs. Attempting to get rid of redundant logic covered by moment.fixes #703
fixes #550
fixes #493