@elliemae/ds-menu 2.3.0-alpha.9 → 2.3.0-next.3
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 +195 -0
- package/cjs/MenuCombobox.js +56 -0
- package/cjs/MenuContext.js +11 -0
- package/cjs/MenuItems/CheckboxGroup.js +45 -0
- package/cjs/MenuItems/MenuItem.js +203 -0
- package/cjs/MenuItems/MenuItemCheckable.js +119 -0
- package/cjs/MenuItems/MenuItemCheckbox.js +42 -0
- package/cjs/MenuItems/MenuItemRadio.js +41 -0
- package/cjs/MenuItems/RadioGroup.js +42 -0
- package/cjs/MenuItems/SearchableGroup.js +101 -0
- package/cjs/MenuItems/SearchableList.js +117 -0
- package/cjs/MenuItems/SelectionGroup.js +107 -0
- package/cjs/MenuItems/Separator.js +44 -0
- package/cjs/MenuItems/SubMenu.js +203 -0
- package/cjs/MenuItems/menuItemFactory.js +73 -0
- package/cjs/VirtualMenuList.js +48 -0
- package/cjs/index.js +36 -0
- package/cjs/utils/useHeightByAmountOfItems.js +20 -0
- package/esm/Menu.js +180 -0
- package/esm/MenuCombobox.js +48 -0
- package/esm/MenuContext.js +5 -0
- package/esm/MenuItems/CheckboxGroup.js +35 -0
- package/esm/MenuItems/MenuItem.js +191 -0
- package/esm/MenuItems/MenuItemCheckable.js +108 -0
- package/esm/MenuItems/MenuItemCheckbox.js +34 -0
- package/esm/MenuItems/MenuItemRadio.js +32 -0
- package/esm/MenuItems/RadioGroup.js +32 -0
- package/esm/MenuItems/SearchableGroup.js +91 -0
- package/esm/MenuItems/SearchableList.js +108 -0
- package/esm/MenuItems/SelectionGroup.js +97 -0
- package/esm/MenuItems/Separator.js +33 -0
- package/esm/MenuItems/SubMenu.js +190 -0
- package/esm/MenuItems/menuItemFactory.js +64 -0
- package/esm/VirtualMenuList.js +42 -0
- package/esm/index.js +13 -0
- package/{dist/esm → esm}/utils/useHeightByAmountOfItems.js +11 -13
- package/package.json +62 -72
- package/{dist/types → types}/Menu.d.ts +2 -4
- package/{dist/types → types}/MenuCombobox.d.ts +0 -0
- package/types/MenuContext.d.ts +3 -0
- package/{dist/types → types}/MenuItems/CheckboxGroup.d.ts +5 -5
- package/{dist/types → types}/MenuItems/MenuItem.d.ts +5 -5
- package/{dist/types → types}/MenuItems/MenuItemCheckable.d.ts +14 -15
- package/{dist/types → types}/MenuItems/MenuItemCheckbox.d.ts +2 -3
- package/{dist/types → types}/MenuItems/MenuItemRadio.d.ts +5 -5
- package/{dist/types → types}/MenuItems/RadioGroup.d.ts +5 -5
- package/{dist/types → types}/MenuItems/SearchableGroup.d.ts +3 -3
- package/{dist/types → types}/MenuItems/SearchableList.d.ts +16 -16
- package/{dist/types → types}/MenuItems/SelectionGroup.d.ts +16 -16
- package/{dist/types → types}/MenuItems/Separator.d.ts +1 -2
- package/{dist/types → types}/MenuItems/SubMenu.d.ts +18 -18
- package/types/MenuItems/menuItemFactory.d.ts +3 -0
- package/{dist/types → types}/VirtualMenuList.d.ts +1 -3
- package/{dist/types → types}/index.d.ts +2 -3
- package/{dist/types → types}/tests/Menu.test.d.ts +0 -0
- package/{dist/types → types}/tests/MenuItem.test.d.ts +0 -0
- package/types/utils/useHeightByAmountOfItems.d.ts +5 -0
- package/dist/cjs/Menu.js +0 -151
- package/dist/cjs/Menu.js.map +0 -7
- package/dist/cjs/MenuCombobox.js +0 -70
- package/dist/cjs/MenuCombobox.js.map +0 -7
- package/dist/cjs/MenuContext.js +0 -38
- package/dist/cjs/MenuContext.js.map +0 -7
- package/dist/cjs/MenuExports.js +0 -36
- package/dist/cjs/MenuExports.js.map +0 -7
- package/dist/cjs/MenuItems/CheckboxGroup.js +0 -52
- package/dist/cjs/MenuItems/CheckboxGroup.js.map +0 -7
- package/dist/cjs/MenuItems/MenuItem.js +0 -157
- package/dist/cjs/MenuItems/MenuItem.js.map +0 -7
- package/dist/cjs/MenuItems/MenuItemCheckable.js +0 -88
- package/dist/cjs/MenuItems/MenuItemCheckable.js.map +0 -7
- package/dist/cjs/MenuItems/MenuItemCheckbox.js +0 -48
- package/dist/cjs/MenuItems/MenuItemCheckbox.js.map +0 -7
- package/dist/cjs/MenuItems/MenuItemRadio.js +0 -53
- package/dist/cjs/MenuItems/MenuItemRadio.js.map +0 -7
- package/dist/cjs/MenuItems/RadioGroup.js +0 -51
- package/dist/cjs/MenuItems/RadioGroup.js.map +0 -7
- package/dist/cjs/MenuItems/SearchableGroup.js +0 -97
- package/dist/cjs/MenuItems/SearchableGroup.js.map +0 -7
- package/dist/cjs/MenuItems/SearchableList.js +0 -114
- package/dist/cjs/MenuItems/SearchableList.js.map +0 -7
- package/dist/cjs/MenuItems/SelectionGroup.js +0 -102
- package/dist/cjs/MenuItems/SelectionGroup.js.map +0 -7
- package/dist/cjs/MenuItems/Separator.js +0 -59
- package/dist/cjs/MenuItems/Separator.js.map +0 -7
- package/dist/cjs/MenuItems/SubMenu.js +0 -187
- package/dist/cjs/MenuItems/SubMenu.js.map +0 -7
- package/dist/cjs/MenuItems/menuItemFactory.js +0 -41
- package/dist/cjs/MenuItems/menuItemFactory.js.map +0 -7
- package/dist/cjs/MenuItems/renderMenuItems.js +0 -54
- package/dist/cjs/MenuItems/renderMenuItems.js.map +0 -7
- package/dist/cjs/VirtualMenuList.js +0 -78
- package/dist/cjs/VirtualMenuList.js.map +0 -7
- package/dist/cjs/index.js +0 -63
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/utils/useHeightByAmountOfItems.js +0 -49
- package/dist/cjs/utils/useHeightByAmountOfItems.js.map +0 -7
- package/dist/esm/Menu.js +0 -122
- package/dist/esm/Menu.js.map +0 -7
- package/dist/esm/MenuCombobox.js +0 -41
- package/dist/esm/MenuCombobox.js.map +0 -7
- package/dist/esm/MenuContext.js +0 -9
- package/dist/esm/MenuContext.js.map +0 -7
- package/dist/esm/MenuExports.js +0 -7
- package/dist/esm/MenuExports.js.map +0 -7
- package/dist/esm/MenuItems/CheckboxGroup.js +0 -23
- package/dist/esm/MenuItems/CheckboxGroup.js.map +0 -7
- package/dist/esm/MenuItems/MenuItem.js +0 -128
- package/dist/esm/MenuItems/MenuItem.js.map +0 -7
- package/dist/esm/MenuItems/MenuItemCheckable.js +0 -59
- package/dist/esm/MenuItems/MenuItemCheckable.js.map +0 -7
- package/dist/esm/MenuItems/MenuItemCheckbox.js +0 -19
- package/dist/esm/MenuItems/MenuItemCheckbox.js.map +0 -7
- package/dist/esm/MenuItems/MenuItemRadio.js +0 -24
- package/dist/esm/MenuItems/MenuItemRadio.js.map +0 -7
- package/dist/esm/MenuItems/RadioGroup.js +0 -22
- package/dist/esm/MenuItems/RadioGroup.js.map +0 -7
- package/dist/esm/MenuItems/SearchableGroup.js +0 -68
- package/dist/esm/MenuItems/SearchableGroup.js.map +0 -7
- package/dist/esm/MenuItems/SearchableList.js +0 -85
- package/dist/esm/MenuItems/SearchableList.js.map +0 -7
- package/dist/esm/MenuItems/SelectionGroup.js +0 -73
- package/dist/esm/MenuItems/SelectionGroup.js.map +0 -7
- package/dist/esm/MenuItems/Separator.js +0 -30
- package/dist/esm/MenuItems/Separator.js.map +0 -7
- package/dist/esm/MenuItems/SubMenu.js +0 -158
- package/dist/esm/MenuItems/SubMenu.js.map +0 -7
- package/dist/esm/MenuItems/menuItemFactory.js +0 -12
- package/dist/esm/MenuItems/menuItemFactory.js.map +0 -7
- package/dist/esm/MenuItems/renderMenuItems.js +0 -25
- package/dist/esm/MenuItems/renderMenuItems.js.map +0 -7
- package/dist/esm/VirtualMenuList.js +0 -49
- package/dist/esm/VirtualMenuList.js.map +0 -7
- package/dist/esm/index.js +0 -34
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/utils/useHeightByAmountOfItems.js.map +0 -7
- package/dist/types/MenuContext.d.ts +0 -4
- package/dist/types/MenuExports.d.ts +0 -1
- package/dist/types/MenuItems/menuItemFactory.d.ts +0 -2
- package/dist/types/MenuItems/renderMenuItems.d.ts +0 -1
- package/dist/types/utils/useHeightByAmountOfItems.d.ts +0 -7
|
@@ -0,0 +1,108 @@
|
|
|
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 _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
9
|
+
import 'react';
|
|
10
|
+
import { PropTypes, describe } from 'react-desc';
|
|
11
|
+
import { Checkmark } from '@elliemae/ds-icons';
|
|
12
|
+
import { runAll } from '@elliemae/ds-utilities';
|
|
13
|
+
import MenuItem from './MenuItem.js';
|
|
14
|
+
import { jsx } from 'react/jsx-runtime';
|
|
15
|
+
|
|
16
|
+
var _div;
|
|
17
|
+
|
|
18
|
+
const _excluded = ["role", "checked", "name", "checkIcon", "children", "leftAddon", "item"];
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
function useCheckable(_ref) {
|
|
25
|
+
let {
|
|
26
|
+
checked
|
|
27
|
+
} = _ref;
|
|
28
|
+
return {
|
|
29
|
+
checked,
|
|
30
|
+
'aria-checked': checked
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Reuses the same props as the MenuItem
|
|
35
|
+
*
|
|
36
|
+
* @param root0
|
|
37
|
+
* @param root0.role
|
|
38
|
+
* @param root0.checked
|
|
39
|
+
* @param root0.name
|
|
40
|
+
* @param root0.checkIcon
|
|
41
|
+
* @param root0.children
|
|
42
|
+
* @param root0.leftAddon
|
|
43
|
+
* @param root0.item
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function MenuItemCheckable(_ref2) {
|
|
48
|
+
let {
|
|
49
|
+
role = 'menuitemcheckbox',
|
|
50
|
+
checked = false,
|
|
51
|
+
name = '',
|
|
52
|
+
checkIcon = /*#__PURE__*/_jsx(Checkmark, {
|
|
53
|
+
color: ['brand-primary', 600]
|
|
54
|
+
}),
|
|
55
|
+
// eslint-disable-next-line react/prop-types
|
|
56
|
+
children,
|
|
57
|
+
leftAddon,
|
|
58
|
+
item = undefined
|
|
59
|
+
} = _ref2,
|
|
60
|
+
otherProps = _objectWithoutProperties(_ref2, _excluded);
|
|
61
|
+
|
|
62
|
+
const checkableProps = useCheckable({
|
|
63
|
+
checked,
|
|
64
|
+
name
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const handleClick = () => runAll(otherProps.onClick, checkableProps.onClick)({
|
|
68
|
+
target: {
|
|
69
|
+
value: name,
|
|
70
|
+
checked
|
|
71
|
+
}
|
|
72
|
+
}, item);
|
|
73
|
+
|
|
74
|
+
const checkAddon = leftAddon || (checkableProps.checked ? /*#__PURE__*/_jsx("div", {
|
|
75
|
+
className: "checkable-mark"
|
|
76
|
+
}, void 0, checkIcon) : _div || (_div = /*#__PURE__*/_jsx("div", {})));
|
|
77
|
+
return /*#__PURE__*/jsx(MenuItem, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, item), otherProps), checkableProps), {}, {
|
|
78
|
+
customRenderer: item && item.customRenderer ? item.customRenderer : () => {},
|
|
79
|
+
items: otherProps.subItems,
|
|
80
|
+
leftAddon: checkAddon,
|
|
81
|
+
onClick: handleClick,
|
|
82
|
+
role: role
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const props = {
|
|
87
|
+
/** Whether the item is checked or not */
|
|
88
|
+
checked: PropTypes.bool.description('Whether the item is checked or not'),
|
|
89
|
+
|
|
90
|
+
/** A custom item when the item is checked */
|
|
91
|
+
checkIcon: PropTypes.element.description('A custom item when the item is checked'),
|
|
92
|
+
|
|
93
|
+
/** form field name */
|
|
94
|
+
name: PropTypes.string.description('form field name'),
|
|
95
|
+
|
|
96
|
+
/** menu item object props */
|
|
97
|
+
item: PropTypes.object.description('menu item object props'),
|
|
98
|
+
|
|
99
|
+
/** a11y role */
|
|
100
|
+
role: PropTypes.string.description('a11y role'),
|
|
101
|
+
|
|
102
|
+
/** left addon component */
|
|
103
|
+
leftAddon: PropTypes.node.description('left addon component')
|
|
104
|
+
};
|
|
105
|
+
const DSMenuItemCheckeableWithSchema = describe(MenuItemCheckable);
|
|
106
|
+
DSMenuItemCheckeableWithSchema.propTypes = props;
|
|
107
|
+
|
|
108
|
+
export { DSMenuItemCheckeableWithSchema, MenuItemCheckable as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
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 _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
9
|
+
import 'react';
|
|
10
|
+
import { DSCheckbox } from '@elliemae/ds-form';
|
|
11
|
+
import MenuItemCheckable from './MenuItemCheckable.js';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
const _excluded = ["checked"];
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
function MenuItemCheckbox(_ref) {
|
|
21
|
+
let {
|
|
22
|
+
checked
|
|
23
|
+
} = _ref,
|
|
24
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
|
|
26
|
+
return /*#__PURE__*/jsx(MenuItemCheckable, _objectSpread(_objectSpread({}, rest), {}, {
|
|
27
|
+
leftAddon: /*#__PURE__*/_jsx(DSCheckbox, {
|
|
28
|
+
checked: checked
|
|
29
|
+
}),
|
|
30
|
+
role: "menuitemcheckbox"
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { MenuItemCheckbox as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
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 'react';
|
|
8
|
+
import { PropTypes, describe } from 'react-desc';
|
|
9
|
+
import MenuItemCheckable from './MenuItemCheckable.js';
|
|
10
|
+
import { jsx } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
function MenuItemRadio(props) {
|
|
17
|
+
return /*#__PURE__*/jsx(MenuItemCheckable, _objectSpread(_objectSpread({}, props), {}, {
|
|
18
|
+
role: "menuitemradio"
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const props = {
|
|
23
|
+
/** Whether the item is checked or not */
|
|
24
|
+
checked: PropTypes.bool.description('Whether the item is checked or not'),
|
|
25
|
+
|
|
26
|
+
/** A custom item when the item is checked */
|
|
27
|
+
checkIcon: PropTypes.element.description('A custom item when the item is checked')
|
|
28
|
+
};
|
|
29
|
+
const DSMenuItemRadioWithSchema = describe(MenuItemCheckable);
|
|
30
|
+
DSMenuItemRadioWithSchema.propTypes = props;
|
|
31
|
+
|
|
32
|
+
export { DSMenuItemRadioWithSchema, MenuItemRadio as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
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 'react';
|
|
8
|
+
import { PropTypes, describe } from 'react-desc';
|
|
9
|
+
import CheckableGroup from '@elliemae/ds-shared/CheckableGroup';
|
|
10
|
+
import { jsx } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
function RadioGroup(props) {
|
|
17
|
+
return /*#__PURE__*/jsx(CheckableGroup, _objectSpread(_objectSpread({}, props), {}, {
|
|
18
|
+
multi: false
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const props = {
|
|
23
|
+
/* The item selected */
|
|
24
|
+
active: PropTypes.arrayOf(PropTypes.string).description('the item selected'),
|
|
25
|
+
|
|
26
|
+
/* Handler when a user checks an item */
|
|
27
|
+
onCheck: PropTypes.func.description('Handler when a user checks an item')
|
|
28
|
+
};
|
|
29
|
+
const DSMenuRadioGroupWithSchema = describe(RadioGroup);
|
|
30
|
+
DSMenuRadioGroupWithSchema.propTypes = props;
|
|
31
|
+
|
|
32
|
+
export { DSMenuRadioGroupWithSchema, RadioGroup as default };
|
|
@@ -0,0 +1,91 @@
|
|
|
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;
|
|
28
|
+
const searchRef = useRef(null);
|
|
29
|
+
const [searchTerm, setSearchTerm] = useState(searchTermProp);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (searchRef.current) searchRef.current.focus();
|
|
32
|
+
}, []);
|
|
33
|
+
const {
|
|
34
|
+
visible
|
|
35
|
+
} = useContext(MenuContext) || {};
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (focusOnOpen && visible) {
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
if (searchRef.current) searchRef.current.focus();
|
|
40
|
+
}, 0);
|
|
41
|
+
}
|
|
42
|
+
}, [focusOnOpen, visible]);
|
|
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
|
+
|
|
65
|
+
const props = {
|
|
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 */
|
|
73
|
+
noOptionsText: PropTypes.string.description("Text to show when there's no options to show"),
|
|
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')
|
|
86
|
+
};
|
|
87
|
+
const DSMenuSearchableGroupWithSchema = describe(SearchableGroup);
|
|
88
|
+
DSMenuSearchableGroupWithSchema.propTypes = props;
|
|
89
|
+
var SearchableGroup$1 = focusGroupManagerHoc(SearchableGroup);
|
|
90
|
+
|
|
91
|
+
export { DSMenuSearchableGroupWithSchema, SearchableGroup$1 as default };
|
|
@@ -0,0 +1,108 @@
|
|
|
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;
|
|
33
|
+
const [searchTerm, setInputValue] = useState(searchTermProp);
|
|
34
|
+
const handleInputChange = useCallback((value, args) => {
|
|
35
|
+
const action = args ? args.action : null;
|
|
36
|
+
if (action === 'input-blur' || action === 'menu-close') return;
|
|
37
|
+
setInputValue(value);
|
|
38
|
+
}, [searchTerm]);
|
|
39
|
+
const handleFilterByText = useCallback(() => {
|
|
40
|
+
if (searchTerm) onSelectMenuItem(searchTerm);
|
|
41
|
+
}, [searchTerm]);
|
|
42
|
+
const handleKeyDown = useCallback(e => {
|
|
43
|
+
if (e.key === 'ArrowRight') {
|
|
44
|
+
handleFilterByText();
|
|
45
|
+
}
|
|
46
|
+
}, [searchTerm]);
|
|
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({
|
|
52
|
+
autoFocus: true,
|
|
53
|
+
components: _objectSpread({
|
|
54
|
+
DropdownIndicator: null
|
|
55
|
+
}, components),
|
|
56
|
+
customMenuItemOptions: {
|
|
57
|
+
useTruncatedText: true
|
|
58
|
+
},
|
|
59
|
+
inlineMenu: true,
|
|
60
|
+
inputValue: searchTerm,
|
|
61
|
+
menuIsOpen: true,
|
|
62
|
+
onChange: onSelectMenuItem,
|
|
63
|
+
onFilterByInputText: handleFilterByText,
|
|
64
|
+
onInputChange: handleInputChange,
|
|
65
|
+
onKeyDown: handleKeyDown,
|
|
66
|
+
options: options,
|
|
67
|
+
returnValue: returnValue,
|
|
68
|
+
valueProperty: "id",
|
|
69
|
+
maxOptions: maxOptions,
|
|
70
|
+
loading: loading
|
|
71
|
+
}, extraListProps), dropdownFilterOptions));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const props = {
|
|
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')
|
|
104
|
+
};
|
|
105
|
+
const DSMenuSearchableListWithSchema = describe(SearchableList);
|
|
106
|
+
DSMenuSearchableListWithSchema.propTypes = props;
|
|
107
|
+
|
|
108
|
+
export { DSMenuSearchableListWithSchema, SearchableList as default };
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
|
|
21
|
+
const noop = () => null;
|
|
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), {}, {
|
|
39
|
+
key: item.name || item.id || item.key,
|
|
40
|
+
item: item,
|
|
41
|
+
name: item.id || item.name
|
|
42
|
+
}));
|
|
43
|
+
}), [items]);
|
|
44
|
+
const decoratedGroupChildren = useCheckableGroup({
|
|
45
|
+
children: renderedItems || children,
|
|
46
|
+
multi,
|
|
47
|
+
active,
|
|
48
|
+
onCheck: onSelect
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (searchable) {
|
|
52
|
+
return /*#__PURE__*/_jsx(SearchableGroup, {
|
|
53
|
+
focusOnOpen: focusOnOpen,
|
|
54
|
+
height: height,
|
|
55
|
+
items: items,
|
|
56
|
+
width: width
|
|
57
|
+
}, void 0, decoratedGroupChildren);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return /*#__PURE__*/_jsx(VirtualMenuList, {
|
|
61
|
+
height: height,
|
|
62
|
+
items: decoratedGroupChildren,
|
|
63
|
+
width: width,
|
|
64
|
+
amountItemsInWindow: maxOptions
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const props = {
|
|
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')
|
|
93
|
+
};
|
|
94
|
+
const DSMenuSelectionGroupWithSchema = describe(SelectionGroup);
|
|
95
|
+
DSMenuSelectionGroupWithSchema.propTypes = props;
|
|
96
|
+
|
|
97
|
+
export { DSMenuSelectionGroupWithSchema, SelectionGroup as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
|
|
23
|
+
const props = {
|
|
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')
|
|
29
|
+
};
|
|
30
|
+
const DSMenuSeparatorWithSchema = describe(MenuSeparator);
|
|
31
|
+
DSMenuSeparatorWithSchema.propTypes = props;
|
|
32
|
+
|
|
33
|
+
export { DSMenuSeparatorWithSchema, MenuSeparator as default };
|