@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
package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldState.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useFieldState.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldState.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport useControlled from '@mui/utils/useControlled';\nimport { useRtl } from '@mui/system/RtlProvider';\nimport { usePickersTranslations } from \"../../../hooks/usePickersTranslations.js\";\nimport { useUtils, useLocalizationContext } from \"../useUtils.js\";\nimport { mergeDateIntoReferenceDate, getSectionsBoundaries, validateSections, getDateFromDateSections, parseSelectedSections, getLocalizedDigits } from \"./useField.utils.js\";\nimport { buildSectionsFromFormat } from \"./buildSectionsFromFormat.js\";\nimport { useValueWithTimezone } from \"../useValueWithTimezone.js\";\nimport { getSectionTypeGranularity } from \"../../utils/getDefaultReferenceDate.js\";\nexport const useFieldState = params => {\n const utils = useUtils();\n const translations = usePickersTranslations();\n const adapter = useLocalizationContext();\n const isRtl = useRtl();\n const {\n valueManager,\n fieldValueManager,\n valueType,\n validator,\n internalProps,\n internalProps: {\n value: valueProp,\n defaultValue,\n referenceDate: referenceDateProp,\n onChange,\n format,\n formatDensity = 'dense',\n selectedSections: selectedSectionsProp,\n onSelectedSectionsChange,\n shouldRespectLeadingZeros = false,\n timezone: timezoneProp,\n enableAccessibleFieldDOMStructure = false\n }\n } = params;\n const {\n timezone,\n value: valueFromTheOutside,\n handleValueChange\n } = useValueWithTimezone({\n timezone: timezoneProp,\n value: valueProp,\n defaultValue,\n referenceDate: referenceDateProp,\n onChange,\n valueManager\n });\n const localizedDigits = React.useMemo(() => getLocalizedDigits(utils), [utils]);\n const sectionsValueBoundaries = React.useMemo(() => getSectionsBoundaries(utils, localizedDigits, timezone), [utils, localizedDigits, timezone]);\n const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, date => buildSectionsFromFormat({\n utils,\n localeText: translations,\n localizedDigits,\n format,\n date,\n formatDensity,\n shouldRespectLeadingZeros,\n enableAccessibleFieldDOMStructure,\n isRtl\n })), [fieldValueManager, format, translations, localizedDigits, isRtl, shouldRespectLeadingZeros, utils, formatDensity, enableAccessibleFieldDOMStructure]);\n const [state, setState] = React.useState(() => {\n const sections = getSectionsFromValue(valueFromTheOutside);\n validateSections(sections, valueType);\n const stateWithoutReferenceDate = {\n sections,\n value: valueFromTheOutside,\n referenceValue: valueManager.emptyValue,\n tempValueStrAndroid: null\n };\n const granularity = getSectionTypeGranularity(sections);\n const referenceValue = valueManager.getInitialReferenceValue({\n referenceDate: referenceDateProp,\n value: valueFromTheOutside,\n utils,\n props: internalProps,\n granularity,\n timezone\n });\n return _extends({}, stateWithoutReferenceDate, {\n referenceValue\n });\n });\n const [selectedSections, innerSetSelectedSections] = useControlled({\n controlled: selectedSectionsProp,\n default: null,\n name: 'useField',\n state: 'selectedSections'\n });\n const setSelectedSections = newSelectedSections => {\n innerSetSelectedSections(newSelectedSections);\n onSelectedSectionsChange?.(newSelectedSections);\n };\n const parsedSelectedSections = React.useMemo(() => parseSelectedSections(selectedSections, state.sections), [selectedSections, state.sections]);\n const activeSectionIndex = parsedSelectedSections === 'all' ? 0 : parsedSelectedSections;\n const publishValue = ({\n value,\n referenceValue,\n sections\n }) => {\n setState(prevState => _extends({}, prevState, {\n sections,\n value,\n referenceValue,\n tempValueStrAndroid: null\n }));\n if (valueManager.areValuesEqual(utils, state.value, value)) {\n return;\n }\n const context = {\n validationError: validator({\n adapter,\n value,\n timezone,\n props: internalProps\n })\n };\n handleValueChange(value, context);\n };\n const setSectionValue = (sectionIndex, newSectionValue) => {\n const newSections = [...state.sections];\n newSections[sectionIndex] = _extends({}, newSections[sectionIndex], {\n value: newSectionValue,\n modified: true\n });\n return newSections;\n };\n const clearValue = () => {\n publishValue({\n value: valueManager.emptyValue,\n referenceValue: state.referenceValue,\n sections: getSectionsFromValue(valueManager.emptyValue)\n });\n };\n const clearActiveSection = () => {\n if (activeSectionIndex == null) {\n return;\n }\n const activeSection = state.sections[activeSectionIndex];\n const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);\n const nonEmptySectionCountBefore = activeDateManager.getSections(state.sections).filter(section => section.value !== '').length;\n const hasNoOtherNonEmptySections = nonEmptySectionCountBefore === (activeSection.value === '' ? 0 : 1);\n const newSections = setSectionValue(activeSectionIndex, '');\n const newActiveDate = hasNoOtherNonEmptySections ? null : utils.getInvalidDate();\n const newValues = activeDateManager.getNewValuesFromNewActiveDate(newActiveDate);\n publishValue(_extends({}, newValues, {\n sections: newSections\n }));\n };\n const updateValueFromValueStr = valueStr => {\n const parseDateStr = (dateStr, referenceDate) => {\n const date = utils.parse(dateStr, format);\n if (date == null || !utils.isValid(date)) {\n return null;\n }\n const sections = buildSectionsFromFormat({\n utils,\n localeText: translations,\n localizedDigits,\n format,\n date,\n formatDensity,\n shouldRespectLeadingZeros,\n enableAccessibleFieldDOMStructure,\n isRtl\n });\n return mergeDateIntoReferenceDate(utils, date, sections, referenceDate, false);\n };\n const newValue = fieldValueManager.parseValueStr(valueStr, state.referenceValue, parseDateStr);\n const newReferenceValue = fieldValueManager.updateReferenceValue(utils, newValue, state.referenceValue);\n publishValue({\n value: newValue,\n referenceValue: newReferenceValue,\n sections: getSectionsFromValue(newValue, state.sections)\n });\n };\n const updateSectionValue = ({\n activeSection,\n newSectionValue,\n shouldGoToNextSection\n }) => {\n /**\n * 1. Decide which section should be focused\n */\n if (shouldGoToNextSection && activeSectionIndex < state.sections.length - 1) {\n setSelectedSections(activeSectionIndex + 1);\n }\n\n /**\n * 2. Try to build a valid date from the new section value\n */\n const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);\n const newSections = setSectionValue(activeSectionIndex, newSectionValue);\n const newActiveDateSections = activeDateManager.getSections(newSections);\n const newActiveDate = getDateFromDateSections(utils, newActiveDateSections, localizedDigits);\n let values;\n let shouldPublish;\n\n /**\n * If the new date is valid,\n * Then we merge the value of the modified sections into the reference date.\n * This makes sure that we don't lose some information of the initial date (like the time on a date field).\n */\n if (newActiveDate != null && utils.isValid(newActiveDate)) {\n const mergedDate = mergeDateIntoReferenceDate(utils, newActiveDate, newActiveDateSections, activeDateManager.referenceDate, true);\n values = activeDateManager.getNewValuesFromNewActiveDate(mergedDate);\n shouldPublish = true;\n } else {\n values = activeDateManager.getNewValuesFromNewActiveDate(newActiveDate);\n shouldPublish = (newActiveDate != null && !utils.isValid(newActiveDate)) !== (activeDateManager.date != null && !utils.isValid(activeDateManager.date));\n }\n\n /**\n * Publish or update the internal state with the new value and sections.\n */\n if (shouldPublish) {\n return publishValue(_extends({}, values, {\n sections: newSections\n }));\n }\n return setState(prevState => _extends({}, prevState, values, {\n sections: newSections,\n tempValueStrAndroid: null\n }));\n };\n const setTempAndroidValueStr = tempValueStrAndroid => setState(prev => _extends({}, prev, {\n tempValueStrAndroid\n }));\n React.useEffect(() => {\n const sections = getSectionsFromValue(state.value);\n validateSections(sections, valueType);\n setState(prevState => _extends({}, prevState, {\n sections\n }));\n }, [format, utils.locale, isRtl]); // eslint-disable-line react-hooks/exhaustive-deps\n\n React.useEffect(() => {\n let shouldUpdate;\n if (!valueManager.areValuesEqual(utils, state.value, valueFromTheOutside)) {\n shouldUpdate = true;\n } else {\n shouldUpdate = valueManager.getTimezone(utils, state.value) !== valueManager.getTimezone(utils, valueFromTheOutside);\n }\n if (shouldUpdate) {\n setState(prevState => _extends({}, prevState, {\n value: valueFromTheOutside,\n referenceValue: fieldValueManager.updateReferenceValue(utils, valueFromTheOutside, prevState.referenceValue),\n sections: getSectionsFromValue(valueFromTheOutside)\n }));\n }\n }, [valueFromTheOutside]); // eslint-disable-line react-hooks/exhaustive-deps\n\n return {\n state,\n activeSectionIndex,\n parsedSelectedSections,\n setSelectedSections,\n clearValue,\n clearActiveSection,\n updateSectionValue,\n updateValueFromValueStr,\n setTempAndroidValueStr,\n getSectionsFromValue,\n sectionsValueBoundaries,\n localizedDigits,\n timezone\n };\n};"],"names":["useFieldState","params","utils","useUtils","translations","usePickersTranslations","adapter","useLocalizationContext","isRtl","useRtl","valueManager","fieldValueManager","valueType","validator","internalProps","value","valueProp","defaultValue","referenceDate","referenceDateProp","onChange","format","formatDensity","selectedSections","selectedSectionsProp","onSelectedSectionsChange","shouldRespectLeadingZeros","timezone","timezoneProp","enableAccessibleFieldDOMStructure","valueFromTheOutside","handleValueChange","useValueWithTimezone","localizedDigits","React","useMemo","getLocalizedDigits","sectionsValueBoundaries","getSectionsBoundaries","getSectionsFromValue","useCallback","fallbackSections","date","buildSectionsFromFormat","localeText","state","setState","useState","sections","validateSections","stateWithoutReferenceDate","referenceValue","emptyValue","tempValueStrAndroid","granularity","getSectionTypeGranularity","getInitialReferenceValue","props","_extends","innerSetSelectedSections","useControlled","controlled","default","name","setSelectedSections","newSelectedSections","parsedSelectedSections","parseSelectedSections","activeSectionIndex","publishValue","prevState","areValuesEqual","context","validationError","setSectionValue","sectionIndex","newSectionValue","newSections","modified","useEffect","locale","shouldUpdate","getTimezone","updateReferenceValue","clearValue","clearActiveSection","activeSection","activeDateManager","getActiveDateManager","hasNoOtherNonEmptySections","getSections","filter","section","length","newActiveDate","getInvalidDate","newValues","getNewValuesFromNewActiveDate","updateSectionValue","shouldGoToNextSection","newActiveDateSections","getDateFromDateSections","values","shouldPublish","isValid","mergedDate","mergeDateIntoReferenceDate","updateValueFromValueStr","valueStr","newValue","parseValueStr","dateStr","parse","newReferenceValue","setTempAndroidValueStr","prev"],"mappings":"0yBAUY,MAACA,EAAgBC,IAC3B,MAAMC,EAAQC,IACRC,EAAeC,IACfC,EAAUC,IACVC,EAAQC,KACRC,aACJA,EAAYC,kBACZA,EAAiBC,UACjBA,EAASC,UACTA,EAASC,cACTA,EACAA,eACEC,MAAOC,EAASC,aAChBA,EACAC,cAAeC,EAAiBC,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EAAQ,CAC3DtD,SAAU6B,EACVxB,oBAAqB,QACpB,EAqCHsD,wBA/G8BC,IAC9B,MAkBMC,EAAWlG,EAAkBmG,cAAcF,EAAU/D,EAAMM,gBAlB5C,CAAC4D,EAAS7F,KAC7B,MAAMwB,EAAOxC,EAAM8G,MAAMD,EAAS1F,GAClC,GAAY,MAARqB,IAAiBxC,EAAMsG,QAAQ9D,GACjC,OAAO,KAET,MAAMM,EAAWL,EAAwB,CACvCzC,QACA0C,WAAYxC,EACZ6B,kBACAZ,SACAqB,OACApB,gBACAI,4BACAG,oCACArB,UAEF,OAAOkG,EAA2BxG,EAAOwC,EAAMM,EAAU9B,GAAe,EAAM,IAG1E+F,EAAoBtG,EAAkBwE,qBAAqBjF,EAAO2G,EAAUhE,EAAMM,gBACxFkB,EAAa,CACXtD,MAAO8F,EACP1D,eAAgB8D,EAChBjE,SAAUT,EAAqBsE,EAAUhE,EAAMG,WAC/C,EAuFFkE,uBApC6B7D,GAAuBP,GAASqE,GAAQzD,EAAS,CAAE,EAAEyD,EAAM,CACxF9D,0BAoCAd,uBACAF,0BACAJ,kBACAN,WACD"}
|
1
|
+
{"version":3,"file":"useFieldState.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldState.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport useControlled from '@mui/utils/useControlled';\nimport { useRtl } from '@mui/system/RtlProvider';\nimport { usePickersTranslations } from \"../../../hooks/usePickersTranslations.js\";\nimport { useUtils, useLocalizationContext } from \"../useUtils.js\";\nimport { mergeDateIntoReferenceDate, getSectionsBoundaries, validateSections, getDateFromDateSections, parseSelectedSections, getLocalizedDigits } from \"./useField.utils.js\";\nimport { buildSectionsFromFormat } from \"./buildSectionsFromFormat.js\";\nimport { useValueWithTimezone } from \"../useValueWithTimezone.js\";\nimport { getSectionTypeGranularity } from \"../../utils/getDefaultReferenceDate.js\";\nexport const useFieldState = params => {\n const utils = useUtils();\n const translations = usePickersTranslations();\n const adapter = useLocalizationContext();\n const isRtl = useRtl();\n const {\n valueManager,\n fieldValueManager,\n valueType,\n validator,\n internalProps,\n internalProps: {\n value: valueProp,\n defaultValue,\n referenceDate: referenceDateProp,\n onChange,\n format,\n formatDensity = 'dense',\n selectedSections: selectedSectionsProp,\n onSelectedSectionsChange,\n shouldRespectLeadingZeros = false,\n timezone: timezoneProp,\n enableAccessibleFieldDOMStructure = false\n }\n } = params;\n const {\n timezone,\n value: valueFromTheOutside,\n handleValueChange\n } = useValueWithTimezone({\n timezone: timezoneProp,\n value: valueProp,\n defaultValue,\n referenceDate: referenceDateProp,\n onChange,\n valueManager\n });\n const localizedDigits = React.useMemo(() => getLocalizedDigits(utils), [utils]);\n const sectionsValueBoundaries = React.useMemo(() => getSectionsBoundaries(utils, localizedDigits, timezone), [utils, localizedDigits, timezone]);\n const getSectionsFromValue = React.useCallback((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, date => buildSectionsFromFormat({\n utils,\n localeText: translations,\n localizedDigits,\n format,\n date,\n formatDensity,\n shouldRespectLeadingZeros,\n enableAccessibleFieldDOMStructure,\n isRtl\n })), [fieldValueManager, format, translations, localizedDigits, isRtl, shouldRespectLeadingZeros, utils, formatDensity, enableAccessibleFieldDOMStructure]);\n const [state, setState] = React.useState(() => {\n const sections = getSectionsFromValue(valueFromTheOutside);\n validateSections(sections, valueType);\n const stateWithoutReferenceDate = {\n sections,\n value: valueFromTheOutside,\n referenceValue: valueManager.emptyValue,\n tempValueStrAndroid: null\n };\n const granularity = getSectionTypeGranularity(sections);\n const referenceValue = valueManager.getInitialReferenceValue({\n referenceDate: referenceDateProp,\n value: valueFromTheOutside,\n utils,\n props: internalProps,\n granularity,\n timezone\n });\n return _extends({}, stateWithoutReferenceDate, {\n referenceValue\n });\n });\n const [selectedSections, innerSetSelectedSections] = useControlled({\n controlled: selectedSectionsProp,\n default: null,\n name: 'useField',\n state: 'selectedSections'\n });\n const setSelectedSections = newSelectedSections => {\n innerSetSelectedSections(newSelectedSections);\n onSelectedSectionsChange?.(newSelectedSections);\n };\n const parsedSelectedSections = React.useMemo(() => parseSelectedSections(selectedSections, state.sections), [selectedSections, state.sections]);\n const activeSectionIndex = parsedSelectedSections === 'all' ? 0 : parsedSelectedSections;\n const publishValue = ({\n value,\n referenceValue,\n sections\n }) => {\n setState(prevState => _extends({}, prevState, {\n sections,\n value,\n referenceValue,\n tempValueStrAndroid: null\n }));\n if (valueManager.areValuesEqual(utils, state.value, value)) {\n return;\n }\n const context = {\n validationError: validator({\n adapter,\n value,\n timezone,\n props: internalProps\n })\n };\n handleValueChange(value, context);\n };\n const setSectionValue = (sectionIndex, newSectionValue) => {\n const newSections = [...state.sections];\n newSections[sectionIndex] = _extends({}, newSections[sectionIndex], {\n value: newSectionValue,\n modified: true\n });\n return newSections;\n };\n const clearValue = () => {\n publishValue({\n value: valueManager.emptyValue,\n referenceValue: state.referenceValue,\n sections: getSectionsFromValue(valueManager.emptyValue)\n });\n };\n const clearActiveSection = () => {\n if (activeSectionIndex == null) {\n return;\n }\n const activeSection = state.sections[activeSectionIndex];\n const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);\n const nonEmptySectionCountBefore = activeDateManager.getSections(state.sections).filter(section => section.value !== '').length;\n const hasNoOtherNonEmptySections = nonEmptySectionCountBefore === (activeSection.value === '' ? 0 : 1);\n const newSections = setSectionValue(activeSectionIndex, '');\n const newActiveDate = hasNoOtherNonEmptySections ? null : utils.getInvalidDate();\n const newValues = activeDateManager.getNewValuesFromNewActiveDate(newActiveDate);\n publishValue(_extends({}, newValues, {\n sections: newSections\n }));\n };\n const updateValueFromValueStr = valueStr => {\n const parseDateStr = (dateStr, referenceDate) => {\n const date = utils.parse(dateStr, format);\n if (date == null || !utils.isValid(date)) {\n return null;\n }\n const sections = buildSectionsFromFormat({\n utils,\n localeText: translations,\n localizedDigits,\n format,\n date,\n formatDensity,\n shouldRespectLeadingZeros,\n enableAccessibleFieldDOMStructure,\n isRtl\n });\n return mergeDateIntoReferenceDate(utils, date, sections, referenceDate, false);\n };\n const newValue = fieldValueManager.parseValueStr(valueStr, state.referenceValue, parseDateStr);\n const newReferenceValue = fieldValueManager.updateReferenceValue(utils, newValue, state.referenceValue);\n publishValue({\n value: newValue,\n referenceValue: newReferenceValue,\n sections: getSectionsFromValue(newValue, state.sections)\n });\n };\n const updateSectionValue = ({\n activeSection,\n newSectionValue,\n shouldGoToNextSection\n }) => {\n /**\n * 1. Decide which section should be focused\n */\n if (shouldGoToNextSection && activeSectionIndex < state.sections.length - 1) {\n setSelectedSections(activeSectionIndex + 1);\n }\n\n /**\n * 2. Try to build a valid date from the new section value\n */\n const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);\n const newSections = setSectionValue(activeSectionIndex, newSectionValue);\n const newActiveDateSections = activeDateManager.getSections(newSections);\n const newActiveDate = getDateFromDateSections(utils, newActiveDateSections, localizedDigits);\n let values;\n let shouldPublish;\n\n /**\n * If the new date is valid,\n * Then we merge the value of the modified sections into the reference date.\n * This makes sure that we don't lose some information of the initial date (like the time on a date field).\n */\n if (newActiveDate != null && utils.isValid(newActiveDate)) {\n const mergedDate = mergeDateIntoReferenceDate(utils, newActiveDate, newActiveDateSections, activeDateManager.referenceDate, true);\n values = activeDateManager.getNewValuesFromNewActiveDate(mergedDate);\n shouldPublish = true;\n } else {\n values = activeDateManager.getNewValuesFromNewActiveDate(newActiveDate);\n shouldPublish = (newActiveDate != null && !utils.isValid(newActiveDate)) !== (activeDateManager.date != null && !utils.isValid(activeDateManager.date));\n }\n\n /**\n * Publish or update the internal state with the new value and sections.\n */\n if (shouldPublish) {\n return publishValue(_extends({}, values, {\n sections: newSections\n }));\n }\n return setState(prevState => _extends({}, prevState, values, {\n sections: newSections,\n tempValueStrAndroid: null\n }));\n };\n const setTempAndroidValueStr = tempValueStrAndroid => setState(prev => _extends({}, prev, {\n tempValueStrAndroid\n }));\n React.useEffect(() => {\n const sections = getSectionsFromValue(state.value);\n validateSections(sections, valueType);\n setState(prevState => _extends({}, prevState, {\n sections\n }));\n }, [format, utils.locale, isRtl]); // eslint-disable-line react-hooks/exhaustive-deps\n\n React.useEffect(() => {\n let shouldUpdate;\n if (!valueManager.areValuesEqual(utils, state.value, valueFromTheOutside)) {\n shouldUpdate = true;\n } else {\n shouldUpdate = valueManager.getTimezone(utils, state.value) !== valueManager.getTimezone(utils, valueFromTheOutside);\n }\n if (shouldUpdate) {\n setState(prevState => _extends({}, prevState, {\n value: valueFromTheOutside,\n referenceValue: fieldValueManager.updateReferenceValue(utils, valueFromTheOutside, prevState.referenceValue),\n sections: getSectionsFromValue(valueFromTheOutside)\n }));\n }\n }, [valueFromTheOutside]); // eslint-disable-line react-hooks/exhaustive-deps\n\n return {\n state,\n activeSectionIndex,\n parsedSelectedSections,\n setSelectedSections,\n clearValue,\n clearActiveSection,\n updateSectionValue,\n updateValueFromValueStr,\n setTempAndroidValueStr,\n getSectionsFromValue,\n sectionsValueBoundaries,\n localizedDigits,\n timezone\n };\n};"],"names":["useFieldState","params","utils","useUtils","translations","usePickersTranslations","adapter","useLocalizationContext","isRtl","useRtl","valueManager","fieldValueManager","valueType","validator","internalProps","value","valueProp","defaultValue","referenceDate","referenceDateProp","onChange","format","formatDensity","selectedSections","selectedSectionsProp","onSelectedSectionsChange","shouldRespectLeadingZeros","timezone","timezoneProp","enableAccessibleFieldDOMStructure","valueFromTheOutside","handleValueChange","useValueWithTimezone","localizedDigits","React","useMemo","getLocalizedDigits","sectionsValueBoundaries","getSectionsBoundaries","getSectionsFromValue","useCallback","fallbackSections","date","buildSectionsFromFormat","localeText","state","setState","useState","sections","validateSections","stateWithoutReferenceDate","referenceValue","emptyValue","tempValueStrAndroid","granularity","getSectionTypeGranularity","getInitialReferenceValue","props","_extends","innerSetSelectedSections","useControlled","controlled","default","name","setSelectedSections","newSelectedSections","parsedSelectedSections","parseSelectedSections","activeSectionIndex","publishValue","prevState","areValuesEqual","context","validationError","setSectionValue","sectionIndex","newSectionValue","newSections","modified","useEffect","locale","shouldUpdate","getTimezone","updateReferenceValue","clearValue","clearActiveSection","activeSection","activeDateManager","getActiveDateManager","hasNoOtherNonEmptySections","getSections","filter","section","length","newActiveDate","getInvalidDate","newValues","getNewValuesFromNewActiveDate","updateSectionValue","shouldGoToNextSection","newActiveDateSections","getDateFromDateSections","values","shouldPublish","isValid","mergedDate","mergeDateIntoReferenceDate","updateValueFromValueStr","valueStr","newValue","parseValueStr","dateStr","parse","newReferenceValue","setTempAndroidValueStr","prev"],"mappings":"2xBAUY,MAACA,EAAgBC,IAC3B,MAAMC,EAAQC,IACRC,EAAeC,IACfC,EAAUC,IACVC,EAAQC,KACRC,aACJA,EAAYC,kBACZA,EAAiBC,UACjBA,EAASC,UACTA,EAASC,cACTA,EACAA,eACEC,MAAOC,EAASC,aAChBA,EACAC,cAAeC,EAAiBC,SAChCA,EAAQC,OACRA,EAAMC,cACNA,EAAgB,QAChBC,iBAAkBC,EAAoBC,yBACtCA,EAAwBC,0BACxBA,GAA4B,EAC5BC,SAAUC,EAAYC,kCACtBA,GAAoC,IAEpC5B,GACE0B,SACJA,EACAZ,MAAOe,EAAmBC,kBAC1BA,GACEC,EAAqB,CACvBL,SAAUC,EACVb,MAAOC,EACPC,eACAC,cAAeC,EACfC,WACAV,iBAEIuB,EAAkBC,EAAMC,SAAQ,IAAMC,EAAmBlC,IAAQ,CAACA,IAClEmC,EAA0BH,EAAMC,SAAQ,IAAMG,EAAsBpC,EAAO+B,EAAiBN,IAAW,CAACzB,EAAO+B,EAAiBN,IAChIY,EAAuBL,EAAMM,aAAY,CAACzB,EAAO0B,EAAmB,OAAS9B,EAAkB4B,qBAAqBrC,EAAOa,EAAO0B,GAAkBC,GAAQC,EAAwB,CACxLzC,QACA0C,WAAYxC,EACZ6B,kBACAZ,SACAqB,OACApB,gBACAI,4BACAG,oCACArB,aACG,CAACG,EAAmBU,EAAQjB,EAAc6B,EAAiBzB,EAAOkB,EAA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,0BACAJ,kBACAN,WACD"}
|
package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV6TextField.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import*as t from"react";import{useRtl as n}from"../../../../system/esm/RtlProvider/index.js";import
|
1
|
+
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import*as t from"react";import{useRtl as n}from"../../../../system/esm/RtlProvider/index.js";import r from"../../../../utils/esm/useEventCallback/useEventCallback.js";import o from"../../../../utils/esm/useForkRef/useForkRef.js";import{getActiveElement as l}from"../../utils/utils.js";import{isAndroid as u,getSectionVisibleValue as c}from"./useField.utils.js";const s=e=>e.replace(/[\u2066\u2067\u2068\u2069]/g,""),a=(t,n,r)=>{let o=0,l=r?1:0;const u=[];for(let a=0;a<t.length;a+=1){const i=t[a],d=c(i,r?"input-rtl":"input-ltr",n),p=`${i.startSeparator}${d}${i.endSeparator}`,m=s(p).length,f=p.length,g=s(d),S=l+(""===g?0:d.indexOf(g[0]))+i.startSeparator.length,h=S+g.length;u.push(e({},i,{start:o,end:o+m,startInInput:S,endInInput:h})),o+=m,l+=f}return u},i=e=>{const c=n(),i=t.useRef(void 0),d=t.useRef(void 0),{forwardedProps:{onFocus:p,onClick:m,onPaste:f,onBlur:g,inputRef:S,placeholder:h},internalProps:{readOnly:I=!1,disabled:v=!1},parsedSelectedSections:y,activeSectionIndex:V,state:T,fieldValueManager:F,valueManager:x,applyCharacterEditing:M,resetCharacterQuery:b,updateSectionValue:E,updateValueFromValueStr:A,clearActiveSection:D,clearValue:R,setTempAndroidValueStr:C,setSelectedSections:k,getSectionsFromValue:O,areAllSectionsEmpty:P,localizedDigits:j}=e,$=t.useRef(null),z=o(S,$),w=t.useMemo((()=>a(T.sections,j,c)),[T.sections,j,c]),N=t.useMemo((()=>({syncSelectionToDOM:()=>{if(!$.current)return;if(null==y)return void($.current.scrollLeft&&($.current.scrollLeft=0));if($.current!==l(document))return;const e=$.current.scrollTop;if("all"===y)$.current.select();else{const e=w[y],t="empty"===e.type?e.startInInput-e.startSeparator.length:e.startInInput,n="empty"===e.type?e.endInInput+e.endSeparator.length:e.endInInput;t===$.current.selectionStart&&n===$.current.selectionEnd||$.current===l(document)&&$.current.setSelectionRange(t,n),clearTimeout(d.current),d.current=setTimeout((()=>{!$.current||$.current!==l(document)||$.current.selectionStart!==$.current.selectionEnd||$.current.selectionStart===t&&$.current.selectionEnd===n||N.syncSelectionToDOM()}))}$.current.scrollTop=e},getActiveSectionIndexFromDOM:()=>{const e=$.current.selectionStart??0,t=$.current.selectionEnd??0;if(0===e&&0===t)return null;const n=e<=w[0].startInInput?1:w.findIndex((t=>t.startInInput-t.startSeparator.length>e));return-1===n?w.length-1:n-1},focusField:(e=0)=>{l(document)!==$.current&&($.current?.focus(),k(e))},setSelectedSections:e=>k(e),isFieldFocused:()=>$.current===l(document)})),[$,y,w,k]),Z=()=>{const e=$.current.selectionStart??0;let t;t=e<=w[0].startInInput||e>=w[w.length-1].endInInput?1:w.findIndex((t=>t.startInInput-t.startSeparator.length>e));const n=-1===t?w.length-1:t-1;k(n)},B=r(((...e)=>{p?.(...e);const t=$.current;clearTimeout(i.current),i.current=setTimeout((()=>{t&&t===$.current&&null==V&&(t.value.length&&Number(t.selectionEnd)-Number(t.selectionStart)===t.value.length?k("all"):Z())}))})),L=r(((e,...t)=>{e.isDefaultPrevented()||(m?.(e,...t),Z())})),G=r((e=>{if(f?.(e),e.preventDefault(),I||v)return;const t=e.clipboardData.getData("text");if("number"==typeof y){const e=T.sections[y],n=/^[a-zA-Z]+$/.test(t),r=/^[0-9]+$/.test(t),o=/^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(t);if("letter"===e.contentType&&n||"digit"===e.contentType&&r||"digit-with-letter"===e.contentType&&o)return b(),void E({activeSection:e,newSectionValue:t,shouldGoToNextSection:!0});if(n||r)return}b(),A(t)})),Q=r(((...e)=>{g?.(...e),k(null)})),q=r((e=>{if(I)return;const t=e.target.value;if(""===t)return b(),void R();const n=e.nativeEvent.data,r=n&&n.length>1,o=r?n:t,l=s(o);if("all"===y&&k(V),null==V||r)return void A(r?n:l);let a;if("all"===y&&1===l.length)a=l;else{const e=s(F.getV6InputValueFromSections(w,j,c));let t=-1,n=-1;for(let r=0;r<e.length;r+=1)-1===t&&e[r]!==l[r]&&(t=r),-1===n&&e[e.length-r-1]!==l[l.length-r-1]&&(n=r);const r=w[V];if(t<r.start||e.length-n-1>r.end)return;const o=l.length-e.length+r.end-s(r.endSeparator||"").length;a=l.slice(r.start+s(r.startSeparator||"").length,o)}if(0===a.length)return u()&&C(o),b(),void D();M({keyPressed:a,sectionIndex:V})})),H=t.useMemo((()=>void 0!==h?h:F.getV6InputValueFromSections(O(x.emptyValue),j,c)),[h,F,O,x.emptyValue,j,c]),J=t.useMemo((()=>T.tempValueStrAndroid??F.getV6InputValueFromSections(T.sections,j,c)),[T.sections,F,T.tempValueStrAndroid,j,c]);t.useEffect((()=>($.current&&$.current===l(document)&&k("all"),()=>{clearTimeout(i.current),clearTimeout(d.current)})),[]);const K=t.useMemo((()=>null==V||"letter"===T.sections[V].contentType?"text":"numeric"),[V,T.sections]),U=$.current&&$.current===l(document);return{interactions:N,returnedValue:{readOnly:I,onBlur:Q,onClick:L,onFocus:B,onPaste:G,inputRef:z,enableAccessibleFieldDOMStructure:!1,placeholder:H,inputMode:K,autoComplete:"off",value:!U&&P?"":J,onChange:q}}};export{a as addPositionPropertiesToSections,i as useFieldV6TextField};
|
2
2
|
//# sourceMappingURL=useFieldV6TextField.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useFieldV6TextField.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV6TextField.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { useRtl } from '@mui/system/RtlProvider';\nimport useEventCallback from '@mui/utils/useEventCallback';\nimport useForkRef from '@mui/utils/useForkRef';\nimport { getActiveElement } from \"../../utils/utils.js\";\nimport { getSectionVisibleValue, isAndroid } from \"./useField.utils.js\";\nconst cleanString = dirtyString => dirtyString.replace(/[\\u2066\\u2067\\u2068\\u2069]/g, '');\nexport const addPositionPropertiesToSections = (sections, localizedDigits, isRtl) => {\n let position = 0;\n let positionInInput = isRtl ? 1 : 0;\n const newSections = [];\n for (let i = 0; i < sections.length; i += 1) {\n const section = sections[i];\n const renderedValue = getSectionVisibleValue(section, isRtl ? 'input-rtl' : 'input-ltr', localizedDigits);\n const sectionStr = `${section.startSeparator}${renderedValue}${section.endSeparator}`;\n const sectionLength = cleanString(sectionStr).length;\n const sectionLengthInInput = sectionStr.length;\n\n // The ...InInput values consider the unicode characters but do include them in their indexes\n const cleanedValue = cleanString(renderedValue);\n const startInInput = positionInInput + (cleanedValue === '' ? 0 : renderedValue.indexOf(cleanedValue[0])) + section.startSeparator.length;\n const endInInput = startInInput + cleanedValue.length;\n newSections.push(_extends({}, section, {\n start: position,\n end: position + sectionLength,\n startInInput,\n endInInput\n }));\n position += sectionLength;\n // Move position to the end of string associated to the current section\n positionInInput += sectionLengthInInput;\n }\n return newSections;\n};\nexport const useFieldV6TextField = params => {\n const isRtl = useRtl();\n const focusTimeoutRef = React.useRef(undefined);\n const selectionSyncTimeoutRef = React.useRef(undefined);\n const {\n forwardedProps: {\n onFocus,\n onClick,\n onPaste,\n onBlur,\n inputRef: inputRefProp,\n placeholder: inPlaceholder\n },\n internalProps: {\n readOnly = false,\n disabled = false\n },\n parsedSelectedSections,\n activeSectionIndex,\n state,\n fieldValueManager,\n valueManager,\n applyCharacterEditing,\n resetCharacterQuery,\n updateSectionValue,\n updateValueFromValueStr,\n clearActiveSection,\n clearValue,\n setTempAndroidValueStr,\n setSelectedSections,\n getSectionsFromValue,\n areAllSectionsEmpty,\n localizedDigits\n } = params;\n const inputRef = React.useRef(null);\n const handleRef = useForkRef(inputRefProp, inputRef);\n const sections = React.useMemo(() => addPositionPropertiesToSections(state.sections, localizedDigits, isRtl), [state.sections, localizedDigits, isRtl]);\n const interactions = React.useMemo(() => ({\n syncSelectionToDOM: () => {\n if (!inputRef.current) {\n return;\n }\n if (parsedSelectedSections == null) {\n if (inputRef.current.scrollLeft) {\n // Ensure that input content is not marked as selected.\n // setting selection range to 0 causes issues in Safari.\n // https://bugs.webkit.org/show_bug.cgi?id=224425\n inputRef.current.scrollLeft = 0;\n }\n return;\n }\n\n // On multi input range pickers we want to update selection range only for the active input\n // This helps to avoid the focus jumping on Safari https://github.com/mui/mui-x/issues/9003\n // because WebKit implements the `setSelectionRange` based on the spec: https://bugs.webkit.org/show_bug.cgi?id=224425\n if (inputRef.current !== getActiveElement(document)) {\n return;\n }\n\n // Fix scroll jumping on iOS browser: https://github.com/mui/mui-x/issues/8321\n const currentScrollTop = inputRef.current.scrollTop;\n if (parsedSelectedSections === 'all') {\n inputRef.current.select();\n } else {\n const selectedSection = sections[parsedSelectedSections];\n const selectionStart = selectedSection.type === 'empty' ? selectedSection.startInInput - selectedSection.startSeparator.length : selectedSection.startInInput;\n const selectionEnd = selectedSection.type === 'empty' ? selectedSection.endInInput + selectedSection.endSeparator.length : selectedSection.endInInput;\n if (selectionStart !== inputRef.current.selectionStart || selectionEnd !== inputRef.current.selectionEnd) {\n if (inputRef.current === getActiveElement(document)) {\n inputRef.current.setSelectionRange(selectionStart, selectionEnd);\n }\n }\n clearTimeout(selectionSyncTimeoutRef.current);\n selectionSyncTimeoutRef.current = setTimeout(() => {\n // handle case when the selection is not updated correctly\n // could happen on Android\n if (inputRef.current && inputRef.current === getActiveElement(document) &&\n // The section might loose all selection, where `selectionStart === selectionEnd`\n // https://github.com/mui/mui-x/pull/13652\n inputRef.current.selectionStart === inputRef.current.selectionEnd && (inputRef.current.selectionStart !== selectionStart || inputRef.current.selectionEnd !== selectionEnd)) {\n interactions.syncSelectionToDOM();\n }\n });\n }\n\n // Even reading this variable seems to do the trick, but also setting it just to make use of it\n inputRef.current.scrollTop = currentScrollTop;\n },\n getActiveSectionIndexFromDOM: () => {\n const browserStartIndex = inputRef.current.selectionStart ?? 0;\n const browserEndIndex = inputRef.current.selectionEnd ?? 0;\n if (browserStartIndex === 0 && browserEndIndex === 0) {\n return null;\n }\n const nextSectionIndex = browserStartIndex <= sections[0].startInInput ? 1 // Special case if browser index is in invisible characters at the beginning.\n : sections.findIndex(section => section.startInInput - section.startSeparator.length > browserStartIndex);\n return nextSectionIndex === -1 ? sections.length - 1 : nextSectionIndex - 1;\n },\n focusField: (newSelectedSection = 0) => {\n if (getActiveElement(document) === inputRef.current) {\n return;\n }\n inputRef.current?.focus();\n setSelectedSections(newSelectedSection);\n },\n setSelectedSections: newSelectedSections => setSelectedSections(newSelectedSections),\n isFieldFocused: () => inputRef.current === getActiveElement(document)\n }), [inputRef, parsedSelectedSections, sections, setSelectedSections]);\n const syncSelectionFromDOM = () => {\n const browserStartIndex = inputRef.current.selectionStart ?? 0;\n let nextSectionIndex;\n if (browserStartIndex <= sections[0].startInInput) {\n // Special case if browser index is in invisible characters at the beginning\n nextSectionIndex = 1;\n } else if (browserStartIndex >= sections[sections.length - 1].endInInput) {\n // If the click is after the last character of the input, then we want to select the 1st section.\n nextSectionIndex = 1;\n } else {\n nextSectionIndex = sections.findIndex(section => section.startInInput - section.startSeparator.length > browserStartIndex);\n }\n const sectionIndex = nextSectionIndex === -1 ? sections.length - 1 : nextSectionIndex - 1;\n setSelectedSections(sectionIndex);\n };\n const handleInputFocus = useEventCallback((...args) => {\n onFocus?.(...args);\n // The ref is guaranteed to be resolved at this point.\n const input = inputRef.current;\n clearTimeout(focusTimeoutRef.current);\n focusTimeoutRef.current = setTimeout(() => {\n // The ref changed, the component got remounted, the focus event is no longer relevant.\n if (!input || input !== inputRef.current) {\n return;\n }\n if (activeSectionIndex != null) {\n return;\n }\n if (\n // avoid selecting all sections when focusing empty field without value\n input.value.length && Number(input.selectionEnd) - Number(input.selectionStart) === input.value.length) {\n setSelectedSections('all');\n } else {\n syncSelectionFromDOM();\n }\n });\n });\n const handleInputClick = useEventCallback((event, ...args) => {\n // The click event on the clear button would propagate to the input, trigger this handler and result in a wrong section selection.\n // We avoid this by checking if the call of `handleInputClick` is actually intended, or a side effect.\n if (event.isDefaultPrevented()) {\n return;\n }\n onClick?.(event, ...args);\n syncSelectionFromDOM();\n });\n const handleInputPaste = useEventCallback(event => {\n onPaste?.(event);\n\n // prevent default to avoid the input `onChange` handler being called\n event.preventDefault();\n if (readOnly || disabled) {\n return;\n }\n const pastedValue = event.clipboardData.getData('text');\n if (typeof parsedSelectedSections === 'number') {\n const activeSection = state.sections[parsedSelectedSections];\n const lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);\n const digitsOnly = /^[0-9]+$/.test(pastedValue);\n const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);\n const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;\n if (isValidPastedValue) {\n resetCharacterQuery();\n updateSectionValue({\n activeSection,\n newSectionValue: pastedValue,\n shouldGoToNextSection: true\n });\n return;\n }\n if (lettersOnly || digitsOnly) {\n // The pasted value corresponds to a single section, but not the expected type,\n // skip the modification\n return;\n }\n }\n resetCharacterQuery();\n updateValueFromValueStr(pastedValue);\n });\n const handleContainerBlur = useEventCallback((...args) => {\n onBlur?.(...args);\n setSelectedSections(null);\n });\n const handleInputChange = useEventCallback(event => {\n if (readOnly) {\n return;\n }\n const targetValue = event.target.value;\n if (targetValue === '') {\n resetCharacterQuery();\n clearValue();\n return;\n }\n const eventData = event.nativeEvent.data;\n // Calling `.fill(04/11/2022)` in playwright will trigger a change event with the requested content to insert in `event.nativeEvent.data`\n // usual changes have only the currently typed character in the `event.nativeEvent.data`\n const shouldUseEventData = eventData && eventData.length > 1;\n const valueStr = shouldUseEventData ? eventData : targetValue;\n const cleanValueStr = cleanString(valueStr);\n if (parsedSelectedSections === 'all') {\n setSelectedSections(activeSectionIndex);\n }\n\n // If no section is selected or eventData should be used, we just try to parse the new value\n // This line is mostly triggered by imperative code / application tests.\n if (activeSectionIndex == null || shouldUseEventData) {\n updateValueFromValueStr(shouldUseEventData ? eventData : cleanValueStr);\n return;\n }\n let keyPressed;\n if (parsedSelectedSections === 'all' && cleanValueStr.length === 1) {\n keyPressed = cleanValueStr;\n } else {\n const prevValueStr = cleanString(fieldValueManager.getV6InputValueFromSections(sections, localizedDigits, isRtl));\n let startOfDiffIndex = -1;\n let endOfDiffIndex = -1;\n for (let i = 0; i < prevValueStr.length; i += 1) {\n if (startOfDiffIndex === -1 && prevValueStr[i] !== cleanValueStr[i]) {\n startOfDiffIndex = i;\n }\n if (endOfDiffIndex === -1 && prevValueStr[prevValueStr.length - i - 1] !== cleanValueStr[cleanValueStr.length - i - 1]) {\n endOfDiffIndex = i;\n }\n }\n const activeSection = sections[activeSectionIndex];\n const hasDiffOutsideOfActiveSection = startOfDiffIndex < activeSection.start || prevValueStr.length - endOfDiffIndex - 1 > activeSection.end;\n if (hasDiffOutsideOfActiveSection) {\n // TODO: Support if the new date is valid\n return;\n }\n\n // The active section being selected, the browser has replaced its value with the key pressed by the user.\n const activeSectionEndRelativeToNewValue = cleanValueStr.length - prevValueStr.length + activeSection.end - cleanString(activeSection.endSeparator || '').length;\n keyPressed = cleanValueStr.slice(activeSection.start + cleanString(activeSection.startSeparator || '').length, activeSectionEndRelativeToNewValue);\n }\n if (keyPressed.length === 0) {\n if (isAndroid()) {\n setTempAndroidValueStr(valueStr);\n }\n resetCharacterQuery();\n clearActiveSection();\n return;\n }\n applyCharacterEditing({\n keyPressed,\n sectionIndex: activeSectionIndex\n });\n });\n const placeholder = React.useMemo(() => {\n if (inPlaceholder !== undefined) {\n return inPlaceholder;\n }\n return fieldValueManager.getV6InputValueFromSections(getSectionsFromValue(valueManager.emptyValue), localizedDigits, isRtl);\n }, [inPlaceholder, fieldValueManager, getSectionsFromValue, valueManager.emptyValue, localizedDigits, isRtl]);\n const valueStr = React.useMemo(() => state.tempValueStrAndroid ?? fieldValueManager.getV6InputValueFromSections(state.sections, localizedDigits, isRtl), [state.sections, fieldValueManager, state.tempValueStrAndroid, localizedDigits, isRtl]);\n React.useEffect(() => {\n // Select all the sections when focused on mount (`autoFocus = true` on the input)\n if (inputRef.current && inputRef.current === getActiveElement(document)) {\n setSelectedSections('all');\n }\n return () => {\n clearTimeout(focusTimeoutRef.current);\n clearTimeout(selectionSyncTimeoutRef.current);\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const inputMode = React.useMemo(() => {\n if (activeSectionIndex == null) {\n return 'text';\n }\n if (state.sections[activeSectionIndex].contentType === 'letter') {\n return 'text';\n }\n return 'numeric';\n }, [activeSectionIndex, state.sections]);\n const inputHasFocus = inputRef.current && inputRef.current === getActiveElement(document);\n const shouldShowPlaceholder = !inputHasFocus && areAllSectionsEmpty;\n return {\n interactions,\n returnedValue: {\n // Forwarded\n readOnly,\n onBlur: handleContainerBlur,\n onClick: handleInputClick,\n onFocus: handleInputFocus,\n onPaste: handleInputPaste,\n inputRef: handleRef,\n // Additional\n enableAccessibleFieldDOMStructure: false,\n placeholder,\n inputMode,\n autoComplete: 'off',\n value: shouldShowPlaceholder ? '' : valueStr,\n onChange: handleInputChange\n }\n };\n};"],"names":["cleanString","dirtyString","replace","addPositionPropertiesToSections","sections","localizedDigits","isRtl","position","positionInInput","newSections","i","length","section","renderedValue","getSectionVisibleValue","sectionStr","startSeparator","endSeparator","sectionLength","sectionLengthInInput","cleanedValue","startInInput","indexOf","endInInput","push","_extends","start","end","useFieldV6TextField","params","useRtl","focusTimeoutRef","React","useRef","undefined","selectionSyncTimeoutRef","forwardedProps","onFocus","onClick","onPaste","onBlur","inputRef","inputRefProp","placeholder","inPlaceholder","internalProps","readOnly","disabled","parsedSelectedSections","activeSectionIndex","state","fieldValueManager","valueManager","applyCharacterEditing","resetCharacterQuery","updateSectionValue","updateValueFromValueStr","clearActiveSection","clearValue","setTempAndroidValueStr","setSelectedSections","getSectionsFromValue","areAllSectionsEmpty","handleRef","useForkRef","useMemo","interactions","syncSelectionToDOM","current","scrollLeft","getActiveElement","document","currentScrollTop","scrollTop","select","selectedSection","selectionStart","type","selectionEnd","setSelectionRange","clearTimeout","setTimeout","getActiveSectionIndexFromDOM","browserStartIndex","browserEndIndex","nextSectionIndex","findIndex","focusField","newSelectedSection","focus","newSelectedSections","isFieldFocused","syncSelectionFromDOM","sectionIndex","handleInputFocus","useEventCallback","args","input","value","Number","handleInputClick","event","isDefaultPrevented","handleInputPaste","preventDefault","pastedValue","clipboardData","getData","activeSection","lettersOnly","test","digitsOnly","digitsAndLetterOnly","contentType","newSectionValue","shouldGoToNextSection","handleContainerBlur","handleInputChange","targetValue","target","eventData","nativeEvent","data","shouldUseEventData","valueStr","cleanValueStr","keyPressed","prevValueStr","getV6InputValueFromSections","startOfDiffIndex","endOfDiffIndex","activeSectionEndRelativeToNewValue","slice","isAndroid","emptyValue","tempValueStrAndroid","useEffect","inputMode","inputHasFocus","returnedValue","enableAccessibleFieldDOMStructure","autoComplete","onChange"],"mappings":"2cAOA,MAAMA,EAAcC,GAAeA,EAAYC,QAAQ,8BAA+B,IACzEC,EAAkC,CAACC,EAAUC,EAAiBC,KACzE,IAAIC,EAAW,EACXC,EAAkBF,EAAQ,EAAI,EAClC,MAAMG,EAAc,GACpB,IAAK,IAAIC,EAAI,EAAGA,EAAIN,EAASO,OAAQD,GAAK,EAAG,CAC3C,MAAME,EAAUR,EAASM,GACnBG,EAAgBC,EAAuBF,EAASN,EAAQ,YAAc,YAAaD,GACnFU,EAAa,GAAGH,EAAQI,iBAAiBH,IAAgBD,EAAQK,eACjEC,EAAgBlB,EAAYe,GAAYJ,OACxCQ,EAAuBJ,EAAWJ,OAGlCS,EAAepB,EAAYa,GAC3BQ,EAAeb,GAAoC,KAAjBY,EAAsB,EAAIP,EAAcS,QAAQF,EAAa,KAA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GFJ,EAAsB,CACpByE,aACAjC,aAAc5C,GACd,IAEEN,EAAcX,EAAMiC,SAAQ,SACV/B,IAAlBU,EACKA,EAEFO,EAAkB6E,4BAA4BnE,EAAqBT,EAAakF,YAAajI,EAAiBC,IACpH,CAACsC,EAAeO,EAAmBU,EAAsBT,EAAakF,WAAYjI,EAAiBC,IAChGsH,EAAW5F,EAAMiC,SAAQ,IAAMf,EAAMqF,qBAAuBpF,EAAkB6E,4BAA4B9E,EAAM9C,SAAUC,EAAiBC,IAAQ,CAAC4C,EAAM9C,SAAU+C,EAAmBD,EAAMqF,oBAAqBlI,EAAiBC,IACzO0B,EAAMwG,WAAU,KAEV/F,EAAS2B,SAAW3B,EAAS2B,UAAYE,EAAiBC,WAC5DX,EAAoB,OAEf,KACLoB,aAAajD,EAAgBqC,SAC7BY,aAAa7C,EAAwBiC,QAAQ,IAE9C,IAEH,MAAMqE,EAAYzG,EAAMiC,SAAQ,IACJ,MAAtBhB,GAGmD,WAAnDC,EAAM9C,SAAS6C,GAAoBgE,YAF9B,OAKF,WACN,CAAChE,EAAoBC,EAAM9C,WACxBsI,EAAgBjG,EAAS2B,SAAW3B,EAAS2B,UAAYE,EAAiBC,UAEhF,MAAO,CACLL,eACAyE,cAAe,CAEb7F,WACAN,OAAQ4E,EACR9E,QAAS8D,EACT/D,QAASyD,EACTvD,QAASgE,EACT9D,SAAUsB,EAEV6E,mCAAmC,EACnCjG,cACA8F,YACAI,aAAc,MACd3C,OAhB2BwC,GAAiB5E,EAgBb,GAAK8D,EACpCkB,SAAUzB,GAEb"}
|
1
|
+
{"version":3,"file":"useFieldV6TextField.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV6TextField.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { useRtl } from '@mui/system/RtlProvider';\nimport useEventCallback from '@mui/utils/useEventCallback';\nimport useForkRef from '@mui/utils/useForkRef';\nimport { getActiveElement } from \"../../utils/utils.js\";\nimport { getSectionVisibleValue, isAndroid } from \"./useField.utils.js\";\nconst cleanString = dirtyString => dirtyString.replace(/[\\u2066\\u2067\\u2068\\u2069]/g, '');\nexport const addPositionPropertiesToSections = (sections, localizedDigits, isRtl) => {\n let position = 0;\n let positionInInput = isRtl ? 1 : 0;\n const newSections = [];\n for (let i = 0; i < sections.length; i += 1) {\n const section = sections[i];\n const renderedValue = getSectionVisibleValue(section, isRtl ? 'input-rtl' : 'input-ltr', localizedDigits);\n const sectionStr = `${section.startSeparator}${renderedValue}${section.endSeparator}`;\n const sectionLength = cleanString(sectionStr).length;\n const sectionLengthInInput = sectionStr.length;\n\n // The ...InInput values consider the unicode characters but do include them in their indexes\n const cleanedValue = cleanString(renderedValue);\n const startInInput = positionInInput + (cleanedValue === '' ? 0 : renderedValue.indexOf(cleanedValue[0])) + section.startSeparator.length;\n const endInInput = startInInput + cleanedValue.length;\n newSections.push(_extends({}, section, {\n start: position,\n end: position + sectionLength,\n startInInput,\n endInInput\n }));\n position += sectionLength;\n // Move position to the end of string associated to the current section\n positionInInput += sectionLengthInInput;\n }\n return newSections;\n};\nexport const useFieldV6TextField = params => {\n const isRtl = useRtl();\n const focusTimeoutRef = React.useRef(undefined);\n const selectionSyncTimeoutRef = React.useRef(undefined);\n const {\n forwardedProps: {\n onFocus,\n onClick,\n onPaste,\n onBlur,\n inputRef: inputRefProp,\n placeholder: inPlaceholder\n },\n internalProps: {\n readOnly = false,\n disabled = false\n },\n parsedSelectedSections,\n activeSectionIndex,\n state,\n fieldValueManager,\n valueManager,\n applyCharacterEditing,\n resetCharacterQuery,\n updateSectionValue,\n updateValueFromValueStr,\n clearActiveSection,\n clearValue,\n setTempAndroidValueStr,\n setSelectedSections,\n getSectionsFromValue,\n areAllSectionsEmpty,\n localizedDigits\n } = params;\n const inputRef = React.useRef(null);\n const handleRef = useForkRef(inputRefProp, inputRef);\n const sections = React.useMemo(() => addPositionPropertiesToSections(state.sections, localizedDigits, isRtl), [state.sections, localizedDigits, isRtl]);\n const interactions = React.useMemo(() => ({\n syncSelectionToDOM: () => {\n if (!inputRef.current) {\n return;\n }\n if (parsedSelectedSections == null) {\n if (inputRef.current.scrollLeft) {\n // Ensure that input content is not marked as selected.\n // setting selection range to 0 causes issues in Safari.\n // https://bugs.webkit.org/show_bug.cgi?id=224425\n inputRef.current.scrollLeft = 0;\n }\n return;\n }\n\n // On multi input range pickers we want to update selection range only for the active input\n // This helps to avoid the focus jumping on Safari https://github.com/mui/mui-x/issues/9003\n // because WebKit implements the `setSelectionRange` based on the spec: https://bugs.webkit.org/show_bug.cgi?id=224425\n if (inputRef.current !== getActiveElement(document)) {\n return;\n }\n\n // Fix scroll jumping on iOS browser: https://github.com/mui/mui-x/issues/8321\n const currentScrollTop = inputRef.current.scrollTop;\n if (parsedSelectedSections === 'all') {\n inputRef.current.select();\n } else {\n const selectedSection = sections[parsedSelectedSections];\n const selectionStart = selectedSection.type === 'empty' ? selectedSection.startInInput - selectedSection.startSeparator.length : selectedSection.startInInput;\n const selectionEnd = selectedSection.type === 'empty' ? selectedSection.endInInput + selectedSection.endSeparator.length : selectedSection.endInInput;\n if (selectionStart !== inputRef.current.selectionStart || selectionEnd !== inputRef.current.selectionEnd) {\n if (inputRef.current === getActiveElement(document)) {\n inputRef.current.setSelectionRange(selectionStart, selectionEnd);\n }\n }\n clearTimeout(selectionSyncTimeoutRef.current);\n selectionSyncTimeoutRef.current = setTimeout(() => {\n // handle case when the selection is not updated correctly\n // could happen on Android\n if (inputRef.current && inputRef.current === getActiveElement(document) &&\n // The section might loose all selection, where `selectionStart === selectionEnd`\n // https://github.com/mui/mui-x/pull/13652\n inputRef.current.selectionStart === inputRef.current.selectionEnd && (inputRef.current.selectionStart !== selectionStart || inputRef.current.selectionEnd !== selectionEnd)) {\n interactions.syncSelectionToDOM();\n }\n });\n }\n\n // Even reading this variable seems to do the trick, but also setting it just to make use of it\n inputRef.current.scrollTop = currentScrollTop;\n },\n getActiveSectionIndexFromDOM: () => {\n const browserStartIndex = inputRef.current.selectionStart ?? 0;\n const browserEndIndex = inputRef.current.selectionEnd ?? 0;\n if (browserStartIndex === 0 && browserEndIndex === 0) {\n return null;\n }\n const nextSectionIndex = browserStartIndex <= sections[0].startInInput ? 1 // Special case if browser index is in invisible characters at the beginning.\n : sections.findIndex(section => section.startInInput - section.startSeparator.length > browserStartIndex);\n return nextSectionIndex === -1 ? sections.length - 1 : nextSectionIndex - 1;\n },\n focusField: (newSelectedSection = 0) => {\n if (getActiveElement(document) === inputRef.current) {\n return;\n }\n inputRef.current?.focus();\n setSelectedSections(newSelectedSection);\n },\n setSelectedSections: newSelectedSections => setSelectedSections(newSelectedSections),\n isFieldFocused: () => inputRef.current === getActiveElement(document)\n }), [inputRef, parsedSelectedSections, sections, setSelectedSections]);\n const syncSelectionFromDOM = () => {\n const browserStartIndex = inputRef.current.selectionStart ?? 0;\n let nextSectionIndex;\n if (browserStartIndex <= sections[0].startInInput) {\n // Special case if browser index is in invisible characters at the beginning\n nextSectionIndex = 1;\n } else if (browserStartIndex >= sections[sections.length - 1].endInInput) {\n // If the click is after the last character of the input, then we want to select the 1st section.\n nextSectionIndex = 1;\n } else {\n nextSectionIndex = sections.findIndex(section => section.startInInput - section.startSeparator.length > browserStartIndex);\n }\n const sectionIndex = nextSectionIndex === -1 ? sections.length - 1 : nextSectionIndex - 1;\n setSelectedSections(sectionIndex);\n };\n const handleInputFocus = useEventCallback((...args) => {\n onFocus?.(...args);\n // The ref is guaranteed to be resolved at this point.\n const input = inputRef.current;\n clearTimeout(focusTimeoutRef.current);\n focusTimeoutRef.current = setTimeout(() => {\n // The ref changed, the component got remounted, the focus event is no longer relevant.\n if (!input || input !== inputRef.current) {\n return;\n }\n if (activeSectionIndex != null) {\n return;\n }\n if (\n // avoid selecting all sections when focusing empty field without value\n input.value.length && Number(input.selectionEnd) - Number(input.selectionStart) === input.value.length) {\n setSelectedSections('all');\n } else {\n syncSelectionFromDOM();\n }\n });\n });\n const handleInputClick = useEventCallback((event, ...args) => {\n // The click event on the clear button would propagate to the input, trigger this handler and result in a wrong section selection.\n // We avoid this by checking if the call of `handleInputClick` is actually intended, or a side effect.\n if (event.isDefaultPrevented()) {\n return;\n }\n onClick?.(event, ...args);\n syncSelectionFromDOM();\n });\n const handleInputPaste = useEventCallback(event => {\n onPaste?.(event);\n\n // prevent default to avoid the input `onChange` handler being called\n event.preventDefault();\n if (readOnly || disabled) {\n return;\n }\n const pastedValue = event.clipboardData.getData('text');\n if (typeof parsedSelectedSections === 'number') {\n const activeSection = state.sections[parsedSelectedSections];\n const lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);\n const digitsOnly = /^[0-9]+$/.test(pastedValue);\n const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);\n const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;\n if (isValidPastedValue) {\n resetCharacterQuery();\n updateSectionValue({\n activeSection,\n newSectionValue: pastedValue,\n shouldGoToNextSection: true\n });\n return;\n }\n if (lettersOnly || digitsOnly) {\n // The pasted value corresponds to a single section, but not the expected type,\n // skip the modification\n return;\n }\n }\n resetCharacterQuery();\n updateValueFromValueStr(pastedValue);\n });\n const handleContainerBlur = useEventCallback((...args) => {\n onBlur?.(...args);\n setSelectedSections(null);\n });\n const handleInputChange = useEventCallback(event => {\n if (readOnly) {\n return;\n }\n const targetValue = event.target.value;\n if (targetValue === '') {\n resetCharacterQuery();\n clearValue();\n return;\n }\n const eventData = event.nativeEvent.data;\n // Calling `.fill(04/11/2022)` in playwright will trigger a change event with the requested content to insert in `event.nativeEvent.data`\n // usual changes have only the currently typed character in the `event.nativeEvent.data`\n const shouldUseEventData = eventData && eventData.length > 1;\n const valueStr = shouldUseEventData ? eventData : targetValue;\n const cleanValueStr = cleanString(valueStr);\n if (parsedSelectedSections === 'all') {\n setSelectedSections(activeSectionIndex);\n }\n\n // If no section is selected or eventData should be used, we just try to parse the new value\n // This line is mostly triggered by imperative code / application tests.\n if (activeSectionIndex == null || shouldUseEventData) {\n updateValueFromValueStr(shouldUseEventData ? eventData : cleanValueStr);\n return;\n }\n let keyPressed;\n if (parsedSelectedSections === 'all' && cleanValueStr.length === 1) {\n keyPressed = cleanValueStr;\n } else {\n const prevValueStr = cleanString(fieldValueManager.getV6InputValueFromSections(sections, localizedDigits, isRtl));\n let startOfDiffIndex = -1;\n let endOfDiffIndex = -1;\n for (let i = 0; i < prevValueStr.length; i += 1) {\n if (startOfDiffIndex === -1 && prevValueStr[i] !== cleanValueStr[i]) {\n startOfDiffIndex = i;\n }\n if (endOfDiffIndex === -1 && prevValueStr[prevValueStr.length - i - 1] !== cleanValueStr[cleanValueStr.length - i - 1]) {\n endOfDiffIndex = i;\n }\n }\n const activeSection = sections[activeSectionIndex];\n const hasDiffOutsideOfActiveSection = startOfDiffIndex < activeSection.start || prevValueStr.length - endOfDiffIndex - 1 > activeSection.end;\n if (hasDiffOutsideOfActiveSection) {\n // TODO: Support if the new date is valid\n return;\n }\n\n // The active section being selected, the browser has replaced its value with the key pressed by the user.\n const activeSectionEndRelativeToNewValue = cleanValueStr.length - prevValueStr.length + activeSection.end - cleanString(activeSection.endSeparator || '').length;\n keyPressed = cleanValueStr.slice(activeSection.start + cleanString(activeSection.startSeparator || '').length, activeSectionEndRelativeToNewValue);\n }\n if (keyPressed.length === 0) {\n if (isAndroid()) {\n setTempAndroidValueStr(valueStr);\n }\n resetCharacterQuery();\n clearActiveSection();\n return;\n }\n applyCharacterEditing({\n keyPressed,\n sectionIndex: activeSectionIndex\n });\n });\n const placeholder = React.useMemo(() => {\n if (inPlaceholder !== undefined) {\n return inPlaceholder;\n }\n return fieldValueManager.getV6InputValueFromSections(getSectionsFromValue(valueManager.emptyValue), localizedDigits, isRtl);\n }, [inPlaceholder, fieldValueManager, getSectionsFromValue, valueManager.emptyValue, localizedDigits, isRtl]);\n const valueStr = React.useMemo(() => state.tempValueStrAndroid ?? fieldValueManager.getV6InputValueFromSections(state.sections, localizedDigits, isRtl), [state.sections, fieldValueManager, state.tempValueStrAndroid, localizedDigits, isRtl]);\n React.useEffect(() => {\n // Select all the sections when focused on mount (`autoFocus = true` on the input)\n if (inputRef.current && inputRef.current === getActiveElement(document)) {\n setSelectedSections('all');\n }\n return () => {\n clearTimeout(focusTimeoutRef.current);\n clearTimeout(selectionSyncTimeoutRef.current);\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const inputMode = React.useMemo(() => {\n if (activeSectionIndex == null) {\n return 'text';\n }\n if (state.sections[activeSectionIndex].contentType === 'letter') {\n return 'text';\n }\n return 'numeric';\n }, [activeSectionIndex, state.sections]);\n const inputHasFocus = inputRef.current && inputRef.current === getActiveElement(document);\n const shouldShowPlaceholder = !inputHasFocus && areAllSectionsEmpty;\n return {\n interactions,\n returnedValue: {\n // Forwarded\n readOnly,\n onBlur: handleContainerBlur,\n onClick: handleInputClick,\n onFocus: handleInputFocus,\n onPaste: handleInputPaste,\n inputRef: handleRef,\n // Additional\n enableAccessibleFieldDOMStructure: false,\n placeholder,\n inputMode,\n autoComplete: 'off',\n value: shouldShowPlaceholder ? '' : valueStr,\n onChange: handleInputChange\n }\n };\n};"],"names":["cleanString","dirtyString","replace","addPositionPropertiesToSections","sections","localizedDigits","isRtl","position","positionInInput","newSections","i","length","section","renderedValue","getSectionVisibleValue","sectionStr","startSeparator","endSeparator","sectionLength","sectionLengthInInput","cleanedValue","startInInput","indexOf","endInInput","push","_extends","start","end","useFieldV6TextField","params","useRtl","focusTimeoutRef","React","useRef","undefined","selectionSyncTimeoutRef","forwardedProps","onFocus","onClick","onPaste","onBlur","inputRef","inputRefProp","placeholder","inPlaceholder","internalProps","readOnly","disabled","parsedSelectedSections","activeSectionIndex","state","fieldValueManager","valueManager","applyCharacterEditing","resetCharacterQuery","updateSectionValue","updateValueFromValueStr","clearActiveSection","clearValue","setTempAndroidValueStr","setSelectedSections","getSectionsFromValue","areAllSectionsEmpty","handleRef","useForkRef","useMemo","interactions","syncSelectionToDOM","current","scrollLeft","getActiveElement","document","currentScrollTop","scrollTop","select","selectedSection","selectionStart","type","selectionEnd","setSelectionRange","clearTimeout","setTimeout","getActiveSectionIndexFromDOM","browserStartIndex","browserEndIndex","nextSectionIndex","findIndex","focusField","newSelectedSection","focus","newSelectedSections","isFieldFocused","syncSelectionFromDOM","sectionIndex","handleInputFocus","useEventCallback","args","input","value","Number","handleInputClick","event","isDefaultPrevented","handleInputPaste","preventDefault","pastedValue","clipboardData","getData","activeSection","lettersOnly","test","digitsOnly","digitsAndLetterOnly","contentType","newSectionValue","shouldGoToNextSection","handleContainerBlur","handleInputChange","targetValue","target","eventData","nativeEvent","data","shouldUseEventData","valueStr","cleanValueStr","keyPressed","prevValueStr","getV6InputValueFromSections","startOfDiffIndex","endOfDiffIndex","activeSectionEndRelativeToNewValue","slice","isAndroid","emptyValue","tempValueStrAndroid","useEffect","inputMode","inputHasFocus","returnedValue","enableAccessibleFieldDOMStructure","autoComplete","onChange"],"mappings":"6aAOA,MAAMA,EAAcC,GAAeA,EAAYC,QAAQ,8BAA+B,IACzEC,EAAkC,CAACC,EAAUC,EAAiBC,KACzE,IAAIC,EAAW,EACXC,EAAkBF,EAAQ,EAAI,EAClC,MAAMG,EAAc,GACpB,IAAK,IAAIC,EAAI,EAAGA,EAAIN,EAASO,OAAQD,GAAK,EAAG,CAC3C,MAAME,EAAUR,EAASM,GACnBG,EAAgBC,EAAuBF,EAASN,EAAQ,YAAc,YAAaD,GACnFU,EAAa,GAAGH,EAAQI,iBAAiBH,IAAgBD,EAAQK,eACjEC,EAAgBlB,EAAYe,GAAYJ,OACxCQ,EAAuBJ,EAAWJ,OAGlCS,EAAepB,EAAYa,GAC3BQ,EAAeb,GAAoC,KAAjBY,EAAsB,EAAIP,EAAcS,QAAQF,EAAa,KAAOR,EAAQI,eAAeL,OAC7HY,EAAaF,EAAeD,EA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EEN,EAAcX,EAAMiC,SAAQ,SACV/B,IAAlBU,EACKA,EAEFO,EAAkB6E,4BAA4BnE,EAAqBT,EAAakF,YAAajI,EAAiBC,IACpH,CAACsC,EAAeO,EAAmBU,EAAsBT,EAAakF,WAAYjI,EAAiBC,IAChGsH,EAAW5F,EAAMiC,SAAQ,IAAMf,EAAMqF,qBAAuBpF,EAAkB6E,4BAA4B9E,EAAM9C,SAAUC,EAAiBC,IAAQ,CAAC4C,EAAM9C,SAAU+C,EAAmBD,EAAMqF,oBAAqBlI,EAAiBC,IACzO0B,EAAMwG,WAAU,KAEV/F,EAAS2B,SAAW3B,EAAS2B,UAAYE,EAAiBC,WAC5DX,EAAoB,OAEf,KACLoB,aAAajD,EAAgBqC,SAC7BY,aAAa7C,EAAwBiC,QAAQ,IAE9C,IAEH,MAAMqE,EAAYzG,EAAMiC,SAAQ,IACJ,MAAtBhB,GAGmD,WAAnDC,EAAM9C,SAAS6C,GAAoBgE,YAF9B,OAKF,WACN,CAAChE,EAAoBC,EAAM9C,WACxBsI,EAAgBjG,EAAS2B,SAAW3B,EAAS2B,UAAYE,EAAiBC,UAEhF,MAAO,CACLL,eACAyE,cAAe,CAEb7F,WACAN,OAAQ4E,EACR9E,QAAS8D,EACT/D,QAASyD,EACTvD,QAASgE,EACT9D,SAAUsB,EAEV6E,mCAAmC,EACnCjG,cACA8F,YACAI,aAAc,MACd3C,OAhB2BwC,GAAiB5E,EAgBb,GAAK8D,EACpCkB,SAAUzB,GAEb"}
|
package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV7TextField.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import*as e from"react";import
|
1
|
+
import*as e from"react";import t from"../../../../utils/esm/useForkRef/useForkRef.js";import n from"../../../../utils/esm/useEventCallback/useEventCallback.js";import o from"../../../../utils/esm/useEnhancedEffect/useEnhancedEffect.js";import r from"../../../../utils/esm/useId/useId.js";import{parseSelectedSections as i,getSectionValueNow as s,getSectionValueText as a}from"./useField.utils.js";import{getActiveElement as c}from"../../utils/utils.js";import{usePickersTranslations as u}from"../../../hooks/usePickersTranslations.js";import{useUtils as l}from"../useUtils.js";const d=d=>{const{internalProps:{disabled:f,readOnly:p=!1},forwardedProps:{sectionListRef:m,onBlur:g,onClick:v,onFocus:S,onInput:y,onPaste:h,focused:x,autoFocus:b=!1},fieldValueManager:D,applyCharacterEditing:C,resetCharacterQuery:I,setSelectedSections:M,parsedSelectedSections:F,state:R,clearActiveSection:k,clearValue:T,updateSectionValue:E,updateValueFromValueStr:O,sectionOrder:A,areAllSectionsEmpty:P,sectionsValueBoundaries:$}=d,j=e.useRef(null),w=t(m,j),L=u(),V=l(),z=r(),[H,B]=e.useState(!1),U=e.useMemo((()=>({syncSelectionToDOM:()=>{if(!j.current)return;const e=document.getSelection();if(!e)return;if(null==F)return e.rangeCount>0&&j.current.getRoot().contains(e.getRangeAt(0).startContainer)&&e.removeAllRanges(),void(H&&j.current.getRoot().blur());if(!j.current.getRoot().contains(c(document)))return;const t=new window.Range;let n;if("all"===F)n=j.current.getRoot();else{n="empty"===R.sections[F].type?j.current.getSectionContainer(F):j.current.getSectionContent(F)}t.selectNodeContents(n),n.focus(),e.removeAllRanges(),e.addRange(t)},getActiveSectionIndexFromDOM:()=>{const e=c(document);return e&&j.current&&j.current.getRoot().contains(e)?j.current.getSectionIndexFromDOMElement(e):null},focusField:(e=0)=>{if(!j.current||null!=U.getActiveSectionIndexFromDOM())return;const t=i(e,R.sections);B(!0),j.current.getSectionContent(t).focus()},setSelectedSections:e=>{if(!j.current)return;const t=i(e,R.sections);B(null!==("all"===t?0:t)),M(e)},isFieldFocused:()=>{const e=c(document);return!!j.current&&j.current.getRoot().contains(e)}})),[F,M,R.sections,H]),Z=n((e=>{if(!j.current)return;const t=R.sections[e];j.current.getSectionContent(e).innerHTML=t.value||t.placeholder,U.syncSelectionToDOM()})),N=n(((e,...t)=>{if(!e.isDefaultPrevented()&&j.current)if(B(!0),v?.(e,...t),"all"===F)setTimeout((()=>{const e=document.getSelection().getRangeAt(0).startOffset;if(0===e)return void M(A.startIndex);let t=0,n=0;for(;n<e&&t<R.sections.length;){const e=R.sections[t];t+=1,n+=`${e.startSeparator}${e.value||e.placeholder}${e.endSeparator}`.length}M(t-1)}));else if(H){j.current.getRoot().contains(e.target)||M(A.startIndex)}else B(!0),M(A.startIndex)})),G=n((e=>{if(y?.(e),!j.current||"all"!==F)return;const t=e.target.textContent??"";j.current.getRoot().innerHTML=R.sections.map((e=>`${e.startSeparator}${e.value||e.placeholder}${e.endSeparator}`)).join(""),U.syncSelectionToDOM(),0===t.length||10===t.charCodeAt(0)?(I(),T(),M("all")):t.length>1?O(t):("all"===F&&M(0),C({keyPressed:t,sectionIndex:0}))})),K=n((e=>{if(h?.(e),p||"all"!==F)return void e.preventDefault();const t=e.clipboardData.getData("text");e.preventDefault(),I(),O(t)})),Q=n(((...e)=>{if(S?.(...e),H||!j.current)return;B(!0);null!=j.current.getSectionIndexFromDOMElement(c(document))||M(A.startIndex)})),X=n(((...e)=>{g?.(...e),setTimeout((()=>{if(!j.current)return;const e=c(document);!j.current.getRoot().contains(e)&&(B(!1),M(null))}))})),Y=n((e=>t=>{t.isDefaultPrevented()||M(e)})),q=n((e=>{e.preventDefault()})),J=n((e=>()=>{M(e)})),W=n((e=>{if(e.preventDefault(),p||f||"number"!=typeof F)return;const t=R.sections[F],n=e.clipboardData.getData("text"),o=/^[a-zA-Z]+$/.test(n),r=/^[0-9]+$/.test(n),i=/^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(n);"letter"===t.contentType&&o||"digit"===t.contentType&&r||"digit-with-letter"===t.contentType&&i?(I(),E({activeSection:t,newSectionValue:n,shouldGoToNextSection:!0})):o||r||(I(),O(n))})),_=n((e=>{e.preventDefault(),e.dataTransfer.dropEffect="none"})),ee=n((e=>{if(!j.current)return;const t=e.target,n=t.textContent??"",o=j.current.getSectionIndexFromDOMElement(t),r=R.sections[o];if(!p&&j.current){if(0===n.length){if(""===r.value)return void Z(o);const t=e.nativeEvent.inputType;return"insertParagraph"===t||"insertLineBreak"===t?void Z(o):(I(),void k())}C({keyPressed:n,sectionIndex:o}),Z(o)}else Z(o)}));o((()=>{if(H&&j.current)if("all"===F)j.current.getRoot().focus();else if("number"==typeof F){const e=j.current.getSectionContent(F);e&&e.focus()}}),[F,H]);const te=e.useMemo((()=>R.sections.reduce(((e,t)=>(e[t.type]=$[t.type]({currentDate:null,contentType:t.contentType,format:t.format}),e)),{})),[$,R.sections]),ne="all"===F,oe=e.useMemo((()=>R.sections.map(((t,n)=>{const o=!ne&&!f&&!p;return{container:{"data-sectionindex":n,onClick:Y(n)},content:{tabIndex:ne||n>0?-1:0,contentEditable:!ne&&!f&&!p,role:"spinbutton",id:`${z}-${t.type}`,"aria-labelledby":`${z}-${t.type}`,"aria-readonly":p,"aria-valuenow":s(t,V),"aria-valuemin":te[t.type].minimum,"aria-valuemax":te[t.type].maximum,"aria-valuetext":t.value?a(t,V):L.empty,"aria-label":L[t.type],"aria-disabled":f,spellCheck:!o&&void 0,autoCapitalize:o?"off":void 0,autoCorrect:o?"off":void 0,[parseInt(e.version,10)>=17?"enterKeyHint":"enterkeyhint"]:o?"next":void 0,children:t.value||t.placeholder,onInput:ee,onPaste:W,onFocus:J(n),onDragOver:_,onMouseUp:q,inputMode:"letter"===t.contentType?"text":"numeric"},before:{children:t.startSeparator},after:{children:t.endSeparator}}}))),[R.sections,J,W,_,ee,Y,q,f,p,ne,L,V,te,z]),re=n((e=>{O(e.target.value)})),ie=e.useMemo((()=>P?"":D.getV7HiddenInputValueFromSections(R.sections)),[P,R.sections,D]);return e.useEffect((()=>{if(null==j.current)throw new Error(["MUI X: The `sectionListRef` prop has not been initialized by `PickersSectionList`","You probably tried to pass a component to the `textField` slot that contains an `<input />` element instead of a `PickersSectionList`.","","If you want to keep using an `<input />` HTML element for the editing, please remove the `enableAccessibleFieldDOMStructure` prop from your picker or field component:","","<DatePicker slots={{ textField: MyCustomTextField }} />","","Learn more about the field accessible DOM structure on the MUI documentation: https://mui.com/x/react-date-pickers/fields/#fields-to-edit-a-single-element"].join("\n"));b&&j.current&&j.current.getSectionContent(A.startIndex).focus()}),[]),{interactions:U,returnedValue:{autoFocus:b,readOnly:p,focused:x??H,sectionListRef:w,onBlur:X,onClick:N,onFocus:Q,onInput:G,onPaste:K,enableAccessibleFieldDOMStructure:!0,elements:oe,tabIndex:0===F?-1:0,contentEditable:ne,value:ie,onChange:re,areAllSectionsEmpty:P}}};export{d as useFieldV7TextField};
|
2
2
|
//# sourceMappingURL=useFieldV7TextField.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useFieldV7TextField.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV7TextField.js"],"sourcesContent":["import * as React from 'react';\nimport useForkRef from '@mui/utils/useForkRef';\nimport useEventCallback from '@mui/utils/useEventCallback';\nimport useEnhancedEffect from '@mui/utils/useEnhancedEffect';\nimport useId from '@mui/utils/useId';\nimport { getSectionValueNow, getSectionValueText, parseSelectedSections } from \"./useField.utils.js\";\nimport { getActiveElement } from \"../../utils/utils.js\";\nimport { usePickersTranslations } from \"../../../hooks/usePickersTranslations.js\";\nimport { useUtils } from \"../useUtils.js\";\nexport const useFieldV7TextField = params => {\n const {\n internalProps: {\n disabled,\n readOnly = false\n },\n forwardedProps: {\n sectionListRef: inSectionListRef,\n onBlur,\n onClick,\n onFocus,\n onInput,\n onPaste,\n focused: focusedProp,\n autoFocus = false\n },\n fieldValueManager,\n applyCharacterEditing,\n resetCharacterQuery,\n setSelectedSections,\n parsedSelectedSections,\n state,\n clearActiveSection,\n clearValue,\n updateSectionValue,\n updateValueFromValueStr,\n sectionOrder,\n areAllSectionsEmpty,\n sectionsValueBoundaries\n } = params;\n const sectionListRef = React.useRef(null);\n const handleSectionListRef = useForkRef(inSectionListRef, sectionListRef);\n const translations = usePickersTranslations();\n const utils = useUtils();\n const id = useId();\n const [focused, setFocused] = React.useState(false);\n const interactions = React.useMemo(() => ({\n syncSelectionToDOM: () => {\n if (!sectionListRef.current) {\n return;\n }\n const selection = document.getSelection();\n if (!selection) {\n return;\n }\n if (parsedSelectedSections == null) {\n // If the selection contains an element inside the field, we reset it.\n if (selection.rangeCount > 0 && sectionListRef.current.getRoot().contains(selection.getRangeAt(0).startContainer)) {\n selection.removeAllRanges();\n }\n if (focused) {\n sectionListRef.current.getRoot().blur();\n }\n return;\n }\n\n // On multi input range pickers we want to update selection range only for the active input\n if (!sectionListRef.current.getRoot().contains(getActiveElement(document))) {\n return;\n }\n const range = new window.Range();\n let target;\n if (parsedSelectedSections === 'all') {\n target = sectionListRef.current.getRoot();\n } else {\n const section = state.sections[parsedSelectedSections];\n if (section.type === 'empty') {\n target = sectionListRef.current.getSectionContainer(parsedSelectedSections);\n } else {\n target = sectionListRef.current.getSectionContent(parsedSelectedSections);\n }\n }\n range.selectNodeContents(target);\n target.focus();\n selection.removeAllRanges();\n selection.addRange(range);\n },\n getActiveSectionIndexFromDOM: () => {\n const activeElement = getActiveElement(document);\n if (!activeElement || !sectionListRef.current || !sectionListRef.current.getRoot().contains(activeElement)) {\n return null;\n }\n return sectionListRef.current.getSectionIndexFromDOMElement(activeElement);\n },\n focusField: (newSelectedSections = 0) => {\n if (!sectionListRef.current ||\n // if the field is already focused, we don't need to focus it again\n interactions.getActiveSectionIndexFromDOM() != null) {\n return;\n }\n const newParsedSelectedSections = parseSelectedSections(newSelectedSections, state.sections);\n setFocused(true);\n sectionListRef.current.getSectionContent(newParsedSelectedSections).focus();\n },\n setSelectedSections: newSelectedSections => {\n if (!sectionListRef.current) {\n return;\n }\n const newParsedSelectedSections = parseSelectedSections(newSelectedSections, state.sections);\n const newActiveSectionIndex = newParsedSelectedSections === 'all' ? 0 : newParsedSelectedSections;\n setFocused(newActiveSectionIndex !== null);\n setSelectedSections(newSelectedSections);\n },\n isFieldFocused: () => {\n const activeElement = getActiveElement(document);\n return !!sectionListRef.current && sectionListRef.current.getRoot().contains(activeElement);\n }\n }), [parsedSelectedSections, setSelectedSections, state.sections, focused]);\n\n /**\n * If a section content has been updated with a value we don't want to keep,\n * Then we need to imperatively revert it (we can't let React do it because the value did not change in his internal representation).\n */\n const revertDOMSectionChange = useEventCallback(sectionIndex => {\n if (!sectionListRef.current) {\n return;\n }\n const section = state.sections[sectionIndex];\n sectionListRef.current.getSectionContent(sectionIndex).innerHTML = section.value || section.placeholder;\n interactions.syncSelectionToDOM();\n });\n const handleContainerClick = useEventCallback((event, ...args) => {\n // The click event on the clear button would propagate to the input, trigger this handler and result in a wrong section selection.\n // We avoid this by checking if the call of `handleContainerClick` is actually intended, or a side effect.\n if (event.isDefaultPrevented() || !sectionListRef.current) {\n return;\n }\n setFocused(true);\n onClick?.(event, ...args);\n if (parsedSelectedSections === 'all') {\n setTimeout(() => {\n const cursorPosition = document.getSelection().getRangeAt(0).startOffset;\n if (cursorPosition === 0) {\n setSelectedSections(sectionOrder.startIndex);\n return;\n }\n let sectionIndex = 0;\n let cursorOnStartOfSection = 0;\n while (cursorOnStartOfSection < cursorPosition && sectionIndex < state.sections.length) {\n const section = state.sections[sectionIndex];\n sectionIndex += 1;\n cursorOnStartOfSection += `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`.length;\n }\n setSelectedSections(sectionIndex - 1);\n });\n } else if (!focused) {\n setFocused(true);\n setSelectedSections(sectionOrder.startIndex);\n } else {\n const hasClickedOnASection = sectionListRef.current.getRoot().contains(event.target);\n if (!hasClickedOnASection) {\n setSelectedSections(sectionOrder.startIndex);\n }\n }\n });\n const handleContainerInput = useEventCallback(event => {\n onInput?.(event);\n if (!sectionListRef.current || parsedSelectedSections !== 'all') {\n return;\n }\n const target = event.target;\n const keyPressed = target.textContent ?? '';\n sectionListRef.current.getRoot().innerHTML = state.sections.map(section => `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`).join('');\n interactions.syncSelectionToDOM();\n if (keyPressed.length === 0 || keyPressed.charCodeAt(0) === 10) {\n resetCharacterQuery();\n clearValue();\n setSelectedSections('all');\n } else if (keyPressed.length > 1) {\n updateValueFromValueStr(keyPressed);\n } else {\n if (parsedSelectedSections === 'all') {\n setSelectedSections(0);\n }\n applyCharacterEditing({\n keyPressed,\n sectionIndex: 0\n });\n }\n });\n const handleContainerPaste = useEventCallback(event => {\n onPaste?.(event);\n if (readOnly || parsedSelectedSections !== 'all') {\n event.preventDefault();\n return;\n }\n const pastedValue = event.clipboardData.getData('text');\n event.preventDefault();\n resetCharacterQuery();\n updateValueFromValueStr(pastedValue);\n });\n const handleContainerFocus = useEventCallback((...args) => {\n onFocus?.(...args);\n if (focused || !sectionListRef.current) {\n return;\n }\n setFocused(true);\n const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(getActiveElement(document)) != null;\n if (!isFocusInsideASection) {\n setSelectedSections(sectionOrder.startIndex);\n }\n });\n const handleContainerBlur = useEventCallback((...args) => {\n onBlur?.(...args);\n setTimeout(() => {\n if (!sectionListRef.current) {\n return;\n }\n const activeElement = getActiveElement(document);\n const shouldBlur = !sectionListRef.current.getRoot().contains(activeElement);\n if (shouldBlur) {\n setFocused(false);\n setSelectedSections(null);\n }\n });\n });\n const getInputContainerClickHandler = useEventCallback(sectionIndex => event => {\n // The click event on the clear button would propagate to the input, trigger this handler and result in a wrong section selection.\n // We avoid this by checking if the call to this function is actually intended, or a side effect.\n if (event.isDefaultPrevented()) {\n return;\n }\n setSelectedSections(sectionIndex);\n });\n const handleInputContentMouseUp = useEventCallback(event => {\n // Without this, the browser will remove the selected when clicking inside an already-selected section.\n event.preventDefault();\n });\n const getInputContentFocusHandler = useEventCallback(sectionIndex => () => {\n setSelectedSections(sectionIndex);\n });\n const handleInputContentPaste = useEventCallback(event => {\n // prevent default to avoid the input `onInput` handler being called\n event.preventDefault();\n if (readOnly || disabled || typeof parsedSelectedSections !== 'number') {\n return;\n }\n const activeSection = state.sections[parsedSelectedSections];\n const pastedValue = event.clipboardData.getData('text');\n const lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);\n const digitsOnly = /^[0-9]+$/.test(pastedValue);\n const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);\n const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;\n if (isValidPastedValue) {\n resetCharacterQuery();\n updateSectionValue({\n activeSection,\n newSectionValue: pastedValue,\n shouldGoToNextSection: true\n });\n }\n // If the pasted value corresponds to a single section, but not the expected type, we skip the modification\n else if (!lettersOnly && !digitsOnly) {\n resetCharacterQuery();\n updateValueFromValueStr(pastedValue);\n }\n });\n const handleInputContentDragOver = useEventCallback(event => {\n event.preventDefault();\n event.dataTransfer.dropEffect = 'none';\n });\n const handleInputContentInput = useEventCallback(event => {\n if (!sectionListRef.current) {\n return;\n }\n const target = event.target;\n const keyPressed = target.textContent ?? '';\n const sectionIndex = sectionListRef.current.getSectionIndexFromDOMElement(target);\n const section = state.sections[sectionIndex];\n if (readOnly || !sectionListRef.current) {\n revertDOMSectionChange(sectionIndex);\n return;\n }\n if (keyPressed.length === 0) {\n if (section.value === '') {\n revertDOMSectionChange(sectionIndex);\n return;\n }\n const inputType = event.nativeEvent.inputType;\n if (inputType === 'insertParagraph' || inputType === 'insertLineBreak') {\n revertDOMSectionChange(sectionIndex);\n return;\n }\n resetCharacterQuery();\n clearActiveSection();\n return;\n }\n applyCharacterEditing({\n keyPressed,\n sectionIndex\n });\n\n // The DOM value needs to remain the one React is expecting.\n revertDOMSectionChange(sectionIndex);\n });\n useEnhancedEffect(() => {\n if (!focused || !sectionListRef.current) {\n return;\n }\n if (parsedSelectedSections === 'all') {\n sectionListRef.current.getRoot().focus();\n } else if (typeof parsedSelectedSections === 'number') {\n const domElement = sectionListRef.current.getSectionContent(parsedSelectedSections);\n if (domElement) {\n domElement.focus();\n }\n }\n }, [parsedSelectedSections, focused]);\n const sectionBoundaries = React.useMemo(() => {\n return state.sections.reduce((acc, next) => {\n acc[next.type] = sectionsValueBoundaries[next.type]({\n currentDate: null,\n contentType: next.contentType,\n format: next.format\n });\n return acc;\n }, {});\n }, [sectionsValueBoundaries, state.sections]);\n const isContainerEditable = parsedSelectedSections === 'all';\n const elements = React.useMemo(() => {\n return state.sections.map((section, index) => {\n const isEditable = !isContainerEditable && !disabled && !readOnly;\n return {\n container: {\n 'data-sectionindex': index,\n onClick: getInputContainerClickHandler(index)\n },\n content: {\n tabIndex: isContainerEditable || index > 0 ? -1 : 0,\n contentEditable: !isContainerEditable && !disabled && !readOnly,\n role: 'spinbutton',\n id: `${id}-${section.type}`,\n 'aria-labelledby': `${id}-${section.type}`,\n 'aria-readonly': readOnly,\n 'aria-valuenow': getSectionValueNow(section, utils),\n 'aria-valuemin': sectionBoundaries[section.type].minimum,\n 'aria-valuemax': sectionBoundaries[section.type].maximum,\n 'aria-valuetext': section.value ? getSectionValueText(section, utils) : translations.empty,\n 'aria-label': translations[section.type],\n 'aria-disabled': disabled,\n spellCheck: isEditable ? false : undefined,\n autoCapitalize: isEditable ? 'off' : undefined,\n autoCorrect: isEditable ? 'off' : undefined,\n [parseInt(React.version, 10) >= 17 ? 'enterKeyHint' : 'enterkeyhint']: isEditable ? 'next' : undefined,\n children: section.value || section.placeholder,\n onInput: handleInputContentInput,\n onPaste: handleInputContentPaste,\n onFocus: getInputContentFocusHandler(index),\n onDragOver: handleInputContentDragOver,\n onMouseUp: handleInputContentMouseUp,\n inputMode: section.contentType === 'letter' ? 'text' : 'numeric'\n },\n before: {\n children: section.startSeparator\n },\n after: {\n children: section.endSeparator\n }\n };\n });\n }, [state.sections, getInputContentFocusHandler, handleInputContentPaste, handleInputContentDragOver, handleInputContentInput, getInputContainerClickHandler, handleInputContentMouseUp, disabled, readOnly, isContainerEditable, translations, utils, sectionBoundaries, id]);\n const handleValueStrChange = useEventCallback(event => {\n updateValueFromValueStr(event.target.value);\n });\n const valueStr = React.useMemo(() => areAllSectionsEmpty ? '' : fieldValueManager.getV7HiddenInputValueFromSections(state.sections), [areAllSectionsEmpty, state.sections, fieldValueManager]);\n React.useEffect(() => {\n if (sectionListRef.current == null) {\n throw new Error(['MUI X: The `sectionListRef` prop has not been initialized by `PickersSectionList`', 'You probably tried to pass a component to the `textField` slot that contains an `<input />` element instead of a `PickersSectionList`.', '', 'If you want to keep using an `<input />` HTML element for the editing, please remove the `enableAccessibleFieldDOMStructure` prop from your picker or field component:', '', '<DatePicker slots={{ textField: MyCustomTextField }} />', '', 'Learn more about the field accessible DOM structure on the MUI documentation: https://mui.com/x/react-date-pickers/fields/#fields-to-edit-a-single-element'].join('\\n'));\n }\n if (autoFocus && sectionListRef.current) {\n sectionListRef.current.getSectionContent(sectionOrder.startIndex).focus();\n }\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n return {\n interactions,\n returnedValue: {\n // Forwarded\n autoFocus,\n readOnly,\n focused: focusedProp ?? focused,\n sectionListRef: handleSectionListRef,\n onBlur: handleContainerBlur,\n onClick: handleContainerClick,\n onFocus: handleContainerFocus,\n onInput: handleContainerInput,\n onPaste: handleContainerPaste,\n // Additional\n enableAccessibleFieldDOMStructure: true,\n elements,\n // TODO v7: Try to set to undefined when there is a section selected.\n tabIndex: parsedSelectedSections === 0 ? -1 : 0,\n contentEditable: isContainerEditable,\n value: valueStr,\n onChange: handleValueStrChange,\n areAllSectionsEmpty\n }\n };\n};"],"names":["useFieldV7TextField","params","internalProps","disabled","readOnly","forwardedProps","sectionListRef","inSectionListRef","onBlur","onClick","onFocus","onInput","onPaste","focused","focusedProp","autoFocus","fieldValueManager","applyCharacterEditing","resetCharacterQuery","setSelectedSections","parsedSelectedSections","state","clearActiveSection","clearValue","updateSectionValue","updateValueFromValueStr","sectionOrder","areAllSectionsEmpty","sectionsValueBoundaries","React","useRef","handleSectionListRef","useForkRef","translations","usePickersTranslations","utils","useUtils","id","useId","setFocused","useState","interactions","useMemo","syncSelectionToDOM","current","selection","document","getSelection","rangeCount","getRoot","contains","getRangeAt","startContainer","removeAllRanges","blur","getActiveElement","range","window","Range","target","sections","type","getSectionContainer","getSectionContent","selectNodeContents","focus","addRange","getActiveSectionIndexFromDOM","activeElement","getSectionIndexFromDOMElement","focusField","newSelectedSections","newParsedSelectedSections","parseSelectedSections","isFieldFocused","revertDOMSectionChange","useEventCallback","sectionIndex","section","innerHTML","value","placeholder","handleContainerClick","event","args","isDefaultPrevented","setTimeout","cursorPosition","startOffset","startIndex","cursorOnStartOfSection","length","startSeparator","endSeparator","handleContainerInput","keyPressed","textContent","map","join","charCodeAt","handleContainerPaste","preventDefault","pastedValue","clipboardData","getData","handleContainerFocus","handleContainerBlur","getInputContainerClickHandler","handleInputContentMouseUp","getInputContentFocusHandler","handleInputContentPaste","activeSection","lettersOnly","test","digitsOnly","digitsAndLetterOnly","contentType","newSectionValue","shouldGoToNextSection","handleInputContentDragOver","dataTransfer","dropEffect","handleInputContentInput","inputType","nativeEvent","useEnhancedEffect","domElement","sectionBoundaries","reduce","acc","next","currentDate","format","isContainerEditable","elements","index","isEditable","container","content","tabIndex","contentEditable","role","getSectionValueNow","minimum","maximum","getSectionValueText","empty","spellCheck","undefined","autoCapitalize","autoCorrect","parseInt","version","children","onDragOver","onMouseUp","inputMode","before","after","handleValueStrChange","valueStr","getV7HiddenInputValueFromSections","useEffect","Error","returnedValue","enableAccessibleFieldDOMStructure","onChange"],"mappings":"6nBASY,MAACA,EAAsBC,IACjC,MACEC,eAAeC,SACbA,EAAQC,SACRA,GAAW,GAEbC,gBACEC,eAAgBC,EAAgBC,OAChCA,EAAMC,QACNA,EAAOC,QACPA,EAAOC,QACPA,EAAOC,QACPA,EACAC,QAASC,EAAWC,UACpBA,GAAY,GACbC,kBACDA,EAAiBC,sBACjBA,EAAqBC,oBACrBA,EAAmBC,oBACnBA,EAAmBC,uBACnBA,EAAsBC,MACtBA,EAAKC,mBACLA,EAAkBC,WAClBA,EAAUC,mBACVA,EAAkBC,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,CACLL,SAAU3E,EAAQe,cAErB,KAEF,CAACxE,EAAMuC,SAAUiD,EAA6BC,EAAyBS,EAA4BG,GAAyBf,EAA+BC,EAA2BzG,EAAUC,EAAUiI,GAAqBpG,EAAcE,EAAO4F,GAAmB1F,IACpQ0H,GAAuBnF,GAAiBO,IAC5C1D,EAAwB0D,EAAMxB,OAAOqB,MAAM,IAEvCgF,GAAWnI,EAAMa,SAAQ,IAAMf,EAAsB,GAAKX,EAAkBiJ,kCAAkC5I,EAAMuC,WAAW,CAACjC,EAAqBN,EAAMuC,SAAU5C,IAU3K,OATAa,EAAMqI,WAAU,KACd,GAA8B,MAA1B5J,EAAesC,QACjB,MAAM,IAAIuH,MAAM,CAAC,oFAAqF,yIAA0I,GAAI,yKAA0K,GAAI,0DAA2D,GAAI,8JAA8JjE,KAAK,OAEloBnF,GAAaT,EAAesC,SAC9BtC,EAAesC,QAAQmB,kBAAkBrC,EAAa+D,YAAYxB,OACnE,GACA,IAEI,CACLxB,eACA2H,cAAe,CAEbrJ,YACAX,WACAS,QAASC,GAAeD,EACxBP,eAAgByB,EAChBvB,OAAQkG,EACRjG,QAASyE,EACTxE,QAAS+F,EACT9F,QAASmF,EACTlF,QAASwF,EAETiE,mCAAmC,EACnC/B,YAEAK,SAAqC,IAA3BvH,GAAgC,EAAI,EAC9CwH,gBAAiBP,GACjBrD,MAAOgF,GACPM,SAAUP,GACVpI,uBAEH"}
|
1
|
+
{"version":3,"file":"useFieldV7TextField.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV7TextField.js"],"sourcesContent":["import * as React from 'react';\nimport useForkRef from '@mui/utils/useForkRef';\nimport useEventCallback from '@mui/utils/useEventCallback';\nimport useEnhancedEffect from '@mui/utils/useEnhancedEffect';\nimport useId from '@mui/utils/useId';\nimport { getSectionValueNow, getSectionValueText, parseSelectedSections } from \"./useField.utils.js\";\nimport { getActiveElement } from \"../../utils/utils.js\";\nimport { usePickersTranslations } from \"../../../hooks/usePickersTranslations.js\";\nimport { useUtils } from \"../useUtils.js\";\nexport const useFieldV7TextField = params => {\n const {\n internalProps: {\n disabled,\n readOnly = false\n },\n forwardedProps: {\n sectionListRef: inSectionListRef,\n onBlur,\n onClick,\n onFocus,\n onInput,\n onPaste,\n focused: focusedProp,\n autoFocus = false\n },\n fieldValueManager,\n applyCharacterEditing,\n resetCharacterQuery,\n setSelectedSections,\n parsedSelectedSections,\n state,\n clearActiveSection,\n clearValue,\n updateSectionValue,\n updateValueFromValueStr,\n sectionOrder,\n areAllSectionsEmpty,\n sectionsValueBoundaries\n } = params;\n const sectionListRef = React.useRef(null);\n const handleSectionListRef = useForkRef(inSectionListRef, sectionListRef);\n const translations = usePickersTranslations();\n const utils = useUtils();\n const id = useId();\n const [focused, setFocused] = React.useState(false);\n const interactions = React.useMemo(() => ({\n syncSelectionToDOM: () => {\n if (!sectionListRef.current) {\n return;\n }\n const selection = document.getSelection();\n if (!selection) {\n return;\n }\n if (parsedSelectedSections == null) {\n // If the selection contains an element inside the field, we reset it.\n if (selection.rangeCount > 0 && sectionListRef.current.getRoot().contains(selection.getRangeAt(0).startContainer)) {\n selection.removeAllRanges();\n }\n if (focused) {\n sectionListRef.current.getRoot().blur();\n }\n return;\n }\n\n // On multi input range pickers we want to update selection range only for the active input\n if (!sectionListRef.current.getRoot().contains(getActiveElement(document))) {\n return;\n }\n const range = new window.Range();\n let target;\n if (parsedSelectedSections === 'all') {\n target = sectionListRef.current.getRoot();\n } else {\n const section = state.sections[parsedSelectedSections];\n if (section.type === 'empty') {\n target = sectionListRef.current.getSectionContainer(parsedSelectedSections);\n } else {\n target = sectionListRef.current.getSectionContent(parsedSelectedSections);\n }\n }\n range.selectNodeContents(target);\n target.focus();\n selection.removeAllRanges();\n selection.addRange(range);\n },\n getActiveSectionIndexFromDOM: () => {\n const activeElement = getActiveElement(document);\n if (!activeElement || !sectionListRef.current || !sectionListRef.current.getRoot().contains(activeElement)) {\n return null;\n }\n return sectionListRef.current.getSectionIndexFromDOMElement(activeElement);\n },\n focusField: (newSelectedSections = 0) => {\n if (!sectionListRef.current ||\n // if the field is already focused, we don't need to focus it again\n interactions.getActiveSectionIndexFromDOM() != null) {\n return;\n }\n const newParsedSelectedSections = parseSelectedSections(newSelectedSections, state.sections);\n setFocused(true);\n sectionListRef.current.getSectionContent(newParsedSelectedSections).focus();\n },\n setSelectedSections: newSelectedSections => {\n if (!sectionListRef.current) {\n return;\n }\n const newParsedSelectedSections = parseSelectedSections(newSelectedSections, state.sections);\n const newActiveSectionIndex = newParsedSelectedSections === 'all' ? 0 : newParsedSelectedSections;\n setFocused(newActiveSectionIndex !== null);\n setSelectedSections(newSelectedSections);\n },\n isFieldFocused: () => {\n const activeElement = getActiveElement(document);\n return !!sectionListRef.current && sectionListRef.current.getRoot().contains(activeElement);\n }\n }), [parsedSelectedSections, setSelectedSections, state.sections, focused]);\n\n /**\n * If a section content has been updated with a value we don't want to keep,\n * Then we need to imperatively revert it (we can't let React do it because the value did not change in his internal representation).\n */\n const revertDOMSectionChange = useEventCallback(sectionIndex => {\n if (!sectionListRef.current) {\n return;\n }\n const section = state.sections[sectionIndex];\n sectionListRef.current.getSectionContent(sectionIndex).innerHTML = section.value || section.placeholder;\n interactions.syncSelectionToDOM();\n });\n const handleContainerClick = useEventCallback((event, ...args) => {\n // The click event on the clear button would propagate to the input, trigger this handler and result in a wrong section selection.\n // We avoid this by checking if the call of `handleContainerClick` is actually intended, or a side effect.\n if (event.isDefaultPrevented() || !sectionListRef.current) {\n return;\n }\n setFocused(true);\n onClick?.(event, ...args);\n if (parsedSelectedSections === 'all') {\n setTimeout(() => {\n const cursorPosition = document.getSelection().getRangeAt(0).startOffset;\n if (cursorPosition === 0) {\n setSelectedSections(sectionOrder.startIndex);\n return;\n }\n let sectionIndex = 0;\n let cursorOnStartOfSection = 0;\n while (cursorOnStartOfSection < cursorPosition && sectionIndex < state.sections.length) {\n const section = state.sections[sectionIndex];\n sectionIndex += 1;\n cursorOnStartOfSection += `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`.length;\n }\n setSelectedSections(sectionIndex - 1);\n });\n } else if (!focused) {\n setFocused(true);\n setSelectedSections(sectionOrder.startIndex);\n } else {\n const hasClickedOnASection = sectionListRef.current.getRoot().contains(event.target);\n if (!hasClickedOnASection) {\n setSelectedSections(sectionOrder.startIndex);\n }\n }\n });\n const handleContainerInput = useEventCallback(event => {\n onInput?.(event);\n if (!sectionListRef.current || parsedSelectedSections !== 'all') {\n return;\n }\n const target = event.target;\n const keyPressed = target.textContent ?? '';\n sectionListRef.current.getRoot().innerHTML = state.sections.map(section => `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`).join('');\n interactions.syncSelectionToDOM();\n if (keyPressed.length === 0 || keyPressed.charCodeAt(0) === 10) {\n resetCharacterQuery();\n clearValue();\n setSelectedSections('all');\n } else if (keyPressed.length > 1) {\n updateValueFromValueStr(keyPressed);\n } else {\n if (parsedSelectedSections === 'all') {\n setSelectedSections(0);\n }\n applyCharacterEditing({\n keyPressed,\n sectionIndex: 0\n });\n }\n });\n const handleContainerPaste = useEventCallback(event => {\n onPaste?.(event);\n if (readOnly || parsedSelectedSections !== 'all') {\n event.preventDefault();\n return;\n }\n const pastedValue = event.clipboardData.getData('text');\n event.preventDefault();\n resetCharacterQuery();\n updateValueFromValueStr(pastedValue);\n });\n const handleContainerFocus = useEventCallback((...args) => {\n onFocus?.(...args);\n if (focused || !sectionListRef.current) {\n return;\n }\n setFocused(true);\n const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(getActiveElement(document)) != null;\n if (!isFocusInsideASection) {\n setSelectedSections(sectionOrder.startIndex);\n }\n });\n const handleContainerBlur = useEventCallback((...args) => {\n onBlur?.(...args);\n setTimeout(() => {\n if (!sectionListRef.current) {\n return;\n }\n const activeElement = getActiveElement(document);\n const shouldBlur = !sectionListRef.current.getRoot().contains(activeElement);\n if (shouldBlur) {\n setFocused(false);\n setSelectedSections(null);\n }\n });\n });\n const getInputContainerClickHandler = useEventCallback(sectionIndex => event => {\n // The click event on the clear button would propagate to the input, trigger this handler and result in a wrong section selection.\n // We avoid this by checking if the call to this function is actually intended, or a side effect.\n if (event.isDefaultPrevented()) {\n return;\n }\n setSelectedSections(sectionIndex);\n });\n const handleInputContentMouseUp = useEventCallback(event => {\n // Without this, the browser will remove the selected when clicking inside an already-selected section.\n event.preventDefault();\n });\n const getInputContentFocusHandler = useEventCallback(sectionIndex => () => {\n setSelectedSections(sectionIndex);\n });\n const handleInputContentPaste = useEventCallback(event => {\n // prevent default to avoid the input `onInput` handler being called\n event.preventDefault();\n if (readOnly || disabled || typeof parsedSelectedSections !== 'number') {\n return;\n }\n const activeSection = state.sections[parsedSelectedSections];\n const pastedValue = event.clipboardData.getData('text');\n const lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);\n const digitsOnly = /^[0-9]+$/.test(pastedValue);\n const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);\n const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;\n if (isValidPastedValue) {\n resetCharacterQuery();\n updateSectionValue({\n activeSection,\n newSectionValue: pastedValue,\n shouldGoToNextSection: true\n });\n }\n // If the pasted value corresponds to a single section, but not the expected type, we skip the modification\n else if (!lettersOnly && !digitsOnly) {\n resetCharacterQuery();\n updateValueFromValueStr(pastedValue);\n }\n });\n const handleInputContentDragOver = useEventCallback(event => {\n event.preventDefault();\n event.dataTransfer.dropEffect = 'none';\n });\n const handleInputContentInput = useEventCallback(event => {\n if (!sectionListRef.current) {\n return;\n }\n const target = event.target;\n const keyPressed = target.textContent ?? '';\n const sectionIndex = sectionListRef.current.getSectionIndexFromDOMElement(target);\n const section = state.sections[sectionIndex];\n if (readOnly || !sectionListRef.current) {\n revertDOMSectionChange(sectionIndex);\n return;\n }\n if (keyPressed.length === 0) {\n if (section.value === '') {\n revertDOMSectionChange(sectionIndex);\n return;\n }\n const inputType = event.nativeEvent.inputType;\n if (inputType === 'insertParagraph' || inputType === 'insertLineBreak') {\n revertDOMSectionChange(sectionIndex);\n return;\n }\n resetCharacterQuery();\n clearActiveSection();\n return;\n }\n applyCharacterEditing({\n keyPressed,\n sectionIndex\n });\n\n // The DOM value needs to remain the one React is expecting.\n revertDOMSectionChange(sectionIndex);\n });\n useEnhancedEffect(() => {\n if (!focused || !sectionListRef.current) {\n return;\n }\n if (parsedSelectedSections === 'all') {\n sectionListRef.current.getRoot().focus();\n } else if (typeof parsedSelectedSections === 'number') {\n const domElement = sectionListRef.current.getSectionContent(parsedSelectedSections);\n if (domElement) {\n domElement.focus();\n }\n }\n }, [parsedSelectedSections, focused]);\n const sectionBoundaries = React.useMemo(() => {\n return state.sections.reduce((acc, next) => {\n acc[next.type] = sectionsValueBoundaries[next.type]({\n currentDate: null,\n contentType: next.contentType,\n format: next.format\n });\n return acc;\n }, {});\n }, [sectionsValueBoundaries, state.sections]);\n const isContainerEditable = parsedSelectedSections === 'all';\n const elements = React.useMemo(() => {\n return state.sections.map((section, index) => {\n const isEditable = !isContainerEditable && !disabled && !readOnly;\n return {\n container: {\n 'data-sectionindex': index,\n onClick: getInputContainerClickHandler(index)\n },\n content: {\n tabIndex: isContainerEditable || index > 0 ? -1 : 0,\n contentEditable: !isContainerEditable && !disabled && !readOnly,\n role: 'spinbutton',\n id: `${id}-${section.type}`,\n 'aria-labelledby': `${id}-${section.type}`,\n 'aria-readonly': readOnly,\n 'aria-valuenow': getSectionValueNow(section, utils),\n 'aria-valuemin': sectionBoundaries[section.type].minimum,\n 'aria-valuemax': sectionBoundaries[section.type].maximum,\n 'aria-valuetext': section.value ? getSectionValueText(section, utils) : translations.empty,\n 'aria-label': translations[section.type],\n 'aria-disabled': disabled,\n spellCheck: isEditable ? false : undefined,\n autoCapitalize: isEditable ? 'off' : undefined,\n autoCorrect: isEditable ? 'off' : undefined,\n [parseInt(React.version, 10) >= 17 ? 'enterKeyHint' : 'enterkeyhint']: isEditable ? 'next' : undefined,\n children: section.value || section.placeholder,\n onInput: handleInputContentInput,\n onPaste: handleInputContentPaste,\n onFocus: getInputContentFocusHandler(index),\n onDragOver: handleInputContentDragOver,\n onMouseUp: handleInputContentMouseUp,\n inputMode: section.contentType === 'letter' ? 'text' : 'numeric'\n },\n before: {\n children: section.startSeparator\n },\n after: {\n children: section.endSeparator\n }\n };\n });\n }, [state.sections, getInputContentFocusHandler, handleInputContentPaste, handleInputContentDragOver, handleInputContentInput, getInputContainerClickHandler, handleInputContentMouseUp, disabled, readOnly, isContainerEditable, translations, utils, sectionBoundaries, id]);\n const handleValueStrChange = useEventCallback(event => {\n updateValueFromValueStr(event.target.value);\n });\n const valueStr = React.useMemo(() => areAllSectionsEmpty ? '' : fieldValueManager.getV7HiddenInputValueFromSections(state.sections), [areAllSectionsEmpty, state.sections, fieldValueManager]);\n React.useEffect(() => {\n if (sectionListRef.current == null) {\n throw new Error(['MUI X: The `sectionListRef` prop has not been initialized by `PickersSectionList`', 'You probably tried to pass a component to the `textField` slot that contains an `<input />` element instead of a `PickersSectionList`.', '', 'If you want to keep using an `<input />` HTML element for the editing, please remove the `enableAccessibleFieldDOMStructure` prop from your picker or field component:', '', '<DatePicker slots={{ textField: MyCustomTextField }} />', '', 'Learn more about the field accessible DOM structure on the MUI documentation: https://mui.com/x/react-date-pickers/fields/#fields-to-edit-a-single-element'].join('\\n'));\n }\n if (autoFocus && sectionListRef.current) {\n sectionListRef.current.getSectionContent(sectionOrder.startIndex).focus();\n }\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n return {\n interactions,\n returnedValue: {\n // Forwarded\n autoFocus,\n readOnly,\n focused: focusedProp ?? focused,\n sectionListRef: handleSectionListRef,\n onBlur: handleContainerBlur,\n onClick: handleContainerClick,\n onFocus: handleContainerFocus,\n onInput: handleContainerInput,\n onPaste: handleContainerPaste,\n // Additional\n enableAccessibleFieldDOMStructure: true,\n elements,\n // TODO v7: Try to set to undefined when there is a section selected.\n tabIndex: parsedSelectedSections === 0 ? -1 : 0,\n contentEditable: isContainerEditable,\n value: valueStr,\n onChange: handleValueStrChange,\n areAllSectionsEmpty\n }\n };\n};"],"names":["useFieldV7TextField","params","internalProps","disabled","readOnly","forwardedProps","sectionListRef","inSectionListRef","onBlur","onClick","onFocus","onInput","onPaste","focused","focusedProp","autoFocus","fieldValueManager","applyCharacterEditing","resetCharacterQuery","setSelectedSections","parsedSelectedSections","state","clearActiveSection","clearValue","updateSectionValue","updateValueFromValueStr","sectionOrder","areAllSectionsEmpty","sectionsValueBoundaries","React","useRef","handleSectionListRef","useForkRef","translations","usePickersTranslations","utils","useUtils","id","useId","setFocused","useState","interactions","useMemo","syncSelectionToDOM","current","selection","document","getSelection","rangeCount","getRoot","contains","getRangeAt","startContainer","removeAllRanges","blur","getActiveElement","range","window","Range","target","sections","type","getSectionContainer","getSectionContent","selectNodeContents","focus","addRange","getActiveSectionIndexFromDOM","activeElement","getSectionIndexFromDOMElement","focusField","newSelectedSections","newParsedSelectedSections","parseSelectedSections","isFieldFocused","revertDOMSectionChange","useEventCallback","sectionIndex","section","innerHTML","value","placeholder","handleContainerClick","event","args","isDefaultPrevented","setTimeout","cursorPosition","startOffset","startIndex","cursorOnStartOfSection","length","startSeparator","endSeparator","handleContainerInput","keyPressed","textContent","map","join","charCodeAt","handleContainerPaste","preventDefault","pastedValue","clipboardData","getData","handleContainerFocus","handleContainerBlur","getInputContainerClickHandler","handleInputContentMouseUp","getInputContentFocusHandler","handleInputContentPaste","activeSection","lettersOnly","test","digitsOnly","digitsAndLetterOnly","contentType","newSectionValue","shouldGoToNextSection","handleInputContentDragOver","dataTransfer","dropEffect","handleInputContentInput","inputType","nativeEvent","useEnhancedEffect","domElement","sectionBoundaries","reduce","acc","next","currentDate","format","isContainerEditable","elements","index","isEditable","container","content","tabIndex","contentEditable","role","getSectionValueNow","minimum","maximum","getSectionValueText","empty","spellCheck","undefined","autoCapitalize","autoCorrect","parseInt","version","children","onDragOver","onMouseUp","inputMode","before","after","handleValueStrChange","valueStr","getV7HiddenInputValueFromSections","useEffect","Error","returnedValue","enableAccessibleFieldDOMStructure","onChange"],"mappings":"ikBASY,MAACA,EAAsBC,IACjC,MACEC,eAAeC,SACbA,EAAQC,SACRA,GAAW,GAEbC,gBACEC,eAAgBC,EAAgBC,OAChCA,EAAMC,QACNA,EAAOC,QACPA,EAAOC,QACPA,EAAOC,QACPA,EACAC,QAASC,EAAWC,UACpBA,GAAY,GACbC,kBACDA,EAAiBC,sBACjBA,EAAqBC,oBACrBA,EAAmBC,oBACnBA,EAAmBC,uBACnBA,EAAsBC,MACtBA,EAAKC,mBACLA,EAAkBC,WAClBA,EAAUC,mBACVA,EAAkBC,wBAClBA,EAAuBC,aACvBA,EAAYC,oBACZA,EAAmBC,wBACnBA,GACE3B,EACEK,EAAiBuB,EAAMC,OAAO,MAC9BC,EAAuBC,EAAWzB,EAAkBD,GACpD2B,EAAeC,IACfC,EAAQC,IACRC,EAAKC,KACJzB,EAAS0B,GAAcV,EAAMW,UAAS,GACvCC,EAAeZ,EAAMa,SAAQ,KAAO,CACxCC,mBAAoB,KAClB,IAAKrC,EAAesC,QAClB,OAEF,MAAMC,EAAYC,SAASC,eAC3B,IAAKF,EACH,OAEF,GAA8B,MAA1BzB,EAQF,OANIyB,EAAUG,WAAa,GAAK1C,EAAesC,QAAQK,UAAUC,SAASL,EAAUM,WAAW,GAAGC,iBAChGP,EAAUQ,uBAERxC,GACFP,EAAesC,QAAQK,UAAUK,QAMrC,IAAKhD,EAAesC,QAAQK,UAAUC,SAASK,EAAiBT,WAC9D,OAEF,MAAMU,EAAQ,IAAIC,OAAOC,MACzB,IAAIC,EACJ,GAA+B,QAA3BvC,EACFuC,EAASrD,EAAesC,QAAQK,cAC3B,CAGHU,EADmB,UADLtC,EAAMuC,SAASxC,GACnByC,KACDvD,EAAesC,QAAQkB,oBAAoB1C,GAE3Cd,EAAesC,QAAQm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AETiE,mCAAmC,EACnC/B,YAEAK,SAAqC,IAA3BvH,GAAgC,EAAI,EAC9CwH,gBAAiBP,GACjBrD,MAAOgF,GACPM,SAAUP,GACVpI,uBAEH"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import*as
|
1
|
+
import*as e from"react";import"../../../../react-is/index.js";import"../../../utils/esm/elementAcceptingRef/elementAcceptingRef.js";import"../../../utils/esm/elementTypeAcceptingRef/elementTypeAcceptingRef.js";import"../../../utils/esm/ponyfillGlobal/ponyfillGlobal.js";import"../../../utils/esm/refType/refType.js";import t from"../../../utils/esm/useEnhancedEffect/useEnhancedEffect.js";import"../../../utils/esm/integerPropType/integerPropType.js";import{arrayIncludes as n}from"../utils/utils.js";function i(){return"undefined"==typeof window?"portrait":window.screen&&window.screen.orientation&&window.screen.orientation.angle?90===Math.abs(window.screen.orientation.angle)?"landscape":"portrait":window.orientation&&90===Math.abs(Number(window.orientation))?"landscape":"portrait"}const o=(o,r)=>{const[s,a]=e.useState(i);if(t((()=>{const e=()=>{a(i())};return window.addEventListener("orientationchange",e),()=>{window.removeEventListener("orientationchange",e)}}),[]),n(o,["hours","minutes","seconds"]))return!1;return"landscape"===(r||s)};export{o as useIsLandscape};
|
2
2
|
//# sourceMappingURL=useIsLandscape.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useIsLandscape.js","sources":["../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useIsLandscape.js"],"sourcesContent":["import * as React from 'react';\nimport { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';\nimport { arrayIncludes } from \"../utils/utils.js\";\nfunction getOrientation() {\n if (typeof window === 'undefined') {\n return 'portrait';\n }\n if (window.screen && window.screen.orientation && window.screen.orientation.angle) {\n return Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';\n }\n\n // Support IOS safari\n if (window.orientation) {\n return Math.abs(Number(window.orientation)) === 90 ? 'landscape' : 'portrait';\n }\n return 'portrait';\n}\nexport const useIsLandscape = (views, customOrientation) => {\n const [orientation, setOrientation] = React.useState(getOrientation);\n useEnhancedEffect(() => {\n const eventHandler = () => {\n setOrientation(getOrientation());\n };\n window.addEventListener('orientationchange', eventHandler);\n return () => {\n window.removeEventListener('orientationchange', eventHandler);\n };\n }, []);\n if (arrayIncludes(views, ['hours', 'minutes', 'seconds'])) {\n // could not display 13:34:44 in landscape mode\n return false;\n }\n const orientationToUse = customOrientation || orientation;\n return orientationToUse === 'landscape';\n};"],"names":["getOrientation","window","screen","orientation","angle","Math","abs","Number","useIsLandscape","views","customOrientation","setOrientation","React","useState","useEnhancedEffect","eventHandler","addEventListener","removeEventListener","arrayIncludes"],"mappings":"
|
1
|
+
{"version":3,"file":"useIsLandscape.js","sources":["../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useIsLandscape.js"],"sourcesContent":["import * as React from 'react';\nimport { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';\nimport { arrayIncludes } from \"../utils/utils.js\";\nfunction getOrientation() {\n if (typeof window === 'undefined') {\n return 'portrait';\n }\n if (window.screen && window.screen.orientation && window.screen.orientation.angle) {\n return Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';\n }\n\n // Support IOS safari\n if (window.orientation) {\n return Math.abs(Number(window.orientation)) === 90 ? 'landscape' : 'portrait';\n }\n return 'portrait';\n}\nexport const useIsLandscape = (views, customOrientation) => {\n const [orientation, setOrientation] = React.useState(getOrientation);\n useEnhancedEffect(() => {\n const eventHandler = () => {\n setOrientation(getOrientation());\n };\n window.addEventListener('orientationchange', eventHandler);\n return () => {\n window.removeEventListener('orientationchange', eventHandler);\n };\n }, []);\n if (arrayIncludes(views, ['hours', 'minutes', 'seconds'])) {\n // could not display 13:34:44 in landscape mode\n return false;\n }\n const orientationToUse = customOrientation || orientation;\n return orientationToUse === 'landscape';\n};"],"names":["getOrientation","window","screen","orientation","angle","Math","abs","Number","useIsLandscape","views","customOrientation","setOrientation","React","useState","useEnhancedEffect","eventHandler","addEventListener","removeEventListener","arrayIncludes"],"mappings":"qfAGA,SAASA,IACP,MAAsB,oBAAXC,OACF,WAELA,OAAOC,QAAUD,OAAOC,OAAOC,aAAeF,OAAOC,OAAOC,YAAYC,MACrB,KAA9CC,KAAKC,IAAIL,OAAOC,OAAOC,YAAYC,OAAgB,YAAc,WAItEH,OAAOE,aACuC,KAAzCE,KAAKC,IAAIC,OAAON,OAAOE,cAAuB,YAEhD,UACT,CACY,MAACK,EAAiB,CAACC,EAAOC,KACpC,MAAOP,EAAaQ,GAAkBC,EAAMC,SAASb,GAUrD,GATAc,GAAkB,KAChB,MAAMC,EAAe,KACnBJ,EAAeX,IAAiB,EAGlC,OADAC,OAAOe,iBAAiB,oBAAqBD,GACtC,KACLd,OAAOgB,oBAAoB,oBAAqBF,EAAa,CAC9D,GACA,IACCG,EAAcT,EAAO,CAAC,QAAS,UAAW,YAE5C,OAAO,EAGT,MAA4B,eADHC,GAAqBP,EACP"}
|
package/dist/esm/node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import o from"../../../../../@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js";import*as t from"react";import{PickersModalDialog as
|
1
|
+
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import o from"../../../../../@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js";import*as t from"react";import s from"../../../../utils/esm/useSlotProps/useSlotProps.js";import r from"../../../../utils/esm/useForkRef/useForkRef.js";import l from"../../../../utils/esm/useId/useId.js";import{PickersModalDialog as i}from"../../components/PickersModalDialog.js";import{onSpaceOrEnter as a}from"../../utils/utils.js";import{PickersProvider as n}from"../../components/PickersProvider.js";import{jsxs as p,jsx as m}from"react/jsx-runtime";import{usePicker as c}from"../usePicker/usePicker.js";import{PickersLayout as u}from"../../../PickersLayout/PickersLayout.js";const d=["props","getOpenDialogAriaText"],f=f=>{let{props:b,getOpenDialogAriaText:P}=f,x=o(f,d);const{slots:j,slotProps:y,className:S,sx:k,format:h,formatDensity:F,enableAccessibleFieldDOMStructure:D,selectedSections:O,onSelectedSectionsChange:R,timezone:g,name:w,label:V,inputRef:T,readOnly:A,disabled:C,localeText:v}=b,I=t.useRef(null),L=l(),M=y?.toolbar?.hidden??!1,{open:z,actions:N,layoutProps:K,renderCurrentView:W,fieldProps:$,contextValue:q}=c(e({},x,{props:b,fieldRef:I,autoFocusView:!0,additionalViewProps:{},wrapperVariant:"mobile"})),B=j.field,E=s({elementType:B,externalSlotProps:y?.field,additionalProps:e({},$,M&&{id:L},!(C||A)&&{onClick:N.onOpen,onKeyDown:a(N.onOpen)},{readOnly:A??!0,disabled:C,className:S,sx:k,format:h,formatDensity:F,enableAccessibleFieldDOMStructure:D,selectedSections:O,onSelectedSectionsChange:R,timezone:g,label:V,name:w},T?{inputRef:T}:{}),ownerState:b});E.inputProps=e({},E.inputProps,{"aria-label":P($.value)});const G=e({textField:j.textField},E.slots),H=j.layout??u;let J=L;M&&(J=V?`${L}-label`:void 0);const Q=e({},y,{toolbar:e({},y?.toolbar,{titleId:L}),mobilePaper:e({"aria-labelledby":J},y?.mobilePaper)}),U=r(I,E.unstableFieldRef);return{renderPicker:()=>p(n,{contextValue:q,localeText:v,children:[m(B,e({},E,{slots:G,slotProps:Q,unstableFieldRef:U})),m(i,e({},N,{open:z,slots:j,slotProps:Q,children:m(H,e({},K,Q?.layout,{slots:j,slotProps:Q,children:W()}))}))]})}};export{f as useMobilePicker};
|
2
2
|
//# sourceMappingURL=useMobilePicker.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useMobilePicker.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nconst _excluded = [\"props\", \"getOpenDialogAriaText\"];\nimport * as React from 'react';\nimport useSlotProps from '@mui/utils/useSlotProps';\nimport useForkRef from '@mui/utils/useForkRef';\nimport useId from '@mui/utils/useId';\nimport { PickersModalDialog } from \"../../components/PickersModalDialog.js\";\nimport { usePicker } from \"../usePicker/index.js\";\nimport { onSpaceOrEnter } from \"../../utils/utils.js\";\nimport { PickersLayout } from \"../../../PickersLayout/index.js\";\nimport { PickersProvider } from \"../../components/PickersProvider.js\";\n\n/**\n * Hook managing all the single-date mobile pickers:\n * - MobileDatePicker\n * - MobileDateTimePicker\n * - MobileTimePicker\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const useMobilePicker = _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 localeText\n } = props;\n const fieldRef = React.useRef(null);\n const labelId = useId();\n const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;\n const {\n open,\n actions,\n layoutProps,\n renderCurrentView,\n fieldProps: pickerFieldProps,\n contextValue\n } = usePicker(_extends({}, pickerParams, {\n props,\n fieldRef,\n autoFocusView: true,\n additionalViewProps: {},\n wrapperVariant: 'mobile'\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 }, !(disabled || readOnly) && {\n onClick: actions.onOpen,\n onKeyDown: onSpaceOrEnter(actions.onOpen)\n }, {\n readOnly: readOnly ?? true,\n disabled,\n className,\n sx,\n format,\n formatDensity,\n enableAccessibleFieldDOMStructure,\n selectedSections,\n onSelectedSectionsChange,\n timezone,\n label,\n name\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 fieldProps.inputProps = _extends({}, fieldProps.inputProps, {\n 'aria-label': getOpenDialogAriaText(pickerFieldProps.value)\n });\n const slotsForField = _extends({\n textField: slots.textField\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 mobilePaper: _extends({\n 'aria-labelledby': labelledById\n }, innerSlotProps?.mobilePaper)\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(PickersModalDialog, _extends({}, actions, {\n open: open,\n slots: slots,\n slotProps: slotProps,\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","useMobilePicker","_ref","props","getOpenDialogAriaText","pickerParams","_objectWithoutPropertiesLoose","slots","slotProps","innerSlotProps","className","sx","format","formatDensity","enableAccessibleFieldDOMStructure","selectedSections","onSelectedSectionsChange","timezone","name","label","inputRef","readOnly","disabled","localeText","fieldRef","React","useRef","labelId","useId","isToolbarHidden","toolbar","hidden","open","actions","layoutProps","renderCurrentView","fieldProps","pickerFieldProps","contextValue","usePicker","_extends","autoFocusView","additionalViewProps","wrapperVariant","Field","field","useSlotProps","elementType","externalSlotProps","additionalProps","id","onClick","onOpen","onKeyDown","onSpaceOrEnter","ownerState","inputProps","value","slotsForField","textField","Layout","layout","PickersLayout","labelledById","undefined","titleId","mobilePaper","handleFieldRef","useForkRef","unstableFieldRef","renderPicker","_jsxs","PickersProvider","children","_jsx","PickersModalDialog"],"mappings":"
|
1
|
+
{"version":3,"file":"useMobilePicker.js","sources":["../../../../../../../../node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nconst _excluded = [\"props\", \"getOpenDialogAriaText\"];\nimport * as React from 'react';\nimport useSlotProps from '@mui/utils/useSlotProps';\nimport useForkRef from '@mui/utils/useForkRef';\nimport useId from '@mui/utils/useId';\nimport { PickersModalDialog } from \"../../components/PickersModalDialog.js\";\nimport { usePicker } from \"../usePicker/index.js\";\nimport { onSpaceOrEnter } from \"../../utils/utils.js\";\nimport { PickersLayout } from \"../../../PickersLayout/index.js\";\nimport { PickersProvider } from \"../../components/PickersProvider.js\";\n\n/**\n * Hook managing all the single-date mobile pickers:\n * - MobileDatePicker\n * - MobileDateTimePicker\n * - MobileTimePicker\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const useMobilePicker = _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 localeText\n } = props;\n const fieldRef = React.useRef(null);\n const labelId = useId();\n const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;\n const {\n open,\n actions,\n layoutProps,\n renderCurrentView,\n fieldProps: pickerFieldProps,\n contextValue\n } = usePicker(_extends({}, pickerParams, {\n props,\n fieldRef,\n autoFocusView: true,\n additionalViewProps: {},\n wrapperVariant: 'mobile'\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 }, !(disabled || readOnly) && {\n onClick: actions.onOpen,\n onKeyDown: onSpaceOrEnter(actions.onOpen)\n }, {\n readOnly: readOnly ?? true,\n disabled,\n className,\n sx,\n format,\n formatDensity,\n enableAccessibleFieldDOMStructure,\n selectedSections,\n onSelectedSectionsChange,\n timezone,\n label,\n name\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 fieldProps.inputProps = _extends({}, fieldProps.inputProps, {\n 'aria-label': getOpenDialogAriaText(pickerFieldProps.value)\n });\n const slotsForField = _extends({\n textField: slots.textField\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 mobilePaper: _extends({\n 'aria-labelledby': labelledById\n }, innerSlotProps?.mobilePaper)\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(PickersModalDialog, _extends({}, actions, {\n open: open,\n slots: slots,\n slotProps: slotProps,\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","useMobilePicker","_ref","props","getOpenDialogAriaText","pickerParams","_objectWithoutPropertiesLoose","slots","slotProps","innerSlotProps","className","sx","format","formatDensity","enableAccessibleFieldDOMStructure","selectedSections","onSelectedSectionsChange","timezone","name","label","inputRef","readOnly","disabled","localeText","fieldRef","React","useRef","labelId","useId","isToolbarHidden","toolbar","hidden","open","actions","layoutProps","renderCurrentView","fieldProps","pickerFieldProps","contextValue","usePicker","_extends","autoFocusView","additionalViewProps","wrapperVariant","Field","field","useSlotProps","elementType","externalSlotProps","additionalProps","id","onClick","onOpen","onKeyDown","onSpaceOrEnter","ownerState","inputProps","value","slotsForField","textField","Layout","layout","PickersLayout","labelledById","undefined","titleId","mobilePaper","handleFieldRef","useForkRef","unstableFieldRef","renderPicker","_jsxs","PickersProvider","children","_jsx","PickersModalDialog"],"mappings":"iuBAEA,MAAMA,EAAY,CAAC,QAAS,yBAkBfC,EAAkBC,IAC7B,IAAIC,MACAA,EAAKC,sBACLA,GACEF,EACJG,EAAeC,EAA8BJ,EAAMF,GACrD,MAAMO,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,WACRA,GACEpB,EACEqB,EAAWC,EAAMC,OAAO,MACxBC,EAAUC,IACVC,EAAkBpB,GAAgBqB,SAASC,SAAU,GACrDC,KACJA,EAAIC,QACJA,EAAOC,YACPA,EAAWC,kBACXA,EACAC,WAAYC,EAAgBC,aAC5BA,GACEC,EAAUC,EAAS,CAAE,EAAEnC,EAAc,CACvCF,QACAqB,WACAiB,eAAe,EACfC,oBAAqB,CAAE,EACvBC,eAAgB,YAEZC,EAAQrC,EAAMsC,MACdT,EAAaU,EAAa,CAC9B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/internals/hooks/usePicker/usePickerValue.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import*as t from"react";import{useOpenState as
|
1
|
+
import e from"../../../../../@babel/runtime/helpers/esm/extends.js";import*as t from"react";import a from"../../../../utils/esm/useEventCallback/useEventCallback.js";import{useOpenState as o}from"../useOpenState.js";import{useUtils as n,useLocalizationContext as l}from"../useUtils.js";import{useValueWithTimezone as r}from"../useValueWithTimezone.js";import{useValidation as s}from"../../../validation/useValidation.js";const i=({props:i,valueManager:u,valueType:c,wrapperVariant:d,validator:m})=>{const{onAccept:p,onChange:V,value:h,defaultValue:f,closeOnSelect:v="desktop"===d,timezone:C,referenceDate:S}=i,{current:g}=t.useRef(f),{current:F}=t.useRef(void 0!==h),[A,M]=t.useState(C);"production"!==process.env.NODE_ENV&&(t.useEffect((()=>{F!==(void 0!==h)&&console.error([`MUI X: A component is changing the ${F?"":"un"}controlled value of a picker to be ${F?"un":""}controlled.`,"Elements should not switch from uncontrolled to controlled (or vice versa).","Decide between using a controlled or uncontrolled valuefor the lifetime of the component.","The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.","More info: https://fb.me/react-controlled-components"].join("\n"))}),[h]),t.useEffect((()=>{F||g===f||console.error(["MUI X: A component is changing the defaultValue of an uncontrolled picker after being initialized. To suppress this warning opt to use a controlled value."].join("\n"))}),[JSON.stringify(g)]));const b=n(),E=l(),{isOpen:k,setIsOpen:w}=o(i),{timezone:O,value:P,handleValueChange:y}=r({timezone:C,value:h,defaultValue:g,referenceDate:S,onChange:V,valueManager:u}),[z,j]=t.useState((()=>{let e;return e=void 0!==P?P:void 0!==g?g:u.emptyValue,{draft:e,lastPublishedValue:e,lastCommittedValue:e,lastControlledValue:h,hasBeenModifiedSinceMount:!1}})),T=u.getTimezone(b,z.draft);A!==C&&(M(C),C&&T&&C!==T&&j((t=>e({},t,{draft:u.setTimezone(b,C,t.draft)}))));const{getValidationErrorForNewValue:D}=s({props:i,validator:m,timezone:O,value:z.draft,onError:i.onError}),I=a((t=>{const a={action:t,dateState:z,hasChanged:e=>!u.areValuesEqual(b,t.value,e),isControlled:F,closeOnSelect:v},o=(e=>{const{action:t,hasChanged:a,dateState:o,isControlled:n}=e,l=!n&&!o.hasBeenModifiedSinceMount;return"setValueFromField"===t.name||("setValueFromAction"===t.name?!(!l||!["accept","today","clear"].includes(t.pickerAction))||a(o.lastPublishedValue):("setValueFromView"===t.name&&"shallow"!==t.selectionState||"setValueFromShortcut"===t.name)&&(!!l||a(o.lastPublishedValue)))})(a),n=(e=>{const{action:t,hasChanged:a,dateState:o,isControlled:n,closeOnSelect:l}=e,r=!n&&!o.hasBeenModifiedSinceMount;return"setValueFromAction"===t.name?!(!r||!["accept","today","clear"].includes(t.pickerAction))||a(o.lastCommittedValue):"setValueFromView"===t.name&&"finish"===t.selectionState&&l?!!r||a(o.lastCommittedValue):"setValueFromShortcut"===t.name&&"accept"===t.changeImportance&&a(o.lastCommittedValue)})(a),l=(e=>{const{action:t,closeOnSelect:a}=e;return"setValueFromAction"===t.name||("setValueFromView"===t.name?"finish"===t.selectionState&&a:"setValueFromShortcut"===t.name&&"accept"===t.changeImportance)})(a);j((a=>e({},a,{draft:t.value,lastPublishedValue:o?t.value:a.lastPublishedValue,lastCommittedValue:n?t.value:a.lastCommittedValue,hasBeenModifiedSinceMount:!0})));let r=null;const s=()=>{if(!r){const e="setValueFromField"===t.name?t.context.validationError:D(t.value);r={validationError:e},"setValueFromShortcut"===t.name&&(r.shortcut=t.shortcut)}return r};o&&y(t.value,s()),n&&p&&p(t.value,s()),l&&w(!1)}));if(z.lastControlledValue!==h){const t=u.areValuesEqual(b,z.draft,P);j((a=>e({},a,{lastControlledValue:h},t?{}:{lastCommittedValue:P,lastPublishedValue:P,draft:P,hasBeenModifiedSinceMount:!0})))}const x=a((()=>{I({value:u.emptyValue,name:"setValueFromAction",pickerAction:"clear"})})),B=a((()=>{I({value:z.lastPublishedValue,name:"setValueFromAction",pickerAction:"accept"})})),N=a((()=>{I({value:z.lastPublishedValue,name:"setValueFromAction",pickerAction:"dismiss"})})),U=a((()=>{I({value:z.lastCommittedValue,name:"setValueFromAction",pickerAction:"cancel"})})),q=a((()=>{I({value:u.getTodayValue(b,O,c),name:"setValueFromAction",pickerAction:"today"})})),R=a((e=>{e.preventDefault(),w(!0)})),X=a((e=>{e?.preventDefault(),w(!1)})),$=a(((e,t="partial")=>I({name:"setValueFromView",value:e,selectionState:t}))),J=a(((e,t,a)=>I({name:"setValueFromShortcut",value:e,changeImportance:t,shortcut:a}))),W=a(((e,t)=>I({name:"setValueFromField",value:e,context:t}))),_={onClear:x,onAccept:B,onDismiss:N,onCancel:U,onSetToday:q,onOpen:R,onClose:X},G={value:z.draft,onChange:W},H=t.useMemo((()=>u.cleanValue(b,z.draft)),[b,u,z.draft]),K={value:H,onChange:$,onClose:X,open:k},L=e({},_,{value:H,onChange:$,onSelectShortcut:J,isValid:e=>{const t=m({adapter:E,value:e,timezone:O,props:i});return!u.hasError(t)}}),Q=t.useMemo((()=>({onOpen:R,onClose:X,open:k})),[k,X,R]);return{open:k,fieldProps:G,viewProps:K,layoutProps:L,actions:_,contextValue:Q}};export{i as usePickerValue};
|
2
2
|
//# sourceMappingURL=usePickerValue.js.map
|