@lemon-fe/components 0.0.20 → 0.0.24

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.
@@ -132,6 +132,8 @@ function Actions(props) {
132
132
  content: /*#__PURE__*/React.createElement("ul", {
133
133
  className: "".concat(prefixCls, "-actions-popover-list")
134
134
  }, collapsedBtns.map(function (item, index) {
135
+ var _classNames;
136
+
135
137
  if (item === null) {
136
138
  return item;
137
139
  }
@@ -142,15 +144,18 @@ function Actions(props) {
142
144
  }, item);
143
145
  }
144
146
 
147
+ var disabled = item.disabled;
145
148
  return /*#__PURE__*/React.createElement("li", {
146
- className: "".concat(prefixCls, "-actions-popover-item"),
149
+ className: classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-actions-popover-item-disabled"), disabled), _defineProperty(_classNames, "".concat(prefixCls, "-actions-popover-item"), !disabled), _classNames)),
147
150
  key: index,
148
151
  onClick: function onClick() {
149
- var handleClick = item.onClick || item.action;
150
- setVisible(false);
152
+ if (!disabled) {
153
+ var handleClick = item.onClick || item.action;
154
+ setVisible(false);
151
155
 
152
- if (handleClick) {
153
- handleClick();
156
+ if (handleClick) {
157
+ handleClick();
158
+ }
154
159
  }
155
160
  }
156
161
  }, item.text);
@@ -35,6 +35,19 @@
35
35
  color: .primary(1) [];
36
36
  background: .primary(0.08) [];
37
37
  }
38
+
39
+ &-disabled {
40
+ box-sizing: border-box;
41
+ width: 124px;
42
+ height: 38px;
43
+ padding: 8px;
44
+ color: rgba(0, 0, 0, 0.25);
45
+ line-height: 22px;
46
+ text-align: left;
47
+ list-style: none;
48
+ border-radius: 2px;
49
+ cursor: not-allowed;
50
+ }
38
51
  }
39
52
  }
40
53
 
@@ -11,8 +11,6 @@
11
11
  }
12
12
 
