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