@elliemae/ds-menu 1.57.1-rc.0 → 2.0.0-alpha.11
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 +176 -39
- package/cjs/MenuCombobox.js +33 -80
- package/cjs/MenuContext.js +1 -2
- package/cjs/MenuItems/CheckboxGroup.js +12 -10
- package/cjs/MenuItems/MenuItem.js +186 -36
- package/cjs/MenuItems/MenuItemCheckable.js +109 -35
- package/cjs/MenuItems/MenuItemCheckbox.js +35 -34
- package/cjs/MenuItems/MenuItemRadio.js +31 -35
- package/cjs/MenuItems/RadioGroup.js +12 -10
- package/cjs/MenuItems/SearchableGroup.js +44 -59
- package/cjs/MenuItems/SearchableList.js +35 -56
- package/cjs/MenuItems/SelectionGroup.js +93 -36
- package/cjs/MenuItems/Separator.js +14 -16
- package/cjs/MenuItems/SubMenu.js +197 -36
- package/cjs/MenuItems/menuItemFactory.js +56 -36
- package/cjs/VirtualMenuList.js +23 -26
- package/cjs/index.js +27 -48
- package/cjs/utils/useHeightByAmountOfItems.js +8 -10
- package/esm/Menu.js +165 -31
- package/esm/MenuCombobox.js +28 -74
- package/esm/MenuContext.js +0 -1
- package/esm/MenuItems/CheckboxGroup.js +10 -7
- package/esm/MenuItems/MenuItem.js +178 -31
- package/esm/MenuItems/MenuItemCheckable.js +101 -30
- package/esm/MenuItems/MenuItemCheckbox.js +28 -30
- package/esm/MenuItems/MenuItemRadio.js +26 -30
- package/esm/MenuItems/RadioGroup.js +10 -7
- package/esm/MenuItems/SearchableGroup.js +42 -56
- package/esm/MenuItems/SearchableList.js +32 -51
- package/esm/MenuItems/SelectionGroup.js +87 -31
- package/esm/MenuItems/Separator.js +12 -14
- package/esm/MenuItems/SubMenu.js +186 -31
- package/esm/MenuItems/menuItemFactory.js +51 -31
- package/esm/VirtualMenuList.js +21 -24
- package/esm/index.js +7 -28
- package/esm/utils/useHeightByAmountOfItems.js +8 -10
- package/package.json +106 -21
- package/types/Menu.d.ts +5 -0
- package/types/MenuCombobox.d.ts +28 -0
- package/types/MenuContext.d.ts +3 -0
- package/types/MenuItems/CheckboxGroup.d.ts +12 -0
- package/types/MenuItems/MenuItem.d.ts +29 -0
- package/types/MenuItems/MenuItemCheckable.d.ts +42 -0
- package/types/MenuItems/MenuItemCheckbox.d.ts +6 -0
- package/types/MenuItems/MenuItemRadio.d.ts +13 -0
- package/types/MenuItems/RadioGroup.d.ts +11 -0
- package/types/MenuItems/SearchableGroup.d.ts +4 -0
- package/types/MenuItems/SearchableList.d.ts +40 -0
- package/types/MenuItems/SelectionGroup.d.ts +36 -0
- package/types/MenuItems/Separator.d.ts +16 -0
- package/types/MenuItems/SubMenu.d.ts +44 -0
- package/types/MenuItems/menuItemFactory.d.ts +3 -0
- package/types/VirtualMenuList.d.ts +8 -0
- package/types/index.d.ts +13 -0
- package/types/tests/Menu.test.d.ts +1 -0
- package/types/tests/MenuItem.test.d.ts +1 -0
- package/types/utils/useHeightByAmountOfItems.d.ts +5 -0
- package/Menu/package.json +0 -10
- package/MenuCombobox/package.json +0 -10
- package/MenuContext/package.json +0 -10
- package/MenuItems/CheckboxGroup/package.json +0 -10
- package/MenuItems/MenuItem/package.json +0 -10
- package/MenuItems/MenuItemCheckable/package.json +0 -10
- package/MenuItems/MenuItemCheckbox/package.json +0 -10
- package/MenuItems/MenuItemRadio/package.json +0 -10
- package/MenuItems/RadioGroup/package.json +0 -10
- package/MenuItems/SearchableGroup/package.json +0 -10
- package/MenuItems/SearchableList/package.json +0 -10
- package/MenuItems/SelectionGroup/package.json +0 -10
- package/MenuItems/Separator/package.json +0 -10
- package/MenuItems/SubMenu/package.json +0 -10
- package/MenuItems/menuItemFactory/package.json +0 -10
- package/VirtualMenuList/package.json +0 -10
- package/cjs/Menu.js.map +0 -1
- package/cjs/MenuCombobox.js.map +0 -1
- package/cjs/MenuContext.js.map +0 -1
- package/cjs/MenuItems/CheckboxGroup.js.map +0 -1
- package/cjs/MenuItems/MenuItem.js.map +0 -1
- package/cjs/MenuItems/MenuItemCheckable.js.map +0 -1
- package/cjs/MenuItems/MenuItemCheckbox.js.map +0 -1
- package/cjs/MenuItems/MenuItemRadio.js.map +0 -1
- package/cjs/MenuItems/RadioGroup.js.map +0 -1
- package/cjs/MenuItems/SearchableGroup.js.map +0 -1
- package/cjs/MenuItems/SearchableList.js.map +0 -1
- package/cjs/MenuItems/SelectionGroup.js.map +0 -1
- package/cjs/MenuItems/Separator.js.map +0 -1
- package/cjs/MenuItems/SubMenu.js.map +0 -1
- package/cjs/MenuItems/menuItemFactory.js.map +0 -1
- package/cjs/SubMenu-22be0a18.js +0 -806
- package/cjs/SubMenu-22be0a18.js.map +0 -1
- package/cjs/VirtualMenuList.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/utils/useHeightByAmountOfItems.js.map +0 -1
- package/esm/Menu.js.map +0 -1
- package/esm/MenuCombobox.js.map +0 -1
- package/esm/MenuContext.js.map +0 -1
- package/esm/MenuItems/CheckboxGroup.js.map +0 -1
- package/esm/MenuItems/MenuItem.js.map +0 -1
- package/esm/MenuItems/MenuItemCheckable.js.map +0 -1
- package/esm/MenuItems/MenuItemCheckbox.js.map +0 -1
- package/esm/MenuItems/MenuItemRadio.js.map +0 -1
- package/esm/MenuItems/RadioGroup.js.map +0 -1
- package/esm/MenuItems/SearchableGroup.js.map +0 -1
- package/esm/MenuItems/SearchableList.js.map +0 -1
- package/esm/MenuItems/SelectionGroup.js.map +0 -1
- package/esm/MenuItems/Separator.js.map +0 -1
- package/esm/MenuItems/SubMenu.js.map +0 -1
- package/esm/MenuItems/menuItemFactory.js.map +0 -1
- package/esm/SubMenu-a25e69ec.js +0 -778
- package/esm/SubMenu-a25e69ec.js.map +0 -1
- package/esm/VirtualMenuList.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/utils/useHeightByAmountOfItems.js.map +0 -1
- package/utils/useHeightByAmountOfItems/package.json +0 -10
|
@@ -1,31 +1,178 @@
|
|
|
1
|
-
import '@babel/runtime/helpers/esm/
|
|
2
|
-
import '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
3
|
-
import '@babel/runtime/helpers/esm/
|
|
4
|
-
import '
|
|
5
|
-
import 'react
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
8
|
-
import '@elliemae/ds-
|
|
9
|
-
import '@elliemae/ds-
|
|
10
|
-
import '@elliemae/ds-
|
|
11
|
-
|
|
12
|
-
import '
|
|
13
|
-
import '
|
|
14
|
-
import '
|
|
15
|
-
import '
|
|
16
|
-
import '
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
3
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import { useContext, useRef, useMemo } from 'react';
|
|
6
|
+
import { PropTypes, describe } from 'react-desc';
|
|
7
|
+
import { omit } from 'lodash';
|
|
8
|
+
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
9
|
+
import { mergeRefs } from '@elliemae/ds-utilities/system';
|
|
10
|
+
import { useFocusGroupItem } from '@elliemae/ds-shared/FocusGroup';
|
|
11
|
+
import { runAll } from '@elliemae/ds-utilities/utils';
|
|
12
|
+
import DSTruncatedTooltipText from '@elliemae/ds-truncated-tooltip-text';
|
|
13
|
+
import { renderMenuItems } from './menuItemFactory.js';
|
|
14
|
+
import SubMenu from './SubMenu.js';
|
|
15
|
+
import MenuContext from '../MenuContext.js';
|
|
16
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
17
|
+
|
|
18
|
+
const _excluded = ["innerRef", "as", "role", "leftAddon", "rightAddon", "disabledAddonInactive", "label", "children", "tabIndex", "onKeyDown", "fixedItem", "noAddon", "disabled", "customRenderer", "maxOption", "closeMenu", "style"];
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
+
|
|
24
|
+
const noop = () => null;
|
|
25
|
+
|
|
26
|
+
const blockName = 'menu-item';
|
|
27
|
+
const Content = aggregatedClasses('div')(blockName, 'content');
|
|
28
|
+
const Addon = aggregatedClasses('div')(blockName, 'addon', ({
|
|
29
|
+
empty,
|
|
30
|
+
fixedItem
|
|
31
|
+
}) => ({
|
|
32
|
+
empty,
|
|
33
|
+
fixedItem
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
const renderAddon = (addon, fixedItem, addonId) => /*#__PURE__*/_jsx(Addon, {
|
|
37
|
+
classProps: {
|
|
38
|
+
fixedItem
|
|
39
|
+
}
|
|
40
|
+
}, addonId, addon);
|
|
41
|
+
|
|
42
|
+
const renderAddons = (addons, fixedItem) => Array.isArray(addons) ? addons.map(renderAddon) : renderAddon(addons, fixedItem);
|
|
43
|
+
|
|
44
|
+
const Wrapper = aggregatedClasses('li')(blockName, null, ({
|
|
45
|
+
disabled,
|
|
46
|
+
disabledAddonInactive,
|
|
47
|
+
customRenderer,
|
|
48
|
+
fixedItem,
|
|
49
|
+
type
|
|
50
|
+
}) => ({
|
|
51
|
+
disabled,
|
|
52
|
+
disabledAddonInactive,
|
|
53
|
+
customRenderer,
|
|
54
|
+
fixedItem,
|
|
55
|
+
["menu-type-".concat(type)]: type
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
const calculateSize = (length = 0) => {
|
|
59
|
+
if (length > 45) return 45 * 7;
|
|
60
|
+
return length * 7;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
function MenuItem(props) {
|
|
64
|
+
const {
|
|
65
|
+
innerRef,
|
|
66
|
+
as = 'li',
|
|
67
|
+
role = 'menuitem',
|
|
68
|
+
leftAddon = null,
|
|
69
|
+
rightAddon = undefined,
|
|
70
|
+
disabledAddonInactive = undefined,
|
|
71
|
+
label = undefined,
|
|
72
|
+
children,
|
|
73
|
+
tabIndex = -1,
|
|
74
|
+
onKeyDown = noop,
|
|
75
|
+
fixedItem = false,
|
|
76
|
+
noAddon,
|
|
77
|
+
disabled = false,
|
|
78
|
+
customRenderer,
|
|
79
|
+
maxOption,
|
|
80
|
+
closeMenu,
|
|
81
|
+
style
|
|
82
|
+
} = props,
|
|
83
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
84
|
+
|
|
85
|
+
const menuCxt = useContext(MenuContext);
|
|
86
|
+
const ref = useRef(null);
|
|
87
|
+
useFocusGroupItem(ref);
|
|
88
|
+
|
|
89
|
+
if (otherProps.subItems) {
|
|
90
|
+
return /*#__PURE__*/jsx(SubMenu, _objectSpread(_objectSpread({}, props), {}, {
|
|
91
|
+
closeMenu: menuCxt.closeMenu,
|
|
92
|
+
children: renderMenuItems(otherProps.subItems)
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const wrapperProps = useMemo(() => omit(otherProps, ['icon']), [otherProps]);
|
|
97
|
+
|
|
98
|
+
const onClick = (...args) => {
|
|
99
|
+
if (wrapperProps.onClick) wrapperProps.onClick(...args);
|
|
100
|
+
|
|
101
|
+
if (wrapperProps.closeOnClick && menuCxt.closeMenu) {
|
|
102
|
+
menuCxt.closeMenu(...args);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return /*#__PURE__*/jsxs(Wrapper, _objectSpread(_objectSpread({
|
|
107
|
+
as: as,
|
|
108
|
+
classProps: {
|
|
109
|
+
disabled,
|
|
110
|
+
disabledAddonInactive,
|
|
111
|
+
customRenderer,
|
|
112
|
+
fixedItem,
|
|
113
|
+
type: otherProps.type
|
|
114
|
+
},
|
|
115
|
+
id: otherProps.id,
|
|
116
|
+
innerRef: otherProps.type !== 'disabled' ? mergeRefs(innerRef, ref) : innerRef,
|
|
117
|
+
onKeyDown: !fixedItem && runAll(e => {
|
|
118
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
e.target.dispatchEvent(new MouseEvent('click', {
|
|
121
|
+
view: window,
|
|
122
|
+
bubbles: true,
|
|
123
|
+
cancelable: false
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
}, onKeyDown),
|
|
127
|
+
role: role,
|
|
128
|
+
style: style,
|
|
129
|
+
tabIndex: tabIndex
|
|
130
|
+
}, wrapperProps), {}, {
|
|
131
|
+
onClick: onClick,
|
|
132
|
+
children: [!noAddon && renderAddons(leftAddon, fixedItem), label && /*#__PURE__*/_jsx(Content, {
|
|
133
|
+
style: maxOption > 0 ? {
|
|
134
|
+
width: "".concat(calculateSize(maxOption), "px"),
|
|
135
|
+
maxWidth: "".concat(calculateSize(maxOption), "px")
|
|
136
|
+
} : undefined
|
|
137
|
+
}, void 0, /*#__PURE__*/_jsx(DSTruncatedTooltipText, {
|
|
138
|
+
value: label
|
|
139
|
+
})), customRenderer, rightAddon && renderAddons(rightAddon), children]
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const props = {
|
|
144
|
+
/** Renders the MenuItem with a specific html element */
|
|
145
|
+
as: PropTypes.element.description('Renders the MenuItem with a specific html element'),
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* reference to the component
|
|
149
|
+
*/
|
|
150
|
+
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
151
|
+
current: PropTypes.any
|
|
152
|
+
})]).description('reference to the component'),
|
|
153
|
+
|
|
154
|
+
/** Renders the passed element to the left */
|
|
155
|
+
leftAddon: PropTypes.element.description('Renders the passed element to the left'),
|
|
156
|
+
|
|
157
|
+
/** Renders the passed element to the right */
|
|
158
|
+
rightAddon: PropTypes.element.description('Renders the passed element to the right'),
|
|
159
|
+
|
|
160
|
+
/** Label for the menu item */
|
|
161
|
+
label: PropTypes.string.description('Label for the menu item'),
|
|
162
|
+
|
|
163
|
+
/** style object for menu item wrapper */
|
|
164
|
+
style: PropTypes.object.description('style object for menu item wrapper'),
|
|
165
|
+
|
|
166
|
+
/** disable menu item */
|
|
167
|
+
disabled: PropTypes.bool.description('disable menu item'),
|
|
168
|
+
|
|
169
|
+
/** HTML tabindex to manage focus order */
|
|
170
|
+
tabindex: PropTypes.number.description('HTML tabindex to manage focus order'),
|
|
171
|
+
|
|
172
|
+
/** a11y role */
|
|
173
|
+
role: PropTypes.string.description('a11y role')
|
|
174
|
+
};
|
|
175
|
+
const DSMenuItemWithSchema = describe(MenuItem);
|
|
176
|
+
DSMenuItemWithSchema.propTypes = props;
|
|
177
|
+
|
|
178
|
+
export { DSMenuItemWithSchema, MenuItem as default };
|
|
@@ -1,31 +1,102 @@
|
|
|
1
|
-
import '@babel/runtime/helpers/esm/
|
|
2
|
-
import '@babel/runtime/helpers/esm/
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
3
4
|
import 'react';
|
|
4
|
-
import 'react-desc';
|
|
5
|
-
import '@elliemae/ds-icons';
|
|
6
|
-
import '@elliemae/ds-utilities';
|
|
7
|
-
|
|
8
|
-
import '
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
5
|
+
import { PropTypes, describe } from 'react-desc';
|
|
6
|
+
import Checkmark from '@elliemae/ds-icons/Checkmark';
|
|
7
|
+
import { runAll } from '@elliemae/ds-utilities/utils';
|
|
8
|
+
import MenuItem from './MenuItem.js';
|
|
9
|
+
import { jsx } from 'react/jsx-runtime';
|
|
10
|
+
|
|
11
|
+
var _div;
|
|
12
|
+
|
|
13
|
+
const _excluded = ["role", "checked", "name", "checkIcon", "children", "leftAddon", "item"];
|
|
14
|
+
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
+
|
|
17
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
18
|
+
|
|
19
|
+
function useCheckable({
|
|
20
|
+
checked
|
|
21
|
+
}) {
|
|
22
|
+
return {
|
|
23
|
+
checked,
|
|
24
|
+
'aria-checked': checked
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Reuses the same props as the MenuItem
|
|
29
|
+
*
|
|
30
|
+
* @param root0
|
|
31
|
+
* @param root0.role
|
|
32
|
+
* @param root0.checked
|
|
33
|
+
* @param root0.name
|
|
34
|
+
* @param root0.checkIcon
|
|
35
|
+
* @param root0.children
|
|
36
|
+
* @param root0.leftAddon
|
|
37
|
+
* @param root0.item
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
function MenuItemCheckable(_ref) {
|
|
42
|
+
let {
|
|
43
|
+
role = 'menuitemcheckbox',
|
|
44
|
+
checked = false,
|
|
45
|
+
name = '',
|
|
46
|
+
checkIcon = /*#__PURE__*/_jsx(Checkmark, {
|
|
47
|
+
color: ['brand-primary', 600]
|
|
48
|
+
}),
|
|
49
|
+
// eslint-disable-next-line react/prop-types
|
|
50
|
+
children,
|
|
51
|
+
leftAddon,
|
|
52
|
+
item = undefined
|
|
53
|
+
} = _ref,
|
|
54
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
55
|
+
|
|
56
|
+
const checkableProps = useCheckable({
|
|
57
|
+
checked,
|
|
58
|
+
name
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const handleClick = () => runAll(otherProps.onClick, checkableProps.onClick)({
|
|
62
|
+
target: {
|
|
63
|
+
value: name,
|
|
64
|
+
checked
|
|
65
|
+
}
|
|
66
|
+
}, item);
|
|
67
|
+
|
|
68
|
+
const checkAddon = leftAddon || (checkableProps.checked ? /*#__PURE__*/_jsx("div", {
|
|
69
|
+
className: "checkable-mark"
|
|
70
|
+
}, void 0, checkIcon) : _div || (_div = /*#__PURE__*/_jsx("div", {})));
|
|
71
|
+
return /*#__PURE__*/jsx(MenuItem, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, item), otherProps), checkableProps), {}, {
|
|
72
|
+
customRenderer: item && item.customRenderer ? item.customRenderer : () => {},
|
|
73
|
+
items: otherProps.subItems,
|
|
74
|
+
leftAddon: checkAddon,
|
|
75
|
+
onClick: handleClick,
|
|
76
|
+
role: role
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const props = {
|
|
81
|
+
/** Whether the item is checked or not */
|
|
82
|
+
checked: PropTypes.bool.description('Whether the item is checked or not'),
|
|
83
|
+
|
|
84
|
+
/** A custom item when the item is checked */
|
|
85
|
+
checkIcon: PropTypes.element.description('A custom item when the item is checked'),
|
|
86
|
+
|
|
87
|
+
/** form field name */
|
|
88
|
+
name: PropTypes.string.description('form field name'),
|
|
89
|
+
|
|
90
|
+
/** menu item object props */
|
|
91
|
+
item: PropTypes.object.description('menu item object props'),
|
|
92
|
+
|
|
93
|
+
/** a11y role */
|
|
94
|
+
role: PropTypes.string.description('a11y role'),
|
|
95
|
+
|
|
96
|
+
/** left addon component */
|
|
97
|
+
leftAddon: PropTypes.node.description('left addon component')
|
|
98
|
+
};
|
|
99
|
+
const DSMenuItemCheckeableWithSchema = describe(MenuItemCheckable);
|
|
100
|
+
DSMenuItemCheckeableWithSchema.propTypes = props;
|
|
101
|
+
|
|
102
|
+
export { DSMenuItemCheckeableWithSchema, MenuItemCheckable as default };
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import '@babel/runtime/helpers/esm/
|
|
2
|
-
import '@babel/runtime/helpers/esm/
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
3
4
|
import 'react';
|
|
4
|
-
import '@elliemae/ds-form';
|
|
5
|
-
|
|
6
|
-
import '
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
import './CheckboxGroup.js';
|
|
30
|
-
import './RadioGroup.js';
|
|
31
|
-
//# sourceMappingURL=MenuItemCheckbox.js.map
|
|
5
|
+
import DSCheckbox from '@elliemae/ds-form/Checkbox';
|
|
6
|
+
import MenuItemCheckable from './MenuItemCheckable.js';
|
|
7
|
+
import { jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
const _excluded = ["checked"];
|
|
10
|
+
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
|
+
|
|
15
|
+
function MenuItemCheckbox(_ref) {
|
|
16
|
+
let {
|
|
17
|
+
checked
|
|
18
|
+
} = _ref,
|
|
19
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
20
|
+
|
|
21
|
+
return /*#__PURE__*/jsx(MenuItemCheckable, _objectSpread(_objectSpread({}, rest), {}, {
|
|
22
|
+
leftAddon: /*#__PURE__*/_jsx(DSCheckbox, {
|
|
23
|
+
checked: checked
|
|
24
|
+
}),
|
|
25
|
+
role: "menuitemcheckbox"
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { MenuItemCheckbox as default };
|
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
import '@babel/runtime/helpers/esm/
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
2
|
import 'react';
|
|
3
|
-
import 'react-desc';
|
|
4
|
-
|
|
5
|
-
import '
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
import '@elliemae/ds-form';
|
|
29
|
-
import './CheckboxGroup.js';
|
|
30
|
-
import './RadioGroup.js';
|
|
31
|
-
//# sourceMappingURL=MenuItemRadio.js.map
|
|
3
|
+
import { PropTypes, describe } from 'react-desc';
|
|
4
|
+
import MenuItemCheckable from './MenuItemCheckable.js';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
+
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
10
|
+
|
|
11
|
+
function MenuItemRadio(props) {
|
|
12
|
+
return /*#__PURE__*/jsx(MenuItemCheckable, _objectSpread(_objectSpread({}, props), {}, {
|
|
13
|
+
role: "menuitemradio"
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const props = {
|
|
18
|
+
/** Whether the item is checked or not */
|
|
19
|
+
checked: PropTypes.bool.description('Whether the item is checked or not'),
|
|
20
|
+
|
|
21
|
+
/** A custom item when the item is checked */
|
|
22
|
+
checkIcon: PropTypes.element.description('A custom item when the item is checked')
|
|
23
|
+
};
|
|
24
|
+
const DSMenuItemRadioWithSchema = describe(MenuItemCheckable);
|
|
25
|
+
DSMenuItemRadioWithSchema.propTypes = props;
|
|
26
|
+
|
|
27
|
+
export { DSMenuItemRadioWithSchema, MenuItemRadio as default };
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import 'react';
|
|
3
3
|
import { PropTypes, describe } from 'react-desc';
|
|
4
4
|
import CheckableGroup from '@elliemae/ds-shared/CheckableGroup';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
+
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
5
10
|
|
|
6
11
|
function RadioGroup(props) {
|
|
7
|
-
return /*#__PURE__*/
|
|
12
|
+
return /*#__PURE__*/jsx(CheckableGroup, _objectSpread(_objectSpread({}, props), {}, {
|
|
8
13
|
multi: false
|
|
9
14
|
}));
|
|
10
15
|
}
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
const props = {
|
|
13
18
|
/* The item selected */
|
|
14
19
|
active: PropTypes.arrayOf(PropTypes.string).description('the item selected'),
|
|
15
20
|
|
|
16
21
|
/* Handler when a user checks an item */
|
|
17
22
|
onCheck: PropTypes.func.description('Handler when a user checks an item')
|
|
18
23
|
};
|
|
19
|
-
|
|
20
|
-
var DSMenuRadioGroupWithSchema = describe(RadioGroup);
|
|
24
|
+
const DSMenuRadioGroupWithSchema = describe(RadioGroup);
|
|
21
25
|
DSMenuRadioGroupWithSchema.propTypes = props;
|
|
22
26
|
|
|
23
27
|
export { DSMenuRadioGroupWithSchema, RadioGroup as default };
|
|
24
|
-
//# sourceMappingURL=RadioGroup.js.map
|
|
@@ -1,73 +1,61 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
+
import { useRef, useState, useEffect, useContext, useMemo } from 'react';
|
|
3
4
|
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
4
5
|
import { focusGroupManagerHoc } from '@elliemae/ds-shared/FocusGroup';
|
|
5
6
|
import DSSearchBox from '@elliemae/ds-form/SearchBox';
|
|
6
7
|
import { PropTypes, describe } from 'react-desc';
|
|
7
8
|
import VirtualMenuList from '../VirtualMenuList.js';
|
|
8
9
|
import MenuContext from '../MenuContext.js';
|
|
9
|
-
import 'react-
|
|
10
|
-
import '../utils/useHeightByAmountOfItems.js';
|
|
10
|
+
import { jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const SearchBoxWrapper = aggregatedClasses('div')('menu-search-group', 'search-wrapper');
|
|
13
|
+
const NoOptionsWrapper = aggregatedClasses('div')('menu-search-group', 'no-options');
|
|
14
14
|
|
|
15
|
-
function SearchableGroup(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var searchRef = useRef(null);
|
|
28
|
-
|
|
29
|
-
var _useState = useState(searchTermProp),
|
|
30
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
-
searchTerm = _useState2[0],
|
|
32
|
-
setSearchTerm = _useState2[1];
|
|
33
|
-
|
|
34
|
-
useEffect(function () {
|
|
15
|
+
function SearchableGroup({
|
|
16
|
+
children,
|
|
17
|
+
amountItemsInWindow = 5,
|
|
18
|
+
searchTerm: searchTermProp = '',
|
|
19
|
+
noOptionsText = 'No options',
|
|
20
|
+
height,
|
|
21
|
+
width,
|
|
22
|
+
focusOnOpen = false
|
|
23
|
+
}) {
|
|
24
|
+
const searchRef = useRef(null);
|
|
25
|
+
const [searchTerm, setSearchTerm] = useState(searchTermProp);
|
|
26
|
+
useEffect(() => {
|
|
35
27
|
if (searchRef.current) searchRef.current.focus();
|
|
36
28
|
}, []);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
useEffect(function () {
|
|
29
|
+
const {
|
|
30
|
+
visible
|
|
31
|
+
} = useContext(MenuContext) || {};
|
|
32
|
+
useEffect(() => {
|
|
42
33
|
if (focusOnOpen && visible) {
|
|
43
|
-
setTimeout(
|
|
34
|
+
setTimeout(() => {
|
|
44
35
|
if (searchRef.current) searchRef.current.focus();
|
|
45
36
|
}, 0);
|
|
46
37
|
}
|
|
47
38
|
}, [focusOnOpen, visible]);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
items: filteredChildren,
|
|
66
|
-
width: width
|
|
67
|
-
}));
|
|
39
|
+
const filteredChildren = useMemo(() => children.filter(child => !searchTerm || child.props.label.toLowerCase().startsWith(searchTerm.toLowerCase())), [children, searchTerm]);
|
|
40
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
41
|
+
children: [/*#__PURE__*/_jsx(SearchBoxWrapper, {}, void 0, /*#__PURE__*/_jsx(DSSearchBox, {
|
|
42
|
+
innerRef: searchRef,
|
|
43
|
+
onSearch: ({
|
|
44
|
+
value
|
|
45
|
+
}) => setSearchTerm(value),
|
|
46
|
+
searchOnEnter: false,
|
|
47
|
+
showIcon: false,
|
|
48
|
+
value: searchTerm
|
|
49
|
+
})), !filteredChildren.length && /*#__PURE__*/_jsx(NoOptionsWrapper, {}, void 0, noOptionsText), /*#__PURE__*/_jsx(VirtualMenuList, {
|
|
50
|
+
amountItemsInWindow: amountItemsInWindow,
|
|
51
|
+
height: height,
|
|
52
|
+
items: filteredChildren,
|
|
53
|
+
width: width
|
|
54
|
+
})]
|
|
55
|
+
});
|
|
68
56
|
}
|
|
69
57
|
|
|
70
|
-
|
|
58
|
+
const props = {
|
|
71
59
|
/** The amount of items that are going to be rendered in the group */
|
|
72
60
|
amountItemsInWindow: PropTypes.number.description('The amount of items that are going to be rendered in the group'),
|
|
73
61
|
|
|
@@ -89,10 +77,8 @@ var props = {
|
|
|
89
77
|
/** weather to focus on searchable group on open */
|
|
90
78
|
focusOnOpen: PropTypes.bool.description('weather to focus on searchable group on open')
|
|
91
79
|
};
|
|
92
|
-
|
|
93
|
-
var DSMenuSearchableGroupWithSchema = describe(SearchableGroup);
|
|
80
|
+
const DSMenuSearchableGroupWithSchema = describe(SearchableGroup);
|
|
94
81
|
DSMenuSearchableGroupWithSchema.propTypes = props;
|
|
95
82
|
var SearchableGroup$1 = focusGroupManagerHoc(SearchableGroup);
|
|
96
83
|
|
|
97
84
|
export { DSMenuSearchableGroupWithSchema, SearchableGroup$1 as default };
|
|
98
|
-
//# sourceMappingURL=SearchableGroup.js.map
|