@lemon-fe/components 0.0.32 → 0.1.0

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.
Files changed (57) hide show
  1. package/es/Actions/index.d.ts +3 -2
  2. package/es/Actions/index.js +29 -28
  3. package/es/Actions/index.less +26 -51
  4. package/es/BaseTable/Actions.d.ts +8 -0
  5. package/es/BaseTable/Actions.js +119 -0
  6. package/es/BaseTable/ResizeHeaderCell.js +16 -5
  7. package/es/BaseTable/index.js +63 -19
  8. package/es/BaseTable/index.less +99 -0
  9. package/es/BaseTable/typings.d.ts +11 -0
  10. package/es/DurationPicker/index.js +2 -10
  11. package/es/DurationPicker/index.less +4 -4
  12. package/es/Filter/index.js +100 -41
  13. package/es/Filter/index.less +11 -7
  14. package/es/Filter/typings.d.ts +3 -2
  15. package/es/FormLayout/index.less +1 -1
  16. package/es/Icons/Calendar.d.ts +5 -0
  17. package/es/Icons/Calendar.js +47 -0
  18. package/es/Icons/Down.js +10 -5
  19. package/es/Icons/More.d.ts +5 -0
  20. package/es/Icons/More.js +44 -0
  21. package/es/Icons/Search.js +8 -12
  22. package/es/Icons/index.d.ts +4 -0
  23. package/es/Icons/index.js +5 -1
  24. package/es/Layout/index.js +80 -3
  25. package/es/Layout/index.less +69 -25
  26. package/es/MainFramework/components/DropMenu/index.less +2 -32
  27. package/es/MainFramework/components/Menu/index.less +2 -2
  28. package/es/MainFramework/components/RefreshButton/index.less +2 -32
  29. package/es/Portal/index.d.ts +12 -0
  30. package/es/Portal/index.js +72 -0
  31. package/es/Section/TabBar.d.ts +12 -0
  32. package/es/Section/TabBar.js +48 -0
  33. package/es/Section/index.js +38 -53
  34. package/es/Section/index.less +44 -91
  35. package/es/SiderTree/TreeNodeTitle.d.ts +1 -1
  36. package/es/SiderTree/TreeNodeTitle.js +17 -35
  37. package/es/SiderTree/index.d.ts +3 -1
  38. package/es/SiderTree/index.js +40 -64
  39. package/es/SiderTree/index.less +76 -75
  40. package/es/SymbolIcon/index.d.ts +8 -0
  41. package/es/SymbolIcon/index.js +32 -0
  42. package/es/SymbolIcon/index.less +7 -0
  43. package/es/TabBar/index.d.ts +14 -0
  44. package/es/TabBar/index.js +52 -0
  45. package/es/TabBar/index.less +31 -0
  46. package/es/index.d.ts +3 -1
  47. package/es/index.js +3 -1
  48. package/es/index.less +4 -35
  49. package/es/init.js +15 -16
  50. package/es/overrides.less +136 -0
  51. package/es/theme.less +1 -8
  52. package/es/utils.d.ts +2 -0
  53. package/es/utils.js +14 -0
  54. package/es/utils.less +53 -0
  55. package/package.json +3 -3
  56. package/es/BaseTable/Sort.d.ts +0 -10
  57. package/es/BaseTable/Sort.js +0 -122
