@mui/x-date-pickers 7.16.0 → 7.18.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/AdapterDateFns.js +1 -1
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -1
- package/AdapterDayjs/AdapterDayjs.js +1 -1
- package/CHANGELOG.md +184 -4
- package/DateCalendar/DateCalendar.js +11 -1
- package/DateCalendar/useCalendarState.js +2 -0
- package/DateCalendar/useIsDateDisabled.d.ts +4 -3
- package/DateCalendar/useIsDateDisabled.js +5 -3
- package/DateField/DateField.js +2 -0
- package/DateField/DateField.types.d.ts +7 -2
- package/DateField/index.d.ts +1 -1
- package/DateField/useDateField.d.ts +1 -1
- package/DateField/useDateField.js +5 -3
- package/DatePicker/DatePicker.js +8 -0
- package/DatePicker/DatePicker.types.d.ts +5 -5
- package/DatePicker/DatePickerToolbar.js +2 -0
- package/DateTimeField/DateTimeField.js +2 -0
- package/DateTimeField/DateTimeField.types.d.ts +7 -2
- package/DateTimeField/index.d.ts +1 -1
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimeField/useDateTimeField.js +5 -3
- package/DateTimePicker/DateTimePicker.js +8 -0
- package/DateTimePicker/DateTimePicker.types.d.ts +7 -6
- package/DateTimePicker/DateTimePickerTabs.js +2 -0
- package/DateTimePicker/DateTimePickerToolbar.js +2 -0
- package/DayCalendarSkeleton/DayCalendarSkeleton.js +2 -0
- package/DesktopDatePicker/DesktopDatePicker.js +16 -3
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +7 -6
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +16 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +11 -10
- package/DesktopTimePicker/DesktopTimePicker.js +10 -3
- package/DigitalClock/DigitalClock.js +2 -0
- package/LocalizationProvider/LocalizationProvider.js +2 -0
- package/MobileDatePicker/MobileDatePicker.js +16 -3
- package/MobileDatePicker/MobileDatePicker.types.d.ts +5 -0
- package/MobileDateTimePicker/MobileDateTimePicker.js +16 -3
- package/MobileTimePicker/MobileTimePicker.js +10 -3
- package/MonthCalendar/MonthCalendar.js +2 -0
- package/MonthCalendar/MonthCalendar.types.d.ts +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +2 -0
- package/PickersActionBar/PickersActionBar.js +2 -0
- package/PickersCalendarHeader/PickersCalendarHeader.js +2 -0
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +1 -1
- package/PickersDay/PickersDay.js +2 -0
- package/PickersLayout/PickersLayout.js +2 -0
- package/PickersLayout/usePickerLayout.js +2 -0
- package/PickersSectionList/PickersSectionList.js +2 -0
- package/PickersShortcuts/PickersShortcuts.js +2 -0
- package/PickersTextField/PickersTextField.js +2 -0
- package/StaticDatePicker/StaticDatePicker.js +10 -2
- package/StaticDatePicker/StaticDatePicker.types.d.ts +5 -0
- package/StaticDateTimePicker/StaticDateTimePicker.js +10 -2
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +5 -0
- package/StaticTimePicker/StaticTimePicker.js +3 -1
- package/TimeClock/Clock.js +1 -1
- package/TimeClock/TimeClock.js +2 -0
- package/TimeField/TimeField.js +2 -0
- package/TimeField/TimeField.types.d.ts +7 -2
- package/TimeField/index.d.ts +1 -1
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimeField/useTimeField.js +5 -3
- package/TimePicker/TimePicker.js +2 -0
- package/TimePicker/TimePickerToolbar.js +2 -0
- package/YearCalendar/YearCalendar.js +21 -6
- package/YearCalendar/YearCalendar.types.d.ts +7 -1
- package/dateViewRenderers/dateViewRenderers.d.ts +1 -1
- package/dateViewRenderers/dateViewRenderers.js +2 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/useClearableField.js +2 -0
- package/hooks/usePickersTranslations.js +2 -0
- package/hooks/useSplitFieldProps.d.ts +19 -0
- package/hooks/useSplitFieldProps.js +43 -0
- package/index.d.ts +1 -0
- package/index.js +3 -2
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +2 -2
- package/internals/hooks/useField/useField.js +11 -6
- package/internals/hooks/useField/useField.types.d.ts +4 -22
- package/internals/hooks/useField/useFieldState.js +2 -4
- package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/usePicker.d.ts +1 -2
- package/internals/hooks/usePicker/usePicker.js +1 -1
- package/internals/hooks/usePicker/usePickerValue.d.ts +1 -2
- package/internals/hooks/usePicker/usePickerValue.js +12 -16
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +4 -15
- package/internals/index.d.ts +0 -8
- package/internals/index.js +0 -7
- package/locales/beBY.d.ts +3 -3
- package/locales/beBY.js +4 -4
- package/locales/caES.d.ts +3 -3
- package/locales/caES.js +3 -3
- package/locales/csCZ.d.ts +3 -3
- package/locales/csCZ.js +4 -4
- package/locales/daDK.d.ts +3 -3
- package/locales/daDK.js +3 -3
- package/locales/deDE.d.ts +3 -3
- package/locales/deDE.js +3 -3
- package/locales/elGR.d.ts +3 -3
- package/locales/elGR.js +4 -4
- package/locales/enUS.d.ts +3 -3
- package/locales/enUS.js +4 -4
- package/locales/esES.d.ts +3 -3
- package/locales/esES.js +3 -3
- package/locales/eu.d.ts +3 -3
- package/locales/eu.js +3 -3
- package/locales/faIR.d.ts +3 -3
- package/locales/faIR.js +3 -3
- package/locales/fiFI.d.ts +3 -3
- package/locales/fiFI.js +3 -3
- package/locales/frFR.d.ts +3 -3
- package/locales/frFR.js +3 -3
- package/locales/heIL.d.ts +3 -3
- package/locales/heIL.js +3 -3
- package/locales/huHU.d.ts +3 -3
- package/locales/huHU.js +3 -3
- package/locales/isIS.d.ts +3 -3
- package/locales/isIS.js +4 -4
- package/locales/itIT.d.ts +3 -3
- package/locales/itIT.js +3 -3
- package/locales/jaJP.d.ts +3 -3
- package/locales/jaJP.js +3 -3
- package/locales/koKR.d.ts +3 -3
- package/locales/koKR.js +3 -3
- package/locales/kzKZ.d.ts +3 -3
- package/locales/kzKZ.js +4 -4
- package/locales/mk.d.ts +3 -3
- package/locales/mk.js +3 -3
- package/locales/nbNO.d.ts +3 -3
- package/locales/nbNO.js +4 -4
- package/locales/nlNL.d.ts +3 -3
- package/locales/nlNL.js +3 -3
- package/locales/nnNO.d.ts +3 -3
- package/locales/nnNO.js +3 -3
- package/locales/plPL.d.ts +3 -3
- package/locales/plPL.js +4 -4
- package/locales/ptBR.d.ts +3 -3
- package/locales/ptBR.js +4 -4
- package/locales/roRO.d.ts +3 -3
- package/locales/roRO.js +3 -3
- package/locales/ruRU.d.ts +3 -3
- package/locales/ruRU.js +3 -3
- package/locales/skSK.d.ts +3 -3
- package/locales/skSK.js +4 -4
- package/locales/svSE.d.ts +3 -3
- package/locales/svSE.js +3 -3
- package/locales/trTR.d.ts +3 -3
- package/locales/trTR.js +4 -4
- package/locales/ukUA.d.ts +3 -3
- package/locales/ukUA.js +3 -3
- package/locales/urPK.d.ts +3 -3
- package/locales/urPK.js +4 -4
- package/locales/utils/getPickersLocalization.d.ts +10 -3
- package/locales/utils/getPickersLocalization.js +13 -0
- package/locales/utils/pickersLocaleTextApi.d.ts +27 -3
- package/locales/viVN.d.ts +3 -3
- package/locales/viVN.js +3 -3
- package/locales/zhCN.d.ts +3 -3
- package/locales/zhCN.js +3 -3
- package/locales/zhHK.d.ts +3 -3
- package/locales/zhHK.js +3 -3
- package/models/validation.d.ts +13 -0
- package/modern/AdapterDateFns/AdapterDateFns.js +1 -1
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -1
- package/modern/AdapterDayjs/AdapterDayjs.js +1 -1
- package/modern/DateCalendar/DateCalendar.js +11 -1
- package/modern/DateCalendar/useCalendarState.js +2 -0
- package/modern/DateCalendar/useIsDateDisabled.js +5 -3
- package/modern/DateField/DateField.js +2 -0
- package/modern/DateField/useDateField.js +5 -3
- package/modern/DatePicker/DatePicker.js +8 -0
- package/modern/DatePicker/DatePickerToolbar.js +2 -0
- package/modern/DateTimeField/DateTimeField.js +2 -0
- package/modern/DateTimeField/useDateTimeField.js +5 -3
- package/modern/DateTimePicker/DateTimePicker.js +8 -0
- package/modern/DateTimePicker/DateTimePickerTabs.js +2 -0
- package/modern/DateTimePicker/DateTimePickerToolbar.js +2 -0
- package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +2 -0
- package/modern/DesktopDatePicker/DesktopDatePicker.js +16 -3
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +16 -3
- package/modern/DesktopTimePicker/DesktopTimePicker.js +10 -3
- package/modern/DigitalClock/DigitalClock.js +2 -0
- package/modern/LocalizationProvider/LocalizationProvider.js +2 -0
- package/modern/MobileDatePicker/MobileDatePicker.js +16 -3
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +16 -3
- package/modern/MobileTimePicker/MobileTimePicker.js +10 -3
- package/modern/MonthCalendar/MonthCalendar.js +2 -0
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +2 -0
- package/modern/PickersActionBar/PickersActionBar.js +2 -0
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +2 -0
- package/modern/PickersDay/PickersDay.js +2 -0
- package/modern/PickersLayout/PickersLayout.js +2 -0
- package/modern/PickersLayout/usePickerLayout.js +2 -0
- package/modern/PickersSectionList/PickersSectionList.js +2 -0
- package/modern/PickersShortcuts/PickersShortcuts.js +2 -0
- package/modern/PickersTextField/PickersTextField.js +2 -0
- package/modern/StaticDatePicker/StaticDatePicker.js +10 -2
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +10 -2
- package/modern/StaticTimePicker/StaticTimePicker.js +3 -1
- package/modern/TimeClock/Clock.js +1 -1
- package/modern/TimeClock/TimeClock.js +2 -0
- package/modern/TimeField/TimeField.js +2 -0
- package/modern/TimeField/useTimeField.js +5 -3
- package/modern/TimePicker/TimePicker.js +2 -0
- package/modern/TimePicker/TimePickerToolbar.js +2 -0
- package/modern/YearCalendar/YearCalendar.js +21 -6
- package/modern/dateViewRenderers/dateViewRenderers.js +2 -0
- package/modern/hooks/index.js +2 -1
- package/modern/hooks/useClearableField.js +2 -0
- package/modern/hooks/usePickersTranslations.js +2 -0
- package/modern/hooks/useSplitFieldProps.js +43 -0
- package/modern/index.js +3 -2
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
- package/modern/internals/hooks/useField/useField.js +11 -6
- package/modern/internals/hooks/useField/useFieldState.js +2 -4
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
- package/modern/internals/hooks/usePicker/usePicker.js +1 -1
- package/modern/internals/hooks/usePicker/usePickerValue.js +12 -16
- package/modern/internals/index.js +0 -7
- package/modern/locales/beBY.js +4 -4
- package/modern/locales/caES.js +3 -3
- package/modern/locales/csCZ.js +4 -4
- package/modern/locales/daDK.js +3 -3
- package/modern/locales/deDE.js +3 -3
- package/modern/locales/elGR.js +4 -4
- package/modern/locales/enUS.js +4 -4
- package/modern/locales/esES.js +3 -3
- package/modern/locales/eu.js +3 -3
- package/modern/locales/faIR.js +3 -3
- package/modern/locales/fiFI.js +3 -3
- package/modern/locales/frFR.js +3 -3
- package/modern/locales/heIL.js +3 -3
- package/modern/locales/huHU.js +3 -3
- package/modern/locales/isIS.js +4 -4
- package/modern/locales/itIT.js +3 -3
- package/modern/locales/jaJP.js +3 -3
- package/modern/locales/koKR.js +3 -3
- package/modern/locales/kzKZ.js +4 -4
- package/modern/locales/mk.js +3 -3
- package/modern/locales/nbNO.js +4 -4
- package/modern/locales/nlNL.js +3 -3
- package/modern/locales/nnNO.js +3 -3
- package/modern/locales/plPL.js +4 -4
- package/modern/locales/ptBR.js +4 -4
- package/modern/locales/roRO.js +3 -3
- package/modern/locales/ruRU.js +3 -3
- package/modern/locales/skSK.js +4 -4
- package/modern/locales/svSE.js +3 -3
- package/modern/locales/trTR.js +4 -4
- package/modern/locales/ukUA.js +3 -3
- package/modern/locales/urPK.js +4 -4
- package/modern/locales/utils/getPickersLocalization.js +13 -0
- package/modern/locales/viVN.js +3 -3
- package/modern/locales/zhCN.js +3 -3
- package/modern/locales/zhHK.js +3 -3
- package/modern/validation/index.js +5 -0
- package/modern/validation/useValidation.js +54 -0
- package/{internals/utils → modern}/validation/validateDate.js +6 -4
- package/modern/{internals/utils/validation → validation}/validateDateTime.js +8 -3
- package/{internals/utils → modern}/validation/validateTime.js +6 -4
- package/node/AdapterDateFns/AdapterDateFns.js +1 -1
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +1 -1
- package/node/AdapterDayjs/AdapterDayjs.js +1 -1
- package/node/DateCalendar/DateCalendar.js +10 -1
- package/node/DateCalendar/useCalendarState.js +1 -0
- package/node/DateCalendar/useIsDateDisabled.js +5 -4
- package/node/DateField/DateField.js +1 -0
- package/node/DateField/useDateField.js +5 -4
- package/node/DatePicker/DatePicker.js +7 -0
- package/node/DatePicker/DatePickerToolbar.js +1 -0
- package/node/DateTimeField/DateTimeField.js +1 -0
- package/node/DateTimeField/useDateTimeField.js +5 -4
- package/node/DateTimePicker/DateTimePicker.js +7 -0
- package/node/DateTimePicker/DateTimePickerTabs.js +1 -0
- package/node/DateTimePicker/DateTimePickerToolbar.js +1 -0
- package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +1 -0
- package/node/DesktopDatePicker/DesktopDatePicker.js +17 -5
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +17 -5
- package/node/DesktopTimePicker/DesktopTimePicker.js +11 -5
- package/node/DigitalClock/DigitalClock.js +1 -0
- package/node/LocalizationProvider/LocalizationProvider.js +1 -0
- package/node/MobileDatePicker/MobileDatePicker.js +17 -5
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +17 -5
- package/node/MobileTimePicker/MobileTimePicker.js +11 -5
- package/node/MonthCalendar/MonthCalendar.js +1 -0
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/node/PickersActionBar/PickersActionBar.js +1 -0
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +1 -0
- package/node/PickersDay/PickersDay.js +1 -0
- package/node/PickersLayout/PickersLayout.js +1 -0
- package/node/PickersLayout/usePickerLayout.js +1 -0
- package/node/PickersSectionList/PickersSectionList.js +1 -0
- package/node/PickersShortcuts/PickersShortcuts.js +1 -0
- package/node/PickersTextField/PickersTextField.js +1 -0
- package/node/StaticDatePicker/StaticDatePicker.js +10 -3
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +10 -3
- package/node/StaticTimePicker/StaticTimePicker.js +3 -2
- package/node/TimeClock/Clock.js +1 -1
- package/node/TimeClock/TimeClock.js +1 -0
- package/node/TimeField/TimeField.js +1 -0
- package/node/TimeField/useTimeField.js +5 -4
- package/node/TimePicker/TimePicker.js +1 -0
- package/node/TimePicker/TimePickerToolbar.js +1 -0
- package/node/YearCalendar/YearCalendar.js +20 -6
- package/node/dateViewRenderers/dateViewRenderers.js +2 -0
- package/node/hooks/index.js +8 -1
- package/node/hooks/useClearableField.js +1 -0
- package/node/hooks/usePickersTranslations.js +1 -0
- package/node/hooks/useSplitFieldProps.js +51 -0
- package/node/index.js +13 -1
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -3
- package/node/internals/hooks/useField/useField.js +11 -6
- package/node/internals/hooks/useField/useFieldState.js +2 -4
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -3
- package/node/internals/hooks/usePicker/usePicker.js +1 -1
- package/node/internals/hooks/usePicker/usePickerValue.js +12 -16
- package/node/internals/index.js +0 -49
- package/node/locales/beBY.js +4 -4
- package/node/locales/caES.js +3 -3
- package/node/locales/csCZ.js +4 -4
- package/node/locales/daDK.js +3 -3
- package/node/locales/deDE.js +3 -3
- package/node/locales/elGR.js +4 -4
- package/node/locales/enUS.js +4 -4
- package/node/locales/esES.js +3 -3
- package/node/locales/eu.js +3 -3
- package/node/locales/faIR.js +3 -3
- package/node/locales/fiFI.js +3 -3
- package/node/locales/frFR.js +3 -3
- package/node/locales/heIL.js +3 -3
- package/node/locales/huHU.js +3 -3
- package/node/locales/isIS.js +4 -4
- package/node/locales/itIT.js +3 -3
- package/node/locales/jaJP.js +3 -3
- package/node/locales/koKR.js +3 -3
- package/node/locales/kzKZ.js +4 -4
- package/node/locales/mk.js +3 -3
- package/node/locales/nbNO.js +4 -4
- package/node/locales/nlNL.js +3 -3
- package/node/locales/nnNO.js +3 -3
- package/node/locales/plPL.js +4 -4
- package/node/locales/ptBR.js +4 -4
- package/node/locales/roRO.js +3 -3
- package/node/locales/ruRU.js +3 -3
- package/node/locales/skSK.js +4 -4
- package/node/locales/svSE.js +3 -3
- package/node/locales/trTR.js +4 -4
- package/node/locales/ukUA.js +3 -3
- package/node/locales/urPK.js +4 -4
- package/node/locales/utils/getPickersLocalization.js +16 -2
- package/node/locales/viVN.js +3 -3
- package/node/locales/zhCN.js +3 -3
- package/node/locales/zhHK.js +3 -3
- package/node/validation/index.js +40 -0
- package/node/validation/useValidation.js +61 -0
- package/node/{internals/utils/validation → validation}/validateDate.js +6 -4
- package/node/{internals/utils/validation → validation}/validateDateTime.js +8 -3
- package/node/{internals/utils/validation → validation}/validateTime.js +6 -4
- package/package.json +4 -4
- package/{internals/utils/validation → validation}/extractValidationProps.d.ts +1 -1
- package/validation/index.d.ts +9 -0
- package/validation/index.js +5 -0
- package/validation/package.json +6 -0
- package/validation/useValidation.d.ts +68 -0
- package/validation/useValidation.js +54 -0
- package/validation/validateDate.d.ts +6 -0
- package/{modern/internals/utils/validation → validation}/validateDate.js +6 -4
- package/validation/validateDateTime.d.ts +7 -0
- package/{internals/utils/validation → validation}/validateDateTime.js +8 -3
- package/validation/validateTime.d.ts +6 -0
- package/{modern/internals/utils/validation → validation}/validateTime.js +6 -4
- package/internals/hooks/useValidation.d.ts +0 -24
- package/internals/hooks/useValidation.js +0 -22
- package/internals/utils/fields.d.ts +0 -5
- package/internals/utils/fields.js +0 -28
- package/internals/utils/validation/validateDate.d.ts +0 -7
- package/internals/utils/validation/validateDateTime.d.ts +0 -7
- package/internals/utils/validation/validateTime.d.ts +0 -7
- package/internals/utils/warning.d.ts +0 -2
- package/internals/utils/warning.js +0 -21
- package/modern/internals/hooks/useValidation.js +0 -22
- package/modern/internals/utils/fields.js +0 -28
- package/modern/internals/utils/warning.js +0 -21
- package/node/internals/hooks/useValidation.js +0 -29
- package/node/internals/utils/fields.js +0 -36
- package/node/internals/utils/warning.js +0 -28
- /package/{internals/utils → modern}/validation/extractValidationProps.js +0 -0
- /package/node/{internals/utils/validation → validation}/extractValidationProps.js +0 -0
- /package/{modern/internals/utils/validation → validation}/extractValidationProps.js +0 -0
|
@@ -6,14 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.validateDateTime = void 0;
|
|
7
7
|
var _validateDate = require("./validateDate");
|
|
8
8
|
var _validateTime = require("./validateTime");
|
|
9
|
+
var _valueManagers = require("../internals/utils/valueManagers");
|
|
9
10
|
const validateDateTime = ({
|
|
10
|
-
|
|
11
|
+
adapter,
|
|
11
12
|
value,
|
|
12
|
-
|
|
13
|
+
timezone,
|
|
14
|
+
props
|
|
13
15
|
}) => {
|
|
14
16
|
const dateValidationResult = (0, _validateDate.validateDate)({
|
|
15
17
|
adapter,
|
|
16
18
|
value,
|
|
19
|
+
timezone,
|
|
17
20
|
props
|
|
18
21
|
});
|
|
19
22
|
if (dateValidationResult !== null) {
|
|
@@ -22,7 +25,9 @@ const validateDateTime = ({
|
|
|
22
25
|
return (0, _validateTime.validateTime)({
|
|
23
26
|
adapter,
|
|
24
27
|
value,
|
|
28
|
+
timezone,
|
|
25
29
|
props
|
|
26
30
|
});
|
|
27
31
|
};
|
|
28
|
-
exports.validateDateTime = validateDateTime;
|
|
32
|
+
exports.validateDateTime = validateDateTime;
|
|
33
|
+
validateDateTime.valueManager = _valueManagers.singleItemValueManager;
|
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.validateTime = void 0;
|
|
7
|
-
var _timeUtils = require("../time-utils");
|
|
7
|
+
var _timeUtils = require("../internals/utils/time-utils");
|
|
8
|
+
var _valueManagers = require("../internals/utils/valueManagers");
|
|
8
9
|
const validateTime = ({
|
|
9
10
|
adapter,
|
|
10
11
|
value,
|
|
12
|
+
timezone,
|
|
11
13
|
props
|
|
12
14
|
}) => {
|
|
13
15
|
if (value === null) {
|
|
@@ -20,8 +22,7 @@ const validateTime = ({
|
|
|
20
22
|
shouldDisableTime,
|
|
21
23
|
disableIgnoringDatePartForTimeValidation = false,
|
|
22
24
|
disablePast,
|
|
23
|
-
disableFuture
|
|
24
|
-
timezone
|
|
25
|
+
disableFuture
|
|
25
26
|
} = props;
|
|
26
27
|
const now = adapter.utils.date(undefined, timezone);
|
|
27
28
|
const isAfter = (0, _timeUtils.createIsAfterIgnoreDatePart)(disableIgnoringDatePartForTimeValidation, adapter.utils);
|
|
@@ -48,4 +49,5 @@ const validateTime = ({
|
|
|
48
49
|
return null;
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
|
-
exports.validateTime = validateTime;
|
|
52
|
+
exports.validateTime = validateTime;
|
|
53
|
+
validateTime.valueManager = _valueManagers.singleItemValueManager;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-date-pickers",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.18.0",
|
|
4
4
|
"description": "The community edition of the Date and Time Picker components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
],
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
34
|
-
"url": "https://github.com/mui/mui-x.git",
|
|
34
|
+
"url": "git+https://github.com/mui/mui-x.git",
|
|
35
35
|
"directory": "packages/x-date-pickers"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"clsx": "^2.1.1",
|
|
42
42
|
"prop-types": "^15.8.1",
|
|
43
43
|
"react-transition-group": "^4.4.5",
|
|
44
|
-
"@mui/x-internals": "7.
|
|
44
|
+
"@mui/x-internals": "7.18.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@emotion/react": "^11.9.0",
|
|
48
48
|
"@emotion/styled": "^11.8.1",
|
|
49
49
|
"@mui/material": "^5.15.14 || ^6.0.0",
|
|
50
50
|
"@mui/system": "^5.15.14 || ^6.0.0",
|
|
51
|
-
"date-fns": "^2.25.0 || ^3.2.0",
|
|
51
|
+
"date-fns": "^2.25.0 || ^3.2.0 || ^4.0.0",
|
|
52
52
|
"date-fns-jalali": "^2.13.0-0 || ^3.2.0-0",
|
|
53
53
|
"dayjs": "^1.10.7",
|
|
54
54
|
"luxon": "^3.0.2",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseDateValidationProps, BaseTimeValidationProps, DateTimeValidationProps, DayValidationProps, MonthValidationProps, TimeValidationProps, YearValidationProps } from '
|
|
1
|
+
import { BaseDateValidationProps, BaseTimeValidationProps, DateTimeValidationProps, DayValidationProps, MonthValidationProps, TimeValidationProps, YearValidationProps } from '../internals/models/validation';
|
|
2
2
|
export declare const DATE_VALIDATION_PROP_NAMES: (keyof BaseDateValidationProps<any> | keyof YearValidationProps<any> | keyof MonthValidationProps<any> | keyof DayValidationProps<any>)[];
|
|
3
3
|
export declare const TIME_VALIDATION_PROP_NAMES: (keyof BaseTimeValidationProps | keyof TimeValidationProps<any> | 'ampm')[];
|
|
4
4
|
export declare const DATE_TIME_VALIDATION_PROP_NAMES: (keyof DateTimeValidationProps<any>)[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { validateDate } from './validateDate';
|
|
2
|
+
export type { ValidateDateProps } from './validateDate';
|
|
3
|
+
export { validateTime } from './validateTime';
|
|
4
|
+
export type { ValidateTimeProps } from './validateTime';
|
|
5
|
+
export { validateDateTime } from './validateDateTime';
|
|
6
|
+
export type { ValidateDateTimeProps } from './validateDateTime';
|
|
7
|
+
export { extractValidationProps } from './extractValidationProps';
|
|
8
|
+
export { useValidation } from './useValidation';
|
|
9
|
+
export type { Validator } from './useValidation';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { validateDate } from "./validateDate.js";
|
|
2
|
+
export { validateTime } from "./validateTime.js";
|
|
3
|
+
export { validateDateTime } from "./validateDateTime.js";
|
|
4
|
+
export { extractValidationProps } from "./extractValidationProps.js";
|
|
5
|
+
export { useValidation } from "./useValidation.js";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { MuiPickersAdapterContextValue } from '../LocalizationProvider/LocalizationProvider';
|
|
2
|
+
import { OnErrorProps, PickersTimezone, PickerValidDate } from '../models';
|
|
3
|
+
import type { PickerValueManager } from '../internals/hooks/usePicker';
|
|
4
|
+
export type Validator<TValue, TDate extends PickerValidDate, TError, TValidationProps> = {
|
|
5
|
+
(params: {
|
|
6
|
+
adapter: MuiPickersAdapterContextValue<TDate>;
|
|
7
|
+
value: TValue;
|
|
8
|
+
timezone: PickersTimezone;
|
|
9
|
+
props: TValidationProps;
|
|
10
|
+
}): TError;
|
|
11
|
+
valueManager: PickerValueManager<TValue, TDate, any>;
|
|
12
|
+
};
|
|
13
|
+
interface UseValidationOptions<TValue, TDate extends PickerValidDate, TError, TValidationProps extends {}> extends OnErrorProps<TValue, TError> {
|
|
14
|
+
/**
|
|
15
|
+
* The value to validate.
|
|
16
|
+
*/
|
|
17
|
+
value: TValue;
|
|
18
|
+
/**
|
|
19
|
+
* The timezone to use for the validation.
|
|
20
|
+
*/
|
|
21
|
+
timezone: PickersTimezone;
|
|
22
|
+
/**
|
|
23
|
+
* The validator function to use.
|
|
24
|
+
* They can be imported from `@mui/x-date-pickers/validation` and `@mui/x-date-pickers-pro/validation`.
|
|
25
|
+
* It is recommended to only use the validator exported by the MUI X packages,
|
|
26
|
+
* otherwise you may have inconsistent behaviors between the field and the views.
|
|
27
|
+
*/
|
|
28
|
+
validator: Validator<TValue, TDate, TError, TValidationProps>;
|
|
29
|
+
/**
|
|
30
|
+
* The validation props, they differ depending on the component.
|
|
31
|
+
* For example, the `validateTime` function supports `minTime`, `maxTime`, etc.
|
|
32
|
+
*/
|
|
33
|
+
props: TValidationProps;
|
|
34
|
+
}
|
|
35
|
+
interface UseValidationReturnValue<TValue, TError> {
|
|
36
|
+
/**
|
|
37
|
+
* The validation error associated to the value passed to the `useValidation` hook.
|
|
38
|
+
*/
|
|
39
|
+
validationError: TError;
|
|
40
|
+
/**
|
|
41
|
+
* `true` if the current error is not null.
|
|
42
|
+
* For single value components, it means that the value is invalid.
|
|
43
|
+
* For range components, it means that either start or end value is invalid.
|
|
44
|
+
*/
|
|
45
|
+
hasValidationError: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Get the validation error for a new value.
|
|
48
|
+
* This can be used to validate the value in a change handler before updating the state.
|
|
49
|
+
* @template TValue The value type.
|
|
50
|
+
* @param {TValue} newValue The value to validate.
|
|
51
|
+
* @returns {TError} The validation error associated to the new value.
|
|
52
|
+
*/
|
|
53
|
+
getValidationErrorForNewValue: (newValue: TValue) => TError;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Utility hook to check if a given value is valid based on the provided validation props.
|
|
57
|
+
* @template TDate
|
|
58
|
+
* @template TValue The value type. It will be either the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
59
|
+
* @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
|
|
60
|
+
* @param {UseValidationOptions<TValue, TDate, TError, TValidationProps>} options The options to configure the hook.
|
|
61
|
+
* @param {TValue} options.value The value to validate.
|
|
62
|
+
* @param {PickersTimezone} options.timezone The timezone to use for the validation.
|
|
63
|
+
* @param {Validator<TValue, TDate, TError, TValidationProps>} options.validator The validator function to use.
|
|
64
|
+
* @param {TValidationProps} options.props The validation props, they differ depending on the component.
|
|
65
|
+
* @param {(error: TError, value: TValue) => void} options.onError Callback fired when the error associated with the current value changes.
|
|
66
|
+
*/
|
|
67
|
+
export declare function useValidation<TValue, TDate extends PickerValidDate, TError, TValidationProps extends {}>(options: UseValidationOptions<TValue, TDate, TError, TValidationProps>): UseValidationReturnValue<TValue, TError>;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
|
+
import { useLocalizationContext } from "../internals/hooks/useUtils.js";
|
|
6
|
+
/**
|
|
7
|
+
* Utility hook to check if a given value is valid based on the provided validation props.
|
|
8
|
+
* @template TDate
|
|
9
|
+
* @template TValue The value type. It will be either the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
10
|
+
* @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
|
|
11
|
+
* @param {UseValidationOptions<TValue, TDate, TError, TValidationProps>} options The options to configure the hook.
|
|
12
|
+
* @param {TValue} options.value The value to validate.
|
|
13
|
+
* @param {PickersTimezone} options.timezone The timezone to use for the validation.
|
|
14
|
+
* @param {Validator<TValue, TDate, TError, TValidationProps>} options.validator The validator function to use.
|
|
15
|
+
* @param {TValidationProps} options.props The validation props, they differ depending on the component.
|
|
16
|
+
* @param {(error: TError, value: TValue) => void} options.onError Callback fired when the error associated with the current value changes.
|
|
17
|
+
*/
|
|
18
|
+
export function useValidation(options) {
|
|
19
|
+
const {
|
|
20
|
+
props,
|
|
21
|
+
validator,
|
|
22
|
+
value,
|
|
23
|
+
timezone,
|
|
24
|
+
onError
|
|
25
|
+
} = options;
|
|
26
|
+
const adapter = useLocalizationContext();
|
|
27
|
+
const previousValidationErrorRef = React.useRef(validator.valueManager.defaultErrorState);
|
|
28
|
+
const validationError = validator({
|
|
29
|
+
adapter,
|
|
30
|
+
value,
|
|
31
|
+
timezone,
|
|
32
|
+
props
|
|
33
|
+
});
|
|
34
|
+
const hasValidationError = validator.valueManager.hasError(validationError);
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (onError && !validator.valueManager.isSameError(validationError, previousValidationErrorRef.current)) {
|
|
37
|
+
onError(validationError, value);
|
|
38
|
+
}
|
|
39
|
+
previousValidationErrorRef.current = validationError;
|
|
40
|
+
}, [validator, onError, validationError, value]);
|
|
41
|
+
const getValidationErrorForNewValue = useEventCallback(newValue => {
|
|
42
|
+
return validator({
|
|
43
|
+
adapter,
|
|
44
|
+
value: newValue,
|
|
45
|
+
timezone,
|
|
46
|
+
props
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
validationError,
|
|
51
|
+
hasValidationError,
|
|
52
|
+
getValidationErrorForNewValue
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Validator } from './useValidation';
|
|
2
|
+
import { BaseDateValidationProps, DayValidationProps, MonthValidationProps, YearValidationProps } from '../internals/models/validation';
|
|
3
|
+
import { DateValidationError, PickerValidDate } from '../models';
|
|
4
|
+
export interface ValidateDateProps<TDate extends PickerValidDate> extends DayValidationProps<TDate>, MonthValidationProps<TDate>, YearValidationProps<TDate>, Required<BaseDateValidationProps<TDate>> {
|
|
5
|
+
}
|
|
6
|
+
export declare const validateDate: Validator<any | null, any, DateValidationError, ValidateDateProps<any>>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { applyDefaultDate } from "../date-utils.js";
|
|
1
|
+
import { applyDefaultDate } from "../internals/utils/date-utils.js";
|
|
2
|
+
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
2
3
|
export const validateDate = ({
|
|
3
4
|
props,
|
|
4
5
|
value,
|
|
6
|
+
timezone,
|
|
5
7
|
adapter
|
|
6
8
|
}) => {
|
|
7
9
|
if (value === null) {
|
|
@@ -12,8 +14,7 @@ export const validateDate = ({
|
|
|
12
14
|
shouldDisableMonth,
|
|
13
15
|
shouldDisableYear,
|
|
14
16
|
disablePast,
|
|
15
|
-
disableFuture
|
|
16
|
-
timezone
|
|
17
|
+
disableFuture
|
|
17
18
|
} = props;
|
|
18
19
|
const now = adapter.utils.date(undefined, timezone);
|
|
19
20
|
const minDate = applyDefaultDate(adapter.utils, props.minDate, adapter.defaultDates.minDate);
|
|
@@ -38,4 +39,5 @@ export const validateDate = ({
|
|
|
38
39
|
default:
|
|
39
40
|
return null;
|
|
40
41
|
}
|
|
41
|
-
};
|
|
42
|
+
};
|
|
43
|
+
validateDate.valueManager = singleItemValueManager;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Validator } from './useValidation';
|
|
2
|
+
import { ValidateDateProps } from './validateDate';
|
|
3
|
+
import { ValidateTimeProps } from './validateTime';
|
|
4
|
+
import { DateTimeValidationError, PickerValidDate } from '../models';
|
|
5
|
+
export interface ValidateDateTimeProps<TDate extends PickerValidDate> extends ValidateDateProps<TDate>, ValidateTimeProps<TDate> {
|
|
6
|
+
}
|
|
7
|
+
export declare const validateDateTime: Validator<any | null, any, DateTimeValidationError, ValidateDateTimeProps<any>>;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { validateDate } from "./validateDate.js";
|
|
2
2
|
import { validateTime } from "./validateTime.js";
|
|
3
|
+
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
3
4
|
export const validateDateTime = ({
|
|
4
|
-
|
|
5
|
+
adapter,
|
|
5
6
|
value,
|
|
6
|
-
|
|
7
|
+
timezone,
|
|
8
|
+
props
|
|
7
9
|
}) => {
|
|
8
10
|
const dateValidationResult = validateDate({
|
|
9
11
|
adapter,
|
|
10
12
|
value,
|
|
13
|
+
timezone,
|
|
11
14
|
props
|
|
12
15
|
});
|
|
13
16
|
if (dateValidationResult !== null) {
|
|
@@ -16,6 +19,8 @@ export const validateDateTime = ({
|
|
|
16
19
|
return validateTime({
|
|
17
20
|
adapter,
|
|
18
21
|
value,
|
|
22
|
+
timezone,
|
|
19
23
|
props
|
|
20
24
|
});
|
|
21
|
-
};
|
|
25
|
+
};
|
|
26
|
+
validateDateTime.valueManager = singleItemValueManager;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Validator } from './useValidation';
|
|
2
|
+
import { BaseTimeValidationProps, TimeValidationProps } from '../internals/models/validation';
|
|
3
|
+
import { PickerValidDate, TimeValidationError } from '../models';
|
|
4
|
+
export interface ValidateTimeProps<TDate extends PickerValidDate> extends Required<BaseTimeValidationProps>, TimeValidationProps<TDate> {
|
|
5
|
+
}
|
|
6
|
+
export declare const validateTime: Validator<any | null, any, TimeValidationError, ValidateTimeProps<any>>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { createIsAfterIgnoreDatePart } from "../time-utils.js";
|
|
1
|
+
import { createIsAfterIgnoreDatePart } from "../internals/utils/time-utils.js";
|
|
2
|
+
import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
2
3
|
export const validateTime = ({
|
|
3
4
|
adapter,
|
|
4
5
|
value,
|
|
6
|
+
timezone,
|
|
5
7
|
props
|
|
6
8
|
}) => {
|
|
7
9
|
if (value === null) {
|
|
@@ -14,8 +16,7 @@ export const validateTime = ({
|
|
|
14
16
|
shouldDisableTime,
|
|
15
17
|
disableIgnoringDatePartForTimeValidation = false,
|
|
16
18
|
disablePast,
|
|
17
|
-
disableFuture
|
|
18
|
-
timezone
|
|
19
|
+
disableFuture
|
|
19
20
|
} = props;
|
|
20
21
|
const now = adapter.utils.date(undefined, timezone);
|
|
21
22
|
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, adapter.utils);
|
|
@@ -41,4 +42,5 @@ export const validateTime = ({
|
|
|
41
42
|
default:
|
|
42
43
|
return null;
|
|
43
44
|
}
|
|
44
|
-
};
|
|
45
|
+
};
|
|
46
|
+
validateTime.valueManager = singleItemValueManager;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MuiPickersAdapterContextValue } from '../../LocalizationProvider/LocalizationProvider';
|
|
2
|
-
import { PickerValidDate } from '../../models';
|
|
3
|
-
interface ValidationCommonProps<TError, TValue> {
|
|
4
|
-
/**
|
|
5
|
-
* Callback fired when the error associated with the current value changes.
|
|
6
|
-
* When a validation error is detected, the `error` parameter contains a non-null value.
|
|
7
|
-
* This can be used to render an appropriate form error.
|
|
8
|
-
* @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
|
|
9
|
-
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
10
|
-
* @param {TError} error The reason why the current value is not valid.
|
|
11
|
-
* @param {TValue} value The value associated with the error.
|
|
12
|
-
*/
|
|
13
|
-
onError?: (error: TError, value: TValue) => void;
|
|
14
|
-
value: TValue;
|
|
15
|
-
}
|
|
16
|
-
export type ValidationProps<TError, TValue, TValidationProps extends {}> = ValidationCommonProps<TError, TValue> & TValidationProps;
|
|
17
|
-
export type InferError<TProps> = TProps extends Pick<ValidationCommonProps<any, any>, 'onError'> ? Parameters<Exclude<TProps['onError'], undefined>>[0] : never;
|
|
18
|
-
export type Validator<TValue, TDate extends PickerValidDate, TError, TValidationProps> = (params: {
|
|
19
|
-
adapter: MuiPickersAdapterContextValue<TDate>;
|
|
20
|
-
value: TValue;
|
|
21
|
-
props: Omit<TValidationProps, 'value' | 'onError'>;
|
|
22
|
-
}) => TError;
|
|
23
|
-
export declare function useValidation<TValue, TDate extends PickerValidDate, TError, TValidationProps extends {}>(props: ValidationProps<TError, TValue, TValidationProps>, validate: Validator<TValue, TDate, TError, TValidationProps>, isSameError: (a: TError, b: TError | null) => boolean, defaultErrorState: TError): TError;
|
|
24
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useLocalizationContext } from "./useUtils.js";
|
|
3
|
-
export function useValidation(props, validate, isSameError, defaultErrorState) {
|
|
4
|
-
const {
|
|
5
|
-
value,
|
|
6
|
-
onError
|
|
7
|
-
} = props;
|
|
8
|
-
const adapter = useLocalizationContext();
|
|
9
|
-
const previousValidationErrorRef = React.useRef(defaultErrorState);
|
|
10
|
-
const validationError = validate({
|
|
11
|
-
adapter,
|
|
12
|
-
value,
|
|
13
|
-
props
|
|
14
|
-
});
|
|
15
|
-
React.useEffect(() => {
|
|
16
|
-
if (onError && !isSameError(validationError, previousValidationErrorRef.current)) {
|
|
17
|
-
onError(validationError, value);
|
|
18
|
-
}
|
|
19
|
-
previousValidationErrorRef.current = validationError;
|
|
20
|
-
}, [isSameError, onError, previousValidationErrorRef, validationError, value]);
|
|
21
|
-
return validationError;
|
|
22
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { FieldValueType } from '../../models';
|
|
2
|
-
export declare const splitFieldInternalAndForwardedProps: <TProps extends {}, TInternalPropNames extends keyof TProps>(props: TProps, valueType: FieldValueType) => {
|
|
3
|
-
forwardedProps: Omit<TProps, TInternalPropNames>;
|
|
4
|
-
internalProps: Pick<TProps, TInternalPropNames>;
|
|
5
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from "./validation/extractValidationProps.js";
|
|
3
|
-
const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly', 'dateSeparator'];
|
|
4
|
-
export const splitFieldInternalAndForwardedProps = (props, valueType) => {
|
|
5
|
-
const forwardedProps = _extends({}, props);
|
|
6
|
-
const internalProps = {};
|
|
7
|
-
const extractProp = propName => {
|
|
8
|
-
if (forwardedProps.hasOwnProperty(propName)) {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
internalProps[propName] = forwardedProps[propName];
|
|
11
|
-
delete forwardedProps[propName];
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
SHARED_FIELD_INTERNAL_PROP_NAMES.forEach(extractProp);
|
|
15
|
-
if (valueType === 'date') {
|
|
16
|
-
DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
17
|
-
} else if (valueType === 'time') {
|
|
18
|
-
TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
19
|
-
} else if (valueType === 'date-time') {
|
|
20
|
-
DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
21
|
-
TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
22
|
-
DATE_TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
forwardedProps,
|
|
26
|
-
internalProps
|
|
27
|
-
};
|
|
28
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Validator } from '../../hooks/useValidation';
|
|
2
|
-
import { BaseDateValidationProps, DayValidationProps, MonthValidationProps, YearValidationProps } from '../../models/validation';
|
|
3
|
-
import { DateValidationError, PickerValidDate, TimezoneProps } from '../../../models';
|
|
4
|
-
import { DefaultizedProps } from '../../models/helpers';
|
|
5
|
-
export interface DateComponentValidationProps<TDate extends PickerValidDate> extends DayValidationProps<TDate>, MonthValidationProps<TDate>, YearValidationProps<TDate>, Required<BaseDateValidationProps<TDate>>, DefaultizedProps<TimezoneProps, 'timezone'> {
|
|
6
|
-
}
|
|
7
|
-
export declare const validateDate: Validator<any | null, any, DateValidationError, DateComponentValidationProps<any>>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Validator } from '../../hooks/useValidation';
|
|
2
|
-
import { DateComponentValidationProps } from './validateDate';
|
|
3
|
-
import { TimeComponentValidationProps } from './validateTime';
|
|
4
|
-
import { DateTimeValidationError, PickerValidDate } from '../../../models';
|
|
5
|
-
export interface DateTimeComponentValidationProps<TDate extends PickerValidDate> extends DateComponentValidationProps<TDate>, TimeComponentValidationProps<TDate> {
|
|
6
|
-
}
|
|
7
|
-
export declare const validateDateTime: Validator<any | null, any, DateTimeValidationError, DateTimeComponentValidationProps<any>>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Validator } from '../../hooks/useValidation';
|
|
2
|
-
import { BaseTimeValidationProps, TimeValidationProps } from '../../models/validation';
|
|
3
|
-
import { PickerValidDate, TimeValidationError, TimezoneProps } from '../../../models';
|
|
4
|
-
import { DefaultizedProps } from '../../models/helpers';
|
|
5
|
-
export interface TimeComponentValidationProps<TDate extends PickerValidDate> extends Required<BaseTimeValidationProps>, TimeValidationProps<TDate>, DefaultizedProps<TimezoneProps, 'timezone'> {
|
|
6
|
-
}
|
|
7
|
-
export declare const validateTime: Validator<any | null, any, TimeValidationError, TimeComponentValidationProps<any>>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const warnedOnceCache = new Set();
|
|
2
|
-
|
|
3
|
-
// TODO move to @mui/x-internals
|
|
4
|
-
// TODO eventually move to @base_ui/internals. Base UI, etc. too need this helper.
|
|
5
|
-
export function warnOnce(message, gravity = 'warning') {
|
|
6
|
-
if (process.env.NODE_ENV === 'production') {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
|
|
10
|
-
if (!warnedOnceCache.has(cleanMessage)) {
|
|
11
|
-
warnedOnceCache.add(cleanMessage);
|
|
12
|
-
if (gravity === 'error') {
|
|
13
|
-
console.error(cleanMessage);
|
|
14
|
-
} else {
|
|
15
|
-
console.warn(cleanMessage);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export function clearWarningsCache() {
|
|
20
|
-
warnedOnceCache.clear();
|
|
21
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useLocalizationContext } from "./useUtils.js";
|
|
3
|
-
export function useValidation(props, validate, isSameError, defaultErrorState) {
|
|
4
|
-
const {
|
|
5
|
-
value,
|
|
6
|
-
onError
|
|
7
|
-
} = props;
|
|
8
|
-
const adapter = useLocalizationContext();
|
|
9
|
-
const previousValidationErrorRef = React.useRef(defaultErrorState);
|
|
10
|
-
const validationError = validate({
|
|
11
|
-
adapter,
|
|
12
|
-
value,
|
|
13
|
-
props
|
|
14
|
-
});
|
|
15
|
-
React.useEffect(() => {
|
|
16
|
-
if (onError && !isSameError(validationError, previousValidationErrorRef.current)) {
|
|
17
|
-
onError(validationError, value);
|
|
18
|
-
}
|
|
19
|
-
previousValidationErrorRef.current = validationError;
|
|
20
|
-
}, [isSameError, onError, previousValidationErrorRef, validationError, value]);
|
|
21
|
-
return validationError;
|
|
22
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from "./validation/extractValidationProps.js";
|
|
3
|
-
const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly', 'dateSeparator'];
|
|
4
|
-
export const splitFieldInternalAndForwardedProps = (props, valueType) => {
|
|
5
|
-
const forwardedProps = _extends({}, props);
|
|
6
|
-
const internalProps = {};
|
|
7
|
-
const extractProp = propName => {
|
|
8
|
-
if (forwardedProps.hasOwnProperty(propName)) {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
internalProps[propName] = forwardedProps[propName];
|
|
11
|
-
delete forwardedProps[propName];
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
SHARED_FIELD_INTERNAL_PROP_NAMES.forEach(extractProp);
|
|
15
|
-
if (valueType === 'date') {
|
|
16
|
-
DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
17
|
-
} else if (valueType === 'time') {
|
|
18
|
-
TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
19
|
-
} else if (valueType === 'date-time') {
|
|
20
|
-
DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
21
|
-
TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
22
|
-
DATE_TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
forwardedProps,
|
|
26
|
-
internalProps
|
|
27
|
-
};
|
|
28
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const warnedOnceCache = new Set();
|
|
2
|
-
|
|
3
|
-
// TODO move to @mui/x-internals
|
|
4
|
-
// TODO eventually move to @base_ui/internals. Base UI, etc. too need this helper.
|
|
5
|
-
export function warnOnce(message, gravity = 'warning') {
|
|
6
|
-
if (process.env.NODE_ENV === 'production') {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
|
|
10
|
-
if (!warnedOnceCache.has(cleanMessage)) {
|
|
11
|
-
warnedOnceCache.add(cleanMessage);
|
|
12
|
-
if (gravity === 'error') {
|
|
13
|
-
console.error(cleanMessage);
|
|
14
|
-
} else {
|
|
15
|
-
console.warn(cleanMessage);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export function clearWarningsCache() {
|
|
20
|
-
warnedOnceCache.clear();
|
|
21
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.useValidation = useValidation;
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _useUtils = require("./useUtils");
|
|
10
|
-
function useValidation(props, validate, isSameError, defaultErrorState) {
|
|
11
|
-
const {
|
|
12
|
-
value,
|
|
13
|
-
onError
|
|
14
|
-
} = props;
|
|
15
|
-
const adapter = (0, _useUtils.useLocalizationContext)();
|
|
16
|
-
const previousValidationErrorRef = React.useRef(defaultErrorState);
|
|
17
|
-
const validationError = validate({
|
|
18
|
-
adapter,
|
|
19
|
-
value,
|
|
20
|
-
props
|
|
21
|
-
});
|
|
22
|
-
React.useEffect(() => {
|
|
23
|
-
if (onError && !isSameError(validationError, previousValidationErrorRef.current)) {
|
|
24
|
-
onError(validationError, value);
|
|
25
|
-
}
|
|
26
|
-
previousValidationErrorRef.current = validationError;
|
|
27
|
-
}, [isSameError, onError, previousValidationErrorRef, validationError, value]);
|
|
28
|
-
return validationError;
|
|
29
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.splitFieldInternalAndForwardedProps = void 0;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _extractValidationProps = require("./validation/extractValidationProps");
|
|
10
|
-
const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'referenceDate', 'format', 'formatDensity', 'onChange', 'timezone', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef', 'enableAccessibleFieldDOMStructure', 'disabled', 'readOnly', 'dateSeparator'];
|
|
11
|
-
const splitFieldInternalAndForwardedProps = (props, valueType) => {
|
|
12
|
-
const forwardedProps = (0, _extends2.default)({}, props);
|
|
13
|
-
const internalProps = {};
|
|
14
|
-
const extractProp = propName => {
|
|
15
|
-
if (forwardedProps.hasOwnProperty(propName)) {
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
internalProps[propName] = forwardedProps[propName];
|
|
18
|
-
delete forwardedProps[propName];
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
SHARED_FIELD_INTERNAL_PROP_NAMES.forEach(extractProp);
|
|
22
|
-
if (valueType === 'date') {
|
|
23
|
-
_extractValidationProps.DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
24
|
-
} else if (valueType === 'time') {
|
|
25
|
-
_extractValidationProps.TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
26
|
-
} else if (valueType === 'date-time') {
|
|
27
|
-
_extractValidationProps.DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
28
|
-
_extractValidationProps.TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
29
|
-
_extractValidationProps.DATE_TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
forwardedProps,
|
|
33
|
-
internalProps
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
exports.splitFieldInternalAndForwardedProps = splitFieldInternalAndForwardedProps;
|