@elliemae/ds-controlled-form 2.4.0 → 2.4.1-rc.11
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/cjs/autocomplete/Autocomplete.js +4 -5
- package/cjs/autocomplete/AutocompleteCTX.js +3 -14
- package/cjs/autocomplete/AutocompleteDataTestids.js +1 -7
- package/cjs/autocomplete/config/useAutocomplete.js +23 -10
- package/cjs/autocomplete/parts/container/Container.js +36 -20
- package/cjs/autocomplete/parts/container/styled.js +1 -5
- package/cjs/autocomplete/parts/{controls → container}/useKeyboardNavigation.js +8 -24
- package/cjs/autocomplete/parts/menu-list/MenuList.js +17 -50
- package/cjs/autocomplete/parts/menu-list/styled.js +9 -10
- package/cjs/autocomplete/parts/menu-list/useItemRenderer.js +38 -44
- package/cjs/autocomplete/react-desc-prop-types.js +4 -8
- package/cjs/autocomplete/utils/listHelper.js +8 -16
- package/cjs/checkbox/ControlledCheckbox.js +2 -1
- package/cjs/checkbox/react-desc-prop-types.js +2 -0
- package/cjs/combobox/ComboBox.js +1 -0
- package/cjs/combobox/config/useComboBox.js +8 -2
- package/cjs/combobox/config/useCorrectOptions.js +14 -42
- package/cjs/combobox/index.js +1 -0
- package/cjs/combobox/parts/A11yFocusedOption.js +3 -3
- package/cjs/combobox/parts/controls/Controls.js +4 -2
- package/cjs/combobox/parts/controls-input/ControlsInput.js +2 -0
- package/cjs/combobox/parts/controls-input/styled.js +1 -1
- package/cjs/combobox/parts/controls-input/useControlsInput.js +6 -6
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +30 -26
- package/cjs/combobox/parts/controls-input/useMaskedOnChange.js +7 -5
- package/cjs/combobox/parts/dropdown-indicator/DropdownIndicator.js +6 -4
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +4 -4
- package/cjs/combobox/parts/menu-list/MenuList.js +13 -7
- package/cjs/combobox/parts/menu-list/styled.js +16 -5
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +8 -8
- package/cjs/combobox/parts/menu-list/useMenuListSetFocusOption.js +6 -6
- package/cjs/combobox/react-desc-prop-types.js +2 -1
- package/cjs/combobox/utils/listHelper.js +40 -11
- package/cjs/date-time-picker/ControlledDateTimePickerCTX.js +1 -114
- package/cjs/date-time-picker/ControlledDateTimePickerDatatestid.js +0 -2
- package/cjs/date-time-picker/config/useChangeHandlers.js +264 -0
- package/cjs/date-time-picker/config/useControlledDateTimePicker.js +37 -420
- package/cjs/date-time-picker/config/useGetDestructuredValues.js +25 -68
- package/cjs/date-time-picker/config/useGetFlags.js +173 -0
- package/cjs/date-time-picker/config/useGetPropsBasedOnType.js +101 -0
- package/cjs/date-time-picker/config/useGetPropsWithDefault.js +2 -3
- package/cjs/date-time-picker/config/useGetReferences.js +86 -0
- package/cjs/date-time-picker/config/useGlobalKeyHandlers.js +106 -0
- package/cjs/date-time-picker/config/useRelevantValueFromProps.js +39 -0
- package/cjs/date-time-picker/config/useValidateProps.js +47 -42
- package/cjs/date-time-picker/parts/ClearButton/ClearButton.js +20 -8
- package/cjs/date-time-picker/parts/ControlledDateTimePickerContent.js +14 -12
- package/cjs/date-time-picker/parts/DateInputs/useDateInputs.js +5 -5
- package/cjs/date-time-picker/parts/Pickers/Calendar/Calendar.js +11 -13
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarContent.js +4 -1
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarContext.js +1 -49
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +10 -7
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +8 -4
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarMonthDays.js +5 -2
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarWrapper.js +5 -2
- package/cjs/date-time-picker/parts/Pickers/Calendar/Day.js +18 -18
- package/cjs/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +24 -122
- package/cjs/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +32 -4
- package/cjs/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +10 -6
- package/cjs/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +30 -14
- package/cjs/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +7 -4
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheel.js +7 -3
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelContext.js +1 -16
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +0 -1
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +10 -10
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +18 -13
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +60 -33
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +18 -13
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheel.js +11 -13
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +5 -2
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContext.js +1 -65
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +8 -3
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelWrapper.js +5 -2
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useConfigTimePickerCTX.js +18 -116
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +52 -94
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +4 -1
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +1 -1
- package/cjs/date-time-picker/parts/TimeInputs/HHInput.js +1 -3
- package/cjs/date-time-picker/parts/TimeInputs/MeridiemInput.js +1 -1
- package/cjs/date-time-picker/parts/TimeInputs/TimeInputs.js +3 -7
- package/cjs/date-time-picker/parts/TimeInputs/useTimeInputs.js +3 -6
- package/cjs/date-time-picker/propTypes.js +56 -23
- package/cjs/{autocomplete/index.d.js → date-time-picker/sharedTypes.js} +0 -0
- package/cjs/date-time-picker/utils/dateHelpers.js +56 -56
- package/cjs/date-time-picker/utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js +2 -5
- package/cjs/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +50 -47
- package/cjs/date-time-picker/utils/hooks/useOnClickOutside.js +1 -2
- package/cjs/date-time-picker/utils/stringHelpers.js +8 -14
- package/cjs/date-time-picker/utils/typeGuards.js +14 -0
- package/cjs/index.js +20 -3
- package/cjs/large-text-input/DSControlledLargeTextInput.js +83 -0
- package/cjs/large-text-input/exported-related/data-test-ids.js +11 -0
- package/cjs/large-text-input/exported-related/index.js +12 -0
- package/cjs/large-text-input/exported-related/theming.js +13 -0
- package/cjs/large-text-input/index.js +15 -0
- package/cjs/large-text-input/react-desc-prop-types.js +45 -0
- package/cjs/large-text-input/styles.js +40 -0
- package/cjs/mask-hook/hooks/index.js +11 -3
- package/cjs/mask-hook/hooks/useNumberMask.js +7 -0
- package/cjs/mask-hook/hooks/usePhoneMask.js +7 -0
- package/cjs/mask-hook/hooks/useRegExpMask.js +122 -0
- package/cjs/mask-hook/hooks/useSSNMask.js +7 -0
- package/cjs/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +12 -5
- package/cjs/mask-hook/index.js +11 -3
- package/cjs/mask-hook/react-desc-prop-types.js +9 -0
- package/cjs/mask-hook/utils/addSpecialCharacters.js +3 -4
- package/cjs/mask-hook/utils/flatStringArray.js +18 -0
- package/cjs/mask-hook/utils/index.js +2 -0
- package/esm/autocomplete/Autocomplete.js +2 -3
- package/esm/autocomplete/AutocompleteCTX.js +3 -14
- package/esm/autocomplete/AutocompleteDataTestids.js +1 -7
- package/esm/autocomplete/config/useAutocomplete.js +27 -14
- package/esm/autocomplete/parts/container/Container.js +38 -23
- package/esm/autocomplete/parts/container/styled.js +2 -5
- package/esm/autocomplete/parts/{controls → container}/useKeyboardNavigation.js +8 -24
- package/esm/autocomplete/parts/menu-list/MenuList.js +19 -52
- package/esm/autocomplete/parts/menu-list/styled.js +9 -10
- package/esm/autocomplete/parts/menu-list/useItemRenderer.js +39 -45
- package/esm/autocomplete/react-desc-prop-types.js +5 -8
- package/esm/autocomplete/utils/listHelper.js +8 -16
- package/esm/checkbox/ControlledCheckbox.js +2 -1
- package/esm/checkbox/react-desc-prop-types.js +2 -0
- package/esm/combobox/ComboBox.js +1 -1
- package/esm/combobox/config/useComboBox.js +8 -2
- package/esm/combobox/config/useCorrectOptions.js +15 -43
- package/esm/combobox/index.js +1 -1
- package/esm/combobox/parts/A11yFocusedOption.js +3 -3
- package/esm/combobox/parts/controls/Controls.js +4 -2
- package/esm/combobox/parts/controls-input/ControlsInput.js +2 -0
- package/esm/combobox/parts/controls-input/styled.js +1 -1
- package/esm/combobox/parts/controls-input/useControlsInput.js +6 -6
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +30 -26
- package/esm/combobox/parts/controls-input/useMaskedOnChange.js +7 -5
- package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +4 -4
- package/esm/combobox/parts/menu-list/MenuList.js +13 -7
- package/esm/combobox/parts/menu-list/styled.js +16 -5
- package/esm/combobox/parts/menu-list/useItemRenderer.js +8 -8
- package/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js +6 -6
- package/esm/combobox/react-desc-prop-types.js +2 -1
- package/esm/combobox/utils/listHelper.js +38 -12
- package/esm/date-time-picker/ControlledDateTimePickerCTX.js +3 -115
- package/esm/date-time-picker/ControlledDateTimePickerDatatestid.js +0 -2
- package/esm/date-time-picker/config/useChangeHandlers.js +256 -0
- package/esm/date-time-picker/config/useControlledDateTimePicker.js +38 -421
- package/esm/date-time-picker/config/useGetDestructuredValues.js +21 -68
- package/esm/date-time-picker/config/useGetFlags.js +165 -0
- package/esm/date-time-picker/config/useGetPropsBasedOnType.js +97 -0
- package/esm/date-time-picker/config/useGetPropsWithDefault.js +1 -2
- package/esm/date-time-picker/config/useGetReferences.js +82 -0
- package/esm/date-time-picker/config/useGlobalKeyHandlers.js +98 -0
- package/esm/date-time-picker/config/useRelevantValueFromProps.js +35 -0
- package/esm/date-time-picker/config/useValidateProps.js +47 -42
- package/esm/date-time-picker/parts/ClearButton/ClearButton.js +20 -9
- package/esm/date-time-picker/parts/ControlledDateTimePickerContent.js +14 -12
- package/esm/date-time-picker/parts/DateInputs/useDateInputs.js +5 -5
- package/esm/date-time-picker/parts/Pickers/Calendar/Calendar.js +11 -13
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarContent.js +4 -1
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarContext.js +2 -50
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +10 -7
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +9 -5
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarMonthDays.js +5 -2
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarWrapper.js +5 -2
- package/esm/date-time-picker/parts/Pickers/Calendar/Day.js +18 -18
- package/esm/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +23 -125
- package/esm/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +33 -5
- package/esm/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +10 -6
- package/esm/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +30 -14
- package/esm/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +7 -4
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheel.js +9 -5
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelContext.js +1 -16
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -2
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +10 -10
- package/esm/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +18 -13
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +59 -33
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +18 -13
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheel.js +11 -13
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +5 -2
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContext.js +2 -66
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +8 -3
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelWrapper.js +5 -2
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useConfigTimePickerCTX.js +15 -117
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +54 -96
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +4 -1
- package/esm/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +1 -1
- package/esm/date-time-picker/parts/TimeInputs/HHInput.js +1 -3
- package/esm/date-time-picker/parts/TimeInputs/MeridiemInput.js +1 -1
- package/esm/date-time-picker/parts/TimeInputs/TimeInputs.js +3 -7
- package/esm/date-time-picker/parts/TimeInputs/useTimeInputs.js +3 -6
- package/esm/date-time-picker/propTypes.js +49 -17
- package/esm/{autocomplete/index.d.js → date-time-picker/sharedTypes.js} +0 -0
- package/esm/date-time-picker/utils/dateHelpers.js +57 -57
- package/esm/date-time-picker/utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js +2 -5
- package/esm/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +46 -47
- package/esm/date-time-picker/utils/hooks/useOnClickOutside.js +1 -2
- package/esm/date-time-picker/utils/stringHelpers.js +8 -14
- package/esm/date-time-picker/utils/typeGuards.js +8 -0
- package/esm/index.js +9 -5
- package/esm/large-text-input/DSControlledLargeTextInput.js +72 -0
- package/esm/large-text-input/exported-related/data-test-ids.js +7 -0
- package/esm/large-text-input/exported-related/index.js +2 -0
- package/esm/large-text-input/exported-related/theming.js +8 -0
- package/esm/large-text-input/index.js +3 -0
- package/esm/large-text-input/react-desc-prop-types.js +36 -0
- package/esm/large-text-input/styles.js +30 -0
- package/esm/mask-hook/hooks/index.js +5 -4
- package/esm/mask-hook/hooks/useNumberMask.js +7 -1
- package/esm/mask-hook/hooks/usePhoneMask.js +7 -1
- package/esm/mask-hook/hooks/useRegExpMask.js +116 -0
- package/esm/mask-hook/hooks/useSSNMask.js +7 -1
- package/esm/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +11 -5
- package/esm/mask-hook/index.js +5 -4
- package/esm/mask-hook/react-desc-prop-types.js +8 -1
- package/esm/mask-hook/utils/addSpecialCharacters.js +3 -4
- package/esm/mask-hook/utils/flatStringArray.js +14 -0
- package/esm/mask-hook/utils/index.js +1 -0
- package/package.json +92 -88
- package/types/autocomplete/Autocomplete.d.ts +4 -61
- package/types/autocomplete/AutocompleteCTX.d.ts +4 -3
- package/types/autocomplete/AutocompleteDataTestids.d.ts +1 -7
- package/types/autocomplete/config/useAutocomplete.d.ts +3 -2
- package/types/autocomplete/parts/container/Container.d.ts +1 -2
- package/types/autocomplete/parts/container/styled.d.ts +0 -1
- package/types/autocomplete/parts/{controls → container}/useKeyboardNavigation.d.ts +0 -0
- package/types/autocomplete/parts/menu-list/MenuList.d.ts +1 -2
- package/types/autocomplete/parts/menu-list/styled.d.ts +1 -4
- package/types/autocomplete/parts/menu-list/useItemRenderer.d.ts +2 -3
- package/types/autocomplete/react-desc-prop-types.d.ts +8 -18
- package/types/autocomplete/sharedTypes.d.ts +1 -3
- package/types/autocomplete/tests/general.test.d.ts +1 -0
- package/types/autocomplete/tests/utils.d.ts +5 -0
- package/types/autocomplete/utils/listHelper.d.ts +2 -2
- package/types/checkbox/ControlledCheckbox.d.ts +1 -1
- package/types/checkbox/react-desc-prop-types.d.ts +367 -1
- package/types/combobox/ComboBox.d.ts +2 -2
- package/types/combobox/parts/dropdown-indicator/DropdownIndicator.d.ts +1 -0
- package/types/combobox/react-desc-prop-types.d.ts +381 -3
- package/types/combobox/utils/listHelper.d.ts +4 -1
- package/types/date-time-picker/ControlledDateTimePicker.d.ts +25 -80
- package/types/date-time-picker/ControlledDateTimePickerCTX.d.ts +1 -2
- package/types/date-time-picker/ControlledDateTimePickerDatatestid.d.ts +46 -46
- package/types/date-time-picker/ControlledDateTimePickerTypes.d.ts +15 -15
- package/types/date-time-picker/config/useChangeHandlers.d.ts +25 -0
- package/types/date-time-picker/config/useControlledDateTimePicker.d.ts +18 -2
- package/types/date-time-picker/config/useGetDestructuredValues.d.ts +30 -4
- package/types/date-time-picker/config/useGetFlags.d.ts +27 -0
- package/types/date-time-picker/config/useGetPropsBasedOnType.d.ts +28 -0
- package/types/date-time-picker/config/useGetPropsWithDefault.d.ts +2 -2
- package/types/date-time-picker/config/useGetReferences.d.ts +39 -0
- package/types/date-time-picker/config/useGlobalKeyHandlers.d.ts +16 -0
- package/types/date-time-picker/config/useRelevantValueFromProps.d.ts +10 -0
- package/types/date-time-picker/config/useValidateProps.d.ts +2 -2
- package/types/date-time-picker/parts/ClearButton/useClearButton.d.ts +6 -6
- package/types/date-time-picker/parts/DateInputs/DDInput.d.ts +6 -6
- package/types/date-time-picker/parts/DateInputs/MMInput.d.ts +6 -6
- package/types/date-time-picker/parts/DateInputs/YYYYInput.d.ts +6 -6
- package/types/date-time-picker/parts/DateInputs/useDateInputs.d.ts +2 -2
- package/types/date-time-picker/parts/Pickers/Calendar/Calendar.d.ts +4 -2
- package/types/date-time-picker/parts/Pickers/Calendar/CalendarContext.d.ts +3 -63
- package/types/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.d.ts +4 -4
- package/types/date-time-picker/parts/Pickers/Calendar/CalendarFooter.d.ts +2 -2
- package/types/date-time-picker/parts/Pickers/Calendar/Day.d.ts +2 -2
- package/types/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.d.ts +15 -2
- package/types/date-time-picker/parts/Pickers/Calendar/useFocusLogic.d.ts +12 -5
- package/types/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.d.ts +17 -11
- package/types/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelContext.d.ts +1 -16
- package/types/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelFooter.d.ts +2 -2
- package/types/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.d.ts +15 -1
- package/types/date-time-picker/parts/Pickers/TimeWheel/TimeWheel.d.ts +4 -2
- package/types/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContext.d.ts +3 -62
- package/types/date-time-picker/parts/Pickers/TimeWheel/TimeWheelFooter.d.ts +2 -2
- package/types/date-time-picker/parts/Pickers/TimeWheel/useConfigTimePickerCTX.d.ts +4 -1
- package/types/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.d.ts +16 -5
- package/types/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.d.ts +18 -3
- package/types/date-time-picker/parts/TimeInputs/HHInput.d.ts +6 -6
- package/types/date-time-picker/parts/TimeInputs/MeridiemInput.d.ts +6 -6
- package/types/date-time-picker/parts/TimeInputs/MinutesInput.d.ts +6 -6
- package/types/date-time-picker/parts/TimeInputs/useTimeInputs.d.ts +22 -2
- package/types/date-time-picker/parts/config.d.ts +3 -3
- package/types/date-time-picker/sharedTypes.d.ts +94 -0
- package/types/date-time-picker/utils/constants.d.ts +33 -33
- package/types/date-time-picker/utils/dateHelpers.d.ts +15 -14
- package/types/date-time-picker/utils/dateTimeHelpers.d.ts +3 -3
- package/types/date-time-picker/utils/hooks/useGetDayFromDateString.d.ts +1 -1
- package/types/date-time-picker/utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.d.ts +2 -2
- package/types/date-time-picker/utils/hooks/useGetStartingFocusedDay.d.ts +6 -6
- package/types/date-time-picker/utils/hooks/useOnClickOutside.d.ts +1 -1
- package/types/date-time-picker/utils/timeHelpers.d.ts +2 -2
- package/types/date-time-picker/utils/typeGuards.d.ts +4 -0
- package/types/index.d.ts +1 -0
- package/types/large-text-input/DSControlledLargeTextInput.d.ts +5 -0
- package/types/large-text-input/exported-related/data-test-ids.d.ts +5 -0
- package/types/large-text-input/exported-related/index.d.ts +2 -0
- package/types/large-text-input/exported-related/theming.d.ts +6 -0
- package/types/large-text-input/index.d.ts +2 -0
- package/types/large-text-input/react-desc-prop-types.d.ts +447 -0
- package/types/large-text-input/styles.d.ts +3 -0
- package/types/large-text-input/tests/DSControlledLargeTextInput.test.d.ts +1 -0
- package/types/mask-hook/hooks/index.d.ts +2 -1
- package/types/mask-hook/hooks/useNumberMask.d.ts +2 -1
- package/types/mask-hook/hooks/usePhoneMask.d.ts +2 -1
- package/types/mask-hook/hooks/useRegExpMask.d.ts +4 -0
- package/types/mask-hook/hooks/useSSNMask.d.ts +2 -1
- package/types/mask-hook/hooks/useZipCodeMask.d.ts +4 -0
- package/types/mask-hook/react-desc-prop-types.d.ts +6 -1
- package/types/mask-hook/tests/useRegExpMask.test.d.ts +1 -0
- package/types/mask-hook/utils/flatStringArray.d.ts +1 -0
- package/types/mask-hook/utils/index.d.ts +1 -0
- package/types/text-input/DSInputText.d.ts +1 -1
- package/types/text-input/config/useInputText.d.ts +110 -110
- package/cjs/autocomplete/config/constants.js +0 -14
- package/cjs/autocomplete/config/useGetPropsWithDefault.js +0 -11
- package/cjs/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -33
- package/cjs/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -28
- package/cjs/autocomplete/parts/a11y-messages/index.js +0 -11
- package/cjs/autocomplete/parts/a11y-messages/styled.js +0 -15
- package/cjs/autocomplete/parts/controls/Controls.js +0 -63
- package/cjs/autocomplete/parts/controls/index.js +0 -9
- package/cjs/autocomplete/parts/controls/styled.js +0 -44
- package/cjs/autocomplete/parts/controls/useControlsInput.js +0 -44
- package/cjs/autocomplete/parts/controls/useMaskedOnChange.js +0 -28
- package/cjs/autocomplete/parts/menu-list/useMenuList.js +0 -69
- package/cjs/autocomplete/propTypes.js +0 -25
- package/cjs/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -97
- package/cjs/autocomplete/utils/hooks/useOnElementResize.js +0 -37
- package/cjs/text-input/exported-related/name.js +0 -7
- package/cjs/text-input/exported-related/slots.js +0 -11
- package/esm/autocomplete/config/constants.js +0 -10
- package/esm/autocomplete/config/useGetPropsWithDefault.js +0 -7
- package/esm/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -25
- package/esm/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -20
- package/esm/autocomplete/parts/a11y-messages/index.js +0 -2
- package/esm/autocomplete/parts/a11y-messages/styled.js +0 -7
- package/esm/autocomplete/parts/controls/Controls.js +0 -55
- package/esm/autocomplete/parts/controls/index.js +0 -1
- package/esm/autocomplete/parts/controls/styled.js +0 -32
- package/esm/autocomplete/parts/controls/useControlsInput.js +0 -40
- package/esm/autocomplete/parts/controls/useMaskedOnChange.js +0 -24
- package/esm/autocomplete/parts/menu-list/useMenuList.js +0 -65
- package/esm/autocomplete/propTypes.js +0 -21
- package/esm/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -93
- package/esm/autocomplete/utils/hooks/useOnElementResize.js +0 -33
- package/esm/text-input/exported-related/name.js +0 -3
- package/esm/text-input/exported-related/slots.js +0 -7
- package/types/autocomplete/config/constants.d.ts +0 -8
- package/types/autocomplete/config/useGetPropsWithDefault.d.ts +0 -2
- package/types/autocomplete/parts/a11y-messages/MultiAllyMessages.d.ts +0 -3
- package/types/autocomplete/parts/a11y-messages/SingleAllyMessages.d.ts +0 -3
- package/types/autocomplete/parts/a11y-messages/index.d.ts +0 -2
- package/types/autocomplete/parts/a11y-messages/styled.d.ts +0 -1
- package/types/autocomplete/parts/controls/Controls.d.ts +0 -3
- package/types/autocomplete/parts/controls/index.d.ts +0 -1
- package/types/autocomplete/parts/controls/styled.d.ts +0 -8
- package/types/autocomplete/parts/controls/useControlsInput.d.ts +0 -9
- package/types/autocomplete/parts/controls/useMaskedOnChange.d.ts +0 -2
- package/types/autocomplete/parts/menu-list/useMenuList.d.ts +0 -2
- package/types/autocomplete/propTypes.d.ts +0 -51
- package/types/autocomplete/utils/hooks/useKeyboardNavigation.d.ts +0 -4
- package/types/autocomplete/utils/hooks/useOnElementResize.d.ts +0 -3
- package/types/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.d.ts +0 -2
- package/types/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.d.ts +0 -12
- package/types/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.d.ts +0 -2
- package/types/date-time-picker/propTypes.d.ts +0 -81
- package/types/mask-hook/hooks/useZipCode.d.ts +0 -3
- package/types/text-input/exported-related/name.d.ts +0 -1
- package/types/text-input/exported-related/slots.d.ts +0 -5
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
import { CONTROLLED_DATE_TIME_PICKER_TYPES } from '../ControlledDateTimePickerTypes.js';
|
|
9
|
+
import { getIsDateTime, getIsDate } from '../utils/typeGuards.js';
|
|
10
|
+
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
+
|
|
15
|
+
const getDateTimeFlags = props => {
|
|
16
|
+
const {
|
|
17
|
+
type,
|
|
18
|
+
isClearable,
|
|
19
|
+
dateTime,
|
|
20
|
+
autoFocus
|
|
21
|
+
} = props;
|
|
22
|
+
const constants = {
|
|
23
|
+
hideDatePicker: true,
|
|
24
|
+
hideTimePicker: true,
|
|
25
|
+
isDateSelector: false,
|
|
26
|
+
isTimeSelector: false,
|
|
27
|
+
isDateTimeSelector: true,
|
|
28
|
+
isWithDateInputsOnly: false,
|
|
29
|
+
isWithTimeInputsOnly: false,
|
|
30
|
+
autoFocusHourInput: false,
|
|
31
|
+
autoFocusHourTimeWheel: false
|
|
32
|
+
};
|
|
33
|
+
const withAnyInputs = type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE_TIME.FULL || type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE_TIME.INPUTS;
|
|
34
|
+
const hideDateTimePicker = type !== CONTROLLED_DATE_TIME_PICKER_TYPES.DATE_TIME.FULL && type !== CONTROLLED_DATE_TIME_PICKER_TYPES.DATE_TIME.PICKER && type !== CONTROLLED_DATE_TIME_PICKER_TYPES.DATE_TIME.CONTROLLER_ONLY;
|
|
35
|
+
const isControllerOnly = type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE_TIME.CONTROLLER_ONLY;
|
|
36
|
+
const withAnyPicker = !hideDateTimePicker;
|
|
37
|
+
const withClearBtn = withAnyInputs && isClearable && dateTime !== '' && dateTime !== '__/__/____ __:__ __';
|
|
38
|
+
const shouldPreserveClearableSpace = isClearable && withAnyInputs;
|
|
39
|
+
|
|
40
|
+
const finalFlags = _objectSpread({
|
|
41
|
+
hideDate: !withAnyInputs,
|
|
42
|
+
hideTime: !withAnyInputs,
|
|
43
|
+
hideDateTimePicker,
|
|
44
|
+
isControllerOnly,
|
|
45
|
+
isWithTimeWheelToo: !hideDateTimePicker,
|
|
46
|
+
isWithCalendarToo: !hideDateTimePicker,
|
|
47
|
+
withAnyInputs,
|
|
48
|
+
withAnyPicker,
|
|
49
|
+
withClearBtn,
|
|
50
|
+
isWithDateInputs: withAnyInputs,
|
|
51
|
+
isWithTimeInputs: withAnyInputs,
|
|
52
|
+
autoFocusMonthInput: withAnyInputs && autoFocus,
|
|
53
|
+
autoFocusPrevMonthArrow: isControllerOnly && autoFocus,
|
|
54
|
+
shouldPreserveClearableSpace,
|
|
55
|
+
withAnyRightController: withAnyPicker || withClearBtn || shouldPreserveClearableSpace
|
|
56
|
+
}, constants);
|
|
57
|
+
|
|
58
|
+
return finalFlags;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const getDateFlags = props => {
|
|
62
|
+
const {
|
|
63
|
+
type,
|
|
64
|
+
isClearable,
|
|
65
|
+
date,
|
|
66
|
+
autoFocus
|
|
67
|
+
} = props;
|
|
68
|
+
const constants = {
|
|
69
|
+
isDateSelector: true,
|
|
70
|
+
hideTime: true,
|
|
71
|
+
hideDateTimePicker: true,
|
|
72
|
+
hideTimePicker: true,
|
|
73
|
+
isTimeSelector: false,
|
|
74
|
+
isDateTimeSelector: false,
|
|
75
|
+
isWithCalendarToo: false,
|
|
76
|
+
isWithTimeWheelToo: false,
|
|
77
|
+
isWithTimeInputs: false,
|
|
78
|
+
isWithTimeInputsOnly: false,
|
|
79
|
+
autoFocusHourTimeWheel: false,
|
|
80
|
+
autoFocusHourInput: false
|
|
81
|
+
};
|
|
82
|
+
const withAnyInputs = type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE.FULL || type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE.INPUTS;
|
|
83
|
+
const hideDatePicker = type !== CONTROLLED_DATE_TIME_PICKER_TYPES.DATE.FULL && type !== CONTROLLED_DATE_TIME_PICKER_TYPES.DATE.PICKER && type !== CONTROLLED_DATE_TIME_PICKER_TYPES.DATE.CONTROLLER_ONLY;
|
|
84
|
+
const isControllerOnly = type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE.CONTROLLER_ONLY;
|
|
85
|
+
const withAnyPicker = !hideDatePicker;
|
|
86
|
+
const withClearBtn = withAnyInputs && isClearable && date !== '' && date !== '__/__/____';
|
|
87
|
+
const shouldPreserveClearableSpace = isClearable && withAnyInputs;
|
|
88
|
+
|
|
89
|
+
const finalFlags = _objectSpread({
|
|
90
|
+
hideDate: !withAnyInputs,
|
|
91
|
+
hideDatePicker,
|
|
92
|
+
isControllerOnly,
|
|
93
|
+
withAnyInputs,
|
|
94
|
+
withAnyPicker,
|
|
95
|
+
withClearBtn,
|
|
96
|
+
isWithDateInputs: withAnyInputs,
|
|
97
|
+
isWithDateInputsOnly: withAnyInputs,
|
|
98
|
+
autoFocusMonthInput: withAnyInputs && autoFocus,
|
|
99
|
+
autoFocusPrevMonthArrow: isControllerOnly && autoFocus,
|
|
100
|
+
shouldPreserveClearableSpace,
|
|
101
|
+
withAnyRightController: withAnyPicker || withClearBtn || shouldPreserveClearableSpace
|
|
102
|
+
}, constants);
|
|
103
|
+
|
|
104
|
+
return finalFlags;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const getTimeFlags = props => {
|
|
108
|
+
const {
|
|
109
|
+
type,
|
|
110
|
+
isClearable,
|
|
111
|
+
time,
|
|
112
|
+
autoFocus
|
|
113
|
+
} = props;
|
|
114
|
+
const constants = {
|
|
115
|
+
hideDate: true,
|
|
116
|
+
hideDateTimePicker: true,
|
|
117
|
+
hideDatePicker: true,
|
|
118
|
+
isDateSelector: false,
|
|
119
|
+
isDateTimeSelector: false,
|
|
120
|
+
isWithDateInputs: false,
|
|
121
|
+
isWithDateInputsOnly: false,
|
|
122
|
+
isTimeSelector: true,
|
|
123
|
+
isWithTimeWheelToo: false,
|
|
124
|
+
isWithCalendarToo: false,
|
|
125
|
+
autoFocusMonthInput: false,
|
|
126
|
+
autoFocusPrevMonthArrow: false
|
|
127
|
+
};
|
|
128
|
+
const withAnyInputs = type === CONTROLLED_DATE_TIME_PICKER_TYPES.TIME.FULL || type === CONTROLLED_DATE_TIME_PICKER_TYPES.TIME.INPUTS;
|
|
129
|
+
const hideTimePicker = type !== CONTROLLED_DATE_TIME_PICKER_TYPES.TIME.FULL && type !== CONTROLLED_DATE_TIME_PICKER_TYPES.TIME.PICKER && type !== CONTROLLED_DATE_TIME_PICKER_TYPES.TIME.CONTROLLER_ONLY;
|
|
130
|
+
const isControllerOnly = type === CONTROLLED_DATE_TIME_PICKER_TYPES.TIME.CONTROLLER_ONLY;
|
|
131
|
+
const withClearBtn = withAnyInputs && isClearable && time !== '' && time !== '__:__ __';
|
|
132
|
+
const shouldPreserveClearableSpace = isClearable && withAnyInputs;
|
|
133
|
+
const withAnyPicker = !hideTimePicker;
|
|
134
|
+
|
|
135
|
+
const finalFlags = _objectSpread({
|
|
136
|
+
hideTime: !withAnyInputs,
|
|
137
|
+
hideTimePicker,
|
|
138
|
+
isControllerOnly,
|
|
139
|
+
withAnyInputs,
|
|
140
|
+
withAnyPicker,
|
|
141
|
+
withClearBtn,
|
|
142
|
+
isWithTimeInputs: withAnyInputs,
|
|
143
|
+
isWithTimeInputsOnly: withAnyInputs,
|
|
144
|
+
autoFocusHourInput: withAnyInputs && autoFocus,
|
|
145
|
+
autoFocusHourTimeWheel: isControllerOnly && autoFocus,
|
|
146
|
+
shouldPreserveClearableSpace,
|
|
147
|
+
withAnyRightController: withAnyPicker || withClearBtn || shouldPreserveClearableSpace
|
|
148
|
+
}, constants);
|
|
149
|
+
|
|
150
|
+
return finalFlags;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const useGetFlags = props => useMemo(() => {
|
|
154
|
+
if (getIsDateTime(props)) {
|
|
155
|
+
return getDateTimeFlags(props);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (getIsDate(props)) {
|
|
159
|
+
return getDateFlags(props);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return getTimeFlags(props);
|
|
163
|
+
}, [props]);
|
|
164
|
+
|
|
165
|
+
export { useGetFlags };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { getIsDateTime, getIsDate, getIsTime } from '../utils/typeGuards.js';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable max-lines */
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7
|
+
const noop = () => {};
|
|
8
|
+
|
|
9
|
+
const defaultReturnFalse = () => false;
|
|
10
|
+
|
|
11
|
+
const useGetPropsBasedOnType = propsWithDefaults => {
|
|
12
|
+
const isDateTime = getIsDateTime(propsWithDefaults);
|
|
13
|
+
const isDate = getIsDate(propsWithDefaults);
|
|
14
|
+
const isTime = getIsTime(propsWithDefaults);
|
|
15
|
+
/* -------------------------- -------------- --------------------------*/
|
|
16
|
+
|
|
17
|
+
/* -------------------------- DATE OPTIONALS --------------------------*/
|
|
18
|
+
|
|
19
|
+
/* -------------------------- -------------- --------------------------*/
|
|
20
|
+
|
|
21
|
+
const getIsDisabledDay = (isDateTime || isDate) && propsWithDefaults.getIsDisabledDay ? propsWithDefaults.getIsDisabledDay : defaultReturnFalse;
|
|
22
|
+
const getIsOutOfRangeDay = (isDateTime || isDate) && propsWithDefaults.getIsOutOfRangeDay ? propsWithDefaults.getIsOutOfRangeDay : defaultReturnFalse;
|
|
23
|
+
const appOnMonthChange = (isDateTime || isDate) && propsWithDefaults.onMonthChange ? propsWithDefaults.onMonthChange : noop;
|
|
24
|
+
const appOnDayChange = (isDateTime || isDate) && propsWithDefaults.onDayChange ? propsWithDefaults.onDayChange : noop;
|
|
25
|
+
const appOnYearChange = (isDateTime || isDate) && propsWithDefaults.onYearChange ? propsWithDefaults.onYearChange : noop;
|
|
26
|
+
const emptyPickerStartingMonthDefault = "".concat(new Date().getMonth() + 1, "/__/").concat(new Date().getFullYear());
|
|
27
|
+
const emptyPickerStartingMonth = (isDateTime || isDate) && propsWithDefaults.emptyPickerStartingMonth ? propsWithDefaults.emptyPickerStartingMonth : emptyPickerStartingMonthDefault;
|
|
28
|
+
const onCalendarOpenFocusedDay = (isDateTime || isDate) && propsWithDefaults.onCalendarOpenFocusedDay ? propsWithDefaults.onCalendarOpenFocusedDay : undefined;
|
|
29
|
+
/* -------------------------- -------------- --------------------------*/
|
|
30
|
+
|
|
31
|
+
/* -------------------------- TIME OPTIONALS --------------------------*/
|
|
32
|
+
|
|
33
|
+
/* -------------------------- -------------- --------------------------*/
|
|
34
|
+
|
|
35
|
+
const getIsDisabledTime = (isDateTime || isTime) && propsWithDefaults.getIsDisabledTime ? propsWithDefaults.getIsDisabledTime : defaultReturnFalse;
|
|
36
|
+
const appOnHourChange = (isDateTime || isTime) && propsWithDefaults.onHourChange ? propsWithDefaults.onHourChange : noop;
|
|
37
|
+
const appOnMinuteChange = (isDateTime || isTime) && propsWithDefaults.onMinuteChange ? propsWithDefaults.onMinuteChange : noop;
|
|
38
|
+
const appOnMeridiemChange = (isDateTime || isTime) && propsWithDefaults.onMeridiemChange ? propsWithDefaults.onMeridiemChange : noop;
|
|
39
|
+
const minutesInterval = (isDateTime || isTime) && propsWithDefaults.minutesInterval ? propsWithDefaults.minutesInterval : 1;
|
|
40
|
+
const onTimeWheelOpenStartingTime = (isDateTime || isTime) && propsWithDefaults.onTimeWheelOpenStartingTime ? propsWithDefaults.onTimeWheelOpenStartingTime : '01:00 AM';
|
|
41
|
+
/* --------- ------------------------------------ ---------------------*/
|
|
42
|
+
|
|
43
|
+
/* --------- SPECIFIC REQUIRED DATETIME OPTIONALS ---------------------*/
|
|
44
|
+
|
|
45
|
+
/* --------- ------------------------------------ ---------------------*/
|
|
46
|
+
|
|
47
|
+
const appOnDateChange = (isDateTime || isDate) && propsWithDefaults.onDateChange ? propsWithDefaults.onDateChange : noop;
|
|
48
|
+
const appOnTimeChange = (isDateTime || isTime) && propsWithDefaults.onTimeChange ? propsWithDefaults.onTimeChange : noop;
|
|
49
|
+
/* ---------------------- ---------------------- ----------------------*/
|
|
50
|
+
|
|
51
|
+
/* ---------------------- DATE-RELATED OPTIONALS ----------------------*/
|
|
52
|
+
|
|
53
|
+
/* ---------------------- ---------------------- ----------------------*/
|
|
54
|
+
|
|
55
|
+
const getIsStartRangeDay = (isDateTime || isDate) && propsWithDefaults.getIsStartRangeDay ? propsWithDefaults.getIsStartRangeDay : noop;
|
|
56
|
+
const getIsDayInRange = (isDateTime || isDate) && propsWithDefaults.getIsDayInRange ? propsWithDefaults.getIsDayInRange : noop;
|
|
57
|
+
const getIsEndRangeDay = (isDateTime || isDate) && propsWithDefaults.getIsEndRangeDay ? propsWithDefaults.getIsEndRangeDay : noop;
|
|
58
|
+
/* --------------------- ----------------------- ------------------------*/
|
|
59
|
+
|
|
60
|
+
/* --------------------- TYPE SPECIFIC REQUIREDS ------------------------*/
|
|
61
|
+
|
|
62
|
+
/* --------------------- ----------------------- ------------------------*/
|
|
63
|
+
|
|
64
|
+
const appDate = isDate ? propsWithDefaults.date : '';
|
|
65
|
+
const appTime = isTime ? propsWithDefaults.time : '';
|
|
66
|
+
const appDateTime = isDateTime ? propsWithDefaults.dateTime : '';
|
|
67
|
+
const appOnDateTimeChange = isDateTime ? propsWithDefaults.onDateTimeChange : noop;
|
|
68
|
+
return useMemo(() => ({
|
|
69
|
+
getIsDisabledDay,
|
|
70
|
+
getIsOutOfRangeDay,
|
|
71
|
+
getIsStartRangeDay,
|
|
72
|
+
getIsDayInRange,
|
|
73
|
+
getIsEndRangeDay,
|
|
74
|
+
appOnDateChange,
|
|
75
|
+
appOnMonthChange,
|
|
76
|
+
appOnDayChange,
|
|
77
|
+
appOnYearChange,
|
|
78
|
+
appDate,
|
|
79
|
+
getIsDisabledTime,
|
|
80
|
+
appOnTimeChange,
|
|
81
|
+
appOnHourChange,
|
|
82
|
+
appOnMinuteChange,
|
|
83
|
+
appOnMeridiemChange,
|
|
84
|
+
appTime,
|
|
85
|
+
appDateTime,
|
|
86
|
+
appOnDateTimeChange,
|
|
87
|
+
emptyPickerStartingMonth,
|
|
88
|
+
onCalendarOpenFocusedDay,
|
|
89
|
+
minutesInterval,
|
|
90
|
+
onTimeWheelOpenStartingTime,
|
|
91
|
+
isDate,
|
|
92
|
+
isTime,
|
|
93
|
+
isDateTime
|
|
94
|
+
}), [getIsDisabledDay, getIsOutOfRangeDay, getIsStartRangeDay, getIsDayInRange, getIsEndRangeDay, appOnDateChange, appOnMonthChange, appOnDayChange, appOnYearChange, appDate, getIsDisabledTime, appOnTimeChange, appOnHourChange, appOnMinuteChange, appOnMeridiemChange, appTime, appDateTime, appOnDateTimeChange, emptyPickerStartingMonth, onCalendarOpenFocusedDay, minutesInterval, onTimeWheelOpenStartingTime, isDate, isTime, isDateTime]);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export { useGetPropsBasedOnType };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
|
|
2
|
-
import { defaultProps } from '../
|
|
2
|
+
import { defaultProps } from '../propTypes.js';
|
|
3
3
|
|
|
4
|
-
// we have to merge the "default" nested default values with what the user gives us...
|
|
5
4
|
const useGetDatePickerWithDefaultsProps = props => useMemoMergePropsWithDefault(props, defaultProps);
|
|
6
5
|
|
|
7
6
|
export { useGetDatePickerWithDefaultsProps };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useRef, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable complexity */
|
|
4
|
+
const useGetReferences = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
isWithDateInputs,
|
|
7
|
+
isWithTimeInputs,
|
|
8
|
+
withAnyPicker,
|
|
9
|
+
withClearBtn
|
|
10
|
+
} = _ref;
|
|
11
|
+
// refs are used for "auto-advance" feature
|
|
12
|
+
const monthInputRef = useRef(null);
|
|
13
|
+
const dayInputRef = useRef(null);
|
|
14
|
+
const yearInputRef = useRef(null);
|
|
15
|
+
const hourInputRef = useRef(null);
|
|
16
|
+
const minutesInputRef = useRef(null);
|
|
17
|
+
const meridiemInputRef = useRef(null);
|
|
18
|
+
const clearButtonRef = useRef(null);
|
|
19
|
+
const pickerButtonRef = useRef(null);
|
|
20
|
+
const prevYearBtnRef = useRef(null);
|
|
21
|
+
const prevMonthBtnRef = useRef(null);
|
|
22
|
+
const nextMonthBtnRef = useRef(null);
|
|
23
|
+
const nextYearBtnRef = useRef(null);
|
|
24
|
+
const calendarDaysWrapperRef = useRef(null);
|
|
25
|
+
const prevHourBtnRef = useRef(null);
|
|
26
|
+
const currHourBtnRef = useRef(null);
|
|
27
|
+
const nextHourBtnRef = useRef(null);
|
|
28
|
+
const prevMinutesBtnRef = useRef(null);
|
|
29
|
+
const currMinutesBtnRef = useRef(null);
|
|
30
|
+
const nextMinutesBtnRef = useRef(null);
|
|
31
|
+
const prevMeridiemBtnRef = useRef(null);
|
|
32
|
+
const currMeridiemBtnRef = useRef(null);
|
|
33
|
+
const nextMeridiemBtnRef = useRef(null);
|
|
34
|
+
let firstSegmentRef = useRef(null);
|
|
35
|
+
if (isWithDateInputs) firstSegmentRef = monthInputRef;else if (isWithTimeInputs) firstSegmentRef = hourInputRef;else if (withAnyPicker) firstSegmentRef = pickerButtonRef; // we need some non-ref to force refresh of the hooks dependencies when using firstSegmentRef
|
|
36
|
+
|
|
37
|
+
const firstFragmentRefUpdateDeps = useMemo(() => ({
|
|
38
|
+
isWithDateInputs,
|
|
39
|
+
isWithTimeInputs,
|
|
40
|
+
withAnyPicker
|
|
41
|
+
}), [isWithDateInputs, isWithTimeInputs, withAnyPicker]);
|
|
42
|
+
let lastSegmentRef = useRef(null);
|
|
43
|
+
if (withAnyPicker) lastSegmentRef = pickerButtonRef;else if (withClearBtn) lastSegmentRef = clearButtonRef;else if (isWithTimeInputs) lastSegmentRef = meridiemInputRef;else if (isWithDateInputs) lastSegmentRef = yearInputRef; // we need some non-ref to force refresh of the hooks dependencies when using lastSegmentRef
|
|
44
|
+
|
|
45
|
+
const lastFragmentRefUpdateDeps = useMemo(() => ({
|
|
46
|
+
withAnyPicker,
|
|
47
|
+
withClearBtn,
|
|
48
|
+
isWithTimeInputs,
|
|
49
|
+
isWithDateInputs
|
|
50
|
+
}), [isWithDateInputs, isWithTimeInputs, withAnyPicker, withClearBtn]);
|
|
51
|
+
return useMemo(() => ({
|
|
52
|
+
monthInputRef,
|
|
53
|
+
dayInputRef,
|
|
54
|
+
yearInputRef,
|
|
55
|
+
hourInputRef,
|
|
56
|
+
minutesInputRef,
|
|
57
|
+
meridiemInputRef,
|
|
58
|
+
clearButtonRef,
|
|
59
|
+
pickerButtonRef,
|
|
60
|
+
prevYearBtnRef,
|
|
61
|
+
prevMonthBtnRef,
|
|
62
|
+
nextMonthBtnRef,
|
|
63
|
+
nextYearBtnRef,
|
|
64
|
+
calendarDaysWrapperRef,
|
|
65
|
+
prevHourBtnRef,
|
|
66
|
+
currHourBtnRef,
|
|
67
|
+
nextHourBtnRef,
|
|
68
|
+
prevMinutesBtnRef,
|
|
69
|
+
currMinutesBtnRef,
|
|
70
|
+
nextMinutesBtnRef,
|
|
71
|
+
prevMeridiemBtnRef,
|
|
72
|
+
currMeridiemBtnRef,
|
|
73
|
+
nextMeridiemBtnRef,
|
|
74
|
+
firstSegmentRef,
|
|
75
|
+
lastSegmentRef,
|
|
76
|
+
firstFragmentRefUpdateDeps,
|
|
77
|
+
lastFragmentRefUpdateDeps
|
|
78
|
+
}), [firstFragmentRefUpdateDeps, lastFragmentRefUpdateDeps] // if we remove this last/first segment won't work
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { useGetReferences };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import { useCallback, useMemo } from 'react';
|
|
8
|
+
import { getDateStringFromDay, getTimeStringFromDay, getValidationDateStringMetaInfo } from '../utils/dateHelpers.js';
|
|
9
|
+
import { getValidationTimeStringMetaInfo } from '../utils/timeHelpers.js';
|
|
10
|
+
import { deconstructValuesFromDateString, deconstructValuesFromTimeString } from '../utils/stringHelpers.js';
|
|
11
|
+
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
+
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
+
const useGlobalKeyHandlers = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
propsBasedOnType,
|
|
18
|
+
changeHandlers,
|
|
19
|
+
DOMRefs,
|
|
20
|
+
flags
|
|
21
|
+
} = _ref;
|
|
22
|
+
const {
|
|
23
|
+
getIsOutOfRangeDay,
|
|
24
|
+
getIsDisabledDay,
|
|
25
|
+
getIsDisabledTime,
|
|
26
|
+
appOnMonthChange,
|
|
27
|
+
appOnDayChange,
|
|
28
|
+
appOnYearChange,
|
|
29
|
+
appOnHourChange,
|
|
30
|
+
appOnMinuteChange,
|
|
31
|
+
appOnMeridiemChange
|
|
32
|
+
} = propsBasedOnType;
|
|
33
|
+
const {
|
|
34
|
+
handleChangeComposedDateTimeString,
|
|
35
|
+
handleClearAll
|
|
36
|
+
} = changeHandlers;
|
|
37
|
+
const {
|
|
38
|
+
lastSegmentRef,
|
|
39
|
+
clearButtonRef
|
|
40
|
+
} = DOMRefs;
|
|
41
|
+
const {
|
|
42
|
+
shouldPreserveClearableSpace
|
|
43
|
+
} = flags;
|
|
44
|
+
const onFillWithCurrentDateKeys = useCallback(function (e) {
|
|
45
|
+
let metaInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
46
|
+
isAutomaticFillTrigger: true
|
|
47
|
+
};
|
|
48
|
+
const now = new Date();
|
|
49
|
+
const nowDateString = getDateStringFromDay(now);
|
|
50
|
+
const nowTimeString = getTimeStringFromDay(now);
|
|
51
|
+
|
|
52
|
+
const finalMetaInfo = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, metaInfo), getValidationDateStringMetaInfo(nowDateString, getIsOutOfRangeDay, getIsDisabledDay)), getValidationTimeStringMetaInfo(nowTimeString, getIsDisabledTime)), {}, {
|
|
53
|
+
newDateString: nowDateString
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
month,
|
|
58
|
+
day,
|
|
59
|
+
year
|
|
60
|
+
} = deconstructValuesFromDateString(nowDateString);
|
|
61
|
+
appOnMonthChange(month, e, metaInfo);
|
|
62
|
+
appOnDayChange(day, e, metaInfo);
|
|
63
|
+
appOnYearChange(year, e, metaInfo);
|
|
64
|
+
const {
|
|
65
|
+
hours,
|
|
66
|
+
minutes,
|
|
67
|
+
meridiem
|
|
68
|
+
} = deconstructValuesFromTimeString(nowTimeString);
|
|
69
|
+
appOnHourChange(hours, e, metaInfo);
|
|
70
|
+
appOnMinuteChange(minutes, e, metaInfo);
|
|
71
|
+
appOnMeridiemChange(meridiem, e, metaInfo);
|
|
72
|
+
handleChangeComposedDateTimeString(nowDateString, nowTimeString, finalMetaInfo);
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
var _clearButtonRef$curre, _lastSegmentRef$curre;
|
|
75
|
+
|
|
76
|
+
if (shouldPreserveClearableSpace) (_clearButtonRef$curre = clearButtonRef.current) === null || _clearButtonRef$curre === void 0 ? void 0 : _clearButtonRef$curre.focus();else (_lastSegmentRef$curre = lastSegmentRef.current) === null || _lastSegmentRef$curre === void 0 ? void 0 : _lastSegmentRef$curre.focus();
|
|
77
|
+
});
|
|
78
|
+
}, [appOnDayChange, appOnHourChange, appOnMeridiemChange, appOnMinuteChange, appOnMonthChange, appOnYearChange, clearButtonRef, getIsDisabledDay, getIsDisabledTime, getIsOutOfRangeDay, handleChangeComposedDateTimeString, lastSegmentRef, shouldPreserveClearableSpace]);
|
|
79
|
+
const onGlobalKeyDown = useCallback(e => {
|
|
80
|
+
const {
|
|
81
|
+
key,
|
|
82
|
+
ctrlKey,
|
|
83
|
+
metaKey
|
|
84
|
+
} = e;
|
|
85
|
+
|
|
86
|
+
if ((ctrlKey || metaKey) && key === ';') {
|
|
87
|
+
onFillWithCurrentDateKeys(e);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if ((ctrlKey || metaKey) && (key === 'Delete' || key === 'Backspace')) handleClearAll(e);
|
|
91
|
+
}, [handleClearAll, onFillWithCurrentDateKeys]);
|
|
92
|
+
return useMemo(() => ({
|
|
93
|
+
onFillWithCurrentDateKeys,
|
|
94
|
+
onGlobalKeyDown
|
|
95
|
+
}), [onFillWithCurrentDateKeys, onGlobalKeyDown]);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { useGlobalKeyHandlers };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
|
+
import { getIsDateTime, getIsDate, getIsTime } from '../utils/typeGuards.js';
|
|
4
|
+
import { dateTimeToDate, dateTimeToTime } from '../utils/stringHelpers.js';
|
|
5
|
+
|
|
6
|
+
const useRelevantValueFromProps = props => {
|
|
7
|
+
const dateStringFromProps = useMemo(() => {
|
|
8
|
+
if (getIsDateTime(props)) return props.dateTime !== '' ? dateTimeToDate(props.dateTime) : '__/__/____';
|
|
9
|
+
if (getIsDate(props)) return props.date !== '' ? props.date : '__/__/____';
|
|
10
|
+
return '__/__/____';
|
|
11
|
+
}, [props]);
|
|
12
|
+
const timeStringFromProps = useMemo(() => {
|
|
13
|
+
if (getIsDateTime(props)) return props.dateTime !== '' ? dateTimeToTime(props.dateTime) : '__:__ __';
|
|
14
|
+
if (getIsTime(props)) return props.time !== '' ? props.time : '__:__ __';
|
|
15
|
+
return '__:__ __';
|
|
16
|
+
}, [props]); // don't use tempDateString to trigger useEffect for onDateChange
|
|
17
|
+
// that is an anti-pattern and leads to a lot of issue
|
|
18
|
+
// if you don't believe me, check date-time-picker v1 which is doing it
|
|
19
|
+
|
|
20
|
+
const [tempDateString, setTempDateString] = useState(dateStringFromProps); // don't use tempTimeString to trigger useEffect for onTimeChange
|
|
21
|
+
// that is an anti-pattern and leads to a lot of issue
|
|
22
|
+
// if you don't believe me, check date-time-picker v1 which is doing it
|
|
23
|
+
|
|
24
|
+
const [tempTimeString, setTimeString] = useState(timeStringFromProps);
|
|
25
|
+
return useMemo(() => ({
|
|
26
|
+
dateStringFromProps,
|
|
27
|
+
timeStringFromProps,
|
|
28
|
+
tempDateString,
|
|
29
|
+
setTempDateString,
|
|
30
|
+
tempTimeString,
|
|
31
|
+
setTimeString
|
|
32
|
+
}), [dateStringFromProps, tempDateString, tempTimeString, timeStringFromProps]);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { useRelevantValueFromProps };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CONTROLLED_DATE_TIME_PICKER_TYPES } from '../ControlledDateTimePickerTypes.js';
|
|
2
1
|
import { deconstructValuesFromDateString, isValidDateString, dateTimeToDate, isValidTimeString, dateTimeToTime } from '../utils/stringHelpers.js';
|
|
3
2
|
import { convertToPositiveNumberIfPossible } from '../utils/numberHelpers.js';
|
|
3
|
+
import { getIsDateTime, getIsDate, getIsTime } from '../utils/typeGuards.js';
|
|
4
4
|
|
|
5
|
-
/* eslint-disable max-
|
|
5
|
+
/* eslint-disable max-statements */
|
|
6
6
|
const PREPEND = "ControlledDateTimePicker:\n Invalid configuration detected::\n \n ";
|
|
7
7
|
const NOT_A_DEFECT = ''; // '\n\n\t\tThis is not a defect, please check\n\n\t\thttps://qa.dimsum.rd.elliemae.io/?path=/story/components-desktop-components-d-controlledform-date-time-picker--basic\n\n\t\tfor instructions on how to use the component correctly\n\n';
|
|
8
8
|
|
|
@@ -21,15 +21,15 @@ const throwInvalidTimerror = invalidValue => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const throwUncontrolledDateError = (date, onDateChange) => {
|
|
24
|
-
throw new Error("".concat(PREPEND, "you are trying to use a date selector while providing a non-string \"date\" or providing a non-function to \"onDateChange\"\n the full-controlled pattern must be used\n\tcheck https://reactjs.org/docs/forms.html#controlled-components for more informations\n\n Received:\n ").concat(date, "(").concat(typeof date, ")\n
|
|
24
|
+
throw new Error("".concat(PREPEND, "you are trying to use a date selector while providing a non-string \"date\" or providing a non-function to \"onDateChange\"\n the full-controlled pattern must be used\n\tcheck https://reactjs.org/docs/forms.html#controlled-components for more informations\n\n Received:\n date: ").concat(date, "(").concat(typeof date, ")\n onDateChange: (").concat(typeof onDateChange, ")\n ").concat(NOT_A_DEFECT));
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const throwUncontrolledTimeError = (time, onTimeChange) => {
|
|
28
|
-
throw new Error("".concat(PREPEND, "you are trying to use a time selector while providing a non-string \"time\" or providing a non-function to \"onTimeChange\"\n the full-controlled pattern must be used\n\tcheck https://reactjs.org/docs/forms.html#controlled-components for more informations\n\n Received:\n ").concat(time, "(").concat(typeof time, ")\n
|
|
28
|
+
throw new Error("".concat(PREPEND, "you are trying to use a time selector while providing a non-string \"time\" or providing a non-function to \"onTimeChange\"\n the full-controlled pattern must be used\n\tcheck https://reactjs.org/docs/forms.html#controlled-components for more informations\n\n Received:\n time: ").concat(time, "(").concat(typeof time, ")\n onTimeChange: (").concat(typeof onTimeChange, ")\n ").concat(NOT_A_DEFECT));
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const throwUncontrolledDateTimeError = (dateTime, onDateTimeChange) => {
|
|
32
|
-
throw new Error("".concat(PREPEND, "you are trying to use a date-time selector while providing a non-string \"dateTime\" or providing a non-function to \"onDateTimeChange\"\n the full-controlled pattern must be used\n\tcheck https://reactjs.org/docs/forms.html#controlled-components for more informations\n\n Received:\n ").concat(dateTime, "(").concat(typeof dateTime, ")\n
|
|
32
|
+
throw new Error("".concat(PREPEND, "you are trying to use a date-time selector while providing a non-string \"dateTime\" or providing a non-function to \"onDateTimeChange\"\n the full-controlled pattern must be used\n\tcheck https://reactjs.org/docs/forms.html#controlled-components for more informations\n\n Received:\n dateTime: ").concat(dateTime, "(").concat(typeof dateTime, ")\n onDateTimeChange: (").concat(typeof onDateTimeChange, ")\n ").concat(NOT_A_DEFECT));
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const throwInvalidEmptyPickerStartingMonthError = emptyPickerStartingMonth => {
|
|
@@ -41,55 +41,60 @@ const throwInvalidOnCalendarOpenFocusedDayError = onCalendarOpenFocusedDay => {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
const useValidateProps = props => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
dateTime,
|
|
47
|
-
date,
|
|
48
|
-
time,
|
|
49
|
-
onDateChange,
|
|
50
|
-
onTimeChange,
|
|
51
|
-
onDateTimeChange,
|
|
52
|
-
emptyPickerStartingMonth,
|
|
53
|
-
onCalendarOpenFocusedDay
|
|
54
|
-
} = props;
|
|
55
|
-
const isDateSelector = type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE.FULL || type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE.INPUTS || type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE.PICKER;
|
|
56
|
-
const isTimeSelector = type === CONTROLLED_DATE_TIME_PICKER_TYPES.TIME.FULL || type === CONTROLLED_DATE_TIME_PICKER_TYPES.TIME.INPUTS || type === CONTROLLED_DATE_TIME_PICKER_TYPES.TIME.PICKER;
|
|
57
|
-
const isDateTimeSelector = type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE_TIME.FULL || type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE_TIME.INPUTS || type === CONTROLLED_DATE_TIME_PICKER_TYPES.DATE_TIME.PICKER; // validate generic use-cases
|
|
58
|
-
|
|
59
|
-
if (emptyPickerStartingMonth) {
|
|
44
|
+
// validate date-related props
|
|
45
|
+
if (getIsDateTime(props) || getIsDate(props)) {
|
|
60
46
|
const {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
} =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
47
|
+
emptyPickerStartingMonth,
|
|
48
|
+
onCalendarOpenFocusedDay
|
|
49
|
+
} = props; // validate generic use-cases
|
|
50
|
+
|
|
51
|
+
if (emptyPickerStartingMonth) {
|
|
52
|
+
const {
|
|
53
|
+
month: stringMonthVal,
|
|
54
|
+
year: stringYearVal
|
|
55
|
+
} = deconstructValuesFromDateString(emptyPickerStartingMonth);
|
|
56
|
+
const monthNum = convertToPositiveNumberIfPossible(stringMonthVal);
|
|
57
|
+
const yearNum = convertToPositiveNumberIfPossible(stringYearVal);
|
|
58
|
+
if (monthNum <= 0 || monthNum >= 13 || yearNum <= 0 || yearNum > 9999) throwInvalidEmptyPickerStartingMonthError(emptyPickerStartingMonth);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (onCalendarOpenFocusedDay) {
|
|
62
|
+
const {
|
|
63
|
+
month: stringMonthVal,
|
|
64
|
+
day: stringDayVal,
|
|
65
|
+
year: stringYearVal
|
|
66
|
+
} = deconstructValuesFromDateString(onCalendarOpenFocusedDay);
|
|
67
|
+
const monthNum = convertToPositiveNumberIfPossible(stringMonthVal);
|
|
68
|
+
const dayNum = convertToPositiveNumberIfPossible(stringDayVal);
|
|
69
|
+
const yearNum = convertToPositiveNumberIfPossible(stringYearVal);
|
|
70
|
+
if (monthNum <= 0 || monthNum >= 13 || dayNum <= 0 || dayNum >= 31 || yearNum <= 0 || yearNum > 9999) throwInvalidOnCalendarOpenFocusedDayError(onCalendarOpenFocusedDay);
|
|
71
|
+
}
|
|
79
72
|
} // validate full datetime cases
|
|
80
73
|
|
|
81
74
|
|
|
82
|
-
if (
|
|
75
|
+
if (getIsDateTime(props)) {
|
|
76
|
+
const {
|
|
77
|
+
dateTime,
|
|
78
|
+
onDateTimeChange
|
|
79
|
+
} = props;
|
|
83
80
|
if (typeof dateTime !== 'string' || typeof onDateTimeChange !== 'function') throwUncontrolledDateTimeError(dateTime, onDateTimeChange);else if (!isValidDateString(dateTimeToDate(dateTime)) || !isValidTimeString(dateTimeToTime(dateTime))) throwInvalidDateTimeError(dateTimeToTime(dateTime));
|
|
84
81
|
} // validate date-only cases
|
|
85
82
|
|
|
86
83
|
|
|
87
|
-
if (
|
|
84
|
+
if (getIsDate(props)) {
|
|
85
|
+
const {
|
|
86
|
+
date,
|
|
87
|
+
onDateChange
|
|
88
|
+
} = props;
|
|
88
89
|
if (typeof date !== 'string' || typeof onDateChange !== 'function') throwUncontrolledDateError(date, onDateChange);else if (!isValidDateString(date)) throwInvalidDaterror(date);
|
|
89
90
|
} // validate time-only cases
|
|
90
91
|
|
|
91
92
|
|
|
92
|
-
if (
|
|
93
|
+
if (getIsTime(props)) {
|
|
94
|
+
const {
|
|
95
|
+
time,
|
|
96
|
+
onTimeChange
|
|
97
|
+
} = props;
|
|
93
98
|
if (typeof time !== 'string' || typeof onTimeChange !== 'function') throwUncontrolledTimeError(time, onTimeChange);else if (!isValidTimeString(time)) throwInvalidTimerror(time);
|
|
94
99
|
}
|
|
95
100
|
};
|