@hi-ui/menu 4.0.0-beta.7 → 4.0.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/lib/esm/Menu.js CHANGED
@@ -2,13 +2,13 @@
2
2
  * @hi-ui/menu
3
3
  * https://github.com/XiaoMi/hiui/tree/master/packages/ui/menu#readme
4
4
  *
5
- * Copyright (c) HIUI <mi-hiui@xiaomi.com>.
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
6
  *
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
10
  import { __rest } from 'tslib';
11
- import React, { forwardRef, useState, useEffect, useCallback } from 'react';
11
+ import React, { forwardRef, useState, useEffect, useCallback, useMemo, useLayoutEffect } from 'react';
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';
@@ -17,84 +17,200 @@ import MenuContext from './context.js';
17
17
  import { getAncestorIds } from './util.js';
18
18
  import { useUncontrolledState } from '@hi-ui/use-uncontrolled-state';
19
19
  import Tooltip from '@hi-ui/tooltip';
20
+ import { useUncontrolledToggle } from '@hi-ui/use-toggle';
21
+ import { getTreeNodesWithChildren } from '@hi-ui/tree-utils';
22
+ import { isArrayNonEmpty, isFunction } from '@hi-ui/type-assertion';
23
+ import { useResizeObserver } from '@hi-ui/use-resize-observer';
24
+ import { useMergeRefs } from '@hi-ui/use-merge-refs';
25
+ import { uuid } from '@hi-ui/use-id';
20
26
  var MENU_PREFIX = getPrefixCls('menu');
27
+ var DEFAULT_EXPANDED_IDS = [];
28
+ var NOOP_ARRAY = [];
29
+ var MIN_WIDTH = 56;
30
+ var MENU_MORE_ID = "MENU_MORE_" + uuid();
21
31
  /**
22
32
  * TODO: What is Menu
23
33
  */
24
34
 
25
35
  var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
26
- var _cx;
27
-
28
36
  var _a$prefixCls = _a.prefixCls,
29
37
  prefixCls = _a$prefixCls === void 0 ? MENU_PREFIX : _a$prefixCls,
30
38
  _a$role = _a.role,
31
39
  role = _a$role === void 0 ? 'menu' : _a$role,
32
40
  className = _a.className,
33
- data = _a.data,
41
+ _a$data = _a.data,
42
+ data = _a$data === void 0 ? NOOP_ARRAY : _a$data,
34
43
  _a$placement = _a.placement,
35
44
  placement = _a$placement === void 0 ? 'vertical' : _a$placement,
36
- showCollapse = _a.showCollapse,
45
+ _a$showCollapse = _a.showCollapse,
46
+ showCollapse = _a$showCollapse === void 0 ? false : _a$showCollapse,
37
47
  _a$expandedType = _a.expandedType,
38
48
  expandedType = _a$expandedType === void 0 ? 'collapse' : _a$expandedType,
39
49
  _a$showAllSubMenus = _a.showAllSubMenus,
40
50
  showAllSubMenus = _a$showAllSubMenus === void 0 ? false : _a$showAllSubMenus,
41
- defaultExpandedIds = _a.defaultExpandedIds,
42
- defaultActiveId = _a.defaultActiveId,
43
- activeId = _a.activeId,
51
+ _a$defaultExpandAll = _a.defaultExpandAll,
52
+ defaultExpandAll = _a$defaultExpandAll === void 0 ? false : _a$defaultExpandAll,
53
+ _a$defaultExpandedIds = _a.defaultExpandedIds,
54
+ defaultExpandedIds = _a$defaultExpandedIds === void 0 ? DEFAULT_EXPANDED_IDS : _a$defaultExpandedIds,
55
+ expandedIdsProp = _a.expandedIds,
56
+ onExpand = _a.onExpand,
57
+ _a$defaultActiveId = _a.defaultActiveId,
58
+ defaultActiveId = _a$defaultActiveId === void 0 ? '' : _a$defaultActiveId,
59
+ activeIdProp = _a.activeId,
44
60
  onClickSubMenu = _a.onClickSubMenu,
