@hi-ui/menu 5.0.0-canary.2 → 5.0.0-canary.21
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 +250 -0
- package/lib/cjs/EnterIcon.js +44 -0
- package/lib/cjs/Expander.js +11 -3
- package/lib/cjs/GroupMenu.js +124 -0
- package/lib/cjs/Menu.js +68 -17
- package/lib/cjs/MenuItem.js +56 -26
- package/lib/cjs/MenuSearch.js +365 -0
- package/lib/cjs/SideMenu.js +202 -0
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/styles/index.scss.js +1 -1
- package/lib/cjs/util.js +95 -1
- package/lib/esm/EnterIcon.js +32 -0
- package/lib/esm/Expander.js +11 -3
- package/lib/esm/GroupMenu.js +111 -0
- package/lib/esm/Menu.js +69 -18
- package/lib/esm/MenuItem.js +56 -26
- package/lib/esm/MenuSearch.js +347 -0
- package/lib/esm/SideMenu.js +187 -0
- package/lib/esm/index.js +3 -0
- package/lib/esm/styles/index.scss.js +1 -1
- package/lib/esm/util.js +95 -2
- package/lib/types/EnterIcon.d.ts +1 -0
- package/lib/types/GroupMenu.d.ts +34 -0
- package/lib/types/Menu.d.ts +11 -2
- package/lib/types/MenuItem.d.ts +1 -1
- package/lib/types/MenuSearch.d.ts +44 -0
- package/lib/types/SideMenu.d.ts +63 -0
- package/lib/types/context.d.ts +8 -2
- package/lib/types/index.d.ts +3 -0
- package/lib/types/util.d.ts +16 -0
- package/package.json +29 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,255 @@
|
|
|
1
1
|
# @hi-ui/menu
|
|
2
2
|
|
|
3
|
+
## 5.0.0-canary.21
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d49302358: feat(menu): title 支持显示 2 行 (5.0)
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [3a7186e4b]
|
|
12
|
+
- @hi-ui/use-merge-semantic@5.0.0-canary.1
|
|
13
|
+
|
|
14
|
+
## 5.0.0-canary.20
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 59cef699f: feat: 组件语义化样式改造,增加 styles 和 classNames 属性 (5.0)
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- eb17c4697: style: 修复 UI/样式问题 (5.0)
|
|
23
|
+
- Updated dependencies [7f204c892]
|
|
24
|
+
- Updated dependencies [66bc9c3e2]
|
|
25
|
+
- Updated dependencies [eb17c4697]
|
|
26
|
+
- Updated dependencies [eb17c4697]
|
|
27
|
+
- Updated dependencies [c407744fe]
|
|
28
|
+
- Updated dependencies [59cef699f]
|
|
29
|
+
- @hi-ui/icons@5.0.0-canary.10
|
|
30
|
+
- @hi-ui/ellipsis-tooltip@5.0.0-canary.7
|
|
31
|
+
- @hi-ui/core@5.0.0-canary.7
|
|
32
|
+
- @hi-ui/button@5.0.0-canary.14
|
|
33
|
+
- @hi-ui/highlighter@5.0.0-canary.5
|
|
34
|
+
- @hi-ui/icon-button@5.0.0-canary.9
|
|
35
|
+
- @hi-ui/input@5.0.0-canary.19
|
|
36
|
+
- @hi-ui/picker@5.0.0-canary.16
|
|
37
|
+
- @hi-ui/popper@5.0.0-canary.13
|
|
38
|
+
- @hi-ui/scrollbar@5.0.0-canary.8
|
|
39
|
+
- @hi-ui/tooltip@5.0.0-canary.11
|
|
40
|
+
- @hi-ui/use-merge-semantic@5.0.0-canary.0
|
|
41
|
+
|
|
42
|
+
## 5.0.0-canary.19
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- ec6005193: style(layout,menu): 样式和示例调整 (5.0)
|
|
47
|
+
- Updated dependencies [8f23e9322]
|
|
48
|
+
- Updated dependencies [b27483796]
|
|
49
|
+
- Updated dependencies [900c6c2f0]
|
|
50
|
+
- @hi-ui/input@5.0.0-canary.18
|
|
51
|
+
- @hi-ui/picker@5.0.0-canary.15
|
|
52
|
+
|
|
53
|
+
## 5.0.0-canary.18
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- b15a87bd4: style: fix ui bug (5.0)
|
|
58
|
+
|
|
59
|
+
## 5.0.0-canary.17
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- 305b4dd37: style: fix ui bug (5.0)
|
|
64
|
+
- Updated dependencies [c6c0159c4]
|
|
65
|
+
- Updated dependencies [305b4dd37]
|
|
66
|
+
- @hi-ui/icons@5.0.0-canary.9
|
|
67
|
+
- @hi-ui/tooltip@5.0.0-canary.9
|
|
68
|
+
|
|
69
|
+
## 5.0.0-canary.16
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- d1e7ade1e: styles: 主题定制功能完善&&样式变量化写法改造&&兼容 RTL (5.0)
|
|
74
|
+
- Updated dependencies [d1e7ade1e]
|
|
75
|
+
- Updated dependencies [da16450b4]
|
|
76
|
+
- Updated dependencies [1e6276dde]
|
|
77
|
+
- @hi-ui/button@5.0.0-canary.13
|
|
78
|
+
- @hi-ui/icon-button@5.0.0-canary.8
|
|
79
|
+
- @hi-ui/input@5.0.0-canary.17
|
|
80
|
+
- @hi-ui/picker@5.0.0-canary.14
|
|
81
|
+
- @hi-ui/popper@5.0.0-canary.12
|
|
82
|
+
- @hi-ui/scrollbar@5.0.0-canary.7
|
|
83
|
+
- @hi-ui/tooltip@5.0.0-canary.8
|
|
84
|
+
- @hi-ui/icons@5.0.0-canary.8
|
|
85
|
+
- @hi-ui/ellipsis-tooltip@5.0.0-canary.6
|
|
86
|
+
|
|
87
|
+
## 5.0.0-canary.15
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- 58db39510: style: fix ui bug (5.0)
|
|
92
|
+
- Updated dependencies [58db39510]
|
|
93
|
+
- @hi-ui/icons@5.0.0-canary.7
|
|
94
|
+
- @hi-ui/icon-button@5.0.0-canary.7
|
|
95
|
+
- @hi-ui/input@5.0.0-canary.16
|
|
96
|
+
- @hi-ui/popper@5.0.0-canary.11
|
|
97
|
+
|
|
98
|
+
## 5.0.0-canary.14
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- 947edaa7e: style: fix ui bug (5.0)
|
|
103
|
+
- 0b67f7083: style: 修改 UI 问题 (5.0)
|
|
104
|
+
- Updated dependencies [947edaa7e]
|
|
105
|
+
- Updated dependencies [0b67f7083]
|
|
106
|
+
- @hi-ui/tooltip@5.0.0-canary.7
|
|
107
|
+
- @hi-ui/icons@5.0.0-canary.6
|
|
108
|
+
- @hi-ui/icon-button@5.0.0-canary.6
|
|
109
|
+
- @hi-ui/popper@5.0.0-canary.10
|
|
110
|
+
|
|
111
|
+
## 5.0.0-canary.13
|
|
112
|
+
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- d97cc24eb: chore: 修改 react-compat 依赖管理方式 & 更新 react-transition-group 依赖 (5.0)
|
|
116
|
+
- 1f9c6e335: perf: 优化全局 size 配置,对于组件中没有的 size 值,取最接近的尺寸展示 (5.0)
|
|
117
|
+
- 22db9cf70: style: fix ui bug (5.0)
|
|
118
|
+
- Updated dependencies [d97cc24eb]
|
|
119
|
+
- Updated dependencies [1f9c6e335]
|
|
120
|
+
- Updated dependencies [22db9cf70]
|
|
121
|
+
- @hi-ui/popper@5.0.0-canary.9
|
|
122
|
+
- @hi-ui/tooltip@5.0.0-canary.6
|
|
123
|
+
- @hi-ui/core@5.0.0-canary.6
|
|
124
|
+
- @hi-ui/button@5.0.0-canary.12
|
|
125
|
+
- @hi-ui/icon-button@5.0.0-canary.5
|
|
126
|
+
- @hi-ui/input@5.0.0-canary.15
|
|
127
|
+
- @hi-ui/picker@5.0.0-canary.13
|
|
128
|
+
- @hi-ui/scrollbar@5.0.0-canary.6
|
|
129
|
+
|
|
130
|
+
## 5.0.0-canary.12
|
|
131
|
+
|
|
132
|
+
### Minor Changes
|
|
133
|
+
|
|
134
|
+
- 922686dcc: feat(global-context): 增加 size api 全局配置 (5.0)
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- 86877b241: style: 修改样式问题 (5.0)
|
|
139
|
+
- Updated dependencies [2b706fc6d]
|
|
140
|
+
- Updated dependencies [86877b241]
|
|
141
|
+
- Updated dependencies [922686dcc]
|
|
142
|
+
- Updated dependencies [8e969ad73]
|
|
143
|
+
- @hi-ui/picker@5.0.0-canary.12
|
|
144
|
+
- @hi-ui/button@5.0.0-canary.11
|
|
145
|
+
- @hi-ui/ellipsis-tooltip@5.0.0-canary.5
|
|
146
|
+
- @hi-ui/highlighter@5.0.0-canary.4
|
|
147
|
+
- @hi-ui/icon-button@5.0.0-canary.4
|
|
148
|
+
- @hi-ui/input@5.0.0-canary.14
|
|
149
|
+
- @hi-ui/popper@5.0.0-canary.8
|
|
150
|
+
- @hi-ui/scrollbar@5.0.0-canary.5
|
|
151
|
+
- @hi-ui/tooltip@5.0.0-canary.5
|
|
152
|
+
- @hi-ui/core@5.0.0-canary.5
|
|
153
|
+
- @hi-ui/icons@5.0.0-canary.5
|
|
154
|
+
|
|
155
|
+
## 5.0.0-canary.11
|
|
156
|
+
|
|
157
|
+
### Minor Changes
|
|
158
|
+
|
|
159
|
+
- 632895aaf: feat(menu): GroupMenu 组件增加 titleRender 参数 (5.0)
|
|
160
|
+
|
|
161
|
+
## 5.0.0-canary.10
|
|
162
|
+
|
|
163
|
+
### Patch Changes
|
|
164
|
+
|
|
165
|
+
- 3f88c4dca: <br />
|
|
166
|
+
- perf(layout): 优化导航菜单交互体验 (5.0)
|
|
167
|
+
- perf(menu): 优化搜索菜单组件的样式和交互逻辑 & 修改分组菜单样式问题 (5.0)
|
|
168
|
+
- Updated dependencies [4dc72a186]
|
|
169
|
+
- @hi-ui/popper@5.0.0-canary.7
|
|
170
|
+
|
|
171
|
+
## 5.0.0-canary.9
|
|
172
|
+
|
|
173
|
+
### Patch Changes
|
|
174
|
+
|
|
175
|
+
- 282e6c499: perf(layout&menu): 优化 FloatMenuContainer 组件的折叠逻辑 & 修改 SideMenu 组件 hover 样式 (5.0)
|
|
176
|
+
- 4782eb807: style(menu): 优化 GroupMenu 组件的样式和交互逻辑 (5.0)
|
|
177
|
+
- Updated dependencies [19e0da371]
|
|
178
|
+
- @hi-ui/input@5.0.0-canary.11
|
|
179
|
+
|
|
180
|
+
## 5.0.0-canary.8
|
|
181
|
+
|
|
182
|
+
### Patch Changes
|
|
183
|
+
|
|
184
|
+
- efce04a26: fix: 修改 UI 问题 (5.0)
|
|
185
|
+
- Updated dependencies [efce04a26]
|
|
186
|
+
- Updated dependencies [9106dca82]
|
|
187
|
+
- @hi-ui/picker@5.0.0-canary.10
|
|
188
|
+
- @hi-ui/popper@5.0.0-canary.6
|
|
189
|
+
- @hi-ui/core@5.0.0-canary.3
|
|
190
|
+
- @hi-ui/input@5.0.0-canary.10
|
|
191
|
+
- @hi-ui/icons@5.0.0-canary.3
|
|
192
|
+
- @hi-ui/ellipsis-tooltip@5.0.0-canary.3
|
|
193
|
+
- @hi-ui/highlighter@5.0.0-canary.3
|
|
194
|
+
- @hi-ui/icon-button@5.0.0-canary.3
|
|
195
|
+
- @hi-ui/scrollbar@5.0.0-canary.4
|
|
196
|
+
- @hi-ui/tooltip@5.0.0-canary.4
|
|
197
|
+
|
|
198
|
+
## 5.0.0-canary.7
|
|
199
|
+
|
|
200
|
+
### Minor Changes
|
|
201
|
+
|
|
202
|
+
- 4075b33da: feat(menu): 增加 GroupMenu 和 SideMenu 组件 (5.0)
|
|
203
|
+
|
|
204
|
+
## 5.0.0-canary.6
|
|
205
|
+
|
|
206
|
+
### Patch Changes
|
|
207
|
+
|
|
208
|
+
- 07e7b975b: style(layout): 修改 Sider 收起时宽度为 60px & 增加 width 参数 (5.0)
|
|
209
|
+
- Updated dependencies [7182c7bb8]
|
|
210
|
+
- @hi-ui/input@5.0.0-canary.9
|
|
211
|
+
|
|
212
|
+
## 5.0.0-canary.5
|
|
213
|
+
|
|
214
|
+
### Minor Changes
|
|
215
|
+
|
|
216
|
+
- 44c862279: chore(menu): 增加变更记录文件 (5.0)
|
|
217
|
+
|
|
218
|
+
### Patch Changes
|
|
219
|
+
|
|
220
|
+
- Updated dependencies [7bc790804]
|
|
221
|
+
- @hi-ui/picker@5.0.0-canary.9
|
|
222
|
+
- @hi-ui/popper@5.0.0-canary.5
|
|
223
|
+
|
|
224
|
+
## 5.0.0-canary.4
|
|
225
|
+
|
|
226
|
+
### Minor Changes
|
|
227
|
+
|
|
228
|
+
- 47334c3e0: feat(menu): add showTitleOnMini api (5.0)
|
|
229
|
+
|
|
230
|
+
## 5.0.0-canary.3
|
|
231
|
+
|
|
232
|
+
### Patch Changes
|
|
233
|
+
|
|
234
|
+
- chore: rebase master (5.0)
|
|
235
|
+
- Updated dependencies
|
|
236
|
+
- @hi-ui/core@5.0.0-canary.2
|
|
237
|
+
- @hi-ui/use-id@5.0.0-canary.2
|
|
238
|
+
- @hi-ui/use-merge-refs@5.0.0-canary.2
|
|
239
|
+
- @hi-ui/use-resize-observer@5.0.0-canary.2
|
|
240
|
+
- @hi-ui/use-toggle@5.0.0-canary.2
|
|
241
|
+
- @hi-ui/use-uncontrolled-state@5.0.0-canary.2
|
|
242
|
+
- @hi-ui/icons@5.0.0-canary.2
|
|
243
|
+
- @hi-ui/popper@5.0.0-canary.3
|
|
244
|
+
- @hi-ui/scrollbar@5.0.0-canary.2
|
|
245
|
+
- @hi-ui/tooltip@5.0.0-canary.3
|
|
246
|
+
- @hi-ui/array-utils@5.0.0-canary.2
|
|
247
|
+
- @hi-ui/classname@5.0.0-canary.2
|
|
248
|
+
- @hi-ui/env@5.0.0-canary.2
|
|
249
|
+
- @hi-ui/times@5.0.0-canary.2
|
|
250
|
+
- @hi-ui/tree-utils@5.0.0-canary.2
|
|
251
|
+
- @hi-ui/type-assertion@5.0.0-canary.2
|
|
252
|
+
|
|
3
253
|
## 5.0.0-canary.2
|
|
4
254
|
|
|
5
255
|
### Patch Changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/menu
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/menu#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var React = require('react');
|
|
17
|
+
function _interopDefaultCompat(e) {
|
|
18
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
19
|
+
'default': e
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
23
|
+
var EnterIcon = function EnterIcon() {
|
|
24
|
+
return /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
25
|
+
width: "12",
|
|
26
|
+
height: "12",
|
|
27
|
+
viewBox: "0 0 12 12",
|
|
28
|
+
fill: "none",
|
|
29
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
30
|
+
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
31
|
+
d: "M4 9L2 7L4 5",
|
|
32
|
+
stroke: "#91959e",
|
|
33
|
+
strokeWidth: "1.2",
|
|
34
|
+
strokeLinecap: "round",
|
|
35
|
+
strokeLinejoin: "round"
|
|
36
|
+
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
37
|
+
d: "M10 3L10 6.25C10 6.66422 9.66423 7 9.25 7L2 7",
|
|
38
|
+
stroke: "#91959e",
|
|
39
|
+
strokeWidth: "1.2",
|
|
40
|
+
strokeLinecap: "round",
|
|
41
|
+
strokeLinejoin: "round"
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
exports.EnterIcon = EnterIcon;
|
package/lib/cjs/Expander.js
CHANGED
|
@@ -28,12 +28,17 @@ var Expander = function Expander(_ref) {
|
|
|
28
28
|
var _useState = React.useState(visible ? 'auto' : 0),
|
|
29
29
|
height = _useState[0],
|
|
30
30
|
setHeight = _useState[1];
|
|
31
|
+
var innerRef = React__default["default"].useRef(null);
|
|
31
32
|
return /*#__PURE__*/React__default["default"].createElement(reactTransitionGroup.CSSTransition, {
|
|
32
33
|
"in": visible,
|
|
33
34
|
timeout: 200,
|
|
34
35
|
classNames: className,
|
|
35
36
|
unmountOnExit: false,
|
|
36
|
-
|
|
37
|
+
// 参考:https://github.com/reactjs/react-transition-group/issues/918
|
|
38
|
+
nodeRef: innerRef,
|
|
39
|
+
onEnter: function onEnter() {
|
|
40
|
+
var element = innerRef.current;
|
|
41
|
+
if (!element) return;
|
|
37
42
|
setHeight(0);
|
|
38
43
|
setTimeout(function () {
|
|
39
44
|
setHeight(element.scrollHeight);
|
|
@@ -42,7 +47,9 @@ var Expander = function Expander(_ref) {
|
|
|
42
47
|
onEntered: function onEntered() {
|
|
43
48
|
setHeight('auto');
|
|
44
49
|
},
|
|
45
|
-
onExit: function onExit(
|
|
50
|
+
onExit: function onExit() {
|
|
51
|
+
var element = innerRef.current;
|
|
52
|
+
if (!element) return;
|
|
46
53
|
setHeight(element.scrollHeight);
|
|
47
54
|
setTimeout(function () {
|
|
48
55
|
setHeight(0);
|
|
@@ -53,7 +60,8 @@ var Expander = function Expander(_ref) {
|
|
|
53
60
|
height: height,
|
|
54
61
|
overflow: 'hidden',
|
|
55
62
|
transition: 'all 0.3s'
|
|
56
|
-
}
|
|
63
|
+
},
|
|
64
|
+
ref: innerRef
|
|
57
65
|
}, children));
|
|
58
66
|
};
|
|
59
67
|
exports.Expander = Expander;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/menu
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/menu#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var tslib = require('tslib');
|
|
17
|
+
var React = require('react');
|
|
18
|
+
var classname = require('@hi-ui/classname');
|
|
19
|
+
var env = require('@hi-ui/env');
|
|
20
|
+
var core = require('@hi-ui/core');
|
|
21
|
+
var useMergeSemantic = require('@hi-ui/use-merge-semantic');
|
|
22
|
+
var typeAssertion = require('@hi-ui/type-assertion');
|
|
23
|
+
var useLatest = require('@hi-ui/use-latest');
|
|
24
|
+
var useUncontrolledState = require('@hi-ui/use-uncontrolled-state');
|
|
25
|
+
var Scrollbar = require('@hi-ui/scrollbar');
|
|
26
|
+
function _interopDefaultCompat(e) {
|
|
27
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
28
|
+
'default': e
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
32
|
+
var Scrollbar__default = /*#__PURE__*/_interopDefaultCompat(Scrollbar);
|
|
33
|
+
var _role = 'group-menu';
|
|
34
|
+
var GROUP_MENU_PREFIX = classname.getPrefixCls(_role);
|
|
35
|
+
/**
|
|
36
|
+
* 分组菜单
|
|
37
|
+
*/
|
|
38
|
+
var GroupMenu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
39
|
+
var _a$prefixCls = _a.prefixCls,
|
|
40
|
+
prefixCls = _a$prefixCls === void 0 ? GROUP_MENU_PREFIX : _a$prefixCls,
|
|
41
|
+
_a$role = _a.role,
|
|
42
|
+
role = _a$role === void 0 ? _role : _a$role,
|
|
43
|
+
className = _a.className,
|
|
44
|
+
style = _a.style,
|
|
45
|
+
classNamesProp = _a.classNames,
|
|
46
|
+
stylesProp = _a.styles,
|
|
47
|
+
_a$data = _a.data,
|
|
48
|
+
data = _a$data === void 0 ? [] : _a$data,
|
|
49
|
+
onClick = _a.onClick,
|
|
50
|
+
_a$defaultActiveId = _a.defaultActiveId,
|
|
51
|
+
defaultActiveId = _a$defaultActiveId === void 0 ? '' : _a$defaultActiveId,
|
|
52
|
+
activeIdProp = _a.activeId,
|
|
53
|
+
titleRender = _a.titleRender,
|
|
54
|
+
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "style", "classNames", "styles", "data", "onClick", "defaultActiveId", "activeId", "titleRender"]);
|
|
55
|
+
var _useGlobalContext = core.useGlobalContext(),
|
|
56
|
+
groupMenuConfig = _useGlobalContext.groupMenu;
|
|
57
|
+
var _useMergeSemantic = useMergeSemantic.useMergeSemantic({
|
|
58
|
+
classNamesList: [groupMenuConfig === null || groupMenuConfig === void 0 ? void 0 : groupMenuConfig.classNames, classNamesProp],
|
|
59
|
+
stylesList: [groupMenuConfig === null || groupMenuConfig === void 0 ? void 0 : groupMenuConfig.styles, stylesProp],
|
|
60
|
+
info: {
|
|
61
|
+
props: Object.assign(Object.assign({}, rest), {
|
|
62
|
+
data: data,
|
|
63
|
+
defaultActiveId: defaultActiveId,
|
|
64
|
+
activeId: activeIdProp,
|
|
65
|
+
titleRender: titleRender
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
69
|
+
classNames = _useMergeSemantic.classNames,
|
|
70
|
+
styles = _useMergeSemantic.styles;
|
|
71
|
+
var _useUncontrolledState = useUncontrolledState.useUncontrolledState(defaultActiveId, activeIdProp),
|
|
72
|
+
activeId = _useUncontrolledState[0],
|
|
73
|
+
tryChangeActiveId = _useUncontrolledState[1];
|
|
74
|
+
var handleClick = useLatest.useLatestCallback(function (evt, id, item) {
|
|
75
|
+
tryChangeActiveId(id);
|
|
76
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(evt, id, item);
|
|
77
|
+
});
|
|
78
|
+
var renderItem = React.useCallback(function (data) {
|
|
79
|
+
return data.map(function (item) {
|
|
80
|
+
var _cx;
|
|
81
|
+
var id = item.id,
|
|
82
|
+
icon = item.icon,
|
|
83
|
+
title = item.title,
|
|
84
|
+
_item$children = item.children,
|
|
85
|
+
children = _item$children === void 0 ? [] : _item$children,
|
|
86
|
+
disabled = item.disabled;
|
|
87
|
+
var isParent = typeAssertion.isArrayNonEmpty(children);
|
|
88
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
89
|
+
key: id,
|
|
90
|
+
className: classname.cx(isParent ? prefixCls + "-parent-item" : prefixCls + "-item", (_cx = {}, _cx[prefixCls + "-item--active"] = activeId === id, _cx[prefixCls + "-item--disabled"] = disabled, _cx[prefixCls + "-item--empty"] = !title && !icon, _cx), classNames === null || classNames === void 0 ? void 0 : classNames.item),
|
|
91
|
+
style: styles === null || styles === void 0 ? void 0 : styles.item,
|
|
92
|
+
onClick: function onClick(evt) {
|
|
93
|
+
if (disabled || isParent) return;
|
|
94
|
+
evt.stopPropagation();
|
|
95
|
+
handleClick(evt, id, item);
|
|
96
|
+
}
|
|
97
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
98
|
+
className: classname.cx(prefixCls + "-item__content", classNames === null || classNames === void 0 ? void 0 : classNames.itemContent),
|
|
99
|
+
style: styles === null || styles === void 0 ? void 0 : styles.itemContent
|
|
100
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
101
|
+
className: classname.cx(prefixCls + "-item__icon", classNames === null || classNames === void 0 ? void 0 : classNames.itemIcon),
|
|
102
|
+
style: styles === null || styles === void 0 ? void 0 : styles.itemIcon
|
|
103
|
+
}, icon), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
104
|
+
className: classname.cx(prefixCls + "-item__title", classNames === null || classNames === void 0 ? void 0 : classNames.itemTitle),
|
|
105
|
+
style: styles === null || styles === void 0 ? void 0 : styles.itemTitle
|
|
106
|
+
}, typeof titleRender === 'function' ? titleRender(item) : title)), isParent && renderItem(children));
|
|
107
|
+
});
|
|
108
|
+
}, [activeId, handleClick, prefixCls, titleRender, classNames, styles]);
|
|
109
|
+
return /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
|
|
110
|
+
className: classname.cx(prefixCls, className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
|
|
111
|
+
style: Object.assign(Object.assign({}, style), styles === null || styles === void 0 ? void 0 : styles.root),
|
|
112
|
+
ref: ref,
|
|
113
|
+
role: role
|
|
114
|
+
}, rest), /*#__PURE__*/React__default["default"].createElement(Scrollbar__default["default"], {
|
|
115
|
+
onlyScrollVisible: true,
|
|
116
|
+
axes: "y",
|
|
117
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.wrapper,
|
|
118
|
+
style: styles === null || styles === void 0 ? void 0 : styles.wrapper
|
|
119
|
+
}, renderItem(data)));
|
|
120
|
+
});
|
|
121
|
+
if (env.__DEV__) {
|
|
122
|
+
GroupMenu.displayName = 'GroupMenu';
|
|
123
|
+
}
|
|
124
|
+
exports.GroupMenu = GroupMenu;
|
package/lib/cjs/Menu.js
CHANGED
|
@@ -19,6 +19,8 @@ var classname = require('@hi-ui/classname');
|
|
|
19
19
|
var icons = require('@hi-ui/icons');
|
|
20
20
|
var env = require('@hi-ui/env');
|
|
21
21
|
var useUncontrolledState = require('@hi-ui/use-uncontrolled-state');
|
|
22
|
+
var core = require('@hi-ui/core');
|
|
23
|
+
var useMergeSemantic = require('@hi-ui/use-merge-semantic');
|
|
22
24
|
var Tooltip = require('@hi-ui/tooltip');
|
|
23
25
|
var useToggle = require('@hi-ui/use-toggle');
|
|
24
26
|
var treeUtils = require('@hi-ui/tree-utils');
|
|
@@ -45,11 +47,15 @@ var MENU_MORE_ID = "MENU_MORE_" + useId.uuid();
|
|
|
45
47
|
* 菜单
|
|
46
48
|
*/
|
|
47
49
|
var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
50
|
+
var _b, _c;
|
|
48
51
|
var _a$prefixCls = _a.prefixCls,
|
|
49
52
|
prefixCls = _a$prefixCls === void 0 ? MENU_PREFIX : _a$prefixCls,
|
|
50
53
|
_a$role = _a.role,
|
|
51
54
|
role = _a$role === void 0 ? 'menu' : _a$role,
|
|
52
55
|
className = _a.className,
|
|
56
|
+
style = _a.style,
|
|
57
|
+
classNamesProp = _a.classNames,
|
|
58
|
+
stylesProp = _a.styles,
|
|
53
59
|
_a$data = _a.data,
|
|
54
60
|
data = _a$data === void 0 ? NOOP_ARRAY : _a$data,
|
|
55
61
|
fieldNames = _a.fieldNames,
|
|
@@ -80,12 +86,41 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
80
86
|
render = _a.render,
|
|
81
87
|
extraHeader = _a.extraHeader,
|
|
82
88
|
onClick = _a.onClick,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
sizeProp = _a.size,
|
|
90
|
+
_a$showTitleOnMini = _a.showTitleOnMini,
|
|
91
|
+
showTitleOnMini = _a$showTitleOnMini === void 0 ? false : _a$showTitleOnMini,
|
|
92
|
+
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "style", "classNames", "styles", "data", "fieldNames", "placement", "showCollapse", "expandedType", "showAllSubMenus", "defaultExpandAll", "defaultExpandedIds", "expandedIds", "onExpand", "defaultActiveId", "activeId", "onClickSubMenu", "collapsed", "defaultCollapsed", "overlayClassName", "onCollapse", "footerRender", "render", "extraHeader", "onClick", "size", "showTitleOnMini"]);
|
|
93
|
+
var i18n = core.useLocaleContext();
|
|
86
94
|
var _useUncontrolledState = useUncontrolledState.useUncontrolledState(defaultActiveId, activeIdProp, onClick),
|
|
87
95
|
activeId = _useUncontrolledState[0],
|
|
88
96
|
updateActiveId = _useUncontrolledState[1];
|
|
97
|
+
var _useGlobalContext = core.useGlobalContext(),
|
|
98
|
+
globalSize = _useGlobalContext.size,
|
|
99
|
+
menuConfig = _useGlobalContext.menu;
|
|
100
|
+
var size = (_b = sizeProp !== null && sizeProp !== void 0 ? sizeProp : globalSize) !== null && _b !== void 0 ? _b : 'lg';
|
|
101
|
+
if (size === 'xs') {
|
|
102
|
+
size = 'sm';
|
|
103
|
+
}
|
|
104
|
+
var _useMergeSemantic = useMergeSemantic.useMergeSemantic({
|
|
105
|
+
classNamesList: [menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.classNames, classNamesProp],
|
|
106
|
+
stylesList: [menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.styles, stylesProp],
|
|
107
|
+
info: {
|
|
108
|
+
props: Object.assign(Object.assign({}, rest), {
|
|
109
|
+
data: data,
|
|
110
|
+
placement: placement,
|
|
111
|
+
size: (_c = sizeProp !== null && sizeProp !== void 0 ? sizeProp : globalSize) !== null && _c !== void 0 ? _c : 'lg',
|
|
112
|
+
showCollapse: showCollapse,
|
|
113
|
+
expandedType: expandedType,
|
|
114
|
+
showAllSubMenus: showAllSubMenus,
|
|
115
|
+
defaultExpandAll: defaultExpandAll,
|
|
116
|
+
defaultCollapsed: defaultCollapsed,
|
|
117
|
+
collapsed: collapsed,
|
|
118
|
+
showTitleOnMini: showTitleOnMini
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
classNames = _useMergeSemantic.classNames,
|
|
123
|
+
styles = _useMergeSemantic.styles;
|
|
89
124
|
var _useState = React.useState(function () {
|
|
90
125
|
return util.getAncestorIds(activeId, data);
|
|
91
126
|
}),
|
|
@@ -104,6 +139,7 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
104
139
|
}, expandedIdsProp, onExpand),
|
|
105
140
|
expandedIds = _useUncontrolledState2[0],
|
|
106
141
|
updateExpandedIds = _useUncontrolledState2[1];
|
|
142
|
+
var expandedIdsRef = React.useRef(expandedIds);
|
|
107
143
|
var clickMenu = React.useCallback(function (id, raw) {
|
|
108
144
|
updateActiveId(id, raw);
|
|
109
145
|
}, [updateActiveId]);
|
|
@@ -112,14 +148,17 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
112
148
|
return expandedId !== id;
|
|
113
149
|
}) : expandedIds.concat(id);
|
|
114
150
|
updateExpandedIds(nextExpandedIds);
|
|
151
|
+
expandedIdsRef.current = nextExpandedIds;
|
|
115
152
|
if (onClickSubMenu) {
|
|
116
153
|
onClickSubMenu(id, nextExpandedIds);
|
|
117
154
|
}
|
|
118
155
|
}, [onClickSubMenu, expandedIds, updateExpandedIds]);
|
|
119
156
|
var closePopper = React.useCallback(function (id) {
|
|
120
|
-
|
|
157
|
+
var nextExpandedIds = expandedIds.filter(function (expandedId) {
|
|
121
158
|
return expandedId !== id;
|
|
122
|
-
})
|
|
159
|
+
});
|
|
160
|
+
updateExpandedIds(nextExpandedIds);
|
|
161
|
+
expandedIdsRef.current = nextExpandedIds;
|
|
123
162
|
}, [expandedIds, updateExpandedIds]);
|
|
124
163
|
var closeAllPopper = React.useCallback(function () {
|
|
125
164
|
updateExpandedIds([]);
|
|
@@ -152,6 +191,13 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
152
191
|
setContainerWidth(width);
|
|
153
192
|
}
|
|
154
193
|
});
|
|
194
|
+
React.useEffect(function () {
|
|
195
|
+
if (mini) {
|
|
196
|
+
updateExpandedIds([]);
|
|
197
|
+
} else {
|
|
198
|
+
updateExpandedIds(expandedIdsRef.current);
|
|
199
|
+
}
|
|
200
|
+
}, [mini, updateExpandedIds]);
|
|
155
201
|
var _useState4 = React.useState(0),
|
|
156
202
|
tagMaxCount = _useState4[0],
|
|
157
203
|
setTagMaxCount = _useState4[1];
|
|
@@ -200,11 +246,10 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
200
246
|
}, [showVertical, getTagWidth, containerWidth, mergedTagList]);
|
|
201
247
|
var renderFooter = function renderFooter() {
|
|
202
248
|
var collapseNode = canToggle ? ( /*#__PURE__*/React__default["default"].createElement("div", {
|
|
203
|
-
className: classname.cx(prefixCls + "__toggle"),
|
|
249
|
+
className: classname.cx(prefixCls + "__toggle", classNames === null || classNames === void 0 ? void 0 : classNames.toggle),
|
|
250
|
+
style: styles === null || styles === void 0 ? void 0 : styles.toggle,
|
|
204
251
|
onClick: function onClick() {
|
|
205
|
-
miniToggleAction.not();
|
|
206
|
-
// 关闭所有展开的子菜单,防止切换到 mini 模式后,子菜单还是展开的
|
|
207
|
-
updateExpandedIds([]);
|
|
252
|
+
return miniToggleAction.not();
|
|
208
253
|
}
|
|
209
254
|
}, mini ? /*#__PURE__*/React__default["default"].createElement(icons.MenuUnfoldOutlined, null) : /*#__PURE__*/React__default["default"].createElement(icons.MenuFoldOutlined, null))) : null;
|
|
210
255
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, typeAssertion.isFunction(footerRender) ? footerRender({
|
|
@@ -214,22 +259,24 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
214
259
|
};
|
|
215
260
|
var renderItem = React.useCallback(function (menuItem, level) {
|
|
216
261
|
// 显示缩略内容
|
|
217
|
-
if (showMini && level === 1) {
|
|
262
|
+
if (showMini && level === 1 && !showTitleOnMini) {
|
|
218
263
|
return renderMenuItemMini(menuItem);
|
|
219
264
|
}
|
|
220
265
|
return typeAssertion.isFunction(render) ? render(menuItem, level) : menuItem.title;
|
|
221
|
-
}, [render, showMini]);
|
|
222
|
-
var cls = classname.cx(prefixCls, className, prefixCls + "--" + placement, prefixCls + "--size-" + size, mini && prefixCls + "--mini", (expandedType === 'pop' || showAllSubMenus || mini) && prefixCls + "--popup");
|
|
266
|
+
}, [render, showMini, showTitleOnMini]);
|
|
267
|
+
var cls = classname.cx(prefixCls, className, classNames === null || classNames === void 0 ? void 0 : classNames.root, prefixCls + "--" + placement, prefixCls + "--size-" + size, mini && prefixCls + "--mini", showTitleOnMini && prefixCls + "--show-title-on-mini", (expandedType === 'pop' || showAllSubMenus || mini) && prefixCls + "--popup");
|
|
223
268
|
return /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
|
|
224
269
|
ref: useMergeRefs.useMergeRefs(ref, setContainerElement),
|
|
225
270
|
role: role,
|
|
226
|
-
className: cls
|
|
271
|
+
className: cls,
|
|
272
|
+
style: Object.assign(Object.assign({}, style), styles === null || styles === void 0 ? void 0 : styles.root)
|
|
227
273
|
}, rest), extraHeader, /*#__PURE__*/React__default["default"].createElement(context["default"].Provider, {
|
|
228
274
|
value: {
|
|
229
275
|
placement: placement,
|
|
230
276
|
expandedType: expandedType,
|
|
231
277
|
showAllSubMenus: showAllSubMenus,
|
|
232
278
|
mini: mini,
|
|
279
|
+
showTitleOnMini: showTitleOnMini,
|
|
233
280
|
clickMenu: clickMenu,
|
|
234
281
|
clickSubMenu: clickSubMenu,
|
|
235
282
|
closePopper: closePopper,
|
|
@@ -237,10 +284,13 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
237
284
|
activeParents: activeParents,
|
|
238
285
|
activeId: activeId,
|
|
239
286
|
expandedIds: expandedIds,
|
|
240
|
-
overlayClassName: overlayClassName
|
|
287
|
+
overlayClassName: overlayClassName,
|
|
288
|
+
semanticClassNames: classNames,
|
|
289
|
+
semanticStyles: styles
|
|
241
290
|
}
|
|
242
291
|
}, /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
243
|
-
className: classname.cx(prefixCls + "__wrapper")
|
|
292
|
+
className: classname.cx(prefixCls + "__wrapper", classNames === null || classNames === void 0 ? void 0 : classNames.wrapper),
|
|
293
|
+
style: styles === null || styles === void 0 ? void 0 : styles.wrapper
|
|
244
294
|
}, mergedTagList.map(function (item, index) {
|
|
245
295
|
return showMini ? ( /*#__PURE__*/React__default["default"].createElement(Tooltip__default["default"], {
|
|
246
296
|
title: item.title,
|
|
@@ -263,10 +313,11 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
263
313
|
}), showVertical || restTagList.length === 0 ? null : ( /*#__PURE__*/React__default["default"].createElement(MenuItem.MenuItem, {
|
|
264
314
|
key: MENU_MORE_ID,
|
|
265
315
|
id: MENU_MORE_ID,
|
|
266
|
-
title:
|
|
316
|
+
title: i18n.tabs.more,
|
|
267
317
|
children: restTagList
|
|
268
318
|
}))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
269
|
-
className: prefixCls + "__footer"
|
|
319
|
+
className: classname.cx(prefixCls + "__footer", classNames === null || classNames === void 0 ? void 0 : classNames.footer),
|
|
320
|
+
style: styles === null || styles === void 0 ? void 0 : styles.footer
|
|
270
321
|
}, renderFooter())));
|
|
271
322
|
});
|
|
272
323
|
if (env.__DEV__) {
|