[pickers] Improve the DX of custom pickers #14718
Labels
component: pickers
This is the name of the generic UI component, not the React module!
customization: logic
Logic customizability
design: base-ui
It's about the headless components.
WIP
This is very early stage and will probably change dramatically before any actual development can happen.
If the team wants to discuss some API, I would prefer to focus on #14496 for now.
Introduction
What is the Base UI DX?
In this document, I talk a lot about the "Base UI DX". I use generic term to describe some of the key concepts that Base UI decided to follow in its components. Following those principles requires to use some Base UI utils but it does not mean using the Base UI components directly (which is an entire different topic).
Here is what using a Base UI component can look like:
Opinions
The Base UI DX will be highly valuable for some parts of the pickers.
DayCalendar
,MultiSectionDigitalClock
, ...)Migrating the whole codebase to use the Base UI DX is a huge task that is not cost-effective in the forseable future, we should concentrate our efforts where it brings the most value to our users
The Base UI DX makes very little sense on some heavy UI-oriented like the Android analog clock.
Package structure
Throughout this document, I am using the following package structure:
@base-ui/x-date-pickers
(and@base-ui/x-date-pickers-pro
): The packages that contain the components built using the Base UI DX and potentially some higher level components. Should not have@mui/material
as a dependency, and if possible not even@mui/system
.@mui/x-date-pickers
(and@mui/x-date-pickers-pro
): The package that contain the components built on top of Material UI (the equivalent of the current components).@zucchini
is a placeholder and will of course be replaced by the ne name of MUI X once decided.New components
Picker
The
Picker
component would be the cornerstone for people that wants:@mui/system
and@mui/material
)TimeClock
on desktop).This component would replace most of the current
useXXXPicker
hook and the currentPickersLayout
component.It would allow people to override only the part of the UI that they want to override, allowing them to migrate step by step from
@mui/material
without having to rebuild everything from day 1.I am far from certain how this component should look like, the only thing I'm pretty sure about is that we need some tool like to give users an escape hatch when they need advanced customization (either for unstyled or to replace some views).
Mimimal example
A mimimal example using all our Material UI components would look something like this:
Custom field
Using
Picker
, people could easily swap their built-in field for one that is built usingPickerField
(see #14496 (comment) for more details)Note that for now the rest of the UI is style using Material UI, people can migrate the field to their design system and then tackle the other parts of the UI they think are the most importants.
Modal / popover management
The example above are using
PickerResponsivePopup
for managing the opening of their views.This component would be built on top of
Picker.ResponsivePopup
and apply some MUI style to it.Picker.ResponsivePopup
would then use eitherPopover
orDialog
from Base UI depending on the current variant of the picker (currently "mobile", "desktop" but we can change this nomenclature if we want to).Here is what it would look like for people using the responsive approach but without Material UI:
To customize when
Popover
andModal
should be used, we can keep an API similar to today withdesktopModeMediaQuery
(which is very poorly documented btw):Or people can then decide to directly use the Base UI components to get rid of the responsive aspect if they want:
By default, our popper management would be encapsulated in a
PickerResponsiveViewPopper
component exposed by@mui/x-date-picers
. But this component uses@mui/material
so it is important that people wanting to stop bundling our library are able to replace it with their own component.It is also a good opportunity to allow people to control if they want a modal, a drop down etc...
To allow overriding this component, we could expose a component in
Picker
that takes a render prop as its children and passes all the necessary information to map to the popper:Custom view component
To replace the
viewManagers
API which is quite hard to understand, we could introduce aPicker.View
component that allows to conditionnally render the view depending on the current view:It would even easily support nested views out of the box.
Here is what it would look like if someone wanted to only override the year view:
Potential roadmap
v8.0.0 alpha
v8.X.X :
PickerField
component as unstable (see [pickers] Improve the DX of custom fields #14496 (comment) for more details about the field's roadmap)Picker
component as unstablev9.0.0:
Picker
stablePicker
for their structureDateCalendar
component with a Base UI DX, then our Material UIDateCalendar
should be re-build using it as much as possible).The text was updated successfully, but these errors were encountered: