@mui/x-date-pickers 7.6.2 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/DateCalendar/DateCalendar.js +3 -3
  3. package/DateCalendar/DateCalendar.types.d.ts +4 -4
  4. package/DateCalendar/DayCalendar.d.ts +3 -4
  5. package/MonthCalendar/MonthCalendar.js +17 -3
  6. package/MonthCalendar/MonthCalendar.types.d.ts +25 -0
  7. package/MonthCalendar/PickersMonth.d.ts +4 -0
  8. package/MonthCalendar/PickersMonth.js +38 -21
  9. package/MonthCalendar/index.d.ts +1 -1
  10. package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +1 -1
  11. package/YearCalendar/PickersYear.d.ts +3 -0
  12. package/YearCalendar/PickersYear.js +34 -22
  13. package/YearCalendar/YearCalendar.js +17 -3
  14. package/YearCalendar/YearCalendar.types.d.ts +25 -0
  15. package/YearCalendar/index.d.ts +1 -1
  16. package/index.js +1 -1
  17. package/locales/faIR.js +19 -22
  18. package/locales/koKR.js +2 -2
  19. package/modern/DateCalendar/DateCalendar.js +3 -3
  20. package/modern/MonthCalendar/MonthCalendar.js +17 -3
  21. package/modern/MonthCalendar/PickersMonth.js +38 -21
  22. package/modern/YearCalendar/PickersYear.js +34 -22
  23. package/modern/YearCalendar/YearCalendar.js +17 -3
  24. package/modern/index.js +1 -1
  25. package/modern/locales/faIR.js +19 -22
  26. package/modern/locales/koKR.js +2 -2
  27. package/node/DateCalendar/DateCalendar.js +3 -3
  28. package/node/MonthCalendar/MonthCalendar.js +17 -3
  29. package/node/MonthCalendar/PickersMonth.js +40 -23
  30. package/node/YearCalendar/PickersYear.js +34 -22
  31. package/node/YearCalendar/YearCalendar.js +17 -3
  32. package/node/index.js +1 -1
  33. package/node/locales/faIR.js +19 -22
  34. package/node/locales/koKR.js +2 -2
  35. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,87 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 7.7.0
