@elliemae/ds-controlled-form 2.4.2-rc.1 → 2.4.2-rc.13
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/config/useAutocomplete.js +0 -1
- package/cjs/autocomplete/parts/A11yFocusedOption.js +46 -0
- package/cjs/autocomplete/parts/container/Container.js +36 -24
- package/cjs/autocomplete/parts/container/styled.js +2 -2
- package/cjs/autocomplete/parts/container/useKeyboardNavigation.js +2 -2
- package/cjs/autocomplete/parts/menu-list/MenuList.js +6 -6
- package/cjs/autocomplete/parts/menu-list/styled.js +2 -2
- package/cjs/autocomplete/parts/menu-list/useItemRenderer.js +1 -1
- package/cjs/autocomplete/parts/styled.js +2 -0
- package/cjs/autocomplete/utils/listHelper.js +1 -1
- package/cjs/checkbox/ControlledCheckbox.js +1 -1
- package/cjs/checkbox/config/useValidateProps.js +6 -3
- package/cjs/checkbox/react-desc-prop-types.js +2 -1
- package/cjs/checkbox/styles.js +73 -27
- package/cjs/checkbox/utils/styleHelpers.js +20 -2
- package/cjs/combobox/ComboBoxCTX.js +6 -3
- package/cjs/combobox/config/useComboBox.js +16 -6
- package/cjs/combobox/config/useCorrectOptions.js +1 -2
- package/cjs/combobox/parts/A11yFocusedOption.js +14 -6
- package/cjs/combobox/parts/A11ySelectedValues.js +2 -4
- package/cjs/combobox/parts/DropdownIndicator.js +15 -7
- package/cjs/combobox/parts/container/Container.js +11 -14
- package/cjs/combobox/parts/container/styled.js +11 -10
- package/cjs/combobox/parts/controls/Controls.js +19 -27
- package/cjs/combobox/parts/controls/styled.js +54 -22
- package/cjs/combobox/parts/controls/useOnPillsNavigation.js +7 -15
- package/cjs/combobox/parts/controls-input/ControlsInput.js +2 -2
- package/cjs/combobox/parts/controls-input/styled.js +41 -11
- package/cjs/combobox/parts/controls-input/useControlsInput.js +4 -7
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +19 -28
- package/cjs/combobox/parts/controls-input/useMaskedOnChange.js +7 -7
- package/cjs/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/cjs/combobox/parts/header-list/HeaderList.js +1 -1
- package/cjs/combobox/parts/header-list/styled.js +39 -10
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +7 -14
- package/cjs/combobox/parts/menu-list/MenuList.js +8 -6
- package/cjs/combobox/parts/menu-list/styled.js +38 -20
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +18 -17
- package/cjs/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/cjs/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +1 -3
- package/cjs/combobox/parts/multi-selected-values-container/useGroupPills.js +1 -2
- package/cjs/combobox/parts/styled.js +6 -7
- package/cjs/combobox/react-desc-prop-types.js +3 -2
- package/cjs/combobox/sharedTypes.js +2 -2
- package/cjs/combobox/utils/listHelper.js +14 -9
- package/cjs/date-range-picker/config/useRangePickerLogic.js +4 -8
- package/cjs/date-range-picker/parts/ControlledDateRangeCalendar.js +0 -2
- package/cjs/date-range-picker/parts/ControlledDateRangeFromDate.js +0 -2
- package/cjs/date-range-picker/parts/ControlledDateRangeToDate.js +0 -2
- package/cjs/date-time-picker/config/useChangeHandlers.js +11 -15
- package/cjs/date-time-picker/config/useControlledDateTimePicker.js +14 -10
- package/cjs/date-time-picker/config/useFocusTracker.js +136 -0
- package/cjs/date-time-picker/config/useGetDestructuredValues.js +6 -6
- package/cjs/date-time-picker/config/useGetPropsBasedOnType.js +1 -1
- package/cjs/date-time-picker/config/useGetReferences.js +39 -18
- package/cjs/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
- package/cjs/date-time-picker/config/useRelevantValueFromProps.js +1 -1
- package/cjs/date-time-picker/config/useValidateProps.js +42 -11
- package/cjs/date-time-picker/parts/ClearButton/ClearButton.js +10 -2
- package/cjs/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
- package/cjs/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
- package/cjs/date-time-picker/parts/DateInputs/DDInput.js +8 -6
- package/cjs/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
- package/cjs/date-time-picker/parts/DateInputs/MMInput.js +8 -6
- package/cjs/date-time-picker/parts/DateInputs/YYYYInput.js +8 -6
- package/cjs/date-time-picker/parts/DateInputs/useDateInputs.js +84 -113
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +25 -7
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +1 -1
- package/cjs/date-time-picker/parts/Pickers/Calendar/Day.js +21 -17
- package/cjs/date-time-picker/parts/Pickers/Calendar/Styleds.js +44 -15
- package/cjs/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +13 -14
- package/cjs/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +2 -1
- package/cjs/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +2 -39
- package/cjs/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
- package/cjs/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -29
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +2 -1
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +19 -27
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +15 -11
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +17 -13
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +15 -11
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/SecondsList.js +2 -2
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/Styleds.js +47 -15
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +1 -1
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +1 -1
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +3 -3
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +12 -17
- package/cjs/date-time-picker/parts/Styleds.js +12 -6
- package/cjs/date-time-picker/parts/TimeInputs/HHInput.js +7 -3
- package/cjs/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -7
- package/cjs/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -6
- package/cjs/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
- package/cjs/date-time-picker/parts/TimeInputs/useTimeInputs.js +55 -97
- package/cjs/date-time-picker/utils/constants.js +0 -12
- package/cjs/date-time-picker/utils/dateHelpers.js +17 -34
- package/cjs/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
- package/cjs/date-time-picker/utils/hooks/useOnClickOutside.js +1 -3
- package/cjs/date-time-picker/utils/stringHelpers.js +5 -11
- package/cjs/input-group/InputGroup.js +8 -7
- package/cjs/input-group/exported-related/data-test-ids.js +12 -0
- package/cjs/input-group/exported-related/index.js +12 -0
- package/cjs/input-group/exported-related/theming.js +13 -0
- package/cjs/input-group/styled.js +90 -23
- package/cjs/large-text-input/DSControlledLargeTextInput.js +1 -1
- package/cjs/large-text-input/styles.js +27 -13
- package/cjs/mask-hook/hooks/useNumberMask.js +1 -5
- package/cjs/mask-hook/hooks/usePhoneMask.js +1 -4
- package/cjs/mask-hook/hooks/useRegExpMask.js +4 -7
- package/cjs/mask-hook/hooks/useSSNMask.js +1 -4
- package/cjs/mask-hook/hooks/useZipCodeMask.js +1 -4
- package/cjs/mask-hook/utils/addSpecialCharacters.js +0 -1
- package/cjs/mask-hook/utils/flatStringArray.js +0 -1
- package/cjs/text-input/config/useInputText.js +0 -1
- package/cjs/text-input/styled/borders.js +18 -11
- package/cjs/text-input/styled/components.js +49 -10
- package/cjs/toggle/ControlledToggle.js +2 -3
- package/cjs/toggle/styles.js +7 -5
- package/esm/autocomplete/config/useAutocomplete.js +0 -1
- package/esm/autocomplete/parts/A11yFocusedOption.js +36 -0
- package/esm/autocomplete/parts/container/Container.js +39 -27
- package/esm/autocomplete/parts/container/styled.js +2 -2
- package/esm/autocomplete/parts/container/useKeyboardNavigation.js +2 -2
- package/esm/autocomplete/parts/menu-list/MenuList.js +7 -7
- package/esm/autocomplete/parts/menu-list/styled.js +2 -2
- package/esm/autocomplete/parts/menu-list/useItemRenderer.js +1 -1
- package/esm/autocomplete/parts/styled.js +1 -0
- package/esm/autocomplete/utils/listHelper.js +1 -1
- package/esm/checkbox/ControlledCheckbox.js +2 -2
- package/esm/checkbox/config/useValidateProps.js +6 -3
- package/esm/checkbox/react-desc-prop-types.js +2 -1
- package/esm/checkbox/styles.js +73 -24
- package/esm/checkbox/utils/styleHelpers.js +20 -2
- package/esm/combobox/ComboBoxCTX.js +6 -3
- package/esm/combobox/config/useComboBox.js +16 -6
- package/esm/combobox/config/useCorrectOptions.js +1 -2
- package/esm/combobox/parts/A11yFocusedOption.js +15 -7
- package/esm/combobox/parts/A11ySelectedValues.js +2 -4
- package/esm/combobox/parts/DropdownIndicator.js +15 -6
- package/esm/combobox/parts/container/Container.js +11 -14
- package/esm/combobox/parts/container/styled.js +11 -6
- package/esm/combobox/parts/controls/Controls.js +19 -27
- package/esm/combobox/parts/controls/styled.js +54 -18
- package/esm/combobox/parts/controls/useOnPillsNavigation.js +7 -15
- package/esm/combobox/parts/controls-input/ControlsInput.js +2 -2
- package/esm/combobox/parts/controls-input/styled.js +41 -7
- package/esm/combobox/parts/controls-input/useControlsInput.js +4 -7
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +20 -29
- package/esm/combobox/parts/controls-input/useMaskedOnChange.js +7 -7
- package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/header-list/HeaderList.js +1 -1
- package/esm/combobox/parts/header-list/styled.js +40 -7
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +7 -14
- package/esm/combobox/parts/menu-list/MenuList.js +8 -6
- package/esm/combobox/parts/menu-list/styled.js +38 -17
- package/esm/combobox/parts/menu-list/useItemRenderer.js +20 -19
- package/esm/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/esm/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +1 -3
- package/esm/combobox/parts/multi-selected-values-container/useGroupPills.js +1 -2
- package/esm/combobox/parts/styled.js +6 -3
- package/esm/combobox/react-desc-prop-types.js +3 -2
- package/esm/combobox/sharedTypes.js +2 -2
- package/esm/combobox/utils/listHelper.js +14 -10
- package/esm/date-range-picker/config/useRangePickerLogic.js +3 -7
- package/esm/date-range-picker/parts/ControlledDateRangeCalendar.js +0 -2
- package/esm/date-range-picker/parts/ControlledDateRangeFromDate.js +0 -2
- package/esm/date-range-picker/parts/ControlledDateRangeToDate.js +0 -2
- package/esm/date-time-picker/config/useChangeHandlers.js +11 -15
- package/esm/date-time-picker/config/useControlledDateTimePicker.js +14 -10
- package/esm/date-time-picker/config/useFocusTracker.js +132 -0
- package/esm/date-time-picker/config/useGetDestructuredValues.js +6 -6
- package/esm/date-time-picker/config/useGetPropsBasedOnType.js +1 -1
- package/esm/date-time-picker/config/useGetReferences.js +40 -19
- package/esm/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
- package/esm/date-time-picker/config/useRelevantValueFromProps.js +1 -1
- package/esm/date-time-picker/config/useValidateProps.js +42 -11
- package/esm/date-time-picker/parts/ClearButton/ClearButton.js +10 -2
- package/esm/date-time-picker/parts/ClearButton/useClearButton.js +12 -25
- package/esm/date-time-picker/parts/ControlledDateTimePickerContent.js +4 -7
- package/esm/date-time-picker/parts/DateInputs/DDInput.js +8 -6
- package/esm/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
- package/esm/date-time-picker/parts/DateInputs/MMInput.js +8 -6
- package/esm/date-time-picker/parts/DateInputs/YYYYInput.js +8 -6
- package/esm/date-time-picker/parts/DateInputs/useDateInputs.js +85 -114
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +26 -8
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +1 -1
- package/esm/date-time-picker/parts/Pickers/Calendar/Day.js +21 -17
- package/esm/date-time-picker/parts/Pickers/Calendar/Styleds.js +44 -14
- package/esm/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +12 -13
- package/esm/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +2 -1
- package/esm/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +3 -40
- package/esm/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
- package/esm/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -29
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +2 -1
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +19 -27
- package/esm/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +16 -12
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +18 -14
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +16 -12
- package/esm/date-time-picker/parts/Pickers/TimeWheel/SecondsList.js +2 -2
- package/esm/date-time-picker/parts/Pickers/TimeWheel/Styleds.js +47 -14
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +1 -1
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +1 -1
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +3 -3
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
- package/esm/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +12 -17
- package/esm/date-time-picker/parts/Styleds.js +12 -6
- package/esm/date-time-picker/parts/TimeInputs/HHInput.js +7 -3
- package/esm/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -7
- package/esm/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -6
- package/esm/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
- package/esm/date-time-picker/parts/TimeInputs/useTimeInputs.js +55 -97
- package/esm/date-time-picker/utils/constants.js +1 -7
- package/esm/date-time-picker/utils/dateHelpers.js +17 -34
- package/esm/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
- package/esm/date-time-picker/utils/hooks/useOnClickOutside.js +1 -3
- package/esm/date-time-picker/utils/stringHelpers.js +5 -11
- package/esm/input-group/InputGroup.js +5 -4
- package/esm/input-group/exported-related/data-test-ids.js +8 -0
- package/esm/input-group/exported-related/index.js +2 -0
- package/esm/input-group/exported-related/theming.js +8 -0
- package/esm/input-group/styled.js +89 -18
- package/esm/large-text-input/DSControlledLargeTextInput.js +1 -1
- package/esm/large-text-input/styles.js +27 -9
- package/esm/mask-hook/hooks/useNumberMask.js +1 -5
- package/esm/mask-hook/hooks/usePhoneMask.js +1 -4
- package/esm/mask-hook/hooks/useRegExpMask.js +4 -7
- package/esm/mask-hook/hooks/useSSNMask.js +1 -4
- package/esm/mask-hook/hooks/useZipCodeMask.js +1 -4
- package/esm/mask-hook/utils/addSpecialCharacters.js +0 -1
- package/esm/mask-hook/utils/flatStringArray.js +0 -1
- package/esm/text-input/config/useInputText.js +0 -1
- package/esm/text-input/styled/borders.js +18 -7
- package/esm/text-input/styled/components.js +49 -6
- package/esm/toggle/ControlledToggle.js +0 -1
- package/esm/toggle/styles.js +7 -5
- package/package.json +39 -15
- package/types/autocomplete/parts/A11yFocusedOption.d.ts +5 -0
- package/types/autocomplete/parts/container/styled.d.ts +1 -1
- package/types/autocomplete/parts/styled.d.ts +0 -0
- package/types/autocomplete/utils/listHelper.d.ts +5 -5
- package/types/checkbox/react-desc-prop-types.d.ts +1 -1
- package/types/checkbox/styles.d.ts +1 -0
- package/types/combobox/parts/menu-list/styled.d.ts +1 -0
- package/types/combobox/react-desc-prop-types.d.ts +8 -6
- package/types/combobox/sharedTypes.d.ts +3 -2
- package/types/combobox/utils/listHelper.d.ts +1 -0
- package/types/date-time-picker/config/useChangeHandlers.d.ts +3 -1
- package/types/date-time-picker/config/useControlledDateTimePicker.d.ts +2 -5
- package/types/date-time-picker/config/useFocusTracker.d.ts +38 -0
- package/types/date-time-picker/config/useGetPropsBasedOnType.d.ts +6 -6
- package/types/date-time-picker/config/useGetReferences.d.ts +30 -36
- package/types/date-time-picker/config/useGlobalKeyHandlers.d.ts +3 -1
- package/types/date-time-picker/parts/DateInputs/DDInput.d.ts +2 -1
- package/types/date-time-picker/parts/DateInputs/MMInput.d.ts +2 -1
- package/types/date-time-picker/parts/DateInputs/YYYYInput.d.ts +2 -1
- package/types/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.d.ts +14 -0
- package/types/date-time-picker/parts/Pickers/Calendar/useFocusLogic.d.ts +1 -2
- package/types/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.d.ts +19 -0
- package/types/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.d.ts +0 -6
- package/types/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.d.ts +14 -0
- package/types/date-time-picker/parts/TimeInputs/HHInput.d.ts +2 -1
- package/types/date-time-picker/parts/TimeInputs/MeridiemInput.d.ts +2 -1
- package/types/date-time-picker/parts/TimeInputs/MinutesInput.d.ts +2 -1
- package/types/date-time-picker/propTypes.d.ts +117 -0
- package/types/date-time-picker/sharedTypes.d.ts +1 -1
- package/types/date-time-picker/utils/constants.d.ts +0 -6
- package/types/input-group/exported-related/data-test-ids.d.ts +6 -0
- package/types/input-group/exported-related/index.d.ts +2 -0
- package/types/input-group/exported-related/theming.d.ts +6 -0
- package/types/input-group/styled.d.ts +4 -7
- package/types/text-input/config/useInputText.d.ts +4 -4
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useContext, useCallback, useMemo } from 'react';
|
|
2
2
|
import { ControlledDateTimePickerContext } from '../../ControlledDateTimePickerCTX.js';
|
|
3
|
-
import { homeEndArrowUpDownSemiKeys, homeEndArrowUpDownSpaceKeys, homeEndArrowUpDownKeys } from '../../utils/constants.js';
|
|
4
3
|
import { prependStringWithPlaceHolders } from '../../utils/stringHelpers.js';
|
|
5
4
|
|
|
6
5
|
/* eslint-disable complexity */
|
|
@@ -9,66 +8,53 @@ const useTimeInputs = () => {
|
|
|
9
8
|
props: {
|
|
10
9
|
disabled
|
|
11
10
|
},
|
|
12
|
-
lastSegmentRef,
|
|
13
11
|
hours,
|
|
14
12
|
minutes,
|
|
15
13
|
meridiem,
|
|
16
|
-
hideDate,
|
|
17
14
|
withAnyRightController,
|
|
18
15
|
withAnyPicker,
|
|
19
16
|
withClearBtn,
|
|
20
17
|
isWithDateInputs,
|
|
21
|
-
hourInputRef,
|
|
22
|
-
minutesInputRef,
|
|
23
|
-
meridiemInputRef,
|
|
24
|
-
yearInputRef,
|
|
25
|
-
clearButtonRef,
|
|
26
|
-
pickerButtonRef,
|
|
27
|
-
monthInputRef,
|
|
28
18
|
autoFocusHourInput,
|
|
29
19
|
handleChangeHours,
|
|
30
20
|
handleChangeMinutes,
|
|
31
21
|
handleChangeMeridiem,
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
minutesInterval,
|
|
23
|
+
trackFocusFirstSegment,
|
|
24
|
+
trackFocusLastSegment,
|
|
25
|
+
trackFocusHourInput,
|
|
26
|
+
trackFocusMinuteInput,
|
|
27
|
+
trackFocusMeridiemInput,
|
|
28
|
+
trackFocusClearBtn,
|
|
29
|
+
trackFocusPicker,
|
|
30
|
+
trackFocusYearInput
|
|
34
31
|
} = useContext(ControlledDateTimePickerContext);
|
|
35
|
-
const setLatestInteractionRegionTimeInputs = useCallback(() => {
|
|
36
|
-
setLatestInteractionRegion('time-inputs');
|
|
37
|
-
}, [setLatestInteractionRegion]);
|
|
38
32
|
const onHomeKeyDown = useCallback(() => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!hideDate) monthInputRef === null || monthInputRef === void 0 ? void 0 : (_monthInputRef$curren = monthInputRef.current) === null || _monthInputRef$curren === void 0 ? void 0 : (_monthInputRef$curren2 = _monthInputRef$curren.focus) === null || _monthInputRef$curren2 === void 0 ? void 0 : _monthInputRef$curren2.call(_monthInputRef$curren);else hourInputRef === null || hourInputRef === void 0 ? void 0 : (_hourInputRef$current = hourInputRef.current) === null || _hourInputRef$current === void 0 ? void 0 : (_hourInputRef$current2 = _hourInputRef$current.focus) === null || _hourInputRef$current2 === void 0 ? void 0 : _hourInputRef$current2.call(_hourInputRef$current);
|
|
42
|
-
}, [hideDate, monthInputRef, hourInputRef]);
|
|
33
|
+
trackFocusFirstSegment();
|
|
34
|
+
}, [trackFocusFirstSegment]);
|
|
43
35
|
const onEndKeyDown = useCallback(() => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (withAnyPicker) pickerButtonRef === null || pickerButtonRef === void 0 ? void 0 : (_pickerButtonRef$curr = pickerButtonRef.current) === null || _pickerButtonRef$curr === void 0 ? void 0 : (_pickerButtonRef$curr2 = _pickerButtonRef$curr.focus) === null || _pickerButtonRef$curr2 === void 0 ? void 0 : _pickerButtonRef$curr2.call(_pickerButtonRef$curr);else if (withClearBtn) clearButtonRef === null || clearButtonRef === void 0 ? void 0 : (_clearButtonRef$curre = clearButtonRef.current) === null || _clearButtonRef$curre === void 0 ? void 0 : (_clearButtonRef$curre2 = _clearButtonRef$curre.focus) === null || _clearButtonRef$curre2 === void 0 ? void 0 : _clearButtonRef$curre2.call(_clearButtonRef$curre);else meridiemInputRef === null || meridiemInputRef === void 0 ? void 0 : (_meridiemInputRef$cur = meridiemInputRef.current) === null || _meridiemInputRef$cur === void 0 ? void 0 : (_meridiemInputRef$cur2 = _meridiemInputRef$cur.focus) === null || _meridiemInputRef$cur2 === void 0 ? void 0 : _meridiemInputRef$cur2.call(_meridiemInputRef$cur);
|
|
47
|
-
}, [withAnyPicker, pickerButtonRef, withClearBtn, clearButtonRef, meridiemInputRef]);
|
|
36
|
+
trackFocusLastSegment();
|
|
37
|
+
}, [trackFocusLastSegment]);
|
|
48
38
|
const onHoursFocus = useCallback(() => {
|
|
49
|
-
|
|
50
|
-
}, [
|
|
39
|
+
trackFocusHourInput();
|
|
40
|
+
}, [trackFocusHourInput]);
|
|
51
41
|
const onHoursChange = useCallback(e => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
let newHours = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value; // converts hours 2~9 to 07~09
|
|
42
|
+
let newHours = e?.target?.value; // converts hours 2~9 to 07~09
|
|
55
43
|
|
|
56
44
|
if (Number.parseInt(newHours, 10) > 1) newHours = prependStringWithPlaceHolders(newHours, 2);
|
|
57
45
|
handleChangeHours(newHours, e); // auto-advance functionality:
|
|
58
46
|
|
|
59
|
-
if (newHours.length === 2)
|
|
60
|
-
}, [
|
|
47
|
+
if (newHours.length === 2) trackFocusMinuteInput();
|
|
48
|
+
}, [handleChangeHours, trackFocusMinuteInput]);
|
|
61
49
|
const onHoursKeyDown = useCallback(e => {
|
|
62
|
-
var _lastSegmentRef$curre, _lastSegmentRef$curre2;
|
|
63
|
-
|
|
64
50
|
const {
|
|
65
51
|
key,
|
|
66
52
|
ctrlKey,
|
|
67
53
|
metaKey
|
|
68
54
|
} = e;
|
|
69
55
|
const hoursStringConvertedToInteger = Number.parseInt(hours, 10);
|
|
70
|
-
if (
|
|
71
|
-
if (
|
|
56
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', ':'].includes(key)) e.preventDefault();
|
|
57
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', ':'].includes(key)) e.stopPropagation();
|
|
72
58
|
if (key === 'Home') onHomeKeyDown();
|
|
73
59
|
if (key === 'End') onEndKeyDown();
|
|
74
60
|
|
|
@@ -76,33 +62,27 @@ const useTimeInputs = () => {
|
|
|
76
62
|
const hoursInteger = Number.isNaN(hoursStringConvertedToInteger) ? 0 : hoursStringConvertedToInteger;
|
|
77
63
|
let newHours;
|
|
78
64
|
if (key === 'ArrowUp') newHours = hoursInteger + 1 <= 12 ? hoursInteger + 1 : hoursInteger;else newHours = hoursInteger - 1 > 1 ? hoursInteger - 1 : 1;
|
|
79
|
-
newHours = prependStringWithPlaceHolders(
|
|
65
|
+
newHours = prependStringWithPlaceHolders(`${newHours}`, 2);
|
|
80
66
|
handleChangeHours(newHours, e);
|
|
81
67
|
}
|
|
82
68
|
|
|
83
69
|
if (!Number.isNaN(hoursStringConvertedToInteger) && key === ':') {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const newHours = prependStringWithPlaceHolders("".concat(hoursStringConvertedToInteger), 2);
|
|
70
|
+
const newHours = prependStringWithPlaceHolders(`${hoursStringConvertedToInteger}`, 2);
|
|
87
71
|
handleChangeHours(newHours, e); // auto-advance functionality:
|
|
88
72
|
|
|
89
|
-
if (newHours.length === 2)
|
|
73
|
+
if (newHours.length === 2) trackFocusMinuteInput();
|
|
90
74
|
} // regressive backspace functionality
|
|
91
75
|
|
|
92
76
|
|
|
93
77
|
if (key === 'Backspace' && hours.length === 0 && isWithDateInputs) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
yearInputRef === null || yearInputRef === void 0 ? void 0 : (_yearInputRef$current = yearInputRef.current) === null || _yearInputRef$current === void 0 ? void 0 : (_yearInputRef$current2 = _yearInputRef$current.focus) === null || _yearInputRef$current2 === void 0 ? void 0 : _yearInputRef$current2.call(_yearInputRef$current);
|
|
78
|
+
trackFocusYearInput();
|
|
97
79
|
} // focus last fragment on fill with now
|
|
98
80
|
|
|
99
81
|
|
|
100
|
-
if ((ctrlKey || metaKey) && key === ';')
|
|
101
|
-
}, [hours,
|
|
82
|
+
if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
|
|
83
|
+
}, [hours, isWithDateInputs, trackFocusYearInput, onHomeKeyDown, onEndKeyDown, trackFocusLastSegment, trackFocusMinuteInput, handleChangeHours]);
|
|
102
84
|
const onHoursBlur = useCallback(e => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const newHours = e === null || e === void 0 ? void 0 : (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.value;
|
|
85
|
+
const newHours = e?.target?.value;
|
|
106
86
|
if (newHours === '0') handleChangeHours('01', e, {
|
|
107
87
|
isAutomaticFillTrigger: true
|
|
108
88
|
});else if (newHours.length > 0 && newHours.length < 2) handleChangeHours(prependStringWithPlaceHolders(newHours, 2), e, {
|
|
@@ -110,30 +90,25 @@ const useTimeInputs = () => {
|
|
|
110
90
|
});
|
|
111
91
|
}, [handleChangeHours]);
|
|
112
92
|
const onMinutesFocus = useCallback(() => {
|
|
113
|
-
|
|
114
|
-
}, [
|
|
93
|
+
trackFocusMinuteInput();
|
|
94
|
+
}, [trackFocusMinuteInput]);
|
|
115
95
|
const onMinutesChange = useCallback(e => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
let newMinutes = e === null || e === void 0 ? void 0 : (_e$target3 = e.target) === null || _e$target3 === void 0 ? void 0 : _e$target3.value; // converts minutes 7~9 to 07~09
|
|
96
|
+
let newMinutes = e?.target?.value; // converts minutes 7~9 to 07~09
|
|
119
97
|
|
|
120
98
|
if (Number.parseInt(newMinutes, 10) > 6) newMinutes = prependStringWithPlaceHolders(newMinutes, 2);
|
|
121
99
|
handleChangeMinutes(newMinutes, e); // auto-advance functionality:
|
|
122
|
-
// if (newMinutes.length === 2) secondsInputRef?.current?.focus?.();
|
|
123
100
|
|
|
124
|
-
if (newMinutes.length === 2)
|
|
125
|
-
}, [
|
|
101
|
+
if (newMinutes.length === 2) trackFocusMeridiemInput();
|
|
102
|
+
}, [handleChangeMinutes, trackFocusMeridiemInput]);
|
|
126
103
|
const onMinutesKeyDown = useCallback(e => {
|
|
127
|
-
var _lastSegmentRef$curre3, _lastSegmentRef$curre4;
|
|
128
|
-
|
|
129
104
|
const {
|
|
130
105
|
key,
|
|
131
106
|
ctrlKey,
|
|
132
107
|
metaKey
|
|
133
108
|
} = e;
|
|
134
109
|
const minutesStringConvertedToInteger = Number.parseInt(minutes, 10);
|
|
135
|
-
if (
|
|
136
|
-
if (
|
|
110
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', ' '].includes(key)) e.preventDefault();
|
|
111
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', ' '].includes(key)) e.stopPropagation();
|
|
137
112
|
if (key === 'Home') onHomeKeyDown();
|
|
138
113
|
if (key === 'End') onEndKeyDown();
|
|
139
114
|
|
|
@@ -141,86 +116,69 @@ const useTimeInputs = () => {
|
|
|
141
116
|
const minutesInteger = Number.isNaN(minutesStringConvertedToInteger) ? 0 : minutesStringConvertedToInteger;
|
|
142
117
|
let newMinutes;
|
|
143
118
|
if (key === 'ArrowUp') newMinutes = minutesInteger + minutesInterval <= 59 ? minutesInteger + minutesInterval : minutesInteger;else newMinutes = minutesInteger - minutesInterval > 0 ? minutesInteger - minutesInterval : 0;
|
|
144
|
-
newMinutes = prependStringWithPlaceHolders(
|
|
119
|
+
newMinutes = prependStringWithPlaceHolders(`${newMinutes}`, 2);
|
|
145
120
|
handleChangeMinutes(newMinutes, e);
|
|
146
121
|
}
|
|
147
122
|
|
|
148
123
|
if (!Number.isNaN(minutesStringConvertedToInteger) && key === ' ') {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const newMinutes = prependStringWithPlaceHolders("".concat(minutesStringConvertedToInteger), 2);
|
|
124
|
+
const newMinutes = prependStringWithPlaceHolders(`${minutesStringConvertedToInteger}`, 2);
|
|
152
125
|
handleChangeMinutes(newMinutes, e); // auto-advance functionality:
|
|
153
|
-
// if (newMinutes.length === 2) secondsInputRef?.current?.focus?.();
|
|
154
126
|
|
|
155
|
-
if (newMinutes.length === 2)
|
|
127
|
+
if (newMinutes.length === 2) trackFocusMeridiemInput();
|
|
156
128
|
} // regressive backspace functionality
|
|
157
129
|
|
|
158
130
|
|
|
159
|
-
if (key === 'Backspace' &&
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
hourInputRef === null || hourInputRef === void 0 ? void 0 : (_hourInputRef$current3 = hourInputRef.current) === null || _hourInputRef$current3 === void 0 ? void 0 : (_hourInputRef$current4 = _hourInputRef$current3.focus) === null || _hourInputRef$current4 === void 0 ? void 0 : _hourInputRef$current4.call(_hourInputRef$current3);
|
|
131
|
+
if (key === 'Backspace' && minutes?.length === 0) {
|
|
132
|
+
trackFocusHourInput();
|
|
163
133
|
} // focus last fragment on fill with now
|
|
164
134
|
|
|
165
135
|
|
|
166
|
-
if ((ctrlKey || metaKey) && key === ';')
|
|
167
|
-
}, [minutes, onHomeKeyDown, onEndKeyDown,
|
|
136
|
+
if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
|
|
137
|
+
}, [minutes, onHomeKeyDown, onEndKeyDown, trackFocusLastSegment, minutesInterval, handleChangeMinutes, trackFocusMeridiemInput, trackFocusHourInput]);
|
|
168
138
|
const onMinutesBlur = useCallback(e => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const newMinutes = e === null || e === void 0 ? void 0 : (_e$target4 = e.target) === null || _e$target4 === void 0 ? void 0 : _e$target4.value;
|
|
139
|
+
const newMinutes = e?.target?.value;
|
|
172
140
|
if (newMinutes.length > 0 && newMinutes.length < 2) handleChangeMinutes(prependStringWithPlaceHolders(newMinutes, 2), e, {
|
|
173
141
|
isAutomaticFillTrigger: true
|
|
174
142
|
});
|
|
175
143
|
}, [handleChangeMinutes]);
|
|
176
144
|
const onMeridiemFocus = useCallback(() => {
|
|
177
|
-
|
|
178
|
-
}, [
|
|
145
|
+
trackFocusMeridiemInput();
|
|
146
|
+
}, [trackFocusMeridiemInput]);
|
|
179
147
|
const onMeridiemChange = useCallback(e => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
let newMeridiem = e === null || e === void 0 ? void 0 : (_e$target5 = e.target) === null || _e$target5 === void 0 ? void 0 : (_e$target5$value = _e$target5.value) === null || _e$target5$value === void 0 ? void 0 : (_e$target5$value$toUp = _e$target5$value.toUpperCase) === null || _e$target5$value$toUp === void 0 ? void 0 : _e$target5$value$toUp.call(_e$target5$value); // if new value is length 1,
|
|
148
|
+
let newMeridiem = e?.target?.value?.toUpperCase?.(); // if new value is length 1,
|
|
183
149
|
// if previous value was empty, auto-complete
|
|
184
150
|
// if previous value was not empty, set to empty (regressive backspace)
|
|
185
151
|
|
|
186
|
-
if (newMeridiem.length === 1) if (meridiem === '') newMeridiem =
|
|
152
|
+
if (newMeridiem.length === 1) if (meridiem === '') newMeridiem = `${newMeridiem}M`;else newMeridiem = '';
|
|
187
153
|
handleChangeMeridiem(newMeridiem, e); // auto-advance functionality:
|
|
188
154
|
|
|
189
155
|
if (newMeridiem.length === 2 && withAnyRightController) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (withClearBtn) (_clearButtonRef$curre3 = clearButtonRef.current) === null || _clearButtonRef$curre3 === void 0 ? void 0 : (_clearButtonRef$curre4 = _clearButtonRef$curre3.focus) === null || _clearButtonRef$curre4 === void 0 ? void 0 : _clearButtonRef$curre4.call(_clearButtonRef$curre3);else if (withAnyPicker) pickerButtonRef === null || pickerButtonRef === void 0 ? void 0 : (_pickerButtonRef$curr3 = pickerButtonRef.current) === null || _pickerButtonRef$curr3 === void 0 ? void 0 : (_pickerButtonRef$curr4 = _pickerButtonRef$curr3.focus) === null || _pickerButtonRef$curr4 === void 0 ? void 0 : _pickerButtonRef$curr4.call(_pickerButtonRef$curr3);
|
|
156
|
+
if (withClearBtn) trackFocusClearBtn();else if (withAnyPicker) trackFocusPicker();
|
|
193
157
|
}
|
|
194
|
-
}, [meridiem, handleChangeMeridiem, withAnyRightController, withClearBtn,
|
|
158
|
+
}, [meridiem, handleChangeMeridiem, withAnyRightController, withClearBtn, trackFocusClearBtn, withAnyPicker, trackFocusPicker]);
|
|
195
159
|
const onMeridiemKeyDown = useCallback(e => {
|
|
196
|
-
var _lastSegmentRef$curre5, _lastSegmentRef$curre6;
|
|
197
|
-
|
|
198
160
|
const {
|
|
199
161
|
key,
|
|
200
162
|
ctrlKey,
|
|
201
163
|
metaKey
|
|
202
164
|
} = e;
|
|
203
|
-
if (
|
|
204
|
-
if (
|
|
165
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown'].includes(key)) e.preventDefault();
|
|
166
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown'].includes(key)) e.stopPropagation();
|
|
205
167
|
if (key === 'Home') onHomeKeyDown();
|
|
206
168
|
if (key === 'End') onEndKeyDown();
|
|
207
169
|
if (key === 'ArrowUp' && meridiem !== 'AM') handleChangeMeridiem('AM', e);
|
|
208
170
|
if (key === 'ArrowDown' && meridiem !== 'PM') handleChangeMeridiem('PM', e); // regressive backspace functionality
|
|
209
171
|
|
|
210
172
|
if (key === 'Backspace') {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if ((meridiem === null || meridiem === void 0 ? void 0 : meridiem.length) === 2) handleChangeMeridiem('', e);else minutesInputRef === null || minutesInputRef === void 0 ? void 0 : (_minutesInputRef$curr5 = minutesInputRef.current) === null || _minutesInputRef$curr5 === void 0 ? void 0 : (_minutesInputRef$curr6 = _minutesInputRef$curr5.focus) === null || _minutesInputRef$curr6 === void 0 ? void 0 : _minutesInputRef$curr6.call(_minutesInputRef$curr5);
|
|
173
|
+
if (meridiem?.length === 2) handleChangeMeridiem('', e);else trackFocusMinuteInput();
|
|
214
174
|
} // focus last fragment on fill with now
|
|
215
175
|
|
|
216
176
|
|
|
217
|
-
if ((ctrlKey || metaKey) && key === ';')
|
|
218
|
-
}, [onHomeKeyDown, onEndKeyDown, meridiem, handleChangeMeridiem,
|
|
177
|
+
if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
|
|
178
|
+
}, [onHomeKeyDown, onEndKeyDown, meridiem, handleChangeMeridiem, trackFocusLastSegment, trackFocusMinuteInput]);
|
|
219
179
|
const onMeridiemBlur = useCallback(e => {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const newMeridiem = e === null || e === void 0 ? void 0 : (_e$target6 = e.target) === null || _e$target6 === void 0 ? void 0 : (_e$target6$value = _e$target6.value) === null || _e$target6$value === void 0 ? void 0 : (_e$target6$value$toUp = _e$target6$value.toUpperCase) === null || _e$target6$value$toUp === void 0 ? void 0 : _e$target6$value$toUp.call(_e$target6$value);
|
|
223
|
-
if (newMeridiem.length === 1) handleChangeMeridiem("".concat(newMeridiem, "M"), e, {
|
|
180
|
+
const newMeridiem = e?.target?.value?.toUpperCase?.();
|
|
181
|
+
if (newMeridiem.length === 1) handleChangeMeridiem(`${newMeridiem}M`, e, {
|
|
224
182
|
isAutomaticFillTrigger: true
|
|
225
183
|
});
|
|
226
184
|
}, [handleChangeMeridiem]);
|
|
@@ -33,14 +33,8 @@ const announcableCardinalDays = {
|
|
|
33
33
|
30: 'thirtieth',
|
|
34
34
|
31: 'thirty first'
|
|
35
35
|
};
|
|
36
|
-
const homeEndAllArrowKeys = ['Home', 'End', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
|
|
37
|
-
const homeEndKeys = ['Home', 'End'];
|
|
38
|
-
const homeEndArrowUpDownDashSlashesKeys = ['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'];
|
|
39
|
-
const homeEndArrowUpDownSpaceKeys = ['Home', 'End', 'ArrowUp', 'ArrowDown', ' '];
|
|
40
|
-
const homeEndArrowUpDownSemiKeys = ['Home', 'End', 'ArrowUp', 'ArrowDown', ':'];
|
|
41
|
-
const homeEndArrowUpDownKeys = ['Home', 'End', 'ArrowUp', 'ArrowDown'];
|
|
42
36
|
const defaultMetaInfo = {
|
|
43
37
|
isAutomaticFillTrigger: false
|
|
44
38
|
};
|
|
45
39
|
|
|
46
|
-
export { announcableCardinalDays, defaultMetaInfo,
|
|
40
|
+
export { announcableCardinalDays, defaultMetaInfo, monthNames, weekDays };
|
|
@@ -1,42 +1,33 @@
|
|
|
1
1
|
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
2
|
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
4
3
|
import { createRef } from 'react';
|
|
5
4
|
import { monthNames } from './constants.js';
|
|
6
5
|
import { prependStringWithPlaceHolders, deconstructValuesFromDateString, isIncompleteString } from './stringHelpers.js';
|
|
7
6
|
import { convertToPositiveNumberIfPossible } from './numberHelpers.js';
|
|
8
7
|
|
|
9
|
-
const getDateValuesFromDate = day => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
day: day === null || day === void 0 ? void 0 : (_day$getDate = day.getDate) === null || _day$getDate === void 0 ? void 0 : _day$getDate.call(day),
|
|
15
|
-
year: day === null || day === void 0 ? void 0 : (_day$getFullYear = day.getFullYear) === null || _day$getFullYear === void 0 ? void 0 : _day$getFullYear.call(day)
|
|
16
|
-
};
|
|
17
|
-
};
|
|
8
|
+
const getDateValuesFromDate = day => ({
|
|
9
|
+
month: day?.getMonth?.(),
|
|
10
|
+
day: day?.getDate?.(),
|
|
11
|
+
year: day?.getFullYear?.()
|
|
12
|
+
});
|
|
18
13
|
const getDateStringFromDay = day => {
|
|
19
|
-
const monthFromDay = prependStringWithPlaceHolders(
|
|
14
|
+
const monthFromDay = prependStringWithPlaceHolders(`${day.getMonth() + 1}`, 2); // months from 1-12
|
|
20
15
|
|
|
21
|
-
const dayFromDay = prependStringWithPlaceHolders(
|
|
22
|
-
const yearFromDay = prependStringWithPlaceHolders(
|
|
23
|
-
return
|
|
16
|
+
const dayFromDay = prependStringWithPlaceHolders(`${day.getDate()}`, 2);
|
|
17
|
+
const yearFromDay = prependStringWithPlaceHolders(`${day.getFullYear()}`, 4);
|
|
18
|
+
return `${monthFromDay}/${dayFromDay}/${yearFromDay}`;
|
|
24
19
|
};
|
|
25
20
|
const getTimeStringFromDay = day => {
|
|
26
21
|
const hoursNum = day.getHours();
|
|
27
22
|
const meridiem = hoursNum > 12 ? 'PM' : 'AM';
|
|
28
23
|
const twelveHourFormat = hoursNum > 12 ? hoursNum - 12 : hoursNum;
|
|
29
24
|
const minutesNum = day.getMinutes();
|
|
30
|
-
const hoursFromDay = prependStringWithPlaceHolders(
|
|
31
|
-
const minutesFromDay = prependStringWithPlaceHolders(
|
|
32
|
-
return
|
|
25
|
+
const hoursFromDay = prependStringWithPlaceHolders(`${twelveHourFormat}`, 2);
|
|
26
|
+
const minutesFromDay = prependStringWithPlaceHolders(`${minutesNum}`, 2);
|
|
27
|
+
return `${hoursFromDay}:${minutesFromDay} ${meridiem}`;
|
|
33
28
|
};
|
|
34
29
|
const getMonthNameByMonthNumber = monthNumber => monthNames[monthNumber];
|
|
35
|
-
const isSameDateMoment = (dateA, dateB) =>
|
|
36
|
-
var _dateA$getTime, _dateB$getTime;
|
|
37
|
-
|
|
38
|
-
return (dateA === null || dateA === void 0 ? void 0 : (_dateA$getTime = dateA.getTime) === null || _dateA$getTime === void 0 ? void 0 : _dateA$getTime.call(dateA)) === (dateB === null || dateB === void 0 ? void 0 : (_dateB$getTime = dateB.getTime) === null || _dateB$getTime === void 0 ? void 0 : _dateB$getTime.call(dateB));
|
|
39
|
-
};
|
|
30
|
+
const isSameDateMoment = (dateA, dateB) => dateA?.getTime?.() === dateB?.getTime?.();
|
|
40
31
|
const compareTwoDatesDayEquality = (dayA, dayB) => {
|
|
41
32
|
const {
|
|
42
33
|
day: currD,
|
|
@@ -51,11 +42,7 @@ const compareTwoDatesDayEquality = (dayA, dayB) => {
|
|
|
51
42
|
return currD === focusD && currM === focusM && currY === focusY;
|
|
52
43
|
};
|
|
53
44
|
const getLastDayOfMonth = (month, year) => new Date(year, month + 1, 0);
|
|
54
|
-
const isValidDayForTheMonth = (month, year, day) =>
|
|
55
|
-
var _Date, _Date$getMonth;
|
|
56
|
-
|
|
57
|
-
return ((_Date = new Date(year, month, day)) === null || _Date === void 0 ? void 0 : (_Date$getMonth = _Date.getMonth) === null || _Date$getMonth === void 0 ? void 0 : _Date$getMonth.call(_Date)) === month;
|
|
58
|
-
};
|
|
45
|
+
const isValidDayForTheMonth = (month, year, day) => new Date(year, month, day)?.getMonth?.() === month;
|
|
59
46
|
const getDayFromDateString = dateString => {
|
|
60
47
|
const {
|
|
61
48
|
month,
|
|
@@ -69,8 +56,6 @@ const getDayFromDateString = dateString => {
|
|
|
69
56
|
return null;
|
|
70
57
|
};
|
|
71
58
|
const isValidDayForTheMonthDateString = dateString => {
|
|
72
|
-
var _getDayFromDateString, _getDayFromDateString2;
|
|
73
|
-
|
|
74
59
|
if (isIncompleteString(dateString)) return true;
|
|
75
60
|
const {
|
|
76
61
|
month
|
|
@@ -78,7 +63,7 @@ const isValidDayForTheMonthDateString = dateString => {
|
|
|
78
63
|
const monthInt = convertToPositiveNumberIfPossible(month);
|
|
79
64
|
if (monthInt === -1) return false;
|
|
80
65
|
const monthDateMonth = monthInt - 1;
|
|
81
|
-
return
|
|
66
|
+
return getDayFromDateString(dateString)?.getMonth?.() === monthDateMonth;
|
|
82
67
|
};
|
|
83
68
|
const getValidationDateStringMetaInfo = function (dateString) {
|
|
84
69
|
let getIsOutOfRangeDay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : day => false;
|
|
@@ -205,8 +190,6 @@ const getFirstXDaysFromNextMonth = (month, year, howMany) => {
|
|
|
205
190
|
return days;
|
|
206
191
|
};
|
|
207
192
|
const getFiveBySevenCurrentMonthDaysMatrix = (month, year) => {
|
|
208
|
-
var _currentMonthDays$, _currentMonthDays$$da, _currentMonthDays, _currentMonthDays$day;
|
|
209
|
-
|
|
210
193
|
const currentMonthDays = getDaysInMonth(month, year).map(day => ({
|
|
211
194
|
day,
|
|
212
195
|
dayAsString: getDateStringFromDay(day),
|
|
@@ -216,7 +199,7 @@ const getFiveBySevenCurrentMonthDaysMatrix = (month, year) => {
|
|
|
216
199
|
isHidden: false,
|
|
217
200
|
dayBtnRef: /*#__PURE__*/createRef()
|
|
218
201
|
}));
|
|
219
|
-
const firstDayOfTheMonthWeekDay = currentMonthDays
|
|
202
|
+
const firstDayOfTheMonthWeekDay = currentMonthDays?.[0]?.day?.getDay();
|
|
220
203
|
const previousMonthDaysToPrepend = getLastXDaysFromPreviousMonth(month, year, firstDayOfTheMonthWeekDay).map(day => ({
|
|
221
204
|
day,
|
|
222
205
|
dayAsString: getDateStringFromDay(day),
|
|
@@ -226,7 +209,7 @@ const getFiveBySevenCurrentMonthDaysMatrix = (month, year) => {
|
|
|
226
209
|
isHidden: false,
|
|
227
210
|
dayBtnRef: /*#__PURE__*/createRef()
|
|
228
211
|
}));
|
|
229
|
-
const lastDayOfTheMonthWeekDay = currentMonthDays
|
|
212
|
+
const lastDayOfTheMonthWeekDay = currentMonthDays?.[currentMonthDays.length - 1]?.day?.getDay();
|
|
230
213
|
const nextMonthDaysToAppend = getFirstXDaysFromNextMonth(month, year, 6 - lastDayOfTheMonthWeekDay).map(day => ({
|
|
231
214
|
day,
|
|
232
215
|
dayAsString: getDateStringFromDay(day),
|
|
@@ -25,50 +25,52 @@ const useGetStartingFocusedDay = () => {
|
|
|
25
25
|
onCalendarOpenFocusedDay
|
|
26
26
|
} = useContext(ControlledDateTimePickerContext);
|
|
27
27
|
const dayFromInputValues = useGetDayFromDateString();
|
|
28
|
+
const {
|
|
29
|
+
month: inputValuesSplitMonth,
|
|
30
|
+
day: inputValuesSplitDay,
|
|
31
|
+
year: inputValuesDaySplitYear
|
|
32
|
+
} = dayFromInputValues ? getDateValuesFromDate(dayFromInputValues) : {
|
|
33
|
+
month: null,
|
|
34
|
+
day: null,
|
|
35
|
+
year: null
|
|
36
|
+
};
|
|
37
|
+
const isInputFilledAndValid = inputValuesSplitMonth && inputValuesSplitDay && inputValuesDaySplitYear && isValidDayForTheMonth(inputValuesSplitMonth, inputValuesDaySplitYear, inputValuesSplitDay);
|
|
38
|
+
const isOnCalendarOpenFocusedDayEmpty = !onCalendarOpenFocusedDay;
|
|
39
|
+
const shouldFillWithOnCalendarOpenFocusedDay = !isInputFilledAndValid && !isOnCalendarOpenFocusedDayEmpty;
|
|
28
40
|
return useMemo(() => {
|
|
29
|
-
const startingDay = _objectSpread({}, empty);
|
|
41
|
+
const startingDay = _objectSpread({}, empty); // if input was filled start focus is the filled value (if it's valid day for the month)
|
|
30
42
|
|
|
31
|
-
if (dayFromInputValues) {
|
|
32
|
-
const {
|
|
33
|
-
month: inputValuesSplitMonth,
|
|
34
|
-
day: inputValuesSplitDay,
|
|
35
|
-
year: inputValuesDaySplitYear
|
|
36
|
-
} = getDateValuesFromDate(dayFromInputValues);
|
|
37
|
-
const isInputFilledAndValid = inputValuesSplitMonth && inputValuesSplitDay && inputValuesDaySplitYear && isValidDayForTheMonth(inputValuesSplitMonth, inputValuesDaySplitYear, inputValuesSplitDay);
|
|
38
|
-
const isOnCalendarOpenFocusedDayEmpty = !onCalendarOpenFocusedDay;
|
|
39
|
-
const shouldFillWithOnCalendarOpenFocusedDay = !isInputFilledAndValid && !isOnCalendarOpenFocusedDayEmpty; // if input was filled start focus is the filled value (if it's valid day for the month)
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
44
|
+
if (isInputFilledAndValid) {
|
|
45
|
+
startingDay.startFocusedMonth = inputValuesSplitMonth;
|
|
46
|
+
startingDay.startFocusedDay = inputValuesSplitDay;
|
|
47
|
+
startingDay.startFocusedYear = inputValuesDaySplitYear;
|
|
48
|
+
startingDay.startFocusedDate = dayFromInputValues; // if input was not filled (or filled invalid) and there is no onCalendarOpenFocusedDay start focus is not a day
|
|
49
|
+
} else if (isOnCalendarOpenFocusedDayEmpty) {
|
|
50
|
+
// if input was not filled and there is onCalendarOpenFocusedDay start focus is onCalendarOpenFocusedDay day
|
|
51
|
+
return empty;
|
|
52
|
+
} else if (shouldFillWithOnCalendarOpenFocusedDay) {
|
|
53
|
+
const {
|
|
54
|
+
month: focusedDaySplitMonth,
|
|
55
|
+
day: focusedDaySplitDay,
|
|
56
|
+
year: focusedDaySplitYear
|
|
57
|
+
} = deconstructValuesFromDateString(onCalendarOpenFocusedDay);
|
|
58
|
+
const monthAsInt = convertToPositiveNumberIfPossible(focusedDaySplitMonth);
|
|
59
|
+
const dayAsInt = convertToPositiveNumberIfPossible(focusedDaySplitDay);
|
|
60
|
+
const yearAsInt = convertToPositiveNumberIfPossible(focusedDaySplitYear); // if this condition is false, return will be the same as return empty
|
|
61
|
+
// because startFocusedMonth/Day/Year/Date will be === null
|
|
62
|
+
// which is the expected result
|
|
60
63
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
64
|
+
if (monthAsInt !== -1 && dayAsInt !== -1 && yearAsInt !== -1 && isValidDayForTheMonth(monthAsInt - 1, yearAsInt, dayAsInt)) {
|
|
65
|
+
startingDay.startFocusedMonth = monthAsInt;
|
|
66
|
+
startingDay.startFocusedDay = dayAsInt;
|
|
67
|
+
startingDay.startFocusedYear = yearAsInt;
|
|
68
|
+
startingDay.startFocusedDate = new Date(yearAsInt, monthAsInt - 1, dayAsInt);
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
return startingDay;
|
|
71
|
-
}, [dayFromInputValues, onCalendarOpenFocusedDay]);
|
|
73
|
+
}, [dayFromInputValues, inputValuesDaySplitYear, inputValuesSplitDay, inputValuesSplitMonth, isInputFilledAndValid, isOnCalendarOpenFocusedDayEmpty, onCalendarOpenFocusedDay, shouldFillWithOnCalendarOpenFocusedDay]);
|
|
72
74
|
};
|
|
73
75
|
|
|
74
76
|
export { useGetStartingFocusedDay };
|
|
@@ -3,10 +3,8 @@ import { useEffect } from 'react';
|
|
|
3
3
|
const useOnClickOutside = (ref, handler) => {
|
|
4
4
|
useEffect(() => {
|
|
5
5
|
const listener = event => {
|
|
6
|
-
var _ref$contains;
|
|
7
|
-
|
|
8
6
|
// Do nothing if clicking ref's element or descendent elements
|
|
9
|
-
if (event.target instanceof Element) if (!ref || ref
|
|
7
|
+
if (event.target instanceof Element) if (!ref || ref?.contains?.(event.target)) {
|
|
10
8
|
return;
|
|
11
9
|
}
|
|
12
10
|
handler(event);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
2
|
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
4
|
-
import 'core-js/modules/es.string.replace.js';
|
|
5
3
|
import { monthNames, announcableCardinalDays } from './constants.js';
|
|
6
4
|
import { convertToPositiveNumberIfPossible } from './numberHelpers.js';
|
|
7
5
|
|
|
@@ -27,13 +25,9 @@ const getFormattedDateString = _ref => {
|
|
|
27
25
|
const finalMonth = fillStringWithPlaceHolders(month, 2);
|
|
28
26
|
const finalDay = fillStringWithPlaceHolders(day, 2);
|
|
29
27
|
const finalYear = fillStringWithPlaceHolders(year, 4);
|
|
30
|
-
return
|
|
31
|
-
};
|
|
32
|
-
const dateTimeToDate = dateTime => {
|
|
33
|
-
var _dateTime$split, _dateTime$split$call;
|
|
34
|
-
|
|
35
|
-
return dateTime === null || dateTime === void 0 ? void 0 : (_dateTime$split = dateTime.split) === null || _dateTime$split === void 0 ? void 0 : (_dateTime$split$call = _dateTime$split.call(dateTime, ' ')) === null || _dateTime$split$call === void 0 ? void 0 : _dateTime$split$call[0];
|
|
28
|
+
return `${finalMonth}/${finalDay}/${finalYear}`;
|
|
36
29
|
};
|
|
30
|
+
const dateTimeToDate = dateTime => dateTime?.split?.(' ')?.[0];
|
|
37
31
|
const deconstructValuesFromDateString = dateString => {
|
|
38
32
|
const [dirtyMonth = '', dirtyDay = '', dirtyYear = ''] = dateString.split('/');
|
|
39
33
|
const replaceAllRegexp = /_/g;
|
|
@@ -79,13 +73,13 @@ const getFormattedTimeString = _ref2 => {
|
|
|
79
73
|
|
|
80
74
|
const finalMeridiem = fillStringWithPlaceHolders(meridiem, 2); // return `${finalHour}:${finalMinutes}:${finalSeconds} ${finalMeridiem}`;// <-- seconds format
|
|
81
75
|
|
|
82
|
-
return
|
|
76
|
+
return `${finalHour}:${finalMinutes} ${finalMeridiem}`;
|
|
83
77
|
};
|
|
84
78
|
const dateTimeToTime = dateTime => {
|
|
85
79
|
const [// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
86
80
|
date, // timeNumbers = '__:__:__', // <-- seconds format
|
|
87
81
|
timeNumbers = '__:__', timeMeridiem = '__'] = dateTime.split(' ');
|
|
88
|
-
return
|
|
82
|
+
return `${timeNumbers} ${timeMeridiem}`;
|
|
89
83
|
};
|
|
90
84
|
const deconstructTimeValues = timeString => {
|
|
91
85
|
const [dirtyTimes = '', dirtyMeridiem] = timeString.split(' '); // <--['__:__','__']
|
|
@@ -131,7 +125,7 @@ const getAriaDayFromDateString = dateString => {
|
|
|
131
125
|
const dayNum = convertToPositiveNumberIfPossible(dayString);
|
|
132
126
|
const yearNum = convertToPositiveNumberIfPossible(yearString);
|
|
133
127
|
if (monthNum === -1 || dayNum === -1 || yearNum === -1) return '';
|
|
134
|
-
return
|
|
128
|
+
return `${monthNames[monthNum - 1]} ${announcableCardinalDays[dayNum]} ${yearNum}`;
|
|
135
129
|
};
|
|
136
130
|
|
|
137
131
|
export { dateTimeToDate, dateTimeToTime, deconstructTimeValues, deconstructValuesFromDateString, deconstructValuesFromTimeString, fillStringWithPlaceHolders, getAriaDayFromDateString, getFormattedDateString, getFormattedTimeString, isEmptyDateStringMask, isEmptyDateTimeStringMask, isEmptyTimeStringMask, isIncompleteString, isValidDateString, isValidTimeString, prependStringWithPlaceHolders };
|
|
@@ -6,10 +6,10 @@ import 'core-js/modules/esnext.iterator.for-each.js';
|
|
|
6
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
7
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
8
|
import { useMemo } from 'react';
|
|
9
|
-
import { describe, useValidateTypescriptPropTypes, useGetGlobalAttributes } from '@elliemae/ds-props-helpers';
|
|
9
|
+
import { describe, useValidateTypescriptPropTypes, useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';
|
|
10
10
|
import { StyledContainer, StyledLeftAddon, StyledInput, StyledRightAddon } from './styled.js';
|
|
11
11
|
import { propTypes } from './react-desc-prop-types.js';
|
|
12
|
-
import { InputGroupDataTestIds } from './
|
|
12
|
+
import { InputGroupDataTestIds } from './exported-related/data-test-ids.js';
|
|
13
13
|
import { jsxs } from 'react/jsx-runtime';
|
|
14
14
|
|
|
15
15
|
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; }
|
|
@@ -24,6 +24,7 @@ const DSInputGroup = props => {
|
|
|
24
24
|
rightAddon
|
|
25
25
|
} = props;
|
|
26
26
|
const globals = useGetGlobalAttributes(props);
|
|
27
|
+
const xstyledProps = useGetXstyledProps(props);
|
|
27
28
|
const cols = useMemo(() => {
|
|
28
29
|
if (leftAddon && rightAddon) {
|
|
29
30
|
return ['max-content', 'auto', 'max-content'];
|
|
@@ -39,10 +40,10 @@ const DSInputGroup = props => {
|
|
|
39
40
|
|
|
40
41
|
return ['auto'];
|
|
41
42
|
}, [leftAddon, rightAddon]);
|
|
42
|
-
return /*#__PURE__*/jsxs(StyledContainer, _objectSpread(_objectSpread({
|
|
43
|
+
return /*#__PURE__*/jsxs(StyledContainer, _objectSpread(_objectSpread(_objectSpread({
|
|
43
44
|
cols: cols,
|
|
44
45
|
"data-testid": InputGroupDataTestIds.CONTAINER
|
|
45
|
-
}, globals), {}, {
|
|
46
|
+
}, globals), xstyledProps), {}, {
|
|
46
47
|
children: [leftAddon && /*#__PURE__*/_jsx(StyledLeftAddon, {
|
|
47
48
|
"data-testid": InputGroupDataTestIds.LEFTADDON
|
|
48
49
|
}, void 0, leftAddon), /*#__PURE__*/_jsx(StyledInput, {
|