@lemon-fe/components 0.0.2 → 0.0.6

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;
@@ -115,7 +115,7 @@ export default function Menu(props) {
115
115
  }, [location.pathname, menus]);
116
116
 
117
117
  var openMenu = function openMenu(item, elm) {
118
- if (item.children && item.children.length > 0) {
118
+ if (item.children !== undefined && item.children.length > 0 || collapsed) {
119
119
  setPopover(item);
120
120
  setTop(elm.offsetTop);
121
121
  setTimeout(function () {
@@ -123,20 +123,12 @@ 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
 
129
- var handleMouseEnter = useDebounce(openMenu, 200);
130
-
131
- var toggleMenu = function toggleMenu() {
132
- setCollapsed(function (prev) {
133
- return !prev;
134
- });
135
- };
136
-
137
131
  var closeMenu = function closeMenu() {
138
- handleMouseEnter.cancel();
139
-
140
132
  if (popup.current) {
141
133
  popup.current.classList.remove('animated');
142
134
 
@@ -151,6 +143,18 @@ export default function Menu(props) {
151
143
  }
152
144
  };
153
145
 
146
+ var toggle = useDebounce(function (handler) {
147
+ if (handler) {
148
+ handler();
149
+ }
150
+ }, 200);
151
+
152
+ var toggleCollapse = function toggleCollapse() {
153
+ setCollapsed(function (prev) {
154
+ return !prev;
155
+ });
156
+ };
157
+
154
158
  useEffect(function () {
155
159
  if (!visible) {
156
160
  return;
@@ -218,49 +222,61 @@ export default function Menu(props) {
218
222
 
219
223
  var renderDrawerItems = function renderDrawerItems() {
220
224
  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
- });
225
+ var value = [0, 0, 0];
226
+ menus.forEach(function (item) {
227
+ var list = [/*#__PURE__*/React.createElement("div", {
228
+ className: classNames("".concat(prefixCls, "-menu-drawer-1"), _defineProperty({}, "".concat(prefixCls, "-menu-drawer-1-path"), item.path !== undefined)),
229
+ key: item.name,
230
+ onClick: function onClick() {
231
+ return handleClick(item);
232
+ }
233
+ }, item.name)];
234
+
235
+ if (item.children) {
236
+ item.children.forEach(function (subItem) {
237
+ list.push( /*#__PURE__*/React.createElement("div", {
238
+ className: "".concat(prefixCls, "-menu-drawer-2"),
239
+ key: "2-".concat(subItem.name),
240
+ onClick: function onClick() {
241
+ return handleClick(subItem);
256
242
  }
257
- });
243
+ }, subItem.name));
244
+
245
+ if (subItem.children) {
246
+ subItem.children.forEach(function (child) {
247
+ list.push( /*#__PURE__*/React.createElement("div", {
248
+ className: classNames("".concat(prefixCls, "-menu-drawer-3"), _defineProperty({}, "".concat(prefixCls, "-menu-active"), activeMenu !== undefined && activeMenu.key === child.path)),
249
+ key: "3-".concat(child.name),
250
+ onClick: function onClick() {
251
+ return handleClick(child);
252
+ }
253
+ }, child.name));
254
+ });
255
+ }
256
+ });
257
+ }
258
+
259
+ var node = /*#__PURE__*/React.createElement("div", {
260
+ className: "".concat(prefixCls, "-menu-drawer-block")
261
+ }, /*#__PURE__*/React.createElement("div", null, list));
262
+ var target = 0;
263
+ var min = Infinity;
264
+
265
+ for (var i = 0; i < value.length; i++) {
266
+ if (value[i] < min) {
267
+ target = i;
268
+ min = value[i];
258
269
  }
270
+ }
259
271
 
260
- return /*#__PURE__*/React.createElement("div", {
261
- className: "".concat(prefixCls, "-menu-drawer-block")
262
- }, /*#__PURE__*/React.createElement("div", null, list));
263
- }));
272
+ value[target] += list.length;
273
+ cols[target].push(node);
274
+ });
275
+ return cols.map(function (items, index) {
276
+ return /*#__PURE__*/React.createElement("div", {
277
+ className: "".concat(prefixCls, "-menu-drawer-col"),
278
+ key: index
279
+ }, items);
264
280
  });
265
281
  };
266
282
 
@@ -268,18 +284,21 @@ export default function Menu(props) {
268
284
  className: classNames("".concat(prefixCls, "-menu"), _defineProperty({}, "".concat(prefixCls, "-menu-collapsed"), collapsed))
269
285
  }, /*#__PURE__*/React.createElement("div", {
270
286
  className: "".concat(prefixCls, "-menu-bar"),
271
- onMouseLeave: closeMenu
272
- }, popover !== null && popover.children !== undefined && /*#__PURE__*/React.createElement("div", {
287
+ onMouseLeave: function onMouseLeave() {
288
+ return toggle(closeMenu);
289
+ }
290
+ }, popover !== null && /*#__PURE__*/React.createElement("div", {
273
291
  className: "".concat(prefixCls, "-menu-popup"),
274
292
  style: {
275
293
  top: top
276
294
  },
277
295
  ref: popup,
278
296
  onMouseEnter: function onMouseEnter() {
279
- return handleMouseEnter.cancel();
297
+ return toggle.cancel();
280
298
  }
281
- }, /*#__PURE__*/React.createElement("div", {
282
- className: "".concat(prefixCls, "-menu-popup-body")
299
+ }, popover.children !== undefined ? /*#__PURE__*/React.createElement("div", {
300
+ className: "".concat(prefixCls, "-menu-popup-body"),
301
+ key: "pop"
283
302
  }, popover.children.map(function (item, index) {
284
303
  return /*#__PURE__*/React.createElement("div", {
285
304
  className: "".concat(prefixCls, "-menu-block"),
@@ -287,9 +306,15 @@ export default function Menu(props) {
287
306
  }, /*#__PURE__*/React.createElement("div", {
288
307
  className: "".concat(prefixCls, "-menu-sub-item")
289
308
  }, item.name), item.children !== undefined && item.children.map(renderItem));
290
- }))), /*#__PURE__*/React.createElement("div", {
309
+ })) : /*#__PURE__*/React.createElement("div", {
310
+ className: "".concat(prefixCls, "-menu-popup-tip"),
311
+ key: "tip"
312
+ }, popover.name)), /*#__PURE__*/React.createElement("div", {
291
313
  className: "".concat(prefixCls, "-menu-collapse"),
292
- onClick: toggleMenu
314
+ onClick: toggleCollapse,
315
+ onMouseEnter: function onMouseEnter() {
316
+ return toggle(closeMenu);
317
+ }
293
318
  }, /*#__PURE__*/React.createElement("svg", {
294
319
  width: "20",
295
320
  height: "20",
@@ -316,24 +341,29 @@ export default function Menu(props) {
316
341
  strokeDasharray: "0,0",
317
342
  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
343
  })))))), menus.map(function (item, index) {
319
- var _classNames4;
344
+ var _classNames5;
320
345
 
321
346
  return /*#__PURE__*/React.createElement("div", {
322
347
  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)),
348
+ 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
349
  onClick: function onClick() {
325
350
  return handleClick(item);
326
351
  },
327
352
  onMouseEnter: function onMouseEnter(e) {
328
- return handleMouseEnter(item, e.currentTarget);
353
+ var target = e.currentTarget;
354
+ toggle(function () {
355
+ return openMenu(item, target);
356
+ });
329
357
  }
330
- }, /*#__PURE__*/React.createElement("img", {
358
+ }, typeof item.icon === 'string' ? /*#__PURE__*/React.createElement("img", {
331
359
  className: "".concat(prefixCls, "-menu-icon"),
332
360
  src: item.icon
333
- }), /*#__PURE__*/React.createElement("div", {
361
+ }) : /*#__PURE__*/React.createElement("div", {
362
+ className: "".concat(prefixCls, "-menu-icon")
363
+ }, item.icon), /*#__PURE__*/React.createElement("div", {
334
364
  className: "".concat(prefixCls, "-menu-title")
335
365
  }, item.name));
336
- }), /*#__PURE__*/React.createElement("div", {
366
+ })), false && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
337
367
  className: "".concat(prefixCls, "-menu-gutter")
