@elliemae/ds-controlled-form 2.4.2-rc.1 → 2.4.2-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/autocomplete/parts/A11yFocusedOption.js +43 -0
- package/cjs/autocomplete/parts/container/Container.js +36 -24
- package/cjs/autocomplete/parts/container/styled.js +2 -2
- package/cjs/autocomplete/parts/menu-list/MenuList.js +4 -2
- 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/react-desc-prop-types.js +2 -1
- package/cjs/checkbox/styles.js +4 -2
- package/cjs/combobox/ComboBoxCTX.js +6 -3
- package/cjs/combobox/config/useComboBox.js +15 -4
- package/cjs/combobox/parts/A11yFocusedOption.js +14 -6
- package/cjs/combobox/parts/A11ySelectedValues.js +0 -2
- package/cjs/combobox/parts/DropdownIndicator.js +2 -2
- package/cjs/combobox/parts/container/Container.js +10 -13
- package/cjs/combobox/parts/controls/Controls.js +16 -18
- package/cjs/combobox/parts/controls/useOnPillsNavigation.js +3 -3
- package/cjs/combobox/parts/controls-input/ControlsInput.js +2 -2
- package/cjs/combobox/parts/controls-input/useControlsInput.js +3 -2
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +16 -23
- package/cjs/combobox/parts/controls-input/useMaskedOnChange.js +6 -6
- package/cjs/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +3 -3
- package/cjs/combobox/parts/menu-list/MenuList.js +7 -5
- package/cjs/combobox/parts/menu-list/styled.js +5 -3
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +16 -15
- package/cjs/combobox/react-desc-prop-types.js +3 -2
- package/cjs/combobox/utils/listHelper.js +10 -0
- 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/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 +21 -20
- package/esm/autocomplete/parts/A11yFocusedOption.js +32 -0
- package/esm/autocomplete/parts/container/Container.js +39 -27
- package/esm/autocomplete/parts/container/styled.js +2 -2
- package/esm/autocomplete/parts/menu-list/MenuList.js +5 -3
- 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/react-desc-prop-types.js +2 -1
- package/esm/checkbox/styles.js +4 -3
- package/esm/combobox/ComboBoxCTX.js +6 -3
- package/esm/combobox/config/useComboBox.js +16 -5
- package/esm/combobox/parts/A11yFocusedOption.js +15 -7
- package/esm/combobox/parts/A11ySelectedValues.js +0 -2
- package/esm/combobox/parts/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/container/Container.js +10 -13
- package/esm/combobox/parts/controls/Controls.js +16 -18
- package/esm/combobox/parts/controls/useOnPillsNavigation.js +3 -3
- package/esm/combobox/parts/controls-input/ControlsInput.js +2 -2
- package/esm/combobox/parts/controls-input/useControlsInput.js +3 -2
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +17 -24
- package/esm/combobox/parts/controls-input/useMaskedOnChange.js +6 -6
- package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +3 -3
- package/esm/combobox/parts/menu-list/MenuList.js +7 -5
- package/esm/combobox/parts/menu-list/styled.js +5 -4
- package/esm/combobox/parts/menu-list/useItemRenderer.js +18 -17
- package/esm/combobox/react-desc-prop-types.js +3 -2
- package/esm/combobox/utils/listHelper.js +10 -1
- 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 +12 -12
- 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/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 +18 -17
- 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 +1 -1
|
@@ -30,12 +30,12 @@ const useKeyboardNavigation = () => {
|
|
|
30
30
|
withoutPortal
|
|
31
31
|
},
|
|
32
32
|
inputValue,
|
|
33
|
-
|
|
33
|
+
menuState,
|
|
34
34
|
focusOptionIdx,
|
|
35
35
|
listRef,
|
|
36
36
|
selectAllCheckboxRef,
|
|
37
37
|
toggleSelectionButtonRef,
|
|
38
|
-
|
|
38
|
+
setMenuState,
|
|
39
39
|
setInputValue,
|
|
40
40
|
scrollOptionIntoView,
|
|
41
41
|
setFocusOptionIdx
|
|
@@ -50,15 +50,10 @@ const useKeyboardNavigation = () => {
|
|
|
50
50
|
// =============================================================================
|
|
51
51
|
if (onKeyDown && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === constants.MENU_OPTION_TYPES.OPTION) onKeyDown(e, currentItem);
|
|
52
52
|
|
|
53
|
-
if (['ArrowDown', 'ArrowUp', 'Enter', 'Spacebar'].includes(e.key) || e.keyCode >= 48 && e.keyCode <= 90) {
|
|
54
|
-
|
|
53
|
+
if ((['ArrowDown', 'ArrowUp', 'Enter', 'Spacebar'].includes(e.key) || e.keyCode >= 48 && e.keyCode <= 90) && !menuState) {
|
|
54
|
+
setMenuState(true);
|
|
55
55
|
window.requestAnimationFrame(() => {
|
|
56
|
-
if (listRef.current
|
|
57
|
-
window.scrollTo({
|
|
58
|
-
top: listRef.current.offsetHeight,
|
|
59
|
-
behavior: 'smooth'
|
|
60
|
-
});
|
|
61
|
-
}
|
|
56
|
+
if (listRef.current) listHelper.scrollIfNeeded(listRef.current);
|
|
62
57
|
});
|
|
63
58
|
} // =============================================================================
|
|
64
59
|
// ESCAPE
|
|
@@ -73,7 +68,7 @@ const useKeyboardNavigation = () => {
|
|
|
73
68
|
setInputValue('');
|
|
74
69
|
}
|
|
75
70
|
|
|
76
|
-
if (!inline)
|
|
71
|
+
if (!inline) setMenuState(false, 'close', e);
|
|
77
72
|
} // =============================================================================
|
|
78
73
|
// ENTER KEY TO CREATE ELEMENTS
|
|
79
74
|
// =============================================================================
|
|
@@ -95,12 +90,12 @@ const useKeyboardNavigation = () => {
|
|
|
95
90
|
e.preventDefault();
|
|
96
91
|
e.stopPropagation();
|
|
97
92
|
|
|
98
|
-
if (focusOptionIdx !== '' && (
|
|
93
|
+
if (focusOptionIdx !== '' && (menuState || inline) && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === constants.MENU_OPTION_TYPES.OPTION && !currentItem.disabled) {
|
|
99
94
|
if (onFilter) onFilter(allOptions, '');
|
|
100
95
|
setInputValue('');
|
|
101
96
|
|
|
102
97
|
if (!multiple) {
|
|
103
|
-
|
|
98
|
+
setMenuState(false, 'selectOption', e);
|
|
104
99
|
}
|
|
105
100
|
|
|
106
101
|
onChange(listHelper.getSuggestedValueOnChange(currentItem, selectedValues), currentItem, e);
|
|
@@ -108,7 +103,7 @@ const useKeyboardNavigation = () => {
|
|
|
108
103
|
}
|
|
109
104
|
|
|
110
105
|
if (e.key === 'Enter' && e.altKey) {
|
|
111
|
-
|
|
106
|
+
setMenuState(false, 'selectOption', e);
|
|
112
107
|
}
|
|
113
108
|
|
|
114
109
|
if (e.key === 'a' && e.ctrlKey && multiple && onSelectAll) {
|
|
@@ -122,7 +117,7 @@ const useKeyboardNavigation = () => {
|
|
|
122
117
|
e.preventDefault();
|
|
123
118
|
e.stopPropagation();
|
|
124
119
|
|
|
125
|
-
if ((
|
|
120
|
+
if ((menuState || inline) && selectableOptions.length) {
|
|
126
121
|
const nextItemIndexIndex = listHelper.findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable);
|
|
127
122
|
|
|
128
123
|
if (nextItemIndexIndex > -1) {
|
|
@@ -139,12 +134,12 @@ const useKeyboardNavigation = () => {
|
|
|
139
134
|
const prevItemIndex = listHelper.findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable, -1);
|
|
140
135
|
|
|
141
136
|
if (prevItemIndex > -1) {
|
|
142
|
-
if (
|
|
137
|
+
if (menuState || inline) {
|
|
143
138
|
setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);
|
|
144
139
|
scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);
|
|
145
140
|
} else {
|
|
146
141
|
// open menu and search last item to focused
|
|
147
|
-
|
|
142
|
+
setMenuState(true, 'open', e);
|
|
148
143
|
const lastItemIndex = listHelper.findInCircularList(filteredOptions, 0, isOptionFocuseable, -1);
|
|
149
144
|
setFocusOptionIdx(filteredOptions[lastItemIndex].dsId);
|
|
150
145
|
setTimeout(() => {
|
|
@@ -167,7 +162,7 @@ const useKeyboardNavigation = () => {
|
|
|
167
162
|
if (onFilter) onFilter(allOptions, inputValue);
|
|
168
163
|
}
|
|
169
164
|
|
|
170
|
-
if (e.key === 'Tab' && !inline &&
|
|
165
|
+
if (e.key === 'Tab' && !inline && menuState) {
|
|
171
166
|
var _selectAllCheckboxRef;
|
|
172
167
|
|
|
173
168
|
const element = (_selectAllCheckboxRef = selectAllCheckboxRef.current) !== null && _selectAllCheckboxRef !== void 0 ? _selectAllCheckboxRef : toggleSelectionButtonRef.current;
|
|
@@ -175,14 +170,12 @@ const useKeyboardNavigation = () => {
|
|
|
175
170
|
if (element) {
|
|
176
171
|
e.preventDefault();
|
|
177
172
|
element.focus();
|
|
173
|
+
} else {
|
|
174
|
+
setMenuState(false, 'blur', e);
|
|
178
175
|
}
|
|
179
176
|
}
|
|
180
|
-
|
|
181
|
-
if (e.key === 'Tab' && !multiple && showPopover) {
|
|
182
|
-
setShowPopover(false);
|
|
183
|
-
}
|
|
184
177
|
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
185
|
-
[onKeyDown, currentItem, onCreate, multiple, inputValue, inline, withoutPortal,
|
|
178
|
+
[onKeyDown, currentItem, onCreate, multiple, inputValue, inline, withoutPortal, setMenuState, onCancel, onFilter, setInputValue, listRef, focusOptionIdx, menuState, selectableOptions.length, filteredOptions, currentItemIndex, setFocusOptionIdx, selectedValues, onChange, selectAllCheckboxRef, toggleSelectionButtonRef]);
|
|
186
179
|
return {
|
|
187
180
|
onInputKeyDown
|
|
188
181
|
};
|
|
@@ -13,26 +13,26 @@ const useMaskedOnChange = () => {
|
|
|
13
13
|
onFilter,
|
|
14
14
|
allOptions
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
setMenuState,
|
|
17
17
|
setInputValue,
|
|
18
18
|
setShowSelectedOptions
|
|
19
19
|
} = React.useContext(ComboBoxCTX.ComboBoxContext); // default onchange when no mask provided
|
|
20
20
|
|
|
21
21
|
const handleOnChange = React.useCallback(e => {
|
|
22
22
|
setShowSelectedOptions(false);
|
|
23
|
-
|
|
23
|
+
setMenuState(true, 'filter', e);
|
|
24
24
|
|
|
25
25
|
if (onFilter) {
|
|
26
26
|
onFilter(listHelper.filterOptions(e.currentTarget.value, allOptions), e.currentTarget.value);
|
|
27
27
|
setInputValue(e.currentTarget.value);
|
|
28
28
|
}
|
|
29
|
-
}, [allOptions, onFilter, setInputValue,
|
|
29
|
+
}, [allOptions, onFilter, setInputValue, setMenuState, setShowSelectedOptions]); // onchange used when mask is provided
|
|
30
30
|
|
|
31
|
-
const handleOnChangeMask = React.useCallback((
|
|
31
|
+
const handleOnChangeMask = React.useCallback((e, mask) => {
|
|
32
32
|
setShowSelectedOptions(false);
|
|
33
|
-
|
|
33
|
+
setMenuState(true, 'filter', e);
|
|
34
34
|
if (mask && onFilter) onFilter(listHelper.filterOptions(mask, allOptions), mask);else if (!mask && onFilter) onFilter(allOptions, '');
|
|
35
|
-
}, [allOptions, onFilter,
|
|
35
|
+
}, [allOptions, onFilter, setMenuState, setShowSelectedOptions]);
|
|
36
36
|
const onChangeMask = useMask({
|
|
37
37
|
valueSetter: setInputValue,
|
|
38
38
|
onChange: handleOnChangeMask
|
|
@@ -20,14 +20,14 @@ const DropdownIndicator = () => {
|
|
|
20
20
|
props: {
|
|
21
21
|
disabled
|
|
22
22
|
},
|
|
23
|
-
|
|
23
|
+
menuState
|
|
24
24
|
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
25
25
|
return /*#__PURE__*/_jsx__default["default"](styled.StyledDropDownButton, {
|
|
26
26
|
"data-testid": ComboboxDataTestids.ComboboxDataTestid.DROPDOWN,
|
|
27
27
|
"aria-controls": "combo-listbox",
|
|
28
28
|
"aria-labelledby": "combo-label",
|
|
29
29
|
disabled: disabled,
|
|
30
|
-
"aria-expanded":
|
|
30
|
+
"aria-expanded": menuState,
|
|
31
31
|
"aria-haspopup": "listbox",
|
|
32
32
|
"aria-hidden": true,
|
|
33
33
|
buttonType: "icon",
|
|
@@ -20,7 +20,7 @@ const useHeaderListHandlers = () => {
|
|
|
20
20
|
},
|
|
21
21
|
showSelectedOptions,
|
|
22
22
|
setShowSelectedOptions,
|
|
23
|
-
|
|
23
|
+
setMenuState
|
|
24
24
|
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
25
25
|
const multiSelectedValues = selectedValues;
|
|
26
26
|
const selectableOptions = listHelper.getSelectableOptions(filteredOptions);
|
|
@@ -61,10 +61,10 @@ const useHeaderListHandlers = () => {
|
|
|
61
61
|
if (e.key === 'Escape') {
|
|
62
62
|
var _innerRef$current;
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
setMenuState(false, 'close', e);
|
|
65
65
|
(_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.focus();
|
|
66
66
|
}
|
|
67
|
-
}, [
|
|
67
|
+
}, [setMenuState, innerRef]); // when hitting tab on selected values button filter we target the input again
|
|
68
68
|
|
|
69
69
|
const handleFilterSelectionBtnOnTab = React.useCallback(e => {
|
|
70
70
|
if (e.key === 'Tab' && !e.shiftKey) {
|
|
@@ -16,11 +16,14 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
16
16
|
|
|
17
17
|
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
18
18
|
|
|
19
|
-
var _HeaderList
|
|
19
|
+
var _HeaderList;
|
|
20
20
|
const MenuList = () => {
|
|
21
|
+
var _StyledNoResultsWrapp;
|
|
22
|
+
|
|
21
23
|
const {
|
|
22
24
|
props: {
|
|
23
25
|
menuMinWidth,
|
|
26
|
+
noOptionsMessage,
|
|
24
27
|
menuMaxHeight,
|
|
25
28
|
onCreate,
|
|
26
29
|
inline,
|
|
@@ -66,10 +69,9 @@ const MenuList = () => {
|
|
|
66
69
|
}
|
|
67
70
|
}, void 0, ItemRenderer)
|
|
68
71
|
}) : _StyledNoResultsWrapp || (_StyledNoResultsWrapp = /*#__PURE__*/_jsx__default["default"](styled.StyledNoResultsWrapper, {
|
|
69
|
-
role: "alert"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, width), [wrapperListRef, inline, preventLoseInputFocus, menuMinWidth, withHeader, filteredOptions.length, onCreate, menuMaxHeight, listRef, virtualListHelpers === null || virtualListHelpers === void 0 ? void 0 : virtualListHelpers.totalSize, ItemRenderer, width]);
|
|
72
|
+
role: "alert"
|
|
73
|
+
}, void 0, noOptionsMessage))]
|
|
74
|
+
}, width), [wrapperListRef, inline, preventLoseInputFocus, width, menuMinWidth, withHeader, filteredOptions.length, onCreate, menuMaxHeight, listRef, virtualListHelpers === null || virtualListHelpers === void 0 ? void 0 : virtualListHelpers.totalSize, ItemRenderer, noOptionsMessage]);
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
exports.MenuList = MenuList;
|
|
@@ -9,7 +9,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
|
|
10
10
|
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
11
11
|
|
|
12
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
12
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
13
13
|
const StyledListWrapper = dsSystem.styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n min-width: ", ";\n width: ", ";\n background-color: #ffffff;\n max-height: ", ";\n z-index: 100;\n"])), _ref => {
|
|
14
14
|
let {
|
|
15
15
|
inline,
|
|
@@ -27,7 +27,7 @@ const StyledListWrapper = dsSystem.styled.div(_templateObject || (_templateObjec
|
|
|
27
27
|
} = _ref3;
|
|
28
28
|
return "".concat(maxHeight, "px");
|
|
29
29
|
});
|
|
30
|
-
const StyledList = dsSystem.styled.ul(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n position: relative;\n padding: 0;\n background-color: #ffffff;\n"])));
|
|
30
|
+
const StyledList = dsSystem.styled.ul(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n position: relative;\n padding: 0;\n background-color: #ffffff;\n overflow-x: hidden;\n"])));
|
|
31
31
|
const StyledVirtualListWrapper = dsSystem.styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral__default["default"](["\n overflow-y: auto;\n margin-top: ", ";\n max-height: ", ";\n"])), _ref4 => {
|
|
32
32
|
let {
|
|
33
33
|
withHeader
|
|
@@ -40,9 +40,11 @@ const StyledVirtualListWrapper = dsSystem.styled.div(_templateObject3 || (_templ
|
|
|
40
40
|
return maxHeight ? "".concat(maxHeight, "px") : '300px';
|
|
41
41
|
});
|
|
42
42
|
const StyledCreatableLabel = dsSystem.styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral__default["default"](["\n font-weight: bold;\n font-style: italic;\n"])));
|
|
43
|
-
const
|
|
43
|
+
const StyledCreatableValue = dsSystem.styled.span(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral__default["default"](["\n word-break: break-all;\n"])));
|
|
44
|
+
const StyledNoResultsWrapper = dsSystem.styled.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral__default["default"](["\n padding: 16px;\n"])));
|
|
44
45
|
|
|
45
46
|
exports.StyledCreatableLabel = StyledCreatableLabel;
|
|
47
|
+
exports.StyledCreatableValue = StyledCreatableValue;
|
|
46
48
|
exports.StyledList = StyledList;
|
|
47
49
|
exports.StyledListWrapper = StyledListWrapper;
|
|
48
50
|
exports.StyledNoResultsWrapper = StyledNoResultsWrapper;
|
|
@@ -41,7 +41,7 @@ const useItemRenderer = () => {
|
|
|
41
41
|
onFilter,
|
|
42
42
|
allOptions
|
|
43
43
|
},
|
|
44
|
-
|
|
44
|
+
setMenuState,
|
|
45
45
|
inputValue,
|
|
46
46
|
focusOptionIdx,
|
|
47
47
|
setInputValue,
|
|
@@ -49,20 +49,21 @@ const useItemRenderer = () => {
|
|
|
49
49
|
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
50
50
|
const multiple = Array.isArray(selectedValues);
|
|
51
51
|
const CBItem = multiple ? dsForm.MultiMenuItem : dsForm.SingleMenuItem;
|
|
52
|
+
const handleOnCreateClick = React.useCallback(() => {
|
|
53
|
+
if (inputValue && onCreate) {
|
|
54
|
+
onCreate(inputValue);
|
|
55
|
+
setInputValue('');
|
|
56
|
+
if (onFilter) onFilter(allOptions, inputValue);
|
|
57
|
+
}
|
|
58
|
+
}, [onFilter, onCreate, inputValue, allOptions, setInputValue]);
|
|
52
59
|
const handleClick = React.useCallback((option, e) => {
|
|
53
|
-
if (option.type === constants.
|
|
54
|
-
if (inputValue) {
|
|
55
|
-
onCreate(inputValue);
|
|
56
|
-
setInputValue('');
|
|
57
|
-
onFilter(allOptions, inputValue);
|
|
58
|
-
}
|
|
59
|
-
} else if (option.type === constants.MENU_OPTION_TYPES.OPTION) {
|
|
60
|
+
if (option.type === constants.MENU_OPTION_TYPES.OPTION) {
|
|
60
61
|
if (!option.disabled) {
|
|
61
62
|
if (onFilter) onFilter(allOptions, inputValue);
|
|
62
63
|
setInputValue('');
|
|
63
64
|
|
|
64
65
|
if (!multiple) {
|
|
65
|
-
|
|
66
|
+
setMenuState(false, 'selectOption', e);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
onChange(listHelper.getSuggestedValueOnChange(option, selectedValues), option, e);
|
|
@@ -72,7 +73,7 @@ const useItemRenderer = () => {
|
|
|
72
73
|
|
|
73
74
|
e.stopPropagation();
|
|
74
75
|
e.preventDefault();
|
|
75
|
-
}, [onFilter, selectedValues, onChange,
|
|
76
|
+
}, [onFilter, selectedValues, allOptions, onChange, setMenuState, multiple]); // prevent blur from controls input
|
|
76
77
|
|
|
77
78
|
const handleOnMouseDown = React.useCallback(e => {
|
|
78
79
|
e.preventDefault();
|
|
@@ -115,8 +116,8 @@ const useItemRenderer = () => {
|
|
|
115
116
|
onClick: e => handleClick(option, e),
|
|
116
117
|
onMouseDown: handleOnMouseDown,
|
|
117
118
|
isActive: option.dsId === focusOptionIdx,
|
|
118
|
-
isSelected: listHelper.isSelected(selectedValues, option)
|
|
119
|
-
|
|
119
|
+
isSelected: listHelper.isSelected(selectedValues, option),
|
|
120
|
+
tabIndex: -1
|
|
120
121
|
}));
|
|
121
122
|
}
|
|
122
123
|
|
|
@@ -130,14 +131,14 @@ const useItemRenderer = () => {
|
|
|
130
131
|
label
|
|
131
132
|
} = _ref;
|
|
132
133
|
return /*#__PURE__*/_jsx__default["default"](dsGrid.Grid, {
|
|
134
|
+
p: "8px",
|
|
133
135
|
cols: ['min-content', 'auto'],
|
|
134
|
-
height: "16px",
|
|
135
136
|
gutter: "xxs",
|
|
136
137
|
alignItems: "center"
|
|
137
|
-
}, void 0, _StyledCreatableLabel || (_StyledCreatableLabel = /*#__PURE__*/_jsx__default["default"](styled.StyledCreatableLabel, {}, void 0, "Add:")), /*#__PURE__*/_jsx__default["default"](
|
|
138
|
+
}, void 0, _StyledCreatableLabel || (_StyledCreatableLabel = /*#__PURE__*/_jsx__default["default"](styled.StyledCreatableLabel, {}, void 0, "Add:")), /*#__PURE__*/_jsx__default["default"](styled.StyledCreatableValue, {}, void 0, "\"".concat(label, "\"")));
|
|
138
139
|
},
|
|
139
140
|
label: option.label,
|
|
140
|
-
onClick:
|
|
141
|
+
onClick: handleOnCreateClick
|
|
141
142
|
}));
|
|
142
143
|
}
|
|
143
144
|
|
|
@@ -26,12 +26,13 @@ const ComboboxPropTypes = _objectSpread(_objectSpread({}, dsPropsHelpers.globalA
|
|
|
26
26
|
disabled: dsPropsHelpers.PropTypes.bool.description('wheter or not the input is disabled').defaultValue('false'),
|
|
27
27
|
autoFocus: dsPropsHelpers.PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),
|
|
28
28
|
hasError: dsPropsHelpers.PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),
|
|
29
|
+
noOptionsMessage: dsPropsHelpers.PropTypes.string.description('Custome message to be display when no matches found after filtering').defaultValue('No Matches Found'),
|
|
30
|
+
closeMenuOnScroll: dsPropsHelpers.PropTypes.oneOfType([dsPropsHelpers.PropTypes.func, dsPropsHelpers.PropTypes.bool]).description('If true, close the select menu when the user scrolls the document/body.').defaultValue(false),
|
|
29
31
|
onChange: dsPropsHelpers.PropTypes.func.isRequired.description('function triggered when an option is selected it will send the options selected').defaultValue('() => {}'),
|
|
30
32
|
onFilter: dsPropsHelpers.PropTypes.func.description('function triggered when user type in the combobox input').defaultValue(''),
|
|
31
33
|
onCreate: dsPropsHelpers.PropTypes.func.description('function triggered when user select "create" a new item whenever is not a match in the all option list').defaultValue(''),
|
|
32
34
|
onCancel: dsPropsHelpers.PropTypes.func.description('function triggered when user press ESC key').defaultValue('() => {}'),
|
|
33
|
-
|
|
34
|
-
onMenuClose: dsPropsHelpers.PropTypes.func.description('function triggered when user close the menu list').defaultValue('() => {}'),
|
|
35
|
+
onMenuChange: dsPropsHelpers.PropTypes.func.description('function triggered when user open or close the menu list').defaultValue('() => {}'),
|
|
35
36
|
inputMinWidth: dsPropsHelpers.PropTypes.any.description('Minimum width for the combo box input controller').defaultValue(undefined),
|
|
36
37
|
menuMinWidth: dsPropsHelpers.PropTypes.any.description('Minimum width for the dropdown menu').defaultValue(undefined),
|
|
37
38
|
menuMaxHeight: dsPropsHelpers.PropTypes.any.description('Maximum height for the dropdown menu').defaultValue(undefined),
|
|
@@ -102,6 +102,15 @@ const selectedValuesWithSections = (optionsToParse, multiSelectedValue) => {
|
|
|
102
102
|
return items;
|
|
103
103
|
};
|
|
104
104
|
const getFilteredOptionsSelected = (filteredOption, selectedValues) => filteredOption.filter(option => option.type === constants.MENU_OPTION_TYPES.OPTION && isSelected(selectedValues, option));
|
|
105
|
+
const scrollIfNeeded = function (elem) {
|
|
106
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
107
|
+
behavior: 'smooth',
|
|
108
|
+
block: 'end',
|
|
109
|
+
inline: 'nearest'
|
|
110
|
+
};
|
|
111
|
+
const bounding = elem.getBoundingClientRect();
|
|
112
|
+
if (!(bounding.top >= 0 && bounding.left >= 0 && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && bounding.right <= (window.innerWidth || document.documentElement.clientWidth))) elem.scrollIntoView(options);
|
|
113
|
+
};
|
|
105
114
|
|
|
106
115
|
exports.filterOptions = filterOptions;
|
|
107
116
|
exports.findInCircularList = findInCircularList;
|
|
@@ -114,4 +123,5 @@ exports.getSuggestedValueOnChange = getSuggestedValueOnChange;
|
|
|
114
123
|
exports.isSelected = isSelected;
|
|
115
124
|
exports.isSelectedValueEmpty = isSelectedValueEmpty;
|
|
116
125
|
exports.isSelectedValueMultiple = isSelectedValueMultiple;
|
|
126
|
+
exports.scrollIfNeeded = scrollIfNeeded;
|
|
117
127
|
exports.selectedValuesWithSections = selectedValuesWithSections;
|
|
@@ -26,7 +26,7 @@ const useChangeHandlers = _ref => {
|
|
|
26
26
|
relevantValues,
|
|
27
27
|
destructuredValues,
|
|
28
28
|
propsBasedOnType,
|
|
29
|
-
|
|
29
|
+
focusTrackers
|
|
30
30
|
} = _ref;
|
|
31
31
|
const {
|
|
32
32
|
tempDateString,
|
|
@@ -60,8 +60,8 @@ const useChangeHandlers = _ref => {
|
|
|
60
60
|
meridiem
|
|
61
61
|
} = destructuredValues;
|
|
62
62
|
const {
|
|
63
|
-
|
|
64
|
-
} =
|
|
63
|
+
trackFocusFirstSegment
|
|
64
|
+
} = focusTrackers;
|
|
65
65
|
const getDateMetaInfo = React.useCallback(function () {
|
|
66
66
|
let newDateString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
67
67
|
let metaInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -91,7 +91,7 @@ const useChangeHandlers = _ref => {
|
|
|
91
91
|
setTimeString(newTimeString);
|
|
92
92
|
const newDateTimeString = "".concat(newDateString, " ").concat(newTimeString);
|
|
93
93
|
|
|
94
|
-
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread({}, getTimeMetaInfo(newTimeString, metaInfo)), getDateMetaInfo(newDateString, metaInfo)), {}, {
|
|
94
|
+
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, metaInfo), getTimeMetaInfo(newTimeString, metaInfo)), getDateMetaInfo(newDateString, metaInfo)), {}, {
|
|
95
95
|
newDateString,
|
|
96
96
|
newTimeString,
|
|
97
97
|
newDateTimeString
|
|
@@ -108,7 +108,7 @@ const useChangeHandlers = _ref => {
|
|
|
108
108
|
setTempDateString(newDateString);
|
|
109
109
|
const newDateTimeString = "".concat(newDateString, " ").concat(tempTimeString);
|
|
110
110
|
|
|
111
|
-
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread({}, getTimeMetaInfo(tempTimeString, metaInfo)), getDateMetaInfo(newDateString, metaInfo)), {}, {
|
|
111
|
+
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, metaInfo), getTimeMetaInfo(tempTimeString, metaInfo)), getDateMetaInfo(newDateString, metaInfo)), {}, {
|
|
112
112
|
newDateString,
|
|
113
113
|
newTimeString: tempTimeString,
|
|
114
114
|
newDateTimeString
|
|
@@ -124,7 +124,7 @@ const useChangeHandlers = _ref => {
|
|
|
124
124
|
setTimeString(newTimeString);
|
|
125
125
|
const newDateTimeString = "".concat(tempDateString, " ").concat(newTimeString);
|
|
126
126
|
|
|
127
|
-
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread({}, getTimeMetaInfo(newTimeString, metaInfo)), getDateMetaInfo(tempDateString, metaInfo)), {}, {
|
|
127
|
+
const newMetaInfo = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, metaInfo), getTimeMetaInfo(newTimeString, metaInfo)), getDateMetaInfo(tempDateString, metaInfo)), {}, {
|
|
128
128
|
newDateTimeString,
|
|
129
129
|
newDateString: tempDateString,
|
|
130
130
|
newTimeString
|
|
@@ -241,12 +241,8 @@ const useChangeHandlers = _ref => {
|
|
|
241
241
|
if (isDateTime) handleChangeComposedDateTimeString('__/__/____', '__:__ __', metaInfo);
|
|
242
242
|
if (isDate) handleChangeComposedDateString('__/__/____', metaInfo);
|
|
243
243
|
if (isTime) handleChangeComposedTimeString('__:__ __', metaInfo);
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
(_firstSegmentRef$curr = firstSegmentRef.current) === null || _firstSegmentRef$curr === void 0 ? void 0 : _firstSegmentRef$curr.focus();
|
|
248
|
-
});
|
|
249
|
-
}, [appOnDayChange, appOnHourChange, appOnMeridiemChange, appOnMinuteChange, appOnMonthChange, appOnYearChange, firstSegmentRef, handleChangeComposedDateString, handleChangeComposedDateTimeString, handleChangeComposedTimeString, isDate, isDateTime, isTime]);
|
|
244
|
+
trackFocusFirstSegment();
|
|
245
|
+
}, [appOnDayChange, appOnHourChange, appOnMeridiemChange, appOnMinuteChange, appOnMonthChange, appOnYearChange, handleChangeComposedDateString, handleChangeComposedDateTimeString, handleChangeComposedTimeString, isDate, isDateTime, isTime, trackFocusFirstSegment]);
|
|
250
246
|
return React.useMemo(() => ({
|
|
251
247
|
handleChangeComposedDateTimeString,
|
|
252
248
|
handleChangeComposedDateString,
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
5
|
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
8
6
|
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
7
|
require('core-js/modules/esnext.iterator.filter.js');
|
|
10
8
|
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
9
|
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
12
11
|
var React = require('react');
|
|
13
12
|
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
14
13
|
var useGetPropsWithDefault = require('./useGetPropsWithDefault.js');
|
|
14
|
+
var useFocusTracker = require('./useFocusTracker.js');
|
|
15
15
|
var useGetFlags = require('./useGetFlags.js');
|
|
16
16
|
var useGetReferences = require('./useGetReferences.js');
|
|
17
17
|
var useRelevantValueFromProps = require('./useRelevantValueFromProps.js');
|
|
@@ -36,6 +36,10 @@ const useControlledDateTimePicker = props => {
|
|
|
36
36
|
const flags = useGetFlags.useGetFlags(propsWithDefaults);
|
|
37
37
|
const DOMRefs = useGetReferences.useGetReferences(flags); // refs are used for "auto-advance" feature
|
|
38
38
|
|
|
39
|
+
const focusTrackers = useFocusTracker.useFocusTracker({
|
|
40
|
+
DOMRefs,
|
|
41
|
+
flags
|
|
42
|
+
});
|
|
39
43
|
const relevantValues = useRelevantValueFromProps.useRelevantValueFromProps(propsWithDefaults);
|
|
40
44
|
const propsBasedOnType = useGetPropsBasedOnType.useGetPropsBasedOnType(propsWithDefaults);
|
|
41
45
|
const destructuredValues = useGetDestructuredValues.useGetDestructuredValues(_objectSpread(_objectSpread({}, propsBasedOnType), flags));
|
|
@@ -43,17 +47,18 @@ const useControlledDateTimePicker = props => {
|
|
|
43
47
|
relevantValues,
|
|
44
48
|
destructuredValues,
|
|
45
49
|
propsBasedOnType,
|
|
46
|
-
DOMRefs
|
|
50
|
+
DOMRefs,
|
|
51
|
+
focusTrackers
|
|
47
52
|
});
|
|
48
53
|
const globalKeyHandlers = useGlobalKeyHandlers.useGlobalKeyHandlers({
|
|
49
54
|
changeHandlers,
|
|
50
55
|
propsBasedOnType,
|
|
51
56
|
DOMRefs,
|
|
52
|
-
flags
|
|
57
|
+
flags,
|
|
58
|
+
focusTrackers
|
|
53
59
|
}); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
54
60
|
|
|
55
61
|
const dataAttrs = dsPropsHelpers.getDataProps(propsWithDefaults);
|
|
56
|
-
const [latestInteractionRegion, setLatestInteractionRegion] = React.useState('');
|
|
57
62
|
const {
|
|
58
63
|
announcedDateValues,
|
|
59
64
|
announcedTimeValues
|
|
@@ -64,13 +69,12 @@ const useControlledDateTimePicker = props => {
|
|
|
64
69
|
isWithTimeInputs
|
|
65
70
|
} = flags;
|
|
66
71
|
const ariaCurrentValueForInputs = "current values: ".concat(isWithDateInputs ? "".concat(announcedDateValues) : '').concat(isDateTimeSelector ? ', ' : '').concat(isWithTimeInputs ? "".concat(announcedTimeValues) : '');
|
|
67
|
-
const ctx = React__default["default"].useMemo(() => _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
72
|
+
const ctx = React__default["default"].useMemo(() => _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
68
73
|
props: propsWithDefaults,
|
|
69
|
-
latestInteractionRegion,
|
|
70
|
-
setLatestInteractionRegion,
|
|
71
74
|
ariaCurrentValueForInputs,
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
72
76
|
dataAttrs
|
|
73
|
-
}, flags), DOMRefs), relevantValues), propsBasedOnType), destructuredValues), changeHandlers), globalKeyHandlers), [propsWithDefaults,
|
|
77
|
+
}, focusTrackers), flags), DOMRefs), relevantValues), propsBasedOnType), destructuredValues), changeHandlers), globalKeyHandlers), [propsWithDefaults, ariaCurrentValueForInputs, dataAttrs, focusTrackers, flags, DOMRefs, relevantValues, propsBasedOnType, destructuredValues, changeHandlers, globalKeyHandlers]);
|
|
74
78
|
return ctx;
|
|
75
79
|
};
|
|
76
80
|
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
|
|
8
|
+
const useFocusTracker = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
DOMRefs,
|
|
11
|
+
flags
|
|
12
|
+
} = _ref;
|
|
13
|
+
const [latestInteractionRegion, setLatestInteractionRegion] = React.useState('');
|
|
14
|
+
const [currFocusDescriber, setCurrFocusDescriber] = React.useState('');
|
|
15
|
+
const {
|
|
16
|
+
firstSegment,
|
|
17
|
+
lastSegment
|
|
18
|
+
} = DOMRefs;
|
|
19
|
+
const {
|
|
20
|
+
isDateSelector,
|
|
21
|
+
isTimeSelector
|
|
22
|
+
} = flags;
|
|
23
|
+
const trackFocusPicker = React.useCallback(() => {
|
|
24
|
+
let picker = 'datetime-picker-icon';
|
|
25
|
+
if (isDateSelector) picker = 'date-picker-icon';
|
|
26
|
+
if (isTimeSelector) picker = 'time-picker-icon';
|
|
27
|
+
if (latestInteractionRegion !== 'picker-icon') setLatestInteractionRegion('picker-icon');
|
|
28
|
+
if (picker !== currFocusDescriber) setCurrFocusDescriber(picker);
|
|
29
|
+
}, [currFocusDescriber, isDateSelector, isTimeSelector, latestInteractionRegion]);
|
|
30
|
+
const trackFocusFirstSegment = React.useCallback(() => {
|
|
31
|
+
let region = 'date-inputs';
|
|
32
|
+
if (firstSegment === 'hour-input') region = 'time-inputs';
|
|
33
|
+
if (firstSegment === 'date-picker-icon') region = 'picker-icon';
|
|
34
|
+
if (firstSegment === 'time-picker-icon') region = 'picker-icon';
|
|
35
|
+
if (firstSegment === 'datetime-picker-icon') region = 'picker-icon';
|
|
36
|
+
if (region !== latestInteractionRegion) setLatestInteractionRegion(region);
|
|
37
|
+
if (firstSegment !== currFocusDescriber) setCurrFocusDescriber(firstSegment);
|
|
38
|
+
}, [currFocusDescriber, firstSegment, latestInteractionRegion]);
|
|
39
|
+
const trackFocusLastSegment = React.useCallback(() => {
|
|
40
|
+
let region = 'date-inputs';
|
|
41
|
+
if (lastSegment === 'meridiem-input') region = 'time-inputs';
|
|
42
|
+
if (lastSegment === 'clear-btn') region = 'clear-btn';
|
|
43
|
+
if (lastSegment === 'date-picker-icon') region = 'picker-icon';
|
|
44
|
+
if (lastSegment === 'time-picker-icon') region = 'picker-icon';
|
|
45
|
+
if (lastSegment === 'datetime-picker-icon') region = 'picker-icon';
|
|
46
|
+
if (region !== latestInteractionRegion) setLatestInteractionRegion(region);
|
|
47
|
+
if (lastSegment !== currFocusDescriber) setCurrFocusDescriber(lastSegment);
|
|
48
|
+
}, [currFocusDescriber, lastSegment, latestInteractionRegion]);
|
|
49
|
+
return React.useMemo(() => ({
|
|
50
|
+
latestInteractionRegion,
|
|
51
|
+
setLatestInteractionRegion,
|
|
52
|
+
currFocusDescriber,
|
|
53
|
+
setCurrFocusDescriber,
|
|
54
|
+
trackFocusResetter: () => {
|
|
55
|
+
if (latestInteractionRegion !== '') setLatestInteractionRegion('');
|
|
56
|
+
if (currFocusDescriber !== '') setCurrFocusDescriber('');
|
|
57
|
+
},
|
|
58
|
+
trackFocusMonthInput: () => {
|
|
59
|
+
if (latestInteractionRegion !== 'date-inputs') setLatestInteractionRegion('date-inputs');
|
|
60
|
+
if (currFocusDescriber !== 'month-input') setCurrFocusDescriber('month-input');
|
|
61
|
+
},
|
|
62
|
+
trackFocusDayInput: () => {
|
|
63
|
+
if (latestInteractionRegion !== 'date-inputs') setLatestInteractionRegion('date-inputs');
|
|
64
|
+
if (currFocusDescriber !== 'day-input') setCurrFocusDescriber('day-input');
|
|
65
|
+
},
|
|
66
|
+
trackFocusYearInput: () => {
|
|
67
|
+
if (latestInteractionRegion !== 'date-inputs') setLatestInteractionRegion('date-inputs');
|
|
68
|
+
if (currFocusDescriber !== 'year-input') setCurrFocusDescriber('year-input');
|
|
69
|
+
},
|
|
70
|
+
trackFocusHourInput: () => {
|
|
71
|
+
if (latestInteractionRegion !== 'time-inputs') setLatestInteractionRegion('time-inputs');
|
|
72
|
+
if (currFocusDescriber !== 'hour-input') setCurrFocusDescriber('hour-input');
|
|
73
|
+
},
|
|
74
|
+
trackFocusMinuteInput: () => {
|
|
75
|
+
if (latestInteractionRegion !== 'time-inputs') setLatestInteractionRegion('time-inputs');
|
|
76
|
+
if (currFocusDescriber !== 'minute-input') setCurrFocusDescriber('minute-input');
|
|
77
|
+
},
|
|
78
|
+
trackFocusMeridiemInput: () => {
|
|
79
|
+
if (latestInteractionRegion !== 'time-inputs') setLatestInteractionRegion('time-inputs');
|
|
80
|
+
if (currFocusDescriber !== 'meridiem-input') setCurrFocusDescriber('meridiem-input');
|
|
81
|
+
},
|
|
82
|
+
trackFocusClearBtn: () => {
|
|
83
|
+
if (latestInteractionRegion !== 'clear-btn') setLatestInteractionRegion('clear-btn');
|
|
84
|
+
if (currFocusDescriber !== 'clear-btn') setCurrFocusDescriber('clear-btn');
|
|
85
|
+
},
|
|
86
|
+
trackFocusDatePickerIcon: () => {
|
|
87
|
+
if (latestInteractionRegion !== 'picker-icon') setLatestInteractionRegion('picker-icon');
|
|
88
|
+
if (currFocusDescriber !== 'date-picker-icon') setCurrFocusDescriber('date-picker-icon');
|
|
89
|
+
},
|
|
90
|
+
trackFocusTimePickerIcon: () => {
|
|
91
|
+
if (latestInteractionRegion !== 'picker-icon') setLatestInteractionRegion('picker-icon');
|
|
92
|
+
if (currFocusDescriber !== 'time-picker-icon') setCurrFocusDescriber('time-picker-icon');
|
|
93
|
+
},
|
|
94
|
+
trackFocusDatetimePickerIcon: () => {
|
|
95
|
+
if (latestInteractionRegion !== 'picker-icon') setLatestInteractionRegion('picker-icon');
|
|
96
|
+
if (currFocusDescriber !== 'datetime-picker-icon') setCurrFocusDescriber('datetime-picker-icon');
|
|
97
|
+
},
|
|
98
|
+
trackFocusCalendarPrevMonth: () => {
|
|
99
|
+
if (latestInteractionRegion !== 'calendar-head') setLatestInteractionRegion('calendar-head');
|
|
100
|
+
if (currFocusDescriber !== 'calendar-prev-month') setCurrFocusDescriber('calendar-prev-month');
|
|
101
|
+
},
|
|
102
|
+
trackFocusCalendarNextMonth: () => {
|
|
103
|
+
if (latestInteractionRegion !== 'calendar-head') setLatestInteractionRegion('calendar-head');
|
|
104
|
+
if (currFocusDescriber !== 'calendar-next-month') setCurrFocusDescriber('calendar-next-month');
|
|
105
|
+
},
|
|
106
|
+
trackFocusCalendarPrevYear: () => {
|
|
107
|
+
if (latestInteractionRegion !== 'calendar-head') setLatestInteractionRegion('calendar-head');
|
|
108
|
+
if (currFocusDescriber !== 'calendar-prev-year') setCurrFocusDescriber('calendar-prev-year');
|
|
109
|
+
},
|
|
110
|
+
trackFocusCalendarNextYear: () => {
|
|
111
|
+
if (latestInteractionRegion !== 'calendar-head') setLatestInteractionRegion('calendar-head');
|
|
112
|
+
if (currFocusDescriber !== 'calendar-next-year') setCurrFocusDescriber('calendar-next-year');
|
|
113
|
+
},
|
|
114
|
+
trackFocusCalendarMetafocusedDay: () => {
|
|
115
|
+
if (latestInteractionRegion !== 'calendar-days') setLatestInteractionRegion('calendar-days');
|
|
116
|
+
if (currFocusDescriber !== 'calendar-metafocused-day') setCurrFocusDescriber('calendar-metafocused-day');
|
|
117
|
+
},
|
|
118
|
+
trackFocusTimewheelCurrHour: () => {
|
|
119
|
+
if (latestInteractionRegion !== 'timewheel') setLatestInteractionRegion('timewheel');
|
|
120
|
+
if (currFocusDescriber !== 'timewheel-curr-hour') setCurrFocusDescriber('timewheel-curr-hour');
|
|
121
|
+
},
|
|
122
|
+
trackFocusTimewheelCurrMinute: () => {
|
|
123
|
+
if (latestInteractionRegion !== 'timewheel') setLatestInteractionRegion('timewheel');
|
|
124
|
+
if (currFocusDescriber !== 'timewheel-curr-minute') setCurrFocusDescriber('timewheel-curr-minute');
|
|
125
|
+
},
|
|
126
|
+
trackFocusTimewheelCurrMeridiem: () => {
|
|
127
|
+
if (latestInteractionRegion !== 'timewheel') setLatestInteractionRegion('timewheel');
|
|
128
|
+
if (currFocusDescriber !== 'timewheel-curr-meridiem') setCurrFocusDescriber('timewheel-curr-meridiem');
|
|
129
|
+
},
|
|
130
|
+
trackFocusPicker,
|
|
131
|
+
trackFocusFirstSegment,
|
|
132
|
+
trackFocusLastSegment
|
|
133
|
+
}), [currFocusDescriber, latestInteractionRegion, trackFocusPicker, trackFocusFirstSegment, trackFocusLastSegment]);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
exports.useFocusTracker = useFocusTracker;
|