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