@lemon-fe/components 0.0.0 → 0.0.1

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.
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { MenuItem } from '../../typings';
3
+ interface Props {
4
+ data: MenuItem[];
5
+ onClick: (item: MenuItem) => void;
6
+ }
7
+ export default function Menu(props: Props): JSX.Element;
8
+ export {};
@@ -0,0 +1,203 @@
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, { useMemo, useRef, useState } from 'react';
16
+ import classNames from 'classnames';
17
+ import { useDebounce } from '@lemon-fe/hooks';
18
+ import { PREFIX_CLS as prefixCls } from '../../../constants';
19
+ export default function Menu(props) {
20
+ var menus = props.data,
21
+ onClick = props.onClick;
22
+ var location = window.location;
23
+
24
+ var _useState = useState(null),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ popover = _useState2[0],
27
+ setPopover = _useState2[1];
28
+
29
+ var popup = useRef(null);
30
+
31
+ var _useState3 = useState(false),
32
+ _useState4 = _slicedToArray(_useState3, 2),
33
+ collapsed = _useState4[0],
34
+ setCollapsed = _useState4[1];
35
+
36
+ var _useState5 = useState(0),
37
+ _useState6 = _slicedToArray(_useState5, 2),
38
+ top = _useState6[0],
39
+ setTop = _useState6[1];
40
+
41
+ var activeMenu = useMemo(function () {
42
+ var check = function check(path) {
43
+ if (path) {
44
+ return new RegExp("".concat(path, "\\b")).test(location.pathname);
45
+ }
46
+
47
+ return false;
48
+ };
49
+
50
+ for (var i = 0; i < menus.length; i += 1) {
51
+ var _menus$i = menus[i],
52
+ _menus$i$children = _menus$i.children,
53
+ subMenus = _menus$i$children === void 0 ? [] : _menus$i$children,
54
+ topPath = _menus$i.path;
55
+
56
+ if (check(topPath)) {
57
+ return i;
58
+ }
59
+
60
+ for (var j = 0; j < subMenus.length; j += 1) {
61
+ var _subMenus$j = subMenus[j],
62
+ subPath = _subMenus$j.path,
63
+ _subMenus$j$children = _subMenus$j.children,
64
+ items = _subMenus$j$children === void 0 ? [] : _subMenus$j$children;
65
+
66
+ if (check(subPath)) {
67
+ return i;
68
+ }
69
+
70
+ for (var k = 0; k < items.length; k += 1) {
71
+ if (check(items[k].path)) {
72
+ return i;
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }, [location.pathname, menus]);
78
+
79
+ var openMenu = function openMenu(item, elm) {
80
+ if (item.children && item.children.length > 0) {
81
+ setPopover(item);
82
+ setTop(elm.offsetTop);
83
+ setTimeout(function () {
84
+ if (popup.current) {
85
+ popup.current.classList.add('animated');
86
+ }
87
+ }, 16);
88
+ }
89
+ };
90
+
91
+ var handleClick = function handleClick(item) {
92
+ if (item.path) {
93
+ setPopover(null);
94
+ onClick(item);
95
+ }
96
+ };
97
+
98
+ var handleMouseEnter = useDebounce(openMenu, 200);
99
+
100
+ var toggleMenu = function toggleMenu() {
101
+ setCollapsed(function (prev) {
102
+ return !prev;
103
+ });
104
+ };
105
+
106
+ var closeMenu = function closeMenu() {
107
+ handleMouseEnter.cancel();
108
+
109
+ if (popup.current) {
110
+ popup.current.classList.remove('animated');
111
+
112
+ var handler = function handler() {
113
+ var _popup$current;
114
+
115
+ setPopover(null);
116
+ (_popup$current = popup.current) === null || _popup$current === void 0 ? void 0 : _popup$current.removeEventListener('transitionend', handler);
117
+ };
118
+
119
+ popup.current.addEventListener('transitionend', handler);
120
+ }
121
+ };
122
+
123
+ var renderItem = function renderItem(item, index) {
124
+ return /*#__PURE__*/React.createElement("div", {
125
+ key: index,
126
+ className: "".concat(prefixCls, "-menu-item"),
127
+ onClick: function onClick() {
128
+ return handleClick(item);
129
+ }
130
+ }, item.name);
131
+ };
132
+
133
+ return /*#__PURE__*/React.createElement("div", {
134
+ className: classNames("".concat(prefixCls, "-menu"), _defineProperty({}, "".concat(prefixCls, "-menu-collapsed"), collapsed))
135
+ }, /*#__PURE__*/React.createElement("div", {
136
+ className: "".concat(prefixCls, "-menu-bar"),
137
+ onMouseLeave: closeMenu
138
+ }, popover !== null && popover.children !== undefined && /*#__PURE__*/React.createElement("div", {
139
+ className: "".concat(prefixCls, "-menu-popup"),
140
+ style: {
141
+ top: top
142
+ },
143
+ ref: popup,
144
+ onMouseEnter: function onMouseEnter() {
145
+ return handleMouseEnter.cancel();
146
+ }
147
+ }, /*#__PURE__*/React.createElement("div", {
148
+ className: "".concat(prefixCls, "-menu-popup-body")
149
+ }, popover.children.map(function (item, index) {
150
+ return /*#__PURE__*/React.createElement("div", {
151
+ className: "".concat(prefixCls, "-menu-block"),
152
+ key: index
153
+ }, /*#__PURE__*/React.createElement("div", {
154
+ className: "".concat(prefixCls, "-menu-sub-item")
155
+ }, item.name), item.children !== undefined && item.children.map(renderItem));
156
+ }))), /*#__PURE__*/React.createElement("div", {
157
+ className: "".concat(prefixCls, "-menu-collapse"),
158
+ onClick: toggleMenu
159
+ }, /*#__PURE__*/React.createElement("svg", {
160
+ width: "20",
161
+ height: "20",
162
+ xmlns: "http://www.w3.org/2000/svg"
163
+ }, /*#__PURE__*/React.createElement("g", {
164
+ fill: "none",
165
+ fillRule: "evenodd",
166
+ opacity: ".7"
167
+ }, /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("path", {
168
+ 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",
169
+ fill: "currentColor",
170
+ transform: "translate(-274.000000, -57.000000) translate(284.000000, 67.000000) scale(-1, 1) translate(-284.000000, -67.000000) translate(274.000000, 57.000000)"
171
+ }), /*#__PURE__*/React.createElement("path", {
172
+ 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",
173
+ fill: "currentColor",
174
+ "fill-rule": "nonzero",
175
+ transform: "translate(-274.000000, -57.000000) translate(284.000000, 67.000000) scale(-1, 1) translate(-284.000000, -67.000000) translate(274.000000, 57.000000)"
176
+ }), /*#__PURE__*/React.createElement("path", {
177
+ d: "M11.7426212,6.79290128 L5.32842371,6.79290128 L5.32842371,13.2070987",
178
+ stroke: "currentColor",
179
+ strokeWidth: "1.5",
180
+ strokeLinecap: "round",
181
+ strokeLinejoin: "round",
182
+ strokeDasharray: "0,0",
183
+ 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)"
184
+ })))))), menus.map(function (item, index) {
185
+ var _classNames2;
186
+
187
+ return /*#__PURE__*/React.createElement("div", {
188
+ key: index,
189
+ className: classNames("".concat(prefixCls, "-menu-top-item"), (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-menu-top-item-active"), index === activeMenu), _defineProperty(_classNames2, "".concat(prefixCls, "-menu-top-item-popover-active"), item === popover), _classNames2)),
190
+ onClick: function onClick() {
191
+ return handleClick(item);
192
+ },
193
+ onMouseEnter: function onMouseEnter(e) {
194
+ return handleMouseEnter(item, e.currentTarget);
195
+ }
196
+ }, /*#__PURE__*/React.createElement("img", {
197
+ className: "".concat(prefixCls, "-menu-icon"),
198
+ src: item.icon
199
+ }), /*#__PURE__*/React.createElement("div", {
200
+ className: "".concat(prefixCls, "-menu-title")
201
+ }, item.name));
202
+ })));
203
+ }
@@ -0,0 +1,205 @@
1
+ .@{prefixCls}-menu {
2
+ flex: 0 0 200px;
3
+ min-width: 0;
4
+ height: 100%;
5
+ transition: flex 0.1s;
6
+
7
+ &-collapsed {
8
+ flex: 0 0 52px;
9
+ }
10
+
11
+ &-bar {
12
+ position: relative;
13
+ z-index: 3;
14
+ box-sizing: border-box;
15
+ width: 100%;
16
+ padding: 16px 0;
17
+ background: #f2f2f2;
18
+ }
19
+
20
+ &-collapse {
21
+ position: absolute;
22
+ right: 0;
23
+ z-index: 1;
24
+ box-sizing: content-box;
25
+ width: 20px;
26
+ height: 20px;
27
+ padding: 12px;
28
+ color: #333;
29
+ transform: rotate(180deg);
30
+ cursor: pointer;
31
+
32
+ &:hover {
33
+ color: .primary() [];
34
+ }
35
+ }
36
+
37
+ &-collapsed &-collapse {
38
+ position: static;
39
+ padding: 12px 16px;
40
+ transform: rotate(0);
41
+ }
42
+
43
+ &-collapsed &-top-item {
44
+ margin: 0;
45
+ padding: 0 16px;
46
+ }
47
+
48
+ &-collapsed &-title {
49
+ display: none;
50
+ }
51
+
52
+ &-collapsed &-popup {
53
+ left: 52px;
54
+ }
55
+
56
+ &-top-item {
57
+ box-sizing: border-box;
58
+ height: 44px;
59
+ margin: 0 12px;
60
+ padding: 0 4px;
61
+ overflow: hidden;
62
+ color: #333;
63
+ font-size: 14px;
64
+ line-height: 44px;
65
+ border-radius: 8px;
66
+ cursor: pointer;
67
+ transition: background-color 0.2s;
68
+
69
+ &:hover,
70
+ &-popover-active {
71
+ background: #e6e6e6;
72
+ }
73
+
74
+ &-active {
75
+ font-weight: 500;
76
+ background-color: #e6e6e6;
77
+
78
+ &::before {
79
+ position: absolute;
80
+ top: 50%;
81
+ left: 0;
82
+ display: block;
83
+ width: 2px;
84
+ height: 14px;
85
+ margin-top: -7px;
86
+ content: '';
87
+ }
88
+ }
89
+ }
90
+
91
+ &-icon {
92
+ display: inline-block;
93
+ width: 20px;
94
+ height: 20px;
95
+ margin-right: 8px;
96
+ font-size: 16px;
97
+ vertical-align: middle;
98
+ opacity: 0.7;
99
+ }
100
+
101
+ &-top-item-active &-icon {
102
+ opacity: 1;
103
+ }
104
+
105
+ &-title {
106
+ display: inline-block;
107
+ overflow: hidden;
108
+ white-space: nowrap;
109
+ text-overflow: ellipsis;
110
+ vertical-align: middle;
111
+ }
112
+
113
+ &-popup {
114
+ position: absolute;
115
+ top: 0;
116
+ left: 200px;
117
+ z-index: 2;
118
+ transition: left 0.1s;
119
+
120
+ &-body {
121
+ position: relative;
122
+ z-index: 1;
123
+ margin-left: 4px;
124
+ padding: 8px;
125
+ background: #f9f9f9;
126
+ border-radius: 10px;
127
+ box-shadow: 0 12px 48px 16px rgba(0, 0, 0, 0.03), 0 9px 28px 0 rgba(0, 0, 0, 0.05),
128
+ 0 6px 16px -8px rgba(0, 0, 0, 0.08);
129
+ transform: translate3d(-40px, 0, 0);
130
+ opacity: 0;
131
+ transition: all 0.3s;
132
+ }
133
+
134
+ &.animated &-body {
135
+ transform: translate3d(0, 0, 0);
136
+ opacity: 1;
137
+ }
138
+ }
139
+
140
+ &-block {
141
+ display: inline-block;
142
+
143
+ &-empty {
144
+ display: flex;
145
+ flex-direction: column;
146
+ align-items: center;
147
+ justify-content: center;
148
+ height: 100%;
149
+ padding: 0 16px;
150
+ writing-mode: horizontal-tb;
151
+
152
+ & > span {
153
+ color: rgba(51, 51, 51, 0.65);
154
+ font-size: 12px;
155
+ }
156
+ }
157
+ }
158
+
159
+ &-sub-item {
160
+ box-sizing: border-box;
161
+ width: 120px;
162
+ height: 40px;
163
+ padding: 0 16px;
164
+ color: #979797;
165
+ font-weight: 600;
166
+ font-size: 14px;
167
+ line-height: 40px;
168
+ }
169
+
170
+ &-item {
171
+ display: flex;
172
+ align-items: center;
173
+ justify-content: space-between;
174
+ box-sizing: border-box;
175
+ width: 120px;
176
+ height: 40px;
177
+ padding: 0 16px;
178
+ color: rgba(51, 51, 51, 0.85);
179
+ font-size: 14px;
180
+ line-height: 40px;
181
+ border-radius: 8px;
182
+ cursor: pointer;
183
+ transition: background-color 0.2s;
184
+
185
+ &:hover {
186
+ background-color: #e6e6e6;
187
+ }
188
+
189
+ &-favorite {
190
+ display: none;
191
+
192
+ &-active {
193
+ display: block;
194
+ }
195
+
196
+ & > svg {
197
+ display: block;
198
+ }
199
+ }
200
+
201
+ &:hover &-favorite {
202
+ display: block;
203
+ }
204
+ }
205
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export default function TabBar<T extends {
3
+ title: string;
4
+ }>(props: {
5
+ tabs: T[];
6
+ active: number;
7
+ onClick: (active: number) => void;
8
+ onClose: (active: number) => void;
9
+ }): 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
+ };
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.1",
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.1",
21
17
  "antd": "^4.17.0",
22
18
  "classnames": "^2.2.6",
23
19
  "lodash": "^4.17.21",