@lemon-fe/components 0.0.20 → 0.0.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.
@@ -1,6 +1,8 @@
1
- import type { MenuItem } from '../../typings';
1
+ import type { MenuFavorites, MenuItem } from '../../typings';
2
2
  interface Props {
3
3
  data: MenuItem[];
4
+ favorites?: MenuFavorites;
5
+ onFavoritesChange?: (items: MenuFavorites) => void;
4
6
  onClick: (item: MenuItem) => void;
5
7
  }
6
8
  export default function Menu(props: Props): JSX.Element;
@@ -1,4 +1,10 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
2
8
 
3
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
10
 
@@ -12,11 +18,47 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
12
18
 
13
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
20
 
21
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
+
23
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
+
25
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
26
+
15
27
  import React, { useEffect, useMemo, useRef, useState } from 'react';
16
28
  import { createPortal } from 'react-dom';
17
29
  import classNames from 'classnames';
18
30
  import { useDebounce } from '@lemon-fe/hooks';
19
31
  import { PREFIX_CLS as prefixCls } from '../../../constants';
32
+ import { Divider } from 'antd';
33
+
34
+ function Star(props) {
35
+ if (props.active) {
36
+ return /*#__PURE__*/React.createElement("svg", {
37
+ className: props.className,
38
+ width: "20",
39
+ height: "20",
40
+ xmlns: "http://www.w3.org/2000/svg"
41
+ }, /*#__PURE__*/React.createElement("path", {
42
+ d: "m9.666 15.526-3.584 1.27a1 1 0 0 1-1.334-.97l.1-3.8a1 1 0 0 0-.206-.636L2.326 8.373a1 1 0 0 1 .51-1.567l3.646-1.08a1 1 0 0 0 .54-.393L9.176 2.2a1 1 0 0 1 1.648 0l2.154 3.134a1 1 0 0 0 .54.393l3.646 1.08a1 1 0 0 1 .51 1.567l-2.316 3.017a1 1 0 0 0-.206.635l.1 3.801a1 1 0 0 1-1.334.97l-3.584-1.27a1 1 0 0 0-.668 0Z",
43
+ fill: "currentColor",
44
+ fillRule: "evenodd"
45
+ }));
46
+ }
47
+
48
+ return /*#__PURE__*/React.createElement("svg", {
49
+ className: props.className,
50
+ width: "20",
51
+ height: "20",
52
+ xmlns: "http://www.w3.org/2000/svg"
53
+ }, /*#__PURE__*/React.createElement("path", {
54
+ d: "m9.954 2.52 2.406 3.238c.227.33.56.573.945.687l3.646 1.08a.25.25 0 0 1 .179.22l-2.367 3.188a1.75 1.75 0 0 0-.36 1.112l.1 3.801a.25.25 0 0 1-.156.238l-3.77-1.267a1.75 1.75 0 0 0-1.161.002l-3.585 1.27a.25.25 0 0 1-.274-.075l.04-3.976a1.75 1.75 0 0 0-.36-1.105L2.92 7.917a.25.25 0 0 1-.014-.284l3.794-1.19a1.75 1.75 0 0 0 .94-.685l2.153-3.134a.25.25 0 0 1 .16-.104Z",
55
+ stroke: "currentColor",
56
+ strokeWidth: "1.5",
57
+ fill: "none",
58
+ fillRule: "evenodd"
59
+ }));
60
+ }
61
+
20
62
  var drawerIcon = /*#__PURE__*/React.createElement("svg", {
21
63
  width: "20",
22
64
  height: "20",
@@ -39,9 +81,124 @@ var drawerIcon = /*#__PURE__*/React.createElement("svg", {
39
81
  opacity: ".7",
40
82
  transform: "translate(-274.000000, -586.000000) translate(274.000000, 586.000000)"
41
83
  })))));
