@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.
Files changed (117) hide show
  1. package/dist/index.esm.css +66 -52
  2. package/dist/less.esm.css +66 -52
  3. package/es/ProEditTable/components/DndWrapper/index.d.ts +1 -0
  4. package/es/ProEditTable/components/DndWrapper/index.js +4 -3
  5. package/es/ProEditTable/components/RenderField/index.js +20 -1
  6. package/es/ProEditTable/index.js +49 -56
  7. package/es/ProEditTable/propsType.d.ts +7 -2
  8. package/es/ProEditTable/style/index.less +10 -0
  9. package/es/ProEditTable/utils/index.js +1 -0
  10. package/es/ProEnum/components/Group.d.ts +1 -0
  11. package/es/ProEnum/index.js +11 -5
  12. package/es/ProEnum/style/index.less +2 -2
  13. package/es/ProForm/components/base/InputNumber/index.js +41 -24
  14. package/es/ProForm/components/combination/FormList/components/ActionButton.js +83 -37
  15. package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +72 -26
  16. package/es/ProForm/components/combination/FormList/propsType.d.ts +4 -4
  17. package/es/ProForm/components/combination/Group/component/AddonWrapper/index.d.ts +8 -0
  18. package/es/ProForm/components/combination/Group/component/AddonWrapper/index.js +18 -0
  19. package/es/ProForm/components/combination/Group/component/AddonWrapper/index.less +10 -0
  20. package/es/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
  21. package/es/ProForm/components/combination/Group/component/ComRender.js +29 -13
  22. package/es/ProForm/components/combination/Group/index.d.ts +2 -2
  23. package/es/ProForm/components/combination/Group/index.js +7 -7
  24. package/es/ProForm/components/combination/Group/style/index.less +1 -1
  25. package/es/ProForm/components/combination/Group/utils.d.ts +1 -1
  26. package/es/ProForm/components/combination/Group/utils.js +23 -4
  27. package/es/ProForm/components/combination/ProCascader/index.js +2 -2
  28. package/es/ProForm/components/combination/ProCascader/utils/index.js +8 -3
  29. package/es/ProForm/components/combination/ProModalSelect/index.js +1 -1
  30. package/es/ProForm/components/combination/ProRangeLimit/index.d.ts +1 -1
  31. package/es/ProForm/components/combination/ProRangeLimit/index.js +10 -5
  32. package/es/ProForm/components/render/RenderFields.js +4 -1
  33. package/es/ProForm/utils/useDeepCompareMemo.d.ts +1 -1
  34. package/es/ProForm/utils/useDeepCompareMemo.js +2 -1
  35. package/es/ProForm/utils/useForm.js +10 -1
  36. package/es/ProLayout/components/ProCollapse/style/index.less +5 -2
  37. package/es/ProLayout/style/index.less +1 -1
  38. package/es/ProSelect/index.js +6 -3
  39. package/es/ProSelect/utils/index.d.ts +2 -1
  40. package/es/ProSelect/utils/index.js +9 -6
  41. package/es/ProTree/components/ProTree.js +18 -10
  42. package/es/ProTree/components/ProTreeSelect/index.js +2 -2
  43. package/es/ProTree/components/Tree.js +15 -7
  44. package/es/ProTree/index.js +2 -1
  45. package/es/ProTree/propsType.d.ts +5 -0
  46. package/es/ProUpload/components/ButtonRender.d.ts +1 -0
  47. package/es/ProUpload/components/ButtonRender.js +3 -1
  48. package/es/ProUpload/components/FileItem.d.ts +1 -0
  49. package/es/ProUpload/components/FileItem.js +21 -3
  50. package/es/ProUpload/index.js +4 -2
  51. package/es/ProUpload/propsType.d.ts +5 -0
  52. package/es/ProUpload/style/index.less +101 -111
  53. package/lib/ProEditTable/components/DndWrapper/index.d.ts +1 -0
  54. package/lib/ProEditTable/components/DndWrapper/index.js +4 -3
  55. package/lib/ProEditTable/components/RenderField/index.js +20 -1
  56. package/lib/ProEditTable/index.js +48 -55
  57. package/lib/ProEditTable/propsType.d.ts +7 -2
  58. package/lib/ProEditTable/style/index.less +10 -0
  59. package/lib/ProEditTable/utils/index.js +1 -0
  60. package/lib/ProEnum/components/Group.d.ts +1 -0
  61. package/lib/ProEnum/index.js +11 -5
  62. package/lib/ProEnum/style/index.less +2 -2
  63. package/lib/ProForm/components/base/InputNumber/index.js +40 -23
  64. package/lib/ProForm/components/combination/FormList/components/ActionButton.js +83 -37
  65. package/lib/ProForm/components/combination/FormList/components/ToolbarButton.js +72 -26
  66. package/lib/ProForm/components/combination/FormList/propsType.d.ts +4 -4
  67. package/lib/ProForm/components/combination/Group/component/AddonWrapper/index.d.ts +8 -0
  68. package/lib/ProForm/components/combination/Group/component/AddonWrapper/index.js +24 -0
  69. package/lib/ProForm/components/combination/Group/component/AddonWrapper/index.less +10 -0
  70. package/lib/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
  71. package/lib/ProForm/components/combination/Group/component/ComRender.js +31 -15
  72. package/lib/ProForm/components/combination/Group/index.d.ts +2 -2
  73. package/lib/ProForm/components/combination/Group/index.js +6 -6
  74. package/lib/ProForm/components/combination/Group/style/index.less +1 -1
  75. package/lib/ProForm/components/combination/Group/utils.d.ts +1 -1
  76. package/lib/ProForm/components/combination/Group/utils.js +24 -5
  77. package/lib/ProForm/components/combination/ProCascader/index.js +1 -1
  78. package/lib/ProForm/components/combination/ProCascader/utils/index.js +8 -3
  79. package/lib/ProForm/components/combination/ProModalSelect/index.js +1 -1
  80. package/lib/ProForm/components/combination/ProRangeLimit/index.d.ts +1 -1
  81. package/lib/ProForm/components/combination/ProRangeLimit/index.js +10 -5
  82. package/lib/ProForm/components/render/RenderFields.js +4 -1
  83. package/lib/ProForm/utils/useDeepCompareMemo.d.ts +1 -1
  84. package/lib/ProForm/utils/useDeepCompareMemo.js +2 -1
  85. package/lib/ProForm/utils/useForm.js +10 -1
  86. package/lib/ProLayout/components/ProCollapse/style/index.less +5 -2
  87. package/lib/ProLayout/style/index.less +1 -1
  88. package/lib/ProSelect/index.js +6 -3
  89. package/lib/ProSelect/utils/index.d.ts +2 -1
  90. package/lib/ProSelect/utils/index.js +9 -6
  91. package/lib/ProTree/components/ProTree.js +17 -9
  92. package/lib/ProTree/components/ProTreeSelect/index.js +2 -2
  93. package/lib/ProTree/components/Tree.js +15 -7
  94. package/lib/ProTree/index.js +2 -1
  95. package/lib/ProTree/propsType.d.ts +5 -0
  96. package/lib/ProUpload/components/ButtonRender.d.ts +1 -0
  97. package/lib/ProUpload/components/ButtonRender.js +3 -1
  98. package/lib/ProUpload/components/FileItem.d.ts +1 -0
  99. package/lib/ProUpload/components/FileItem.js +19 -3
  100. package/lib/ProUpload/index.js +4 -2
  101. package/lib/ProUpload/propsType.d.ts +5 -0
  102. package/lib/ProUpload/style/index.less +101 -111
  103. package/package.json +2 -2
  104. package/es/ProForm/components/combination/_Group/index.d.ts +0 -4
  105. package/es/ProForm/components/combination/_Group/index.js +0 -109
  106. package/es/ProForm/components/combination/_Group/propsType.d.ts +0 -35
  107. package/es/ProForm/components/combination/_Group/propsType.js +0 -1
  108. package/es/ProForm/components/combination/_Group/style/index.less +0 -131
  109. package/es/ProForm/components/combination/_Group/utils.d.ts +0 -10
  110. package/es/ProForm/components/combination/_Group/utils.js +0 -46
  111. package/lib/ProForm/components/combination/_Group/index.d.ts +0 -4
  112. package/lib/ProForm/components/combination/_Group/index.js +0 -113
  113. package/lib/ProForm/components/combination/_Group/propsType.d.ts +0 -35
  114. package/lib/ProForm/components/combination/_Group/propsType.js +0 -5
  115. package/lib/ProForm/components/combination/_Group/style/index.less +0 -131
  116. package/lib/ProForm/components/combination/_Group/utils.d.ts +0 -10
  117. 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
