-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[pickers] Prepare compatibility with @mui/zero-runtime (stop using ownerState in styled)
#12003
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
Changes from all commits
e5aa92b
3e0c277
12e3395
b026e73
56bf1ab
399c385
a486d69
9ef8017
413dfc1
5630924
481abb5
c625f01
3b9665b
d484bf7
6bb160a
d9f6f3e
9bdb32b
c8f0f6b
07560fc
aeee6c4
59dba00
201a84f
96aae27
4160f43
5b61ce3
8909a74
02a177c
e5cdbdd
43346fa
48b8026
d518d2a
5c2ef51
79bac3d
db6bd2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -76,24 +76,43 @@ const DateTimeRangePickerToolbarStart = styled(DateTimePickerToolbar, { | |||||
| name: 'MuiDateTimeRangePickerToolbar', | ||||||
| slot: 'StartToolbar', | ||||||
| overridesResolver: (_, styles) => styles.startToolbar, | ||||||
| })<DateTimeRangePickerStartOrEndToolbarProps<any>>(({ ownerState }) => ({ | ||||||
| })<DateTimeRangePickerStartOrEndToolbarProps<any>>({ | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This would make sure that the styled-component receives
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
type DateTimeRangePickerStartOrEndToolbarProps<TDate extends PickerValidDate> =
DateTimePickerToolbarProps<TDate> & {
ownerState?: DateTimeRangePickerToolbarProps<TDate>;
};
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK the problem was that
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the right API here is : props: ({ toolbarVariant }: DateTimeRangePickerStartOrEndToolbarProps<any>) => toolbarVariant !== 'desktop',In which case I do need the typing because the types equals |
||||||
| borderBottom: 'none', | ||||||
| ...(ownerState?.toolbarVariant !== 'desktop' | ||||||
| ? { | ||||||
| variants: [ | ||||||
| { | ||||||
| props: ({ toolbarVariant }: DateTimeRangePickerStartOrEndToolbarProps<any>) => | ||||||
| toolbarVariant !== 'desktop', | ||||||
| style: { | ||||||
| padding: '12px 8px 0 12px', | ||||||
| } | ||||||
| : { | ||||||
| }, | ||||||
| }, | ||||||
| { | ||||||
| props: { toolbarVariant: 'desktop' }, | ||||||
| style: { | ||||||
| paddingBottom: 0, | ||||||
| }), | ||||||
| })) as DateTimeRangePickerStartOrEndToolbarComponent; | ||||||
| }, | ||||||
| }, | ||||||
| ], | ||||||
| }) as DateTimeRangePickerStartOrEndToolbarComponent; | ||||||
|
|
||||||
| const DateTimeRangePickerToolbarEnd = styled(DateTimePickerToolbar, { | ||||||
| name: 'MuiDateTimeRangePickerToolbar', | ||||||
| slot: 'EndToolbar', | ||||||
| overridesResolver: (_, styles) => styles.endToolbar, | ||||||
| })<DateTimeRangePickerStartOrEndToolbarProps<any>>(({ ownerState }) => ({ | ||||||
| padding: ownerState?.toolbarVariant !== 'desktop' ? '12px 8px 12px 12px' : undefined, | ||||||
| })) as DateTimeRangePickerStartOrEndToolbarComponent; | ||||||
| })<DateTimeRangePickerStartOrEndToolbarProps<any>>({ | ||||||
| variants: [ | ||||||
| { | ||||||
| props: ({ | ||||||
| ownerState: { toolbarVariant }, | ||||||
| }: { | ||||||
| ownerState: DateTimeRangePickerStartOrEndToolbarProps<any>; | ||||||
| }) => toolbarVariant !== 'desktop', | ||||||
| style: { | ||||||
| padding: '12px 8px 12px 12px', | ||||||
| }, | ||||||
| }, | ||||||
| ], | ||||||
| }) as DateTimeRangePickerStartOrEndToolbarComponent; | ||||||
|
|
||||||
| const DateTimeRangePickerToolbar = React.forwardRef(function DateTimeRangePickerToolbar< | ||||||
| TDate extends 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.
Right now the typing comes from the DOM element which also accepts
"true"and"false"But we are only passing
trueofundefinedso I restricted the typing so that our check in the styled component and the typing are coherent