61
+ collapsed = _a.collapsed,
62
+ _a$defaultCollapsed = _a.defaultCollapsed,
63
+ defaultCollapsed = _a$defaultCollapsed === void 0 ? false : _a$defaultCollapsed,
64
+ onCollapse = _a.onCollapse,
65
+ footerRender = _a.footerRender,
45
66
  onClick = _a.onClick,
46
- rest = __rest(_a, ["prefixCls", "role", "className", "data", "placement", "showCollapse", "expandedType", "showAllSubMenus", "defaultExpandedIds", "defaultActiveId", "activeId", "onClickSubMenu", "onClick"]);
67
+ rest = __rest(_a, ["prefixCls", "role", "className", "data", "placement", "showCollapse", "expandedType", "showAllSubMenus", "defaultExpandAll", "defaultExpandedIds", "expandedIds", "onExpand", "defaultActiveId", "activeId", "onClickSubMenu", "collapsed", "defaultCollapsed", "onCollapse", "footerRender", "onClick"]);
47
68
 
48
- var _useUncontrolledState = useUncontrolledState(defaultActiveId || '', activeId, onClick),
49
- _activeId = _useUncontrolledState[0],
69
+ var _useUncontrolledState = useUncontrolledState(defaultActiveId, activeIdProp, onClick),
70
+ activeId = _useUncontrolledState[0],
50
71
  updateActiveId = _useUncontrolledState[1];
51
72
 
52
- var _useState = useState(getAncestorIds(_activeId, data)),
73
+ var _useState = useState(function () {
74
+ return getAncestorIds(activeId, data);
75
+ }),
53
76
  activeParents = _useState[0],
54
77
  updateActiveParents = _useState[1];
55
78
 
56
79
  useEffect(function () {
57
- updateActiveParents(getAncestorIds(_activeId, data));
58
- }, [_activeId, data]);
80
+ updateActiveParents(getAncestorIds(activeId, data));
81
+ }, [activeId, data]);
59
82
 
60
- var _useState2 = useState(defaultExpandedIds || []),
61
- _expandedIds = _useState2[0],
62
- updateExpanedIds = _useState2[1];
83
+ var _useUncontrolledState2 = useUncontrolledState(function () {
84
+ return defaultExpandAll ? getTreeNodesWithChildren(data).map(function (node) {
85
+ return node.id;
86
+ }) : defaultExpandedIds;
87
+ }, expandedIdsProp, onExpand),
88
+ expandedIds = _useUncontrolledState2[0],
89
+ updateExpandedIds = _useUncontrolledState2[1];
63
90
 