@@ -3,8 +3,13 @@
3
3
  .@{prefixCls}-section {
4
4
  position: relative;
5
5
  width: 100%;
6
+ padding: @space;
6
7
  color: #333;
7
8
 
9
+ & + & {
10
+ padding-top: 0;
11
+ }
12
+
8
13
  &-flex {
9
14
  display: flex;
10
15
  flex-direction: column;
@@ -13,33 +18,33 @@
13
18
 
14
19
  &-flex &-body {
15
20
  flex: 1 1 100%;
16
- overflow: auto;
17
21
  }
18
22
 
19
23
  &-header {
20
24
  display: flex;
21
- margin-bottom: 8px;
25
+ align-items: flex-end;
26
+ margin-bottom: @space;
27
+ padding: 8px 0;
22
28
  }
23
29
 
24
30
  &-title {
25
31
  flex: 1;
26
- font-weight: bold;
27
- font-size: 14px;
28
- }
29
-
30
- &-with-actions &-header {
31
- align-items: flex-end;
32
+ font-weight: 500;
33
+ font-size: 16px;
34
+ line-height: 24px;
35
+
36
+ &::before {
37
+ display: inline-block;
38
+ width: 4px;
39
+ height: 16px;
40
+ margin-right: 8px;
41
+ vertical-align: -0.15em;
42
+ background-color: @primary-color;
43
+ content: '';
44
+ }
32
45
  }
33
46
 
34
47
  &-body {
35
- padding: @space;
36
- background-color: #fff;
37
- border-radius: 4px;
38
-
39
- & > .@{prefixCls}-actions {
40
- padding: 16px;
41
- }
42
-
43
48
  & > .@{prefixCls}-table {
44
49
  overflow: auto;
45
50
  border-radius: 6px 6px 0 0;
@@ -48,11 +53,14 @@
48
53
  &.ant-tabs-tabpane {
49
54
  border-top-left-radius: 0;
50
55
  }
56
+
57
+ & > .@{prefixCls}-filter:first-child {
58
+ margin-top: -16px;
59
+ }
51
60
  }
52
61
 
53
62
  &-footer {
54
63
  padding: 10px 0;
55
- background-color: #fff;
56
64
  }
57
65
 
58
66
  & > .ant-tabs {
@@ -68,97 +76,42 @@
68
76
  }
69
77
 
70
78
  &-tab {
71
- position: relative;
72
- left: 4px;
73
- display: flex;
79
+ display: inline-flex;
80
+ align-self: flex-start;
81
+ margin-bottom: 12px;
82
+ padding: 2px;
83
+ background-color: #f2f2f2;
84
+ border-radius: 4px;
74
85
 
75
86
  &-item {
76
87
  position: relative;
77
- z-index: 1;
78
- padding: 0 8px;
88
+ min-width: 88px;
89
+ padding: 6px 8px;
90
+ color: rgba(51, 51, 51, 0.65);
91
+ font-size: 14px;
92
+ line-height: 22px;
93
+ text-align: center;
94
+ background-color: transparent;
95
+ border-radius: 4px;
79
96
  cursor: pointer;
80
97
 
81
- &-content {
82
- position: relative;
83
- z-index: 2;
84
- height: 40px;
85
- padding: 0 8px;
86
- line-height: 40px;
87
- background: #ededed;
88
- }
89
-
90
- &-arc-left {
91
- position: absolute;
92
- top: 0;
93
- left: 0;
94
- z-index: 1;
95
- width: 16px;
96
- height: 40px;
97
- background: #ededed;
98
- transform-origin: 50% 50%;
99
- }
100
-
101
- &-arc-right {
102
- position: absolute;
103
- top: 0;
104
- right: 0;
105
- z-index: 1;
106
- width: 16px;
107
- height: 40px;
108
- background: #ededed;
109
- transform-origin: 50% 50%;
110
- }
111
-
112
98
  &-active {
113
- z-index: 2;
114
99
  color: .primary(1) [];
115
- }
116
-
117
- &-active &-content {
118
- background: #fff;
119
- }
120
-
121
- &-active &-arc-left {
122
- background: #fff;
123
- border-top-left-radius: 4px;
124
- transform: skew(-10deg);
125
- }
126
-
127
- &-active &-arc-right {
128
- background: #fff;
129
- border-top-right-radius: 4px;
130
- transform: skew(10deg);
131
- }
132
-
133
- &-active-left &-arc-right,
134
- &:last-child &-arc-right {
135
- border-top-right-radius: 4px;
136
- transform: skew(10deg);
137
- }
138
-
139
- &-active-right &-arc-left,
140
- &:first-child &-arc-left {
141
- border-top-left-radius: 4px;
142
- transform: skew(-10deg);
100
+ background-color: #fff;
143
101
  }
144
102
  }
145
103
 
146
- &-item + &-item::before {
104
+ &-item:not(&-item-active) + &-item:not(&-item-active)::before {
147
105
  position: absolute;
148
- top: 14px;
106
+ top: 12px;
149
107
  left: 0;
150
- z-index: 2;
108
+ z-index: 1;
151
109
  display: block;
152
110
  width: 1px;
153
111
  height: 12px;
154
- background: #dbdbdb;
112
+ background: #dfdfdf;
155
113
  content: '';
156
114
  }
157
-
158
- &-item-active::before,
159
- &-item-active-right::before {
160
- display: none !important;
161
- }
162
115
  }
163
116
  }
164
117
 
@@ -1,4 +1,4 @@
1
- import { OperationType, TreeData } from './typings';
1
+ import type { OperationType, TreeData } from './typings';
2
2
  interface Props<T> {
3
3
  node: TreeData<T>;
4
4
  prefixCls: string;
@@ -1,3 +1,5 @@
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
+
1
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
4
 
3
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."); }
@@ -12,6 +14,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
14
 
13
15
  import { Popover } from 'antd';
14
16
  import React, { useEffect, useRef, useState } from 'react';
17
+ import classNames from 'classnames';
15
18
  export default function TreeNodeTitle(props) {
16
19
  var _operation$others;
17
20
 
@@ -64,12 +67,12 @@ export default function TreeNodeTitle(props) {
64
67
  }, item.title), /*#__PURE__*/React.createElement("div", {
65
68
  className: "".concat(prefixCls, "-title-operators"),
66
69
  style: {
67
- display: visible || show ? 'flex' : 'none'
70
+ display: visible || show ? 'block' : 'none'
68
71
  },
69
72
  onClick: function onClick(e) {
70
73
  return e.stopPropagation();
71
74
  }
72
- }, others ? /*#__PURE__*/React.createElement(Popover, {
75
+ }, others || operation.onAdd ? /*#__PURE__*/React.createElement(Popover, {
73
76
  overlayClassName: "".concat(prefixCls, "-menu-popover"),
74
77
  placement: "bottomLeft",
75
78
  visible: visible,
@@ -78,47 +81,26 @@ export default function TreeNodeTitle(props) {
78
81
  onClick: function onClick() {
79
82
  return setVisible(false);
80
83
  }
81
- }, others),
84
+ }, operation.onAdd ? /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
85
+ onClick: function onClick() {
86
+ return operation.onAdd(item);
87
+ }
88
+ }, "\u65B0\u589E")) : null, others),
82
89
  onVisibleChange: setVisible
83
90
  }, /*#__PURE__*/React.createElement("div", {
84
- className: "".concat(prefixCls, "-title-operators-item"),
91
+ className: classNames("".concat(prefixCls, "-title-operators-item"), _defineProperty({}, "".concat(prefixCls, "-title-operators-item-active"), visible)),
85
92
  onClick: function onClick() {
86
93
  return setVisible(true);
87
94
  }
88
95
  }, /*#__PURE__*/React.createElement("svg", {
89
- width: "7",
90
- height: "7",
91
- xmlns: "http://www.w3.org/2000/svg"
92
- }, /*#__PURE__*/React.createElement("g", {
93
- fill: "currentColor",
94
- fillRule: "evenodd"
95
- }, /*#__PURE__*/React.createElement("circle", {
96
- cx: "3.5",
97
- cy: "3.5",
98
- r: "1"
99
- }), /*#__PURE__*/React.createElement("circle", {
100
- cx: ".5",
101
- cy: "3.5",
102
- r: "1"
103
- }), /*#__PURE__*/React.createElement("circle", {
104
- cx: "6.5",
105
- cy: "3.5",
106
- r: "1"
107
- }))))) : null, operation.onAdd ? /*#__PURE__*/React.createElement("div", {
108
- className: "".concat(prefixCls, "-title-operators-item"),
109
- onClick: function onClick() {
110
- return operation.onAdd(item);
111
- }
112
- }, /*#__PURE__*/React.createElement("svg", {
113
- width: "7",
114
- height: "7",
96
+ width: "20",
97
+ height: "20",
98
+ viewBox: "0 0 20 20",
115
99
  xmlns: "http://www.w3.org/2000/svg"
116
100
  }, /*#__PURE__*/React.createElement("g", {
117
- fill: "currentColor",
101
+ fill: "#333",
118
102
  fillRule: "evenodd"
119
103
  }, /*#__PURE__*/React.createElement("path", {
120
- d: "M0 3h7v1H0z"
121
- }), /*#__PURE__*/React.createElement("path", {
122
- d: "M4 0v7H3V0z"
123
- })))) : null));
104
+ d: "M10 4a1 1 0 1 1 0 2 1 1 0 0 1 0-2ZM10 9a1 1 0 1 1 0 2 1 1 0 0 1 0-2ZM10 14a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z"
105
+ }))))) : null));
124
106
  }