84
+
85
+ function FavoritesEmpty(props) {
86
+ return /*#__PURE__*/React.createElement("svg", _objectSpread(_objectSpread({}, props), {}, {
87
+ width: "72",
88
+ height: "72",
89
+ xmlns: "http://www.w3.org/2000/svg",
90
+ xmlnsXlink: "http://www.w3.org/1999/xlink"
91
+ }), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("path", {
92
+ d: "M3.2 0h27.475a3.2 3.2 0 0 1 2.262.937l10.126 10.126c.6.6.937 1.414.937 2.262V46.8a3.2 3.2 0 0 1-3.2 3.2H3.2A3.2 3.2 0 0 1 0 46.8V3.2A3.2 3.2 0 0 1 3.2 0Z",
93
+ id: "a"
94
+ })), /*#__PURE__*/React.createElement("g", {
95
+ fill: "none",
96
+ fillRule: "evenodd"
97
+ }, /*#__PURE__*/React.createElement("path", {
98
+ d: "M10.766 23.2h20.889a3.2 3.2 0 0 1 3.051 2.236l9.98 31.6a3.2 3.2 0 0 1-3.052 4.164H20.745a3.2 3.2 0 0 1-3.051-2.236l-9.98-31.6a3.2 3.2 0 0 1 3.052-4.164Z",
99
+ fill: "#E7E7E7",
100
+ opacity: ".4"
101
+ }), /*#__PURE__*/React.createElement("rect", {
102
+ fill: "#E7E7E7",
103
+ x: "49.2",
104
+ y: "11.2",
105
+ width: "14.8",
106
+ height: "14.8",
107
+ rx: "3.2"
108
+ }), /*#__PURE__*/React.createElement("g", {
109
+ transform: "translate(20 11.2)"
110
+ }, /*#__PURE__*/React.createElement("mask", {
111
+ id: "b",
112
+ fill: "#fff"
113
+ }, /*#__PURE__*/React.createElement("use", {
114
+ xlinkHref: "#a"
115
+ })), /*#__PURE__*/React.createElement("use", {
116
+ fill: "#E7E7E7",
117
+ xlinkHref: "#a"
118
+ }), /*#__PURE__*/React.createElement("circle", {
119
+ fill: "#CFCFCF",
120
+ mask: "url(#b)",
121
+ cx: "31.8",
122
+ cy: "17",
123
+ r: "35.4"
124
+ }), /*#__PURE__*/React.createElement("rect", {
125
+ fill: "#BEBEBE",
126
+ mask: "url(#b)",
127
+ x: "29.2",
128
+ width: "14.8",
129
+ height: "14.8",
130
+ rx: "3.2"
131
+ })), /*#__PURE__*/React.createElement("rect", {
132
+ fill: "#FFF",
133
+ x: "30",
134
+ y: "31.6",
135
+ width: "24",
136
+ height: "2.4",
137
+ rx: "1.2"
138
+ }), /*#__PURE__*/React.createElement("rect", {
139
+ fill: "#FFF",
140
+ x: "30",
141
+ y: "39.6",
142
+ width: "12.8",
143
+ height: "2.4",
144
+ rx: "1.2"
145
+ })));
146
+ }
147
+
148
+ var favoriteIcon = /*#__PURE__*/React.createElement("svg", {
149
+ width: "20px",
150
+ height: "20px",
151
+ viewBox: "0 0 20 20",
152
+ version: "1.1",
153
+ xmlns: "http://www.w3.org/2000/svg",
154
+ xmlnsXlink: "http://www.w3.org/1999/xlink"
155
+ }, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("rect", {
156
+ x: "0",
157
+ y: "0",
158
+ width: "20",
159
+ height: "20"
160
+ })), /*#__PURE__*/React.createElement("g", {
161
+ stroke: "none",
162
+ strokeWidth: "1",
163
+ fill: "none",
164
+ fillRule: "evenodd"
165
+ }, /*#__PURE__*/React.createElement("g", {
166
+ transform: "translate(-1398.000000, -481.000000)"
167
+ }, /*#__PURE__*/React.createElement("g", {
168
+ transform: "translate(1398.000000, 481.000000)"
169
+ }, /*#__PURE__*/React.createElement("mask", {
170
+ fill: "white"
171
+ }, /*#__PURE__*/React.createElement("use", {
172
+ xlinkHref: "#path-1"
173
+ })), /*#__PURE__*/React.createElement("use", {
174
+ fillOpacity: "0",
175
+ fill: "#C4C4C4",
176
+ xlinkHref: "#path-1"
177
+ }), /*#__PURE__*/React.createElement("path", {
178
+ d: "M17.4350762,7.192388 L17.4350762,13.192388 C17.4350762,15.9538117 15.1964999,18.192388 12.4350762,18.192388 C9.67365243,18.192388 7.43507618,15.9538117 7.43507618,13.192388 L7.43507618,7.192388 C7.43507618,4.43096425 9.67365243,2.192388 12.4350762,2.192388 C15.1964999,2.192388 17.4350762,4.43096425 17.4350762,7.192388 Z",
179
+ fill: "currentColor",
180
+ opacity: "0.5",
181
+ mask: "url(#mask-2)",
182
+ transform: "translate(12.435076, 10.192388) rotate(45.000000) translate(-12.435076, -10.192388) "
183
+ }), /*#__PURE__*/React.createElement("path", {
184
+ d: "M13.192388,7.19236523 L13.192388,13.1923652 C13.192388,15.953789 10.9538117,18.1923652 8.192388,18.1923652 C5.43096425,18.1923652 3.192388,15.953789 3.192388,13.1923652 L3.192388,7.19236523 C3.192388,4.43094148 5.43096425,2.19236523 8.192388,2.19236523 C10.9538117,2.19236523 13.192388,4.43094148 13.192388,7.19236523 Z",
185
+ fill: "currentColor",
186
+ fillRule: "nonzero",
187
+ mask: "url(#mask-2)",
188
+ transform: "translate(8.192388, 10.192365) rotate(-45.000000) translate(-8.192388, -10.192365) "
189
+ }), /*#__PURE__*/React.createElement("path", {
190
+ d: "M6,6 C5.5,6 4,6.5 4,8.5",
191
+ stroke: "#F2F2F2",
192
+ strokeLinecap: "round",
193
+ strokeDasharray: "0,0",
194
+ mask: "url(#mask-2)"
195
+ })))));
42
196
  export default function Menu(props) {
43
197
  var menus = props.data,
44
- onClick = props.onClick;
198
+ onClick = props.onClick,
199
+ onFavoritesChange = props.onFavoritesChange,
200
+ _props$favorites = props.favorites,
201
+ favorites = _props$favorites === void 0 ? [] : _props$favorites;
45
202
  var location = window.location;
46
203
 
47
204
  var _useState = useState(null),
@@ -67,6 +224,7 @@ export default function Menu(props) {
67
224
  top = _useState8[0],
68
225
  setTop = _useState8[1];
69
226
 
227
+ var FAVORITES_POPOVER = 'FAVORITES_POPOVER';
70
228
  var activeMenu = useMemo(function () {
71
229
  var check = function check(path) {
72
230
  if (path) {
@@ -115,7 +273,7 @@ export default function Menu(props) {
115
273
  }, [location.pathname, menus]);
116
274
 
117
275
  var openMenu = function openMenu(item, elm) {
118
- if (item.children !== undefined && item.children.length > 0 || collapsed) {
276
+ if (item.name === FAVORITES_POPOVER || item.children !== undefined && item.children.length > 0 || collapsed) {
119
277
  setPopover(item);
120
278
  setTop(elm.offsetTop);
121
279
  setTimeout(function () {
@@ -210,14 +368,52 @@ export default function Menu(props) {
210
368
  }
211
369
  };
212
370
 
371
+ var favoritesMap = useMemo(function () {
372
+ return new Map(favorites.map(function (item) {
373
+ return [item.path || '', item];
374
+ }));
375
+ }, [favorites]);
376
+
377
+ var toggleFavorite = function toggleFavorite(e, item) {
378
+ e.stopPropagation();
379
+ var nextMap = new Map(favoritesMap);
380
+ var key = item.path || '';
381
+
382
+ if (nextMap.has(key)) {
383
+ nextMap.delete(key);
384
+ } else {
385
+ nextMap.set(key, {
386
+ name: item.name,
387
+ path: item.path
388
+ });
389
+ }
390
+
391
+ if (onFavoritesChange) {
392
+ onFavoritesChange(_toConsumableArray(nextMap.values()));
393
+ }
394
+ };
395
+
213
396
  var renderItem = function renderItem(item, index) {
397
+ var favorited = favoritesMap.has(item.path || '');
214
398
  return /*#__PURE__*/React.createElement("div", {
215
399
  key: index,
216
400
  className: classNames("".concat(prefixCls, "-menu-item"), _defineProperty({}, "".concat(prefixCls, "-menu-active"), activeMenu !== undefined && activeMenu.key === item.path)),
217
401
  onClick: function onClick() {
218
402
  return handleClick(item);
219
403
  }
220
- }, item.name);
404
+ }, /*#__PURE__*/React.createElement("span", {
405
+ style: {
406
+ overflow: 'hidden'
407
+ }
408
+ }, item.name), /*#__PURE__*/React.createElement("div", {
409
+ className: classNames("".concat(prefixCls, "-menu-item-favorite"), _defineProperty({}, "".concat(prefixCls, "-menu-item-favorite-active"), favorited)),
410
+ onClick: function onClick(e) {
411
+ toggleFavorite(e, item);
412
+ }
413
+ }, /*#__PURE__*/React.createElement(Star, {
414
+ className: "".concat(prefixCls, "-menu-favorite-star"),
415
+ active: favorited
416
+ })));
221
417
  };
222
418
 
223
419
  var renderDrawerItems = function renderDrawerItems() {
@@ -285,7 +481,7 @@ export default function Menu(props) {
285
481
  }, /*#__PURE__*/React.createElement("div", {
286
482
  className: "".concat(prefixCls, "-menu-bar"),
287
483
  onMouseLeave: function onMouseLeave() {
288
- return toggle(closeMenu);
484
+ toggle(closeMenu);
289
485
  }
290
486
  }, popover !== null && /*#__PURE__*/React.createElement("div", {
291
487
  className: "".concat(prefixCls, "-menu-popup"),
@@ -296,7 +492,14 @@ export default function Menu(props) {
296
492
  onMouseEnter: function onMouseEnter() {
297
493
  return toggle.cancel();
298
494
  }
299
- }, popover.children !== undefined ? /*#__PURE__*/React.createElement("div", {
495
+ }, popover.children !== undefined ? popover.name === FAVORITES_POPOVER ? /*#__PURE__*/React.createElement("div", {
496
+ className: "".concat(prefixCls, "-menu-popup-body"),
497
+ key: "pop"
498
+ }, popover.children !== undefined && popover.children.length > 0 ? /*#__PURE__*/React.createElement("div", {
499
+ className: "".concat(prefixCls, "-menu-block-favorite")
500
+ }, popover.children.map(renderItem)) : /*#__PURE__*/React.createElement("div", {
501
+ className: "".concat(prefixCls, "-menu-block-empty")
502
+ }, /*#__PURE__*/React.createElement(FavoritesEmpty, null), /*#__PURE__*/React.createElement("span", null, "\u6682\u65E0\u6536\u85CF"))) : /*#__PURE__*/React.createElement("div", {
300
503
  className: "".concat(prefixCls, "-menu-popup-body"),
301
504
  key: "pop"
302
505
  }, popover.children.map(function (item, index) {
@@ -341,11 +544,11 @@ export default function Menu(props) {
341
544
  strokeDasharray: "0,0",
342
545
  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)"
343
546
  })))))), menus.map(function (item, index) {
344
- var _classNames5;
547
+ var _classNames6;
345
548
 
346
549
  return /*#__PURE__*/React.createElement("div", {
347
550
  key: index,
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)),
551
+ className: classNames("".concat(prefixCls, "-menu-top-item"), (_classNames6 = {}, _defineProperty(_classNames6, "".concat(prefixCls, "-menu-top-item-active"), activeMenu !== undefined && activeMenu.path[0] === index), _defineProperty(_classNames6, "".concat(prefixCls, "-menu-top-item-popover-active"), item === popover), _classNames6)),
349
552
  onClick: function onClick() {
350
553
  return handleClick(item);
351
554
  },
@@ -363,7 +566,32 @@ export default function Menu(props) {
363
566
  }, item.icon), /*#__PURE__*/React.createElement("div", {
364
567
  className: "".concat(prefixCls, "-menu-title")
365
568
  }, item.name));
366
- })), false && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
569
+ }), /*#__PURE__*/React.createElement("div", {
570
+ className: classNames("".concat(prefixCls, "-menu-divider-div"), _defineProperty({}, "".concat(prefixCls, "-menu-divider-div-collapsed"), collapsed))
571
+ }, /*#__PURE__*/React.createElement(Divider, {
572
+ className: "".concat(prefixCls, "-menu-divider")
573
+ })), !collapsed ? /*#__PURE__*/React.createElement("div", {
574
+ className: "".concat(prefixCls, "-menu-other-title")
575
+ }, "\u529F\u80FD\u7BA1\u7406") : null, /*#__PURE__*/React.createElement("div", {
576
+ className: classNames("".concat(prefixCls, "-menu-top-item"), _defineProperty({}, "".concat(prefixCls, "-menu-top-item-popover-active"), (popover === null || popover === void 0 ? void 0 : popover.name) === FAVORITES_POPOVER)),
577
+ onMouseEnter: function onMouseEnter(e) {
578
+ var target = e.currentTarget;
579
+ toggle(function () {
580
+ return openMenu({
581
+ name: 'FAVORITES_POPOVER',
582
+ children: _toConsumableArray(favoritesMap.values())
583
+ }, target);
584
+ });
585
+ }
586
+ }, /*#__PURE__*/React.createElement("div", {
587
+ className: "".concat(prefixCls, "-menu-icon")
588
+ }, favoriteIcon), /*#__PURE__*/React.createElement("div", {
589
+ className: "".concat(prefixCls, "-menu-title")
590
+ }, "\u6536\u85CF")), /*#__PURE__*/React.createElement("div", {
591
+ className: classNames("".concat(prefixCls, "-menu-divider-div"), _defineProperty({}, "".concat(prefixCls, "-menu-divider-div-collapsed"), collapsed))
592
+ }, /*#__PURE__*/React.createElement(Divider, {
593
+ className: "".concat(prefixCls, "-menu-divider")
594
+ }))), false && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
367
595
  className: "".concat(prefixCls, "-menu-gutter")
368
596
  }), collapsed ? /*#__PURE__*/React.createElement("div", {
369
597
  className: "".concat(prefixCls, "-menu-top-item"),
@@ -92,6 +92,10 @@
92
92
  font-size: 16px;
93
93
  }
94
94
 
95
+ &-favorite-star {
96
+ color: var(--ant-primary-color);
97
+ }
98
+
95
99
  &-title {
96
100
  overflow: hidden;
97
101
  white-space: nowrap;
@@ -120,7 +124,7 @@
120
124
  display: flex;
121
125
  margin-left: 4px;
122
126
  padding: 8px;
123
- background: #f9f9f9;
127
+ background: #fff;
124
128
  border-radius: 10px;
125
129
  box-shadow: 0 12px 48px 16px rgba(0, 0, 0, 0.03), 0 9px 28px 0 rgba(0, 0, 0, 0.05),
126
130
  0 6px 16px -8px rgba(0, 0, 0, 0.08);
@@ -158,15 +162,24 @@
158
162
  flex-direction: column;
159
163
  align-items: center;
160
164
  justify-content: center;
161
- height: 100%;
162
- padding: 0 16px;
163
- writing-mode: horizontal-tb;
165
+ width: 256px;
166
+ height: 180px;
164
167
 
165
168
  & > span {
166
- color: rgba(51, 51, 51, 0.65);
167
- font-size: 12px;
169
+ margin-top: 24px;
170
+ color: #333333;
171
+ font-weight: 400;
172
+ font-size: 14px;
173
+ line-height: 22px;
174
+ opacity: 50%;
168
175
  }
169
176
  }
177
+
178
+ &-favorite {
179
+ display: grid;
180
+ grid-auto-flow: column;
181
+ grid-template-rows: repeat(5, auto);
182
+ }
170
183
  }
