@hi-ui/menu 4.0.6 → 4.0.8

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 ADDED
@@ -0,0 +1,7 @@
1
+ # @hi-ui/menu
2
+
3
+ ## 4.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2383](https://github.com/XiaoMi/hiui/pull/2383) [`6248e798b`](https://github.com/XiaoMi/hiui/commit/6248e798b4ad7b9256637027f6bbe79245ed68de) Thanks [@zyprepare](https://github.com/zyprepare)! - 实现 expandedType="pop" 模式下,可以自定义弹出层样式类名
package/lib/cjs/Menu.js CHANGED
@@ -95,10 +95,11 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
95
95
  collapsed = _a.collapsed,
96
96
  _a$defaultCollapsed = _a.defaultCollapsed,
97
97
  defaultCollapsed = _a$defaultCollapsed === void 0 ? false : _a$defaultCollapsed,
98
+ overlayClassName = _a.overlayClassName,
98
99
  onCollapse = _a.onCollapse,
99
100
  footerRender = _a.footerRender,
100
101
  onClick = _a.onClick,
101
- rest = tslib.__rest(_a, ["prefixCls", "role", "className", "data", "placement", "showCollapse", "expandedType", "showAllSubMenus", "defaultExpandAll", "defaultExpandedIds", "expandedIds", "onExpand", "defaultActiveId", "activeId", "onClickSubMenu", "collapsed", "defaultCollapsed", "onCollapse", "footerRender", "onClick"]);
102
+ rest = tslib.__rest(_a, ["prefixCls", "role", "className", "data", "placement", "showCollapse", "expandedType", "showAllSubMenus", "defaultExpandAll", "defaultExpandedIds", "expandedIds", "onExpand", "defaultActiveId", "activeId", "onClickSubMenu", "collapsed", "defaultCollapsed", "overlayClassName", "onCollapse", "footerRender", "onClick"]);
102
103
 
103
104
  var _useUncontrolledState = useUncontrolledState.useUncontrolledState(defaultActiveId, activeIdProp, onClick),
104
105
  activeId = _useUncontrolledState[0],
@@ -259,7 +260,8 @@ var Menu = /*#__PURE__*/React.forwardRef(function (_a, ref) {
259
260
  closeAllPopper: closeAllPopper,
260
261
  activeParents: activeParents,
261
262
  activeId: activeId,
262
- expandedIds: expandedIds
263
+ expandedIds: expandedIds,
264
+ overlayClassName: overlayClassName
263
265
  }
264
266
  }, /*#__PURE__*/React__default["default"].createElement("ul", {
265
267
  className: classname.cx(prefixCls + "__wrapper")
@@ -87,7 +87,8 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
87
87
  clickMenu = _useContext.clickMenu,
88
88
  clickSubMenu = _useContext.clickSubMenu,
89
89
  closeAllPopper = _useContext.closeAllPopper,
90
- activeParents = _useContext.activeParents;
90
+ activeParents = _useContext.activeParents,
91
+ overlayClassName = _useContext.overlayClassName;
91
92
 
92
93
  var _parentIds = (parentIds || []).concat(id);
93
94
 
@@ -160,6 +161,7 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
160
161
  attachEl: itemRef.current,
161
162
  placement: 'right-start',
162
163
  gutterGap: 16,
164
+ className: overlayClassName,
163
165
  onClose: function onClose() {
164
166
  if (closePopper) {
165
167
  closePopper(id);
@@ -171,7 +173,8 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
171
173
  return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
172
174
  key: child.id,
173
175
  level: level + 1,
174
- parentIds: _parentIds
176
+ parentIds: _parentIds,
177
+ raw: child
175
178
  }));
176
179
  }))) : /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
177
180
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
@@ -179,6 +182,7 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
179
182
  placement: 'right-start',
180
183
  gutterGap: 16,
181
184
  disabledPortal: true,
