@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,48 +3,92 @@
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  min-height: 100%;
6
+ padding: 0 @space;
6
7
  background: #f2f2f2;
7
8
 
8
9
  &-header {
9
- padding: (@space - 3) @space 0;
10
-
11
- .@{prefixCls}-actions {
12
- display: inline-flex;
13
- align-items: center;
14
- height: 22px;
15
- }
10
+ padding: @space 0;
16
11
  }
17
12
 
18
13
  &-content {
19
14
  display: flex;
20
15
  flex: 1;
21
- padding: @space;
22
- }
16
+ background-color: #fff;
17
+ background-clip: content-box;
18
+ border-top-left-radius: 8px;
19
+ border-top-right-radius: 8px;
23
20
 
24
- &-header + &-content {
25
- padding-top: @space - 3;
21
+ &:first-child {
22
+ margin-top: @space;
23
+ }
26
24
  }
27
25
 
28
26
  &-left {
29
- display: flex;
30
- flex: 0 0 242px;
31
- flex-direction: column;
32
- min-width: 0;
33
- margin-right: @space;
34
- overflow: auto;
35
- }
27
+ position: relative;
36
28
 
37
- &-main {
38
- flex: 1;
39
- min-width: 0;
29
+ &-body {
30
+ width: 242px;
31
+ height: 100%;
32
+ overflow-x: hidden;
33
+ transition: width 0.2s;
34
+ }
40
35
 
41
- & > .@{prefixCls}-section:not(:first-child) {
42
- margin-top: @space;
36
+ &-content {
37
+ position: relative;
38
+ display: flex;
39
+ flex-direction: column;
40
+ width: 242px;
41
+ height: 100%;
42
+
43
+ &::after {
44
+ position: absolute;
45
+ top: 0;
46
+ right: 0;
47
+ width: 1px;
48
+ height: 100%;
49
+ background-color: #e6e6e6;
50
+ content: '';
51
+ }
43
52
  }
44
53
 
45
- & > .@{prefixCls}-section-with-actions:not(:first-child) {
46
- margin-top: @space / 2;
54
+ &-collapse {
55
+ position: absolute;
56
+ top: 16px;
57
+ right: 0;
58
+ z-index: 100;
59
+ box-sizing: border-box;
60
+ width: 16px;
61
+ height: 32px;
62
+ font-size: 14px;
63
+ line-height: 32px;
64
+ text-align: center;
65
+ text-decoration: underline overline;
66
+ background-color: #fff;
67
+ border: 1px solid #e6e6e6;
68
+ border-right: none;
69
+ border-top-left-radius: 4px;
70
+ border-bottom-left-radius: 4px;
71
+ transform-origin: 100% 50%;
72
+ cursor: pointer;
73
+ transition: transform 0.3s;
74
+
75
+ &:hover {
76
+ color: @primary-color;
77
+ }
47
78
  }
79
+
80
+ &-collapsed &-body {
81
+ width: 0;
82
+ }
83
+
84
+ &-collapsed &-collapse {
85
+ transform: rotateY(180deg);
86
+ }
87
+ }
88
+
89
+ &-main {
90
+ flex: 1;
91
+ min-width: 0;
48
92
  }
49
93
 
50
94
  &-footer {
@@ -1,24 +1,6 @@
1
1
  .@{prefixCls}-nav-menu {
2
2
  &-pop {
3
- padding-top: 0 !important;
4
-
5
- .ant-popover-arrow {
6
- display: none;
7
- }
8
-
9
- .ant-popover-inner {
10
- position: relative;
11
- width: 160px;
12
- padding: 8px 0;
13
- border-radius: 8px;
14
- border-image: linear-gradient(147deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0)) 1 1;
15
- box-shadow: 0 12px 48px 16px rgba(0, 0, 0, 0.03), 0 9px 28px 0 rgba(0, 0, 0, 0.05),
16
- 0 6px 16px -8px rgba(0, 0, 0, 0.08);
17
- }
18
-
19
- .ant-popover-inner-content {
20
- padding: 0;
21
- }
3
+ .popover(160px);
22
4
  }
23
5
 
24
6
  &-tabs {
@@ -26,19 +8,7 @@
26
8
  }
27
9
 
28
10
  &-tab {
29
- position: relative;
30
- box-sizing: border-box;
31
- width: 100%;
32
- height: 36px;
33
- padding: 0 16px;
34
- overflow: hidden;
35
- color: #333;
36
- font-size: 14px;
37
- line-height: 36px;
38
- white-space: nowrap;
39
- text-overflow: ellipsis;
40
- cursor: pointer;
41
- transition: background-color 0.2s;
11
+ .popoverItem();
42
12
 
43
13
  &:hover {
44
14
  background-color: #eee;
@@ -167,7 +167,7 @@
167
167
 
168
168
  & > span {
169
169
  margin-top: 24px;
170
- color: #333333;
170
+ color: #333;
171
171
  font-weight: 400;
172
172
  font-size: 14px;
173
173
  line-height: 22px;
@@ -263,7 +263,7 @@
263
263
 
264
264
  &-other-title {
265
265
  margin: 0 0 8px 16px;
266
- color: #000000;
266
+ color: #000;
267
267
  font-weight: 400;
268
268
  font-size: 14px;
269
269
  line-height: 22px;
@@ -21,40 +21,10 @@
21
21
  line-height: 1;
22
22
 
23
23
  &-tab {
24
- position: relative;
25
- width: 100%;
26
- height: 36px;
27
- color: #333;
28
- font-size: 14px;
29
- line-height: 36px;
30
- text-align: center;
31
- cursor: pointer;
32
- transition: background-color 0.2s;
33
-
34
- &:hover {
35
- background-color: #eee;
36
- }
24
+ .popoverItem();
37
25
  }
38
26
 
39
27
  &-pop {
40
- padding-top: 0 !important;
41
-
42
- .ant-popover-arrow {
43
- display: none;
44
- }
45
-
46
- .ant-popover-inner {
47
- position: relative;
48
- width: 120px;
49
- padding: 8px 0;
50
- border-radius: 8px;
51
- border-image: linear-gradient(147deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0)) 1 1;
52
- box-shadow: 0 12px 48px 16px rgba(0, 0, 0, 0.03), 0 9px 28px 0 rgba(0, 0, 0, 0.05),
53
- 0 6px 16px -8px rgba(0, 0, 0, 0.08);
54
- }
55
-
56
- .ant-popover-inner-content {
57
- padding: 0;
58
- }
28
+ .popover();
59
29
  }
60
30
  }
@@ -0,0 +1,12 @@
1
+ import type { ReactNode } from 'react';
2
+ declare type ContentType = ReactNode | null;
3
+ declare function PortalHost(props: {
4
+ children: ContentType;
5
+ }): JSX.Element;
6
+ declare function Portal(props: {
7
+ children?: ContentType;
8
+ }): JSX.Element | null;
9
+ declare namespace Portal {
10
+ var Host: typeof PortalHost;
11
+ }
12
+ export default Portal;
@@ -0,0 +1,72 @@
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 from 'react';
14
+ import { createContext, memo, useContext, useEffect, useMemo, useState } from 'react';
15
+ import { uniqueId } from 'lodash';
16
+ var Slot = /*#__PURE__*/memo(function Content(props) {
17
+ return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
18
+ });
19
+ var Context = /*#__PURE__*/createContext(null);
20
+
21
+ function PortalHost(props) {
22
+ var children = props.children;
23
+
24
+ var _useState = useState(null),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ content = _useState2[0],
27
+ setContent = _useState2[1];
28
+
29
+ var portal = useMemo(function () {
30
+ return {
31
+ add: function add(key, node) {
32
+ setContent({
33
+ key: key,
34
+ node: node
35
+ });
36
+ },
37
+ clear: function clear(key) {
38
+ setContent(function (prev) {
39
+ if ((prev === null || prev === void 0 ? void 0 : prev.key) === key) {
40
+ return null;
41
+ }
42
+
43
+ return prev;
44
+ });
45
+ }
46
+ };
47
+ }, []);
48
+ return /*#__PURE__*/React.createElement(Context.Provider, {
49
+ value: portal
50
+ }, /*#__PURE__*/React.createElement(Slot, null, content ? content.node : null), /*#__PURE__*/React.createElement(Slot, null, children));
51
+ }
52
+
53
+ function Portal(props) {
54
+ var _props$children = props.children,
55
+ children = _props$children === void 0 ? null : _props$children;
56
+ var portal = useContext(Context);
57
+ var key = useMemo(function () {
58
+ return uniqueId('portal-');
59
+ }, []);
60
+ useEffect(function () {
61
+ if (portal !== null) {
62
+ portal.add(key, children);
63
+ return function () {
64
+ portal.clear(key);
65
+ };
66
+ }
67
+ }, [portal, key, children]);
68
+ return portal ? null : /*#__PURE__*/React.createElement(React.Fragment, null, children);
69
+ }
70
+
71
+ Portal.Host = PortalHost;
72
+ export default Portal;
@@ -0,0 +1,12 @@
1
+ import type { MouseEvent } from 'react';
2
+ interface Props {
3
+ prefixCls: string;
4
+ tabs: {
5
+ title?: string;
6
+ key: string;
7
+ }[];
8
+ activeKey?: string;
9
+ onTabClick: (key: string, index: number, e: MouseEvent) => void;
10
+ }
11
+ export default function TabBar(props: Props): JSX.Element;
12
+ export {};
@@ -0,0 +1,48 @@
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, useState } from 'react';
16
+ import classNames from 'classnames';
17
+ export default function TabBar(props) {
18
+ var prefixCls = props.prefixCls,
19
+ tabs = props.tabs,
20
+ onTabClick = props.onTabClick,
21
+ activeKey = props.activeKey;
22
+
23
+ var getKey = function getKey() {
24
+ return activeKey || (tabs.length > 0 ? tabs[0].key : undefined);
25
+ };
26
+
27
+ var _useState = useState(getKey()),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ key = _useState2[0],
30
+ setKey = _useState2[1];
31
+
32
+ useEffect(function () {
33
+ setKey(getKey());
34
+ }, [activeKey]);
35
+ return /*#__PURE__*/React.createElement("div", {
36
+ className: "".concat(prefixCls, "-tab")
37
+ }, tabs.map(function (_, index) {
38
+ var tab = tabs[index];
39
+ return /*#__PURE__*/React.createElement("div", {
40
+ key: tab.key,
41
+ className: classNames("".concat(prefixCls, "-tab-item"), _defineProperty({}, "".concat(prefixCls, "-tab-item-active"), key === tab.key)),
42
+ onClick: function onClick(e) {
43
+ setKey(tab.key);
44
+ onTabClick(tab.key, index, e);
45
+ }
46
+ }, tab.title);
47
+ }));
48
+ }
@@ -7,7 +7,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
7
7
  import React from 'react';
8
8
  import classNames from 'classnames';
9
9
  import { Tabs } from 'antd';
10
+ import { mapChildren } from '../utils';
10
11
  import { PREFIX_CLS } from '../constants';
12
+ import TabBar from './TabBar';
11
13
  export default function Section(props) {
12
14
  var _classNames;
13
15
 
@@ -22,7 +24,7 @@ export default function Section(props) {
22
24
  actions = props.actions,
23
25
  flex = props.flex,
24
26
  activeKey = props.activeKey,
25
- onTabClick = props.onTabClick;
27
+ _onTabClick = props.onTabClick;
26
28
  var prefixCls = PREFIX_CLS + '-section';
27
29
  var containerStyle = style;
28
30
 
@@ -30,69 +32,36 @@ export default function Section(props) {
30
32
  containerStyle = _objectSpread({
31
33
  flex: typeof flex === 'number' ? flex : 1
32
34
  }, containerStyle);
33
- } // 不使用Children.map的原因是由于它会给子节点生成一个key与tabs的activeTabKey无法对应
34
-
35
-
36
- var mapChildren = function mapChildren(children, cb) {
37
- var nodes = [];
38
-
39
- if (Array.isArray(children)) {
40
- nodes = children;
41
- } else {
42
- nodes = [children];
43
- }
44
-
45
- return nodes.filter(function (item) {
46
- return item !== null;
47
- }).map(cb);
48
- };
35
+ }
49
36
 
50
37
  var hasActions = !!actions;
51
38
  return /*#__PURE__*/React.createElement("div", {
52
- className: classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-").concat(type), !!type), _defineProperty(_classNames, "".concat(prefixCls, "-flex"), !!flex), _defineProperty(_classNames, "".concat(prefixCls, "-with-actions"), hasActions), _classNames), className),
39
+ className: classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-").concat(type), !!type), _defineProperty(_classNames, "".concat(prefixCls, "-flex"), !!flex), _classNames), className),
53
40
  style: containerStyle
54
- }, !!title || hasActions ? /*#__PURE__*/React.createElement("div", {
41
+ }, title || hasActions ? /*#__PURE__*/React.createElement("div", {
55
42
  className: "".concat(prefixCls, "-header")
56
43
  }, /*#__PURE__*/React.createElement("div", {
57
44
  className: "".concat(prefixCls, "-title")
58
- }, title), actions) : null, tabs !== undefined && tabs.length > 0 ? /*#__PURE__*/React.createElement(Tabs, {
45
+ }, title), actions) : null, tabs !== undefined && tabs.length > 0 ? Array.isArray(children) && children.length > 1 ? /*#__PURE__*/React.createElement(Tabs, {
59
46
  activeKey: activeKey,
60
- onTabClick: onTabClick,
47
+ onTabClick: _onTabClick,
61
48
  renderTabBar: function renderTabBar(tabProps) {
62
- var activeKey = tabProps.activeKey,
63
- onTabClick = tabProps.onTabClick;
64
- var active = tabs.findIndex(function (item) {
65
- return item.key === activeKey;
66
- });
67
- return /*#__PURE__*/React.createElement("div", {
68
- className: "".concat(prefixCls, "-tab")
69
- }, tabs.map(function (_, index) {
70
- var _classNames2;
71
-
72
- var tab = tabs[index];
73
- var key = tab.key;
74
- return /*#__PURE__*/React.createElement("div", {
75
- key: key,
76
- className: classNames("".concat(prefixCls, "-tab-item"), (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-tab-item-active"), active === index), _defineProperty(_classNames2, "".concat(prefixCls, "-tab-item-active-left"), index === active - 1), _defineProperty(_classNames2, "".concat(prefixCls, "-tab-item-active-right"), index === active + 1), _classNames2)),
77
- onClick: function onClick(e) {
78
- if (key !== null) {
79
- onTabClick(key, e);
80
- }
49
+ var mKey = tabProps.activeKey,
50
+ mClick = tabProps.onTabClick;
51
+ return /*#__PURE__*/React.createElement(TabBar, {
52
+ activeKey: mKey,
53
+ tabs: tabs,
54
+ prefixCls: prefixCls,
55
+ onTabClick: function onTabClick(key, index, e) {
56
+ mClick(key, e);
81
57
 
82
- if (key !== activeKey) {
83
- if (onTabChange) {
84
- onTabChange(tab.key, index);
85
- }
58
+ if (key !== mKey) {
59
+ if (onTabChange) {
60
+ onTabChange(key, index);
86
61
  }
87
62
  }
88
- }, /*#__PURE__*/React.createElement("div", {
89
- className: "".concat(prefixCls, "-tab-item-arc-left")
90
- }), /*#__PURE__*/React.createElement("div", {
91
- className: "".concat(prefixCls, "-tab-item-content")
92
- }, tab.title), /*#__PURE__*/React.createElement("div", {
93
- className: "".concat(prefixCls, "-tab-item-arc-right")
94
- }));
95
- }));
63
+ }
64
+ });
96
65
  }
97
66
  }, mapChildren(children, function (child, index) {
98
67
  var _tabs$index = tabs[index],
@@ -104,7 +73,23 @@ export default function Section(props) {
104
73
  className: "".concat(prefixCls, "-body"),
105
74
  style: bodyStyle
106
75
  }, child);
107
- })) : /*#__PURE__*/React.createElement("div", {
76
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TabBar, {
77
+ activeKey: activeKey,
78
+ tabs: tabs,
79
+ prefixCls: prefixCls,
80
+ onTabClick: function onTabClick(key, index, e) {
81
+ if (_onTabClick) {
82
+ _onTabClick(key, e);
83
+ }
84
+
85
+ if (key !== activeKey && onTabChange) {
86
+ onTabChange(key, index);
87
+ }
88
+ }
89
+ }), /*#__PURE__*/React.createElement("div", {
90
+ className: "".concat(prefixCls, "-body"),
91
+ style: bodyStyle
92
+ }, children)) : /*#__PURE__*/React.createElement("div", {
108
93
  className: "".concat(prefixCls, "-body"),
109
94
  style: bodyStyle
110
95
  }, children));