@mui/x-date-pickers 8.0.0-alpha.6 → 8.0.0-alpha.7
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/AdapterDateFns/AdapterDateFns.d.ts +2 -4
- package/AdapterDateFns/AdapterDateFns.js +49 -47
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +1 -1
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +2 -4
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +48 -46
- package/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.d.ts} +2 -2
- package/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +45 -52
- package/AdapterDateFnsJalaliV2/index.d.ts +1 -0
- package/AdapterDateFnsJalaliV2/index.js +1 -0
- package/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/package.json +1 -1
- package/{AdapterDateFnsV3/AdapterDateFnsV3.d.ts → AdapterDateFnsV2/AdapterDateFnsV2.d.ts} +2 -2
- package/{AdapterDateFnsV3/AdapterDateFnsV3.js → AdapterDateFnsV2/AdapterDateFnsV2.js} +46 -54
- package/AdapterDateFnsV2/index.d.ts +1 -0
- package/AdapterDateFnsV2/index.js +1 -0
- package/{AdapterDateFnsV3 → AdapterDateFnsV2}/package.json +1 -1
- package/AdapterDayjs/AdapterDayjs.d.ts +1 -1
- package/AdapterLuxon/AdapterLuxon.d.ts +1 -1
- package/AdapterMoment/AdapterMoment.d.ts +1 -1
- package/CHANGELOG.md +127 -1
- package/DateCalendar/DateCalendar.js +1 -1
- package/DateCalendar/PickersFadeTransitionGroup.d.ts +1 -1
- package/DateCalendar/PickersSlideTransition.d.ts +1 -1
- package/DateField/useDateField.d.ts +1 -1
- package/DateField/useDateField.js +13 -11
- package/DatePicker/DatePicker.js +1 -1
- package/DatePicker/DatePicker.types.d.ts +5 -0
- package/DatePicker/DatePickerToolbar.d.ts +1 -2
- package/DatePicker/DatePickerToolbar.js +7 -11
- package/DatePicker/shared.d.ts +1 -1
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimeField/useDateTimeField.js +13 -11
- package/DateTimePicker/DateTimePicker.js +2 -2
- package/DateTimePicker/DateTimePickerTabs.js +2 -2
- package/DateTimePicker/DateTimePickerToolbar.d.ts +6 -2
- package/DateTimePicker/DateTimePickerToolbar.js +36 -31
- package/DateTimePicker/shared.d.ts +1 -1
- package/DesktopDatePicker/DesktopDatePicker.js +9 -3
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +5 -0
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -10
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -5
- package/DesktopTimePicker/DesktopTimePicker.js +3 -7
- package/MobileDatePicker/MobileDatePicker.js +2 -2
- package/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/MobileTimePicker/MobileTimePicker.js +2 -2
- package/PickersActionBar/PickersActionBar.d.ts +6 -3
- package/PickersActionBar/PickersActionBar.js +6 -3
- package/PickersLayout/PickersLayout.js +1 -5
- package/PickersLayout/PickersLayout.types.d.ts +2 -3
- package/PickersLayout/usePickerLayout.js +12 -31
- package/PickersShortcuts/PickersShortcuts.d.ts +2 -5
- package/PickersShortcuts/PickersShortcuts.js +13 -10
- package/PickersShortcuts/index.d.ts +1 -1
- package/PickersTextField/PickersInputBase/PickersInputBase.js +7 -0
- package/PickersTextField/PickersTextField.js +1 -1
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimeField/useTimeField.js +13 -11
- package/TimePicker/TimePicker.js +2 -2
- package/TimePicker/TimePickerToolbar.d.ts +1 -2
- package/TimePicker/TimePickerToolbar.js +20 -18
- package/TimePicker/shared.d.ts +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/useIsValidValue.d.ts +7 -0
- package/hooks/useIsValidValue.js +11 -0
- package/hooks/usePickerActionsContext.d.ts +3 -1
- package/hooks/usePickerActionsContext.js +0 -1
- package/hooks/usePickerContext.d.ts +2 -2
- package/hooks/usePickerContext.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +3 -2
- package/internals/components/PickerProvider.d.ts +11 -10
- package/internals/components/PickerProvider.js +8 -3
- package/internals/components/PickersToolbar.d.ts +2 -3
- package/internals/components/PickersToolbar.js +1 -1
- package/internals/hooks/date-helpers-hooks.js +4 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
- package/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/internals/hooks/useField/index.d.ts +1 -1
- package/internals/hooks/useField/index.js +1 -1
- package/internals/hooks/useField/useField.d.ts +10 -1
- package/internals/hooks/useField/useField.js +17 -1
- package/internals/hooks/useField/useField.utils.js +2 -2
- package/internals/hooks/useField/useFieldState.js +2 -2
- package/internals/hooks/useField/useFieldV6TextField.js +2 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
- package/internals/hooks/useOpenState.js +3 -2
- package/internals/hooks/usePicker/usePicker.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.js +0 -6
- package/internals/hooks/usePicker/usePicker.types.d.ts +5 -6
- package/internals/hooks/usePicker/usePickerProvider.d.ts +5 -5
- package/internals/hooks/usePicker/usePickerProvider.js +4 -2
- package/internals/hooks/usePicker/usePickerValue.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +67 -184
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +48 -54
- package/internals/hooks/usePicker/usePickerViews.d.ts +27 -23
- package/internals/hooks/usePicker/usePickerViews.js +17 -11
- package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +2 -2
- package/internals/hooks/useUtils.js +1 -1
- package/internals/index.d.ts +5 -3
- package/internals/index.js +5 -3
- package/internals/models/index.d.ts +1 -0
- package/internals/models/index.js +2 -1
- package/internals/models/manager.d.ts +12 -0
- package/internals/models/manager.js +1 -0
- package/internals/models/props/basePickerProps.d.ts +2 -2
- package/internals/models/props/toolbar.d.ts +1 -5
- package/internals/utils/date-utils.js +1 -1
- package/internals/utils/valueManagers.js +4 -4
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/nbNO.js +15 -19
- package/locales/utils/getPickersLocalization.js +1 -1
- package/locales/zhTW.d.ts +80 -0
- package/locales/zhTW.js +73 -0
- package/managers/index.d.ts +6 -0
- package/managers/index.js +3 -0
- package/managers/package.json +6 -0
- package/managers/useDateManager.d.ts +27 -0
- package/managers/useDateManager.js +47 -0
- package/managers/useDateTimeManager.d.ts +28 -0
- package/managers/useDateTimeManager.js +52 -0
- package/managers/useTimeManager.d.ts +28 -0
- package/managers/useTimeManager.js +43 -0
- package/models/adapters.d.ts +1 -1
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/manager.d.ts +78 -0
- package/models/manager.js +1 -0
- package/models/pickers.d.ts +7 -0
- package/modern/AdapterDateFns/AdapterDateFns.js +49 -47
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +48 -46
- package/modern/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +45 -52
- package/modern/AdapterDateFnsJalaliV2/index.js +1 -0
- package/modern/{AdapterDateFnsV3/AdapterDateFnsV3.js → AdapterDateFnsV2/AdapterDateFnsV2.js} +46 -54
- package/modern/AdapterDateFnsV2/index.js +1 -0
- package/modern/DateCalendar/DateCalendar.js +1 -1
- package/modern/DateField/useDateField.js +13 -11
- package/modern/DatePicker/DatePicker.js +1 -1
- package/modern/DatePicker/DatePickerToolbar.js +7 -11
- package/modern/DateTimeField/useDateTimeField.js +13 -11
- package/modern/DateTimePicker/DateTimePicker.js +2 -2
- package/modern/DateTimePicker/DateTimePickerTabs.js +2 -2
- package/modern/DateTimePicker/DateTimePickerToolbar.js +36 -31
- package/modern/DesktopDatePicker/DesktopDatePicker.js +9 -3
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -10
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -5
- package/modern/DesktopTimePicker/DesktopTimePicker.js +3 -7
- package/modern/MobileDatePicker/MobileDatePicker.js +2 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/modern/MobileTimePicker/MobileTimePicker.js +2 -2
- package/modern/PickersActionBar/PickersActionBar.js +6 -3
- package/modern/PickersLayout/PickersLayout.js +1 -5
- package/modern/PickersLayout/usePickerLayout.js +12 -31
- package/modern/PickersShortcuts/PickersShortcuts.js +13 -10
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +7 -0
- package/modern/PickersTextField/PickersTextField.js +1 -1
- package/modern/TimeField/useTimeField.js +13 -11
- package/modern/TimePicker/TimePicker.js +2 -2
- package/modern/TimePicker/TimePickerToolbar.js +20 -18
- package/modern/hooks/index.js +2 -1
- package/modern/hooks/useIsValidValue.js +11 -0
- package/modern/hooks/usePickerActionsContext.js +0 -1
- package/modern/hooks/usePickerContext.js +1 -1
- package/modern/index.js +3 -2
- package/modern/internals/components/PickerProvider.js +8 -3
- package/modern/internals/components/PickersToolbar.js +1 -1
- package/modern/internals/hooks/date-helpers-hooks.js +4 -3
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/modern/internals/hooks/useField/index.js +1 -1
- package/modern/internals/hooks/useField/useField.js +17 -1
- package/modern/internals/hooks/useField/useField.utils.js +2 -2
- package/modern/internals/hooks/useField/useFieldState.js +2 -2
- package/modern/internals/hooks/useField/useFieldV6TextField.js +2 -2
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
- package/modern/internals/hooks/useOpenState.js +3 -2
- package/modern/internals/hooks/usePicker/usePicker.js +0 -6
- package/modern/internals/hooks/usePicker/usePickerProvider.js +4 -2
- package/modern/internals/hooks/usePicker/usePickerValue.js +67 -184
- package/modern/internals/hooks/usePicker/usePickerViews.js +17 -11
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
- package/modern/internals/hooks/useUtils.js +1 -1
- package/modern/internals/index.js +5 -3
- package/modern/internals/models/index.js +2 -1
- package/modern/internals/models/manager.js +1 -0
- package/modern/internals/utils/date-utils.js +1 -1
- package/modern/internals/utils/valueManagers.js +4 -4
- package/modern/locales/index.js +1 -0
- package/modern/locales/nbNO.js +15 -19
- package/modern/locales/utils/getPickersLocalization.js +1 -1
- package/modern/locales/zhTW.js +73 -0
- package/modern/managers/index.js +3 -0
- package/modern/managers/useDateManager.js +47 -0
- package/modern/managers/useDateTimeManager.js +52 -0
- package/modern/managers/useTimeManager.js +43 -0
- package/modern/models/index.js +1 -0
- package/modern/models/manager.js +1 -0
- package/node/AdapterDateFns/AdapterDateFns.js +97 -97
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +97 -96
- package/node/{AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js → AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js} +94 -101
- package/node/{AdapterDateFnsJalaliV3 → AdapterDateFnsJalaliV2}/index.js +1 -1
- package/node/AdapterDateFnsV2/AdapterDateFnsV2.js +291 -0
- package/node/{AdapterDateFnsV3 → AdapterDateFnsV2}/index.js +1 -1
- package/node/DateCalendar/DateCalendar.js +1 -1
- package/node/DateField/useDateField.js +12 -10
- package/node/DatePicker/DatePicker.js +1 -1
- package/node/DatePicker/DatePickerToolbar.js +7 -11
- package/node/DateTimeField/useDateTimeField.js +12 -10
- package/node/DateTimePicker/DateTimePicker.js +2 -2
- package/node/DateTimePicker/DateTimePickerTabs.js +2 -2
- package/node/DateTimePicker/DateTimePickerToolbar.js +36 -31
- package/node/DesktopDatePicker/DesktopDatePicker.js +9 -3
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +13 -10
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -5
- package/node/DesktopTimePicker/DesktopTimePicker.js +3 -7
- package/node/MobileDatePicker/MobileDatePicker.js +2 -2
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/node/MobileTimePicker/MobileTimePicker.js +2 -2
- package/node/PickersActionBar/PickersActionBar.js +8 -5
- package/node/PickersLayout/PickersLayout.js +1 -5
- package/node/PickersLayout/usePickerLayout.js +16 -35
- package/node/PickersShortcuts/PickersShortcuts.js +13 -10
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +7 -0
- package/node/PickersTextField/PickersTextField.js +1 -1
- package/node/TimeField/useTimeField.js +12 -10
- package/node/TimePicker/TimePicker.js +2 -2
- package/node/TimePicker/TimePickerToolbar.js +20 -18
- package/node/hooks/index.js +8 -1
- package/node/hooks/useIsValidValue.js +18 -0
- package/node/hooks/usePickerContext.js +1 -1
- package/node/index.js +13 -1
- package/node/internals/components/PickerProvider.js +8 -3
- package/node/internals/components/PickersToolbar.js +1 -1
- package/node/internals/hooks/date-helpers-hooks.js +4 -3
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +1 -1
- package/node/internals/hooks/useField/index.js +6 -0
- package/node/internals/hooks/useField/useField.js +18 -1
- package/node/internals/hooks/useField/useField.utils.js +2 -2
- package/node/internals/hooks/useField/useFieldState.js +2 -2
- package/node/internals/hooks/useField/useFieldV6TextField.js +2 -2
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
- package/node/internals/hooks/useOpenState.js +4 -2
- package/node/internals/hooks/usePicker/usePicker.js +0 -7
- package/node/internals/hooks/usePicker/usePickerProvider.js +4 -2
- package/node/internals/hooks/usePicker/usePickerValue.js +67 -184
- package/node/internals/hooks/usePicker/usePickerViews.js +17 -12
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -4
- package/node/internals/hooks/useUtils.js +1 -1
- package/node/internals/index.js +26 -18
- package/node/internals/models/index.js +11 -0
- package/node/internals/models/manager.js +5 -0
- package/node/internals/utils/date-utils.js +1 -1
- package/node/internals/utils/valueManagers.js +4 -4
- package/node/locales/index.js +11 -0
- package/node/locales/nbNO.js +15 -19
- package/node/locales/utils/getPickersLocalization.js +1 -1
- package/node/locales/zhTW.js +79 -0
- package/node/managers/index.js +26 -0
- package/node/managers/useDateManager.js +55 -0
- package/node/managers/useDateTimeManager.js +60 -0
- package/node/managers/useTimeManager.js +51 -0
- package/node/models/index.js +11 -0
- package/node/models/manager.js +5 -0
- package/package.json +3 -3
- package/themeAugmentation/props.d.ts +1 -1
- package/validation/extractValidationProps.d.ts +1 -1
- package/AdapterDateFnsJalaliV3/index.d.ts +0 -1
- package/AdapterDateFnsJalaliV3/index.js +0 -1
- package/AdapterDateFnsV3/index.d.ts +0 -1
- package/AdapterDateFnsV3/index.js +0 -1
- package/internals/hooks/defaultizedFieldProps.d.ts +0 -18
- package/internals/hooks/defaultizedFieldProps.js +0 -40
- package/modern/AdapterDateFnsJalaliV3/index.js +0 -1
- package/modern/AdapterDateFnsV3/index.js +0 -1
- package/modern/internals/hooks/defaultizedFieldProps.js +0 -40
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -299
- package/node/internals/hooks/defaultizedFieldProps.js +0 -50
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["ampm", "ampmInClock", "
|
|
5
|
+
const _excluded = ["ampm", "ampmInClock", "className", "classes"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
@@ -122,9 +122,6 @@ function TimePickerToolbar(inProps) {
|
|
|
122
122
|
const {
|
|
123
123
|
ampm,
|
|
124
124
|
ampmInClock,
|
|
125
|
-
value,
|
|
126
|
-
isLandscape,
|
|
127
|
-
onChange,
|
|
128
125
|
className,
|
|
129
126
|
classes: classesProp
|
|
130
127
|
} = props,
|
|
@@ -134,18 +131,27 @@ function TimePickerToolbar(inProps) {
|
|
|
134
131
|
const ownerState = useToolbarOwnerState();
|
|
135
132
|
const classes = useUtilityClasses(classesProp, ownerState);
|
|
136
133
|
const {
|
|
134
|
+
value,
|
|
135
|
+
setValue,
|
|
137
136
|
disabled,
|
|
138
137
|
readOnly,
|
|
139
138
|
view,
|
|
140
|
-
|
|
139
|
+
setView,
|
|
141
140
|
views
|
|
142
141
|
} = usePickerContext();
|
|
143
142
|
const showAmPmControl = Boolean(ampm && !ampmInClock && views.includes('hours'));
|
|
144
143
|
const {
|
|
145
144
|
meridiemMode,
|
|
146
145
|
handleMeridiemChange
|
|
147
|
-
} = useMeridiemMode(value, ampm,
|
|
148
|
-
|
|
146
|
+
} = useMeridiemMode(value, ampm, newValue => setValue(newValue, {
|
|
147
|
+
changeImportance: 'set'
|
|
148
|
+
}));
|
|
149
|
+
const formatSection = format => {
|
|
150
|
+
if (!utils.isValid(value)) {
|
|
151
|
+
return '--';
|
|
152
|
+
}
|
|
153
|
+
return utils.format(value, format);
|
|
154
|
+
};
|
|
149
155
|
const separator = /*#__PURE__*/_jsx(TimePickerToolbarSeparator, {
|
|
150
156
|
tabIndex: -1,
|
|
151
157
|
value: ":",
|
|
@@ -156,7 +162,6 @@ function TimePickerToolbar(inProps) {
|
|
|
156
162
|
return /*#__PURE__*/_jsxs(TimePickerToolbarRoot, _extends({
|
|
157
163
|
landscapeDirection: "row",
|
|
158
164
|
toolbarTitle: translations.timePickerToolbarTitle,
|
|
159
|
-
isLandscape: isLandscape,
|
|
160
165
|
ownerState: ownerState,
|
|
161
166
|
className: clsx(classes.root, className)
|
|
162
167
|
}, other, {
|
|
@@ -166,20 +171,20 @@ function TimePickerToolbar(inProps) {
|
|
|
166
171
|
children: [arrayIncludes(views, 'hours') && /*#__PURE__*/_jsx(PickersToolbarButton, {
|
|
167
172
|
tabIndex: -1,
|
|
168
173
|
variant: "h3",
|
|
169
|
-
onClick: () =>
|
|
174
|
+
onClick: () => setView('hours'),
|
|
170
175
|
selected: view === 'hours',
|
|
171
|
-
value:
|
|
176
|
+
value: formatSection(ampm ? 'hours12h' : 'hours24h')
|
|
172
177
|
}), arrayIncludes(views, ['hours', 'minutes']) && separator, arrayIncludes(views, 'minutes') && /*#__PURE__*/_jsx(PickersToolbarButton, {
|
|
173
178
|
tabIndex: -1,
|
|
174
179
|
variant: "h3",
|
|
175
|
-
onClick: () =>
|
|
180
|
+
onClick: () => setView('minutes'),
|
|
176
181
|
selected: view === 'minutes',
|
|
177
|
-
value:
|
|
182
|
+
value: formatSection('minutes')
|
|
178
183
|
}), arrayIncludes(views, ['minutes', 'seconds']) && separator, arrayIncludes(views, 'seconds') && /*#__PURE__*/_jsx(PickersToolbarButton, {
|
|
179
184
|
variant: "h3",
|
|
180
|
-
onClick: () =>
|
|
185
|
+
onClick: () => setView('seconds'),
|
|
181
186
|
selected: view === 'seconds',
|
|
182
|
-
value:
|
|
187
|
+
value: formatSection('seconds')
|
|
183
188
|
})]
|
|
184
189
|
}), showAmPmControl && /*#__PURE__*/_jsxs(TimePickerToolbarAmPmSelection, {
|
|
185
190
|
className: classes.ampmSelection,
|
|
@@ -221,8 +226,6 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
|
|
|
221
226
|
* @default `true` for Desktop, `false` for Mobile.
|
|
222
227
|
*/
|
|
223
228
|
hidden: PropTypes.bool,
|
|
224
|
-
isLandscape: PropTypes.bool.isRequired,
|
|
225
|
-
onChange: PropTypes.func.isRequired,
|
|
226
229
|
/**
|
|
227
230
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
228
231
|
*/
|
|
@@ -236,7 +239,6 @@ process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
|
|
|
236
239
|
* Toolbar value placeholder—it is displayed when the value is empty.
|
|
237
240
|
* @default "––"
|
|
238
241
|
*/
|
|
239
|
-
toolbarPlaceholder: PropTypes.node
|
|
240
|
-
value: PropTypes.object
|
|
242
|
+
toolbarPlaceholder: PropTypes.node
|
|
241
243
|
} : void 0;
|
|
242
244
|
export { TimePickerToolbar };
|
package/TimePicker/shared.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface BaseTimePickerSlots extends TimeClockSlots {
|
|
|
20
20
|
export interface BaseTimePickerSlotProps extends TimeClockSlotProps {
|
|
21
21
|
toolbar?: ExportedTimePickerToolbarProps;
|
|
22
22
|
}
|
|
23
|
-
export type TimePickerViewRenderers<TView extends TimeViewWithMeridiem
|
|
23
|
+
export type TimePickerViewRenderers<TView extends TimeViewWithMeridiem> = PickerViewRendererLookup<PickerValue, TView, TimeViewRendererProps<TView, BaseClockProps<TView>>>;
|
|
24
24
|
export interface BaseTimePickerProps<TView extends TimeViewWithMeridiem> extends BasePickerInputProps<PickerValue, TView, TimeValidationError>, ExportedBaseClockProps {
|
|
25
25
|
/**
|
|
26
26
|
* Display ampm controls under the clock (instead of in the toolbar).
|
package/hooks/index.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export { useSplitFieldProps } from './useSplitFieldProps';
|
|
|
5
5
|
export { useParsedFormat } from './useParsedFormat';
|
|
6
6
|
export { usePickerContext } from './usePickerContext';
|
|
7
7
|
export { usePickerActionsContext } from './usePickerActionsContext';
|
|
8
|
+
export { useIsValidValue } from './useIsValidValue';
|
package/hooks/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { usePickerTranslations } from "./usePickerTranslations.js";
|
|
|
3
3
|
export { useSplitFieldProps } from "./useSplitFieldProps.js";
|
|
4
4
|
export { useParsedFormat } from "./useParsedFormat.js";
|
|
5
5
|
export { usePickerContext } from "./usePickerContext.js";
|
|
6
|
-
export { usePickerActionsContext } from "./usePickerActionsContext.js";
|
|
6
|
+
export { usePickerActionsContext } from "./usePickerActionsContext.js";
|
|
7
|
+
export { useIsValidValue } from "./useIsValidValue.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PickerValidValue } from '../internals/models';
|
|
3
|
+
export declare const IsValidValueContext: React.Context<(value: any) => boolean>;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a function to check if a value is valid according to the validation props passed to the parent picker.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useIsValidValue<TValue extends PickerValidValue>(): (value: TValue) => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export const IsValidValueContext = /*#__PURE__*/React.createContext(() => true);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns a function to check if a value is valid according to the validation props passed to the parent picker.
|
|
8
|
+
*/
|
|
9
|
+
export function useIsValidValue() {
|
|
10
|
+
return React.useContext(IsValidValueContext);
|
|
11
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { PickerActionsContextValue } from '../internals/components/PickerProvider';
|
|
2
|
+
import { DateOrTimeViewWithMeridiem, PickerValidValue, PickerValue } from '../internals/models';
|
|
1
3
|
/**
|
|
2
4
|
* Returns a subset of the context passed by the picker wrapping the current component.
|
|
3
5
|
* It only contains the actions and never causes a re-render of the component using it.
|
|
4
6
|
*/
|
|
5
|
-
export declare const usePickerActionsContext: () =>
|
|
7
|
+
export declare const usePickerActionsContext: <TValue extends PickerValidValue = PickerValue, TView extends DateOrTimeViewWithMeridiem = DateOrTimeViewWithMeridiem, TError = string>() => PickerActionsContextValue<TValue, TView, TError>;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { PickerActionsContext } from "../internals/components/PickerProvider.js";
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Returns a subset of the context passed by the picker wrapping the current component.
|
|
8
7
|
* It only contains the actions and never causes a re-render of the component using it.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PickerContextValue } from '../internals/components/PickerProvider';
|
|
2
|
-
import { DateOrTimeViewWithMeridiem } from '../internals/models';
|
|
2
|
+
import { DateOrTimeViewWithMeridiem, PickerValidValue, PickerValue } from '../internals/models';
|
|
3
3
|
/**
|
|
4
4
|
* Returns the context passed by the picker that wraps the current component.
|
|
5
5
|
*/
|
|
6
|
-
export declare const usePickerContext: <TView extends DateOrTimeViewWithMeridiem = DateOrTimeViewWithMeridiem>() => PickerContextValue<TView>;
|
|
6
|
+
export declare const usePickerContext: <TValue extends PickerValidValue = PickerValue, TView extends DateOrTimeViewWithMeridiem = DateOrTimeViewWithMeridiem, TError = string>() => PickerContextValue<TValue, TView, TError>;
|
|
@@ -8,7 +8,7 @@ import { PickerContext } from "../internals/components/PickerProvider.js";
|
|
|
8
8
|
export const usePickerContext = () => {
|
|
9
9
|
const value = React.useContext(PickerContext);
|
|
10
10
|
if (value == null) {
|
|
11
|
-
throw new Error(
|
|
11
|
+
throw new Error('MUI X: The `usePickerContext` hook can only be called inside the context of a picker component');
|
|
12
12
|
}
|
|
13
13
|
return value;
|
|
14
14
|
};
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-date-pickers v8.0.0-alpha.
|
|
2
|
+
* @mui/x-date-pickers v8.0.0-alpha.7
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -57,4 +57,5 @@ export { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from "./internals/utils/utils.js";
|
|
|
57
57
|
export * from "./models/index.js";
|
|
58
58
|
export * from "./icons/index.js";
|
|
59
59
|
export * from "./hooks/index.js";
|
|
60
|
-
export * from "./validation/index.js";
|
|
60
|
+
export * from "./validation/index.js";
|
|
61
|
+
export * from "./managers/index.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PickerOwnerState } from '../../models';
|
|
3
3
|
import { PickersInputLocaleText } from '../../locales';
|
|
4
|
-
import { DateOrTimeViewWithMeridiem, PickerOrientation, PickerVariant } from '../models';
|
|
4
|
+
import { DateOrTimeViewWithMeridiem, PickerOrientation, PickerValidValue, PickerVariant } from '../models';
|
|
5
5
|
import type { UsePickerValueActionsContextValue, UsePickerValueContextValue, UsePickerValuePrivateContextValue } from '../hooks/usePicker/usePickerValue.types';
|
|
6
|
-
import { UsePickerViewsContextValue } from '../hooks/usePicker/usePickerViews';
|
|
7
|
-
export declare const PickerContext: React.Context<PickerContextValue<any> | null>;
|
|
8
|
-
export declare const PickerActionsContext: React.Context<PickerActionsContextValue | null>;
|
|
6
|
+
import { UsePickerViewsActionsContextValue, UsePickerViewsContextValue } from '../hooks/usePicker/usePickerViews';
|
|
7
|
+
export declare const PickerContext: React.Context<PickerContextValue<any, any, any> | null>;
|
|
8
|
+
export declare const PickerActionsContext: React.Context<PickerActionsContextValue<any, any, any> | null>;
|
|
9
9
|
export declare const PickerPrivateContext: React.Context<PickerPrivateContextValue>;
|
|
10
10
|
/**
|
|
11
11
|
* Provides the context for the various parts of a picker component:
|
|
@@ -14,15 +14,16 @@ export declare const PickerPrivateContext: React.Context<PickerPrivateContextVal
|
|
|
14
14
|
*
|
|
15
15
|
* @ignore - do not document.
|
|
16
16
|
*/
|
|
17
|
-
export declare function PickerProvider(props: PickerProviderProps): React.JSX.Element;
|
|
18
|
-
export interface PickerProviderProps {
|
|
19
|
-
contextValue: PickerContextValue<any>;
|
|
20
|
-
actionsContextValue: PickerActionsContextValue
|
|
17
|
+
export declare function PickerProvider<TValue extends PickerValidValue>(props: PickerProviderProps<TValue>): React.JSX.Element;
|
|
18
|
+
export interface PickerProviderProps<TValue extends PickerValidValue> {
|
|
19
|
+
contextValue: PickerContextValue<any, any, any>;
|
|
20
|
+
actionsContextValue: PickerActionsContextValue<any, any, any>;
|
|
21
21
|
privateContextValue: PickerPrivateContextValue;
|
|
22
|
+
isValidContextValue: (value: TValue) => boolean;
|
|
22
23
|
localeText: PickersInputLocaleText | undefined;
|
|
23
24
|
children: React.ReactNode;
|
|
24
25
|
}
|
|
25
|
-
export interface PickerContextValue<TView extends DateOrTimeViewWithMeridiem
|
|
26
|
+
export interface PickerContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends UsePickerValueContextValue<TValue, TError>, UsePickerViewsContextValue<TView> {
|
|
26
27
|
/**
|
|
27
28
|
* `true` if the picker is disabled, `false` otherwise.
|
|
28
29
|
*/
|
|
@@ -49,7 +50,7 @@ export interface PickerContextValue<TView extends DateOrTimeViewWithMeridiem = D
|
|
|
49
50
|
*/
|
|
50
51
|
orientation: PickerOrientation;
|
|
51
52
|
}
|
|
52
|
-
export interface PickerActionsContextValue extends UsePickerValueActionsContextValue {
|
|
53
|
+
export interface PickerActionsContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError = string> extends UsePickerValueActionsContextValue<TValue, TError>, UsePickerViewsActionsContextValue<TView> {
|
|
53
54
|
}
|
|
54
55
|
export interface PickerPrivateContextValue extends UsePickerValuePrivateContextValue {
|
|
55
56
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { LocalizationProvider } from "../../LocalizationProvider/index.js";
|
|
3
|
+
import { IsValidValueContext } from "../../hooks/useIsValidValue.js";
|
|
3
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
export const PickerContext = /*#__PURE__*/React.createContext(null);
|
|
5
6
|
export const PickerActionsContext = /*#__PURE__*/React.createContext(null);
|
|
@@ -27,6 +28,7 @@ export function PickerProvider(props) {
|
|
|
27
28
|
contextValue,
|
|
28
29
|
actionsContextValue,
|
|
29
30
|
privateContextValue,
|
|
31
|
+
isValidContextValue,
|
|
30
32
|
localeText,
|
|
31
33
|
children
|
|
32
34
|
} = props;
|
|
@@ -36,9 +38,12 @@ export function PickerProvider(props) {
|
|
|
36
38
|
value: actionsContextValue,
|
|
37
39
|
children: /*#__PURE__*/_jsx(PickerPrivateContext.Provider, {
|
|
38
40
|
value: privateContextValue,
|
|
39
|
-
children: /*#__PURE__*/_jsx(
|
|
40
|
-
|
|
41
|
-
children:
|
|
41
|
+
children: /*#__PURE__*/_jsx(IsValidValueContext.Provider, {
|
|
42
|
+
value: isValidContextValue,
|
|
43
|
+
children: /*#__PURE__*/_jsx(LocalizationProvider, {
|
|
44
|
+
localeText: localeText,
|
|
45
|
+
children: children
|
|
46
|
+
})
|
|
42
47
|
})
|
|
43
48
|
})
|
|
44
49
|
})
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BaseToolbarProps } from '../models/props/toolbar';
|
|
3
3
|
import { PickersToolbarClasses } from './pickersToolbarClasses';
|
|
4
|
-
|
|
5
|
-
export interface PickersToolbarProps<TValue extends PickerValidValue> extends Pick<BaseToolbarProps<TValue>, 'isLandscape' | 'hidden' | 'titleId'> {
|
|
4
|
+
export interface PickersToolbarProps extends Pick<BaseToolbarProps, 'hidden' | 'titleId'> {
|
|
6
5
|
className?: string;
|
|
7
6
|
landscapeDirection?: 'row' | 'column';
|
|
8
7
|
toolbarTitle: React.ReactNode;
|
|
9
8
|
classes?: Partial<PickersToolbarClasses>;
|
|
10
9
|
}
|
|
11
|
-
type PickersToolbarComponent = (
|
|
10
|
+
type PickersToolbarComponent = ((props: React.PropsWithChildren<PickersToolbarProps> & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
|
12
11
|
propTypes?: any;
|
|
13
12
|
};
|
|
14
13
|
export declare const PickersToolbar: PickersToolbarComponent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["children", "className", "classes", "toolbarTitle", "hidden", "titleId", "
|
|
3
|
+
const _excluded = ["children", "className", "classes", "toolbarTitle", "hidden", "titleId", "classes", "landscapeDirection"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import Typography from '@mui/material/Typography';
|
|
@@ -27,11 +27,12 @@ export function usePreviousMonthDisabled(month, {
|
|
|
27
27
|
}
|
|
28
28
|
export function useMeridiemMode(date, ampm, onChange, selectionState) {
|
|
29
29
|
const utils = useUtils();
|
|
30
|
-
const
|
|
30
|
+
const cleanDate = React.useMemo(() => !utils.isValid(date) ? null : date, [utils, date]);
|
|
31
|
+
const meridiemMode = getMeridiem(cleanDate, utils);
|
|
31
32
|
const handleMeridiemChange = React.useCallback(mode => {
|
|
32
|
-
const timeWithMeridiem =
|
|
33
|
+
const timeWithMeridiem = cleanDate == null ? null : convertToMeridiem(cleanDate, mode, Boolean(ampm), utils);
|
|
33
34
|
onChange(timeWithMeridiem, selectionState ?? 'partial');
|
|
34
|
-
}, [ampm,
|
|
35
|
+
}, [ampm, cleanDate, onChange, selectionState, utils]);
|
|
35
36
|
return {
|
|
36
37
|
meridiemMode,
|
|
37
38
|
handleMeridiemChange
|
|
@@ -53,7 +53,6 @@ export const useDesktopPicker = _ref => {
|
|
|
53
53
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
54
54
|
const {
|
|
55
55
|
hasUIView,
|
|
56
|
-
layoutProps,
|
|
57
56
|
providerProps,
|
|
58
57
|
renderCurrentView,
|
|
59
58
|
shouldRestoreFocus,
|
|
@@ -64,7 +63,6 @@ export const useDesktopPicker = _ref => {
|
|
|
64
63
|
fieldRef,
|
|
65
64
|
localeText,
|
|
66
65
|
autoFocusView: true,
|
|
67
|
-
additionalViewProps: {},
|
|
68
66
|
variant: 'desktop'
|
|
69
67
|
}));
|
|
70
68
|
const InputAdornment = slots.inputAdornment ?? MuiInputAdornment;
|
|
@@ -180,7 +178,7 @@ export const useDesktopPicker = _ref => {
|
|
|
180
178
|
slotProps: slotProps,
|
|
181
179
|
shouldRestoreFocus: shouldRestoreFocus,
|
|
182
180
|
reduceAnimations: reduceAnimations,
|
|
183
|
-
children: /*#__PURE__*/_jsx(Layout, _extends({},
|
|
181
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
184
182
|
slots: slots,
|
|
185
183
|
slotProps: slotProps,
|
|
186
184
|
children: renderCurrentView()
|
|
@@ -55,7 +55,7 @@ export interface DesktopOnlyPickerProps extends BaseNonStaticPickerProps, BaseNo
|
|
|
55
55
|
*/
|
|
56
56
|
autoFocus?: boolean;
|
|
57
57
|
}
|
|
58
|
-
export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<PickerValue, TView, any
|
|
58
|
+
export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<PickerValue, TView, any>> extends BasePickerProps<PickerValue, any, TError, TExternalProps>, MakeRequired<DesktopOnlyPickerProps, 'format'> {
|
|
59
59
|
/**
|
|
60
60
|
* Overridable component slots.
|
|
61
61
|
* @default {}
|
|
@@ -67,7 +67,7 @@ export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
|
67
67
|
*/
|
|
68
68
|
slotProps?: UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
69
69
|
}
|
|
70
|
-
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps
|
|
70
|
+
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor'> {
|
|
71
71
|
props: TExternalProps;
|
|
72
72
|
getOpenDialogAriaText: (date: PickerValidDate | null) => string;
|
|
73
73
|
}
|
|
@@ -113,7 +113,7 @@ const createSection = ({
|
|
|
113
113
|
const sectionConfig = getDateSectionConfigFromFormatToken(utils, token);
|
|
114
114
|
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, sectionConfig.contentType, sectionConfig.type, token);
|
|
115
115
|
const hasLeadingZerosInInput = shouldRespectLeadingZeros ? hasLeadingZerosInFormat : sectionConfig.contentType === 'digit';
|
|
116
|
-
const isValidDate =
|
|
116
|
+
const isValidDate = utils.isValid(date);
|
|
117
117
|
let sectionValue = isValidDate ? utils.formatByString(date, token) : '';
|
|
118
118
|
let maxLength = null;
|
|
119
119
|
if (hasLeadingZerosInInput) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { useField } from './useField';
|
|
1
|
+
export { useField, useFieldInternalPropsWithDefaults } from './useField';
|
|
2
2
|
export type { FieldValueManager, UseFieldInternalProps, UseFieldParams, UseFieldResponse, FieldChangeHandler, FieldChangeHandlerContext, } from './useField.types';
|
|
3
3
|
export { createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections, } from './useField.utils';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { useField } from "./useField.js";
|
|
1
|
+
export { useField, useFieldInternalPropsWithDefaults } from "./useField.js";
|
|
2
2
|
export { createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections } from "./useField.utils.js";
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { UseFieldParams, UseFieldResponse, UseFieldCommonForwardedProps, UseFieldInternalProps, UseFieldForwardedProps } from './useField.types';
|
|
2
|
-
import { PickerValidValue } from '../../models';
|
|
2
|
+
import { PickerValidValue, PickerAnyManager, PickerManagerFieldInternalProps, PickerManagerFieldInternalPropsWithDefaults } from '../../models';
|
|
3
|
+
/**
|
|
4
|
+
* Applies the default values to the field internal props.
|
|
5
|
+
* This is a temporary hook that will be removed during a follow up when `useField` will receive the internal props without the defaults.
|
|
6
|
+
* It is only here to allow the migration to be done in smaller steps.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useFieldInternalPropsWithDefaults: <TManager extends PickerAnyManager>({ manager, internalProps, }: {
|
|
9
|
+
manager: TManager;
|
|
10
|
+
internalProps: PickerManagerFieldInternalProps<TManager>;
|
|
11
|
+
}) => PickerManagerFieldInternalPropsWithDefaults<TManager>;
|
|
3
12
|
export declare const useField: <TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TForwardedProps extends UseFieldCommonForwardedProps & UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>, TInternalProps extends UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, any> & {
|
|
4
13
|
minutesStep?: number;
|
|
5
14
|
}>(params: UseFieldParams<TValue, TEnableAccessibleFieldDOMStructure, TForwardedProps, TInternalProps>) => UseFieldResponse<TEnableAccessibleFieldDOMStructure, TForwardedProps>;
|
|
@@ -4,12 +4,28 @@ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
|
4
4
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
5
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
6
6
|
import { useValidation } from "../../../validation/index.js";
|
|
7
|
-
import { useUtils } from "../useUtils.js";
|
|
7
|
+
import { useLocalizationContext, useUtils } from "../useUtils.js";
|
|
8
8
|
import { adjustSectionValue, getSectionOrder } from "./useField.utils.js";
|
|
9
9
|
import { useFieldState } from "./useFieldState.js";
|
|
10
10
|
import { useFieldCharacterEditing } from "./useFieldCharacterEditing.js";
|
|
11
11
|
import { useFieldV7TextField } from "./useFieldV7TextField.js";
|
|
12
12
|
import { useFieldV6TextField } from "./useFieldV6TextField.js";
|
|
13
|
+
/**
|
|
14
|
+
* Applies the default values to the field internal props.
|
|
15
|
+
* This is a temporary hook that will be removed during a follow up when `useField` will receive the internal props without the defaults.
|
|
16
|
+
* It is only here to allow the migration to be done in smaller steps.
|
|
17
|
+
*/
|
|
18
|
+
export const useFieldInternalPropsWithDefaults = ({
|
|
19
|
+
manager,
|
|
20
|
+
internalProps
|
|
21
|
+
}) => {
|
|
22
|
+
const localizationContext = useLocalizationContext();
|
|
23
|
+
return React.useMemo(() => {
|
|
24
|
+
return manager.internal_applyDefaultsToFieldInternalProps(_extends({}, localizationContext, {
|
|
25
|
+
internalProps
|
|
26
|
+
}));
|
|
27
|
+
}, [manager, internalProps, localizationContext]);
|
|
28
|
+
};
|
|
13
29
|
export const useField = params => {
|
|
14
30
|
const utils = useUtils();
|
|
15
31
|
const {
|
|
@@ -361,7 +361,7 @@ export const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
|
|
|
361
361
|
currentDate
|
|
362
362
|
}) => ({
|
|
363
363
|
minimum: 1,
|
|
364
|
-
maximum:
|
|
364
|
+
maximum: utils.isValid(currentDate) ? utils.getDaysInMonth(currentDate) : maxDaysInMonth,
|
|
365
365
|
longestMonth: longestMonth
|
|
366
366
|
}),
|
|
367
367
|
weekDay: ({
|
|
@@ -509,7 +509,7 @@ export const mergeDateIntoReferenceDate = (utils, dateToTransferFrom, sections,
|
|
|
509
509
|
}, referenceDate);
|
|
510
510
|
export const isAndroid = () => navigator.userAgent.toLowerCase().includes('android');
|
|
511
511
|
|
|
512
|
-
// TODO
|
|
512
|
+
// TODO v9: Remove
|
|
513
513
|
export const getSectionOrder = (sections, shouldApplyRTL) => {
|
|
514
514
|
const neighbors = {};
|
|
515
515
|
if (!shouldApplyRTL) {
|
|
@@ -148,7 +148,7 @@ export const useFieldState = params => {
|
|
|
148
148
|
const updateValueFromValueStr = valueStr => {
|
|
149
149
|
const parseDateStr = (dateStr, referenceDate) => {
|
|
150
150
|
const date = utils.parse(dateStr, format);
|
|
151
|
-
if (
|
|
151
|
+
if (!utils.isValid(date)) {
|
|
152
152
|
return null;
|
|
153
153
|
}
|
|
154
154
|
const sections = buildSectionsFromFormat({
|
|
@@ -199,7 +199,7 @@ export const useFieldState = params => {
|
|
|
199
199
|
* Then we merge the value of the modified sections into the reference date.
|
|
200
200
|
* This makes sure that we don't lose some information of the initial date (like the time on a date field).
|
|
201
201
|
*/
|
|
202
|
-
if (
|
|
202
|
+
if (utils.isValid(newActiveDate)) {
|
|
203
203
|
const mergedDate = mergeDateIntoReferenceDate(utils, newActiveDate, newActiveDateSections, activeDateManager.referenceDate, true);
|
|
204
204
|
values = activeDateManager.getNewValuesFromNewActiveDate(mergedDate);
|
|
205
205
|
shouldPublish = true;
|
|
@@ -35,8 +35,8 @@ export const addPositionPropertiesToSections = (sections, localizedDigits, isRtl
|
|
|
35
35
|
};
|
|
36
36
|
export const useFieldV6TextField = params => {
|
|
37
37
|
const isRtl = useRtl();
|
|
38
|
-
const focusTimeoutRef = React.useRef();
|
|
39
|
-
const selectionSyncTimeoutRef = React.useRef();
|
|
38
|
+
const focusTimeoutRef = React.useRef(undefined);
|
|
39
|
+
const selectionSyncTimeoutRef = React.useRef(undefined);
|
|
40
40
|
const {
|
|
41
41
|
forwardedProps: {
|
|
42
42
|
onFocus,
|
|
@@ -46,7 +46,6 @@ export const useMobilePicker = _ref => {
|
|
|
46
46
|
const labelId = useId();
|
|
47
47
|
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
|
48
48
|
const {
|
|
49
|
-
layoutProps,
|
|
50
49
|
providerProps,
|
|
51
50
|
renderCurrentView,
|
|
52
51
|
fieldProps: pickerFieldProps,
|
|
@@ -56,7 +55,6 @@ export const useMobilePicker = _ref => {
|
|
|
56
55
|
fieldRef,
|
|
57
56
|
localeText,
|
|
58
57
|
autoFocusView: true,
|
|
59
|
-
additionalViewProps: {},
|
|
60
58
|
variant: 'mobile'
|
|
61
59
|
}));
|
|
62
60
|
const Field = slots.field;
|
|
@@ -129,7 +127,7 @@ export const useMobilePicker = _ref => {
|
|
|
129
127
|
})), /*#__PURE__*/_jsx(PickersModalDialog, {
|
|
130
128
|
slots: slots,
|
|
131
129
|
slotProps: slotProps,
|
|
132
|
-
children: /*#__PURE__*/_jsx(Layout, _extends({},
|
|
130
|
+
children: /*#__PURE__*/_jsx(Layout, _extends({}, slotProps?.layout, {
|
|
133
131
|
slots: slots,
|
|
134
132
|
slotProps: slotProps,
|
|
135
133
|
children: renderCurrentView()
|
|
@@ -30,7 +30,7 @@ export interface UseMobilePickerSlotProps<TEnableAccessibleFieldDOMStructure ext
|
|
|
30
30
|
}
|
|
31
31
|
export interface MobileOnlyPickerProps extends BaseNonStaticPickerProps, BaseNonRangeNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerProviderNonStaticProps {
|
|
32
32
|
}
|
|
33
|
-
export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any
|
|
33
|
+
export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerViewsProps<any, TView, any>> extends BasePickerProps<PickerValue, TView, TError, TExternalProps>, MakeRequired<MobileOnlyPickerProps, 'format'> {
|
|
34
34
|
/**
|
|
35
35
|
* Overridable component slots.
|
|
36
36
|
* @default {}
|
|
@@ -42,7 +42,7 @@ export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem,
|
|
|
42
42
|
*/
|
|
43
43
|
slotProps?: UseMobilePickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
44
44
|
}
|
|
45
|
-
export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps
|
|
45
|
+
export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParams<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator'> {
|
|
46
46
|
props: TExternalProps;
|
|
47
47
|
getOpenDialogAriaText: (date: PickerValidDate | null) => string;
|
|
48
48
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
2
3
|
export const useOpenState = ({
|
|
3
4
|
open,
|
|
4
5
|
onOpen,
|
|
@@ -17,7 +18,7 @@ export const useOpenState = ({
|
|
|
17
18
|
setOpenState(open);
|
|
18
19
|
}
|
|
19
20
|
}, [isControllingOpenProp, open]);
|
|
20
|
-
const setOpen =
|
|
21
|
+
const setOpen = useEventCallback(action => {
|
|
21
22
|
const newOpen = typeof action === 'function' ? action(openState) : action;
|
|
22
23
|
if (!isControllingOpenProp) {
|
|
23
24
|
setOpenState(newOpen);
|
|
@@ -28,7 +29,7 @@ export const useOpenState = ({
|
|
|
28
29
|
if (!newOpen && onClose) {
|
|
29
30
|
onClose();
|
|
30
31
|
}
|
|
31
|
-
}
|
|
32
|
+
});
|
|
32
33
|
return {
|
|
33
34
|
open: openState,
|
|
34
35
|
setOpen
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { UsePickerParams, UsePickerProps, UsePickerResponse } from './usePicker.types';
|
|
2
2
|
import { InferError } from '../../../models';
|
|
3
3
|
import { DateOrTimeViewWithMeridiem, PickerValidValue } from '../../models';
|
|
4
|
-
export declare const usePicker: <TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerProps<TValue, TView, any, any
|
|
4
|
+
export declare const usePicker: <TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerProps<TValue, TView, any, any>>({ props, valueManager, valueType, variant, validator, autoFocusView, rendererInterceptor, fieldRef, localeText, }: UsePickerParams<TValue, TView, TExternalProps>) => UsePickerResponse<TValue, TView, InferError<TExternalProps>>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
3
2
|
import { usePickerValue } from "./usePickerValue.js";
|
|
4
3
|
import { usePickerViews } from "./usePickerViews.js";
|
|
@@ -8,7 +7,6 @@ export const usePicker = ({
|
|
|
8
7
|
valueManager,
|
|
9
8
|
valueType,
|
|
10
9
|
variant,
|
|
11
|
-
additionalViewProps,
|
|
12
10
|
validator,
|
|
13
11
|
autoFocusView,
|
|
14
12
|
rendererInterceptor,
|
|
@@ -24,12 +22,10 @@ export const usePicker = ({
|
|
|
24
22
|
props,
|
|
25
23
|
valueManager,
|
|
26
24
|
valueType,
|
|
27
|
-
variant,
|
|
28
25
|
validator
|
|
29
26
|
});
|
|
30
27
|
const pickerViewsResponse = usePickerViews({
|
|
31
28
|
props,
|
|
32
|
-
additionalViewProps,
|
|
33
29
|
autoFocusView,
|
|
34
30
|
fieldRef,
|
|
35
31
|
propsFromPickerValue: pickerValueResponse.viewProps,
|
|
@@ -50,8 +46,6 @@ export const usePicker = ({
|
|
|
50
46
|
renderCurrentView: pickerViewsResponse.renderCurrentView,
|
|
51
47
|
hasUIView: pickerViewsResponse.provider.hasUIView,
|
|
52
48
|
shouldRestoreFocus: pickerViewsResponse.shouldRestoreFocus,
|
|
53
|
-
// Picker layout
|
|
54
|
-
layoutProps: _extends({}, pickerValueResponse.layoutProps),
|
|
55
49
|
// Picker provider
|
|
56
50
|
providerProps,
|
|
57
51
|
// Picker owner state
|