@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
|
@@ -31,13 +31,13 @@ const ControlledDateTimePickerContent = () => {
|
|
|
31
31
|
hideTime,
|
|
32
32
|
hideTimePicker,
|
|
33
33
|
hideDateTimePicker,
|
|
34
|
-
setLatestInteractionRegion,
|
|
35
34
|
withAnyPicker,
|
|
36
35
|
withAnyRightController,
|
|
37
36
|
shouldPreserveClearableSpace,
|
|
38
37
|
isControllerOnly,
|
|
39
38
|
dataAttrs,
|
|
40
|
-
onGlobalKeyDown
|
|
39
|
+
onGlobalKeyDown,
|
|
40
|
+
trackFocusResetter
|
|
41
41
|
} = React.useContext(ControlledDateTimePickerContext);
|
|
42
42
|
const styledsAttrs = {
|
|
43
43
|
justPicker: hideDate && hideTime,
|
|
@@ -45,9 +45,6 @@ const ControlledDateTimePickerContent = () => {
|
|
|
45
45
|
hasError,
|
|
46
46
|
isControllerOnly
|
|
47
47
|
};
|
|
48
|
-
const resetLatestInteraction = React.useCallback(() => {
|
|
49
|
-
setLatestInteractionRegion('');
|
|
50
|
-
}, [setLatestInteractionRegion]);
|
|
51
48
|
const mainCols = [];
|
|
52
49
|
if (!hideDate) mainCols.push('auto');
|
|
53
50
|
if (!hideTime) mainCols.push('auto');
|
|
@@ -60,9 +57,9 @@ const ControlledDateTimePickerContent = () => {
|
|
|
60
57
|
cols: mainCols,
|
|
61
58
|
gutter: "xxs",
|
|
62
59
|
pr: hideDatePicker && hideTimePicker && hideDateTimePicker ? '2px' : undefined,
|
|
63
|
-
onBlur: resetLatestInteraction,
|
|
64
60
|
onKeyDown: onGlobalKeyDown,
|
|
65
|
-
disabled: disabled
|
|
61
|
+
disabled: disabled,
|
|
62
|
+
onBlur: trackFocusResetter
|
|
66
63
|
}, styledsAttrs), dataAttrs), {}, {
|
|
67
64
|
children: [hideDate ? null : _DateInputs || (_DateInputs = /*#__PURE__*/_jsx(DateInputs, {})), hideTime ? null : _TimeInputs || (_TimeInputs = /*#__PURE__*/_jsx(TimeInputs, {})), withAnyRightController ? /*#__PURE__*/_jsx(Grid, {
|
|
68
65
|
cols: rightControlCols
|
|
@@ -21,12 +21,11 @@ const DDInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
21
21
|
disabled,
|
|
22
22
|
contextRef,
|
|
23
23
|
placeholder,
|
|
24
|
-
ariaCurrentValueForInputs
|
|
24
|
+
ariaCurrentValueForInputs,
|
|
25
|
+
isFocused
|
|
25
26
|
} = _ref;
|
|
26
27
|
const validateOnChange = useCallback(e => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (isInvalidDay(e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value)) {
|
|
28
|
+
if (isInvalidDay(e?.target?.value)) {
|
|
30
29
|
e.preventDefault();
|
|
31
30
|
return;
|
|
32
31
|
}
|
|
@@ -39,9 +38,12 @@ const DDInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
39
38
|
onFocus: onFocus,
|
|
40
39
|
onKeyDown: onKeyDown,
|
|
41
40
|
value: value,
|
|
42
|
-
ref:
|
|
41
|
+
ref: DomElem => {
|
|
42
|
+
contextRef.current = DomElem;
|
|
43
|
+
if (isFocused) DomElem?.focus?.();
|
|
44
|
+
},
|
|
43
45
|
placeholder: placeholder,
|
|
44
|
-
"aria-label":
|
|
46
|
+
"aria-label": `day input field, ${ariaCurrentValueForInputs}`,
|
|
45
47
|
"data-testid": ControlledDateTimePickerDatatestid.DATE_INPUTS.DAY,
|
|
46
48
|
disabled: disabled,
|
|
47
49
|
"aria-disabled": disabled
|
|
@@ -35,7 +35,9 @@ const DateInputs = () => {
|
|
|
35
35
|
monthInputRef,
|
|
36
36
|
dayInputRef,
|
|
37
37
|
yearInputRef,
|
|
38
|
-
ariaCurrentValueForInputs
|
|
38
|
+
ariaCurrentValueForInputs,
|
|
39
|
+
latestInteractionRegion,
|
|
40
|
+
currFocusDescriber
|
|
39
41
|
} = useContext(ControlledDateTimePickerContext);
|
|
40
42
|
return /*#__PURE__*/_jsx(Grid, {
|
|
41
43
|
cols: [fixedValues.smallInputWidth, fixedValues.separatorWidth, fixedValues.smallInputWidth, fixedValues.separatorWidth, fixedValues.largeInputWidth]
|
|
@@ -49,7 +51,8 @@ const DateInputs = () => {
|
|
|
49
51
|
autoFocusMonthInput: autoFocusMonthInput,
|
|
50
52
|
placeholder: "MM",
|
|
51
53
|
ariaCurrentValueForInputs: ariaCurrentValueForInputs,
|
|
52
|
-
disabled: disabled
|
|
54
|
+
disabled: disabled,
|
|
55
|
+
isFocused: latestInteractionRegion === 'date-inputs' && currFocusDescriber === 'month-input'
|
|
53
56
|
})), _StyledSeparator || (_StyledSeparator = /*#__PURE__*/_jsx(StyledSeparator, {
|
|
54
57
|
alignItems: "center"
|
|
55
58
|
}, void 0, "/")), /*#__PURE__*/_jsx(StyledFocusWithIn, {}, void 0, /*#__PURE__*/_jsx(DDInput, {
|
|
@@ -61,7 +64,8 @@ const DateInputs = () => {
|
|
|
61
64
|
contextRef: dayInputRef,
|
|
62
65
|
placeholder: "DD",
|
|
63
66
|
ariaCurrentValueForInputs: ariaCurrentValueForInputs,
|
|
64
|
-
disabled: disabled
|
|
67
|
+
disabled: disabled,
|
|
68
|
+
isFocused: latestInteractionRegion === 'date-inputs' && currFocusDescriber === 'day-input'
|
|
65
69
|
})), _StyledSeparator2 || (_StyledSeparator2 = /*#__PURE__*/_jsx(StyledSeparator, {
|
|
66
70
|
alignItems: "center"
|
|
67
71
|
}, void 0, "/")), /*#__PURE__*/_jsx(StyledFocusWithIn, {}, void 0, /*#__PURE__*/_jsx(YYYYInput, {
|
|
@@ -73,7 +77,8 @@ const DateInputs = () => {
|
|
|
73
77
|
contextRef: yearInputRef,
|
|
74
78
|
placeholder: "YYYY",
|
|
75
79
|
ariaCurrentValueForInputs: ariaCurrentValueForInputs,
|
|
76
|
-
disabled: disabled
|
|
80
|
+
disabled: disabled,
|
|
81
|
+
isFocused: latestInteractionRegion === 'date-inputs' && currFocusDescriber === 'year-input'
|
|
77
82
|
})));
|
|
78
83
|
};
|
|
79
84
|
|
|
@@ -22,12 +22,11 @@ const MMInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
22
22
|
placeholder,
|
|
23
23
|
contextRef,
|
|
24
24
|
autoFocusMonthInput,
|
|
25
|
-
ariaCurrentValueForInputs
|
|
25
|
+
ariaCurrentValueForInputs,
|
|
26
|
+
isFocused
|
|
26
27
|
} = _ref;
|
|
27
28
|
const validateOnChange = useCallback(e => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (isInvalidMonth(e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value)) {
|
|
29
|
+
if (isInvalidMonth(e?.target?.value)) {
|
|
31
30
|
e.preventDefault();
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
@@ -41,9 +40,12 @@ const MMInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
41
40
|
onFocus: onFocus,
|
|
42
41
|
onKeyDown: onKeyDown,
|
|
43
42
|
value: value,
|
|
44
|
-
ref:
|
|
43
|
+
ref: DomElem => {
|
|
44
|
+
contextRef.current = DomElem;
|
|
45
|
+
if (isFocused) DomElem?.focus?.();
|
|
46
|
+
},
|
|
45
47
|
placeholder: placeholder,
|
|
46
|
-
"aria-label":
|
|
48
|
+
"aria-label": `month input field, ${ariaCurrentValueForInputs}`,
|
|
47
49
|
"data-testid": ControlledDateTimePickerDatatestid.DATE_INPUTS.MONTH,
|
|
48
50
|
disabled: disabled,
|
|
49
51
|
"aria-disabled": disabled
|
|
@@ -21,12 +21,11 @@ const YYYYInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
21
21
|
disabled,
|
|
22
22
|
placeholder,
|
|
23
23
|
contextRef,
|
|
24
|
-
ariaCurrentValueForInputs
|
|
24
|
+
ariaCurrentValueForInputs,
|
|
25
|
+
isFocused
|
|
25
26
|
} = _ref;
|
|
26
27
|
const validateOnChange = useCallback(e => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (isInvalidYear(e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value)) {
|
|
28
|
+
if (isInvalidYear(e?.target?.value)) {
|
|
30
29
|
e.preventDefault();
|
|
31
30
|
return;
|
|
32
31
|
}
|
|
@@ -39,9 +38,12 @@ const YYYYInput = /*#__PURE__*/React.memo(_ref => {
|
|
|
39
38
|
onFocus: onFocus,
|
|
40
39
|
onKeyDown: onKeyDown,
|
|
41
40
|
value: value,
|
|
42
|
-
ref:
|
|
41
|
+
ref: DomElem => {
|
|
42
|
+
contextRef.current = DomElem;
|
|
43
|
+
if (isFocused) DomElem?.focus?.();
|
|
44
|
+
},
|
|
43
45
|
placeholder: placeholder,
|
|
44
|
-
"aria-label":
|
|
46
|
+
"aria-label": `year input field, ${ariaCurrentValueForInputs}`,
|
|
45
47
|
"data-testid": ControlledDateTimePickerDatatestid.DATE_INPUTS.YEAR,
|
|
46
48
|
disabled: disabled,
|
|
47
49
|
"aria-disabled": disabled
|
|
@@ -8,7 +8,7 @@ import { useContext, useCallback, useMemo } from 'react';
|
|
|
8
8
|
import { ControlledDateTimePickerContext } from '../../ControlledDateTimePickerCTX.js';
|
|
9
9
|
import { getFormattedDateString, prependStringWithPlaceHolders, fillStringWithPlaceHolders } from '../../utils/stringHelpers.js';
|
|
10
10
|
import { getValidationDateStringMetaInfo } from '../../utils/dateHelpers.js';
|
|
11
|
-
import {
|
|
11
|
+
import { defaultMetaInfo } from '../../utils/constants.js';
|
|
12
12
|
|
|
13
13
|
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; }
|
|
14
14
|
|
|
@@ -27,34 +27,27 @@ const useDateInputs = () => {
|
|
|
27
27
|
day,
|
|
28
28
|
year,
|
|
29
29
|
hideTime,
|
|
30
|
-
monthInputRef,
|
|
31
|
-
dayInputRef,
|
|
32
|
-
yearInputRef,
|
|
33
|
-
hourInputRef,
|
|
34
|
-
meridiemInputRef,
|
|
35
|
-
clearButtonRef,
|
|
36
|
-
pickerButtonRef,
|
|
37
30
|
handleChangeComposedDateString,
|
|
38
|
-
setLatestInteractionRegion,
|
|
39
31
|
withClearBtn,
|
|
40
32
|
withAnyPicker,
|
|
41
33
|
withAnyRightController,
|
|
42
34
|
autoFocusMonthInput,
|
|
43
|
-
|
|
35
|
+
trackFocusResetter,
|
|
36
|
+
trackFocusFirstSegment,
|
|
37
|
+
trackFocusLastSegment,
|
|
38
|
+
trackFocusDayInput,
|
|
39
|
+
trackFocusMonthInput,
|
|
40
|
+
trackFocusYearInput,
|
|
41
|
+
trackFocusHourInput,
|
|
42
|
+
trackFocusClearBtn,
|
|
43
|
+
trackFocusPicker
|
|
44
44
|
} = useContext(ControlledDateTimePickerContext);
|
|
45
45
|
const onHomeKeyDown = useCallback(() => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
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);
|
|
49
|
-
}, [monthInputRef]);
|
|
46
|
+
trackFocusFirstSegment();
|
|
47
|
+
}, [trackFocusFirstSegment]);
|
|
50
48
|
const onEndKeyDown = useCallback(() => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
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 if (!hideTime) 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);else 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);
|
|
54
|
-
}, [withAnyPicker, pickerButtonRef, withClearBtn, clearButtonRef, hideTime, meridiemInputRef, yearInputRef]);
|
|
55
|
-
const setLatestInteractionRegionDateInputs = useCallback(() => {
|
|
56
|
-
setLatestInteractionRegion('date-inputs');
|
|
57
|
-
}, [setLatestInteractionRegion]);
|
|
49
|
+
trackFocusLastSegment();
|
|
50
|
+
}, [trackFocusLastSegment]);
|
|
58
51
|
const handleChangeMonth = useCallback(function (newMonth, e) {
|
|
59
52
|
let metaInfo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultMetaInfo;
|
|
60
53
|
const newDateString = getFormattedDateString({
|
|
@@ -71,29 +64,25 @@ const useDateInputs = () => {
|
|
|
71
64
|
handleChangeComposedDateString(newDateString, finalMetaInfo);
|
|
72
65
|
}, [day, year, getIsOutOfRangeDay, getIsDisabledDay, appOnMonthChange, handleChangeComposedDateString]);
|
|
73
66
|
const onMonthFocus = useCallback(() => {
|
|
74
|
-
|
|
75
|
-
}, [
|
|
67
|
+
trackFocusMonthInput();
|
|
68
|
+
}, [trackFocusMonthInput]);
|
|
76
69
|
const onMonthChange = useCallback(e => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
let newMonth = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value; // converts months 2~9 to 02~09
|
|
70
|
+
let newMonth = e?.target?.value; // converts months 2~9 to 02~09
|
|
80
71
|
|
|
81
72
|
if (Number.parseInt(newMonth, 10) > 1) newMonth = prependStringWithPlaceHolders(newMonth, 2);
|
|
82
73
|
handleChangeMonth(newMonth, e); // auto-advance functionality:
|
|
83
74
|
|
|
84
|
-
if (newMonth.length === 2)
|
|
85
|
-
}, [
|
|
75
|
+
if (newMonth.length === 2) trackFocusDayInput();
|
|
76
|
+
}, [handleChangeMonth, trackFocusDayInput]);
|
|
86
77
|
const onMonthKeyDown = useCallback(e => {
|
|
87
|
-
var _lastSegmentRef$curre, _lastSegmentRef$curre2;
|
|
88
|
-
|
|
89
78
|
const {
|
|
90
79
|
key,
|
|
91
80
|
ctrlKey,
|
|
92
81
|
metaKey
|
|
93
82
|
} = e;
|
|
94
83
|
const monthStringConvertedToInteger = Number.parseInt(month, 10);
|
|
95
|
-
if (
|
|
96
|
-
if (
|
|
84
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.preventDefault();
|
|
85
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.stopPropagation();
|
|
97
86
|
if (key === 'Home') onHomeKeyDown();
|
|
98
87
|
if (key === 'End') onEndKeyDown();
|
|
99
88
|
|
|
@@ -101,26 +90,22 @@ const useDateInputs = () => {
|
|
|
101
90
|
const monthInteger = Number.isNaN(monthStringConvertedToInteger) ? 0 : monthStringConvertedToInteger;
|
|
102
91
|
let newMonth;
|
|
103
92
|
if (key === 'ArrowUp') newMonth = monthInteger + 1 <= 12 ? monthInteger + 1 : monthInteger;else newMonth = monthInteger - 1 > 0 ? monthInteger - 1 : 1;
|
|
104
|
-
newMonth = prependStringWithPlaceHolders(
|
|
93
|
+
newMonth = prependStringWithPlaceHolders(`${newMonth}`, 2);
|
|
105
94
|
handleChangeMonth(newMonth, e);
|
|
106
95
|
}
|
|
107
96
|
|
|
108
97
|
if (!Number.isNaN(monthStringConvertedToInteger) && (key === '-' || key === '/' || key === '\\')) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const newMonth = prependStringWithPlaceHolders("".concat(monthStringConvertedToInteger), 2);
|
|
98
|
+
const newMonth = prependStringWithPlaceHolders(`${monthStringConvertedToInteger}`, 2);
|
|
112
99
|
handleChangeMonth(newMonth, e); // auto-advance functionality:
|
|
113
100
|
|
|
114
|
-
if (newMonth.length === 2)
|
|
101
|
+
if (newMonth.length === 2) trackFocusDayInput();
|
|
115
102
|
} // focus last fragment on fill with now
|
|
116
103
|
|
|
117
104
|
|
|
118
|
-
if ((ctrlKey || metaKey) && key === ';')
|
|
119
|
-
}, [month, onHomeKeyDown, onEndKeyDown,
|
|
105
|
+
if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
|
|
106
|
+
}, [month, onHomeKeyDown, onEndKeyDown, trackFocusLastSegment, trackFocusDayInput, handleChangeMonth]);
|
|
120
107
|
const onMonthBlur = useCallback(e => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const newMonth = e === null || e === void 0 ? void 0 : (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.value;
|
|
108
|
+
const newMonth = e?.target?.value;
|
|
124
109
|
if (newMonth === '0') handleChangeMonth('01', e, {
|
|
125
110
|
isAutomaticFillTrigger: true
|
|
126
111
|
});else if (newMonth.length > 0 && newMonth.length < 2) handleChangeMonth(prependStringWithPlaceHolders(newMonth, 2), e, {
|
|
@@ -143,29 +128,25 @@ const useDateInputs = () => {
|
|
|
143
128
|
handleChangeComposedDateString(newDateString, finalMetaInfo);
|
|
144
129
|
}, [month, year, getIsOutOfRangeDay, getIsDisabledDay, appOnDayChange, handleChangeComposedDateString]);
|
|
145
130
|
const onDayFocus = useCallback(() => {
|
|
146
|
-
|
|
147
|
-
}, [
|
|
131
|
+
trackFocusDayInput();
|
|
132
|
+
}, [trackFocusDayInput]);
|
|
148
133
|
const onDayChange = useCallback(e => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
let newDay = e === null || e === void 0 ? void 0 : (_e$target3 = e.target) === null || _e$target3 === void 0 ? void 0 : _e$target3.value; // converts days 4~9 to 04~09
|
|
134
|
+
let newDay = e?.target?.value; // converts days 4~9 to 04~09
|
|
152
135
|
|
|
153
136
|
if (Number.parseInt(newDay, 10) > 3) newDay = prependStringWithPlaceHolders(newDay, 2);
|
|
154
137
|
handleChangeDay(newDay, e); // auto-advance functionality:
|
|
155
138
|
|
|
156
|
-
if (newDay.length === 2)
|
|
157
|
-
}, [handleChangeDay,
|
|
139
|
+
if (newDay.length === 2) trackFocusYearInput();
|
|
140
|
+
}, [handleChangeDay, trackFocusYearInput]);
|
|
158
141
|
const onDayKeyDown = useCallback(e => {
|
|
159
|
-
var _lastSegmentRef$curre3, _lastSegmentRef$curre4;
|
|
160
|
-
|
|
161
142
|
const {
|
|
162
143
|
key,
|
|
163
144
|
ctrlKey,
|
|
164
145
|
metaKey
|
|
165
146
|
} = e;
|
|
166
147
|
const dayStringConvertedToInteger = Number.parseInt(day, 10);
|
|
167
|
-
if (
|
|
168
|
-
if (
|
|
148
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.preventDefault();
|
|
149
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.stopPropagation();
|
|
169
150
|
if (key === 'Home') onHomeKeyDown();
|
|
170
151
|
if (key === 'End') onEndKeyDown();
|
|
171
152
|
|
|
@@ -173,33 +154,27 @@ const useDateInputs = () => {
|
|
|
173
154
|
const dayInteger = Number.isNaN(dayStringConvertedToInteger) ? 0 : dayStringConvertedToInteger;
|
|
174
155
|
let newDay;
|
|
175
156
|
if (key === 'ArrowUp') newDay = dayInteger + 1 <= 31 ? dayInteger + 1 : dayInteger;else newDay = dayInteger - 1 > 0 ? dayInteger - 1 : 1;
|
|
176
|
-
newDay = prependStringWithPlaceHolders(
|
|
157
|
+
newDay = prependStringWithPlaceHolders(`${newDay}`, 2);
|
|
177
158
|
handleChangeDay(newDay, e);
|
|
178
159
|
}
|
|
179
160
|
|
|
180
161
|
if (!Number.isNaN(dayStringConvertedToInteger) && (key === '-' || key === '/' || key === '\\')) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const newDay = prependStringWithPlaceHolders("".concat(dayStringConvertedToInteger), 2);
|
|
162
|
+
const newDay = prependStringWithPlaceHolders(`${dayStringConvertedToInteger}`, 2);
|
|
184
163
|
handleChangeDay(newDay, e); // auto-advance functionality:
|
|
185
164
|
|
|
186
|
-
if (newDay.length === 2)
|
|
165
|
+
if (newDay.length === 2) trackFocusYearInput();
|
|
187
166
|
} // regressive backspace functionality
|
|
188
167
|
|
|
189
168
|
|
|
190
|
-
if (key === 'Backspace' &&
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
monthInputRef === null || monthInputRef === void 0 ? void 0 : (_monthInputRef$curren3 = monthInputRef.current) === null || _monthInputRef$curren3 === void 0 ? void 0 : (_monthInputRef$curren4 = _monthInputRef$curren3.focus) === null || _monthInputRef$curren4 === void 0 ? void 0 : _monthInputRef$curren4.call(_monthInputRef$curren3);
|
|
169
|
+
if (key === 'Backspace' && day?.length === 0) {
|
|
170
|
+
trackFocusMonthInput();
|
|
194
171
|
} // focus last fragment on fill with now
|
|
195
172
|
|
|
196
173
|
|
|
197
|
-
if ((ctrlKey || metaKey) && key === ';')
|
|
198
|
-
}, [day, onHomeKeyDown, onEndKeyDown,
|
|
174
|
+
if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
|
|
175
|
+
}, [day, onHomeKeyDown, onEndKeyDown, trackFocusLastSegment, handleChangeDay, trackFocusYearInput, trackFocusMonthInput]);
|
|
199
176
|
const onDayBlur = useCallback(e => {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const newDay = e === null || e === void 0 ? void 0 : (_e$target4 = e.target) === null || _e$target4 === void 0 ? void 0 : _e$target4.value;
|
|
177
|
+
const newDay = e?.target?.value;
|
|
203
178
|
if (newDay === '0') handleChangeDay('01', e, {
|
|
204
179
|
isAutomaticFillTrigger: true
|
|
205
180
|
});else if (newDay.length > 0 && newDay.length < 2) handleChangeDay(prependStringWithPlaceHolders(newDay, 2), e, {
|
|
@@ -222,79 +197,75 @@ const useDateInputs = () => {
|
|
|
222
197
|
handleChangeComposedDateString(newDateString, finalMetaInfo);
|
|
223
198
|
}, [month, day, getIsOutOfRangeDay, getIsDisabledDay, appOnYearChange, handleChangeComposedDateString]);
|
|
224
199
|
const onYearFocus = useCallback(() => {
|
|
225
|
-
|
|
226
|
-
}, [
|
|
200
|
+
trackFocusYearInput();
|
|
201
|
+
}, [trackFocusYearInput]);
|
|
227
202
|
const onYearChange = useCallback(e => {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const newYear = e === null || e === void 0 ? void 0 : (_e$target5 = e.target) === null || _e$target5 === void 0 ? void 0 : _e$target5.value;
|
|
203
|
+
const newYear = e?.target?.value;
|
|
231
204
|
handleChangeYear(newYear, e); // auto-advance functionality:
|
|
232
205
|
|
|
233
206
|
if (newYear.length === 4) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (!hideTime) 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);else if (withAnyRightController) {
|
|
237
|
-
var _clearButtonRef$curre3, _clearButtonRef$curre4, _pickerButtonRef$curr3, _pickerButtonRef$curr4;
|
|
238
|
-
|
|
239
|
-
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); // pending approval from Seda, check which one should be focused first...
|
|
207
|
+
if (!hideTime) trackFocusHourInput();else if (withAnyRightController) {
|
|
208
|
+
if (withClearBtn) trackFocusClearBtn();else if (withAnyPicker) trackFocusPicker(); // pending approval from Seda, check which one should be focused first...
|
|
240
209
|
}
|
|
241
210
|
}
|
|
242
|
-
}, [handleChangeYear, hideTime,
|
|
211
|
+
}, [handleChangeYear, hideTime, trackFocusHourInput, withAnyRightController, withClearBtn, trackFocusClearBtn, withAnyPicker, trackFocusPicker]);
|
|
243
212
|
const onYearKeyDown = useCallback(e => {
|
|
244
|
-
var _lastSegmentRef$curre5, _lastSegmentRef$curre6;
|
|
245
|
-
|
|
246
213
|
const {
|
|
247
214
|
key,
|
|
248
215
|
ctrlKey,
|
|
249
216
|
metaKey
|
|
250
217
|
} = e;
|
|
218
|
+
/* ****** New year value calculator logic ********* */
|
|
219
|
+
|
|
251
220
|
const yearStringConvertedToInteger = Number.parseInt(year, 10);
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (key === 'Home') onHomeKeyDown();
|
|
255
|
-
if (key === 'End') onEndKeyDown();
|
|
221
|
+
const yearInteger = Number.isNaN(yearStringConvertedToInteger) ? 0 : yearStringConvertedToInteger;
|
|
222
|
+
let newYear = yearInteger !== 0 ? fillStringWithPlaceHolders(`${yearInteger}`, 4, '0') : '';
|
|
256
223
|
|
|
257
224
|
if (key === 'ArrowUp' || key === 'ArrowDown') {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
newYear = prependStringWithPlaceHolders("".concat(newYear), 4);
|
|
262
|
-
handleChangeYear(newYear, e);
|
|
225
|
+
let newYearInteger;
|
|
226
|
+
if (key === 'ArrowUp') newYearInteger = yearInteger + 1 <= 9999 ? yearInteger + 1 : yearInteger;else newYearInteger = yearInteger - 1 > 0 ? yearInteger - 1 : 1;
|
|
227
|
+
newYear = prependStringWithPlaceHolders(`${newYearInteger}`, 4);
|
|
263
228
|
}
|
|
264
229
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
230
|
+
const isAutomaticFillTrigger = newYear !== year && ['Tab', ' '].includes(key);
|
|
231
|
+
const metainfo = {
|
|
232
|
+
isAutomaticFillTrigger
|
|
233
|
+
};
|
|
234
|
+
/* ************* new year apply logic ************* */
|
|
235
|
+
// tab/spacebar applies auto-fill
|
|
236
|
+
// arrows up/down applies increment/decrement
|
|
268
237
|
|
|
269
|
-
|
|
270
|
-
|
|
238
|
+
if (key === 'ArrowUp' || key === 'ArrowDown' || isAutomaticFillTrigger) {
|
|
239
|
+
handleChangeYear(newYear, e, metainfo);
|
|
240
|
+
}
|
|
241
|
+
/* ************* focus tracking logic ************* */
|
|
271
242
|
|
|
272
|
-
if (!hideTime) 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);else if (withAnyRightController) {
|
|
273
|
-
var _clearButtonRef$curre5, _clearButtonRef$curre6, _pickerButtonRef$curr5, _pickerButtonRef$curr6;
|
|
274
243
|
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
} // regressive backspace functionality
|
|
244
|
+
let trackNextFocus = trackFocusResetter; // if nothing after, we reset internal focus tracker to avoid re-render unexpected focus shift
|
|
279
245
|
|
|
246
|
+
if (!hideTime) trackNextFocus = trackFocusHourInput;else if (withClearBtn) trackNextFocus = trackFocusClearBtn;else if (withAnyPicker) trackNextFocus = trackFocusPicker;
|
|
247
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', ' '].includes(key)) e.preventDefault();
|
|
248
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', ' '].includes(key)) e.stopPropagation();
|
|
249
|
+
if (key === 'Home') onHomeKeyDown();
|
|
250
|
+
if (key === 'End') onEndKeyDown();
|
|
251
|
+
/* ************** auto-advance logic ************** */
|
|
280
252
|
|
|
281
|
-
if (key === '
|
|
282
|
-
|
|
253
|
+
if (key === ' ') {
|
|
254
|
+
// auto-advance functionality:
|
|
255
|
+
trackNextFocus();
|
|
256
|
+
}
|
|
257
|
+
/* ********** regressive backspace logic ********** */
|
|
283
258
|
|
|
284
|
-
dayInputRef === null || dayInputRef === void 0 ? void 0 : (_dayInputRef$current4 = dayInputRef.current) === null || _dayInputRef$current4 === void 0 ? void 0 : (_dayInputRef$current5 = _dayInputRef$current4.focus) === null || _dayInputRef$current5 === void 0 ? void 0 : _dayInputRef$current5.call(_dayInputRef$current4);
|
|
285
|
-
} // focus last fragment on fill with now
|
|
286
259
|
|
|
260
|
+
if (key === 'Backspace' && year?.length === 0) {
|
|
261
|
+
trackFocusDayInput();
|
|
262
|
+
} // focus last fragment on fill with now
|
|
287
263
|
|
|
288
|
-
if ((ctrlKey || metaKey) && key === ';') lastSegmentRef === null || lastSegmentRef === void 0 ? void 0 : (_lastSegmentRef$curre5 = lastSegmentRef.current) === null || _lastSegmentRef$curre5 === void 0 ? void 0 : (_lastSegmentRef$curre6 = _lastSegmentRef$curre5.focus) === null || _lastSegmentRef$curre6 === void 0 ? void 0 : _lastSegmentRef$curre6.call(_lastSegmentRef$curre5);
|
|
289
|
-
}, [year, onHomeKeyDown, onEndKeyDown, lastSegmentRef, handleChangeYear, hideTime, hourInputRef, withAnyRightController, withClearBtn, clearButtonRef, withAnyPicker, pickerButtonRef, dayInputRef]);
|
|
290
|
-
const onYearBlur = useCallback(e => {
|
|
291
|
-
var _e$target6;
|
|
292
264
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}, [handleChangeYear]);
|
|
265
|
+
if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
|
|
266
|
+
}, [year, trackFocusResetter, hideTime, trackFocusHourInput, withClearBtn, trackFocusClearBtn, withAnyPicker, trackFocusPicker, onHomeKeyDown, onEndKeyDown, trackFocusLastSegment, trackFocusDayInput, handleChangeYear]);
|
|
267
|
+
const onYearBlur = useCallback(() => {// this was used before, now that we have a wrapping onBlur resetting the focus tracker, this is unused;
|
|
268
|
+
}, []);
|
|
298
269
|
return useMemo(() => ({
|
|
299
270
|
month,
|
|
300
271
|
day,
|
|
@@ -19,7 +19,7 @@ const CalendarDaysList = /*#__PURE__*/React.memo(_ref => {
|
|
|
19
19
|
children: [invisibleFirstDay ? /*#__PURE__*/_jsx(Day, {
|
|
20
20
|
metaDay: invisibleFirstDay,
|
|
21
21
|
isInvisible: true
|
|
22
|
-
},
|
|
22
|
+
}, `ds-calendar-${invisibleFirstDay.day.toString()}`) : null, daysMatrixByWeekday.map((week, i) => /*#__PURE__*/_jsx(StyledWeekDaysListWrapper, {
|
|
23
23
|
role: "row",
|
|
24
24
|
"aria-rowindex": i + 1,
|
|
25
25
|
cols: ['32px', '32px', '32px', '32px', '32px', '32px', '32px'],
|
|
@@ -28,13 +28,13 @@ const CalendarDaysList = /*#__PURE__*/React.memo(_ref => {
|
|
|
28
28
|
px: "2px",
|
|
29
29
|
justifyContent: "space-between",
|
|
30
30
|
alignItems: "center"
|
|
31
|
-
},
|
|
31
|
+
}, `ds-calendar-week-${week[0].day.toString()}-${week[6].day.toString()}`, week.map((metaDay, z) => /*#__PURE__*/_jsx(Day, {
|
|
32
32
|
metaDay: metaDay,
|
|
33
33
|
colIndex: z + 1
|
|
34
|
-
},
|
|
34
|
+
}, `ds-calendar-${metaDay.day.toString()}`)))), invisibleLastDay ? /*#__PURE__*/_jsx(Day, {
|
|
35
35
|
metaDay: invisibleLastDay,
|
|
36
36
|
isInvisible: true
|
|
37
|
-
},
|
|
37
|
+
}, `ds-calendar-${invisibleLastDay.day.toString()}`) : null]
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import { useMemo, useContext } from 'react';
|
|
2
|
+
import { useMemo, useContext, useCallback } from 'react';
|
|
3
3
|
import { BUTTON_SIZES } from '@elliemae/ds-button';
|
|
4
4
|
import { ChevronDoubleLeft, ChevronLeft, ChevronRight, ChevronDoubleRight } from '@elliemae/ds-icons';
|
|
5
5
|
import { ControlledDateTimePickerDatatestid } from '../../../ControlledDateTimePickerDatatestid.js';
|
|
@@ -15,8 +15,8 @@ const useGetFormattedCurrentDate = () => {
|
|
|
15
15
|
currentMonth,
|
|
16
16
|
currentYear
|
|
17
17
|
} = useContext(CalendarContext);
|
|
18
|
-
const monthString = currentMonth >= 0 && currentMonth <= 11 ?
|
|
19
|
-
return useMemo(() =>
|
|
18
|
+
const monthString = currentMonth >= 0 && currentMonth <= 11 ? `${getMonthNameByMonthNumber(currentMonth)} ` : '';
|
|
19
|
+
return useMemo(() => `${monthString}${currentYear}`, [monthString, currentYear]);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const CalendarHead = () => {
|
|
@@ -41,14 +41,32 @@ const CalendarHead = () => {
|
|
|
41
41
|
prevYearBtnRef,
|
|
42
42
|
prevMonthBtnRef,
|
|
43
43
|
nextMonthBtnRef,
|
|
44
|
-
nextYearBtnRef
|
|
44
|
+
nextYearBtnRef,
|
|
45
|
+
latestInteractionRegion,
|
|
46
|
+
currFocusDescriber
|
|
45
47
|
} = useContext(ControlledDateTimePickerContext);
|
|
48
|
+
const handlePrevYearRef = useCallback(ButtonDomNode => {
|
|
49
|
+
prevYearBtnRef.current = ButtonDomNode;
|
|
50
|
+
if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-prev-year') ButtonDomNode?.focus?.();
|
|
51
|
+
}, [currFocusDescriber, latestInteractionRegion, prevYearBtnRef]);
|
|
52
|
+
const handlePrevMonthRef = useCallback(ButtonDomNode => {
|
|
53
|
+
prevMonthBtnRef.current = ButtonDomNode;
|
|
54
|
+
if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-prev-month') ButtonDomNode?.focus?.();
|
|
55
|
+
}, [currFocusDescriber, latestInteractionRegion, prevMonthBtnRef]);
|
|
56
|
+
const handleNextMonthRef = useCallback(ButtonDomNode => {
|
|
57
|
+
nextMonthBtnRef.current = ButtonDomNode;
|
|
58
|
+
if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-next-month') ButtonDomNode?.focus?.();
|
|
59
|
+
}, [currFocusDescriber, latestInteractionRegion, nextMonthBtnRef]);
|
|
60
|
+
const handleNextYearRef = useCallback(ButtonDomNode => {
|
|
61
|
+
nextYearBtnRef.current = ButtonDomNode;
|
|
62
|
+
if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-next-year') ButtonDomNode?.focus?.();
|
|
63
|
+
}, [currFocusDescriber, latestInteractionRegion, nextYearBtnRef]);
|
|
46
64
|
return /*#__PURE__*/_jsx(StyledHeader, {}, void 0, /*#__PURE__*/_jsx(StyledHeaderButton, {
|
|
47
65
|
"aria-label": "previous year",
|
|
48
66
|
buttonType: "raw",
|
|
49
67
|
size: BUTTON_SIZES.M,
|
|
50
68
|
onClick: handlePrevYear,
|
|
51
|
-
innerRef:
|
|
69
|
+
innerRef: handlePrevYearRef,
|
|
52
70
|
onKeyDown: handlePrevYearKeyDown,
|
|
53
71
|
onFocus: onPrevYearFocus,
|
|
54
72
|
tabIndex: isControllerOnly ? -1 : 1,
|
|
@@ -63,7 +81,7 @@ const CalendarHead = () => {
|
|
|
63
81
|
buttonType: "raw",
|
|
64
82
|
size: BUTTON_SIZES.M,
|
|
65
83
|
onClick: handlePrevMonth,
|
|
66
|
-
innerRef:
|
|
84
|
+
innerRef: handlePrevMonthRef,
|
|
67
85
|
onKeyDown: handlePrevMonthKeyDown,
|
|
68
86
|
onFocus: onPrevMonthFocus,
|
|
69
87
|
"data-testid": ControlledDateTimePickerDatatestid.CALENDAR.PREV_MONTH // this is a tabstop for when the calendar is open
|
|
@@ -75,7 +93,7 @@ const CalendarHead = () => {
|
|
|
75
93
|
buttonType: "raw",
|
|
76
94
|
size: BUTTON_SIZES.M,
|
|
77
95
|
onClick: handleNextMonth,
|
|
78
|
-
innerRef:
|
|
96
|
+
innerRef: handleNextMonthRef,
|
|
79
97
|
onKeyDown: handleNextMonthKeyDown,
|
|
80
98
|
onFocus: onNextMonthFocus,
|
|
81
99
|
"data-testid": ControlledDateTimePickerDatatestid.CALENDAR.NEXT_MONTH
|
|
@@ -86,7 +104,7 @@ const CalendarHead = () => {
|
|
|
86
104
|
buttonType: "raw",
|
|
87
105
|
size: BUTTON_SIZES.M,
|
|
88
106
|
onClick: handleNextYear,
|
|
89
|
-
innerRef:
|
|
107
|
+
innerRef: handleNextYearRef,
|
|
90
108
|
onKeyDown: handleNextYearKeyDown,
|
|
91
109
|
onFocus: onNextYearFocus,
|
|
92
110
|
"data-testid": ControlledDateTimePickerDatatestid.CALENDAR.NEXT_YEAR
|
|
@@ -24,7 +24,7 @@ const CalendarIconTrigger = () => {
|
|
|
24
24
|
ariaCurrentValueForInputs
|
|
25
25
|
} = useContext(ControlledDateTimePickerContext);
|
|
26
26
|
return useMemo(() => /*#__PURE__*/_jsx(StyledIconTriggerButton, {
|
|
27
|
-
"aria-label":
|
|
27
|
+
"aria-label": `date picker context menu trigger, ${ariaCurrentValueForInputs}`,
|
|
28
28
|
buttonType: "icon",
|
|
29
29
|
size: BUTTON_SIZES.M,
|
|
30
30
|
innerRef: handleSetTriggerRef,
|