@elliemae/ds-controlled-form 2.4.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/config/useAutocomplete.js +1 -3
- 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 +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 +2 -2
- package/cjs/checkbox/styles.js +28 -15
- package/cjs/combobox/ComboBoxCTX.js +7 -4
- package/cjs/combobox/ComboboxDataTestids.js +1 -1
- package/cjs/combobox/config/useComboBox.js +21 -8
- package/cjs/combobox/index.js +5 -0
- package/cjs/combobox/parts/A11yFocusedOption.js +14 -6
- package/cjs/combobox/parts/A11ySelectedValues.js +0 -2
- package/cjs/combobox/parts/DropdownIndicator.js +4 -4
- package/cjs/combobox/parts/container/Container.js +14 -17
- package/cjs/combobox/parts/container/styled.js +13 -7
- package/cjs/combobox/parts/controls/Controls.js +22 -14
- package/cjs/combobox/parts/controls/styled.js +22 -13
- package/cjs/combobox/parts/controls/useOnPillsNavigation.js +3 -3
- package/cjs/combobox/parts/controls-input/ControlsInput.js +3 -3
- package/cjs/combobox/parts/controls-input/styled.js +7 -3
- package/cjs/combobox/parts/controls-input/useControlsInput.js +5 -5
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +37 -29
- 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/HeaderList.js +4 -3
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +11 -7
- package/cjs/combobox/parts/menu-list/MenuList.js +10 -5
- package/cjs/combobox/parts/menu-list/styled.js +16 -9
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +17 -15
- 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/react-desc-prop-types.js +3 -2
- package/cjs/combobox/theming.js +13 -0
- package/cjs/combobox/utils/listHelper.js +12 -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 +70 -0
- package/cjs/input-group/InputGroupDataTestIds.js +12 -0
- 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/index.js +12 -0
- package/cjs/input-group/react-desc-prop-types.js +14 -0
- package/cjs/input-group/styled.js +47 -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 +1 -3
- 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 +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 +2 -2
- package/esm/checkbox/styles.js +26 -15
- package/esm/combobox/ComboBoxCTX.js +7 -4
- package/esm/combobox/ComboboxDataTestids.js +1 -1
- package/esm/combobox/config/useComboBox.js +22 -9
- package/esm/combobox/index.js +2 -0
- package/esm/combobox/parts/A11yFocusedOption.js +15 -7
- package/esm/combobox/parts/A11ySelectedValues.js +0 -2
- package/esm/combobox/parts/DropdownIndicator.js +4 -4
- package/esm/combobox/parts/container/Container.js +16 -19
- package/esm/combobox/parts/container/styled.js +13 -6
- package/esm/combobox/parts/controls/Controls.js +22 -14
- package/esm/combobox/parts/controls/styled.js +22 -13
- package/esm/combobox/parts/controls/useOnPillsNavigation.js +3 -3
- package/esm/combobox/parts/controls-input/ControlsInput.js +3 -3
- package/esm/combobox/parts/controls-input/styled.js +7 -3
- package/esm/combobox/parts/controls-input/useControlsInput.js +5 -5
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +38 -30
- 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/HeaderList.js +4 -3
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +11 -7
- package/esm/combobox/parts/menu-list/MenuList.js +10 -5
- package/esm/combobox/parts/menu-list/styled.js +16 -10
- package/esm/combobox/parts/menu-list/useItemRenderer.js +19 -17
- 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/react-desc-prop-types.js +3 -2
- package/esm/combobox/theming.js +8 -0
- package/esm/combobox/utils/listHelper.js +12 -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 +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/index.js +5 -1
- package/esm/input-group/InputGroup.js +60 -0
- package/esm/input-group/InputGroupDataTestIds.js +8 -0
- 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/index.js +2 -0
- package/esm/input-group/react-desc-prop-types.js +10 -0
- package/esm/input-group/styled.js +36 -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/package.json +75 -19
- 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/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 +4 -4
- package/types/checkbox/styles.d.ts +6 -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/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/theming.d.ts +6 -0
- 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/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/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/index.d.ts +2 -0
- package/types/input-group/react-desc-prop-types.d.ts +19 -0
- package/types/input-group/styled.d.ts +4 -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 +6 -6
- 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
|
@@ -9,26 +9,26 @@ const useMaskedOnChange = () => {
|
|
|
9
9
|
onFilter,
|
|
10
10
|
allOptions
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
setMenuState,
|
|
13
13
|
setInputValue,
|
|
14
14
|
setShowSelectedOptions
|
|
15
15
|
} = useContext(ComboBoxContext); // default onchange when no mask provided
|
|
16
16
|
|
|
17
17
|
const handleOnChange = useCallback(e => {
|
|
18
18
|
setShowSelectedOptions(false);
|
|
19
|
-
|
|
19
|
+
setMenuState(true, 'filter', e);
|
|
20
20
|
|
|
21
21
|
if (onFilter) {
|
|
22
22
|
onFilter(filterOptions(e.currentTarget.value, allOptions), e.currentTarget.value);
|
|
23
23
|
setInputValue(e.currentTarget.value);
|
|
24
24
|
}
|
|
25
|
-
}, [allOptions, onFilter, setInputValue,
|
|
25
|
+
}, [allOptions, onFilter, setInputValue, setMenuState, setShowSelectedOptions]); // onchange used when mask is provided
|
|
26
26
|
|
|
27
|
-
const handleOnChangeMask = useCallback((
|
|
27
|
+
const handleOnChangeMask = useCallback((e, mask) => {
|
|
28
28
|
setShowSelectedOptions(false);
|
|
29
|
-
|
|
29
|
+
setMenuState(true, 'filter', e);
|
|
30
30
|
if (mask && onFilter) onFilter(filterOptions(mask, allOptions), mask);else if (!mask && onFilter) onFilter(allOptions, '');
|
|
31
|
-
}, [allOptions, onFilter,
|
|
31
|
+
}, [allOptions, onFilter, setMenuState, setShowSelectedOptions]);
|
|
32
32
|
const onChangeMask = useMask({
|
|
33
33
|
valueSetter: setInputValue,
|
|
34
34
|
onChange: handleOnChangeMask
|
|
@@ -12,14 +12,14 @@ const DropdownIndicator = () => {
|
|
|
12
12
|
props: {
|
|
13
13
|
disabled
|
|
14
14
|
},
|
|
15
|
-
|
|
15
|
+
menuState
|
|
16
16
|
} = useContext(ComboBoxContext);
|
|
17
17
|
return /*#__PURE__*/_jsx(StyledDropDownButton, {
|
|
18
18
|
"data-testid": ComboboxDataTestid.DROPDOWN,
|
|
19
19
|
"aria-controls": "combo-listbox",
|
|
20
20
|
"aria-labelledby": "combo-label",
|
|
21
21
|
disabled: disabled,
|
|
22
|
-
"aria-expanded":
|
|
22
|
+
"aria-expanded": menuState,
|
|
23
23
|
"aria-haspopup": "listbox",
|
|
24
24
|
"aria-hidden": true,
|
|
25
25
|
buttonType: "icon",
|
|
@@ -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, {
|
|
@@ -16,7 +16,7 @@ const useHeaderListHandlers = () => {
|
|
|
16
16
|
},
|
|
17
17
|
showSelectedOptions,
|
|
18
18
|
setShowSelectedOptions,
|
|
19
|
-
|
|
19
|
+
setMenuState
|
|
20
20
|
} = useContext(ComboBoxContext);
|
|
21
21
|
const multiSelectedValues = selectedValues;
|
|
22
22
|
const selectableOptions = getSelectableOptions(filteredOptions);
|
|
@@ -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') {
|
|
57
|
-
|
|
58
|
+
var _innerRef$current;
|
|
59
|
+
|
|
60
|
+
setMenuState(false, 'close', e);
|
|
61
|
+
(_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.focus();
|
|
58
62
|
}
|
|
59
|
-
}, [
|
|
63
|
+
}, [setMenuState, 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(() => {
|
|
@@ -8,11 +8,14 @@ import { HeaderList } from '../header-list/HeaderList.js';
|
|
|
8
8
|
import { useItemRenderer } from './useItemRenderer.js';
|
|
9
9
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
10
10
|
|
|
11
|
-
var _HeaderList
|
|
11
|
+
var _HeaderList;
|
|
12
12
|
const MenuList = () => {
|
|
13
|
+
var _StyledNoResultsWrapp;
|
|
14
|
+
|
|
13
15
|
const {
|
|
14
16
|
props: {
|
|
15
17
|
menuMinWidth,
|
|
18
|
+
noOptionsMessage,
|
|
16
19
|
menuMaxHeight,
|
|
17
20
|
onCreate,
|
|
18
21
|
inline,
|
|
@@ -40,7 +43,9 @@ const MenuList = () => {
|
|
|
40
43
|
inline: inline,
|
|
41
44
|
onMouseDown: preventLoseInputFocus,
|
|
42
45
|
width: width,
|
|
43
|
-
minWidth: menuMinWidth
|
|
46
|
+
minWidth: menuMinWidth // we use width as key to force react virtual re-render on window resize
|
|
47
|
+
// and update the item height accordly
|
|
48
|
+
,
|
|
44
49
|
children: [withHeader && (_HeaderList || (_HeaderList = /*#__PURE__*/_jsx(HeaderList, {}))), filteredOptions.length > 0 || onCreate ? /*#__PURE__*/jsx(StyledVirtualListWrapper, {
|
|
45
50
|
inline: inline,
|
|
46
51
|
maxHeight: menuMaxHeight,
|
|
@@ -56,9 +61,9 @@ const MenuList = () => {
|
|
|
56
61
|
}
|
|
57
62
|
}, void 0, ItemRenderer)
|
|
58
63
|
}) : _StyledNoResultsWrapp || (_StyledNoResultsWrapp = /*#__PURE__*/_jsx(StyledNoResultsWrapper, {
|
|
59
|
-
|
|
60
|
-
}, void 0,
|
|
61
|
-
}), [wrapperListRef, inline, preventLoseInputFocus, width, menuMinWidth, withHeader, filteredOptions.length, onCreate, menuMaxHeight, listRef, virtualListHelpers === null || virtualListHelpers === void 0 ? void 0 : virtualListHelpers.totalSize, ItemRenderer]);
|
|
64
|
+
role: "alert"
|
|
65
|
+
}, void 0, noOptionsMessage))]
|
|
66
|
+
}, width), [wrapperListRef, inline, preventLoseInputFocus, width, menuMinWidth, withHeader, filteredOptions.length, onCreate, menuMaxHeight, listRef, virtualListHelpers === null || virtualListHelpers === void 0 ? void 0 : virtualListHelpers.totalSize, ItemRenderer, noOptionsMessage]);
|
|
62
67
|
};
|
|
63
68
|
|
|
64
69
|
export { MenuList };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
2
|
import { styled } from '@elliemae/ds-system';
|
|
3
3
|
|
|
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 => {
|
|
4
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
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,20 +13,26 @@ 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 overflow-x: hidden;\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
|
-
const
|
|
35
|
+
const StyledCreatableValue = styled.span(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n word-break: break-all;\n"])));
|
|
36
|
+
const StyledNoResultsWrapper = styled.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n padding: 16px;\n"])));
|
|
31
37
|
|
|
32
|
-
export { StyledCreatableLabel, StyledList, StyledListWrapper, StyledNoResultsWrapper, StyledVirtualListWrapper };
|
|
38
|
+
export { StyledCreatableLabel, StyledCreatableValue, StyledList, StyledListWrapper, StyledNoResultsWrapper, StyledVirtualListWrapper };
|
|
@@ -11,10 +11,10 @@ import { useContext, useCallback, useMemo } from 'react';
|
|
|
11
11
|
import { Grid } from '@elliemae/ds-grid';
|
|
12
12
|
import { Section, Separator, SingleMenuItem, MultiMenuItem } from '@elliemae/ds-form';
|
|
13
13
|
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
14
|
-
import { StyledCreatableLabel } from './styled.js';
|
|
14
|
+
import { StyledCreatableLabel, StyledCreatableValue } from './styled.js';
|
|
15
15
|
import { getSuggestedValueOnChange, isSelected } from '../../utils/listHelper.js';
|
|
16
16
|
import { ComboboxDataTestid } from '../../ComboboxDataTestids.js';
|
|
17
|
-
import {
|
|
17
|
+
import { MENU_OPTION_TYPES, INTERNAL_MENU_OPTION_TYPES } from '../../constants.js';
|
|
18
18
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
19
19
|
|
|
20
20
|
var _StyledCreatableLabel;
|
|
@@ -32,7 +32,7 @@ const useItemRenderer = () => {
|
|
|
32
32
|
onFilter,
|
|
33
33
|
allOptions
|
|
34
34
|
},
|
|
35
|
-
|
|
35
|
+
setMenuState,
|
|
36
36
|
inputValue,
|
|
37
37
|
focusOptionIdx,
|
|
38
38
|
setInputValue,
|
|
@@ -40,20 +40,21 @@ const useItemRenderer = () => {
|
|
|
40
40
|
} = useContext(ComboBoxContext);
|
|
41
41
|
const multiple = Array.isArray(selectedValues);
|
|
42
42
|
const CBItem = multiple ? MultiMenuItem : SingleMenuItem;
|
|
43
|
+
const handleOnCreateClick = useCallback(() => {
|
|
44
|
+
if (inputValue && onCreate) {
|
|
45
|
+
onCreate(inputValue);
|
|
46
|
+
setInputValue('');
|
|
47
|
+
if (onFilter) onFilter(allOptions, inputValue);
|
|
48
|
+
}
|
|
49
|
+
}, [onFilter, onCreate, inputValue, allOptions, setInputValue]);
|
|
43
50
|
const handleClick = useCallback((option, e) => {
|
|
44
|
-
if (option.type ===
|
|
45
|
-
if (inputValue) {
|
|
46
|
-
onCreate(inputValue);
|
|
47
|
-
setInputValue('');
|
|
48
|
-
onFilter(allOptions, inputValue);
|
|
49
|
-
}
|
|
50
|
-
} else if (option.type === MENU_OPTION_TYPES.OPTION) {
|
|
51
|
+
if (option.type === MENU_OPTION_TYPES.OPTION) {
|
|
51
52
|
if (!option.disabled) {
|
|
52
53
|
if (onFilter) onFilter(allOptions, inputValue);
|
|
53
54
|
setInputValue('');
|
|
54
55
|
|
|
55
56
|
if (!multiple) {
|
|
56
|
-
|
|
57
|
+
setMenuState(false, 'selectOption', e);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
onChange(getSuggestedValueOnChange(option, selectedValues), option, e);
|
|
@@ -63,7 +64,7 @@ const useItemRenderer = () => {
|
|
|
63
64
|
|
|
64
65
|
e.stopPropagation();
|
|
65
66
|
e.preventDefault();
|
|
66
|
-
}, [onFilter, selectedValues, onChange,
|
|
67
|
+
}, [onFilter, selectedValues, allOptions, onChange, setMenuState, multiple]); // prevent blur from controls input
|
|
67
68
|
|
|
68
69
|
const handleOnMouseDown = useCallback(e => {
|
|
69
70
|
e.preventDefault();
|
|
@@ -78,9 +79,10 @@ const useItemRenderer = () => {
|
|
|
78
79
|
const generalProps = {
|
|
79
80
|
wrapperStyles: {
|
|
80
81
|
position: 'absolute',
|
|
81
|
-
top:
|
|
82
|
+
top: 0,
|
|
82
83
|
left: 0,
|
|
83
|
-
width: '100%'
|
|
84
|
+
width: '100%',
|
|
85
|
+
transform: "translateY(".concat(vItem.start, "px)")
|
|
84
86
|
},
|
|
85
87
|
key: "".concat(option.dsId),
|
|
86
88
|
innerRef: vItem.measureRef
|
|
@@ -120,14 +122,14 @@ const useItemRenderer = () => {
|
|
|
120
122
|
label
|
|
121
123
|
} = _ref;
|
|
122
124
|
return /*#__PURE__*/_jsx(Grid, {
|
|
125
|
+
p: "8px",
|
|
123
126
|
cols: ['min-content', 'auto'],
|
|
124
|
-
height: "16px",
|
|
125
127
|
gutter: "xxs",
|
|
126
128
|
alignItems: "center"
|
|
127
|
-
}, void 0, _StyledCreatableLabel || (_StyledCreatableLabel = /*#__PURE__*/_jsx(StyledCreatableLabel, {}, void 0, "Add:")), /*#__PURE__*/_jsx(
|
|
129
|
+
}, void 0, _StyledCreatableLabel || (_StyledCreatableLabel = /*#__PURE__*/_jsx(StyledCreatableLabel, {}, void 0, "Add:")), /*#__PURE__*/_jsx(StyledCreatableValue, {}, void 0, "\"".concat(label, "\"")));
|
|
128
130
|
},
|
|
129
131
|
label: option.label,
|
|
130
|
-
onClick:
|
|
132
|
+
onClick: handleOnCreateClick
|
|
131
133
|
}));
|
|
132
134
|
}
|
|
133
135
|
|
|
@@ -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
|
|
|
@@ -18,12 +18,13 @@ const ComboboxPropTypes = _objectSpread(_objectSpread({}, globalAttributesPropTy
|
|
|
18
18
|
disabled: PropTypes.bool.description('wheter or not the input is disabled').defaultValue('false'),
|
|
19
19
|
autoFocus: PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),
|
|
20
20
|
hasError: PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),
|
|
21
|
+
noOptionsMessage: PropTypes.string.description('Custome message to be display when no matches found after filtering').defaultValue('No Matches Found'),
|
|
22
|
+
closeMenuOnScroll: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]).description('If true, close the select menu when the user scrolls the document/body.').defaultValue(false),
|
|
21
23
|
onChange: PropTypes.func.isRequired.description('function triggered when an option is selected it will send the options selected').defaultValue('() => {}'),
|
|
22
24
|
onFilter: PropTypes.func.description('function triggered when user type in the combobox input').defaultValue(''),
|
|
23
25
|
onCreate: PropTypes.func.description('function triggered when user select "create" a new item whenever is not a match in the all option list').defaultValue(''),
|
|
24
26
|
onCancel: PropTypes.func.description('function triggered when user press ESC key').defaultValue('() => {}'),
|
|
25
|
-
|
|
26
|
-
onMenuClose: PropTypes.func.description('function triggered when user close the menu list').defaultValue('() => {}'),
|
|
27
|
+
onMenuChange: PropTypes.func.description('function triggered when user open or close the menu list').defaultValue('() => {}'),
|
|
27
28
|
inputMinWidth: PropTypes.any.description('Minimum width for the combo box input controller').defaultValue(undefined),
|
|
28
29
|
menuMinWidth: PropTypes.any.description('Minimum width for the dropdown menu').defaultValue(undefined),
|
|
29
30
|
menuMaxHeight: PropTypes.any.description('Maximum height for the dropdown menu').defaultValue(undefined),
|
|
@@ -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
|
};
|
|
@@ -97,5 +98,14 @@ const selectedValuesWithSections = (optionsToParse, multiSelectedValue) => {
|
|
|
97
98
|
return items;
|
|
98
99
|
};
|
|
99
100
|
const getFilteredOptionsSelected = (filteredOption, selectedValues) => filteredOption.filter(option => option.type === MENU_OPTION_TYPES.OPTION && isSelected(selectedValues, option));
|
|
101
|
+
const scrollIfNeeded = function (elem) {
|
|
102
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
103
|
+
behavior: 'smooth',
|
|
104
|
+
block: 'end',
|
|
105
|
+
inline: 'nearest'
|
|
106
|
+
};
|
|
107
|
+
const bounding = elem.getBoundingClientRect();
|
|
108
|
+
if (!(bounding.top >= 0 && bounding.left >= 0 && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && bounding.right <= (window.innerWidth || document.documentElement.clientWidth))) elem.scrollIntoView(options);
|
|
109
|
+
};
|
|
100
110
|
|
|
101
|
-
export { filterOptions, findInCircularList, getFilteredOptionsSelected, getFirstOption, getLastValueSelected, getOptions, getSelectableOptions, getSuggestedValueOnChange, isSelected, isSelectedValueEmpty, isSelectedValueMultiple, selectedValuesWithSections };
|
|
111
|
+
export { filterOptions, findInCircularList, getFilteredOptionsSelected, getFirstOption, getLastValueSelected, getOptions, getSelectableOptions, getSuggestedValueOnChange, isSelected, isSelectedValueEmpty, isSelectedValueMultiple, scrollIfNeeded, selectedValuesWithSections };
|
|
@@ -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
|
|