-
-
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] Use the new ownerState
object in all the field components
#15510
Conversation
df964b8
to
97bda6f
Compare
Deploy preview: https://deploy-preview-15510--material-ui-x.netlify.app/ |
97bda6f
to
41f8e02
Compare
@@ -117,6 +118,17 @@ export interface FieldRef<TSection extends FieldSection> { | |||
|
|||
export type FieldSelectedSections = number | FieldSectionType | null | 'all'; | |||
|
|||
export interface FieldOwnerState extends PickerOwnerState { |
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.
In v9, we should be able to access a lot more info if needed, but for now the structure of the component makes it very hard to put anything useful here.
I added the disabled
and readOnly
props because when used as standalone then are needed since isPickerDisabled
and isPickerReadOnly
are not reliable.
I think that's a good start that we can enrich in the future 👌
This object will also be used for the inputAdornment
, openPickerButton
and openPickerIcon
slots once those are handled by the field component.
export interface TimeFieldSlots extends UseClearableFieldSlots { | ||
/** | ||
* Form control with an input to render the value. | ||
* @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`. | ||
* @default <PickersTextField />, or <TextField /> from '@mui/material' if `enableAccessibleFieldDOMStructure` is `false`. |
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.
Not related to this PR but I noticed this inconsistent JSDoc while doing the changes
41f8e02
to
826d3d9
Compare
@@ -79,9 +80,13 @@ export interface ExportedUseDesktopPickerSlotProps< | |||
{}, | |||
PickerOwnerState | |||
>; | |||
textField?: SlotComponentProps<typeof TextField, {}, Record<string, any>>; | |||
textField?: SlotComponentPropsFromProps< |
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.
Always great to have this kind of cleaning 👌
Now the slots
exposed at the picker level will always have the right ownerState
and the right 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.
LGTM
@@ -65,7 +67,7 @@ export interface MultiInputDateRangeFieldSlots { | |||
/** | |||
* Form control with an input to render a date. | |||
* It is rendered twice: once for the start date and once for the end date. | |||
* @default TextField from '@mui/material' or PickersTextField if `enableAccessibleFieldDOMStructure` is `true`. | |||
* @default <PickersTextField />, or <TextField /> from '@mui/material' if `enableAccessibleFieldDOMStructure` is `false`. |
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.
should we wrap these in backticks? Not sure if we do this and if we are consistent with that.
* @default <PickersTextField />, or <TextField /> from '@mui/material' if `enableAccessibleFieldDOMStructure` is `false`. | |
* @default `<PickersTextField />`, or `<TextField />` from '@mui/material' if `enableAccessibleFieldDOMStructure` is `false`. |
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.
The @default
is already inside a code block in the doc so adding backticks won't help 👍
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
381f7bd
to
9633546
Compare
9633546
to
c1cb6a6
Compare
Part of #14475
useFieldOwnerState
hook to create aFieldOwnerState
object that extendsPickerOwnerState
FieldOwnerState
to resolveslotProps.textField
, in all the field componentsFieldOwnerState
to resolveslotProps.root
andslotProps.separator
in the multi input range field componentsSlotComponentPropsFromProps
instead ofSlotComponentProps
for any slot handled by the field components