@lemon-fe/components 0.0.29 → 0.1.0-alpha.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.
@@ -11,21 +11,17 @@ var Svg = function Svg(props) {
11
11
  return /*#__PURE__*/React.createElement("svg", _objectSpread({
12
12
  width: "16",
13
13
  height: "16",
14
+ viewBox: "0 0 16 16",
14
15
  xmlns: "http://www.w3.org/2000/svg"
15
16
  }, props), /*#__PURE__*/React.createElement("g", {
16
- fill: "none",
17
- fillRule: "evenodd"
18
- }, /*#__PURE__*/React.createElement("circle", {
19
- strokeOpacity: ".25",
20
- stroke: "currentColor",
21
- strokeWidth: "2",
22
- cx: "7",
23
- cy: "7",
24
- r: "5"
25
- }), /*#__PURE__*/React.createElement("path", {
26
- fillOpacity: ".15",
27
17
  fill: "currentColor",
28
- d: "m10.878 12.293 1.414-1.414L14.414 13l-1.415 1.414z"
18
+ fillRule: "evenodd",
19
+ opacity: ".7"
20
+ }, /*#__PURE__*/React.createElement("path", {
21
+ d: "M7.5.5a7 7 0 1 1 0 14 7 7 0 0 1 0-14Zm0 1.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z",
22
+ fillRule: "nonzero"
23
+ }), /*#__PURE__*/React.createElement("path", {
24
+ d: "M12.03 12.03a.75.75 0 0 1 1.061 0l1.768 1.768a.75.75 0 1 1-1.06 1.06l-1.769-1.767a.75.75 0 0 1 0-1.06Z"
29
25
  })));
30
26
  };
31
27
 
@@ -1,9 +1,86 @@
1
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
2
 
3
- import React from 'react';
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, { useState } from 'react';
4
16
  import classNames from 'classnames';
5
17
  import { Spin } from 'antd';
6
18
  import { PREFIX_CLS } from '../constants';
19
+
20
+ function Sider(props) {
21
+ var prefixCls = props.prefixCls,
22
+ children = props.children;
23
+
24
+ var _useState = useState(false),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ collapsed = _useState2[0],
27
+ setCollapsed = _useState2[1];
28
+
29
+ return /*#__PURE__*/React.createElement("div", {
30
+ className: classNames("".concat(prefixCls, "-left"), _defineProperty({}, "".concat(prefixCls, "-left-collapsed"), collapsed))
31
+ }, /*#__PURE__*/React.createElement("div", {
32
+ className: "".concat(prefixCls, "-left-body")
33
+ }, /*#__PURE__*/React.createElement("div", {
34
+ className: "".concat(prefixCls, "-left-content")
35
+ }, children)), /*#__PURE__*/React.createElement("div", {
36
+ className: "".concat(prefixCls, "-left-collapse"),
37
+ onClick: function onClick() {
38
+ return setCollapsed(!collapsed);
39
+ }
40
+ }, /*#__PURE__*/React.createElement("svg", {
41
+ width: "12",
42
+ height: "12",
43
+ version: "1.1",
44
+ viewBox: "0 0 12 12"
45
+ }, /*#__PURE__*/React.createElement("g", {
46
+ stroke: "none",
47
+ strokeWidth: "1",
48
+ fill: "none",
49
+ fillRule: "evenodd",
50
+ opacity: "1"
51
+ }, /*#__PURE__*/React.createElement("g", {
52
+ transform: "translate(-463.000000, -140.000000)"
53
+ }, /*#__PURE__*/React.createElement("g", {
54
+ transform: "translate(463.000000, 140.000000)"
55
+ }, /*#__PURE__*/React.createElement("g", {
56
+ opacity: "0.699999988",
57
+ transform: "translate(2.000000, 2.000000)"
58
+ }, /*#__PURE__*/React.createElement("path", {
59
+ d: "M9,0.75 C9,1.16421356 8.66421356,1.5 8.25,1.5 L5.75,1.5 C5.33578644,1.5 5,1.16421356 5,0.75 C5,0.335786438 5.33578644,7.6089797e-17 5.75,0 L8.25,0 C8.66421356,-7.6089797e-17 9,0.335786438 9,0.75 Z",
60
+ id: "Rectangle-393",
61
+ fill: "currentColor",
62
+ fillRule: "nonzero"
63
+ }), /*#__PURE__*/React.createElement("path", {
64
+ d: "M9,4 C9,4.41421356 8.66421356,4.75 8.25,4.75 L5.75,4.75 C5.33578644,4.75 5,4.41421356 5,4 C5,3.58578644 5.33578644,3.25 5.75,3.25 L8.25,3.25 C8.66421356,3.25 9,3.58578644 9,4 Z",
65
+ id: "Rectangle-394",
66
+ fill: "currentColor",
67
+ fillRule: "nonzero"
68
+ }), /*#__PURE__*/React.createElement("path", {
69
+ d: "M9,7.75 C9,8.16421356 8.66421356,8.5 8.25,8.5 L0.75,8.5 C0.335786438,8.5 5.07265313e-17,8.16421356 0,7.75 C-5.07265313e-17,7.33578644 0.335786438,7 0.75,7 L8.25,7 C8.66421356,7 9,7.33578644 9,7.75 Z",
70
+ id: "Rectangle-395",
71
+ fill: "currentColor",
72
+ fillRule: "nonzero"
73
+ }), /*#__PURE__*/React.createElement("path", {
74
+ d: "M4.32842712,0.621320344 L1.32842712,0.621320344 L1.32842712,3.62132034",
75
+ stroke: "currentColor",
76
+ strokeWidth: "1.5",
77
+ strokeLinecap: "round",
78
+ strokeLinejoin: "round",
79
+ strokeDasharray: "0,0",
80
+ transform: "translate(2.828427, 2.121320) rotate(-45.000000) translate(-2.828427, -2.121320) "
81
+ }))))))));
82
+ }
83
+
7
84
  export default function Layout(props) {
8
85
  var className = props.className,
9
86
  style = props.style,
@@ -23,8 +100,8 @@ export default function Layout(props) {
23
100
  className: "".concat(prefixCls, "-header")
24
101
  }, header) : null, /*#__PURE__*/React.createElement("div", {
25
102
  className: "".concat(prefixCls, "-content")
26
- }, left ? /*#__PURE__*/React.createElement("div", {
27
- className: "".concat(prefixCls, "-left")
103
+ }, left ? /*#__PURE__*/React.createElement(Sider, {
104
+ prefixCls: prefixCls
28
105
  }, left) : null, /*#__PURE__*/React.createElement("div", {
29
106
  className: "".concat(prefixCls, "-main")
30
107
  }, children)), footer ? /*#__PURE__*/React.createElement("div", {
@@ -3,48 +3,96 @@
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
+ }
52
+
53
+ & > .@{prefixCls}-tree-wrapper > .@{prefixCls}-tree-header {
54
+ padding-right: 12px;
55
+ }
43
56
  }
44
57
 
45
- & > .@{prefixCls}-section-with-actions:not(:first-child) {
46
- margin-top: @space / 2;
58
+ &-collapse {
59
+ position: absolute;
60
+ top: 16px;
61
+ right: 0;
62
+ z-index: 100;
63
+ box-sizing: border-box;
64
+ width: 16px;
65
+ height: 32px;
66
+ font-size: 14px;
67
+ line-height: 32px;
68
+ text-align: center;
69
+ text-decoration: underline overline;
70
+ background-color: #fff;
71
+ border: 1px solid #e6e6e6;
72
+ border-right: none;
73
+ border-top-left-radius: 4px;
74
+ border-bottom-left-radius: 4px;
75
+ transform-origin: 100% 50%;
76
+ cursor: pointer;
77
+ transition: transform 0.3s;
78
+
79
+ &:hover {
80
+ color: @primary-color;
81
+ }
47
82
  }
83
+
84
+ &-collapsed &-body {
85
+ width: 0;
86
+ }
87
+
88
+ &-collapsed &-collapse {
89
+ transform: rotateY(180deg);
90
+ }
91
+ }
92
+
93
+ &-main {
94
+ flex: 1;
95
+ min-width: 0;
48
96
  }
49
97
 
50
98
  &-footer {
@@ -406,7 +406,7 @@ export default function Menu(props) {
406
406
  overflow: 'hidden'
407
407
  }
408
408
  }, item.name), /*#__PURE__*/React.createElement("div", {
409
- className: "".concat(prefixCls, "-menu-item-favorite"),
409
+ className: classNames("".concat(prefixCls, "-menu-item-favorite"), _defineProperty({}, "".concat(prefixCls, "-menu-item-favorite-active"), favorited)),
410
410
  onClick: function onClick(e) {
411
411
  toggleFavorite(e, item);
412
412
  }
@@ -544,11 +544,11 @@ export default function Menu(props) {
544
544
  strokeDasharray: "0,0",
545
545
  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)"
546
546
  })))))), menus.map(function (item, index) {
547
- var _classNames5;
547
+ var _classNames6;
548
548
 
549
549
  return /*#__PURE__*/React.createElement("div", {
550
550
  key: index,
551
- 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)),
551
+ className: classNames("".concat(prefixCls, "-menu-top-item"), (_classNames6 = {}, _defineProperty(_classNames6, "".concat(prefixCls, "-menu-top-item-active"), activeMenu !== undefined && activeMenu.path[0] === index), _defineProperty(_classNames6, "".concat(prefixCls, "-menu-top-item-popover-active"), item === popover), _classNames6)),
552
552
  onClick: function onClick() {
553
553
  return handleClick(item);
554
554
  },
@@ -587,7 +587,11 @@ export default function Menu(props) {
587
587
  className: "".concat(prefixCls, "-menu-icon")
588
588
  }, favoriteIcon), /*#__PURE__*/React.createElement("div", {
589
589
  className: "".concat(prefixCls, "-menu-title")
590
- }, "\u6536\u85CF"))), false && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
590
+ }, "\u6536\u85CF")), /*#__PURE__*/React.createElement("div", {
591
+ className: classNames("".concat(prefixCls, "-menu-divider-div"), _defineProperty({}, "".concat(prefixCls, "-menu-divider-div-collapsed"), collapsed))
592
+ }, /*#__PURE__*/React.createElement(Divider, {
593
+ className: "".concat(prefixCls, "-menu-divider")
594
+ }))), false && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
591
595
  className: "".concat(prefixCls, "-menu-gutter")
592
596
  }), collapsed ? /*#__PURE__*/React.createElement("div", {
593
597
  className: "".concat(prefixCls, "-menu-top-item"),
@@ -215,7 +215,7 @@
215
215
  &-favorite {
216
216
  display: none;
217
217
 
218
- &:hover {
218
+ &-active {
219
219
  display: block;
220
220
  }
221
221
 
@@ -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));