338
368
  }), collapsed ? /*#__PURE__*/React.createElement("div", {
339
369
  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: 8px 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
 
@@ -94,12 +94,8 @@
94
94
  width: 20px;
95
95
  height: 20px;
96
96
  margin-right: 8px;
97
+ color: rgba(108, 108, 108, 1);
97
98
  font-size: 16px;
98
- opacity: 0.7;
99
- }
100
-
101
- &-top-item-active &-icon {
102
- opacity: 1;
103
99
  }
104
100
 
105
101
  &-title {
@@ -108,6 +104,15 @@
108
104
  text-overflow: ellipsis;
109
105
  }
110
106
 
107
+ &-top-item:hover &-icon {
108
+ color: #333;
109
+ }
110
+
111
+ &-top-item&-top-item-active &-title,
112
+ &-top-item&-top-item-active &-icon {
113
+ color: .primary() [];
114
+ }
115
+
111
116
  &-popup {
112
117
  position: absolute;
113
118
  top: 0;
@@ -125,12 +130,27 @@
125
130
  border-radius: 10px;
126
131
  box-shadow: 0 12px 48px 16px rgba(0, 0, 0, 0.03), 0 9px 28px 0 rgba(0, 0, 0, 0.05),
127
132
  0 6px 16px -8px rgba(0, 0, 0, 0.08);
128
- transform: translate3d(-40px, 0, 0);
133
+ transform: translate3d(-20px, 0, 0);
129
134
  opacity: 0;
130
- transition: all 0.2s;
135
+ transition: all 0.15s;
131
136
  }
132
137
 
133
- &.animated &-body {
138
+ &-tip {
139
+ height: 36px;
140
+ margin: 4px 0 0 4px;
141
+ padding: 0 16px;
142
+ color: #fff;
143
+ line-height: 36px;
144
+ text-align: center;
145
+ background-color: .primary() [];
146
+ border-radius: 22px;
147
+ transform: translate3d(-10px, 0, 0);
148
+ opacity: 0;
149
+ transition: all 0.15s;
150
+ }
151
+
152
+ &.animated &-body,
153
+ &.animated &-tip {
134
154
  transform: translate3d(0, 0, 0);
135
155
  opacity: 1;
136
156
  }
@@ -161,6 +181,7 @@
161
181
  height: 40px;
162
182
  padding: 0 16px;
163
183
  color: rgba(51, 51, 51, 0.5);
184
+ font-weight: 500;
164
185
  font-size: 14px;
165
186
  line-height: 40px;
166
187
  }
@@ -227,11 +248,11 @@
227
248
  width: 107px;
228
249
  height: 36px;
229
250
  margin-left: 12px;
230
- color: rgba(5, 96, 253, 1);
251
+ color: .primary() [];
231
252
  font-size: 14px;
232
253
  text-align: center;
233
254
  background-color: #fff;
234
- border: 1px solid rgba(5, 96, 253, 1);
255
+ border: 1px solid .primary() [];
235
256
  border-radius: 4px;
236
257
  cursor: pointer;
237
258
  user-select: none;
@@ -255,7 +276,7 @@
255
276
  height: 100vh;
256
277
  background-color: #fff;
257
278
  box-shadow: 0 12px 48px 16px rgba(0, 0, 0, 0.03), 0 9px 28px 0 rgba(0, 0, 0, 0.05),
258
- 0px 6px 16px -8px rgba(0, 0, 0, 0.08);
279
+ 0 6px 16px -8px rgba(0, 0, 0, 0.08);
259
280
  transform: translate3d(60px, 0, 0);
260
281
  opacity: 0;
261
282
  transition: all 0.2s;
@@ -278,14 +299,16 @@
278
299
  }
