@elliemae/ds-menu 2.2.0-alpha.2 → 2.2.0-beta.0
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 +71 -39
- 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 +63 -11
- 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 +4 -22
- package/types/MenuContext.d.ts +2 -3
- package/types/MenuItems/CheckboxGroup.d.ts +6 -6
- package/types/MenuItems/MenuItem.d.ts +6 -6
- package/types/MenuItems/MenuItemCheckable.d.ts +15 -24
- package/types/MenuItems/MenuItemCheckbox.d.ts +2 -3
- package/types/MenuItems/MenuItemRadio.d.ts +6 -15
- package/types/MenuItems/RadioGroup.d.ts +6 -6
- package/types/MenuItems/SearchableGroup.d.ts +4 -12
- package/types/MenuItems/SearchableList.d.ts +17 -28
- package/types/MenuItems/SelectionGroup.d.ts +17 -28
- package/types/MenuItems/Separator.d.ts +2 -6
- package/types/MenuItems/SubMenu.d.ts +19 -32
- 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,64 @@
|
|
|
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
|
+
|
|
22
|
+
const itemTypes = () => ({
|
|
23
|
+
separator: MenuSeparator,
|
|
24
|
+
menuitem: MenuItem,
|
|
25
|
+
radio: MenuItemRadio,
|
|
26
|
+
checkbox: MenuItemCheckbox,
|
|
27
|
+
submenu: SubMenu,
|
|
28
|
+
'selection-group': SelectionGroup
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const fallback = {
|
|
32
|
+
SelectionGroup: 'selection-group'
|
|
6
33
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
34
|
+
function menuItemFactory() {
|
|
35
|
+
let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
36
|
+
let items = arguments.length > 1 ? arguments[1] : undefined;
|
|
37
|
+
let defaultItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : itemTypes().menuitem;
|
|
38
|
+
const itemsObject = items || itemTypes();
|
|
39
|
+
const parsedType = fallback[type] || type.toLowerCase();
|
|
40
|
+
return itemsObject[parsedType] || defaultItem;
|
|
41
|
+
}
|
|
42
|
+
function renderMenuItems(options) {
|
|
43
|
+
let factory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : menuItemFactory;
|
|
44
|
+
return options.map((option, index) => {
|
|
45
|
+
if (isFunction(option.renderer)) {
|
|
46
|
+
return option.renderer({
|
|
47
|
+
key: option.id,
|
|
48
|
+
item: option
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const ItemComponent = factory(option.type);
|
|
53
|
+
const children = option.subItems && renderMenuItems(option.subItems, factory);
|
|
54
|
+
return /*#__PURE__*/createElement(ItemComponent, _objectSpread(_objectSpread({}, option), {}, {
|
|
55
|
+
key: option.id || index,
|
|
56
|
+
item: option,
|
|
57
|
+
onClick: null,
|
|
58
|
+
onMouseDown: option.onClick // onClick callback called in onMouseDown due to events order issue
|
|
59
|
+
|
|
60
|
+
}), children);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
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": "2.2.0-
|
|
3
|
+
"version": "2.2.0-beta.0",
|
|
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": "2.2.0-
|
|
112
|
-
"@elliemae/ds-classnames": "2.2.0-
|
|
113
|
-
"@elliemae/ds-form": "2.2.0-
|
|
114
|
-
"@elliemae/ds-hidden": "2.2.0-
|
|
115
|
-
"@elliemae/ds-icons": "2.2.0-
|
|
116
|
-
"@elliemae/ds-popper": "2.2.0-
|
|
117
|
-
"@elliemae/ds-separator": "2.2.0-
|
|
118
|
-
"@elliemae/ds-shared": "2.2.0-
|
|
119
|
-
"@elliemae/ds-truncated-tooltip-text": "2.2.0-
|
|
120
|
-
"@elliemae/ds-utilities": "2.2.0-
|
|
103
|
+
"@elliemae/ds-button": "2.2.0-beta.0",
|
|
104
|
+
"@elliemae/ds-classnames": "2.2.0-beta.0",
|
|
105
|
+
"@elliemae/ds-form": "2.2.0-beta.0",
|
|
106
|
+
"@elliemae/ds-hidden": "2.2.0-beta.0",
|
|
107
|
+
"@elliemae/ds-icons": "2.2.0-beta.0",
|
|
108
|
+
"@elliemae/ds-popper": "2.2.0-beta.0",
|
|
109
|
+
"@elliemae/ds-separator": "2.2.0-beta.0",
|
|
110
|
+
"@elliemae/ds-shared": "2.2.0-beta.0",
|
|
111
|
+
"@elliemae/ds-truncated-tooltip-text": "2.2.0-beta.0",
|
|
112
|
+
"@elliemae/ds-utilities": "2.2.0-beta.0",
|
|
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,29 +1,11 @@
|
|
|
1
1
|
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
-
|
|
3
|
-
import { menuItemFactory } from './MenuItems/menuItemFactory';
|
|
4
|
-
import { renderMenuItems } from './MenuItems/renderMenuItems';
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
import { renderMenuItems, menuItemFactory } from './MenuItems/menuItemFactory';
|
|
5
4
|
declare const Menu: any;
|
|
6
5
|
declare const DSMenuWithSchema: {
|
|
7
|
-
(props?:
|
|
8
|
-
[x: string]: any;
|
|
9
|
-
containerProps?: {} | undefined;
|
|
10
|
-
innerRef: any;
|
|
11
|
-
as?: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "key" | keyof React.HTMLAttributes<HTMLUListElement>> & {
|
|
12
|
-
ref?: ((instance: HTMLUListElement | null) => void) | React.RefObject<HTMLUListElement> | null | undefined;
|
|
13
|
-
}> | undefined;
|
|
14
|
-
children?: undefined;
|
|
15
|
-
onClickOutside?: (() => void) | undefined;
|
|
16
|
-
visible?: undefined;
|
|
17
|
-
focusOnOpen?: boolean | undefined;
|
|
18
|
-
maxOption?: number | undefined;
|
|
19
|
-
style?: {} | undefined;
|
|
20
|
-
minWidth?: undefined;
|
|
21
|
-
maxWidth?: undefined;
|
|
22
|
-
closeMenu: any;
|
|
23
|
-
responsiveHeight?: boolean | undefined;
|
|
24
|
-
} | undefined): JSX.Element;
|
|
6
|
+
(props?: unknown): JSX.Element;
|
|
25
7
|
propTypes: unknown;
|
|
26
8
|
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
27
9
|
};
|
|
28
|
-
export { menuItemFactory, renderMenuItems, DSMenuWithSchema
|
|
10
|
+
export { Menu, menuItemFactory, renderMenuItems, DSMenuWithSchema };
|
|
29
11
|
export default Menu;
|
package/types/MenuContext.d.ts
CHANGED