tntd 1.3.64 → 1.4.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 (170) hide show
  1. package/.eslintignore +2 -1
  2. package/babel.config.js +12 -2
  3. package/dist/0645cf743e4e44ca9da321d689897f07.png +0 -0
  4. package/dist/09db77de0c24fa0f45f8a5cf299a3d11.png +0 -0
  5. package/dist/1.tntd.js +12 -0
  6. package/dist/1d0b52448de217857b270af807e9360d.png +0 -0
  7. package/dist/25d78d77c9c2f0d403e5d899ceb5b1ef.png +0 -0
  8. package/dist/27fa44ff0c98e1594d79b73045aabedf.png +0 -0
  9. package/dist/2c95075adb68d6131b59cae9fa554ec2.png +0 -0
  10. package/dist/377c871d922a25c773a9e7c2f42ed7c0.png +0 -0
  11. package/dist/3d901589b40bd56ff1fde2bbb700bfe1.png +0 -0
  12. package/dist/4abe481e130d7be0574e45573de8beb7.png +0 -0
  13. package/dist/95ee2260a509cd630d89c5367ed1973b.png +0 -0
  14. package/dist/b9dd5ff3622296fbee51ed68f4bca1bf.png +0 -0
  15. package/dist/bd2921989f9296089ba58efb7a76f3ef.png +0 -0
  16. package/dist/stats.json +45855 -0
  17. package/dist/tntd.css +1 -0
  18. package/dist/tntd.js +15 -0
  19. package/es/ArrayInput/README.md +129 -0
  20. package/es/ArrayInput/icon.js +24 -0
  21. package/es/ArrayInput/index.js +282 -0
  22. package/es/ArrayInput/index.less +20 -0
  23. package/es/AuthContext.js +4 -0
  24. package/es/Columns/README.md +149 -0
  25. package/es/Columns/index.js +86 -0
  26. package/es/Columns/index.less +75 -0
  27. package/es/DevelopmentLogin/LoginModal.js +126 -0
  28. package/es/DevelopmentLogin/README.md +49 -0
  29. package/es/DevelopmentLogin/index.js +40 -0
  30. package/es/Ellipsis/README.md +104 -0
  31. package/es/Ellipsis/Svg/CopySVG.js +63 -0
  32. package/es/Ellipsis/Svg/TickSVG.js +41 -0
  33. package/es/Ellipsis/index.js +143 -0
  34. package/es/Ellipsis/index.less +56 -0
  35. package/es/Handle/README.md +104 -0
  36. package/es/Handle/index.js +92 -0
  37. package/es/Handle/index.less +9 -0
  38. package/es/Icon/README.md +119 -0
  39. package/es/Icon/fonts/demo.css +539 -0
  40. package/es/Icon/fonts/demo_index.html +3345 -0
  41. package/es/Icon/fonts/iconfont.css +569 -0
  42. package/es/Icon/fonts/iconfont.eot +0 -0
  43. package/es/Icon/fonts/iconfont.js +41 -0
  44. package/es/Icon/fonts/iconfont.json +975 -0
  45. package/es/Icon/fonts/iconfont.svg +440 -0
  46. package/es/Icon/fonts/iconfont.ttf +0 -0
  47. package/es/Icon/fonts/iconfont.woff +0 -0
  48. package/es/Icon/fonts/iconfont.woff2 +0 -0
  49. package/es/Icon/iconList.js +1 -0
  50. package/es/Icon/index.js +26 -0
  51. package/es/Icon/index.less +9 -0
  52. package/es/Img/Contain.js +69 -0
  53. package/es/Img/Cover.js +126 -0
  54. package/es/Img/README.md +131 -0
  55. package/es/Img/index.js +76 -0
  56. package/es/Layout/ActionsContext.js +3 -0
  57. package/es/Layout/AppList.js +233 -0
  58. package/es/Layout/Application.js +115 -0
  59. package/es/Layout/Avatar.js +116 -0
  60. package/es/Layout/CompatibleLanguage.js +179 -0
  61. package/es/Layout/EnterpriseLayout/Avatar.js +144 -0
  62. package/es/Layout/EnterpriseLayout/Language.js +81 -0
  63. package/es/Layout/EnterpriseLayout/Theme.js +77 -0
  64. package/es/Layout/EnterpriseLayout/index.js +31 -0
  65. package/es/Layout/GlobalNavigation/NavigationPopup.js +396 -0
  66. package/es/Layout/GlobalNavigation/index.js +137 -0
  67. package/es/Layout/Header.js +95 -0
  68. package/es/Layout/HeaderActions.js +107 -0
  69. package/es/Layout/HeaderNavs.js +93 -0
  70. package/es/Layout/HeaderTabs.js +264 -0
  71. package/es/Layout/Iconfont.js +4 -0
  72. package/es/Layout/Language.js +81 -0
  73. package/es/Layout/Layout.js +234 -0
  74. package/es/Layout/Logo.js +86 -0
  75. package/es/Layout/OrgAppList.js +310 -0
  76. package/es/Layout/README.md +783 -0
  77. package/es/Layout/SideMenu.js +340 -0
  78. package/es/Layout/Theme.js +107 -0
  79. package/es/Layout/checkAuth.js +29 -0
  80. package/es/Layout/createActions.js +39 -0
  81. package/es/Layout/images/avatar/empty.png +0 -0
  82. package/es/Layout/images/avatar/female1.png +0 -0
  83. package/es/Layout/images/avatar/female2.png +0 -0
  84. package/es/Layout/images/avatar/female3.png +0 -0
  85. package/es/Layout/images/avatar/female4.png +0 -0
  86. package/es/Layout/images/avatar/female5.png +0 -0
  87. package/es/Layout/images/avatar/female6.png +0 -0
  88. package/es/Layout/images/avatar/male1.png +0 -0
  89. package/es/Layout/images/avatar/male2.png +0 -0
  90. package/es/Layout/images/avatar/male3.png +0 -0
  91. package/es/Layout/images/avatar/male4.png +0 -0
  92. package/es/Layout/images/avatar/male5.png +0 -0
  93. package/es/Layout/images/avatar/male6.png +0 -0
  94. package/es/Layout/images/index.js +35 -0
  95. package/es/Layout/images/logo/baldur.svg +14 -0
  96. package/es/Layout/images/logo/bi.svg +14 -0
  97. package/es/Layout/images/logo/bridge.svg +15 -0
  98. package/es/Layout/images/logo/convert.svg +18 -0
  99. package/es/Layout/images/logo/dataocean.svg +31 -0
  100. package/es/Layout/images/logo/default.svg +19 -0
  101. package/es/Layout/images/logo/dispatch.svg +14 -0
  102. package/es/Layout/images/logo/graph.svg +26 -0
  103. package/es/Layout/images/logo/handle.svg +10 -0
  104. package/es/Layout/images/logo/indicator.svg +41 -0
  105. package/es/Layout/images/logo/kafka.svg +12 -0
  106. package/es/Layout/images/logo/logo-custom.svg +13 -0
  107. package/es/Layout/images/logo/model.svg +17 -0
  108. package/es/Layout/images/logo/mysql.svg +15 -0
  109. package/es/Layout/images/logo/orion.svg +24 -0
  110. package/es/Layout/images/logo/salaxy.svg +11 -0
  111. package/es/Layout/images/logo/storage.svg +16 -0
  112. package/es/Layout/images/logo/tnt_cli_identify.svg +19 -0
  113. package/es/Layout/images/logo/turing.svg +35 -0
  114. package/es/Layout/images/theme/theme1.svg +35 -0
  115. package/es/Layout/images/theme/theme2.svg +33 -0
  116. package/es/Layout/index.js +122 -0
  117. package/es/Layout/paaslayout/CompactSideMenu.js +167 -0
  118. package/es/Layout/paaslayout/Header.js +77 -0
  119. package/es/Layout/paaslayout/Logo.js +22 -0
  120. package/es/Layout/paaslayout/SideMenu.js +168 -0
  121. package/es/Layout/paaslayout/index.js +235 -0
  122. package/es/Layout/storage.js +47 -0
  123. package/es/Layout/utils.js +136 -0
  124. package/es/LoadingButton/README.md +75 -0
  125. package/es/LoadingButton/index.js +45 -0
  126. package/es/Modal/README.md +59 -0
  127. package/es/Modal/index.js +96 -0
  128. package/es/Modal/index.less +86 -0
  129. package/es/Page/Box.js +74 -0
  130. package/es/Page/README.md +180 -0
  131. package/es/Page/index.js +165 -0
  132. package/es/Page/index.less +144 -0
  133. package/es/Page/utils.js +23 -0
  134. package/es/QueryForm/Field/Checkbox.js +21 -0
  135. package/es/QueryForm/Field/Select.js +80 -0
  136. package/es/QueryForm/Field/SelectInput.js +92 -0
  137. package/es/QueryForm/Field/fieldsMap.js +32 -0
  138. package/es/QueryForm/Field/index.js +157 -0
  139. package/es/QueryForm/README.md +512 -0
  140. package/es/QueryForm/createActions.js +53 -0
  141. package/es/QueryForm/index.js +384 -0
  142. package/es/QueryForm/index.less +133 -0
  143. package/es/QueryForm/useForm.js +7 -0
  144. package/es/QueryListScene/List.js +378 -0
  145. package/es/QueryListScene/QueryForm.js +166 -0
  146. package/es/QueryListScene/QueryListScene.js +76 -0
  147. package/es/QueryListScene/README.md +790 -0
  148. package/es/QueryListScene/Title.js +12 -0
  149. package/es/QueryListScene/Toolbar.js +20 -0
  150. package/es/QueryListScene/createActions.js +72 -0
  151. package/es/QueryListScene/index.js +19 -0
  152. package/es/QueryListScene/index.less +97 -0
  153. package/es/QueryListScene/useActions.js +7 -0
  154. package/es/Select/DropDownWrap.js +116 -0
  155. package/es/Select/README.md +68 -0
  156. package/es/Select/index.js +622 -0
  157. package/es/Table/README.md +109 -0
  158. package/es/Table/ResizableTable/index.js +110 -0
  159. package/es/Table/ResizableTable/index.less +36 -0
  160. package/es/Table/index.js +35 -0
  161. package/es/Title/README.md +106 -0
  162. package/es/Title/index.js +40 -0
  163. package/es/Title/index.less +170 -0
  164. package/es/index.js +19 -0
  165. package/es/locale.js +60 -0
  166. package/package.json +4 -1
  167. package/scripts/postbuild.sh +5 -0
  168. package/doc-scripts.config.js +0 -37
  169. package/doc-scripts.renderer.js +0 -11
  170. package/docs/README.md +0 -1643