279
300
 
280
301
  &-body {
281
- display: flex;
302
+ height: calc(100vh - 56px);
282
303
  padding: 16px;
283
304
  overflow-x: hidden;
284
305
  overflow-y: auto;
285
306
  }
286
307
 
287
308
  &-col {
309
+ display: inline-block;
288
310
  width: 33.33333333%;
311
+ vertical-align: top;
289
312
  }
290
313
 
291
314
  .item() {
@@ -299,6 +322,16 @@
299
322
  color: rgba(51, 51, 51, 1);
300
323
  font-weight: 500;
301
324
  .item();
325
+
326
+ &-path {
327
+ cursor: pointer;
328
+ .transition();
329
+
330
+ &:hover {
331
+ color: .primary() [];
332
+ background-color: rgba(238, 238, 238, 1);
333
+ }
334
+ }
302
335
  }
303
336
 
304
337
  &-2 {
@@ -314,7 +347,7 @@
314
347
  .transition();
315
348
 
316
349
  &:hover {
317
- color: rgba(5, 96, 253, 1);
350
+ color: .primary() [];
318
351
  background-color: rgba(238, 238, 238, 1);
319
352
  }
320
353
  }
@@ -323,6 +356,7 @@
323
356
  padding: 8px;
324
357
 
325
358
  & > div {
359
+ overflow: hidden;
326
360
  background-color: rgba(238, 238, 238, 0.5);
327
361
  border-radius: 8px;
328
362
  }
