@lemon-fe/components 0.0.21 → 0.0.25

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;
@@ -5,7 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
5
5
  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; }
6
6
 
7
7
  import React, { useContext, useMemo } from 'react';
8
- import { FormContext } from 'antd/lib/form/context';
8
+ import { FormContext } from 'antd/es/form/context';
9
9
  import { PREFIX_CLS } from '../constants';
10
10
 
11
11
  function FormHorizontal(props) {
@@ -13,7 +13,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
13
13
 
14
14
  import React, { useContext, useMemo } from 'react';
15
15
  import { Row, Col } from 'antd';
16
- import { FormContext } from 'antd/lib/form/context';
16
+ import { FormContext } from 'antd/es/form/context';
17
17
  import { PREFIX_CLS } from '../constants';
18
18
 
19
19
  function FormInline(props) {
@@ -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
+ }
@@ -171,7 +171,7 @@
171
171
  font-weight: 400;
172
172
  font-size: 14px;
173
173
  line-height: 22px;
174
- opacity: 50%;
174
+ opacity: 0.5;
175
175
  }
176
176
  }
177
177
 
@@ -267,7 +267,7 @@
267
267
  font-weight: 400;
268
268
  font-size: 14px;
269
269
  line-height: 22px;
270
- opacity: 50%;
270
+ opacity: 0.5;
271
271
  }
272
272
 
273
273
  &-more {
@@ -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,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,
@@ -15,10 +29,45 @@ export default function MainFramework(props) {
15
29
  title = props.title,
16
30
  favorites = props.favorites,
17
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]);
18
66
  return /*#__PURE__*/React.createElement("div", {
19
67
  className: "".concat(prefixCls, "-main")
20
68
  }, /*#__PURE__*/React.createElement("div", {
21
- className: "".concat(prefixCls, "-nav")
69
+ className: "".concat(prefixCls, "-nav"),
70
+ ref: tabRef
22
71
  }, /*#__PURE__*/React.createElement("div", {
23
72
  className: "".concat(prefixCls, "-nav-left")
24
73
  }, logo !== false && /*#__PURE__*/React.createElement("div", {
@@ -43,7 +92,13 @@ export default function MainFramework(props) {
43
92
  onClose: onTabClose
44
93
  }), /*#__PURE__*/React.createElement("div", {
45
94
  className: "".concat(prefixCls, "-nav-right")
46
- }, 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", {
47
102
  className: "".concat(prefixCls, "-body")
48
103
  }, /*#__PURE__*/React.createElement(Menu, {
49
104
  data: menus,
@@ -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
  }
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.21",
3
+ "version": "0.0.25",
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.21",
19
+ "@lemon-fe/hooks": "^0.0.25",
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": "800cd94fab88bdc749dc65602b9d15abbb89691d"
42
+ "gitHead": "d4f76b96b8cd80a5c7d1fb357ffb0bd165683c91"
43
43
  }