@lemon-fe/components 0.0.2 → 0.0.3

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.
@@ -70,7 +70,7 @@ export default function Menu(props) {
70
70
  var activeMenu = useMemo(function () {
71
71
  var check = function check(path) {
72
72
  if (path) {
73
- return new RegExp("".concat(path, "\\b")).test(location.pathname);
73
+ return new RegExp("".concat(path, "(?![^\\/])")).test(location.pathname);
74
74
  }
75
75
 
76
76
  return false;
@@ -123,6 +123,8 @@ export default function Menu(props) {
123
123
  popup.current.classList.add('animated');
124
124
  }
125
125
  }, 16);
126
+ } else {
127
+ setPopover(null);
126
128
  }
127
129
  };
128
130
 
@@ -218,49 +220,61 @@ export default function Menu(props) {
218
220
 
219
221
  var renderDrawerItems = function renderDrawerItems() {
220
222
  var cols = [[], [], []];
221
- menus.forEach(function (item, index) {
222
- cols[index % 3].push(item);
223
- });
224
- return cols.map(function (items) {
225
- return /*#__PURE__*/React.createElement("div", {
226
- className: "".concat(prefixCls, "-menu-drawer-col")
227
- }, items.map(function (item) {
228
- var list = [/*#__PURE__*/React.createElement("div", {
229
- className: "".concat(prefixCls, "-menu-drawer-1"),
230
- key: item.name,
231
- onClick: function onClick() {
232
- return handleClick(item);
233
- }
234
- }, item.name)];
235
-
236
- if (item.children) {
237
- item.children.forEach(function (subItem) {
238
- list.push( /*#__PURE__*/React.createElement("div", {
239
- className: "".concat(prefixCls, "-menu-drawer-2"),
240
- key: subItem.name,
241
- onClick: function onClick() {
242
- return handleClick(subItem);
243
- }
244
- }, subItem.name));
245
-
246
- if (subItem.children) {
247
- subItem.children.forEach(function (child) {
248
- list.push( /*#__PURE__*/React.createElement("div", {
249
- className: classNames("".concat(prefixCls, "-menu-drawer-3"), _defineProperty({}, "".concat(prefixCls, "-menu-active"), activeMenu !== undefined && activeMenu.key === child.path)),
250
- key: child.name,
251
- onClick: function onClick() {
252
- return handleClick(child);
253
- }
254
- }, child.name));
255
- });
223
+ var value = [0, 0, 0];
224
+ menus.forEach(function (item) {
225
+ var list = [/*#__PURE__*/React.createElement("div", {
226
+ className: classNames("".concat(prefixCls, "-menu-drawer-1"), _defineProperty({}, "".concat(prefixCls, "-menu-drawer-1-path"), item.path !== undefined)),
227
+ key: item.name,
228
+ onClick: function onClick() {
229
+ return handleClick(item);
230
+ }
231
+ }, item.name)];
232
+
233
+ if (item.children) {
234
+ item.children.forEach(function (subItem) {
235
+ list.push( /*#__PURE__*/React.createElement("div", {
236
+ className: "".concat(prefixCls, "-menu-drawer-2"),
237
+ key: "2-".concat(subItem.name),
238
+ onClick: function onClick() {
239
+ return handleClick(subItem);
256
240
  }
257
- });
241
+ }, subItem.name));
242
+
243
+ if (subItem.children) {
244
+ subItem.children.forEach(function (child) {
245
+ list.push( /*#__PURE__*/React.createElement("div", {
246
+ className: classNames("".concat(prefixCls, "-menu-drawer-3"), _defineProperty({}, "".concat(prefixCls, "-menu-active"), activeMenu !== undefined && activeMenu.key === child.path)),
247
+ key: "3-".concat(child.name),
248
+ onClick: function onClick() {
249
+ return handleClick(child);
250
+ }
251
+ }, child.name));
252
+ });
253
+ }
254
+ });
255
+ }
256
+
257
+ var node = /*#__PURE__*/React.createElement("div", {
258
+ className: "".concat(prefixCls, "-menu-drawer-block")
259
+ }, /*#__PURE__*/React.createElement("div", null, list));
260
+ var target = 0;
261
+ var min = Infinity;
262
+
263
+ for (var i = 0; i < value.length; i++) {
264
+ if (value[i] < min) {
265
+ target = i;
266
+ min = value[i];
258
267
  }
268
+ }
259
269
 
260
- return /*#__PURE__*/React.createElement("div", {
261
- className: "".concat(prefixCls, "-menu-drawer-block")
262
- }, /*#__PURE__*/React.createElement("div", null, list));
263
- }));
270
+ value[target] += list.length;
271
+ cols[target].push(node);
272
+ });
273
+ return cols.map(function (items, index) {
274
+ return /*#__PURE__*/React.createElement("div", {
275
+ className: "".concat(prefixCls, "-menu-drawer-col"),
276
+ key: index
277
+ }, items);
264
278
  });
265
279
  };
266
280
 
@@ -316,11 +330,11 @@ export default function Menu(props) {
316
330
  strokeDasharray: "0,0",
317
331
  transform: "translate(-274.000000, -57.000000) translate(284.000000, 67.000000) scale(-1, 1) translate(-284.000000, -67.000000) translate(274.000000, 57.000000) translate(8.535522, 10.000000) rotate(-45.000000) translate(-8.535522, -10.000000)"
318
332
  })))))), menus.map(function (item, index) {
319
- var _classNames4;
333
+ var _classNames5;
320
334
 
321
335
  return /*#__PURE__*/React.createElement("div", {
322
336
  key: index,
323
- className: classNames("".concat(prefixCls, "-menu-top-item"), (_classNames4 = {}, _defineProperty(_classNames4, "".concat(prefixCls, "-menu-top-item-active"), activeMenu !== undefined && activeMenu.path[0] === index), _defineProperty(_classNames4, "".concat(prefixCls, "-menu-top-item-popover-active"), item === popover), _classNames4)),
337
+ className: classNames("".concat(prefixCls, "-menu-top-item"), (_classNames5 = {}, _defineProperty(_classNames5, "".concat(prefixCls, "-menu-top-item-active"), activeMenu !== undefined && activeMenu.path[0] === index), _defineProperty(_classNames5, "".concat(prefixCls, "-menu-top-item-popover-active"), item === popover), _classNames5)),
324
338
  onClick: function onClick() {
325
339
  return handleClick(item);
326
340
  },
@@ -333,7 +347,7 @@ export default function Menu(props) {
333
347
  }), /*#__PURE__*/React.createElement("div", {
334
348
  className: "".concat(prefixCls, "-menu-title")
335
349
  }, item.name));
336
- }), /*#__PURE__*/React.createElement("div", {
350
+ })), false && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
337
351
  className: "".concat(prefixCls, "-menu-gutter")