@@ -332,12 +366,12 @@
332
366
  cursor: pointer;
333
367
 
334
368
  &:hover {
335
- color: rgba(5, 96, 253, 1);
369
+ color: .primary() [];
336
370
  }
337
371
  }
338
372
  }
339
373
 
340
374
  &-active {
341
- color: rgba(5, 96, 253, 1);
375
+ color: .primary() [];
342
376
  }
343
377
  }
@@ -34,28 +34,22 @@ export default function TabBar(props) {
34
34
  return handleClose(e, index);
35
35
  }
36
36
  }, /*#__PURE__*/React.createElement("svg", {
37
- width: "10",
38
- height: "10",
39
- viewBox: "0 0 9 9",
37
+ width: "14",
38
+ height: "14",
40
39
  xmlns: "http://www.w3.org/2000/svg"
41
40
  }, /*#__PURE__*/React.createElement("g", {
42
- fill: "#000",
43
- fillRule: "evenodd",
44
- fillOpacity: ".25"
45
- }, /*#__PURE__*/React.createElement("rect", {
46
- transform: "rotate(45 4.559 4.559)",
47
- x: "3.976",
48
- y: ".059",
49
- width: "1",
50
- height: "9",
51
- rx: ".5"
52
- }), /*#__PURE__*/React.createElement("rect", {
53
- transform: "rotate(-45 4.559 4.441)",
54
- x: "3.976",
55
- y: "-.059",
56
- width: "1",
57
- height: "9",
58
- rx: ".5"
59
- }))))));
41
+ fill: "none",
42
+ fillRule: "evenodd"
43
+ }, /*#__PURE__*/React.createElement("g", {
44
+ fill: "currentColor"
45
+ }, /*#__PURE__*/React.createElement("g", {
46
+ fillRule: "nonzero"
47
+ }, /*#__PURE__*/React.createElement("path", {
48
+ d: "M7.74992318,2.75006802 L7.74992318,11.250068 C7.74992318,11.6642816 7.41413675,12.000068 6.99992318,12.000068 C6.58570962,12.000068 6.24992318,11.6642816 6.24992318,11.250068 L6.24992318,2.75006802 C6.24992318,2.33585446 6.58570962,2.00006802 6.99992318,2.00006802 C7.41413675,2.00006802 7.74992318,2.33585446 7.74992318,2.75006802 Z",
49
+ transform: "translate(-367.000000, -21.000000) translate(367.000000, 21.000000) translate(6.999923, 7.000068) rotate(45.000000) translate(-6.999923, -7.000068)"
50
+ }), /*#__PURE__*/React.createElement("path", {
51
+ d: "M7.74994595,2.75007682 L7.74994595,11.2500768 C7.74994595,11.6642904 7.41415952,12.0000768 6.99994595,12.0000768 C6.58573239,12.0000768 6.24994595,11.6642904 6.24994595,11.2500768 L6.24994595,2.75007682 C6.24994595,2.33586325 6.58573239,2.00007682 6.99994595,2.00007682 C7.41415952,2.00007682 7.74994595,2.33586325 7.74994595,2.75007682 Z",
52
+ transform: "translate(-367.000000, -21.000000) translate(367.000000, 21.000000) translate(6.999946, 7.000077) rotate(-45.000000) translate(-6.999946, -7.000077)"
53
+ }))))))));
60
54
  }));
