-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[pickers] Limit the valid values of TDate
#11791
Conversation
Localization writing tips ✍️Seems you are updating localization 🌍 files. Thank you for contributing to the localization! 🎉 To make your PR perfect, here is a list of elements to check: ✔️
Deploy preview: https://deploy-preview-11791--material-ui-x.netlify.app/ |
TDate
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@@ -278,7 +279,7 @@ DateTimePicker.propTypes = { | |||
* The date used to generate the new value when both `value` and `defaultValue` are empty. | |||
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`. | |||
*/ | |||
referenceDate: PropTypes.any, | |||
referenceDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.object]), |
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.
OK this is the major drawback of the new approach..
The proptype generation script is smart with Date
object does not just mark them as "object", so we end up with a proptype that is wrong for people not using date-fns...
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.
I could add a param in getPropTypesFromFile
ignoreDateType
or something similar, it's not great but I think it's worth it here
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.
Yes, this case would need some extra attention in order to avoid this particular change. 🙈
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.
Fixed by mui/material-ui#40774
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@@ -55,56 +55,56 @@ import { | |||
import { PickersSectionListProps } from '../PickersSectionList'; | |||
|
|||
export interface PickersComponentsPropsList { | |||
MuiClock: ClockProps<unknown>; | |||
MuiClock: ClockProps<PickerValidDate>; |
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 is a big benefit
Now those theme entries are correctly typed 🤩
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
75546c6
to
eda97ab
Compare
TDate
TDate
<MobileDateTimePicker | ||
open | ||
value={adapterToUse.date('2021-11-20T10:01:22')} | ||
defaultValue={(params) => <TextField {...params} />} |
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.
🤷
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.
🤣
@@ -70,7 +70,7 @@ function GridEditDateCell({ | |||
field, | |||
value, | |||
colDef, | |||
}: GridRenderEditCellParams<any, Date | string | null>) { | |||
}: GridRenderEditCellParams<any, Date | null, string>) { |
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.
Is it a fix of something?
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.
Yes, the date in the pickers can no longer be a string since v6 and the formatted value on the other hand is always a string
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.
Letting @mui/xgrid know.
Maybe you need to add a mention of this fact somewhere as well as it could impact the users. 🤔
Clarifying that this is technically not BC, because it is already the case for v6. 🙈 😆
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.
Yes, this looks good to me 👍🏻
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
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.
Really nice to see such an improvement regarding typing, great work! 🚀 👏
Hopefully it will avoid numerous cases of people being lost with types at first. 🙈
It will be breaking for people that don't import the adapter in the same typescript project.
For me it's an edge-case and they would just have to add the following import somewhere like they do for the theme augmentation:
Maybe we could add this mention in the migration guide? 🤔
@@ -70,7 +70,7 @@ function GridEditDateCell({ | |||
field, | |||
value, | |||
colDef, | |||
}: GridRenderEditCellParams<any, Date | string | null>) { | |||
}: GridRenderEditCellParams<any, Date | null, string>) { |
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.
Letting @mui/xgrid know.
Maybe you need to add a mention of this fact somewhere as well as it could impact the users. 🤔
Clarifying that this is technically not BC, because it is already the case for v6. 🙈 😆
packages/x-date-pickers-pro/src/DateRangePickerDay/DateRangePickerDay.tsx
Outdated
Show resolved
Hide resolved
packages/x-date-pickers-pro/src/internals/hooks/models/useRangePicker.ts
Show resolved
Hide resolved
...-date-pickers-pro/src/internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.ts
Show resolved
Hide resolved
<MobileDateTimePicker | ||
open | ||
value={adapterToUse.date('2021-11-20T10:01:22')} | ||
defaultValue={(params) => <TextField {...params} />} |
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.
🤣
packages/x-date-pickers/src/MultiSectionDigitalClock/MultiSectionDigitalClock.types.ts
Show resolved
Hide resolved
packages/x-date-pickers/src/PickersCalendarHeader/PickersCalendarHeader.tsx
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/PickersCalendarHeader/PickersCalendarHeader.types.ts
Show resolved
Hide resolved
1cbc888
to
ca1f66d
Compare
ca1f66d
to
68e9d73
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Co-authored-by: alexandre <[email protected]>
Fixes #10540
The approach seems to work.
It will be breaking for people that don't import the adapter in the same typescript project.
For me it's an edge-case and they would just have to add the following import somewhere like they do for the theme augmentation: