@hi-ui/menu 4.0.8 → 4.1.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/CHANGELOG.md +21 -0
- package/lib/cjs/Menu.js +24 -17
- package/lib/cjs/MenuItem.js +34 -18
- package/lib/cjs/styles/index.scss.js +2 -2
- package/lib/esm/Menu.js +21 -14
- package/lib/esm/MenuItem.js +32 -16
- package/lib/esm/styles/index.scss.js +2 -2
- package/lib/types/Menu.d.ts +14 -2
- package/lib/types/MenuItem.d.ts +2 -1
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @hi-ui/menu
|
|
2
2
|
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2576](https://github.com/XiaoMi/hiui/pull/2576) [`ccb1eec12`](https://github.com/XiaoMi/hiui/commit/ccb1eec122a33466536b365d443f175d1e16dc86) Thanks [@zyprepare](https://github.com/zyprepare)! - feat: 增加 render 和 extraHeader API
|
|
8
|
+
|
|
9
|
+
- [#2577](https://github.com/XiaoMi/hiui/pull/2577) [`2f094567e`](https://github.com/XiaoMi/hiui/commit/2f094567e678235e75ff5c443dce1ee09c3bd115) Thanks [@zyprepare](https://github.com/zyprepare)! - feat: 增加 size API
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`937052db3`](https://github.com/XiaoMi/hiui/commit/937052db36ecfa50fef53df13d159bee0d08fa41), [`ccb1eec12`](https://github.com/XiaoMi/hiui/commit/ccb1eec122a33466536b365d443f175d1e16dc86), [`eee5e6d16`](https://github.com/XiaoMi/hiui/commit/eee5e6d1658685a6119b5aa40038c572145b3b4e)]:
|
|
14
|
+
- @hi-ui/icons@4.0.14
|
|
15
|
+
- @hi-ui/popper@4.1.0
|
|
16
|
+
- @hi-ui/tree-utils@4.1.1
|
|
17
|
+
|
|
18
|
+
## 4.0.9
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [#2545](https://github.com/XiaoMi/hiui/pull/2545) [`a2f9f569a`](https://github.com/XiaoMi/hiui/commit/a2f9f569aefad8d4956db021510163ed8993887c) Thanks [@zyprepare](https://github.com/zyprepare)! - fix: 体验优化
|
|
23
|
+
|
|
3
24
|
## 4.0.8
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/lib/cjs/Menu.js
CHANGED
|
@@ -25,12 +25,6 @@ var icons = require('@hi-ui/icons');
|
|
|
25
25
|
|
|
26
26
|
var env = require('@hi-ui/env');
|
|
27
27
|
|
|
28
|
-
var MenuItem = require('./MenuItem.js');
|
|
29
|
-
|
|
30
|
-
var context = require('./context.js');
|
|
31
|
-
|
|
32
|
-
var util = require('./util.js');
|
|
33
|
-
|
|
34
28
|
var useUncontrolledState = require('@hi-ui/use-uncontrolled-state');
|
|
35
29
|
|
|
36
30
|
var Tooltip = require('@hi-ui/tooltip');
|
|
@@ -47,6 +41,12 @@ var useMergeRefs = require('@hi-ui/use-merge-refs');
|
|
|
47
41
|
|
|
48
42
|
var useId = require('@hi-ui/use-id');
|
|
49
43
|
|
|
44
|
+
var MenuItem = require('./MenuItem.js');
|
|
45
|
+
|
|
46
|
+
var context = require('./context.js');
|
|
47
|
+
|
|
48
|
+
var util = require('./util.js');
|
|
49
|
+
|
|
50
50
|
function _interopDefaultLegacy(e) {
|
|
51
51
|
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
52
52
|
'default': e
|
|
@@ -63,7 +63,7 @@ var NOOP_ARRAY = [];
|
|
|
63
63
|
var MIN_WIDTH = 56;
|
|
64
64
|
var MENU_MORE_ID = "MENU_MORE_" + useId.uuid();
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* 菜单
|
|
67
67
|
*/
|
|
68
68
|
|
|
69
69
|
var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
@@ -98,8 +98,12 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
98
98
|
overlayClassName = _a.overlayClassName,
|
|
99
99
|
onCollapse = _a.onCollapse,
|
|
100
100
|
footerRender = _a.footerRender,
|
|
101
|
+
render = _a.render,
|
|
102
|
+
extraHeader = _a.extraHeader,
|
|
101
103
|
onClick = _a.onClick,
|
|
102
|
-
|
|
104
|
+
_a$size = _a.size,
|
|
105
|
+
size = _a$size === void 0 ? 'lg' : _a$size,
|
|
106
|
+
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "data", "placement", "showCollapse", "expandedType", "showAllSubMenus", "defaultExpandAll", "defaultExpandedIds", "expandedIds", "onExpand", "defaultActiveId", "activeId", "onClickSubMenu", "collapsed", "defaultCollapsed", "overlayClassName", "onCollapse", "footerRender", "render", "extraHeader", "onClick", "size"]);
|
|
103
107
|
|
|
104
108
|
var _useUncontrolledState = useUncontrolledState.useUncontrolledState(defaultActiveId, activeIdProp, onClick),
|
|
105
109
|
activeId = _useUncontrolledState[0],
|
|
@@ -235,7 +239,11 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
235
239
|
var renderFooter = function renderFooter() {
|
|
236
240
|
var collapseNode = canToggle ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
237
241
|
className: classname.cx(prefixCls + "__toggle"),
|
|
238
|
-
onClick:
|
|
242
|
+
onClick: function onClick() {
|
|
243
|
+
miniToggleAction.not(); // 关闭所有展开的子菜单,防止切换到 mini 模式后,子菜单还是展开的
|
|
244
|
+
|
|
245
|
+
updateExpandedIds([]);
|
|
246
|
+
}
|
|
239
247
|
}, mini ? /*#__PURE__*/React__default["default"].createElement(icons.MenuUnfoldOutlined, null) : /*#__PURE__*/React__default["default"].createElement(icons.MenuFoldOutlined, null)) : null;
|
|
240
248
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, typeAssertion.isFunction(footerRender) ? footerRender({
|
|
241
249
|
collapsed: showMini,
|
|
@@ -243,12 +251,12 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
243
251
|
}) : collapseNode);
|
|
244
252
|
};
|
|
245
253
|
|
|
246
|
-
var cls = classname.cx(prefixCls, className, prefixCls + "--" + placement, mini && prefixCls + "--mini", (expandedType === 'pop' || showAllSubMenus || mini) && prefixCls + "--popup");
|
|
254
|
+
var cls = classname.cx(prefixCls, className, prefixCls + "--" + placement, prefixCls + "--size-" + size, mini && prefixCls + "--mini", (expandedType === 'pop' || showAllSubMenus || mini) && prefixCls + "--popup");
|
|
247
255
|
return /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
|
|
248
256
|
ref: useMergeRefs.useMergeRefs(ref, setContainerElement),
|
|
249
257
|
role: role,
|
|
250
258
|
className: cls
|
|
251
|
-
}, rest), /*#__PURE__*/React__default["default"].createElement(context["default"].Provider, {
|
|
259
|
+
}, rest), extraHeader, /*#__PURE__*/React__default["default"].createElement(context["default"].Provider, {
|
|
252
260
|
value: {
|
|
253
261
|
placement: placement,
|
|
254
262
|
expandedType: expandedType,
|
|
@@ -273,13 +281,16 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
273
281
|
}, /*#__PURE__*/React__default["default"].createElement(MenuItem.MenuItem, Object.assign({}, item, {
|
|
274
282
|
level: 1,
|
|
275
283
|
render: renderMenuItemMini,
|
|
276
|
-
raw: item
|
|
284
|
+
raw: item,
|
|
285
|
+
size: size
|
|
277
286
|
}))) : /*#__PURE__*/React__default["default"].createElement(MenuItem.MenuItem, Object.assign({
|
|
278
287
|
hidden: !showVertical && index >= tagMaxCount
|
|
279
288
|
}, item, {
|
|
289
|
+
render: render,
|
|
280
290
|
key: item.id,
|
|
281
291
|
level: 1,
|
|
282
|
-
raw: item
|
|
292
|
+
raw: item,
|
|
293
|
+
size: size
|
|
283
294
|
}));
|
|
284
295
|
}), showVertical || restTagList.length === 0 ? null : /*#__PURE__*/React__default["default"].createElement(MenuItem.MenuItem, {
|
|
285
296
|
key: MENU_MORE_ID,
|
|
@@ -300,10 +311,6 @@ if (env.__DEV__) {
|
|
|
300
311
|
|
|
301
312
|
|
|
302
313
|
var renderMenuItemMini = function renderMenuItemMini(menu) {
|
|
303
|
-
if (typeof menu.icon !== 'undefined') {
|
|
304
|
-
return menu.icon;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
314
|
if (typeof menu.title === 'string') {
|
|
308
315
|
return menu.title.substring(0, 1);
|
|
309
316
|
}
|
package/lib/cjs/MenuItem.js
CHANGED
|
@@ -25,18 +25,18 @@ var env = require('@hi-ui/env');
|
|
|
25
25
|
|
|
26
26
|
var icons = require('@hi-ui/icons');
|
|
27
27
|
|
|
28
|
-
var context = require('./context.js');
|
|
29
|
-
|
|
30
28
|
var Popper = require('@hi-ui/popper');
|
|
31
29
|
|
|
32
|
-
var Expander = require('./Expander.js');
|
|
33
|
-
|
|
34
30
|
var typeAssertion = require('@hi-ui/type-assertion');
|
|
35
31
|
|
|
36
32
|
var arrayUtils = require('@hi-ui/array-utils');
|
|
37
33
|
|
|
38
34
|
var useMergeRefs = require('@hi-ui/use-merge-refs');
|
|
39
35
|
|
|
36
|
+
var context = require('./context.js');
|
|
37
|
+
|
|
38
|
+
var Expander = require('./Expander.js');
|
|
39
|
+
|
|
40
40
|
function _interopDefaultLegacy(e) {
|
|
41
41
|
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
42
42
|
'default': e
|
|
@@ -72,7 +72,9 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
72
72
|
hidden = _a$hidden === void 0 ? false : _a$hidden,
|
|
73
73
|
render = _a.render,
|
|
74
74
|
raw = _a.raw,
|
|
75
|
-
|
|
75
|
+
_a$size = _a.size,
|
|
76
|
+
size = _a$size === void 0 ? 'lg' : _a$size,
|
|
77
|
+
rest = tslib.__rest(_a, ["prefixCls", "className", "icon", "title", "disabled", "id", "level", "children", "parentIds", "hidden", "render", "raw", "size"]);
|
|
76
78
|
|
|
77
79
|
var itemRef = React.useRef(null);
|
|
78
80
|
|
|
@@ -154,7 +156,9 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
154
156
|
key: child.id,
|
|
155
157
|
level: level + 1,
|
|
156
158
|
parentIds: _parentIds,
|
|
157
|
-
raw: child
|
|
159
|
+
raw: child,
|
|
160
|
+
render: render,
|
|
161
|
+
size: size
|
|
158
162
|
}));
|
|
159
163
|
}))) : null), hasChildren && placement === 'vertical' && mini && !showAllSubMenus && expandedType === 'collapse' && (level === 1 ? /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
|
|
160
164
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -168,13 +172,15 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
168
172
|
}
|
|
169
173
|
}
|
|
170
174
|
}, /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
171
|
-
className: prefixCls + "-popmenu"
|
|
175
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
172
176
|
}, children.map(function (child) {
|
|
173
177
|
return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
|
|
174
178
|
key: child.id,
|
|
175
179
|
level: level + 1,
|
|
176
180
|
parentIds: _parentIds,
|
|
177
|
-
raw: child
|
|
181
|
+
raw: child,
|
|
182
|
+
render: render,
|
|
183
|
+
size: size
|
|
178
184
|
}));
|
|
179
185
|
}))) : /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
|
|
180
186
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -189,13 +195,15 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
189
195
|
}
|
|
190
196
|
}
|
|
191
197
|
}, /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
192
|
-
className: prefixCls + "-popmenu"
|
|
198
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
193
199
|
}, children.map(function (child) {
|
|
194
200
|
return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
|
|
195
201
|
key: child.id,
|
|
196
202
|
level: level + 1,
|
|
197
203
|
parentIds: _parentIds,
|
|
198
|
-
raw: child
|
|
204
|
+
raw: child,
|
|
205
|
+
render: render,
|
|
206
|
+
size: size
|
|
199
207
|
}));
|
|
200
208
|
})))), hasChildren && placement === 'vertical' && !showAllSubMenus && expandedType === 'pop' && (level === 1 ? /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
|
|
201
209
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -209,13 +217,15 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
209
217
|
}
|
|
210
218
|
}
|
|
211
219
|
}, /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
212
|
-
className: prefixCls + "-popmenu"
|
|
220
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
213
221
|
}, children.map(function (child) {
|
|
214
222
|
return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
|
|
215
223
|
key: child.id,
|
|
216
224
|
level: level + 1,
|
|
217
225
|
parentIds: _parentIds,
|
|
218
|
-
raw: child
|
|
226
|
+
raw: child,
|
|
227
|
+
render: render,
|
|
228
|
+
size: size
|
|
219
229
|
}));
|
|
220
230
|
}))) : /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
|
|
221
231
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -230,13 +240,15 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
230
240
|
}
|
|
231
241
|
}
|
|
232
242
|
}, /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
233
|
-
className: prefixCls + "-popmenu"
|
|
243
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
234
244
|
}, children.map(function (child) {
|
|
235
245
|
return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
|
|
236
246
|
key: child.id,
|
|
237
247
|
level: level + 1,
|
|
238
248
|
parentIds: _parentIds,
|
|
239
|
-
raw: child
|
|
249
|
+
raw: child,
|
|
250
|
+
render: render,
|
|
251
|
+
size: size
|
|
240
252
|
}));
|
|
241
253
|
})))), hasChildren && placement === 'vertical' && showAllSubMenus ? /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
|
|
242
254
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -286,13 +298,15 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
286
298
|
}
|
|
287
299
|
}
|
|
288
300
|
}, /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
289
|
-
className: prefixCls + "-popmenu"
|
|
301
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
290
302
|
}, children.map(function (child) {
|
|
291
303
|
return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
|
|
292
304
|
key: child.id,
|
|
293
305
|
level: level + 1,
|
|
294
306
|
parentIds: _parentIds,
|
|
295
|
-
raw: child
|
|
307
|
+
raw: child,
|
|
308
|
+
render: render,
|
|
309
|
+
size: size
|
|
296
310
|
}));
|
|
297
311
|
}))) : /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
|
|
298
312
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -307,13 +321,15 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
307
321
|
}
|
|
308
322
|
}
|
|
309
323
|
}, /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
310
|
-
className: prefixCls + "-popmenu"
|
|
324
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
311
325
|
}, children.map(function (child) {
|
|
312
326
|
return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
|
|
313
327
|
key: child.id,
|
|
314
328
|
level: level + 1,
|
|
315
329
|
parentIds: _parentIds,
|
|
316
|
-
raw: child
|
|
330
|
+
raw: child,
|
|
331
|
+
render: render,
|
|
332
|
+
size: size
|
|
317
333
|
}));
|
|
318
334
|
})))), hasChildren && placement === 'horizontal' && showAllSubMenus ? /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
|
|
319
335
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
|
13
13
|
value: true
|
|
14
14
|
});
|
|
15
|
-
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: hidden; }.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 {padding: 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;-ms-flex-negative: 0;flex-shrink: 0;-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;
|
|
15
|
+
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: hidden; }.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 {padding: 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;-ms-flex-negative: 0;flex-shrink: 0;-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;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);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; }.hi-v4-menu--size-lg .hi-v4-menu-item__inner {height: var(--hi-v4-height-10, 40px);margin-bottom: var(--hi-v4-spacing-4, 8px); }.hi-v4-menu--size-md .hi-v4-menu-item__inner {height: var(--hi-v4-height-9, 36px);margin-bottom: var(--hi-v4-spacing-2, 4px); }.hi-v4-menu--size-sm .hi-v4-menu-item__inner {height: var(--hi-v4-height-8, 32px);margin-bottom: var(--hi-v4-spacing-1, 2px); }";
|
|
16
16
|
|
|
17
|
-
var __styleInject__ = require('inject
|
|
17
|
+
var __styleInject__ = require('style-inject')["default"];
|
|
18
18
|
|
|
19
19
|
__styleInject__(css_248z);
|
|
20
20
|
|
package/lib/esm/Menu.js
CHANGED
|
@@ -12,9 +12,6 @@ import React, { forwardRef, useState, useEffect, useCallback, useMemo, useLayout
|
|
|
12
12
|
import { getPrefixCls, cx } from '@hi-ui/classname';
|
|
13
13
|
import { MenuUnfoldOutlined, MenuFoldOutlined } from '@hi-ui/icons';
|
|
14
14
|
import { __DEV__ } from '@hi-ui/env';
|
|
15
|
-
import { MenuItem } from './MenuItem.js';
|
|
16
|
-
import MenuContext from './context.js';
|
|
17
|
-
import { getAncestorIds } from './util.js';
|
|
18
15
|
import { useUncontrolledState } from '@hi-ui/use-uncontrolled-state';
|
|
19
16
|
import Tooltip from '@hi-ui/tooltip';
|
|
20
17
|
import { useUncontrolledToggle } from '@hi-ui/use-toggle';
|
|
@@ -23,13 +20,16 @@ import { isArrayNonEmpty, isFunction } from '@hi-ui/type-assertion';
|
|
|
23
20
|
import { useResizeObserver } from '@hi-ui/use-resize-observer';
|
|
24
21
|
import { useMergeRefs } from '@hi-ui/use-merge-refs';
|
|
25
22
|
import { uuid } from '@hi-ui/use-id';
|
|
23
|
+
import { MenuItem } from './MenuItem.js';
|
|
24
|
+
import MenuContext from './context.js';
|
|
25
|
+
import { getAncestorIds } from './util.js';
|
|
26
26
|
var MENU_PREFIX = getPrefixCls('menu');
|
|
27
27
|
var DEFAULT_EXPANDED_IDS = [];
|
|
28
28
|
var NOOP_ARRAY = [];
|
|
29
29
|
var MIN_WIDTH = 56;
|
|
30
30
|
var MENU_MORE_ID = "MENU_MORE_" + uuid();
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* 菜单
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
@@ -64,8 +64,12 @@ var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
64
64
|
overlayClassName = _a.overlayClassName,
|
|
65
65
|
onCollapse = _a.onCollapse,
|
|
66
66
|
footerRender = _a.footerRender,
|
|
67
|
+
render = _a.render,
|
|
68
|
+
extraHeader = _a.extraHeader,
|
|
67
69
|
onClick = _a.onClick,
|
|
68
|
-
|
|
70
|
+
_a$size = _a.size,
|
|
71
|
+
size = _a$size === void 0 ? 'lg' : _a$size,
|
|
72
|
+
rest = __rest(_a, ["prefixCls", "role", "className", "data", "placement", "showCollapse", "expandedType", "showAllSubMenus", "defaultExpandAll", "defaultExpandedIds", "expandedIds", "onExpand", "defaultActiveId", "activeId", "onClickSubMenu", "collapsed", "defaultCollapsed", "overlayClassName", "onCollapse", "footerRender", "render", "extraHeader", "onClick", "size"]);
|
|
69
73
|
|
|
70
74
|
var _useUncontrolledState = useUncontrolledState(defaultActiveId, activeIdProp, onClick),
|
|
71
75
|
activeId = _useUncontrolledState[0],
|
|
@@ -201,7 +205,11 @@ var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
201
205
|
var renderFooter = function renderFooter() {
|
|
202
206
|
var collapseNode = canToggle ? /*#__PURE__*/React.createElement("div", {
|
|
203
207
|
className: cx(prefixCls + "__toggle"),
|
|
204
|
-
onClick:
|
|
208
|
+
onClick: function onClick() {
|
|
209
|
+
miniToggleAction.not(); // 关闭所有展开的子菜单,防止切换到 mini 模式后,子菜单还是展开的
|
|
210
|
+
|
|
211
|
+
updateExpandedIds([]);
|
|
212
|
+
}
|
|
205
213
|
}, mini ? /*#__PURE__*/React.createElement(MenuUnfoldOutlined, null) : /*#__PURE__*/React.createElement(MenuFoldOutlined, null)) : null;
|
|
206
214
|
return /*#__PURE__*/React.createElement(React.Fragment, null, isFunction(footerRender) ? footerRender({
|
|
207
215
|
collapsed: showMini,
|
|
@@ -209,12 +217,12 @@ var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
209
217
|
}) : collapseNode);
|
|
210
218
|
};
|
|
211
219
|
|
|
212
|
-
var cls = cx(prefixCls, className, prefixCls + "--" + placement, mini && prefixCls + "--mini", (expandedType === 'pop' || showAllSubMenus || mini) && prefixCls + "--popup");
|
|
220
|
+
var cls = cx(prefixCls, className, prefixCls + "--" + placement, prefixCls + "--size-" + size, mini && prefixCls + "--mini", (expandedType === 'pop' || showAllSubMenus || mini) && prefixCls + "--popup");
|
|
213
221
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
214
222
|
ref: useMergeRefs(ref, setContainerElement),
|
|
215
223
|
role: role,
|
|
216
224
|
className: cls
|
|
217
|
-
}, rest), /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
225
|
+
}, rest), extraHeader, /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
218
226
|
value: {
|
|
219
227
|
placement: placement,
|
|
220
228
|
expandedType: expandedType,
|
|
@@ -239,13 +247,16 @@ var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
239
247
|
}, /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, item, {
|
|
240
248
|
level: 1,
|
|
241
249
|
render: renderMenuItemMini,
|
|
242
|
-
raw: item
|
|
250
|
+
raw: item,
|
|
251
|
+
size: size
|
|
243
252
|
}))) : /*#__PURE__*/React.createElement(MenuItem, Object.assign({
|
|
244
253
|
hidden: !showVertical && index >= tagMaxCount
|
|
245
254
|
}, item, {
|
|
255
|
+
render: render,
|
|
246
256
|
key: item.id,
|
|
247
257
|
level: 1,
|
|
248
|
-
raw: item
|
|
258
|
+
raw: item,
|
|
259
|
+
size: size
|
|
249
260
|
}));
|
|
250
261
|
}), showVertical || restTagList.length === 0 ? null : /*#__PURE__*/React.createElement(MenuItem, {
|
|
251
262
|
key: MENU_MORE_ID,
|
|
@@ -266,10 +277,6 @@ if (__DEV__) {
|
|
|
266
277
|
|
|
267
278
|
|
|
268
279
|
var renderMenuItemMini = function renderMenuItemMini(menu) {
|
|
269
|
-
if (typeof menu.icon !== 'undefined') {
|
|
270
|
-
return menu.icon;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
280
|
if (typeof menu.title === 'string') {
|
|
274
281
|
return menu.title.substring(0, 1);
|
|
275
282
|
}
|
package/lib/esm/MenuItem.js
CHANGED
|
@@ -12,12 +12,12 @@ import React, { forwardRef, useRef, useContext } from 'react';
|
|
|
12
12
|
import { getPrefixCls, cx } from '@hi-ui/classname';
|
|
13
13
|
import { __DEV__ } from '@hi-ui/env';
|
|
14
14
|
import { RightOutlined, DownOutlined, UpOutlined } from '@hi-ui/icons';
|
|
15
|
-
import MenuContext from './context.js';
|
|
16
15
|
import Popper from '@hi-ui/popper';
|
|
17
|
-
import { Expander } from './Expander.js';
|
|
18
16
|
import { isArrayNonEmpty, isFunction } from '@hi-ui/type-assertion';
|
|
19
17
|
import { times } from '@hi-ui/array-utils';
|
|
20
18
|
import { useMergeRefs } from '@hi-ui/use-merge-refs';
|
|
19
|
+
import MenuContext from './context.js';
|
|
20
|
+
import { Expander } from './Expander.js';
|
|
21
21
|
var MENU_PREFIX = getPrefixCls('menu');
|
|
22
22
|
var hiddenStyle = {
|
|
23
23
|
position: 'absolute',
|
|
@@ -43,7 +43,9 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
43
43
|
hidden = _a$hidden === void 0 ? false : _a$hidden,
|
|
44
44
|
render = _a.render,
|
|
45
45
|
raw = _a.raw,
|
|
46
|
-
|
|
46
|
+
_a$size = _a.size,
|
|
47
|
+
size = _a$size === void 0 ? 'lg' : _a$size,
|
|
48
|
+
rest = __rest(_a, ["prefixCls", "className", "icon", "title", "disabled", "id", "level", "children", "parentIds", "hidden", "render", "raw", "size"]);
|
|
47
49
|
|
|
48
50
|
var itemRef = useRef(null);
|
|
49
51
|
|
|
@@ -125,7 +127,9 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
125
127
|
key: child.id,
|
|
126
128
|
level: level + 1,
|
|
127
129
|
parentIds: _parentIds,
|
|
128
|
-
raw: child
|
|
130
|
+
raw: child,
|
|
131
|
+
render: render,
|
|
132
|
+
size: size
|
|
129
133
|
}));
|
|
130
134
|
}))) : null), hasChildren && placement === 'vertical' && mini && !showAllSubMenus && expandedType === 'collapse' && (level === 1 ? /*#__PURE__*/React.createElement(Popper, {
|
|
131
135
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -139,13 +143,15 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
142
|
-
className: prefixCls + "-popmenu"
|
|
146
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
143
147
|
}, children.map(function (child) {
|
|
144
148
|
return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
|
|
145
149
|
key: child.id,
|
|
146
150
|
level: level + 1,
|
|
147
151
|
parentIds: _parentIds,
|
|
148
|
-
raw: child
|
|
152
|
+
raw: child,
|
|
153
|
+
render: render,
|
|
154
|
+
size: size
|
|
149
155
|
}));
|
|
150
156
|
}))) : /*#__PURE__*/React.createElement(Popper, {
|
|
151
157
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -160,13 +166,15 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
160
166
|
}
|
|
161
167
|
}
|
|
162
168
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
163
|
-
className: prefixCls + "-popmenu"
|
|
169
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
164
170
|
}, children.map(function (child) {
|
|
165
171
|
return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
|
|
166
172
|
key: child.id,
|
|
167
173
|
level: level + 1,
|
|
168
174
|
parentIds: _parentIds,
|
|
169
|
-
raw: child
|
|
175
|
+
raw: child,
|
|
176
|
+
render: render,
|
|
177
|
+
size: size
|
|
170
178
|
}));
|
|
171
179
|
})))), hasChildren && placement === 'vertical' && !showAllSubMenus && expandedType === 'pop' && (level === 1 ? /*#__PURE__*/React.createElement(Popper, {
|
|
172
180
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -180,13 +188,15 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
180
188
|
}
|
|
181
189
|
}
|
|
182
190
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
183
|
-
className: prefixCls + "-popmenu"
|
|
191
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
184
192
|
}, children.map(function (child) {
|
|
185
193
|
return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
|
|
186
194
|
key: child.id,
|
|
187
195
|
level: level + 1,
|
|
188
196
|
parentIds: _parentIds,
|
|
189
|
-
raw: child
|
|
197
|
+
raw: child,
|
|
198
|
+
render: render,
|
|
199
|
+
size: size
|
|
190
200
|
}));
|
|
191
201
|
}))) : /*#__PURE__*/React.createElement(Popper, {
|
|
192
202
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -201,13 +211,15 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
201
211
|
}
|
|
202
212
|
}
|
|
203
213
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
204
|
-
className: prefixCls + "-popmenu"
|
|
214
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
205
215
|
}, children.map(function (child) {
|
|
206
216
|
return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
|
|
207
217
|
key: child.id,
|
|
208
218
|
level: level + 1,
|
|
209
219
|
parentIds: _parentIds,
|
|
210
|
-
raw: child
|
|
220
|
+
raw: child,
|
|
221
|
+
render: render,
|
|
222
|
+
size: size
|
|
211
223
|
}));
|
|
212
224
|
})))), hasChildren && placement === 'vertical' && showAllSubMenus ? /*#__PURE__*/React.createElement(Popper, {
|
|
213
225
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -257,13 +269,15 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
257
269
|
}
|
|
258
270
|
}
|
|
259
271
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
260
|
-
className: prefixCls + "-popmenu"
|
|
272
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
261
273
|
}, children.map(function (child) {
|
|
262
274
|
return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
|
|
263
275
|
key: child.id,
|
|
264
276
|
level: level + 1,
|
|
265
277
|
parentIds: _parentIds,
|
|
266
|
-
raw: child
|
|
278
|
+
raw: child,
|
|
279
|
+
render: render,
|
|
280
|
+
size: size
|
|
267
281
|
}));
|
|
268
282
|
}))) : /*#__PURE__*/React.createElement(Popper, {
|
|
269
283
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -278,13 +292,15 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
278
292
|
}
|
|
279
293
|
}
|
|
280
294
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
281
|
-
className: prefixCls + "-popmenu"
|
|
295
|
+
className: prefixCls + "-popmenu " + prefixCls + "--size-" + size
|
|
282
296
|
}, children.map(function (child) {
|
|
283
297
|
return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
|
|
284
298
|
key: child.id,
|
|
285
299
|
level: level + 1,
|
|
286
300
|
parentIds: _parentIds,
|
|
287
|
-
raw: child
|
|
301
|
+
raw: child,
|
|
302
|
+
render: render,
|
|
303
|
+
size: size
|
|
288
304
|
}));
|
|
289
305
|
})))), hasChildren && placement === 'horizontal' && showAllSubMenus ? /*#__PURE__*/React.createElement(Popper, {
|
|
290
306
|
visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
|
|
@@ -7,8 +7,8 @@
|
|
|
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 __styleInject__ from 'inject
|
|
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: hidden; }.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 {padding: 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;-ms-flex-negative: 0;flex-shrink: 0;-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;
|
|
10
|
+
import __styleInject__ from 'style-inject';
|
|
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: hidden; }.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 {padding: 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;-ms-flex-negative: 0;flex-shrink: 0;-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;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);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; }.hi-v4-menu--size-lg .hi-v4-menu-item__inner {height: var(--hi-v4-height-10, 40px);margin-bottom: var(--hi-v4-spacing-4, 8px); }.hi-v4-menu--size-md .hi-v4-menu-item__inner {height: var(--hi-v4-height-9, 36px);margin-bottom: var(--hi-v4-spacing-2, 4px); }.hi-v4-menu--size-sm .hi-v4-menu-item__inner {height: var(--hi-v4-height-8, 32px);margin-bottom: var(--hi-v4-spacing-1, 2px); }";
|
|
12
12
|
|
|
13
13
|
__styleInject__(css_248z);
|
|
14
14
|
|
package/lib/types/Menu.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { HiBaseHTMLProps } from '@hi-ui/core';
|
|
2
|
+
import { HiBaseHTMLProps, HiBaseSizeEnum } from '@hi-ui/core';
|
|
3
3
|
import { MenuDataItem, MenuFooterRenderProps } from './types';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* 菜单
|
|
6
6
|
*/
|
|
7
7
|
export declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLDivElement | null>>;
|
|
8
8
|
export interface MenuProps extends Omit<HiBaseHTMLProps<'div'>, 'onClick'> {
|
|
@@ -82,4 +82,16 @@ export interface MenuProps extends Omit<HiBaseHTMLProps<'div'>, 'onClick'> {
|
|
|
82
82
|
* 底部渲染器
|
|
83
83
|
*/
|
|
84
84
|
footerRender?: (props: MenuFooterRenderProps) => React.ReactNode;
|
|
85
|
+
/**
|
|
86
|
+
* 自定义渲染菜单项
|
|
87
|
+
*/
|
|
88
|
+
render?: (menuItem: MenuDataItem) => React.ReactNode;
|
|
89
|
+
/**
|
|
90
|
+
* 额外的头部内容
|
|
91
|
+
*/
|
|
92
|
+
extraHeader?: React.ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* 设置菜单项的尺寸
|
|
95
|
+
*/
|
|
96
|
+
size?: HiBaseSizeEnum;
|
|
85
97
|
}
|
package/lib/types/MenuItem.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { HiBaseHTMLProps } from '@hi-ui/core';
|
|
2
|
+
import { HiBaseHTMLProps, HiBaseSizeEnum } from '@hi-ui/core';
|
|
3
3
|
import { MenuDataItem } from './types';
|
|
4
4
|
export declare const MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLLIElement | null>>;
|
|
5
5
|
export interface MenuItemProps extends Omit<HiBaseHTMLProps<'li'>, 'id'> {
|
|
@@ -12,4 +12,5 @@ export interface MenuItemProps extends Omit<HiBaseHTMLProps<'li'>, 'id'> {
|
|
|
12
12
|
parentIds?: React.ReactText[];
|
|
13
13
|
render?: (node: MenuDataItem) => React.ReactNode;
|
|
14
14
|
raw?: MenuDataItem;
|
|
15
|
+
size?: HiBaseSizeEnum;
|
|
15
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hi-ui/menu",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "HiUI <mi-hiui@xiaomi.com>",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"@hi-ui/array-utils": "^4.0.1",
|
|
47
47
|
"@hi-ui/classname": "^4.0.1",
|
|
48
48
|
"@hi-ui/env": "^4.0.1",
|
|
49
|
-
"@hi-ui/icons": "^4.0.
|
|
50
|
-
"@hi-ui/popper": "^4.0
|
|
49
|
+
"@hi-ui/icons": "^4.0.14",
|
|
50
|
+
"@hi-ui/popper": "^4.1.0",
|
|
51
51
|
"@hi-ui/times": "^4.0.1",
|
|
52
52
|
"@hi-ui/tooltip": "^4.0.5",
|
|
53
|
-
"@hi-ui/tree-utils": "^4.
|
|
53
|
+
"@hi-ui/tree-utils": "^4.1.1",
|
|
54
54
|
"@hi-ui/type-assertion": "^4.0.1",
|
|
55
55
|
"@hi-ui/use-id": "^4.0.1",
|
|
56
56
|
"@hi-ui/use-merge-refs": "^4.0.1",
|
|
@@ -67,7 +67,6 @@
|
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@hi-ui/core": "^4.0.4",
|
|
69
69
|
"@hi-ui/core-css": "^4.0.1",
|
|
70
|
-
"@hi-ui/hi-build": "^4.0.1",
|
|
71
70
|
"react": "^17.0.1",
|
|
72
71
|
"react-dom": "^17.0.1"
|
|
73
72
|
}
|