@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
|
@@ -27,8 +27,6 @@ const A11ySelectedValues = () => {
|
|
|
27
27
|
if (selectedValues.length > 0) {
|
|
28
28
|
msg = "Options selected: ".concat(selectedValues.map(item => item.label).join(', '));
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
msg = 'No Options Selected';
|
|
32
30
|
} else if (selectedValues) {
|
|
33
31
|
msg = "Option selected: ".concat(selectedValues === null || selectedValues === void 0 ? void 0 : selectedValues.label);
|
|
34
32
|
}
|
|
@@ -17,19 +17,19 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
|
17
17
|
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
18
18
|
|
|
19
19
|
var _templateObject;
|
|
20
|
-
const StyledDropDownButton = dsSystem.styled(DSButton.DSButtonV2)(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n &:focus::after {\n border: none;\n }\n & svg {\n fill: ", ";\n }\n"])), _ref => {
|
|
20
|
+
const StyledDropDownButton = dsSystem.styled(DSButton.DSButtonV2)(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n &:focus::after {\n border: none;\n }\n &:hover:not(:disabled) {\n background-color: transparent;\n }\n\n & svg {\n fill: ", ";\n }\n"])), _ref => {
|
|
21
21
|
let {
|
|
22
22
|
theme,
|
|
23
23
|
disabled
|
|
24
24
|
} = _ref;
|
|
25
|
-
return disabled ? '
|
|
25
|
+
return disabled ? theme.colors.neutral['400'] : theme.colors.brand['700'];
|
|
26
26
|
});
|
|
27
27
|
const DropdownIndicator = () => {
|
|
28
28
|
const {
|
|
29
29
|
props: {
|
|
30
30
|
disabled
|
|
31
31
|
},
|
|
32
|
-
|
|
32
|
+
menuState
|
|
33
33
|
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
34
34
|
const colorButton = React.useMemo(() => disabled ? ['neutral', 400] : ['brand-primary', 700], [disabled]);
|
|
35
35
|
const handleOnClick = React.useCallback(e => {
|
|
@@ -41,7 +41,7 @@ const DropdownIndicator = () => {
|
|
|
41
41
|
"aria-controls": "combo-listbox",
|
|
42
42
|
"aria-labelledby": "combo-label",
|
|
43
43
|
disabled: disabled,
|
|
44
|
-
"aria-expanded":
|
|
44
|
+
"aria-expanded": menuState,
|
|
45
45
|
"aria-haspopup": "listbox",
|
|
46
46
|
"aria-hidden": true,
|
|
47
47
|
buttonType: "icon",
|
|
@@ -38,23 +38,21 @@ const Container = () => {
|
|
|
38
38
|
|
|
39
39
|
const {
|
|
40
40
|
props,
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
setMenuState,
|
|
42
|
+
menuState,
|
|
43
43
|
setReferenceElement,
|
|
44
44
|
referenceElement
|
|
45
45
|
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
46
46
|
const {
|
|
47
47
|
inline,
|
|
48
|
-
onMenuOpen,
|
|
49
|
-
onMenuClose,
|
|
50
48
|
innerRef,
|
|
51
49
|
startPlacementPreference,
|
|
52
50
|
placementOrderPreference,
|
|
53
51
|
withoutPortal,
|
|
54
52
|
zIndex
|
|
55
53
|
} = props;
|
|
56
|
-
const
|
|
57
|
-
const
|
|
54
|
+
const globalAttributes = dsPropsHelpers.useGetGlobalAttributes(props);
|
|
55
|
+
const xStyledProps = dsPropsHelpers.useGetXstyledProps(props); // Removing possible collisionable props
|
|
58
56
|
|
|
59
57
|
const globalsAttrs = _objectWithoutProperties__default["default"](globalAttributes, _excluded);
|
|
60
58
|
|
|
@@ -62,31 +60,30 @@ const Container = () => {
|
|
|
62
60
|
e.preventDefault();
|
|
63
61
|
}, []);
|
|
64
62
|
const handleCloseMenu = React.useCallback(() => {
|
|
65
|
-
|
|
63
|
+
setMenuState(false, 'blur');
|
|
66
64
|
if (innerRef !== null && innerRef !== void 0 && innerRef.current) innerRef.current.blur();
|
|
67
|
-
}, [innerRef,
|
|
65
|
+
}, [innerRef, setMenuState]);
|
|
68
66
|
React.useEffect(() => {
|
|
69
|
-
const closeMenuOnWindowBlur = () =>
|
|
67
|
+
const closeMenuOnWindowBlur = () => {
|
|
68
|
+
setMenuState(false, 'blur');
|
|
69
|
+
};
|
|
70
70
|
|
|
71
71
|
window.addEventListener('blur', closeMenuOnWindowBlur);
|
|
72
72
|
return () => {
|
|
73
73
|
window.removeEventListener('blur', closeMenuOnWindowBlur);
|
|
74
74
|
};
|
|
75
|
-
}, [
|
|
76
|
-
React.
|
|
77
|
-
if (onMenuOpen && showPopover) onMenuOpen();else if (onMenuClose && !showPopover) onMenuClose();
|
|
78
|
-
}, [showPopover, onMenuOpen, onMenuClose]);
|
|
79
|
-
return React.useMemo(() => /*#__PURE__*/jsxRuntime.jsx(StyledContainer, _objectSpread(_objectSpread({
|
|
75
|
+
}, [setMenuState]);
|
|
76
|
+
return React.useMemo(() => /*#__PURE__*/jsxRuntime.jsx(styled.StyledContainer, _objectSpread(_objectSpread(_objectSpread({
|
|
80
77
|
"data-testid": ComboboxDataTestids.ComboboxDataTestid.CONTAINER,
|
|
81
78
|
ref: setReferenceElement
|
|
82
|
-
}, globalsAttrs), {}, {
|
|
79
|
+
}, globalsAttrs), xStyledProps), {}, {
|
|
83
80
|
children: inline ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
84
81
|
children: [_Controls || (_Controls = /*#__PURE__*/_jsx__default["default"](Controls.Controls, {})), _MenuList || (_MenuList = /*#__PURE__*/_jsx__default["default"](MenuList.MenuList, {}))]
|
|
85
82
|
}) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
86
83
|
children: [_Controls2 || (_Controls2 = /*#__PURE__*/_jsx__default["default"](Controls.Controls, {})), /*#__PURE__*/_jsx__default["default"](dsPopperjs.DSPopperJS, {
|
|
87
84
|
customOffset: [0, 5],
|
|
88
85
|
referenceElement: referenceElement,
|
|
89
|
-
showPopover:
|
|
86
|
+
showPopover: menuState,
|
|
90
87
|
closeContextMenu: handleCloseMenu,
|
|
91
88
|
startPlacementPreference: startPlacementPreference,
|
|
92
89
|
placementOrderPreference: placementOrderPreference,
|
|
@@ -99,7 +96,7 @@ const Container = () => {
|
|
|
99
96
|
onMouseDown: handleMouseDown
|
|
100
97
|
}, void 0, _MenuList2 || (_MenuList2 = /*#__PURE__*/_jsx__default["default"](MenuList.MenuList, {})))))]
|
|
101
98
|
})
|
|
102
|
-
})), [inline,
|
|
99
|
+
})), [inline, setReferenceElement, globalsAttrs, referenceElement, menuState, xStyledProps, handleCloseMenu, startPlacementPreference, placementOrderPreference, withoutPortal, zIndex, handleMouseDown]);
|
|
103
100
|
};
|
|
104
101
|
|
|
105
102
|
exports.Container = Container;
|
|
@@ -4,22 +4,28 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
|
|
6
6
|
var dsSystem = require('@elliemae/ds-system');
|
|
7
|
+
var theming = require('../../theming.js');
|
|
7
8
|
|
|
8
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
10
|
|
|
10
11
|
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
11
12
|
|
|
12
|
-
var _templateObject, _templateObject2
|
|
13
|
-
const
|
|
13
|
+
var _templateObject, _templateObject2;
|
|
14
|
+
const StyledContainer = dsSystem.styled('div', {
|
|
15
|
+
name: theming.DSComboBoxName,
|
|
16
|
+
slot: theming.DSComboboxSlots.CONTAINER
|
|
17
|
+
})(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n position: relative;\n cursor: ", ";\n"])), _ref => {
|
|
14
18
|
let {
|
|
15
19
|
disabled
|
|
16
20
|
} = _ref;
|
|
17
21
|
return disabled ? 'not-allowed' : 'default';
|
|
18
22
|
});
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
const StyledPopperWrapper = dsSystem.styled('div')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n position: relative;\n cursor: ", ";\n overflow: auto;\n"])), _ref2 => {
|
|
24
|
+
let {
|
|
25
|
+
disabled
|
|
26
|
+
} = _ref2;
|
|
27
|
+
return disabled ? 'not-allowed' : 'default';
|
|
28
|
+
});
|
|
22
29
|
|
|
23
|
-
exports.
|
|
24
|
-
exports.StyledContainerWithPopper = StyledContainerWithPopper;
|
|
30
|
+
exports.StyledContainer = StyledContainer;
|
|
25
31
|
exports.StyledPopperWrapper = StyledPopperWrapper;
|
|
@@ -8,6 +8,7 @@ var DropdownIndicator = require('../DropdownIndicator.js');
|
|
|
8
8
|
var ComboboxDataTestids = require('../../ComboboxDataTestids.js');
|
|
9
9
|
var ComboBoxCTX = require('../../ComboBoxCTX.js');
|
|
10
10
|
var styled = require('./styled.js');
|
|
11
|
+
var listHelper = require('../../utils/listHelper.js');
|
|
11
12
|
var MultiSelectedValuesContainer = require('../multi-selected-values-container/MultiSelectedValuesContainer.js');
|
|
12
13
|
var ControlsInput = require('../controls-input/ControlsInput.js');
|
|
13
14
|
var useOnPillsNavigation = require('./useOnPillsNavigation.js');
|
|
@@ -20,7 +21,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
20
21
|
|
|
21
22
|
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
22
23
|
|
|
23
|
-
var _A11ySelectedValues,
|
|
24
|
+
var _A11ySelectedValues, _MultiSelectedValuesC, _A11yFocusedOption, _ControlsInput, _DropdownIndicator;
|
|
24
25
|
const Controls = () => {
|
|
25
26
|
const {
|
|
26
27
|
props: {
|
|
@@ -32,11 +33,12 @@ const Controls = () => {
|
|
|
32
33
|
innerRef
|
|
33
34
|
},
|
|
34
35
|
selectedOptionsRef,
|
|
35
|
-
|
|
36
|
+
setMenuState,
|
|
37
|
+
setFocusOptionIdx,
|
|
36
38
|
hasFocus,
|
|
39
|
+
listRef,
|
|
37
40
|
focusOptionIdx,
|
|
38
|
-
|
|
39
|
-
showPopover,
|
|
41
|
+
menuState,
|
|
40
42
|
controlsWrapperRef
|
|
41
43
|
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
42
44
|
const handleOnClick = React.useCallback(() => {
|
|
@@ -44,28 +46,34 @@ const Controls = () => {
|
|
|
44
46
|
|
|
45
47
|
if (disabled) return;
|
|
46
48
|
|
|
47
|
-
if (hasFocus &&
|
|
49
|
+
if (hasFocus && menuState && !inline) {
|
|
48
50
|
var _innerRef$current;
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
setMenuState(false);
|
|
53
|
+
setFocusOptionIdx('');
|
|
51
54
|
(_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.blur();
|
|
52
55
|
return;
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
(_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.focus();
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
setMenuState(true);
|
|
60
|
+
window.requestAnimationFrame(() => {
|
|
61
|
+
window.requestAnimationFrame(() => {
|
|
62
|
+
if (listRef.current) listHelper.scrollIfNeeded(listRef.current);
|
|
63
|
+
});
|
|
64
|
+
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
+
}, [disabled, listRef, hasFocus, menuState, inline, innerRef, setMenuState, focusOptionIdx]); // this callback prevent to toggle the menu when clicking or removing pills
|
|
58
66
|
|
|
59
67
|
const handleOnPillsClick = React.useCallback(e => {
|
|
60
|
-
if (
|
|
68
|
+
if (menuState || disabled) {
|
|
61
69
|
e.stopPropagation();
|
|
62
70
|
} else {
|
|
63
71
|
var _innerRef$current3;
|
|
64
72
|
|
|
65
73
|
(_innerRef$current3 = innerRef.current) === null || _innerRef$current3 === void 0 ? void 0 : _innerRef$current3.focus();
|
|
66
|
-
|
|
74
|
+
setMenuState(true);
|
|
67
75
|
}
|
|
68
|
-
}, [
|
|
76
|
+
}, [menuState, innerRef, disabled, setMenuState]); // callback to prevent onBlur on the input when clicking in all the wrapper
|
|
69
77
|
|
|
70
78
|
const handleOnMouseDown = React.useCallback(e => {
|
|
71
79
|
if (document.activeElement === innerRef.current || inline) {
|
|
@@ -90,14 +98,14 @@ const Controls = () => {
|
|
|
90
98
|
children: [!inline && /*#__PURE__*/jsxRuntime.jsxs(styled.StyledSelection, {
|
|
91
99
|
ref: selectedOptionsRef,
|
|
92
100
|
onClick: handleOnPillsClick,
|
|
93
|
-
children: [_A11ySelectedValues || (_A11ySelectedValues = /*#__PURE__*/_jsx__default["default"](A11ySelectedValues.A11ySelectedValues, {})),
|
|
101
|
+
children: [_A11ySelectedValues || (_A11ySelectedValues = /*#__PURE__*/_jsx__default["default"](A11ySelectedValues.A11ySelectedValues, {})), Array.isArray(selectedValues) ? _MultiSelectedValuesC || (_MultiSelectedValuesC = /*#__PURE__*/_jsx__default["default"](MultiSelectedValuesContainer.MultiSelectedValuesContainer, {})) : /*#__PURE__*/_jsx__default["default"]("div", {
|
|
94
102
|
"data-testid": ComboboxDataTestids.ComboboxDataTestid.SELECTED_VALUES
|
|
95
103
|
}, void 0, selectedValues && /*#__PURE__*/_jsx__default["default"](RemovableSelectedValuePill.RemovableSelectedValuePill, {
|
|
96
104
|
pill: selectedValues
|
|
97
105
|
}))]
|
|
98
|
-
}), _ControlsInput || (_ControlsInput = /*#__PURE__*/_jsx__default["default"](ControlsInput.ControlsInput, {})), !inline && /*#__PURE__*/_jsx__default["default"](styled.StyledHeaderActionsWrapper, {
|
|
106
|
+
}), _A11yFocusedOption || (_A11yFocusedOption = /*#__PURE__*/_jsx__default["default"](A11yFocusedOption.A11yFocusedOption, {})), _ControlsInput || (_ControlsInput = /*#__PURE__*/_jsx__default["default"](ControlsInput.ControlsInput, {})), !inline && /*#__PURE__*/_jsx__default["default"](styled.StyledHeaderActionsWrapper, {
|
|
99
107
|
justifyContent: "center",
|
|
100
|
-
cols: ['
|
|
108
|
+
cols: ['min-content', 'min-content']
|
|
101
109
|
}, void 0, /*#__PURE__*/_jsx__default["default"](styled.StyleHeaderActionsSeparator, {
|
|
102
110
|
disabled: disabled
|
|
103
111
|
}), _DropdownIndicator || (_DropdownIndicator = /*#__PURE__*/_jsx__default["default"](DropdownIndicator.DropdownIndicator, {})))]
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
|
|
6
6
|
var dsSystem = require('@elliemae/ds-system');
|
|
7
7
|
var dsGrid = require('@elliemae/ds-grid');
|
|
8
|
+
var theming = require('../../theming.js');
|
|
8
9
|
|
|
9
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
11
|
|
|
@@ -18,39 +19,47 @@ const normalBorder = dsSystem.css(_templateObject || (_templateObject = _taggedT
|
|
|
18
19
|
} = _ref;
|
|
19
20
|
return hasError ? theme.colors.danger[900] : theme.colors.neutral[400];
|
|
20
21
|
});
|
|
21
|
-
const focusBorder = dsSystem.css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n
|
|
22
|
+
const focusBorder = dsSystem.css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n outline: 2px solid ", ";\n outline-offset: -2px;\n"])), _ref2 => {
|
|
22
23
|
let {
|
|
23
24
|
theme
|
|
24
25
|
} = _ref2;
|
|
25
26
|
return theme.colors.brand[700];
|
|
26
27
|
});
|
|
27
|
-
const
|
|
28
|
-
const StyledControlsWrapper = dsSystem.styled(dsGrid.Grid)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral__default["default"](["\n background: ", ";\n position: relative;\n border-radius: 2px;\n min-width: ", ";\n align-items: center;\n align-content: center;\n height: 28px;\n padding-left: 8px;\n margin: ", ";\n &::after {\n ", "\n ", "\n }\n\n &:focus-within {\n &::after {\n ", "\n ", "\n }\n }\n"])), _ref3 => {
|
|
28
|
+
const hoverBorder = dsSystem.css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral__default["default"](["\n border: 1px solid ", ";\n"])), _ref3 => {
|
|
29
29
|
let {
|
|
30
|
-
disabled,
|
|
31
30
|
theme
|
|
32
31
|
} = _ref3;
|
|
32
|
+
return theme.colors.brand[700];
|
|
33
|
+
});
|
|
34
|
+
const StyledControlsWrapper = dsSystem.styled(dsGrid.Grid, {
|
|
35
|
+
name: theming.DSComboBoxName,
|
|
36
|
+
slot: theming.DSComboboxSlots.INPUT_WRAPPER
|
|
37
|
+
})(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral__default["default"](["\n background: ", ";\n position: relative;\n border-radius: 2px;\n min-width: ", ";\n align-items: center;\n align-content: center;\n height: 28px;\n padding-left: 8px;\n margin: ", ";\n ", "\n &:hover {\n ", "\n }\n &:focus-within {\n ", "\n }\n"])), _ref4 => {
|
|
38
|
+
let {
|
|
39
|
+
disabled,
|
|
40
|
+
theme
|
|
41
|
+
} = _ref4;
|
|
33
42
|
return disabled ? theme.colors.neutral['080'] : '#ffffff';
|
|
34
|
-
},
|
|
43
|
+
}, _ref5 => {
|
|
35
44
|
let {
|
|
36
45
|
minWidth,
|
|
37
46
|
inline
|
|
38
|
-
} =
|
|
47
|
+
} = _ref5;
|
|
39
48
|
return inline || !minWidth ? '' : "".concat(minWidth, "px");
|
|
40
|
-
},
|
|
49
|
+
}, _ref6 => {
|
|
41
50
|
let {
|
|
42
51
|
inline
|
|
43
|
-
} =
|
|
44
|
-
return inline ? '10px 16px' : '
|
|
45
|
-
},
|
|
46
|
-
const StyledSelection = dsSystem.styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral__default["default"](["\n font-size: 13px;\n margin-right: 3px;\n
|
|
52
|
+
} = _ref6;
|
|
53
|
+
return inline ? '10px 16px' : '';
|
|
54
|
+
}, normalBorder, hoverBorder, focusBorder);
|
|
55
|
+
const StyledSelection = dsSystem.styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral__default["default"](["\n font-size: 13px;\n margin-right: 3px;\n display: flex;\n"])));
|
|
47
56
|
const StyledHeaderActionsWrapper = dsSystem.styled(dsGrid.Grid)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral__default["default"](["\n height: 100%;\n .em-ds-button--text:focus::after {\n border: none;\n }\n"])));
|
|
48
57
|
const StyleDropdownIndicator = dsSystem.styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral__default["default"]([""])));
|
|
49
|
-
const StyleHeaderActionsSeparator = dsSystem.styled.span(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral__default["default"](["\n align-self: stretch;\n margin: 4px 0px;\n width: 1px;\n background-color: ", ";\n"])),
|
|
58
|
+
const StyleHeaderActionsSeparator = dsSystem.styled.span(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral__default["default"](["\n align-self: stretch;\n margin: 4px 0px;\n width: 1px;\n background-color: ", ";\n"])), _ref7 => {
|
|
50
59
|
let {
|
|
51
60
|
theme,
|
|
52
61
|
disabled
|
|
53
|
-
} =
|
|
62
|
+
} = _ref7;
|
|
54
63
|
return disabled ? theme.colors.neutral['400'] : theme.colors.neutral['500'];
|
|
55
64
|
});
|
|
56
65
|
|
|
@@ -13,7 +13,7 @@ const useOnPillsNavigation = () => {
|
|
|
13
13
|
},
|
|
14
14
|
inputValue,
|
|
15
15
|
hasFocus,
|
|
16
|
-
|
|
16
|
+
setMenuState,
|
|
17
17
|
selectedOptionsRef
|
|
18
18
|
} = React.useContext(ComboBoxCTX.ComboBoxContext); // todo: constant must be defined on pills component
|
|
19
19
|
|
|
@@ -24,7 +24,7 @@ const useOnPillsNavigation = () => {
|
|
|
24
24
|
var _innerRef$current;
|
|
25
25
|
|
|
26
26
|
(_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.focus();
|
|
27
|
-
|
|
27
|
+
setMenuState(true, 'open', e);
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -47,7 +47,7 @@ const useOnPillsNavigation = () => {
|
|
|
47
47
|
(_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.focus();
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
}, [inputValue,
|
|
50
|
+
}, [inputValue, innerRef, setMenuState, selectedOptionsRef, hasFocus]);
|
|
51
51
|
return {
|
|
52
52
|
onKeyDownPills
|
|
53
53
|
};
|
|
@@ -27,7 +27,7 @@ const ControlsInput = () => {
|
|
|
27
27
|
},
|
|
28
28
|
focusOptionIdx,
|
|
29
29
|
inputValue,
|
|
30
|
-
|
|
30
|
+
menuState
|
|
31
31
|
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
32
32
|
const {
|
|
33
33
|
onInputKeyDown
|
|
@@ -52,8 +52,8 @@ const ControlsInput = () => {
|
|
|
52
52
|
placeholder: placeholder,
|
|
53
53
|
"aria-controls": "combo-listbox",
|
|
54
54
|
"aria-activedescendant": focusOptionIdx,
|
|
55
|
-
"aria-expanded":
|
|
56
|
-
"aria-haspopup": "
|
|
55
|
+
"aria-expanded": menuState,
|
|
56
|
+
"aria-haspopup": "listbox",
|
|
57
57
|
"aria-describedby": "combobox-selected-items",
|
|
58
58
|
role: "combobox",
|
|
59
59
|
disabled: disabled,
|
|
@@ -4,21 +4,25 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
|
|
6
6
|
var dsSystem = require('@elliemae/ds-system');
|
|
7
|
+
var theming = require('../../theming.js');
|
|
7
8
|
|
|
8
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
10
|
|
|
10
11
|
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
11
12
|
|
|
12
13
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
13
|
-
const StyledInput = dsSystem.styled
|
|
14
|
+
const StyledInput = dsSystem.styled('input', {
|
|
15
|
+
name: theming.DSComboBoxName,
|
|
16
|
+
slot: theming.DSComboboxSlots.INPUT
|
|
17
|
+
})(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n font-size: 13px;\n line-height: 13px;\n border: none;\n padding: 0;\n outline: none;\n color: ", ";\n &:focus {\n outline: none;\n }\n ", "\n &::placeholder {\n color: transparent;\n }\n"])), props => props.theme.colors.neutral[700], _ref => {
|
|
14
18
|
let {
|
|
15
19
|
withoutCaret
|
|
16
20
|
} = _ref;
|
|
17
21
|
return withoutCaret && 'caret-color: transparent;';
|
|
18
22
|
});
|
|
19
|
-
const StyledInputPlaceHolder = dsSystem.styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n font-style: italic;\n color: ", ";\n position: absolute;\n display: flex;\n align-items: center;\n width: 100%;\n user-select: none;\n height: 28px;\n & span {\n
|
|
23
|
+
const StyledInputPlaceHolder = dsSystem.styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n font-style: italic;\n color: ", ";\n position: absolute;\n display: flex;\n align-items: center;\n width: 100%;\n user-select: none;\n height: 28px;\n font-size: 13px;\n & span::after {\n content: '';\n padding: 1px;\n }\n"])), props => props.theme.colors.neutral[500]);
|
|
20
24
|
const StyledInputWidthReference = dsSystem.styled.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral__default["default"](["\n visibility: hidden;\n position: absolute;\n top: -9999px;\n"])));
|
|
21
|
-
const StyledInputWrapper = dsSystem.styled
|
|
25
|
+
const StyledInputWrapper = dsSystem.styled('div')(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral__default["default"](["\n position: relative;\n align-items: center;\n display: flex;\n"])));
|
|
22
26
|
|
|
23
27
|
exports.StyledInput = StyledInput;
|
|
24
28
|
exports.StyledInputPlaceHolder = StyledInputPlaceHolder;
|
|
@@ -19,8 +19,8 @@ const useControlsInput = () => {
|
|
|
19
19
|
},
|
|
20
20
|
setHasFocus,
|
|
21
21
|
inputValue,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
setMenuState,
|
|
23
|
+
setInputValue
|
|
24
24
|
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
25
25
|
const [width, setWidth] = React.useState(1); // use span reference to calculate the real width for the input
|
|
26
26
|
|
|
@@ -37,9 +37,9 @@ const useControlsInput = () => {
|
|
|
37
37
|
const handleOnChange = useMaskedOnChange.useMaskedOnChange();
|
|
38
38
|
const handleOnBlur = React.useCallback(() => {
|
|
39
39
|
setInputValue('');
|
|
40
|
-
if (onFilter) onFilter(allOptions
|
|
41
|
-
setHasFocus(false);
|
|
42
|
-
}, [setInputValue, onFilter, allOptions,
|
|
40
|
+
if (onFilter) onFilter(allOptions);
|
|
41
|
+
setHasFocus(false);
|
|
42
|
+
}, [setInputValue, onFilter, allOptions, setHasFocus]);
|
|
43
43
|
const handleOnFocus = React.useCallback(() => {
|
|
44
44
|
setHasFocus(true);
|
|
45
45
|
}, [setHasFocus]);
|
|
@@ -30,11 +30,12 @@ const useKeyboardNavigation = () => {
|
|
|
30
30
|
withoutPortal
|
|
31
31
|
},
|
|
32
32
|
inputValue,
|
|
33
|
-
|
|
33
|
+
menuState,
|
|
34
34
|
focusOptionIdx,
|
|
35
|
+
listRef,
|
|
35
36
|
selectAllCheckboxRef,
|
|
36
37
|
toggleSelectionButtonRef,
|
|
37
|
-
|
|
38
|
+
setMenuState,
|
|
38
39
|
setInputValue,
|
|
39
40
|
scrollOptionIntoView,
|
|
40
41
|
setFocusOptionIdx
|
|
@@ -49,8 +50,11 @@ const useKeyboardNavigation = () => {
|
|
|
49
50
|
// =============================================================================
|
|
50
51
|
if (onKeyDown && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === constants.MENU_OPTION_TYPES.OPTION) onKeyDown(e, currentItem);
|
|
51
52
|
|
|
52
|
-
if (['ArrowDown', 'ArrowUp', 'Enter', 'Spacebar'].includes(e.key) || e.keyCode >= 48 && e.keyCode <= 90) {
|
|
53
|
-
|
|
53
|
+
if ((['ArrowDown', 'ArrowUp', 'Enter', 'Spacebar'].includes(e.key) || e.keyCode >= 48 && e.keyCode <= 90) && !menuState) {
|
|
54
|
+
setMenuState(true);
|
|
55
|
+
window.requestAnimationFrame(() => {
|
|
56
|
+
if (listRef.current) listHelper.scrollIfNeeded(listRef.current);
|
|
57
|
+
});
|
|
54
58
|
} // =============================================================================
|
|
55
59
|
// ESCAPE
|
|
56
60
|
// =============================================================================
|
|
@@ -64,14 +68,14 @@ const useKeyboardNavigation = () => {
|
|
|
64
68
|
setInputValue('');
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
if (!inline)
|
|
71
|
+
if (!inline) setMenuState(false, 'close', e);
|
|
68
72
|
} // =============================================================================
|
|
69
73
|
// ENTER KEY TO CREATE ELEMENTS
|
|
70
74
|
// =============================================================================
|
|
71
75
|
|
|
72
76
|
|
|
73
77
|
if (e.key === 'Enter' && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === constants.INTERNAL_MENU_OPTION_TYPES.CREATABLE && onCreate) {
|
|
74
|
-
onCreate(inputValue); //blank active item to force search last one
|
|
78
|
+
onCreate(inputValue); // blank active item to force search last one
|
|
75
79
|
|
|
76
80
|
setFocusOptionIdx('');
|
|
77
81
|
if (onFilter) onFilter(allOptions, '');
|
|
@@ -86,12 +90,12 @@ const useKeyboardNavigation = () => {
|
|
|
86
90
|
e.preventDefault();
|
|
87
91
|
e.stopPropagation();
|
|
88
92
|
|
|
89
|
-
if (focusOptionIdx !== '' && (
|
|
93
|
+
if (focusOptionIdx !== '' && (menuState || inline) && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === constants.MENU_OPTION_TYPES.OPTION && !currentItem.disabled) {
|
|
90
94
|
if (onFilter) onFilter(allOptions, '');
|
|
91
95
|
setInputValue('');
|
|
92
96
|
|
|
93
97
|
if (!multiple) {
|
|
94
|
-
|
|
98
|
+
setMenuState(false, 'selectOption', e);
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
onChange(listHelper.getSuggestedValueOnChange(currentItem, selectedValues), currentItem, e);
|
|
@@ -99,7 +103,7 @@ const useKeyboardNavigation = () => {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
if (e.key === 'Enter' && e.altKey) {
|
|
102
|
-
|
|
106
|
+
setMenuState(false, 'selectOption', e);
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
if (e.key === 'a' && e.ctrlKey && multiple && onSelectAll) {
|
|
@@ -113,10 +117,13 @@ const useKeyboardNavigation = () => {
|
|
|
113
117
|
e.preventDefault();
|
|
114
118
|
e.stopPropagation();
|
|
115
119
|
|
|
116
|
-
if ((
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
if ((menuState || inline) && selectableOptions.length) {
|
|
121
|
+
const nextItemIndexIndex = listHelper.findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable);
|
|
122
|
+
|
|
123
|
+
if (nextItemIndexIndex > -1) {
|
|
124
|
+
setFocusOptionIdx(filteredOptions[nextItemIndexIndex].dsId);
|
|
125
|
+
scrollOptionIntoView(filteredOptions[nextItemIndexIndex].dsId);
|
|
126
|
+
}
|
|
120
127
|
}
|
|
121
128
|
}
|
|
122
129
|
|
|
@@ -126,16 +133,19 @@ const useKeyboardNavigation = () => {
|
|
|
126
133
|
if (!selectableOptions.length) return;
|
|
127
134
|
const prevItemIndex = listHelper.findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable, -1);
|
|
128
135
|
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
if (prevItemIndex > -1) {
|
|
137
|
+
if (menuState || inline) {
|
|
138
|
+
setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);
|
|
139
|
+
scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);
|
|
140
|
+
} else {
|
|
141
|
+
// open menu and search last item to focused
|
|
142
|
+
setMenuState(true, 'open', e);
|
|
143
|
+
const lastItemIndex = listHelper.findInCircularList(filteredOptions, 0, isOptionFocuseable, -1);
|
|
144
|
+
setFocusOptionIdx(filteredOptions[lastItemIndex].dsId);
|
|
145
|
+
setTimeout(() => {
|
|
146
|
+
scrollOptionIntoView(filteredOptions[lastItemIndex].dsId);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
139
149
|
}
|
|
140
150
|
} // =============================================================================
|
|
141
151
|
// BACKSPACE
|
|
@@ -152,7 +162,7 @@ const useKeyboardNavigation = () => {
|
|
|
152
162
|
if (onFilter) onFilter(allOptions, inputValue);
|
|
153
163
|
}
|
|
154
164
|
|
|
155
|
-
if (e.key === 'Tab' && !inline &&
|
|
165
|
+
if (e.key === 'Tab' && !inline && menuState) {
|
|
156
166
|
var _selectAllCheckboxRef;
|
|
157
167
|
|
|
158
168
|
const element = (_selectAllCheckboxRef = selectAllCheckboxRef.current) !== null && _selectAllCheckboxRef !== void 0 ? _selectAllCheckboxRef : toggleSelectionButtonRef.current;
|
|
@@ -160,14 +170,12 @@ const useKeyboardNavigation = () => {
|
|
|
160
170
|
if (element) {
|
|
161
171
|
e.preventDefault();
|
|
162
172
|
element.focus();
|
|
173
|
+
} else {
|
|
174
|
+
setMenuState(false, 'blur', e);
|
|
163
175
|
}
|
|
164
176
|
}
|
|
165
|
-
|
|
166
|
-
if (e.key === 'Tab' && !multiple && showPopover) {
|
|
167
|
-
setShowPopover(false);
|
|
168
|
-
}
|
|
169
177
|
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
170
|
-
[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]);
|
|
171
179
|
return {
|
|
172
180
|
onInputKeyDown
|
|
173
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",
|