@elliemae/ds-menu 2.2.0-alpha.4 → 3.0.0-next.2
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/Menu.js +181 -137
- package/cjs/MenuCombobox.js +53 -67
- package/cjs/MenuContext.js +11 -38
- package/cjs/MenuItems/CheckboxGroup.js +42 -49
- package/cjs/MenuItems/MenuItem.js +163 -116
- package/cjs/MenuItems/MenuItemCheckable.js +108 -77
- package/cjs/MenuItems/MenuItemCheckbox.js +41 -47
- package/cjs/MenuItems/MenuItemRadio.js +38 -50
- package/cjs/MenuItems/RadioGroup.js +39 -48
- package/cjs/MenuItems/SearchableGroup.js +92 -88
- package/cjs/MenuItems/SearchableList.js +95 -92
- package/cjs/MenuItems/SelectionGroup.js +90 -85
- package/cjs/MenuItems/Separator.js +40 -55
- package/cjs/MenuItems/SubMenu.js +160 -143
- package/cjs/MenuItems/menuItemFactory.js +68 -38
- package/cjs/VirtualMenuList.js +39 -69
- package/cjs/index.js +36 -63
- package/cjs/utils/useHeightByAmountOfItems.js +14 -43
- package/esm/Menu.js +149 -91
- package/esm/MenuCombobox.js +45 -38
- package/esm/MenuContext.js +5 -9
- package/esm/MenuItems/CheckboxGroup.js +31 -19
- package/esm/MenuItems/MenuItem.js +148 -84
- package/esm/MenuItems/MenuItemCheckable.js +96 -47
- package/esm/MenuItems/MenuItemCheckbox.js +33 -18
- package/esm/MenuItems/MenuItemRadio.js +28 -20
- package/esm/MenuItems/RadioGroup.js +28 -18
- package/esm/MenuItems/SearchableGroup.js +76 -53
- package/esm/MenuItems/SearchableList.js +82 -59
- package/esm/MenuItems/SelectionGroup.js +78 -54
- package/esm/MenuItems/Separator.js +29 -26
- package/esm/MenuItems/SubMenu.js +140 -107
- package/esm/MenuItems/menuItemFactory.js +60 -10
- package/esm/VirtualMenuList.js +32 -39
- package/esm/index.js +13 -34
- package/esm/utils/useHeightByAmountOfItems.js +11 -13
- package/package.json +11 -19
- package/types/Menu.d.ts +2 -3
- package/types/MenuContext.d.ts +2 -3
- package/types/MenuItems/CheckboxGroup.d.ts +5 -5
- package/types/MenuItems/MenuItem.d.ts +5 -5
- package/types/MenuItems/MenuItemCheckable.d.ts +15 -15
- package/types/MenuItems/MenuItemCheckbox.d.ts +2 -3
- package/types/MenuItems/MenuItemRadio.d.ts +5 -5
- package/types/MenuItems/RadioGroup.d.ts +5 -5
- package/types/MenuItems/SearchableGroup.d.ts +3 -3
- package/types/MenuItems/SearchableList.d.ts +16 -16
- package/types/MenuItems/SelectionGroup.d.ts +16 -16
- package/types/MenuItems/Separator.d.ts +1 -2
- package/types/MenuItems/SubMenu.d.ts +18 -18
- package/types/MenuItems/menuItemFactory.d.ts +3 -2
- package/types/VirtualMenuList.d.ts +1 -3
- package/types/index.d.ts +2 -3
- package/types/utils/useHeightByAmountOfItems.d.ts +1 -3
- package/cjs/Menu.js.map +0 -7
- package/cjs/MenuCombobox.js.map +0 -7
- package/cjs/MenuContext.js.map +0 -7
- package/cjs/MenuExports.js +0 -28
- package/cjs/MenuExports.js.map +0 -7
- package/cjs/MenuItems/CheckboxGroup.js.map +0 -7
- package/cjs/MenuItems/MenuItem.js.map +0 -7
- package/cjs/MenuItems/MenuItemCheckable.js.map +0 -7
- package/cjs/MenuItems/MenuItemCheckbox.js.map +0 -7
- package/cjs/MenuItems/MenuItemRadio.js.map +0 -7
- package/cjs/MenuItems/RadioGroup.js.map +0 -7
- package/cjs/MenuItems/SearchableGroup.js.map +0 -7
- package/cjs/MenuItems/SearchableList.js.map +0 -7
- package/cjs/MenuItems/SelectionGroup.js.map +0 -7
- package/cjs/MenuItems/Separator.js.map +0 -7
- package/cjs/MenuItems/SubMenu.js.map +0 -7
- package/cjs/MenuItems/menuItemFactory.js.map +0 -7
- package/cjs/MenuItems/renderMenuItems.js +0 -53
- package/cjs/MenuItems/renderMenuItems.js.map +0 -7
- package/cjs/VirtualMenuList.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/utils/useHeightByAmountOfItems.js.map +0 -7
- package/esm/Menu.js.map +0 -7
- package/esm/MenuCombobox.js.map +0 -7
- package/esm/MenuContext.js.map +0 -7
- package/esm/MenuExports.js +0 -3
- package/esm/MenuExports.js.map +0 -7
- package/esm/MenuItems/CheckboxGroup.js.map +0 -7
- package/esm/MenuItems/MenuItem.js.map +0 -7
- package/esm/MenuItems/MenuItemCheckable.js.map +0 -7
- package/esm/MenuItems/MenuItemCheckbox.js.map +0 -7
- package/esm/MenuItems/MenuItemRadio.js.map +0 -7
- package/esm/MenuItems/RadioGroup.js.map +0 -7
- package/esm/MenuItems/SearchableGroup.js.map +0 -7
- package/esm/MenuItems/SearchableList.js.map +0 -7
- package/esm/MenuItems/SelectionGroup.js.map +0 -7
- package/esm/MenuItems/Separator.js.map +0 -7
- package/esm/MenuItems/SubMenu.js.map +0 -7
- package/esm/MenuItems/menuItemFactory.js.map +0 -7
- package/esm/MenuItems/renderMenuItems.js +0 -24
- package/esm/MenuItems/renderMenuItems.js.map +0 -7
- package/esm/VirtualMenuList.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/utils/useHeightByAmountOfItems.js.map +0 -7
- package/types/MenuExports.d.ts +0 -1
- package/types/MenuItems/renderMenuItems.d.ts +0 -1
|
@@ -1,68 +1,91 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
6
|
+
import { useRef, useState, useEffect, useContext, useMemo } from 'react';
|
|
7
|
+
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
8
|
+
import { focusGroupManagerHoc } from '@elliemae/ds-shared/FocusGroup';
|
|
9
|
+
import DSSearchBox from '@elliemae/ds-form/SearchBox';
|
|
10
|
+
import { PropTypes, describe } from 'react-desc';
|
|
11
|
+
import VirtualMenuList from '../VirtualMenuList.js';
|
|
12
|
+
import MenuContext from '../MenuContext.js';
|
|
13
|
+
import { jsxs, Fragment } from 'react/jsx-runtime';
|
|
14
|
+
|
|
15
|
+
const SearchBoxWrapper = aggregatedClasses('div')('menu-search-group', 'search-wrapper');
|
|
16
|
+
const NoOptionsWrapper = aggregatedClasses('div')('menu-search-group', 'no-options');
|
|
17
|
+
|
|
18
|
+
function SearchableGroup(_ref) {
|
|
19
|
+
let {
|
|
20
|
+
children,
|
|
21
|
+
amountItemsInWindow = 5,
|
|
22
|
+
searchTerm: searchTermProp = '',
|
|
23
|
+
noOptionsText = 'No options',
|
|
24
|
+
height,
|
|
25
|
+
width,
|
|
26
|
+
focusOnOpen = false
|
|
27
|
+
} = _ref;
|
|
20
28
|
const searchRef = useRef(null);
|
|
21
29
|
const [searchTerm, setSearchTerm] = useState(searchTermProp);
|
|
22
30
|
useEffect(() => {
|
|
23
|
-
if (searchRef.current)
|
|
24
|
-
searchRef.current.focus();
|
|
31
|
+
if (searchRef.current) searchRef.current.focus();
|
|
25
32
|
}, []);
|
|
26
|
-
const {
|
|
33
|
+
const {
|
|
34
|
+
visible
|
|
35
|
+
} = useContext(MenuContext) || {};
|
|
27
36
|
useEffect(() => {
|
|
28
37
|
if (focusOnOpen && visible) {
|
|
29
38
|
setTimeout(() => {
|
|
30
|
-
if (searchRef.current)
|
|
31
|
-
searchRef.current.focus();
|
|
39
|
+
if (searchRef.current) searchRef.current.focus();
|
|
32
40
|
}, 0);
|
|
33
41
|
}
|
|
34
42
|
}, [focusOnOpen, visible]);
|
|
35
|
-
const filteredChildren = useMemo(() => children.filter(
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
43
|
+
const filteredChildren = useMemo(() => children.filter(child => !searchTerm || child.props.label.toLowerCase().startsWith(searchTerm.toLowerCase())), [children, searchTerm]);
|
|
44
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
45
|
+
children: [/*#__PURE__*/_jsx(SearchBoxWrapper, {}, void 0, /*#__PURE__*/_jsx(DSSearchBox, {
|
|
46
|
+
innerRef: searchRef,
|
|
47
|
+
onSearch: _ref2 => {
|
|
48
|
+
let {
|
|
49
|
+
value
|
|
50
|
+
} = _ref2;
|
|
51
|
+
return setSearchTerm(value);
|
|
52
|
+
},
|
|
53
|
+
searchOnEnter: false,
|
|
54
|
+
showIcon: false,
|
|
55
|
+
value: searchTerm
|
|
56
|
+
})), !filteredChildren.length && /*#__PURE__*/_jsx(NoOptionsWrapper, {}, void 0, noOptionsText), /*#__PURE__*/_jsx(VirtualMenuList, {
|
|
57
|
+
amountItemsInWindow: amountItemsInWindow,
|
|
58
|
+
height: height,
|
|
59
|
+
items: filteredChildren,
|
|
60
|
+
width: width
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
49
65
|
const props = {
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
/** The amount of items that are going to be rendered in the group */
|
|
67
|
+
amountItemsInWindow: PropTypes.number.description('The amount of items that are going to be rendered in the group'),
|
|
68
|
+
|
|
69
|
+
/** A search term */
|
|
70
|
+
searchTerm: PropTypes.string.description('A search term'),
|
|
71
|
+
|
|
72
|
+
/** Text to show when there's no options to show */
|
|
52
73
|
noOptionsText: PropTypes.string.description("Text to show when there's no options to show"),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
74
|
+
|
|
75
|
+
/** array of children for search list */
|
|
76
|
+
children: PropTypes.array.description('array of children for search list'),
|
|
77
|
+
|
|
78
|
+
/** height for virtual list wrapper */
|
|
79
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('height for virtual list wrapper'),
|
|
80
|
+
|
|
81
|
+
/** width for virtual list wrapper */
|
|
82
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description('width for virtual list wrapper'),
|
|
83
|
+
|
|
84
|
+
/** weather to focus on searchable group on open */
|
|
85
|
+
focusOnOpen: PropTypes.bool.description('weather to focus on searchable group on open')
|
|
57
86
|
};
|
|
58
|
-
SearchableGroup.propTypes = props;
|
|
59
87
|
const DSMenuSearchableGroupWithSchema = describe(SearchableGroup);
|
|
60
88
|
DSMenuSearchableGroupWithSchema.propTypes = props;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export {
|
|
64
|
-
DSMenuSearchableGroupWithSchema,
|
|
65
|
-
SearchableGroupHOC as SearchableGroup,
|
|
66
|
-
SearchableGroup_default as default
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=SearchableGroup.js.map
|
|
89
|
+
var SearchableGroup$1 = focusGroupManagerHoc(SearchableGroup);
|
|
90
|
+
|
|
91
|
+
export { DSMenuSearchableGroupWithSchema, SearchableGroup$1 as default };
|
|
@@ -1,47 +1,58 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
9
|
+
import { PropTypes, describe } from 'react-desc';
|
|
10
|
+
import { uniqBy } from '@elliemae/ds-utilities';
|
|
11
|
+
import { DSComboBox } from '@elliemae/ds-form';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
|
|
18
|
+
const noop = () => {};
|
|
19
|
+
|
|
20
|
+
function SearchableList(_ref) {
|
|
21
|
+
let {
|
|
22
|
+
onSelectMenuItem = noop,
|
|
23
|
+
components = {},
|
|
24
|
+
searchTerm: searchTermProp = '',
|
|
25
|
+
items = [],
|
|
26
|
+
dropdownFilterOptions = {},
|
|
27
|
+
returnValue,
|
|
28
|
+
extraListProps = {},
|
|
29
|
+
appendTermInList = false,
|
|
30
|
+
maxOptions = 10,
|
|
31
|
+
loading = false
|
|
32
|
+
} = _ref;
|
|
20
33
|
const [searchTerm, setInputValue] = useState(searchTermProp);
|
|
21
34
|
const handleInputChange = useCallback((value, args) => {
|
|
22
35
|
const action = args ? args.action : null;
|
|
23
|
-
if (action ===
|
|
24
|
-
return;
|
|
36
|
+
if (action === 'input-blur' || action === 'menu-close') return;
|
|
25
37
|
setInputValue(value);
|
|
26
38
|
}, [searchTerm]);
|
|
27
39
|
const handleFilterByText = useCallback(() => {
|
|
28
|
-
if (searchTerm)
|
|
29
|
-
onSelectMenuItem(searchTerm);
|
|
40
|
+
if (searchTerm) onSelectMenuItem(searchTerm);
|
|
30
41
|
}, [searchTerm]);
|
|
31
|
-
const handleKeyDown = useCallback(
|
|
32
|
-
if (e.key ===
|
|
42
|
+
const handleKeyDown = useCallback(e => {
|
|
43
|
+
if (e.key === 'ArrowRight') {
|
|
33
44
|
handleFilterByText();
|
|
34
45
|
}
|
|
35
46
|
}, [searchTerm]);
|
|
36
|
-
const options = useMemo(() => searchTerm && appendTermInList ? uniqBy([
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
].concat(items), (item) => item.label) : items, [searchTerm, appendTermInList]);
|
|
42
|
-
return /* @__PURE__ */ React2.createElement(DSComboBox, {
|
|
47
|
+
const options = useMemo(() => searchTerm && appendTermInList ? uniqBy([{
|
|
48
|
+
id: searchTerm,
|
|
49
|
+
label: searchTerm
|
|
50
|
+
}].concat(items), item => item.label) : items, [searchTerm, appendTermInList]);
|
|
51
|
+
return /*#__PURE__*/jsx(DSComboBox, _objectSpread(_objectSpread({
|
|
43
52
|
autoFocus: true,
|
|
44
|
-
components: {
|
|
53
|
+
components: _objectSpread({
|
|
54
|
+
DropdownIndicator: null
|
|
55
|
+
}, components),
|
|
45
56
|
customMenuItemOptions: {
|
|
46
57
|
useTruncatedText: true
|
|
47
58
|
},
|
|
@@ -52,34 +63,46 @@ const SearchableList = ({
|
|
|
52
63
|
onFilterByInputText: handleFilterByText,
|
|
53
64
|
onInputChange: handleInputChange,
|
|
54
65
|
onKeyDown: handleKeyDown,
|
|
55
|
-
options,
|
|
56
|
-
returnValue,
|
|
66
|
+
options: options,
|
|
67
|
+
returnValue: returnValue,
|
|
57
68
|
valueProperty: "id",
|
|
58
|
-
maxOptions,
|
|
59
|
-
loading
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
69
|
+
maxOptions: maxOptions,
|
|
70
|
+
loading: loading
|
|
71
|
+
}, extraListProps), dropdownFilterOptions));
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
const props = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
/** callback after item gets selected */
|
|
76
|
+
onSelectMenuItem: PropTypes.func.description('callback after item gets selected'),
|
|
77
|
+
|
|
78
|
+
/** Object with custom components for react-select */
|
|
79
|
+
components: PropTypes.shape({}).description('Object with custom components for react-select'),
|
|
80
|
+
|
|
81
|
+
/** search term to filter for */
|
|
82
|
+
searchTerm: PropTypes.string.description('search term to filter for'),
|
|
83
|
+
|
|
84
|
+
/** item options */
|
|
85
|
+
items: PropTypes.array.description('item options'),
|
|
86
|
+
|
|
87
|
+
/** options */
|
|
88
|
+
dropdownFilterOptions: PropTypes.shape({}).description('options'),
|
|
89
|
+
|
|
90
|
+
/** Whether the combo box is has value to return or not */
|
|
91
|
+
returnValue: PropTypes.bool.description('Whether the combo box is has value to return or not'),
|
|
92
|
+
|
|
93
|
+
/** extra props to pass down to combo */
|
|
94
|
+
extraListProps: PropTypes.shape({}).description('extra props to pass down to combo'),
|
|
95
|
+
|
|
96
|
+
/** append search term as item on the list */
|
|
97
|
+
appendTermInList: PropTypes.bool.description('append search term as item on the list'),
|
|
98
|
+
|
|
99
|
+
/** maxoptions for combobox */
|
|
100
|
+
maxOptions: PropTypes.number.description('maxoptions for combobox'),
|
|
101
|
+
|
|
102
|
+
/** loading flag */
|
|
103
|
+
loading: PropTypes.bool.description('loading flag')
|
|
75
104
|
};
|
|
76
|
-
SearchableList.propTypes = props;
|
|
77
105
|
const DSMenuSearchableListWithSchema = describe(SearchableList);
|
|
78
106
|
DSMenuSearchableListWithSchema.propTypes = props;
|
|
79
|
-
|
|
80
|
-
export {
|
|
81
|
-
DSMenuSearchableListWithSchema,
|
|
82
|
-
SearchableList,
|
|
83
|
-
SearchableList_default as default
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=SearchableList.js.map
|
|
107
|
+
|
|
108
|
+
export { DSMenuSearchableListWithSchema, SearchableList as default };
|
|
@@ -1,31 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
10
|
+
import { useMemo, createElement } from 'react';
|
|
11
|
+
import { PropTypes, describe } from 'react-desc';
|
|
12
|
+
import { useCheckableGroup } from '@elliemae/ds-shared/CheckableGroup';
|
|
13
|
+
import SearchableGroup from './SearchableGroup.js';
|
|
14
|
+
import { menuItemFactory } from './menuItemFactory.js';
|
|
15
|
+
import VirtualMenuList from '../VirtualMenuList.js';
|
|
16
|
+
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
+
|
|
19
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
|
+
|
|
8
21
|
const noop = () => null;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
|
|
23
|
+
function SelectionGroup(_ref) {
|
|
24
|
+
let {
|
|
25
|
+
multi = false,
|
|
26
|
+
searchable = false,
|
|
27
|
+
focusOnOpen = false,
|
|
28
|
+
onSelect = noop,
|
|
29
|
+
children,
|
|
30
|
+
items = undefined,
|
|
31
|
+
active = multi ? [] : '',
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
maxOptions = 5
|
|
35
|
+
} = _ref;
|
|
36
|
+
const renderedItems = useMemo(() => items && items.map(item => {
|
|
37
|
+
const Component = menuItemFactory(multi ? 'checkbox' : 'radio');
|
|
38
|
+
return /*#__PURE__*/createElement(Component, _objectSpread(_objectSpread({}, item), {}, {
|
|
25
39
|
key: item.name || item.id || item.key,
|
|
26
|
-
item,
|
|
40
|
+
item: item,
|
|
27
41
|
name: item.id || item.name
|
|
28
|
-
});
|
|
42
|
+
}));
|
|
29
43
|
}), [items]);
|
|
30
44
|
const decoratedGroupChildren = useCheckableGroup({
|
|
31
45
|
children: renderedItems || children,
|
|
@@ -33,41 +47,51 @@ const SelectionGroup = ({
|
|
|
33
47
|
active,
|
|
34
48
|
onCheck: onSelect
|
|
35
49
|
});
|
|
50
|
+
|
|
36
51
|
if (searchable) {
|
|
37
|
-
return
|
|
38
|
-
focusOnOpen,
|
|
39
|
-
height,
|
|
40
|
-
items,
|
|
41
|
-
width
|
|
42
|
-
}, decoratedGroupChildren);
|
|
52
|
+
return /*#__PURE__*/_jsx(SearchableGroup, {
|
|
53
|
+
focusOnOpen: focusOnOpen,
|
|
54
|
+
height: height,
|
|
55
|
+
items: items,
|
|
56
|
+
width: width
|
|
57
|
+
}, void 0, decoratedGroupChildren);
|
|
43
58
|
}
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
|
|
60
|
+
return /*#__PURE__*/_jsx(VirtualMenuList, {
|
|
61
|
+
height: height,
|
|
46
62
|
items: decoratedGroupChildren,
|
|
47
|
-
width,
|
|
63
|
+
width: width,
|
|
48
64
|
amountItemsInWindow: maxOptions
|
|
49
65
|
});
|
|
50
|
-
}
|
|
66
|
+
}
|
|
67
|
+
|
|
51
68
|
const props = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
/** toggle on multi select */
|
|
70
|
+
multi: PropTypes.bool.description('toggle on multi select'),
|
|
71
|
+
|
|
72
|
+
/** toggle on searchable behavior */
|
|
73
|
+
searchable: PropTypes.bool.description('toggle on searchable behavior'),
|
|
74
|
+
|
|
75
|
+
/** toggle to focus component on open */
|
|
76
|
+
focusOnOpen: PropTypes.bool.description('toggle to focus component on open'),
|
|
77
|
+
|
|
78
|
+
/** callback that triggers when select happens */
|
|
79
|
+
onSelect: PropTypes.func.description('callback that triggers when select happens'),
|
|
80
|
+
children: PropTypes.node.description(''),
|
|
81
|
+
|
|
82
|
+
/** selection group items */
|
|
83
|
+
items: PropTypes.array.description('selection group items'),
|
|
84
|
+
|
|
85
|
+
/** array of values for multi and string for single selection */
|
|
86
|
+
active: PropTypes.oneOfType([PropTypes.string, PropTypes.array]).description('array of values for multi and string for single selection'),
|
|
87
|
+
|
|
88
|
+
/** selection group width */
|
|
89
|
+
width: PropTypes.number.description('selection group width'),
|
|
90
|
+
|
|
91
|
+
/** selection group height */
|
|
92
|
+
height: PropTypes.number.description('selection group height')
|
|
61
93
|
};
|
|
62
|
-
SelectionGroup.propTypes = props;
|
|
63
|
-
registerMenuItem("selectiongroup", SelectionGroup);
|
|
64
|
-
registerMenuItem("SelectionGroup", SelectionGroup);
|
|
65
94
|
const DSMenuSelectionGroupWithSchema = describe(SelectionGroup);
|
|
66
95
|
DSMenuSelectionGroupWithSchema.propTypes = props;
|
|
67
|
-
|
|
68
|
-
export {
|
|
69
|
-
DSMenuSelectionGroupWithSchema,
|
|
70
|
-
SelectionGroup,
|
|
71
|
-
SelectionGroup_default as default
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=SelectionGroup.js.map
|
|
96
|
+
|
|
97
|
+
export { DSMenuSelectionGroupWithSchema, SelectionGroup as default };
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { aggregatedClasses } from
|
|
5
|
-
import
|
|
6
|
-
import styled from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const MenuSeparator =
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { PropTypes, describe } from 'react-desc';
|
|
4
|
+
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
5
|
+
import DSSeparator from '@elliemae/ds-separator';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
|
|
8
|
+
var _DSSeparator;
|
|
9
|
+
const blockName = 'menu-separator';
|
|
10
|
+
const Li = /*#__PURE__*/styled.li.withConfig({
|
|
11
|
+
componentId: "sc-aysbq3-0"
|
|
12
|
+
})(["display:flex;align-items:flex-start;flex-direction:column;"]);
|
|
13
|
+
const Title = aggregatedClasses('h5')(blockName, 'title');
|
|
14
|
+
|
|
15
|
+
const MenuSeparator = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
title,
|
|
18
|
+
showSeparator = true
|
|
19
|
+
} = _ref;
|
|
20
|
+
return /*#__PURE__*/_jsx(Li, {}, void 0, showSeparator && (_DSSeparator || (_DSSeparator = /*#__PURE__*/_jsx(DSSeparator, {}))), title && /*#__PURE__*/_jsx(Title, {}, void 0, title));
|
|
21
|
+
};
|
|
22
|
+
|
|
16
23
|
const props = {
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
/** menu separator h5 title */
|
|
25
|
+
title: PropTypes.string.description('menu separator h5 title'),
|
|
26
|
+
|
|
27
|
+
/** toggle separator on and off */
|
|
28
|
+
showSeparator: PropTypes.bool.description('toggle separator on and off')
|
|
19
29
|
};
|
|
20
|
-
MenuSeparator.propTypes = props;
|
|
21
|
-
registerMenuItem("separator", MenuSeparator);
|
|
22
30
|
const DSMenuSeparatorWithSchema = describe(MenuSeparator);
|
|
23
31
|
DSMenuSeparatorWithSchema.propTypes = props;
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
DSMenuSeparatorWithSchema,
|
|
27
|
-
MenuSeparator,
|
|
28
|
-
Separator_default as default
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=Separator.js.map
|
|
32
|
+
|
|
33
|
+
export { DSMenuSeparatorWithSchema, MenuSeparator as default };
|