61
55
  }
@@ -38,7 +38,7 @@
38
38
  box-sizing: content-box;
39
39
  min-width: 14px;
40
40
  max-width: 120px;
41
- height: 49px;
41
+ height: 43px;
42
42
  cursor: pointer;
43
43
 
44
44
  &::before {
@@ -72,7 +72,7 @@
72
72
  z-index: 4;
73
73
  display: flex;
74
74
  align-items: center;
75
- padding: 10px 10px 17px;
75
+ padding: 7px 12px 14px;
76
76
  background-color: #fff;
77
77
  border-radius: 10px;
78
78
  transition: background-color 0.2s;
@@ -128,12 +128,14 @@
128
128
  &-close {
129
129
  width: 14px;
130
130
  height: 14px;
131
+ color: #c4c4c4;
131
132
  line-height: 14px;
132
133
  text-align: center;
133
134
  border-radius: 50%;
134
135
 
135
136
  &:hover {
136
- background-color: rgba(0, 0, 0, 0.15);
137
+ color: #f2f2f2;
138
+ background-color: #c1c1c1;
137
139
  }
138
140
  }
139
141
  }
@@ -17,7 +17,7 @@
17
17
  align-items: center;
18
18
  box-sizing: border-box;
19
19
  width: 100vw;
20
- height: 56px;
20
+ height: 50px;
21
21
  padding: 0 16px;
22
22
  background: #ffff;
23
23
 
@@ -1,6 +1,8 @@
1
+ import type { ReactElement } from 'react';
2
+
1
3
  export type MenuItem = {
2
4
  name: string;
3
5
  path?: string;
4
- icon?: string;
6
+ icon?: string | ReactElement;
5
7
  children?: MenuItem[];
6
8
  };
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.6",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -12,8 +12,11 @@
12
12
  "scripts": {
13
13
  "test": "echo \"Error: run tests from root\" && exit 1"
14
14
  },
15
+ "publishConfig": {
16
+ "registry": "https://registry.npmjs.org"
17
+ },
15
18
  "dependencies": {
16
- "@lemon-fe/hooks": "^0.0.2",
19
+ "@lemon-fe/hooks": "^0.0.6",
17
20
  "antd": "^4.17.0",
18
21
  "classnames": "^2.2.6",
19
22
  "lodash": "^4.17.21",
@@ -36,5 +39,5 @@
36
39
  "@types/lodash": "^4.14.179",
37
40
  "@types/react-resizable": "^1.7.4"
38
41
  },
39
- "gitHead": "fb99301b92d7fce50677a82ba546bf4309b33413"
42
+ "gitHead": "031652790452c9baca3ea69f2fc1982c6a8c7a18"
40
43
  }