@elliemae/ds-controlled-form 2.4.1 → 2.4.2-rc.3
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 +1 -3
- package/cjs/checkbox/ControlledCheckbox.js +49 -33
- package/cjs/checkbox/exported-related/data-test-ids.js +10 -0
- package/cjs/checkbox/exported-related/index.js +12 -0
- package/cjs/checkbox/exported-related/theming.js +13 -0
- package/cjs/checkbox/react-desc-prop-types.js +0 -1
- package/cjs/checkbox/styles.js +26 -15
- package/cjs/combobox/ComboBoxCTX.js +1 -1
- package/cjs/combobox/ComboboxDataTestids.js +1 -1
- package/cjs/combobox/config/useComboBox.js +6 -4
- package/cjs/combobox/index.js +5 -0
- package/cjs/combobox/parts/DropdownIndicator.js +2 -2
- package/cjs/combobox/parts/container/Container.js +5 -5
- package/cjs/combobox/parts/container/styled.js +13 -7
- package/cjs/combobox/parts/controls/Controls.js +14 -4
- package/cjs/combobox/parts/controls/styled.js +22 -13
- package/cjs/combobox/parts/controls-input/ControlsInput.js +1 -1
- package/cjs/combobox/parts/controls-input/styled.js +7 -3
- package/cjs/combobox/parts/controls-input/useControlsInput.js +3 -4
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +30 -15
- package/cjs/combobox/parts/header-list/HeaderList.js +4 -3
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +9 -5
- package/cjs/combobox/parts/menu-list/MenuList.js +5 -2
- package/cjs/combobox/parts/menu-list/styled.js +12 -7
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +5 -4
- package/cjs/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/cjs/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +2 -0
- package/cjs/combobox/parts/multi-selected-values-container/useGroupPills.js +13 -10
- package/cjs/combobox/theming.js +13 -0
- package/cjs/combobox/utils/listHelper.js +2 -1
- package/cjs/date-time-picker/config/useChangeHandlers.js +8 -12
- package/cjs/date-time-picker/config/useControlledDateTimePicker.js +13 -9
- package/cjs/date-time-picker/config/useFocusTracker.js +136 -0
- package/cjs/date-time-picker/config/useGetReferences.js +40 -19
- package/cjs/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
- package/cjs/date-time-picker/parts/ClearButton/ClearButton.js +12 -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 -2
- package/cjs/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
- package/cjs/date-time-picker/parts/DateInputs/MMInput.js +8 -2
- package/cjs/date-time-picker/parts/DateInputs/YYYYInput.js +8 -2
- package/cjs/date-time-picker/parts/DateInputs/useDateInputs.js +76 -95
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +31 -5
- package/cjs/date-time-picker/parts/Pickers/Calendar/Day.js +16 -10
- package/cjs/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +12 -12
- package/cjs/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +2 -38
- package/cjs/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
- package/cjs/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -27
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -0
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +17 -23
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +13 -7
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +14 -8
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +13 -7
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +11 -13
- package/cjs/date-time-picker/parts/TimeInputs/HHInput.js +8 -2
- package/cjs/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -2
- package/cjs/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -2
- package/cjs/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
- package/cjs/date-time-picker/parts/TimeInputs/useTimeInputs.js +44 -74
- package/cjs/date-time-picker/utils/constants.js +0 -12
- package/cjs/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
- package/cjs/index.js +16 -7
- package/cjs/input-group/InputGroup.js +69 -0
- package/cjs/input-group/InputGroupDataTestIds.js +12 -0
- package/cjs/input-group/index.js +12 -0
- package/cjs/input-group/react-desc-prop-types.js +14 -0
- package/cjs/input-group/styled.js +46 -0
- package/cjs/mask-hook/hooks/index.js +0 -1
- package/cjs/mask-hook/hooks/usePhoneMask.js +2 -2
- package/cjs/mask-hook/hooks/useRegExpMask.js +0 -1
- package/cjs/mask-hook/index.js +0 -1
- package/cjs/text-input/styled/borders.js +1 -1
- package/esm/autocomplete/config/useAutocomplete.js +3 -5
- package/esm/checkbox/ControlledCheckbox.js +52 -36
- package/esm/checkbox/exported-related/data-test-ids.js +6 -0
- package/esm/checkbox/exported-related/index.js +2 -0
- package/esm/checkbox/exported-related/theming.js +8 -0
- package/esm/checkbox/react-desc-prop-types.js +0 -1
- package/esm/checkbox/styles.js +25 -15
- package/esm/combobox/ComboBoxCTX.js +1 -1
- package/esm/combobox/ComboboxDataTestids.js +1 -1
- package/esm/combobox/config/useComboBox.js +8 -6
- package/esm/combobox/index.js +2 -0
- package/esm/combobox/parts/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/container/Container.js +7 -7
- package/esm/combobox/parts/container/styled.js +13 -6
- package/esm/combobox/parts/controls/Controls.js +14 -4
- package/esm/combobox/parts/controls/styled.js +22 -13
- package/esm/combobox/parts/controls-input/ControlsInput.js +1 -1
- package/esm/combobox/parts/controls-input/styled.js +7 -3
- package/esm/combobox/parts/controls-input/useControlsInput.js +3 -4
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +30 -15
- package/esm/combobox/parts/header-list/HeaderList.js +4 -3
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +9 -5
- package/esm/combobox/parts/menu-list/MenuList.js +5 -2
- package/esm/combobox/parts/menu-list/styled.js +12 -7
- package/esm/combobox/parts/menu-list/useItemRenderer.js +5 -4
- package/esm/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/esm/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +2 -0
- package/esm/combobox/parts/multi-selected-values-container/useGroupPills.js +13 -10
- package/esm/combobox/theming.js +8 -0
- package/esm/combobox/utils/listHelper.js +2 -1
- package/esm/date-range-picker/config/useRangePickerLogic.js +2 -2
- package/esm/date-time-picker/config/useChangeHandlers.js +8 -12
- package/esm/date-time-picker/config/useControlledDateTimePicker.js +13 -9
- package/esm/date-time-picker/config/useFocusTracker.js +132 -0
- package/esm/date-time-picker/config/useGetReferences.js +41 -20
- package/esm/date-time-picker/config/useGlobalKeyHandlers.js +8 -12
- package/esm/date-time-picker/parts/ClearButton/ClearButton.js +12 -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 -2
- package/esm/date-time-picker/parts/DateInputs/DateInputs.js +9 -4
- package/esm/date-time-picker/parts/DateInputs/MMInput.js +8 -2
- package/esm/date-time-picker/parts/DateInputs/YYYYInput.js +8 -2
- package/esm/date-time-picker/parts/DateInputs/useDateInputs.js +77 -96
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +32 -6
- package/esm/date-time-picker/parts/Pickers/Calendar/Day.js +16 -10
- package/esm/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +14 -14
- package/esm/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +3 -39
- package/esm/date-time-picker/parts/Pickers/Calendar/useKeyboardHandlers.js +40 -73
- package/esm/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +18 -27
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -0
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +17 -23
- package/esm/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +14 -8
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +15 -9
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +14 -8
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useKeyboardHandlers.js +36 -230
- package/esm/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +11 -13
- package/esm/date-time-picker/parts/TimeInputs/HHInput.js +8 -2
- package/esm/date-time-picker/parts/TimeInputs/MeridiemInput.js +8 -2
- package/esm/date-time-picker/parts/TimeInputs/MinutesInput.js +8 -2
- package/esm/date-time-picker/parts/TimeInputs/TimeInputs.js +11 -6
- package/esm/date-time-picker/parts/TimeInputs/useTimeInputs.js +44 -74
- package/esm/date-time-picker/utils/constants.js +1 -7
- package/esm/date-time-picker/utils/hooks/useGetStartingFocusedDay.js +38 -36
- package/esm/index.js +5 -1
- package/esm/input-group/InputGroup.js +59 -0
- package/esm/input-group/InputGroupDataTestIds.js +8 -0
- package/esm/input-group/index.js +2 -0
- package/esm/input-group/react-desc-prop-types.js +10 -0
- package/esm/input-group/styled.js +35 -0
- package/esm/mask-hook/hooks/index.js +1 -1
- package/esm/mask-hook/hooks/usePhoneMask.js +2 -2
- package/esm/mask-hook/hooks/useRegExpMask.js +1 -1
- package/esm/mask-hook/index.js +1 -1
- package/esm/text-input/styled/borders.js +1 -1
- package/esm/toggle/ControlledToggle.js +3 -3
- package/package.json +55 -19
- package/types/checkbox/exported-related/data-test-ids.d.ts +4 -0
- package/types/checkbox/exported-related/index.d.ts +2 -0
- package/types/checkbox/exported-related/theming.d.ts +6 -0
- package/types/checkbox/react-desc-prop-types.d.ts +3 -3
- package/types/checkbox/styles.d.ts +5 -5
- package/types/combobox/ComboboxDataTestids.d.ts +1 -1
- package/types/combobox/index.d.ts +2 -0
- package/types/combobox/parts/container/styled.d.ts +1 -2
- package/types/combobox/theming.d.ts +6 -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/index.d.ts +1 -0
- package/types/input-group/InputGroup.d.ts +5 -0
- package/types/input-group/InputGroupDataTestIds.d.ts +6 -0
- package/types/input-group/index.d.ts +2 -0
- package/types/input-group/react-desc-prop-types.d.ts +19 -0
- package/types/input-group/styled.d.ts +7 -0
- package/types/input-group/tests/DSInputGroup.test.d.ts +1 -0
- package/types/mask-hook/hooks/useRegExpMask.d.ts +0 -1
- package/types/text-input/config/useInputText.d.ts +5 -5
- package/cjs/combobox/parts/menu-list/useMenuListSetFocusOption.js +0 -51
- package/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js +0 -47
- package/types/combobox/parts/menu-list/useMenuListSetFocusOption.d.ts +0 -1
|
@@ -35,34 +35,27 @@ const useDateInputs = () => {
|
|
|
35
35
|
day,
|
|
36
36
|
year,
|
|
37
37
|
hideTime,
|
|
38
|
-
monthInputRef,
|
|
39
|
-
dayInputRef,
|
|
40
|
-
yearInputRef,
|
|
41
|
-
hourInputRef,
|
|
42
|
-
meridiemInputRef,
|
|
43
|
-
clearButtonRef,
|
|
44
|
-
pickerButtonRef,
|
|
45
38
|
handleChangeComposedDateString,
|
|
46
|
-
setLatestInteractionRegion,
|
|
47
39
|
withClearBtn,
|
|
48
40
|
withAnyPicker,
|
|
49
41
|
withAnyRightController,
|
|
50
42
|
autoFocusMonthInput,
|
|
51
|
-
|
|
43
|
+
trackFocusResetter,
|
|
44
|
+
trackFocusFirstSegment,
|
|
45
|
+
trackFocusLastSegment,
|
|
46
|
+
trackFocusDayInput,
|
|
47
|
+
trackFocusMonthInput,
|
|
48
|
+
trackFocusYearInput,
|
|
49
|
+
trackFocusHourInput,
|
|
50
|
+
trackFocusClearBtn,
|
|
51
|
+
trackFocusPicker
|
|
52
52
|
} = React.useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
|
|
53
53
|
const onHomeKeyDown = React.useCallback(() => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
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);
|
|
57
|
-
}, [monthInputRef]);
|
|
54
|
+
trackFocusFirstSegment();
|
|
55
|
+
}, [trackFocusFirstSegment]);
|
|
58
56
|
const onEndKeyDown = React.useCallback(() => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
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);
|
|
62
|
-
}, [withAnyPicker, pickerButtonRef, withClearBtn, clearButtonRef, hideTime, meridiemInputRef, yearInputRef]);
|
|
63
|
-
const setLatestInteractionRegionDateInputs = React.useCallback(() => {
|
|
64
|
-
setLatestInteractionRegion('date-inputs');
|
|
65
|
-
}, [setLatestInteractionRegion]);
|
|
57
|
+
trackFocusLastSegment();
|
|
58
|
+
}, [trackFocusLastSegment]);
|
|
66
59
|
const handleChangeMonth = React.useCallback(function (newMonth, e) {
|
|
67
60
|
let metaInfo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : constants.defaultMetaInfo;
|
|
68
61
|
const newDateString = stringHelpers.getFormattedDateString({
|
|
@@ -79,29 +72,27 @@ const useDateInputs = () => {
|
|
|
79
72
|
handleChangeComposedDateString(newDateString, finalMetaInfo);
|
|
80
73
|
}, [day, year, getIsOutOfRangeDay, getIsDisabledDay, appOnMonthChange, handleChangeComposedDateString]);
|
|
81
74
|
const onMonthFocus = React.useCallback(() => {
|
|
82
|
-
|
|
83
|
-
}, [
|
|
75
|
+
trackFocusMonthInput();
|
|
76
|
+
}, [trackFocusMonthInput]);
|
|
84
77
|
const onMonthChange = React.useCallback(e => {
|
|
85
|
-
var _e$target
|
|
78
|
+
var _e$target;
|
|
86
79
|
|
|
87
80
|
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
|
|
88
81
|
|
|
89
82
|
if (Number.parseInt(newMonth, 10) > 1) newMonth = stringHelpers.prependStringWithPlaceHolders(newMonth, 2);
|
|
90
83
|
handleChangeMonth(newMonth, e); // auto-advance functionality:
|
|
91
84
|
|
|
92
|
-
if (newMonth.length === 2)
|
|
93
|
-
}, [
|
|
85
|
+
if (newMonth.length === 2) trackFocusDayInput();
|
|
86
|
+
}, [handleChangeMonth, trackFocusDayInput]);
|
|
94
87
|
const onMonthKeyDown = React.useCallback(e => {
|
|
95
|
-
var _lastSegmentRef$curre, _lastSegmentRef$curre2;
|
|
96
|
-
|
|
97
88
|
const {
|
|
98
89
|
key,
|
|
99
90
|
ctrlKey,
|
|
100
91
|
metaKey
|
|
101
92
|
} = e;
|
|
102
93
|
const monthStringConvertedToInteger = Number.parseInt(month, 10);
|
|
103
|
-
if (
|
|
104
|
-
if (
|
|
94
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.preventDefault();
|
|
95
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.stopPropagation();
|
|
105
96
|
if (key === 'Home') onHomeKeyDown();
|
|
106
97
|
if (key === 'End') onEndKeyDown();
|
|
107
98
|
|
|
@@ -114,17 +105,15 @@ const useDateInputs = () => {
|
|
|
114
105
|
}
|
|
115
106
|
|
|
116
107
|
if (!Number.isNaN(monthStringConvertedToInteger) && (key === '-' || key === '/' || key === '\\')) {
|
|
117
|
-
var _dayInputRef$current2, _dayInputRef$current3;
|
|
118
|
-
|
|
119
108
|
const newMonth = stringHelpers.prependStringWithPlaceHolders("".concat(monthStringConvertedToInteger), 2);
|
|
120
109
|
handleChangeMonth(newMonth, e); // auto-advance functionality:
|
|
121
110
|
|
|
122
|
-
if (newMonth.length === 2)
|
|
111
|
+
if (newMonth.length === 2) trackFocusDayInput();
|
|
123
112
|
} // focus last fragment on fill with now
|
|
124
113
|
|
|
125
114
|
|
|
126
|
-
if ((ctrlKey || metaKey) && key === ';')
|
|
127
|
-
}, [month, onHomeKeyDown, onEndKeyDown,
|
|
115
|
+
if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
|
|
116
|
+
}, [month, onHomeKeyDown, onEndKeyDown, trackFocusLastSegment, trackFocusDayInput, handleChangeMonth]);
|
|
128
117
|
const onMonthBlur = React.useCallback(e => {
|
|
129
118
|
var _e$target2;
|
|
130
119
|
|
|
@@ -151,29 +140,27 @@ const useDateInputs = () => {
|
|
|
151
140
|
handleChangeComposedDateString(newDateString, finalMetaInfo);
|
|
152
141
|
}, [month, year, getIsOutOfRangeDay, getIsDisabledDay, appOnDayChange, handleChangeComposedDateString]);
|
|
153
142
|
const onDayFocus = React.useCallback(() => {
|
|
154
|
-
|
|
155
|
-
}, [
|
|
143
|
+
trackFocusDayInput();
|
|
144
|
+
}, [trackFocusDayInput]);
|
|
156
145
|
const onDayChange = React.useCallback(e => {
|
|
157
|
-
var _e$target3
|
|
146
|
+
var _e$target3;
|
|
158
147
|
|
|
159
148
|
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
|
|
160
149
|
|
|
161
150
|
if (Number.parseInt(newDay, 10) > 3) newDay = stringHelpers.prependStringWithPlaceHolders(newDay, 2);
|
|
162
151
|
handleChangeDay(newDay, e); // auto-advance functionality:
|
|
163
152
|
|
|
164
|
-
if (newDay.length === 2)
|
|
165
|
-
}, [handleChangeDay,
|
|
153
|
+
if (newDay.length === 2) trackFocusYearInput();
|
|
154
|
+
}, [handleChangeDay, trackFocusYearInput]);
|
|
166
155
|
const onDayKeyDown = React.useCallback(e => {
|
|
167
|
-
var _lastSegmentRef$curre3, _lastSegmentRef$curre4;
|
|
168
|
-
|
|
169
156
|
const {
|
|
170
157
|
key,
|
|
171
158
|
ctrlKey,
|
|
172
159
|
metaKey
|
|
173
160
|
} = e;
|
|
174
161
|
const dayStringConvertedToInteger = Number.parseInt(day, 10);
|
|
175
|
-
if (
|
|
176
|
-
if (
|
|
162
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.preventDefault();
|
|
163
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', '-', '/', '\\'].includes(key)) e.stopPropagation();
|
|
177
164
|
if (key === 'Home') onHomeKeyDown();
|
|
178
165
|
if (key === 'End') onEndKeyDown();
|
|
179
166
|
|
|
@@ -186,24 +173,20 @@ const useDateInputs = () => {
|
|
|
186
173
|
}
|
|
187
174
|
|
|
188
175
|
if (!Number.isNaN(dayStringConvertedToInteger) && (key === '-' || key === '/' || key === '\\')) {
|
|
189
|
-
var _yearInputRef$current5, _yearInputRef$current6;
|
|
190
|
-
|
|
191
176
|
const newDay = stringHelpers.prependStringWithPlaceHolders("".concat(dayStringConvertedToInteger), 2);
|
|
192
177
|
handleChangeDay(newDay, e); // auto-advance functionality:
|
|
193
178
|
|
|
194
|
-
if (newDay.length === 2)
|
|
179
|
+
if (newDay.length === 2) trackFocusYearInput();
|
|
195
180
|
} // regressive backspace functionality
|
|
196
181
|
|
|
197
182
|
|
|
198
183
|
if (key === 'Backspace' && (day === null || day === void 0 ? void 0 : day.length) === 0) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
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);
|
|
184
|
+
trackFocusMonthInput();
|
|
202
185
|
} // focus last fragment on fill with now
|
|
203
186
|
|
|
204
187
|
|
|
205
|
-
if ((ctrlKey || metaKey) && key === ';')
|
|
206
|
-
}, [day, onHomeKeyDown, onEndKeyDown,
|
|
188
|
+
if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
|
|
189
|
+
}, [day, onHomeKeyDown, onEndKeyDown, trackFocusLastSegment, handleChangeDay, trackFocusYearInput, trackFocusMonthInput]);
|
|
207
190
|
const onDayBlur = React.useCallback(e => {
|
|
208
191
|
var _e$target4;
|
|
209
192
|
|
|
@@ -230,8 +213,8 @@ const useDateInputs = () => {
|
|
|
230
213
|
handleChangeComposedDateString(newDateString, finalMetaInfo);
|
|
231
214
|
}, [month, day, getIsOutOfRangeDay, getIsDisabledDay, appOnYearChange, handleChangeComposedDateString]);
|
|
232
215
|
const onYearFocus = React.useCallback(() => {
|
|
233
|
-
|
|
234
|
-
}, [
|
|
216
|
+
trackFocusYearInput();
|
|
217
|
+
}, [trackFocusYearInput]);
|
|
235
218
|
const onYearChange = React.useCallback(e => {
|
|
236
219
|
var _e$target5;
|
|
237
220
|
|
|
@@ -239,70 +222,68 @@ const useDateInputs = () => {
|
|
|
239
222
|
handleChangeYear(newYear, e); // auto-advance functionality:
|
|
240
223
|
|
|
241
224
|
if (newYear.length === 4) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
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) {
|
|
245
|
-
var _clearButtonRef$curre3, _clearButtonRef$curre4, _pickerButtonRef$curr3, _pickerButtonRef$curr4;
|
|
246
|
-
|
|
247
|
-
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...
|
|
225
|
+
if (!hideTime) trackFocusHourInput();else if (withAnyRightController) {
|
|
226
|
+
if (withClearBtn) trackFocusClearBtn();else if (withAnyPicker) trackFocusPicker(); // pending approval from Seda, check which one should be focused first...
|
|
248
227
|
}
|
|
249
228
|
}
|
|
250
|
-
}, [handleChangeYear, hideTime,
|
|
229
|
+
}, [handleChangeYear, hideTime, trackFocusHourInput, withAnyRightController, withClearBtn, trackFocusClearBtn, withAnyPicker, trackFocusPicker]);
|
|
251
230
|
const onYearKeyDown = React.useCallback(e => {
|
|
252
|
-
var _lastSegmentRef$curre5, _lastSegmentRef$curre6;
|
|
253
|
-
|
|
254
231
|
const {
|
|
255
232
|
key,
|
|
256
233
|
ctrlKey,
|
|
257
234
|
metaKey
|
|
258
235
|
} = e;
|
|
236
|
+
/* ****** New year value calculator logic ********* */
|
|
237
|
+
|
|
259
238
|
const yearStringConvertedToInteger = Number.parseInt(year, 10);
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (key === 'Home') onHomeKeyDown();
|
|
263
|
-
if (key === 'End') onEndKeyDown();
|
|
239
|
+
const yearInteger = Number.isNaN(yearStringConvertedToInteger) ? 0 : yearStringConvertedToInteger;
|
|
240
|
+
let newYear = yearInteger !== 0 ? stringHelpers.fillStringWithPlaceHolders("".concat(yearInteger), 4, '0') : '';
|
|
264
241
|
|
|
265
242
|
if (key === 'ArrowUp' || key === 'ArrowDown') {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
newYear = stringHelpers.prependStringWithPlaceHolders("".concat(newYear), 4);
|
|
270
|
-
handleChangeYear(newYear, e);
|
|
243
|
+
let newYearInteger;
|
|
244
|
+
if (key === 'ArrowUp') newYearInteger = yearInteger + 1 <= 9999 ? yearInteger + 1 : yearInteger;else newYearInteger = yearInteger - 1 > 0 ? yearInteger - 1 : 1;
|
|
245
|
+
newYear = stringHelpers.prependStringWithPlaceHolders("".concat(newYearInteger), 4);
|
|
271
246
|
}
|
|
272
247
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
248
|
+
const isAutomaticFillTrigger = newYear !== year && ['Tab', ' '].includes(key);
|
|
249
|
+
const metainfo = {
|
|
250
|
+
isAutomaticFillTrigger
|
|
251
|
+
};
|
|
252
|
+
/* ************* new year apply logic ************* */
|
|
253
|
+
// tab/spacebar applies auto-fill
|
|
254
|
+
// arrows up/down applies increment/decrement
|
|
276
255
|
|
|
277
|
-
|
|
278
|
-
|
|
256
|
+
if (key === 'ArrowUp' || key === 'ArrowDown' || isAutomaticFillTrigger) {
|
|
257
|
+
handleChangeYear(newYear, e, metainfo);
|
|
258
|
+
}
|
|
259
|
+
/* ************* focus tracking logic ************* */
|
|
279
260
|
|
|
280
|
-
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) {
|
|
281
|
-
var _clearButtonRef$curre5, _clearButtonRef$curre6, _pickerButtonRef$curr5, _pickerButtonRef$curr6;
|
|
282
261
|
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
} // regressive backspace functionality
|
|
262
|
+
let trackNextFocus = trackFocusResetter; // if nothing after, we reset internal focus tracker to avoid re-render unexpected focus shift
|
|
287
263
|
|
|
264
|
+
if (!hideTime) trackNextFocus = trackFocusHourInput;else if (withClearBtn) trackNextFocus = trackFocusClearBtn;else if (withAnyPicker) trackNextFocus = trackFocusPicker;
|
|
265
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', ' '].includes(key)) e.preventDefault();
|
|
266
|
+
if (['Home', 'End', 'ArrowUp', 'ArrowDown', ' '].includes(key)) e.stopPropagation();
|
|
267
|
+
if (key === 'Home') onHomeKeyDown();
|
|
268
|
+
if (key === 'End') onEndKeyDown();
|
|
269
|
+
/* ************** auto-advance logic ************** */
|
|
288
270
|
|
|
289
|
-
if (key === '
|
|
290
|
-
|
|
271
|
+
if (key === ' ') {
|
|
272
|
+
// auto-advance functionality:
|
|
273
|
+
trackNextFocus();
|
|
274
|
+
}
|
|
275
|
+
/* ********** regressive backspace logic ********** */
|
|
291
276
|
|
|
292
|
-
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);
|
|
293
|
-
} // focus last fragment on fill with now
|
|
294
277
|
|
|
278
|
+
if (key === 'Backspace' && (year === null || year === void 0 ? void 0 : year.length) === 0) {
|
|
279
|
+
trackFocusDayInput();
|
|
280
|
+
} // focus last fragment on fill with now
|
|
295
281
|
|
|
296
|
-
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);
|
|
297
|
-
}, [year, onHomeKeyDown, onEndKeyDown, lastSegmentRef, handleChangeYear, hideTime, hourInputRef, withAnyRightController, withClearBtn, clearButtonRef, withAnyPicker, pickerButtonRef, dayInputRef]);
|
|
298
|
-
const onYearBlur = React.useCallback(e => {
|
|
299
|
-
var _e$target6;
|
|
300
282
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}, [handleChangeYear]);
|
|
283
|
+
if ((ctrlKey || metaKey) && key === ';') trackFocusLastSegment();
|
|
284
|
+
}, [year, trackFocusResetter, hideTime, trackFocusHourInput, withClearBtn, trackFocusClearBtn, withAnyPicker, trackFocusPicker, onHomeKeyDown, onEndKeyDown, trackFocusLastSegment, trackFocusDayInput, handleChangeYear]);
|
|
285
|
+
const onYearBlur = React.useCallback(() => {// this was used before, now that we have a wrapping onBlur resetting the focus tracker, this is unused;
|
|
286
|
+
}, []);
|
|
306
287
|
return React.useMemo(() => ({
|
|
307
288
|
month,
|
|
308
289
|
day,
|
|
@@ -49,14 +49,40 @@ const CalendarHead = () => {
|
|
|
49
49
|
prevYearBtnRef,
|
|
50
50
|
prevMonthBtnRef,
|
|
51
51
|
nextMonthBtnRef,
|
|
52
|
-
nextYearBtnRef
|
|
52
|
+
nextYearBtnRef,
|
|
53
|
+
latestInteractionRegion,
|
|
54
|
+
currFocusDescriber
|
|
53
55
|
} = React.useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
|
|
56
|
+
const handlePrevYearRef = React.useCallback(ButtonDomNode => {
|
|
57
|
+
var _ButtonDomNode$focus;
|
|
58
|
+
|
|
59
|
+
prevYearBtnRef.current = ButtonDomNode;
|
|
60
|
+
if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-prev-year') ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus = ButtonDomNode.focus) === null || _ButtonDomNode$focus === void 0 ? void 0 : _ButtonDomNode$focus.call(ButtonDomNode);
|
|
61
|
+
}, [currFocusDescriber, latestInteractionRegion, prevYearBtnRef]);
|
|
62
|
+
const handlePrevMonthRef = React.useCallback(ButtonDomNode => {
|
|
63
|
+
var _ButtonDomNode$focus2;
|
|
64
|
+
|
|
65
|
+
prevMonthBtnRef.current = ButtonDomNode;
|
|
66
|
+
if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-prev-month') ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus2 = ButtonDomNode.focus) === null || _ButtonDomNode$focus2 === void 0 ? void 0 : _ButtonDomNode$focus2.call(ButtonDomNode);
|
|
67
|
+
}, [currFocusDescriber, latestInteractionRegion, prevMonthBtnRef]);
|
|
68
|
+
const handleNextMonthRef = React.useCallback(ButtonDomNode => {
|
|
69
|
+
var _ButtonDomNode$focus3;
|
|
70
|
+
|
|
71
|
+
nextMonthBtnRef.current = ButtonDomNode;
|
|
72
|
+
if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-next-month') ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus3 = ButtonDomNode.focus) === null || _ButtonDomNode$focus3 === void 0 ? void 0 : _ButtonDomNode$focus3.call(ButtonDomNode);
|
|
73
|
+
}, [currFocusDescriber, latestInteractionRegion, nextMonthBtnRef]);
|
|
74
|
+
const handleNextYearRef = React.useCallback(ButtonDomNode => {
|
|
75
|
+
var _ButtonDomNode$focus4;
|
|
76
|
+
|
|
77
|
+
nextYearBtnRef.current = ButtonDomNode;
|
|
78
|
+
if (latestInteractionRegion === 'calendar-head' && currFocusDescriber === 'calendar-next-year') ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus4 = ButtonDomNode.focus) === null || _ButtonDomNode$focus4 === void 0 ? void 0 : _ButtonDomNode$focus4.call(ButtonDomNode);
|
|
79
|
+
}, [currFocusDescriber, latestInteractionRegion, nextYearBtnRef]);
|
|
54
80
|
return /*#__PURE__*/_jsx__default["default"](Styleds.StyledHeader, {}, void 0, /*#__PURE__*/_jsx__default["default"](Styleds.StyledHeaderButton, {
|
|
55
81
|
"aria-label": "previous year",
|
|
56
82
|
buttonType: "raw",
|
|
57
83
|
size: DSButton.BUTTON_SIZES.M,
|
|
58
84
|
onClick: handlePrevYear,
|
|
59
|
-
innerRef:
|
|
85
|
+
innerRef: handlePrevYearRef,
|
|
60
86
|
onKeyDown: handlePrevYearKeyDown,
|
|
61
87
|
onFocus: onPrevYearFocus,
|
|
62
88
|
tabIndex: isControllerOnly ? -1 : 1,
|
|
@@ -71,7 +97,7 @@ const CalendarHead = () => {
|
|
|
71
97
|
buttonType: "raw",
|
|
72
98
|
size: DSButton.BUTTON_SIZES.M,
|
|
73
99
|
onClick: handlePrevMonth,
|
|
74
|
-
innerRef:
|
|
100
|
+
innerRef: handlePrevMonthRef,
|
|
75
101
|
onKeyDown: handlePrevMonthKeyDown,
|
|
76
102
|
onFocus: onPrevMonthFocus,
|
|
77
103
|
"data-testid": ControlledDateTimePickerDatatestid.ControlledDateTimePickerDatatestid.CALENDAR.PREV_MONTH // this is a tabstop for when the calendar is open
|
|
@@ -83,7 +109,7 @@ const CalendarHead = () => {
|
|
|
83
109
|
buttonType: "raw",
|
|
84
110
|
size: DSButton.BUTTON_SIZES.M,
|
|
85
111
|
onClick: handleNextMonth,
|
|
86
|
-
innerRef:
|
|
112
|
+
innerRef: handleNextMonthRef,
|
|
87
113
|
onKeyDown: handleNextMonthKeyDown,
|
|
88
114
|
onFocus: onNextMonthFocus,
|
|
89
115
|
"data-testid": ControlledDateTimePickerDatatestid.ControlledDateTimePickerDatatestid.CALENDAR.NEXT_MONTH
|
|
@@ -94,7 +120,7 @@ const CalendarHead = () => {
|
|
|
94
120
|
buttonType: "raw",
|
|
95
121
|
size: DSButton.BUTTON_SIZES.M,
|
|
96
122
|
onClick: handleNextYear,
|
|
97
|
-
innerRef:
|
|
123
|
+
innerRef: handleNextYearRef,
|
|
98
124
|
onKeyDown: handleNextYearKeyDown,
|
|
99
125
|
onFocus: onNextYearFocus,
|
|
100
126
|
"data-testid": ControlledDateTimePickerDatatestid.ControlledDateTimePickerDatatestid.CALENDAR.NEXT_YEAR
|
|
@@ -58,15 +58,14 @@ const Day = _ref => {
|
|
|
58
58
|
appOnDayChange,
|
|
59
59
|
appOnYearChange,
|
|
60
60
|
latestInteractionRegion,
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
isWithTimeWheelToo,
|
|
62
|
+
trackFocusCalendarMetafocusedDay
|
|
63
63
|
} = React.useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
|
|
64
64
|
const {
|
|
65
65
|
focusedDay,
|
|
66
66
|
handleDayOnKeyDown,
|
|
67
67
|
handleFocusMetaDayByDay,
|
|
68
|
-
closeCalendar
|
|
69
|
-
tryToFocusCurrentlyDataIsFocusedDay
|
|
68
|
+
closeCalendar
|
|
70
69
|
} = React.useContext(CalendarContext.CalendarContext);
|
|
71
70
|
const isFocusedMetaDay = focusedDay !== null && focusedDay !== void 0 && focusedDay.day ? dateHelpers.compareTwoDatesDayEquality(metaDay === null || metaDay === void 0 ? void 0 : metaDay.day, focusedDay === null || focusedDay === void 0 ? void 0 : focusedDay.day) : false;
|
|
72
71
|
const isSelected = React.useMemo(() => {
|
|
@@ -81,7 +80,6 @@ const Day = _ref => {
|
|
|
81
80
|
const isDayInRange = !isStartRangeDay && !isEndRangeDay && getIsDayInRange(metaDay.dayAsString);
|
|
82
81
|
const handleOnDayClick = React.useCallback(e => {
|
|
83
82
|
handleFocusMetaDayByDay(day);
|
|
84
|
-
tryToFocusCurrentlyDataIsFocusedDay();
|
|
85
83
|
|
|
86
84
|
if (!isDisabled && !isOutOfRange) {
|
|
87
85
|
const newDateString = dateHelpers.getDateStringFromDay(day);
|
|
@@ -99,13 +97,21 @@ const Day = _ref => {
|
|
|
99
97
|
if (dayNumber) appOnDayChange("".concat(dayNumber), e, metaInfo);
|
|
100
98
|
appOnYearChange("".concat(year), e, metaInfo);
|
|
101
99
|
handleChangeComposedDateString(newDateString, metaInfo);
|
|
102
|
-
|
|
100
|
+
trackFocusCalendarMetafocusedDay();
|
|
103
101
|
if (!isWithTimeWheelToo && !preventCloseOnSelection) closeCalendar();
|
|
104
102
|
}
|
|
105
|
-
}, [isDisabled, isOutOfRange,
|
|
103
|
+
}, [handleFocusMetaDayByDay, day, isDisabled, isOutOfRange, appOnMonthChange, appOnDayChange, appOnYearChange, handleChangeComposedDateString, trackFocusCalendarMetafocusedDay, isWithTimeWheelToo, preventCloseOnSelection, closeCalendar]);
|
|
104
|
+
const handleInnerRef = React.useCallback(ButtonDomNode => {
|
|
105
|
+
window.requestAnimationFrame(() => {
|
|
106
|
+
var _ButtonDomNode$focus;
|
|
107
|
+
|
|
108
|
+
dayBtnRef.current = ButtonDomNode;
|
|
109
|
+
if (isFocused) ButtonDomNode === null || ButtonDomNode === void 0 ? void 0 : (_ButtonDomNode$focus = ButtonDomNode.focus) === null || _ButtonDomNode$focus === void 0 ? void 0 : _ButtonDomNode$focus.call(ButtonDomNode);
|
|
110
|
+
});
|
|
111
|
+
}, [dayBtnRef, isFocused]);
|
|
106
112
|
const handleOnDayFocus = React.useCallback(() => {
|
|
107
|
-
|
|
108
|
-
}, [
|
|
113
|
+
trackFocusCalendarMetafocusedDay('calendar-days');
|
|
114
|
+
}, [trackFocusCalendarMetafocusedDay]);
|
|
109
115
|
const dayClassModifiers = React.useMemo(() => "dayWrapper ".concat(isSelected ? 'selectedDay ' : '').concat(isDisabled ? 'disabledDay ' : '').concat(isOutOfRange ? 'outOfRangeDay ' : '').concat(isFocused ? 'focusedDay ' : '').concat(isStartRangeDay ? 'startRangeDay ' : '').concat(isDayInRange ? 'inRangeDay ' : '').concat(isEndRangeDay ? 'endRangeDay ' : '').concat(isCurrMonthDay ? '' : 'notCurrentMonth'), [isSelected, isDisabled, isOutOfRange, isFocused, isStartRangeDay, isDayInRange, isEndRangeDay, isCurrMonthDay]);
|
|
110
116
|
let dataTestid = ControlledDateTimePickerDatatestid.ControlledDateTimePickerDatatestid.CALENDAR.DAY;
|
|
111
117
|
if (isSelected) dataTestid = ControlledDateTimePickerDatatestid.ControlledDateTimePickerDatatestid.CALENDAR.SELECTED_DAY;
|
|
@@ -133,7 +139,7 @@ const Day = _ref => {
|
|
|
133
139
|
onKeyDown: e => {
|
|
134
140
|
handleDayOnKeyDown(e, metaDay);
|
|
135
141
|
},
|
|
136
|
-
innerRef:
|
|
142
|
+
innerRef: handleInnerRef,
|
|
137
143
|
tabIndex: isSelected ? 0 : -1,
|
|
138
144
|
"data-isfocused": isFocused,
|
|
139
145
|
"data-testid": dataTestid
|
|
@@ -25,24 +25,24 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
25
25
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
26
26
|
const useConfigCalendarCTX = () => {
|
|
27
27
|
const {
|
|
28
|
-
|
|
28
|
+
trackFocusCalendarPrevYear,
|
|
29
|
+
trackFocusCalendarNextYear,
|
|
30
|
+
trackFocusCalendarPrevMonth,
|
|
31
|
+
trackFocusCalendarNextMonth
|
|
29
32
|
} = React.useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
|
|
30
33
|
const [showCalendar, setShowCalendar] = React.useState(false);
|
|
31
|
-
const setLatestInteractionRegionCalendarHead = React.useCallback(() => {
|
|
32
|
-
setLatestInteractionRegion('calendar-head');
|
|
33
|
-
}, [setLatestInteractionRegion]);
|
|
34
34
|
const onPrevYearFocus = React.useCallback(() => {
|
|
35
|
-
|
|
36
|
-
}, [
|
|
35
|
+
trackFocusCalendarPrevYear();
|
|
36
|
+
}, [trackFocusCalendarPrevYear]);
|
|
37
37
|
const onPrevMonthFocus = React.useCallback(() => {
|
|
38
|
-
|
|
39
|
-
}, [
|
|
38
|
+
trackFocusCalendarPrevMonth();
|
|
39
|
+
}, [trackFocusCalendarPrevMonth]);
|
|
40
40
|
const onNextMonthFocus = React.useCallback(() => {
|
|
41
|
-
|
|
42
|
-
}, [
|
|
41
|
+
trackFocusCalendarNextMonth();
|
|
42
|
+
}, [trackFocusCalendarNextMonth]);
|
|
43
43
|
const onNextYearFocus = React.useCallback(() => {
|
|
44
|
-
|
|
45
|
-
}, [
|
|
44
|
+
trackFocusCalendarNextYear();
|
|
45
|
+
}, [trackFocusCalendarNextYear]);
|
|
46
46
|
const currentDisplayedMonthLogic = useCurrentDisplayedMonthYearLogic.useCurrentDisplayedMonthYearLogic();
|
|
47
47
|
const focusLogic = useFocusLogic.useFocusLogic({
|
|
48
48
|
currentDisplayedMonthLogic,
|
|
@@ -7,31 +7,13 @@ require('core-js/modules/esnext.async-iterator.find.js');
|
|
|
7
7
|
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
8
|
require('core-js/modules/esnext.iterator.find.js');
|
|
9
9
|
var React = require('react');
|
|
10
|
-
var ControlledDateTimePickerCTX = require('../../../ControlledDateTimePickerCTX.js');
|
|
11
10
|
var dateHelpers = require('../../../utils/dateHelpers.js');
|
|
12
11
|
var useGetStartingFocusedDay = require('../../../utils/hooks/useGetStartingFocusedDay.js');
|
|
13
12
|
|
|
14
|
-
// eslint-disable-next-line max-params
|
|
15
|
-
const loopWhileWaiting = function (cb) {
|
|
16
|
-
let shortcircuit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => false;
|
|
17
|
-
let timePerTry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
|
|
18
|
-
let maxTries = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 5;
|
|
19
|
-
let ab = maxTries;
|
|
20
|
-
const inter = setInterval(() => {
|
|
21
|
-
cb();
|
|
22
|
-
if (shortcircuit() || ab === 0) clearInterval(inter);
|
|
23
|
-
ab -= 1;
|
|
24
|
-
}, timePerTry);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
13
|
const useFocusLogic = _ref => {
|
|
28
14
|
let {
|
|
29
|
-
currentDisplayedMonthLogic
|
|
30
|
-
showCalendar
|
|
15
|
+
currentDisplayedMonthLogic
|
|
31
16
|
} = _ref;
|
|
32
|
-
const {
|
|
33
|
-
calendarDaysWrapperRef
|
|
34
|
-
} = React.useContext(ControlledDateTimePickerCTX.ControlledDateTimePickerContext);
|
|
35
17
|
const {
|
|
36
18
|
daysArray
|
|
37
19
|
} = currentDisplayedMonthLogic;
|
|
@@ -63,23 +45,6 @@ const useFocusLogic = _ref => {
|
|
|
63
45
|
});
|
|
64
46
|
return newFocusedDay;
|
|
65
47
|
}, [daysArray, startFocusedDate, metadayToFocus]);
|
|
66
|
-
const tryToFocusCurrentlyDataIsFocusedDay = React.useCallback(function () {
|
|
67
|
-
let wrapperDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (calendarDaysWrapperRef === null || calendarDaysWrapperRef === void 0 ? void 0 : calendarDaysWrapperRef.current) || document;
|
|
68
|
-
let shortcircuit = false;
|
|
69
|
-
loopWhileWaiting(() => {
|
|
70
|
-
const domElem = wrapperDOM === null || wrapperDOM === void 0 ? void 0 : wrapperDOM.querySelector('[data-isfocused="true"]');
|
|
71
|
-
|
|
72
|
-
if (domElem) {
|
|
73
|
-
var _domElem$focus;
|
|
74
|
-
|
|
75
|
-
domElem === null || domElem === void 0 ? void 0 : (_domElem$focus = domElem.focus) === null || _domElem$focus === void 0 ? void 0 : _domElem$focus.call(domElem);
|
|
76
|
-
shortcircuit = true;
|
|
77
|
-
}
|
|
78
|
-
}, () => shortcircuit);
|
|
79
|
-
}, [calendarDaysWrapperRef]);
|
|
80
|
-
React.useLayoutEffect(() => {
|
|
81
|
-
if (showCalendar) tryToFocusCurrentlyDataIsFocusedDay(calendarDaysWrapperRef === null || calendarDaysWrapperRef === void 0 ? void 0 : calendarDaysWrapperRef.current);
|
|
82
|
-
}, [calendarDaysWrapperRef, focusedDay, showCalendar, tryToFocusCurrentlyDataIsFocusedDay]);
|
|
83
48
|
const handleFocusMetaDay = React.useCallback(metaDayToFocus => {
|
|
84
49
|
// if focusedDay is inside current daysArray we set Focused day
|
|
85
50
|
const newFocusedMetaDay = daysArray.find(_ref5 => {
|
|
@@ -105,11 +70,10 @@ const useFocusLogic = _ref => {
|
|
|
105
70
|
}, []);
|
|
106
71
|
return React.useMemo(() => ({
|
|
107
72
|
focusedDay,
|
|
108
|
-
tryToFocusCurrentlyDataIsFocusedDay,
|
|
109
73
|
resetFocusedDayToStartDate,
|
|
110
74
|
handleFocusMetaDay,
|
|
111
75
|
handleFocusMetaDayByDay
|
|
112
|
-
}), [focusedDay,
|
|
76
|
+
}), [focusedDay, resetFocusedDayToStartDate, handleFocusMetaDay, handleFocusMetaDayByDay]);
|
|
113
77
|
};
|
|
114
78
|
|
|
115
79
|
exports.useFocusLogic = useFocusLogic;
|