@zat-design/sisyphus-react 3.4.9 → 3.4.10-beta.10
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/dist/index.esm.css +66 -52
- package/dist/less.esm.css +66 -52
- package/es/ProEditTable/components/DndWrapper/index.d.ts +1 -0
- package/es/ProEditTable/components/DndWrapper/index.js +4 -3
- package/es/ProEditTable/components/RenderField/index.js +20 -1
- package/es/ProEditTable/index.js +49 -56
- package/es/ProEditTable/propsType.d.ts +7 -2
- package/es/ProEditTable/style/index.less +10 -0
- package/es/ProEditTable/utils/index.js +1 -0
- package/es/ProEnum/components/Group.d.ts +1 -0
- package/es/ProEnum/index.js +11 -5
- package/es/ProEnum/style/index.less +2 -2
- package/es/ProForm/components/base/InputNumber/index.js +41 -24
- package/es/ProForm/components/combination/FormList/components/ActionButton.js +83 -37
- package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +72 -26
- package/es/ProForm/components/combination/FormList/propsType.d.ts +4 -4
- package/es/ProForm/components/combination/Group/component/AddonWrapper/index.d.ts +8 -0
- package/es/ProForm/components/combination/Group/component/AddonWrapper/index.js +18 -0
- package/es/ProForm/components/combination/Group/component/AddonWrapper/index.less +10 -0
- package/es/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
- package/es/ProForm/components/combination/Group/component/ComRender.js +29 -13
- package/es/ProForm/components/combination/Group/index.d.ts +2 -2
- package/es/ProForm/components/combination/Group/index.js +7 -7
- package/es/ProForm/components/combination/Group/style/index.less +1 -1
- package/es/ProForm/components/combination/Group/utils.d.ts +1 -1
- package/es/ProForm/components/combination/Group/utils.js +23 -4
- package/es/ProForm/components/combination/ProCascader/index.js +2 -2
- package/es/ProForm/components/combination/ProCascader/utils/index.js +8 -3
- package/es/ProForm/components/combination/ProModalSelect/index.js +1 -1
- package/es/ProForm/components/combination/ProRangeLimit/index.d.ts +1 -1
- package/es/ProForm/components/combination/ProRangeLimit/index.js +10 -5
- package/es/ProForm/components/render/RenderFields.js +4 -1
- package/es/ProForm/utils/useDeepCompareMemo.d.ts +1 -1
- package/es/ProForm/utils/useDeepCompareMemo.js +2 -1
- package/es/ProForm/utils/useForm.js +10 -1
- package/es/ProLayout/components/ProCollapse/style/index.less +5 -2
- package/es/ProLayout/style/index.less +1 -1
- package/es/ProSelect/index.js +6 -3
- package/es/ProSelect/utils/index.d.ts +2 -1
- package/es/ProSelect/utils/index.js +9 -6
- package/es/ProTree/components/ProTree.js +18 -10
- package/es/ProTree/components/ProTreeSelect/index.js +2 -2
- package/es/ProTree/components/Tree.js +15 -7
- package/es/ProTree/index.js +2 -1
- package/es/ProTree/propsType.d.ts +5 -0
- package/es/ProUpload/components/ButtonRender.d.ts +1 -0
- package/es/ProUpload/components/ButtonRender.js +3 -1
- package/es/ProUpload/components/FileItem.d.ts +1 -0
- package/es/ProUpload/components/FileItem.js +21 -3
- package/es/ProUpload/index.js +4 -2
- package/es/ProUpload/propsType.d.ts +5 -0
- package/es/ProUpload/style/index.less +101 -111
- package/lib/ProEditTable/components/DndWrapper/index.d.ts +1 -0
- package/lib/ProEditTable/components/DndWrapper/index.js +4 -3
- package/lib/ProEditTable/components/RenderField/index.js +20 -1
- package/lib/ProEditTable/index.js +48 -55
- package/lib/ProEditTable/propsType.d.ts +7 -2
- package/lib/ProEditTable/style/index.less +10 -0
- package/lib/ProEditTable/utils/index.js +1 -0
- package/lib/ProEnum/components/Group.d.ts +1 -0
- package/lib/ProEnum/index.js +11 -5
- package/lib/ProEnum/style/index.less +2 -2
- package/lib/ProForm/components/base/InputNumber/index.js +40 -23
- package/lib/ProForm/components/combination/FormList/components/ActionButton.js +83 -37
- package/lib/ProForm/components/combination/FormList/components/ToolbarButton.js +72 -26
- package/lib/ProForm/components/combination/FormList/propsType.d.ts +4 -4
- package/lib/ProForm/components/combination/Group/component/AddonWrapper/index.d.ts +8 -0
- package/lib/ProForm/components/combination/Group/component/AddonWrapper/index.js +24 -0
- package/lib/ProForm/components/combination/Group/component/AddonWrapper/index.less +10 -0
- package/lib/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
- package/lib/ProForm/components/combination/Group/component/ComRender.js +31 -15
- package/lib/ProForm/components/combination/Group/index.d.ts +2 -2
- package/lib/ProForm/components/combination/Group/index.js +6 -6
- package/lib/ProForm/components/combination/Group/style/index.less +1 -1
- package/lib/ProForm/components/combination/Group/utils.d.ts +1 -1
- package/lib/ProForm/components/combination/Group/utils.js +24 -5
- package/lib/ProForm/components/combination/ProCascader/index.js +1 -1
- package/lib/ProForm/components/combination/ProCascader/utils/index.js +8 -3
- package/lib/ProForm/components/combination/ProModalSelect/index.js +1 -1
- package/lib/ProForm/components/combination/ProRangeLimit/index.d.ts +1 -1
- package/lib/ProForm/components/combination/ProRangeLimit/index.js +10 -5
- package/lib/ProForm/components/render/RenderFields.js +4 -1
- package/lib/ProForm/utils/useDeepCompareMemo.d.ts +1 -1
- package/lib/ProForm/utils/useDeepCompareMemo.js +2 -1
- package/lib/ProForm/utils/useForm.js +10 -1
- package/lib/ProLayout/components/ProCollapse/style/index.less +5 -2
- package/lib/ProLayout/style/index.less +1 -1
- package/lib/ProSelect/index.js +6 -3
- package/lib/ProSelect/utils/index.d.ts +2 -1
- package/lib/ProSelect/utils/index.js +9 -6
- package/lib/ProTree/components/ProTree.js +17 -9
- package/lib/ProTree/components/ProTreeSelect/index.js +2 -2
- package/lib/ProTree/components/Tree.js +15 -7
- package/lib/ProTree/index.js +2 -1
- package/lib/ProTree/propsType.d.ts +5 -0
- package/lib/ProUpload/components/ButtonRender.d.ts +1 -0
- package/lib/ProUpload/components/ButtonRender.js +3 -1
- package/lib/ProUpload/components/FileItem.d.ts +1 -0
- package/lib/ProUpload/components/FileItem.js +19 -3
- package/lib/ProUpload/index.js +4 -2
- package/lib/ProUpload/propsType.d.ts +5 -0
- package/lib/ProUpload/style/index.less +101 -111
- package/package.json +2 -2
- package/es/ProForm/components/combination/_Group/index.d.ts +0 -4
- package/es/ProForm/components/combination/_Group/index.js +0 -109
- package/es/ProForm/components/combination/_Group/propsType.d.ts +0 -35
- package/es/ProForm/components/combination/_Group/propsType.js +0 -1
- package/es/ProForm/components/combination/_Group/style/index.less +0 -131
- package/es/ProForm/components/combination/_Group/utils.d.ts +0 -10
- package/es/ProForm/components/combination/_Group/utils.js +0 -46
- package/lib/ProForm/components/combination/_Group/index.d.ts +0 -4
- package/lib/ProForm/components/combination/_Group/index.js +0 -113
- package/lib/ProForm/components/combination/_Group/propsType.d.ts +0 -35
- package/lib/ProForm/components/combination/_Group/propsType.js +0 -5
- package/lib/ProForm/components/combination/_Group/style/index.less +0 -131
- package/lib/ProForm/components/combination/_Group/utils.d.ts +0 -10
- package/lib/ProForm/components/combination/_Group/utils.js +0 -53
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import "antd/es/button/style";
|
|
2
2
|
import _Button from "antd/es/button";
|
|
3
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
3
|
import "antd/es/popconfirm/style";
|
|
5
4
|
import _Popconfirm from "antd/es/popconfirm";
|
|
6
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
6
|
import "antd/es/space/style";
|
|
8
7
|
import _Space from "antd/es/space";
|
|
8
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
9
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
9
10
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
10
|
-
|
|
11
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
12
|
+
var _excluded = ["label", "onClick", "onHandle", "type", "needConfirm", "confirmProps", "title"],
|
|
11
13
|
_excluded2 = ["onClick", "label"];
|
|
12
14
|
import { createElement as _createElement } from "react";
|
|
13
15
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -26,7 +28,6 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
26
28
|
var add = operation.add;
|
|
27
29
|
add(undefined, index + 1);
|
|
28
30
|
},
|
|
29
|
-
type: 'text',
|
|
30
31
|
label: "".concat(locale.ProForm.formListActions[0]),
|
|
31
32
|
icon: _jsx(PlusSquareOutlined, {})
|
|
32
33
|
},
|
|
@@ -38,7 +39,6 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
38
39
|
var remove = operation.remove;
|
|
39
40
|
remove(index);
|
|
40
41
|
},
|
|
41
|
-
type: 'text',
|
|
42
42
|
label: "".concat(locale.ProForm.formListActions[1]),
|
|
43
43
|
icon: mode === 'less' ? _jsx(ProIcon, {
|
|
44
44
|
type: "solid-close",
|
|
@@ -55,7 +55,6 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
55
55
|
var add = operation.add;
|
|
56
56
|
add(record, index + 1);
|
|
57
57
|
},
|
|
58
|
-
type: 'text',
|
|
59
58
|
label: "".concat(locale.ProForm.formListActions[2]),
|
|
60
59
|
icon: _jsx(CopyOutlined, {})
|
|
61
60
|
},
|
|
@@ -67,7 +66,6 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
67
66
|
var move = operation.move;
|
|
68
67
|
move(index, index - 1);
|
|
69
68
|
},
|
|
70
|
-
type: 'text',
|
|
71
69
|
label: "".concat(locale.ProForm.formListActions[3]),
|
|
72
70
|
icon: _jsx(UpSquareOutlined, {})
|
|
73
71
|
},
|
|
@@ -79,7 +77,6 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
79
77
|
var move = operation.move;
|
|
80
78
|
move(index, index + 1);
|
|
81
79
|
},
|
|
82
|
-
type: 'text',
|
|
83
80
|
label: "".concat(locale.ProForm.formListActions[4]),
|
|
84
81
|
icon: _jsx(DownSquareOutlined, {})
|
|
85
82
|
}
|
|
@@ -103,7 +100,7 @@ var getDefaultActions = function getDefaultActions(mode) {
|
|
|
103
100
|
return originActions;
|
|
104
101
|
};
|
|
105
102
|
var defaultActionProps = [{
|
|
106
|
-
|
|
103
|
+
type: 'delete'
|
|
107
104
|
}];
|
|
108
105
|
var ActionButton = function ActionButton(props) {
|
|
109
106
|
var namePath = props.namePath,
|
|
@@ -121,24 +118,69 @@ var ActionButton = function ActionButton(props) {
|
|
|
121
118
|
// 默认显示一个delete
|
|
122
119
|
var actionProps = useMemo(function () {
|
|
123
120
|
var _props$actionProps;
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
// 兼容 actionType 和 type
|
|
122
|
+
var _actionProps = (_props$actionProps = props.actionProps) === null || _props$actionProps === void 0 ? void 0 : _props$actionProps.map(function (item) {
|
|
123
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
124
|
+
// @ts-ignore
|
|
125
|
+
type: item.actionType
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
if (!(_actionProps === null || _actionProps === void 0 ? void 0 : _actionProps.find(function (item) {
|
|
129
|
+
return item.type === 'delete';
|
|
126
130
|
}))) {
|
|
127
|
-
return
|
|
131
|
+
return _actionProps ? [].concat(_toConsumableArray(_actionProps), defaultActionProps) : defaultActionProps;
|
|
128
132
|
}
|
|
129
|
-
return
|
|
133
|
+
return _actionProps;
|
|
130
134
|
}, [props.actionProps]);
|
|
131
|
-
var handleClick = function
|
|
135
|
+
var handleClick = /*#__PURE__*/function () {
|
|
136
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(defaultCallback, callback, index, item) {
|
|
137
|
+
var value, data;
|
|
138
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
139
|
+
while (1) switch (_context.prev = _context.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
value = form.getFieldValue(namePath);
|
|
142
|
+
_context.next = 3;
|
|
143
|
+
return callback === null || callback === void 0 ? void 0 : callback(value, {
|
|
144
|
+
namePath: namePath,
|
|
145
|
+
index: index,
|
|
146
|
+
operation: operation,
|
|
147
|
+
form: form
|
|
148
|
+
});
|
|
149
|
+
case 3:
|
|
150
|
+
data = _context.sent;
|
|
151
|
+
if (!(!callback || data === true)) {
|
|
152
|
+
_context.next = 7;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
defaultCallback === null || defaultCallback === void 0 ? void 0 : defaultCallback(value, {
|
|
156
|
+
namePath: namePath,
|
|
157
|
+
index: index,
|
|
158
|
+
operation: operation,
|
|
159
|
+
form: form
|
|
160
|
+
});
|
|
161
|
+
return _context.abrupt("return");
|
|
162
|
+
case 7:
|
|
163
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === 'add') {
|
|
164
|
+
operation.add(data, index !== undefined ? index + 1 : undefined);
|
|
165
|
+
}
|
|
166
|
+
case 8:
|
|
167
|
+
case "end":
|
|
168
|
+
return _context.stop();
|
|
169
|
+
}
|
|
170
|
+
}, _callee);
|
|
171
|
+
}));
|
|
172
|
+
return function handleClick(_x, _x2, _x3, _x4) {
|
|
173
|
+
return _ref6.apply(this, arguments);
|
|
174
|
+
};
|
|
175
|
+
}();
|
|
176
|
+
var customClick = function customClick(callback, index) {
|
|
132
177
|
var value = form.getFieldValue(namePath);
|
|
133
|
-
|
|
178
|
+
callback === null || callback === void 0 ? void 0 : callback(value, {
|
|
134
179
|
namePath: namePath,
|
|
135
180
|
index: index,
|
|
136
181
|
operation: operation,
|
|
137
182
|
form: form
|
|
138
183
|
});
|
|
139
|
-
if ((item === null || item === void 0 ? void 0 : item.actionType) === 'add') {
|
|
140
|
-
operation.add(data, index !== undefined ? index + 1 : undefined);
|
|
141
|
-
}
|
|
142
184
|
};
|
|
143
185
|
var defaultActions = useMemo(function () {
|
|
144
186
|
return getDefaultActions(mode);
|
|
@@ -147,18 +189,18 @@ var ActionButton = function ActionButton(props) {
|
|
|
147
189
|
align: "start",
|
|
148
190
|
className: "pro-form-list-action",
|
|
149
191
|
children: actionProps === null || actionProps === void 0 ? void 0 : actionProps.map(function (item) {
|
|
150
|
-
if (item.show === false) return _jsx("span", {}, "".concat(item === null || item === void 0 ? void 0 : item.
|
|
192
|
+
if (item.show === false) return _jsx("span", {}, "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index));
|
|
151
193
|
if (isFunction(item.show) && !item.show(form.getFieldValue(namePath), {
|
|
152
194
|
namePath: namePath,
|
|
153
195
|
index: index,
|
|
154
196
|
form: form
|
|
155
197
|
})) {
|
|
156
|
-
return _jsx("span", {}, "".concat(item === null || item === void 0 ? void 0 : item.
|
|
198
|
+
return _jsx("span", {}, "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index));
|
|
157
199
|
}
|
|
158
200
|
var label = item.label,
|
|
159
201
|
onClick = item.onClick,
|
|
160
202
|
onHandle = item.onHandle,
|
|
161
|
-
|
|
203
|
+
type = item.type,
|
|
162
204
|
needConfirm = item.needConfirm,
|
|
163
205
|
confirmProps = item.confirmProps,
|
|
164
206
|
title = item.title,
|
|
@@ -166,27 +208,27 @@ var ActionButton = function ActionButton(props) {
|
|
|
166
208
|
var _needConfirm = needConfirm || confirmProps;
|
|
167
209
|
var _confirmProps = !confirmProps || confirmProps === true ? {} : confirmProps;
|
|
168
210
|
var _onClick = onClick || onHandle;
|
|
169
|
-
if (['add', 'delete', 'copy', 'moveUp', 'moveDown'].includes(
|
|
211
|
+
if (['add', 'delete', 'copy', 'moveUp', 'moveDown'].includes(type)) {
|
|
170
212
|
// 禁用状态默认隐藏内置操作按钮
|
|
171
213
|
if (disabled || isView) return _jsx(_Fragment, {});
|
|
172
|
-
var _defaultActions$
|
|
173
|
-
internalOnClick = _defaultActions$
|
|
174
|
-
defaultLabel = _defaultActions$
|
|
175
|
-
defaultRest = _objectWithoutProperties(_defaultActions$
|
|
214
|
+
var _defaultActions$type = defaultActions[type],
|
|
215
|
+
internalOnClick = _defaultActions$type.onClick,
|
|
216
|
+
defaultLabel = _defaultActions$type.label,
|
|
217
|
+
defaultRest = _objectWithoutProperties(_defaultActions$type, _excluded2);
|
|
176
218
|
// 小于min不可删除
|
|
177
|
-
if (min && min >= fields.length && ['delete'].includes(
|
|
219
|
+
if (min && min >= fields.length && ['delete'].includes(type)) {
|
|
178
220
|
return false;
|
|
179
221
|
}
|
|
180
222
|
// 大于等于max不可新增和复制
|
|
181
|
-
if (max && max <= fields.length && ['add', 'copy'].includes(
|
|
223
|
+
if (max && max <= fields.length && ['add', 'copy'].includes(type)) {
|
|
182
224
|
return false;
|
|
183
225
|
}
|
|
184
226
|
// 下标为零 不可向上移动
|
|
185
|
-
if (index === 0 && ['moveUp'].includes(
|
|
227
|
+
if (index === 0 && ['moveUp'].includes(type)) {
|
|
186
228
|
return false;
|
|
187
229
|
}
|
|
188
230
|
// 下标最大 不可向下移动
|
|
189
|
-
if (index + 1 === fields.length &&
|
|
231
|
+
if (index + 1 === fields.length && type === 'moveDown') {
|
|
190
232
|
return false;
|
|
191
233
|
}
|
|
192
234
|
return _needConfirm ? _jsx(_Popconfirm, _objectSpread(_objectSpread({
|
|
@@ -195,22 +237,24 @@ var ActionButton = function ActionButton(props) {
|
|
|
195
237
|
return e.stopPropagation();
|
|
196
238
|
},
|
|
197
239
|
onConfirm: function onConfirm(e) {
|
|
198
|
-
handleClick(
|
|
240
|
+
handleClick(internalOnClick, _onClick, index, item);
|
|
199
241
|
}
|
|
200
242
|
}, _confirmProps), {}, {
|
|
201
243
|
children: _jsx(_Button, _objectSpread(_objectSpread(_objectSpread({}, defaultRest), rest), {}, {
|
|
244
|
+
type: "text",
|
|
202
245
|
onClick: function onClick(e) {
|
|
203
246
|
return e.stopPropagation();
|
|
204
247
|
},
|
|
205
248
|
children: label || defaultLabel
|
|
206
249
|
}))
|
|
207
|
-
}), "".concat(item === null || item === void 0 ? void 0 : item.
|
|
250
|
+
}), "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index)) : _jsx(_Button, _objectSpread(_objectSpread(_objectSpread({}, defaultRest), rest), {}, {
|
|
251
|
+
type: "text",
|
|
208
252
|
onClick: function onClick(e) {
|
|
209
253
|
e.stopPropagation();
|
|
210
|
-
handleClick(
|
|
254
|
+
handleClick(internalOnClick, _onClick, index, item);
|
|
211
255
|
},
|
|
212
256
|
children: label || defaultLabel
|
|
213
|
-
}), "".concat(item === null || item === void 0 ? void 0 : item.
|
|
257
|
+
}), "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index));
|
|
214
258
|
}
|
|
215
259
|
return needConfirm ? _jsx(_Popconfirm, _objectSpread(_objectSpread({
|
|
216
260
|
title: title !== null && title !== void 0 ? title : "".concat(locale.ProForm.formListConfirmMessage),
|
|
@@ -218,20 +262,22 @@ var ActionButton = function ActionButton(props) {
|
|
|
218
262
|
return e.stopPropagation();
|
|
219
263
|
},
|
|
220
264
|
onConfirm: function onConfirm() {
|
|
221
|
-
return
|
|
265
|
+
return customClick(_onClick, index);
|
|
222
266
|
}
|
|
223
267
|
}, _confirmProps), {}, {
|
|
224
268
|
children: _jsx(_Button, _objectSpread(_objectSpread({}, rest), {}, {
|
|
269
|
+
type: "text",
|
|
225
270
|
onClick: function onClick(e) {
|
|
226
271
|
return e.stopPropagation();
|
|
227
272
|
},
|
|
228
273
|
children: label
|
|
229
274
|
}))
|
|
230
|
-
}), "".concat(item === null || item === void 0 ? void 0 : item.
|
|
231
|
-
key: "".concat(item === null || item === void 0 ? void 0 : item.
|
|
275
|
+
}), "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index)) : ( /*#__PURE__*/_createElement(_Button, _objectSpread(_objectSpread({}, rest), {}, {
|
|
276
|
+
key: "".concat(item === null || item === void 0 ? void 0 : item.type).concat(index),
|
|
277
|
+
type: "text",
|
|
232
278
|
onClick: function onClick(e) {
|
|
233
279
|
e.stopPropagation();
|
|
234
|
-
|
|
280
|
+
customClick(_onClick, index);
|
|
235
281
|
}
|
|
236
282
|
}), label));
|
|
237
283
|
})
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
1
|
import "antd/es/button/style";
|
|
3
2
|
import _Button from "antd/es/button";
|
|
4
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
4
|
import "antd/es/space/style";
|
|
6
5
|
import _Space from "antd/es/space";
|
|
6
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
7
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
7
8
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
8
|
-
|
|
9
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
10
|
+
var _excluded = ["label", "onClick", "onHandle", "type"],
|
|
9
11
|
_excluded2 = ["onClick", "label"];
|
|
10
12
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
13
|
import { PlusOutlined } from '@ant-design/icons';
|
|
@@ -21,12 +23,11 @@ var actions = {
|
|
|
21
23
|
operation.add();
|
|
22
24
|
},
|
|
23
25
|
label: "".concat(locale.ProForm.formListActions[5]),
|
|
24
|
-
type: 'link',
|
|
25
26
|
icon: _jsx(PlusOutlined, {})
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
29
|
var defaultActionProps = [{
|
|
29
|
-
|
|
30
|
+
type: 'add'
|
|
30
31
|
}];
|
|
31
32
|
var ToolbarButton = function ToolbarButton(props) {
|
|
32
33
|
var namePath = props.namePath,
|
|
@@ -41,28 +42,71 @@ var ToolbarButton = function ToolbarButton(props) {
|
|
|
41
42
|
// 默认显示一个delete
|
|
42
43
|
var toolbarProps = useMemo(function () {
|
|
43
44
|
var _props$toolbarProps;
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
// 兼容 actionType 和 type
|
|
46
|
+
var _toolbarProps = (_props$toolbarProps = props.toolbarProps) === null || _props$toolbarProps === void 0 ? void 0 : _props$toolbarProps.map(function (item) {
|
|
47
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
type: item.actionType
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
if (!(_toolbarProps === null || _toolbarProps === void 0 ? void 0 : _toolbarProps.find(function (item) {
|
|
53
|
+
return item.type === 'add';
|
|
46
54
|
}))) {
|
|
47
|
-
return
|
|
55
|
+
return _toolbarProps ? [].concat(_toConsumableArray(_toolbarProps), defaultActionProps) : defaultActionProps;
|
|
48
56
|
}
|
|
49
|
-
return
|
|
57
|
+
return _toolbarProps;
|
|
50
58
|
}, [props.toolbarProps]);
|
|
51
|
-
var handleClick = function
|
|
59
|
+
var handleClick = /*#__PURE__*/function () {
|
|
60
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(defaultCallback, callback, item) {
|
|
61
|
+
var value, data;
|
|
62
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
63
|
+
while (1) switch (_context.prev = _context.next) {
|
|
64
|
+
case 0:
|
|
65
|
+
value = form.getFieldValue(namePath);
|
|
66
|
+
_context.next = 3;
|
|
67
|
+
return callback === null || callback === void 0 ? void 0 : callback(value, {
|
|
68
|
+
operation: operation,
|
|
69
|
+
form: form,
|
|
70
|
+
namePath: namePath
|
|
71
|
+
});
|
|
72
|
+
case 3:
|
|
73
|
+
data = _context.sent;
|
|
74
|
+
if (!(!callback || data === true)) {
|
|
75
|
+
_context.next = 7;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
defaultCallback === null || defaultCallback === void 0 ? void 0 : defaultCallback(value, {
|
|
79
|
+
operation: operation,
|
|
80
|
+
form: form,
|
|
81
|
+
namePath: namePath
|
|
82
|
+
});
|
|
83
|
+
return _context.abrupt("return");
|
|
84
|
+
case 7:
|
|
85
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === 'add' && data) {
|
|
86
|
+
operation.add(data);
|
|
87
|
+
}
|
|
88
|
+
case 8:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context.stop();
|
|
91
|
+
}
|
|
92
|
+
}, _callee);
|
|
93
|
+
}));
|
|
94
|
+
return function handleClick(_x, _x2, _x3) {
|
|
95
|
+
return _ref2.apply(this, arguments);
|
|
96
|
+
};
|
|
97
|
+
}();
|
|
98
|
+
var customClick = function customClick(callback, item) {
|
|
52
99
|
var value = form.getFieldValue(namePath);
|
|
53
|
-
|
|
100
|
+
callback === null || callback === void 0 ? void 0 : callback(value, {
|
|
54
101
|
operation: operation,
|
|
55
102
|
form: form,
|
|
56
103
|
namePath: namePath
|
|
57
104
|
});
|
|
58
|
-
if ((item === null || item === void 0 ? void 0 : item.actionType) === 'add' && data) {
|
|
59
|
-
operation.add(data);
|
|
60
|
-
}
|
|
61
105
|
};
|
|
62
106
|
return _jsx(_Space, {
|
|
63
107
|
align: "start",
|
|
64
108
|
className: "pro-form-list-toolbar",
|
|
65
|
-
children: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.map(function (item) {
|
|
109
|
+
children: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.map(function (item, index) {
|
|
66
110
|
if (item.show === false) return _jsx(_Fragment, {});
|
|
67
111
|
if (isFunction(item.show) && !item.show(form.getFieldValue(namePath), {
|
|
68
112
|
namePath: namePath,
|
|
@@ -73,32 +117,34 @@ var ToolbarButton = function ToolbarButton(props) {
|
|
|
73
117
|
var label = item.label,
|
|
74
118
|
_onClick2 = item.onClick,
|
|
75
119
|
onHandle = item.onHandle,
|
|
76
|
-
|
|
120
|
+
type = item.type,
|
|
77
121
|
rest = _objectWithoutProperties(item, _excluded);
|
|
78
122
|
var _onClick = _onClick2 || onHandle;
|
|
79
|
-
if (
|
|
123
|
+
if (type === 'add') {
|
|
80
124
|
if (disabled || isView) return _jsx(_Fragment, {});
|
|
81
|
-
var _actions$
|
|
82
|
-
internalOnClick = _actions$
|
|
83
|
-
defaultLabel = _actions$
|
|
84
|
-
defaultRest = _objectWithoutProperties(_actions$
|
|
125
|
+
var _actions$type = actions[type],
|
|
126
|
+
internalOnClick = _actions$type.onClick,
|
|
127
|
+
defaultLabel = _actions$type.label,
|
|
128
|
+
defaultRest = _objectWithoutProperties(_actions$type, _excluded2);
|
|
85
129
|
// 大于等于max不可新增
|
|
86
|
-
if (max && max <= fields.length &&
|
|
130
|
+
if (max && max <= fields.length && type === 'add') {
|
|
87
131
|
return false;
|
|
88
132
|
}
|
|
89
|
-
return _jsx(_Button, _objectSpread(_objectSpread(_objectSpread({}, actions[
|
|
133
|
+
return _jsx(_Button, _objectSpread(_objectSpread(_objectSpread({}, actions[type]), rest), {}, {
|
|
134
|
+
type: "link",
|
|
90
135
|
onClick: function onClick() {
|
|
91
|
-
return handleClick(
|
|
136
|
+
return handleClick(internalOnClick, _onClick, item);
|
|
92
137
|
},
|
|
93
138
|
children: label || defaultLabel
|
|
94
|
-
}),
|
|
139
|
+
}), "".concat(type).concat(index));
|
|
95
140
|
}
|
|
96
141
|
return _jsx(_Button, _objectSpread(_objectSpread({}, rest), {}, {
|
|
142
|
+
type: "link",
|
|
97
143
|
onClick: function onClick() {
|
|
98
|
-
return
|
|
144
|
+
return customClick(_onClick2, item);
|
|
99
145
|
},
|
|
100
146
|
children: label
|
|
101
|
-
}),
|
|
147
|
+
}), "".concat(type).concat(index));
|
|
102
148
|
})
|
|
103
149
|
});
|
|
104
150
|
};
|
|
@@ -14,8 +14,8 @@ export interface Option {
|
|
|
14
14
|
form: FormInstance;
|
|
15
15
|
operation: FormListOperation;
|
|
16
16
|
}
|
|
17
|
-
export interface ActionProps extends Omit<ButtonProps, 'onClick'> {
|
|
18
|
-
|
|
17
|
+
export interface ActionProps extends Omit<ButtonProps, 'onClick' | 'type'> {
|
|
18
|
+
type?: 'add' | 'delete' | 'copy' | 'moveUp' | 'moveDown';
|
|
19
19
|
onHandle?: Callback;
|
|
20
20
|
onClick?: Callback;
|
|
21
21
|
label?: string;
|
|
@@ -24,8 +24,8 @@ export interface ActionProps extends Omit<ButtonProps, 'onClick'> {
|
|
|
24
24
|
title?: string;
|
|
25
25
|
show?: boolean | ((record: any, option: Pick<Option, 'index' | 'form' | 'namePath'>) => boolean);
|
|
26
26
|
}
|
|
27
|
-
export interface ToolbarActionProps extends Omit<ActionProps, 'actionType' | 'onHandle' | 'onClick' | 'show'> {
|
|
28
|
-
|
|
27
|
+
export interface ToolbarActionProps extends Omit<ActionProps, 'actionType' | 'onHandle' | 'onClick' | 'show' | 'type'> {
|
|
28
|
+
type?: 'add';
|
|
29
29
|
onHandle?: ToolbarCallback;
|
|
30
30
|
onClick?: ToolbarCallback;
|
|
31
31
|
show?: boolean | ((record: any, option: Pick<Option, 'form' | 'namePath'>) => boolean);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './index.less';
|
|
3
|
+
var AddonWrapper = function AddonWrapper(props) {
|
|
4
|
+
var before = props.before,
|
|
5
|
+
after = props.after,
|
|
6
|
+
children = props.children;
|
|
7
|
+
return _jsxs("div", {
|
|
8
|
+
className: "addon-wrapper",
|
|
9
|
+
children: [before && _jsx("div", {
|
|
10
|
+
className: "before",
|
|
11
|
+
children: before
|
|
12
|
+
}), children, after && _jsx("div", {
|
|
13
|
+
className: "after",
|
|
14
|
+
children: after
|
|
15
|
+
})]
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export default AddonWrapper;
|
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps", "before", "after"];
|
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
import React from 'react';
|
|
6
7
|
import ConfirmWrapper from '../../../../components/render/ConfirmWrapper';
|
|
7
8
|
import { FieldProvider } from '../../../../utils/useFieldProps';
|
|
8
9
|
import * as componentMap from '../../../../../index';
|
|
10
|
+
import AddonWrapper from './AddonWrapper';
|
|
11
|
+
// 这里的key与组件内参数一致, 决定使用哪个包裹组件
|
|
12
|
+
var wrapperMap = {
|
|
13
|
+
confirm: ConfirmWrapper,
|
|
14
|
+
before: AddonWrapper,
|
|
15
|
+
after: AddonWrapper
|
|
16
|
+
};
|
|
17
|
+
// 增加middleware根据配置增加多层包裹
|
|
18
|
+
var getComRender = function getComRender(component, props, componentProps) {
|
|
19
|
+
var wrappers = Object.keys(wrapperMap);
|
|
20
|
+
var Com = component;
|
|
21
|
+
wrappers.forEach(function (item) {
|
|
22
|
+
if (item in props) {
|
|
23
|
+
var Wrapper = wrapperMap[item];
|
|
24
|
+
Com = _jsx(Wrapper, _objectSpread(_objectSpread(_objectSpread({}, componentProps), _defineProperty({}, item, props[item])), {}, {
|
|
25
|
+
children: Com
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return Com;
|
|
30
|
+
};
|
|
9
31
|
/** 渲染组件 */
|
|
10
32
|
var ComRender = function ComRender(props) {
|
|
11
33
|
var type = props.type,
|
|
@@ -13,24 +35,18 @@ var ComRender = function ComRender(props) {
|
|
|
13
35
|
component = props.component,
|
|
14
36
|
fieldProps = props.fieldProps,
|
|
15
37
|
contextProps = props.contextProps,
|
|
38
|
+
before = props.before,
|
|
39
|
+
after = props.after,
|
|
16
40
|
rest = _objectWithoutProperties(props, _excluded);
|
|
17
41
|
var TypeComponent = componentMap[type];
|
|
18
42
|
var componentProps = _objectSpread(_objectSpread({}, fieldProps), rest);
|
|
19
|
-
var Component;
|
|
20
|
-
|
|
21
|
-
Component = _jsx(ConfirmWrapper, _objectSpread(_objectSpread({
|
|
22
|
-
confirm: confirm
|
|
23
|
-
}, componentProps), {}, {
|
|
24
|
-
children: component || _jsx(TypeComponent, _objectSpread({}, componentProps))
|
|
25
|
-
}));
|
|
26
|
-
} else {
|
|
27
|
-
Component = component ? ( /*#__PURE__*/React.cloneElement(component, _objectSpread({}, componentProps))) : _jsx(TypeComponent, _objectSpread({}, componentProps));
|
|
28
|
-
}
|
|
43
|
+
var Component = component ? ( /*#__PURE__*/React.cloneElement(component, _objectSpread({}, componentProps))) : _jsx(TypeComponent, _objectSpread({}, componentProps));
|
|
44
|
+
var Com = getComRender(Component, props, componentProps);
|
|
29
45
|
return _jsx(FieldProvider, {
|
|
30
46
|
value: _objectSpread(_objectSpread({}, contextProps), {}, {
|
|
31
47
|
type: type
|
|
32
48
|
}),
|
|
33
|
-
children:
|
|
49
|
+
children: Com
|
|
34
50
|
});
|
|
35
51
|
};
|
|
36
52
|
export default ComRender;
|
|
@@ -6,5 +6,5 @@ import { GroupProps } from './propsType';
|
|
|
6
6
|
*
|
|
7
7
|
* render内部能力 show, component, value, onChange, disabled, clearNotShow, fieldProps
|
|
8
8
|
*/
|
|
9
|
-
declare const
|
|
10
|
-
export default
|
|
9
|
+
declare const Group: React.FC<GroupProps>;
|
|
10
|
+
export default Group;
|
|
@@ -7,7 +7,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { omit } from 'lodash';
|
|
9
9
|
import classnames from 'classnames';
|
|
10
|
-
import { insertSeparator,
|
|
10
|
+
import { insertSeparator, useTransformColumns } from './utils';
|
|
11
11
|
import ProForm from '../../../../ProForm';
|
|
12
12
|
import ComRender from './component/ComRender';
|
|
13
13
|
/**
|
|
@@ -16,7 +16,7 @@ import ComRender from './component/ComRender';
|
|
|
16
16
|
*
|
|
17
17
|
* render内部能力 show, component, value, onChange, disabled, clearNotShow, fieldProps
|
|
18
18
|
*/
|
|
19
|
-
var
|
|
19
|
+
var Group = function Group(props) {
|
|
20
20
|
var children = props.children,
|
|
21
21
|
className = props.className,
|
|
22
22
|
_props$space = props.space,
|
|
@@ -41,7 +41,7 @@ var GroupCopy = function GroupCopy(props) {
|
|
|
41
41
|
_option.current[index] = option;
|
|
42
42
|
onChange(_value, _option.current);
|
|
43
43
|
};
|
|
44
|
-
var columnsProps =
|
|
44
|
+
var columnsProps = useTransformColumns({
|
|
45
45
|
columns: children,
|
|
46
46
|
name: name,
|
|
47
47
|
names: names,
|
|
@@ -66,12 +66,12 @@ var GroupCopy = function GroupCopy(props) {
|
|
|
66
66
|
return _jsx("div", {
|
|
67
67
|
className: _className,
|
|
68
68
|
children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? _jsx(_Space.Compact, {
|
|
69
|
-
children: columns.map(function (column) {
|
|
69
|
+
children: columns.map(function (column, index) {
|
|
70
70
|
return _jsx(ComRender, _objectSpread(_objectSpread({
|
|
71
71
|
contextProps: contextProps
|
|
72
72
|
}, column), {}, {
|
|
73
73
|
otherProps: otherProps
|
|
74
|
-
}));
|
|
74
|
+
}), column.name);
|
|
75
75
|
})
|
|
76
76
|
}) : _jsx(_Space, _objectSpread(_objectSpread({
|
|
77
77
|
align: "start"
|
|
@@ -81,9 +81,9 @@ var GroupCopy = function GroupCopy(props) {
|
|
|
81
81
|
contextProps: contextProps
|
|
82
82
|
}, column), {}, {
|
|
83
83
|
otherProps: otherProps
|
|
84
|
-
}));
|
|
84
|
+
}), column.name);
|
|
85
85
|
})
|
|
86
86
|
}))
|
|
87
87
|
});
|
|
88
88
|
};
|
|
89
|
-
export default
|
|
89
|
+
export default Group;
|
|
@@ -59,5 +59,5 @@ interface ColumnsTransformerParams {
|
|
|
59
59
|
groupProps: GroupProps;
|
|
60
60
|
}
|
|
61
61
|
/** 转换columns */
|
|
62
|
-
export declare const
|
|
62
|
+
export declare const useTransformColumns: (params: ColumnsTransformerParams) => any[];
|
|
63
63
|
export {};
|