@mui/x-date-pickers 6.0.4 → 6.2.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.
- package/AdapterDateFns/index.d.ts +1 -1
- package/AdapterDateFnsJalali/index.d.ts +1 -1
- package/AdapterDayjs/AdapterDayjs.d.ts +114 -0
- package/AdapterDayjs/AdapterDayjs.js +387 -0
- package/AdapterDayjs/index.d.ts +1 -29
- package/AdapterDayjs/index.js +1 -102
- package/AdapterLuxon/index.d.ts +2 -2
- package/AdapterLuxon/index.js +1 -1
- package/AdapterMoment/index.d.ts +1 -1
- package/AdapterMomentHijri/index.d.ts +1 -1
- package/AdapterMomentJalaali/index.d.ts +1 -1
- package/CHANGELOG.md +110 -0
- package/DateCalendar/DateCalendar.js +0 -2
- package/DateCalendar/DateCalendar.types.d.ts +1 -1
- package/DateCalendar/DayCalendar.d.ts +1 -1
- package/DateCalendar/PickersCalendarHeader.d.ts +0 -12
- package/DateCalendar/PickersCalendarHeader.js +7 -9
- package/DateCalendar/PickersSlideTransition.js +1 -0
- package/DateCalendar/useCalendarState.d.ts +1 -1
- package/DateField/DateField.js +14 -2
- package/DateField/useDateField.js +3 -1
- package/DatePicker/DatePicker.js +6 -0
- package/DatePicker/shared.d.ts +2 -2
- package/DateTimeField/DateTimeField.js +14 -2
- package/DateTimeField/useDateTimeField.js +3 -1
- package/DateTimePicker/DateTimePicker.js +6 -0
- package/DateTimePicker/shared.js +3 -1
- package/DesktopDatePicker/DesktopDatePicker.js +6 -0
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -0
- package/DesktopTimePicker/DesktopTimePicker.js +6 -0
- package/LocalizationProvider/LocalizationProvider.d.ts +2 -3
- package/MobileDatePicker/MobileDatePicker.js +6 -0
- package/MobileDateTimePicker/MobileDateTimePicker.js +6 -0
- package/MobileTimePicker/MobileTimePicker.js +6 -0
- package/MonthCalendar/PickersMonth.js +1 -0
- package/README.md +3 -2
- package/TimeClock/ClockNumbers.d.ts +1 -1
- package/TimeClock/TimeClock.js +5 -4
- package/TimeClock/TimeClock.types.d.ts +1 -1
- package/TimeField/TimeField.js +14 -2
- package/TimeField/useTimeField.js +3 -1
- package/TimePicker/TimePicker.js +6 -0
- package/YearCalendar/PickersYear.js +1 -0
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -12
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +0 -12
- package/internals/components/PickersModalDialog.d.ts +1 -13
- package/internals/components/PickersModalDialog.js +7 -9
- package/internals/components/PickersPopper.d.ts +1 -3
- package/internals/components/PickersPopper.js +2 -7
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -3
- package/internals/hooks/useField/useField.js +2 -2
- package/internals/hooks/useField/useField.types.d.ts +9 -11
- package/internals/hooks/useField/useField.utils.d.ts +2 -3
- package/internals/hooks/useField/useField.utils.js +19 -5
- package/internals/hooks/useField/useFieldCharacterEditing.js +23 -0
- package/internals/hooks/useField/useFieldState.js +3 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -3
- package/internals/hooks/usePicker/index.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.types.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerLayoutProps.js +6 -0
- package/internals/hooks/usePicker/usePickerValue.d.ts +3 -173
- package/internals/hooks/usePicker/usePickerValue.js +199 -144
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +233 -0
- package/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/internals/hooks/usePicker/usePickerViews.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerViews.js +13 -0
- package/internals/hooks/useUtils.d.ts +1 -1
- package/internals/index.d.ts +1 -2
- package/internals/models/index.d.ts +0 -1
- package/internals/models/index.js +1 -2
- package/internals/models/props/basePickerProps.d.ts +6 -0
- package/internals/utils/date-utils.d.ts +1 -1
- package/internals/utils/time-utils.d.ts +1 -2
- package/internals/utils/valueManagers.d.ts +1 -1
- package/internals/utils/valueManagers.js +2 -2
- package/legacy/AdapterDayjs/AdapterDayjs.js +403 -0
- package/legacy/AdapterDayjs/index.js +1 -119
- package/legacy/AdapterLuxon/index.js +1 -1
- package/legacy/DateCalendar/DateCalendar.js +0 -2
- package/legacy/DateCalendar/PickersCalendarHeader.js +8 -10
- package/legacy/DateField/DateField.js +13 -1
- package/legacy/DateField/useDateField.js +3 -1
- package/legacy/DatePicker/DatePicker.js +6 -0
- package/legacy/DateTimeField/DateTimeField.js +13 -1
- package/legacy/DateTimeField/useDateTimeField.js +3 -1
- package/legacy/DateTimePicker/DateTimePicker.js +6 -0
- package/legacy/DateTimePicker/shared.js +3 -1
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +6 -0
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -0
- package/legacy/DesktopTimePicker/DesktopTimePicker.js +6 -0
- package/legacy/MobileDatePicker/MobileDatePicker.js +6 -0
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +6 -0
- package/legacy/MobileTimePicker/MobileTimePicker.js +6 -0
- package/legacy/TimeClock/TimeClock.js +5 -4
- package/legacy/TimeField/TimeField.js +13 -1
- package/legacy/TimeField/useTimeField.js +3 -1
- package/legacy/TimePicker/TimePicker.js +6 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +10 -12
- package/legacy/internals/components/PickersModalDialog.js +7 -9
- package/legacy/internals/components/PickersPopper.js +2 -7
- package/legacy/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/legacy/internals/hooks/useField/useField.js +2 -2
- package/legacy/internals/hooks/useField/useField.utils.js +27 -10
- package/legacy/internals/hooks/useField/useFieldCharacterEditing.js +23 -0
- package/legacy/internals/hooks/useField/useFieldState.js +5 -3
- package/legacy/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/legacy/internals/hooks/usePicker/usePickerLayoutProps.js +6 -0
- package/legacy/internals/hooks/usePicker/usePickerValue.js +196 -146
- package/legacy/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/legacy/internals/hooks/usePicker/usePickerViews.js +13 -0
- package/legacy/internals/models/index.js +1 -2
- package/legacy/internals/utils/valueManagers.js +3 -3
- package/legacy/locales/caES.js +88 -0
- package/legacy/locales/esES.js +34 -17
- package/legacy/locales/heIL.js +33 -16
- package/legacy/locales/index.js +1 -0
- package/legacy/locales/jaJP.js +3 -1
- package/legacy/locales/kzKZ.js +88 -0
- package/legacy/locales/nlNL.js +25 -11
- package/legacy/locales/ptBR.js +33 -16
- package/legacy/models/adapters.js +1 -0
- package/legacy/models/index.js +2 -1
- package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.js +20 -0
- package/legacy/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +1 -0
- package/legacy/tests/describeGregorianAdapter/index.js +1 -0
- package/legacy/tests/describeGregorianAdapter/testCalculations.js +273 -0
- package/legacy/tests/describeGregorianAdapter/testFormat.js +26 -0
- package/legacy/tests/describeGregorianAdapter/testLocalization.js +15 -0
- package/legacy/tests/describeValidation/describeValidation.js +2 -1
- package/legacy/tests/describeValidation/testMinutesViewValidation.js +201 -0
- package/legacy/tests/describeValue/testPickerActionBar.js +52 -3
- package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
- package/locales/beBY.d.ts +3 -3
- package/locales/caES.d.ts +51 -0
- package/locales/caES.js +54 -0
- package/locales/csCZ.d.ts +3 -3
- package/locales/daDK.d.ts +3 -3
- package/locales/deDE.d.ts +3 -3
- package/locales/enUS.d.ts +3 -3
- package/locales/esES.d.ts +3 -3
- package/locales/esES.js +14 -17
- package/locales/faIR.d.ts +3 -3
- package/locales/fiFI.d.ts +3 -3
- package/locales/frFR.d.ts +3 -3
- package/locales/heIL.d.ts +3 -3
- package/locales/heIL.js +13 -16
- package/locales/huHU.d.ts +3 -3
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/isIS.d.ts +3 -3
- package/locales/itIT.d.ts +3 -3
- package/locales/jaJP.d.ts +3 -3
- package/locales/jaJP.js +1 -1
- package/locales/koKR.d.ts +3 -3
- package/locales/kzKZ.d.ts +51 -0
- package/locales/kzKZ.js +56 -0
- package/locales/nbNO.d.ts +3 -3
- package/locales/nlNL.d.ts +3 -3
- package/locales/nlNL.js +9 -11
- package/locales/plPL.d.ts +3 -3
- package/locales/ptBR.d.ts +3 -3
- package/locales/ptBR.js +13 -16
- package/locales/ruRU.d.ts +3 -3
- package/locales/svSE.d.ts +3 -3
- package/locales/trTR.d.ts +3 -3
- package/locales/ukUA.d.ts +3 -3
- package/locales/urPK.d.ts +3 -3
- package/locales/utils/getPickersLocalization.d.ts +3 -3
- package/locales/utils/pickersLocaleTextApi.d.ts +1 -2
- package/locales/zhCN.d.ts +3 -3
- package/models/adapters.d.ts +568 -0
- package/models/adapters.js +1 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +2 -1
- package/modern/AdapterDayjs/AdapterDayjs.js +386 -0
- package/modern/AdapterDayjs/index.js +1 -101
- package/modern/AdapterLuxon/index.js +1 -1
- package/modern/DateCalendar/DateCalendar.js +0 -2
- package/modern/DateCalendar/PickersCalendarHeader.js +6 -8
- package/modern/DateCalendar/PickersSlideTransition.js +1 -0
- package/modern/DateField/DateField.js +14 -2
- package/modern/DateField/useDateField.js +3 -1
- package/modern/DatePicker/DatePicker.js +6 -0
- package/modern/DateTimeField/DateTimeField.js +14 -2
- package/modern/DateTimeField/useDateTimeField.js +3 -1
- package/modern/DateTimePicker/DateTimePicker.js +6 -0
- package/modern/DateTimePicker/shared.js +3 -1
- package/modern/DesktopDatePicker/DesktopDatePicker.js +6 -0
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -0
- package/modern/DesktopTimePicker/DesktopTimePicker.js +6 -0
- package/modern/MobileDatePicker/MobileDatePicker.js +6 -0
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +6 -0
- package/modern/MobileTimePicker/MobileTimePicker.js +6 -0
- package/modern/MonthCalendar/PickersMonth.js +1 -0
- package/modern/TimeClock/TimeClock.js +5 -4
- package/modern/TimeField/TimeField.js +14 -2
- package/modern/TimeField/useTimeField.js +3 -1
- package/modern/TimePicker/TimePicker.js +6 -0
- package/modern/YearCalendar/PickersYear.js +1 -0
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +9 -11
- package/modern/internals/components/PickersModalDialog.js +6 -8
- package/modern/internals/components/PickersPopper.js +2 -7
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/modern/internals/hooks/useField/useField.js +2 -2
- package/modern/internals/hooks/useField/useField.utils.js +19 -5
- package/modern/internals/hooks/useField/useFieldCharacterEditing.js +23 -0
- package/modern/internals/hooks/useField/useFieldState.js +3 -2
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +6 -0
- package/modern/internals/hooks/usePicker/usePickerValue.js +199 -144
- package/modern/internals/hooks/usePicker/usePickerValue.types.js +1 -0
- package/modern/internals/hooks/usePicker/usePickerViews.js +13 -0
- package/modern/internals/models/index.js +1 -2
- package/modern/internals/utils/valueManagers.js +2 -2
- package/modern/locales/caES.js +54 -0
- package/modern/locales/esES.js +14 -17
- package/modern/locales/heIL.js +13 -16
- package/modern/locales/index.js +1 -0
- package/modern/locales/jaJP.js +1 -1
- package/modern/locales/kzKZ.js +56 -0
- package/modern/locales/nlNL.js +9 -11
- package/modern/locales/ptBR.js +13 -16
- package/modern/models/adapters.js +1 -0
- package/modern/models/index.js +2 -1
- package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.js +20 -0
- package/modern/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +1 -0
- package/modern/tests/describeGregorianAdapter/index.js +1 -0
- package/modern/tests/describeGregorianAdapter/testCalculations.js +272 -0
- package/modern/tests/describeGregorianAdapter/testFormat.js +27 -0
- package/modern/tests/describeGregorianAdapter/testLocalization.js +16 -0
- package/modern/tests/describeValidation/describeValidation.js +2 -1
- package/modern/tests/describeValidation/testMinutesViewValidation.js +200 -0
- package/modern/tests/describeValue/testPickerActionBar.js +52 -3
- package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
- package/node/AdapterDayjs/AdapterDayjs.js +395 -0
- package/node/AdapterDayjs/index.js +6 -104
- package/node/AdapterLuxon/index.js +1 -1
- package/node/AdapterMomentHijri/index.js +2 -0
- package/node/DateCalendar/DateCalendar.js +0 -2
- package/node/DateCalendar/PickersCalendarHeader.js +5 -9
- package/node/DateCalendar/PickersSlideTransition.js +1 -0
- package/node/DateField/DateField.js +14 -2
- package/node/DateField/useDateField.js +3 -1
- package/node/DatePicker/DatePicker.js +6 -0
- package/node/DateTimeField/DateTimeField.js +14 -2
- package/node/DateTimeField/useDateTimeField.js +3 -1
- package/node/DateTimePicker/DateTimePicker.js +6 -0
- package/node/DateTimePicker/shared.js +3 -1
- package/node/DesktopDatePicker/DesktopDatePicker.js +6 -0
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +6 -0
- package/node/DesktopTimePicker/DesktopTimePicker.js +6 -0
- package/node/MobileDatePicker/MobileDatePicker.js +6 -0
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +6 -0
- package/node/MobileTimePicker/MobileTimePicker.js +6 -0
- package/node/MonthCalendar/PickersMonth.js +1 -0
- package/node/TimeClock/TimeClock.js +5 -4
- package/node/TimeField/TimeField.js +14 -2
- package/node/TimeField/useTimeField.js +3 -1
- package/node/TimePicker/TimePicker.js +6 -0
- package/node/YearCalendar/PickersYear.js +1 -0
- package/node/index.js +1 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +9 -11
- package/node/internals/components/PickersModalDialog.js +6 -8
- package/node/internals/components/PickersPopper.js +2 -7
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +2 -0
- package/node/internals/hooks/useField/useField.js +2 -2
- package/node/internals/hooks/useField/useField.utils.js +19 -5
- package/node/internals/hooks/useField/useFieldCharacterEditing.js +22 -0
- package/node/internals/hooks/useField/useFieldState.js +3 -2
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +2 -0
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +5 -0
- package/node/internals/hooks/usePicker/usePickerValue.js +199 -144
- package/node/internals/hooks/usePicker/usePickerValue.types.js +5 -0
- package/node/internals/hooks/usePicker/usePickerViews.js +12 -0
- package/node/internals/models/index.js +0 -11
- package/node/internals/utils/valueManagers.js +2 -2
- package/node/locales/caES.js +61 -0
- package/node/locales/csCZ.js +0 -1
- package/node/locales/esES.js +14 -17
- package/node/locales/heIL.js +13 -16
- package/node/locales/index.js +11 -0
- package/node/locales/jaJP.js +1 -1
- package/node/locales/kzKZ.js +62 -0
- package/node/locales/nlNL.js +9 -11
- package/node/locales/ptBR.js +13 -16
- package/node/models/adapters.js +5 -0
- package/node/models/index.js +11 -0
- package/node/tests/describeGregorianAdapter/describeGregorianAdapter.js +29 -0
- package/node/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +5 -0
- package/node/tests/describeGregorianAdapter/index.js +18 -0
- package/node/tests/describeGregorianAdapter/testCalculations.js +279 -0
- package/node/tests/describeGregorianAdapter/testFormat.js +34 -0
- package/node/tests/describeGregorianAdapter/testLocalization.js +23 -0
- package/node/tests/describeValidation/describeValidation.js +2 -1
- package/node/tests/describeValidation/testMinutesViewValidation.js +210 -0
- package/node/tests/describeValue/testPickerActionBar.js +52 -3
- package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
- package/package.json +11 -11
- package/tests/describeGregorianAdapter/describeGregorianAdapter.js +20 -0
- package/tests/describeGregorianAdapter/describeGregorianAdapter.types.js +1 -0
- package/tests/describeGregorianAdapter/index.js +1 -0
- package/tests/describeGregorianAdapter/testCalculations.js +272 -0
- package/tests/describeGregorianAdapter/testFormat.js +27 -0
- package/tests/describeGregorianAdapter/testLocalization.js +16 -0
- package/tests/describeValidation/describeValidation.js +2 -1
- package/tests/describeValidation/testMinutesViewValidation.js +200 -0
- package/tests/describeValue/testPickerActionBar.js +52 -3
- package/tests/describeValue/testPickerOpenCloseLifeCycle.js +6 -6
- package/internals/models/muiPickersAdapter.d.ts +0 -26
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { FieldChangeHandlerContext, UseFieldInternalProps } from '../useField';
|
|
2
|
+
import { InferError, Validator } from '../validation/useValidation';
|
|
3
|
+
import { UseFieldValidationProps } from '../useField/useField.types';
|
|
4
|
+
import { WrapperVariant } from '../../models/common';
|
|
5
|
+
import { FieldSection, FieldSelectedSections, MuiPickersAdapter } from '../../../models';
|
|
6
|
+
export interface PickerValueManager<TValue, TDate, TError> {
|
|
7
|
+
/**
|
|
8
|
+
* Determines if two values are equal.
|
|
9
|
+
* @template TDate, TValue
|
|
10
|
+
* @param {MuiPickersAdapter<TDate>} utils The adapter.
|
|
11
|
+
* @param {TValue} valueLeft The first value to compare.
|
|
12
|
+
* @param {TValue} valueRight The second value to compare.
|
|
13
|
+
* @returns {boolean} A boolean indicating if the two values are equal.
|
|
14
|
+
*/
|
|
15
|
+
areValuesEqual: (utils: MuiPickersAdapter<TDate>, valueLeft: TValue, valueRight: TValue) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Value to set when clicking the "Clear" button.
|
|
18
|
+
*/
|
|
19
|
+
emptyValue: TValue;
|
|
20
|
+
/**
|
|
21
|
+
* Method returning the value to set when clicking the "Today" button
|
|
22
|
+
* @template TDate, TValue
|
|
23
|
+
* @param {MuiPickersAdapter<TDate>} utils The adapter.
|
|
24
|
+
* @returns {TValue} The value to set when clicking the "Today" button.
|
|
25
|
+
*/
|
|
26
|
+
getTodayValue: (utils: MuiPickersAdapter<TDate>) => TValue;
|
|
27
|
+
/**
|
|
28
|
+
* Method parsing the input value to replace all invalid dates by `null`.
|
|
29
|
+
* @template TDate, TValue
|
|
30
|
+
* @param {MuiPickersAdapter<TDate>} utils The adapter.
|
|
31
|
+
* @param {TValue} value The value to parse.
|
|
32
|
+
* @returns {TValue} The value without invalid date.
|
|
33
|
+
*/
|
|
34
|
+
cleanValue: (utils: MuiPickersAdapter<TDate>, value: TValue) => TValue;
|
|
35
|
+
/**
|
|
36
|
+
* Generates the new value, given the previous value and the new proposed value.
|
|
37
|
+
* @template TDate, TValue
|
|
38
|
+
* @param {MuiPickersAdapter<TDate>} utils The adapter.
|
|
39
|
+
* @param {TValue} lastValidDateValue The last valid value.
|
|
40
|
+
* @param {TValue} value The proposed value.
|
|
41
|
+
* @returns {TValue} The new value.
|
|
42
|
+
*/
|
|
43
|
+
valueReducer?: (utils: MuiPickersAdapter<TDate>, lastValidDateValue: TValue, value: TValue) => TValue;
|
|
44
|
+
/**
|
|
45
|
+
* Compare two errors to know if they are equal.
|
|
46
|
+
* @template TError
|
|
47
|
+
* @param {TError} error The new error
|
|
48
|
+
* @param {TError | null} prevError The previous error
|
|
49
|
+
* @returns {boolean} `true` if the new error is different from the previous one.
|
|
50
|
+
*/
|
|
51
|
+
isSameError: (error: TError, prevError: TError | null) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Checks if the current error is empty or not.
|
|
54
|
+
* @template TError
|
|
55
|
+
* @param {TError} error The current error.
|
|
56
|
+
* @returns {boolean} `true` if the current error is not empty.
|
|
57
|
+
*/
|
|
58
|
+
hasError: (error: TError) => boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The value identifying no error, used to initialise the error state.
|
|
61
|
+
*/
|
|
62
|
+
defaultErrorState: TError;
|
|
63
|
+
}
|
|
64
|
+
export interface PickerChangeHandlerContext<TError> {
|
|
65
|
+
validationError: TError;
|
|
66
|
+
}
|
|
67
|
+
export type PickerSelectionState = 'partial' | 'shallow' | 'finish';
|
|
68
|
+
export interface UsePickerValueState<TValue> {
|
|
69
|
+
/**
|
|
70
|
+
* Date displayed on the views and the field.
|
|
71
|
+
* It is updated whenever the user modifies something.
|
|
72
|
+
*/
|
|
73
|
+
draft: TValue;
|
|
74
|
+
/**
|
|
75
|
+
* Last value published (e.g: the last value for which `shouldPublishValue` returned `true`).
|
|
76
|
+
* If `onChange` is defined, it's the value that was passed on the last call to this callback.
|
|
77
|
+
*/
|
|
78
|
+
lastPublishedValue: TValue;
|
|
79
|
+
/**
|
|
80
|
+
* Last value committed (e.g: the last value for which `shouldCommitValue` returned `true`).
|
|
81
|
+
* If `onAccept` is defined, it's the value that was passed on the last call to this callback.
|
|
82
|
+
*/
|
|
83
|
+
lastCommittedValue: TValue;
|
|
84
|
+
/**
|
|
85
|
+
* Last value passed with `props.value`.
|
|
86
|
+
* Used to update the `draft` value whenever the `value` prop changes.
|
|
87
|
+
*/
|
|
88
|
+
lastControlledValue: TValue | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* If we never modified the value since the mount of the component,
|
|
91
|
+
* Then we might want to apply some custom logic.
|
|
92
|
+
*
|
|
93
|
+
* For example, when the component is not controlled and `defaultValue` is defined.
|
|
94
|
+
* Then clicking on "Accept", "Today" or "Clear" should fire `onAccept` with `defaultValue`, but clicking on "Cancel" or dimissing the picker should not.
|
|
95
|
+
*/
|
|
96
|
+
hasBeenModifiedSinceMount: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface PickerValueUpdaterParams<TValue, TError> {
|
|
99
|
+
action: PickerValueUpdateAction<TValue, TError>;
|
|
100
|
+
dateState: UsePickerValueState<TValue>;
|
|
101
|
+
/**
|
|
102
|
+
* Check if the new draft value has changed compared to some given value.
|
|
103
|
+
* @template TValue
|
|
104
|
+
* @param {TValue} comparisonValue The value to compare the new draft value with.
|
|
105
|
+
* @returns {boolean} `true` if the new draft value is equal to the comparison value.
|
|
106
|
+
*/
|
|
107
|
+
hasChanged: (comparisonValue: TValue) => boolean;
|
|
108
|
+
isControlled: boolean;
|
|
109
|
+
closeOnSelect: boolean;
|
|
110
|
+
}
|
|
111
|
+
export type PickerValueUpdateAction<TValue, TError> = {
|
|
112
|
+
name: 'setValueFromView';
|
|
113
|
+
value: TValue;
|
|
114
|
+
selectionState: PickerSelectionState;
|
|
115
|
+
} | {
|
|
116
|
+
name: 'setValueFromField';
|
|
117
|
+
value: TValue;
|
|
118
|
+
context: FieldChangeHandlerContext<TError>;
|
|
119
|
+
} | {
|
|
120
|
+
name: 'setValueFromAction';
|
|
121
|
+
value: TValue;
|
|
122
|
+
pickerAction: 'accept' | 'today' | 'cancel' | 'dismiss' | 'clear';
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Props used to handle the value that are common to all pickers.
|
|
126
|
+
*/
|
|
127
|
+
export interface UsePickerValueBaseProps<TValue, TError> {
|
|
128
|
+
/**
|
|
129
|
+
* The selected value.
|
|
130
|
+
* Used when the component is controlled.
|
|
131
|
+
*/
|
|
132
|
+
value?: TValue;
|
|
133
|
+
/**
|
|
134
|
+
* The default value.
|
|
135
|
+
* Used when the component is not controlled.
|
|
136
|
+
*/
|
|
137
|
+
defaultValue?: TValue;
|
|
138
|
+
/**
|
|
139
|
+
* Callback fired when the value changes.
|
|
140
|
+
* @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.
|
|
141
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
142
|
+
* @param {TValue} value The new value.
|
|
143
|
+
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
|
144
|
+
*/
|
|
145
|
+
onChange?: (value: TValue, context: PickerChangeHandlerContext<TError>) => void;
|
|
146
|
+
/**
|
|
147
|
+
* Callback fired when the value is accepted.
|
|
148
|
+
* @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.
|
|
149
|
+
* @param {TValue} value The value that was just accepted.
|
|
150
|
+
*/
|
|
151
|
+
onAccept?: (value: TValue) => void;
|
|
152
|
+
/**
|
|
153
|
+
* Callback fired when the error associated to the current value changes.
|
|
154
|
+
* If the error has a non-null value, then the `TextField` will be rendered in `error` state.
|
|
155
|
+
*
|
|
156
|
+
* @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.
|
|
157
|
+
* @template TError The validation error type. Will be either `string` or a `null`. Can be in `[start, end]` format in case of range value.
|
|
158
|
+
* @param {TError} error The new error describing why the current value is not valid.
|
|
159
|
+
* @param {TValue} value The value associated to the error.
|
|
160
|
+
*/
|
|
161
|
+
onError?: (error: TError, value: TValue) => void;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Props used to handle the value of non-static pickers.
|
|
165
|
+
*/
|
|
166
|
+
export interface UsePickerValueNonStaticProps<TValue, TSection extends FieldSection> extends Pick<UseFieldInternalProps<TValue, TSection, unknown>, 'selectedSections' | 'onSelectedSectionsChange'> {
|
|
167
|
+
/**
|
|
168
|
+
* If `true`, the popover or modal will close after submitting the full date.
|
|
169
|
+
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
|
|
170
|
+
*/
|
|
171
|
+
closeOnSelect?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Control the popup or dialog open state.
|
|
174
|
+
* @default false
|
|
175
|
+
*/
|
|
176
|
+
open?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Callback fired when the popup requests to be closed.
|
|
179
|
+
* Use in controlled mode (see `open`).
|
|
180
|
+
*/
|
|
181
|
+
onClose?: () => void;
|
|
182
|
+
/**
|
|
183
|
+
* Callback fired when the popup requests to be opened.
|
|
184
|
+
* Use in controlled mode (see `open`).
|
|
185
|
+
*/
|
|
186
|
+
onOpen?: () => void;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Props used to handle the value of the pickers.
|
|
190
|
+
*/
|
|
191
|
+
export interface UsePickerValueProps<TValue, TSection extends FieldSection, TError> extends UsePickerValueBaseProps<TValue, TError>, UsePickerValueNonStaticProps<TValue, TSection> {
|
|
192
|
+
}
|
|
193
|
+
export interface UsePickerValueParams<TValue, TDate, TSection extends FieldSection, TExternalProps extends UsePickerValueProps<TValue, TSection, any>> {
|
|
194
|
+
props: TExternalProps;
|
|
195
|
+
valueManager: PickerValueManager<TValue, TDate, InferError<TExternalProps>>;
|
|
196
|
+
wrapperVariant: WrapperVariant;
|
|
197
|
+
validator: Validator<TValue, TDate, InferError<TExternalProps>, UseFieldValidationProps<TValue, TExternalProps>>;
|
|
198
|
+
}
|
|
199
|
+
export interface UsePickerValueActions {
|
|
200
|
+
onAccept: () => void;
|
|
201
|
+
onClear: () => void;
|
|
202
|
+
onDismiss: () => void;
|
|
203
|
+
onCancel: () => void;
|
|
204
|
+
onSetToday: () => void;
|
|
205
|
+
onOpen: () => void;
|
|
206
|
+
onClose: () => void;
|
|
207
|
+
}
|
|
208
|
+
export type UsePickerValueFieldResponse<TValue, TSection extends FieldSection, TError> = Required<Pick<UseFieldInternalProps<TValue, TSection, TError>, 'value' | 'onChange' | 'selectedSections' | 'onSelectedSectionsChange'>>;
|
|
209
|
+
/**
|
|
210
|
+
* Props passed to `usePickerViews`.
|
|
211
|
+
*/
|
|
212
|
+
export interface UsePickerValueViewsResponse<TValue> {
|
|
213
|
+
value: TValue;
|
|
214
|
+
onChange: (value: TValue, selectionState?: PickerSelectionState) => void;
|
|
215
|
+
open: boolean;
|
|
216
|
+
onClose: () => void;
|
|
217
|
+
onSelectedSectionsChange: (newValue: FieldSelectedSections) => void;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Props passed to `usePickerLayoutProps`.
|
|
221
|
+
*/
|
|
222
|
+
export interface UsePickerValueLayoutResponse<TValue> extends UsePickerValueActions {
|
|
223
|
+
value: TValue;
|
|
224
|
+
onChange: (newValue: TValue) => void;
|
|
225
|
+
isValid: (value: TValue) => boolean;
|
|
226
|
+
}
|
|
227
|
+
export interface UsePickerValueResponse<TValue, TSection extends FieldSection, TError> {
|
|
228
|
+
open: boolean;
|
|
229
|
+
actions: UsePickerValueActions;
|
|
230
|
+
viewProps: UsePickerValueViewsResponse<TValue>;
|
|
231
|
+
fieldProps: UsePickerValueFieldResponse<TValue, TSection, TError>;
|
|
232
|
+
layoutProps: UsePickerValueLayoutResponse<TValue>;
|
|
233
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import { SxProps } from '@mui/system';
|
|
|
3
3
|
import { Theme } from '@mui/material/styles';
|
|
4
4
|
import { DateOrTimeView } from '../../../models';
|
|
5
5
|
import { UseViewsOptions } from '../useViews';
|
|
6
|
-
import type { UsePickerValueViewsResponse } from './usePickerValue';
|
|
6
|
+
import type { UsePickerValueViewsResponse } from './usePickerValue.types';
|
|
7
7
|
interface PickerViewsRendererBaseExternalProps<TView extends DateOrTimeView> extends Omit<UsePickerViewsProps<any, TView, any, any>, 'openTo' | 'viewRenderers'> {
|
|
8
8
|
}
|
|
9
9
|
export type PickerViewsRendererProps<TValue, TView extends DateOrTimeView, TExternalProps extends PickerViewsRendererBaseExternalProps<TView>, TAdditionalProps extends {}> = TExternalProps & TAdditionalProps & UsePickerValueViewsResponse<TValue> & {
|
|
@@ -6,6 +6,19 @@ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
|
6
6
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
7
7
|
import { useViews } from '../useViews';
|
|
8
8
|
import { isTimeView } from '../../utils/time-utils';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Props used to handle the views that are common to all pickers.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Props used to handle the views of the pickers.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Props used to handle the value of the pickers.
|
|
20
|
+
*/
|
|
21
|
+
|
|
9
22
|
/**
|
|
10
23
|
* Manage the views of all the pickers:
|
|
11
24
|
* - Handles the view switch
|
|
@@ -3,7 +3,7 @@ import { PickersLocaleText } from '../../locales/utils/pickersLocaleTextApi';
|
|
|
3
3
|
export declare const useLocalizationContext: <TDate>() => Omit<MuiPickersAdapterContextValue<TDate>, "localeText"> & {
|
|
4
4
|
localeText: PickersLocaleText<TDate>;
|
|
5
5
|
};
|
|
6
|
-
export declare const useUtils: <TDate>() => import("
|
|
6
|
+
export declare const useUtils: <TDate>() => import("../..").MuiPickersAdapter<TDate>;
|
|
7
7
|
export declare const useDefaultDates: <TDate>() => {
|
|
8
8
|
minDate: TDate;
|
|
9
9
|
maxDate: TDate;
|
package/internals/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export type { UseFieldInternalProps, UseFieldParams, UseFieldResponse, UseFieldF
|
|
|
27
27
|
export type { MobileOnlyPickerProps } from './hooks/useMobilePicker';
|
|
28
28
|
export { usePicker } from './hooks/usePicker';
|
|
29
29
|
export type { UsePickerResponse, UsePickerParams, UsePickerProps } from './hooks/usePicker';
|
|
30
|
-
export type { UsePickerValueNonStaticProps, PickerValueManager, PickerSelectionState, } from './hooks/usePicker/usePickerValue';
|
|
30
|
+
export type { UsePickerValueNonStaticProps, PickerValueManager, PickerSelectionState, } from './hooks/usePicker/usePickerValue.types';
|
|
31
31
|
export type { UsePickerViewsNonStaticProps, PickerViewRendererLookup, UsePickerViewsProps, } from './hooks/usePicker/usePickerViews';
|
|
32
32
|
export { useStaticPicker } from './hooks/useStaticPicker';
|
|
33
33
|
export type { StaticOnlyPickerProps, UseStaticPickerSlotsComponent, UseStaticPickerSlotsComponentsProps, } from './hooks/useStaticPicker';
|
|
@@ -43,7 +43,6 @@ export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-hel
|
|
|
43
43
|
export type { BaseFieldProps, FieldsTextFieldProps } from './models/fields';
|
|
44
44
|
export type { BasePickerProps, BasePickerInputProps, BaseNonStaticPickerProps, } from './models/props/basePickerProps';
|
|
45
45
|
export type { BaseToolbarProps, ExportedBaseToolbarProps } from './models/props/toolbar';
|
|
46
|
-
export type { MuiPickersAdapter } from './models/muiPickersAdapter';
|
|
47
46
|
export type { DefaultizedProps, MakeOptional } from './models/helpers';
|
|
48
47
|
export type { WrapperVariant } from './models/common';
|
|
49
48
|
export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual } from './utils/date-utils';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './fields';
|
|
2
|
-
export * from './muiPickersAdapter';
|
|
1
|
+
export * from './fields';
|
|
@@ -39,6 +39,12 @@ export interface BaseNonStaticPickerProps {
|
|
|
39
39
|
* Defaults to localized format based on the used `views`.
|
|
40
40
|
*/
|
|
41
41
|
format?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Density of the format when rendered in the input.
|
|
44
|
+
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
|
45
|
+
* @default "dense"
|
|
46
|
+
*/
|
|
47
|
+
formatDensity?: 'dense' | 'spacious';
|
|
42
48
|
}
|
|
43
49
|
/**
|
|
44
50
|
* Props common to all non-range non-static pickers.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { MuiPickersAdapter } from '
|
|
2
|
-
import { DateOrTimeView } from '../../models';
|
|
1
|
+
import { DateOrTimeView, MuiPickersAdapter } from '../../models';
|
|
3
2
|
export declare const isTimeView: (view: DateOrTimeView) => boolean;
|
|
4
3
|
type Meridiem = 'am' | 'pm' | null;
|
|
5
4
|
export declare const getMeridiem: <TDate>(date: TDate | null, utils: MuiPickersAdapter<TDate>) => Meridiem;
|
|
@@ -3,4 +3,4 @@ import { DateValidationError, TimeValidationError, DateTimeValidationError, Fiel
|
|
|
3
3
|
import type { FieldValueManager } from '../hooks/useField';
|
|
4
4
|
export type SingleItemPickerValueManager<TValue = any, TDate = any, TError extends DateValidationError | TimeValidationError | DateTimeValidationError = any> = PickerValueManager<TValue, TDate, TError>;
|
|
5
5
|
export declare const singleItemValueManager: SingleItemPickerValueManager;
|
|
6
|
-
export declare const singleItemFieldValueManager: FieldValueManager<any, any, FieldSection
|
|
6
|
+
export declare const singleItemFieldValueManager: FieldValueManager<any, any, FieldSection>;
|
|
@@ -6,6 +6,7 @@ export const singleItemValueManager = {
|
|
|
6
6
|
cleanValue: replaceInvalidDateByNull,
|
|
7
7
|
areValuesEqual: areDatesEqual,
|
|
8
8
|
isSameError: (a, b) => a === b,
|
|
9
|
+
hasError: error => error != null,
|
|
9
10
|
defaultErrorState: null
|
|
10
11
|
};
|
|
11
12
|
export const singleItemFieldValueManager = {
|
|
@@ -27,6 +28,5 @@ export const singleItemFieldValueManager = {
|
|
|
27
28
|
referenceValue: newActiveDate == null || !utils.isValid(newActiveDate) ? state.referenceValue : newActiveDate
|
|
28
29
|
})
|
|
29
30
|
}),
|
|
30
|
-
parseValueStr: (valueStr, referenceValue, parseDate) => parseDate(valueStr.trim(), referenceValue)
|
|
31
|
-
hasError: error => error != null
|
|
31
|
+
parseValueStr: (valueStr, referenceValue, parseDate) => parseDate(valueStr.trim(), referenceValue)
|
|
32
32
|
};
|