@hi-ui/menu 4.0.0-beta.2 → 4.0.0-beta.22
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/lib/cjs/Expander.js +2 -3
- package/lib/cjs/Menu.js +24 -14
- package/lib/cjs/MenuItem.js +137 -75
- package/lib/cjs/context.js +0 -1
- package/lib/cjs/index.js +0 -1
- package/lib/cjs/styles/index.scss.js +2 -3
- package/lib/cjs/util.js +0 -1
- package/lib/esm/Expander.js +0 -1
- package/lib/esm/Menu.js +18 -11
- package/lib/esm/MenuItem.js +107 -51
- package/lib/esm/context.js +1 -2
- package/lib/esm/index.js +0 -1
- package/lib/esm/styles/index.scss.js +3 -5
- package/lib/esm/util.js +0 -1
- package/lib/types/Menu.d.ts +42 -27
- package/lib/types/MenuItem.d.ts +11 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/types.d.ts +14 -2
- package/package.json +14 -9
- package/lib/cjs/Expander.js.map +0 -1
- package/lib/cjs/Menu.js.map +0 -1
- package/lib/cjs/MenuItem.js.map +0 -1
- package/lib/cjs/context.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/styles/index.scss.js.map +0 -1
- package/lib/cjs/util.js.map +0 -1
- package/lib/esm/Expander.js.map +0 -1
- package/lib/esm/Menu.js.map +0 -1
- package/lib/esm/MenuItem.js.map +0 -1
- package/lib/esm/context.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/styles/index.scss.js.map +0 -1
- package/lib/esm/util.js.map +0 -1
package/lib/esm/Menu.js
CHANGED
|
@@ -16,6 +16,7 @@ import { MenuItem } from './MenuItem.js';
|
|
|
16
16
|
import MenuContext from './context.js';
|
|
17
17
|
import { getAncestorIds } from './util.js';
|
|
18
18
|
import { useUncontrolledState } from '@hi-ui/use-uncontrolled-state';
|
|
19
|
+
import Tooltip from '@hi-ui/tooltip';
|
|
19
20
|
var MENU_PREFIX = getPrefixCls('menu');
|
|
20
21
|
/**
|
|
21
22
|
* TODO: What is Menu
|
|
@@ -64,8 +65,8 @@ var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
64
65
|
updateActiveId(id);
|
|
65
66
|
}, [updateActiveId]);
|
|
66
67
|
var clickSubMenu = useCallback(function (id) {
|
|
67
|
-
var expandedIds = _expandedIds.includes(id) ? _expandedIds.filter(function (
|
|
68
|
-
return
|
|
68
|
+
var expandedIds = _expandedIds.includes(id) ? _expandedIds.filter(function (expandedId) {
|
|
69
|
+
return expandedId !== id;
|
|
69
70
|
}) : _expandedIds.concat(id);
|
|
70
71
|
updateExpanedIds(expandedIds);
|
|
71
72
|
|
|
@@ -74,8 +75,8 @@ var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
74
75
|
}
|
|
75
76
|
}, [onClickSubMenu, _expandedIds]);
|
|
76
77
|
var closePopper = useCallback(function (id) {
|
|
77
|
-
updateExpanedIds(_expandedIds.filter(function (
|
|
78
|
-
return
|
|
78
|
+
updateExpanedIds(_expandedIds.filter(function (expandedId) {
|
|
79
|
+
return expandedId !== id;
|
|
79
80
|
}));
|
|
80
81
|
}, [_expandedIds]);
|
|
81
82
|
var closeAllPopper = useCallback(function () {
|
|
@@ -86,11 +87,12 @@ var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
86
87
|
mini = _useState3[0],
|
|
87
88
|
setMini = _useState3[1];
|
|
88
89
|
|
|
89
|
-
var cls = cx(prefixCls, className, prefixCls + "--" + placement, (_cx = {}, _cx[prefixCls + "--mini"] = mini, _cx));
|
|
90
|
+
var cls = cx(prefixCls, className, prefixCls + "--" + placement, (_cx = {}, _cx[prefixCls + "--mini"] = mini, _cx[prefixCls + "--popup"] = expandedType === 'pop' || showAllSubMenus || mini, _cx));
|
|
90
91
|
var onToggle = useCallback(function () {
|
|
91
92
|
setMini(!mini);
|
|
92
93
|
closeAllPopper();
|
|
93
94
|
}, [mini, closeAllPopper]);
|
|
95
|
+
var canToggle = placement === 'vertical' && showCollapse;
|
|
94
96
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
95
97
|
ref: ref,
|
|
96
98
|
role: role,
|
|
@@ -111,15 +113,21 @@ var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
111
113
|
}
|
|
112
114
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
113
115
|
className: cx(prefixCls + "__wrapper")
|
|
114
|
-
}, data.map(function (
|
|
115
|
-
return /*#__PURE__*/React.createElement(
|
|
116
|
-
|
|
116
|
+
}, data.map(function (item) {
|
|
117
|
+
return canToggle && mini ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
118
|
+
title: item.title,
|
|
119
|
+
key: item.id,
|
|
120
|
+
placement: "right"
|
|
121
|
+
}, /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, item, {
|
|
122
|
+
level: 1
|
|
123
|
+
}))) : /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, item, {
|
|
124
|
+
key: item.id,
|
|
117
125
|
level: 1
|
|
118
126
|
}));
|
|
119
|
-
})),
|
|
127
|
+
})), canToggle ? /*#__PURE__*/React.createElement("div", {
|
|
120
128
|
className: cx(prefixCls + "__toggle"),
|
|
121
129
|
onClick: onToggle
|
|
122
|
-
}, mini ? /*#__PURE__*/React.createElement(MenuUnfoldOutlined, null) : /*#__PURE__*/React.createElement(MenuFoldOutlined, null))));
|
|
130
|
+
}, mini ? /*#__PURE__*/React.createElement(MenuUnfoldOutlined, null) : /*#__PURE__*/React.createElement(MenuFoldOutlined, null)) : null));
|
|
123
131
|
});
|
|
124
132
|
|
|
125
133
|
if (__DEV__) {
|
|
@@ -127,4 +135,3 @@ if (__DEV__) {
|
|
|
127
135
|
}
|
|
128
136
|
|
|
129
137
|
export { Menu };
|
|
130
|
-
//# sourceMappingURL=Menu.js.map
|
package/lib/esm/MenuItem.js
CHANGED
|
@@ -7,28 +7,34 @@
|
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
10
|
+
import { __rest } from 'tslib';
|
|
11
|
+
import React, { forwardRef, useRef, useContext } from 'react';
|
|
11
12
|
import { getPrefixCls, cx } from '@hi-ui/classname';
|
|
12
13
|
import { __DEV__ } from '@hi-ui/env';
|
|
13
|
-
import {
|
|
14
|
+
import { RightOutlined, DownOutlined, UpOutlined } from '@hi-ui/icons';
|
|
14
15
|
import MenuContext from './context.js';
|
|
15
|
-
import
|
|
16
|
+
import Popper from '@hi-ui/popper';
|
|
16
17
|
import { Expander } from './Expander.js';
|
|
18
|
+
import { isArrayNonEmpty } from '@hi-ui/type-assertion';
|
|
19
|
+
import { times } from '@hi-ui/array-utils';
|
|
20
|
+
import { useMergeRefs } from '@hi-ui/use-merge-refs';
|
|
17
21
|
var MENU_PREFIX = getPrefixCls('menu');
|
|
18
|
-
|
|
19
|
-
var MenuItem = function MenuItem(_ref) {
|
|
22
|
+
var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
20
23
|
var _cx, _cx2;
|
|
21
24
|
|
|
22
|
-
var
|
|
23
|
-
prefixCls =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
level =
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
var _a$prefixCls = _a.prefixCls,
|
|
26
|
+
prefixCls = _a$prefixCls === void 0 ? MENU_PREFIX : _a$prefixCls,
|
|
27
|
+
className = _a.className,
|
|
28
|
+
icon = _a.icon,
|
|
29
|
+
title = _a.title,
|
|
30
|
+
disabled = _a.disabled,
|
|
31
|
+
id = _a.id,
|
|
32
|
+
_a$level = _a.level,
|
|
33
|
+
level = _a$level === void 0 ? 1 : _a$level,
|
|
34
|
+
children = _a.children,
|
|
35
|
+
parentIds = _a.parentIds,
|
|
36
|
+
rest = __rest(_a, ["prefixCls", "className", "icon", "title", "disabled", "id", "level", "children", "parentIds"]);
|
|
37
|
+
|
|
32
38
|
var itemRef = useRef(null);
|
|
33
39
|
|
|
34
40
|
var _useContext = useContext(MenuContext),
|
|
@@ -46,13 +52,15 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
46
52
|
|
|
47
53
|
var _parentIds = (parentIds || []).concat(id);
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
className: cx(prefixCls + "-
|
|
55
|
+
var hasChildren = isArrayNonEmpty(children);
|
|
56
|
+
var mergedRef = useMergeRefs(itemRef, ref);
|
|
57
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("li", Object.assign({
|
|
58
|
+
ref: mergedRef,
|
|
59
|
+
className: cx(prefixCls + "-item", (_cx = {}, _cx[prefixCls + "-item__inner--mini"] = mini, _cx[prefixCls + "-item--disabled"] = disabled, _cx[prefixCls + "-item--active"] = placement === 'horizontal' && (activeId === id || (activeParents === null || activeParents === void 0 ? void 0 : activeParents.includes(id))) && level === 1, _cx), className)
|
|
60
|
+
}, rest), /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
className: cx(prefixCls + "-item__inner", (_cx2 = {}, _cx2[prefixCls + "-item__inner--active"] = activeId === id, _cx2[prefixCls + "-item__inner--active-p"] = activeParents === null || activeParents === void 0 ? void 0 : activeParents.includes(id), _cx2[prefixCls + "-item__inner--expanded"] = expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id), _cx2)),
|
|
54
62
|
onClick: function onClick() {
|
|
55
|
-
if (children
|
|
63
|
+
if (isArrayNonEmpty(children)) {
|
|
56
64
|
if (clickSubMenu) {
|
|
57
65
|
clickSubMenu(id);
|
|
58
66
|
}
|
|
@@ -65,21 +73,33 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
65
73
|
closeAllPopper();
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
|
-
},
|
|
69
|
-
style: placement === 'vertical' && expandedType === 'collapse' && !mini ? {
|
|
70
|
-
paddingLeft: level > 1 ? 12 + (level - 1 > 0 ? 1 : 0) * 20 + (level - 2 || 0) * 16 : 12
|
|
71
|
-
} : {}
|
|
72
|
-
}, icon, /*#__PURE__*/React.createElement("span", {
|
|
73
|
-
className: prefixCls + "-item__content"
|
|
74
|
-
}, title), (children === null || children === void 0 ? void 0 : children.length) && !mini && placement === 'vertical' && expandedType === 'collapse' && !showAllSubMenus && ((expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)) ? /*#__PURE__*/React.createElement(UpOutlined, null) : /*#__PURE__*/React.createElement(DownOutlined, null)), (children === null || children === void 0 ? void 0 : children.length) && mini && level > 1 && placement === 'vertical' && /*#__PURE__*/React.createElement(RightOutlined, null), (children === null || children === void 0 ? void 0 : children.length) && !mini && placement === 'vertical' && (expandedType === 'pop' || showAllSubMenus) && /*#__PURE__*/React.createElement(RightOutlined, null), (children === null || children === void 0 ? void 0 : children.length) && placement === 'horizontal' && level > 1 && /*#__PURE__*/React.createElement(RightOutlined, null), (children === null || children === void 0 ? void 0 : children.length) && placement === 'horizontal' && level === 1 && ((expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)) ? /*#__PURE__*/React.createElement(UpOutlined, {
|
|
75
|
-
style: {
|
|
76
|
-
marginLeft: 4
|
|
77
|
-
}
|
|
78
|
-
}) : /*#__PURE__*/React.createElement(DownOutlined, {
|
|
79
|
-
style: {
|
|
80
|
-
marginLeft: 4
|
|
81
76
|
}
|
|
82
|
-
}
|
|
77
|
+
}, placement === 'vertical' && expandedType === 'collapse' && !mini ? renderIndent({
|
|
78
|
+
prefixCls: prefixCls + "-item",
|
|
79
|
+
depth: level - 1
|
|
80
|
+
}) : null, icon ? /*#__PURE__*/React.createElement("span", {
|
|
81
|
+
className: prefixCls + "-item__icon"
|
|
82
|
+
}, icon) : null, /*#__PURE__*/React.createElement("span", {
|
|
83
|
+
className: prefixCls + "-item__content"
|
|
84
|
+
}, title), hasChildren && !mini && placement === 'vertical' && expandedType === 'collapse' && !showAllSubMenus && ((expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)) ? /*#__PURE__*/React.createElement(Arrow, {
|
|
85
|
+
prefixCls: prefixCls + "-item",
|
|
86
|
+
direction: "up"
|
|
87
|
+
}) : /*#__PURE__*/React.createElement(Arrow, {
|
|
88
|
+
prefixCls: prefixCls + "-item",
|
|
89
|
+
direction: "down"
|
|
90
|
+
})), hasChildren && mini && level > 1 && placement === 'vertical' ? /*#__PURE__*/React.createElement(Arrow, {
|
|
91
|
+
prefixCls: prefixCls + "-item"
|
|
92
|
+
}) : null, hasChildren && !mini && placement === 'vertical' && (expandedType === 'pop' || showAllSubMenus) ? /*#__PURE__*/React.createElement(Arrow, {
|
|
93
|
+
prefixCls: prefixCls + "-item"
|
|
94
|
+
}) : null, hasChildren && placement === 'horizontal' && level > 1 ? /*#__PURE__*/React.createElement(Arrow, {
|
|
95
|
+
prefixCls: prefixCls + "-item"
|
|
96
|
+
}) : null, hasChildren && placement === 'horizontal' && level === 1 && ((expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)) ? /*#__PURE__*/React.createElement(Arrow, {
|
|
97
|
+
prefixCls: prefixCls + "-item",
|
|
98
|
+
direction: "up"
|
|
99
|
+
}) : /*#__PURE__*/React.createElement(Arrow, {
|
|
100
|
+
prefixCls: prefixCls + "-item",
|
|
101
|
+
direction: "down"
|
|
102
|
+
}))), hasChildren && placement === 'vertical' && !mini && !showAllSubMenus && expandedType === 'collapse' ? /*#__PURE__*/React.createElement(Expander, {
|
|
83
103
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id))
|
|
84
104
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
85
105
|
className: prefixCls + "-submenu"
|
|
@@ -89,7 +109,7 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
89
109
|
level: level + 1,
|
|
90
110
|
parentIds: _parentIds
|
|
91
111
|
}));
|
|
92
|
-
})))
|
|
112
|
+
}))) : null), hasChildren && placement === 'vertical' && mini && !showAllSubMenus && expandedType === 'collapse' && (level === 1 ? /*#__PURE__*/React.createElement(Popper, {
|
|
93
113
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
94
114
|
attachEl: itemRef.current,
|
|
95
115
|
placement: 'right-start',
|
|
@@ -112,6 +132,7 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
112
132
|
attachEl: itemRef.current,
|
|
113
133
|
placement: 'right-start',
|
|
114
134
|
gutterGap: 16,
|
|
135
|
+
disabledPortal: true,
|
|
115
136
|
onClose: function onClose() {
|
|
116
137
|
if (closePopper) {
|
|
117
138
|
closePopper(id);
|
|
@@ -125,7 +146,7 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
125
146
|
level: level + 1,
|
|
126
147
|
parentIds: _parentIds
|
|
127
148
|
}));
|
|
128
|
-
})))),
|
|
149
|
+
})))), hasChildren && placement === 'vertical' && !showAllSubMenus && expandedType === 'pop' && (level === 1 ? /*#__PURE__*/React.createElement(Popper, {
|
|
129
150
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
130
151
|
attachEl: itemRef.current,
|
|
131
152
|
placement: 'right-start',
|
|
@@ -146,6 +167,7 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
146
167
|
}))) : /*#__PURE__*/React.createElement(Popper, {
|
|
147
168
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
148
169
|
attachEl: itemRef.current,
|
|
170
|
+
disabledPortal: true,
|
|
149
171
|
placement: 'right-start',
|
|
150
172
|
gutterGap: 16,
|
|
151
173
|
onClose: function onClose() {
|
|
@@ -161,7 +183,7 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
161
183
|
level: level + 1,
|
|
162
184
|
parentIds: _parentIds
|
|
163
185
|
}));
|
|
164
|
-
})))),
|
|
186
|
+
})))), hasChildren && placement === 'vertical' && showAllSubMenus ? /*#__PURE__*/React.createElement(Popper, {
|
|
165
187
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
166
188
|
attachEl: itemRef.current,
|
|
167
189
|
placement: 'right-start',
|
|
@@ -174,14 +196,12 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
174
196
|
}, /*#__PURE__*/React.createElement("div", {
|
|
175
197
|
className: prefixCls + "-fat-menu"
|
|
176
198
|
}, children.map(function (child) {
|
|
177
|
-
var _a;
|
|
178
|
-
|
|
179
199
|
return /*#__PURE__*/React.createElement("div", {
|
|
180
200
|
key: child.id,
|
|
181
201
|
className: prefixCls + "-fat-menu__group"
|
|
182
202
|
}, /*#__PURE__*/React.createElement("div", {
|
|
183
203
|
className: prefixCls + "-group-item"
|
|
184
|
-
}, child.title),
|
|
204
|
+
}, child.title), child && isArrayNonEmpty(child.children) ? /*#__PURE__*/React.createElement("ul", null, child.children.map(function (item) {
|
|
185
205
|
var _cx3;
|
|
186
206
|
|
|
187
207
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -197,8 +217,8 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
197
217
|
className: cx(prefixCls + "-item", (_cx3 = {}, _cx3[prefixCls + "-item--active"] = activeId === item.id, _cx3)),
|
|
198
218
|
key: item.id
|
|
199
219
|
}, item.title);
|
|
200
|
-
})));
|
|
201
|
-
})))
|
|
220
|
+
})) : null);
|
|
221
|
+
}))) : null, hasChildren && placement === 'horizontal' && !showAllSubMenus && (level === 1 ? /*#__PURE__*/React.createElement(Popper, {
|
|
202
222
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
203
223
|
attachEl: itemRef.current,
|
|
204
224
|
placement: level === 1 ? 'bottom-start' : 'right-start',
|
|
@@ -219,6 +239,7 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
219
239
|
}))) : /*#__PURE__*/React.createElement(Popper, {
|
|
220
240
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
221
241
|
attachEl: itemRef.current,
|
|
242
|
+
disabledPortal: true,
|
|
222
243
|
placement: level === 1 ? 'bottom-start' : 'right-start',
|
|
223
244
|
gutterGap: level === 1 ? 8 : 16,
|
|
224
245
|
onClose: function onClose() {
|
|
@@ -234,7 +255,7 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
234
255
|
level: level + 1,
|
|
235
256
|
parentIds: _parentIds
|
|
236
257
|
}));
|
|
237
|
-
})))),
|
|
258
|
+
})))), hasChildren && placement === 'horizontal' && showAllSubMenus ? /*#__PURE__*/React.createElement(Popper, {
|
|
238
259
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
239
260
|
attachEl: itemRef.current,
|
|
240
261
|
placement: 'bottom-start',
|
|
@@ -247,14 +268,12 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
247
268
|
}, /*#__PURE__*/React.createElement("div", {
|
|
248
269
|
className: prefixCls + "-fat-menu"
|
|
249
270
|
}, children.map(function (child) {
|
|
250
|
-
var _a;
|
|
251
|
-
|
|
252
271
|
return /*#__PURE__*/React.createElement("div", {
|
|
253
272
|
key: child.id,
|
|
254
273
|
className: prefixCls + "-fat-menu__group"
|
|
255
274
|
}, /*#__PURE__*/React.createElement("div", {
|
|
256
275
|
className: prefixCls + "-group-item"
|
|
257
|
-
}, child.title),
|
|
276
|
+
}, child.title), child && isArrayNonEmpty(child.children) ? /*#__PURE__*/React.createElement("ul", null, child.children.map(function (item) {
|
|
258
277
|
var _cx4;
|
|
259
278
|
|
|
260
279
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -270,13 +289,50 @@ var MenuItem = function MenuItem(_ref) {
|
|
|
270
289
|
},
|
|
271
290
|
key: item.id
|
|
272
291
|
}, item.title);
|
|
273
|
-
})));
|
|
274
|
-
}))));
|
|
275
|
-
};
|
|
292
|
+
})) : null);
|
|
293
|
+
}))) : null);
|
|
294
|
+
});
|
|
276
295
|
|
|
277
296
|
if (__DEV__) {
|
|
278
297
|
MenuItem.displayName = 'MenuItem';
|
|
279
298
|
}
|
|
280
299
|
|
|
300
|
+
var Arrow = function Arrow(_ref) {
|
|
301
|
+
var prefixCls = _ref.prefixCls,
|
|
302
|
+
direction = _ref.direction;
|
|
303
|
+
var icon = null;
|
|
304
|
+
|
|
305
|
+
switch (direction) {
|
|
306
|
+
case 'up':
|
|
307
|
+
icon = /*#__PURE__*/React.createElement(UpOutlined, null);
|
|
308
|
+
break;
|
|
309
|
+
|
|
310
|
+
case 'down':
|
|
311
|
+
icon = /*#__PURE__*/React.createElement(DownOutlined, null);
|
|
312
|
+
break;
|
|
313
|
+
|
|
314
|
+
default:
|
|
315
|
+
icon = /*#__PURE__*/React.createElement(RightOutlined, null);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
319
|
+
className: prefixCls + "__arrow"
|
|
320
|
+
}, icon);
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* 渲染空白占位
|
|
324
|
+
*/
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
var renderIndent = function renderIndent(_ref2) {
|
|
328
|
+
var prefixCls = _ref2.prefixCls,
|
|
329
|
+
depth = _ref2.depth;
|
|
330
|
+
return times(depth, function (index) {
|
|
331
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
332
|
+
className: prefixCls + "__indent",
|
|
333
|
+
key: index
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
|
|
281
338
|
export { MenuItem };
|
|
282
|
-
//# sourceMappingURL=MenuItem.js.map
|
package/lib/esm/context.js
CHANGED
package/lib/esm/index.js
CHANGED
|
@@ -7,11 +7,9 @@
|
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
|
-
var css_248z = "@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n.hi-v4-menu-fat-menu {\n background-color: #fff;\n background-color: var(--hi-v4-color-static-white, #fff);\n margin: 0;\n font-size: 0.875rem;\n font-size: var(--hi-v4-text-size-normal, 0.875rem);\n padding: 8px;\n padding: var(--hi-v4-spacing-4, 8px);\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n color: #1f2733;\n color: var(--hi-v4-color-gray-700, #1f2733);\n border-radius: 4px;\n border-radius: var(--hi-v4-border-radius-normal, 4px);\n -ms-flex-wrap: wrap;\n flex-wrap: wrap; }\n.hi-v4-menu-fat-menu__group:not(:last-of-type) {\n margin-right: 36px;\n margin-right: var(--hi-v4-spacing-18, 36px); }\n.hi-v4-menu-fat-menu .hi-v4-menu-group-item {\n height: 40px;\n margin: 0;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n padding: 0 12px;\n padding: 0 var(--hi-v4-spacing-6, 12px);\n color: #929aa6;\n color: var(--hi-v4-color-gray-500, #929aa6); }\n.hi-v4-menu-fat-menu .hi-v4-menu-item {\n height: 40px;\n margin: 0;\n border-radius: 4px;\n border-radius: var(--hi-v4-border-radius-normal, 4px);\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n padding: 0 12px;\n padding: 0 var(--hi-v4-spacing-6, 12px); }\n.hi-v4-menu-fat-menu .hi-v4-menu-item--active {\n color: #237ffa;\n color: var(--hi-v4-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));\n background-color: #e2f3fe;\n background-color: var(--hi-v4-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }\n.hi-v4-menu-fat-menu .hi-v4-menu-item:not(.hi-v4-menu-item--active):hover {\n background-color: #f2f4f7;\n background-color: var(--hi-v4-color-gray-100, #f2f4f7); }\n.hi-v4-menu-fat-menu ul {\n padding: 0;\n margin: 0; }\n.hi-v4-menu-fat-menu ul li {\n list-style-type: none; }\n.hi-v4-menu-popmenu {\n background-color: #fff;\n background-color: var(--hi-v4-color-static-white, #fff);\n border-radius: 4px;\n border-radius: var(--hi-v4-border-radius-normal, 4px);\n margin: 0;\n font-size: 0.875rem;\n font-size: var(--hi-v4-text-size-normal, 0.875rem);\n padding: 8px;\n padding: var(--hi-v4-spacing-4, 8px);\n color: #1f2733;\n color: var(--hi-v4-color-gray-700, #1f2733); }\n.hi-v4-menu-popmenu .hi-v4-menu-item {\n height: 40px;\n margin: 0; }\n.hi-v4-menu-popmenu .hi-v4-menu-item__inner {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n height: 40px;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin-bottom: 8px;\n margin-bottom: var(--hi-v4-spacing-4, 8px);\n padding: 0 12px;\n padding: 0 var(--hi-v4-spacing-6, 12px);\n border-radius: 4px;\n border-radius: var(--hi-v4-border-radius-normal, 4px); }\n.hi-v4-menu-popmenu .hi-v4-menu-item__inner--active {\n color: #237ffa;\n color: var(--hi-v4-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));\n background-color: #e2f3fe;\n background-color: var(--hi-v4-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }\n.hi-v4-menu-popmenu .hi-v4-menu-item__inner--active-p {\n color: #237ffa;\n color: var(--hi-v4-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu-popmenu .hi-v4-menu-item__inner:not(.hi-v4-menu-item__inner--active):hover {\n background-color: #f2f4f7;\n background-color: var(--hi-v4-color-gray-100, #f2f4f7); }\n.hi-v4-menu-popmenu .hi-v4-menu-item__content {\n -webkit-box-flex: 1;\n -ms-flex: 1 1;\n flex: 1 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 100px;\n padding-right: 8px;\n padding-right: var(--hi-v4-spacing-4, 8px); }\n.hi-v4-menu {\n background-color: #fff;\n background-color: var(--hi-v4-color-static-white, #fff);\n color: #1f2733;\n color: var(--hi-v4-color-gray-700, #1f2733);\n font-size: 0.875rem;\n font-size: var(--hi-v4-text-size-normal, 0.875rem);\n line-height: 1.375rem;\n line-height: var(--hi-v4-text-lineheight-normal, 1.375rem);\n -webkit-box-sizing: border-box;\n box-sizing: border-box; }\n.hi-v4-menu ul {\n margin: 0;\n padding: 0; }\n.hi-v4-menu-item {\n list-style: none;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n cursor: pointer;\n -webkit-transition: all 0.3s;\n transition: all 0.3s; }\n.hi-v4-menu__wrapper {\n padding: 0;\n margin: 0; }\n.hi-v4-menu--horizontal {\n width: 100%;\n overflow: auto; }\n.hi-v4-menu--horizontal .hi-v4-menu__wrapper {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex; }\n.hi-v4-menu--horizontal .hi-v4-menu-item {\n margin: 0 20px;\n margin: 0 var(--hi-v4-spacing-10, 20px);\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n height: 56px;\n border-bottom: 2px solid transparent;\n font-size: 1rem;\n font-size: var(--hi-v4-text-size-lg, 1rem); }\n.hi-v4-menu--horizontal .hi-v4-menu-item:hover {\n color: #237ffa;\n color: var(--hi-v4-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));\n border-bottom: 2px solid #237ffa;\n border-bottom: 2px solid var(--hi-v4-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--horizontal .hi-v4-menu-item--active {\n color: #237ffa;\n color: var(--hi-v4-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));\n border-bottom: 2px solid #237ffa;\n border-bottom: 2px solid var(--hi-v4-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--horizontal .hi-v4-menu-item--active-p {\n color: #237ffa;\n color: var(--hi-v4-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--horizontal .hi-v4-menu-item__inner {\n height: 100%;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center; }\n.hi-v4-menu--horizontal .hi-v4-menu-item__content {\n -webkit-box-flex: 1;\n -ms-flex: 1 1;\n flex: 1 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 100px; }\n.hi-v4-menu--vertical {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n padding: 8px;\n padding: var(--hi-v4-spacing-4, 8px);\n width: 232px;\n height: 100%;\n -webkit-transition: width 0.3s;\n transition: width 0.3s; }\n.hi-v4-menu--vertical .hi-v4-menu__wrapper {\n -webkit-box-flex: 1;\n -ms-flex: 1 1;\n flex: 1 1;\n overflow: auto; }\n.hi-v4-menu--vertical.hi-v4-menu--mini {\n width: 56px;\n overflow-x: hidden; }\n.hi-v4-menu--vertical .hi-v4-menu__toggle {\n width: 40px;\n cursor: pointer;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n border-radius: 4px;\n border-radius: var(--hi-v4-border-radius-normal, 4px);\n height: 40px; }\n.hi-v4-menu--vertical .hi-v4-menu__toggle:hover {\n background-color: #f2f4f7;\n background-color: var(--hi-v4-color-gray-100, #f2f4f7); }\n.hi-v4-menu--vertical .hi-v4-menu-item__inner {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n height: 40px;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin-bottom: 8px;\n margin-bottom: var(--hi-v4-spacing-4, 8px);\n padding: 0 12px;\n padding: 0 var(--hi-v4-spacing-6, 12px);\n border-radius: 4px;\n border-radius: var(--hi-v4-border-radius-normal, 4px);\n -webkit-transition: all 0.3s;\n transition: all 0.3s; }\n.hi-v4-menu--vertical .hi-v4-menu-item__inner--active {\n color: #237ffa;\n color: var(--hi-v4-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));\n background-color: #e2f3fe;\n background-color: var(--hi-v4-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }\n.hi-v4-menu--vertical .hi-v4-menu-item__inner--active-p {\n color: #237ffa;\n color: var(--hi-v4-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--vertical .hi-v4-menu-item__inner:not(.hi-v4-menu-item__inner--active):hover {\n background-color: #f2f4f7;\n background-color: var(--hi-v4-color-gray-100, #f2f4f7); }\n.hi-v4-menu--vertical .hi-v4-menu-item svg[class^=hi-v4-icon] {\n -ms-flex-negative: 0;\n flex-shrink: 0;\n margin-right: 8px;\n margin-right: var(--hi-v4-spacing-4, 8px);\n margin-left: 1px; }\n.hi-v4-menu--vertical .hi-v4-menu-item__content {\n -webkit-box-flex: 1;\n -ms-flex: 1 1;\n flex: 1 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n text-indent: 0.5px; }\n";
|
|
11
|
-
|
|
12
|
-
var __styleInject__ = require('style-inject/dist/style-inject.es.js')["default"];
|
|
10
|
+
import __styleInject__ from 'inject-head-style';
|
|
11
|
+
var css_248z = ".hi-v4-menu-fat-menu {background-color: var(--hi-v4-color-static-white, #fff);margin: 0;font-size: var(--hi-v4-text-size-md, 0.875rem);padding: var(--hi-v4-spacing-4, 8px);display: -webkit-box;display: -ms-flexbox;display: flex;color: var(--hi-v4-color-gray-700, #1f2733);border-radius: var(--hi-v4-border-radius-md, 4px);-ms-flex-wrap: wrap;flex-wrap: wrap; }.hi-v4-menu-fat-menu__group:not(:last-of-type) {margin-right: var(--hi-v4-spacing-18, 36px); }.hi-v4-menu-fat-menu .hi-v4-menu-group-item {height: 40px;margin: 0;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;padding: 0 var(--hi-v4-spacing-6, 12px);color: var(--hi-v4-color-gray-500, #929aa6); }.hi-v4-menu-fat-menu .hi-v4-menu-item {height: 40px;margin: 0;border-radius: var(--hi-v4-border-radius-md, 4px);display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;padding: 0 var(--hi-v4-spacing-4, 8px) 0 var(--hi-v4-spacing-6, 12px); }.hi-v4-menu-fat-menu .hi-v4-menu-item--active {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background-color: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }.hi-v4-menu-fat-menu .hi-v4-menu-item:not(.hi-v4-menu-item--active):hover {background-color: var(--hi-v4-color-gray-100, #f2f4f7); }.hi-v4-menu-fat-menu ul {padding: 0;margin: 0; }.hi-v4-menu-fat-menu ul li {list-style-type: none; }.hi-v4-menu-popmenu {background-color: var(--hi-v4-color-static-white, #fff);border-radius: var(--hi-v4-border-radius-md, 4px);margin: 0;font-size: var(--hi-v4-text-size-md, 0.875rem);padding: var(--hi-v4-spacing-4, 8px);color: var(--hi-v4-color-gray-700, #1f2733);width: 216px;-webkit-box-sizing: border-box;box-sizing: border-box; }.hi-v4-menu-popmenu .hi-v4-menu-item {height: 40px;margin: 0; }.hi-v4-menu-popmenu .hi-v4-menu-item__inner {-webkit-box-sizing: border-box;box-sizing: border-box;height: 40px;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;margin-bottom: var(--hi-v4-spacing-4, 8px);padding: 0 var(--hi-v4-spacing-4, 8px) 0 var(--hi-v4-spacing-6, 12px);border-radius: var(--hi-v4-border-radius-md, 4px); }.hi-v4-menu-popmenu .hi-v4-menu-item__inner--active {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background-color: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }.hi-v4-menu-popmenu .hi-v4-menu-item__inner--active-p {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu-popmenu .hi-v4-menu-item__inner--expanded {background-color: var(--hi-v4-color-gray-100, #f2f4f7); }.hi-v4-menu-popmenu .hi-v4-menu-item__inner:not(.hi-v4-menu-item__inner--active):hover {background-color: var(--hi-v4-color-gray-100, #f2f4f7); }.hi-v4-menu-popmenu .hi-v4-menu-item__content {-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width: 100%;padding-right: var(--hi-v4-spacing-4, 8px); }.hi-v4-menu {background-color: var(--hi-v4-color-static-white, #fff);color: var(--hi-v4-color-gray-700, #1f2733);font-size: var(--hi-v4-text-size-md, 0.875rem);line-height: var(--hi-v4-text-lineheight-md, 1.375rem);-webkit-box-sizing: border-box;box-sizing: border-box; }.hi-v4-menu ul {margin: 0;padding: 0; }.hi-v4-menu-item {list-style: none;-webkit-box-sizing: border-box;box-sizing: border-box;cursor: pointer;-webkit-transition: all 0.3s;transition: all 0.3s; }.hi-v4-menu-item__icon {color: var(--hi-v4-color-gray-500, #929aa6);-webkit-margin-end: var(--hi-v4-spacing-4, 8px);margin-inline-end: var(--hi-v4-spacing-4, 8px); }.hi-v4-menu-item__icon svg[class^=hi-v4-icon] {font-size: var(--hi-v4-text-size-lg, 1rem); }.hi-v4-menu-item__arrow {color: var(--hi-v4-color-gray-500, #929aa6);font-size: var(--hi-v4-text-size-lg, 1rem); }.hi-v4-menu-item__indent {display: inline-block;width: 24px;height: 100%;-ms-flex-negative: 0;flex-shrink: 0; }.hi-v4-menu__wrapper {padding: 0;margin: 0; }.hi-v4-menu--horizontal {width: 100%;overflow-x: auto; }.hi-v4-menu--horizontal .hi-v4-menu__wrapper {display: -webkit-box;display: -ms-flexbox;display: flex;overflow: visible;width: -webkit-max-content;width: -moz-max-content;width: max-content;-webkit-box-sizing: border-box;box-sizing: border-box; }.hi-v4-menu--horizontal .hi-v4-menu-item {margin: 0 var(--hi-v4-spacing-10, 20px);display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-pack: center;-ms-flex-pack: center;justify-content: center;-webkit-box-align: center;-ms-flex-align: center;align-items: center;height: 56px;border: none;font-size: var(--hi-v4-text-size-lg, 1rem); }.hi-v4-menu--horizontal .hi-v4-menu-item__arrow {-webkit-margin-start: var(--hi-v4-spacing-2, 4px);margin-inline-start: var(--hi-v4-spacing-2, 4px); }.hi-v4-menu--horizontal .hi-v4-menu-item:hover {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu--horizontal .hi-v4-menu-item:hover .hi-v4-menu-item__inner {border-bottom: 2px solid var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu--horizontal .hi-v4-menu-item--active {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu--horizontal .hi-v4-menu-item--active .hi-v4-menu-item__inner {border-bottom: 2px solid var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu--horizontal .hi-v4-menu-item--active .hi-v4-menu-item__icon {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu--horizontal .hi-v4-menu-item--active-p {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu--horizontal .hi-v4-menu-item--active-p .hi-v4-menu-item__icon {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu--horizontal .hi-v4-menu-item__inner {height: 100%;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;-webkit-box-sizing: border-box;box-sizing: border-box;border-bottom: 2px solid transparent; }.hi-v4-menu--horizontal .hi-v4-menu-item__inner--expanded {border-bottom: 2px solid var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu--horizontal .hi-v4-menu-item__content {-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;white-space: nowrap;max-width: none; }.hi-v4-menu--vertical {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;padding: var(--hi-v4-spacing-4, 8px);width: 216px;-webkit-box-sizing: border-box;box-sizing: border-box;height: 100%;-webkit-transition: width 0.3s;transition: width 0.3s; }.hi-v4-menu--vertical .hi-v4-menu__wrapper {-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;overflow: auto; }.hi-v4-menu--vertical.hi-v4-menu--mini {width: 56px;overflow-x: hidden; }.hi-v4-menu--vertical.hi-v4-menu--popup .hi-v4-menu-item__inner--expanded {background-color: var(--hi-v4-color-gray-100, #f2f4f7); }.hi-v4-menu--vertical .hi-v4-menu__toggle {width: 40px;cursor: pointer;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;-webkit-box-pack: center;-ms-flex-pack: center;justify-content: center;border-radius: var(--hi-v4-border-radius-md, 4px);color: var(--hi-v4-color-gray-500, #929aa6);height: 40px;-webkit-transition-duration: var(--hi-v4-motion-duration-normal, 200ms);transition-duration: var(--hi-v4-motion-duration-normal, 200ms);-webkit-transition-timing-function: var(--hi-v4-motion-bezier-easing, cubic-bezier(0.37, 0.02, 0.34, 1));transition-timing-function: var(--hi-v4-motion-bezier-easing, cubic-bezier(0.37, 0.02, 0.34, 1));-webkit-transition-property: background-color;transition-property: background-color; }.hi-v4-menu--vertical .hi-v4-menu__toggle:hover {background-color: var(--hi-v4-color-gray-100, #f2f4f7); }.hi-v4-menu--vertical .hi-v4-menu-item__inner {-webkit-box-sizing: border-box;box-sizing: border-box;height: 40px;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;margin-bottom: var(--hi-v4-spacing-4, 8px);padding: 0 var(--hi-v4-spacing-4, 8px) 0 var(--hi-v4-spacing-6, 12px);border-radius: var(--hi-v4-border-radius-md, 4px);-webkit-transition: all 0.3s;transition: all 0.3s; }.hi-v4-menu--vertical .hi-v4-menu-item__inner--active {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background-color: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }.hi-v4-menu--vertical .hi-v4-menu-item__inner--active .hi-v4-menu-item__icon {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu--vertical .hi-v4-menu-item__inner--active-p {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu--vertical .hi-v4-menu-item__inner--active-p .hi-v4-menu-item__icon {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-menu--vertical .hi-v4-menu-item__inner:not(.hi-v4-menu-item__inner--active):hover {background-color: var(--hi-v4-color-gray-100, #f2f4f7); }.hi-v4-menu--vertical .hi-v4-menu-item__content {-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;text-indent: 0.5px; }";
|
|
13
12
|
|
|
14
13
|
__styleInject__(css_248z);
|
|
15
14
|
|
|
16
|
-
export default
|
|
17
|
-
//# sourceMappingURL=index.scss.js.map
|
|
15
|
+
export { css_248z as default };
|
package/lib/esm/util.js
CHANGED
package/lib/types/Menu.d.ts
CHANGED
|
@@ -1,50 +1,65 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { HiBaseHTMLProps } from '@hi-ui/core';
|
|
3
|
+
import { MenuDataItem } from './types';
|
|
2
4
|
/**
|
|
3
5
|
* TODO: What is Menu
|
|
4
6
|
*/
|
|
5
7
|
export declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLDivElement | null>>;
|
|
6
|
-
export
|
|
8
|
+
export interface MenuProps extends Omit<HiBaseHTMLProps<'div'>, 'onClick'> {
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
10
|
+
* 菜单项数据列表
|
|
9
11
|
*/
|
|
10
|
-
|
|
11
|
-
title: React.ReactNode;
|
|
12
|
-
icon?: React.ReactNode;
|
|
13
|
-
id: React.ReactText;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
children?: MenuItemProps[];
|
|
16
|
-
level?: number;
|
|
17
|
-
parentIds?: React.ReactText[];
|
|
18
|
-
};
|
|
19
|
-
export interface MenuProps {
|
|
12
|
+
data: MenuDataItem[];
|
|
20
13
|
/**
|
|
21
|
-
*
|
|
14
|
+
* 默认激活的菜单项 id
|
|
22
15
|
*/
|
|
23
|
-
|
|
16
|
+
defaultActiveId?: React.ReactText;
|
|
24
17
|
/**
|
|
25
|
-
*
|
|
18
|
+
* 激活的菜单项 id
|
|
26
19
|
*/
|
|
27
|
-
|
|
20
|
+
activeId?: React.ReactText;
|
|
28
21
|
/**
|
|
29
|
-
*
|
|
22
|
+
* 设置菜单水平或垂直展示
|
|
30
23
|
*/
|
|
31
|
-
|
|
24
|
+
placement?: 'horizontal' | 'vertical';
|
|
32
25
|
/**
|
|
33
|
-
*
|
|
26
|
+
* 是否收起子菜单,菜单垂直展示时有效
|
|
34
27
|
*/
|
|
35
|
-
data: MenuItemProps[];
|
|
36
|
-
activeId?: React.ReactText;
|
|
37
|
-
placement?: 'horizontal' | 'vertical';
|
|
38
28
|
collapsed?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* 是否显示收缩开关,菜单垂直展示时有效
|
|
31
|
+
*/
|
|
39
32
|
showCollapse?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 是否以胖菜单的形式展开所有子菜单(仅在水平菜单时有效)
|
|
35
|
+
*/
|
|
40
36
|
showAllSubMenus?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 手风琴模式,菜单水平展示时有效
|
|
39
|
+
*/
|
|
41
40
|
accordion?: boolean;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
onCollapse?: (collapsed: boolean) => void;
|
|
41
|
+
/**
|
|
42
|
+
* 下拉框根类名
|
|
43
|
+
*/
|
|
46
44
|
overlayClassName?: string;
|
|
45
|
+
/**
|
|
46
|
+
* 弹出层展开方式
|
|
47
|
+
*/
|
|
47
48
|
expandedType?: 'collapse' | 'pop';
|
|
49
|
+
/**
|
|
50
|
+
* 默认展开菜单项 ids 列表
|
|
51
|
+
*/
|
|
48
52
|
defaultExpandedIds?: React.ReactText[];
|
|
49
|
-
|
|
53
|
+
/**
|
|
54
|
+
* 点击菜单选项时的回调
|
|
55
|
+
*/
|
|
56
|
+
onClick?: (menuId: React.ReactText) => void;
|
|
57
|
+
/**
|
|
58
|
+
* 点击父菜单项时的回调
|
|
59
|
+
*/
|
|
60
|
+
onClickSubMenu?: (subMenuId: React.ReactText, expandedIds: React.ReactText[]) => void;
|
|
61
|
+
/**
|
|
62
|
+
* 点击收缩开关时的回调
|
|
63
|
+
*/
|
|
64
|
+
onCollapse?: (collapsed: boolean) => void;
|
|
50
65
|
}
|
package/lib/types/MenuItem.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare const MenuItem: React.
|
|
2
|
+
import { HiBaseHTMLProps } from '@hi-ui/core';
|
|
3
|
+
export declare const MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLLIElement | null>>;
|
|
4
|
+
export interface MenuItemProps extends Omit<HiBaseHTMLProps<'li'>, 'id'> {
|
|
5
|
+
id: React.ReactText;
|
|
6
|
+
title: React.ReactNode;
|
|
7
|
+
icon?: React.ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
children?: MenuItemProps[];
|
|
10
|
+
level?: number;
|
|
11
|
+
parentIds?: React.ReactText[];
|
|
12
|
+
}
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/types.d.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface MenuDataItem {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 菜单项唯一标识
|
|
5
5
|
*/
|
|
6
6
|
id: React.ReactText;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* 菜单项标题
|
|
9
9
|
*/
|
|
10
10
|
title: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* 菜单项 icon
|
|
13
|
+
*/
|
|
14
|
+
icon?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* 菜单项是否禁止点击
|
|
17
|
+
*/
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 子菜单项配置
|
|
21
|
+
*/
|
|
22
|
+
children?: MenuDataItem[];
|
|
11
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hi-ui/menu",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.22",
|
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "HIUI <mi-hiui@xiaomi.com>",
|
|
@@ -43,13 +43,18 @@
|
|
|
43
43
|
"url": "https://github.com/XiaoMi/hiui/issues"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
+
"@hi-ui/array-utils": "^4.0.0-beta.8",
|
|
46
47
|
"@hi-ui/classname": "^4.0.0-beta.0",
|
|
47
|
-
"@hi-ui/core": "^4.0.0-beta.
|
|
48
|
-
"@hi-ui/core-css": "^4.0.0-beta.
|
|
49
|
-
"@hi-ui/env": "^4.0.0-beta.
|
|
50
|
-
"@hi-ui/icons": "^4.0.0-beta.
|
|
51
|
-
"@hi-ui/popper": "^4.0.0-beta.
|
|
52
|
-
"@hi-ui/
|
|
48
|
+
"@hi-ui/core": "^4.0.0-beta.9",
|
|
49
|
+
"@hi-ui/core-css": "^4.0.0-beta.5",
|
|
50
|
+
"@hi-ui/env": "^4.0.0-beta.1",
|
|
51
|
+
"@hi-ui/icons": "^4.0.0-beta.11",
|
|
52
|
+
"@hi-ui/popper": "^4.0.0-beta.18",
|
|
53
|
+
"@hi-ui/times": "^4.0.0-beta.6",
|
|
54
|
+
"@hi-ui/tooltip": "^4.0.0-beta.23",
|
|
55
|
+
"@hi-ui/type-assertion": "^4.0.0-beta.5",
|
|
56
|
+
"@hi-ui/use-merge-refs": "^4.0.0-beta.5",
|
|
57
|
+
"@hi-ui/use-uncontrolled-state": "^4.0.0-beta.5",
|
|
53
58
|
"react-transition-group": "^4.4.2"
|
|
54
59
|
},
|
|
55
60
|
"peerDependencies": {
|
|
@@ -57,9 +62,9 @@
|
|
|
57
62
|
"react-dom": ">=16.8.6"
|
|
58
63
|
},
|
|
59
64
|
"devDependencies": {
|
|
60
|
-
"@hi-ui/hi-build": "^4.0.0-beta.
|
|
65
|
+
"@hi-ui/hi-build": "^4.0.0-beta.5",
|
|
61
66
|
"react": "^17.0.1",
|
|
62
67
|
"react-dom": "^17.0.1"
|
|
63
68
|
},
|
|
64
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "b714e09d5c7a7d4bfe7c03cc58422365b3688f3c"
|
|
65
70
|
}
|
package/lib/cjs/Expander.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Expander.js","sources":["../../src/Expander.tsx"],"sourcesContent":[null],"names":["Expander","children","visible","className","useState","height","setHeight","React","CSSTransition","in","timeout","classNames","unmountOnExit","onEnter","element","setTimeout","scrollHeight","onEntered","onExit","style","overflow","transition"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGaA,QAAQ,GAA4B,SAApCA,QAAoC,KAAA;MAAGC,gBAAAA;MAAUC,eAAAA;MAASC,iBAAAA;;kBACzCC,cAAAA,CAASF,OAAO,GAAG,MAAH,GAAY,CAA5BE;MAArBC,MAAP;MAAeC,SAAf;;sBAEEC,yBAAAA,cAAAA,CAACC,kCAADD;AACEE,UAAIP;AACJQ,IAAAA,OAAO,EAAE;AACTC,IAAAA,UAAU,EAAER;AACZS,IAAAA,aAAa,EAAE;AACfC,IAAAA,OAAO,EAAE,gBAAA,CAACC,OAAD;AACPR,MAAAA,SAAS,CAAC,CAAD,CAATA;AACAS,MAAAA,UAAU,CAAC;AACTT,QAAAA,SAAS,CAACQ,OAAO,CAACE,YAAT,CAATV;AADQ,OAAA,CAAVS;;AAIFE,IAAAA,SAAS,EAAE,kBAAA;AACTX,MAAAA,SAAS,CAAC,MAAD,CAATA;;AAEFY,IAAAA,MAAM,EAAE,eAAA,CAACJ,OAAD;AACNR,MAAAA,SAAS,CAACQ,OAAO,CAACE,YAAT,CAATV;AACAS,MAAAA,UAAU,CAAC;AACTT,QAAAA,SAAS,CAAC,CAAD,CAATA;AADQ,OAAA,CAAVS;;GAhBJR,eAqBEA,yBAAAA,cAAAA,MAAAA;AAAKY,IAAAA,KAAK,EAAE;AAAEd,MAAAA,MAAM,EAANA,MAAF;AAAUe,MAAAA,QAAQ,EAAE,QAApB;AAA8BC,MAAAA,UAAU,EAAE;AAA1C;GAAZd,EAAqEN,QAArEM,CArBFA;;;"}
|
package/lib/cjs/Menu.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.js","sources":["../../src/Menu.tsx"],"sourcesContent":[null],"names":["MENU_PREFIX","getPrefixCls","Menu","forwardRef","_a","ref","prefixCls","role","className","data","placement","showCollapse","expandedType","showAllSubMenus","defaultExpandedIds","defaultActiveId","activeId","onClickSubMenu","onClick","rest","useUncontrolledState","_activeId","updateActiveId","useState","getAncestorIds","activeParents","updateActiveParents","useEffect","_expandedIds","updateExpanedIds","clickMenu","useCallback","id","clickSubMenu","expandedIds","includes","filter","expandedid","concat","closePopper","closeAllPopper","mini","setMini","cls","cx","onToggle","React","MenuContext","Provider","value","map","d","MenuItem","key","level","MenuUnfoldOutlined","MenuFoldOutlined","__DEV__","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,WAAW,GAAGC,sBAAAA,CAAa,MAAbA,CAApB;AAEA;;;;IAGaC,IAAI,gBAAGC,gBAAAA,CAClB,UACEC,EADF,EAiBEC,GAjBF;;;wBAEIC;MAAAA,sCAAYN;mBACZO;MAAAA,4BAAO;MACPC,eAAAA;MACAC,UAAAA;wBACAC;MAAAA,sCAAY;MACZC,kBAAAA;2BACAC;MAAAA,4CAAe;8BACfC;MAAAA,kDAAkB;MAClBC,wBAAAA;MACAC,qBAAAA;MACAC,cAAAA;MACAC,oBAAAA;MACAC,aAAAA;MACGC,wBAdL,YAAA,QAAA,aAAA,QAAA,aAAA,gBAAA,gBAAA,mBAAA,sBAAA,mBAAA,YAAA,kBAAA,WAAA;;8BAkBoCC,yCAAAA,CAClCL,eAAe,IAAI,EADeK,EAElCJ,QAFkCI,EAGlCF,OAHkCE;MAA7BC,SAAP;MAAkBC,cAAlB;;kBAM6CC,cAAAA,CAASC,mBAAAA,CAAeH,SAAfG,EAA0Bf,IAA1Be,CAATD;MAAtCE,aAAP;MAAsBC,mBAAtB;;AACAC,EAAAA,eAAAA,CAAU;AACRD,IAAAA,mBAAmB,CAACF,mBAAAA,CAAeH,SAAfG,EAA0Bf,IAA1Be,CAAD,CAAnBE;AADO,GAATC,EAEG,CAACN,SAAD,EAAYZ,IAAZ,CAFHkB;;mBAGyCJ,cAAAA,CAAST,kBAAkB,IAAI,EAA/BS;MAAlCK,YAAP;MAAqBC,gBAArB;;MAEMC,SAAS,GAAGC,iBAAAA,CAChB,UAACC,EAAD;AACEV,IAAAA,cAAc,CAACU,EAAD,CAAdV;AAFyB,GAAXS,EAIhB,CAACT,cAAD,CAJgBS;MAMZE,YAAY,GAAGF,iBAAAA,CACnB,UAACC,EAAD;QACQE,WAAW,GAAGN,YAAY,CAACO,QAAbP,CAAsBI,EAAtBJ,IAClBA,YAAY,CAACQ,MAAbR,CAAoB,UAACS,UAAD;aAAgBA,UAAU,KAAKL;AAAnD,KAAAJ,CADkBA,GAElBA,YAAY,CAACU,MAAbV,CAAoBI,EAApBJ;AACFC,IAAAA,gBAAgB,CAACK,WAAD,CAAhBL;;QACIZ,gBAAgB;AAClBA,MAAAA,cAAc,CAACe,EAAD,EAAKE,WAAL,CAAdjB;;AAP0B,GAAXc,EAUnB,CAACd,cAAD,EAAiBW,YAAjB,CAVmBG;MAafQ,WAAW,GAAGR,iBAAAA,CAClB,UAACC,EAAD;AACEH,IAAAA,gBAAgB,CAACD,YAAY,CAACQ,MAAbR,CAAoB,UAACS,UAAD;aAAgBA,UAAU,KAAKL;AAAnD,KAAAJ,CAAD,CAAhBC;AAF2B,GAAXE,EAIlB,CAACH,YAAD,CAJkBG;MAOdS,cAAc,GAAGT,iBAAAA,CAAY;AACjCF,IAAAA,gBAAgB,CAAC,EAAD,CAAhBA;AADgC,GAAXE,EAEpB,EAFoBA;;mBAICR,cAAAA,CAAS,KAATA;MAAjBkB,IAAP;MAAaC,OAAb;;MACMC,GAAG,GAAGC,YAAAA,CAAGtC,SAAHsC,EAAcpC,SAAdoC,EAA4BtC,SAA1B,OAA0BA,GAAcI,SAA1CkC,iBACNtC,SADQ,eACYmC,SADdG;MAINC,QAAQ,GAAGd,iBAAAA,CAAY;AAC3BW,IAAAA,OAAO,CAAC,CAACD,IAAF,CAAPC;AACAF,IAAAA,cAAc;AAFY,GAAXT,EAGd,CAACU,IAAD,EAAOD,cAAP,CAHcT;sBAMfe,yBAAAA,cAAAA,MAAAA;AAAKzC,IAAAA,GAAG,EAAEA;AAAKE,IAAAA,IAAI,EAAEA;AAAMC,IAAAA,SAAS,EAAEmC;KAASxB,KAA/C2B,eACEA,yBAAAA,cAAAA,CAACC,kBAAAA,CAAYC,QAAbF;AACEG,IAAAA,KAAK,EAAE;AACLvC,MAAAA,SAAS,EAATA,SADK;AAELE,MAAAA,YAAY,EAAZA,YAFK;AAGLC,MAAAA,eAAe,EAAfA,eAHK;AAIL4B,MAAAA,IAAI,EAAJA,IAJK;AAKLX,MAAAA,SAAS,EAATA,SALK;AAMLG,MAAAA,YAAY,EAAZA,YANK;AAOLM,MAAAA,WAAW,EAAXA,WAPK;AAQLC,MAAAA,cAAc,EAAdA,cARK;AASLf,MAAAA,aAAa,EAAbA,aATK;AAULT,MAAAA,QAAQ,EAAEK,SAVL;AAWLa,MAAAA,WAAW,EAAEN;AAXR;GADTkB,eAeEA,yBAAAA,cAAAA,KAAAA;AAAItC,IAAAA,SAAS,EAAEoC,YAAAA,CAAMtC,SAAJ,cAAFsC;GAAfE,EACGrC,IAAI,CAACyC,GAALzC,CAAS,UAAC0C,CAAD;wBACRL,yBAAAA,cAAAA,CAACM,iBAADN,oBAAcK;AAAGE,MAAAA,GAAG,EAAEF,CAAC,CAACnB;AAAIsB,MAAAA,KAAK,EAAE;MAAnCR;AADD,GAAArC,CADHqC,CAfFA,EAoBGpC,SAAS,KAAK,UAAdA,IAA4BC,YAA5BD,iBACCoC,yBAAAA,cAAAA,MAAAA;AAAKtC,IAAAA,SAAS,EAAEoC,YAAAA,CAAMtC,SAAJ,aAAFsC;AAA4B1B,IAAAA,OAAO,EAAE2B;GAArDC,EACGL,IAAI,gBAAGK,yBAAAA,cAAAA,CAACS,wBAADT,MAAAA,CAAH,gBAA4BA,yBAAAA,cAAAA,CAACU,sBAADV,MAAAA,CADnCA,CArBJA,CADFA;AAzEwB,CAAV3C;;AAsJpB,IAAIsD,WAAJ,EAAa;AACXvD,EAAAA,IAAI,CAACwD,WAALxD,GAAmB,MAAnBA;;;"}
|