@@ -0,0 +1,129 @@
1
+ ## ArrayInput 组件
2
+
3
+ ### 代码演示 1
4
+
5
+ ```jsx
6
+ import React, { useState } from "react";
7
+ import ReactDOM from "react-dom";
8
+ import { Button, Icon, Input, Select } from "antd";
9
+ import { ArrayInput } from "tntd";
10
+ import "antd/dist/antd.css";
11
+
12
+ const Option = Select.Option;
13
+
14
+ const Demo = () => {
15
+ const [value, setValue] = useState([{ type: "input" }]);
16
+ return (
17
+ <ArrayInput
18
+ value={value}
19
+ onChange={v => {
20
+ console.log("值修改了", v);
21
+ setValue(v);
22
+ }}
23
+ plusTip="注意要添加哦"
24
+ deleteTip="注意要删除了哦"
25
+ require
26
+ >
27
+ {(row, index) => {
28
+ return (
29
+ <>
30
+ <Select
31
+ name="type"
32
+ placeholder="联动"
33
+ span={4}
34
+ onChange={(value, index, changeValue) => {
35
+ changeValue(index, "string", undefined);
36
+ }}
37
+ >
38
+ <Option value="input">输入框</Option>
39
+ <Option value="select">选择框</Option>
40
+ </Select>
41
+ {row.type === "input" ? (
42
+ <Input name="string" placeholder="输入值" span={6} />
43
+ ) : (
44
+ <Select name="string" placeholder="下拉值" span={6}>
45
+ <Option value="input">下拉值1</Option>
46
+ <Option value="select">下拉值2</Option>
47
+ </Select>
48
+ )}
49
+ <Input name="input" placeholder="输入框" />
50
+ </>
51
+ );
52
+ }}
53
+ </ArrayInput>
54
+ );
55
+ };
56
+
57
+ ReactDOM.render(<Demo />, document.getElementById("root"));
58
+ ```
59
+
60
+ ### 代码演示 2
61
+
62
+ ```jsx
63
+ import React, { useState } from "react";
64
+ import ReactDOM from "react-dom";
65
+ import { Button, Icon, Input, Select } from "antd";
66
+ import { ArrayInput } from "tntd";
67
+ import "antd/dist/antd.css";
68
+
69
+ const Option = Select.Option;
70
+
71
+ const Demo = () => {
72
+ return (
73
+ <ArrayInput mode="table">
74
+ {(row, index) => {
75
+ return [
76
+ <Select
77
+ name="type"
78
+ placeholder="联动"
79
+ title="输入框类型"
80
+ span={4}
81
+ onChange={(value, index, changeValue) => {
82
+ changeValue(index, "string", undefined);
83
+ }}
84
+ >
85
+ <Option value="input">输入框</Option>
86
+ <Option value="select">选择框</Option>
87
+ </Select>,
88
+ row.type === "input" ? (
89
+ <Input name="string" placeholder="输入值" title="输入类型联动" span={6} />
90
+ ) : (
91
+ <Select name="string" placeholder="输入值" title="输入类型联动" span={6}>
92
+ <Option value="input">下拉值1</Option>
93
+ <Option value="select">下拉值2</Option>
94
+ </Select>
95
+ ),
96
+ <Input name="input" placeholder="输入框" title="输入框" span={6} />,
97
+ ];
98
+ }}
99
+ </ArrayInput>
100
+ );
101
+ };
102
+
103
+ ReactDOM.render(<Demo />, document.getElementById("root"));
104
+ ```
105
+
106
+ ### API
107
+
108
+ #### ArrayInput
109
+
110
+ | 参数 | type | description | default |
111
+ | :----------- | :---------------- | :---------------------------- | :------ |
112
+ | defaultValue | array | 默认值 | |
113
+ | value | array | 可控值 | |
114
+ | onChange | Function | 值变化时的回调 | |
115
+ | mode | string | 展示形式(list 或者 table) | list |
116
+ | gutter | number/array | 同 antd 中的 row 使用方法类似 | 10 |
117
+ | require | boolean | 是否至少有一列 | false |
118
+ | children | Function | 每行渲染函数 | |
119
+ | deleteTip | string | 删除按钮说明文案 | |
120
+ | plusTip | string | 添加按钮说明文案 | |
121
+ | addText | string\|ReactNode | 添加按钮文本 | '添加' |
122
+
123
+ #### children 中输入控件参数
124
+
125
+ | 参数 | type | description | default |
126
+ | :---- | :----- | :---------------------------- | :------ |
127
+ | name | string | 控件的 key(必填) | |
128
+ | span | number | 同 antd 中的 Col 使用方法类似 | 4 |
129
+ | title | string | mode 为 table 的时候必填 | |
@@ -0,0 +1,24 @@
1
+ export var plusIcon = React.createElement("svg", {
2
+ viewBox: "64 64 896 896",
3
+ focusable: "false",
4
+ "data-icon": "plus-circle",
5
+ width: "1em",
6
+ height: "1em",
7
+ fill: "currentColor",
8
+ "aria-hidden": "true"
9
+ }, React.createElement("path", {
10
+ d: "M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"
11
+ }), React.createElement("path", {
12
+ d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
13
+ }));
14
+ export var deleteIcon = React.createElement("svg", {
15
+ viewBox: "64 64 896 896",
16
+ focusable: "false",
17
+ "data-icon": "delete",
18
+ width: "1em",
19
+ height: "1em",
20
+ fill: "currentColor",
21
+ "aria-hidden": "true"
22
+ }, React.createElement("path", {
23
+ d: "M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"
24
+ }));
@@ -0,0 +1,282 @@
1
+ import "antd/es/row/style";
2
+ import _Row from "antd/es/row";
3
+ import "antd/es/tooltip/style";
4
+ import _Tooltip from "antd/es/tooltip";
5
+ import "antd/es/col/style";
6
+ import _Col from "antd/es/col";
7
+ import "antd/es/table/style";
8
+ import _Table from "antd/es/table";
9
+
10
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
11
+
12
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
+
14
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
15
+
16
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
17
+
18
+ function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
19
+
20
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
21
+
22
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
23
+
24
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
25
+
26
+ 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; }
27
+
28
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
29
+
30
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
31
+
32
+ function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_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; }
33
+
34
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
+
36
+ import React, { useEffect, useState, useCallback, isValidElement } from "react";
37
+ import { isFunction, isArray, sumBy, sum, set, get } from "lodash";
38
+ import { plusIcon, deleteIcon } from "./icon";
39
+ import "./index.less";
40
+ var Column = _Table.Column;
41
+
42
+ var getWidth = function getWidth(span) {
43
+ return 1000 / span;
44
+ };
45
+
46
+ export default function ArrayInput(_ref) {
47
+ var children = _ref.children,
48
+ defaultValue = _ref.defaultValue,
49
+ value = _ref.value,
50
+ onChange = _ref.onChange,
51
+ _ref$mode = _ref.mode,
52
+ mode = _ref$mode === void 0 ? "list" : _ref$mode,
53
+ _ref$gutter = _ref.gutter,
54
+ gutter = _ref$gutter === void 0 ? 10 : _ref$gutter,
55
+ _ref$require = _ref.require,
56
+ require = _ref$require === void 0 ? false : _ref$require,
57
+ _ref$deleteTip = _ref.deleteTip,
58
+ deleteTip = _ref$deleteTip === void 0 ? "" : _ref$deleteTip,
59
+ _ref$plusTip = _ref.plusTip,
60
+ plusTip = _ref$plusTip === void 0 ? "" : _ref$plusTip,
61
+ _ref$addText = _ref.addText,
62
+ addText = _ref$addText === void 0 ? "添加" : _ref$addText;
63
+
64
+ if (!isFunction(children)) {
65
+ throw new Error("ArrayInput的children必须是函数");
66
+ }
67
+
68
+ var _useState = useState(value || defaultValue),
69
+ _useState2 = _slicedToArray(_useState, 2),
70
+ _value = _useState2[0],
71
+ setValue = _useState2[1];
72
+
73
+ useEffect(function () {
74
+ setValue(value);
75
+ }, [value]);
76
+
77
+ var _onChange = useCallback(function (value) {
78
+ if (onChange) {
79
+ onChange(value);
80
+ } else {
81
+ setValue(value);
82
+ }
83
+ }, []);
84
+
85
+ var inValue = _value || [];
86
+
87
+ if (require && inValue.length === 0) {
88
+ inValue = [{}];
89
+ }
90
+
91
+ var changeValue = function changeValue(index, name, value) {
92
+ inValue[index] = _objectSpread({}, inValue[index], _defineProperty({}, name, value));
93
+
94
+ _onChange(_toConsumableArray(inValue));
95
+ };
96
+
97
+ var onAdd = function onAdd(index) {
98
+ if (index === undefined) {
99
+ _onChange([].concat(_toConsumableArray(inValue), [{}]));
100
+ } else {
101
+ inValue.splice(index + 1, 0, {});
102
+
103
+ _onChange(_toConsumableArray(inValue));
104
+ }
105
+ };
106
+
107
+ var onDelete = function onDelete(i) {
108
+ inValue.splice(i, 1);
109
+
110
+ _onChange(_toConsumableArray(inValue));
111
+ };
112
+
113
+ if (mode === "list") {
114
+ return React.createElement("div", {
115
+ className: "tntd-array-input"
116
+ }, inValue.map(function (item, index) {
117
+ var fields = children(item, index);
118
+
119
+ if (!isArray(fields)) {
120
+ fields = get(fields, "props.children", []);
121
+ }
122
+
123
+ return React.createElement(_Row, {
124
+ gutter: gutter,
125
+ key: index,
126
+ className: "tntd-array-input-item"
127
+ }, fields.map(function (field, i) {
128
+ if (!isValidElement(field)) {
129
+ return field ? React.createElement(_Col, {
130
+ span: 4,
131
+ key: i
132
+ }, field) : "";
133
+ }
134
+
135
+ var _ref2 = field == null ? void 0 : field.props,
136
+ name = _ref2.name,
137
+ _ref2$span = _ref2.span,
138
+ span = _ref2$span === void 0 ? 4 : _ref2$span,
139
+ fieldChange = _ref2.onChange,
140
+ other = _objectWithoutProperties(_ref2, ["name", "span", "onChange"]);
141
+
142
+ return React.createElement(_Col, {
143
+ span: span,
144
+ key: i
145
+ }, React.cloneElement(field, _objectSpread({
146
+ value: item[name] || undefined,
147
+ onChange: function onChange(e) {
148
+ fieldChange && fieldChange(e, index, changeValue);
149
+ var newValue = e.target ? e.target.value : e;
150
+ changeValue(index, name, newValue);
151
+ }
152
+ }, other)));
153
+ }), React.createElement(_Col, {
154
+ span: 24 - sum(fields.map(function (f) {
155
+ return get(f, "props.span", 4);
156
+ })) % 24
157
+ }, React.createElement("span", {
158
+ className: "tntd-array-input-action"
159
+ }, plusTip ? React.createElement(_Tooltip, {
160
+ title: plusTip,
161
+ placement: "left"
162
+ }, React.createElement("span", {
163
+ className: "mr10",
164
+ onClick: function onClick() {
165
+ return onAdd(index);
166
+ }
167
+ }, plusIcon)) : React.createElement("span", {
168
+ className: "mr10",
169
+ onClick: function onClick() {
170
+ return onAdd(index);
171
+ }
172
+ }, plusIcon), deleteTip ? React.createElement(_Tooltip, {
173
+ title: deleteTip,
174
+ placement: "right"
175
+ }, React.createElement("span", {
176
+ onClick: function onClick() {
177
+ return onDelete(index);
178
+ }
179
+ }, deleteIcon)) : React.createElement("span", {
180
+ onClick: function onClick() {
181
+ return onDelete(index);
182
+ }
183
+ }, deleteIcon))));
184
+ }), inValue.length === 0 && React.createElement("a", {
185
+ onClick: function onClick() {
186
+ return onAdd();
187
+ }
188
+ }, addText));
189
+ } else {
190
+ var fields = children({}, 0);
191
+
192
+ if (!isArray(fields)) {
193
+ fields = get(fields, "props.children", []);
194
+ }
195
+
196
+ var dataSource = inValue.map(function (value, index) {
197
+ var fields = children(value, index);
198
+ var back = {};
199
+ fields.forEach(function (field) {
200
+ var _field$props;
201
+
202
+ var name = field == null ? void 0 : (_field$props = field.props) == null ? void 0 : _field$props.name;
203
+ name && set(back, name, field);
204
+ });
205
+ return back;
206
+ });
207
+ return React.createElement("div", {
208
+ className: "tntd-array-input"
209
+ }, React.createElement(_Table, {
210
+ dataSource: dataSource,
211
+ pagination: false,
212
+ locale: {
213
+ emptyText: React.createElement("a", {
214
+ onClick: function onClick() {
215
+ return onAdd();
216
+ }
217
+ }, addText)
218
+ }
219
+ }, fields.map(function (field) {
220
+ var _ref3 = (field == null ? void 0 : field.props) || {},
221
+ name = _ref3.name,
222
+ span = _ref3.span,
223
+ title = _ref3.title;
224
+
225
+ return React.createElement(Column, {
226
+ key: name,
227
+ dataIndex: name,
228
+ title: title,
229
+ width: getWidth(span || 24 / (fields.length + 1)),
230
+ render: function render(field, row, index) {
231
+ if (!isValidElement(field)) {
232
+ return field;
233
+ }
234
+
235
+ var fieldChange = field.props.onChange;
236
+ return React.cloneElement(field, {
237
+ value: inValue[index][name] || undefined,
238
+ onChange: function onChange(e) {
239
+ fieldChange && fieldChange(e, index, changeValue);
240
+ var newValue = e.target ? e.target.value : e;
241
+ changeValue(index, name, newValue);
242
+ }
243
+ });
244
+ }
245
+ });
246
+ }), React.createElement(Column, {
247
+ key: "action",
248
+ dataIndex: "action",
249
+ title: "\u64CD\u4F5C",
250
+ width: getWidth(24 - sumBy(fields, "props.span") % 24),
251
+ render: function render(text, row, index) {
252
+ return React.createElement("span", {
253
+ className: "tntd-array-input-action"
254
+ }, plusTip ? React.createElement(_Tooltip, {
255
+ title: plusTip,
256
+ placement: "left"
257
+ }, React.createElement("span", {
258
+ className: "mr10",
259
+ onClick: function onClick() {
260
+ return onAdd(index);
261
+ }
262
+ }, plusIcon)) : React.createElement("span", {
263
+ className: "mr10",
264
+ onClick: function onClick() {
265
+ return onAdd(index);
266
+ }
267
+ }, plusIcon), deleteTip ? React.createElement(_Tooltip, {
268
+ title: deleteTip,
269
+ placement: "right"
270
+ }, React.createElement("span", {
271
+ onClick: function onClick() {
272
+ return onDelete(index);
273
+ }
274
+ }, deleteIcon)) : React.createElement("span", {
275
+ onClick: function onClick() {
276
+ return onDelete(index);
277
+ }
278
+ }, deleteIcon));
279
+ }
280
+ })));
281
+ }
282
+ }
@@ -0,0 +1,20 @@
1
+ .tntd-array-input {
2
+ &-item {
3
+ margin-bottom: 10px;
4
+ }
5
+ .ant-col,
6
+ .ant-table-row {
7
+ .ant-select {
8
+ width: 100%;
9
+ }
10
+ }
11
+ .mr10 {
12
+ margin-right: 10px;
13
+ }
14
+ &-action {
15
+ line-height: 28px;
16
+ > span {
17
+ cursor: pointer;
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,4 @@
1
+ import { createContext } from 'react';
2
+ export default createContext(function () {
3
+ return true;
4
+ });
@@ -0,0 +1,149 @@
1
+ ## Columns组件
2
+ ### 代码演示
3
+ ```jsx
4
+ import React, { useState } from 'react';
5
+ import ReactDOM from 'react-dom';
6
+ import { createGlobalStyle } from 'styled-components';
7
+ import { Button, Icon } from 'antd';
8
+ import { Columns } from 'tntd';
9
+ import 'antd/dist/antd.css';
10
+
11
+
12
+ const { Item } = Columns;
13
+
14
+ const GlobalStyle = createGlobalStyle`
15
+ .site-body {
16
+ .ichYgh {
17
+ padding: 0;
18
+ overflow: visible;
19
+ }
20
+ }
21
+ `;
22
+
23
+ const Demo = props => {
24
+ const [activeTabKey1, setActiveTabKey1] = useState('3');
25
+
26
+ const tabList = [
27
+ {
28
+ key: "1",
29
+ tab: "tab1"
30
+ },
31
+ {
32
+ key: "2",
33
+ tab: "tab2"
34
+ }
35
+ ];
36
+ const contentList = {
37
+ "1": <p>content1</p>,
38
+ "2": <p>content2</p>
39
+ };
40
+ const tabList1 = [
41
+ {
42
+ key: "3",
43
+ tab: "tab3"
44
+ },
45
+ {
46
+ key: "4",
47
+ tab: "tab4"
48
+ }
49
+ ];
50
+ const contentList1 = {
51
+ "3": <p>content3</p>,
52
+ "4": <p>content4</p>
53
+ };
54
+ return (
55
+ <>
56
+ <Columns gutter={0} height={500}>
57
+ <Item
58
+ title="项目列表"
59
+ span={5}
60
+ hoverable
61
+ style={{ color: "#bbb" }}
62
+ cover={<span>123</span>}
63
+ loading={true}
64
+ >
65
+ 内容
66
+ </Item>
67
+ <Item
68
+ title="项目详情"
69
+ extra={
70
+ <Button
71
+ size="small"
72
+ type="primary"
73
+ icon="more"
74
+ >
75
+ 更多
76
+ </Button>
77
+ }
78
+ span={14}
79
+ >
80
+ 内容
81
+ </Item>
82
+ <Item
83
+ title="项目配置"
84
+ span={5}
85
+ >
86
+ 我的column
87
+ 我的column
88
+ 我的column
89
+ 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的column 我的column 我的column 我的column 我的column我的
90
+ </Item>
91
+ </Columns>
92
+ <Columns height={500} gutter={[20, 24]}>
93
+ <Item
94
+ bordered={true}
95
+ span={12}
96
+ tabList={tabList1}
97
+ activeTabKey={activeTabKey1}
98
+ onTabChange={key => setActiveTabKey1(key)}
99
+ tabBarExtraContent={(
100
+ <Button
101
+ size="small"
102
+ type="primary"
103
+ icon="search"
104
+ >搜索</Button>
105
+ )}
106
+ >
107
+ 我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦!
108
+ {contentList1[activeTabKey1]}
109
+ </Item>
110
+ <Item
111
+ title="测试5"
112
+ span={12}
113
+ bordered={true}
114
+ >
115
+ 我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是
116
+ </Item>
117
+ </Columns>
118
+ </>
119
+ );
120
+ };
121
+
122
+
123
+ ReactDOM.render(
124
+ <Demo />,
125
+ document.getElementById('root')
126
+ );
127
+ ```
128
+
129
+ ### API
130
+ #### Columns
131
+
132
+ | 参数 | type | description | default |
133
+ | :------------------ | :----------------------------------- | :---------------------------------------------- | :---------------------- |
134
+ | gutter | number/array | 同antd中的row使用方法类似 | 0 |
135
+ | height | int | 列的高度 | - |
136
+
137
+
138
+ #### Columns.Item
139
+
140
+ | 参数 | type | description | default |
141
+ | :------------------ | :----------------------------------- | :---------------------------------------------- | :---------------------- |
142
+ | span | int | 与antd中col的span的使用方法相同 | 24 |
143
+ | extra | string/ReactNode | title 右上角的操作区域 | - |
144
+ | title | string/ReactNode | column 标题 | - |
145
+ | tabList | Array<{key: string, tab: ReactNode}> | 标题列表 | - |
146
+ | activeTabKey | string | 当前激活页签的 key | - |
147
+ | onTabChange | (key) => void | 页签切换的回调 | - |
148
+ | defaultActiveTabKey | string | 初始化选中页签的 key,如果没有设置 activeTabKey | 第一个页签 |
149
+ | tabType | string | average-根据数量等分, default-默认 | default |