171
184
 
172
185
  &-sub-item {
@@ -187,7 +200,7 @@
187
200
  box-sizing: border-box;
188
201
  width: 120px;
189
202
  height: 40px;
190
- padding: 0 16px;
203
+ padding: 9px 4px 9px 16px;
191
204
  color: rgba(51, 51, 51, 1);
192
205
  font-size: 14px;
193
206
  line-height: 40px;
@@ -234,6 +247,29 @@
234
247
  line-height: 22px;
235
248
  }
236
249
 
250
+ &-divider-div {
251
+ padding-left: 16px;
252
+ }
253
+
254
+ &-divider-div-collapsed {
255
+ padding-right: 12px;
256
+ padding-left: 12px;
257
+ }
258
+
259
+ &-divider {
260
+ margin-top: 12px;
261
+ margin-bottom: 16px;
262
+ }
263
+
264
+ &-other-title {
265
+ margin: 0 0 8px 16px;
266
+ color: #000000;
267
+ font-weight: 400;
268
+ font-size: 14px;
269
+ line-height: 22px;
270
+ opacity: 50%;
271
+ }
272
+
237
273
  &-more {
238
274
  display: flex;
239
275
  align-items: center;
@@ -1,5 +1,5 @@
1
1
  import type { ReactElement, ReactNode } from 'react';
2
- import type { MenuItem } from './typings';
2
+ import type { MenuFavorites, MenuItem } from './typings';
3
3
  interface Props<T> {
4
4
  active: number;
5
5
  tabs: T[];
@@ -11,6 +11,8 @@ interface Props<T> {
11
11
  children?: ReactNode;
12
12
  logo?: string | false | ReactElement;
13
13
  title: string | ReactNode;
14
+ favorites?: MenuFavorites;
15
+ onFavoritesChange?: (value: MenuFavorites) => void;
14
16
  }
15
17
  export default function MainFramework<TabType extends {
16
18
  title: string;
@@ -12,7 +12,9 @@ export default function MainFramework(props) {
12
12
  onMenuClick = props.onMenuClick,
13
13
  onTabClose = props.onTabClose,
14
14
  logo = props.logo,
15
- title = props.title;
15
+ title = props.title,
16
+ favorites = props.favorites,
17
+ onFavoritesChange = props.onFavoritesChange;
16
18
  return /*#__PURE__*/React.createElement("div", {
17
19
  className: "".concat(prefixCls, "-main")
18
20
  }, /*#__PURE__*/React.createElement("div", {
@@ -45,7 +47,9 @@ export default function MainFramework(props) {
45
47
  className: "".concat(prefixCls, "-body")
46
48
  }, /*#__PURE__*/React.createElement(Menu, {
47
49
  data: menus,
48
- onClick: onMenuClick
50
+ onClick: onMenuClick,
51
+ favorites: favorites,
52
+ onFavoritesChange: onFavoritesChange
49
53
  }), /*#__PURE__*/React.createElement("div", {
50
54
  className: "".concat(prefixCls, "-content")
51
55
  }, children)));
@@ -6,3 +6,5 @@ export type MenuItem = {
6
6
  icon?: string | ReactElement;
7
7
  children?: MenuItem[];
8
8
  };
9
+
10
+ export type MenuFavorites = { name: string; path?: string }[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -16,7 +16,7 @@
16
16
  "registry": "https://registry.npmjs.org"
17
17
  },
18
18
  "dependencies": {
19
- "@lemon-fe/hooks": "^0.0.20",
19
+ "@lemon-fe/hooks": "^0.0.21",
20
20
  "antd": "^4.17.0",
21
21
  "classnames": "^2.2.6",
22
22
  "lodash": "^4.17.21",
@@ -39,5 +39,5 @@
39
39
  "@types/lodash": "^4.14.179",
40
40
  "@types/react-resizable": "^1.7.4"
41
41
  },
42
- "gitHead": "74a29e43bf5b94819763c3bd2ab188ee4f3dc8f1"
42
+ "gitHead": "800cd94fab88bdc749dc65602b9d15abbb89691d"
43
43
  }