64
- var clickMenu = useCallback(function (id) {
65
- updateActiveId(id);
91
+ var clickMenu = useCallback(function (id, raw) {
92
+ updateActiveId(id, raw);
66
93
  }, [updateActiveId]);
67
94
  var clickSubMenu = useCallback(function (id) {
68
- var expandedIds = _expandedIds.includes(id) ? _expandedIds.filter(function (expandedId) {
95
+ var nextExpandedIds = expandedIds.includes(id) ? expandedIds.filter(function (expandedId) {
69
96
  return expandedId !== id;
70
- }) : _expandedIds.concat(id);
71
- updateExpanedIds(expandedIds);
97
+ }) : expandedIds.concat(id);
98
+ updateExpandedIds(nextExpandedIds);
72
99
 
73
100
  if (onClickSubMenu) {
74
- onClickSubMenu(id, expandedIds);
101
+ onClickSubMenu(id, nextExpandedIds);
75
102
  }
76
- }, [onClickSubMenu, _expandedIds]);
103
+ }, [onClickSubMenu, expandedIds, updateExpandedIds]);
77
104
  var closePopper = useCallback(function (id) {
78
- updateExpanedIds(_expandedIds.filter(function (expandedId) {
105
+ updateExpandedIds(expandedIds.filter(function (expandedId) {
79
106
  return expandedId !== id;
80
107
  }));
81
- }, [_expandedIds]);
108
+ }, [expandedIds, updateExpandedIds]);
82
109
  var closeAllPopper = useCallback(function () {
83
- updateExpanedIds([]);
84
- }, []);
85
-
86
- var _useState3 = useState(false),
87
- mini = _useState3[0],
88
- setMini = _useState3[1];
89
-
90
- var cls = cx(prefixCls, className, prefixCls + "--" + placement, (_cx = {}, _cx[prefixCls + "--mini"] = mini, _cx[prefixCls + "--popup"] = expandedType === 'pop' || showAllSubMenus || mini, _cx));
91
- var onToggle = useCallback(function () {
92
- setMini(!mini);
93
- closeAllPopper();
94
- }, [mini, closeAllPopper]);
95
- var canToggle = placement === 'vertical' && showCollapse;
110
+ updateExpandedIds([]);
111
+ }, [updateExpandedIds]);
112
+
113
+ var _useUncontrolledToggl = useUncontrolledToggle({
114
+ defaultVisible: defaultCollapsed,
115
+ visible: collapsed,
116
+ onToggle: onCollapse
117
+ }),
118
+ mini = _useUncontrolledToggl[0],
119
+ miniToggleAction = _useUncontrolledToggl[1];
120
+
121
+ var showVertical = placement === 'vertical';
122
+ var canToggle = showVertical && showCollapse;
123
+ var showMini = showVertical && mini;
124
+
125
+ var _useState2 = useState(null),
126
+ containerElement = _useState2[0],
127
+ setContainerElement = _useState2[1];
128
+
129
+ var _useState3 = useState(),
130
+ _useState3$ = _useState3[0],
131
+ containerWidth = _useState3$ === void 0 ? 0 : _useState3$,
132
+ setContainerWidth = _useState3[1];
133
+
134
+ useResizeObserver({
135
+ element: containerElement,
136
+ disabled: showVertical,
137
+ getSize: function getSize(element) {
138
+ var itemRect = element.getBoundingClientRect();
139
+ return itemRect.width;
140
+ },
141
+ onResize: function onResize(el, width) {
142
+ setContainerWidth(width);
143
+ }
144
+ });
145
+
146
+ var _useState4 = useState(0),
147
+ tagMaxCount = _useState4[0],
148
+ setTagMaxCount = _useState4[1];
149
+
150
+ var mergedTagList = useMemo(function () {
151
+ if (showVertical) return data;
152
+ if (containerWidth < MIN_WIDTH) return data;
153
+ return data.slice(0, Math.min(data.length, containerWidth / MIN_WIDTH));
154
+ }, [showVertical, data, containerWidth]);
155
+ var restTagList = useMemo(function () {
156
+ if (tagMaxCount > 0) return data.slice(tagMaxCount);
157
+ return [];
158
+ }, [data, tagMaxCount]);
159
+ var getTagWidth = useCallback(function (index) {
160
+ if (!containerElement) return MIN_WIDTH;
161
+ var elements = containerElement.getElementsByClassName('hi-v4-menu-item');
162
+ var element = elements && elements[index];
163
+ if (!element) return MIN_WIDTH;
164
+ return element.getBoundingClientRect().width;
165
+ }, [containerElement]);
166
+ useLayoutEffect(function () {
167
+ if (showVertical) return;
168
+ var tagMaxCount = 0;
169
+
170
+ if (isArrayNonEmpty(mergedTagList)) {
171
+ var len = mergedTagList.length;
172
+ var lastIndex = len - 1;
173
+ var totalWidth = 72; // 更多
174
+
175
+ for (var i = 0; i < len; ++i) {
176
+ var currentTagWidth = getTagWidth(i);
177
+
178
+ if (currentTagWidth === undefined) {
179
+ break;
180
+ }
181
+
182
+ totalWidth += currentTagWidth;
183
+
184
+ if (lastIndex === 0 && totalWidth <= containerWidth || i === lastIndex - 1 && totalWidth + getTagWidth(lastIndex) <= containerWidth) {
185
+ tagMaxCount = lastIndex;
186
+ break;
187
+ } else if (totalWidth > containerWidth) {
188
+ tagMaxCount = i - 1;
189
+ break;
190
+ }
191
+ }
192
+ } else {
193
+ tagMaxCount = 0;
194
+ } // 保底要展示 1 个
195
+
196
+
197
+ setTagMaxCount(isArrayNonEmpty(mergedTagList) && tagMaxCount < 1 ? 1 : tagMaxCount + 1);
198
+ }, [showVertical, getTagWidth, containerWidth, mergedTagList]);
199
+
200
+ var renderFooter = function renderFooter() {
201
+ var collapseNode = canToggle ? /*#__PURE__*/React.createElement("div", {
202
+ className: cx(prefixCls + "__toggle"),
203
+ onClick: miniToggleAction.not
204
+ }, mini ? /*#__PURE__*/React.createElement(MenuUnfoldOutlined, null) : /*#__PURE__*/React.createElement(MenuFoldOutlined, null)) : null;
205
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isFunction(footerRender) ? footerRender({
206
+ collapsed: showMini,
207
+ collapseNode: collapseNode
208
+ }) : collapseNode);
209
+ };
210
+
211
+ var cls = cx(prefixCls, className, prefixCls + "--" + placement, mini && prefixCls + "--mini", (expandedType === 'pop' || showAllSubMenus || mini) && prefixCls + "--popup");
96
212
  return /*#__PURE__*/React.createElement("div", Object.assign({
97
- ref: ref,
213
+ ref: useMergeRefs(ref, setContainerElement),
98
214
  role: role,
99
215
  className: cls
100
216
  }, rest), /*#__PURE__*/React.createElement(MenuContext.Provider, {
@@ -108,31 +224,55 @@ var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
108
224
  closePopper: closePopper,
109
225
  closeAllPopper: closeAllPopper,
110
226
  activeParents: activeParents,
111
- activeId: _activeId,
112
- expandedIds: _expandedIds
227
+ activeId: activeId,
228
+ expandedIds: expandedIds
113
229
  }
114
230
  }, /*#__PURE__*/React.createElement("ul", {
115
231
  className: cx(prefixCls + "__wrapper")
116
- }, data.map(function (item) {
117
- return canToggle && mini ? /*#__PURE__*/React.createElement(Tooltip, {
232
+ }, mergedTagList.map(function (item, index) {
233
+ return showMini ? /*#__PURE__*/React.createElement(Tooltip, {
118
234
  title: item.title,
119
235
  key: item.id,
120
236
  placement: "right"
121
237
  }, /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, item, {
122
- level: 1
123
- }))) : /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, item, {
238
+ level: 1,
239
+ render: renderMenuItemMini,
240
+ raw: item
241
+ }))) : /*#__PURE__*/React.createElement(MenuItem, Object.assign({
242
+ hidden: !showVertical && index >= tagMaxCount
243
+ }, item, {
124
244
  key: item.id,
125
- level: 1
245
+ level: 1,
246
+ raw: item
126
247
  }));
127
- })), canToggle ? /*#__PURE__*/React.createElement("div", {
128
- className: cx(prefixCls + "__toggle"),
129
- onClick: onToggle
130
- }, mini ? /*#__PURE__*/React.createElement(MenuUnfoldOutlined, null) : /*#__PURE__*/React.createElement(MenuFoldOutlined, null)) : null));
248
+ }), showVertical || restTagList.length === 0 ? null : /*#__PURE__*/React.createElement(MenuItem, {
249
+ key: MENU_MORE_ID,
250
+ id: MENU_MORE_ID,
251
+ title: "\u66F4\u591A",
252
+ children: restTagList
253
+ })), /*#__PURE__*/React.createElement("div", {
254
+ className: prefixCls + "__footer"
255
+ }, renderFooter())));
131
256
  });