185
+ className: overlayClassName,
182
186
  onClose: function onClose() {
183
187
  if (closePopper) {
184
188
  closePopper(id);
@@ -190,13 +194,15 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
190
194
  return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
191
195
  key: child.id,
192
196
  level: level + 1,
193
- parentIds: _parentIds
197
+ parentIds: _parentIds,
198
+ raw: child
194
199
  }));
195
200
  })))), hasChildren && placement === 'vertical' && !showAllSubMenus && expandedType === 'pop' && (level === 1 ? /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
196
201
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
197
202
  attachEl: itemRef.current,
198
203
  placement: 'right-start',
199
204
  gutterGap: 16,
205
+ className: overlayClassName,
200
206
  onClose: function onClose() {
201
207
  if (closePopper) {
202
208
  closePopper(id);
@@ -208,7 +214,8 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
208
214
  return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
209
215
  key: child.id,
210
216
  level: level + 1,
211
- parentIds: _parentIds
217
+ parentIds: _parentIds,
218
+ raw: child
212
219
  }));
213
220
  }))) : /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
214
221
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
@@ -216,6 +223,7 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
216
223
  disabledPortal: true,
217
224
  placement: 'right-start',
218
225
  gutterGap: 16,
226
+ className: overlayClassName,
219
227
  onClose: function onClose() {
220
228
  if (closePopper) {
221
229
  closePopper(id);
@@ -227,13 +235,15 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
227
235
  return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
228
236
  key: child.id,
229
237
  level: level + 1,
230
- parentIds: _parentIds
238
+ parentIds: _parentIds,
239
+ raw: child
231
240
  }));
232
241
  })))), hasChildren && placement === 'vertical' && showAllSubMenus ? /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
233
242
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
234
243
  attachEl: itemRef.current,
235
244
  placement: 'right-start',
236
245
  gutterGap: 16,
246
+ className: overlayClassName,
237
247
  onClose: function onClose() {
238
248
  if (closePopper) {
239
249
  closePopper(id);
@@ -269,6 +279,7 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
269
279
  attachEl: itemRef.current,
270
280
  placement: level === 1 ? 'bottom-start' : 'right-start',
271
281
  gutterGap: level === 1 ? 8 : 16,
282
+ className: overlayClassName,
272
283
  onClose: function onClose() {
273
284
  if (closePopper) {
274
285
  closePopper(id);
@@ -280,7 +291,8 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
280
291
  return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
281
292
  key: child.id,
282
293
  level: level + 1,
283
- parentIds: _parentIds
294
+ parentIds: _parentIds,
295
+ raw: child
284
296
  }));
285
297
  }))) : /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
286
298
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
@@ -288,6 +300,7 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
288
300
  disabledPortal: true,
289
301
  placement: level === 1 ? 'bottom-start' : 'right-start',
290
302
  gutterGap: level === 1 ? 8 : 16,
