@lemon-fe/components 0.0.0 → 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.
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { BaseTableProps as Props } from './typings';
3
2
  declare function BaseTable<T extends Record<string, any>>(props: Props<T>): JSX.Element;
4
3
  declare namespace BaseTable {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { Moment } from 'moment';
3
2
  import type { RangePickerProps } from 'antd/lib/date-picker';
4
3
  declare type Value = {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { FormItemProps } from 'antd';
3
2
  import { EditableTableProps } from './typings';
4
3
  declare type Props<T> = Pick<FormItemProps, 'name' | 'label' | 'labelCol' | 'wrapperCol' | 'className' | 'required' | 'style' | 'colon'> & EditableTableProps<T>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ComponentOption, FilterProps } from './typings';
3
2
  declare function Filter<T extends Record<string, any> = Record<string, any>>(props: FilterProps<T>): JSX.Element;
4
3
  declare namespace Filter {
@@ -0,0 +1,7 @@
1
+ import type { MenuItem } from '../../typings';
2
+ interface Props {
3
+ data: MenuItem[];
4
+ onClick: (item: MenuItem) => void;
5
+ }
6
+ export default function Menu(props: Props): JSX.Element;
7
+ export {};
@@ -0,0 +1,396 @@
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
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+
5
+ 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."); }
6
+
7
+ 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); }
8
+
9
+ 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; }
10
+
11
+ 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; }
12
+
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+
15
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
16
+ import { createPortal } from 'react-dom';
17
+ import classNames from 'classnames';
18
+ import { useDebounce } from '@lemon-fe/hooks';
19
+ import { PREFIX_CLS as prefixCls } from '../../../constants';
20
+ var drawerIcon = /*#__PURE__*/React.createElement("svg", {
21
+ width: "20",
22
+ height: "20",
23
+ xmlns: "http://www.w3.org/2000/svg"
24
+ }, /*#__PURE__*/React.createElement("g", {
25
+ fill: "none",
26
+ fillRule: "evenodd"
27
+ }, /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("g", {
28
+ fill: "currentColor"
29
+ }, /*#__PURE__*/React.createElement("path", {
30
+ d: "M4.75,5 L15.25,5 C15.6642136,5 16,5.33578644 16,5.75 C16,6.16421356 15.6642136,6.5 15.25,6.5 L4.75,6.5 C4.33578644,6.5 4,6.16421356 4,5.75 C4,5.33578644 4.33578644,5 4.75,5 Z",
31
+ opacity: ".7",
32
+ transform: "translate(-274.000000, -586.000000) translate(274.000000, 586.000000)"
33
+ }), /*#__PURE__*/React.createElement("path", {
34
+ d: "M4.75,9 L15.25,9 C15.6642136,9 16,9.33578644 16,9.75 C16,10.1642136 15.6642136,10.5 15.25,10.5 L4.75,10.5 C4.33578644,10.5 4,10.1642136 4,9.75 C4,9.33578644 4.33578644,9 4.75,9 Z",
35
+ opacity: ".7",
36
+ transform: "translate(-274.000000, -586.000000) translate(274.000000, 586.000000)"
37
+ }), /*#__PURE__*/React.createElement("path", {
38
+ d: "M4.75,13 L15.25,13 C15.6642136,13 16,13.3357864 16,13.75 C16,14.1642136 15.6642136,14.5 15.25,14.5 L4.75,14.5 C4.33578644,14.5 4,14.1642136 4,13.75 C4,13.3357864 4.33578644,13 4.75,13 Z",
39
+ opacity: ".7",
40
+ transform: "translate(-274.000000, -586.000000) translate(274.000000, 586.000000)"
41
+ })))));
42
+ export default function Menu(props) {
43
+ var menus = props.data,
44
+ onClick = props.onClick;
45
+ var location = window.location;
46
+
47
+ var _useState = useState(null),
48
+ _useState2 = _slicedToArray(_useState, 2),
49
+ popover = _useState2[0],
50
+ setPopover = _useState2[1];
51
+
52
+ var popup = useRef(null);
53
+ var drawer = useRef(null);
54
+
55
+ var _useState3 = useState(false),
56
+ _useState4 = _slicedToArray(_useState3, 2),
57
+ collapsed = _useState4[0],
58
+ setCollapsed = _useState4[1];
59
+
60
+ var _useState5 = useState(false),
61
+ _useState6 = _slicedToArray(_useState5, 2),
62
+ visible = _useState6[0],
63
+ setVisible = _useState6[1];
64
+
65
+ var _useState7 = useState(0),
66
+ _useState8 = _slicedToArray(_useState7, 2),
67
+ top = _useState8[0],
68
+ setTop = _useState8[1];
69
+
70
+ var activeMenu = useMemo(function () {
71
+ var check = function check(path) {
72
+ if (path) {
73
+ return new RegExp("".concat(path, "(?![^\\/])")).test(location.pathname);
74
+ }
75
+
76
+ return false;
77
+ };
78
+
79
+ for (var i = 0; i < menus.length; i += 1) {
80
+ var _menus$i = menus[i],
81
+ _menus$i$children = _menus$i.children,
82
+ subMenus = _menus$i$children === void 0 ? [] : _menus$i$children,
83
+ topPath = _menus$i.path;
84
+
85
+ if (check(topPath)) {
86
+ return {
87
+ path: [i],
88
+ key: topPath
89
+ };
90
+ }
91
+
92
+ for (var j = 0; j < subMenus.length; j += 1) {
93
+ var _subMenus$j = subMenus[j],
94
+ subPath = _subMenus$j.path,
95
+ _subMenus$j$children = _subMenus$j.children,
96
+ items = _subMenus$j$children === void 0 ? [] : _subMenus$j$children;
97
+
98
+ if (check(subPath)) {
99
+ return {
100
+ path: [i, j],
101
+ key: subPath
102
+ };
103
+ }
104
+
105
+ for (var k = 0; k < items.length; k += 1) {
106
+ if (check(items[k].path)) {
107
+ return {
108
+ path: [i, j, k],
109
+ key: items[k].path
110
+ };
111
+ }
112
+ }
113
+ }
114
+ }
115
+ }, [location.pathname, menus]);
116
+
117
+ var openMenu = function openMenu(item, elm) {
118
+ if (item.children && item.children.length > 0) {
119
+ setPopover(item);
120
+ setTop(elm.offsetTop);
121
+ setTimeout(function () {
122
+ if (popup.current) {
123
+ popup.current.classList.add('animated');
124
+ }
125
+ }, 16);
126
+ } else {
127
+ setPopover(null);
128
+ }
129
+ };
130
+
131
+ var handleMouseEnter = useDebounce(openMenu, 200);
132
+
133
+ var toggleMenu = function toggleMenu() {
134
+ setCollapsed(function (prev) {
135
+ return !prev;
136
+ });
137
+ };
138
+
139
+ var closeMenu = function closeMenu() {
140
+ handleMouseEnter.cancel();
141
+
142
+ if (popup.current) {
143
+ popup.current.classList.remove('animated');
144
+
145
+ var handler = function handler() {
146
+ var _popup$current;
147
+
148
+ setPopover(null);
149
+ (_popup$current = popup.current) === null || _popup$current === void 0 ? void 0 : _popup$current.removeEventListener('transitionend', handler);
150
+ };
151
+
152
+ popup.current.addEventListener('transitionend', handler);
153
+ }
154
+ };
155
+
156
+ useEffect(function () {
157
+ if (!visible) {
158
+ return;
159
+ }
160
+
161
+ var target = drawer.current;
162
+
163
+ if (target !== null) {
164
+ var handler = function handler(e) {
165
+ if (!target.contains(e.target)) {
166
+ closeDrawer();
167
+ }
168
+ };
169
+
170
+ requestAnimationFrame(function () {
171
+ window.addEventListener('click', handler);
172
+ });
173
+ return function () {
174
+ window.removeEventListener('click', handler);
175
+ };
176
+ }
177
+ }, [visible]);
178
+
179
+ var openDrawer = function openDrawer() {
180
+ setVisible(true);
181
+ setTimeout(function () {
182
+ var _drawer$current;
183
+
184
+ (_drawer$current = drawer.current) === null || _drawer$current === void 0 ? void 0 : _drawer$current.classList.add('animated');
185
+ }, 16);
186
+ };
187
+
188
+ var closeDrawer = function closeDrawer() {
189
+ if (drawer.current) {
190
+ drawer.current.classList.remove('animated');
191
+
192
+ var handler = function handler() {
193
+ var _drawer$current2;
194
+
195
+ (_drawer$current2 = drawer.current) === null || _drawer$current2 === void 0 ? void 0 : _drawer$current2.removeEventListener('transitionend', handler);
196
+ setVisible(false);
197
+ };
198
+
199
+ drawer.current.addEventListener('transitionend', handler);
200
+ }
201
+ };
202
+
203
+ var handleClick = function handleClick(item) {
204
+ if (item.path) {
205
+ onClick(item);
206
+ closeDrawer();
207
+ closeMenu();
208
+ }
209
+ };
210
+
211
+ var renderItem = function renderItem(item, index) {
212
+ return /*#__PURE__*/React.createElement("div", {
213
+ key: index,
214
+ className: classNames("".concat(prefixCls, "-menu-item"), _defineProperty({}, "".concat(prefixCls, "-menu-active"), activeMenu !== undefined && activeMenu.key === item.path)),
215
+ onClick: function onClick() {
216
+ return handleClick(item);
217
+ }
218
+ }, item.name);
219
+ };
220
+
221
+ var renderDrawerItems = function renderDrawerItems() {
222
+ var cols = [[], [], []];
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);
240
+ }
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];
267
+ }
268
+ }
269
+
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);
278
+ });
279
+ };
280
+
281
+ return /*#__PURE__*/React.createElement("div", {
282
+ className: classNames("".concat(prefixCls, "-menu"), _defineProperty({}, "".concat(prefixCls, "-menu-collapsed"), collapsed))
283
+ }, /*#__PURE__*/React.createElement("div", {
284
+ className: "".concat(prefixCls, "-menu-bar"),
285
+ onMouseLeave: closeMenu
286
+ }, popover !== null && popover.children !== undefined && /*#__PURE__*/React.createElement("div", {
287
+ className: "".concat(prefixCls, "-menu-popup"),
288
+ style: {
289
+ top: top
290
+ },
291
+ ref: popup,
292
+ onMouseEnter: function onMouseEnter() {
293
+ return handleMouseEnter.cancel();
294
+ }
295
+ }, /*#__PURE__*/React.createElement("div", {
296
+ className: "".concat(prefixCls, "-menu-popup-body")
297
+ }, popover.children.map(function (item, index) {
298
+ return /*#__PURE__*/React.createElement("div", {
299
+ className: "".concat(prefixCls, "-menu-block"),
300
+ key: index
301
+ }, /*#__PURE__*/React.createElement("div", {
302
+ className: "".concat(prefixCls, "-menu-sub-item")
303
+ }, item.name), item.children !== undefined && item.children.map(renderItem));
304
+ }))), /*#__PURE__*/React.createElement("div", {
305
+ className: "".concat(prefixCls, "-menu-collapse"),
306
+ onClick: toggleMenu
307
+ }, /*#__PURE__*/React.createElement("svg", {
308
+ width: "20",
309
+ height: "20",
310
+ xmlns: "http://www.w3.org/2000/svg"
311
+ }, /*#__PURE__*/React.createElement("g", {
312
+ fill: "none",
313
+ fillRule: "evenodd",
314
+ opacity: ".7"
315
+ }, /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("path", {
316
+ d: "M14.75,5 C15.1642136,5 15.5,5.33578644 15.5,5.75 L15.5,14.25 C15.5,14.6642136 15.1642136,15 14.75,15 C14.3357864,15 14,14.6642136 14,14.25 L14,5.75 C14,5.33578644 14.3357864,5 14.75,5 Z",
317
+ fill: "currentColor",
318
+ transform: "translate(-274.000000, -57.000000) translate(284.000000, 67.000000) scale(-1, 1) translate(-284.000000, -67.000000) translate(274.000000, 57.000000)"
319
+ }), /*#__PURE__*/React.createElement("path", {
320
+ d: "M15,10 C15,10.4142136 14.6642136,10.75 14.25,10.75 L5,10.75 L5,10.75 L5,9.25 L14.25,9.25 C14.6642136,9.25 15,9.58578644 15,10 Z",
321
+ fill: "currentColor",
322
+ fillRule: "nonzero",
323
+ transform: "translate(-274.000000, -57.000000) translate(284.000000, 67.000000) scale(-1, 1) translate(-284.000000, -67.000000) translate(274.000000, 57.000000)"
324
+ }), /*#__PURE__*/React.createElement("path", {
325
+ d: "M11.7426212,6.79290128 L5.32842371,6.79290128 L5.32842371,13.2070987",
326
+ stroke: "currentColor",
327
+ strokeWidth: "1.5",
328
+ strokeLinecap: "round",
329
+ strokeLinejoin: "round",
330
+ strokeDasharray: "0,0",
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)"
332
+ })))))), menus.map(function (item, index) {
333
+ var _classNames5;
334
+
335
+ return /*#__PURE__*/React.createElement("div", {
336
+ key: index,
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)),
338
+ onClick: function onClick() {
339
+ return handleClick(item);
340
+ },
341
+ onMouseEnter: function onMouseEnter(e) {
342
+ return handleMouseEnter(item, e.currentTarget);
343
+ }
344
+ }, /*#__PURE__*/React.createElement("img", {
345
+ className: "".concat(prefixCls, "-menu-icon"),
346
+ src: item.icon
347
+ }), /*#__PURE__*/React.createElement("div", {
348
+ className: "".concat(prefixCls, "-menu-title")
349
+ }, item.name));
350
+ })), false && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
351
+ className: "".concat(prefixCls, "-menu-gutter")
352
+ }), collapsed ? /*#__PURE__*/React.createElement("div", {
353
+ className: "".concat(prefixCls, "-menu-top-item"),
354
+ onClick: openDrawer
355
+ }, drawerIcon) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
356
+ className: "".concat(prefixCls, "-menu-label")
357
+ }, "\u6CA1\u6709\u627E\u5230\u60F3\u8981\u7684\u529F\u80FD?"), /*#__PURE__*/React.createElement("div", {
358
+ className: "".concat(prefixCls, "-menu-more"),
359
+ onClick: openDrawer
360
+ }, drawerIcon, /*#__PURE__*/React.createElement("span", null, "\u67E5\u770B\u5168\u90E8")))), visible && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", {
361
+ className: "".concat(prefixCls, "-menu-drawer"),
362
+ ref: drawer
363
+ }, /*#__PURE__*/React.createElement("div", {
364
+ className: "".concat(prefixCls, "-menu-drawer-header")
365
+ }, /*#__PURE__*/React.createElement("div", null, "\u67E5\u770B\u5168\u90E8"), /*#__PURE__*/React.createElement("div", {
366
+ className: "".concat(prefixCls, "-menu-drawer-close"),
367
+ onClick: closeDrawer
368
+ }, /*#__PURE__*/React.createElement("svg", {
369
+ width: "16",
370
+ height: "16",
371
+ xmlns: "http://www.w3.org/2000/svg"
372
+ }, /*#__PURE__*/React.createElement("g", {
373
+ fill: "none",
374
+ fillRule: "evenodd",
375
+ opacity: ".7"
376
+ }, /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("g", {
377
+ transform: "translate(-1880.000000, -20.000000) translate(1880.000000, 20.000000)",
378
+ fill: "currentColor"
379
+ }, /*#__PURE__*/React.createElement("rect", {
380
+ transform: "translate(8.000000, 8.000000) rotate(-45.000000) translate(-8.000000, -8.000000)",
381
+ x: "7.25",
382
+ y: "1",
383
+ width: "1.5",
384
+ height: "14",
385
+ rx: ".75"
386
+ }), /*#__PURE__*/React.createElement("rect", {
387
+ transform: "translate(8.000000, 8.000000) scale(-1, 1) rotate(-45.000000) translate(-8.000000, -8.000000)",
388
+ x: "7.25",
389
+ y: "1",
390
+ width: "1.5",
391
+ height: "14",
392
+ rx: ".75"
393
+ }))))))), /*#__PURE__*/React.createElement("div", {
394
+ className: "".concat(prefixCls, "-menu-drawer-body")
395
+ }, renderDrawerItems())), document.body));
396
+ }
@@ -0,0 +1,356 @@
1
+ .transition() {
2
+ transition: background-color 0.2s;
3
+ }
4
+
5
+ .@{prefixCls}-menu {
6
+ flex: 0 0 200px;
7
+ min-width: 0;
8
+ height: 100%;
9
+ padding: 16px 0;
10
+ white-space: nowrap;
11
+ transition: flex 0.1s;
12
+
13
+ &-collapsed {
14
+ flex: 0 0 52px;
15
+ }
16
+
17
+ &-bar {
18
+ position: relative;
19
+ z-index: 3;
20
+ box-sizing: border-box;
21
+ width: 100%;
22
+ background: #f2f2f2;
23
+ }
24
+
25
+ &-collapse {
26
+ position: absolute;
27
+ right: 0;
28
+ z-index: 1;
29
+ box-sizing: content-box;
30
+ width: 20px;
31
+ height: 20px;
32
+ padding: 12px;
33
+ color: #333;
34
+ transform: rotate(180deg);
35
+ cursor: pointer;
36
+
37
+ &:hover {
38
+ color: .primary() [];
39
+ }
40
+ }
41
+
42
+ &-collapsed &-collapse {
43
+ position: static;
44
+ padding: 12px 16px;
45
+ transform: rotate(0);
46
+ }
47
+
48
+ &-collapsed &-top-item {
49
+ margin: 0;
50
+ padding: 0 16px;
51
+ }
52
+
53
+ &-collapsed &-popup {
54
+ left: 52px;
55
+ }
56
+
57
+ &-top-item {
58
+ display: flex;
59
+ align-items: center;
60
+ box-sizing: border-box;
61
+ height: 44px;
62
+ margin: 0 12px;
63
+ padding: 0 4px;
64
+ overflow: hidden;
65
+ color: #333;
66
+ font-size: 14px;
67
+ border-radius: 8px;
68
+ cursor: pointer;
69
+ .transition();
70
+
71
+ &:hover,
72
+ &-popover-active {
73
+ background: #e6e6e6;
74
+ }
75
+
76
+ &-active {
77
+ font-weight: 500;
78
+ background-color: #e6e6e6;
79
+
80
+ &::before {
81
+ position: absolute;
82
+ top: 50%;
83
+ left: 0;
84
+ display: block;
85
+ width: 2px;
86
+ height: 14px;
87
+ margin-top: -7px;
88
+ content: '';
89
+ }
90
+ }
91
+ }
92
+
93
+ &-icon {
94
+ width: 20px;
95
+ height: 20px;
96
+ margin-right: 8px;
97
+ font-size: 16px;
98
+ opacity: 0.7;
99
+ }
100
+
101
+ &-top-item-active &-icon {
102
+ opacity: 1;
103
+ }
104
+
105
+ &-title {
106
+ overflow: hidden;
107
+ white-space: nowrap;
108
+ text-overflow: ellipsis;
109
+ }
110
+
111
+ &-popup {
112
+ position: absolute;
113
+ top: 0;
114
+ left: 200px;
115
+ z-index: 2;
116
+ transition: left 0.1s;
117
+
118
+ &-body {
119
+ position: relative;
120
+ z-index: 1;
121
+ display: flex;
122
+ margin-left: 4px;
123
+ padding: 8px;
124
+ background: #f9f9f9;
125
+ border-radius: 10px;
126
+ box-shadow: 0 12px 48px 16px rgba(0, 0, 0, 0.03), 0 9px 28px 0 rgba(0, 0, 0, 0.05),
127
+ 0 6px 16px -8px rgba(0, 0, 0, 0.08);
128
+ transform: translate3d(-40px, 0, 0);
129
+ opacity: 0;
130
+ transition: all 0.2s;
131
+ }
132
+
133
+ &.animated &-body {
134
+ transform: translate3d(0, 0, 0);
135
+ opacity: 1;
136
+ }
137
+ }
138
+
139
+ &-block {
140
+ display: inline-block;
141
+
142
+ &-empty {
143
+ display: flex;
144
+ flex-direction: column;
145
+ align-items: center;
146
+ justify-content: center;
147
+ height: 100%;
148
+ padding: 0 16px;
149
+ writing-mode: horizontal-tb;
150
+
151
+ & > span {
152
+ color: rgba(51, 51, 51, 0.65);
153
+ font-size: 12px;
154
+ }
155
+ }
156
+ }
157
+
158
+ &-sub-item {
159
+ box-sizing: border-box;
160
+ width: 120px;
161
+ height: 40px;
162
+ padding: 0 16px;
163
+ color: rgba(51, 51, 51, 0.5);
164
+ font-size: 14px;
165
+ line-height: 40px;
166
+ }
167
+
168
+ &-item {
169
+ display: flex;
170
+ align-items: center;
171
+ justify-content: space-between;
172
+ box-sizing: border-box;
173
+ width: 120px;
174
+ height: 40px;
175
+ padding: 0 16px;
176
+ color: rgba(51, 51, 51, 1);
177
+ font-size: 14px;
178
+ line-height: 40px;
179
+ border-radius: 8px;
180
+ cursor: pointer;
181
+ .transition();
182
+
183
+ &:hover {
184
+ background-color: #e6e6e6;
185
+ }
186
+
187
+ &-favorite {
188
+ display: none;
189
+
190
+ &-active {
191
+ display: block;
192
+ }
193
+
194
+ & > svg {
195
+ display: block;
196
+ }
197
+ }
198
+
199
+ &:hover &-favorite {
200
+ display: block;
201
+ }
202
+ }
203
+
204
+ &-gutter {
205
+ height: 1px;
206
+ margin: 12px 0 16px 12px;
207
+ background-color: rgba(196, 196, 196, 0.2);
208
+ }
209
+
210
+ &-collapsed &-gutter {
211
+ margin: 0 12px;
212
+ }
213
+
214
+ &-label {
215
+ margin: 0 0 12px 12px;
216
+ color: rgba(0, 0, 0, 0.5);
217
+ font-weight: 400;
218
+ font-size: 14px;
219
+ line-height: 22px;
220
+ }
221
+
222
+ &-more {
223
+ display: flex;
224
+ align-items: center;
225
+ justify-content: center;
226
+ box-sizing: border-box;
227
+ width: 107px;
228
+ height: 36px;
229
+ margin-left: 12px;
230
+ color: rgba(5, 96, 253, 1);
231
+ font-size: 14px;
232
+ text-align: center;
233
+ background-color: #fff;
234
+ border: 1px solid rgba(5, 96, 253, 1);
235
+ border-radius: 4px;
236
+ cursor: pointer;
237
+ user-select: none;
238
+ .transition();
239
+
240
+ &:hover {
241
+ background-color: rgba(222, 234, 255, 1);
242
+ }
243
+
244
+ & > span {
245
+ margin-left: 8px;
246
+ }
247
+ }
248
+
249
+ &-drawer {
250
+ position: absolute;
251
+ top: 0;
252
+ right: 0;
253
+ z-index: 10;
254
+ width: 740px;
255
+ height: 100vh;
256
+ background-color: #fff;
257
+ 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);
259
+ transform: translate3d(60px, 0, 0);
260
+ opacity: 0;
261
+ transition: all 0.2s;
262
+
263
+ &.animated {
264
+ transform: translate3d(0, 0, 0);
265
+ opacity: 1;
266
+ }
267
+
268
+ &-header {
269
+ display: flex;
270
+ align-items: center;
271
+ justify-content: space-between;
272
+ height: 56px;
273
+ padding: 0 24px;
274
+ color: #333;
275
+ font-weight: 500;
276
+ font-size: 16px;
277
+ border-bottom: 1px solid rgba(0, 0, 0, 0.08);
278
+ }
279
+
280
+ &-body {
281
+ height: calc(100vh - 56px);
282
+ padding: 16px;
283
+ overflow-x: hidden;
284
+ overflow-y: auto;
285
+ }
286
+
287
+ &-col {
288
+ display: inline-block;
289
+ width: 33.33333333%;
290
+ vertical-align: top;
291
+ }
292
+
293
+ .item() {
294
+ height: 44px;
295
+ padding: 0 16px;
296
+ font-size: 14px;
297
+ line-height: 44px;
298
+ }
299
+
300
+ &-1 {
301
+ color: rgba(51, 51, 51, 1);
302
+ font-weight: 500;
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
+ }
314
+ }
315
+
316
+ &-2 {
317
+ color: rgba(51, 51, 51, 0.5);
318
+ font-weight: 500;
319
+ .item();
320
+ }
321
+
322
+ &-3 {
323
+ color: rgba(51, 51, 51, 1);
324
+ cursor: pointer;
325
+ .item();
326
+ .transition();
327
+
328
+ &:hover {
329
+ color: rgba(5, 96, 253, 1);
330
+ background-color: rgba(238, 238, 238, 1);
331
+ }
332
+ }
333
+
334
+ &-block {
335
+ padding: 8px;
336
+
337
+ & > div {
338
+ overflow: hidden;
339
+ background-color: rgba(238, 238, 238, 0.5);
340
+ border-radius: 8px;
341
+ }
342
+ }
343
+
344
+ &-close {
345
+ cursor: pointer;
346
+
347
+ &:hover {
348
+ color: rgba(5, 96, 253, 1);
349
+ }
350
+ }
351
+ }
352
+
353
+ &-active {
354
+ color: rgba(5, 96, 253, 1);
355
+ }
356
+ }
@@ -0,0 +1,8 @@
1
+ export default function TabBar<T extends {
2
+ title: string;
3
+ }>(props: {
4
+ tabs: T[];
5
+ active: number;
6
+ onClick: (active: number) => void;
7
+ onClose: (active: number) => void;
8
+ }): JSX.Element;
@@ -0,0 +1,61 @@
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
+ export default function TabBar(props) {
7
+ var tabs = props.tabs,
8
+ active = props.active,
9
+ _onClick = props.onClick,
10
+ onClose = props.onClose;
11
+
12
+ var handleClose = function handleClose(e, index) {
13
+ e.stopPropagation();
14
+ onClose(index);
15
+ };
16
+
17
+ return /*#__PURE__*/React.createElement("div", {
18
+ className: "".concat(prefixCls, "-nav-tabs")
19
+ }, tabs.map(function (item, index) {
20
+ var key = item.title;
21
+ return /*#__PURE__*/React.createElement("div", {
22
+ className: classNames("".concat(prefixCls, "-nav-tab"), _defineProperty({}, "".concat(prefixCls, "-nav-tab-active"), index === active)),
23
+ onClick: function onClick() {
24
+ return _onClick(index);
25
+ },
26
+ key: key
27
+ }, /*#__PURE__*/React.createElement("div", {
28
+ className: "".concat(prefixCls, "-nav-tab-title")
29
+ }, /*#__PURE__*/React.createElement("div", {
30
+ className: "".concat(prefixCls, "-nav-tab-inner")
31
+ }, item.title), /*#__PURE__*/React.createElement("div", {
32
+ className: "".concat(prefixCls, "-nav-tab-close"),
33
+ onClick: function onClick(e) {
34
+ return handleClose(e, index);
35
+ }
36
+ }, /*#__PURE__*/React.createElement("svg", {
37
+ width: "10",
38
+ height: "10",
39
+ viewBox: "0 0 9 9",
40
+ xmlns: "http://www.w3.org/2000/svg"
41
+ }, /*#__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
+ }))))));
60
+ }));
61
+ }
@@ -0,0 +1,139 @@
1
+ .@{prefixCls}-nav-tabs {
2
+ position: relative;
3
+ display: flex;
4
+ flex-wrap: nowrap;
5
+ align-items: flex-end;
6
+ padding: 7px 16px 0;
7
+ overflow-x: hidden;
8
+
9
+ &::before {
10
+ position: absolute;
11
+ top: 0;
12
+ left: 6px;
13
+ z-index: 4;
14
+ display: block;
15
+ width: 10px;
16
+ height: 100%;
17
+ background-color: #fff;
18
+ border-bottom-right-radius: 10px;
19
+ content: '';
20
+ }
21
+
22
+ &::after {
23
+ position: absolute;
24
+ top: 0;
25
+ right: 6px;
26
+ z-index: 4;
27
+ display: block;
28
+ width: 10px;
29
+ height: 100%;
30
+ background-color: #fff;
31
+ border-bottom-left-radius: 10px;
32
+ content: '';
33
+ }
34
+ }
35
+
36
+ .@{prefixCls}-nav-tab {
37
+ position: relative;
38
+ box-sizing: content-box;
39
+ min-width: 14px;
40
+ max-width: 120px;
41
+ height: 49px;
42
+ cursor: pointer;
43
+
44
+ &::before {
45
+ position: absolute;
46
+ top: 15px;
47
+ left: 0;
48
+ z-index: 5;
49
+ display: block;
50
+ width: 1px;
51
+ height: 12px;
52
+ background-color: #c4c4c4;
53
+ opacity: 0.2;
54
+ content: '';
55
+ }
56
+
57
+ &::after {
58
+ position: absolute;
59
+ right: -10px;
60
+ bottom: 0;
61
+ left: -10px;
62
+ z-index: 1;
63
+ display: block;
64
+ height: 10px;
65
+ background-color: #fff;
66
+ transition: background-color 0.2s;
67
+ content: '';
68
+ }
69
+
70
+ &-title {
71
+ position: relative;
72
+ z-index: 4;
73
+ display: flex;
74
+ align-items: center;
75
+ padding: 10px 10px 17px;
76
+ background-color: #fff;
77
+ border-radius: 10px;
78
+ transition: background-color 0.2s;
79
+ }
80
+
81
+ &:hover:not(&-active) &-title,
82
+ &:hover:not(&-active)::after {
83
+ background-color: #f9f9f9;
84
+ }
85
+
86
+ &-active &-title,
87
+ &-active::after {
88
+ background-color: #f2f2f2;
89
+ }
90
+
91
+ &:hover::after {
92
+ z-index: 2;
93
+ }
94
+
95
+ &-active::after {
96
+ z-index: 3;
97
+ }
98
+
99
+ &-active::before,
100
+ &-active + &::before,
101
+ &:hover::before,
102
+ &:hover + &::before {
103
+ opacity: 0;
104
+ }
105
+
106
+ &-active &-inner {
107
+ opacity: 1;
108
+ }
109
+
110
+ &-inner {
111
+ flex: 1;
112
+ min-width: 0;
113
+ overflow: hidden;
114
+ color: #333;
115
+ font-size: 14px;
116
+ line-height: 22px;
117
+ white-space: nowrap;
118
+ text-overflow: ellipsis;
119
+ opacity: 0.7;
120
+
121
+ &::after {
122
+ display: inline-block;
123
+ width: 16px;
124
+ content: ' ';
125
+ }
126
+ }
127
+
128
+ &-close {
129
+ width: 14px;
130
+ height: 14px;
131
+ line-height: 14px;
132
+ text-align: center;
133
+ border-radius: 50%;
134
+
135
+ &:hover {
136
+ background-color: rgba(0, 0, 0, 0.15);
137
+ }
138
+ }
139
+ }
@@ -0,0 +1,18 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ import type { MenuItem } from './typings';
3
+ interface Props<T> {
4
+ active: number;
5
+ tabs: T[];
6
+ menus: MenuItem[];
7
+ onTabClick: (index: number) => void;
8
+ onTabClose: (index: number) => void;
9
+ onMenuClick: (menu: MenuItem) => void;
10
+ right?: ReactNode;
11
+ children?: ReactNode;
12
+ logo?: string | false | ReactElement;
13
+ title: string | ReactNode;
14
+ }
15
+ export default function MainFramework<TabType extends {
16
+ title: string;
17
+ }>(props: Props<TabType>): JSX.Element;
18
+ export {};
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import TabBar from './components/TabBar';
3
+ import Menu from './components/Menu';
4
+ import { PREFIX_CLS as prefixCls } from '../constants';
5
+ export default function MainFramework(props) {
6
+ var tabs = props.tabs,
7
+ active = props.active,
8
+ children = props.children,
9
+ right = props.right,
10
+ menus = props.menus,
11
+ onTabClick = props.onTabClick,
12
+ onMenuClick = props.onMenuClick,
13
+ onTabClose = props.onTabClose,
14
+ logo = props.logo,
15
+ title = props.title;
16
+ return /*#__PURE__*/React.createElement("div", {
17
+ className: "".concat(prefixCls, "-main")
18
+ }, /*#__PURE__*/React.createElement("div", {
19
+ className: "".concat(prefixCls, "-nav")
20
+ }, /*#__PURE__*/React.createElement("div", {
21
+ className: "".concat(prefixCls, "-nav-left")
22
+ }, logo !== false && /*#__PURE__*/React.createElement("div", {
23
+ className: "".concat(prefixCls, "-nav-logo")
24
+ }, typeof logo === 'string' ? /*#__PURE__*/React.createElement("img", {
25
+ src: logo
26
+ }) : logo || /*#__PURE__*/React.createElement("svg", {
27
+ width: "15",
28
+ height: "22",
29
+ xmlns: "http://www.w3.org/2000/svg"
30
+ }, /*#__PURE__*/React.createElement("g", {
31
+ fill: "currentColor",
32
+ fillRule: "nonzero"
33
+ }, /*#__PURE__*/React.createElement("path", {
34
+ d: "M3.403 10.313c.194-.163.393-.324.6-.481 1.47-1.123 2.592-2.339 3.333-3.622a7.805 7.805 0 0 0 1.101-4.036L8.427.966C8.159.657 7.906.335 7.67 0c-.26.384-.544.752-.849 1.103a15.52 15.52 0 0 1-2.336 2.165C2.853 4.514 1.67 5.858.938 7.28c.563 1.06 1.391 2.073 2.461 3.027M3.602 12.008a17.318 17.318 0 0 1-.835-.711C1.782 10.4.99 9.44.402 8.437a8.004 8.004 0 0 0 .362 5.91c.677 1.448 1.812 2.814 3.375 4.053.502.398.981.828 1.434 1.288v-.264a8.913 8.913 0 0 1 .99-4.146c-.687-1.157-1.683-2.256-2.96-3.276M11.025 12.036c-1.482 1.092-2.611 2.27-3.355 3.51a7.355 7.355 0 0 0-1.107 3.91l.008 1.173c.272.298.528.61.764.933.263-.372.549-.73.856-1.07a15.398 15.398 0 0 1 2.346-2.098c2.984-2.196 4.486-4.693 4.463-7.42a7.134 7.134 0 0 0-.489-2.537c-.802 1.278-1.971 2.484-3.486 3.597M11.353 9.828c.186.156.371.317.553.485.945-.983 1.668-2.02 2.156-3.096-.675-1.429-1.765-2.778-3.239-4.01-.496-.411-.968-.856-1.414-1.332v.268a9.617 9.617 0 0 1-.972 4.298c.68 1.201 1.661 2.34 2.917 3.387"
35
+ })))), /*#__PURE__*/React.createElement("div", {
36
+ className: "".concat(prefixCls, "-nav-title")
37
+ }, title)), /*#__PURE__*/React.createElement(TabBar, {
38
+ tabs: tabs,
39
+ active: active,
40
+ onClick: onTabClick,
41
+ onClose: onTabClose
42
+ }), /*#__PURE__*/React.createElement("div", {
43
+ className: "".concat(prefixCls, "-nav-right")
44
+ }, right)), /*#__PURE__*/React.createElement("div", {
45
+ className: "".concat(prefixCls, "-body")
46
+ }, /*#__PURE__*/React.createElement(Menu, {
47
+ data: menus,
48
+ onClick: onMenuClick
49
+ }), /*#__PURE__*/React.createElement("div", {
50
+ className: "".concat(prefixCls, "-content")
51
+ }, children)));
52
+ }
@@ -0,0 +1,88 @@
1
+ @import './components/Menu/index.less';
2
+ @import './components/TabBar/index.less';
3
+
4
+ .@{prefixCls}-main {
5
+ display: flex;
6
+ flex-direction: column;
7
+ width: 100vw;
8
+ min-width: 768px;
9
+ height: 100vh;
10
+ background: #f2f2f2;
11
+ }
12
+
13
+ .@{prefixCls}-nav {
14
+ position: relative;
15
+ z-index: 4;
16
+ display: flex;
17
+ align-items: center;
18
+ box-sizing: border-box;
19
+ width: 100vw;
20
+ height: 56px;
21
+ padding: 0 16px;
22
+ background: #ffff;
23
+
24
+ &-logo {
25
+ display: flex;
26
+ align-items: center;
27
+ justify-content: center;
28
+ height: 24px;
29
+ margin-right: 8px;
30
+ color: .primary(1) [];
31
+
32
+ & > img {
33
+ display: block;
34
+ height: 24px;
35
+ margin: 0 auto;
36
+ }
37
+ }
38
+
39
+ &-title {
40
+ color: #000;
41
+ font-weight: 500;
42
+ font-size: 16px;
43
+ }
44
+
45
+ &-left,
46
+ &-right {
47
+ display: flex;
48
+ align-items: center;
49
+ }
50
+
51
+ &-left {
52
+ flex: 0 0 184px;
53
+ box-sizing: border-box;
54
+ }
55
+
56
+ &-right {
57
+ justify-content: flex-end;
58
+ min-width: 180px;
59
+ margin-left: auto;
60
+ }
61
+ }
62
+
63
+ .@{prefixCls}-body {
64
+ position: relative;
65
+ display: flex;
66
+ flex: 1;
67
+ min-height: 0;
68
+ }
69
+
70
+ .@{prefixCls}-content {
71
+ position: relative;
72
+ z-index: 1;
73
+ flex: 1;
74
+ min-width: 0;
75
+
76
+ &-loading {
77
+ position: absolute;
78
+ top: 0;
79
+ left: 0;
80
+ z-index: 1;
81
+ }
82
+
83
+ & > div {
84
+ width: 100%;
85
+ height: 100%;
86
+ overflow: auto;
87
+ }
88
+ }
@@ -0,0 +1,6 @@
1
+ export type MenuItem = {
2
+ name: string;
3
+ path?: string;
4
+ icon?: string;
5
+ children?: MenuItem[];
6
+ };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { OperationType, TreeData } from './typings';
3
2
  interface Props<T> {
4
3
  node: TreeData<T>;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { TableProps } from './typings';
3
2
  export default function Table<RecordType extends Record<string, any>>(props: TableProps<RecordType>): JSX.Element;
package/es/index.d.ts CHANGED
@@ -17,5 +17,6 @@ export { default as Popup } from './Popup';
17
17
  export { default as SiderTree } from './SiderTree';
18
18
  export { default as Icons } from './Icons';
19
19
  export { default as FormLayout } from './FormLayout';
20
+ export { default as MainFramework } from './MainFramework';
20
21
  export { default as init } from './init';
21
22
  export * from './constants';
package/es/index.js CHANGED
@@ -13,5 +13,6 @@ export { default as Popup } from './Popup';
13
13
  export { default as SiderTree } from './SiderTree';
14
14
  export { default as Icons } from './Icons';
15
15
  export { default as FormLayout } from './FormLayout';
16
+ export { default as MainFramework } from './MainFramework';
16
17
  export { default as init } from './init';
17
18
  export * from './constants';
package/es/index.less CHANGED
@@ -1,3 +1,5 @@
1
+ @import '~antd/dist/antd.variable.less';
2
+ @import './theme.less';
1
3
  @import './Actions/index.less';
2
4
  @import './Layout/index.less';
3
5
  @import './Section/index.less';
@@ -12,7 +14,7 @@
12
14
  @import './FormLayout/index.less';
13
15
  @import './EditableTable/index.less';
14
16
  @import './PageLoading/index.less';
15
- @import '~antd/dist/antd.variable.less';
17
+ @import './MainFramework/index.less';
16
18
 
17
19
  @blue-base: #2357df;
18
20
 
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "0.0.0",
4
- "private": false,
3
+ "version": "0.0.3",
5
4
  "description": "> TODO: description",
6
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
7
6
  "homepage": "",
@@ -10,14 +9,11 @@
10
9
  "files": [
11
10
  "es"
12
11
  ],
13
- "publishConfig": {
14
- "@lemon-fe:registry": "https://registry.npmjs.org"
15
- },
16
12
  "scripts": {
17
13
  "test": "echo \"Error: run tests from root\" && exit 1"
18
14
  },
19
15
  "dependencies": {
20
- "@lemon-fe/hooks": "^0.0.0",
16
+ "@lemon-fe/hooks": "^0.0.3",
21
17
  "antd": "^4.17.0",
22
18
  "classnames": "^2.2.6",
23
19
  "lodash": "^4.17.21",
@@ -39,5 +35,6 @@
39
35
  "@types/color-string": "^1.5.2",
40
36
  "@types/lodash": "^4.14.179",
41
37
  "@types/react-resizable": "^1.7.4"
42
- }
38
+ },
39
+ "gitHead": "4793be25184347a233655cd67038427b79767c46"
43
40
  }