132
257
 
133
258
  if (__DEV__) {
134
259
  Menu.displayName = 'Menu';
135
260
  }
261
+ /**
262
+ * Mini 模式下渲染 item
263
+ */
264
+
265
+
266
+ var renderMenuItemMini = function renderMenuItemMini(menu) {
267
+ if (typeof menu.icon !== 'undefined') {
268
+ return menu.icon;
269
+ }
270
+
271
+ if (typeof menu.title === 'string') {
272
+ return menu.title.substring(0, 1);
273
+ }
274
+
275
+ return menu.title;
276
+ };
136
277
 
137
278
  export { Menu };
138
- //# sourceMappingURL=Menu.js.map
@@ -2,7 +2,7 @@
2
2
  * @hi-ui/menu
3
3
  * https://github.com/XiaoMi/hiui/tree/master/packages/ui/menu#readme
4
4
  *
5
- * Copyright (c) HIUI <mi-hiui@xiaomi.com>.
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
6
  *
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.
@@ -15,10 +15,16 @@ import { RightOutlined, DownOutlined, UpOutlined } from '@hi-ui/icons';
15
15
  import MenuContext from './context.js';
16
16
  import Popper from '@hi-ui/popper';
17
17
  import { Expander } from './Expander.js';
18
- import { isArrayNonEmpty } from '@hi-ui/type-assertion';
18
+ import { isArrayNonEmpty, isFunction } from '@hi-ui/type-assertion';
19
19
  import { times } from '@hi-ui/array-utils';