13
13
  .ant-table-body {
14
- scrollbar-width: thin;
15
-
16
14
  &::-webkit-scrollbar {
17
15
  width: 8px;
18
16
  height: 8px;
@@ -0,0 +1,10 @@
1
+ export default function DownBar<T extends {
2
+ title: string;
3
+ closable?: boolean;
4
+ }>(props: {
5
+ tabs: T[];
6
+ active: number;
7
+ visible?: boolean;
8
+ onClick: (active: number) => void;
9
+ onClose: (active: number) => void;
10
+ }): JSX.Element;
@@ -0,0 +1,84 @@
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; }
2
+
3
+ import React from 'react';
4
+ import classNames from 'classnames';
5
+ import { PREFIX_CLS as prefixCls } from '../../../constants';
6
+ import { Dropdown } from 'antd';
7
+ export default function DownBar(props) {
8
+ var tabs = props.tabs,
9
+ active = props.active,
10
+ _props$visible = props.visible,
11
+ visible = _props$visible === void 0 ? false : _props$visible,
12
+ _onClick = props.onClick,
13
+ onClose = props.onClose;
14
+
15
+ var handleClose = function handleClose(e, index) {
16
+ e.stopPropagation();
17
+ onClose(index);
18
+ };
19
+
20
+ return /*#__PURE__*/React.createElement(Dropdown, {
21
+ overlayStyle: visible ? {
22
+ visibility: 'visible'
23
+ } : {
24
+ visibility: 'hidden'
25
+ },
26
+ placement: "bottomRight",
27
+ overlay: /*#__PURE__*/React.createElement("div", {
28
+ className: "".concat(prefixCls, "-down-tabs")
29
+ }, tabs.map(function (item, index) {
30
+ var key = item.title;
31
+ return /*#__PURE__*/React.createElement("div", {
32
+ className: classNames("".concat(prefixCls, "-down-tab"), _defineProperty({}, "".concat(prefixCls, "-down-tab-active"), index === active)),
33
+ onClick: function onClick() {
34
+ return _onClick(index);
35
+ },
36
+ key: key
37
+ }, /*#__PURE__*/React.createElement("div", {
38
+ className: "".concat(prefixCls, "-down-tab-title")
39
+ }, /*#__PURE__*/React.createElement("div", {
40
+ className: "".concat(prefixCls, "-down-tab-inner")
41
+ }, item.title), item.closable !== false && /*#__PURE__*/React.createElement("div", {
42
+ className: "".concat(prefixCls, "-down-tab-close"),
43
+ onClick: function onClick(e) {
44
+ return handleClose(e, index);
45
+ }
46
+ }, /*#__PURE__*/React.createElement("svg", {
47
+ width: "20",
48
+ height: "20",
49
+ xmlns: "http://www.w3.org/2000/svg"
50
+ }, /*#__PURE__*/React.createElement("g", {
51
+ fill: "none",
52
+ fillRule: "evenodd"
53
+ }, /*#__PURE__*/React.createElement("g", {
54
+ fill: "currentColor"
55
+ }, /*#__PURE__*/React.createElement("g", {
56
+ fillRule: "nonzero"
57
+ }, /*#__PURE__*/React.createElement("path", {
58
+ 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",
59
+ transform: "translate(-367.000000, -21.000000) translate(367.000000, 21.000000) translate(6.999923, 7.000068) rotate(45.000000) translate(-6.999923, -7.000068)"
60
+ }), /*#__PURE__*/React.createElement("path", {
61
+ 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",
62
+ transform: "translate(-367.000000, -21.000000) translate(367.000000, 21.000000) translate(6.999946, 7.000077) rotate(-45.000000) translate(-6.999946, -7.000077)"
63
+ }))))))));
64
+ }))
65
+ }, /*#__PURE__*/React.createElement("div", {
66
+ className: "".concat(prefixCls, "-down-tab-icon"),
67
+ style: visible ? {
68
+ visibility: 'visible'
69
+ } : {
70
+ visibility: 'hidden'
71
+ }
72
+ }, /*#__PURE__*/React.createElement("svg", {
73
+ width: "14",
74
+ height: "14",
75
+ viewBox: "0 0 16 16",
76
+ xmlns: "http://www.w3.org/2000/svg"
77
+ }, /*#__PURE__*/React.createElement("path", {
78
+ d: "M4.707 5.293L3.293 6.707 8 11.414l4.707-4.707-1.414-1.414L8 8.586z",
79
+ color: "#6D6D6D",
80
+ opacity: ".9",
81
+ fill: "currentColor",
82
+ fillRule: "nonzero"
83
+ }))));
84
+ }
@@ -0,0 +1,108 @@
1
+ .@{prefixCls}-down-tabs {
2
+ position: relative;
3
+ display: flex;
4
+ flex-direction: column;
5
+ align-items: flex-start;
6
+ width: 120px;
7
+ overflow-x: hidden;
8
+ background-color: #fcfcfc;
9
+ border-radius: 8px;
10
+ box-shadow: 0px 12px 48px 16px rgba(0, 0, 0, 0.03), 0px 9px 28px 0px rgba(0, 0, 0, 0.05),
11
+ 0px 6px 16px -8px rgba(0, 0, 0, 0.08);
12
+ backdrop-filter: blur(13px);
13
+ }
14
+
15
+ .@{prefixCls}-down-tab {
16
+ position: relative;
17
+ box-sizing: content-box;
18
+ width: 100%;
19
+ height: 43px;
20
+ cursor: pointer;
21
+
22
+ &-title {
23
+ position: relative;
24
+ z-index: 4;
25
+ display: flex;
26
+ flex-wrap: nowrap;
27
+ align-items: center;
28
+ padding: 0 12px;
29
+ transition: background-color 0.2s;
30
+ }
31
+
32
+ &:hover:not(&-active) &-title,
33
+ &:hover:not(&-active)::after {
34
+ background-color: #f2f2f2;
35
+ }
36
+
37
+ &-active &-title,
38
+ &-active::after {
39
+ background-color: #eeeeee;
40
+ }
41
+
42
+ &:hover::after {
43
+ z-index: 2;
44
+ }
45
+
46
+ &-active::after {
47
+ z-index: 3;
48
+ }
49
+
50
+ &-active::before,
51
+ &-active + &::before,
52
+ &:hover::before,
53
+ &:hover + &::before {
54
+ opacity: 0;
55
+ }
56
+
57
+ &-active &-inner {
58
+ opacity: 1;
59
+ }
60
+
61
+ &-inner {
62
+ flex: 1;
63
+ min-width: 0;
64
+ overflow: hidden;
65
+ color: #333;
66
+ font-size: 14px;
67
+ line-height: 43px;
68
+ white-space: nowrap;
69
+ text-overflow: ellipsis;
70
+ opacity: 0.7;
71
+
72
+ &::after {
73
+ display: inline-block;
74
+ width: 16px;
75
+ content: ' ';
76
+ }
77
+ }
78
+
79
+ &-close {
80
+ display: none;
81
+ }
82
+ &:hover &-close {
83
+ display: block;
84
+ width: 14px;
85
+ height: 14px;
86
+ color: #c4c4c4;
87
+ line-height: 14px;
88
+ text-align: center;
89
+ border-radius: 50%;
90
+ &:hover {
91
+ color: #f2f2f2;
92
+ background-color: #c1c1c1;
93
+ }
94
+ }
95
+ }
96
+
97
+ .@{prefixCls}-down-tab-icon {
98
+ display: flex;
99
+ align-items: center;
100
+ justify-content: center;
101
+ width: 34px;
102
+ height: 34px;
103
+ border-radius: 50%;
104
+ cursor: pointer;
105
+ &:hover {
106
+ background-color: #eeeeee;
107
+ }
108
+ }
@@ -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: 0.5;
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: 0.5;
271
+ }
272
+
237
273
  &-more {
238
274
  display: flex;
239
275
  align-items: center;
@@ -9,10 +9,10 @@
9
9
  &::before {
10
10
  position: absolute;
11
11
  top: 0;
12
- left: 6px;
12
+ left: 0;
13
13
  z-index: 4;
14
14
  display: block;
15
- width: 10px;
15
+ width: 16px;
16
16
  height: 100%;
17
17
  background-color: #fff;
18
18
  border-bottom-right-radius: 10px;
@@ -22,10 +22,10 @@
22
22
  &::after {
23
23
  position: absolute;
24
24
  top: 0;
25
- right: 6px;
25
+ right: 0;
26
26
  z-index: 4;
27
27
  display: block;
28
- width: 10px;
28
+ width: 16px;
29
29
  height: 100%;
30
30
  background-color: #fff;
31
31
  border-bottom-left-radius: 10px;
@@ -36,7 +36,7 @@
36
36
  .@{prefixCls}-nav-tab {
37
37
  position: relative;
38
38
  box-sizing: content-box;
39
- min-width: 14px;
39
+ min-width: 66px;
40
40
  max-width: 120px;
41
41
  height: 43px;
42
42
  cursor: pointer;
@@ -109,7 +109,7 @@
109
109
 
110
110
  &-inner {
111
111
  flex: 1;
112
- min-width: 0;
112
+ min-width: 28px;
113
113
  overflow: hidden;
114
114
  color: #333;
115
115
  font-size: 14px;
@@ -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;
@@ -1,7 +1,21 @@
1
- import React from 'react';
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import React, { useEffect, useRef, useState } from 'react';
2
14
  import TabBar from './components/TabBar';
3
15
  import Menu from './components/Menu';
4
16
  import { PREFIX_CLS as prefixCls } from '../constants';
17
+ import DownBar from './components/DownBar';
18
+ import { useDebounce } from '@lemon-fe/hooks';
5
19
  export default function MainFramework(props) {
6
20
  var tabs = props.tabs,
7
21
  active = props.active,
@@ -12,11 +26,48 @@ export default function MainFramework(props) {
12
26
  onMenuClick = props.onMenuClick,
13
27
  onTabClose = props.onTabClose,
14
28
  logo = props.logo,
15
- title = props.title;
29
+ title = props.title,
30
+ favorites = props.favorites,
31
+ onFavoritesChange = props.onFavoritesChange;
32
+
33
+ var _useState = useState(false),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ hideTabs = _useState2[0],
36
+ setHideTabs = _useState2[1];
37
+
38
+ var tabRef = useRef(null);
39
+ var handleDownBar = useDebounce(function () {
40
+ var _tabRef$current$query, _tabRef$current$query2;
41
+
42
+ if (tabRef.current === null) {
43
+ return;
44
+ }
45
+
46
+ var leftLength = (_tabRef$current$query = tabRef.current.querySelector(".".concat(prefixCls, "-nav-left"))) === null || _tabRef$current$query === void 0 ? void 0 : _tabRef$current$query.offsetWidth;
47
+ var rightLength = (_tabRef$current$query2 = tabRef.current.querySelector(".".concat(prefixCls, "-nav-right"))) === null || _tabRef$current$query2 === void 0 ? void 0 : _tabRef$current$query2.offsetWidth;
48
+ var minWidth = 66 * tabs.length + 32;
49
+ var width = window.innerWidth - (leftLength || 0) - (rightLength || 0);
50
+
51
+ if (tabs.length && minWidth >= width) {
52
+ setHideTabs(true);
53
+ } else if (minWidth < width) {
54
+ setHideTabs(false);
55
+ }
56
+ }, 300);
57
+ useEffect(function () {
58
+ window.addEventListener('resize', handleDownBar);
59
+ return function () {
60
+ window.removeEventListener('resize', handleDownBar);
61
+ };
62
+ }, []);
63
+ useEffect(function () {
64
+ handleDownBar();
65
+ }, [tabs, active]);
16
66
  return /*#__PURE__*/React.createElement("div", {
17
67
  className: "".concat(prefixCls, "-main")
18
68
  }, /*#__PURE__*/React.createElement("div", {
19
- className: "".concat(prefixCls, "-nav")
69
+ className: "".concat(prefixCls, "-nav"),
70
+ ref: tabRef
20
71
  }, /*#__PURE__*/React.createElement("div", {
21
72
  className: "".concat(prefixCls, "-nav-left")
22
73
  }, logo !== false && /*#__PURE__*/React.createElement("div", {
@@ -41,11 +92,19 @@ export default function MainFramework(props) {
41
92
  onClose: onTabClose
42
93
  }), /*#__PURE__*/React.createElement("div", {
43
94
  className: "".concat(prefixCls, "-nav-right")
44
- }, right)), /*#__PURE__*/React.createElement("div", {
95
+ }, /*#__PURE__*/React.createElement(DownBar, {
96
+ visible: hideTabs,
97
+ tabs: tabs,
98
+ active: active,
99
+ onClick: onTabClick,
100
+ onClose: onTabClose
101
+ }), right)), /*#__PURE__*/React.createElement("div", {
45
102
  className: "".concat(prefixCls, "-body")
46
103
  }, /*#__PURE__*/React.createElement(Menu, {
47
104
  data: menus,
48
- onClick: onMenuClick
105
+ onClick: onMenuClick,
106
+ favorites: favorites,
107
+ onFavoritesChange: onFavoritesChange
49
108
  }), /*#__PURE__*/React.createElement("div", {
50
109
  className: "".concat(prefixCls, "-content")
51
110
  }, children)));
@@ -1,5 +1,6 @@
1
1
  @import './components/Menu/index.less';
2
2
  @import './components/TabBar/index.less';
3
+ @import './components/DownBar/index.less';
3
4
 
4
5
  .@{prefixCls}-main {
5
6
  display: flex;
@@ -14,9 +15,10 @@
14
15
  position: relative;
15
16
  z-index: 4;
16
17
  display: flex;
18
+ flex-wrap: nowrap;
17
19
  align-items: center;
18
20
  box-sizing: border-box;
19
- width: 100vw;
21
+ width: 100%;
20
22
  height: 50px;
21
23
  padding: 0 16px;
22
24
  background: #ffff;
@@ -54,8 +56,8 @@
54
56
  }
55
57
 
56
58
  &-right {
59
+ flex-shrink: 0;
57
60
  justify-content: flex-end;
58
- min-width: 180px;
59
61
  margin-left: auto;
60
62
  }
61
63
  }
@@ -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/es/init.js CHANGED
@@ -7,8 +7,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
7
7
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
8
8
 
9
9
  import React from 'react';
10
+ import { message, Modal, Empty, Select, ConfigProvider, Result, Button } from 'antd';
11
+ import { config } from '@lemon-fe/hooks';
12
+ import PageLoading from './PageLoading';
10
13
  import Icons from './Icons';
11
- import { message, Modal, Empty, Select } from 'antd';
12
14
  var Tip = Icons.Tip,
13
15
  EmptyIcon = Icons.Empty,
14
16
  Down = Icons.Down;
@@ -97,4 +99,36 @@ export default function init() {
97
99
  Empty.defaultProps = {
98
100
  image: Empty.PRESENTED_IMAGE_DEFAULT
99
101
  };
102
+ config({
103
+ showToast: function showToast() {
104
+ return message.loading('请稍等', 0);
105
+ },
106
+ cancelToast: function cancelToast(hide) {
107
+ hide();
108
+ },
109
+ showLoading: function showLoading() {
110
+ return /*#__PURE__*/React.createElement(PageLoading, null);
111
+ },
112
+ showError: function showError(err) {
113
+ message.error(err.message);
114
+ },
115
+ setPrimaryColor: function setPrimaryColor(color) {
116
+ ConfigProvider.config({
117
+ theme: {
118
+ primaryColor: color
119
+ }
120
+ });
121
+ },
122
+ errorResult: function errorResult(err, refresh) {
123
+ return /*#__PURE__*/React.createElement(Result, {
124
+ status: "500",
125
+ title: "500",
126
+ subTitle: err.message,
127
+ extra: /*#__PURE__*/React.createElement(Button, {
128
+ type: "primary",
129
+ onClick: refresh
130
+ }, "\u91CD\u65B0\u52A0\u8F7D")
131
+ });
132
+ }
133
+ });
100
134
  }
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.24",
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.24",
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": "85f8df424cf24a01973162690b65a2747ee67af5"
43
43
  }