tntd 1.3.66 → 1.4.2

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 (168) hide show
  1. package/babel.config.js +1 -1
  2. package/dist/0645cf743e4e44ca9da321d689897f07.png +0 -0
  3. package/dist/09db77de0c24fa0f45f8a5cf299a3d11.png +0 -0
  4. package/dist/1.tntd.js +12 -0
  5. package/dist/1d0b52448de217857b270af807e9360d.png +0 -0
  6. package/dist/25d78d77c9c2f0d403e5d899ceb5b1ef.png +0 -0
  7. package/dist/27fa44ff0c98e1594d79b73045aabedf.png +0 -0
  8. package/dist/2c95075adb68d6131b59cae9fa554ec2.png +0 -0
  9. package/dist/377c871d922a25c773a9e7c2f42ed7c0.png +0 -0
  10. package/dist/3d901589b40bd56ff1fde2bbb700bfe1.png +0 -0
  11. package/dist/4abe481e130d7be0574e45573de8beb7.png +0 -0
  12. package/dist/95ee2260a509cd630d89c5367ed1973b.png +0 -0
  13. package/dist/b9dd5ff3622296fbee51ed68f4bca1bf.png +0 -0
  14. package/dist/bd2921989f9296089ba58efb7a76f3ef.png +0 -0
  15. package/dist/stats.json +45855 -0
  16. package/dist/tntd.css +1 -0
  17. package/dist/tntd.js +15 -0
  18. package/es/ArrayInput/README.md +129 -0
  19. package/es/ArrayInput/icon.js +24 -0
  20. package/es/ArrayInput/index.js +282 -0
  21. package/es/ArrayInput/index.less +20 -0
  22. package/es/AuthContext.js +4 -0
  23. package/es/Columns/README.md +149 -0
  24. package/es/Columns/index.js +86 -0
  25. package/es/Columns/index.less +75 -0
  26. package/es/DevelopmentLogin/LoginModal.js +126 -0
  27. package/es/DevelopmentLogin/README.md +49 -0
  28. package/es/DevelopmentLogin/index.js +40 -0
  29. package/es/Ellipsis/README.md +104 -0
  30. package/es/Ellipsis/Svg/CopySVG.js +63 -0
  31. package/es/Ellipsis/Svg/TickSVG.js +41 -0
  32. package/es/Ellipsis/index.js +143 -0
  33. package/es/Ellipsis/index.less +56 -0
  34. package/es/Handle/README.md +104 -0
  35. package/es/Handle/index.js +92 -0
  36. package/es/Handle/index.less +9 -0
  37. package/es/Icon/README.md +119 -0
  38. package/es/Icon/fonts/demo.css +539 -0
  39. package/es/Icon/fonts/demo_index.html +3345 -0
  40. package/es/Icon/fonts/iconfont.css +569 -0
  41. package/es/Icon/fonts/iconfont.eot +0 -0
  42. package/es/Icon/fonts/iconfont.js +41 -0
  43. package/es/Icon/fonts/iconfont.json +975 -0
  44. package/es/Icon/fonts/iconfont.svg +440 -0
  45. package/es/Icon/fonts/iconfont.ttf +0 -0
  46. package/es/Icon/fonts/iconfont.woff +0 -0
  47. package/es/Icon/fonts/iconfont.woff2 +0 -0
  48. package/es/Icon/iconList.js +1 -0
  49. package/es/Icon/index.js +26 -0
  50. package/es/Icon/index.less +9 -0
  51. package/es/Img/Contain.js +69 -0
  52. package/es/Img/Cover.js +126 -0
  53. package/es/Img/README.md +131 -0
  54. package/es/Img/index.js +76 -0
  55. package/es/Layout/ActionsContext.js +3 -0
  56. package/es/Layout/AppList.js +233 -0
  57. package/es/Layout/Application.js +115 -0
  58. package/es/Layout/Avatar.js +116 -0
  59. package/es/Layout/CompatibleLanguage.js +179 -0
  60. package/es/Layout/EnterpriseLayout/Avatar.js +144 -0
  61. package/es/Layout/EnterpriseLayout/Language.js +81 -0
  62. package/es/Layout/EnterpriseLayout/Theme.js +77 -0
  63. package/es/Layout/EnterpriseLayout/index.js +31 -0
  64. package/es/Layout/GlobalNavigation/NavigationPopup.js +396 -0
  65. package/es/Layout/GlobalNavigation/index.js +137 -0
  66. package/es/Layout/Header.js +95 -0
  67. package/es/Layout/HeaderActions.js +107 -0
  68. package/es/Layout/HeaderNavs.js +93 -0
  69. package/es/Layout/HeaderTabs.js +264 -0
  70. package/es/Layout/Iconfont.js +4 -0
  71. package/es/Layout/Language.js +81 -0
  72. package/es/Layout/Layout.js +234 -0
  73. package/es/Layout/Logo.js +86 -0
  74. package/es/Layout/OrgAppList.js +310 -0
  75. package/es/Layout/README.md +783 -0
  76. package/es/Layout/SideMenu.js +340 -0
  77. package/es/Layout/Theme.js +107 -0
  78. package/es/Layout/checkAuth.js +29 -0
  79. package/es/Layout/createActions.js +39 -0
  80. package/es/Layout/images/avatar/empty.png +0 -0
  81. package/es/Layout/images/avatar/female1.png +0 -0
  82. package/es/Layout/images/avatar/female2.png +0 -0
  83. package/es/Layout/images/avatar/female3.png +0 -0
  84. package/es/Layout/images/avatar/female4.png +0 -0
  85. package/es/Layout/images/avatar/female5.png +0 -0
  86. package/es/Layout/images/avatar/female6.png +0 -0
  87. package/es/Layout/images/avatar/male1.png +0 -0
  88. package/es/Layout/images/avatar/male2.png +0 -0
  89. package/es/Layout/images/avatar/male3.png +0 -0
  90. package/es/Layout/images/avatar/male4.png +0 -0
  91. package/es/Layout/images/avatar/male5.png +0 -0
  92. package/es/Layout/images/avatar/male6.png +0 -0
  93. package/es/Layout/images/index.js +35 -0
  94. package/es/Layout/images/logo/baldur.svg +14 -0
  95. package/es/Layout/images/logo/bi.svg +14 -0
  96. package/es/Layout/images/logo/bridge.svg +15 -0
  97. package/es/Layout/images/logo/convert.svg +18 -0
  98. package/es/Layout/images/logo/dataocean.svg +31 -0
  99. package/es/Layout/images/logo/default.svg +19 -0
  100. package/es/Layout/images/logo/dispatch.svg +14 -0
  101. package/es/Layout/images/logo/graph.svg +26 -0
  102. package/es/Layout/images/logo/handle.svg +10 -0
  103. package/es/Layout/images/logo/indicator.svg +41 -0
  104. package/es/Layout/images/logo/kafka.svg +12 -0
  105. package/es/Layout/images/logo/logo-custom.svg +13 -0
  106. package/es/Layout/images/logo/model.svg +17 -0
  107. package/es/Layout/images/logo/mysql.svg +15 -0
  108. package/es/Layout/images/logo/orion.svg +24 -0
  109. package/es/Layout/images/logo/salaxy.svg +11 -0
  110. package/es/Layout/images/logo/storage.svg +16 -0
  111. package/es/Layout/images/logo/tnt_cli_identify.svg +19 -0
  112. package/es/Layout/images/logo/turing.svg +35 -0
  113. package/es/Layout/images/theme/theme1.svg +35 -0
  114. package/es/Layout/images/theme/theme2.svg +33 -0
  115. package/es/Layout/index.js +122 -0
  116. package/es/Layout/paaslayout/CompactSideMenu.js +167 -0
  117. package/es/Layout/paaslayout/Header.js +77 -0
  118. package/es/Layout/paaslayout/Logo.js +22 -0
  119. package/es/Layout/paaslayout/SideMenu.js +168 -0
  120. package/es/Layout/paaslayout/index.js +235 -0
  121. package/es/Layout/storage.js +47 -0
  122. package/es/Layout/utils.js +136 -0
  123. package/es/LoadingButton/README.md +75 -0
  124. package/es/LoadingButton/index.js +45 -0
  125. package/es/Modal/README.md +59 -0
  126. package/es/Modal/index.js +96 -0
  127. package/es/Modal/index.less +86 -0
  128. package/es/Page/Box.js +74 -0
  129. package/es/Page/README.md +180 -0
  130. package/es/Page/index.js +165 -0
  131. package/es/Page/index.less +144 -0
  132. package/es/Page/utils.js +23 -0
  133. package/es/QueryForm/Field/Checkbox.js +21 -0
  134. package/es/QueryForm/Field/Select.js +80 -0
  135. package/es/QueryForm/Field/SelectInput.js +92 -0
  136. package/es/QueryForm/Field/fieldsMap.js +32 -0
  137. package/es/QueryForm/Field/index.js +157 -0
  138. package/es/QueryForm/README.md +512 -0
  139. package/es/QueryForm/createActions.js +53 -0
  140. package/es/QueryForm/index.js +384 -0
  141. package/es/QueryForm/index.less +133 -0
  142. package/es/QueryForm/useForm.js +7 -0
  143. package/es/QueryListScene/List.js +378 -0
  144. package/es/QueryListScene/QueryForm.js +166 -0
  145. package/es/QueryListScene/QueryListScene.js +76 -0
  146. package/es/QueryListScene/README.md +790 -0
  147. package/es/QueryListScene/Title.js +12 -0
  148. package/es/QueryListScene/Toolbar.js +20 -0
  149. package/es/QueryListScene/createActions.js +72 -0
  150. package/es/QueryListScene/index.js +19 -0
  151. package/es/QueryListScene/index.less +97 -0
  152. package/es/QueryListScene/useActions.js +7 -0
  153. package/es/Select/DropDownWrap.js +116 -0
  154. package/es/Select/README.md +68 -0
  155. package/es/Select/index.js +622 -0
  156. package/es/Table/README.md +109 -0
  157. package/es/Table/ResizableTable/index.js +110 -0
  158. package/es/Table/ResizableTable/index.less +36 -0
  159. package/es/Table/index.js +35 -0
  160. package/es/Title/README.md +106 -0
  161. package/es/Title/index.js +40 -0
  162. package/es/Title/index.less +170 -0
  163. package/es/index.js +19 -0
  164. package/es/locale.js +60 -0
  165. package/package.json +1 -1
  166. package/doc-scripts.config.js +0 -37
  167. package/doc-scripts.renderer.js +0 -11
  168. package/docs/README.md +0 -1643