20
20
  import { useMergeRefs } from '@hi-ui/use-merge-refs';
21
21
  var MENU_PREFIX = getPrefixCls('menu');
22
+ var hiddenStyle = {
23
+ position: 'absolute',
24
+ opacity: 0,
25
+ order: 9999,
26
+ visibility: 'hidden'
27
+ };
22
28
  var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
23
29
  var _cx, _cx2;
24
30
 
@@ -33,7 +39,11 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
33
39
  level = _a$level === void 0 ? 1 : _a$level,
34
40
  children = _a.children,
35
41
  parentIds = _a.parentIds,
36
- rest = __rest(_a, ["prefixCls", "className", "icon", "title", "disabled", "id", "level", "children", "parentIds"]);
42
+ _a$hidden = _a.hidden,
43
+ hidden = _a$hidden === void 0 ? false : _a$hidden,
44
+ render = _a.render,
45
+ raw = _a.raw,
46
+ rest = __rest(_a, ["prefixCls", "className", "icon", "title", "disabled", "id", "level", "children", "parentIds", "hidden", "render", "raw"]);
37
47
 
38
48
  var itemRef = useRef(null);
39
49
 
@@ -56,7 +66,8 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
56
66
  var mergedRef = useMergeRefs(itemRef, ref);
57
67
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("li", Object.assign({
58
68
  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)
69
+ 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),
70
+ style: hidden ? hiddenStyle : undefined
60
71
  }, rest), /*#__PURE__*/React.createElement("div", {
61
72
  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)),
62
73
  onClick: function onClick() {
@@ -66,7 +77,8 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
66
77
  }
67
78
  } else {
68
79
  if (clickMenu) {
69
- clickMenu(id);
80
+ // @ts-ignore
81
+ clickMenu(id, raw);
70
82
  }
71
83
 
72
84
  if (closeAllPopper && !(placement === 'vertical' && expandedType === 'collapse' && mini === false)) {
@@ -81,7 +93,11 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
81
93
  className: prefixCls + "-item__icon"
82
94
  }, icon) : null, /*#__PURE__*/React.createElement("span", {
83
95
  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, {
96
+ }, isFunction(render) ? render({
97
+ id: id,
98
+ icon: icon,
99
+ title: title
100
+ }) : title), hasChildren && !mini && placement === 'vertical' && expandedType === 'collapse' && !showAllSubMenus && ((expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)) ? /*#__PURE__*/React.createElement(Arrow, {
85
101
  prefixCls: prefixCls + "-item",
86
102
  direction: "up"
87
103
  }) : /*#__PURE__*/React.createElement(Arrow, {
@@ -107,7 +123,8 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
107
123
  return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
108
124
  key: child.id,
109
125
  level: level + 1,
110
- parentIds: _parentIds
126
+ parentIds: _parentIds,
127
+ raw: child
111
128
  }));
