-
-
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] Add new properties to PickerOwnerState
and PickerContextValue
#15415
[pickers] Add new properties to PickerOwnerState
and PickerContextValue
#15415
Conversation
0c9c094
to
6b86c85
Compare
extends Pick<PickerProviderProps, 'localeText'> { | ||
pickerValueResponse: UsePickerValueResponse<TValue, FieldSection, any>; | ||
ownerState: PickerOwnerState; | ||
function getOrientation(): PickerOrientation { |
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 logic of getOrientation
and usePickerOrientation
comes from useIsLandscape
which is used in usePickerLayoutProps
and will be removed once we stop passing isLandscape
as a prop to PickersLayout
Deploy preview: https://deploy-preview-15415--material-ui-x.netlify.app/ |
6b86c85
to
e82a694
Compare
ownerState
and to usePickerContext
PickerOwnerState
and PickerContextValue
e82a694
to
ea217ec
Compare
*/ | ||
export interface UsePickerProviderProps extends FormProps { | ||
/** | ||
* Force rendering in particular orientation. |
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.
It's the JSDoc we currently have in usePickersLayoutProps
but it's probably not great 🤔
If you have a better one, I can apply it in a follow up (to avoid poluting this PR with all the doc gen)
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 would go with something like "Specifies the picker's orientation"
…o the private context
ea217ec
to
b27b009
Compare
PickerOwnerState
and PickerContextValue
PickerOwnerState
and PickerContextValue
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
packages/x-date-pickers/src/internals/hooks/usePicker/usePickerLayoutProps.ts
Show resolved
Hide resolved
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 🎉
The new naming makes sense in my opinion. Thanks for taking care of it
Extracted from #15300
Part of #14475
Part of #14718
In this PR
Rename
wrapperVariant
intovariant
.I always found this name confusing. What is the "wrapper"? For now
wrapperVariant
is only public in someownerState
and as a prop received byPickersLayout
(and the toolbars have an equivalent prop namedtoolbarVariant
), but if we add it to the public context and to all theownerState
, we will make it widely used so I think it's important to think about its naming now.Side note: I did not rename them on any public API since the goal is to remove them and use the context instead.
Add
variant
,orientation
,disabled
andreadOnly
to thePickerContextValue
interface (accessed viausePickerContext
).I want to stop passing props to
PickersLayout
and to the toolbar components to prepare for the composition API so I need another way to access them. I'm adding it to the public context not to the private one because when creating a custom toolbar people currently have access to this info (through the props) and should continue to have access to it.Add
pickerVariant
andpickerOrientation
to thePickerOwnerState
interface.I was relunctant to do it, but while working on [pickers] ON HOLD - Use the new
ownerState
in all the toolbars and stop passing variant and isLandscape to any component #15300 it was clear that we have a lot of slots (especiallystyled()
components) that uses it and it's a pain to manually add it everytime.I went for
orientation
/pickerOrientation
instead ofisLandscape
because I think it provides a better DX and if we change how people access this information, it's also the right time to change the value. But I can revert toisLandscape
/isPickerInLandscape
instead if you prefer.