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 #12131

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 } },
"components": {
"type": { "name": "object" },
"default": "{}",
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,8 +12,16 @@
},
"required": true
},
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"className": { "type": { "name": "string" } },
"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 @@ -5,6 +5,7 @@
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
"default": "2"
},
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"components": {
"type": { "name": "object" },
"default": "{}",
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,7 +1,15 @@
{
"props": {
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"className": { "type": { "name": "string" } },
"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 @@ -15,6 +15,13 @@
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"className": { "type": { "name": "string" } },
"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 } },
"components": {
"type": { "name": "object" },
"default": "{}",
Expand All @@ -20,6 +21,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,8 +12,16 @@
},
"required": true
},
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"className": { "type": { "name": "string" } },
"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." },
"components": { "description": "Overridable components." },
"componentsProps": { "description": "The props used for each component slot." },
"dayOfWeekFormatter": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"componentDescription": "",
"propDescriptions": {
"classes": { "description": "Override or extend the styles applied to the component." },
"className": { "description": "className applied to the root 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 @@ -5,6 +5,7 @@
"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."
},
"calendars": { "description": "The number of calendars to render." },
"classes": { "description": "Override or extend the styles applied to the component." },
"components": { "description": "Overridable components." },
"componentsProps": { "description": "The props used for each component slot." },
"currentMonthCalendarPosition": { "description": "Position the current month is rendered in." },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"componentDescription": "",
"propDescriptions": {
"classes": { "description": "Override or extend the styles applied to the component." },
"className": { "description": "className applied to the root 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 @@ -8,6 +8,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
@@ -1,11 +1,15 @@
{
"componentDescription": "",
"propDescriptions": {
"classes": { "description": "Override or extend the styles applied to the component." },
"components": { "description": "Overridable components." },
"componentsProps": { "description": "The props used for each component slot." },
"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": {
"actionBar": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the action bar" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"componentDescription": "",
"propDescriptions": {
"classes": { "description": "Override or extend the styles applied to the component." },
"className": { "description": "className applied to the root 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 @@ -617,6 +617,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 @@ -131,6 +131,9 @@ export interface DateRangeCalendarProps<TDate>
*/
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 @@ -35,6 +35,9 @@ export interface DateRangePickerToolbarProps<TDate>
'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 @@ -127,6 +130,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 applied to the root component.
Expand All @@ -141,6 +147,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
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 @@ -422,6 +422,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 @@ -113,6 +113,9 @@ export interface DateCalendarProps<TDate>
*/
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
3 changes: 3 additions & 0 deletions packages/x-date-pickers/src/DateCalendar/DayCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ export interface DayCalendarProps<TDate>
hasFocus?: boolean;
onFocusedViewChange?: (newHasFocus: boolean) => void;
gridLabelId?: string;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<DayCalendarClasses>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export interface PickersFadeTransitionGroupProps {
className?: string;
reduceAnimations: boolean;
transKey: React.Key;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<PickersFadeTransitionGroupClasses>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import {

export type SlideDirection = 'right' | 'left';
export interface ExportedSlideTransitionProps {
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<PickersSlideTransitionClasses>;
}
export interface SlideTransitionProps
Expand Down
24 changes: 18 additions & 6 deletions packages/x-date-pickers/src/DatePicker/DatePickerToolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import Typography from '@mui/material/Typography';
import { styled, SxProps, Theme, useThemeProps } from '@mui/material/styles';
import { styled, useThemeProps } from '@mui/material/styles';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { PickersToolbar } from '../internals/components/PickersToolbar';
import { useLocaleText, useUtils } from '../internals/hooks/useUtils';
Expand All @@ -13,13 +14,17 @@ import {
} from './datePickerToolbarClasses';
import { resolveDateFormat } from '../internals/utils/date-utils';

export interface DatePickerToolbarProps<TDate> extends BaseToolbarProps<TDate | null, DateView> {
export interface DatePickerToolbarProps<TDate>
extends BaseToolbarProps<TDate | null, DateView>,
ExportedDatePickerToolbarProps {}

export interface ExportedDatePickerToolbarProps extends ExportedBaseToolbarProps {
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<DatePickerToolbarClasses>;
sx?: SxProps<Theme>;
}

export interface ExportedDatePickerToolbarProps extends ExportedBaseToolbarProps {}

const useUtilityClasses = (ownerState: DatePickerToolbarProps<any>) => {
const { classes } = ownerState;
const slots = {
Expand Down Expand Up @@ -72,6 +77,7 @@ export const DatePickerToolbar = React.forwardRef(function DatePickerToolbar<TDa
toolbarFormat,
toolbarPlaceholder = '––',
views,
className,
...other
} = props;
const utils = useUtils<TDate>();
Expand All @@ -95,7 +101,7 @@ export const DatePickerToolbar = React.forwardRef(function DatePickerToolbar<TDa
ref={ref}
toolbarTitle={localeText.datePickerToolbarTitle}
isLandscape={isLandscape}
className={classes.root}
className={clsx(classes.root, className)}
{...other}
>
<DatePickerToolbarTitle
Expand All @@ -116,6 +122,9 @@ DatePickerToolbar.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 applied to the root component.
Expand All @@ -136,6 +145,9 @@ DatePickerToolbar.propTypes = {
*/
onViewChange: PropTypes.func.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
Loading
Loading