338
352
  }), collapsed ? /*#__PURE__*/React.createElement("div", {
339
353
  className: "".concat(prefixCls, "-menu-top-item"),
@@ -6,6 +6,8 @@
6
6
  flex: 0 0 200px;
7
7
  min-width: 0;
8
8
  height: 100%;
9
+ padding: 16px 0;
10
+ white-space: nowrap;
9
11
  transition: flex 0.1s;
10
12
 
11
13
  &-collapsed {
@@ -17,8 +19,6 @@
17
19
  z-index: 3;
18
20
  box-sizing: border-box;
19
21
  width: 100%;
20
- padding: 16px 0;
21
- white-space: nowrap;
22
22
  background: #f2f2f2;
23
23
  }
24
24
 
@@ -278,14 +278,16 @@
278
278
  }
279
279
 
280
280
  &-body {
281
- display: flex;
281
+ height: calc(100vh - 56px);
282
282
  padding: 16px;
283
283
  overflow-x: hidden;
284
284
  overflow-y: auto;
285
285
  }
286
286
 
287
287
  &-col {
288
+ display: inline-block;
288
289
  width: 33.33333333%;
290
+ vertical-align: top;
289
291
  }
290
292
 
291
293
  .item() {
@@ -299,6 +301,16 @@
299
301
  color: rgba(51, 51, 51, 1);
300
302
  font-weight: 500;
301
303
  .item();
304
+
305
+ &-path {
306
+ cursor: pointer;
307
+ .transition();
308
+
309
+ &:hover {
310
+ color: rgba(5, 96, 253, 1);
311
+ background-color: rgba(238, 238, 238, 1);
312
+ }
313
+ }
302
314
  }
303
315
 
304
316
  &-2 {
@@ -323,6 +335,7 @@
323
335
  padding: 8px;
324
336
 
325
337
  & > div {
338
+ overflow: hidden;
326
339
  background-color: rgba(238, 238, 238, 0.5);
327
340
  border-radius: 8px;
328
341
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -13,7 +13,7 @@
13
13
  "test": "echo \"Error: run tests from root\" && exit 1"
14
14
  },
15
15
  "dependencies": {
16
- "@lemon-fe/hooks": "^0.0.2",
16
+ "@lemon-fe/hooks": "^0.0.3",
17
17
  "antd": "^4.17.0",
18
18
  "classnames": "^2.2.6",
19
19
  "lodash": "^4.17.21",
@@ -36,5 +36,5 @@
36
36
  "@types/lodash": "^4.14.179",
37
37
  "@types/react-resizable": "^1.7.4"
38
38
  },
39
- "gitHead": "fb99301b92d7fce50677a82ba546bf4309b33413"
39
+ "gitHead": "4793be25184347a233655cd67038427b79767c46"
40
40
  }