@@ -2,11 +2,12 @@ import { ReactNode } from 'react';
2
2
  import { TreeProps } from 'rc-tree';
3
3
  import type { DataNode, EventDataNode } from 'rc-tree/lib/interface';
4
4
  import { TabsProps } from 'antd';
5
- import { TreeData, OperationType } from './typings';
5
+ import type { TreeData, OperationType } from './typings';
6
6
  interface Props<KeyType> extends Omit<TreeProps, 'onSelect' | 'selectedKeys' | 'defaultSelectedKeys' | 'defaultExpandAll' | 'defaultExpandedKeys' | 'prefixCls'> {
7
7
  data?: TreeData<KeyType>[];
8
8
  showSearch?: boolean;
9
9
  placeholder?: string;
10
+ header?: ReactNode;
10
11
  operation?: OperationType<KeyType>;
11
12
  onSelect?: (node: TreeData<KeyType>, info: {
12
13
  event: 'select';
@@ -19,6 +20,7 @@ interface Props<KeyType> extends Omit<TreeProps, 'onSelect' | 'selectedKeys' | '
19
20
  defaultSelectedKeys?: KeyType[];
20
21
  defaultExpandAll?: boolean;
21
22
  defaultExpandedKeys?: KeyType[];
23
+ active?: boolean;
22
24
  }
23
25
  declare function SiderTreeTabs(props: {
24
26
  tabs: {
@@ -1,5 +1,5 @@
1
1
  var _excluded = ["tabs", "children"],
2
- _excluded2 = ["data", "showSearch", "placeholder", "onSelect", "operation"];
2
+ _excluded2 = ["data", "showSearch", "placeholder", "onSelect", "operation", "header"];
3
3
 
4
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
5
 
@@ -35,31 +35,17 @@ import React, { useMemo, useState } from 'react';
35
35
  import { useDebounce } from '@lemon-fe/hooks';
36
36
  import Tree from 'rc-tree';
37
37
  import { Empty, Input, Tabs } from 'antd';
38
- import classNames from 'classnames';
39
38
  import { PREFIX_CLS } from '../constants';
40
- import TreeNodeTitle from './TreeNodeTitle'; // 不使用Children.map的原因是由于它会给子节点生成一个key与tabs的activeTabKey无法对应
41
-
42
- var mapChildren = function mapChildren(children, cb) {
43
- var nodes = [];
44
-
45
- if (Array.isArray(children)) {
46
- nodes = children;
47
- } else {
48
- nodes = [children];
49
- }
50
-
51
- return nodes.filter(function (item) {
52
- return item !== null;
53
- }).map(cb);
54
- };
39
+ import TreeNodeTitle from './TreeNodeTitle';
40
+ import Icons from '../Icons';
41
+ import TabBar from '../TabBar';
42
+ import { mapChildren } from '../utils';
55
43
 
56
44
  function SiderTreeTabs(props) {
57
45
  var tabs = props.tabs,
58
46
  children = props.children,
59
47
  restProps = _objectWithoutProperties(props, _excluded);
60
48
 
61
- var prefixCls = "".concat(PREFIX_CLS, "-tree");
62
-
63
49
  var getKey = function getKey(item) {
64
50
  return item.key || item.title;
65
51
  };
@@ -67,24 +53,15 @@ function SiderTreeTabs(props) {
67
53
  return /*#__PURE__*/React.createElement(Tabs, _objectSpread(_objectSpread({}, restProps), {}, {
68
54
  renderTabBar: function renderTabBar(tabProps) {
69
55
  var activeKey = tabProps.activeKey,
70
- onTabClick = tabProps.onTabClick;
71
- var active = tabs.findIndex(function (item) {
72
- return getKey(item) === activeKey;
56
+ _onTabClick = tabProps.onTabClick;
57
+ return /*#__PURE__*/React.createElement(TabBar, {
58
+ className: "".concat(PREFIX_CLS, "-tree-tab-bar"),
59
+ activeKey: activeKey,
60
+ tabs: tabs,
61
+ onTabClick: function onTabClick(key, _, e) {
62
+ return _onTabClick(key, e);
63
+ }
73
64
  });
74
- return /*#__PURE__*/React.createElement("div", {
75
- className: "".concat(prefixCls, "-tabs")
76
- }, tabs.map(function (item, index) {
77
- var key = getKey(item);
78
- return /*#__PURE__*/React.createElement("div", {
79
- key: key,
80
- className: classNames("".concat(prefixCls, "-tab"), _defineProperty({}, "".concat(prefixCls, "-tab-active"), active === index)),
81
- onClick: function onClick(e) {
82
- if (active !== index && key !== null) {
83
- onTabClick(key, e);
84
- }
85
- }
86
- }, item.title);
87
- }));
88
65
  }
89
66
  }), mapChildren(children, function (child, index) {
90
67
  var tab = tabs[index];
@@ -98,10 +75,11 @@ function SiderTreeTabs(props) {
98
75
  export default function SiderTree(props) {
99
76
  var _props$data = props.data,
100
77
  mData = _props$data === void 0 ? [] : _props$data,
101
- mShowSearch = props.showSearch,
102
- mPlaceholder = props.placeholder,
78
+ showSearch = props.showSearch,
79
+ placeholder = props.placeholder,
103
80
  _onSelect = props.onSelect,
104
81
  operation = props.operation,
82
+ header = props.header,
105
83
  restProps = _objectWithoutProperties(props, _excluded2);
106
84
 
107
85
  var prefixCls = "".concat(PREFIX_CLS, "-tree");
@@ -158,35 +136,33 @@ export default function SiderTree(props) {
158
136
  var handleChange = useDebounce(function (value) {
159
137
  setKeywords(value);
160
138
  }, 300);
139
+ var mHeader = header;
140
+
141
+ if (!header && showSearch) {
142
+ mHeader = /*#__PURE__*/React.createElement(Input, {
143
+ defaultValue: keywords,
144
+ allowClear: true,
145
+ onChange: function onChange(e) {
146
+ return handleChange(e.currentTarget.value);
147
+ },
148
+ placeholder: placeholder,
149
+ prefix: /*#__PURE__*/React.createElement(Icons.Search, null)
150
+ });
151
+ }
152
+
161
153
  return /*#__PURE__*/React.createElement("div", {
162
154
  className: "".concat(prefixCls, "-wrapper")
163
- }, mShowSearch ? /*#__PURE__*/React.createElement(Input, {
164
- allowClear: true,
165
- onChange: function onChange(e) {
166
- return handleChange(e.currentTarget.value);
167
- },
168
- placeholder: mPlaceholder,
169
- suffix: /*#__PURE__*/React.createElement("svg", {
170
- width: "15",
171
- height: "15",
172
- xmlns: "http://www.w3.org/2000/svg"
173
- }, /*#__PURE__*/React.createElement("g", {
174
- fill: "#686868",
175
- fillRule: "evenodd"
176
- }, /*#__PURE__*/React.createElement("path", {
177
- d: "M6.5 12a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11Zm0 1a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13Z",
178
- fillRule: "nonzero"
179
- }), /*#__PURE__*/React.createElement("path", {
180
- d: "m10.23 11.77 1.414-1.414 2.293 2.293a1 1 0 1 1-1.414 1.414L10.23 11.77Z"
181
- })))
182
- }) : null, /*#__PURE__*/React.createElement("div", {
155
+ }, /*#__PURE__*/React.createElement("div", {
156
+ className: "".concat(prefixCls, "-header")
157
+ }, mHeader), /*#__PURE__*/React.createElement("div", {
183
158
  className: "".concat(prefixCls, "-body")
184
159
  }, tree.length <= 0 ? /*#__PURE__*/React.createElement(Empty, {
185
160
  description: false
186
161
  }) : /*#__PURE__*/React.createElement(Tree, _objectSpread({
187
162
  treeData: tree,
188
163
  prefixCls: prefixCls,
189
- itemHeight: 36,
164
+ itemHeight: 40,
165
+ showLine: true,
190
166
  onSelect: function onSelect(selectedKeys, info) {
191
167
  if (_onSelect) {
192
168
  _onSelect(info.node.data, info);
@@ -209,7 +185,7 @@ export default function SiderTree(props) {
209
185
  fill: "none",
210
186
  fillRule: "evenodd"
211
187
  }, /*#__PURE__*/React.createElement("rect", {
212
- stroke: "#686868",
188
+ stroke: "#c4c4c4",
213
189
  fill: "#FFF",
214
190
  x: ".5",
215
191
  y: ".5",
@@ -217,7 +193,7 @@ export default function SiderTree(props) {
217
193
  height: "12",
218
194
  rx: "2"
219
195
  }), /*#__PURE__*/React.createElement("path", {
220
- fill: "#686868",
196
+ fill: "#c4c4c4",
221
197
  d: "M3 6h7v1H3z"
222
198
  })));
223
199
  }
@@ -230,7 +206,7 @@ export default function SiderTree(props) {
230
206
  fill: "none",
231
207
  fillRule: "evenodd"
232
208
  }, /*#__PURE__*/React.createElement("rect", {
233
- stroke: "#686868",
209
+ stroke: "#c4c4c4",
234
210
  fill: "#FFF",
235
211
  x: ".5",
236
212
  y: ".5",
@@ -238,10 +214,10 @@ export default function SiderTree(props) {
238
214
  height: "12",
239
215
  rx: "2"
240
216
  }), /*#__PURE__*/React.createElement("path", {
241
- fill: "#686868",
217
+ fill: "#c4c4c4",
242
218
  d: "M3 6h7v1H3z"
243
219
  }), /*#__PURE__*/React.createElement("path", {
244
- fill: "#686868",
220
+ fill: "#c4c4c4",
245
221
  d: "M7 3v7H6V3z"
246
222
  })));
247
223
  }