112
129
  }))) : null), hasChildren && placement === 'vertical' && mini && !showAllSubMenus && expandedType === 'collapse' && (level === 1 ? /*#__PURE__*/React.createElement(Popper, {
113
130
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
@@ -207,7 +224,7 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
207
224
  return /*#__PURE__*/React.createElement("div", {
208
225
  onClick: function onClick() {
209
226
  if (clickMenu) {
210
- clickMenu(item.id);
227
+ clickMenu(item.id, item);
211
228
  }
212
229
 
213
230
  if (closePopper) {
@@ -280,7 +297,7 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
280
297
  className: cx(prefixCls + "-item", (_cx4 = {}, _cx4[prefixCls + "-item--active"] = activeId === item.id, _cx4)),
281
298
  onClick: function onClick() {
282
299
  if (clickMenu) {
283
- clickMenu(item.id);
300
+ clickMenu(item.id, item);
284
301
  }
285
302
 
286
303
  if (closePopper) {
@@ -336,4 +353,3 @@ var renderIndent = function renderIndent(_ref2) {
336
353
  };
337
354
 
338
355
  export { MenuItem };
339
- //# sourceMappingURL=MenuItem.js.map
@@ -2,12 +2,11 @@
2
2
  * @hi-ui/menu
3
3
  * https://github.com/XiaoMi/hiui/tree/master/packages/ui/menu#readme
4
4
  *
5
- * Copyright (c) HIUI <mi-hiui@xiaomi.com>.
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
6
  *
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
10
  import { createContext } from 'react';
11
11
  var MenuContext = /*#__PURE__*/createContext({});
12
- export default MenuContext;
13
- //# sourceMappingURL=context.js.map
12
+ export { MenuContext as default };
package/lib/esm/index.js CHANGED
@@ -2,11 +2,10 @@
2
2
  * @hi-ui/menu
3
3
  * https://github.com/XiaoMi/hiui/tree/master/packages/ui/menu#readme
4
4
  *
5
- * Copyright (c) HIUI <mi-hiui@xiaomi.com>.
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
6
  *
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
10
  import './styles/index.scss.js';
11
11
  export { Menu, Menu as default } from './Menu.js';
12
- //# sourceMappingURL=index.js.map
@@ -2,16 +2,14 @@
2
2
  * @hi-ui/menu
3
3
  * https://github.com/XiaoMi/hiui/tree/master/packages/ui/menu#readme
4
4
  *
5
- * Copyright (c) HIUI <mi-hiui@xiaomi.com>.
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
6
  *
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: var(--hi-v4-color-static-white, #fff);\n margin: 0;\n font-size: var(--hi-v4-text-size-normal, 0.875rem);\n padding: var(--hi-v4-spacing-4, 8px);\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n color: var(--hi-v4-color-gray-700, #1f2733);\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: 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 var(--hi-v4-spacing-6, 12px);\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: 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 var(--hi-v4-spacing-4, 8px) 0 var(--hi-v4-spacing-6, 12px); }\n.hi-v4-menu-fat-menu .hi-v4-menu-item--active {\n color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));\n background-color: var(--hi-v4-color-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: 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: var(--hi-v4-color-static-white, #fff);\n border-radius: var(--hi-v4-border-radius-normal, 4px);\n margin: 0;\n font-size: var(--hi-v4-text-size-normal, 0.875rem);\n padding: var(--hi-v4-spacing-4, 8px);\n color: var(--hi-v4-color-gray-700, #1f2733);\n width: 216px;\n -webkit-box-sizing: border-box;\n box-sizing: border-box; }\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: var(--hi-v4-spacing-4, 8px);\n padding: 0 var(--hi-v4-spacing-4, 8px) 0 var(--hi-v4-spacing-6, 12px);\n border-radius: var(--hi-v4-border-radius-normal, 4px); }\n.hi-v4-menu-popmenu .hi-v4-menu-item__inner--active {\n color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));\n background-color: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }\n.hi-v4-menu-popmenu .hi-v4-menu-item__inner--active-p {\n color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu-popmenu .hi-v4-menu-item__inner--expanded {\n background-color: var(--hi-v4-color-gray-100, #f2f4f7); }\n.hi-v4-menu-popmenu .hi-v4-menu-item__inner:not(.hi-v4-menu-item__inner--active):hover {\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: 100%;\n padding-right: var(--hi-v4-spacing-4, 8px); }\n.hi-v4-menu {\n background-color: var(--hi-v4-color-static-white, #fff);\n color: var(--hi-v4-color-gray-700, #1f2733);\n font-size: var(--hi-v4-text-size-normal, 0.875rem);\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-item__icon {\n color: var(--hi-v4-color-gray-500, #929aa6);\n -webkit-margin-end: var(--hi-v4-spacing-4, 8px);\n margin-inline-end: var(--hi-v4-spacing-4, 8px); }\n.hi-v4-menu-item__icon svg[class^=hi-v4-icon] {\n font-size: var(--hi-v4-text-size-lg, 1rem); }\n.hi-v4-menu-item__arrow {\n color: var(--hi-v4-color-gray-500, #929aa6);\n font-size: var(--hi-v4-text-size-lg, 1rem); }\n.hi-v4-menu-item__indent {\n display: inline-block;\n width: 24px;\n height: 100%;\n -ms-flex-negative: 0;\n flex-shrink: 0; }\n.hi-v4-menu__wrapper {\n padding: 0;\n margin: 0; }\n.hi-v4-menu--horizontal {\n width: 100%;\n overflow-x: auto; }\n.hi-v4-menu--horizontal .hi-v4-menu__wrapper {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n overflow: visible;\n width: -webkit-max-content;\n width: -moz-max-content;\n width: max-content;\n -webkit-box-sizing: border-box;\n box-sizing: border-box; }\n.hi-v4-menu--horizontal .hi-v4-menu-item {\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: none;\n font-size: var(--hi-v4-text-size-lg, 1rem); }\n.hi-v4-menu--horizontal .hi-v4-menu-item__arrow {\n -webkit-margin-start: var(--hi-v4-spacing-2, 4px);\n margin-inline-start: var(--hi-v4-spacing-2, 4px); }\n.hi-v4-menu--horizontal .hi-v4-menu-item:hover {\n color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--horizontal .hi-v4-menu-item:hover .hi-v4-menu-item__inner {\n border-bottom: 2px solid var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--horizontal .hi-v4-menu-item--active {\n color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--horizontal .hi-v4-menu-item--active .hi-v4-menu-item__inner {\n border-bottom: 2px solid var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--horizontal .hi-v4-menu-item--active .hi-v4-menu-item__icon {\n color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--horizontal .hi-v4-menu-item--active-p {\n color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--horizontal .hi-v4-menu-item--active-p .hi-v4-menu-item__icon {\n color: var(--hi-v4-color-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 -webkit-box-sizing: border-box;\n box-sizing: border-box;\n border-bottom: 2px solid transparent; }\n.hi-v4-menu--horizontal .hi-v4-menu-item__inner--expanded {\n border-bottom: 2px solid var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\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 white-space: nowrap;\n max-width: none; }\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: var(--hi-v4-spacing-4, 8px);\n width: 216px;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\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--popup .hi-v4-menu-item__inner--expanded {\n background-color: var(--hi-v4-color-gray-100, #f2f4f7); }\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: var(--hi-v4-border-radius-normal, 4px);\n color: var(--hi-v4-color-gray-500, #929aa6);\n height: 40px; }\n.hi-v4-menu--vertical .hi-v4-menu__toggle:hover {\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: var(--hi-v4-spacing-4, 8px);\n padding: 0 var(--hi-v4-spacing-4, 8px) 0 var(--hi-v4-spacing-6, 12px);\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: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));\n background-color: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }\n.hi-v4-menu--vertical .hi-v4-menu-item__inner--active .hi-v4-menu-item__icon {\n color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--vertical .hi-v4-menu-item__inner--active-p {\n color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }\n.hi-v4-menu--vertical .hi-v4-menu-item__inner--active-p .hi-v4-menu-item__icon {\n color: var(--hi-v4-color-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: var(--hi-v4-color-gray-100, #f2f4f7); }\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: 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;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 css_248z;
17
- //# sourceMappingURL=index.scss.js.map
15
+ export { css_248z as default };
package/lib/esm/util.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @hi-ui/menu
3
3
  * https://github.com/XiaoMi/hiui/tree/master/packages/ui/menu#readme
4
4
  *
5
- * Copyright (c) HIUI <mi-hiui@xiaomi.com>.
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
6
  *
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.
@@ -39,4 +39,3 @@ var getAncestorIds = function getAncestorIds(id, data, arr) {
39
39
  };
40
40
 
41
41
  export { getAncestorIds, getParentId };
42
- //# sourceMappingURL=util.js.map
@@ -1,23 +1,85 @@
1
1
  import React from 'react';
2
2
  import { HiBaseHTMLProps } from '@hi-ui/core';
3
- import { MenuDataItem } from './types';
3
+ import { MenuDataItem, MenuFooterRenderProps } from './types';
4
4
  /**
5
5
  * TODO: What is Menu
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'> {
9
+ /**
10
+ * 菜单项数据列表
11
+ */
9
12
  data: MenuDataItem[];
13
+ /**
14
+ * 默认激活的菜单项 id
15
+ */
16
+ defaultActiveId?: React.ReactText;
17
+ /**
18
+ * 激活的菜单项 id
19
+ */
10
20
  activeId?: React.ReactText;
21
+ /**
22
+ * 设置菜单水平或垂直展示
23
+ */
11
24
  placement?: 'horizontal' | 'vertical';
25
+ /**
26
+ * 是否收起子菜单,菜单垂直展示时有效
27
+ */
12
28
  collapsed?: boolean;
29
+ /**
30
+ * 默认是否收起子菜单,菜单垂直展示时有效
31
+ */
32
+ defaultCollapsed?: boolean;
33
+ /**
34
+ * 是否显示收缩开关,菜单垂直展示时有效
35
+ */
13
36
  showCollapse?: boolean;
37
+ /**
38
+ * 是否以胖菜单的形式展开所有子菜单(仅在水平菜单时有效)
39
+ */
14
40
  showAllSubMenus?: boolean;
41
+ /**
42
+ * 手风琴模式,菜单水平展示时有效
43
+ */
15
44
  accordion?: boolean;
16
- onClick?: (menuId: React.ReactText) => void;
17
- onClickSubMenu?: (subMenuId: React.ReactText, expandedIds: React.ReactText[]) => void;
18
- onCollapse?: (collapsed: boolean) => void;
45
+ /**
46
+ * 下拉框根类名
47
+ */
19
48
  overlayClassName?: string;
49
+ /**
50
+ * 弹出层展开方式
51
+ */
20
52
  expandedType?: 'collapse' | 'pop';
53
+ /**
54
+ * 首次渲染默认展开所有菜单项,为非受控模式
55
+ */
56
+ defaultExpandAll?: boolean;
57
+ /**
58
+ * 首次渲染默认展开菜单项 ids 列表,为非受控模式
59
+ */
21
60
  defaultExpandedIds?: React.ReactText[];
22
- defaultActiveId?: React.ReactText;
61
+ /**
62
+ * 展开菜单项 ids 列表,开启受控
63
+ */
64
+ expandedIds?: React.ReactText[];
65
+ /**
66
+ * 展开菜单时回调
67
+ */
68
+ onExpand?: (expandedIds: React.ReactText[]) => void;
69
+ /**
70
+ * 点击菜单选项时的回调
71
+ */
72
+ onClick?: (menuId: React.ReactText, menuItem: MenuDataItem) => void;
73
+ /**
74
+ * 点击父菜单项时的回调
75
+ */
76
+ onClickSubMenu?: (subMenuId: React.ReactText, expandedIds: React.ReactText[]) => void;
77
+ /**
78
+ * 点击收缩开关时的回调
79
+ */
80
+ onCollapse?: (collapsed: boolean) => void;
81
+ /**
82
+ * 底部渲染器
83
+ */
84
+ footerRender?: (props: MenuFooterRenderProps) => React.ReactNode;
23
85
  }
@@ -1,12 +1,15 @@
1
1
  import React from 'react';
2
2
  import { HiBaseHTMLProps } from '@hi-ui/core';
3
+ import { MenuDataItem } from './types';
3
4
  export declare const MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLLIElement | null>>;
4
5
  export interface MenuItemProps extends Omit<HiBaseHTMLProps<'li'>, 'id'> {
5
6
  id: React.ReactText;
6
7
  title: React.ReactNode;
7
8
  icon?: React.ReactNode;
8
9
  disabled?: boolean;
9
- children?: MenuItemProps[];
10
+ children?: MenuDataItem[];
10
11
  level?: number;
11
12
  parentIds?: React.ReactText[];
13
+ render?: (node: MenuDataItem) => React.ReactNode;
14
+ raw?: MenuDataItem;
12
15
  }