@elliemae/ds-controlled-form 2.4.1-rc.1 → 2.4.1-rc.5
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/Autocomplete.js +4 -5
- package/cjs/autocomplete/AutocompleteCTX.js +3 -14
- package/cjs/autocomplete/AutocompleteDataTestids.js +1 -7
- package/cjs/autocomplete/config/useAutocomplete.js +23 -10
- package/cjs/autocomplete/parts/container/Container.js +36 -20
- package/cjs/autocomplete/parts/container/styled.js +1 -5
- package/cjs/autocomplete/parts/{controls → container}/useKeyboardNavigation.js +8 -24
- package/cjs/autocomplete/parts/menu-list/MenuList.js +17 -50
- package/cjs/autocomplete/parts/menu-list/styled.js +9 -10
- package/cjs/autocomplete/parts/menu-list/useItemRenderer.js +38 -44
- package/cjs/autocomplete/react-desc-prop-types.js +4 -8
- package/cjs/autocomplete/utils/listHelper.js +8 -16
- package/cjs/checkbox/ControlledCheckbox.js +2 -1
- package/cjs/checkbox/react-desc-prop-types.js +2 -0
- package/cjs/combobox/ComboBox.js +1 -0
- package/cjs/combobox/config/useComboBox.js +8 -2
- package/cjs/combobox/config/useCorrectOptions.js +14 -42
- package/cjs/combobox/index.js +1 -0
- package/cjs/combobox/parts/A11yFocusedOption.js +3 -3
- package/cjs/combobox/parts/controls/Controls.js +4 -2
- package/cjs/combobox/parts/controls-input/ControlsInput.js +2 -0
- package/cjs/combobox/parts/controls-input/styled.js +1 -1
- package/cjs/combobox/parts/controls-input/useControlsInput.js +6 -6
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +30 -26
- package/cjs/combobox/parts/controls-input/useMaskedOnChange.js +7 -5
- package/cjs/combobox/parts/dropdown-indicator/DropdownIndicator.js +6 -4
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +4 -4
- package/cjs/combobox/parts/menu-list/MenuList.js +13 -7
- package/cjs/combobox/parts/menu-list/styled.js +16 -5
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +8 -8
- package/cjs/combobox/parts/menu-list/useMenuListSetFocusOption.js +6 -6
- package/cjs/combobox/react-desc-prop-types.js +2 -1
- package/cjs/combobox/utils/listHelper.js +40 -11
- package/cjs/index.js +16 -3
- package/cjs/large-text-input/DSControlledLargeTextInput.js +83 -0
- package/cjs/large-text-input/exported-related/data-test-ids.js +11 -0
- package/cjs/large-text-input/exported-related/index.js +12 -0
- package/cjs/large-text-input/exported-related/theming.js +13 -0
- package/cjs/large-text-input/index.js +15 -0
- package/cjs/large-text-input/react-desc-prop-types.js +45 -0
- package/cjs/large-text-input/styles.js +40 -0
- package/cjs/mask-hook/hooks/index.js +7 -3
- package/cjs/mask-hook/hooks/useNumberMask.js +5 -0
- package/cjs/mask-hook/hooks/usePhoneMask.js +5 -0
- package/cjs/mask-hook/hooks/useSSNMask.js +5 -0
- package/cjs/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +10 -5
- package/cjs/mask-hook/index.js +7 -3
- package/esm/autocomplete/Autocomplete.js +2 -3
- package/esm/autocomplete/AutocompleteCTX.js +3 -14
- package/esm/autocomplete/AutocompleteDataTestids.js +1 -7
- package/esm/autocomplete/config/useAutocomplete.js +27 -14
- package/esm/autocomplete/parts/container/Container.js +38 -23
- package/esm/autocomplete/parts/container/styled.js +2 -5
- package/esm/autocomplete/parts/{controls → container}/useKeyboardNavigation.js +8 -24
- package/esm/autocomplete/parts/menu-list/MenuList.js +19 -52
- package/esm/autocomplete/parts/menu-list/styled.js +9 -10
- package/esm/autocomplete/parts/menu-list/useItemRenderer.js +39 -45
- package/esm/autocomplete/react-desc-prop-types.js +5 -8
- package/esm/autocomplete/utils/listHelper.js +8 -16
- package/esm/checkbox/ControlledCheckbox.js +2 -1
- package/esm/checkbox/react-desc-prop-types.js +2 -0
- package/esm/combobox/ComboBox.js +1 -1
- package/esm/combobox/config/useComboBox.js +8 -2
- package/esm/combobox/config/useCorrectOptions.js +15 -43
- package/esm/combobox/index.js +1 -1
- package/esm/combobox/parts/A11yFocusedOption.js +3 -3
- package/esm/combobox/parts/controls/Controls.js +4 -2
- package/esm/combobox/parts/controls-input/ControlsInput.js +2 -0
- package/esm/combobox/parts/controls-input/styled.js +1 -1
- package/esm/combobox/parts/controls-input/useControlsInput.js +6 -6
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +30 -26
- package/esm/combobox/parts/controls-input/useMaskedOnChange.js +7 -5
- package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +4 -4
- package/esm/combobox/parts/menu-list/MenuList.js +13 -7
- package/esm/combobox/parts/menu-list/styled.js +16 -5
- package/esm/combobox/parts/menu-list/useItemRenderer.js +8 -8
- package/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js +6 -6
- package/esm/combobox/react-desc-prop-types.js +2 -1
- package/esm/combobox/utils/listHelper.js +38 -12
- package/esm/index.js +8 -5
- package/esm/large-text-input/DSControlledLargeTextInput.js +72 -0
- package/esm/large-text-input/exported-related/data-test-ids.js +7 -0
- package/esm/large-text-input/exported-related/index.js +2 -0
- package/esm/large-text-input/exported-related/theming.js +8 -0
- package/esm/large-text-input/index.js +3 -0
- package/esm/large-text-input/react-desc-prop-types.js +36 -0
- package/esm/large-text-input/styles.js +30 -0
- package/esm/mask-hook/hooks/index.js +4 -4
- package/esm/mask-hook/hooks/useNumberMask.js +5 -1
- package/esm/mask-hook/hooks/usePhoneMask.js +5 -1
- package/esm/mask-hook/hooks/useSSNMask.js +5 -1
- package/esm/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +9 -5
- package/esm/mask-hook/index.js +4 -4
- package/package.json +52 -88
- package/types/autocomplete/Autocomplete.d.ts +4 -61
- package/types/autocomplete/AutocompleteCTX.d.ts +4 -3
- package/types/autocomplete/AutocompleteDataTestids.d.ts +1 -7
- package/types/autocomplete/config/useAutocomplete.d.ts +3 -2
- package/types/autocomplete/parts/container/Container.d.ts +1 -2
- package/types/autocomplete/parts/container/styled.d.ts +0 -1
- package/types/autocomplete/parts/{controls → container}/useKeyboardNavigation.d.ts +0 -0
- package/types/autocomplete/parts/menu-list/MenuList.d.ts +1 -2
- package/types/autocomplete/parts/menu-list/styled.d.ts +1 -4
- package/types/autocomplete/parts/menu-list/useItemRenderer.d.ts +2 -3
- package/types/autocomplete/react-desc-prop-types.d.ts +8 -18
- package/types/autocomplete/sharedTypes.d.ts +1 -3
- package/types/autocomplete/tests/general.test.d.ts +1 -0
- package/types/autocomplete/tests/utils.d.ts +5 -0
- package/types/autocomplete/utils/listHelper.d.ts +2 -2
- package/types/checkbox/ControlledCheckbox.d.ts +1 -1
- package/types/checkbox/react-desc-prop-types.d.ts +367 -1
- package/types/combobox/ComboBox.d.ts +2 -2
- package/types/combobox/parts/dropdown-indicator/DropdownIndicator.d.ts +1 -0
- package/types/combobox/react-desc-prop-types.d.ts +381 -3
- package/types/combobox/utils/listHelper.d.ts +4 -1
- package/types/index.d.ts +1 -0
- package/types/large-text-input/DSControlledLargeTextInput.d.ts +5 -0
- package/types/large-text-input/exported-related/data-test-ids.d.ts +5 -0
- package/types/large-text-input/exported-related/index.d.ts +2 -0
- package/types/large-text-input/exported-related/theming.d.ts +6 -0
- package/types/large-text-input/index.d.ts +2 -0
- package/types/large-text-input/react-desc-prop-types.d.ts +447 -0
- package/types/large-text-input/styles.d.ts +3 -0
- package/types/large-text-input/tests/DSControlledLargeTextInput.test.d.ts +1 -0
- package/types/mask-hook/hooks/index.d.ts +1 -1
- package/types/mask-hook/hooks/useNumberMask.d.ts +2 -1
- package/types/mask-hook/hooks/usePhoneMask.d.ts +2 -1
- package/types/mask-hook/hooks/useSSNMask.d.ts +2 -1
- package/types/mask-hook/hooks/useZipCodeMask.d.ts +4 -0
- package/types/text-input/DSInputText.d.ts +1 -1
- package/types/text-input/config/useInputText.d.ts +110 -110
- package/cjs/autocomplete/config/constants.js +0 -14
- package/cjs/autocomplete/config/useGetPropsWithDefault.js +0 -11
- package/cjs/autocomplete/index.d.js +0 -2
- package/cjs/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -33
- package/cjs/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -28
- package/cjs/autocomplete/parts/a11y-messages/index.js +0 -11
- package/cjs/autocomplete/parts/a11y-messages/styled.js +0 -15
- package/cjs/autocomplete/parts/controls/Controls.js +0 -63
- package/cjs/autocomplete/parts/controls/index.js +0 -9
- package/cjs/autocomplete/parts/controls/styled.js +0 -44
- package/cjs/autocomplete/parts/controls/useControlsInput.js +0 -44
- package/cjs/autocomplete/parts/controls/useMaskedOnChange.js +0 -28
- package/cjs/autocomplete/parts/menu-list/useMenuList.js +0 -69
- package/cjs/autocomplete/propTypes.js +0 -25
- package/cjs/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -97
- package/cjs/autocomplete/utils/hooks/useOnElementResize.js +0 -37
- package/cjs/text-input/exported-related/name.js +0 -7
- package/cjs/text-input/exported-related/slots.js +0 -11
- package/esm/autocomplete/config/constants.js +0 -10
- package/esm/autocomplete/config/useGetPropsWithDefault.js +0 -7
- package/esm/autocomplete/index.d.js +0 -1
- package/esm/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -25
- package/esm/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -20
- package/esm/autocomplete/parts/a11y-messages/index.js +0 -2
- package/esm/autocomplete/parts/a11y-messages/styled.js +0 -7
- package/esm/autocomplete/parts/controls/Controls.js +0 -55
- package/esm/autocomplete/parts/controls/index.js +0 -1
- package/esm/autocomplete/parts/controls/styled.js +0 -32
- package/esm/autocomplete/parts/controls/useControlsInput.js +0 -40
- package/esm/autocomplete/parts/controls/useMaskedOnChange.js +0 -24
- package/esm/autocomplete/parts/menu-list/useMenuList.js +0 -65
- package/esm/autocomplete/propTypes.js +0 -21
- package/esm/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -93
- package/esm/autocomplete/utils/hooks/useOnElementResize.js +0 -33
- package/esm/text-input/exported-related/name.js +0 -3
- package/esm/text-input/exported-related/slots.js +0 -7
- package/types/autocomplete/config/constants.d.ts +0 -8
- package/types/autocomplete/config/useGetPropsWithDefault.d.ts +0 -2
- package/types/autocomplete/parts/a11y-messages/MultiAllyMessages.d.ts +0 -3
- package/types/autocomplete/parts/a11y-messages/SingleAllyMessages.d.ts +0 -3
- package/types/autocomplete/parts/a11y-messages/index.d.ts +0 -2
- package/types/autocomplete/parts/a11y-messages/styled.d.ts +0 -1
- package/types/autocomplete/parts/controls/Controls.d.ts +0 -3
- package/types/autocomplete/parts/controls/index.d.ts +0 -1
- package/types/autocomplete/parts/controls/styled.d.ts +0 -8
- package/types/autocomplete/parts/controls/useControlsInput.d.ts +0 -9
- package/types/autocomplete/parts/controls/useMaskedOnChange.d.ts +0 -2
- package/types/autocomplete/parts/menu-list/useMenuList.d.ts +0 -2
- package/types/autocomplete/propTypes.d.ts +0 -51
- package/types/autocomplete/utils/hooks/useKeyboardNavigation.d.ts +0 -4
- package/types/autocomplete/utils/hooks/useOnElementResize.d.ts +0 -3
- package/types/mask-hook/hooks/useZipCode.d.ts +0 -3
- package/types/text-input/exported-related/name.d.ts +0 -1
- package/types/text-input/exported-related/slots.d.ts +0 -5
package/esm/combobox/ComboBox.js
CHANGED
|
@@ -38,7 +38,7 @@ const useComboBox = props => {
|
|
|
38
38
|
const {
|
|
39
39
|
selectedValues
|
|
40
40
|
} = propsWithDefaults; // ---------------------------------------------------------------------------
|
|
41
|
-
//
|
|
41
|
+
// Options with creatable option + filtered by selected
|
|
42
42
|
// ---------------------------------------------------------------------------
|
|
43
43
|
|
|
44
44
|
const correctOptions = useCorrectOptions(propsWithDefaults, inputValue, showSelectedOptions); // ===========================================================================
|
|
@@ -78,9 +78,15 @@ const useComboBox = props => {
|
|
|
78
78
|
|
|
79
79
|
if (!hasFocus) setFocusOptionIdx(''); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
80
|
}, [showPopover, hasFocus, correctOptions, selectedValues, inputValue]);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (!showPopover) {
|
|
83
|
+
setFocusOptionIdx('');
|
|
84
|
+
setShowSelectedOptions(false);
|
|
85
|
+
}
|
|
86
|
+
}, [showPopover]);
|
|
81
87
|
const ctx = useMemo(() => ({
|
|
82
88
|
props: _objectSpread(_objectSpread({}, propsWithDefaults), {}, {
|
|
83
|
-
|
|
89
|
+
filteredOptions: correctOptions
|
|
84
90
|
}),
|
|
85
91
|
virtualListHelpers,
|
|
86
92
|
showPopover,
|
|
@@ -1,66 +1,38 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.find.js';
|
|
6
1
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
7
|
-
import {
|
|
2
|
+
import { useMemo } from 'react';
|
|
8
3
|
import { uid } from 'uid';
|
|
9
4
|
import { MENU_OPTION_TYPES } from '../constants.js';
|
|
5
|
+
import { selectedValuesWithSections } from '../utils/listHelper.js';
|
|
10
6
|
|
|
11
7
|
const useCorrectOptions = (propsWithDefaults, inputValue, showSelectedOptions) => {
|
|
12
8
|
const {
|
|
13
|
-
|
|
9
|
+
filteredOptions,
|
|
10
|
+
allOptions,
|
|
14
11
|
selectedValues,
|
|
15
12
|
onCreate
|
|
16
13
|
} = propsWithDefaults;
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
return useMemo(() => {
|
|
15
|
+
// if filteredOptions is not passed we copy allOptions into the prop as default
|
|
16
|
+
// this is useful when the user wants a combo with out filtering and only pass allOptions as its required
|
|
17
|
+
if (!filteredOptions) return [...allOptions]; // when show selected toggle is on we return the selected value only as filteredOptions prop
|
|
19
18
|
|
|
20
|
-
const multiSelectedValue = selectedValues;
|
|
21
|
-
const items = [];
|
|
22
|
-
options.forEach(option => {
|
|
23
|
-
const isSelectedValue = multiSelectedValue.find(item => item.dsId === option.dsId);
|
|
24
|
-
|
|
25
|
-
if (isSelectedValue) {
|
|
26
|
-
items.push(option);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (option.type === MENU_OPTION_TYPES.SECTION) {
|
|
30
|
-
var _items;
|
|
31
|
-
|
|
32
|
-
if (((_items = items[items.length - 1]) === null || _items === void 0 ? void 0 : _items.type) === MENU_OPTION_TYPES.SECTION) {
|
|
33
|
-
items[items.length - 1] = option;
|
|
34
|
-
} else {
|
|
35
|
-
items.push(option);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (((_items2 = items[items.length - 1]) === null || _items2 === void 0 ? void 0 : _items2.type) === MENU_OPTION_TYPES.SECTION) {
|
|
41
|
-
items.pop();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return items;
|
|
45
|
-
}, [options, selectedValues]);
|
|
46
|
-
const correctOptions = useMemo(() => {
|
|
47
19
|
if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {
|
|
48
|
-
return selectedValuesWithSections();
|
|
49
|
-
}
|
|
20
|
+
return selectedValuesWithSections(filteredOptions, selectedValues);
|
|
21
|
+
} // whether oncreate is passed we add as first option the creatable action based on input value string
|
|
22
|
+
|
|
50
23
|
|
|
51
|
-
if (onCreate && inputValue &&
|
|
24
|
+
if (onCreate && inputValue && filteredOptions.findIndex(option => option.type === MENU_OPTION_TYPES.OPTION && option.label === inputValue) === -1) {
|
|
52
25
|
const creatableUuid = uid();
|
|
53
26
|
const creatableItem = {
|
|
54
27
|
dsId: "creatable-".concat(creatableUuid),
|
|
55
28
|
label: inputValue,
|
|
56
29
|
type: 'creatable'
|
|
57
30
|
};
|
|
58
|
-
return [creatableItem, ...
|
|
31
|
+
return [creatableItem, ...filteredOptions];
|
|
59
32
|
}
|
|
60
33
|
|
|
61
|
-
return
|
|
62
|
-
}, [
|
|
63
|
-
return correctOptions;
|
|
34
|
+
return filteredOptions;
|
|
35
|
+
}, [filteredOptions, allOptions, showSelectedOptions, selectedValues, onCreate, inputValue]);
|
|
64
36
|
};
|
|
65
37
|
|
|
66
38
|
export { useCorrectOptions };
|
package/esm/combobox/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DSComboBox, DSComboBoxWithSchema } from './ComboBox.js';
|
|
1
|
+
export { DSComboBox, DSComboBox as DSComboBoxV3, DSComboBoxWithSchema } from './ComboBox.js';
|
|
@@ -11,13 +11,13 @@ import { isSeparator } from '../sharedTypes.js';
|
|
|
11
11
|
const A11yFocusedOption = () => {
|
|
12
12
|
const {
|
|
13
13
|
props: {
|
|
14
|
-
|
|
14
|
+
filteredOptions
|
|
15
15
|
},
|
|
16
16
|
focusOptionIdx,
|
|
17
17
|
showPopover
|
|
18
18
|
} = useContext(ComboBoxContext);
|
|
19
|
-
const selectabledOptions = getSelectableOptions(
|
|
20
|
-
const focusOption =
|
|
19
|
+
const selectabledOptions = getSelectableOptions(filteredOptions);
|
|
20
|
+
const focusOption = filteredOptions.find(option => !isSeparator(option) && option.dsId === focusOptionIdx);
|
|
21
21
|
const focusSelectableOptionIdx = selectabledOptions.findIndex(option => option.dsId === focusOptionIdx);
|
|
22
22
|
return useMemo(() => {
|
|
23
23
|
if (!isSeparator(focusOption) && showPopover && focusOption) return /*#__PURE__*/_jsx(StyledA11ySelectedValues, {
|
|
@@ -26,6 +26,8 @@ const Controls = () => {
|
|
|
26
26
|
selectedOptionsRef,
|
|
27
27
|
setShowPopover,
|
|
28
28
|
hasFocus,
|
|
29
|
+
focusOptionIdx,
|
|
30
|
+
scrollOptionIntoView,
|
|
29
31
|
showPopover,
|
|
30
32
|
controlsWrapperRef
|
|
31
33
|
} = useContext(ComboBoxContext);
|
|
@@ -43,8 +45,8 @@ const Controls = () => {
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
(_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.focus();
|
|
46
|
-
setShowPopover(true);
|
|
47
|
-
}, [disabled, hasFocus,
|
|
48
|
+
setShowPopover(true); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
|
+
}, [disabled, hasFocus, showPopover, inline, innerRef, setShowPopover, focusOptionIdx]); // this callback prevent to toggle the menu when clicking or removing pills
|
|
48
50
|
|
|
49
51
|
const handleOnPillsClick = useCallback(e => {
|
|
50
52
|
if (showPopover || disabled) {
|
|
@@ -12,6 +12,7 @@ const ControlsInput = () => {
|
|
|
12
12
|
const {
|
|
13
13
|
props: {
|
|
14
14
|
autoFocus,
|
|
15
|
+
placeholder,
|
|
15
16
|
disabled,
|
|
16
17
|
innerRef,
|
|
17
18
|
onFilter
|
|
@@ -40,6 +41,7 @@ const ControlsInput = () => {
|
|
|
40
41
|
})), /*#__PURE__*/jsx(StyledInput, {
|
|
41
42
|
"data-testid": ComboboxDataTestid.INPUT,
|
|
42
43
|
autoFocus: autoFocus,
|
|
44
|
+
placeholder: placeholder,
|
|
43
45
|
"aria-controls": "combo-listbox",
|
|
44
46
|
"aria-activedescendant": focusOptionIdx,
|
|
45
47
|
"aria-expanded": showPopover,
|
|
@@ -2,7 +2,7 @@ import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLit
|
|
|
2
2
|
import { styled } from '@elliemae/ds-system';
|
|
3
3
|
|
|
4
4
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
5
|
-
const StyledInput = styled.input(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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"])), props => props.theme.colors.neutral[700], _ref => {
|
|
5
|
+
const StyledInput = styled.input(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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 => {
|
|
6
6
|
let {
|
|
7
7
|
withoutCaret
|
|
8
8
|
} = _ref;
|
|
@@ -9,6 +9,7 @@ const useControlsInput = () => {
|
|
|
9
9
|
const {
|
|
10
10
|
props: {
|
|
11
11
|
selectedValues,
|
|
12
|
+
allOptions,
|
|
12
13
|
placeholder,
|
|
13
14
|
onFilter
|
|
14
15
|
},
|
|
@@ -23,19 +24,18 @@ const useControlsInput = () => {
|
|
|
23
24
|
const showPlaceholder = !inputValue && isSelectedValueEmpty(selectedValues) ? placeholder : null;
|
|
24
25
|
const spanReferenceText = inputValue.replace(/\s/g, '\u00a0');
|
|
25
26
|
useEffect(() => {
|
|
26
|
-
var _spanReference$curren
|
|
27
|
+
var _spanReference$curren;
|
|
27
28
|
|
|
28
|
-
setWidth((_spanReference$curren = spanReference.current) !== null && _spanReference$curren !== void 0 && _spanReference$curren.offsetWidth ?
|
|
29
|
+
setWidth((_spanReference$curren = spanReference.current) !== null && _spanReference$curren !== void 0 && _spanReference$curren.offsetWidth ? spanReference.current.offsetWidth + 2 : 1);
|
|
29
30
|
}, [inputValue]); // if we se an input mask we configure inside here the proper mask
|
|
30
31
|
// or a stardard combobox onchange event
|
|
31
32
|
|
|
32
33
|
const handleOnChange = useMaskedOnChange();
|
|
33
34
|
const handleOnBlur = useCallback(() => {
|
|
34
35
|
setInputValue('');
|
|
35
|
-
if (onFilter) onFilter(
|
|
36
|
-
setHasFocus(false);
|
|
37
|
-
|
|
38
|
-
}, [setInputValue, setShowSelectedOptions, onFilter, setHasFocus]);
|
|
36
|
+
if (onFilter) onFilter(allOptions, inputValue);
|
|
37
|
+
setHasFocus(false); // setShowSelectedOptions(false);
|
|
38
|
+
}, [setInputValue, onFilter, allOptions, inputValue, setHasFocus, setShowSelectedOptions]);
|
|
39
39
|
const handleOnFocus = useCallback(() => {
|
|
40
40
|
setHasFocus(true);
|
|
41
41
|
}, [setHasFocus]);
|
|
@@ -13,6 +13,7 @@ const isOptionFocuseable = opt => !['section', 'separator'].includes(opt.type) &
|
|
|
13
13
|
const useKeyboardNavigation = () => {
|
|
14
14
|
const {
|
|
15
15
|
props: {
|
|
16
|
+
allOptions,
|
|
16
17
|
onCancel,
|
|
17
18
|
onKeyDown,
|
|
18
19
|
onChange,
|
|
@@ -20,7 +21,7 @@ const useKeyboardNavigation = () => {
|
|
|
20
21
|
onFilter,
|
|
21
22
|
onSelectAll,
|
|
22
23
|
inline,
|
|
23
|
-
|
|
24
|
+
filteredOptions,
|
|
24
25
|
selectedValues,
|
|
25
26
|
withoutPortal
|
|
26
27
|
},
|
|
@@ -35,9 +36,9 @@ const useKeyboardNavigation = () => {
|
|
|
35
36
|
setFocusOptionIdx
|
|
36
37
|
} = useContext(ComboBoxContext);
|
|
37
38
|
const multiple = Array.isArray(selectedValues);
|
|
38
|
-
const selectableOptions = getOptions(
|
|
39
|
-
const currentItemIndex =
|
|
40
|
-
const currentItem =
|
|
39
|
+
const selectableOptions = getOptions(filteredOptions);
|
|
40
|
+
const currentItemIndex = filteredOptions.findIndex(opt => opt.dsId === focusOptionIdx);
|
|
41
|
+
const currentItem = filteredOptions.find(item => item.dsId === focusOptionIdx);
|
|
41
42
|
const onInputKeyDown = useCallback(e => {
|
|
42
43
|
// =============================================================================
|
|
43
44
|
// CUSTOM KEYS
|
|
@@ -55,7 +56,7 @@ const useKeyboardNavigation = () => {
|
|
|
55
56
|
if (onCancel) onCancel();
|
|
56
57
|
|
|
57
58
|
if (inputValue) {
|
|
58
|
-
if (onFilter) onFilter(
|
|
59
|
+
if (onFilter) onFilter(allOptions, inputValue);
|
|
59
60
|
setInputValue('');
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -66,8 +67,10 @@ const useKeyboardNavigation = () => {
|
|
|
66
67
|
|
|
67
68
|
|
|
68
69
|
if (e.key === 'Enter' && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === INTERNAL_MENU_OPTION_TYPES.CREATABLE && onCreate) {
|
|
69
|
-
onCreate(inputValue);
|
|
70
|
-
|
|
70
|
+
onCreate(inputValue); //blank active item to force search last one
|
|
71
|
+
|
|
72
|
+
setFocusOptionIdx('');
|
|
73
|
+
if (onFilter) onFilter(allOptions, '');
|
|
71
74
|
setInputValue('');
|
|
72
75
|
return;
|
|
73
76
|
} // =============================================================================
|
|
@@ -80,10 +83,10 @@ const useKeyboardNavigation = () => {
|
|
|
80
83
|
e.stopPropagation();
|
|
81
84
|
|
|
82
85
|
if (focusOptionIdx !== '' && (showPopover || inline) && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === MENU_OPTION_TYPES.OPTION && !currentItem.disabled) {
|
|
83
|
-
if (onFilter) onFilter('');
|
|
86
|
+
if (onFilter) onFilter(allOptions, '');
|
|
84
87
|
setInputValue('');
|
|
85
88
|
|
|
86
|
-
if (!multiple
|
|
89
|
+
if (!multiple) {
|
|
87
90
|
setShowPopover(false);
|
|
88
91
|
}
|
|
89
92
|
|
|
@@ -96,7 +99,7 @@ const useKeyboardNavigation = () => {
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
if (e.key === 'a' && e.ctrlKey && multiple && onSelectAll) {
|
|
99
|
-
onSelectAll(
|
|
102
|
+
onSelectAll(filteredOptions.filter(option => option.type === 'option' && !option.disabled), e);
|
|
100
103
|
} // =============================================================================
|
|
101
104
|
// ARROWS UP AND DOWN: LOGIC TO CALCULATE NEXT OR PREV ITEM TO PSEUDOFOCUS FROM INPUT
|
|
102
105
|
// =============================================================================
|
|
@@ -107,9 +110,9 @@ const useKeyboardNavigation = () => {
|
|
|
107
110
|
e.stopPropagation();
|
|
108
111
|
|
|
109
112
|
if ((showPopover || inline) && selectableOptions.length) {
|
|
110
|
-
const nextItemIndex = findInCircularList(
|
|
111
|
-
setFocusOptionIdx(
|
|
112
|
-
scrollOptionIntoView(
|
|
113
|
+
const nextItemIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable);
|
|
114
|
+
setFocusOptionIdx(filteredOptions[nextItemIndex].dsId);
|
|
115
|
+
scrollOptionIntoView(filteredOptions[nextItemIndex].dsId);
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
|
|
@@ -117,17 +120,17 @@ const useKeyboardNavigation = () => {
|
|
|
117
120
|
e.preventDefault();
|
|
118
121
|
e.stopPropagation();
|
|
119
122
|
if (!selectableOptions.length) return;
|
|
120
|
-
const prevItemIndex = findInCircularList(
|
|
123
|
+
const prevItemIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable, -1);
|
|
121
124
|
|
|
122
125
|
if (showPopover || inline) {
|
|
123
|
-
setFocusOptionIdx(
|
|
124
|
-
scrollOptionIntoView(
|
|
126
|
+
setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);
|
|
127
|
+
scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);
|
|
125
128
|
} else {
|
|
126
129
|
setShowPopover(true);
|
|
127
130
|
setTimeout(() => {
|
|
128
|
-
const prevItem = findInCircularList(
|
|
129
|
-
setFocusOptionIdx(
|
|
130
|
-
scrollOptionIntoView(
|
|
131
|
+
const prevItem = findInCircularList(filteredOptions, 0, isOptionFocuseable, -1);
|
|
132
|
+
setFocusOptionIdx(filteredOptions[prevItem].dsId);
|
|
133
|
+
scrollOptionIntoView(filteredOptions[prevItem].dsId);
|
|
131
134
|
});
|
|
132
135
|
}
|
|
133
136
|
} // =============================================================================
|
|
@@ -135,14 +138,14 @@ const useKeyboardNavigation = () => {
|
|
|
135
138
|
// =============================================================================
|
|
136
139
|
|
|
137
140
|
|
|
138
|
-
if (e.key === 'Backspace' &&
|
|
141
|
+
if (e.key === 'Backspace' && e.currentTarget.value.length <= 0 && !inline) {
|
|
139
142
|
const lastValue = getLastValueSelected(selectedValues);
|
|
140
143
|
|
|
141
|
-
if (!
|
|
144
|
+
if (!e.currentTarget.value && lastValue) {
|
|
142
145
|
onChange(getSuggestedValueOnChange(lastValue, selectedValues), lastValue, e);
|
|
143
146
|
}
|
|
144
147
|
|
|
145
|
-
if (onFilter) onFilter(
|
|
148
|
+
if (onFilter) onFilter(allOptions, inputValue);
|
|
146
149
|
}
|
|
147
150
|
|
|
148
151
|
if (e.key === 'Tab' && !inline && !withoutPortal) {
|
|
@@ -154,12 +157,13 @@ const useKeyboardNavigation = () => {
|
|
|
154
157
|
e.preventDefault();
|
|
155
158
|
element.focus();
|
|
156
159
|
}
|
|
157
|
-
}
|
|
158
|
-
// if (e.key === 'Tab' && multiple) {
|
|
159
|
-
// }
|
|
160
|
+
}
|
|
160
161
|
|
|
162
|
+
if (e.key === 'Tab' && !multiple && showPopover) {
|
|
163
|
+
setShowPopover(false);
|
|
164
|
+
}
|
|
161
165
|
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
162
|
-
[onKeyDown, currentItem, onCreate, multiple, inputValue, inline, withoutPortal, setShowPopover, onCancel, onFilter, setInputValue, focusOptionIdx, showPopover, selectableOptions.length,
|
|
166
|
+
[onKeyDown, currentItem, onCreate, multiple, inputValue, inline, withoutPortal, setShowPopover, onCancel, onFilter, setInputValue, focusOptionIdx, showPopover, selectableOptions.length, filteredOptions, currentItemIndex, setFocusOptionIdx, selectedValues, onChange, selectAllCheckboxRef, toggleSelectionButtonRef]);
|
|
163
167
|
return {
|
|
164
168
|
onInputKeyDown
|
|
165
169
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { useContext, useCallback } from 'react';
|
|
2
2
|
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
3
|
+
import { filterOptions } from '../../utils/listHelper.js';
|
|
3
4
|
|
|
4
5
|
const useMaskedOnChange = () => {
|
|
5
6
|
const {
|
|
6
7
|
props: {
|
|
7
8
|
useMask,
|
|
8
|
-
onFilter
|
|
9
|
+
onFilter,
|
|
10
|
+
allOptions
|
|
9
11
|
},
|
|
10
12
|
setShowPopover,
|
|
11
13
|
setInputValue,
|
|
@@ -17,16 +19,16 @@ const useMaskedOnChange = () => {
|
|
|
17
19
|
setShowPopover(true);
|
|
18
20
|
|
|
19
21
|
if (onFilter) {
|
|
20
|
-
onFilter(e.currentTarget.value);
|
|
22
|
+
onFilter(filterOptions(e.currentTarget.value, allOptions), e.currentTarget.value);
|
|
21
23
|
setInputValue(e.currentTarget.value);
|
|
22
24
|
}
|
|
23
|
-
}, [onFilter, setInputValue, setShowPopover, setShowSelectedOptions]); // onchange used when mask is provided
|
|
25
|
+
}, [allOptions, onFilter, setInputValue, setShowPopover, setShowSelectedOptions]); // onchange used when mask is provided
|
|
24
26
|
|
|
25
27
|
const handleOnChangeMask = useCallback((_, mask) => {
|
|
26
28
|
setShowSelectedOptions(false);
|
|
27
29
|
setShowPopover(true);
|
|
28
|
-
if (mask && onFilter) onFilter(mask);
|
|
29
|
-
}, [onFilter, setShowPopover, setShowSelectedOptions]);
|
|
30
|
+
if (mask && onFilter) onFilter(filterOptions(mask, allOptions), mask);else if (!mask && onFilter) onFilter(allOptions, '');
|
|
31
|
+
}, [allOptions, onFilter, setShowPopover, setShowSelectedOptions]);
|
|
30
32
|
const onChangeMask = useMask({
|
|
31
33
|
valueSetter: setInputValue,
|
|
32
34
|
onChange: handleOnChangeMask
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
|
-
import ChevronSmallDown from '@elliemae/ds-icons
|
|
3
|
+
import { ChevronSmallDown } from '@elliemae/ds-icons';
|
|
4
4
|
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
5
5
|
import { StyledDropDownButton } from './styled.js';
|
|
6
6
|
import { ComboboxDataTestid } from '../../ComboboxDataTestids.js';
|
|
@@ -27,4 +27,4 @@ const DropdownIndicator = () => {
|
|
|
27
27
|
}, void 0, _ChevronSmallDown || (_ChevronSmallDown = /*#__PURE__*/_jsx(ChevronSmallDown, {})));
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export { DropdownIndicator as default };
|
|
30
|
+
export { DropdownIndicator, DropdownIndicator as default };
|
|
@@ -10,7 +10,7 @@ const useHeaderListHandlers = () => {
|
|
|
10
10
|
const {
|
|
11
11
|
props: {
|
|
12
12
|
selectedValues,
|
|
13
|
-
|
|
13
|
+
filteredOptions,
|
|
14
14
|
onSelectAll,
|
|
15
15
|
innerRef
|
|
16
16
|
},
|
|
@@ -19,7 +19,7 @@ const useHeaderListHandlers = () => {
|
|
|
19
19
|
setShowPopover
|
|
20
20
|
} = useContext(ComboBoxContext);
|
|
21
21
|
const multiSelectedValues = selectedValues;
|
|
22
|
-
const selectableOptions = getSelectableOptions(
|
|
22
|
+
const selectableOptions = getSelectableOptions(filteredOptions);
|
|
23
23
|
const getCheckboxStatus = useMemo(() => {
|
|
24
24
|
if (multiSelectedValues.length === selectableOptions.length) {
|
|
25
25
|
return true;
|
|
@@ -40,13 +40,13 @@ const useHeaderListHandlers = () => {
|
|
|
40
40
|
}, []);
|
|
41
41
|
const handleSelectAllCheckboxChange = useCallback(e => {
|
|
42
42
|
if ((!checkboxStatus || checkboxStatus === 'mixed') && onSelectAll) {
|
|
43
|
-
onSelectAll(
|
|
43
|
+
onSelectAll(filteredOptions.filter(option => option.type === 'option' && !option.disabled), e);
|
|
44
44
|
setCheckboxStatus(true);
|
|
45
45
|
} else if (onSelectAll) {
|
|
46
46
|
onSelectAll([], e);
|
|
47
47
|
setCheckboxStatus(false);
|
|
48
48
|
}
|
|
49
|
-
}, [checkboxStatus, onSelectAll,
|
|
49
|
+
}, [checkboxStatus, onSelectAll, filteredOptions]);
|
|
50
50
|
const handleToggleSelectedValuesFilter = useCallback(e => {
|
|
51
51
|
e.preventDefault();
|
|
52
52
|
setShowSelectedOptions(!showSelectedOptions);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
2
|
import { useContext, useCallback, useMemo } from 'react';
|
|
3
|
+
import { useOnElementResize } from '@elliemae/ds-utilities';
|
|
3
4
|
import { StyledListWrapper, StyledVirtualListWrapper, StyledList, StyledNoResultsWrapper } from './styled.js';
|
|
4
5
|
import { ComboboxDataTestid } from '../../ComboboxDataTestids.js';
|
|
5
6
|
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
@@ -15,18 +16,22 @@ const MenuList = () => {
|
|
|
15
16
|
menuMaxHeight,
|
|
16
17
|
onCreate,
|
|
17
18
|
inline,
|
|
18
|
-
|
|
19
|
+
filteredOptions,
|
|
19
20
|
selectedValues
|
|
20
21
|
},
|
|
21
|
-
|
|
22
|
+
controlsWrapperRef,
|
|
22
23
|
listRef,
|
|
23
24
|
inputValue,
|
|
24
25
|
wrapperListRef,
|
|
25
26
|
virtualListHelpers
|
|
26
27
|
} = useContext(ComboBoxContext);
|
|
27
|
-
const multiple = Array.isArray(selectedValues);
|
|
28
|
-
|
|
28
|
+
const multiple = Array.isArray(selectedValues); // removing the header list if we are filtering or is inline cb or we have no options to show
|
|
29
|
+
|
|
30
|
+
const withHeader = !inline && multiple && filteredOptions.length > 0 && !inputValue;
|
|
29
31
|
const ItemRenderer = useItemRenderer();
|
|
32
|
+
const {
|
|
33
|
+
width
|
|
34
|
+
} = useOnElementResize(controlsWrapperRef);
|
|
30
35
|
const preventLoseInputFocus = useCallback(e => {
|
|
31
36
|
e.preventDefault();
|
|
32
37
|
}, []);
|
|
@@ -34,8 +39,9 @@ const MenuList = () => {
|
|
|
34
39
|
ref: wrapperListRef,
|
|
35
40
|
inline: inline,
|
|
36
41
|
onMouseDown: preventLoseInputFocus,
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
width: width,
|
|
43
|
+
minWidth: menuMinWidth,
|
|
44
|
+
children: [withHeader && (_HeaderList || (_HeaderList = /*#__PURE__*/_jsx(HeaderList, {}))), filteredOptions.length > 0 || onCreate ? /*#__PURE__*/jsx(StyledVirtualListWrapper, {
|
|
39
45
|
inline: inline,
|
|
40
46
|
maxHeight: menuMaxHeight,
|
|
41
47
|
ref: listRef,
|
|
@@ -52,7 +58,7 @@ const MenuList = () => {
|
|
|
52
58
|
}) : _StyledNoResultsWrapp || (_StyledNoResultsWrapp = /*#__PURE__*/_jsx(StyledNoResultsWrapper, {
|
|
53
59
|
"aria-live": "polite"
|
|
54
60
|
}, void 0, "No matches found"))]
|
|
55
|
-
}), [wrapperListRef, inline,
|
|
61
|
+
}), [wrapperListRef, inline, preventLoseInputFocus, width, menuMinWidth, withHeader, filteredOptions.length, onCreate, menuMaxHeight, listRef, virtualListHelpers === null || virtualListHelpers === void 0 ? void 0 : virtualListHelpers.totalSize, ItemRenderer]);
|
|
56
62
|
};
|
|
57
63
|
|
|
58
64
|
export { MenuList };
|
|
@@ -2,17 +2,28 @@ import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLit
|
|
|
2
2
|
import { styled } from '@elliemae/ds-system';
|
|
3
3
|
|
|
4
4
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
5
|
-
const StyledListWrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-width: ", ";\n background-color: #ffffff;\n"])),
|
|
5
|
+
const StyledListWrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-width: ", ";\n width: ", ";\n background-color: #ffffff;\n"])), _ref => {
|
|
6
|
+
let {
|
|
7
|
+
inline,
|
|
8
|
+
minWidth
|
|
9
|
+
} = _ref;
|
|
10
|
+
return inline ? '100%' : "".concat(minWidth, "px");
|
|
11
|
+
}, _ref2 => {
|
|
12
|
+
let {
|
|
13
|
+
width
|
|
14
|
+
} = _ref2;
|
|
15
|
+
return "".concat(width, "px");
|
|
16
|
+
});
|
|
6
17
|
const StyledList = styled.ul(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n padding: 0;\n"])));
|
|
7
|
-
const StyledVirtualListWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow-y: auto;\n margin-top: ", ";\n\n max-height: ", ";\n"])),
|
|
18
|
+
const StyledVirtualListWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow-y: auto;\n margin-top: ", ";\n\n max-height: ", ";\n"])), _ref3 => {
|
|
8
19
|
let {
|
|
9
20
|
withHeader
|
|
10
|
-
} =
|
|
21
|
+
} = _ref3;
|
|
11
22
|
return withHeader ? '28px' : '';
|
|
12
|
-
},
|
|
23
|
+
}, _ref4 => {
|
|
13
24
|
let {
|
|
14
25
|
maxHeight
|
|
15
|
-
} =
|
|
26
|
+
} = _ref4;
|
|
16
27
|
return !maxHeight ? '400px' : "".concat(maxHeight, "px");
|
|
17
28
|
});
|
|
18
29
|
const StyledCreatableLabel = styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-weight: bold;\n font-style: italic;\n"])));
|
|
@@ -25,12 +25,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
25
25
|
const useItemRenderer = () => {
|
|
26
26
|
const {
|
|
27
27
|
props: {
|
|
28
|
-
|
|
28
|
+
filteredOptions,
|
|
29
29
|
onCreate,
|
|
30
30
|
onChange,
|
|
31
31
|
selectedValues,
|
|
32
32
|
onFilter,
|
|
33
|
-
|
|
33
|
+
allOptions
|
|
34
34
|
},
|
|
35
35
|
setShowPopover,
|
|
36
36
|
inputValue,
|
|
@@ -45,11 +45,11 @@ const useItemRenderer = () => {
|
|
|
45
45
|
if (inputValue) {
|
|
46
46
|
onCreate(inputValue);
|
|
47
47
|
setInputValue('');
|
|
48
|
-
onFilter(
|
|
48
|
+
onFilter(allOptions, inputValue);
|
|
49
49
|
}
|
|
50
50
|
} else if (option.type === MENU_OPTION_TYPES.OPTION) {
|
|
51
51
|
if (!option.disabled) {
|
|
52
|
-
if (onFilter) onFilter(
|
|
52
|
+
if (onFilter) onFilter(allOptions, inputValue);
|
|
53
53
|
setInputValue('');
|
|
54
54
|
|
|
55
55
|
if (!multiple) {
|
|
@@ -63,7 +63,7 @@ const useItemRenderer = () => {
|
|
|
63
63
|
|
|
64
64
|
e.stopPropagation();
|
|
65
65
|
e.preventDefault();
|
|
66
|
-
}, [onFilter, selectedValues, onChange, setShowPopover, multiple
|
|
66
|
+
}, [onFilter, selectedValues, onChange, setShowPopover, multiple]); // prevent blur from controls input
|
|
67
67
|
|
|
68
68
|
const handleOnMouseDown = useCallback(e => {
|
|
69
69
|
e.preventDefault();
|
|
@@ -74,7 +74,7 @@ const useItemRenderer = () => {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
return virtualListHelpers.virtualItems.map(vItem => {
|
|
77
|
-
const option =
|
|
77
|
+
const option = filteredOptions[vItem.index];
|
|
78
78
|
const generalProps = {
|
|
79
79
|
wrapperStyles: {
|
|
80
80
|
position: 'absolute',
|
|
@@ -124,7 +124,7 @@ const useItemRenderer = () => {
|
|
|
124
124
|
height: "16px",
|
|
125
125
|
gutter: "xxs",
|
|
126
126
|
alignItems: "center"
|
|
127
|
-
}, void 0, _StyledCreatableLabel || (_StyledCreatableLabel = /*#__PURE__*/_jsx(StyledCreatableLabel, {}, void 0, "Add:")), /*#__PURE__*/_jsx("span", {}, void 0, label));
|
|
127
|
+
}, void 0, _StyledCreatableLabel || (_StyledCreatableLabel = /*#__PURE__*/_jsx(StyledCreatableLabel, {}, void 0, "Add:")), /*#__PURE__*/_jsx("span", {}, void 0, "\"".concat(label, "\"")));
|
|
128
128
|
},
|
|
129
129
|
label: option.label,
|
|
130
130
|
onClick: e => handleClick(option, e)
|
|
@@ -133,7 +133,7 @@ const useItemRenderer = () => {
|
|
|
133
133
|
|
|
134
134
|
return /*#__PURE__*/jsx(Fragment, {});
|
|
135
135
|
});
|
|
136
|
-
}, [
|
|
136
|
+
}, [filteredOptions, focusOptionIdx, selectedValues, virtualListHelpers]);
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
export { useItemRenderer };
|
|
@@ -6,7 +6,7 @@ const useMenuListSetFocusOption = () => {
|
|
|
6
6
|
const {
|
|
7
7
|
props: {
|
|
8
8
|
selectedValues,
|
|
9
|
-
|
|
9
|
+
filteredOptions
|
|
10
10
|
},
|
|
11
11
|
setFocusOptionIdx,
|
|
12
12
|
hasFocus,
|
|
@@ -15,16 +15,16 @@ const useMenuListSetFocusOption = () => {
|
|
|
15
15
|
scrollOptionIntoView
|
|
16
16
|
} = useContext(ComboBoxContext);
|
|
17
17
|
const getFirstOption = useCallback(() => {
|
|
18
|
-
for (let i = 0; i <
|
|
19
|
-
setFocusOptionIdx(
|
|
18
|
+
for (let i = 0; i < filteredOptions.length; i += 1) if (!['section', 'separator'].includes(filteredOptions[i].type) && !filteredOptions[i].disabled) {
|
|
19
|
+
setFocusOptionIdx(filteredOptions[i].dsId);
|
|
20
20
|
break;
|
|
21
21
|
}
|
|
22
|
-
}, [
|
|
22
|
+
}, [filteredOptions, setFocusOptionIdx]);
|
|
23
23
|
useEffect(() => {
|
|
24
24
|
scrollOptionIntoView(focusOptionIdx); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
25
|
}, [focusOptionIdx]);
|
|
26
26
|
useEffect(() => {
|
|
27
|
-
if (
|
|
27
|
+
if (filteredOptions.length === 0) {
|
|
28
28
|
setFocusOptionIdx('');
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -41,7 +41,7 @@ const useMenuListSetFocusOption = () => {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (hasFocus) getFirstOption();
|
|
44
|
-
}, [getFirstOption, inputValue, selectedValues, hasFocus, setFocusOptionIdx,
|
|
44
|
+
}, [getFirstOption, inputValue, selectedValues, hasFocus, setFocusOptionIdx, filteredOptions.length]);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
export { useMenuListSetFocusOption };
|