@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
package/esm/MenuItems/SubMenu.js
CHANGED
|
@@ -1,35 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
+
import { useRef, useState, useCallback } from 'react';
|
|
10
|
+
import { PropTypes, describe } from 'react-desc';
|
|
11
|
+
import { MoreOptionsVert, ChevronSmallRight } from '@elliemae/ds-icons';
|
|
12
|
+
import { useFocusGroupItem } from '@elliemae/ds-shared/FocusGroup';
|
|
13
|
+
import { useHiddenController } from '@elliemae/ds-hidden';
|
|
14
|
+
import DSButton, { BUTTON_VARIANT } from '@elliemae/ds-button';
|
|
15
|
+
import DSPopper, { interactions } from '@elliemae/ds-popper';
|
|
16
|
+
import styled from 'styled-components';
|
|
17
|
+
import { Menu } from '../Menu.js';
|
|
18
|
+
import MenuItem from './MenuItem.js';
|
|
19
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
20
|
+
|
|
21
|
+
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; }
|
|
22
|
+
|
|
23
|
+
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; }
|
|
24
|
+
const ChevronRightComp = /*#__PURE__*/styled.div.withConfig({
|
|
25
|
+
componentId: "sc-1qhp1z-0"
|
|
26
|
+
})(["display:flex;justify-content:center;align-items:center;width:28px;"]);
|
|
27
|
+
|
|
28
|
+
function SubMenu(_ref) {
|
|
29
|
+
let {
|
|
30
|
+
noAddon,
|
|
31
|
+
leftAddon = undefined,
|
|
32
|
+
label = undefined,
|
|
33
|
+
interactionType = 'hover',
|
|
34
|
+
children: subitems,
|
|
35
|
+
rightAddonType,
|
|
36
|
+
disabledAddonInactive,
|
|
37
|
+
checkableProps = {},
|
|
38
|
+
customRenderer,
|
|
39
|
+
onClick,
|
|
40
|
+
closeMenu,
|
|
41
|
+
id
|
|
42
|
+
} = _ref;
|
|
33
43
|
const itemRef = useRef(null);
|
|
34
44
|
const focusOnOpen = useRef(false);
|
|
35
45
|
const [isAddonHovered, setIsAddonHovered] = useState(false);
|
|
@@ -37,121 +47,144 @@ const SubMenu = ({
|
|
|
37
47
|
visible = false,
|
|
38
48
|
onShow,
|
|
39
49
|
onHide
|
|
40
|
-
} = useHiddenController(
|
|
41
|
-
interaction:
|
|
50
|
+
} = useHiddenController(undefined, {
|
|
51
|
+
interaction: 'click'
|
|
42
52
|
});
|
|
43
|
-
const interaction = rightAddonType ===
|
|
44
|
-
const {
|
|
45
|
-
|
|
53
|
+
const interaction = rightAddonType === 'elipsis' ? 'click' : 'hover';
|
|
54
|
+
const {
|
|
55
|
+
focusItemByNode
|
|
56
|
+
} = useFocusGroupItem(); // todo: create a menu state to handle all related menu things
|
|
57
|
+
|
|
58
|
+
const handleShowSubItemsWithMouse = e => {
|
|
46
59
|
e.stopPropagation();
|
|
47
60
|
onShow();
|
|
48
61
|
focusOnOpen.current = true;
|
|
49
62
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
|
|
64
|
+
const handleShowWithMouse = e => {
|
|
65
|
+
if (onClick) onClick(e);
|
|
53
66
|
};
|
|
67
|
+
|
|
54
68
|
const handleShowWithMouseHover = () => {
|
|
55
69
|
setIsAddonHovered(true);
|
|
56
70
|
onShow();
|
|
57
71
|
focusOnOpen.current = false;
|
|
58
72
|
};
|
|
73
|
+
|
|
59
74
|
const handleShowWithKeyboard = () => {
|
|
60
75
|
onShow();
|
|
61
76
|
focusOnOpen.current = true;
|
|
62
77
|
};
|
|
78
|
+
|
|
63
79
|
const handleOnMouseEnter = useCallback(() => {
|
|
64
80
|
setIsAddonHovered(true);
|
|
65
81
|
}, []);
|
|
66
82
|
const handleOnMouseLeave = useCallback(() => {
|
|
67
83
|
setIsAddonHovered(false);
|
|
68
84
|
}, []);
|
|
69
|
-
const hoverHandlers = interaction ===
|
|
85
|
+
const hoverHandlers = interaction === 'hover' ? {
|
|
70
86
|
onMouseEnter: handleShowWithMouseHover,
|
|
71
87
|
onMouseLeave: () => {
|
|
72
88
|
onHide();
|
|
73
89
|
setIsAddonHovered(false);
|
|
74
90
|
}
|
|
75
|
-
} : {
|
|
76
|
-
|
|
91
|
+
} : {
|
|
92
|
+
onClick: handleShowWithMouse
|
|
93
|
+
};
|
|
94
|
+
const rightAddon = rightAddonType === 'elipsis' ? /*#__PURE__*/_jsx(DSButton, {
|
|
77
95
|
"aria-label": "vertical-elipsis",
|
|
78
96
|
"data-testid": "vertical-elipsis",
|
|
79
97
|
buttonType: "text",
|
|
80
|
-
leftIcon:
|
|
98
|
+
leftIcon: /*#__PURE__*/_jsx(MoreOptionsVert, {
|
|
81
99
|
className: "submenu-arrow",
|
|
82
|
-
color: visible || isAddonHovered ? [
|
|
100
|
+
color: visible || isAddonHovered ? ['brand-primary', 800] : ['neutral', 500],
|
|
83
101
|
size: "s"
|
|
84
102
|
}),
|
|
85
|
-
onClick:
|
|
103
|
+
onClick: e => handleShowSubItemsWithMouse(e),
|
|
86
104
|
size: "m",
|
|
87
105
|
variant: BUTTON_VARIANT.DEFAULT
|
|
88
|
-
}) :
|
|
106
|
+
}) : /*#__PURE__*/_jsx(ChevronRightComp, {}, void 0, /*#__PURE__*/_jsx(ChevronSmallRight, {
|
|
89
107
|
"data-testid": "chevron-right",
|
|
90
108
|
className: "submenu-arrow",
|
|
91
|
-
color: visible || isAddonHovered ? [
|
|
109
|
+
color: visible || isAddonHovered ? ['brand-primary', 800] : ['neutral', 500],
|
|
92
110
|
size: "sm"
|
|
93
111
|
}));
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
112
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
113
|
+
children: /*#__PURE__*/_jsx(DSPopper, {
|
|
114
|
+
contentComponent: /*#__PURE__*/jsx(Menu, _objectSpread(_objectSpread({
|
|
115
|
+
focusKeyBindings: {
|
|
116
|
+
ArrowLeft: [() => focusItemByNode(itemRef.current), 'exit']
|
|
117
|
+
},
|
|
118
|
+
focusOnOpen: focusOnOpen.current,
|
|
119
|
+
onExitFocusGroup: onHide
|
|
120
|
+
}, hoverHandlers), {}, {
|
|
121
|
+
closeMenu: closeMenu,
|
|
122
|
+
visible: visible,
|
|
123
|
+
children: subitems
|
|
124
|
+
})),
|
|
125
|
+
interactionType: interactionType,
|
|
126
|
+
isOpen: visible,
|
|
127
|
+
onOpen: opening => opening ? onShow() : onHide(),
|
|
128
|
+
placement: "right-start",
|
|
129
|
+
showArrow: false,
|
|
130
|
+
triggerComponent: /*#__PURE__*/jsx(MenuItem, _objectSpread(_objectSpread({
|
|
131
|
+
customRenderer: customRenderer,
|
|
132
|
+
disabledAddonInactive: disabledAddonInactive,
|
|
133
|
+
id: id,
|
|
134
|
+
innerRef: itemRef,
|
|
135
|
+
label: label,
|
|
136
|
+
leftAddon: leftAddon,
|
|
137
|
+
noAddon: noAddon,
|
|
138
|
+
onFocus: handleOnMouseEnter,
|
|
139
|
+
onBlur: handleOnMouseLeave,
|
|
140
|
+
onMouseEnter: handleOnMouseEnter,
|
|
141
|
+
onMouseLeave: handleOnMouseLeave
|
|
142
|
+
}, hoverHandlers), {}, {
|
|
143
|
+
onKeyDown: e => {
|
|
144
|
+
if (e.key === 'ArrowRight' || e.key === 'Enter' || e.keyCode === 32) {
|
|
145
|
+
handleShowWithKeyboard();
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
rightAddon: rightAddon
|
|
149
|
+
}, checkableProps))
|
|
130
150
|
})
|
|
131
|
-
})
|
|
132
|
-
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
133
154
|
const props = {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
155
|
+
/** dont show addon for submenu */
|
|
156
|
+
noAddon: PropTypes.bool.description('dont show addon for submenu'),
|
|
157
|
+
|
|
158
|
+
/** left addon */
|
|
159
|
+
leftAddon: PropTypes.node.description('left addon'),
|
|
160
|
+
|
|
161
|
+
/** submenu label */
|
|
162
|
+
label: PropTypes.string.description('submenu label'),
|
|
163
|
+
|
|
164
|
+
/** A type indicating how to open/close the tooltip */
|
|
165
|
+
interactionType: PropTypes.oneOf(interactions).description('A type indicating how to open/close the tooltip'),
|
|
166
|
+
|
|
167
|
+
/** sub menu items */
|
|
168
|
+
children: PropTypes.oneOfType([PropTypes.array, PropTypes.node]).description('sub menu items'),
|
|
169
|
+
|
|
170
|
+
/** right addon, ellipsis or undefined */
|
|
171
|
+
rightAddonType: PropTypes.oneOf(['ellipsis']).description('right addon, ellipsis or undefined'),
|
|
172
|
+
disabledAddonInactive: PropTypes.bool.description(''),
|
|
173
|
+
|
|
174
|
+
/** props passed to MenuItem component */
|
|
175
|
+
checkableProps: PropTypes.object.description('props passed to MenuItem component'),
|
|
176
|
+
|
|
177
|
+
/** custom renderer for menu item */
|
|
178
|
+
customRenderer: PropTypes.func.description('custom renderer for menu item'),
|
|
179
|
+
|
|
180
|
+
/** on click handler */
|
|
181
|
+
onClick: PropTypes.func.description('on click handler'),
|
|
182
|
+
closeMenu: PropTypes.any.description(''),
|
|
183
|
+
|
|
184
|
+
/** component id */
|
|
185
|
+
id: PropTypes.string.description('component id')
|
|
146
186
|
};
|
|
147
|
-
SubMenu.propTypes = props;
|
|
148
|
-
registerMenuItem("submenu", SubMenu);
|
|
149
187
|
const DSSubMenuWithSchema = describe(SubMenu);
|
|
150
188
|
DSSubMenuWithSchema.propTypes = props;
|
|
151
|
-
|
|
152
|
-
export {
|
|
153
|
-
DSSubMenuWithSchema,
|
|
154
|
-
SubMenu,
|
|
155
|
-
SubMenu_default as default
|
|
156
|
-
};
|
|
157
|
-
//# sourceMappingURL=SubMenu.js.map
|
|
189
|
+
|
|
190
|
+
export { DSSubMenuWithSchema, SubMenu as default };
|
|
@@ -1,12 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
7
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
9
|
+
import { createElement } from 'react';
|
|
10
|
+
import { isFunction } from '@elliemae/ds-utilities';
|
|
11
|
+
import MenuSeparator from './Separator.js';
|
|
12
|
+
import MenuItem from './MenuItem.js';
|
|
13
|
+
import SubMenu from './SubMenu.js';
|
|
14
|
+
import SelectionGroup from './SelectionGroup.js';
|
|
15
|
+
import MenuItemCheckbox from './MenuItemCheckbox.js';
|
|
16
|
+
import MenuItemRadio from './MenuItemRadio.js';
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
const itemTypes = {
|
|
22
|
+
separator: MenuSeparator,
|
|
23
|
+
menuitem: MenuItem,
|
|
24
|
+
radio: MenuItemRadio,
|
|
25
|
+
checkbox: MenuItemCheckbox,
|
|
26
|
+
submenu: SubMenu,
|
|
27
|
+
'selection-group': SelectionGroup
|
|
6
28
|
};
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
menuItemFactory,
|
|
10
|
-
registerMenuItem
|
|
29
|
+
const fallback = {
|
|
30
|
+
SelectionGroup: 'selection-group'
|
|
11
31
|
};
|
|
12
|
-
|
|
32
|
+
function menuItemFactory() {
|
|
33
|
+
let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
34
|
+
let items = arguments.length > 1 ? arguments[1] : undefined;
|
|
35
|
+
let defaultItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : itemTypes.menuitem;
|
|
36
|
+
const itemsObject = items || itemTypes;
|
|
37
|
+
const parsedType = fallback[type] || type.toLowerCase();
|
|
38
|
+
return itemsObject[parsedType] || defaultItem;
|
|
39
|
+
}
|
|
40
|
+
function renderMenuItems(options) {
|
|
41
|
+
let factory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : menuItemFactory;
|
|
42
|
+
return options.map((option, index) => {
|
|
43
|
+
if (isFunction(option.renderer)) {
|
|
44
|
+
return option.renderer({
|
|
45
|
+
key: option.id,
|
|
46
|
+
item: option
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const ItemComponent = factory(option.type);
|
|
51
|
+
const children = option.subItems && renderMenuItems(option.subItems, factory);
|
|
52
|
+
return /*#__PURE__*/createElement(ItemComponent, _objectSpread(_objectSpread({}, option), {}, {
|
|
53
|
+
key: option.id || index,
|
|
54
|
+
item: option,
|
|
55
|
+
onClick: null,
|
|
56
|
+
onMouseDown: option.onClick // onClick callback called in onMouseDown due to events order issue
|
|
57
|
+
|
|
58
|
+
}), children);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { menuItemFactory, renderMenuItems };
|
package/esm/VirtualMenuList.js
CHANGED
|
@@ -1,49 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
width,
|
|
29
|
-
height
|
|
30
|
-
}) {
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
5
|
+
import 'react';
|
|
6
|
+
import { FixedSizeList } from 'react-window';
|
|
7
|
+
import useHeightByAmountOfItems from './utils/useHeightByAmountOfItems.js';
|
|
8
|
+
|
|
9
|
+
const MenuItem = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
data,
|
|
12
|
+
index,
|
|
13
|
+
style
|
|
14
|
+
} = _ref;
|
|
15
|
+
return /*#__PURE__*/_jsx("div", {
|
|
16
|
+
style: style
|
|
17
|
+
}, index, data && data[index] ? data[index] : '');
|
|
18
|
+
}; // eslint-disable-next-line no-unused-vars
|
|
19
|
+
|
|
20
|
+
function VirtualMenuList(_ref2) {
|
|
21
|
+
let {
|
|
22
|
+
items,
|
|
23
|
+
itemHeight = 32,
|
|
24
|
+
amountItemsInWindow = 5,
|
|
25
|
+
width,
|
|
26
|
+
height
|
|
27
|
+
} = _ref2;
|
|
31
28
|
const computedListHeight = useHeightByAmountOfItems({
|
|
32
29
|
amountItems: amountItemsInWindow,
|
|
33
30
|
itemHeight,
|
|
34
31
|
items
|
|
35
32
|
});
|
|
36
|
-
return
|
|
33
|
+
return /*#__PURE__*/_jsx(FixedSizeList, {
|
|
37
34
|
height: height || computedListHeight,
|
|
38
35
|
itemCount: items.length,
|
|
39
36
|
itemData: items,
|
|
40
37
|
itemSize: itemHeight,
|
|
41
|
-
width
|
|
42
|
-
}, MenuItem);
|
|
38
|
+
width: width
|
|
39
|
+
}, void 0, MenuItem);
|
|
43
40
|
}
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
VirtualMenuList,
|
|
47
|
-
VirtualMenuList_default as default
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=VirtualMenuList.js.map
|
|
41
|
+
|
|
42
|
+
export { VirtualMenuList as default };
|
package/esm/index.js
CHANGED
|
@@ -1,34 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { renderMenuItems } from "./MenuItems/renderMenuItems";
|
|
15
|
-
import { DSMenuWithSchema, Menu, Menu as Menu2 } from "./Menu";
|
|
16
|
-
export {
|
|
17
|
-
DSMenuCheckboxGroupWithSchema,
|
|
18
|
-
DSMenuItemCheckeableWithSchema,
|
|
19
|
-
DSMenuItemRadioWithSchema,
|
|
20
|
-
DSMenuItemWithSchema,
|
|
21
|
-
DSMenuRadioGroupWithSchema,
|
|
22
|
-
DSMenuSearchableGroupWithSchema,
|
|
23
|
-
DSMenuSearchableListWithSchema,
|
|
24
|
-
DSMenuSelectionGroupWithSchema,
|
|
25
|
-
DSMenuSeparatorWithSchema,
|
|
26
|
-
DSMenuWithSchema,
|
|
27
|
-
DSSubMenuWithSchema,
|
|
28
|
-
Menu,
|
|
29
|
-
default2 as MenuCombobox,
|
|
30
|
-
Menu2 as default,
|
|
31
|
-
menuItemFactory,
|
|
32
|
-
renderMenuItems
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { DSMenuWithSchema, Menu, Menu as default } from './Menu.js';
|
|
2
|
+
export { DSMenuItemWithSchema } from './MenuItems/MenuItem.js';
|
|
3
|
+
export { DSSubMenuWithSchema } from './MenuItems/SubMenu.js';
|
|
4
|
+
export { DSMenuCheckboxGroupWithSchema } from './MenuItems/CheckboxGroup.js';
|
|
5
|
+
export { DSMenuItemCheckeableWithSchema } from './MenuItems/MenuItemCheckable.js';
|
|
6
|
+
export { DSMenuItemRadioWithSchema } from './MenuItems/MenuItemRadio.js';
|
|
7
|
+
export { DSMenuRadioGroupWithSchema } from './MenuItems/RadioGroup.js';
|
|
8
|
+
export { DSMenuSearchableGroupWithSchema } from './MenuItems/SearchableGroup.js';
|
|
9
|
+
export { DSMenuSearchableListWithSchema } from './MenuItems/SearchableList.js';
|
|
10
|
+
export { DSMenuSeparatorWithSchema } from './MenuItems/Separator.js';
|
|
11
|
+
export { DSMenuSelectionGroupWithSchema } from './MenuItems/SelectionGroup.js';
|
|
12
|
+
export { default as MenuCombobox } from './MenuCombobox.js';
|
|
13
|
+
export { menuItemFactory, renderMenuItems } from './MenuItems/menuItemFactory.js';
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
3
|
const calculateHeight = (itemHeight, amountItemsInWindow, itemsLength) => {
|
|
4
4
|
const realAmountItemsInWindow = itemsLength < amountItemsInWindow ? itemsLength : amountItemsInWindow;
|
|
5
5
|
return itemHeight * realAmountItemsInWindow;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
|
|
8
|
+
function useHeightByAmountOfItems(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
itemHeight,
|
|
11
|
+
amountItems,
|
|
12
|
+
items
|
|
13
|
+
} = _ref;
|
|
12
14
|
const calculatedHeight = useMemo(() => calculateHeight(itemHeight, amountItems, items.length), [amountItems, items]);
|
|
13
15
|
return calculatedHeight;
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
useHeightByAmountOfItems_default as default,
|
|
18
|
-
useHeightByAmountOfItems
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=useHeightByAmountOfItems.js.map
|
|
17
|
+
|
|
18
|
+
export { useHeightByAmountOfItems as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-menu",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-next.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Menu",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -39,10 +39,6 @@
|
|
|
39
39
|
"import": "./esm/MenuItems/SearchableGroup.js",
|
|
40
40
|
"require": "./cjs/MenuItems/SearchableGroup.js"
|
|
41
41
|
},
|
|
42
|
-
"./MenuItems/renderMenuItems": {
|
|
43
|
-
"import": "./esm/MenuItems/renderMenuItems.js",
|
|
44
|
-
"require": "./cjs/MenuItems/renderMenuItems.js"
|
|
45
|
-
},
|
|
46
42
|
"./MenuItems/RadioGroup": {
|
|
47
43
|
"import": "./esm/MenuItems/RadioGroup.js",
|
|
48
44
|
"require": "./cjs/MenuItems/RadioGroup.js"
|
|
@@ -71,10 +67,6 @@
|
|
|
71
67
|
"import": "./esm/MenuItems/CheckboxGroup.js",
|
|
72
68
|
"require": "./cjs/MenuItems/CheckboxGroup.js"
|
|
73
69
|
},
|
|
74
|
-
"./MenuExports": {
|
|
75
|
-
"import": "./esm/MenuExports.js",
|
|
76
|
-
"require": "./cjs/MenuExports.js"
|
|
77
|
-
},
|
|
78
70
|
"./MenuContext": {
|
|
79
71
|
"import": "./esm/MenuContext.js",
|
|
80
72
|
"require": "./cjs/MenuContext.js"
|
|
@@ -108,16 +100,16 @@
|
|
|
108
100
|
"build": "node ../../scripts/build/build.js"
|
|
109
101
|
},
|
|
110
102
|
"dependencies": {
|
|
111
|
-
"@elliemae/ds-button": "
|
|
112
|
-
"@elliemae/ds-classnames": "
|
|
113
|
-
"@elliemae/ds-form": "
|
|
114
|
-
"@elliemae/ds-hidden": "
|
|
115
|
-
"@elliemae/ds-icons": "
|
|
116
|
-
"@elliemae/ds-popper": "
|
|
117
|
-
"@elliemae/ds-separator": "
|
|
118
|
-
"@elliemae/ds-shared": "
|
|
119
|
-
"@elliemae/ds-truncated-tooltip-text": "
|
|
120
|
-
"@elliemae/ds-utilities": "
|
|
103
|
+
"@elliemae/ds-button": "3.0.0-next.2",
|
|
104
|
+
"@elliemae/ds-classnames": "3.0.0-next.2",
|
|
105
|
+
"@elliemae/ds-form": "3.0.0-next.2",
|
|
106
|
+
"@elliemae/ds-hidden": "3.0.0-next.2",
|
|
107
|
+
"@elliemae/ds-icons": "3.0.0-next.2",
|
|
108
|
+
"@elliemae/ds-popper": "3.0.0-next.2",
|
|
109
|
+
"@elliemae/ds-separator": "3.0.0-next.2",
|
|
110
|
+
"@elliemae/ds-shared": "3.0.0-next.2",
|
|
111
|
+
"@elliemae/ds-truncated-tooltip-text": "3.0.0-next.2",
|
|
112
|
+
"@elliemae/ds-utilities": "3.0.0-next.2",
|
|
121
113
|
"prop-types": "~15.7.2",
|
|
122
114
|
"react-desc": "~4.1.3",
|
|
123
115
|
"react-spring": "~8.0.27",
|
package/types/Menu.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { menuItemFactory } from './MenuItems/menuItemFactory';
|
|
4
|
-
import { renderMenuItems } from './MenuItems/renderMenuItems';
|
|
3
|
+
import { renderMenuItems, menuItemFactory } from './MenuItems/menuItemFactory';
|
|
5
4
|
declare const Menu: any;
|
|
6
5
|
declare const DSMenuWithSchema: {
|
|
7
6
|
(props?: {
|
|
@@ -25,5 +24,5 @@ declare const DSMenuWithSchema: {
|
|
|
25
24
|
propTypes: unknown;
|
|
26
25
|
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
27
26
|
};
|
|
28
|
-
export { menuItemFactory, renderMenuItems, DSMenuWithSchema
|
|
27
|
+
export { Menu, menuItemFactory, renderMenuItems, DSMenuWithSchema };
|
|
29
28
|
export default Menu;
|
package/types/MenuContext.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference path="../../../../../shared/typings/react-desc.d.ts" />
|
|
2
2
|
/// <reference types="react" />
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
propTypes: {
|
|
3
|
+
declare function CheckboxGroup(props: any): JSX.Element;
|
|
4
|
+
declare namespace CheckboxGroup {
|
|
5
|
+
var propTypes: {
|
|
6
6
|
active: {
|
|
7
7
|
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
8
8
|
deprecated: import("react-desc").PropTypesDescValidator;
|
|
@@ -22,11 +22,11 @@ declare const CheckboxGroup: {
|
|
|
22
22
|
isRequired: import("react-desc").PropTypesDescValue;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
}
|
|
25
|
+
}
|
|
26
26
|
declare const DSMenuCheckboxGroupWithSchema: {
|
|
27
27
|
(props?: any): JSX.Element;
|
|
28
28
|
propTypes: unknown;
|
|
29
29
|
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
30
30
|
};
|
|
31
|
-
export { DSMenuCheckboxGroupWithSchema, CheckboxGroup };
|
|
32
31
|
export default CheckboxGroup;
|
|
32
|
+
export { DSMenuCheckboxGroupWithSchema };
|