7
+
8
+ _Jun 13, 2024_
9
+
10
+ We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🎁 Allow customization of the Pickers month and the year buttons
13
+ - 🌍 Improve Persian (fa-IR), Portuguese (pt-PT), and Russian (ru-RU) locales on the Data Grid
14
+ - 🌍 Improve Korean (ko-KR) and Persian (fa-IR) locales on the Date and Time Pickers
15
+ - 🐞 Bugfixes
16
+ - 📚 Documentation improvements
17
+
18
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
19
+
20
+ ### Data Grid
21
+
22
+ #### `@mui/x-data-grid@7.7.0`
23
+
24
+ - [DataGrid] Add `getFilterState` method (#13418) @cherniavskii
25
+ - [DataGrid] Do not show resize separators for column groups (#13455) @cherniavskii
26
+ - [l10n] Improve Persian (fa-IR) locale (#13402) @fakhamatia
27
+ - [l10n] Improve Portuguese (pt-PT) locale (#13384) @olavocarvalho
28
+ - [l10n] Improve Russian (ru-RU) locale (#11210) @dastan-akhmetov-scity
29
+
30
+ #### `@mui/x-data-grid-pro@7.7.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
31
+
32
+ Same changes as in `@mui/x-data-grid@7.7.0`, plus:
33
+
34
+ - [DataGridPro] Do not render detail panel if the focused cell is not visible (#13456) @cherniavskii
35
+
36
+ #### `@mui/x-data-grid-premium@7.7.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
37
+
38
+ Same changes as in `@mui/x-data-grid-pro@7.7.0`.
39
+
40
+ ### Date and Time Pickers
41
+
42
+ #### `@mui/x-date-pickers@7.7.0`
43
+
44
+ - [l10n] Improve Korean (ko-KR) locale (#13452) @ryxxn
45
+ - [l10n] Improve Persian (fa-IR) locale (#13402) @fakhamatia
46
+ - [pickers] Allow to customize the month and the year buttons (#13321) @flaviendelangle
47
+
48
+ #### `@mui/x-date-pickers-pro@7.7.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
49
+
50
+ Same changes as in `@mui/x-date-pickers@7.7.0`.
51
+
52
+ ### Charts
53
+
54
+ #### `@mui/x-charts@7.7.0`
55
+
56
+ - [charts] Add watermark on the pro `ResponsiveChartContainer` (#13398) @alexfauquette
57
+ - [charts] Allow to specify y-axis configuration (#13438) @alexfauquette
58
+ - [charts] Fix eslint for react compiler (#13444) @alexfauquette
59
+ - [charts] Improve themeAugmentation typing (#13433) @noraleonte
60
+ - [charts] Move the `ZAxisContextProvider` by default in the `ChartContainer` (#13465) @alexfauquette
61
+ - [charts] Use plugins to define series extremum and colors (#13397) @alexfauquette
62
+
63
+ ### Tree View
64
+
65
+ #### `@mui/x-tree-view@7.7.0`
66
+
67
+ - [TreeView] Improve TypeScript for plugins (#13380) @flaviendelangle
68
+ - [TreeView] Improve the typing of the cancelable events (#13152) @flaviendelangle
69
+ - [TreeView] Prepare support for PigmentCSS (#13412) @flaviendelangle
70
+ - [TreeView] Refactor the tree view internals to prepare for headless API (#13311) @flaviendelangle
71
+
72
+ ### Docs
73
+
74
+ - [docs] Add `renderHeader` recipe to the Master Details docs (#13370) @michelengelen
75
+ - [docs] Add lazy loading detail panel demo (#13453) @cherniavskii
76
+ - [docs] Add small edits to the Data Grid overview page (#13060) @danilo-leal
77
+ - [docs] Update a11y pages description (#13417) @danilo-leal
78
+ - [docs] improve the writing on the "Quick filter outside of the grid" example (#13155) @michelengelen
79
+
80
+ ### Core
81
+
82
+ - [core] Add `eslint-plugin-react-compiler` experimental version and rules (#13415) @JCQuintas
83
+ - [core] Minor setup cleanup (#13467) @LukasTy
84
+ - [infra] Adjust CI setup (#13448) @LukasTy
85
+ - [test] Add tests for the custom slots of `TreeItem2` (#13314) @flaviendelangle
86
+
6
87
  ## 7.6.2
7
88
 
8
89
  _Jun 6, 2024_
@@ -272,7 +272,9 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
272
272
  readOnly,
273
273
  disabled,
274
274
  timezone,
275
- gridLabelId
275
+ gridLabelId,
276
+ slots,
277
+ slotProps
276
278
  };
277
279
  const prevOpenViewRef = React.useRef(view);
278
280
  React.useEffect(() => {
@@ -333,8 +335,6 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
333
335
  fixedWeekNumber: fixedWeekNumber,
334
336
  dayOfWeekFormatter: dayOfWeekFormatter,
335
337
  displayWeekNumber: displayWeekNumber,
336
- slots: slots,
337
- slotProps: slotProps,
338
338
  loading: loading,
339
339
  renderLoading: renderLoading
340
340
  }))]
@@ -9,9 +9,9 @@ import { BaseDateValidationProps, YearValidationProps, MonthValidationProps, Day
9
9
  import { ExportedUseViewsOptions } from '../internals/hooks/useViews';
10
10
  import { DateView, PickerValidDate, TimezoneProps } from '../models';
11
11
  import { DefaultizedProps } from '../internals/models/helpers';
12
- import { ExportedYearCalendarProps } from '../YearCalendar/YearCalendar.types';
13
- import { ExportedMonthCalendarProps } from '../MonthCalendar/MonthCalendar.types';
14
- export interface DateCalendarSlots<TDate extends PickerValidDate> extends PickersCalendarHeaderSlots, DayCalendarSlots<TDate> {
12
+ import { ExportedYearCalendarProps, YearCalendarSlots, YearCalendarSlotProps } from '../YearCalendar/YearCalendar.types';
13
+ import { ExportedMonthCalendarProps, MonthCalendarSlots, MonthCalendarSlotProps } from '../MonthCalendar/MonthCalendar.types';
14
+ export interface DateCalendarSlots<TDate extends PickerValidDate> extends PickersCalendarHeaderSlots, DayCalendarSlots<TDate>, MonthCalendarSlots, YearCalendarSlots {
15
15
  /**
16
16
  * Custom component for calendar header.
17
17
  * Check the [PickersCalendarHeader](https://mui.com/x/api/date-pickers/pickers-calendar-header/) component.
@@ -19,7 +19,7 @@ export interface DateCalendarSlots<TDate extends PickerValidDate> extends Picker
19
19
  */
20
20
  calendarHeader?: React.ElementType<PickersCalendarHeaderProps<TDate>>;
21
21
  }
22
- export interface DateCalendarSlotProps<TDate extends PickerValidDate> extends PickersCalendarHeaderSlotProps<TDate>, DayCalendarSlotProps<TDate> {
22
+ export interface DateCalendarSlotProps<TDate extends PickerValidDate> extends PickersCalendarHeaderSlotProps<TDate>, DayCalendarSlotProps<TDate>, MonthCalendarSlotProps, YearCalendarSlotProps {
23
23
  calendarHeader?: SlotComponentProps<typeof PickersCalendarHeader, {}, DateCalendarProps<TDate>>;
24
24
  }
25
25
  export interface ExportedDateCalendarProps<TDate extends PickerValidDate> extends ExportedDayCalendarProps<TDate>, ExportedMonthCalendarProps, ExportedYearCalendarProps, BaseDateValidationProps<TDate>, DayValidationProps<TDate>, YearValidationProps<TDate>, MonthValidationProps<TDate>, TimezoneProps {
@@ -1,12 +1,11 @@
1
1
  import * as React from 'react';
2
- import { SlotComponentProps } from '@mui/base/utils';
3
- import { PickersDay, PickersDayProps, ExportedPickersDayProps } from '../PickersDay/PickersDay';
2
+ import { PickersDayProps, ExportedPickersDayProps } from '../PickersDay/PickersDay';
4
3
  import { PickerOnChangeFn } from '../internals/hooks/useViews';
5
4
  import { SlideDirection, SlideTransitionProps } from './PickersSlideTransition';
6
5
  import { BaseDateValidationProps, DayValidationProps, MonthValidationProps, YearValidationProps } from '../internals/models/validation';
7
6
  import { DayCalendarClasses } from './dayCalendarClasses';
8
7
  import { PickerValidDate, TimezoneProps } from '../models';
9
- import { DefaultizedProps } from '../internals/models/helpers';
8
+ import { DefaultizedProps, SlotComponentPropsFromProps } from '../internals/models/helpers';
10
9
  export interface DayCalendarSlots<TDate extends PickerValidDate> {
11
10
  /**
12
11
  * Custom component for day.
@@ -16,7 +15,7 @@ export interface DayCalendarSlots<TDate extends PickerValidDate> {
16
15
  day?: React.ElementType<PickersDayProps<TDate>>;
17
16
  }
18
17
  export interface DayCalendarSlotProps<TDate extends PickerValidDate> {
19
- day?: SlotComponentProps<typeof PickersDay, {}, DayCalendarProps<TDate> & {
18
+ day?: SlotComponentPropsFromProps<PickersDayProps<TDate>, {}, DayCalendarProps<TDate> & {
20
19
  day: TDate;
21
20
  selected: boolean;
22
21
  }>;
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "autoFocus", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow", "timezone", "gridLabelId"];
3
+ const _excluded = ["className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "autoFocus", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
@@ -83,7 +83,9 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
83
83
  onFocusedViewChange,
84
84
  monthsPerRow = 3,
85
85
  timezone: timezoneProp,
86
- gridLabelId
86
+ gridLabelId,
87
+ slots,
88
+ slotProps
87
89
  } = props,
88
90
  other = _objectWithoutPropertiesLoose(props, _excluded);
89
91
  const {
@@ -218,12 +220,14 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
218
220
  onKeyDown: handleKeyDown,
219
221
  autoFocus: internalHasFocus && monthNumber === focusedMonth,
220
222
  disabled: isDisabled,
221
- tabIndex: monthNumber === focusedMonth ? 0 : -1,
223
+ tabIndex: monthNumber === focusedMonth && !isDisabled ? 0 : -1,
222
224
  onFocus: handleMonthFocus,
223
225
  onBlur: handleMonthBlur,
224
226
  "aria-current": todayMonth === monthNumber ? 'date' : undefined,
225
227
  "aria-label": monthLabel,
226
228
  monthsPerRow: monthsPerRow,
229
+ slots: slots,
230
+ slotProps: slotProps,
227
231
  children: monthText
228
232
  }, monthText);
229
233
  })
@@ -303,6 +307,16 @@ process.env.NODE_ENV !== "production" ? MonthCalendar.propTypes = {
303
307
  * @returns {boolean} If `true`, the month will be disabled.
304
308
  */
305
309
  shouldDisableMonth: PropTypes.func,
310
+ /**
311
+ * The props used for each component slot.
312
+ * @default {}
313
+ */
314
+ slotProps: PropTypes.object,
315
+ /**
316
+ * Overridable component slots.
317
+ * @default {}
318
+ */
319
+ slots: PropTypes.object,
306
320
  /**
307
321
  * The system prop that allows defining system overrides as well as additional CSS styles.
308
322
  */
@@ -1,8 +1,23 @@
1
+ import * as React from 'react';
1
2
  import { SxProps } from '@mui/system';
2
3
  import { Theme } from '@mui/material/styles';
3
4
  import { MonthCalendarClasses } from './monthCalendarClasses';
4
5
  import { BaseDateValidationProps, MonthValidationProps } from '../internals/models/validation';
5
6
  import { PickerValidDate, TimezoneProps } from '../models';
7
+ import type { PickersMonthProps } from './PickersMonth';
8
+ import { SlotComponentPropsFromProps } from '../internals/models/helpers';
9
+ export interface MonthCalendarSlots {
10
+ /**
11
+ * Button displayed to render a single month in the "month" view.
12
+ * @default MonthCalendarButton
13
+ */
14
+ monthButton?: React.ElementType;
15
+ }
16
+ export interface MonthCalendarSlotProps {
17
+ monthButton?: SlotComponentPropsFromProps<React.HTMLAttributes<HTMLButtonElement> & {
18
+ sx: SxProps;
19
+ }, {}, PickersMonthProps>;
20
+ }
6
21
  export interface ExportedMonthCalendarProps {
7
22
  /**
8
23
  * Months rendered per row.
@@ -17,6 +32,16 @@ export interface MonthCalendarProps<TDate extends PickerValidDate> extends Expor
17
32
  * Override or extend the styles applied to the component.
18
33
  */
19
34
  classes?: Partial<MonthCalendarClasses>;
35
+ /**
36
+ * Overridable component slots.
37
+ * @default {}
38
+ */
39
+ slots?: MonthCalendarSlots;
40
+ /**
41
+ * The props used for each component slot.
42
+ * @default {}
43
+ */
44
+ slotProps?: MonthCalendarSlotProps;
20
45
  /**
21
46
  * The system prop that allows defining system overrides as well as additional CSS styles.
22
47
  */
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { PickersMonthClasses } from './pickersMonthClasses';
3
+ import { MonthCalendarSlotProps, MonthCalendarSlots } from './MonthCalendar.types';
3
4
  export interface ExportedPickersMonthProps {
4
5
  classes?: Partial<PickersMonthClasses>;
5
6
  }
@@ -8,6 +9,7 @@ export interface PickersMonthProps extends ExportedPickersMonthProps {
8
9
  'aria-label'?: React.AriaAttributes['aria-label'];
9
10
  autoFocus: boolean;
10
11
  children: React.ReactNode;
12
+ className?: string;
11
13
  disabled?: boolean;
12
14
  onClick: (event: React.MouseEvent, month: number) => void;
13
15
  onKeyDown: (event: React.KeyboardEvent, month: number) => void;
@@ -17,6 +19,8 @@ export interface PickersMonthProps extends ExportedPickersMonthProps {
17
19
  value: number;
18
20
  tabIndex: number;
19
21
  monthsPerRow: 3 | 4;
22
+ slots?: MonthCalendarSlots;
23
+ slotProps?: MonthCalendarSlotProps;
20
24
  }
21
25
  /**
22
26
  * @ignore - do not document.
@@ -1,9 +1,12 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["autoFocus", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "aria-label", "monthsPerRow"];
3
+ const _excluded = ["autoFocus", "className", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "aria-label", "monthsPerRow", "slots", "slotProps"];
4
4
  import * as React from 'react';
5
+ import clsx from 'clsx';
5
6
  import { styled, alpha, useThemeProps } from '@mui/material/styles';
6
- import { unstable_composeClasses as composeClasses, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
7
+ import { useSlotProps } from '@mui/base/utils';
8
+ import composeClasses from '@mui/utils/composeClasses';
9
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
7
10
  import { getPickersMonthUtilityClass, pickersMonthClasses } from './pickersMonthClasses';
8
11
  import { jsx as _jsx } from "react/jsx-runtime";
9
12
  const useUtilityClasses = ownerState => {
@@ -36,7 +39,7 @@ const PickersMonthRoot = styled('div', {
36
39
  }
37
40
  }]
38
41
  });
39
- const PickersMonthButton = styled('button', {
42
+ const MonthCalendarButton = styled('button', {
40
43
  name: 'MuiPickersMonth',
41
44
  slot: 'MonthButton',
42
45
  overridesResolver: (_, styles) => [styles.monthButton, {
@@ -89,6 +92,7 @@ export const PickersMonth = /*#__PURE__*/React.memo(function PickersMonth(inProp
89
92
  });
90
93
  const {
91
94
  autoFocus,
95
+ className,
92
96
  children,
93
97
  disabled,
94
98
  selected,
@@ -101,35 +105,48 @@ export const PickersMonth = /*#__PURE__*/React.memo(function PickersMonth(inProp
101
105
  'aria-current': ariaCurrent,
102
106
  'aria-label': ariaLabel
103
107
  // We don't want to forward this prop to the root element
108
+ ,
109
+
110
+ slots,
111
+ slotProps
104
112
  } = props,
105
113
  other = _objectWithoutPropertiesLoose(props, _excluded);
106
114
  const ref = React.useRef(null);
107
115
  const classes = useUtilityClasses(props);
116
+
117
+ // We can't forward the `autoFocus` to the button because it is a native button, not a MUI Button
108
118
  useEnhancedEffect(() => {
109
119
  if (autoFocus) {
120
+ // `ref.current` being `null` would be a bug in MUI.
110
121
  ref.current?.focus();
111
122
  }
112
123
  }, [autoFocus]);
113
- return /*#__PURE__*/_jsx(PickersMonthRoot, _extends({
114
- className: classes.root,
115
- ownerState: props
116
- }, other, {
117
- children: /*#__PURE__*/_jsx(PickersMonthButton, {
118
- ref: ref,
119
- disabled: disabled,
120
- type: "button",
121
- role: "radio",
122
- tabIndex: disabled ? -1 : tabIndex,
123
- "aria-current": ariaCurrent,
124
- "aria-checked": selected,
125
- "aria-label": ariaLabel,
124
+ const MonthButton = slots?.monthButton ?? MonthCalendarButton;
125
+ const monthButtonProps = useSlotProps({
126
+ elementType: MonthButton,
127
+ externalSlotProps: slotProps?.monthButton,
128
+ additionalProps: {
129
+ children,
130
+ disabled,
131
+ tabIndex,
132
+ ref,
133
+ type: 'button',
134
+ role: 'radio',
135
+ 'aria-current': ariaCurrent,
136
+ 'aria-checked': selected,
137
+ 'aria-label': ariaLabel,
126
138
  onClick: event => onClick(event, value),
127
139
  onKeyDown: event => onKeyDown(event, value),
128
140
  onFocus: event => onFocus(event, value),
129
- onBlur: event => onBlur(event, value),
130
- className: classes.monthButton,
131
- ownerState: props,
132
- children: children
133
- })
141
+ onBlur: event => onBlur(event, value)
142
+ },
143
+ ownerState: props,
144
+ className: classes.monthButton
145
+ });
146
+ return /*#__PURE__*/_jsx(PickersMonthRoot, _extends({
147
+ className: clsx(classes.root, className),
148
+ ownerState: props
149
+ }, other, {
150
+ children: /*#__PURE__*/_jsx(MonthButton, _extends({}, monthButtonProps))
134
151
  }));
135
152
  });
@@ -1,5 +1,5 @@
1
1
  export { MonthCalendar } from './MonthCalendar';
2
- export type { MonthCalendarProps } from './MonthCalendar.types';
2
+ export type { MonthCalendarProps, MonthCalendarSlots, MonthCalendarSlotProps, } from './MonthCalendar.types';
3
3
  export { monthCalendarClasses, getMonthCalendarUtilityClass } from './monthCalendarClasses';
4
4
  export type { MonthCalendarClasses, MonthCalendarClassKey } from './monthCalendarClasses';
5
5
  export { pickersMonthClasses } from './pickersMonthClasses';
@@ -15,7 +15,7 @@ export interface PickersCalendarHeaderSlots extends PickersArrowSwitcherSlots {
15
15
  */
16
16
  switchViewButton?: React.ElementType;
17
17
  /**
18
- * Icon displayed in the SwitchViewButton. Rotated by 180° when the open view is 'year'.
18
+ * Icon displayed in the SwitchViewButton. Rotated by 180° when the open view is "year".
19
19
  * @default ArrowDropDown
20
20
  */
21
21
  switchViewIcon?: React.ElementType;
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { PickersYearClasses } from './pickersYearClasses';
3
+ import { YearCalendarSlotProps, YearCalendarSlots } from './YearCalendar.types';
3
4
  export interface ExportedPickersYearProps {
4
5
  classes?: Partial<PickersYearClasses>;
5
6
  }
@@ -17,6 +18,8 @@ export interface PickersYearProps extends ExportedPickersYearProps {
17
18
  value: number;
18
19
  tabIndex: number;
19
20
  yearsPerRow: 3 | 4;
21
+ slots?: YearCalendarSlots;
22
+ slotProps?: YearCalendarSlotProps;
20
23
  }
21
24
  /**
22
25
  * @ignore - internal component.
@@ -1,10 +1,12 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["autoFocus", "className", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "yearsPerRow"];
3
+ const _excluded = ["autoFocus", "className", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "yearsPerRow", "slots", "slotProps"];
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
- import { unstable_composeClasses as composeClasses } from '@mui/utils';
7
- import { alpha, styled, useThemeProps } from '@mui/material/styles';
6
+ import { styled, alpha, useThemeProps } from '@mui/material/styles';
7
+ import { useSlotProps } from '@mui/base/utils';
8
+ import composeClasses from '@mui/utils/composeClasses';
9
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
8
10
  import { getPickersYearUtilityClass, pickersYearClasses } from './pickersYearClasses';
9
11
  import { jsx as _jsx } from "react/jsx-runtime";
10
12
  const useUtilityClasses = ownerState => {
@@ -37,7 +39,7 @@ const PickersYearRoot = styled('div', {
37
39
  }
38
40
  }]
39
41
  });
40
- const PickersYearButton = styled('button', {
42
+ const YearCalendarButton = styled('button', {
41
43
  name: 'MuiPickersYear',
42
44
  slot: 'YearButton',
43
45
  overridesResolver: (_, styles) => [styles.yearButton, {
@@ -102,37 +104,47 @@ export const PickersYear = /*#__PURE__*/React.memo(function PickersYear(inProps)
102
104
  onBlur,
103
105
  'aria-current': ariaCurrent
104
106
  // We don't want to forward this prop to the root element
107
+ ,
108
+
109
+ slots,
110
+ slotProps
105
111
  } = props,
106
112
  other = _objectWithoutPropertiesLoose(props, _excluded);
107
113
  const ref = React.useRef(null);
108
114
  const classes = useUtilityClasses(props);
109
115
 
110
116
  // We can't forward the `autoFocus` to the button because it is a native button, not a MUI Button
111
- React.useEffect(() => {
117
+ useEnhancedEffect(() => {
112
118
  if (autoFocus) {
113
119
  // `ref.current` being `null` would be a bug in MUI.
114
- ref.current.focus();
120
+ ref.current?.focus();
115
121
  }
116
122
  }, [autoFocus]);
123
+ const YearButton = slots?.yearButton ?? YearCalendarButton;
124
+ const yearButtonProps = useSlotProps({
125
+ elementType: YearButton,
126
+ externalSlotProps: slotProps?.yearButton,
127
+ additionalProps: {
128
+ children,
129
+ disabled,
130
+ tabIndex,
131
+ ref,
132
+ type: 'button',
133
+ role: 'radio',
134
+ 'aria-current': ariaCurrent,
135
+ 'aria-checked': selected,
136
+ onClick: event => onClick(event, value),
137
+ onKeyDown: event => onKeyDown(event, value),
138
+ onFocus: event => onFocus(event, value),
139
+ onBlur: event => onBlur(event, value)
140
+ },
141
+ ownerState: props,
142
+ className: classes.yearButton
143
+ });
117
144
  return /*#__PURE__*/_jsx(PickersYearRoot, _extends({
118
145
  className: clsx(classes.root, className),
119
146
  ownerState: props
120
147
  }, other, {
121
- children: /*#__PURE__*/_jsx(PickersYearButton, {
122
- ref: ref,
123
- disabled: disabled,
124
- type: "button",
125
- role: "radio",
126
- tabIndex: disabled ? -1 : tabIndex,
127
- "aria-current": ariaCurrent,
128
- "aria-checked": selected,
129
- onClick: event => onClick(event, value),
130
- onKeyDown: event => onKeyDown(event, value),
131
- onFocus: event => onFocus(event, value),
132
- onBlur: event => onBlur(event, value),
133
- className: classes.yearButton,
134
- ownerState: props,
135
- children: children
136
- })
148
+ children: /*#__PURE__*/_jsx(YearButton, _extends({}, yearButtonProps))
137
149
  }));
138
150
  });
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["autoFocus", "className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "readOnly", "shouldDisableYear", "disableHighlightToday", "onYearFocus", "hasFocus", "onFocusedViewChange", "yearsPerRow", "timezone", "gridLabelId"];
3
+ const _excluded = ["autoFocus", "className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "readOnly", "shouldDisableYear", "disableHighlightToday", "onYearFocus", "hasFocus", "onFocusedViewChange", "yearsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
@@ -88,7 +88,9 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
88
88
  onFocusedViewChange,
89
89
  yearsPerRow,
90
90
  timezone: timezoneProp,
91
- gridLabelId
91
+ gridLabelId,
92
+ slots,
93
+ slotProps
92
94
  } = props,
93
95
  other = _objectWithoutPropertiesLoose(props, _excluded);
94
96
  const {
@@ -244,11 +246,13 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
244
246
  onKeyDown: handleKeyDown,
245
247
  autoFocus: internalHasFocus && yearNumber === focusedYear,
246
248
  disabled: isDisabled,
247
- tabIndex: yearNumber === focusedYear ? 0 : -1,
249
+ tabIndex: yearNumber === focusedYear && !isDisabled ? 0 : -1,
248
250
  onFocus: handleYearFocus,
249
251
  onBlur: handleYearBlur,
250
252
  "aria-current": todayYear === yearNumber ? 'date' : undefined,
251
253
  yearsPerRow: yearsPerRow,
254
+ slots: slots,
255
+ slotProps: slotProps,
252
256
  children: utils.format(year, 'year')
253
257
  }, utils.format(year, 'year'));
254
258
  })
@@ -323,6 +327,16 @@ process.env.NODE_ENV !== "production" ? YearCalendar.propTypes = {
323
327
  * @returns {boolean} If `true`, the year will be disabled.
324
328
  */
325
329
  shouldDisableYear: PropTypes.func,
330
+ /**
331
+ * The props used for each component slot.
332
+ * @default {}
333
+ */
334
+ slotProps: PropTypes.object,
335
+ /**
336
+ * Overridable component slots.
337
+ * @default {}
338
+ */
339
+ slots: PropTypes.object,
326
340
  /**
327
341
  * The system prop that allows defining system overrides as well as additional CSS styles.
328
342
  */
@@ -1,8 +1,23 @@
1
+ import * as React from 'react';
1
2
  import { SxProps } from '@mui/system';
2
3
  import { Theme } from '@mui/material/styles';
3
4
  import { YearCalendarClasses } from './yearCalendarClasses';
4
5
  import { BaseDateValidationProps, YearValidationProps } from '../internals/models/validation';
5
6
  import { PickerValidDate, TimezoneProps } from '../models';
7
+ import type { PickersYearProps } from './PickersYear';
8
+ import { SlotComponentPropsFromProps } from '../internals/models/helpers';
9
+ export interface YearCalendarSlots {
10
+ /**
11
+ * Button displayed to render a single year in the "year" view.
12
+ * @default YearCalendarButton
13
+ */
14
+ yearButton?: React.ElementType;
15
+ }
16
+ export interface YearCalendarSlotProps {
17
+ yearButton?: SlotComponentPropsFromProps<React.HTMLAttributes<HTMLButtonElement> & {
18
+ sx: SxProps;
19
+ }, {}, PickersYearProps>;
20
+ }
6
21
  export interface ExportedYearCalendarProps {
7
22
  /**
8
23
  * Years rendered per row.
@@ -17,6 +32,16 @@ export interface YearCalendarProps<TDate extends PickerValidDate> extends Export
17
32
  * Override or extend the styles applied to the component.
18
33
  */
19
34
  classes?: Partial<YearCalendarClasses>;
35
+ /**
36
+ * Overridable component slots.
37
+ * @default {}
38
+ */
39
+ slots?: YearCalendarSlots;
40
+ /**
41
+ * The props used for each component slot.
42
+ * @default {}
43
+ */
44
+ slotProps?: YearCalendarSlotProps;
20
45
  /**
21
46
  * The system prop that allows defining system overrides as well as additional CSS styles.
22
47
  */
@@ -1,5 +1,5 @@
1
1
  export { YearCalendar } from './YearCalendar';
2
- export type { YearCalendarProps } from './YearCalendar.types';
2
+ export type { YearCalendarProps, YearCalendarSlots, YearCalendarSlotProps, } from './YearCalendar.types';
3
3
  export { yearCalendarClasses, getYearCalendarUtilityClass } from './yearCalendarClasses';
4
4
  export type { YearCalendarClasses, YearCalendarClassKey } from './yearCalendarClasses';
5
5
  export { pickersYearClasses } from './pickersYearClasses';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v7.6.2
2
+ * @mui/x-date-pickers v7.7.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the