@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
|
@@ -28,6 +28,7 @@ const useKeyboardNavigation = () => {
|
|
|
28
28
|
inputValue,
|
|
29
29
|
showPopover,
|
|
30
30
|
focusOptionIdx,
|
|
31
|
+
listRef,
|
|
31
32
|
selectAllCheckboxRef,
|
|
32
33
|
toggleSelectionButtonRef,
|
|
33
34
|
setShowPopover,
|
|
@@ -47,6 +48,14 @@ const useKeyboardNavigation = () => {
|
|
|
47
48
|
|
|
48
49
|
if (['ArrowDown', 'ArrowUp', 'Enter', 'Spacebar'].includes(e.key) || e.keyCode >= 48 && e.keyCode <= 90) {
|
|
49
50
|
setShowPopover(true);
|
|
51
|
+
window.requestAnimationFrame(() => {
|
|
52
|
+
if (listRef.current && window.scrollY < listRef.current.offsetHeight) {
|
|
53
|
+
window.scrollTo({
|
|
54
|
+
top: listRef.current.offsetHeight,
|
|
55
|
+
behavior: 'smooth'
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
50
59
|
} // =============================================================================
|
|
51
60
|
// ESCAPE
|
|
52
61
|
// =============================================================================
|
|
@@ -67,7 +76,7 @@ const useKeyboardNavigation = () => {
|
|
|
67
76
|
|
|
68
77
|
|
|
69
78
|
if (e.key === 'Enter' && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === INTERNAL_MENU_OPTION_TYPES.CREATABLE && onCreate) {
|
|
70
|
-
onCreate(inputValue); //blank active item to force search last one
|
|
79
|
+
onCreate(inputValue); // blank active item to force search last one
|
|
71
80
|
|
|
72
81
|
setFocusOptionIdx('');
|
|
73
82
|
if (onFilter) onFilter(allOptions, '');
|
|
@@ -110,9 +119,12 @@ const useKeyboardNavigation = () => {
|
|
|
110
119
|
e.stopPropagation();
|
|
111
120
|
|
|
112
121
|
if ((showPopover || inline) && selectableOptions.length) {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
const nextItemIndexIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable);
|
|
123
|
+
|
|
124
|
+
if (nextItemIndexIndex > -1) {
|
|
125
|
+
setFocusOptionIdx(filteredOptions[nextItemIndexIndex].dsId);
|
|
126
|
+
scrollOptionIntoView(filteredOptions[nextItemIndexIndex].dsId);
|
|
127
|
+
}
|
|
116
128
|
}
|
|
117
129
|
}
|
|
118
130
|
|
|
@@ -122,16 +134,19 @@ const useKeyboardNavigation = () => {
|
|
|
122
134
|
if (!selectableOptions.length) return;
|
|
123
135
|
const prevItemIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable, -1);
|
|
124
136
|
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
if (prevItemIndex > -1) {
|
|
138
|
+
if (showPopover || inline) {
|
|
139
|
+
setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);
|
|
140
|
+
scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);
|
|
141
|
+
} else {
|
|
142
|
+
// open menu and search last item to focused
|
|
143
|
+
setShowPopover(true);
|
|
144
|
+
const lastItemIndex = findInCircularList(filteredOptions, 0, isOptionFocuseable, -1);
|
|
145
|
+
setFocusOptionIdx(filteredOptions[lastItemIndex].dsId);
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
scrollOptionIntoView(filteredOptions[lastItemIndex].dsId);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
135
150
|
}
|
|
136
151
|
} // =============================================================================
|
|
137
152
|
// BACKSPACE
|
|
@@ -163,7 +178,7 @@ const useKeyboardNavigation = () => {
|
|
|
163
178
|
setShowPopover(false);
|
|
164
179
|
}
|
|
165
180
|
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
166
|
-
[onKeyDown, currentItem, onCreate, multiple, inputValue, inline, withoutPortal, setShowPopover, onCancel, onFilter, setInputValue, focusOptionIdx, showPopover, selectableOptions.length, filteredOptions, currentItemIndex, setFocusOptionIdx, selectedValues, onChange, selectAllCheckboxRef, toggleSelectionButtonRef]);
|
|
181
|
+
[onKeyDown, currentItem, onCreate, multiple, inputValue, inline, withoutPortal, setShowPopover, onCancel, onFilter, setInputValue, listRef, focusOptionIdx, showPopover, selectableOptions.length, filteredOptions, currentItemIndex, setFocusOptionIdx, selectedValues, onChange, selectAllCheckboxRef, toggleSelectionButtonRef]);
|
|
167
182
|
return {
|
|
168
183
|
onInputKeyDown
|
|
169
184
|
};
|
|
@@ -14,6 +14,7 @@ const HeaderList = () => {
|
|
|
14
14
|
const {
|
|
15
15
|
props: {
|
|
16
16
|
selectedValues,
|
|
17
|
+
filteredOptions,
|
|
17
18
|
onSelectAll
|
|
18
19
|
},
|
|
19
20
|
showSelectedOptions,
|
|
@@ -32,15 +33,15 @@ const HeaderList = () => {
|
|
|
32
33
|
} = useHeaderListHandlers();
|
|
33
34
|
return /*#__PURE__*/_jsx(StyledHeaderListWrapper, {
|
|
34
35
|
onKeyDown: handleKeyDown,
|
|
35
|
-
onMouseDown: handleOnMouseDown
|
|
36
|
+
onMouseDown: handleOnMouseDown,
|
|
37
|
+
"data-testid": ComboboxDataTestid.MULTISELECT.HEADER_LIST
|
|
36
38
|
}, void 0, /*#__PURE__*/_jsx(StyledSelectAllCheckbox, {}, void 0, onSelectAll && /*#__PURE__*/_jsx(DSControlledCheckbox, {
|
|
37
39
|
checked: checkboxStatus,
|
|
38
|
-
"aria-controls":
|
|
40
|
+
"aria-controls": filteredOptions.map(item => item.dsId).join(' '),
|
|
39
41
|
name: "select-all-checkbox",
|
|
40
42
|
"aria-label": "Select/Unselect All Items",
|
|
41
43
|
id: "select-all-checkbox",
|
|
42
44
|
onChange: handleSelectAllCheckboxChange,
|
|
43
|
-
"data-testid": ComboboxDataTestid.MULTISELECT.SELECT_ALL_CHECKBOX,
|
|
44
45
|
onKeyDown: handleCheckAllOnTab,
|
|
45
46
|
innerRef: selectAllCheckboxRef
|
|
46
47
|
})), /*#__PURE__*/_jsx(StyledSelectedItems, {}, void 0, multiSelectedValues.length > 0 ? /*#__PURE__*/_jsx(StyledButtonSelection, {
|
|
@@ -51,27 +51,31 @@ const useHeaderListHandlers = () => {
|
|
|
51
51
|
e.preventDefault();
|
|
52
52
|
setShowSelectedOptions(!showSelectedOptions);
|
|
53
53
|
}, [setShowSelectedOptions, showSelectedOptions]); // when pressing escape on each header list button we close the menu
|
|
54
|
+
// and set focus on input
|
|
54
55
|
|
|
55
56
|
const handleKeyDown = useCallback(e => {
|
|
56
57
|
if (e.key === 'Escape') {
|
|
58
|
+
var _innerRef$current;
|
|
59
|
+
|
|
57
60
|
setShowPopover(false);
|
|
61
|
+
(_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.focus();
|
|
58
62
|
}
|
|
59
|
-
}, [setShowPopover]); // when hitting tab on selected values button filter we target the input again
|
|
63
|
+
}, [setShowPopover, innerRef]); // when hitting tab on selected values button filter we target the input again
|
|
60
64
|
|
|
61
65
|
const handleFilterSelectionBtnOnTab = useCallback(e => {
|
|
62
66
|
if (e.key === 'Tab' && !e.shiftKey) {
|
|
63
|
-
var _innerRef$
|
|
67
|
+
var _innerRef$current2;
|
|
64
68
|
|
|
65
69
|
e.preventDefault();
|
|
66
|
-
(_innerRef$
|
|
70
|
+
(_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.focus();
|
|
67
71
|
}
|
|
68
72
|
}, [innerRef]);
|
|
69
73
|
const handleCheckAllOnTab = useCallback(e => {
|
|
70
74
|
if (e.key === 'Tab' && !e.shiftKey && multiSelectedValues.length === 0) {
|
|
71
|
-
var _innerRef$
|
|
75
|
+
var _innerRef$current3;
|
|
72
76
|
|
|
73
77
|
e.preventDefault();
|
|
74
|
-
(_innerRef$
|
|
78
|
+
(_innerRef$current3 = innerRef.current) === null || _innerRef$current3 === void 0 ? void 0 : _innerRef$current3.focus();
|
|
75
79
|
}
|
|
76
80
|
}, [innerRef, multiSelectedValues]);
|
|
77
81
|
useEffect(() => {
|
|
@@ -40,7 +40,9 @@ const MenuList = () => {
|
|
|
40
40
|
inline: inline,
|
|
41
41
|
onMouseDown: preventLoseInputFocus,
|
|
42
42
|
width: width,
|
|
43
|
-
minWidth: menuMinWidth
|
|
43
|
+
minWidth: menuMinWidth // we use width as key to force react virtual re-render on window resize
|
|
44
|
+
// and update the item height accordly
|
|
45
|
+
,
|
|
44
46
|
children: [withHeader && (_HeaderList || (_HeaderList = /*#__PURE__*/_jsx(HeaderList, {}))), filteredOptions.length > 0 || onCreate ? /*#__PURE__*/jsx(StyledVirtualListWrapper, {
|
|
45
47
|
inline: inline,
|
|
46
48
|
maxHeight: menuMaxHeight,
|
|
@@ -56,9 +58,10 @@ const MenuList = () => {
|
|
|
56
58
|
}
|
|
57
59
|
}, void 0, ItemRenderer)
|
|
58
60
|
}) : _StyledNoResultsWrapp || (_StyledNoResultsWrapp = /*#__PURE__*/_jsx(StyledNoResultsWrapper, {
|
|
61
|
+
role: "alert",
|
|
59
62
|
"aria-live": "polite"
|
|
60
63
|
}, void 0, "No matches found"))]
|
|
61
|
-
}), [wrapperListRef, inline, preventLoseInputFocus,
|
|
64
|
+
}, width), [wrapperListRef, inline, preventLoseInputFocus, menuMinWidth, withHeader, filteredOptions.length, onCreate, menuMaxHeight, listRef, virtualListHelpers === null || virtualListHelpers === void 0 ? void 0 : virtualListHelpers.totalSize, ItemRenderer, width]);
|
|
62
65
|
};
|
|
63
66
|
|
|
64
67
|
export { MenuList };
|
|
@@ -2,7 +2,7 @@ import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLit
|
|
|
2
2
|
import { styled } from '@elliemae/ds-system';
|
|
3
3
|
|
|
4
4
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
5
|
-
const StyledListWrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-width: ", ";\n width: ", ";\n background-color: #ffffff;\n"])), _ref => {
|
|
5
|
+
const StyledListWrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-width: ", ";\n width: ", ";\n background-color: #ffffff;\n max-height: ", ";\n z-index: 100;\n"])), _ref => {
|
|
6
6
|
let {
|
|
7
7
|
inline,
|
|
8
8
|
minWidth
|
|
@@ -13,18 +13,23 @@ const StyledListWrapper = styled.div(_templateObject || (_templateObject = _tagg
|
|
|
13
13
|
width
|
|
14
14
|
} = _ref2;
|
|
15
15
|
return "".concat(width, "px");
|
|
16
|
+
}, _ref3 => {
|
|
17
|
+
let {
|
|
18
|
+
maxHeight
|
|
19
|
+
} = _ref3;
|
|
20
|
+
return "".concat(maxHeight, "px");
|
|
16
21
|
});
|
|
17
|
-
const StyledList = styled.ul(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n padding: 0;\n"])));
|
|
18
|
-
const StyledVirtualListWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow-y: auto;\n margin-top: ", ";\n
|
|
22
|
+
const StyledList = styled.ul(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n padding: 0;\n background-color: #ffffff;\n"])));
|
|
23
|
+
const StyledVirtualListWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow-y: auto;\n margin-top: ", ";\n max-height: ", ";\n"])), _ref4 => {
|
|
19
24
|
let {
|
|
20
25
|
withHeader
|
|
21
|
-
} =
|
|
26
|
+
} = _ref4;
|
|
22
27
|
return withHeader ? '28px' : '';
|
|
23
|
-
},
|
|
28
|
+
}, _ref5 => {
|
|
24
29
|
let {
|
|
25
30
|
maxHeight
|
|
26
|
-
} =
|
|
27
|
-
return
|
|
31
|
+
} = _ref5;
|
|
32
|
+
return maxHeight ? "".concat(maxHeight, "px") : '300px';
|
|
28
33
|
});
|
|
29
34
|
const StyledCreatableLabel = styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-weight: bold;\n font-style: italic;\n"])));
|
|
30
35
|
const StyledNoResultsWrapper = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding: 16px;\n"])));
|
|
@@ -78,9 +78,10 @@ const useItemRenderer = () => {
|
|
|
78
78
|
const generalProps = {
|
|
79
79
|
wrapperStyles: {
|
|
80
80
|
position: 'absolute',
|
|
81
|
-
top:
|
|
81
|
+
top: 0,
|
|
82
82
|
left: 0,
|
|
83
|
-
width: '100%'
|
|
83
|
+
width: '100%',
|
|
84
|
+
transform: "translateY(".concat(vItem.start, "px)")
|
|
84
85
|
},
|
|
85
86
|
key: "".concat(option.dsId),
|
|
86
87
|
innerRef: vItem.measureRef
|
|
@@ -105,8 +106,8 @@ const useItemRenderer = () => {
|
|
|
105
106
|
onClick: e => handleClick(option, e),
|
|
106
107
|
onMouseDown: handleOnMouseDown,
|
|
107
108
|
isActive: option.dsId === focusOptionIdx,
|
|
108
|
-
isSelected: isSelected(selectedValues, option)
|
|
109
|
-
|
|
109
|
+
isSelected: isSelected(selectedValues, option) //tabIndex={-1}
|
|
110
|
+
|
|
110
111
|
}));
|
|
111
112
|
}
|
|
112
113
|
|
|
@@ -21,7 +21,7 @@ const MultiSelectedValuesContainer = () => {
|
|
|
21
21
|
const correctPillsToShow = useGroupPills();
|
|
22
22
|
return useMemo(() => /*#__PURE__*/_jsx("div", {
|
|
23
23
|
style: {
|
|
24
|
-
width: 'max-content'
|
|
24
|
+
width: multiSelectedValue.length > 0 ? 'max-content' : '0px'
|
|
25
25
|
},
|
|
26
26
|
"data-testid": ComboboxDataTestid.SELECTED_VALUES
|
|
27
27
|
}, void 0, /*#__PURE__*/_jsx(DSPillGroupV2, {
|
|
@@ -25,6 +25,8 @@ const RemovableSelectedValuePill = props => {
|
|
|
25
25
|
onRemove: e => {
|
|
26
26
|
var _innerRef$current;
|
|
27
27
|
|
|
28
|
+
// preventing the menu to be opened
|
|
29
|
+
e.stopPropagation();
|
|
28
30
|
onChange(getSuggestedValueOnChange(pill, selectedValues), pill, e);
|
|
29
31
|
(_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.focus();
|
|
30
32
|
}
|
|
@@ -25,8 +25,11 @@ const useGroupPills = () => {
|
|
|
25
25
|
controlsWrapperRef,
|
|
26
26
|
pillGroupRef
|
|
27
27
|
} = useContext(ComboBoxContext);
|
|
28
|
-
const multiSelectedValues = selectedValues;
|
|
29
|
-
|
|
28
|
+
const multiSelectedValues = selectedValues; // 30 represent 30 pills maximum to calculate the grouped pill. this fix the load time issue
|
|
29
|
+
// when combobox is receiving a huge amount of options.
|
|
30
|
+
|
|
31
|
+
const selectedValuesLength = Math.min(30, multiSelectedValues.length);
|
|
32
|
+
const [pillsToShow, setPillsToShow] = useState(selectedValuesLength);
|
|
30
33
|
const {
|
|
31
34
|
width
|
|
32
35
|
} = useOnElementResize(controlsWrapperRef);
|
|
@@ -34,28 +37,28 @@ const useGroupPills = () => {
|
|
|
34
37
|
width: widthInput
|
|
35
38
|
} = useOnElementResize(innerRef || null);
|
|
36
39
|
useEffect(() => {
|
|
37
|
-
if (
|
|
38
|
-
setPillsToShow(
|
|
40
|
+
if (selectedValuesLength !== pillsToShow) {
|
|
41
|
+
setPillsToShow(selectedValuesLength);
|
|
39
42
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
43
|
|
|
41
|
-
}, [
|
|
44
|
+
}, [selectedValuesLength, width, widthInput]);
|
|
42
45
|
useLayoutEffect(() => {
|
|
43
|
-
if (selectedOptionsRef.current) {
|
|
46
|
+
if (selectedOptionsRef.current && pillGroupRef.current) {
|
|
44
47
|
if (pillGroupRef.current) pillGroupRef.current.style.width = 'max-content';
|
|
45
48
|
let lastPillFit = -1;
|
|
46
49
|
let currentWidth = 0;
|
|
47
50
|
const referenceWidth = selectedOptionsRef.current.offsetWidth;
|
|
48
|
-
const pills = [...
|
|
51
|
+
const pills = [...pillGroupRef.current.querySelectorAll(disabled ? '.ds-pill-wrapper-value' : '.ds-pill-wrapper-removable')];
|
|
49
52
|
const pillsWidth = pills.map(pill => pill === null || pill === void 0 ? void 0 : pill.offsetWidth);
|
|
50
53
|
pillsWidth.forEach((pillWidth, idx) => {
|
|
51
54
|
currentWidth += pillWidth;
|
|
52
55
|
|
|
53
|
-
if (currentWidth + getGroupedPillWidth(
|
|
56
|
+
if (currentWidth + getGroupedPillWidth(selectedValuesLength - idx - 1) <= referenceWidth) {
|
|
54
57
|
lastPillFit = idx;
|
|
55
58
|
}
|
|
56
59
|
});
|
|
57
60
|
|
|
58
|
-
if (!(
|
|
61
|
+
if (!(selectedValuesLength > 0 && pillsToShow !== selectedValuesLength)) {
|
|
59
62
|
const nextPillsToShow = lastPillFit + 1;
|
|
60
63
|
|
|
61
64
|
if (nextPillsToShow !== pillsToShow) {
|
|
@@ -65,7 +68,7 @@ const useGroupPills = () => {
|
|
|
65
68
|
|
|
66
69
|
if (pillGroupRef.current) pillGroupRef.current.style.width = 'fit-content';
|
|
67
70
|
}
|
|
68
|
-
}, [selectedOptionsRef, innerRef, multiSelectedValues, pillsToShow, pillGroupRef, width, widthInput, disabled]);
|
|
71
|
+
}, [selectedOptionsRef, innerRef, multiSelectedValues, pillsToShow, pillGroupRef, width, widthInput, disabled, selectedValuesLength]);
|
|
69
72
|
return pillsToShow || 1;
|
|
70
73
|
};
|
|
71
74
|
|
|
@@ -47,7 +47,8 @@ const getFirstOption = (options, selectedValues, inputValue) => {
|
|
|
47
47
|
|
|
48
48
|
for (let i = 0; i < options.length; i += 1) if (!['section', 'separator'].includes(options[i].type) && !options[i].disabled) {
|
|
49
49
|
return options[i].dsId;
|
|
50
|
-
}
|
|
50
|
+
} // list of disabled item results return ''
|
|
51
|
+
|
|
51
52
|
|
|
52
53
|
return '';
|
|
53
54
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
1
3
|
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
4
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
5
|
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
6
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
7
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
8
|
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
9
9
|
import '../../date-time-picker/ControlledDateTimePicker.js';
|
|
10
10
|
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
@@ -18,7 +18,7 @@ const useChangeHandlers = _ref => {
|
|
|
18
18
|
relevantValues,
|
|
19
19
|
destructuredValues,
|
|
20
20
|
propsBasedOnType,
|
|
21
|
-
|
|
21
|
+
focusTrackers
|
|
22
22
|
} = _ref;
|
|
23
23
|
const {
|
|
24
24
|
tempDateString,
|
|
@@ -52,8 +52,8 @@ const useChangeHandlers = _ref => {
|
|
|
52
52
|
meridiem
|
|
53
53
|
} = destructuredValues;
|
|
54
54
|
const {
|
|
55
|
-
|
|
56
|
-
} =
|
|
55
|
+
trackFocusFirstSegment
|
|
56
|
+
} = focusTrackers;
|
|
57
57
|
const getDateMetaInfo = useCallback(function () {
|
|
58
58
|
let newDateString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
59
59
|
let metaInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -83,7 +83,7 @@ const useChangeHandlers = _ref => {
|
|
|
83
83
|
setTimeString(newTimeString);
|
|
84
84
|
const newDateTimeString = "".concat(newDateString, " ").concat(newTimeString);
|
|
85
85
|
|
|
86
|
-
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread({}, getTimeMetaInfo(newTimeString, metaInfo)), getDateMetaInfo(newDateString, metaInfo)), {}, {
|
|
86
|
+
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, metaInfo), getTimeMetaInfo(newTimeString, metaInfo)), getDateMetaInfo(newDateString, metaInfo)), {}, {
|
|
87
87
|
newDateString,
|
|
88
88
|
newTimeString,
|
|
89
89
|
newDateTimeString
|
|
@@ -100,7 +100,7 @@ const useChangeHandlers = _ref => {
|
|
|
100
100
|
setTempDateString(newDateString);
|
|
101
101
|
const newDateTimeString = "".concat(newDateString, " ").concat(tempTimeString);
|
|
102
102
|
|
|
103
|
-
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread({}, getTimeMetaInfo(tempTimeString, metaInfo)), getDateMetaInfo(newDateString, metaInfo)), {}, {
|
|
103
|
+
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, metaInfo), getTimeMetaInfo(tempTimeString, metaInfo)), getDateMetaInfo(newDateString, metaInfo)), {}, {
|
|
104
104
|
newDateString,
|
|
105
105
|
newTimeString: tempTimeString,
|
|
106
106
|
newDateTimeString
|
|
@@ -116,7 +116,7 @@ const useChangeHandlers = _ref => {
|
|
|
116
116
|
setTimeString(newTimeString);
|
|
117
117
|
const newDateTimeString = "".concat(tempDateString, " ").concat(newTimeString);
|
|
118
118
|
|
|
119
|
-
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread({}, getTimeMetaInfo(newTimeString, metaInfo)), getDateMetaInfo(tempDateString, metaInfo)), {}, {
|
|
119
|
+
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, metaInfo), getTimeMetaInfo(newTimeString, metaInfo)), getDateMetaInfo(tempDateString, metaInfo)), {}, {
|
|
120
120
|
newDateTimeString,
|
|
121
121
|
newDateString: tempDateString,
|
|
122
122
|
newTimeString
|
|
@@ -233,12 +233,8 @@ const useChangeHandlers = _ref => {
|
|
|
233
233
|
if (isDateTime) handleChangeComposedDateTimeString('__/__/____', '__:__ __', metaInfo);
|
|
234
234
|
if (isDate) handleChangeComposedDateString('__/__/____', metaInfo);
|
|
235
235
|
if (isTime) handleChangeComposedTimeString('__:__ __', metaInfo);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
(_firstSegmentRef$curr = firstSegmentRef.current) === null || _firstSegmentRef$curr === void 0 ? void 0 : _firstSegmentRef$curr.focus();
|
|
240
|
-
});
|
|
241
|
-
}, [appOnDayChange, appOnHourChange, appOnMeridiemChange, appOnMinuteChange, appOnMonthChange, appOnYearChange, firstSegmentRef, handleChangeComposedDateString, handleChangeComposedDateTimeString, handleChangeComposedTimeString, isDate, isDateTime, isTime]);
|
|
236
|
+
trackFocusFirstSegment();
|
|
237
|
+
}, [appOnDayChange, appOnHourChange, appOnMeridiemChange, appOnMinuteChange, appOnMonthChange, appOnYearChange, handleChangeComposedDateString, handleChangeComposedDateTimeString, handleChangeComposedTimeString, isDate, isDateTime, isTime, trackFocusFirstSegment]);
|
|
242
238
|
return useMemo(() => ({
|
|
243
239
|
handleChangeComposedDateTimeString,
|
|
244
240
|
handleChangeComposedDateString,
|
|
@@ -4,10 +4,10 @@ import 'core-js/modules/esnext.iterator.filter.js';
|
|
|
4
4
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
5
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import '
|
|
8
|
-
import React, { useState } from 'react';
|
|
7
|
+
import React from 'react';
|
|
9
8
|
import { getDataProps } from '@elliemae/ds-props-helpers';
|
|
10
9
|
import { useGetDatePickerWithDefaultsProps } from './useGetPropsWithDefault.js';
|
|
10
|
+
import { useFocusTracker } from './useFocusTracker.js';
|
|
11
11
|
import { useGetFlags } from './useGetFlags.js';
|
|
12
12
|
import { useGetReferences } from './useGetReferences.js';
|
|
13
13
|
import { useRelevantValueFromProps } from './useRelevantValueFromProps.js';
|
|
@@ -27,6 +27,10 @@ const useControlledDateTimePicker = props => {
|
|
|
27
27
|
const flags = useGetFlags(propsWithDefaults);
|
|
28
28
|
const DOMRefs = useGetReferences(flags); // refs are used for "auto-advance" feature
|
|
29
29
|
|
|
30
|
+
const focusTrackers = useFocusTracker({
|
|
31
|
+
DOMRefs,
|
|
32
|
+
flags
|
|
33
|
+
});
|
|
30
34
|
const relevantValues = useRelevantValueFromProps(propsWithDefaults);
|
|
31
35
|
const propsBasedOnType = useGetPropsBasedOnType(propsWithDefaults);
|
|
32
36
|
const destructuredValues = useGetDestructuredValues(_objectSpread(_objectSpread({}, propsBasedOnType), flags));
|
|
@@ -34,17 +38,18 @@ const useControlledDateTimePicker = props => {
|
|
|
34
38
|
relevantValues,
|
|
35
39
|
destructuredValues,
|
|
36
40
|
propsBasedOnType,
|
|
37
|
-
DOMRefs
|
|
41
|
+
DOMRefs,
|
|
42
|
+
focusTrackers
|
|
38
43
|
});
|
|
39
44
|
const globalKeyHandlers = useGlobalKeyHandlers({
|
|
40
45
|
changeHandlers,
|
|
41
46
|
propsBasedOnType,
|
|
42
47
|
DOMRefs,
|
|
43
|
-
flags
|
|
48
|
+
flags,
|
|
49
|
+
focusTrackers
|
|
44
50
|
}); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
45
51
|
|
|
46
52
|
const dataAttrs = getDataProps(propsWithDefaults);
|
|
47
|
-
const [latestInteractionRegion, setLatestInteractionRegion] = useState('');
|
|
48
53
|
const {
|
|
49
54
|
announcedDateValues,
|
|
50
55
|
announcedTimeValues
|
|
@@ -55,13 +60,12 @@ const useControlledDateTimePicker = props => {
|
|
|
55
60
|
isWithTimeInputs
|
|
56
61
|
} = flags;
|
|
57
62
|
const ariaCurrentValueForInputs = "current values: ".concat(isWithDateInputs ? "".concat(announcedDateValues) : '').concat(isDateTimeSelector ? ', ' : '').concat(isWithTimeInputs ? "".concat(announcedTimeValues) : '');
|
|
58
|
-
const ctx = React.useMemo(() => _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
63
|
+
const ctx = React.useMemo(() => _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
59
64
|
props: propsWithDefaults,
|
|
60
|
-
latestInteractionRegion,
|
|
61
|
-
setLatestInteractionRegion,
|
|
62
65
|
ariaCurrentValueForInputs,
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
63
67
|
dataAttrs
|
|
64
|
-
}, flags), DOMRefs), relevantValues), propsBasedOnType), destructuredValues), changeHandlers), globalKeyHandlers), [propsWithDefaults,
|
|
68
|
+
}, focusTrackers), flags), DOMRefs), relevantValues), propsBasedOnType), destructuredValues), changeHandlers), globalKeyHandlers), [propsWithDefaults, ariaCurrentValueForInputs, dataAttrs, focusTrackers, flags, DOMRefs, relevantValues, propsBasedOnType, destructuredValues, changeHandlers, globalKeyHandlers]);
|
|
65
69
|
return ctx;
|
|
66
70
|
};
|
|
67
71
|
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
const useFocusTracker = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
DOMRefs,
|
|
7
|
+
flags
|
|
8
|
+
} = _ref;
|
|
9
|
+
const [latestInteractionRegion, setLatestInteractionRegion] = useState('');
|
|
10
|
+
const [currFocusDescriber, setCurrFocusDescriber] = useState('');
|
|
11
|
+
const {
|
|
12
|
+
firstSegment,
|
|
13
|
+
lastSegment
|
|
14
|
+
} = DOMRefs;
|
|
15
|
+
const {
|
|
16
|
+
isDateSelector,
|
|
17
|
+
isTimeSelector
|
|
18
|
+
} = flags;
|
|
19
|
+
const trackFocusPicker = useCallback(() => {
|
|
20
|
+
let picker = 'datetime-picker-icon';
|
|
21
|
+
if (isDateSelector) picker = 'date-picker-icon';
|
|
22
|
+
if (isTimeSelector) picker = 'time-picker-icon';
|
|
23
|
+
if (latestInteractionRegion !== 'picker-icon') setLatestInteractionRegion('picker-icon');
|
|
24
|
+
if (picker !== currFocusDescriber) setCurrFocusDescriber(picker);
|
|
25
|
+
}, [currFocusDescriber, isDateSelector, isTimeSelector, latestInteractionRegion]);
|
|
26
|
+
const trackFocusFirstSegment = useCallback(() => {
|
|
27
|
+
let region = 'date-inputs';
|
|
28
|
+
if (firstSegment === 'hour-input') region = 'time-inputs';
|
|
29
|
+
if (firstSegment === 'date-picker-icon') region = 'picker-icon';
|
|
30
|
+
if (firstSegment === 'time-picker-icon') region = 'picker-icon';
|
|
31
|
+
if (firstSegment === 'datetime-picker-icon') region = 'picker-icon';
|
|
32
|
+
if (region !== latestInteractionRegion) setLatestInteractionRegion(region);
|
|
33
|
+
if (firstSegment !== currFocusDescriber) setCurrFocusDescriber(firstSegment);
|
|
34
|
+
}, [currFocusDescriber, firstSegment, latestInteractionRegion]);
|
|
35
|
+
const trackFocusLastSegment = useCallback(() => {
|
|
36
|
+
let region = 'date-inputs';
|
|
37
|
+
if (lastSegment === 'meridiem-input') region = 'time-inputs';
|
|
38
|
+
if (lastSegment === 'clear-btn') region = 'clear-btn';
|
|
39
|
+
if (lastSegment === 'date-picker-icon') region = 'picker-icon';
|
|
40
|
+
if (lastSegment === 'time-picker-icon') region = 'picker-icon';
|
|
41
|
+
if (lastSegment === 'datetime-picker-icon') region = 'picker-icon';
|
|
42
|
+
if (region !== latestInteractionRegion) setLatestInteractionRegion(region);
|
|
43
|
+
if (lastSegment !== currFocusDescriber) setCurrFocusDescriber(lastSegment);
|
|
44
|
+
}, [currFocusDescriber, lastSegment, latestInteractionRegion]);
|
|
45
|
+
return useMemo(() => ({
|
|
46
|
+
latestInteractionRegion,
|
|
47
|
+
setLatestInteractionRegion,
|
|
48
|
+
currFocusDescriber,
|
|
49
|
+
setCurrFocusDescriber,
|
|
50
|
+
trackFocusResetter: () => {
|
|
51
|
+
if (latestInteractionRegion !== '') setLatestInteractionRegion('');
|
|
52
|
+
if (currFocusDescriber !== '') setCurrFocusDescriber('');
|
|
53
|
+
},
|
|
54
|
+
trackFocusMonthInput: () => {
|
|
55
|
+
if (latestInteractionRegion !== 'date-inputs') setLatestInteractionRegion('date-inputs');
|
|
56
|
+
if (currFocusDescriber !== 'month-input') setCurrFocusDescriber('month-input');
|
|
57
|
+
},
|
|
58
|
+
trackFocusDayInput: () => {
|
|
59
|
+
if (latestInteractionRegion !== 'date-inputs') setLatestInteractionRegion('date-inputs');
|
|
60
|
+
if (currFocusDescriber !== 'day-input') setCurrFocusDescriber('day-input');
|
|
61
|
+
},
|
|
62
|
+
trackFocusYearInput: () => {
|
|
63
|
+
if (latestInteractionRegion !== 'date-inputs') setLatestInteractionRegion('date-inputs');
|
|
64
|
+
if (currFocusDescriber !== 'year-input') setCurrFocusDescriber('year-input');
|
|
65
|
+
},
|
|
66
|
+
trackFocusHourInput: () => {
|
|
67
|
+
if (latestInteractionRegion !== 'time-inputs') setLatestInteractionRegion('time-inputs');
|
|
68
|
+
if (currFocusDescriber !== 'hour-input') setCurrFocusDescriber('hour-input');
|
|
69
|
+
},
|
|
70
|
+
trackFocusMinuteInput: () => {
|
|
71
|
+
if (latestInteractionRegion !== 'time-inputs') setLatestInteractionRegion('time-inputs');
|
|
72
|
+
if (currFocusDescriber !== 'minute-input') setCurrFocusDescriber('minute-input');
|
|
73
|
+
},
|
|
74
|
+
trackFocusMeridiemInput: () => {
|
|
75
|
+
if (latestInteractionRegion !== 'time-inputs') setLatestInteractionRegion('time-inputs');
|
|
76
|
+
if (currFocusDescriber !== 'meridiem-input') setCurrFocusDescriber('meridiem-input');
|
|
77
|
+
},
|
|
78
|
+
trackFocusClearBtn: () => {
|
|
79
|
+
if (latestInteractionRegion !== 'clear-btn') setLatestInteractionRegion('clear-btn');
|
|
80
|
+
if (currFocusDescriber !== 'clear-btn') setCurrFocusDescriber('clear-btn');
|
|
81
|
+
},
|
|
82
|
+
trackFocusDatePickerIcon: () => {
|
|
83
|
+
if (latestInteractionRegion !== 'picker-icon') setLatestInteractionRegion('picker-icon');
|
|
84
|
+
if (currFocusDescriber !== 'date-picker-icon') setCurrFocusDescriber('date-picker-icon');
|
|
85
|
+
},
|
|
86
|
+
trackFocusTimePickerIcon: () => {
|
|
87
|
+
if (latestInteractionRegion !== 'picker-icon') setLatestInteractionRegion('picker-icon');
|
|
88
|
+
if (currFocusDescriber !== 'time-picker-icon') setCurrFocusDescriber('time-picker-icon');
|
|
89
|
+
},
|
|
90
|
+
trackFocusDatetimePickerIcon: () => {
|
|
91
|
+
if (latestInteractionRegion !== 'picker-icon') setLatestInteractionRegion('picker-icon');
|
|
92
|
+
if (currFocusDescriber !== 'datetime-picker-icon') setCurrFocusDescriber('datetime-picker-icon');
|
|
93
|
+
},
|
|
94
|
+
trackFocusCalendarPrevMonth: () => {
|
|
95
|
+
if (latestInteractionRegion !== 'calendar-head') setLatestInteractionRegion('calendar-head');
|
|
96
|
+
if (currFocusDescriber !== 'calendar-prev-month') setCurrFocusDescriber('calendar-prev-month');
|
|
97
|
+
},
|
|
98
|
+
trackFocusCalendarNextMonth: () => {
|
|
99
|
+
if (latestInteractionRegion !== 'calendar-head') setLatestInteractionRegion('calendar-head');
|
|
100
|
+
if (currFocusDescriber !== 'calendar-next-month') setCurrFocusDescriber('calendar-next-month');
|
|
101
|
+
},
|
|
102
|
+
trackFocusCalendarPrevYear: () => {
|
|
103
|
+
if (latestInteractionRegion !== 'calendar-head') setLatestInteractionRegion('calendar-head');
|
|
104
|
+
if (currFocusDescriber !== 'calendar-prev-year') setCurrFocusDescriber('calendar-prev-year');
|
|
105
|
+
},
|
|
106
|
+
trackFocusCalendarNextYear: () => {
|
|
107
|
+
if (latestInteractionRegion !== 'calendar-head') setLatestInteractionRegion('calendar-head');
|
|
108
|
+
if (currFocusDescriber !== 'calendar-next-year') setCurrFocusDescriber('calendar-next-year');
|
|
109
|
+
},
|
|
110
|
+
trackFocusCalendarMetafocusedDay: () => {
|
|
111
|
+
if (latestInteractionRegion !== 'calendar-days') setLatestInteractionRegion('calendar-days');
|
|
112
|
+
if (currFocusDescriber !== 'calendar-metafocused-day') setCurrFocusDescriber('calendar-metafocused-day');
|
|
113
|
+
},
|
|
114
|
+
trackFocusTimewheelCurrHour: () => {
|
|
115
|
+
if (latestInteractionRegion !== 'timewheel') setLatestInteractionRegion('timewheel');
|
|
116
|
+
if (currFocusDescriber !== 'timewheel-curr-hour') setCurrFocusDescriber('timewheel-curr-hour');
|
|
117
|
+
},
|
|
118
|
+
trackFocusTimewheelCurrMinute: () => {
|
|
119
|
+
if (latestInteractionRegion !== 'timewheel') setLatestInteractionRegion('timewheel');
|
|
120
|
+
if (currFocusDescriber !== 'timewheel-curr-minute') setCurrFocusDescriber('timewheel-curr-minute');
|
|
121
|
+
},
|
|
122
|
+
trackFocusTimewheelCurrMeridiem: () => {
|
|
123
|
+
if (latestInteractionRegion !== 'timewheel') setLatestInteractionRegion('timewheel');
|
|
124
|
+
if (currFocusDescriber !== 'timewheel-curr-meridiem') setCurrFocusDescriber('timewheel-curr-meridiem');
|
|
125
|
+
},
|
|
126
|
+
trackFocusPicker,
|
|
127
|
+
trackFocusFirstSegment,
|
|
128
|
+
trackFocusLastSegment
|
|
129
|
+
}), [currFocusDescriber, latestInteractionRegion, trackFocusPicker, trackFocusFirstSegment, trackFocusLastSegment]);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export { useFocusTracker };
|