tntd 1.4.4 → 1.4.7
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.
- package/components/Layout/HeaderActions.js +90 -128
- package/components/LoadingButton/index.js +11 -15
- package/components/QueryListScene/QueryForm.js +7 -4
- package/dist/stats.json +4990 -4990
- package/dist/tntd.js +1 -1
- package/es/Layout/HeaderActions.js +10 -10
- package/es/LoadingButton/index.js +20 -10
- package/es/QueryListScene/QueryForm.js +6 -3
- package/lib/ArrayInput/icon.js +27 -31
- package/lib/ArrayInput/index.js +211 -298
- package/lib/AuthContext.js +2 -13
- package/lib/Columns/index.js +71 -100
- package/lib/DevelopmentLogin/LoginModal.js +79 -141
- package/lib/DevelopmentLogin/index.js +28 -55
- package/lib/Ellipsis/Svg/CopySVG.js +23 -71
- package/lib/Ellipsis/Svg/TickSVG.js +17 -49
- package/lib/Ellipsis/index.js +148 -154
- package/lib/Handle/index.js +72 -109
- package/lib/Icon/fonts/iconfont.js +1 -43
- package/lib/Icon/iconList.js +119 -8
- package/lib/Icon/index.js +13 -45
- package/lib/Img/Contain.js +49 -81
- package/lib/Img/Cover.js +88 -136
- package/lib/Img/index.js +36 -89
- package/lib/Layout/ActionsContext.js +2 -11
- package/lib/Layout/AppList.js +262 -256
- package/lib/Layout/Application.js +119 -135
- package/lib/Layout/Avatar.js +137 -137
- package/lib/Layout/CompatibleLanguage.js +214 -195
- package/lib/Layout/EnterpriseLayout/Avatar.js +156 -168
- package/lib/Layout/EnterpriseLayout/Language.js +75 -100
- package/lib/Layout/EnterpriseLayout/Theme.js +96 -94
- package/lib/Layout/EnterpriseLayout/index.js +32 -45
- package/lib/Layout/GlobalNavigation/NavigationPopup.js +335 -407
- package/lib/Layout/GlobalNavigation/index.js +110 -158
- package/lib/Layout/Header.js +165 -116
- package/lib/Layout/HeaderActions.js +132 -129
- package/lib/Layout/HeaderNavs.js +90 -113
- package/lib/Layout/HeaderTabs.js +312 -278
- package/lib/Layout/Iconfont.js +2 -15
- package/lib/Layout/Language.js +63 -102
- package/lib/Layout/Layout.js +272 -261
- package/lib/Layout/Logo.js +132 -87
- package/lib/Layout/OrgAppList.js +440 -319
- package/lib/Layout/SideMenu.js +429 -343
- package/lib/Layout/Theme.js +95 -124
- package/lib/Layout/checkAuth.js +21 -35
- package/lib/Layout/createActions.js +38 -51
- package/lib/Layout/images/index.js +33 -41
- package/lib/Layout/index.js +110 -161
- package/lib/Layout/paaslayout/CompactSideMenu.js +200 -178
- package/lib/Layout/paaslayout/Header.js +84 -90
- package/lib/Layout/paaslayout/Logo.js +27 -32
- package/lib/Layout/paaslayout/SideMenu.js +161 -174
- package/lib/Layout/paaslayout/index.js +240 -261
- package/lib/Layout/storage.js +20 -78
- package/lib/Layout/utils.js +93 -143
- package/lib/LoadingButton/index.js +25 -57
- package/lib/Modal/index.js +83 -108
- package/lib/Page/Box.js +56 -81
- package/lib/Page/index.js +151 -173
- package/lib/Page/utils.js +12 -30
- package/lib/QueryForm/Field/Checkbox.js +11 -33
- package/lib/QueryForm/Field/Select.js +63 -99
- package/lib/QueryForm/Field/SelectInput.js +69 -114
- package/lib/QueryForm/Field/fieldsMap.js +30 -52
- package/lib/QueryForm/Field/index.js +76 -158
- package/lib/QueryForm/createActions.js +50 -65
- package/lib/QueryForm/index.js +304 -383
- package/lib/QueryForm/useForm.js +6 -17
- package/lib/QueryListScene/List.js +290 -366
- package/lib/QueryListScene/QueryForm.js +93 -158
- package/lib/QueryListScene/QueryListScene.js +33 -87
- package/lib/QueryListScene/Title.js +10 -20
- package/lib/QueryListScene/Toolbar.js +8 -31
- package/lib/QueryListScene/createActions.js +64 -79
- package/lib/QueryListScene/index.js +23 -40
- package/lib/QueryListScene/useActions.js +6 -17
- package/lib/Select/DropDownWrap.js +60 -124
- package/lib/Select/index.js +425 -561
- package/lib/Table/ResizableTable/index.js +77 -121
- package/lib/Table/index.js +19 -51
- package/lib/Title/index.js +34 -52
- package/lib/index.js +19 -159
- package/lib/locale.js +48 -63
- package/package.json +1 -1
- package/lib/Layout/EnterpriseLayout/Header.js +0 -113
- package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
package/lib/ArrayInput/index.js
CHANGED
|
@@ -1,308 +1,221 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var _table = _interopRequireDefault(require("antd/lib/table"));
|
|
25
|
-
|
|
26
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
27
|
-
|
|
28
|
-
var _lodash = require("lodash");
|
|
29
|
-
|
|
30
|
-
var _icon = require("./icon");
|
|
31
|
-
|
|
32
|
-
require("./index.less");
|
|
33
|
-
|
|
34
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
35
|
-
|
|
36
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
-
|
|
38
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
39
|
-
|
|
40
|
-
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; }
|
|
41
|
-
|
|
42
|
-
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; }
|
|
43
|
-
|
|
44
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
45
|
-
|
|
46
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
|
47
|
-
|
|
48
|
-
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
|
49
|
-
|
|
50
|
-
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; } }
|
|
51
|
-
|
|
52
|
-
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; }
|
|
53
|
-
|
|
54
|
-
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; }
|
|
55
|
-
|
|
56
|
-
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; }
|
|
57
|
-
|
|
58
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
59
|
-
|
|
60
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
61
|
-
|
|
62
|
-
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; }
|
|
63
|
-
|
|
64
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
65
|
-
|
|
66
|
-
var Column = _table["default"].Column;
|
|
67
|
-
|
|
68
|
-
var getWidth = function getWidth(span) {
|
|
69
|
-
return 1000 / span;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
function ArrayInput(_ref) {
|
|
73
|
-
var children = _ref.children,
|
|
74
|
-
defaultValue = _ref.defaultValue,
|
|
75
|
-
value = _ref.value,
|
|
76
|
-
onChange = _ref.onChange,
|
|
77
|
-
_ref$mode = _ref.mode,
|
|
78
|
-
mode = _ref$mode === void 0 ? "list" : _ref$mode,
|
|
79
|
-
_ref$gutter = _ref.gutter,
|
|
80
|
-
gutter = _ref$gutter === void 0 ? 10 : _ref$gutter,
|
|
81
|
-
_ref$require = _ref.require,
|
|
82
|
-
require = _ref$require === void 0 ? false : _ref$require,
|
|
83
|
-
_ref$deleteTip = _ref.deleteTip,
|
|
84
|
-
deleteTip = _ref$deleteTip === void 0 ? "" : _ref$deleteTip,
|
|
85
|
-
_ref$plusTip = _ref.plusTip,
|
|
86
|
-
plusTip = _ref$plusTip === void 0 ? "" : _ref$plusTip,
|
|
87
|
-
_ref$addText = _ref.addText,
|
|
88
|
-
addText = _ref$addText === void 0 ? "添加" : _ref$addText;
|
|
89
|
-
|
|
90
|
-
if (!(0, _lodash.isFunction)(children)) {
|
|
91
|
-
throw new Error("ArrayInput的children必须是函数");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
var _useState = (0, _react.useState)(value || defaultValue),
|
|
95
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
96
|
-
_value = _useState2[0],
|
|
97
|
-
setValue = _useState2[1];
|
|
98
|
-
|
|
99
|
-
(0, _react.useEffect)(function () {
|
|
100
|
-
setValue(value);
|
|
101
|
-
}, [value]);
|
|
102
|
-
|
|
103
|
-
var _onChange = (0, _react.useCallback)(function (value) {
|
|
104
|
-
if (onChange) {
|
|
105
|
-
onChange(value);
|
|
106
|
-
} else {
|
|
107
|
-
setValue(value);
|
|
1
|
+
import React, { useEffect, useState, useCallback, isValidElement } from "react";
|
|
2
|
+
import { Row, Col, Table, Tooltip } from "antd";
|
|
3
|
+
import { isFunction, isArray, sumBy, sum, set, get } from "lodash";
|
|
4
|
+
import { plusIcon, deleteIcon } from "./icon";
|
|
5
|
+
import "./index.less";
|
|
6
|
+
|
|
7
|
+
const { Column } = Table;
|
|
8
|
+
const getWidth = span => 1000 / span;
|
|
9
|
+
|
|
10
|
+
export default function ArrayInput({
|
|
11
|
+
children,
|
|
12
|
+
defaultValue,
|
|
13
|
+
value,
|
|
14
|
+
onChange,
|
|
15
|
+
mode = "list",
|
|
16
|
+
gutter = 10,
|
|
17
|
+
require = false,
|
|
18
|
+
deleteTip = "",
|
|
19
|
+
plusTip = "",
|
|
20
|
+
addText = "添加",
|
|
21
|
+
}) {
|
|
22
|
+
if (!isFunction(children)) {
|
|
23
|
+
throw new Error("ArrayInput的children必须是函数");
|
|
108
24
|
}
|
|
109
|
-
}, []);
|
|
110
|
-
|
|
111
|
-
var inValue = _value || [];
|
|
112
|
-
|
|
113
|
-
if (require && inValue.length === 0) {
|
|
114
|
-
inValue = [{}];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
var changeValue = function changeValue(index, name, value) {
|
|
118
|
-
inValue[index] = _objectSpread({}, inValue[index], _defineProperty({}, name, value));
|
|
119
25
|
|
|
120
|
-
|
|
121
|
-
};
|
|
26
|
+
const [_value, setValue] = useState(value || defaultValue);
|
|
122
27
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
} else {
|
|
127
|
-
inValue.splice(index + 1, 0, {});
|
|
128
|
-
|
|
129
|
-
_onChange(_toConsumableArray(inValue));
|
|
130
|
-
}
|
|
131
|
-
};
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
setValue(value);
|
|
30
|
+
}, [value]);
|
|
132
31
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (mode === "list") {
|
|
140
|
-
return _react["default"].createElement("div", {
|
|
141
|
-
className: "tntd-array-input"
|
|
142
|
-
}, inValue.map(function (item, index) {
|
|
143
|
-
var fields = children(item, index);
|
|
144
|
-
|
|
145
|
-
if (!(0, _lodash.isArray)(fields)) {
|
|
146
|
-
fields = (0, _lodash.get)(fields, "props.children", []);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return _react["default"].createElement(_row["default"], {
|
|
150
|
-
gutter: gutter,
|
|
151
|
-
key: index,
|
|
152
|
-
className: "tntd-array-input-item"
|
|
153
|
-
}, fields.map(function (field, i) {
|
|
154
|
-
if (!(0, _react.isValidElement)(field)) {
|
|
155
|
-
return field ? _react["default"].createElement(_col["default"], {
|
|
156
|
-
span: 4,
|
|
157
|
-
key: i
|
|
158
|
-
}, field) : "";
|
|
32
|
+
const _onChange = useCallback(value => {
|
|
33
|
+
if (onChange) {
|
|
34
|
+
onChange(value);
|
|
35
|
+
} else {
|
|
36
|
+
setValue(value);
|
|
159
37
|
}
|
|
38
|
+
}, []);
|
|
160
39
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
fieldChange = _ref2.onChange,
|
|
166
|
-
other = _objectWithoutProperties(_ref2, ["name", "span", "onChange"]);
|
|
40
|
+
let inValue = _value || [];
|
|
41
|
+
if (require && inValue.length === 0) {
|
|
42
|
+
inValue = [{}];
|
|
43
|
+
}
|
|
167
44
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
})) % 24
|
|
183
|
-
}, _react["default"].createElement("span", {
|
|
184
|
-
className: "tntd-array-input-action"
|
|
185
|
-
}, plusTip ? _react["default"].createElement(_tooltip["default"], {
|
|
186
|
-
title: plusTip,
|
|
187
|
-
placement: "left"
|
|
188
|
-
}, _react["default"].createElement("span", {
|
|
189
|
-
className: "mr10",
|
|
190
|
-
onClick: function onClick() {
|
|
191
|
-
return onAdd(index);
|
|
192
|
-
}
|
|
193
|
-
}, _icon.plusIcon)) : _react["default"].createElement("span", {
|
|
194
|
-
className: "mr10",
|
|
195
|
-
onClick: function onClick() {
|
|
196
|
-
return onAdd(index);
|
|
197
|
-
}
|
|
198
|
-
}, _icon.plusIcon), deleteTip ? _react["default"].createElement(_tooltip["default"], {
|
|
199
|
-
title: deleteTip,
|
|
200
|
-
placement: "right"
|
|
201
|
-
}, _react["default"].createElement("span", {
|
|
202
|
-
onClick: function onClick() {
|
|
203
|
-
return onDelete(index);
|
|
45
|
+
const changeValue = (index, name, value) => {
|
|
46
|
+
inValue[index] = {
|
|
47
|
+
...inValue[index],
|
|
48
|
+
[name]: value,
|
|
49
|
+
};
|
|
50
|
+
_onChange([...inValue]);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const onAdd = index => {
|
|
54
|
+
if (index === undefined) {
|
|
55
|
+
_onChange([...inValue, {}]);
|
|
56
|
+
} else {
|
|
57
|
+
inValue.splice(index + 1, 0, {});
|
|
58
|
+
_onChange([...inValue]);
|
|
204
59
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const onDelete = i => {
|
|
63
|
+
inValue.splice(i, 1);
|
|
64
|
+
_onChange([...inValue]);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
if (mode === "list") {
|
|
68
|
+
return (
|
|
69
|
+
<div className="tntd-array-input">
|
|
70
|
+
{inValue.map((item, index) => {
|
|
71
|
+
let fields = children(item, index);
|
|
72
|
+
if (!isArray(fields)) {
|
|
73
|
+
fields = get(fields, "props.children", []);
|
|
74
|
+
}
|
|
75
|
+
return (
|
|
76
|
+
<Row gutter={gutter} key={index} className="tntd-array-input-item">
|
|
77
|
+
{fields.map((field, i) => {
|
|
78
|
+
if (!isValidElement(field)) {
|
|
79
|
+
return field ? (
|
|
80
|
+
<Col span={4} key={i}>
|
|
81
|
+
{field}
|
|
82
|
+
</Col>
|
|
83
|
+
) : (
|
|
84
|
+
""
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
const {
|
|
88
|
+
name,
|
|
89
|
+
span = 4,
|
|
90
|
+
onChange: fieldChange,
|
|
91
|
+
...other
|
|
92
|
+
} = field?.props;
|
|
93
|
+
return (
|
|
94
|
+
<Col span={span} key={i}>
|
|
95
|
+
{React.cloneElement(field, {
|
|
96
|
+
value: item[name] || undefined,
|
|
97
|
+
onChange: e => {
|
|
98
|
+
fieldChange && fieldChange(e, index, changeValue);
|
|
99
|
+
const newValue = e.target ? e.target.value : e;
|
|
100
|
+
changeValue(index, name, newValue);
|
|
101
|
+
},
|
|
102
|
+
...other,
|
|
103
|
+
})}
|
|
104
|
+
</Col>
|
|
105
|
+
);
|
|
106
|
+
})}
|
|
107
|
+
<Col span={24 - (sum(fields.map(f => get(f, "props.span", 4))) % 24)}>
|
|
108
|
+
<span className="tntd-array-input-action">
|
|
109
|
+
{plusTip ? (
|
|
110
|
+
<Tooltip title={plusTip} placement="left">
|
|
111
|
+
<span className="mr10" onClick={() => onAdd(index)}>
|
|
112
|
+
{plusIcon}
|
|
113
|
+
</span>
|
|
114
|
+
</Tooltip>
|
|
115
|
+
) : (
|
|
116
|
+
<span className="mr10" onClick={() => onAdd(index)}>
|
|
117
|
+
{plusIcon}
|
|
118
|
+
</span>
|
|
119
|
+
)}
|
|
120
|
+
{deleteTip ? (
|
|
121
|
+
<Tooltip title={deleteTip} placement="right">
|
|
122
|
+
<span onClick={() => onDelete(index)}>
|
|
123
|
+
{deleteIcon}
|
|
124
|
+
</span>
|
|
125
|
+
</Tooltip>
|
|
126
|
+
) : (
|
|
127
|
+
<span onClick={() => onDelete(index)}>{deleteIcon}</span>
|
|
128
|
+
)}
|
|
129
|
+
</span>
|
|
130
|
+
</Col>
|
|
131
|
+
</Row>
|
|
132
|
+
);
|
|
133
|
+
})}
|
|
134
|
+
{inValue.length === 0 && <a onClick={() => onAdd()}>{addText}</a>}
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
} else {
|
|
138
|
+
let fields = children({}, 0);
|
|
139
|
+
if (!isArray(fields)) {
|
|
140
|
+
fields = get(fields, "props.children", []);
|
|
208
141
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
142
|
+
const dataSource = inValue.map((value, index) => {
|
|
143
|
+
const fields = children(value, index);
|
|
144
|
+
const back = {};
|
|
145
|
+
fields.forEach(field => {
|
|
146
|
+
const name = field?.props?.name;
|
|
147
|
+
name && set(back, name, field);
|
|
148
|
+
});
|
|
149
|
+
return back;
|
|
150
|
+
});
|
|
151
|
+
return (
|
|
152
|
+
<div className="tntd-array-input">
|
|
153
|
+
<Table
|
|
154
|
+
dataSource={dataSource}
|
|
155
|
+
pagination={false}
|
|
156
|
+
locale={{
|
|
157
|
+
emptyText: <a onClick={() => onAdd()}>{addText}</a>,
|
|
158
|
+
}}
|
|
159
|
+
>
|
|
160
|
+
{fields.map(field => {
|
|
161
|
+
const { name, span, title } = field?.props || {};
|
|
162
|
+
return (
|
|
163
|
+
<Column
|
|
164
|
+
key={name}
|
|
165
|
+
dataIndex={name}
|
|
166
|
+
title={title}
|
|
167
|
+
width={getWidth(span || 24 / (fields.length + 1))}
|
|
168
|
+
render={(field, row, index) => {
|
|
169
|
+
if (!isValidElement(field)) {
|
|
170
|
+
return field;
|
|
171
|
+
}
|
|
172
|
+
const { onChange: fieldChange } = field.props;
|
|
173
|
+
return React.cloneElement(field, {
|
|
174
|
+
value: inValue[index][name] || undefined,
|
|
175
|
+
onChange: e => {
|
|
176
|
+
fieldChange && fieldChange(e, index, changeValue);
|
|
177
|
+
const newValue = e.target ? e.target.value : e;
|
|
178
|
+
changeValue(index, name, newValue);
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
}}
|
|
182
|
+
></Column>
|
|
183
|
+
);
|
|
184
|
+
})}
|
|
185
|
+
<Column
|
|
186
|
+
key="action"
|
|
187
|
+
dataIndex="action"
|
|
188
|
+
title="操作"
|
|
189
|
+
width={getWidth(24 - (sumBy(fields, "props.span") % 24))}
|
|
190
|
+
render={(text, row, index) => {
|
|
191
|
+
return (
|
|
192
|
+
<span className="tntd-array-input-action">
|
|
193
|
+
{plusTip ? (
|
|
194
|
+
<Tooltip title={plusTip} placement="left">
|
|
195
|
+
<span className="mr10" onClick={() => onAdd(index)}>
|
|
196
|
+
{plusIcon}
|
|
197
|
+
</span>
|
|
198
|
+
</Tooltip>
|
|
199
|
+
) : (
|
|
200
|
+
<span className="mr10" onClick={() => onAdd(index)}>
|
|
201
|
+
{plusIcon}
|
|
202
|
+
</span>
|
|
203
|
+
)}
|
|
204
|
+
{deleteTip ? (
|
|
205
|
+
<Tooltip title={deleteTip} placement="right">
|
|
206
|
+
<span onClick={() => onDelete(index)}>
|
|
207
|
+
{deleteIcon}
|
|
208
|
+
</span>
|
|
209
|
+
</Tooltip>
|
|
210
|
+
) : (
|
|
211
|
+
<span onClick={() => onDelete(index)}>{deleteIcon}</span>
|
|
212
|
+
)}
|
|
213
|
+
</span>
|
|
214
|
+
);
|
|
215
|
+
}}
|
|
216
|
+
></Column>
|
|
217
|
+
</Table>
|
|
218
|
+
</div>
|
|
219
|
+
);
|
|
220
220
|
}
|
|
221
|
-
|
|
222
|
-
var dataSource = inValue.map(function (value, index) {
|
|
223
|
-
var fields = children(value, index);
|
|
224
|
-
var back = {};
|
|
225
|
-
fields.forEach(function (field) {
|
|
226
|
-
var _field$props;
|
|
227
|
-
|
|
228
|
-
var name = field == null ? void 0 : (_field$props = field.props) == null ? void 0 : _field$props.name;
|
|
229
|
-
name && (0, _lodash.set)(back, name, field);
|
|
230
|
-
});
|
|
231
|
-
return back;
|
|
232
|
-
});
|
|
233
|
-
return _react["default"].createElement("div", {
|
|
234
|
-
className: "tntd-array-input"
|
|
235
|
-
}, _react["default"].createElement(_table["default"], {
|
|
236
|
-
dataSource: dataSource,
|
|
237
|
-
pagination: false,
|
|
238
|
-
locale: {
|
|
239
|
-
emptyText: _react["default"].createElement("a", {
|
|
240
|
-
onClick: function onClick() {
|
|
241
|
-
return onAdd();
|
|
242
|
-
}
|
|
243
|
-
}, addText)
|
|
244
|
-
}
|
|
245
|
-
}, fields.map(function (field) {
|
|
246
|
-
var _ref3 = (field == null ? void 0 : field.props) || {},
|
|
247
|
-
name = _ref3.name,
|
|
248
|
-
span = _ref3.span,
|
|
249
|
-
title = _ref3.title;
|
|
250
|
-
|
|
251
|
-
return _react["default"].createElement(Column, {
|
|
252
|
-
key: name,
|
|
253
|
-
dataIndex: name,
|
|
254
|
-
title: title,
|
|
255
|
-
width: getWidth(span || 24 / (fields.length + 1)),
|
|
256
|
-
render: function render(field, row, index) {
|
|
257
|
-
if (!(0, _react.isValidElement)(field)) {
|
|
258
|
-
return field;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
var fieldChange = field.props.onChange;
|
|
262
|
-
return _react["default"].cloneElement(field, {
|
|
263
|
-
value: inValue[index][name] || undefined,
|
|
264
|
-
onChange: function onChange(e) {
|
|
265
|
-
fieldChange && fieldChange(e, index, changeValue);
|
|
266
|
-
var newValue = e.target ? e.target.value : e;
|
|
267
|
-
changeValue(index, name, newValue);
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
}), _react["default"].createElement(Column, {
|
|
273
|
-
key: "action",
|
|
274
|
-
dataIndex: "action",
|
|
275
|
-
title: "\u64CD\u4F5C",
|
|
276
|
-
width: getWidth(24 - (0, _lodash.sumBy)(fields, "props.span") % 24),
|
|
277
|
-
render: function render(text, row, index) {
|
|
278
|
-
return _react["default"].createElement("span", {
|
|
279
|
-
className: "tntd-array-input-action"
|
|
280
|
-
}, plusTip ? _react["default"].createElement(_tooltip["default"], {
|
|
281
|
-
title: plusTip,
|
|
282
|
-
placement: "left"
|
|
283
|
-
}, _react["default"].createElement("span", {
|
|
284
|
-
className: "mr10",
|
|
285
|
-
onClick: function onClick() {
|
|
286
|
-
return onAdd(index);
|
|
287
|
-
}
|
|
288
|
-
}, _icon.plusIcon)) : _react["default"].createElement("span", {
|
|
289
|
-
className: "mr10",
|
|
290
|
-
onClick: function onClick() {
|
|
291
|
-
return onAdd(index);
|
|
292
|
-
}
|
|
293
|
-
}, _icon.plusIcon), deleteTip ? _react["default"].createElement(_tooltip["default"], {
|
|
294
|
-
title: deleteTip,
|
|
295
|
-
placement: "right"
|
|
296
|
-
}, _react["default"].createElement("span", {
|
|
297
|
-
onClick: function onClick() {
|
|
298
|
-
return onDelete(index);
|
|
299
|
-
}
|
|
300
|
-
}, _icon.deleteIcon)) : _react["default"].createElement("span", {
|
|
301
|
-
onClick: function onClick() {
|
|
302
|
-
return onDelete(index);
|
|
303
|
-
}
|
|
304
|
-
}, _icon.deleteIcon));
|
|
305
|
-
}
|
|
306
|
-
})));
|
|
307
|
-
}
|
|
308
|
-
}
|
|
221
|
+
}
|
package/lib/AuthContext.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { createContext } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
|
|
10
|
-
var _default = (0, _react.createContext)(function () {
|
|
11
|
-
return true;
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
exports["default"] = _default;
|
|
3
|
+
export default createContext(() => true);
|