@zealicsolutions/web-ui 1.0.55 → 1.0.56
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/dist/cjs/contexts/OrganismContext/OrganismContextProvider.d.ts +3 -2
- package/dist/cjs/index.js +1585 -1585
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/RichTextViewer/RichTextViewer.js.map +1 -1
- package/dist/esm/components/RichTextViewer/components/Leaf.js +1 -1
- package/dist/esm/components/RichTextViewer/components/Leaf.js.map +1 -1
- package/dist/esm/contexts/OrganismContext/OrganismContextProvider.d.ts +3 -2
- package/dist/esm/contexts/OrganismContext/OrganismContextProvider.js +1 -1
- package/dist/esm/contexts/OrganismContext/OrganismContextProvider.js.map +1 -1
- package/dist/esm/molecules/Drawer/Drawer.js +1 -1
- package/dist/esm/molecules/Drawer/Drawer.js.map +1 -1
- package/dist/esm/molecules/SpeedDial/SpeedDial.js +1 -1
- package/dist/esm/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js +1 -1
- package/dist/esm/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js.map +1 -1
- package/dist/esm/node_modules/@mui/styled-engine/StyledEngineProvider/StyledEngineProvider.js +1 -1
- package/dist/esm/node_modules/@mui/styled-engine/StyledEngineProvider/StyledEngineProvider.js.map +1 -1
- package/dist/esm/node_modules/@mui/styled-engine/index.js +1 -1
- package/dist/esm/node_modules/@mui/styled-engine/index.js.map +1 -1
- package/dist/esm/node_modules/@mui/system/esm/Grid/deleteLegacyGridProps.js +1 -1
- package/dist/esm/node_modules/@mui/system/esm/Grid/deleteLegacyGridProps.js.map +1 -1
- package/dist/esm/node_modules/@mui/utils/esm/useForkRef/useForkRef.js +1 -1
- package/dist/esm/node_modules/@mui/utils/esm/useForkRef/useForkRef.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/DateCalendar.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/DateCalendar.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/DayCalendar.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/DayCalendar.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/PickersFadeTransitionGroup.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/PickersFadeTransitionGroup.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/PickersSlideTransition.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/PickersSlideTransition.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/dateCalendarClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/dateCalendarClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/dayCalendarClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/dayCalendarClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/pickersFadeTransitionGroupClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/pickersFadeTransitionGroupClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/pickersSlideTransitionClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/pickersSlideTransitionClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/useCalendarState.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateCalendar/useCalendarState.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateField/DateField.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DateField/DateField.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DatePicker/DatePicker.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DatePicker/DatePickerToolbar.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DatePicker/DatePickerToolbar.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DatePicker/datePickerToolbarClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DatePicker/datePickerToolbarClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DesktopDatePicker/DesktopDatePicker.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/DesktopDatePicker/DesktopDatePicker.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/LocalizationProvider/LocalizationProvider.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/MobileDatePicker/MobileDatePicker.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/MobileDatePicker/MobileDatePicker.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/MonthCalendar/MonthCalendar.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/MonthCalendar/MonthCalendar.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/MonthCalendar/PickersMonth.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/MonthCalendar/PickersMonth.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/MonthCalendar/monthCalendarClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/MonthCalendar/monthCalendarClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/MonthCalendar/pickersMonthClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/MonthCalendar/pickersMonthClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersCalendarHeader/PickersCalendarHeader.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersCalendarHeader/PickersCalendarHeader.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersCalendarHeader/pickersCalendarHeaderClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersCalendarHeader/pickersCalendarHeaderClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersDay/PickersDay.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersDay/PickersDay.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersDay/pickersDayClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersDay/pickersDayClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersLayout/PickersLayout.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersLayout/PickersLayout.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersLayout/pickersLayoutClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersLayout/pickersLayoutClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersLayout/usePickerLayout.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersLayout/usePickerLayout.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersSectionList/PickersSectionList.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersSectionList/PickersSectionList.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersSectionList/pickersSectionListClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersSectionList/pickersSectionListClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersFilledInput/PickersFilledInput.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersFilledInput/PickersFilledInput.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersFilledInput/pickersFilledInputClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersFilledInput/pickersFilledInputClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersInput/PickersInput.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersInput/PickersInput.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersInput/pickersInputClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersInputBase/PickersInputBase.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersInputBase/PickersInputBase.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersInputBase/pickersInputBaseClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersInputBase/pickersInputBaseClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersOutlinedInput/pickersOutlinedInputClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersOutlinedInput/pickersOutlinedInputClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersTextField.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/PickersTextField.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/pickersTextFieldClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/PickersTextField/pickersTextFieldClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/YearCalendar/PickersYear.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/YearCalendar/PickersYear.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/YearCalendar/YearCalendar.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/YearCalendar/YearCalendar.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/YearCalendar/pickersYearClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/YearCalendar/pickersYearClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/YearCalendar/yearCalendarClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/YearCalendar/yearCalendarClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/hooks/useClearableField.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/hooks/useClearableField.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/pickersArrowSwitcherClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/pickersArrowSwitcherClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/PickersPopper.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/PickersPopper.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/PickersToolbar.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/PickersToolbar.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/pickersPopperClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/pickersPopperClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/pickersToolbarClasses.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/components/pickersToolbarClasses.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.utils.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.utils.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldCharacterEditing.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldCharacterEditing.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldState.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldState.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV6TextField.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV7TextField.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV7TextField.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useIsLandscape.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useIsLandscape.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/usePicker/usePickerValue.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/usePicker/usePickerValue.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/usePicker/usePickerViews.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/usePicker/usePickerViews.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useValueWithTimezone.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useValueWithTimezone.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useViews.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useViews.js.map +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/validation/useValidation.js +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/validation/useValidation.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/ClassNameGenerator/ClassNameGenerator.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/ClassNameGenerator/ClassNameGenerator.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/appendOwnerState/appendOwnerState.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/appendOwnerState/appendOwnerState.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/capitalize/capitalize.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/capitalize/capitalize.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/composeClasses/composeClasses.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/composeClasses/composeClasses.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/extractEventHandlers/extractEventHandlers.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/extractEventHandlers/extractEventHandlers.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/formatMuiErrorMessage/formatMuiErrorMessage.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/formatMuiErrorMessage/formatMuiErrorMessage.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/generateUtilityClass/generateUtilityClass.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/generateUtilityClass/generateUtilityClass.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/generateUtilityClasses/generateUtilityClasses.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/generateUtilityClasses/generateUtilityClasses.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/isHostComponent/isHostComponent.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/isHostComponent/isHostComponent.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/mergeSlotProps/mergeSlotProps.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/mergeSlotProps/mergeSlotProps.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/omitEventHandlers/omitEventHandlers.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/omitEventHandlers/omitEventHandlers.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/ownerDocument/ownerDocument.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/ownerDocument/ownerDocument.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/refType/refType.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/refType/refType.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/resolveComponentProps/resolveComponentProps.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/resolveComponentProps/resolveComponentProps.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useControlled/useControlled.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useControlled/useControlled.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useEnhancedEffect/useEnhancedEffect.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useEnhancedEffect/useEnhancedEffect.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useEventCallback/useEventCallback.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useEventCallback/useEventCallback.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useForkRef/useForkRef.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useForkRef/useForkRef.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useId/useId.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useId/useId.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useSlotProps/useSlotProps.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/useSlotProps/useSlotProps.js.map +0 -1
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/visuallyHidden/visuallyHidden.js +0 -2
- package/dist/esm/node_modules/@mui/x-date-pickers/node_modules/@mui/utils/esm/visuallyHidden/visuallyHidden.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDesktopPicker.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nconst _excluded = [\"props\", \"getOpenDialogAriaText\"],\n _excluded2 = [\"ownerState\"],\n _excluded3 = [\"ownerState\"];\nimport * as React from 'react';\nimport useSlotProps from '@mui/utils/useSlotProps';\nimport MuiInputAdornment from '@mui/material/InputAdornment';\nimport IconButton from '@mui/material/IconButton';\nimport useForkRef from '@mui/utils/useForkRef';\nimport useId from '@mui/utils/useId';\nimport { PickersPopper } from \"../../components/PickersPopper.js\";\nimport { usePicker } from \"../usePicker/index.js\";\nimport { PickersLayout } from \"../../../PickersLayout/index.js\";\nimport { PickersProvider } from \"../../components/PickersProvider.js\";\n\n/**\n * Hook managing all the single-date desktop pickers:\n * - DesktopDatePicker\n * - DesktopDateTimePicker\n * - DesktopTimePicker\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const useDesktopPicker = _ref => {\n let {\n props,\n getOpenDialogAriaText\n } = _ref,\n pickerParams = _objectWithoutPropertiesLoose(_ref, _excluded);\n const {\n slots,\n slotProps: innerSlotProps,\n className,\n sx,\n format,\n formatDensity,\n enableAccessibleFieldDOMStructure,\n selectedSections,\n onSelectedSectionsChange,\n timezone,\n name,\n label,\n inputRef,\n readOnly,\n disabled,\n autoFocus,\n localeText,\n reduceAnimations\n } = props;\n const containerRef = React.useRef(null);\n const fieldRef = React.useRef(null);\n const labelId = useId();\n const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;\n const {\n open,\n actions,\n hasUIView,\n layoutProps,\n renderCurrentView,\n shouldRestoreFocus,\n fieldProps: pickerFieldProps,\n contextValue,\n ownerState\n } = usePicker(_extends({}, pickerParams, {\n props,\n fieldRef,\n autoFocusView: true,\n additionalViewProps: {},\n wrapperVariant: 'desktop'\n }));\n const InputAdornment = slots.inputAdornment ?? MuiInputAdornment;\n const _useSlotProps = useSlotProps({\n elementType: InputAdornment,\n externalSlotProps: innerSlotProps?.inputAdornment,\n additionalProps: {\n position: 'end'\n },\n ownerState: props\n }),\n inputAdornmentProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);\n const OpenPickerButton = slots.openPickerButton ?? IconButton;\n const _useSlotProps2 = useSlotProps({\n elementType: OpenPickerButton,\n externalSlotProps: innerSlotProps?.openPickerButton,\n additionalProps: {\n disabled: disabled || readOnly,\n onClick: open ? actions.onClose : actions.onOpen,\n 'aria-label': getOpenDialogAriaText(pickerFieldProps.value),\n edge: inputAdornmentProps.position\n },\n ownerState: props\n }),\n openPickerButtonProps = _objectWithoutPropertiesLoose(_useSlotProps2, _excluded3);\n const OpenPickerIcon = slots.openPickerIcon;\n const openPickerIconProps = useSlotProps({\n elementType: OpenPickerIcon,\n externalSlotProps: innerSlotProps?.openPickerIcon,\n ownerState\n });\n const Field = slots.field;\n const fieldProps = useSlotProps({\n elementType: Field,\n externalSlotProps: innerSlotProps?.field,\n additionalProps: _extends({}, pickerFieldProps, isToolbarHidden && {\n id: labelId\n }, {\n readOnly,\n disabled,\n className,\n sx,\n format,\n formatDensity,\n enableAccessibleFieldDOMStructure,\n selectedSections,\n onSelectedSectionsChange,\n timezone,\n label,\n name,\n autoFocus: autoFocus && !props.open,\n focused: open ? true : undefined\n }, inputRef ? {\n inputRef\n } : {}),\n ownerState: props\n });\n\n // TODO: Move to `useSlotProps` when https://github.com/mui/material-ui/pull/35088 will be merged\n if (hasUIView) {\n fieldProps.InputProps = _extends({}, fieldProps.InputProps, {\n ref: containerRef\n }, !props.disableOpenPicker && {\n [`${inputAdornmentProps.position}Adornment`]: /*#__PURE__*/_jsx(InputAdornment, _extends({}, inputAdornmentProps, {\n children: /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {\n children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, openPickerIconProps))\n }))\n }))\n });\n }\n const slotsForField = _extends({\n textField: slots.textField,\n clearIcon: slots.clearIcon,\n clearButton: slots.clearButton\n }, fieldProps.slots);\n const Layout = slots.layout ?? PickersLayout;\n let labelledById = labelId;\n if (isToolbarHidden) {\n if (label) {\n labelledById = `${labelId}-label`;\n } else {\n labelledById = undefined;\n }\n }\n const slotProps = _extends({}, innerSlotProps, {\n toolbar: _extends({}, innerSlotProps?.toolbar, {\n titleId: labelId\n }),\n popper: _extends({\n 'aria-labelledby': labelledById\n }, innerSlotProps?.popper)\n });\n const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);\n const renderPicker = () => /*#__PURE__*/_jsxs(PickersProvider, {\n contextValue: contextValue,\n localeText: localeText,\n children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {\n slots: slotsForField,\n slotProps: slotProps,\n unstableFieldRef: handleFieldRef\n })), /*#__PURE__*/_jsx(PickersPopper, _extends({\n role: \"dialog\",\n placement: \"bottom-start\",\n anchorEl: containerRef.current\n }, actions, {\n open: open,\n slots: slots,\n slotProps: slotProps,\n shouldRestoreFocus: shouldRestoreFocus,\n reduceAnimations: reduceAnimations,\n children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {\n slots: slots,\n slotProps: slotProps,\n children: renderCurrentView()\n }))\n }))]\n });\n return {\n renderPicker\n };\n};"],"names":["_excluded","_excluded2","_excluded3","useDesktopPicker","_ref","props","getOpenDialogAriaText","pickerParams","_objectWithoutPropertiesLoose","slots","slotProps","innerSlotProps","className","sx","format","formatDensity","enableAccessibleFieldDOMStructure","selectedSections","onSelectedSectionsChange","timezone","name","label","inputRef","readOnly","disabled","autoFocus","localeText","reduceAnimations","containerRef","React","useRef","fieldRef","labelId","useId","isToolbarHidden","toolbar","hidden","open","actions","hasUIView","layoutProps","renderCurrentView","shouldRestoreFocus","fieldProps","pickerFieldProps","contextValue","ownerState","usePicker","_extends","autoFocusView","additionalViewProps","wrapperVariant","InputAdornment","inputAdornment","MuiInputAdornment","_useSlotProps","useSlotProps","elementType","externalSlotProps","additionalProps","position","inputAdornmentProps","OpenPickerButton","openPickerButton","IconButton","_useSlotProps2","onClick","onClose","onOpen","value","edge","openPickerButtonProps","OpenPickerIcon","openPickerIcon","openPickerIconProps","Field","field","id","focused","undefined","InputProps","ref","disableOpenPicker","_jsx","children","slotsForField","textField","clearIcon","clearButton","Layout","layout","PickersLayout","labelledById","titleId","popper","handleFieldRef","useForkRef","unstableFieldRef","renderPicker","_jsxs","PickersProvider","PickersPopper","role","placement","anchorEl","current"],"mappings":"g1BAEA,MAAMA,EAAY,CAAC,QAAS,yBAC1BC,EAAa,CAAC,cACdC,EAAa,CAAC,cAmBHC,EAAmBC,IAC9B,IAAIC,MACAA,EAAKC,sBACLA,GACEF,EACJG,EAAeC,EAA8BJ,EAAMJ,GACrD,MAAMS,MACJA,EACAC,UAAWC,EAAcC,UACzBA,EAASC,GACTA,EAAEC,OACFA,EAAMC,cACNA,EAAaC,kCACbA,EAAiCC,iBACjCA,EAAgBC,yBAChBA,EAAwBC,SACxBA,EAAQC,KACRA,EAAIC,MACJA,EAAKC,SACLA,EAAQC,SACRA,EAAQC,SACRA,EAAQC,UACRA,EAASC,WACTA,EAAUC,iBACVA,GACEtB,EACEuB,EAAeC,EAAMC,OAAO,MAC5BC,EAAWF,EAAMC,OAAO,MACxBE,EAAUC,IACVC,EAAkBvB,GAAgBwB,SAASC,SAAU,GACrDC,KACJA,EAAIC,QACJA,EAAOC,UACPA,EAASC,YACTA,EAAWC,kBACXA,EAAiBC,mBACjBA,EACAC,WAAYC,EAAgBC,aAC5BA,EAAYC,WACZA,GACEC,EAAUC,EAAS,CAAE,EAAEzC,EAAc,CACvCF,QACA0B,WACAkB,eAAe,EACfC,oBAAqB,CAA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B,cAKjE,MAAMW,GAAgBrC,EAAS,CAC7BsC,UAAW7E,EAAM6E,UACjBC,UAAW9E,EAAM8E,UACjBC,YAAa/E,EAAM+E,aAClB7C,GAAWlC,OACRgF,GAAShF,EAAMiF,QAAUC,EAC/B,IAAIC,GAAe5D,EACfE,IAEA0D,GADEvE,EACa,GAAGW,eAEH+C,GAGnB,MAAMrE,GAAYsC,EAAS,CAAE,EAAErC,EAAgB,CAC7CwB,QAASa,EAAS,GAAIrC,GAAgBwB,QAAS,CAC7C0D,QAAS7D,IAEX8D,OAAQ9C,EAAS,CACf,kBAAmB4C,IAClBjF,GAAgBmF,UAEfC,GAAiBC,EAAWjE,EAAUY,GAAWsD,kBAyBvD,MAAO,CACLC,aAzBmB,IAAmBC,EAAMC,EAAiB,CAC7DvD,aAAcA,EACdnB,WAAYA,EACZ0D,SAAU,CAAcD,EAAKR,GAAO3B,EAAS,CAAA,EAAIL,GAAY,CAC3DlC,MAAO4E,GACP3E,UAAWA,GACXuF,iBAAkBF,MACFZ,EAAKkB,EAAerD,EAAS,CAC7CsD,KAAM,SACNC,UAAW,eACXC,SAAU5E,EAAa6E,SACtBnE,EAAS,CACVD,KAAMA,EACN5B,MAAOA,EACPC,UAAWA,GACXgC,mBAAoBA,EACpBf,iBAAkBA,EAClByD,SAAuBD,EAAKM,GAAQzC,EAAS,CAAA,EAAIR,EAAa9B,IAAWgF,OAAQ,CAC/EjF,MAAOA,EACPC,UAAWA,GACX0E,SAAU3C,aAMf"}
|
1
|
+
{"version":3,"file":"useDesktopPicker.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nconst _excluded = [\"props\", \"getOpenDialogAriaText\"],\n _excluded2 = [\"ownerState\"],\n _excluded3 = [\"ownerState\"];\nimport * as React from 'react';\nimport useSlotProps from '@mui/utils/useSlotProps';\nimport MuiInputAdornment from '@mui/material/InputAdornment';\nimport IconButton from '@mui/material/IconButton';\nimport useForkRef from '@mui/utils/useForkRef';\nimport useId from '@mui/utils/useId';\nimport { PickersPopper } from \"../../components/PickersPopper.js\";\nimport { usePicker } from \"../usePicker/index.js\";\nimport { PickersLayout } from \"../../../PickersLayout/index.js\";\nimport { PickersProvider } from \"../../components/PickersProvider.js\";\n\n/**\n * Hook managing all the single-date desktop pickers:\n * - DesktopDatePicker\n * - DesktopDateTimePicker\n * - DesktopTimePicker\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const useDesktopPicker = _ref => {\n let {\n props,\n getOpenDialogAriaText\n } = _ref,\n pickerParams = _objectWithoutPropertiesLoose(_ref, _excluded);\n const {\n slots,\n slotProps: innerSlotProps,\n className,\n sx,\n format,\n formatDensity,\n enableAccessibleFieldDOMStructure,\n selectedSections,\n onSelectedSectionsChange,\n timezone,\n name,\n label,\n inputRef,\n readOnly,\n disabled,\n autoFocus,\n localeText,\n reduceAnimations\n } = props;\n const containerRef = React.useRef(null);\n const fieldRef = React.useRef(null);\n const labelId = useId();\n const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;\n const {\n open,\n actions,\n hasUIView,\n layoutProps,\n renderCurrentView,\n shouldRestoreFocus,\n fieldProps: pickerFieldProps,\n contextValue,\n ownerState\n } = usePicker(_extends({}, pickerParams, {\n props,\n fieldRef,\n autoFocusView: true,\n additionalViewProps: {},\n wrapperVariant: 'desktop'\n }));\n const InputAdornment = slots.inputAdornment ?? MuiInputAdornment;\n const _useSlotProps = useSlotProps({\n elementType: InputAdornment,\n externalSlotProps: innerSlotProps?.inputAdornment,\n additionalProps: {\n position: 'end'\n },\n ownerState: props\n }),\n inputAdornmentProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);\n const OpenPickerButton = slots.openPickerButton ?? IconButton;\n const _useSlotProps2 = useSlotProps({\n elementType: OpenPickerButton,\n externalSlotProps: innerSlotProps?.openPickerButton,\n additionalProps: {\n disabled: disabled || readOnly,\n onClick: open ? actions.onClose : actions.onOpen,\n 'aria-label': getOpenDialogAriaText(pickerFieldProps.value),\n edge: inputAdornmentProps.position\n },\n ownerState: props\n }),\n openPickerButtonProps = _objectWithoutPropertiesLoose(_useSlotProps2, _excluded3);\n const OpenPickerIcon = slots.openPickerIcon;\n const openPickerIconProps = useSlotProps({\n elementType: OpenPickerIcon,\n externalSlotProps: innerSlotProps?.openPickerIcon,\n ownerState\n });\n const Field = slots.field;\n const fieldProps = useSlotProps({\n elementType: Field,\n externalSlotProps: innerSlotProps?.field,\n additionalProps: _extends({}, pickerFieldProps, isToolbarHidden && {\n id: labelId\n }, {\n readOnly,\n disabled,\n className,\n sx,\n format,\n formatDensity,\n enableAccessibleFieldDOMStructure,\n selectedSections,\n onSelectedSectionsChange,\n timezone,\n label,\n name,\n autoFocus: autoFocus && !props.open,\n focused: open ? true : undefined\n }, inputRef ? {\n inputRef\n } : {}),\n ownerState: props\n });\n\n // TODO: Move to `useSlotProps` when https://github.com/mui/material-ui/pull/35088 will be merged\n if (hasUIView) {\n fieldProps.InputProps = _extends({}, fieldProps.InputProps, {\n ref: containerRef\n }, !props.disableOpenPicker && {\n [`${inputAdornmentProps.position}Adornment`]: /*#__PURE__*/_jsx(InputAdornment, _extends({}, inputAdornmentProps, {\n children: /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {\n children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, openPickerIconProps))\n }))\n }))\n });\n }\n const slotsForField = _extends({\n textField: slots.textField,\n clearIcon: slots.clearIcon,\n clearButton: slots.clearButton\n }, fieldProps.slots);\n const Layout = slots.layout ?? PickersLayout;\n let labelledById = labelId;\n if (isToolbarHidden) {\n if (label) {\n labelledById = `${labelId}-label`;\n } else {\n labelledById = undefined;\n }\n }\n const slotProps = _extends({}, innerSlotProps, {\n toolbar: _extends({}, innerSlotProps?.toolbar, {\n titleId: labelId\n }),\n popper: _extends({\n 'aria-labelledby': labelledById\n }, innerSlotProps?.popper)\n });\n const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);\n const renderPicker = () => /*#__PURE__*/_jsxs(PickersProvider, {\n contextValue: contextValue,\n localeText: localeText,\n children: [/*#__PURE__*/_jsx(Field, _extends({}, fieldProps, {\n slots: slotsForField,\n slotProps: slotProps,\n unstableFieldRef: handleFieldRef\n })), /*#__PURE__*/_jsx(PickersPopper, _extends({\n role: \"dialog\",\n placement: \"bottom-start\",\n anchorEl: containerRef.current\n }, actions, {\n open: open,\n slots: slots,\n slotProps: slotProps,\n shouldRestoreFocus: shouldRestoreFocus,\n reduceAnimations: reduceAnimations,\n children: /*#__PURE__*/_jsx(Layout, _extends({}, layoutProps, slotProps?.layout, {\n slots: slots,\n slotProps: slotProps,\n children: renderCurrentView()\n }))\n }))]\n });\n return {\n renderPicker\n };\n};"],"names":["_excluded","_excluded2","_excluded3","useDesktopPicker","_ref","props","getOpenDialogAriaText","pickerParams","_objectWithoutPropertiesLoose","slots","slotProps","innerSlotProps","className","sx","format","formatDensity","enableAccessibleFieldDOMStructure","selectedSections","onSelectedSectionsChange","timezone","name","label","inputRef","readOnly","disabled","autoFocus","localeText","reduceAnimations","containerRef","React","useRef","fieldRef","labelId","useId","isToolbarHidden","toolbar","hidden","open","actions","hasUIView","layoutProps","renderCurrentView","shouldRestoreFocus","fieldProps","pickerFieldProps","contextValue","ownerState","usePicker","_extends","autoFocusView","additionalViewProps","wrapperVariant","InputAdornment","inputAdornment","MuiInputAdornment","_useSlotProps","useSlotProps","elementType","externalSlotProps","additionalProps","position","inputAdornmentProps","OpenPickerButton","openPickerButton","IconButton","_useSlotProps2","onClick","onClose","onOpen","value","edge","openPickerButtonProps","OpenPickerIcon","openPickerIcon","openPickerIconProps","Field","field","id","focused","undefined","InputProps","ref","disableOpenPicker","_jsx","children","slotsForField","textField","clearIcon","clearButton","Layout","layout","PickersLayout","labelledById","titleId","popper","handleFieldRef","useForkRef","unstableFieldRef","renderPicker","_jsxs","PickersProvider","PickersPopper","role","placement","anchorEl","current"],"mappings":"myBAEA,MAAMA,EAAY,CAAC,QAAS,yBAC1BC,EAAa,CAAC,cACdC,EAAa,CAAC,cAmBHC,EAAmBC,IAC9B,IAAIC,MACAA,EAAKC,sBACLA,GACEF,EACJG,EAAeC,EAA8BJ,EAAMJ,GACrD,MAAMS,MACJA,EACAC,UAAWC,EAAcC,UACzBA,EAASC,GACTA,EAAEC,OACFA,EAAMC,cACNA,EAAaC,kCACbA,EAAiCC,iBACjCA,EAAgBC,yBAChBA,EAAwBC,SACxBA,EAAQC,KACRA,EAAIC,MACJA,EAAKC,SACLA,EAAQC,SACRA,EAAQC,SACRA,EAAQC,UACRA,EAASC,WACTA,EAAUC,iBACVA,GACEtB,EACEuB,EAAeC,EAAMC,OAAO,MAC5BC,EAAWF,EAAMC,OAAO,MACxBE,EAAUC,IACVC,EAAkBvB,GAAgBwB,SAASC,SAAU,GACrDC,KACJA,EAAIC,QACJA,EAAOC,UACPA,EAASC,YACTA,EAAWC,kBACXA,EAAiBC,mBACjBA,EACAC,WAAYC,EAAgBC,aAC5BA,EAAYC,WACZA,GACEC,EAAUC,EAAS,CAAE,EAAEzC,EAAc,CACvCF,QACA0B,WACAkB,eAAe,EACfC,oBAAqB,CAAE,EACvBC,eAAgB,aAEZC,EAAiB3C,EAAM4C,gBAAkBC,EACzCC,EAAgBC,EAAa,CAC/BC,YAAaL,EACbM,kBAAmB/C,GAAgB0C,eACnCM,gBAAiB,CACfC,SAAU,OAEZd,WAAYzC,IAEdwD,GAAsBrD,EAA8B+C,EAAetD,GAC/D6D,GAAmBrD,EAAMsD,kBAAoBC,EAC7CC,GAAiBT,EAAa,CAChCC,YAAaK,GACbJ,kBAAmB/C,GAAgBoD,iBACnCJ,gBAAiB,CACfnC,SAAUA,GAAYD,EACtB2C,QAAS7B,EAAOC,EAAQ6B,QAAU7B,EAAQ8B,OA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,UAEfC,GAAiBC,EAAWjE,EAAUY,GAAWsD,kBAyBvD,MAAO,CACLC,aAzBmB,IAAmBC,EAAMC,EAAiB,CAC7DvD,aAAcA,EACdnB,WAAYA,EACZ0D,SAAU,CAAcD,EAAKR,GAAO3B,EAAS,CAAA,EAAIL,GAAY,CAC3DlC,MAAO4E,GACP3E,UAAWA,GACXuF,iBAAkBF,MACFZ,EAAKkB,EAAerD,EAAS,CAC7CsD,KAAM,SACNC,UAAW,eACXC,SAAU5E,EAAa6E,SACtBnE,EAAS,CACVD,KAAMA,EACN5B,MAAOA,EACPC,UAAWA,GACXgC,mBAAoBA,EACpBf,iBAAkBA,EAClByD,SAAuBD,EAAKM,GAAQzC,EAAS,CAAA,EAAIR,EAAa9B,IAAWgF,OAAQ,CAC/EjF,MAAOA,EACPC,UAAWA,GACX0E,SAAU3C,aAMf"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import*as t from"react";import{useRtl as
|
1
|
+
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import*as t from"react";import r from"../../../../utils/esm/useEnhancedEffect/useEnhancedEffect.js";import s from"../../../../utils/esm/useEventCallback/useEventCallback.js";import{useRtl as l}from"../../../../system/esm/RtlProvider/index.js";import{useUtils as o}from"../useUtils.js";import{getSectionOrder as i,adjustSectionValue as n}from"./useField.utils.js";import{useFieldState as a}from"./useFieldState.js";import{useFieldCharacterEditing as c}from"./useFieldCharacterEditing.js";import{useFieldV7TextField as d}from"./useFieldV7TextField.js";import{useFieldV6TextField as u}from"./useFieldV6TextField.js";import{useValidation as m}from"../../../validation/useValidation.js";const f=f=>{const p=o(),{internalProps:S,internalProps:{unstableFieldRef:v,minutesStep:b,enableAccessibleFieldDOMStructure:y=!1,disabled:F=!1,readOnly:V=!1},forwardedProps:{onKeyDown:g,error:D,clearable:x,onClear:k},fieldValueManager:E,valueManager:h,validator:A}=f,w=l(),j=a(f),{state:I,activeSectionIndex:C,parsedSelectedSections:M,setSelectedSections:P,clearValue:K,clearActiveSection:O,updateSectionValue:T,setTempAndroidValueStr:z,sectionsValueBoundaries:B,localizedDigits:R,timezone:U}=j,H=c({sections:I.sections,updateSectionValue:T,sectionsValueBoundaries:B,localizedDigits:R,setTempAndroidValueStr:z,timezone:U}),{resetCharacterQuery:q}=H,G=h.areValuesEqual(p,I.value,h.emptyValue),L=y?d:u,N=t.useMemo((()=>i(I.sections,w&&!y)),[I.sections,w,y]),{returnedValue:Q,interactions:J}=L(e({},f,j,H,{areAllSectionsEmpty:G,sectionOrder:N})),W=s((e=>{if(g?.(e),!F)switch(!0){case(e.ctrlKey||e.metaKey)&&"A"===String.fromCharCode(e.keyCode)&&!e.shiftKey&&!e.altKey:e.preventDefault(),P("all");break;case"ArrowRight"===e.key:if(e.preventDefault(),null==M)P(N.startIndex);else if("all"===M)P(N.endIndex);else{const e=N.neighbors[M].rightIndex;null!==e&&P(e)}break;case"ArrowLeft"===e.key:if(e.preventDefault(),null==M)P(N.endIndex);else if("all"===M)P(N.startIndex);else{const e=N.neighbors[M].leftIndex;null!==e&&P(e)}break;case"Delete"===e.key:if(e.preventDefault(),V)break;null==M||"all"===M?K():O(),q();break;case["ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key):{if(e.preventDefault(),V||null==C)break;"all"===M&&P(C);const t=I.sections[C],r=E.getActiveDateManager(p,I,t),s=n(p,U,t,e.key,B,R,r.date,{minutesStep:b});T({activeSection:t,newSectionValue:s,shouldGoToNextSection:!1});break}}}));r((()=>{J.syncSelectionToDOM()}));const{hasValidationError:X}=m({props:S,validator:A,timezone:U,value:I.value,onError:S.onError}),Y=t.useMemo((()=>void 0!==D?D:X),[X,D]);t.useEffect((()=>{Y||null!=C||q()}),[I.referenceValue,C,Y]),t.useEffect((()=>{null!=I.tempValueStrAndroid&&null!=C&&(q(),O())}),[I.sections]),t.useImperativeHandle(v,(()=>({getSections:()=>I.sections,getActiveSectionIndex:J.getActiveSectionIndexFromDOM,setSelectedSections:J.setSelectedSections,focusField:J.focusField,isFieldFocused:J.isFieldFocused})));const Z={onKeyDown:W,onClear:s(((e,...t)=>{e.preventDefault(),k?.(e,...t),K(),J.isFieldFocused()?P(N.startIndex):J.focusField(0)})),error:Y,clearable:Boolean(x&&!G&&!V&&!F)},$={disabled:F,readOnly:V};return e({},f.forwardedProps,Z,$,Q)};export{f as useField};
|
2
2
|
//# sourceMappingURL=useField.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useField.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport useEnhancedEffect from '@mui/utils/useEnhancedEffect';\nimport useEventCallback from '@mui/utils/useEventCallback';\nimport { useRtl } from '@mui/system/RtlProvider';\nimport { useValidation } from \"../../../validation/index.js\";\nimport { useUtils } from \"../useUtils.js\";\nimport { adjustSectionValue, getSectionOrder } from \"./useField.utils.js\";\nimport { useFieldState } from \"./useFieldState.js\";\nimport { useFieldCharacterEditing } from \"./useFieldCharacterEditing.js\";\nimport { useFieldV7TextField } from \"./useFieldV7TextField.js\";\nimport { useFieldV6TextField } from \"./useFieldV6TextField.js\";\nexport const useField = params => {\n const utils = useUtils();\n const {\n internalProps,\n internalProps: {\n unstableFieldRef,\n minutesStep,\n enableAccessibleFieldDOMStructure = false,\n disabled = false,\n readOnly = false\n },\n forwardedProps: {\n onKeyDown,\n error,\n clearable,\n onClear\n },\n fieldValueManager,\n valueManager,\n validator\n } = params;\n const isRtl = useRtl();\n const stateResponse = useFieldState(params);\n const {\n state,\n activeSectionIndex,\n parsedSelectedSections,\n setSelectedSections,\n clearValue,\n clearActiveSection,\n updateSectionValue,\n setTempAndroidValueStr,\n sectionsValueBoundaries,\n localizedDigits,\n timezone\n } = stateResponse;\n const characterEditingResponse = useFieldCharacterEditing({\n sections: state.sections,\n updateSectionValue,\n sectionsValueBoundaries,\n localizedDigits,\n setTempAndroidValueStr,\n timezone\n });\n const {\n resetCharacterQuery\n } = characterEditingResponse;\n const areAllSectionsEmpty = valueManager.areValuesEqual(utils, state.value, valueManager.emptyValue);\n const useFieldTextField = enableAccessibleFieldDOMStructure ? useFieldV7TextField : useFieldV6TextField;\n const sectionOrder = React.useMemo(() => getSectionOrder(state.sections, isRtl && !enableAccessibleFieldDOMStructure), [state.sections, isRtl, enableAccessibleFieldDOMStructure]);\n const {\n returnedValue,\n interactions\n } = useFieldTextField(_extends({}, params, stateResponse, characterEditingResponse, {\n areAllSectionsEmpty,\n sectionOrder\n }));\n const handleContainerKeyDown = useEventCallback(event => {\n onKeyDown?.(event);\n if (disabled) {\n return;\n }\n // eslint-disable-next-line default-case\n switch (true) {\n // Select all\n case (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'A' && !event.shiftKey && !event.altKey:\n {\n // prevent default to make sure that the next line \"select all\" while updating\n // the internal state at the same time.\n event.preventDefault();\n setSelectedSections('all');\n break;\n }\n\n // Move selection to next section\n case event.key === 'ArrowRight':\n {\n event.preventDefault();\n if (parsedSelectedSections == null) {\n setSelectedSections(sectionOrder.startIndex);\n } else if (parsedSelectedSections === 'all') {\n setSelectedSections(sectionOrder.endIndex);\n } else {\n const nextSectionIndex = sectionOrder.neighbors[parsedSelectedSections].rightIndex;\n if (nextSectionIndex !== null) {\n setSelectedSections(nextSectionIndex);\n }\n }\n break;\n }\n\n // Move selection to previous section\n case event.key === 'ArrowLeft':\n {\n event.preventDefault();\n if (parsedSelectedSections == null) {\n setSelectedSections(sectionOrder.endIndex);\n } else if (parsedSelectedSections === 'all') {\n setSelectedSections(sectionOrder.startIndex);\n } else {\n const nextSectionIndex = sectionOrder.neighbors[parsedSelectedSections].leftIndex;\n if (nextSectionIndex !== null) {\n setSelectedSections(nextSectionIndex);\n }\n }\n break;\n }\n\n // Reset the value of the selected section\n case event.key === 'Delete':\n {\n event.preventDefault();\n if (readOnly) {\n break;\n }\n if (parsedSelectedSections == null || parsedSelectedSections === 'all') {\n clearValue();\n } else {\n clearActiveSection();\n }\n resetCharacterQuery();\n break;\n }\n\n // Increment / decrement the selected section value\n case ['ArrowUp', 'ArrowDown', 'Home', 'End', 'PageUp', 'PageDown'].includes(event.key):\n {\n event.preventDefault();\n if (readOnly || activeSectionIndex == null) {\n break;\n }\n\n // if all sections are selected, mark the currently editing one as selected\n if (parsedSelectedSections === 'all') {\n setSelectedSections(activeSectionIndex);\n }\n const activeSection = state.sections[activeSectionIndex];\n const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);\n const newSectionValue = adjustSectionValue(utils, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, activeDateManager.date, {\n minutesStep\n });\n updateSectionValue({\n activeSection,\n newSectionValue,\n shouldGoToNextSection: false\n });\n break;\n }\n }\n });\n useEnhancedEffect(() => {\n interactions.syncSelectionToDOM();\n });\n const {\n hasValidationError\n } = useValidation({\n props: internalProps,\n validator,\n timezone,\n value: state.value,\n onError: internalProps.onError\n });\n const inputError = React.useMemo(() => {\n // only override when `error` is undefined.\n // in case of multi input fields, the `error` value is provided externally and will always be defined.\n if (error !== undefined) {\n return error;\n }\n return hasValidationError;\n }, [hasValidationError, error]);\n React.useEffect(() => {\n if (!inputError && activeSectionIndex == null) {\n resetCharacterQuery();\n }\n }, [state.referenceValue, activeSectionIndex, inputError]); // eslint-disable-line react-hooks/exhaustive-deps\n\n // If `tempValueStrAndroid` is still defined for some section when running `useEffect`,\n // Then `onChange` has only been called once, which means the user pressed `Backspace` to reset the section.\n // This causes a small flickering on Android,\n // But we can't use `useEnhancedEffect` which is always called before the second `onChange` call and then would cause false positives.\n React.useEffect(() => {\n if (state.tempValueStrAndroid != null && activeSectionIndex != null) {\n resetCharacterQuery();\n clearActiveSection();\n }\n }, [state.sections]); // eslint-disable-line react-hooks/exhaustive-deps\n\n React.useImperativeHandle(unstableFieldRef, () => ({\n getSections: () => state.sections,\n getActiveSectionIndex: interactions.getActiveSectionIndexFromDOM,\n setSelectedSections: interactions.setSelectedSections,\n focusField: interactions.focusField,\n isFieldFocused: interactions.isFieldFocused\n }));\n const handleClearValue = useEventCallback((event, ...args) => {\n event.preventDefault();\n onClear?.(event, ...args);\n clearValue();\n if (!interactions.isFieldFocused()) {\n // setSelectedSections is called internally\n interactions.focusField(0);\n } else {\n setSelectedSections(sectionOrder.startIndex);\n }\n });\n const commonForwardedProps = {\n onKeyDown: handleContainerKeyDown,\n onClear: handleClearValue,\n error: inputError,\n clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly && !disabled)\n };\n const commonAdditionalProps = {\n disabled,\n readOnly\n };\n return _extends({}, params.forwardedProps, commonForwardedProps, commonAdditionalProps, returnedValue);\n};"],"names":["useField","params","utils","useUtils","internalProps","unstableFieldRef","minutesStep","enableAccessibleFieldDOMStructure","disabled","readOnly","forwardedProps","onKeyDown","error","clearable","onClear","fieldValueManager","valueManager","validator","isRtl","useRtl","stateResponse","useFieldState","state","activeSectionIndex","parsedSelectedSections","setSelectedSections","clearValue","clearActiveSection","updateSectionValue","setTempAndroidValueStr","sectionsValueBoundaries","localizedDigits","timezone","characterEditingResponse","useFieldCharacterEditing","sections","resetCharacterQuery","areAllSectionsEmpty","areValuesEqual","value","emptyValue","useFieldTextField","useFieldV7TextField","useFieldV6TextField","sectionOrder","React","useMemo","getSectionOrder","returnedValue","interactions","_extends","handleContainerKeyDown","useEventCallback","event","ctrlKey","metaKey","String","fromCharCode","keyCode","shiftKey","altKey","preventDefault","key","startIndex","endIndex","nextSectionIndex","neighbors","rightIndex","leftIndex","includes","activeSection","activeDateManager","getActiveDateManager","newSectionValue","adjustSectionValue","date","shouldGoToNextSection","useEnhancedEffect","syncSelectionToDOM","hasValidationError","useValidation","props","onError","inputError","undefined","useEffect","referenceValue","tempValueStrAndroid","useImperativeHandle","getSections","getActiveSectionIndex","getActiveSectionIndexFromDOM","focusField","isFieldFocused","commonForwardedProps","args","Boolean","commonAdditionalProps"],"mappings":"4wBA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,MAA7B/D,EAAMiE,qBAAqD,MAAtBhE,IACvCa,IACAT,IACD,GACA,CAACL,EAAMa,WAEVU,EAAM2C,oBAAoBnF,GAAkB,KAAO,CACjDoF,YAAa,IAAMnE,EAAMa,SACzBuD,sBAAuBzC,EAAa0C,6BACpClE,oBAAqBwB,EAAaxB,oBAClCmE,WAAY3C,EAAa2C,WACzBC,eAAgB5C,EAAa4C,mBAE/B,MAWMC,EAAuB,CAC3BnF,UAAWwC,EACXrC,QAbuBsC,GAAiB,CAACC,KAAU0C,KACnD1C,EAAMQ,iBACN/C,IAAUuC,KAAU0C,GACpBrE,IACKuB,EAAa4C,iBAIhBpE,EAAoBmB,EAAamB,YAFjCd,EAAa2C,WAAW,EAGzB,IAKDhF,MAAOuE,EACPtE,UAAWmF,QAAQnF,IAAcwB,IAAwB5B,IAAaD,IAElEyF,EAAwB,CAC5BzF,WACAC,YAEF,OAAOyC,EAAS,CAAA,EAAIjD,EAAOS,eAAgBoF,EAAsBG,EAAuBjD,EAAc"}
|
1
|
+
{"version":3,"file":"useField.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport useEnhancedEffect from '@mui/utils/useEnhancedEffect';\nimport useEventCallback from '@mui/utils/useEventCallback';\nimport { useRtl } from '@mui/system/RtlProvider';\nimport { useValidation } from \"../../../validation/index.js\";\nimport { useUtils } from \"../useUtils.js\";\nimport { adjustSectionValue, getSectionOrder } from \"./useField.utils.js\";\nimport { useFieldState } from \"./useFieldState.js\";\nimport { useFieldCharacterEditing } from \"./useFieldCharacterEditing.js\";\nimport { useFieldV7TextField } from \"./useFieldV7TextField.js\";\nimport { useFieldV6TextField } from \"./useFieldV6TextField.js\";\nexport const useField = params => {\n const utils = useUtils();\n const {\n internalProps,\n internalProps: {\n unstableFieldRef,\n minutesStep,\n enableAccessibleFieldDOMStructure = false,\n disabled = false,\n readOnly = false\n },\n forwardedProps: {\n onKeyDown,\n error,\n clearable,\n onClear\n },\n fieldValueManager,\n valueManager,\n validator\n } = params;\n const isRtl = useRtl();\n const stateResponse = useFieldState(params);\n const {\n state,\n activeSectionIndex,\n parsedSelectedSections,\n setSelectedSections,\n clearValue,\n clearActiveSection,\n updateSectionValue,\n setTempAndroidValueStr,\n sectionsValueBoundaries,\n localizedDigits,\n timezone\n } = stateResponse;\n const characterEditingResponse = useFieldCharacterEditing({\n sections: state.sections,\n updateSectionValue,\n sectionsValueBoundaries,\n localizedDigits,\n setTempAndroidValueStr,\n timezone\n });\n const {\n resetCharacterQuery\n } = characterEditingResponse;\n const areAllSectionsEmpty = valueManager.areValuesEqual(utils, state.value, valueManager.emptyValue);\n const useFieldTextField = enableAccessibleFieldDOMStructure ? useFieldV7TextField : useFieldV6TextField;\n const sectionOrder = React.useMemo(() => getSectionOrder(state.sections, isRtl && !enableAccessibleFieldDOMStructure), [state.sections, isRtl, enableAccessibleFieldDOMStructure]);\n const {\n returnedValue,\n interactions\n } = useFieldTextField(_extends({}, params, stateResponse, characterEditingResponse, {\n areAllSectionsEmpty,\n sectionOrder\n }));\n const handleContainerKeyDown = useEventCallback(event => {\n onKeyDown?.(event);\n if (disabled) {\n return;\n }\n // eslint-disable-next-line default-case\n switch (true) {\n // Select all\n case (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'A' && !event.shiftKey && !event.altKey:\n {\n // prevent default to make sure that the next line \"select all\" while updating\n // the internal state at the same time.\n event.preventDefault();\n setSelectedSections('all');\n break;\n }\n\n // Move selection to next section\n case event.key === 'ArrowRight':\n {\n event.preventDefault();\n if (parsedSelectedSections == null) {\n setSelectedSections(sectionOrder.startIndex);\n } else if (parsedSelectedSections === 'all') {\n setSelectedSections(sectionOrder.endIndex);\n } else {\n const nextSectionIndex = sectionOrder.neighbors[parsedSelectedSections].rightIndex;\n if (nextSectionIndex !== null) {\n setSelectedSections(nextSectionIndex);\n }\n }\n break;\n }\n\n // Move selection to previous section\n case event.key === 'ArrowLeft':\n {\n event.preventDefault();\n if (parsedSelectedSections == null) {\n setSelectedSections(sectionOrder.endIndex);\n } else if (parsedSelectedSections === 'all') {\n setSelectedSections(sectionOrder.startIndex);\n } else {\n const nextSectionIndex = sectionOrder.neighbors[parsedSelectedSections].leftIndex;\n if (nextSectionIndex !== null) {\n setSelectedSections(nextSectionIndex);\n }\n }\n break;\n }\n\n // Reset the value of the selected section\n case event.key === 'Delete':\n {\n event.preventDefault();\n if (readOnly) {\n break;\n }\n if (parsedSelectedSections == null || parsedSelectedSections === 'all') {\n clearValue();\n } else {\n clearActiveSection();\n }\n resetCharacterQuery();\n break;\n }\n\n // Increment / decrement the selected section value\n case ['ArrowUp', 'ArrowDown', 'Home', 'End', 'PageUp', 'PageDown'].includes(event.key):\n {\n event.preventDefault();\n if (readOnly || activeSectionIndex == null) {\n break;\n }\n\n // if all sections are selected, mark the currently editing one as selected\n if (parsedSelectedSections === 'all') {\n setSelectedSections(activeSectionIndex);\n }\n const activeSection = state.sections[activeSectionIndex];\n const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);\n const newSectionValue = adjustSectionValue(utils, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, activeDateManager.date, {\n minutesStep\n });\n updateSectionValue({\n activeSection,\n newSectionValue,\n shouldGoToNextSection: false\n });\n break;\n }\n }\n });\n useEnhancedEffect(() => {\n interactions.syncSelectionToDOM();\n });\n const {\n hasValidationError\n } = useValidation({\n props: internalProps,\n validator,\n timezone,\n value: state.value,\n onError: internalProps.onError\n });\n const inputError = React.useMemo(() => {\n // only override when `error` is undefined.\n // in case of multi input fields, the `error` value is provided externally and will always be defined.\n if (error !== undefined) {\n return error;\n }\n return hasValidationError;\n }, [hasValidationError, error]);\n React.useEffect(() => {\n if (!inputError && activeSectionIndex == null) {\n resetCharacterQuery();\n }\n }, [state.referenceValue, activeSectionIndex, inputError]); // eslint-disable-line react-hooks/exhaustive-deps\n\n // If `tempValueStrAndroid` is still defined for some section when running `useEffect`,\n // Then `onChange` has only been called once, which means the user pressed `Backspace` to reset the section.\n // This causes a small flickering on Android,\n // But we can't use `useEnhancedEffect` which is always called before the second `onChange` call and then would cause false positives.\n React.useEffect(() => {\n if (state.tempValueStrAndroid != null && activeSectionIndex != null) {\n resetCharacterQuery();\n clearActiveSection();\n }\n }, [state.sections]); // eslint-disable-line react-hooks/exhaustive-deps\n\n React.useImperativeHandle(unstableFieldRef, () => ({\n getSections: () => state.sections,\n getActiveSectionIndex: interactions.getActiveSectionIndexFromDOM,\n setSelectedSections: interactions.setSelectedSections,\n focusField: interactions.focusField,\n isFieldFocused: interactions.isFieldFocused\n }));\n const handleClearValue = useEventCallback((event, ...args) => {\n event.preventDefault();\n onClear?.(event, ...args);\n clearValue();\n if (!interactions.isFieldFocused()) {\n // setSelectedSections is called internally\n interactions.focusField(0);\n } else {\n setSelectedSections(sectionOrder.startIndex);\n }\n });\n const commonForwardedProps = {\n onKeyDown: handleContainerKeyDown,\n onClear: handleClearValue,\n error: inputError,\n clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly && !disabled)\n };\n const commonAdditionalProps = {\n disabled,\n readOnly\n };\n return _extends({}, params.forwardedProps, commonForwardedProps, commonAdditionalProps, returnedValue);\n};"],"names":["useField","params","utils","useUtils","internalProps","unstableFieldRef","minutesStep","enableAccessibleFieldDOMStructure","disabled","readOnly","forwardedProps","onKeyDown","error","clearable","onClear","fieldValueManager","valueManager","validator","isRtl","useRtl","stateResponse","useFieldState","state","activeSectionIndex","parsedSelectedSections","setSelectedSections","clearValue","clearActiveSection","updateSectionValue","setTempAndroidValueStr","sectionsValueBoundaries","localizedDigits","timezone","characterEditingResponse","useFieldCharacterEditing","sections","resetCharacterQuery","areAllSectionsEmpty","areValuesEqual","value","emptyValue","useFieldTextField","useFieldV7TextField","useFieldV6TextField","sectionOrder","React","useMemo","getSectionOrder","returnedValue","interactions","_extends","handleContainerKeyDown","useEventCallback","event","ctrlKey","metaKey","String","fromCharCode","keyCode","shiftKey","altKey","preventDefault","key","startIndex","endIndex","nextSectionIndex","neighbors","rightIndex","leftIndex","includes","activeSection","activeDateManager","getActiveDateManager","newSectionValue","adjustSectionValue","date","shouldGoToNextSection","useEnhancedEffect","syncSelectionToDOM","hasValidationError","useValidation","props","onError","inputError","undefined","useEffect","referenceValue","tempValueStrAndroid","useImperativeHandle","getSections","getActiveSectionIndex","getActiveSectionIndexFromDOM","focusField","isFieldFocused","commonForwardedProps","args","Boolean","commonAdditionalProps"],"mappings":"8uBAYY,MAACA,EAAWC,IACtB,MAAMC,EAAQC,KACRC,cACJA,EACAA,eAAeC,iBACbA,EAAgBC,YAChBA,EAAWC,kCACXA,GAAoC,EAAKC,SACzCA,GAAW,EAAKC,SAChBA,GAAW,GAEbC,gBAAgBC,UACdA,EAASC,MACTA,EAAKC,UACLA,EAASC,QACTA,GACDC,kBACDA,EAAiBC,aACjBA,EAAYC,UACZA,GACEhB,EACEiB,EAAQC,IACRC,EAAgBC,EAAcpB,IAC9BqB,MACJA,EAAKC,mBACLA,EAAkBC,uBAClBA,EAAsBC,oBACtBA,EAAmBC,WACnBA,EAAUC,mBACVA,EAAkBC,mBAClBA,EAAkBC,uBAClBA,EAAsBC,wBACtBA,EAAuBC,gBACvBA,EAAeC,SACfA,GACEZ,EACEa,EAA2BC,EAAyB,CACxDC,SAAUb,EAAMa,SAChBP,qBACAE,0BACAC,kBACAF,yBACAG,cAEII,oBACJA,GACEH,EACEI,EAAsBrB,EAAasB,eAAepC,EAAOoB,EAAMiB,MAAOvB,EAAawB,YACnFC,EAAoBlC,EAAoCmC,EAAsBC,EAC9EC,EAAeC,EAAMC,SAAQ,IAAMC,EAAgBzB,EAAMa,SAAUjB,IAAUX,IAAoC,CAACe,EAAMa,SAAUjB,EAAOX,KACzIyC,cACJA,EAAaC,aACbA,GACER,EAAkBS,EAAS,CAAA,EAAIjD,EAAQmB,EAAea,EAA0B,CAClFI,sBACAO,kBAEIO,EAAyBC,GAA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B,EAAa6B,oBAAoB,IAEnC,MAAMC,mBACJA,GACEC,EAAc,CAChBC,MAAO7E,EACPa,YACAe,WACAO,MAAOjB,EAAMiB,MACb2C,QAAS9E,EAAc8E,UAEnBC,EAAatC,EAAMC,SAAQ,SAGjBsC,IAAVxE,EACKA,EAEFmE,GACN,CAACA,EAAoBnE,IACxBiC,EAAMwC,WAAU,KACTF,GAAoC,MAAtB5D,GACjBa,GACD,GACA,CAACd,EAAMgE,eAAgB/D,EAAoB4D,IAM9CtC,EAAMwC,WAAU,KACmB,MAA7B/D,EAAMiE,qBAAqD,MAAtBhE,IACvCa,IACAT,IACD,GACA,CAACL,EAAMa,WAEVU,EAAM2C,oBAAoBnF,GAAkB,KAAO,CACjDoF,YAAa,IAAMnE,EAAMa,SACzBuD,sBAAuBzC,EAAa0C,6BACpClE,oBAAqBwB,EAAaxB,oBAClCmE,WAAY3C,EAAa2C,WACzBC,eAAgB5C,EAAa4C,mBAE/B,MAWMC,EAAuB,CAC3BnF,UAAWwC,EACXrC,QAbuBsC,GAAiB,CAACC,KAAU0C,KACnD1C,EAAMQ,iBACN/C,IAAUuC,KAAU0C,GACpBrE,IACKuB,EAAa4C,iBAIhBpE,EAAoBmB,EAAamB,YAFjCd,EAAa2C,WAAW,EAGzB,IAKDhF,MAAOuE,EACPtE,UAAWmF,QAAQnF,IAAcwB,IAAwB5B,IAAaD,IAElEyF,EAAwB,CAC5BzF,WACAC,YAEF,OAAOyC,EAAS,CAAA,EAAIjD,EAAOS,eAAgBoF,EAAsBG,EAAuBjD,EAAc"}
|
package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.utils.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{getMonthsInYear as t}from"../../utils/date-utils.js";const e=(t,e)=>{const n=t.formatTokenMap[e];if(null==n)throw new Error([`MUI X: The token "${e}" is not supported by the Date and Time Pickers.`,"Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported."].join("\n"));return"string"==typeof n?{type:n,contentType:"meridiem"===n?"letter":"digit",maxLength:void 0}:{type:n.sectionType,contentType:n.contentType,maxLength:n.maxLength}},n=(t,e)=>{const n=[],r=t.date(void 0,"default"),o=t.startOfWeek(r),a=t.endOfWeek(r);let i=o;for(;t.isBefore(i,a);)n.push(i),i=t.addDays(i,1);return n.map((n=>t.formatByString(n,e)))},r=(e,r,o,a)=>{switch(o){case"month":return t(e,e.date(void 0,r)).map((t=>e.formatByString(t,a)));case"weekDay":return n(e,a);case"meridiem":{const t=e.date(void 0,r);return[e.startOfDay(t),e.endOfDay(t)].map((t=>e.formatByString(t,a)))}default:return[]}},o="s",a=["0","1","2","3","4","5","6","7","8","9"],i=t=>{const e=t.date(void 0);return"0"===t.formatByString(t.setSeconds(e,0),"s")?a:Array.from({length:10}).map(((n,r)=>t.formatByString(t.setSeconds(e,r),"s")))},s=(t,e)=>{if("0"===e[0])return t;const n=[];let r="";for(let o=0;o<t.length;o+=1){r+=t[o];const a=e.indexOf(r);a>-1&&(n.push(a.toString()),r="")}return n.join("")},m=(t,e)=>"0"===e[0]?t:t.split("").map((t=>e[Number(t)])).join(""),u=(t,e)=>{const n=s(t,e);return" "!==n&&!Number.isNaN(Number(n))},d=(t,e)=>{let n=t;for(n=Number(n).toString();n.length<e;)n=`0${n}`;return n},c=(t,e,n,r,o)=>{if("production"!==process.env.NODE_ENV&&"day"!==o.type&&"digit-with-letter"===o.contentType)throw new Error([`MUI X: The token "${o.format}" is a digit format with letter in it.'\n This type of format is only supported for 'day' sections`].join("\n"));if("day"===o.type&&"digit-with-letter"===o.contentType){const r=t.setDate(n.longestMonth,e);return t.formatByString(r,o.format)}let a=e.toString();return o.hasLeadingZerosInInput&&(a=d(a,o.maxLength)),m(a,r)},l=(t,e,n,o,a,i,m,u)=>{const d=(t=>{switch(t){case"ArrowUp":return 1;case"ArrowDown":return-1;case"PageUp":return 5;case"PageDown":return-5;default:return 0}})(o),l="Home"===o,
|
1
|
+
import{getMonthsInYear as t}from"../../utils/date-utils.js";const e=(t,e)=>{const n=t.formatTokenMap[e];if(null==n)throw new Error([`MUI X: The token "${e}" is not supported by the Date and Time Pickers.`,"Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported."].join("\n"));return"string"==typeof n?{type:n,contentType:"meridiem"===n?"letter":"digit",maxLength:void 0}:{type:n.sectionType,contentType:n.contentType,maxLength:n.maxLength}},n=(t,e)=>{const n=[],r=t.date(void 0,"default"),o=t.startOfWeek(r),a=t.endOfWeek(r);let i=o;for(;t.isBefore(i,a);)n.push(i),i=t.addDays(i,1);return n.map((n=>t.formatByString(n,e)))},r=(e,r,o,a)=>{switch(o){case"month":return t(e,e.date(void 0,r)).map((t=>e.formatByString(t,a)));case"weekDay":return n(e,a);case"meridiem":{const t=e.date(void 0,r);return[e.startOfDay(t),e.endOfDay(t)].map((t=>e.formatByString(t,a)))}default:return[]}},o="s",a=["0","1","2","3","4","5","6","7","8","9"],i=t=>{const e=t.date(void 0);return"0"===t.formatByString(t.setSeconds(e,0),"s")?a:Array.from({length:10}).map(((n,r)=>t.formatByString(t.setSeconds(e,r),"s")))},s=(t,e)=>{if("0"===e[0])return t;const n=[];let r="";for(let o=0;o<t.length;o+=1){r+=t[o];const a=e.indexOf(r);a>-1&&(n.push(a.toString()),r="")}return n.join("")},m=(t,e)=>"0"===e[0]?t:t.split("").map((t=>e[Number(t)])).join(""),u=(t,e)=>{const n=s(t,e);return" "!==n&&!Number.isNaN(Number(n))},d=(t,e)=>{let n=t;for(n=Number(n).toString();n.length<e;)n=`0${n}`;return n},c=(t,e,n,r,o)=>{if("production"!==process.env.NODE_ENV&&"day"!==o.type&&"digit-with-letter"===o.contentType)throw new Error([`MUI X: The token "${o.format}" is a digit format with letter in it.'\n This type of format is only supported for 'day' sections`].join("\n"));if("day"===o.type&&"digit-with-letter"===o.contentType){const r=t.setDate(n.longestMonth,e);return t.formatByString(r,o.format)}let a=e.toString();return o.hasLeadingZerosInInput&&(a=d(a,o.maxLength)),m(a,r)},l=(t,e,n,o,a,i,m,u)=>{const d=(t=>{switch(t){case"ArrowUp":return 1;case"ArrowDown":return-1;case"PageUp":return 5;case"PageDown":return-5;default:return 0}})(o),l="Home"===o,f="End"===o,h=""===n.value||l||f;return"digit"===n.contentType||"digit-with-letter"===n.contentType?(()=>{const r=a[n.type]({currentDate:m,format:n.format,contentType:n.contentType}),o=e=>c(t,e,r,i,n),p="minutes"===n.type&&u?.minutesStep?u.minutesStep:1;let y=parseInt(s(n.value,i),10)+d*p;if(h){if("year"===n.type&&!f&&!l)return t.formatByString(t.date(void 0,e),n.format);y=d>0||l?r.minimum:r.maximum}return y%p!=0&&((d<0||l)&&(y+=p-(p+y)%p),(d>0||f)&&(y-=y%p)),y>r.maximum?o(r.minimum+(y-r.maximum-1)%(r.maximum-r.minimum+1)):y<r.minimum?o(r.maximum-(r.minimum-y-1)%(r.maximum-r.minimum+1)):o(y)})():(()=>{const o=r(t,e,n.type,n.format);if(0===o.length)return n.value;if(h)return d>0||l?o[0]:o[o.length-1];const a=o.indexOf(n.value);return o[((a+d)%o.length+o.length)%o.length]})()},f=(t,e,n)=>{let r=t.value||t.placeholder;const o="non-input"===e?t.hasLeadingZerosInFormat:t.hasLeadingZerosInInput;"non-input"===e&&t.hasLeadingZerosInInput&&!t.hasLeadingZerosInFormat&&(r=Number(s(r,n)).toString());return["input-rtl","input-ltr"].includes(e)&&"digit"===t.contentType&&!o&&1===r.length&&(r=`${r}`),"input-rtl"===e&&(r=`${r}`),r},h=(t,n,r,o)=>{if("production"!==process.env.NODE_ENV&&"weekDay"===e(t,r).type)throw new Error("changeSectionValueFormat doesn't support week day formats");return t.formatByString(t.parse(n,r),o)},p=(t,e)=>4===t.formatByString(t.date(void 0,"system"),e).length,y=(t,e,n,r)=>{if("digit"!==e)return!1;const o=t.date(void 0,"default");switch(n){case"year":if(p(t,r)){return"0001"===t.formatByString(t.setYear(o,1),r)}return"01"===t.formatByString(t.setYear(o,2001),r);case"month":return t.formatByString(t.startOfYear(o),r).length>1;case"day":return t.formatByString(t.startOfMonth(o),r).length>1;case"weekDay":return t.formatByString(t.startOfWeek(o),r).length>1;case"hours":return t.formatByString(t.setHours(o,1),r).length>1;case"minutes":return t.formatByString(t.setMinutes(o,1),r).length>1;case"seconds":return t.formatByString(t.setSeconds(o,1),r).length>1;default:throw new Error("Invalid section type")}},g=(t,e,n)=>{const r=e.some((t=>"day"===t.type)),o=[],a=[];for(let t=0;t<e.length;t+=1){const i=e[t];r&&"weekDay"===i.type||(o.push(i.format),a.push(f(i,"non-input",n)))}const i=o.join(" "),s=a.join(" ");return t.parse(s,i)},x=t=>t.map((t=>`${t.startSeparator}${t.value||t.placeholder}${t.endSeparator}`)).join(""),S=(t,e,n)=>{const r=t.map((t=>{const r=f(t,n?"input-rtl":"input-ltr",e);return`${t.startSeparator}${r}${t.endSeparator}`})).join("");return n?`${r}`:r},v=(e,r,o)=>{const a=e.date(void 0,o),i=e.endOfYear(a),m=e.endOfDay(a),{maxDaysInMonth:u,longestMonth:d}=t(e,a).reduce(((t,n)=>{const r=e.getDaysInMonth(n);return r>t.maxDaysInMonth?{maxDaysInMonth:r,longestMonth:n}:t}),{maxDaysInMonth:0,longestMonth:null});return{year:({format:t})=>({minimum:0,maximum:p(e,t)?9999:99}),month:()=>({minimum:1,maximum:e.getMonth(i)+1}),day:({currentDate:t})=>({minimum:1,maximum:null!=t&&e.isValid(t)?e.getDaysInMonth(t):u,longestMonth:d}),weekDay:({format:t,contentType:r})=>{if("digit"===r){const r=n(e,t).map(Number);return{minimum:Math.min(...r),maximum:Math.max(...r)}}return{minimum:1,maximum:7}},hours:({format:t})=>{const n=e.getHours(m);return s(e.formatByString(e.endOfDay(a),t),r)!==n.toString()?{minimum:1,maximum:Number(s(e.formatByString(e.startOfDay(a),t),r))}:{minimum:0,maximum:n}},minutes:()=>({minimum:0,maximum:e.getMinutes(m)}),seconds:()=>({minimum:0,maximum:e.getSeconds(m)}),meridiem:()=>({minimum:0,maximum:1}),empty:()=>({minimum:0,maximum:0})}};let w=!1;const D=(t,e)=>{if("production"!==process.env.NODE_ENV&&!w){const n=["empty"];["date","date-time"].includes(e)&&n.push("weekDay","day","month","year"),["time","date-time"].includes(e)&&n.push("hours","minutes","seconds","meridiem");const r=t.find((t=>!n.includes(t.type)));r&&(console.warn(`MUI X: The field component you are using is not compatible with the "${r.type}" date section.`,`The supported date sections are ["${n.join('", "')}"]\`.`),w=!0)}},I={year:1,month:2,day:3,weekDay:4,hours:5,minutes:6,seconds:7,meridiem:8,empty:9},M=(t,e,r,o,a)=>[...r].sort(((t,e)=>I[t.type]-I[e.type])).reduce(((r,o)=>!a||o.modified?((t,e,r,o)=>{switch(e.type){case"year":return t.setYear(o,t.getYear(r));case"month":return t.setMonth(o,t.getMonth(r));case"weekDay":{const o=n(t,e.format),a=t.formatByString(r,e.format),i=o.indexOf(a),s=o.indexOf(e.value)-i;return t.addDays(r,s)}case"day":return t.setDate(o,t.getDate(r));case"meridiem":{const e=t.getHours(r)<12,n=t.getHours(o);return e&&n>=12?t.addHours(o,-12):!e&&n<12?t.addHours(o,12):o}case"hours":return t.setHours(o,t.getHours(r));case"minutes":return t.setMinutes(o,t.getMinutes(r));case"seconds":return t.setSeconds(o,t.getSeconds(r));default:return o}})(t,o,e,r):r),o),T=()=>navigator.userAgent.toLowerCase().includes("android"),B=(t,e)=>{const n={};if(!e)return t.forEach(((e,r)=>{const o=0===r?null:r-1,a=r===t.length-1?null:r+1;n[r]={leftIndex:o,rightIndex:a}})),{neighbors:n,startIndex:0,endIndex:t.length-1};const r={},o={};let a=0,i=0,s=t.length-1;for(;s>=0;){i=t.findIndex(((t,e)=>e>=a&&t.endSeparator?.includes(" ")&&" / "!==t.endSeparator)),-1===i&&(i=t.length-1);for(let t=i;t>=a;t-=1)o[t]=s,r[s]=t,s-=1;a=i+1}return t.forEach(((e,a)=>{const i=o[a],s=0===i?null:r[i-1],m=i===t.length-1?null:r[i+1];n[a]={leftIndex:s,rightIndex:m}})),{neighbors:n,startIndex:r[0],endIndex:r[t.length-1]}},N=(t,e)=>{if(null==t)return null;if("all"===t)return"all";if("string"==typeof t){const n=e.findIndex((e=>e.type===t));return-1===n?null:n}return t},O=(t,e)=>{if(t.value)switch(t.type){case"month":{if("digit"===t.contentType)return e.format(e.setMonth(e.date(),Number(t.value)-1),"month");const n=e.parse(t.value,t.format);return n?e.format(n,"month"):void 0}case"day":return"digit"===t.contentType?e.format(e.setDate(e.startOfYear(e.date()),Number(t.value)),"dayOfMonthFull"):t.value;default:return}},b=(t,e)=>{if(t.value)switch(t.type){case"weekDay":if("letter"===t.contentType)return;return Number(t.value);case"meridiem":{const n=e.parse(`01:00 ${t.value}`,`${e.formats.hours12h}:${e.formats.minutes} ${t.format}`);return n?e.getHours(n)>=12?1:0:void 0}case"day":return"digit-with-letter"===t.contentType?parseInt(t.value,10):Number(t.value);case"month":{if("digit"===t.contentType)return Number(t.value);const n=e.parse(t.value,t.format);return n?e.getMonth(n)+1:void 0}default:return"letter"!==t.contentType?Number(t.value):void 0}};export{o as FORMAT_SECONDS_NO_LEADING_ZEROS,l as adjustSectionValue,m as applyLocalizedDigits,h as changeSectionValueFormat,c as cleanDigitSectionValue,d as cleanLeadingZeros,S as createDateStrForV6InputFromSections,x as createDateStrForV7HiddenInputFromSections,y as doesSectionFormatHaveLeadingZeros,g as getDateFromDateSections,e as getDateSectionConfigFromFormatToken,n as getDaysInWeekStr,r as getLetterEditingOptions,i as getLocalizedDigits,B as getSectionOrder,b as getSectionValueNow,O as getSectionValueText,f as getSectionVisibleValue,v as getSectionsBoundaries,T as isAndroid,u as isStringNumber,M as mergeDateIntoReferenceDate,N as parseSelectedSections,s as removeLocalizedDigits,D as validateSections};
|
2
2
|
//# sourceMappingURL=useField.utils.js.map
|
package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.utils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useField.utils.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.utils.js"],"sourcesContent":["import { getMonthsInYear } from \"../../utils/date-utils.js\";\nexport const getDateSectionConfigFromFormatToken = (utils, formatToken) => {\n const config = utils.formatTokenMap[formatToken];\n if (config == null) {\n throw new Error([`MUI X: The token \"${formatToken}\" is not supported by the Date and Time Pickers.`, 'Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported.'].join('\\n'));\n }\n if (typeof config === 'string') {\n return {\n type: config,\n contentType: config === 'meridiem' ? 'letter' : 'digit',\n maxLength: undefined\n };\n }\n return {\n type: config.sectionType,\n contentType: config.contentType,\n maxLength: config.maxLength\n };\n};\nconst getDeltaFromKeyCode = keyCode => {\n switch (keyCode) {\n case 'ArrowUp':\n return 1;\n case 'ArrowDown':\n return -1;\n case 'PageUp':\n return 5;\n case 'PageDown':\n return -5;\n default:\n return 0;\n }\n};\nexport const getDaysInWeekStr = (utils, format) => {\n const elements = [];\n const now = utils.date(undefined, 'default');\n const startDate = utils.startOfWeek(now);\n const endDate = utils.endOfWeek(now);\n let current = startDate;\n while (utils.isBefore(current, endDate)) {\n elements.push(current);\n current = utils.addDays(current, 1);\n }\n return elements.map(weekDay => utils.formatByString(weekDay, format));\n};\nexport const getLetterEditingOptions = (utils, timezone, sectionType, format) => {\n switch (sectionType) {\n case 'month':\n {\n return getMonthsInYear(utils, utils.date(undefined, timezone)).map(month => utils.formatByString(month, format));\n }\n case 'weekDay':\n {\n return getDaysInWeekStr(utils, format);\n }\n case 'meridiem':\n {\n const now = utils.date(undefined, timezone);\n return [utils.startOfDay(now), utils.endOfDay(now)].map(date => utils.formatByString(date, format));\n }\n default:\n {\n return [];\n }\n }\n};\n\n// This format should be the same on all the adapters\n// If some adapter does not respect this convention, then we will need to hardcode the format on each adapter.\nexport const FORMAT_SECONDS_NO_LEADING_ZEROS = 's';\nconst NON_LOCALIZED_DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];\nexport const getLocalizedDigits = utils => {\n const today = utils.date(undefined);\n const formattedZero = utils.formatByString(utils.setSeconds(today, 0), FORMAT_SECONDS_NO_LEADING_ZEROS);\n if (formattedZero === '0') {\n return NON_LOCALIZED_DIGITS;\n }\n return Array.from({\n length: 10\n }).map((_, index) => utils.formatByString(utils.setSeconds(today, index), FORMAT_SECONDS_NO_LEADING_ZEROS));\n};\nexport const removeLocalizedDigits = (valueStr, localizedDigits) => {\n if (localizedDigits[0] === '0') {\n return valueStr;\n }\n const digits = [];\n let currentFormattedDigit = '';\n for (let i = 0; i < valueStr.length; i += 1) {\n currentFormattedDigit += valueStr[i];\n const matchingDigitIndex = localizedDigits.indexOf(currentFormattedDigit);\n if (matchingDigitIndex > -1) {\n digits.push(matchingDigitIndex.toString());\n currentFormattedDigit = '';\n }\n }\n return digits.join('');\n};\nexport const applyLocalizedDigits = (valueStr, localizedDigits) => {\n if (localizedDigits[0] === '0') {\n return valueStr;\n }\n return valueStr.split('').map(char => localizedDigits[Number(char)]).join('');\n};\nexport const isStringNumber = (valueStr, localizedDigits) => {\n const nonLocalizedValueStr = removeLocalizedDigits(valueStr, localizedDigits);\n // `Number(' ')` returns `0` even if ' ' is not a valid number.\n return nonLocalizedValueStr !== ' ' && !Number.isNaN(Number(nonLocalizedValueStr));\n};\n\n/**\n * Remove the leading zeroes to a digit section value.\n * E.g.: `03` => `3`\n * Warning: Should only be called with non-localized digits. Call `removeLocalizedDigits` with your value if needed.\n */\nexport const cleanLeadingZeros = (valueStr, size) => {\n let cleanValueStr = valueStr;\n\n // Remove the leading zeros\n cleanValueStr = Number(cleanValueStr).toString();\n\n // Add enough leading zeros to fill the section\n while (cleanValueStr.length < size) {\n cleanValueStr = `0${cleanValueStr}`;\n }\n return cleanValueStr;\n};\nexport const cleanDigitSectionValue = (utils, value, sectionBoundaries, localizedDigits, section) => {\n if (process.env.NODE_ENV !== 'production') {\n if (section.type !== 'day' && section.contentType === 'digit-with-letter') {\n throw new Error([`MUI X: The token \"${section.format}\" is a digit format with letter in it.'\n This type of format is only supported for 'day' sections`].join('\\n'));\n }\n }\n if (section.type === 'day' && section.contentType === 'digit-with-letter') {\n const date = utils.setDate(sectionBoundaries.longestMonth, value);\n return utils.formatByString(date, section.format);\n }\n\n // queryValue without leading `0` (`01` => `1`)\n let valueStr = value.toString();\n if (section.hasLeadingZerosInInput) {\n valueStr = cleanLeadingZeros(valueStr, section.maxLength);\n }\n return applyLocalizedDigits(valueStr, localizedDigits);\n};\nexport const adjustSectionValue = (utils, timezone, section, keyCode, sectionsValueBoundaries, localizedDigits, activeDate, stepsAttributes) => {\n const delta = getDeltaFromKeyCode(keyCode);\n const isStart = keyCode === 'Home';\n const isEnd = keyCode === 'End';\n const shouldSetAbsolute = section.value === '' || isStart || isEnd;\n const adjustDigitSection = () => {\n const sectionBoundaries = sectionsValueBoundaries[section.type]({\n currentDate: activeDate,\n format: section.format,\n contentType: section.contentType\n });\n const getCleanValue = value => cleanDigitSectionValue(utils, value, sectionBoundaries, localizedDigits, section);\n const step = section.type === 'minutes' && stepsAttributes?.minutesStep ? stepsAttributes.minutesStep : 1;\n let newSectionValueNumber;\n if (shouldSetAbsolute) {\n if (section.type === 'year' && !isEnd && !isStart) {\n return utils.formatByString(utils.date(undefined, timezone), section.format);\n }\n if (delta > 0 || isStart) {\n newSectionValueNumber = sectionBoundaries.minimum;\n } else {\n newSectionValueNumber = sectionBoundaries.maximum;\n }\n } else {\n const currentSectionValue = parseInt(removeLocalizedDigits(section.value, localizedDigits), 10);\n newSectionValueNumber = currentSectionValue + delta * step;\n }\n if (newSectionValueNumber % step !== 0) {\n if (delta < 0 || isStart) {\n newSectionValueNumber += step - (step + newSectionValueNumber) % step; // for JS -3 % 5 = -3 (should be 2)\n }\n if (delta > 0 || isEnd) {\n newSectionValueNumber -= newSectionValueNumber % step;\n }\n }\n if (newSectionValueNumber > sectionBoundaries.maximum) {\n return getCleanValue(sectionBoundaries.minimum + (newSectionValueNumber - sectionBoundaries.maximum - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));\n }\n if (newSectionValueNumber < sectionBoundaries.minimum) {\n return getCleanValue(sectionBoundaries.maximum - (sectionBoundaries.minimum - newSectionValueNumber - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));\n }\n return getCleanValue(newSectionValueNumber);\n };\n const adjustLetterSection = () => {\n const options = getLetterEditingOptions(utils, timezone, section.type, section.format);\n if (options.length === 0) {\n return section.value;\n }\n if (shouldSetAbsolute) {\n if (delta > 0 || isStart) {\n return options[0];\n }\n return options[options.length - 1];\n }\n const currentOptionIndex = options.indexOf(section.value);\n const newOptionIndex = (currentOptionIndex + delta) % options.length;\n const clampedIndex = (newOptionIndex + options.length) % options.length;\n return options[clampedIndex];\n };\n if (section.contentType === 'digit' || section.contentType === 'digit-with-letter') {\n return adjustDigitSection();\n }\n return adjustLetterSection();\n};\nexport const getSectionVisibleValue = (section, target, localizedDigits) => {\n let value = section.value || section.placeholder;\n const hasLeadingZeros = target === 'non-input' ? section.hasLeadingZerosInFormat : section.hasLeadingZerosInInput;\n if (target === 'non-input' && section.hasLeadingZerosInInput && !section.hasLeadingZerosInFormat) {\n value = Number(removeLocalizedDigits(value, localizedDigits)).toString();\n }\n\n // In the input, we add an empty character at the end of each section without leading zeros.\n // This makes sure that `onChange` will always be fired.\n // Otherwise, when your input value equals `1/dd/yyyy` (format `M/DD/YYYY` on DayJs),\n // If you press `1`, on the first section, the new value is also `1/dd/yyyy`,\n // So the browser will not fire the input `onChange`.\n const shouldAddInvisibleSpace = ['input-rtl', 'input-ltr'].includes(target) && section.contentType === 'digit' && !hasLeadingZeros && value.length === 1;\n if (shouldAddInvisibleSpace) {\n value = `${value}\\u200e`;\n }\n if (target === 'input-rtl') {\n value = `\\u2068${value}\\u2069`;\n }\n return value;\n};\nexport const changeSectionValueFormat = (utils, valueStr, currentFormat, newFormat) => {\n if (process.env.NODE_ENV !== 'production') {\n if (getDateSectionConfigFromFormatToken(utils, currentFormat).type === 'weekDay') {\n throw new Error(\"changeSectionValueFormat doesn't support week day formats\");\n }\n }\n return utils.formatByString(utils.parse(valueStr, currentFormat), newFormat);\n};\nconst isFourDigitYearFormat = (utils, format) => utils.formatByString(utils.date(undefined, 'system'), format).length === 4;\nexport const doesSectionFormatHaveLeadingZeros = (utils, contentType, sectionType, format) => {\n if (contentType !== 'digit') {\n return false;\n }\n const now = utils.date(undefined, 'default');\n switch (sectionType) {\n // We can't use `changeSectionValueFormat`, because `utils.parse('1', 'YYYY')` returns `1971` instead of `1`.\n case 'year':\n {\n // Remove once https://github.com/iamkun/dayjs/pull/2847 is merged and bump dayjs version\n if (utils.lib === 'dayjs' && format === 'YY') {\n return true;\n }\n return utils.formatByString(utils.setYear(now, 1), format).startsWith('0');\n }\n case 'month':\n {\n return utils.formatByString(utils.startOfYear(now), format).length > 1;\n }\n case 'day':\n {\n return utils.formatByString(utils.startOfMonth(now), format).length > 1;\n }\n case 'weekDay':\n {\n return utils.formatByString(utils.startOfWeek(now), format).length > 1;\n }\n case 'hours':\n {\n return utils.formatByString(utils.setHours(now, 1), format).length > 1;\n }\n case 'minutes':\n {\n return utils.formatByString(utils.setMinutes(now, 1), format).length > 1;\n }\n case 'seconds':\n {\n return utils.formatByString(utils.setSeconds(now, 1), format).length > 1;\n }\n default:\n {\n throw new Error('Invalid section type');\n }\n }\n};\n\n/**\n * Some date libraries like `dayjs` don't support parsing from date with escaped characters.\n * To make sure that the parsing works, we are building a format and a date without any separator.\n */\nexport const getDateFromDateSections = (utils, sections, localizedDigits) => {\n // If we have both a day and a weekDay section,\n // Then we skip the weekDay in the parsing because libraries like dayjs can't parse complicated formats containing a weekDay.\n // dayjs(dayjs().format('dddd MMMM D YYYY'), 'dddd MMMM D YYYY')) // returns `Invalid Date` even if the format is valid.\n const shouldSkipWeekDays = sections.some(section => section.type === 'day');\n const sectionFormats = [];\n const sectionValues = [];\n for (let i = 0; i < sections.length; i += 1) {\n const section = sections[i];\n const shouldSkip = shouldSkipWeekDays && section.type === 'weekDay';\n if (!shouldSkip) {\n sectionFormats.push(section.format);\n sectionValues.push(getSectionVisibleValue(section, 'non-input', localizedDigits));\n }\n }\n const formatWithoutSeparator = sectionFormats.join(' ');\n const dateWithoutSeparatorStr = sectionValues.join(' ');\n return utils.parse(dateWithoutSeparatorStr, formatWithoutSeparator);\n};\nexport const createDateStrForV7HiddenInputFromSections = sections => sections.map(section => {\n return `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`;\n}).join('');\nexport const createDateStrForV6InputFromSections = (sections, localizedDigits, isRtl) => {\n const formattedSections = sections.map(section => {\n const dateValue = getSectionVisibleValue(section, isRtl ? 'input-rtl' : 'input-ltr', localizedDigits);\n return `${section.startSeparator}${dateValue}${section.endSeparator}`;\n });\n const dateStr = formattedSections.join('');\n if (!isRtl) {\n return dateStr;\n }\n\n // \\u2066: start left-to-right isolation\n // \\u2067: start right-to-left isolation\n // \\u2068: start first strong character isolation\n // \\u2069: pop isolation\n // wrap into an isolated group such that separators can split the string in smaller ones by adding \\u2069\\u2068\n return `\\u2066${dateStr}\\u2069`;\n};\nexport const getSectionsBoundaries = (utils, localizedDigits, timezone) => {\n const today = utils.date(undefined, timezone);\n const endOfYear = utils.endOfYear(today);\n const endOfDay = utils.endOfDay(today);\n const {\n maxDaysInMonth,\n longestMonth\n } = getMonthsInYear(utils, today).reduce((acc, month) => {\n const daysInMonth = utils.getDaysInMonth(month);\n if (daysInMonth > acc.maxDaysInMonth) {\n return {\n maxDaysInMonth: daysInMonth,\n longestMonth: month\n };\n }\n return acc;\n }, {\n maxDaysInMonth: 0,\n longestMonth: null\n });\n return {\n year: ({\n format\n }) => ({\n minimum: 0,\n maximum: isFourDigitYearFormat(utils, format) ? 9999 : 99\n }),\n month: () => ({\n minimum: 1,\n // Assumption: All years have the same amount of months\n maximum: utils.getMonth(endOfYear) + 1\n }),\n day: ({\n currentDate\n }) => ({\n minimum: 1,\n maximum: currentDate != null && utils.isValid(currentDate) ? utils.getDaysInMonth(currentDate) : maxDaysInMonth,\n longestMonth: longestMonth\n }),\n weekDay: ({\n format,\n contentType\n }) => {\n if (contentType === 'digit') {\n const daysInWeek = getDaysInWeekStr(utils, format).map(Number);\n return {\n minimum: Math.min(...daysInWeek),\n maximum: Math.max(...daysInWeek)\n };\n }\n return {\n minimum: 1,\n maximum: 7\n };\n },\n hours: ({\n format\n }) => {\n const lastHourInDay = utils.getHours(endOfDay);\n const hasMeridiem = removeLocalizedDigits(utils.formatByString(utils.endOfDay(today), format), localizedDigits) !== lastHourInDay.toString();\n if (hasMeridiem) {\n return {\n minimum: 1,\n maximum: Number(removeLocalizedDigits(utils.formatByString(utils.startOfDay(today), format), localizedDigits))\n };\n }\n return {\n minimum: 0,\n maximum: lastHourInDay\n };\n },\n minutes: () => ({\n minimum: 0,\n // Assumption: All years have the same amount of minutes\n maximum: utils.getMinutes(endOfDay)\n }),\n seconds: () => ({\n minimum: 0,\n // Assumption: All years have the same amount of seconds\n maximum: utils.getSeconds(endOfDay)\n }),\n meridiem: () => ({\n minimum: 0,\n maximum: 1\n }),\n empty: () => ({\n minimum: 0,\n maximum: 0\n })\n };\n};\nlet warnedOnceInvalidSection = false;\nexport const validateSections = (sections, valueType) => {\n if (process.env.NODE_ENV !== 'production') {\n if (!warnedOnceInvalidSection) {\n const supportedSections = ['empty'];\n if (['date', 'date-time'].includes(valueType)) {\n supportedSections.push('weekDay', 'day', 'month', 'year');\n }\n if (['time', 'date-time'].includes(valueType)) {\n supportedSections.push('hours', 'minutes', 'seconds', 'meridiem');\n }\n const invalidSection = sections.find(section => !supportedSections.includes(section.type));\n if (invalidSection) {\n console.warn(`MUI X: The field component you are using is not compatible with the \"${invalidSection.type}\" date section.`, `The supported date sections are [\"${supportedSections.join('\", \"')}\"]\\`.`);\n warnedOnceInvalidSection = true;\n }\n }\n }\n};\nconst transferDateSectionValue = (utils, section, dateToTransferFrom, dateToTransferTo) => {\n switch (section.type) {\n case 'year':\n {\n return utils.setYear(dateToTransferTo, utils.getYear(dateToTransferFrom));\n }\n case 'month':\n {\n return utils.setMonth(dateToTransferTo, utils.getMonth(dateToTransferFrom));\n }\n case 'weekDay':\n {\n const formattedDaysInWeek = getDaysInWeekStr(utils, section.format);\n const dayInWeekStrOfActiveDate = utils.formatByString(dateToTransferFrom, section.format);\n const dayInWeekOfActiveDate = formattedDaysInWeek.indexOf(dayInWeekStrOfActiveDate);\n const dayInWeekOfNewSectionValue = formattedDaysInWeek.indexOf(section.value);\n const diff = dayInWeekOfNewSectionValue - dayInWeekOfActiveDate;\n return utils.addDays(dateToTransferFrom, diff);\n }\n case 'day':\n {\n return utils.setDate(dateToTransferTo, utils.getDate(dateToTransferFrom));\n }\n case 'meridiem':\n {\n const isAM = utils.getHours(dateToTransferFrom) < 12;\n const mergedDateHours = utils.getHours(dateToTransferTo);\n if (isAM && mergedDateHours >= 12) {\n return utils.addHours(dateToTransferTo, -12);\n }\n if (!isAM && mergedDateHours < 12) {\n return utils.addHours(dateToTransferTo, 12);\n }\n return dateToTransferTo;\n }\n case 'hours':\n {\n return utils.setHours(dateToTransferTo, utils.getHours(dateToTransferFrom));\n }\n case 'minutes':\n {\n return utils.setMinutes(dateToTransferTo, utils.getMinutes(dateToTransferFrom));\n }\n case 'seconds':\n {\n return utils.setSeconds(dateToTransferTo, utils.getSeconds(dateToTransferFrom));\n }\n default:\n {\n return dateToTransferTo;\n }\n }\n};\nconst reliableSectionModificationOrder = {\n year: 1,\n month: 2,\n day: 3,\n weekDay: 4,\n hours: 5,\n minutes: 6,\n seconds: 7,\n meridiem: 8,\n empty: 9\n};\nexport const mergeDateIntoReferenceDate = (utils, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) =>\n// cloning sections before sort to avoid mutating it\n[...sections].sort((a, b) => reliableSectionModificationOrder[a.type] - reliableSectionModificationOrder[b.type]).reduce((mergedDate, section) => {\n if (!shouldLimitToEditedSections || section.modified) {\n return transferDateSectionValue(utils, section, dateToTransferFrom, mergedDate);\n }\n return mergedDate;\n}, referenceDate);\nexport const isAndroid = () => navigator.userAgent.toLowerCase().includes('android');\n\n// TODO v8: Remove if we drop the v6 TextField approach.\nexport const getSectionOrder = (sections, shouldApplyRTL) => {\n const neighbors = {};\n if (!shouldApplyRTL) {\n sections.forEach((_, index) => {\n const leftIndex = index === 0 ? null : index - 1;\n const rightIndex = index === sections.length - 1 ? null : index + 1;\n neighbors[index] = {\n leftIndex,\n rightIndex\n };\n });\n return {\n neighbors,\n startIndex: 0,\n endIndex: sections.length - 1\n };\n }\n const rtl2ltr = {};\n const ltr2rtl = {};\n let groupedSectionsStart = 0;\n let groupedSectionsEnd = 0;\n let RTLIndex = sections.length - 1;\n while (RTLIndex >= 0) {\n groupedSectionsEnd = sections.findIndex(\n // eslint-disable-next-line @typescript-eslint/no-loop-func\n (section, index) => index >= groupedSectionsStart && section.endSeparator?.includes(' ') &&\n // Special case where the spaces were not there in the initial input\n section.endSeparator !== ' / ');\n if (groupedSectionsEnd === -1) {\n groupedSectionsEnd = sections.length - 1;\n }\n for (let i = groupedSectionsEnd; i >= groupedSectionsStart; i -= 1) {\n ltr2rtl[i] = RTLIndex;\n rtl2ltr[RTLIndex] = i;\n RTLIndex -= 1;\n }\n groupedSectionsStart = groupedSectionsEnd + 1;\n }\n sections.forEach((_, index) => {\n const rtlIndex = ltr2rtl[index];\n const leftIndex = rtlIndex === 0 ? null : rtl2ltr[rtlIndex - 1];\n const rightIndex = rtlIndex === sections.length - 1 ? null : rtl2ltr[rtlIndex + 1];\n neighbors[index] = {\n leftIndex,\n rightIndex\n };\n });\n return {\n neighbors,\n startIndex: rtl2ltr[0],\n endIndex: rtl2ltr[sections.length - 1]\n };\n};\nexport const parseSelectedSections = (selectedSections, sections) => {\n if (selectedSections == null) {\n return null;\n }\n if (selectedSections === 'all') {\n return 'all';\n }\n if (typeof selectedSections === 'string') {\n const index = sections.findIndex(section => section.type === selectedSections);\n return index === -1 ? null : index;\n }\n return selectedSections;\n};\nexport const getSectionValueText = (section, utils) => {\n if (!section.value) {\n return undefined;\n }\n switch (section.type) {\n case 'month':\n {\n if (section.contentType === 'digit') {\n return utils.format(utils.setMonth(utils.date(), Number(section.value) - 1), 'month');\n }\n const parsedDate = utils.parse(section.value, section.format);\n return parsedDate ? utils.format(parsedDate, 'month') : undefined;\n }\n case 'day':\n return section.contentType === 'digit' ? utils.format(utils.setDate(utils.startOfYear(utils.date()), Number(section.value)), 'dayOfMonthFull') : section.value;\n case 'weekDay':\n // TODO: improve by providing the label of the week day\n return undefined;\n default:\n return undefined;\n }\n};\nexport const getSectionValueNow = (section, utils) => {\n if (!section.value) {\n return undefined;\n }\n switch (section.type) {\n case 'weekDay':\n {\n if (section.contentType === 'letter') {\n // TODO: improve by resolving the week day number from a letter week day\n return undefined;\n }\n return Number(section.value);\n }\n case 'meridiem':\n {\n const parsedDate = utils.parse(`01:00 ${section.value}`, `${utils.formats.hours12h}:${utils.formats.minutes} ${section.format}`);\n if (parsedDate) {\n return utils.getHours(parsedDate) >= 12 ? 1 : 0;\n }\n return undefined;\n }\n case 'day':\n return section.contentType === 'digit-with-letter' ? parseInt(section.value, 10) : Number(section.value);\n case 'month':\n {\n if (section.contentType === 'digit') {\n return Number(section.value);\n }\n const parsedDate = utils.parse(section.value, section.format);\n return parsedDate ? utils.getMonth(parsedDate) + 1 : undefined;\n }\n default:\n return section.contentType !== 'letter' ? Number(section.value) : undefined;\n }\n};"],"names":["getDateSectionConfigFromFormatToken","utils","formatToken","config","formatTokenMap","Error","join","type","contentType","maxLength","undefined","sectionType","getDaysInWeekStr","format","elements","now","date","startDate","startOfWeek","endDate","endOfWeek","current","isBefore","push","addDays","map","weekDay","formatByString","getLetterEditingOptions","timezone","getMonthsInYear","month","startOfDay","endOfDay","FORMAT_SECONDS_NO_LEADING_ZEROS","NON_LOCALIZED_DIGITS","getLocalizedDigits","today","setSeconds","Array","from","length","_","index","removeLocalizedDigits","valueStr","localizedDigits","digits","currentFormattedDigit","i","matchingDigitIndex","indexOf","toString","applyLocalizedDigits","split","char","Number","isStringNumber","nonLocalizedValueStr","isNaN","cleanLeadingZeros","size","cleanValueStr","cleanDigitSectionValue","value","sectionBoundaries","section","process","env","NODE_ENV","setDate","longestMonth","hasLeadingZerosInInput","adjustSectionValue","keyCode","sectionsValueBoundaries","activeDate","stepsAttributes","delta","getDeltaFromKeyCode","isStart","isEnd","shouldSetAbsolute","currentDate","getCleanValue","step","minutesStep","newSectionValueNumber","minimum","maximum","parseInt","adjustDigitSection","options","currentOptionIndex","adjustLetterSection","getSectionVisibleValue","target","placeholder","hasLeadingZeros","hasLeadingZerosInFormat","includes","changeSectionValueFormat","currentFormat","newFormat","parse","isFourDigitYearFormat","doesSectionFormatHaveLeadingZeros","lib","setYear","startsWith","startOfYear","startOfMonth","setHours","setMinutes","getDateFromDateSections","sections","shouldSkipWeekDays","some","sectionFormats","sectionValues","formatWithoutSeparator","dateWithoutSeparatorStr","createDateStrForV7HiddenInputFromSections","startSeparator","endSeparator","createDateStrForV6InputFromSections","isRtl","dateStr","dateValue","getSectionsBoundaries","endOfYear","maxDaysInMonth","reduce","acc","daysInMonth","getDaysInMonth","year","getMonth","day","isValid","daysInWeek","Math","min","max","hours","lastHourInDay","getHours","minutes","getMinutes","seconds","getSeconds","meridiem","empty","warnedOnceInvalidSection","validateSections","valueType","supportedSections","invalidSection","find","console","warn","reliableSectionModificationOrder","mergeDateIntoReferenceDate","dateToTransferFrom","referenceDate","shouldLimitToEditedSections","sort","a","b","mergedDate","modified","dateToTransferTo","getYear","setMonth","formattedDaysInWeek","dayInWeekStrOfActiveDate","dayInWeekOfActiveDate","diff","getDate","isAM","mergedDateHours","addHours","transferDateSectionValue","isAndroid","navigator","userAgent","toLowerCase","getSectionOrder","shouldApplyRTL","neighbors","forEach","leftIndex","rightIndex","startIndex","endIndex","rtl2ltr","ltr2rtl","groupedSectionsStart","groupedSectionsEnd","RTLIndex","findIndex","rtlIndex","parseSelectedSections","selectedSections","getSectionValueText","parsedDate","getSectionValueNow","formats","hours12h"],"mappings":"4DACY,MAAC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rD,UACvH,OAAIgM,EACK5M,EAAMiJ,SAAS2D,IAAe,GAAK,EAAI,OAEhD,CACD,CACH,IAAK,MACH,MAA+B,sBAAxB3I,EAAQ1D,YAAsCkF,SAASxB,EAAQF,MAAO,IAAMR,OAAOU,EAAQF,OACpG,IAAK,QACH,CACE,GAA4B,UAAxBE,EAAQ1D,YACV,OAAOgD,OAAOU,EAAQF,OAExB,MAAM6I,EAAa5M,EAAMuG,MAAMtC,EAAQF,MAAOE,EAAQrD,QACtD,OAAOgM,EAAa5M,EAAMwI,SAASoE,GAAc,OAAInM,CACtD,CACH,QACE,MAA+B,WAAxBwD,EAAQ1D,YAA2BgD,OAAOU,EAAQF,YAAStD,EACrE"}
|
1
|
+
{"version":3,"file":"useField.utils.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.utils.js"],"sourcesContent":["import { getMonthsInYear } from \"../../utils/date-utils.js\";\nexport const getDateSectionConfigFromFormatToken = (utils, formatToken) => {\n const config = utils.formatTokenMap[formatToken];\n if (config == null) {\n throw new Error([`MUI X: The token \"${formatToken}\" is not supported by the Date and Time Pickers.`, 'Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported.'].join('\\n'));\n }\n if (typeof config === 'string') {\n return {\n type: config,\n contentType: config === 'meridiem' ? 'letter' : 'digit',\n maxLength: undefined\n };\n }\n return {\n type: config.sectionType,\n contentType: config.contentType,\n maxLength: config.maxLength\n };\n};\nconst getDeltaFromKeyCode = keyCode => {\n switch (keyCode) {\n case 'ArrowUp':\n return 1;\n case 'ArrowDown':\n return -1;\n case 'PageUp':\n return 5;\n case 'PageDown':\n return -5;\n default:\n return 0;\n }\n};\nexport const getDaysInWeekStr = (utils, format) => {\n const elements = [];\n const now = utils.date(undefined, 'default');\n const startDate = utils.startOfWeek(now);\n const endDate = utils.endOfWeek(now);\n let current = startDate;\n while (utils.isBefore(current, endDate)) {\n elements.push(current);\n current = utils.addDays(current, 1);\n }\n return elements.map(weekDay => utils.formatByString(weekDay, format));\n};\nexport const getLetterEditingOptions = (utils, timezone, sectionType, format) => {\n switch (sectionType) {\n case 'month':\n {\n return getMonthsInYear(utils, utils.date(undefined, timezone)).map(month => utils.formatByString(month, format));\n }\n case 'weekDay':\n {\n return getDaysInWeekStr(utils, format);\n }\n case 'meridiem':\n {\n const now = utils.date(undefined, timezone);\n return [utils.startOfDay(now), utils.endOfDay(now)].map(date => utils.formatByString(date, format));\n }\n default:\n {\n return [];\n }\n }\n};\n\n// This format should be the same on all the adapters\n// If some adapter does not respect this convention, then we will need to hardcode the format on each adapter.\nexport const FORMAT_SECONDS_NO_LEADING_ZEROS = 's';\nconst NON_LOCALIZED_DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];\nexport const getLocalizedDigits = utils => {\n const today = utils.date(undefined);\n const formattedZero = utils.formatByString(utils.setSeconds(today, 0), FORMAT_SECONDS_NO_LEADING_ZEROS);\n if (formattedZero === '0') {\n return NON_LOCALIZED_DIGITS;\n }\n return Array.from({\n length: 10\n }).map((_, index) => utils.formatByString(utils.setSeconds(today, index), FORMAT_SECONDS_NO_LEADING_ZEROS));\n};\nexport const removeLocalizedDigits = (valueStr, localizedDigits) => {\n if (localizedDigits[0] === '0') {\n return valueStr;\n }\n const digits = [];\n let currentFormattedDigit = '';\n for (let i = 0; i < valueStr.length; i += 1) {\n currentFormattedDigit += valueStr[i];\n const matchingDigitIndex = localizedDigits.indexOf(currentFormattedDigit);\n if (matchingDigitIndex > -1) {\n digits.push(matchingDigitIndex.toString());\n currentFormattedDigit = '';\n }\n }\n return digits.join('');\n};\nexport const applyLocalizedDigits = (valueStr, localizedDigits) => {\n if (localizedDigits[0] === '0') {\n return valueStr;\n }\n return valueStr.split('').map(char => localizedDigits[Number(char)]).join('');\n};\nexport const isStringNumber = (valueStr, localizedDigits) => {\n const nonLocalizedValueStr = removeLocalizedDigits(valueStr, localizedDigits);\n // `Number(' ')` returns `0` even if ' ' is not a valid number.\n return nonLocalizedValueStr !== ' ' && !Number.isNaN(Number(nonLocalizedValueStr));\n};\n\n/**\n * Remove the leading zeroes to a digit section value.\n * E.g.: `03` => `3`\n * Warning: Should only be called with non-localized digits. Call `removeLocalizedDigits` with your value if needed.\n */\nexport const cleanLeadingZeros = (valueStr, size) => {\n let cleanValueStr = valueStr;\n\n // Remove the leading zeros\n cleanValueStr = Number(cleanValueStr).toString();\n\n // Add enough leading zeros to fill the section\n while (cleanValueStr.length < size) {\n cleanValueStr = `0${cleanValueStr}`;\n }\n return cleanValueStr;\n};\nexport const cleanDigitSectionValue = (utils, value, sectionBoundaries, localizedDigits, section) => {\n if (process.env.NODE_ENV !== 'production') {\n if (section.type !== 'day' && section.contentType === 'digit-with-letter') {\n throw new Error([`MUI X: The token \"${section.format}\" is a digit format with letter in it.'\n This type of format is only supported for 'day' sections`].join('\\n'));\n }\n }\n if (section.type === 'day' && section.contentType === 'digit-with-letter') {\n const date = utils.setDate(sectionBoundaries.longestMonth, value);\n return utils.formatByString(date, section.format);\n }\n\n // queryValue without leading `0` (`01` => `1`)\n let valueStr = value.toString();\n if (section.hasLeadingZerosInInput) {\n valueStr = cleanLeadingZeros(valueStr, section.maxLength);\n }\n return applyLocalizedDigits(valueStr, localizedDigits);\n};\nexport const adjustSectionValue = (utils, timezone, section, keyCode, sectionsValueBoundaries, localizedDigits, activeDate, stepsAttributes) => {\n const delta = getDeltaFromKeyCode(keyCode);\n const isStart = keyCode === 'Home';\n const isEnd = keyCode === 'End';\n const shouldSetAbsolute = section.value === '' || isStart || isEnd;\n const adjustDigitSection = () => {\n const sectionBoundaries = sectionsValueBoundaries[section.type]({\n currentDate: activeDate,\n format: section.format,\n contentType: section.contentType\n });\n const getCleanValue = value => cleanDigitSectionValue(utils, value, sectionBoundaries, localizedDigits, section);\n const step = section.type === 'minutes' && stepsAttributes?.minutesStep ? stepsAttributes.minutesStep : 1;\n const currentSectionValue = parseInt(removeLocalizedDigits(section.value, localizedDigits), 10);\n let newSectionValueNumber = currentSectionValue + delta * step;\n if (shouldSetAbsolute) {\n if (section.type === 'year' && !isEnd && !isStart) {\n return utils.formatByString(utils.date(undefined, timezone), section.format);\n }\n if (delta > 0 || isStart) {\n newSectionValueNumber = sectionBoundaries.minimum;\n } else {\n newSectionValueNumber = sectionBoundaries.maximum;\n }\n }\n if (newSectionValueNumber % step !== 0) {\n if (delta < 0 || isStart) {\n newSectionValueNumber += step - (step + newSectionValueNumber) % step; // for JS -3 % 5 = -3 (should be 2)\n }\n if (delta > 0 || isEnd) {\n newSectionValueNumber -= newSectionValueNumber % step;\n }\n }\n if (newSectionValueNumber > sectionBoundaries.maximum) {\n return getCleanValue(sectionBoundaries.minimum + (newSectionValueNumber - sectionBoundaries.maximum - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));\n }\n if (newSectionValueNumber < sectionBoundaries.minimum) {\n return getCleanValue(sectionBoundaries.maximum - (sectionBoundaries.minimum - newSectionValueNumber - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));\n }\n return getCleanValue(newSectionValueNumber);\n };\n const adjustLetterSection = () => {\n const options = getLetterEditingOptions(utils, timezone, section.type, section.format);\n if (options.length === 0) {\n return section.value;\n }\n if (shouldSetAbsolute) {\n if (delta > 0 || isStart) {\n return options[0];\n }\n return options[options.length - 1];\n }\n const currentOptionIndex = options.indexOf(section.value);\n const newOptionIndex = (currentOptionIndex + delta) % options.length;\n const clampedIndex = (newOptionIndex + options.length) % options.length;\n return options[clampedIndex];\n };\n if (section.contentType === 'digit' || section.contentType === 'digit-with-letter') {\n return adjustDigitSection();\n }\n return adjustLetterSection();\n};\nexport const getSectionVisibleValue = (section, target, localizedDigits) => {\n let value = section.value || section.placeholder;\n const hasLeadingZeros = target === 'non-input' ? section.hasLeadingZerosInFormat : section.hasLeadingZerosInInput;\n if (target === 'non-input' && section.hasLeadingZerosInInput && !section.hasLeadingZerosInFormat) {\n value = Number(removeLocalizedDigits(value, localizedDigits)).toString();\n }\n\n // In the input, we add an empty character at the end of each section without leading zeros.\n // This makes sure that `onChange` will always be fired.\n // Otherwise, when your input value equals `1/dd/yyyy` (format `M/DD/YYYY` on DayJs),\n // If you press `1`, on the first section, the new value is also `1/dd/yyyy`,\n // So the browser will not fire the input `onChange`.\n const shouldAddInvisibleSpace = ['input-rtl', 'input-ltr'].includes(target) && section.contentType === 'digit' && !hasLeadingZeros && value.length === 1;\n if (shouldAddInvisibleSpace) {\n value = `${value}\\u200e`;\n }\n if (target === 'input-rtl') {\n value = `\\u2068${value}\\u2069`;\n }\n return value;\n};\nexport const changeSectionValueFormat = (utils, valueStr, currentFormat, newFormat) => {\n if (process.env.NODE_ENV !== 'production') {\n if (getDateSectionConfigFromFormatToken(utils, currentFormat).type === 'weekDay') {\n throw new Error(\"changeSectionValueFormat doesn't support week day formats\");\n }\n }\n return utils.formatByString(utils.parse(valueStr, currentFormat), newFormat);\n};\nconst isFourDigitYearFormat = (utils, format) => utils.formatByString(utils.date(undefined, 'system'), format).length === 4;\nexport const doesSectionFormatHaveLeadingZeros = (utils, contentType, sectionType, format) => {\n if (contentType !== 'digit') {\n return false;\n }\n const now = utils.date(undefined, 'default');\n switch (sectionType) {\n // We can't use `changeSectionValueFormat`, because `utils.parse('1', 'YYYY')` returns `1971` instead of `1`.\n case 'year':\n {\n if (isFourDigitYearFormat(utils, format)) {\n const formatted0001 = utils.formatByString(utils.setYear(now, 1), format);\n return formatted0001 === '0001';\n }\n const formatted2001 = utils.formatByString(utils.setYear(now, 2001), format);\n return formatted2001 === '01';\n }\n case 'month':\n {\n return utils.formatByString(utils.startOfYear(now), format).length > 1;\n }\n case 'day':\n {\n return utils.formatByString(utils.startOfMonth(now), format).length > 1;\n }\n case 'weekDay':\n {\n return utils.formatByString(utils.startOfWeek(now), format).length > 1;\n }\n case 'hours':\n {\n return utils.formatByString(utils.setHours(now, 1), format).length > 1;\n }\n case 'minutes':\n {\n return utils.formatByString(utils.setMinutes(now, 1), format).length > 1;\n }\n case 'seconds':\n {\n return utils.formatByString(utils.setSeconds(now, 1), format).length > 1;\n }\n default:\n {\n throw new Error('Invalid section type');\n }\n }\n};\n\n/**\n * Some date libraries like `dayjs` don't support parsing from date with escaped characters.\n * To make sure that the parsing works, we are building a format and a date without any separator.\n */\nexport const getDateFromDateSections = (utils, sections, localizedDigits) => {\n // If we have both a day and a weekDay section,\n // Then we skip the weekDay in the parsing because libraries like dayjs can't parse complicated formats containing a weekDay.\n // dayjs(dayjs().format('dddd MMMM D YYYY'), 'dddd MMMM D YYYY')) // returns `Invalid Date` even if the format is valid.\n const shouldSkipWeekDays = sections.some(section => section.type === 'day');\n const sectionFormats = [];\n const sectionValues = [];\n for (let i = 0; i < sections.length; i += 1) {\n const section = sections[i];\n const shouldSkip = shouldSkipWeekDays && section.type === 'weekDay';\n if (!shouldSkip) {\n sectionFormats.push(section.format);\n sectionValues.push(getSectionVisibleValue(section, 'non-input', localizedDigits));\n }\n }\n const formatWithoutSeparator = sectionFormats.join(' ');\n const dateWithoutSeparatorStr = sectionValues.join(' ');\n return utils.parse(dateWithoutSeparatorStr, formatWithoutSeparator);\n};\nexport const createDateStrForV7HiddenInputFromSections = sections => sections.map(section => {\n return `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`;\n}).join('');\nexport const createDateStrForV6InputFromSections = (sections, localizedDigits, isRtl) => {\n const formattedSections = sections.map(section => {\n const dateValue = getSectionVisibleValue(section, isRtl ? 'input-rtl' : 'input-ltr', localizedDigits);\n return `${section.startSeparator}${dateValue}${section.endSeparator}`;\n });\n const dateStr = formattedSections.join('');\n if (!isRtl) {\n return dateStr;\n }\n\n // \\u2066: start left-to-right isolation\n // \\u2067: start right-to-left isolation\n // \\u2068: start first strong character isolation\n // \\u2069: pop isolation\n // wrap into an isolated group such that separators can split the string in smaller ones by adding \\u2069\\u2068\n return `\\u2066${dateStr}\\u2069`;\n};\nexport const getSectionsBoundaries = (utils, localizedDigits, timezone) => {\n const today = utils.date(undefined, timezone);\n const endOfYear = utils.endOfYear(today);\n const endOfDay = utils.endOfDay(today);\n const {\n maxDaysInMonth,\n longestMonth\n } = getMonthsInYear(utils, today).reduce((acc, month) => {\n const daysInMonth = utils.getDaysInMonth(month);\n if (daysInMonth > acc.maxDaysInMonth) {\n return {\n maxDaysInMonth: daysInMonth,\n longestMonth: month\n };\n }\n return acc;\n }, {\n maxDaysInMonth: 0,\n longestMonth: null\n });\n return {\n year: ({\n format\n }) => ({\n minimum: 0,\n maximum: isFourDigitYearFormat(utils, format) ? 9999 : 99\n }),\n month: () => ({\n minimum: 1,\n // Assumption: All years have the same amount of months\n maximum: utils.getMonth(endOfYear) + 1\n }),\n day: ({\n currentDate\n }) => ({\n minimum: 1,\n maximum: currentDate != null && utils.isValid(currentDate) ? utils.getDaysInMonth(currentDate) : maxDaysInMonth,\n longestMonth: longestMonth\n }),\n weekDay: ({\n format,\n contentType\n }) => {\n if (contentType === 'digit') {\n const daysInWeek = getDaysInWeekStr(utils, format).map(Number);\n return {\n minimum: Math.min(...daysInWeek),\n maximum: Math.max(...daysInWeek)\n };\n }\n return {\n minimum: 1,\n maximum: 7\n };\n },\n hours: ({\n format\n }) => {\n const lastHourInDay = utils.getHours(endOfDay);\n const hasMeridiem = removeLocalizedDigits(utils.formatByString(utils.endOfDay(today), format), localizedDigits) !== lastHourInDay.toString();\n if (hasMeridiem) {\n return {\n minimum: 1,\n maximum: Number(removeLocalizedDigits(utils.formatByString(utils.startOfDay(today), format), localizedDigits))\n };\n }\n return {\n minimum: 0,\n maximum: lastHourInDay\n };\n },\n minutes: () => ({\n minimum: 0,\n // Assumption: All years have the same amount of minutes\n maximum: utils.getMinutes(endOfDay)\n }),\n seconds: () => ({\n minimum: 0,\n // Assumption: All years have the same amount of seconds\n maximum: utils.getSeconds(endOfDay)\n }),\n meridiem: () => ({\n minimum: 0,\n maximum: 1\n }),\n empty: () => ({\n minimum: 0,\n maximum: 0\n })\n };\n};\nlet warnedOnceInvalidSection = false;\nexport const validateSections = (sections, valueType) => {\n if (process.env.NODE_ENV !== 'production') {\n if (!warnedOnceInvalidSection) {\n const supportedSections = ['empty'];\n if (['date', 'date-time'].includes(valueType)) {\n supportedSections.push('weekDay', 'day', 'month', 'year');\n }\n if (['time', 'date-time'].includes(valueType)) {\n supportedSections.push('hours', 'minutes', 'seconds', 'meridiem');\n }\n const invalidSection = sections.find(section => !supportedSections.includes(section.type));\n if (invalidSection) {\n console.warn(`MUI X: The field component you are using is not compatible with the \"${invalidSection.type}\" date section.`, `The supported date sections are [\"${supportedSections.join('\", \"')}\"]\\`.`);\n warnedOnceInvalidSection = true;\n }\n }\n }\n};\nconst transferDateSectionValue = (utils, section, dateToTransferFrom, dateToTransferTo) => {\n switch (section.type) {\n case 'year':\n {\n return utils.setYear(dateToTransferTo, utils.getYear(dateToTransferFrom));\n }\n case 'month':\n {\n return utils.setMonth(dateToTransferTo, utils.getMonth(dateToTransferFrom));\n }\n case 'weekDay':\n {\n const formattedDaysInWeek = getDaysInWeekStr(utils, section.format);\n const dayInWeekStrOfActiveDate = utils.formatByString(dateToTransferFrom, section.format);\n const dayInWeekOfActiveDate = formattedDaysInWeek.indexOf(dayInWeekStrOfActiveDate);\n const dayInWeekOfNewSectionValue = formattedDaysInWeek.indexOf(section.value);\n const diff = dayInWeekOfNewSectionValue - dayInWeekOfActiveDate;\n return utils.addDays(dateToTransferFrom, diff);\n }\n case 'day':\n {\n return utils.setDate(dateToTransferTo, utils.getDate(dateToTransferFrom));\n }\n case 'meridiem':\n {\n const isAM = utils.getHours(dateToTransferFrom) < 12;\n const mergedDateHours = utils.getHours(dateToTransferTo);\n if (isAM && mergedDateHours >= 12) {\n return utils.addHours(dateToTransferTo, -12);\n }\n if (!isAM && mergedDateHours < 12) {\n return utils.addHours(dateToTransferTo, 12);\n }\n return dateToTransferTo;\n }\n case 'hours':\n {\n return utils.setHours(dateToTransferTo, utils.getHours(dateToTransferFrom));\n }\n case 'minutes':\n {\n return utils.setMinutes(dateToTransferTo, utils.getMinutes(dateToTransferFrom));\n }\n case 'seconds':\n {\n return utils.setSeconds(dateToTransferTo, utils.getSeconds(dateToTransferFrom));\n }\n default:\n {\n return dateToTransferTo;\n }\n }\n};\nconst reliableSectionModificationOrder = {\n year: 1,\n month: 2,\n day: 3,\n weekDay: 4,\n hours: 5,\n minutes: 6,\n seconds: 7,\n meridiem: 8,\n empty: 9\n};\nexport const mergeDateIntoReferenceDate = (utils, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) =>\n// cloning sections before sort to avoid mutating it\n[...sections].sort((a, b) => reliableSectionModificationOrder[a.type] - reliableSectionModificationOrder[b.type]).reduce((mergedDate, section) => {\n if (!shouldLimitToEditedSections || section.modified) {\n return transferDateSectionValue(utils, section, dateToTransferFrom, mergedDate);\n }\n return mergedDate;\n}, referenceDate);\nexport const isAndroid = () => navigator.userAgent.toLowerCase().includes('android');\n\n// TODO v8: Remove if we drop the v6 TextField approach.\nexport const getSectionOrder = (sections, shouldApplyRTL) => {\n const neighbors = {};\n if (!shouldApplyRTL) {\n sections.forEach((_, index) => {\n const leftIndex = index === 0 ? null : index - 1;\n const rightIndex = index === sections.length - 1 ? null : index + 1;\n neighbors[index] = {\n leftIndex,\n rightIndex\n };\n });\n return {\n neighbors,\n startIndex: 0,\n endIndex: sections.length - 1\n };\n }\n const rtl2ltr = {};\n const ltr2rtl = {};\n let groupedSectionsStart = 0;\n let groupedSectionsEnd = 0;\n let RTLIndex = sections.length - 1;\n while (RTLIndex >= 0) {\n groupedSectionsEnd = sections.findIndex(\n // eslint-disable-next-line @typescript-eslint/no-loop-func\n (section, index) => index >= groupedSectionsStart && section.endSeparator?.includes(' ') &&\n // Special case where the spaces were not there in the initial input\n section.endSeparator !== ' / ');\n if (groupedSectionsEnd === -1) {\n groupedSectionsEnd = sections.length - 1;\n }\n for (let i = groupedSectionsEnd; i >= groupedSectionsStart; i -= 1) {\n ltr2rtl[i] = RTLIndex;\n rtl2ltr[RTLIndex] = i;\n RTLIndex -= 1;\n }\n groupedSectionsStart = groupedSectionsEnd + 1;\n }\n sections.forEach((_, index) => {\n const rtlIndex = ltr2rtl[index];\n const leftIndex = rtlIndex === 0 ? null : rtl2ltr[rtlIndex - 1];\n const rightIndex = rtlIndex === sections.length - 1 ? null : rtl2ltr[rtlIndex + 1];\n neighbors[index] = {\n leftIndex,\n rightIndex\n };\n });\n return {\n neighbors,\n startIndex: rtl2ltr[0],\n endIndex: rtl2ltr[sections.length - 1]\n };\n};\nexport const parseSelectedSections = (selectedSections, sections) => {\n if (selectedSections == null) {\n return null;\n }\n if (selectedSections === 'all') {\n return 'all';\n }\n if (typeof selectedSections === 'string') {\n const index = sections.findIndex(section => section.type === selectedSections);\n return index === -1 ? null : index;\n }\n return selectedSections;\n};\nexport const getSectionValueText = (section, utils) => {\n if (!section.value) {\n return undefined;\n }\n switch (section.type) {\n case 'month':\n {\n if (section.contentType === 'digit') {\n return utils.format(utils.setMonth(utils.date(), Number(section.value) - 1), 'month');\n }\n const parsedDate = utils.parse(section.value, section.format);\n return parsedDate ? utils.format(parsedDate, 'month') : undefined;\n }\n case 'day':\n return section.contentType === 'digit' ? utils.format(utils.setDate(utils.startOfYear(utils.date()), Number(section.value)), 'dayOfMonthFull') : section.value;\n case 'weekDay':\n // TODO: improve by providing the label of the week day\n return undefined;\n default:\n return undefined;\n }\n};\nexport const getSectionValueNow = (section, utils) => {\n if (!section.value) {\n return undefined;\n }\n switch (section.type) {\n case 'weekDay':\n {\n if (section.contentType === 'letter') {\n // TODO: improve by resolving the week day number from a letter week day\n return undefined;\n }\n return Number(section.value);\n }\n case 'meridiem':\n {\n const parsedDate = utils.parse(`01:00 ${section.value}`, `${utils.formats.hours12h}:${utils.formats.minutes} ${section.format}`);\n if (parsedDate) {\n return utils.getHours(parsedDate) >= 12 ? 1 : 0;\n }\n return undefined;\n }\n case 'day':\n return section.contentType === 'digit-with-letter' ? parseInt(section.value, 10) : Number(section.value);\n case 'month':\n {\n if (section.contentType === 'digit') {\n return Number(section.value);\n }\n const parsedDate = utils.parse(section.value, section.format);\n return parsedDate ? utils.getMonth(parsedDate) + 1 : undefined;\n }\n default:\n return section.contentType !== 'letter' ? Number(section.value) : undefined;\n }\n};"],"names":["getDateSectionConfigFromFormatToken","utils","formatToken","config","formatTokenMap","Error","join","type","contentType","maxLength","undefined","sectionType","getDaysInWeekStr","format","elements","now","date","startDate","startOfWeek","endDate","endOfWeek","current","isBefore","push","addDays","map","weekDay","formatByString","getLetterEditingOptions","timezone","getMonthsInYear","month","startOfDay","endOfDay","FORMAT_SECONDS_NO_LEADING_ZEROS","NON_LOCALIZED_DIGITS","getLocalizedDigits","today","setSeconds","Array","from","length","_","index","removeLocalizedDigits","valueStr","localizedDigits","digits","currentFormattedDigit","i","matchingDigitIndex","indexOf","toString","applyLocalizedDigits","split","char","Number","isStringNumber","nonLocalizedValueStr","isNaN","cleanLeadingZeros","size","cleanValueStr","cleanDigitSectionValue","value","sectionBoundaries","section","process","env","NODE_ENV","setDate","longestMonth","hasLeadingZerosInInput","adjustSectionValue","keyCode","sectionsValueBoundaries","activeDate","stepsAttributes","delta","getDeltaFromKeyCode","isStart","isEnd","shouldSetAbsolute","currentDate","getCleanValue","step","minutesStep","newSectionValueNumber","parseInt","minimum","maximum","adjustDigitSection","options","currentOptionIndex","adjustLetterSection","getSectionVisibleValue","target","placeholder","hasLeadingZeros","hasLeadingZerosInFormat","includes","changeSectionValueFormat","currentFormat","newFormat","parse","isFourDigitYearFormat","doesSectionFormatHaveLeadingZeros","setYear","startOfYear","startOfMonth","setHours","setMinutes","getDateFromDateSections","sections","shouldSkipWeekDays","some","sectionFormats","sectionValues","formatWithoutSeparator","dateWithoutSeparatorStr","createDateStrForV7HiddenInputFromSections","startSeparator","endSeparator","createDateStrForV6InputFromSections","isRtl","dateStr","dateValue","getSectionsBoundaries","endOfYear","maxDaysInMonth","reduce","acc","daysInMonth","getDaysInMonth","year","getMonth","day","isValid","daysInWeek","Math","min","max","hours","lastHourInDay","getHours","minutes","getMinutes","seconds","getSeconds","meridiem","empty","warnedOnceInvalidSection","validateSections","valueType","supportedSections","invalidSection","find","console","warn","reliableSectionModificationOrder","mergeDateIntoReferenceDate","dateToTransferFrom","referenceDate","shouldLimitToEditedSections","sort","a","b","mergedDate","modified","dateToTransferTo","getYear","setMonth","formattedDaysInWeek","dayInWeekStrOfActiveDate","dayInWeekOfActiveDate","diff","getDate","isAM","mergedDateHours","addHours","transferDateSectionValue","isAndroid","navigator","userAgent","toLowerCase","getSectionOrder","shouldApplyRTL","neighbors","forEach","leftIndex","rightIndex","startIndex","endIndex","rtl2ltr","ltr2rtl","groupedSectionsStart","groupedSectionsEnd","RTLIndex","findIndex","rtlIndex","parseSelectedSections","selectedSections","getSectionValueText","parsedDate","getSectionValueNow","formats","hours12h"],"mappings":"4DACY,MAACA,EAAsC,CAACC,EAAOC,KACzD,MAAMC,EAASF,EAAMG,eAAeF,GACpC,GAAc,MAAVC,EACF,MAAM,IAAIE,MAAM,CAAC,qBAAqBH,oDAA+D,0IAA0II,KAAK,OAEtP,MAAsB,iBAAXH,EACF,CACLI,KAAMJ,EACNK,YAAwB,aAAXL,EAAwB,SAAW,QAChDM,eAAWC,GAGR,CACLH,KAAMJ,EAAOQ,YACbH,YAAaL,EAAOK,YACpBC,UAAWN,EAAOM,UACnB,EAgBUG,EAAmB,CAACX,EAAOY,KACtC,MAAMC,EAAW,GACXC,EAAMd,EAAMe,UAAKN,EAAW,WAC5BO,EAAYhB,EAAMiB,YAAYH,GAC9BI,EAAUlB,EAAMmB,UAAUL,GAChC,IAAIM,EAAUJ,EACd,KAAOhB,EAAMqB,SAASD,EAASF,IAC7BL,EAASS,KAAKF,GACdA,EAAUpB,EAAMuB,QAAQH,EAAS,GAEnC,OAAOP,EAASW,KAAIC,GAAWzB,EAAM0B,eAAeD,EAASb,IAAQ,EAE1De,EAA0B,CAAC3B,EAAO4B,EAAUlB,EAAaE,KACpE,OAAQF,GACN,IAAK,QAED,OAAOmB,EAAgB7B,EAAOA,EAAMe,UAAKN,EAAWmB,IAA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8L,EAAa1M,EAAMY,OAAO8L,EAAY,cAAWjM,CACzD,CACH,IAAK,MACH,MAA+B,UAAxBwD,EAAQ1D,YAA0BP,EAAMY,OAAOZ,EAAMqE,QAAQrE,EAAM2G,YAAY3G,EAAMe,QAASwC,OAAOU,EAAQF,QAAS,kBAAoBE,EAAQF,MAI3J,QACE,OACH,EAEU4I,EAAqB,CAAC1I,EAASjE,KAC1C,GAAKiE,EAAQF,MAGb,OAAQE,EAAQ3D,MACd,IAAK,UAED,GAA4B,WAAxB2D,EAAQ1D,YAEV,OAEF,OAAOgD,OAAOU,EAAQF,OAE1B,IAAK,WACH,CACE,MAAM2I,EAAa1M,EAAMuG,MAAM,SAAStC,EAAQF,QAAS,GAAG/D,EAAM4M,QAAQC,YAAY7M,EAAM4M,QAAQ5D,WAAW/E,EAAQrD,UACvH,OAAI8L,EACK1M,EAAM+I,SAAS2D,IAAe,GAAK,EAAI,OAEhD,CACD,CACH,IAAK,MACH,MAA+B,sBAAxBzI,EAAQ1D,YAAsCgF,SAAStB,EAAQF,MAAO,IAAMR,OAAOU,EAAQF,OACpG,IAAK,QACH,CACE,GAA4B,UAAxBE,EAAQ1D,YACV,OAAOgD,OAAOU,EAAQF,OAExB,MAAM2I,EAAa1M,EAAMuG,MAAMtC,EAAQF,MAAOE,EAAQrD,QACtD,OAAO8L,EAAa1M,EAAMsI,SAASoE,GAAc,OAAIjM,CACtD,CACH,QACE,MAA+B,WAAxBwD,EAAQ1D,YAA2BgD,OAAOU,EAAQF,YAAStD,EACrE"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import*as t from"react";import{useUtils as
|
1
|
+
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import*as t from"react";import n from"../../../../utils/esm/useEventCallback/useEventCallback.js";import{useUtils as r}from"../useUtils.js";import{isStringNumber as o,applyLocalizedDigits as s,doesSectionFormatHaveLeadingZeros as u,changeSectionValueFormat as i,getDaysInWeekStr as a,getDateSectionConfigFromFormatToken as c,removeLocalizedDigits as l,cleanDigitSectionValue as m,getLetterEditingOptions as y}from"./useField.utils.js";const f=e=>null!=e.saveQuery,d=({sections:d,updateSectionValue:p,sectionsValueBoundaries:h,localizedDigits:x,setTempAndroidValueStr:T,timezone:v})=>{const g=r(),[V,S]=t.useState(null),Q=n((()=>S(null)));t.useEffect((()=>{null!=V&&d[V.sectionIndex]?.type!==V.sectionType&&Q()}),[d,V,Q]),t.useEffect((()=>{if(null!=V){const e=setTimeout((()=>Q()),5e3);return()=>{clearTimeout(e)}}return()=>{}}),[V,Q]);const k=({keyPressed:e,sectionIndex:t},n,r)=>{const o=e.toLowerCase(),s=d[t];if(null!=V&&(!r||r(V.value))&&V.sectionIndex===t){const e=`${V.value}${o}`,r=n(e,s);if(!f(r))return S({sectionIndex:t,value:e,sectionType:s.type}),r}const u=n(o,s);return f(u)&&!u.saveQuery?(Q(),null):(S({sectionIndex:t,value:o,sectionType:s.type}),f(u)?null:u)};return{applyCharacterEditing:n((t=>{const n=d[t.sectionIndex],r=o(t.keyPressed,x)?(t=>{const n=(e,t)=>{const n=l(e,x),r=Number(n),o=h[t.type]({currentDate:null,format:t.format,contentType:t.contentType});if(r>o.maximum)return{saveQuery:!1};if(r<o.minimum)return{saveQuery:!0};const s=10*r>o.maximum||n.length===o.maximum.toString().length;return{sectionValue:m(g,r,o,x,t),shouldGoToNextSection:s}};return k(t,((t,r)=>{if("digit"===r.contentType||"digit-with-letter"===r.contentType)return n(t,r);if("month"===r.type){const o=u(g,"digit","month","MM"),s=n(t,{type:r.type,format:"MM",hasLeadingZerosInFormat:o,hasLeadingZerosInInput:!0,contentType:"digit",maxLength:2});if(f(s))return s;const a=i(g,s.sectionValue,"MM",r.format);return e({},s,{sectionValue:a})}if("weekDay"===r.type){const o=n(t,r);if(f(o))return o;const s=a(g,r.format)[Number(o.sectionValue)-1];return e({},o,{sectionValue:s})}return{saveQuery:!1}}),(e=>o(e,x)))})(e({},t,{keyPressed:s(t.keyPressed,x)})):(t=>{const n=(e,t,n)=>{const r=t.filter((e=>e.toLowerCase().startsWith(n)));return 0===r.length?{saveQuery:!1}:{sectionValue:r[0],shouldGoToNextSection:1===r.length}},r=(t,r,o,s)=>{const u=e=>y(g,v,r.type,e);if("letter"===r.contentType)return n(r.format,u(r.format),t);if(o&&null!=s&&"letter"===c(g,o).contentType){const r=u(o),i=n(0,r,t);return f(i)?{saveQuery:!1}:e({},i,{sectionValue:s(i.sectionValue,r)})}return{saveQuery:!1}};return k(t,((e,t)=>{switch(t.type){case"month":{const n=e=>i(g,e,g.formats.month,t.format);return r(e,t,g.formats.month,n)}case"weekDay":{const n=(e,t)=>t.indexOf(e).toString();return r(e,t,g.formats.weekday,n)}case"meridiem":return r(e,t);default:return{saveQuery:!1}}}))})(t);null!=r?p({activeSection:n,newSectionValue:r.sectionValue,shouldGoToNextSection:r.shouldGoToNextSection}):T(null)})),resetCharacterQuery:Q}};export{d as useFieldCharacterEditing};
|
2
2
|
//# sourceMappingURL=useFieldCharacterEditing.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useFieldCharacterEditing.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldCharacterEditing.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport useEventCallback from '@mui/utils/useEventCallback';\nimport { useUtils } from \"../useUtils.js\";\nimport { changeSectionValueFormat, cleanDigitSectionValue, doesSectionFormatHaveLeadingZeros, getDateSectionConfigFromFormatToken, getDaysInWeekStr, getLetterEditingOptions, applyLocalizedDigits, removeLocalizedDigits, isStringNumber } from \"./useField.utils.js\";\n\n/**\n * The letter editing and the numeric editing each define a `CharacterEditingApplier`.\n * This function decides what the new section value should be and if the focus should switch to the next section.\n *\n * If it returns `null`, then the section value is not updated and the focus does not move.\n */\n\n/**\n * Function called by `applyQuery` which decides:\n * - what is the new section value ?\n * - should the query used to get this value be stored for the next key press ?\n *\n * If it returns `{ sectionValue: string; shouldGoToNextSection: boolean }`,\n * Then we store the query and update the section with the new value.\n *\n * If it returns `{ saveQuery: true` },\n * Then we store the query and don't update the section.\n *\n * If it returns `{ saveQuery: false },\n * Then we do nothing.\n */\n\nconst QUERY_LIFE_DURATION_MS = 5000;\nconst isQueryResponseWithoutValue = response => response.saveQuery != null;\n\n/**\n * Update the active section value when the user pressed a key that is not a navigation key (arrow key for example).\n * This hook has two main editing behaviors\n *\n * 1. The numeric editing when the user presses a digit\n * 2. The letter editing when the user presses another key\n */\nexport const useFieldCharacterEditing = ({\n sections,\n updateSectionValue,\n sectionsValueBoundaries,\n localizedDigits,\n setTempAndroidValueStr,\n timezone\n}) => {\n const utils = useUtils();\n const [query, setQuery] = React.useState(null);\n const resetQuery = useEventCallback(() => setQuery(null));\n React.useEffect(() => {\n if (query != null && sections[query.sectionIndex]?.type !== query.sectionType) {\n resetQuery();\n }\n }, [sections, query, resetQuery]);\n React.useEffect(() => {\n if (query != null) {\n const timeout = setTimeout(() => resetQuery(), QUERY_LIFE_DURATION_MS);\n return () => {\n clearTimeout(timeout);\n };\n }\n return () => {};\n }, [query, resetQuery]);\n const applyQuery = ({\n keyPressed,\n sectionIndex\n }, getFirstSectionValueMatchingWithQuery, isValidQueryValue) => {\n const cleanKeyPressed = keyPressed.toLowerCase();\n const activeSection = sections[sectionIndex];\n\n // The current query targets the section being editing\n // We can try to concatenate the value\n if (query != null && (!isValidQueryValue || isValidQueryValue(query.value)) && query.sectionIndex === sectionIndex) {\n const concatenatedQueryValue = `${query.value}${cleanKeyPressed}`;\n const queryResponse = getFirstSectionValueMatchingWithQuery(concatenatedQueryValue, activeSection);\n if (!isQueryResponseWithoutValue(queryResponse)) {\n setQuery({\n sectionIndex,\n value: concatenatedQueryValue,\n sectionType: activeSection.type\n });\n return queryResponse;\n }\n }\n const queryResponse = getFirstSectionValueMatchingWithQuery(cleanKeyPressed, activeSection);\n if (isQueryResponseWithoutValue(queryResponse) && !queryResponse.saveQuery) {\n resetQuery();\n return null;\n }\n setQuery({\n sectionIndex,\n value: cleanKeyPressed,\n sectionType: activeSection.type\n });\n if (isQueryResponseWithoutValue(queryResponse)) {\n return null;\n }\n return queryResponse;\n };\n const applyLetterEditing = params => {\n const findMatchingOptions = (format, options, queryValue) => {\n const matchingValues = options.filter(option => option.toLowerCase().startsWith(queryValue));\n if (matchingValues.length === 0) {\n return {\n saveQuery: false\n };\n }\n return {\n sectionValue: matchingValues[0],\n shouldGoToNextSection: matchingValues.length === 1\n };\n };\n const testQueryOnFormatAndFallbackFormat = (queryValue, activeSection, fallbackFormat, formatFallbackValue) => {\n const getOptions = format => getLetterEditingOptions(utils, timezone, activeSection.type, format);\n if (activeSection.contentType === 'letter') {\n return findMatchingOptions(activeSection.format, getOptions(activeSection.format), queryValue);\n }\n\n // When editing a digit-format month / weekDay and the user presses a letter,\n // We can support the letter editing by using the letter-format month / weekDay and re-formatting the result.\n // We just have to make sure that the default month / weekDay format is a letter format,\n if (fallbackFormat && formatFallbackValue != null && getDateSectionConfigFromFormatToken(utils, fallbackFormat).contentType === 'letter') {\n const fallbackOptions = getOptions(fallbackFormat);\n const response = findMatchingOptions(fallbackFormat, fallbackOptions, queryValue);\n if (isQueryResponseWithoutValue(response)) {\n return {\n saveQuery: false\n };\n }\n return _extends({}, response, {\n sectionValue: formatFallbackValue(response.sectionValue, fallbackOptions)\n });\n }\n return {\n saveQuery: false\n };\n };\n const getFirstSectionValueMatchingWithQuery = (queryValue, activeSection) => {\n switch (activeSection.type) {\n case 'month':\n {\n const formatFallbackValue = fallbackValue => changeSectionValueFormat(utils, fallbackValue, utils.formats.month, activeSection.format);\n return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, utils.formats.month, formatFallbackValue);\n }\n case 'weekDay':\n {\n const formatFallbackValue = (fallbackValue, fallbackOptions) => fallbackOptions.indexOf(fallbackValue).toString();\n return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, utils.formats.weekday, formatFallbackValue);\n }\n case 'meridiem':\n {\n return testQueryOnFormatAndFallbackFormat(queryValue, activeSection);\n }\n default:\n {\n return {\n saveQuery: false\n };\n }\n }\n };\n return applyQuery(params, getFirstSectionValueMatchingWithQuery);\n };\n const applyNumericEditing = params => {\n const getNewSectionValue = (queryValue, section) => {\n const cleanQueryValue = removeLocalizedDigits(queryValue, localizedDigits);\n const queryValueNumber = Number(cleanQueryValue);\n const sectionBoundaries = sectionsValueBoundaries[section.type]({\n currentDate: null,\n format: section.format,\n contentType: section.contentType\n });\n if (queryValueNumber > sectionBoundaries.maximum) {\n return {\n saveQuery: false\n };\n }\n\n // If the user types `0` on a month section,\n // It is below the minimum, but we want to store the `0` in the query,\n // So that when he pressed `1`, it will store `01` and move to the next section.\n if (queryValueNumber < sectionBoundaries.minimum) {\n return {\n saveQuery: true\n };\n }\n const shouldGoToNextSection = queryValueNumber * 10 > sectionBoundaries.maximum || cleanQueryValue.length === sectionBoundaries.maximum.toString().length;\n const newSectionValue = cleanDigitSectionValue(utils, queryValueNumber, sectionBoundaries, localizedDigits, section);\n return {\n sectionValue: newSectionValue,\n shouldGoToNextSection\n };\n };\n const getFirstSectionValueMatchingWithQuery = (queryValue, activeSection) => {\n if (activeSection.contentType === 'digit' || activeSection.contentType === 'digit-with-letter') {\n return getNewSectionValue(queryValue, activeSection);\n }\n\n // When editing a letter-format month and the user presses a digit,\n // We can support the numeric editing by using the digit-format month and re-formatting the result.\n if (activeSection.type === 'month') {\n const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, 'digit', 'month', 'MM');\n const response = getNewSectionValue(queryValue, {\n type: activeSection.type,\n format: 'MM',\n hasLeadingZerosInFormat,\n hasLeadingZerosInInput: true,\n contentType: 'digit',\n maxLength: 2\n });\n if (isQueryResponseWithoutValue(response)) {\n return response;\n }\n const formattedValue = changeSectionValueFormat(utils, response.sectionValue, 'MM', activeSection.format);\n return _extends({}, response, {\n sectionValue: formattedValue\n });\n }\n\n // When editing a letter-format weekDay and the user presses a digit,\n // We can support the numeric editing by returning the nth day in the week day array.\n if (activeSection.type === 'weekDay') {\n const response = getNewSectionValue(queryValue, activeSection);\n if (isQueryResponseWithoutValue(response)) {\n return response;\n }\n const formattedValue = getDaysInWeekStr(utils, activeSection.format)[Number(response.sectionValue) - 1];\n return _extends({}, response, {\n sectionValue: formattedValue\n });\n }\n return {\n saveQuery: false\n };\n };\n return applyQuery(params, getFirstSectionValueMatchingWithQuery, queryValue => isStringNumber(queryValue, localizedDigits));\n };\n const applyCharacterEditing = useEventCallback(params => {\n const activeSection = sections[params.sectionIndex];\n const isNumericEditing = isStringNumber(params.keyPressed, localizedDigits);\n const response = isNumericEditing ? applyNumericEditing(_extends({}, params, {\n keyPressed: applyLocalizedDigits(params.keyPressed, localizedDigits)\n })) : applyLetterEditing(params);\n if (response == null) {\n setTempAndroidValueStr(null);\n return;\n }\n updateSectionValue({\n activeSection,\n newSectionValue: response.sectionValue,\n shouldGoToNextSection: response.shouldGoToNextSection\n });\n });\n return {\n applyCharacterEditing,\n resetCharacterQuery: resetQuery\n };\n};"],"names":["isQueryResponseWithoutValue","response","saveQuery","useFieldCharacterEditing","sections","updateSectionValue","sectionsValueBoundaries","localizedDigits","setTempAndroidValueStr","timezone","utils","useUtils","query","setQuery","React","useState","resetQuery","useEventCallback","useEffect","sectionIndex","type","sectionType","timeout","setTimeout","clearTimeout","applyQuery","keyPressed","getFirstSectionValueMatchingWithQuery","isValidQueryValue","cleanKeyPressed","toLowerCase","activeSection","value","concatenatedQueryValue","queryResponse","applyCharacterEditing","params","isStringNumber","getNewSectionValue","queryValue","section","cleanQueryValue","removeLocalizedDigits","queryValueNumber","Number","sectionBoundaries","currentDate","format","contentType","maximum","minimum","shouldGoToNextSection","length","toString","sectionValue","cleanDigitSectionValue","hasLeadingZerosInFormat","doesSectionFormatHaveLeadingZeros","hasLeadingZerosInInput","maxLength","formattedValue","changeSectionValueFormat","_extends","getDaysInWeekStr","applyNumericEditing","applyLocalizedDigits","findMatchingOptions","options","matchingValues","filter","option","startsWith","testQueryOnFormatAndFallbackFormat","fallbackFormat","formatFallbackValue","getOptions","getLetterEditingOptions","getDateSectionConfigFromFormatToken","fallbackOptions","fallbackValue","formats","month","indexOf","weekday","applyLetterEditing","newSectionValue","resetCharacterQuery"],"mappings":"sgBA4BA,MACMA,EAA8BC,GAAkC,MAAtBA,EAASC,UAS5CC,EAA2B,EACtCC,WACAC,qBACAC,0BACAC,kBACAC,yBACAC,eAEA,MAAMC,EAAQC,KACPC,EAAOC,GAAYC,EAAMC,SAAS,MACnCC,EAAaC,GAAiB,IAAMJ,EAAS,QACnDC,EAAMI,WAAU,KACD,MAATN,GAAiBR,EAASQ,EAAMO,eAAeC,OAASR,EAAMS,aAChEL,GACD,GACA,CAACZ,EAAUQ,EAAOI,IACrBF,EAAMI,WAAU,KACd,GAAa,MAATN,EAAe,CACjB,MAAMU,EAAUC,YAAW,IAAMP,KA5BR,KA6BzB,MAAO,KACLQ,aAAaF,EAAQ,CAExB,CACD,MAAO,MAAQ,GACd,CAACV,EAAOI,IACX,MAAMS,EAAa,EACjBC,aACAP,gBACCQ,EAAuCC,KACxC,MAAMC,EAAkBH,EAAWI,cAC7BC,EAAgB3B,EAASe,GAI/B,GAAa,MAATP,KAAmBgB,GAAqBA,EAAkBhB,EAAMoB,SAAWpB,EAAMO,eAAiBA,EAAc,CAClH,MAAMc,EAAyB,GAAGrB,EAAMoB,QAAQH,IAC1CK,EAAgBP,EAAsCM,EAAwBF,GACpF,IAAK/B,EAA4BkC,GAM/B,OALArB,EAAS,CACPM,eACAa,MAAOC,EACPZ,YAAaU,EAAcX,OAEtBc,CAEV,CACD,MAAMA,EAAgBP,EAAsCE,EAAiBE,GAC7E,OAAI/B,EAA4BkC,KAAmBA,EAAchC,WAC/Dc,IACO,OAETH,EAAS,CACPM,eACAa,MAAOH,EACPR,YAAaU,EAAcX,OAEzBpB,EAA4BkC,GACvB,KAEFA,EAAa,EA4JtB,MAAO,CACLC,sBAjB4BlB,GAAiB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,EAAYR,EAAerB,EAAMsE,QAAQC,MAAOP,EAC3F,CACH,IAAK,UACH,CACE,MAAMA,EAAsB,CAACK,EAAeD,IAAoBA,EAAgBI,QAAQH,GAAe1B,WACvG,OAAOmB,EAAmCjC,EAAYR,EAAerB,EAAMsE,QAAQG,QAAST,EAC7F,CACH,IAAK,WAED,OAAOF,EAAmCjC,EAAYR,GAE1D,QAEI,MAAO,CACL7B,WAAW,GAGlB,GAE6D,EAiF1DkF,CAAmBhD,GACT,MAAZnC,EAIJI,EAAmB,CACjB0B,gBACAsD,gBAAiBpF,EAASqD,aAC1BH,sBAAuBlD,EAASkD,wBANhC3C,EAAuB,KAOvB,IAIF8E,oBAAqBtE,EACtB"}
|
1
|
+
{"version":3,"file":"useFieldCharacterEditing.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldCharacterEditing.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport useEventCallback from '@mui/utils/useEventCallback';\nimport { useUtils } from \"../useUtils.js\";\nimport { changeSectionValueFormat, cleanDigitSectionValue, doesSectionFormatHaveLeadingZeros, getDateSectionConfigFromFormatToken, getDaysInWeekStr, getLetterEditingOptions, applyLocalizedDigits, removeLocalizedDigits, isStringNumber } from \"./useField.utils.js\";\n\n/**\n * The letter editing and the numeric editing each define a `CharacterEditingApplier`.\n * This function decides what the new section value should be and if the focus should switch to the next section.\n *\n * If it returns `null`, then the section value is not updated and the focus does not move.\n */\n\n/**\n * Function called by `applyQuery` which decides:\n * - what is the new section value ?\n * - should the query used to get this value be stored for the next key press ?\n *\n * If it returns `{ sectionValue: string; shouldGoToNextSection: boolean }`,\n * Then we store the query and update the section with the new value.\n *\n * If it returns `{ saveQuery: true` },\n * Then we store the query and don't update the section.\n *\n * If it returns `{ saveQuery: false },\n * Then we do nothing.\n */\n\nconst QUERY_LIFE_DURATION_MS = 5000;\nconst isQueryResponseWithoutValue = response => response.saveQuery != null;\n\n/**\n * Update the active section value when the user pressed a key that is not a navigation key (arrow key for example).\n * This hook has two main editing behaviors\n *\n * 1. The numeric editing when the user presses a digit\n * 2. The letter editing when the user presses another key\n */\nexport const useFieldCharacterEditing = ({\n sections,\n updateSectionValue,\n sectionsValueBoundaries,\n localizedDigits,\n setTempAndroidValueStr,\n timezone\n}) => {\n const utils = useUtils();\n const [query, setQuery] = React.useState(null);\n const resetQuery = useEventCallback(() => setQuery(null));\n React.useEffect(() => {\n if (query != null && sections[query.sectionIndex]?.type !== query.sectionType) {\n resetQuery();\n }\n }, [sections, query, resetQuery]);\n React.useEffect(() => {\n if (query != null) {\n const timeout = setTimeout(() => resetQuery(), QUERY_LIFE_DURATION_MS);\n return () => {\n clearTimeout(timeout);\n };\n }\n return () => {};\n }, [query, resetQuery]);\n const applyQuery = ({\n keyPressed,\n sectionIndex\n }, getFirstSectionValueMatchingWithQuery, isValidQueryValue) => {\n const cleanKeyPressed = keyPressed.toLowerCase();\n const activeSection = sections[sectionIndex];\n\n // The current query targets the section being editing\n // We can try to concatenate the value\n if (query != null && (!isValidQueryValue || isValidQueryValue(query.value)) && query.sectionIndex === sectionIndex) {\n const concatenatedQueryValue = `${query.value}${cleanKeyPressed}`;\n const queryResponse = getFirstSectionValueMatchingWithQuery(concatenatedQueryValue, activeSection);\n if (!isQueryResponseWithoutValue(queryResponse)) {\n setQuery({\n sectionIndex,\n value: concatenatedQueryValue,\n sectionType: activeSection.type\n });\n return queryResponse;\n }\n }\n const queryResponse = getFirstSectionValueMatchingWithQuery(cleanKeyPressed, activeSection);\n if (isQueryResponseWithoutValue(queryResponse) && !queryResponse.saveQuery) {\n resetQuery();\n return null;\n }\n setQuery({\n sectionIndex,\n value: cleanKeyPressed,\n sectionType: activeSection.type\n });\n if (isQueryResponseWithoutValue(queryResponse)) {\n return null;\n }\n return queryResponse;\n };\n const applyLetterEditing = params => {\n const findMatchingOptions = (format, options, queryValue) => {\n const matchingValues = options.filter(option => option.toLowerCase().startsWith(queryValue));\n if (matchingValues.length === 0) {\n return {\n saveQuery: false\n };\n }\n return {\n sectionValue: matchingValues[0],\n shouldGoToNextSection: matchingValues.length === 1\n };\n };\n const testQueryOnFormatAndFallbackFormat = (queryValue, activeSection, fallbackFormat, formatFallbackValue) => {\n const getOptions = format => getLetterEditingOptions(utils, timezone, activeSection.type, format);\n if (activeSection.contentType === 'letter') {\n return findMatchingOptions(activeSection.format, getOptions(activeSection.format), queryValue);\n }\n\n // When editing a digit-format month / weekDay and the user presses a letter,\n // We can support the letter editing by using the letter-format month / weekDay and re-formatting the result.\n // We just have to make sure that the default month / weekDay format is a letter format,\n if (fallbackFormat && formatFallbackValue != null && getDateSectionConfigFromFormatToken(utils, fallbackFormat).contentType === 'letter') {\n const fallbackOptions = getOptions(fallbackFormat);\n const response = findMatchingOptions(fallbackFormat, fallbackOptions, queryValue);\n if (isQueryResponseWithoutValue(response)) {\n return {\n saveQuery: false\n };\n }\n return _extends({}, response, {\n sectionValue: formatFallbackValue(response.sectionValue, fallbackOptions)\n });\n }\n return {\n saveQuery: false\n };\n };\n const getFirstSectionValueMatchingWithQuery = (queryValue, activeSection) => {\n switch (activeSection.type) {\n case 'month':\n {\n const formatFallbackValue = fallbackValue => changeSectionValueFormat(utils, fallbackValue, utils.formats.month, activeSection.format);\n return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, utils.formats.month, formatFallbackValue);\n }\n case 'weekDay':\n {\n const formatFallbackValue = (fallbackValue, fallbackOptions) => fallbackOptions.indexOf(fallbackValue).toString();\n return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, utils.formats.weekday, formatFallbackValue);\n }\n case 'meridiem':\n {\n return testQueryOnFormatAndFallbackFormat(queryValue, activeSection);\n }\n default:\n {\n return {\n saveQuery: false\n };\n }\n }\n };\n return applyQuery(params, getFirstSectionValueMatchingWithQuery);\n };\n const applyNumericEditing = params => {\n const getNewSectionValue = (queryValue, section) => {\n const cleanQueryValue = removeLocalizedDigits(queryValue, localizedDigits);\n const queryValueNumber = Number(cleanQueryValue);\n const sectionBoundaries = sectionsValueBoundaries[section.type]({\n currentDate: null,\n format: section.format,\n contentType: section.contentType\n });\n if (queryValueNumber > sectionBoundaries.maximum) {\n return {\n saveQuery: false\n };\n }\n\n // If the user types `0` on a month section,\n // It is below the minimum, but we want to store the `0` in the query,\n // So that when he pressed `1`, it will store `01` and move to the next section.\n if (queryValueNumber < sectionBoundaries.minimum) {\n return {\n saveQuery: true\n };\n }\n const shouldGoToNextSection = queryValueNumber * 10 > sectionBoundaries.maximum || cleanQueryValue.length === sectionBoundaries.maximum.toString().length;\n const newSectionValue = cleanDigitSectionValue(utils, queryValueNumber, sectionBoundaries, localizedDigits, section);\n return {\n sectionValue: newSectionValue,\n shouldGoToNextSection\n };\n };\n const getFirstSectionValueMatchingWithQuery = (queryValue, activeSection) => {\n if (activeSection.contentType === 'digit' || activeSection.contentType === 'digit-with-letter') {\n return getNewSectionValue(queryValue, activeSection);\n }\n\n // When editing a letter-format month and the user presses a digit,\n // We can support the numeric editing by using the digit-format month and re-formatting the result.\n if (activeSection.type === 'month') {\n const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, 'digit', 'month', 'MM');\n const response = getNewSectionValue(queryValue, {\n type: activeSection.type,\n format: 'MM',\n hasLeadingZerosInFormat,\n hasLeadingZerosInInput: true,\n contentType: 'digit',\n maxLength: 2\n });\n if (isQueryResponseWithoutValue(response)) {\n return response;\n }\n const formattedValue = changeSectionValueFormat(utils, response.sectionValue, 'MM', activeSection.format);\n return _extends({}, response, {\n sectionValue: formattedValue\n });\n }\n\n // When editing a letter-format weekDay and the user presses a digit,\n // We can support the numeric editing by returning the nth day in the week day array.\n if (activeSection.type === 'weekDay') {\n const response = getNewSectionValue(queryValue, activeSection);\n if (isQueryResponseWithoutValue(response)) {\n return response;\n }\n const formattedValue = getDaysInWeekStr(utils, activeSection.format)[Number(response.sectionValue) - 1];\n return _extends({}, response, {\n sectionValue: formattedValue\n });\n }\n return {\n saveQuery: false\n };\n };\n return applyQuery(params, getFirstSectionValueMatchingWithQuery, queryValue => isStringNumber(queryValue, localizedDigits));\n };\n const applyCharacterEditing = useEventCallback(params => {\n const activeSection = sections[params.sectionIndex];\n const isNumericEditing = isStringNumber(params.keyPressed, localizedDigits);\n const response = isNumericEditing ? applyNumericEditing(_extends({}, params, {\n keyPressed: applyLocalizedDigits(params.keyPressed, localizedDigits)\n })) : applyLetterEditing(params);\n if (response == null) {\n setTempAndroidValueStr(null);\n return;\n }\n updateSectionValue({\n activeSection,\n newSectionValue: response.sectionValue,\n shouldGoToNextSection: response.shouldGoToNextSection\n });\n });\n return {\n applyCharacterEditing,\n resetCharacterQuery: resetQuery\n };\n};"],"names":["isQueryResponseWithoutValue","response","saveQuery","useFieldCharacterEditing","sections","updateSectionValue","sectionsValueBoundaries","localizedDigits","setTempAndroidValueStr","timezone","utils","useUtils","query","setQuery","React","useState","resetQuery","useEventCallback","useEffect","sectionIndex","type","sectionType","timeout","setTimeout","clearTimeout","applyQuery","keyPressed","getFirstSectionValueMatchingWithQuery","isValidQueryValue","cleanKeyPressed","toLowerCase","activeSection","value","concatenatedQueryValue","queryResponse","applyCharacterEditing","params","isStringNumber","getNewSectionValue","queryValue","section","cleanQueryValue","removeLocalizedDigits","queryValueNumber","Number","sectionBoundaries","currentDate","format","contentType","maximum","minimum","shouldGoToNextSection","length","toString","sectionValue","cleanDigitSectionValue","hasLeadingZerosInFormat","doesSectionFormatHaveLeadingZeros","hasLeadingZerosInInput","maxLength","formattedValue","changeSectionValueFormat","_extends","getDaysInWeekStr","applyNumericEditing","applyLocalizedDigits","findMatchingOptions","options","matchingValues","filter","option","startsWith","testQueryOnFormatAndFallbackFormat","fallbackFormat","formatFallbackValue","getOptions","getLetterEditingOptions","getDateSectionConfigFromFormatToken","fallbackOptions","fallbackValue","formats","month","indexOf","weekday","applyLetterEditing","newSectionValue","resetCharacterQuery"],"mappings":"ufA4BA,MACMA,EAA8BC,GAAkC,MAAtBA,EAASC,UAS5C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AYR,GAE1D,QAEI,MAAO,CACL7B,WAAW,GAGlB,GAE6D,EAiF1DkF,CAAmBhD,GACT,MAAZnC,EAIJI,EAAmB,CACjB0B,gBACAsD,gBAAiBpF,EAASqD,aAC1BH,sBAAuBlD,EAASkD,wBANhC3C,EAAuB,KAOvB,IAIF8E,oBAAqBtE,EACtB"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import*as t from"react";import{useRtl as
|
1
|
+
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import*as t from"react";import l from"../../../../utils/esm/useControlled/useControlled.js";import{useRtl as a}from"../../../../system/esm/RtlProvider/index.js";import{usePickersTranslations as s}from"../../../hooks/usePickersTranslations.js";import{useUtils as n,useLocalizationContext as r}from"../useUtils.js";import{getLocalizedDigits as o,getSectionsBoundaries as i,validateSections as u,parseSelectedSections as c,getDateFromDateSections as d,mergeDateIntoReferenceDate as m}from"./useField.utils.js";import{buildSectionsFromFormat as f}from"./buildSectionsFromFormat.js";import{useValueWithTimezone as V}from"../useValueWithTimezone.js";import{getSectionTypeGranularity as p}from"../../utils/getDefaultReferenceDate.js";const v=v=>{const g=n(),S=s(),D=r(),h=a(),{valueManager:A,fieldValueManager:F,valueType:z,validator:M,internalProps:b,internalProps:{value:R,defaultValue:j,referenceDate:y,onChange:T,format:w,formatDensity:x="dense",selectedSections:C,onSelectedSectionsChange:N,shouldRespectLeadingZeros:E=!1,timezone:P,enableAccessibleFieldDOMStructure:k=!1}}=v,{timezone:I,value:L,handleValueChange:O}=V({timezone:P,value:R,defaultValue:j,referenceDate:y,onChange:T,valueManager:A}),Z=t.useMemo((()=>o(g)),[g]),q=t.useMemo((()=>i(g,Z,I)),[g,Z,I]),B=t.useCallback(((e,t=null)=>F.getSectionsFromValue(g,e,t,(e=>f({utils:g,localeText:S,localizedDigits:Z,format:w,date:e,formatDensity:x,shouldRespectLeadingZeros:E,enableAccessibleFieldDOMStructure:k,isRtl:h})))),[F,w,S,Z,h,E,g,x,k]),[G,U]=t.useState((()=>{const t=B(L);u(t,z);const l={sections:t,value:L,referenceValue:A.emptyValue,tempValueStrAndroid:null},a=p(t),s=A.getInitialReferenceValue({referenceDate:y,value:L,utils:g,props:b,granularity:a,timezone:I});return e({},l,{referenceValue:s})})),[W,H]=l({controlled:C,default:null,name:"useField",state:"selectedSections"}),J=e=>{H(e),N?.(e)},K=t.useMemo((()=>c(W,G.sections)),[W,G.sections]),Q="all"===K?0:K,X=({value:t,referenceValue:l,sections:a})=>{if(U((s=>e({},s,{sections:a,value:t,referenceValue:l,tempValueStrAndroid:null}))),A.areValuesEqual(g,G.value,t))return;const s={validationError:M({adapter:D,value:t,timezone:I,props:b})};O(t,s)},Y=(t,l)=>{const a=[...G.sections];return a[t]=e({},a[t],{value:l,modified:!0}),a};return t.useEffect((()=>{const t=B(G.value);u(t,z),U((l=>e({},l,{sections:t})))}),[w,g.locale,h]),t.useEffect((()=>{let t;t=!A.areValuesEqual(g,G.value,L)||A.getTimezone(g,G.value)!==A.getTimezone(g,L),t&&U((t=>e({},t,{value:L,referenceValue:F.updateReferenceValue(g,L,t.referenceValue),sections:B(L)})))}),[L]),{state:G,activeSectionIndex:Q,parsedSelectedSections:K,setSelectedSections:J,clearValue:()=>{X({value:A.emptyValue,referenceValue:G.referenceValue,sections:B(A.emptyValue)})},clearActiveSection:()=>{if(null==Q)return;const t=G.sections[Q],l=F.getActiveDateManager(g,G,t),a=l.getSections(G.sections).filter((e=>""!==e.value)).length===(""===t.value?0:1),s=Y(Q,""),n=a?null:g.getInvalidDate(),r=l.getNewValuesFromNewActiveDate(n);X(e({},r,{sections:s}))},updateSectionValue:({activeSection:t,newSectionValue:l,shouldGoToNextSection:a})=>{a&&Q<G.sections.length-1&&J(Q+1);const s=F.getActiveDateManager(g,G,t),n=Y(Q,l),r=s.getSections(n),o=d(g,r,Z);let i,u;if(null!=o&&g.isValid(o)){const e=m(g,o,r,s.referenceDate,!0);i=s.getNewValuesFromNewActiveDate(e),u=!0}else i=s.getNewValuesFromNewActiveDate(o),u=(null!=o&&!g.isValid(o))!=(null!=s.date&&!g.isValid(s.date));return u?X(e({},i,{sections:n})):U((t=>e({},t,i,{sections:n,tempValueStrAndroid:null})))},updateValueFromValueStr:e=>{const t=F.parseValueStr(e,G.referenceValue,((e,t)=>{const l=g.parse(e,w);if(null==l||!g.isValid(l))return null;const a=f({utils:g,localeText:S,localizedDigits:Z,format:w,date:l,formatDensity:x,shouldRespectLeadingZeros:E,enableAccessibleFieldDOMStructure:k,isRtl:h});return m(g,l,a,t,!1)})),l=F.updateReferenceValue(g,t,G.referenceValue);X({value:t,referenceValue:l,sections:B(t,G.sections)})},setTempAndroidValueStr:t=>U((l=>e({},l,{tempValueStrAndroid:t}))),getSectionsFromValue:B,sectionsValueBoundaries:q,localizedDigits:Z,timezone:I}};export{v as useFieldState};
|
2
2
|
//# sourceMappingURL=useFieldState.js.map
|