@@ -0,0 +1,144 @@
1
+ .large-size > .ant-layout-content {
2
+ .tnt-page.in-layout {
3
+ height: calc(100vh - 60px);
4
+ }
5
+ }
6
+ .tnt-page {
7
+ position: relative;
8
+ width: 100%;
9
+ height: 100%;
10
+ overflow-y: hidden;
11
+
12
+ &.in-layout {
13
+ box-shadow: none;
14
+ height: calc(100vh - 50px);
15
+ .tnt-page-box,
16
+ .tnt-page-box > .ant-card {
17
+ height: 100%;
18
+ }
19
+ .tnt-page-content .tnt-page-box .ant-card .ant-card-body {
20
+ overflow-x: hidden;
21
+ overflow-y: auto;
22
+ }
23
+ }
24
+
25
+ &-box-white {
26
+ z-index: 1;
27
+ background: #f3f5f6;
28
+ box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.1), 0 10px 12px 2px rgba(170, 182, 206, 0.2);
29
+
30
+ .in-layout & {
31
+ background: #fafbfc;
32
+ }
33
+ }
34
+
35
+
36
+ &-box-gray {
37
+ background: #e8ebed;
38
+ box-shadow: 0 10px 12px 2px rgba(0, 0, 0, 0.1);
39
+
40
+ .in-layout & {
41
+ background: #f8f9fa;
42
+ // box-shadow: 0 5px 5px 2px rgba(0, 0, 0, 0.1);
43
+ box-shadow: 0 2px 5px 1px rgba(0, 0, 0, 0.1);
44
+ }
45
+ }
46
+
47
+ &-header {
48
+ position: absolute;
49
+ top: 0;
50
+ left: 0;
51
+ right: 0;
52
+ display: flex;
53
+ flex-direction: row;
54
+ justify-content: space-between;
55
+ background: #f0f2f3;
56
+ box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.1),
57
+ 0 10px 6px 0 rgba(170, 182, 206, 0.2);
58
+
59
+ .in-layout & {
60
+ background: #ffffff;
61
+ box-shadow: none;
62
+ }
63
+
64
+ &-section {
65
+ display: flex;
66
+ align-items: center;
67
+ &:nth-child(1) > * {
68
+ margin-right: 10px;
69
+ }
70
+ &:nth-child(2) > * {
71
+ margin: 0 5px;
72
+ }
73
+ &:nth-child(3) > * {
74
+ margin-left: 10px;
75
+ }
76
+ }
77
+ }
78
+
79
+ &-content {
80
+ height: calc(~"100% - 40px");
81
+ flex-direction: row;
82
+ width: 100%;
83
+ position: relative;
84
+ z-index: 0;
85
+ }
86
+
87
+ &-box {
88
+ overflow: auto;
89
+ .ant-card {
90
+ background: inherit;
91
+ }
92
+ }
93
+
94
+ &-box-card {
95
+ background-color: transparent !important;
96
+ .ant-card-head {
97
+ border-bottom: 1px solid #e0e0e0;
98
+ margin-bottom: 0;
99
+ // height: 60px;
100
+ .small & {
101
+ height: 40px;
102
+ line-height: 40px;
103
+ }
104
+ .ant-card-head-title {
105
+ font-weight: normal;
106
+ }
107
+ }
108
+ .ant-card-body {
109
+ overflow: auto;
110
+ }
111
+ }
112
+ }
113
+
114
+
115
+ .page-header-section-back {
116
+ position: relative;
117
+ display: inline-block;
118
+ margin-right: 40px !important;
119
+ cursor: pointer;
120
+ &::after {
121
+ content: "";
122
+ position: absolute;
123
+ width: 1px;
124
+ height: 16px;
125
+ right: -20px;
126
+ top: 50%;
127
+ transform: translateY(-50%);
128
+ background-color: #dcdfe6;
129
+ }
130
+ &:hover {
131
+ &,i {
132
+ color: #126BFB;
133
+ }
134
+ }
135
+ i {
136
+ font-size: 14px;
137
+ margin-right: 6px;
138
+ color: #4c4c4c;
139
+ }
140
+ span {
141
+ font-size: 14px;
142
+ font-weight: normal;
143
+ }
144
+ }
@@ -0,0 +1,23 @@
1
+ var computeWidth = function computeWidth(width) {
2
+ var flex = '1';
3
+ var validNumber = isValidNumber(width);
4
+
5
+ if (/(%|px)$/.test(width) && validNumber) {
6
+ flex = "0 0 ".concat(width);
7
+ } else if (!isNaN(width)) {
8
+ flex = "0 0 ".concat(width, "px");
9
+ }
10
+
11
+ return flex;
12
+ };
13
+
14
+ var isValidNumber = function isValidNumber(value) {
15
+ return !isNaN(parseFloat(value));
16
+ };
17
+
18
+ var addUnitForValue = function addUnitForValue(value) {
19
+ var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'px';
20
+ return !isNaN(value) ? "".concat(value).concat(unit) : value;
21
+ };
22
+
23
+ export { computeWidth, isValidNumber, addUnitForValue };
@@ -0,0 +1,21 @@
1
+ import "antd/lib/checkbox/style";
2
+ import _Checkbox from "antd/lib/checkbox";
3
+
4
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
5
+
6
+ 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; }
7
+
8
+ 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; }
9
+
10
+ export default (function (_ref) {
11
+ var value = _ref.value,
12
+ _onChange = _ref.onChange,
13
+ props = _objectWithoutProperties(_ref, ["value", "onChange"]);
14
+
15
+ return React.createElement(_Checkbox, _extends({}, props, {
16
+ checked: value,
17
+ onChange: function onChange(evt) {
18
+ _onChange == null ? void 0 : _onChange(evt.target.checked);
19
+ }
20
+ }));
21
+ });
@@ -0,0 +1,80 @@
1
+ import "antd/lib/select/style";
2
+ import _Select from "antd/lib/select";
3
+
4
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
5
+
6
+ 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; }
7
+
8
+ 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; }
9
+
10
+ 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; }
11
+
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
13
+
14
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
15
+
16
+ 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; }
17
+
18
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
+
20
+ 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; }
21
+
22
+ 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; }
23
+
24
+ import React, { useState, useEffect } from 'react';
25
+ var Option = _Select.Option;
26
+ export default (function (props) {
27
+ var options = props.options,
28
+ params = props.params,
29
+ _props$queryKey = props.queryKey,
30
+ queryKey = _props$queryKey === void 0 ? 'name' : _props$queryKey,
31
+ _props$fieldNames = props.fieldNames,
32
+ fieldNames = _props$fieldNames === void 0 ? {
33
+ label: 'label',
34
+ value: 'value'
35
+ } : _props$fieldNames,
36
+ loadData = props.loadData,
37
+ rest = _objectWithoutProperties(props, ["options", "params", "queryKey", "fieldNames", "loadData"]);
38
+
39
+ var _useState = useState(options || []),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ items = _useState2[0],
42
+ setItems = _useState2[1];
43
+
44
+ var _useState3 = useState(''),
45
+ _useState4 = _slicedToArray(_useState3, 2),
46
+ query = _useState4[0],
47
+ setQuery = _useState4[1];
48
+
49
+ var onSearch = function onSearch(val) {
50
+ setQuery(val);
51
+ };
52
+
53
+ if (loadData) {
54
+ useEffect(function () {
55
+ loadData(_objectSpread(_defineProperty({}, queryKey, query), params || {})).then(function (items) {
56
+ setItems(items);
57
+ });
58
+ }, [params, query]);
59
+ }
60
+
61
+ useEffect(function () {
62
+ setItems(options || []);
63
+ }, [options]);
64
+ return React.createElement(_Select, _extends({
65
+ allowClear: true,
66
+ showSearch: true,
67
+ optionFilterProp: "children",
68
+ onSearch: onSearch
69
+ }, rest), items.map(function (item) {
70
+ var labelKey = (fieldNames == null ? void 0 : fieldNames.label) || 'label';
71
+ var valueKey = (fieldNames == null ? void 0 : fieldNames.value) || 'value';
72
+ var value = item instanceof Object ? item[valueKey] : item;
73
+ var label = item instanceof Object ? item[labelKey] : item;
74
+ var optionProps = item instanceof Object ? item : {};
75
+ return React.createElement(Option, _extends({}, optionProps, {
76
+ key: value,
77
+ value: value
78
+ }), label);
79
+ }));
80
+ });
@@ -0,0 +1,92 @@
1
+ import "antd/lib/input/style";
2
+ import _Input from "antd/lib/input";
3
+ import "antd/lib/select/style";
4
+ import _Select from "antd/lib/select";
5
+
6
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
7
+
8
+ 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; }
9
+
10
+ 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; }
11
+
12
+ 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; }
13
+
14
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
15
+
16
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
17
+
18
+ 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; }
19
+
20
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
+
22
+ 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; }
23
+
24
+ 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; }
25
+
26
+ import React, { useState, useEffect } from 'react';
27
+ import { get } from 'lodash';
28
+ var Option = _Select.Option;
29
+ export default (function (props) {
30
+ var _props$options = props.options,
31
+ options = _props$options === void 0 ? [] : _props$options,
32
+ addonBeforeStyle = props.addonBeforeStyle,
33
+ inputProps = _objectWithoutProperties(props, ["options", "addonBeforeStyle"]);
34
+
35
+ var _useState = useState(options),
36
+ _useState2 = _slicedToArray(_useState, 2),
37
+ items = _useState2[0],
38
+ setItems = _useState2[1];
39
+
40
+ var getInitialKey = function getInitialKey() {
41
+ var key = get(options, '0.value');
42
+
43
+ if (inputProps.value) {
44
+ key = get(Object.keys(inputProps.value), '0') || key;
45
+ }
46
+
47
+ return key;
48
+ };
49
+
50
+ var _useState3 = useState(getInitialKey()),
51
+ _useState4 = _slicedToArray(_useState3, 2),
52
+ key = _useState4[0],
53
+ setKey = _useState4[1];
54
+
55
+ var onKeyChange = function onKeyChange(key) {
56
+ setKey(key);
57
+ props.onChange(_defineProperty({}, key, ''));
58
+ };
59
+
60
+ var onChange = function onChange(evt) {
61
+ props.onChange(_defineProperty({}, key, evt.target.value));
62
+ };
63
+
64
+ var addonBefore = React.createElement(_Select, {
65
+ value: key,
66
+ onChange: onKeyChange,
67
+ style: _objectSpread({
68
+ width: '120px'
69
+ }, addonBeforeStyle)
70
+ }, items.map(function (_ref) {
71
+ var label = _ref.label,
72
+ value = _ref.value;
73
+ return React.createElement(Option, {
74
+ key: value,
75
+ value: value
76
+ }, label);
77
+ }));
78
+
79
+ var getInputValue = function getInputValue() {
80
+ return get(inputProps.value, key);
81
+ };
82
+
83
+ useEffect(function () {
84
+ setItems(options);
85
+ setKey(getInitialKey());
86
+ }, [options, inputProps.value]);
87
+ return React.createElement(_Input, _extends({}, inputProps, {
88
+ value: getInputValue(),
89
+ addonBefore: addonBefore,
90
+ onChange: onChange
91
+ }));
92
+ });
@@ -0,0 +1,32 @@
1
+ import "antd/lib/date-picker/style";
2
+ import _DatePicker from "antd/lib/date-picker";
3
+ import "antd/lib/input-number/style";
4
+ import _InputNumber from "antd/lib/input-number";
5
+ import "antd/lib/input/style";
6
+ import _Input from "antd/lib/input";
7
+ import SelectField from './Select';
8
+ import SelectInput from './SelectInput';
9
+ import CheckboxField from './Checkbox';
10
+ export var defaultFieldWidth = '200px';
11
+ export var getFieldWidth = function getFieldWidth(type) {
12
+ if (type === 'dateRange') {
13
+ return '340px';
14
+ }
15
+
16
+ return {
17
+ dateRange: '340px',
18
+ selectInput: '320px'
19
+ }[type] || defaultFieldWidth;
20
+ };
21
+ export default {
22
+ string: _Input,
23
+ input: _Input,
24
+ search: _Input.Search,
25
+ inputNumber: _InputNumber,
26
+ number: _InputNumber,
27
+ select: SelectField,
28
+ checkbox: CheckboxField,
29
+ date: _DatePicker,
30
+ dateRange: _DatePicker.RangePicker,
31
+ selectInput: SelectInput
32
+ };
@@ -0,0 +1,157 @@
1
+ import "antd/lib/form/style";
2
+ import _Form from "antd/lib/form";
3
+
4
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
5
+
6
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
7
+
8
+ 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; }
9
+
10
+ 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; }
11
+
12
+ 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; }
13
+
14
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+
16
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17
+
18
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19
+
20
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
21
+
22
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23
+
24
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
25
+
26
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
27
+
28
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29
+
30
+ import { PureComponent } from 'react';
31
+ import { get } from 'lodash';
32
+ import fieldsMap, { getFieldWidth } from './fieldsMap';
33
+ var FormItem = _Form.Item;
34
+
35
+ var isInput = function isInput(type) {
36
+ return ['input', 'string', 'search'].includes(type);
37
+ };
38
+
39
+ var Field =
40
+ /*#__PURE__*/
41
+ function (_PureComponent) {
42
+ _inherits(Field, _PureComponent);
43
+
44
+ function Field(props) {
45
+ var _this;
46
+
47
+ _classCallCheck(this, Field);
48
+
49
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(Field).call(this, props));
50
+
51
+ _this.updateValue = function (name, value) {
52
+ if (name === _this.props.name) {
53
+ _this.setState({
54
+ value: value
55
+ });
56
+
57
+ _this.props.onChange(name, value);
58
+ }
59
+ };
60
+
61
+ _this.onChange = function () {
62
+ var _this$props = _this.props,
63
+ name = _this$props.name,
64
+ _this$props$type = _this$props.type,
65
+ type = _this$props$type === void 0 ? 'input' : _this$props$type,
66
+ component = _this$props.component,
67
+ fieldProps = _this$props.props;
68
+
69
+ var _ref = fieldProps || {},
70
+ onChange = _ref.onChange;
71
+
72
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
73
+ args[_key] = arguments[_key];
74
+ }
75
+
76
+ onChange && onChange.apply(void 0, args); // Input onChange第一个参数为Event对象,取值特殊处理
77
+
78
+ if (!component && isInput(type)) {
79
+ args[0] = get(args[0], 'target.value');
80
+ }
81
+
82
+ _this.setState({
83
+ value: args[0]
84
+ });
85
+
86
+ _this.props.onChange(name, args[0]);
87
+ };
88
+
89
+ _this.onFormChange = function (formData) {
90
+ _this.setState({
91
+ value: get(formData, _this.props.name)
92
+ });
93
+ };
94
+
95
+ _this.state = {
96
+ value: props.initialValue
97
+ };
98
+ return _this;
99
+ }
100
+
101
+ _createClass(Field, [{
102
+ key: "render",
103
+ value: function render() {
104
+ var _fieldProps$style;
105
+
106
+ var _this$props2 = this.props,
107
+ _this$props2$type = _this$props2.type,
108
+ type = _this$props2$type === void 0 ? 'input' : _this$props2$type,
109
+ title = _this$props2.title,
110
+ name = _this$props2.name,
111
+ _this$props2$isFieldI = _this$props2.isFieldInDrawer,
112
+ isFieldInDrawer = _this$props2$isFieldI === void 0 ? false : _this$props2$isFieldI,
113
+ _this$props2$classNam = _this$props2.className,
114
+ className = _this$props2$classNam === void 0 ? '' : _this$props2$classNam,
115
+ component = _this$props2.component,
116
+ form = _this$props2.form,
117
+ fieldProps = _this$props2.props;
118
+ var value = this.state.value;
119
+ var Field = component || fieldsMap[type];
120
+ return React.createElement(FormItem, {
121
+ label: title,
122
+ className: className
123
+ }, React.createElement(Field, _extends({
124
+ value: value
125
+ }, isInput(type) ? {
126
+ onPressEnter: function onPressEnter(evt) {
127
+ var _evt$target, _form$emit;
128
+
129
+ return form.emit('search', (_form$emit = {}, _defineProperty(_form$emit, name, evt == null ? void 0 : (_evt$target = evt.target) == null ? void 0 : _evt$target.value), _defineProperty(_form$emit, "current", 1), _form$emit));
130
+ }
131
+ } : {}, fieldProps, {
132
+ style: _objectSpread({}, fieldProps == null ? void 0 : fieldProps.style, {
133
+ width: isFieldInDrawer ? '100%' : (fieldProps == null ? void 0 : (_fieldProps$style = fieldProps.style) == null ? void 0 : _fieldProps$style.width) || getFieldWidth(type)
134
+ }),
135
+ onChange: this.onChange
136
+ })));
137
+ }
138
+ }, {
139
+ key: "componentDidMount",
140
+ value: function componentDidMount() {
141
+ var form = this.props.form;
142
+ form.on('setValue', this.updateValue);
143
+ form.on('setValues', this.onFormChange);
144
+ }
145
+ }, {
146
+ key: "componentWillUnmount",
147
+ value: function componentWillUnmount() {
148
+ var form = this.props.form;
149
+ form.off('setValue', this.updateValue);
150
+ form.off('setValues', this.onFormChange);
151
+ }
152
+ }]);
153
+
154
+ return Field;
155
+ }(PureComponent);
156
+
157
+ export { Field as default };