Skip to content
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] Fix styling props propagation to DateTimePickerTabs #12096

Merged
merged 10 commits into from
Feb 19, 2024
1 change: 1 addition & 0 deletions docs/pages/x/api/date-pickers/date-calendar.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"props": {
"autoFocus": { "type": { "name": "bool" } },
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"dayOfWeekFormatter": {
"type": { "name": "func" },
"default": "(_day: string, date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()",
Expand Down
8 changes: 8 additions & 0 deletions docs/pages/x/api/date-pickers/date-picker-toolbar.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
},
"required": true
},
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"hidden": { "type": { "name": "bool" }, "default": "`true` for Desktop, `false` for Mobile." },
"sx": {
"type": {
"name": "union",
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
},
"additionalInfo": { "sx": true }
},
"toolbarFormat": { "type": { "name": "string" } },
"toolbarPlaceholder": { "type": { "name": "node" }, "default": "\"––\"" }
},
Expand Down
1 change: 1 addition & 0 deletions docs/pages/x/api/date-pickers/date-range-calendar.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
"default": "2"
},
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"currentMonthCalendarPosition": {
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
"default": "1"
Expand Down
8 changes: 8 additions & 0 deletions docs/pages/x/api/date-pickers/date-range-picker-toolbar.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"props": {
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"hidden": { "type": { "name": "bool" }, "default": "`true` for Desktop, `false` for Mobile." },
"sx": {
"type": {
"name": "union",
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
},
"additionalInfo": { "sx": true }
},
"toolbarFormat": { "type": { "name": "string" } },
"toolbarPlaceholder": { "type": { "name": "node" }, "default": "\"––\"" }
},
Expand Down
7 changes: 7 additions & 0 deletions docs/pages/x/api/date-pickers/date-time-picker-tabs.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
"type": { "name": "bool" },
"default": "`window.innerHeight < 667` for `DesktopDateTimePicker` and `MobileDateTimePicker`, `displayStaticWrapperAs === 'desktop'` for `StaticDateTimePicker`"
},
"sx": {
"type": {
"name": "union",
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
},
"additionalInfo": { "sx": true }
},
"timeIcon": { "type": { "name": "node" }, "default": "Time" }
},
"name": "DateTimePickerTabs",
Expand Down
7 changes: 7 additions & 0 deletions docs/pages/x/api/date-pickers/date-time-picker-toolbar.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
},
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"hidden": { "type": { "name": "bool" }, "default": "`true` for Desktop, `false` for Mobile." },
"sx": {
"type": {
"name": "union",
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
},
"additionalInfo": { "sx": true }
},
"toolbarFormat": { "type": { "name": "string" } },
"toolbarPlaceholder": { "type": { "name": "node" }, "default": "\"––\"" },
"toolbarTitle": { "type": { "name": "node" } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
"type": { "name": "bool" },
"default": "`window.innerHeight < 667` for `DesktopDateTimeRangePicker` and `MobileDateTimeRangePicker`"
},
"sx": {
"type": {
"name": "union",
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
},
"additionalInfo": { "sx": true }
},
"timeIcon": { "type": { "name": "element" }, "default": "TimeIcon" }
},
"name": "DateTimeRangePickerTabs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
},
"required": true
},
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"hidden": { "type": { "name": "bool" }, "default": "`true` for Desktop, `false` for Mobile." },
"sx": {
"type": {
"name": "union",
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
},
"additionalInfo": { "sx": true }
},
"toolbarFormat": { "type": { "name": "string" } },
"toolbarPlaceholder": { "type": { "name": "node" }, "default": "\"––\"" }
},
Expand Down
8 changes: 8 additions & 0 deletions docs/pages/x/api/date-pickers/pickers-layout.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"props": {
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"orientation": {
"type": { "name": "enum", "description": "'landscape'<br>&#124;&nbsp;'portrait'" }
},
Expand All @@ -8,6 +9,13 @@
"type": { "name": "object" },
"default": "{}",
"additionalInfo": { "slotsApi": true }
},
"sx": {
"type": {
"name": "union",
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
},
"additionalInfo": { "sx": true }
}
},
"name": "PickersLayout",
Expand Down
8 changes: 8 additions & 0 deletions docs/pages/x/api/date-pickers/time-picker-toolbar.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
},
"required": true
},
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"hidden": { "type": { "name": "bool" }, "default": "`true` for Desktop, `false` for Mobile." },
"sx": {
"type": {
"name": "union",
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
},
"additionalInfo": { "sx": true }
},
"toolbarFormat": { "type": { "name": "string" } },
"toolbarPlaceholder": { "type": { "name": "node" }, "default": "\"––\"" }
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"autoFocus": {
"description": "If <code>true</code>, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the <code>day</code> view). - the <code>input</code> element if there is a field rendered."
},
"classes": { "description": "Override or extend the styles applied to the component." },
"dayOfWeekFormatter": {
"description": "Formats the day of week displayed in the calendar header.",
"typeDescriptions": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"componentDescription": "",
"propDescriptions": {
"classes": { "description": "Override or extend the styles applied to the component." },
"hidden": { "description": "If <code>true</code>, show the toolbar even in desktop mode." },
"onViewChange": {
"description": "Callback called when a toolbar is clicked",
"typeDescriptions": { "view": "The view to open" }
},
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
},
"toolbarFormat": { "description": "Toolbar date format." },
"toolbarPlaceholder": {
"description": "Toolbar value placeholder—it is displayed when the value is empty."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"description": "Range positions available for selection. This list is checked against when checking if a next range position can be selected.<br>Used on Date Time Range pickers with current <code>rangePosition</code> to force a <code>finish</code> selection after just one range position selection."
},
"calendars": { "description": "The number of calendars to render." },
"classes": { "description": "Override or extend the styles applied to the component." },
"currentMonthCalendarPosition": { "description": "Position the current month is rendered in." },
"dayOfWeekFormatter": {
"description": "Formats the day of week displayed in the calendar header.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"componentDescription": "",
"propDescriptions": {
"classes": { "description": "Override or extend the styles applied to the component." },
"hidden": { "description": "If <code>true</code>, show the toolbar even in desktop mode." },
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
},
"toolbarFormat": { "description": "Toolbar date format." },
"toolbarPlaceholder": {
"description": "Toolbar value placeholder—it is displayed when the value is empty."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"description": "Callback called when a tab is clicked.",
"typeDescriptions": { "view": "The view to open" }
},
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
},
"timeIcon": { "description": "Time tab icon." },
"view": { "description": "Currently visible picker view." }
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"description": "Callback called when a toolbar is clicked",
"typeDescriptions": { "view": "The view to open" }
},
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
},
"toolbarFormat": { "description": "Toolbar date format." },
"toolbarPlaceholder": {
"description": "Toolbar value placeholder—it is displayed when the value is empty."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"description": "Callback called when a tab is clicked.",
"typeDescriptions": { "view": "The view to open" }
},
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
},
"timeIcon": { "description": "Time tab icon." },
"view": { "description": "Currently visible picker view." }
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"componentDescription": "",
"propDescriptions": {
"classes": { "description": "Override or extend the styles applied to the component." },
"hidden": { "description": "If <code>true</code>, show the toolbar even in desktop mode." },
"onViewChange": {
"description": "Callback called when a toolbar is clicked",
"typeDescriptions": { "view": "The view to open" }
},
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
},
"toolbarFormat": { "description": "Toolbar date format." },
"toolbarPlaceholder": {
"description": "Toolbar value placeholder—it is displayed when the value is empty."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"componentDescription": "",
"propDescriptions": {
"classes": { "description": "Override or extend the styles applied to the component." },
"orientation": { "description": "Force rendering in particular orientation." },
"slotProps": { "description": "The props used for each component slot." },
"slots": { "description": "Overridable component slots." }
"slots": { "description": "Overridable component slots." },
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
}
},
"classDescriptions": {
"contentWrapper": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"componentDescription": "",
"propDescriptions": {
"classes": { "description": "Override or extend the styles applied to the component." },
"hidden": { "description": "If <code>true</code>, show the toolbar even in desktop mode." },
"onViewChange": {
"description": "Callback called when a toolbar is clicked",
"typeDescriptions": { "view": "The view to open" }
},
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
},
"toolbarFormat": { "description": "Toolbar date format." },
"toolbarPlaceholder": {
"description": "Toolbar value placeholder—it is displayed when the value is empty."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,9 @@ DateRangeCalendar.propTypes = {
* @default 2
*/
calendars: PropTypes.oneOf([1, 2, 3]),
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
className: PropTypes.string,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ export interface DateRangeCalendarProps<TDate extends PickerValidDate>
*/
calendars?: 1 | 2 | 3;
className?: string;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<DateRangeCalendarClasses>;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export interface DateRangePickerToolbarProps<TDate extends PickerValidDate>
'views' | 'view' | 'onViewChange' | 'onChange' | 'isLandscape'
>,
Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'> {
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<DateRangePickerToolbarClasses>;
}

Expand Down Expand Up @@ -128,6 +131,9 @@ DateRangePickerToolbar.propTypes = {
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
className: PropTypes.string,
disabled: PropTypes.bool,
Expand All @@ -139,6 +145,9 @@ DateRangePickerToolbar.propTypes = {
onRangePositionChange: PropTypes.func.isRequired,
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
readOnly: PropTypes.bool,
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])),
PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(
rangePosition,
onRangePositionChange,
className,
sx,
} = props;

const localeText = useLocaleText();
Expand Down Expand Up @@ -166,7 +167,11 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(
}

return (
<DateTimeRangePickerTabsRoot ownerState={props} className={clsx(classes.root, className)}>
<DateTimeRangePickerTabsRoot
ownerState={props}
className={clsx(classes.root, className)}
sx={sx}
>
{!isPreviousHidden ? (
<IconButton
onClick={changeToPreviousTab}
Expand Down Expand Up @@ -229,6 +234,14 @@ DateTimeRangePickerTabs.propTypes = {
*/
onViewChange: PropTypes.func.isRequired,
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])),
PropTypes.func,
PropTypes.object,
]),
/**
* Time tab icon.
* @default TimeIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export interface DateTimeRangePickerToolbarProps<TDate extends PickerValidDate>
}

export interface ExportedDateTimeRangePickerToolbarProps extends ExportedBaseToolbarProps {
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<DateTimeRangePickerToolbarClasses>;
}

Expand Down Expand Up @@ -195,6 +198,9 @@ DateTimeRangePickerToolbar.propTypes = {
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
ampm: PropTypes.bool,
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
className: PropTypes.string,
disabled: PropTypes.bool,
Expand All @@ -214,6 +220,9 @@ DateTimeRangePickerToolbar.propTypes = {
onViewChange: PropTypes.func.isRequired,
rangePosition: PropTypes.oneOf(['end', 'start']).isRequired,
readOnly: PropTypes.bool,
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])),
PropTypes.func,
Expand Down
3 changes: 3 additions & 0 deletions packages/x-date-pickers/src/DateCalendar/DateCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ DateCalendar.propTypes = {
* - the `input` element if there is a field rendered.
*/
autoFocus: PropTypes.bool,
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
className: PropTypes.string,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export interface DateCalendarProps<TDate extends PickerValidDate>
*/
referenceDate?: TDate;
className?: string;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<DateCalendarClasses>;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
Expand Down
Loading
Loading