@elliemae/ds-form 2.1.0-rc.7 → 2.2.0-alpha.1
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/ComboBox/index.js +3 -0
- package/cjs/ComboBox/v3/ComboBox.js +33 -0
- package/cjs/ComboBox/v3/ComboBoxCTX.js +55 -0
- package/cjs/ComboBox/v3/ComboboxDataTestids.js +17 -0
- package/cjs/ComboBox/v3/config/constants.js +14 -0
- package/cjs/ComboBox/v3/config/useComboBox.js +122 -0
- package/cjs/ComboBox/v3/config/useGetPropsWithDefault.js +11 -0
- package/cjs/ComboBox/v3/index.d.js +2 -0
- package/cjs/ComboBox/v3/index.js +10 -0
- package/cjs/ComboBox/v3/parts/a11y-messages/MultiAllyMessages.js +33 -0
- package/cjs/ComboBox/v3/parts/a11y-messages/SingleAllyMessages.js +28 -0
- package/cjs/ComboBox/v3/parts/a11y-messages/index.js +11 -0
- package/cjs/ComboBox/v3/parts/a11y-messages/styled.js +15 -0
- package/cjs/ComboBox/v3/parts/container/Container.js +67 -0
- package/cjs/ComboBox/v3/parts/container/index.js +9 -0
- package/cjs/ComboBox/v3/parts/container/styled.js +23 -0
- package/cjs/ComboBox/v3/parts/controls/Controls.js +71 -0
- package/cjs/ComboBox/v3/parts/controls/index.js +9 -0
- package/cjs/ComboBox/v3/parts/controls/styled.js +65 -0
- package/cjs/ComboBox/v3/parts/controls-input/ControlsInput.js +67 -0
- package/cjs/ComboBox/v3/parts/controls-input/styled.js +27 -0
- package/cjs/ComboBox/v3/parts/controls-input/useControlsInput.js +77 -0
- package/cjs/ComboBox/v3/parts/dropdown-indicator/DropdownIndicator.js +33 -0
- package/cjs/ComboBox/v3/parts/dropdown-indicator/index.js +2 -0
- package/cjs/ComboBox/v3/parts/dropdown-indicator/styled.js +17 -0
- package/cjs/ComboBox/v3/parts/empty-state/index.js +27 -0
- package/cjs/ComboBox/v3/parts/empty-state/styled.js +19 -0
- package/cjs/ComboBox/v3/parts/header-list/HeaderList.js +113 -0
- package/cjs/ComboBox/v3/parts/header-list/index.js +9 -0
- package/cjs/ComboBox/v3/parts/header-list/styled.js +58 -0
- package/cjs/ComboBox/v3/parts/header-list/useHeaderListHandlers.js +73 -0
- package/cjs/ComboBox/v3/parts/menu-list/MenuList.js +81 -0
- package/cjs/ComboBox/v3/parts/menu-list/index.js +9 -0
- package/cjs/ComboBox/v3/parts/menu-list/styled.js +33 -0
- package/cjs/ComboBox/v3/parts/menu-list/useItemRenderer.js +105 -0
- package/cjs/ComboBox/v3/parts/menu-list/useMenuList.js +61 -0
- package/cjs/ComboBox/v3/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +63 -0
- package/cjs/ComboBox/v3/parts/multi-selected-values-container/index.js +9 -0
- package/cjs/ComboBox/v3/parts/multi-selected-values-container/styled.js +23 -0
- package/cjs/ComboBox/v3/parts/multi-selected-values-container/useGroupPills.js +71 -0
- package/cjs/ComboBox/v3/parts/single-selected-value-container/SingleSelectedValueContainer.js +28 -0
- package/cjs/ComboBox/v3/parts/single-selected-value-container/index.js +9 -0
- package/cjs/ComboBox/v3/parts/single-selected-value-container/styled.js +15 -0
- package/cjs/ComboBox/v3/propTypes.js +25 -0
- package/cjs/ComboBox/v3/utils/hooks/useKeyboardNavigation.js +152 -0
- package/cjs/ComboBox/v3/utils/hooks/useOnElementResize.js +37 -0
- package/cjs/ComboBox/v3/utils/listHelper.js +39 -0
- package/cjs/ComboBoxFreeSolo/ComboBoxFreeSolo.js +1 -0
- package/cjs/index.js +2 -0
- package/esm/ComboBox/index.js +1 -0
- package/esm/ComboBox/v3/ComboBox.js +24 -0
- package/esm/ComboBox/v3/ComboBoxCTX.js +49 -0
- package/esm/ComboBox/v3/ComboboxDataTestids.js +13 -0
- package/esm/ComboBox/v3/config/constants.js +10 -0
- package/esm/ComboBox/v3/config/useComboBox.js +114 -0
- package/esm/ComboBox/v3/config/useGetPropsWithDefault.js +7 -0
- package/esm/ComboBox/v3/index.d.js +1 -0
- package/esm/ComboBox/v3/index.js +1 -0
- package/esm/ComboBox/v3/parts/a11y-messages/MultiAllyMessages.js +25 -0
- package/esm/ComboBox/v3/parts/a11y-messages/SingleAllyMessages.js +20 -0
- package/esm/ComboBox/v3/parts/a11y-messages/index.js +2 -0
- package/esm/ComboBox/v3/parts/a11y-messages/styled.js +7 -0
- package/esm/ComboBox/v3/parts/container/Container.js +59 -0
- package/esm/ComboBox/v3/parts/container/index.js +1 -0
- package/esm/ComboBox/v3/parts/container/styled.js +13 -0
- package/esm/ComboBox/v3/parts/controls/Controls.js +63 -0
- package/esm/ComboBox/v3/parts/controls/index.js +1 -0
- package/esm/ComboBox/v3/parts/controls/styled.js +52 -0
- package/esm/ComboBox/v3/parts/controls-input/ControlsInput.js +59 -0
- package/esm/ComboBox/v3/parts/controls-input/styled.js +16 -0
- package/esm/ComboBox/v3/parts/controls-input/useControlsInput.js +73 -0
- package/esm/ComboBox/v3/parts/dropdown-indicator/DropdownIndicator.js +26 -0
- package/esm/ComboBox/v3/parts/dropdown-indicator/index.js +1 -0
- package/esm/ComboBox/v3/parts/dropdown-indicator/styled.js +8 -0
- package/esm/ComboBox/v3/parts/empty-state/index.js +19 -0
- package/esm/ComboBox/v3/parts/empty-state/styled.js +10 -0
- package/esm/ComboBox/v3/parts/header-list/HeaderList.js +105 -0
- package/esm/ComboBox/v3/parts/header-list/index.js +1 -0
- package/esm/ComboBox/v3/parts/header-list/styled.js +41 -0
- package/esm/ComboBox/v3/parts/header-list/useHeaderListHandlers.js +69 -0
- package/esm/ComboBox/v3/parts/menu-list/MenuList.js +73 -0
- package/esm/ComboBox/v3/parts/menu-list/index.js +1 -0
- package/esm/ComboBox/v3/parts/menu-list/styled.js +23 -0
- package/esm/ComboBox/v3/parts/menu-list/useItemRenderer.js +97 -0
- package/esm/ComboBox/v3/parts/menu-list/useMenuList.js +57 -0
- package/esm/ComboBox/v3/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +54 -0
- package/esm/ComboBox/v3/parts/multi-selected-values-container/index.js +1 -0
- package/esm/ComboBox/v3/parts/multi-selected-values-container/styled.js +13 -0
- package/esm/ComboBox/v3/parts/multi-selected-values-container/useGroupPills.js +67 -0
- package/esm/ComboBox/v3/parts/single-selected-value-container/SingleSelectedValueContainer.js +20 -0
- package/esm/ComboBox/v3/parts/single-selected-value-container/index.js +1 -0
- package/esm/ComboBox/v3/parts/single-selected-value-container/styled.js +7 -0
- package/esm/ComboBox/v3/propTypes.js +21 -0
- package/esm/ComboBox/v3/utils/hooks/useKeyboardNavigation.js +148 -0
- package/esm/ComboBox/v3/utils/hooks/useOnElementResize.js +33 -0
- package/esm/ComboBox/v3/utils/listHelper.js +30 -0
- package/esm/ComboBoxFreeSolo/ComboBoxFreeSolo.js +1 -0
- package/esm/index.js +1 -0
- package/package.json +207 -23
- package/types/ComboBox/index.d.ts +1 -0
- package/types/ComboBox/v3/ComboBox.d.ts +62 -0
- package/types/ComboBox/v3/ComboBoxCTX.d.ts +6 -0
- package/types/ComboBox/v3/ComboboxDataTestids.d.ts +11 -0
- package/types/ComboBox/v3/config/constants.d.ts +8 -0
- package/types/ComboBox/v3/config/useComboBox.d.ts +2 -0
- package/types/ComboBox/v3/config/useGetPropsWithDefault.d.ts +2 -0
- package/types/ComboBox/v3/index.d.ts +1 -0
- package/types/ComboBox/v3/parts/a11y-messages/MultiAllyMessages.d.ts +3 -0
- package/types/ComboBox/v3/parts/a11y-messages/SingleAllyMessages.d.ts +3 -0
- package/types/ComboBox/v3/parts/a11y-messages/index.d.ts +2 -0
- package/types/ComboBox/v3/parts/a11y-messages/styled.d.ts +1 -0
- package/types/ComboBox/v3/parts/container/Container.d.ts +3 -0
- package/types/ComboBox/v3/parts/container/index.d.ts +1 -0
- package/types/ComboBox/v3/parts/container/styled.d.ts +3 -0
- package/types/ComboBox/v3/parts/controls/Controls.d.ts +3 -0
- package/types/ComboBox/v3/parts/controls/index.d.ts +1 -0
- package/types/ComboBox/v3/parts/controls/styled.d.ts +7 -0
- package/types/ComboBox/v3/parts/controls-input/ControlsInput.d.ts +3 -0
- package/types/ComboBox/v3/parts/controls-input/styled.d.ts +4 -0
- package/types/ComboBox/v3/parts/controls-input/useControlsInput.d.ts +12 -0
- package/types/ComboBox/v3/parts/dropdown-indicator/DropdownIndicator.d.ts +3 -0
- package/types/ComboBox/v3/parts/dropdown-indicator/index.d.ts +0 -0
- package/types/ComboBox/v3/parts/dropdown-indicator/styled.d.ts +1 -0
- package/types/ComboBox/v3/parts/empty-state/index.d.ts +3 -0
- package/types/ComboBox/v3/parts/empty-state/styled.d.ts +2 -0
- package/types/ComboBox/v3/parts/header-list/HeaderList.d.ts +3 -0
- package/types/ComboBox/v3/parts/header-list/index.d.ts +1 -0
- package/types/ComboBox/v3/parts/header-list/styled.d.ts +7 -0
- package/types/ComboBox/v3/parts/header-list/useHeaderListHandlers.d.ts +12 -0
- package/types/ComboBox/v3/parts/menu-list/MenuList.d.ts +3 -0
- package/types/ComboBox/v3/parts/menu-list/index.d.ts +1 -0
- package/types/ComboBox/v3/parts/menu-list/styled.d.ts +10 -0
- package/types/ComboBox/v3/parts/menu-list/useItemRenderer.d.ts +2 -0
- package/types/ComboBox/v3/parts/menu-list/useMenuList.d.ts +2 -0
- package/types/ComboBox/v3/parts/multi-selected-values-container/MultiSelectedValuesContainer.d.ts +3 -0
- package/types/ComboBox/v3/parts/multi-selected-values-container/index.d.ts +1 -0
- package/types/ComboBox/v3/parts/multi-selected-values-container/styled.d.ts +3 -0
- package/types/ComboBox/v3/parts/multi-selected-values-container/useGroupPills.d.ts +2 -0
- package/types/ComboBox/v3/parts/single-selected-value-container/SingleSelectedValueContainer.d.ts +3 -0
- package/types/ComboBox/v3/parts/single-selected-value-container/index.d.ts +1 -0
- package/types/ComboBox/v3/parts/single-selected-value-container/styled.d.ts +1 -0
- package/types/ComboBox/v3/propTypes.d.ts +51 -0
- package/types/ComboBox/v3/tests/combobox-general.test.d.ts +1 -0
- package/types/ComboBox/v3/tests/combobox-multi-select.test.d.ts +1 -0
- package/types/ComboBox/v3/tests/combobox-single-select.test.d.ts +1 -0
- package/types/ComboBox/v3/tests/combobox-special-keys.test.d.ts +1 -0
- package/types/ComboBox/v3/tests/utils.d.ts +22 -0
- package/types/ComboBox/v3/utils/hooks/useKeyboardNavigation.d.ts +4 -0
- package/types/ComboBox/v3/utils/hooks/useOnElementResize.d.ts +3 -0
- package/types/ComboBox/v3/utils/listHelper.d.ts +7 -0
- package/types/MenuItem/components/SubmenuItem/styled.d.ts +1 -1
- package/types/MenuItem/components/styled.d.ts +3 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var DSTruncatedTooltipText = require('@elliemae/ds-truncated-tooltip-text');
|
|
8
|
+
var ComboboxDataTestids = require('../../ComboboxDataTestids.js');
|
|
9
|
+
var styled = require('./styled.js');
|
|
10
|
+
var useKeyboardNavigation = require('../../utils/hooks/useKeyboardNavigation.js');
|
|
11
|
+
var useControlsInput = require('./useControlsInput.js');
|
|
12
|
+
var ComboBoxCTX = require('../../ComboBoxCTX.js');
|
|
13
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
14
|
+
|
|
15
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
+
|
|
17
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
18
|
+
|
|
19
|
+
const ControlsInput = () => {
|
|
20
|
+
const {
|
|
21
|
+
props: {
|
|
22
|
+
autoFocus
|
|
23
|
+
},
|
|
24
|
+
showPopover,
|
|
25
|
+
focusOptionIdx,
|
|
26
|
+
inputRef
|
|
27
|
+
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
28
|
+
const {
|
|
29
|
+
onInputKeyDown
|
|
30
|
+
} = useKeyboardNavigation.useKeyboardNavigation();
|
|
31
|
+
const {
|
|
32
|
+
spanReference,
|
|
33
|
+
width,
|
|
34
|
+
spanReferenceText,
|
|
35
|
+
showPlaceholder,
|
|
36
|
+
handleOnBlur,
|
|
37
|
+
handleOnChange,
|
|
38
|
+
handleOnFocus
|
|
39
|
+
} = useControlsInput.useControlsInput();
|
|
40
|
+
return /*#__PURE__*/_jsx__default["default"](styled.StyledInputWrapper, {}, void 0, /*#__PURE__*/jsxRuntime.jsx(styled.StyledInputWidthReference, {
|
|
41
|
+
ref: spanReference,
|
|
42
|
+
children: spanReferenceText
|
|
43
|
+
}), /*#__PURE__*/_jsx__default["default"](styled.StyledInputPlaceHolder, {}, void 0, /*#__PURE__*/_jsx__default["default"](DSTruncatedTooltipText.SimpleTruncatedTooltipText, {
|
|
44
|
+
value: showPlaceholder
|
|
45
|
+
})), /*#__PURE__*/jsxRuntime.jsx(styled.StyledInput, {
|
|
46
|
+
"data-testid": ComboboxDataTestids.ComboboxDataTestid.INPUT,
|
|
47
|
+
autoFocus: autoFocus,
|
|
48
|
+
"aria-labelledby": "combo-label",
|
|
49
|
+
"aria-controls": "combo-listbox",
|
|
50
|
+
"aria-owns": "combo-listbox",
|
|
51
|
+
"aria-activedescendant": focusOptionIdx,
|
|
52
|
+
"aria-expanded": showPopover,
|
|
53
|
+
"aria-haspopup": "listbox",
|
|
54
|
+
role: "combobox",
|
|
55
|
+
style: {
|
|
56
|
+
width
|
|
57
|
+
},
|
|
58
|
+
ref: inputRef,
|
|
59
|
+
type: "text",
|
|
60
|
+
onKeyDown: onInputKeyDown,
|
|
61
|
+
onChange: handleOnChange,
|
|
62
|
+
onBlur: handleOnBlur,
|
|
63
|
+
onFocus: handleOnFocus
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
exports.ControlsInput = ControlsInput;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styled = require('styled-components');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
10
|
+
|
|
11
|
+
const StyledInput = /*#__PURE__*/styled__default["default"].input.withConfig({
|
|
12
|
+
componentId: "sc-1ue5xik-0"
|
|
13
|
+
})(["font-size:13px;line-height:13px;border:none;padding:0;outline:none;color:", ";&:focus{outline:none;}"], props => props.theme.colors.neutral[700]);
|
|
14
|
+
const StyledInputPlaceHolder = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
15
|
+
componentId: "sc-1ue5xik-1"
|
|
16
|
+
})(["font-style:italic;color:", ";position:absolute;display:flex;align-items:center;width:100%;user-select:none;height:28px;"], props => props.theme.colors.neutral[500]);
|
|
17
|
+
const StyledInputWidthReference = /*#__PURE__*/styled__default["default"].span.withConfig({
|
|
18
|
+
componentId: "sc-1ue5xik-2"
|
|
19
|
+
})(["visibility:hidden;position:absolute;top:-9999px;"]);
|
|
20
|
+
const StyledInputWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
21
|
+
componentId: "sc-1ue5xik-3"
|
|
22
|
+
})(["position:relative;flex:1;margin-right:5px;display:flex;align-items:center;"]);
|
|
23
|
+
|
|
24
|
+
exports.StyledInput = StyledInput;
|
|
25
|
+
exports.StyledInputPlaceHolder = StyledInputPlaceHolder;
|
|
26
|
+
exports.StyledInputWidthReference = StyledInputWidthReference;
|
|
27
|
+
exports.StyledInputWrapper = StyledInputWrapper;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
require('core-js/modules/es.string.replace.js');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var ComboBoxCTX = require('../../ComboBoxCTX.js');
|
|
9
|
+
var listHelper = require('../../utils/listHelper.js');
|
|
10
|
+
|
|
11
|
+
const useControlsInput = () => {
|
|
12
|
+
var _inputRef$current, _inputRef$current2, _inputRef$current3;
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
props: {
|
|
16
|
+
selectedValues,
|
|
17
|
+
placeholder,
|
|
18
|
+
onFilter
|
|
19
|
+
},
|
|
20
|
+
setShowPopover,
|
|
21
|
+
setCurrentOption,
|
|
22
|
+
inputRef,
|
|
23
|
+
wrapperListRef,
|
|
24
|
+
setHasFocus,
|
|
25
|
+
setShowSelectedValue,
|
|
26
|
+
setShowSelectedOptions
|
|
27
|
+
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
28
|
+
const [width, setWidth] = React.useState(1);
|
|
29
|
+
const spanReference = React.useRef(null);
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
var _spanReference$curren;
|
|
32
|
+
|
|
33
|
+
setWidth(((_spanReference$curren = spanReference.current) === null || _spanReference$curren === void 0 ? void 0 : _spanReference$curren.offsetWidth) || 1);
|
|
34
|
+
}, [(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value]);
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
setShowSelectedValue(true);
|
|
37
|
+
}, [selectedValues, setShowSelectedValue]); // When writting open popover
|
|
38
|
+
// and refresh selected values and update filter outside value.
|
|
39
|
+
|
|
40
|
+
const handleOnChange = React.useCallback(e => {
|
|
41
|
+
setShowSelectedOptions(false);
|
|
42
|
+
if (e.currentTarget.value) setShowSelectedValue(false);
|
|
43
|
+
setShowPopover(true);
|
|
44
|
+
onFilter(e.currentTarget.value);
|
|
45
|
+
}, [onFilter, setShowPopover, setShowSelectedOptions, setShowSelectedValue]);
|
|
46
|
+
const handleOnBlur = React.useCallback(() => {
|
|
47
|
+
setHasFocus(false);
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
var _wrapperListRef$curre;
|
|
50
|
+
|
|
51
|
+
if (!(wrapperListRef !== null && wrapperListRef !== void 0 && (_wrapperListRef$curre = wrapperListRef.current) !== null && _wrapperListRef$curre !== void 0 && _wrapperListRef$curre.contains(document.activeElement))) {
|
|
52
|
+
setShowPopover(false);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setCurrentOption('');
|
|
56
|
+
setShowSelectedValue(true);
|
|
57
|
+
onFilter('');
|
|
58
|
+
if (inputRef.current) inputRef.current.value = '';
|
|
59
|
+
});
|
|
60
|
+
}, [setHasFocus, setCurrentOption, wrapperListRef, onFilter, inputRef, setShowPopover, setShowSelectedValue]);
|
|
61
|
+
const handleOnFocus = React.useCallback(() => {
|
|
62
|
+
setHasFocus(true);
|
|
63
|
+
}, [setHasFocus]);
|
|
64
|
+
const showPlaceholder = !((_inputRef$current2 = inputRef.current) !== null && _inputRef$current2 !== void 0 && _inputRef$current2.value) && listHelper.isSelectedValueEmpty(selectedValues) ? placeholder : null;
|
|
65
|
+
const spanReferenceText = (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.value.replace(/\s/g, '\u00a0');
|
|
66
|
+
return React.useMemo(() => ({
|
|
67
|
+
handleOnFocus,
|
|
68
|
+
handleOnBlur,
|
|
69
|
+
handleOnChange,
|
|
70
|
+
showPlaceholder,
|
|
71
|
+
spanReferenceText,
|
|
72
|
+
width,
|
|
73
|
+
spanReference
|
|
74
|
+
}), [handleOnFocus, handleOnBlur, handleOnChange, spanReferenceText, showPlaceholder, width, spanReference]);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
exports.useControlsInput = useControlsInput;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var ChevronSmallDown = require('@elliemae/ds-icons/ChevronSmallDown');
|
|
6
|
+
var ComboBoxCTX = require('../../ComboBoxCTX.js');
|
|
7
|
+
var styled = require('./styled.js');
|
|
8
|
+
var ComboboxDataTestids = require('../../ComboboxDataTestids.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
13
|
+
var ChevronSmallDown__default = /*#__PURE__*/_interopDefaultLegacy(ChevronSmallDown);
|
|
14
|
+
|
|
15
|
+
var _ChevronSmallDown;
|
|
16
|
+
|
|
17
|
+
const DropdownIndicator = () => {
|
|
18
|
+
const {
|
|
19
|
+
showPopover
|
|
20
|
+
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
21
|
+
return /*#__PURE__*/_jsx__default["default"](styled.StyledDropDownButton, {
|
|
22
|
+
"data-testid": ComboboxDataTestids.ComboboxDataTestid.DROPDOWN,
|
|
23
|
+
"aria-controls": "combo-listbox",
|
|
24
|
+
"aria-labelledby": "combo-label",
|
|
25
|
+
"aria-expanded": showPopover,
|
|
26
|
+
"aria-haspopup": "listbox",
|
|
27
|
+
buttonType: "text",
|
|
28
|
+
icon: _ChevronSmallDown || (_ChevronSmallDown = /*#__PURE__*/_jsx__default["default"](ChevronSmallDown__default["default"], {})),
|
|
29
|
+
tabIndex: -1
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
module.exports = DropdownIndicator;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styled = require('styled-components');
|
|
6
|
+
var DSButton = require('@elliemae/ds-button');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
11
|
+
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
12
|
+
|
|
13
|
+
const StyledDropDownButton = /*#__PURE__*/styled__default["default"](DSButton__default["default"]).withConfig({
|
|
14
|
+
componentId: "sc-1ijoe1w-0"
|
|
15
|
+
})(["box-sizing:border-box;width:100;& svg{fill:", ";}"], props => props.theme.colors.brand['700']);
|
|
16
|
+
|
|
17
|
+
exports.StyledDropDownButton = StyledDropDownButton;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var ComboBoxCTX = require('../../ComboBoxCTX.js');
|
|
8
|
+
var styled = require('./styled.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
13
|
+
|
|
14
|
+
var _StyledNoResults, _StyledNoResults2;
|
|
15
|
+
|
|
16
|
+
const EmptyState = () => {
|
|
17
|
+
const {
|
|
18
|
+
props: {
|
|
19
|
+
onCreate
|
|
20
|
+
}
|
|
21
|
+
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
22
|
+
return /*#__PURE__*/_jsx__default["default"](styled.StyledNoResultsWrapper, {
|
|
23
|
+
id: "id-no-results"
|
|
24
|
+
}, void 0, onCreate ? _StyledNoResults || (_StyledNoResults = /*#__PURE__*/_jsx__default["default"](styled.StyledNoResults, {}, void 0, "No items match your search, click RETURN at any point to add your unique entry to the field")) : _StyledNoResults2 || (_StyledNoResults2 = /*#__PURE__*/_jsx__default["default"](styled.StyledNoResults, {}, void 0, "No matches found.")));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.EmptyState = EmptyState;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styled = require('styled-components');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
10
|
+
|
|
11
|
+
const StyledNoResultsWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
12
|
+
componentId: "sc-o4fon6-0"
|
|
13
|
+
})(["padding:16px;"]);
|
|
14
|
+
const StyledNoResults = /*#__PURE__*/styled__default["default"].span.withConfig({
|
|
15
|
+
componentId: "sc-o4fon6-1"
|
|
16
|
+
})([""]);
|
|
17
|
+
|
|
18
|
+
exports.StyledNoResults = StyledNoResults;
|
|
19
|
+
exports.StyledNoResultsWrapper = StyledNoResultsWrapper;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var lodash = require('lodash');
|
|
8
|
+
var ComboBoxCTX = require('../../ComboBoxCTX.js');
|
|
9
|
+
var styled = require('./styled.js');
|
|
10
|
+
var listHelper = require('../../utils/listHelper.js');
|
|
11
|
+
var ComboboxDataTestids = require('../../ComboboxDataTestids.js');
|
|
12
|
+
var useHeaderListHandlers = require('./useHeaderListHandlers.js');
|
|
13
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
14
|
+
|
|
15
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
+
|
|
17
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
18
|
+
|
|
19
|
+
var _StyledSeparator, _StyledNoOptionsSelec, _StyledSeparator2;
|
|
20
|
+
|
|
21
|
+
const HeaderList = () => {
|
|
22
|
+
var _inputRef$current;
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
props: {
|
|
26
|
+
onSelectAll,
|
|
27
|
+
onClearAll,
|
|
28
|
+
withToggle,
|
|
29
|
+
selectedValues,
|
|
30
|
+
options
|
|
31
|
+
},
|
|
32
|
+
showSelectedOptions,
|
|
33
|
+
inputRef
|
|
34
|
+
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
35
|
+
const isSelectAllSupplied = onSelectAll !== lodash.noop;
|
|
36
|
+
const isClearAllSupplied = onClearAll !== lodash.noop;
|
|
37
|
+
const multiSelectedValues = selectedValues;
|
|
38
|
+
const selectableOptions = listHelper.getSelectableOptions(options);
|
|
39
|
+
const {
|
|
40
|
+
handleKeyDown,
|
|
41
|
+
handleClickOnClearAll,
|
|
42
|
+
handleClickOnSelectAll,
|
|
43
|
+
handleOnBlurClearAll,
|
|
44
|
+
handleOnBlurSelectAll,
|
|
45
|
+
handleOnMouseDown,
|
|
46
|
+
handleToggle
|
|
47
|
+
} = useHeaderListHandlers.useHeaderListHandlers();
|
|
48
|
+
return /*#__PURE__*/_jsx__default["default"](styled.StyledHeaderListWrapper, {
|
|
49
|
+
onKeyDown: handleKeyDown,
|
|
50
|
+
onMouseDown: handleOnMouseDown
|
|
51
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](styled.StyledSelectedItems, {}, void 0, isSelectAllSupplied && /*#__PURE__*/_jsx__default["default"](styled.StyledButton, {
|
|
52
|
+
disabled: (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value) !== '' || selectableOptions.length === multiSelectedValues.length,
|
|
53
|
+
"data-testid": ComboboxDataTestids.ComboboxDataTestid.SELECT_ALL_BUTTON,
|
|
54
|
+
buttonType: "text",
|
|
55
|
+
labelText: "All",
|
|
56
|
+
size: "s",
|
|
57
|
+
onMouseDown: handleOnMouseDown,
|
|
58
|
+
onBlur: handleOnBlurSelectAll,
|
|
59
|
+
onClick: handleClickOnSelectAll
|
|
60
|
+
}), isSelectAllSupplied && isClearAllSupplied && (_StyledSeparator || (_StyledSeparator = /*#__PURE__*/_jsx__default["default"](styled.StyledSeparator, {
|
|
61
|
+
orientation: "vertical",
|
|
62
|
+
position: "center",
|
|
63
|
+
type: "group-level",
|
|
64
|
+
margin: "none"
|
|
65
|
+
}))), isClearAllSupplied && /*#__PURE__*/_jsx__default["default"](styled.StyledButton, {
|
|
66
|
+
disabled: multiSelectedValues.length === 0,
|
|
67
|
+
tabIndex: 0,
|
|
68
|
+
"data-testid": ComboboxDataTestids.ComboboxDataTestid.CLEAR_ALL_BUTTON,
|
|
69
|
+
buttonType: "text",
|
|
70
|
+
size: "s",
|
|
71
|
+
labelText: "Clear",
|
|
72
|
+
onMouseDown: handleOnMouseDown,
|
|
73
|
+
onBlur: handleOnBlurClearAll,
|
|
74
|
+
onClick: handleClickOnClearAll
|
|
75
|
+
})), /*#__PURE__*/_jsx__default["default"](styled.StyledSelectedItems, {}, void 0, withToggle ? /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
76
|
+
children: multiSelectedValues.length > 0 ? /*#__PURE__*/_jsx__default["default"](styled.StyledButtonSelection, {
|
|
77
|
+
buttonType: "text",
|
|
78
|
+
disabled: !showSelectedOptions && selectableOptions.length === multiSelectedValues.length,
|
|
79
|
+
onClick: handleToggle,
|
|
80
|
+
labelText: !showSelectedOptions ? "".concat(multiSelectedValues.length, " SELECTED") : 'SHOW ALL',
|
|
81
|
+
size: "s"
|
|
82
|
+
}) : _StyledNoOptionsSelec || (_StyledNoOptionsSelec = /*#__PURE__*/_jsx__default["default"](styled.StyledNoOptionsSelected, {}, void 0, "0 SELECTED"))
|
|
83
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
84
|
+
children: [/*#__PURE__*/_jsx__default["default"](styled.StyledShowAllButton, {
|
|
85
|
+
buttonType: "text",
|
|
86
|
+
"data-testid": ComboboxDataTestids.ComboboxDataTestid.SHOW_ALL_BUTTON,
|
|
87
|
+
tabIndex: !showSelectedOptions ? -1 : 0,
|
|
88
|
+
onClick: showSelectedOptions ? handleToggle : lodash.noop,
|
|
89
|
+
labelText: "SHOW ALL",
|
|
90
|
+
isSelected: !showSelectedOptions,
|
|
91
|
+
size: "s",
|
|
92
|
+
style: {
|
|
93
|
+
fontWeight: showSelectedOptions ? '300' : '600'
|
|
94
|
+
}
|
|
95
|
+
}), _StyledSeparator2 || (_StyledSeparator2 = /*#__PURE__*/_jsx__default["default"](styled.StyledSeparator, {
|
|
96
|
+
orientation: "vertical",
|
|
97
|
+
position: "center",
|
|
98
|
+
type: "group-level",
|
|
99
|
+
margin: "none"
|
|
100
|
+
})), /*#__PURE__*/_jsx__default["default"](styled.StyledButtonSelection, {
|
|
101
|
+
tabIndex: showSelectedOptions ? -1 : 0,
|
|
102
|
+
"data-testid": ComboboxDataTestids.ComboboxDataTestid.SHOW_SELECTED_OPTIONS_BUTTON,
|
|
103
|
+
disabled: multiSelectedValues.length === 0 || !showSelectedOptions && selectableOptions.length === multiSelectedValues.length,
|
|
104
|
+
buttonType: "text",
|
|
105
|
+
isSelected: showSelectedOptions,
|
|
106
|
+
onClick: !showSelectedOptions ? handleToggle : lodash.noop,
|
|
107
|
+
labelText: "".concat(multiSelectedValues.length, " SELECTED"),
|
|
108
|
+
size: "s"
|
|
109
|
+
})]
|
|
110
|
+
})));
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
exports.HeaderList = HeaderList;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
|
|
6
|
+
var styled = require('styled-components');
|
|
7
|
+
var dsSystem = require('@elliemae/ds-system');
|
|
8
|
+
var DSButton = require('@elliemae/ds-button');
|
|
9
|
+
var DSSeparator = require('@elliemae/ds-separator');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
14
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
15
|
+
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
16
|
+
var DSSeparator__default = /*#__PURE__*/_interopDefaultLegacy(DSSeparator);
|
|
17
|
+
|
|
18
|
+
var _templateObject;
|
|
19
|
+
|
|
20
|
+
const selectedStyle = isSelected => dsSystem.css(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n & span {\n border-bottom: 2px solid ", ";\n }\n cursor: ", ";\n"])), props => isSelected ? props.theme.colors.brand[700] : '#FFF', isSelected && 'default');
|
|
21
|
+
|
|
22
|
+
const StyledHeaderListWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
23
|
+
componentId: "sc-dazbzt-0"
|
|
24
|
+
})(["display:flex;position:fixed;top:0;z-index:10;justify-content:space-between;padding:0px 12px 0px 12px;width:100%;height:28px;background-color:#fff;box-shadow:0 4px 2px -4px ", ";overflow-x:hidden;& button{font-size:13px;}"], props => props.theme.colors.neutral[700]);
|
|
25
|
+
const StyledSeparator = /*#__PURE__*/styled__default["default"](DSSeparator__default["default"]).withConfig({
|
|
26
|
+
componentId: "sc-dazbzt-1"
|
|
27
|
+
})(["height:50%;width:auto;"]);
|
|
28
|
+
const StyledButton = /*#__PURE__*/styled__default["default"](DSButton__default["default"]).withConfig({
|
|
29
|
+
componentId: "sc-dazbzt-2"
|
|
30
|
+
})(["padding:0 ", ";align-items:center;"], props => props.theme.space.xxs);
|
|
31
|
+
const StyledGeneralSelectionButton = /*#__PURE__*/styled__default["default"](DSButton__default["default"]).withConfig({
|
|
32
|
+
componentId: "sc-dazbzt-3"
|
|
33
|
+
})(["border-radius:0px;padding:0 ", ";margin:0;align-items:center;", " transition:unset;"], props => props.theme.space.xxs, _ref => {
|
|
34
|
+
let {
|
|
35
|
+
isSelected
|
|
36
|
+
} = _ref;
|
|
37
|
+
return selectedStyle(isSelected);
|
|
38
|
+
});
|
|
39
|
+
const StyledButtonSelection = /*#__PURE__*/styled__default["default"](StyledGeneralSelectionButton).withConfig({
|
|
40
|
+
componentId: "sc-dazbzt-4"
|
|
41
|
+
})(["&:hover:not([disabled]){background-color:transparent;color:", ";}"], props => props.theme.colors.brand['700']);
|
|
42
|
+
const StyledShowAllButton = /*#__PURE__*/styled__default["default"](StyledGeneralSelectionButton).withConfig({
|
|
43
|
+
componentId: "sc-dazbzt-5"
|
|
44
|
+
})(["color:", ";&:hover:not([disabled]){background-color:transparent;color:", ";}"], props => props.theme.colors.neutral['700'], props => props.theme.colors.neutral['700']);
|
|
45
|
+
const StyledSelectedItems = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
46
|
+
componentId: "sc-dazbzt-6"
|
|
47
|
+
})(["display:flex;align-items:center;"]);
|
|
48
|
+
const StyledNoOptionsSelected = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
49
|
+
componentId: "sc-dazbzt-7"
|
|
50
|
+
})(["padding:0 ", ";"], props => props.theme.space.xxs);
|
|
51
|
+
|
|
52
|
+
exports.StyledButton = StyledButton;
|
|
53
|
+
exports.StyledButtonSelection = StyledButtonSelection;
|
|
54
|
+
exports.StyledHeaderListWrapper = StyledHeaderListWrapper;
|
|
55
|
+
exports.StyledNoOptionsSelected = StyledNoOptionsSelected;
|
|
56
|
+
exports.StyledSelectedItems = StyledSelectedItems;
|
|
57
|
+
exports.StyledSeparator = StyledSeparator;
|
|
58
|
+
exports.StyledShowAllButton = StyledShowAllButton;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var ComboBoxCTX = require('../../ComboBoxCTX.js');
|
|
7
|
+
|
|
8
|
+
const useHeaderListHandlers = () => {
|
|
9
|
+
const {
|
|
10
|
+
props: {
|
|
11
|
+
onSelectAll,
|
|
12
|
+
onFilter,
|
|
13
|
+
onClearAll,
|
|
14
|
+
selectedValues
|
|
15
|
+
},
|
|
16
|
+
inputRef,
|
|
17
|
+
showSelectedOptions,
|
|
18
|
+
setShowSelectedOptions,
|
|
19
|
+
setShowPopover
|
|
20
|
+
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
21
|
+
const multiSelectedValues = selectedValues;
|
|
22
|
+
const handleOnBlurSelectAll = React.useCallback(e => {
|
|
23
|
+
if (!onClearAll || multiSelectedValues.length === 0) {
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
inputRef.current.focus();
|
|
26
|
+
}
|
|
27
|
+
}, [inputRef, onClearAll, multiSelectedValues]);
|
|
28
|
+
const handleOnBlurClearAll = React.useCallback(e => {// since ux change order from the action buttons this is unneccesary. will comment until review finish
|
|
29
|
+
// e.preventDefault();
|
|
30
|
+
// inputRef.current.focus();
|
|
31
|
+
}, [inputRef]);
|
|
32
|
+
const handleClickOnSelectAll = React.useCallback(() => {
|
|
33
|
+
onSelectAll();
|
|
34
|
+
inputRef.current.focus();
|
|
35
|
+
}, [onSelectAll, inputRef, setShowPopover]);
|
|
36
|
+
const handleClickOnClearAll = React.useCallback(e => {
|
|
37
|
+
setShowSelectedOptions(false);
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
onClearAll();
|
|
41
|
+
inputRef.current.focus();
|
|
42
|
+
}, [inputRef, setShowSelectedOptions, onClearAll]);
|
|
43
|
+
const handleOnMouseDown = React.useCallback(e => {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
}, []);
|
|
46
|
+
const handleToggle = React.useCallback(() => {
|
|
47
|
+
inputRef.current.value = '';
|
|
48
|
+
onFilter('');
|
|
49
|
+
setShowSelectedOptions(!showSelectedOptions);
|
|
50
|
+
inputRef.current.focus();
|
|
51
|
+
}, [setShowSelectedOptions, inputRef, onFilter, showSelectedOptions]);
|
|
52
|
+
const handleKeyDown = React.useCallback(e => {
|
|
53
|
+
if (e.key === 'Escape') {
|
|
54
|
+
setShowPopover(false);
|
|
55
|
+
}
|
|
56
|
+
}, [setShowPopover]);
|
|
57
|
+
React.useEffect(() => {
|
|
58
|
+
if (multiSelectedValues.length === 0) {
|
|
59
|
+
setShowSelectedOptions(false);
|
|
60
|
+
}
|
|
61
|
+
}, [multiSelectedValues, setShowSelectedOptions]);
|
|
62
|
+
return React.useMemo(() => ({
|
|
63
|
+
handleKeyDown,
|
|
64
|
+
handleToggle,
|
|
65
|
+
handleOnMouseDown,
|
|
66
|
+
handleClickOnClearAll,
|
|
67
|
+
handleClickOnSelectAll,
|
|
68
|
+
handleOnBlurClearAll,
|
|
69
|
+
handleOnBlurSelectAll
|
|
70
|
+
}), [handleKeyDown, handleToggle, handleOnMouseDown, handleClickOnClearAll, handleClickOnSelectAll, handleOnBlurClearAll, handleOnBlurSelectAll]);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.useHeaderListHandlers = useHeaderListHandlers;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var styled = require('./styled.js');
|
|
8
|
+
var ComboboxDataTestids = require('../../ComboboxDataTestids.js');
|
|
9
|
+
var ComboBoxCTX = require('../../ComboBoxCTX.js');
|
|
10
|
+
var HeaderList = require('../header-list/HeaderList.js');
|
|
11
|
+
var useOnElementResize = require('../../utils/hooks/useOnElementResize.js');
|
|
12
|
+
var index = require('../empty-state/index.js');
|
|
13
|
+
var useItemRenderer = require('./useItemRenderer.js');
|
|
14
|
+
var useMenuList = require('./useMenuList.js');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
|
|
17
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
+
|
|
19
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
20
|
+
|
|
21
|
+
var _HeaderList, _EmptyState;
|
|
22
|
+
|
|
23
|
+
const MenuList = () => {
|
|
24
|
+
const {
|
|
25
|
+
props: {
|
|
26
|
+
menuMinWidth,
|
|
27
|
+
menuMaxHeight,
|
|
28
|
+
inline,
|
|
29
|
+
options,
|
|
30
|
+
selectedValues
|
|
31
|
+
},
|
|
32
|
+
referenceElement,
|
|
33
|
+
inputRef,
|
|
34
|
+
listRef,
|
|
35
|
+
showPopover,
|
|
36
|
+
wrapperListRef,
|
|
37
|
+
controlsWrapperRef,
|
|
38
|
+
virtualListHelpers: {
|
|
39
|
+
totalSize
|
|
40
|
+
}
|
|
41
|
+
} = React.useContext(ComboBoxCTX.ComboBoxContext);
|
|
42
|
+
const multiple = Array.isArray(selectedValues);
|
|
43
|
+
const withHeader = !inline && multiple && options.length > 0;
|
|
44
|
+
const ItemRenderer = useItemRenderer.useItemRenderer();
|
|
45
|
+
useMenuList.useMenuList();
|
|
46
|
+
useOnElementResize.useOnElementResize(controlsWrapperRef);
|
|
47
|
+
const listWidth = React.useMemo(() => menuMinWidth || "".concat(referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.offsetWidth), [menuMinWidth, referenceElement]);
|
|
48
|
+
const handleOnFocus = React.useCallback(() => {
|
|
49
|
+
var _inputRef$current;
|
|
50
|
+
|
|
51
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
52
|
+
}, [inputRef]);
|
|
53
|
+
return /*#__PURE__*/jsxRuntime.jsxs(styled.StyledListWrapper, {
|
|
54
|
+
tabIndex: -1,
|
|
55
|
+
ref: wrapperListRef,
|
|
56
|
+
inline: inline,
|
|
57
|
+
onMouseDown: e => e.preventDefault(),
|
|
58
|
+
minWidth: listWidth,
|
|
59
|
+
id: "combo-listbox",
|
|
60
|
+
role: "listbox",
|
|
61
|
+
children: [withHeader && (_HeaderList || (_HeaderList = /*#__PURE__*/_jsx__default["default"](HeaderList.HeaderList, {}))), options.length > 0 ? /*#__PURE__*/jsxRuntime.jsx(styled.StyledVirtualListWrapper, {
|
|
62
|
+
tabIndex: -1,
|
|
63
|
+
inline: inline,
|
|
64
|
+
maxHeight: menuMaxHeight,
|
|
65
|
+
ref: listRef,
|
|
66
|
+
withHeader: withHeader,
|
|
67
|
+
children: /*#__PURE__*/_jsx__default["default"](styled.StyledList, {
|
|
68
|
+
tabIndex: -1,
|
|
69
|
+
"aria-expanded": showPopover,
|
|
70
|
+
onFocus: handleOnFocus,
|
|
71
|
+
"data-testid": ComboboxDataTestids.ComboboxDataTestid.LIST,
|
|
72
|
+
style: {
|
|
73
|
+
height: totalSize,
|
|
74
|
+
margin: inline ? '0px' : '8px 0px'
|
|
75
|
+
}
|
|
76
|
+
}, void 0, ItemRenderer)
|
|
77
|
+
}) : _EmptyState || (_EmptyState = /*#__PURE__*/_jsx__default["default"](index.EmptyState, {}))]
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
exports.MenuList = MenuList;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styled = require('styled-components');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
10
|
+
|
|
11
|
+
const StyledListWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
12
|
+
componentId: "sc-1uedyf-0"
|
|
13
|
+
})(["min-width:", ";"], props => props.inline ? '100%' : "".concat(props.minWidth, "px"));
|
|
14
|
+
const StyledList = /*#__PURE__*/styled__default["default"].ul.withConfig({
|
|
15
|
+
componentId: "sc-1uedyf-1"
|
|
16
|
+
})(["position:relative;padding:0;"]);
|
|
17
|
+
const StyledVirtualListWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
18
|
+
componentId: "sc-1uedyf-2"
|
|
19
|
+
})(["overflow-y:auto;margin-top:", ";max-height:", ";"], _ref => {
|
|
20
|
+
let {
|
|
21
|
+
withHeader
|
|
22
|
+
} = _ref;
|
|
23
|
+
return withHeader ? '28px' : '';
|
|
24
|
+
}, _ref2 => {
|
|
25
|
+
let {
|
|
26
|
+
maxHeight
|
|
27
|
+
} = _ref2;
|
|
28
|
+
return !maxHeight ? '400px' : "".concat(maxHeight, "px");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
exports.StyledList = StyledList;
|
|
32
|
+
exports.StyledListWrapper = StyledListWrapper;
|
|
33
|
+
exports.StyledVirtualListWrapper = StyledVirtualListWrapper;
|