- var _excluded = ["label", "onClick", "onHandle", "actionType", "needConfirm", "confirmProps", "title"],
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
- actionType: 'delete'
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
- if (!((_props$actionProps = props.actionProps) === null || _props$actionProps === void 0 ? void 0 : _props$actionProps.find(function (item) {
125
- return item.actionType === 'delete';
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 (props === null || props === void 0 ? void 0 : props.actionProps) ? [].concat(_toConsumableArray(props.actionProps), defaultActionProps) : defaultActionProps;
131
+ return _actionProps ? [].concat(_toConsumableArray(_actionProps), defaultActionProps) : defaultActionProps;
128
132
  }
129
- return props.actionProps;
133
+ return _actionProps;
130
134
  }, [props.actionProps]);
131
- var handleClick = function handleClick(callback, index, item) {
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
- var data = callback === null || callback === void 0 ? void 0 : callback(value, {
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.actionType).concat(index));
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.actionType).concat(index));
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
- actionType = item.actionType,
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(actionType)) {
211
+ if (['add', 'delete', 'copy', 'moveUp', 'moveDown'].includes(type)) {
170
212
  // 禁用状态默认隐藏内置操作按钮
171
213
  if (disabled || isView) return _jsx(_Fragment, {});
172
- var _defaultActions$actio = defaultActions[actionType],
173
- internalOnClick = _defaultActions$actio.onClick,
174
- defaultLabel = _defaultActions$actio.label,
175
- defaultRest = _objectWithoutProperties(_defaultActions$actio, _excluded2);
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(actionType)) {
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(actionType)) {
223
+ if (max && max <= fields.length && ['add', 'copy'].includes(type)) {
182
224
  return false;
183
225
  }
184
226
  // 下标为零 不可向上移动
185
- if (index === 0 && ['moveUp'].includes(actionType)) {
227
+ if (index === 0 && ['moveUp'].includes(type)) {
186
228
  return false;
187
229
  }
188
230
  // 下标最大 不可向下移动
189
- if (index + 1 === fields.length && ['moveDown'].includes(actionType)) {
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(_onClick || internalOnClick, index, item);
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.actionType).concat(index)) : _jsx(_Button, _objectSpread(_objectSpread(_objectSpread({}, defaultRest), rest), {}, {
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(_onClick || internalOnClick, index, item);
254
+ handleClick(internalOnClick, _onClick, index, item);
211
255
  },
212
256
  children: label || defaultLabel
213
- }), "".concat(item === null || item === void 0 ? void 0 : item.actionType).concat(index));
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 handleClick(_onClick, index);
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.actionType).concat(index)) : ( /*#__PURE__*/_createElement(_Button, _objectSpread(_objectSpread({}, rest), {}, {
231
- key: "".concat(item === null || item === void 0 ? void 0 : item.actionType).concat(index),
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
- handleClick(_onClick, index);
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
- var _excluded = ["label", "onClick", "onHandle", "actionType"],
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
- actionType: 'add'
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
- if (!((_props$toolbarProps = props.toolbarProps) === null || _props$toolbarProps === void 0 ? void 0 : _props$toolbarProps.find(function (item) {
45
- return item.actionType === 'add';
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 (props === null || props === void 0 ? void 0 : props.toolbarProps) ? [].concat(_toConsumableArray(props.toolbarProps), defaultActionProps) : defaultActionProps;
55
+ return _toolbarProps ? [].concat(_toConsumableArray(_toolbarProps), defaultActionProps) : defaultActionProps;
48
56
  }
49
- return props.toolbarProps;
57
+ return _toolbarProps;
50
58
  }, [props.toolbarProps]);
51
- var handleClick = function handleClick(callback, item) {
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
- var data = callback === null || callback === void 0 ? void 0 : callback(value, {
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
- actionType = item.actionType,
120
+ type = item.type,
77
121
  rest = _objectWithoutProperties(item, _excluded);
78
122
  var _onClick = _onClick2 || onHandle;
79
- if (['add'].includes(actionType)) {
123
+ if (type === 'add') {
80
124
  if (disabled || isView) return _jsx(_Fragment, {});
81
- var _actions$actionType = actions[actionType],
82
- internalOnClick = _actions$actionType.onClick,
83
- defaultLabel = _actions$actionType.label,
84
- defaultRest = _objectWithoutProperties(_actions$actionType, _excluded2);
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 && ['add'].includes(actionType)) {
130
+ if (max && max <= fields.length && type === 'add') {
87
131
  return false;
88
132
  }
89
- return _jsx(_Button, _objectSpread(_objectSpread(_objectSpread({}, actions[actionType]), rest), {}, {
133
+ return _jsx(_Button, _objectSpread(_objectSpread(_objectSpread({}, actions[type]), rest), {}, {
134
+ type: "link",
90
135
  onClick: function onClick() {
91
- return handleClick(_onClick || internalOnClick, item);
136
+ return handleClick(internalOnClick, _onClick, item);
92
137
  },
93
138
  children: label || defaultLabel
94
- }), actionType);
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 handleClick(_onClick2, item);
144
+ return customClick(_onClick2, item);
99
145
  },
100
146
  children: label
101
- }), actionType);
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
- actionType?: 'add' | 'delete' | 'copy' | 'moveUp' | 'moveDown';
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
- actionType?: 'add';
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,8 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ interface Props {
4
+ before?: React.ReactNode;
5
+ after?: React.ReactNode;
6
+ }
7
+ declare const AddonWrapper: React.FC<Props>;
8
+ export default AddonWrapper;
@@ -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;
@@ -0,0 +1,10 @@
1
+ .addon-wrapper {
2
+ display: flex;
3
+ gap: 16px;
4
+ align-items: center;
5
+
6
+ .before,
7
+ .after {
8
+ white-space: nowrap;
9
+ }
10
+ }
@@ -8,6 +8,8 @@ interface Props {
8
8
  confirm: any;
9
9
  fieldProps: any;
10
10
  contextProps: any;
11
+ before?: React.ReactNode;
12
+ after?: React.ReactNode;
11
13
  }
12
14
  /** 渲染组件 */
13
15
  declare const ComRender: React.FC<Props>;
@@ -1,11 +1,33 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
1
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps"];
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
- if (confirm) {
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: Component
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 GroupCopy: React.FC<GroupProps>;
10
- export default GroupCopy;
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, transformColumns } from './utils';
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 GroupCopy = function GroupCopy(props) {
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 = transformColumns({
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 GroupCopy;
89
+ export default Group;
@@ -20,7 +20,7 @@
20
20
 
21
21
  .pro-group {
22
22
  width: unset !important;
23
-
23
+ display: flex;
24
24
 
25
25
  &.pro-group-diy-width, &.pro-group-width-auto {
26
26
  .@{ant-prefix}-space .@{ant-prefix}-space-item {
@@ -59,5 +59,5 @@ interface ColumnsTransformerParams {
59
59
  groupProps: GroupProps;
60
60
  }
61
61
  /** 转换columns */
62
- export declare const transformColumns: (params: ColumnsTransformerParams) => any[];
62
+ export declare const useTransformColumns: (params: ColumnsTransformerParams) => any[];
63
63
  export {};