@mui/x-date-pickers 7.6.2 → 7.7.1
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.
- package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts +48 -48
- package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +1 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +47 -47
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -0
- package/CHANGELOG.md +163 -0
- package/DateCalendar/DateCalendar.js +3 -3
- package/DateCalendar/DateCalendar.types.d.ts +4 -4
- package/DateCalendar/DayCalendar.d.ts +3 -4
- package/DatePicker/DatePicker.js +2 -0
- package/DateTimePicker/DateTimePicker.js +2 -0
- package/DesktopDatePicker/DesktopDatePicker.js +2 -0
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -0
- package/DesktopTimePicker/DesktopTimePicker.js +2 -0
- package/MobileDatePicker/MobileDatePicker.js +2 -0
- package/MobileDateTimePicker/MobileDateTimePicker.js +2 -0
- package/MobileTimePicker/MobileTimePicker.js +2 -0
- package/MonthCalendar/MonthCalendar.js +17 -3
- package/MonthCalendar/MonthCalendar.types.d.ts +25 -0
- package/MonthCalendar/PickersMonth.d.ts +4 -0
- package/MonthCalendar/PickersMonth.js +38 -21
- package/MonthCalendar/index.d.ts +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +16 -3
- package/PickersCalendarHeader/PickersCalendarHeader.js +4 -0
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +5 -1
- package/PickersLayout/usePickerLayout.js +0 -5
- package/StaticDatePicker/StaticDatePicker.js +2 -0
- package/StaticDateTimePicker/StaticDateTimePicker.js +2 -0
- package/StaticTimePicker/StaticTimePicker.js +2 -0
- package/TimePicker/TimePicker.js +2 -0
- package/YearCalendar/PickersYear.d.ts +3 -0
- package/YearCalendar/PickersYear.js +34 -22
- package/YearCalendar/YearCalendar.js +17 -3
- package/YearCalendar/YearCalendar.types.d.ts +25 -0
- package/YearCalendar/index.d.ts +1 -1
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +4 -2
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +1 -0
- package/internals/hooks/useField/useField.utils.js +2 -1
- package/internals/hooks/usePicker/usePickerValue.js +45 -38
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +3 -1
- package/internals/hooks/usePicker/usePickerViews.js +2 -1
- package/locales/daDK.js +15 -19
- package/locales/faIR.js +19 -22
- package/locales/koKR.js +2 -2
- package/modern/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +1 -0
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -0
- package/modern/DateCalendar/DateCalendar.js +3 -3
- package/modern/DatePicker/DatePicker.js +2 -0
- package/modern/DateTimePicker/DateTimePicker.js +2 -0
- package/modern/DesktopDatePicker/DesktopDatePicker.js +2 -0
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -0
- package/modern/DesktopTimePicker/DesktopTimePicker.js +2 -0
- package/modern/MobileDatePicker/MobileDatePicker.js +2 -0
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -0
- package/modern/MobileTimePicker/MobileTimePicker.js +2 -0
- package/modern/MonthCalendar/MonthCalendar.js +17 -3
- package/modern/MonthCalendar/PickersMonth.js +38 -21
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +16 -3
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +4 -0
- package/modern/PickersLayout/usePickerLayout.js +0 -5
- package/modern/StaticDatePicker/StaticDatePicker.js +2 -0
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +2 -0
- package/modern/StaticTimePicker/StaticTimePicker.js +2 -0
- package/modern/TimePicker/TimePicker.js +2 -0
- package/modern/YearCalendar/PickersYear.js +34 -22
- package/modern/YearCalendar/YearCalendar.js +17 -3
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +4 -2
- package/modern/internals/hooks/useField/useField.utils.js +2 -1
- package/modern/internals/hooks/usePicker/usePickerValue.js +45 -38
- package/modern/internals/hooks/usePicker/usePickerViews.js +2 -1
- package/modern/locales/daDK.js +15 -19
- package/modern/locales/faIR.js +19 -22
- package/modern/locales/koKR.js +2 -2
- package/node/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +1 -0
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -0
- package/node/DateCalendar/DateCalendar.js +3 -3
- package/node/DatePicker/DatePicker.js +2 -0
- package/node/DateTimePicker/DateTimePicker.js +2 -0
- package/node/DesktopDatePicker/DesktopDatePicker.js +2 -0
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -0
- package/node/DesktopTimePicker/DesktopTimePicker.js +2 -0
- package/node/MobileDatePicker/MobileDatePicker.js +2 -0
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +2 -0
- package/node/MobileTimePicker/MobileTimePicker.js +2 -0
- package/node/MonthCalendar/MonthCalendar.js +17 -3
- package/node/MonthCalendar/PickersMonth.js +40 -23
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +16 -3
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +4 -0
- package/node/PickersLayout/usePickerLayout.js +0 -5
- package/node/StaticDatePicker/StaticDatePicker.js +2 -0
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +2 -0
- package/node/StaticTimePicker/StaticTimePicker.js +2 -0
- package/node/TimePicker/TimePicker.js +2 -0
- package/node/YearCalendar/PickersYear.js +34 -22
- package/node/YearCalendar/YearCalendar.js +17 -3
- package/node/index.js +1 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +4 -2
- package/node/internals/hooks/useField/useField.utils.js +2 -1
- package/node/internals/hooks/usePicker/usePickerValue.js +45 -38
- package/node/internals/hooks/usePicker/usePickerViews.js +2 -1
- package/node/locales/daDK.js +15 -19
- package/node/locales/faIR.js +19 -22
- package/node/locales/koKR.js +2 -2
- package/package.json +4 -4
|
@@ -191,7 +191,9 @@ DesktopDatePicker.propTypes = {
|
|
|
191
191
|
/**
|
|
192
192
|
* Callback fired when the value is accepted.
|
|
193
193
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
194
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
194
195
|
* @param {TValue} value The value that was just accepted.
|
|
196
|
+
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
195
197
|
*/
|
|
196
198
|
onAccept: _propTypes.default.func,
|
|
197
199
|
/**
|
|
@@ -314,7 +314,9 @@ DesktopDateTimePicker.propTypes = {
|
|
|
314
314
|
/**
|
|
315
315
|
* Callback fired when the value is accepted.
|
|
316
316
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
317
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
317
318
|
* @param {TValue} value The value that was just accepted.
|
|
319
|
+
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
318
320
|
*/
|
|
319
321
|
onAccept: _propTypes.default.func,
|
|
320
322
|
/**
|
|
@@ -202,7 +202,9 @@ DesktopTimePicker.propTypes = {
|
|
|
202
202
|
/**
|
|
203
203
|
* Callback fired when the value is accepted.
|
|
204
204
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
205
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
205
206
|
* @param {TValue} value The value that was just accepted.
|
|
207
|
+
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
206
208
|
*/
|
|
207
209
|
onAccept: _propTypes.default.func,
|
|
208
210
|
/**
|
|
@@ -188,7 +188,9 @@ MobileDatePicker.propTypes = {
|
|
|
188
188
|
/**
|
|
189
189
|
* Callback fired when the value is accepted.
|
|
190
190
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
191
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
191
192
|
* @param {TValue} value The value that was just accepted.
|
|
193
|
+
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
192
194
|
*/
|
|
193
195
|
onAccept: _propTypes.default.func,
|
|
194
196
|
/**
|
|
@@ -236,7 +236,9 @@ MobileDateTimePicker.propTypes = {
|
|
|
236
236
|
/**
|
|
237
237
|
* Callback fired when the value is accepted.
|
|
238
238
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
239
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
239
240
|
* @param {TValue} value The value that was just accepted.
|
|
241
|
+
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
240
242
|
*/
|
|
241
243
|
onAccept: _propTypes.default.func,
|
|
242
244
|
/**
|
|
@@ -181,7 +181,9 @@ MobileTimePicker.propTypes = {
|
|
|
181
181
|
/**
|
|
182
182
|
* Callback fired when the value is accepted.
|
|
183
183
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
184
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
184
185
|
* @param {TValue} value The value that was just accepted.
|
|
186
|
+
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
185
187
|
*/
|
|
186
188
|
onAccept: _propTypes.default.func,
|
|
187
189
|
/**
|
|
@@ -23,7 +23,7 @@ var _getDefaultReferenceDate = require("../internals/utils/getDefaultReferenceDa
|
|
|
23
23
|
var _useValueWithTimezone = require("../internals/hooks/useValueWithTimezone");
|
|
24
24
|
var _dimensions = require("../internals/constants/dimensions");
|
|
25
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
-
const _excluded = ["className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "autoFocus", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow", "timezone", "gridLabelId"];
|
|
26
|
+
const _excluded = ["className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "autoFocus", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
|
|
27
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
28
28
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
29
29
|
const useUtilityClasses = ownerState => {
|
|
@@ -93,7 +93,9 @@ const MonthCalendar = exports.MonthCalendar = /*#__PURE__*/React.forwardRef(func
|
|
|
93
93
|
onFocusedViewChange,
|
|
94
94
|
monthsPerRow = 3,
|
|
95
95
|
timezone: timezoneProp,
|
|
96
|
-
gridLabelId
|
|
96
|
+
gridLabelId,
|
|
97
|
+
slots,
|
|
98
|
+
slotProps
|
|
97
99
|
} = props,
|
|
98
100
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
99
101
|
const {
|
|
@@ -228,12 +230,14 @@ const MonthCalendar = exports.MonthCalendar = /*#__PURE__*/React.forwardRef(func
|
|
|
228
230
|
onKeyDown: handleKeyDown,
|
|
229
231
|
autoFocus: internalHasFocus && monthNumber === focusedMonth,
|
|
230
232
|
disabled: isDisabled,
|
|
231
|
-
tabIndex: monthNumber === focusedMonth ? 0 : -1,
|
|
233
|
+
tabIndex: monthNumber === focusedMonth && !isDisabled ? 0 : -1,
|
|
232
234
|
onFocus: handleMonthFocus,
|
|
233
235
|
onBlur: handleMonthBlur,
|
|
234
236
|
"aria-current": todayMonth === monthNumber ? 'date' : undefined,
|
|
235
237
|
"aria-label": monthLabel,
|
|
236
238
|
monthsPerRow: monthsPerRow,
|
|
239
|
+
slots: slots,
|
|
240
|
+
slotProps: slotProps,
|
|
237
241
|
children: monthText
|
|
238
242
|
}, monthText);
|
|
239
243
|
})
|
|
@@ -313,6 +317,16 @@ process.env.NODE_ENV !== "production" ? MonthCalendar.propTypes = {
|
|
|
313
317
|
* @returns {boolean} If `true`, the month will be disabled.
|
|
314
318
|
*/
|
|
315
319
|
shouldDisableMonth: _propTypes.default.func,
|
|
320
|
+
/**
|
|
321
|
+
* The props used for each component slot.
|
|
322
|
+
* @default {}
|
|
323
|
+
*/
|
|
324
|
+
slotProps: _propTypes.default.object,
|
|
325
|
+
/**
|
|
326
|
+
* Overridable component slots.
|
|
327
|
+
* @default {}
|
|
328
|
+
*/
|
|
329
|
+
slots: _propTypes.default.object,
|
|
316
330
|
/**
|
|
317
331
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
318
332
|
*/
|
|
@@ -8,11 +8,14 @@ exports.PickersMonth = void 0;
|
|
|
8
8
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
11
12
|
var _styles = require("@mui/material/styles");
|
|
12
|
-
var _utils = require("@mui/utils");
|
|
13
|
+
var _utils = require("@mui/base/utils");
|
|
14
|
+
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
15
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
13
16
|
var _pickersMonthClasses = require("./pickersMonthClasses");
|
|
14
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
const _excluded = ["autoFocus", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "aria-label", "monthsPerRow"];
|
|
18
|
+
const _excluded = ["autoFocus", "className", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "aria-label", "monthsPerRow", "slots", "slotProps"];
|
|
16
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
21
|
const useUtilityClasses = ownerState => {
|
|
@@ -25,7 +28,7 @@ const useUtilityClasses = ownerState => {
|
|
|
25
28
|
root: ['root'],
|
|
26
29
|
monthButton: ['monthButton', disabled && 'disabled', selected && 'selected']
|
|
27
30
|
};
|
|
28
|
-
return (0,
|
|
31
|
+
return (0, _composeClasses.default)(slots, _pickersMonthClasses.getPickersMonthUtilityClass, classes);
|
|
29
32
|
};
|
|
30
33
|
const PickersMonthRoot = (0, _styles.styled)('div', {
|
|
31
34
|
name: 'MuiPickersMonth',
|
|
@@ -45,7 +48,7 @@ const PickersMonthRoot = (0, _styles.styled)('div', {
|
|
|
45
48
|
}
|
|
46
49
|
}]
|
|
47
50
|
});
|
|
48
|
-
const
|
|
51
|
+
const MonthCalendarButton = (0, _styles.styled)('button', {
|
|
49
52
|
name: 'MuiPickersMonth',
|
|
50
53
|
slot: 'MonthButton',
|
|
51
54
|
overridesResolver: (_, styles) => [styles.monthButton, {
|
|
@@ -98,6 +101,7 @@ const PickersMonth = exports.PickersMonth = /*#__PURE__*/React.memo(function Pic
|
|
|
98
101
|
});
|
|
99
102
|
const {
|
|
100
103
|
autoFocus,
|
|
104
|
+
className,
|
|
101
105
|
children,
|
|
102
106
|
disabled,
|
|
103
107
|
selected,
|
|
@@ -110,35 +114,48 @@ const PickersMonth = exports.PickersMonth = /*#__PURE__*/React.memo(function Pic
|
|
|
110
114
|
'aria-current': ariaCurrent,
|
|
111
115
|
'aria-label': ariaLabel
|
|
112
116
|
// We don't want to forward this prop to the root element
|
|
117
|
+
,
|
|
118
|
+
|
|
119
|
+
slots,
|
|
120
|
+
slotProps
|
|
113
121
|
} = props,
|
|
114
122
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
115
123
|
const ref = React.useRef(null);
|
|
116
124
|
const classes = useUtilityClasses(props);
|
|
117
|
-
|
|
125
|
+
|
|
126
|
+
// We can't forward the `autoFocus` to the button because it is a native button, not a MUI Button
|
|
127
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
118
128
|
if (autoFocus) {
|
|
129
|
+
// `ref.current` being `null` would be a bug in MUI.
|
|
119
130
|
ref.current?.focus();
|
|
120
131
|
}
|
|
121
132
|
}, [autoFocus]);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
disabled
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
const MonthButton = slots?.monthButton ?? MonthCalendarButton;
|
|
134
|
+
const monthButtonProps = (0, _utils.useSlotProps)({
|
|
135
|
+
elementType: MonthButton,
|
|
136
|
+
externalSlotProps: slotProps?.monthButton,
|
|
137
|
+
additionalProps: {
|
|
138
|
+
children,
|
|
139
|
+
disabled,
|
|
140
|
+
tabIndex,
|
|
141
|
+
ref,
|
|
142
|
+
type: 'button',
|
|
143
|
+
role: 'radio',
|
|
144
|
+
'aria-current': ariaCurrent,
|
|
145
|
+
'aria-checked': selected,
|
|
146
|
+
'aria-label': ariaLabel,
|
|
135
147
|
onClick: event => onClick(event, value),
|
|
136
148
|
onKeyDown: event => onKeyDown(event, value),
|
|
137
149
|
onFocus: event => onFocus(event, value),
|
|
138
|
-
onBlur: event => onBlur(event, value)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
150
|
+
onBlur: event => onBlur(event, value)
|
|
151
|
+
},
|
|
152
|
+
ownerState: props,
|
|
153
|
+
className: classes.monthButton
|
|
154
|
+
});
|
|
155
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersMonthRoot, (0, _extends2.default)({
|
|
156
|
+
className: (0, _clsx.default)(classes.root, className),
|
|
157
|
+
ownerState: props
|
|
158
|
+
}, other, {
|
|
159
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(MonthButton, (0, _extends2.default)({}, monthButtonProps))
|
|
143
160
|
}));
|
|
144
161
|
});
|
|
@@ -10,6 +10,7 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
13
14
|
var _styles = require("@mui/material/styles");
|
|
14
15
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
15
16
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
@@ -62,6 +63,7 @@ const MultiSectionDigitalClockRoot = (0, _styles.styled)(_PickerViewRoot.PickerV
|
|
|
62
63
|
*/
|
|
63
64
|
const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function MultiSectionDigitalClock(inProps, ref) {
|
|
64
65
|
const utils = (0, _useUtils.useUtils)();
|
|
66
|
+
const isRtl = (0, _RtlProvider.useRtl)();
|
|
65
67
|
const props = (0, _styles.useThemeProps)({
|
|
66
68
|
props: inProps,
|
|
67
69
|
name: 'MuiMultiSectionDigitalClock'
|
|
@@ -304,6 +306,17 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
|
|
|
304
306
|
throw new Error(`Unknown view: ${viewToBuild} found.`);
|
|
305
307
|
}
|
|
306
308
|
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, isTimeDisabled, handleMeridiemChange]);
|
|
309
|
+
const viewsToRender = React.useMemo(() => {
|
|
310
|
+
if (!isRtl) {
|
|
311
|
+
return views;
|
|
312
|
+
}
|
|
313
|
+
const digitViews = views.filter(v => v !== 'meridiem');
|
|
314
|
+
const result = digitViews.toReversed();
|
|
315
|
+
if (views.includes('meridiem')) {
|
|
316
|
+
result.push('meridiem');
|
|
317
|
+
}
|
|
318
|
+
return result;
|
|
319
|
+
}, [isRtl, views]);
|
|
307
320
|
const viewTimeOptions = React.useMemo(() => {
|
|
308
321
|
return views.reduce((result, currentView) => {
|
|
309
322
|
return (0, _extends2.default)({}, result, {
|
|
@@ -319,9 +332,9 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
|
|
|
319
332
|
ownerState: ownerState,
|
|
320
333
|
role: "group"
|
|
321
334
|
}, other, {
|
|
322
|
-
children:
|
|
323
|
-
items:
|
|
324
|
-
onChange:
|
|
335
|
+
children: viewsToRender.map(timeView => /*#__PURE__*/(0, _jsxRuntime.jsx)(_MultiSectionDigitalClockSection.MultiSectionDigitalClockSection, {
|
|
336
|
+
items: viewTimeOptions[timeView].items,
|
|
337
|
+
onChange: viewTimeOptions[timeView].onChange,
|
|
325
338
|
active: view === timeView,
|
|
326
339
|
autoFocus: autoFocus ?? focusedView === timeView,
|
|
327
340
|
disabled: disabled,
|
|
@@ -252,6 +252,10 @@ process.env.NODE_ENV !== "production" ? PickersCalendarHeader.propTypes = {
|
|
|
252
252
|
* @default `${adapter.formats.month} ${adapter.formats.year}`
|
|
253
253
|
*/
|
|
254
254
|
format: _propTypes.default.string,
|
|
255
|
+
/**
|
|
256
|
+
* Id of the calendar text element.
|
|
257
|
+
* It is used to establish an `aria-labelledby` relationship with the calendar `grid` element.
|
|
258
|
+
*/
|
|
255
259
|
labelId: _propTypes.default.string,
|
|
256
260
|
maxDate: _propTypes.default.object.isRequired,
|
|
257
261
|
minDate: _propTypes.default.object.isRequired,
|
|
@@ -62,7 +62,6 @@ const usePickerLayout = props => {
|
|
|
62
62
|
const classes = useUtilityClasses(props);
|
|
63
63
|
|
|
64
64
|
// Action bar
|
|
65
|
-
|
|
66
65
|
const ActionBar = slots?.actionBar ?? _PickersActionBar.PickersActionBar;
|
|
67
66
|
const actionBarProps = (0, _utils.useSlotProps)({
|
|
68
67
|
elementType: ActionBar,
|
|
@@ -82,7 +81,6 @@ const usePickerLayout = props => {
|
|
|
82
81
|
const actionBar = /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionBar, (0, _extends2.default)({}, actionBarProps));
|
|
83
82
|
|
|
84
83
|
// Toolbar
|
|
85
|
-
|
|
86
84
|
const Toolbar = slots?.toolbar;
|
|
87
85
|
const toolbarProps = (0, _utils.useSlotProps)({
|
|
88
86
|
elementType: Toolbar,
|
|
@@ -105,11 +103,9 @@ const usePickerLayout = props => {
|
|
|
105
103
|
const toolbar = toolbarHasView(toolbarProps) && !!Toolbar ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Toolbar, (0, _extends2.default)({}, toolbarProps)) : null;
|
|
106
104
|
|
|
107
105
|
// Content
|
|
108
|
-
|
|
109
106
|
const content = children;
|
|
110
107
|
|
|
111
108
|
// Tabs
|
|
112
|
-
|
|
113
109
|
const Tabs = slots?.tabs;
|
|
114
110
|
const tabs = view && Tabs ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs, (0, _extends2.default)({
|
|
115
111
|
view: view,
|
|
@@ -118,7 +114,6 @@ const usePickerLayout = props => {
|
|
|
118
114
|
}, slotProps?.tabs)) : null;
|
|
119
115
|
|
|
120
116
|
// Shortcuts
|
|
121
|
-
|
|
122
117
|
const Shortcuts = slots?.shortcuts ?? _PickersShortcuts.PickersShortcuts;
|
|
123
118
|
const shortcutsProps = (0, _utils.useSlotProps)({
|
|
124
119
|
elementType: Shortcuts,
|
|
@@ -142,7 +142,9 @@ StaticDatePicker.propTypes = {
|
|
|
142
142
|
/**
|
|
143
143
|
* Callback fired when the value is accepted.
|
|
144
144
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
145
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
145
146
|
* @param {TValue} value The value that was just accepted.
|
|
147
|
+
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
146
148
|
*/
|
|
147
149
|
onAccept: _propTypes.default.func,
|
|
148
150
|
/**
|
|
@@ -190,7 +190,9 @@ StaticDateTimePicker.propTypes = {
|
|
|
190
190
|
/**
|
|
191
191
|
* Callback fired when the value is accepted.
|
|
192
192
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
193
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
193
194
|
* @param {TValue} value The value that was just accepted.
|
|
195
|
+
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
194
196
|
*/
|
|
195
197
|
onAccept: _propTypes.default.func,
|
|
196
198
|
/**
|
|
@@ -134,7 +134,9 @@ StaticTimePicker.propTypes = {
|
|
|
134
134
|
/**
|
|
135
135
|
* Callback fired when the value is accepted.
|
|
136
136
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
137
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
137
138
|
* @param {TValue} value The value that was just accepted.
|
|
139
|
+
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
138
140
|
*/
|
|
139
141
|
onAccept: _propTypes.default.func,
|
|
140
142
|
/**
|
|
@@ -166,7 +166,9 @@ process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
|
|
|
166
166
|
/**
|
|
167
167
|
* Callback fired when the value is accepted.
|
|
168
168
|
* @template TValue The value type. Will be either the same type as `value` or `null`. Can be in `[start, end]` format in case of range value.
|
|
169
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
169
170
|
* @param {TValue} value The value that was just accepted.
|
|
171
|
+
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
170
172
|
*/
|
|
171
173
|
onAccept: _propTypes.default.func,
|
|
172
174
|
/**
|
|
@@ -9,11 +9,13 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
12
|
-
var _utils = require("@mui/utils");
|
|
13
12
|
var _styles = require("@mui/material/styles");
|
|
13
|
+
var _utils = require("@mui/base/utils");
|
|
14
|
+
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
15
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
14
16
|
var _pickersYearClasses = require("./pickersYearClasses");
|
|
15
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
const _excluded = ["autoFocus", "className", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "yearsPerRow"];
|
|
18
|
+
const _excluded = ["autoFocus", "className", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "yearsPerRow", "slots", "slotProps"];
|
|
17
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
21
|
const useUtilityClasses = ownerState => {
|
|
@@ -26,7 +28,7 @@ const useUtilityClasses = ownerState => {
|
|
|
26
28
|
root: ['root'],
|
|
27
29
|
yearButton: ['yearButton', disabled && 'disabled', selected && 'selected']
|
|
28
30
|
};
|
|
29
|
-
return (0,
|
|
31
|
+
return (0, _composeClasses.default)(slots, _pickersYearClasses.getPickersYearUtilityClass, classes);
|
|
30
32
|
};
|
|
31
33
|
const PickersYearRoot = (0, _styles.styled)('div', {
|
|
32
34
|
name: 'MuiPickersYear',
|
|
@@ -46,7 +48,7 @@ const PickersYearRoot = (0, _styles.styled)('div', {
|
|
|
46
48
|
}
|
|
47
49
|
}]
|
|
48
50
|
});
|
|
49
|
-
const
|
|
51
|
+
const YearCalendarButton = (0, _styles.styled)('button', {
|
|
50
52
|
name: 'MuiPickersYear',
|
|
51
53
|
slot: 'YearButton',
|
|
52
54
|
overridesResolver: (_, styles) => [styles.yearButton, {
|
|
@@ -111,37 +113,47 @@ const PickersYear = exports.PickersYear = /*#__PURE__*/React.memo(function Picke
|
|
|
111
113
|
onBlur,
|
|
112
114
|
'aria-current': ariaCurrent
|
|
113
115
|
// We don't want to forward this prop to the root element
|
|
116
|
+
,
|
|
117
|
+
|
|
118
|
+
slots,
|
|
119
|
+
slotProps
|
|
114
120
|
} = props,
|
|
115
121
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
116
122
|
const ref = React.useRef(null);
|
|
117
123
|
const classes = useUtilityClasses(props);
|
|
118
124
|
|
|
119
125
|
// We can't forward the `autoFocus` to the button because it is a native button, not a MUI Button
|
|
120
|
-
|
|
126
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
121
127
|
if (autoFocus) {
|
|
122
128
|
// `ref.current` being `null` would be a bug in MUI.
|
|
123
|
-
ref.current
|
|
129
|
+
ref.current?.focus();
|
|
124
130
|
}
|
|
125
131
|
}, [autoFocus]);
|
|
132
|
+
const YearButton = slots?.yearButton ?? YearCalendarButton;
|
|
133
|
+
const yearButtonProps = (0, _utils.useSlotProps)({
|
|
134
|
+
elementType: YearButton,
|
|
135
|
+
externalSlotProps: slotProps?.yearButton,
|
|
136
|
+
additionalProps: {
|
|
137
|
+
children,
|
|
138
|
+
disabled,
|
|
139
|
+
tabIndex,
|
|
140
|
+
ref,
|
|
141
|
+
type: 'button',
|
|
142
|
+
role: 'radio',
|
|
143
|
+
'aria-current': ariaCurrent,
|
|
144
|
+
'aria-checked': selected,
|
|
145
|
+
onClick: event => onClick(event, value),
|
|
146
|
+
onKeyDown: event => onKeyDown(event, value),
|
|
147
|
+
onFocus: event => onFocus(event, value),
|
|
148
|
+
onBlur: event => onBlur(event, value)
|
|
149
|
+
},
|
|
150
|
+
ownerState: props,
|
|
151
|
+
className: classes.yearButton
|
|
152
|
+
});
|
|
126
153
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersYearRoot, (0, _extends2.default)({
|
|
127
154
|
className: (0, _clsx.default)(classes.root, className),
|
|
128
155
|
ownerState: props
|
|
129
156
|
}, other, {
|
|
130
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
131
|
-
ref: ref,
|
|
132
|
-
disabled: disabled,
|
|
133
|
-
type: "button",
|
|
134
|
-
role: "radio",
|
|
135
|
-
tabIndex: disabled ? -1 : tabIndex,
|
|
136
|
-
"aria-current": ariaCurrent,
|
|
137
|
-
"aria-checked": selected,
|
|
138
|
-
onClick: event => onClick(event, value),
|
|
139
|
-
onKeyDown: event => onKeyDown(event, value),
|
|
140
|
-
onFocus: event => onFocus(event, value),
|
|
141
|
-
onBlur: event => onBlur(event, value),
|
|
142
|
-
className: classes.yearButton,
|
|
143
|
-
ownerState: props,
|
|
144
|
-
children: children
|
|
145
|
-
})
|
|
157
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(YearButton, (0, _extends2.default)({}, yearButtonProps))
|
|
146
158
|
}));
|
|
147
159
|
});
|
|
@@ -22,7 +22,7 @@ var _getDefaultReferenceDate = require("../internals/utils/getDefaultReferenceDa
|
|
|
22
22
|
var _useValueWithTimezone = require("../internals/hooks/useValueWithTimezone");
|
|
23
23
|
var _dimensions = require("../internals/constants/dimensions");
|
|
24
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
-
const _excluded = ["autoFocus", "className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "readOnly", "shouldDisableYear", "disableHighlightToday", "onYearFocus", "hasFocus", "onFocusedViewChange", "yearsPerRow", "timezone", "gridLabelId"];
|
|
25
|
+
const _excluded = ["autoFocus", "className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "readOnly", "shouldDisableYear", "disableHighlightToday", "onYearFocus", "hasFocus", "onFocusedViewChange", "yearsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
|
|
26
26
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
27
27
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
28
28
|
const useUtilityClasses = ownerState => {
|
|
@@ -97,7 +97,9 @@ const YearCalendar = exports.YearCalendar = /*#__PURE__*/React.forwardRef(functi
|
|
|
97
97
|
onFocusedViewChange,
|
|
98
98
|
yearsPerRow,
|
|
99
99
|
timezone: timezoneProp,
|
|
100
|
-
gridLabelId
|
|
100
|
+
gridLabelId,
|
|
101
|
+
slots,
|
|
102
|
+
slotProps
|
|
101
103
|
} = props,
|
|
102
104
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
103
105
|
const {
|
|
@@ -253,11 +255,13 @@ const YearCalendar = exports.YearCalendar = /*#__PURE__*/React.forwardRef(functi
|
|
|
253
255
|
onKeyDown: handleKeyDown,
|
|
254
256
|
autoFocus: internalHasFocus && yearNumber === focusedYear,
|
|
255
257
|
disabled: isDisabled,
|
|
256
|
-
tabIndex: yearNumber === focusedYear ? 0 : -1,
|
|
258
|
+
tabIndex: yearNumber === focusedYear && !isDisabled ? 0 : -1,
|
|
257
259
|
onFocus: handleYearFocus,
|
|
258
260
|
onBlur: handleYearBlur,
|
|
259
261
|
"aria-current": todayYear === yearNumber ? 'date' : undefined,
|
|
260
262
|
yearsPerRow: yearsPerRow,
|
|
263
|
+
slots: slots,
|
|
264
|
+
slotProps: slotProps,
|
|
261
265
|
children: utils.format(year, 'year')
|
|
262
266
|
}, utils.format(year, 'year'));
|
|
263
267
|
})
|
|
@@ -332,6 +336,16 @@ process.env.NODE_ENV !== "production" ? YearCalendar.propTypes = {
|
|
|
332
336
|
* @returns {boolean} If `true`, the year will be disabled.
|
|
333
337
|
*/
|
|
334
338
|
shouldDisableYear: _propTypes.default.func,
|
|
339
|
+
/**
|
|
340
|
+
* The props used for each component slot.
|
|
341
|
+
* @default {}
|
|
342
|
+
*/
|
|
343
|
+
slotProps: _propTypes.default.object,
|
|
344
|
+
/**
|
|
345
|
+
* Overridable component slots.
|
|
346
|
+
* @default {}
|
|
347
|
+
*/
|
|
348
|
+
slots: _propTypes.default.object,
|
|
335
349
|
/**
|
|
336
350
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
337
351
|
*/
|
package/node/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
|
18
18
|
var _icons = require("../../../icons");
|
|
19
19
|
var _pickersArrowSwitcherClasses = require("./pickersArrowSwitcherClasses");
|
|
20
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
const _excluded = ["children", "className", "slots", "slotProps", "isNextDisabled", "isNextHidden", "onGoToNext", "nextLabel", "isPreviousDisabled", "isPreviousHidden", "onGoToPrevious", "previousLabel"],
|
|
21
|
+
const _excluded = ["children", "className", "slots", "slotProps", "isNextDisabled", "isNextHidden", "onGoToNext", "nextLabel", "isPreviousDisabled", "isPreviousHidden", "onGoToPrevious", "previousLabel", "labelId"],
|
|
22
22
|
_excluded2 = ["ownerState"],
|
|
23
23
|
_excluded3 = ["ownerState"];
|
|
24
24
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -82,7 +82,8 @@ const PickersArrowSwitcher = exports.PickersArrowSwitcher = /*#__PURE__*/React.f
|
|
|
82
82
|
isPreviousDisabled,
|
|
83
83
|
isPreviousHidden,
|
|
84
84
|
onGoToPrevious,
|
|
85
|
-
previousLabel
|
|
85
|
+
previousLabel,
|
|
86
|
+
labelId
|
|
86
87
|
} = props,
|
|
87
88
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
88
89
|
const ownerState = props;
|
|
@@ -165,6 +166,7 @@ const PickersArrowSwitcher = exports.PickersArrowSwitcher = /*#__PURE__*/React.f
|
|
|
165
166
|
})), children ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
166
167
|
variant: "subtitle1",
|
|
167
168
|
component: "span",
|
|
169
|
+
id: labelId,
|
|
168
170
|
children: children
|
|
169
171
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersArrowSwitcherSpacer, {
|
|
170
172
|
className: classes.spacer,
|
|
@@ -115,7 +115,8 @@ const applyLocalizedDigits = (valueStr, localizedDigits) => {
|
|
|
115
115
|
exports.applyLocalizedDigits = applyLocalizedDigits;
|
|
116
116
|
const isStringNumber = (valueStr, localizedDigits) => {
|
|
117
117
|
const nonLocalizedValueStr = removeLocalizedDigits(valueStr, localizedDigits);
|
|
118
|
-
|
|
118
|
+
// `Number(' ')` returns `0` even if ' ' is not a valid number.
|
|
119
|
+
return nonLocalizedValueStr !== ' ' && !Number.isNaN(Number(nonLocalizedValueStr));
|
|
119
120
|
};
|
|
120
121
|
|
|
121
122
|
/**
|