303
+ className: overlayClassName,
291
304
  onClose: function onClose() {
292
305
  if (closePopper) {
293
306
  closePopper(id);
@@ -299,13 +312,15 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
299
312
  return /*#__PURE__*/React__default["default"].createElement(MenuItem, Object.assign({}, child, {
300
313
  key: child.id,
301
314
  level: level + 1,
302
- parentIds: _parentIds
315
+ parentIds: _parentIds,
316
+ raw: child
303
317
  }));
304
318
  })))), hasChildren && placement === 'horizontal' && showAllSubMenus ? /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], {
305
319
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
306
320
  attachEl: itemRef.current,
307
321
  placement: 'bottom-start',
308
322
  gutterGap: 8,
323
+ className: overlayClassName,
309
324
  onClose: function onClose() {
310
325
  if (closePopper) {
311
326
  closePopper(id);
package/lib/esm/Menu.js CHANGED
@@ -61,10 +61,11 @@ var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
61
61
  collapsed = _a.collapsed,
62
62
  _a$defaultCollapsed = _a.defaultCollapsed,
63
63
  defaultCollapsed = _a$defaultCollapsed === void 0 ? false : _a$defaultCollapsed,
64
+ overlayClassName = _a.overlayClassName,
64
65
  onCollapse = _a.onCollapse,
65
66
  footerRender = _a.footerRender,
66
67
  onClick = _a.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"]);
68
+ rest = __rest(_a, ["prefixCls", "role", "className", "data", "placement", "showCollapse", "expandedType", "showAllSubMenus", "defaultExpandAll", "defaultExpandedIds", "expandedIds", "onExpand", "defaultActiveId", "activeId", "onClickSubMenu", "collapsed", "defaultCollapsed", "overlayClassName", "onCollapse", "footerRender", "onClick"]);
68
69
 
69
70
  var _useUncontrolledState = useUncontrolledState(defaultActiveId, activeIdProp, onClick),
70
71
  activeId = _useUncontrolledState[0],
@@ -225,7 +226,8 @@ var Menu = /*#__PURE__*/forwardRef(function (_a, ref) {
225
226
  closeAllPopper: closeAllPopper,
226
227
  activeParents: activeParents,
227
228
  activeId: activeId,
228
- expandedIds: expandedIds
229
+ expandedIds: expandedIds,
230
+ overlayClassName: overlayClassName
229
231
  }
230
232
  }, /*#__PURE__*/React.createElement("ul", {
231
233
  className: cx(prefixCls + "__wrapper")
@@ -58,7 +58,8 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
58
58
  clickMenu = _useContext.clickMenu,
59
59
  clickSubMenu = _useContext.clickSubMenu,
60
60
  closeAllPopper = _useContext.closeAllPopper,
61
- activeParents = _useContext.activeParents;
61
+ activeParents = _useContext.activeParents,
62
+ overlayClassName = _useContext.overlayClassName;
62
63
 
63
64
  var _parentIds = (parentIds || []).concat(id);
64
65
 
@@ -131,6 +132,7 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
131
132
  attachEl: itemRef.current,
132
133
  placement: 'right-start',
133
134
  gutterGap: 16,
135
+ className: overlayClassName,
134
136
  onClose: function onClose() {
135
137
  if (closePopper) {
136
138
  closePopper(id);
@@ -142,7 +144,8 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
142
144
  return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
143
145
  key: child.id,
144
146
  level: level + 1,
145
- parentIds: _parentIds
147
+ parentIds: _parentIds,
148
+ raw: child
146
149
  }));
147
150
  }))) : /*#__PURE__*/React.createElement(Popper, {
148
151
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
@@ -150,6 +153,7 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
150
153
  placement: 'right-start',
151
154
  gutterGap: 16,
152
155
  disabledPortal: true,
156
+ className: overlayClassName,
153
157
  onClose: function onClose() {
154
158
  if (closePopper) {
155
159
  closePopper(id);
@@ -161,13 +165,15 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
161
165
  return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
162
166
  key: child.id,
163
167
  level: level + 1,
164
- parentIds: _parentIds
168
+ parentIds: _parentIds,
169
+ raw: child
165
170
  }));
166
171
  })))), hasChildren && placement === 'vertical' && !showAllSubMenus && expandedType === 'pop' && (level === 1 ? /*#__PURE__*/React.createElement(Popper, {
167
172
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
168
173
  attachEl: itemRef.current,
169
174
  placement: 'right-start',
170
175
  gutterGap: 16,
176
+ className: overlayClassName,
171
177
  onClose: function onClose() {
172
178
  if (closePopper) {
173
179
  closePopper(id);
@@ -179,7 +185,8 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
179
185
  return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
180
186
  key: child.id,
181
187
  level: level + 1,
182
- parentIds: _parentIds
188
+ parentIds: _parentIds,
189
+ raw: child
183
190
  }));
184
191
  }))) : /*#__PURE__*/React.createElement(Popper, {
185
192
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
@@ -187,6 +194,7 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
187
194
  disabledPortal: true,
188
195
  placement: 'right-start',
189
196
  gutterGap: 16,
197
+ className: overlayClassName,
190
198
  onClose: function onClose() {
191
199
  if (closePopper) {
192
200
  closePopper(id);
@@ -198,13 +206,15 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
198
206
  return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
199
207
  key: child.id,
200
208
  level: level + 1,
201
- parentIds: _parentIds
209
+ parentIds: _parentIds,
210
+ raw: child
202
211
  }));
203
212
  })))), hasChildren && placement === 'vertical' && showAllSubMenus ? /*#__PURE__*/React.createElement(Popper, {
204
213
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
205
214
  attachEl: itemRef.current,
206
215
  placement: 'right-start',
207
216
  gutterGap: 16,
217
+ className: overlayClassName,
208
218
  onClose: function onClose() {
209
219
  if (closePopper) {
210
220
  closePopper(id);
@@ -240,6 +250,7 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
240
250
  attachEl: itemRef.current,
241
251
  placement: level === 1 ? 'bottom-start' : 'right-start',
242
252
  gutterGap: level === 1 ? 8 : 16,
253
+ className: overlayClassName,
243
254
  onClose: function onClose() {
244
255
  if (closePopper) {
245
256
  closePopper(id);
@@ -251,7 +262,8 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
251
262
  return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
252
263
  key: child.id,
253
264
  level: level + 1,
254
- parentIds: _parentIds
265
+ parentIds: _parentIds,
266
+ raw: child
255
267
  }));
256
268
  }))) : /*#__PURE__*/React.createElement(Popper, {
257
269
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
@@ -259,6 +271,7 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
259
271
  disabledPortal: true,
260
272
  placement: level === 1 ? 'bottom-start' : 'right-start',
261
273
  gutterGap: level === 1 ? 8 : 16,
274
+ className: overlayClassName,
262
275
  onClose: function onClose() {
263
276
  if (closePopper) {
264
277
  closePopper(id);
@@ -270,13 +283,15 @@ var MenuItem = /*#__PURE__*/forwardRef(function (_a, ref) {
270
283
  return /*#__PURE__*/React.createElement(MenuItem, Object.assign({}, child, {
271
284
  key: child.id,
272
285
  level: level + 1,
273
- parentIds: _parentIds
286
+ parentIds: _parentIds,
287
+ raw: child
274
288
  }));
275
289
  })))), hasChildren && placement === 'horizontal' && showAllSubMenus ? /*#__PURE__*/React.createElement(Popper, {
276
290
  visible: !!(expandedIds === null || expandedIds === void 0 ? void 0 : expandedIds.includes(id)),
277
291
  attachEl: itemRef.current,
278
292
  placement: 'bottom-start',
279
293
  gutterGap: 8,
294
+ className: overlayClassName,
280
295
  onClose: function onClose() {
281
296
  if (closePopper) {
282
297
  closePopper(id);
@@ -8,6 +8,7 @@ declare const MenuContext: React.Context<{
8
8
  expandedIds?: React.ReactText[] | undefined;
9
9
  activeId?: React.ReactText | undefined;
10
10
  activeParents?: React.ReactText[] | undefined;
11
+ overlayClassName?: string | undefined;
11
12
  clickMenu?: ((id: React.ReactText, raw: MenuDataItem) => void) | undefined;
12
13
  clickSubMenu?: ((id: React.ReactText) => void) | undefined;
13
14
  closePopper?: ((id: React.ReactText) => void) | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/menu",
3
- "version": "4.0.6",
3
+ "version": "4.0.8",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -70,6 +70,5 @@
70
70
  "@hi-ui/hi-build": "^4.0.1",
71
71
  "react": "^17.0.1",
72
72
  "react-dom": "^17.0.1"
73
- },
74
- "gitHead": "785078746d82c4082b1cf884f8e235166648ef98"
73
+ }
75
74
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Xiaomi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.