@zat-design/sisyphus-react 3.4.6 → 3.4.8

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 (109) hide show
  1. package/dist/index.esm.css +17 -1
  2. package/dist/less.esm.css +17 -1
  3. package/es/ProEditTable/components/RenderField/index.js +5 -8
  4. package/es/ProEditTable/style/index.less +5 -2
  5. package/es/ProForm/components/base/TextArea/index.d.ts +1 -0
  6. package/es/ProForm/components/base/TextArea/index.js +4 -2
  7. package/es/ProForm/components/combination/FormList/components/BlockFields.d.ts +1 -1
  8. package/es/ProForm/components/combination/FormList/index.js +2 -1
  9. package/es/ProForm/components/combination/FormList/propsType.d.ts +1 -1
  10. package/es/ProForm/components/combination/FormList/utils.js +2 -3
  11. package/es/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.js +2 -2
  12. package/es/ProForm/components/combination/Group/index.d.ts +8 -2
  13. package/es/ProForm/components/combination/Group/index.js +58 -76
  14. package/es/ProForm/components/combination/Group/propsType.d.ts +27 -14
  15. package/es/ProForm/components/combination/Group/utils.d.ts +60 -7
  16. package/es/ProForm/components/combination/Group/utils.js +209 -19
  17. package/es/ProForm/components/combination/ProModalSelect/index.js +35 -29
  18. package/es/ProForm/components/combination/_Group/index.d.ts +4 -0
  19. package/es/ProForm/components/combination/_Group/index.js +109 -0
  20. package/es/ProForm/components/combination/_Group/propsType.d.ts +35 -0
  21. package/es/ProForm/components/combination/_Group/utils.d.ts +10 -0
  22. package/es/ProForm/components/combination/_Group/utils.js +46 -0
  23. package/es/ProForm/components/render/Render.js +8 -6
  24. package/es/ProForm/components/render/RenderFields.js +1 -0
  25. package/es/ProForm/components/render/propsType.d.ts +4 -3
  26. package/es/ProForm/propsType.d.ts +1 -0
  27. package/es/ProForm/style/index.less +7 -0
  28. package/es/ProForm/utils/diffOriginal.js +2 -1
  29. package/es/ProForm/utils/index.d.ts +6 -1
  30. package/es/ProForm/utils/index.js +5 -5
  31. package/es/ProForm/utils/transformNames.js +3 -10
  32. package/es/ProForm/utils/useDeepCompareMemo.d.ts +2 -0
  33. package/es/ProForm/utils/useDeepCompareMemo.js +14 -0
  34. package/es/ProForm/utils/useForm.js +2 -1
  35. package/es/ProForm/utils/useListChanged.js +2 -2
  36. package/es/ProForm/utils/useRules.js +2 -20
  37. package/es/ProSelect/index.js +14 -2
  38. package/es/ProSelect/propsType.d.ts +2 -0
  39. package/es/ProSelect/utils/index.d.ts +9 -0
  40. package/es/ProSelect/utils/index.js +60 -0
  41. package/es/ProTree/components/ProTreeSelect/index.js +3 -3
  42. package/es/ProTree/components/ProTreeSelect/style/index.less +6 -8
  43. package/es/ProTree/style/index.less +15 -0
  44. package/es/ProUpload/index.js +5 -6
  45. package/es/ProUpload/propsType.d.ts +1 -1
  46. package/es/global.less +40 -25
  47. package/es/locale/zh_CN.js +1 -1
  48. package/lib/ProEditTable/components/RenderField/index.js +5 -8
  49. package/lib/ProEditTable/style/index.less +5 -2
  50. package/lib/ProForm/components/base/TextArea/index.d.ts +1 -0
  51. package/lib/ProForm/components/base/TextArea/index.js +4 -2
  52. package/lib/ProForm/components/combination/FormList/components/BlockFields.d.ts +1 -1
  53. package/lib/ProForm/components/combination/FormList/index.js +2 -1
  54. package/lib/ProForm/components/combination/FormList/propsType.d.ts +1 -1
  55. package/lib/ProForm/components/combination/FormList/utils.js +2 -3
  56. package/lib/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.js +2 -2
  57. package/lib/ProForm/components/combination/Group/index.d.ts +8 -2
  58. package/lib/ProForm/components/combination/Group/index.js +57 -72
  59. package/lib/ProForm/components/combination/Group/propsType.d.ts +27 -14
  60. package/lib/ProForm/components/combination/Group/utils.d.ts +60 -7
  61. package/lib/ProForm/components/combination/Group/utils.js +210 -20
  62. package/lib/ProForm/components/combination/ProModalSelect/index.js +35 -29
  63. package/lib/ProForm/components/combination/_Group/index.d.ts +4 -0
  64. package/lib/ProForm/components/combination/_Group/index.js +113 -0
  65. package/lib/ProForm/components/combination/_Group/propsType.d.ts +35 -0
  66. package/lib/ProForm/components/combination/_Group/utils.d.ts +10 -0
  67. package/lib/ProForm/components/combination/_Group/utils.js +53 -0
  68. package/lib/ProForm/components/render/Render.js +7 -5
  69. package/lib/ProForm/components/render/RenderFields.js +1 -0
  70. package/lib/ProForm/components/render/propsType.d.ts +4 -3
  71. package/lib/ProForm/propsType.d.ts +1 -0
  72. package/lib/ProForm/style/index.less +7 -0
  73. package/lib/ProForm/utils/diffOriginal.js +2 -1
  74. package/lib/ProForm/utils/index.d.ts +6 -1
  75. package/lib/ProForm/utils/index.js +5 -5
  76. package/lib/ProForm/utils/transformNames.js +2 -9
  77. package/lib/ProForm/utils/useDeepCompareMemo.d.ts +2 -0
  78. package/lib/ProForm/utils/useDeepCompareMemo.js +20 -0
  79. package/lib/ProForm/utils/useForm.js +2 -1
  80. package/lib/ProForm/utils/useListChanged.js +1 -1
  81. package/lib/ProForm/utils/useRules.js +2 -20
  82. package/lib/ProSelect/index.js +14 -2
  83. package/lib/ProSelect/propsType.d.ts +2 -0
  84. package/lib/ProSelect/utils/index.d.ts +9 -0
  85. package/lib/ProSelect/utils/index.js +68 -0
  86. package/lib/ProTree/components/ProTreeSelect/index.js +3 -3
  87. package/lib/ProTree/components/ProTreeSelect/style/index.less +6 -8
  88. package/lib/ProTree/style/index.less +15 -0
  89. package/lib/ProUpload/index.js +5 -6
  90. package/lib/ProUpload/propsType.d.ts +1 -1
  91. package/lib/global.less +40 -25
  92. package/lib/locale/zh_CN.js +1 -1
  93. package/package.json +1 -1
  94. package/es/ProForm/components/combination/GroupCopy/index.d.ts +0 -10
  95. package/es/ProForm/components/combination/GroupCopy/index.js +0 -84
  96. package/es/ProForm/components/combination/GroupCopy/propsType.d.ts +0 -47
  97. package/es/ProForm/components/combination/GroupCopy/utils.d.ts +0 -53
  98. package/es/ProForm/components/combination/GroupCopy/utils.js +0 -180
  99. package/lib/ProForm/components/combination/GroupCopy/index.d.ts +0 -10
  100. package/lib/ProForm/components/combination/GroupCopy/index.js +0 -91
  101. package/lib/ProForm/components/combination/GroupCopy/propsType.d.ts +0 -47
  102. package/lib/ProForm/components/combination/GroupCopy/utils.d.ts +0 -53
  103. package/lib/ProForm/components/combination/GroupCopy/utils.js +0 -187
  104. /package/es/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.d.ts +0 -0
  105. /package/es/ProForm/components/combination/{GroupCopy → _Group}/propsType.js +0 -0
  106. /package/es/ProForm/components/combination/{GroupCopy → _Group}/style/index.less +0 -0
  107. /package/lib/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.d.ts +0 -0
  108. /package/lib/ProForm/components/combination/{GroupCopy → _Group}/propsType.js +0 -0
  109. /package/lib/ProForm/components/combination/{GroupCopy → _Group}/style/index.less +0 -0
@@ -1,31 +1,31 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
4
+ import "antd/es/button/style";
5
+ import _Button from "antd/es/button";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { isFunction } from 'lodash';
8
+ import valueTypeMap from '../../../utils/valueType';
9
+ import { useDeepCompareMemo } from '../../../utils/useDeepCompareMemo';
2
10
  /**
3
- * 插入间隔符
4
- * @param columns 表单配置数组
5
- * @returns
6
- */
7
- export var insertSeparator = function insertSeparator(columns, space, separatorNode, otherProps) {
8
- var _columns = columns;
9
- var _ref = otherProps || {},
10
- names = _ref.names;
11
- // 紧凑模式存在names时,自动给下级拆解name
12
- if (names) {
13
- _columns = _columns.map(function (column, index) {
14
- return _objectSpread(_objectSpread({}, column), {}, {
15
- name: names[index]
16
- });
17
- });
18
- }
11
+ * 插入间隔符
12
+ * @param columns 表单配置数组
13
+ * @returns
14
+ */
15
+ export var insertSeparator = function insertSeparator(columns, space) {
19
16
  if (!(space === null || space === void 0 ? void 0 : space.separator)) {
20
- return _columns;
17
+ return columns;
21
18
  }
22
- return _columns.reduce(function (result, current, index, array) {
19
+ return columns.reduce(function (result, current, index, array) {
23
20
  // 将当前元素添加到结果数组中
24
21
  result.push(current);
25
22
  // 如果当前元素不是最后一个元素,则添加间隔符
26
23
  if (index < array.length - 1) {
27
24
  result.push({
28
- component: separatorNode,
25
+ component: _jsx(_Button, {
26
+ className: "group-separator",
27
+ children: space.separator
28
+ }),
29
29
  fieldProps: {
30
30
  disabled: true
31
31
  }
@@ -34,6 +34,14 @@ export var insertSeparator = function insertSeparator(columns, space, separatorN
34
34
  return result;
35
35
  }, []);
36
36
  };
37
+ /** 带出event的组件默认取值方法 */
38
+ export function defaultGetValueFromEvent(valuePropName) {
39
+ var event = arguments.length <= 1 ? undefined : arguments[1];
40
+ if (event && event.target && _typeof(event.target) === 'object' && valuePropName in event.target) {
41
+ return event.target[valuePropName];
42
+ }
43
+ return event;
44
+ }
37
45
  /** 转换names */
38
46
  export var transformNamesString = function transformNamesString(arr) {
39
47
  var result = arr.map(function (subArr) {
@@ -43,4 +51,186 @@ export var transformNamesString = function transformNamesString(arr) {
43
51
  return subArr;
44
52
  });
45
53
  return result;
54
+ };
55
+ /**
56
+ * Input TextArea 小写自动转大写
57
+ * @param type 组件类型
58
+ * @param upperCase 是否小写转大写
59
+ * @returns {}
60
+ */
61
+ export var isUpperCase = function isUpperCase(type, upperCase) {
62
+ var result = {};
63
+ if (['Input', 'TextArea', 'ProCombination'].includes(type) && upperCase) {
64
+ result.getValueFromEvent = function (event) {
65
+ var _event$target, _event$target$value;
66
+ if (Array.isArray(event)) {
67
+ return event.map(function (value) {
68
+ var newValue = value === null || value === void 0 ? void 0 : value.replace(/[^a-zA-Z]/g, '');
69
+ return (newValue === null || newValue === void 0 ? void 0 : newValue.toUpperCase()) || '';
70
+ });
71
+ }
72
+ var newValue = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : (_event$target$value = _event$target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.replace(/[^a-zA-Z]/g, '');
73
+ return newValue.toUpperCase() || '';
74
+ };
75
+ }
76
+ return result;
77
+ };
78
+ /** 计算响应式参数的值 */
79
+ export var getReactiveProps = function getReactiveProps(params) {
80
+ var form = params.form,
81
+ index = params.index,
82
+ namePath = params.namePath,
83
+ disabled = params.disabled,
84
+ show = params.show,
85
+ component = params.component,
86
+ fieldProps = params.fieldProps,
87
+ name = params.name;
88
+ var values = form.getFieldsValue(namePath || undefined);
89
+ var _disabled = isFunction(disabled) ? disabled(values, {
90
+ form: form,
91
+ index: index,
92
+ namePath: namePath
93
+ }) : disabled;
94
+ var _show = isFunction(show) ? show(values, {
95
+ form: form,
96
+ index: index,
97
+ namePath: namePath
98
+ }) : show;
99
+ var _component = isFunction(component) ? component(values, {
100
+ form: form,
101
+ index: index,
102
+ namePath: namePath
103
+ }) : component;
104
+ var _fieldProps = isFunction(fieldProps) ? fieldProps(values, {
105
+ form: form,
106
+ index: index,
107
+ namePath: namePath
108
+ }) : fieldProps;
109
+ return {
110
+ disabled: _disabled,
111
+ show: _show,
112
+ component: _component,
113
+ fieldProps: _fieldProps
114
+ };
115
+ };
116
+ /** 获取当前字段的转换函数 */
117
+ export var getValueTypeTrans = function getValueTypeTrans(params) {
118
+ var _valueTypeMap$valueTy;
119
+ var valueType = params.valueType;
120
+ var transform = (_valueTypeMap$valueTy = valueTypeMap[valueType]) === null || _valueTypeMap$valueTy === void 0 ? void 0 : _valueTypeMap$valueTy.call(valueTypeMap, params);
121
+ return transform;
122
+ };
123
+ var getTrim = function getTrim(value) {
124
+ return (value === null || value === void 0 ? void 0 : value.trim()) || '';
125
+ };
126
+ var getUpperCase = function getUpperCase(value) {
127
+ var _value = value === null || value === void 0 ? void 0 : value.replace(/[^a-zA-Z]/g, '');
128
+ return _value.toUpperCase() || '';
129
+ };
130
+ /** 执行所有中间件 返回处理后的值 */
131
+ export var getValueMiddleware = function getValueMiddleware(value) {
132
+ var callbacks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
133
+ return callbacks.reduce(function (preValue, cb) {
134
+ return cb === null || cb === void 0 ? void 0 : cb(preValue);
135
+ }, value);
136
+ };
137
+ /** 获取中间件处理后的value */
138
+ var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
139
+ var getValueFromEvent = column.getValueFromEvent,
140
+ _column$valuePropName = column.valuePropName,
141
+ valuePropName = _column$valuePropName === void 0 ? 'value' : _column$valuePropName,
142
+ trim = column.trim,
143
+ upperCase = column.upperCase;
144
+ var newValue;
145
+ if (getValueFromEvent) {
146
+ newValue = getValueFromEvent.apply(void 0, _toConsumableArray(args));
147
+ } else {
148
+ newValue = defaultGetValueFromEvent.apply(void 0, [valuePropName].concat(_toConsumableArray(args)));
149
+ }
150
+ var list = [];
151
+ if (trim) list.push(getTrim);
152
+ if (upperCase) list.push(getUpperCase);
153
+ return getValueMiddleware(newValue, list);
154
+ };
155
+ /** 转换columns */
156
+ export var transformColumns = function transformColumns(params) {
157
+ var form = params.form,
158
+ columns = params.columns,
159
+ name = params.name,
160
+ names = params.names,
161
+ outerIndex = params.index,
162
+ namePath = params.namePath,
163
+ value = params.value,
164
+ internalChange = params.onChange,
165
+ groupProps = params.groupProps;
166
+ return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
167
+ var type = column.type,
168
+ valueType = column.valueType,
169
+ switchValue = column.switchValue,
170
+ toISOString = column.toISOString,
171
+ fieldProps = column.fieldProps,
172
+ normalize = column.normalize,
173
+ disabled = column.disabled,
174
+ show = column.show,
175
+ component = column.component;
176
+ var _ref = fieldProps || {},
177
+ mode = _ref.mode,
178
+ onChange = _ref.onChange,
179
+ onFieldChange = _ref.onFieldChange,
180
+ comDisabled = _ref.disabled;
181
+ var _disabled = disabled || comDisabled;
182
+ var columnName = names ? names[index] : [].concat(name, index);
183
+ // 响应式字段
184
+ var reactiveProps = useDeepCompareMemo(function () {
185
+ return getReactiveProps({
186
+ form: form,
187
+ index: index,
188
+ type: type,
189
+ namePath: namePath,
190
+ disabled: _disabled,
191
+ show: show,
192
+ component: component,
193
+ fieldProps: fieldProps,
194
+ name: columnName
195
+ });
196
+ }, [value, show, fieldProps, columnName, type]);
197
+ if (reactiveProps.show === false) {
198
+ return [];
199
+ }
200
+ var transform = getValueTypeTrans({
201
+ type: type,
202
+ valueType: valueType,
203
+ switchValue: switchValue,
204
+ toISOString: toISOString,
205
+ mode: mode
206
+ });
207
+ var newValue;
208
+ var handleChange = function handleChange() {
209
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
210
+ args[_key] = arguments[_key];
211
+ }
212
+ newValue = valueFromEventWrapper(column, args);
213
+ if ((transform === null || transform === void 0 ? void 0 : transform.normalize) || normalize) {
214
+ var _transform$normalize;
215
+ // @ts-ignore
216
+ newValue = ((_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue)) || (normalize === null || normalize === void 0 ? void 0 : normalize(newValue));
217
+ }
218
+ internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
219
+ onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
220
+ onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, form.getFieldValue(namePath), {
221
+ index: outerIndex,
222
+ namePath: namePath,
223
+ form: form
224
+ });
225
+ };
226
+ return _objectSpread(_objectSpread(_objectSpread({}, column), {}, {
227
+ name: columnName
228
+ }, reactiveProps), {}, {
229
+ disabled: reactiveProps.disabled || groupProps.disabled,
230
+ fieldProps: _objectSpread(_objectSpread({}, column === null || column === void 0 ? void 0 : column.fieldProps), {}, {
231
+ onChange: handleChange,
232
+ value: value === null || value === void 0 ? void 0 : value[index]
233
+ })
234
+ });
235
+ });
46
236
  };
@@ -295,58 +295,64 @@ var ProModalSelect = function ProModalSelect(props, ref) {
295
295
  };
296
296
  var handleFinish = /*#__PURE__*/function () {
297
297
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
298
- var _data, flag, res;
298
+ var _nextSelectedRows, _nextSelectedRows2, nextSelectedRows, record, flag, res;
299
299
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
300
300
  while (1) switch (_context2.prev = _context2.next) {
301
301
  case 0:
302
302
  _context2.prev = 0;
303
- if (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) {
303
+ if (selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.length) {
304
304
  _context2.next = 4;
305
305
  break;
306
306
  }
307
307
  _message.error(locale.ProModalSelect.checkMsg);
308
308
  return _context2.abrupt("return", false);
309
309
  case 4:
310
- _data = isMultiple ? selectedRows : selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows[0];
310
+ nextSelectedRows = selectedRows;
311
+ if (!((_nextSelectedRows = nextSelectedRows) === null || _nextSelectedRows === void 0 ? void 0 : _nextSelectedRows[0])) {
312
+ nextSelectedRows = data.filter(function (item) {
313
+ return selectedRowKeys.includes(item[valueKey]);
314
+ });
315
+ }
316
+ record = isMultiple ? nextSelectedRows : (_nextSelectedRows2 = nextSelectedRows) === null || _nextSelectedRows2 === void 0 ? void 0 : _nextSelectedRows2[0];
311
317
  if (!isMultiple) {
312
318
  // @ts-ignore
313
- _data.value = _data[valueKey];
319
+ record.value = record[valueKey];
314
320
  // @ts-ignore
315
- _data.label = _data[labelKey];
321
+ record.label = record[labelKey];
316
322
  }
317
323
  flag = true;
318
324
  if (!onOk) {
319
- _context2.next = 12;
325
+ _context2.next = 14;
320
326
  break;
321
327
  }
322
- _context2.next = 10;
323
- return onOk(_data);
324
- case 10:
328
+ _context2.next = 12;
329
+ return onOk(record);
330
+ case 12:
325
331
  res = _context2.sent;
326
332
  if (res !== null && res !== undefined) {
327
333
  // @ts-ignore
328
334
  flag = res;
329
335
  }
330
- case 12:
336
+ case 14:
331
337
  if (flag) {
332
- onChange === null || onChange === void 0 ? void 0 : onChange(labelInValue ? _data : getNextValues(_data), _data);
338
+ onChange === null || onChange === void 0 ? void 0 : onChange(labelInValue ? record : getNextValues(record), record);
333
339
  // 更新内部展示值
334
340
  setState({
335
- _value: _data,
336
- options: isArray(_data) ? _data : [_data]
341
+ _value: record,
342
+ options: isArray(record) ? record : [record]
337
343
  });
338
344
  handleClose();
339
345
  }
340
346
  return _context2.abrupt("return", flag);
341
- case 16:
342
- _context2.prev = 16;
347
+ case 18:
348
+ _context2.prev = 18;
343
349
  _context2.t0 = _context2["catch"](0);
344
350
  console.warn('error', _context2.t0);
345
- case 19:
351
+ case 21:
346
352
  case "end":
347
353
  return _context2.stop();
348
354
  }
349
- }, _callee2, null, [[0, 16]]);
355
+ }, _callee2, null, [[0, 18]]);
350
356
  }));
351
357
  return function handleFinish() {
352
358
  return _ref7.apply(this, arguments);
@@ -427,7 +433,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
427
433
  // 初始化回显,当传入initParams时,前端用来回险
428
434
  var getInitValues = /*#__PURE__*/function () {
429
435
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
430
- var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _list, list, _res$data2, _data2, nextSelectRowKeys;
436
+ var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _list, list, _res$data2, _data, nextSelectRowKeys;
431
437
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
432
438
  while (1) switch (_context4.prev = _context4.next) {
433
439
  case 0:
@@ -458,15 +464,15 @@ var ProModalSelect = function ProModalSelect(props, ref) {
458
464
  } else {
459
465
  list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.list : res === null || res === void 0 ? void 0 : res.data;
460
466
  }
461
- _data2 = isMultiple ? list : (_list = list) === null || _list === void 0 ? void 0 : _list[0];
462
- if (_data2) {
467
+ _data = isMultiple ? list : (_list = list) === null || _list === void 0 ? void 0 : _list[0];
468
+ if (_data) {
463
469
  nextSelectRowKeys = isMultiple ? value : [value];
464
470
  if (labelInValue) {
465
- onChange(_data2);
471
+ onChange(_data);
466
472
  }
467
473
  // 更新内部展示值
468
474
  setState({
469
- _value: _data2,
475
+ _value: _data,
470
476
  isInit: false,
471
477
  selectedRows: list,
472
478
  selectedRowKeys: nextSelectRowKeys
@@ -493,7 +499,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
493
499
  var getDefaultOneValues = /*#__PURE__*/function () {
494
500
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
495
501
  var _useRequest$options4, _useRequest$options5;
496
- var queryBean, page, params, res, _list2, list, _res$data3, _data3, nextSelectRowKeys;
502
+ var queryBean, page, params, res, _list2, list, _res$data3, _data2, nextSelectRowKeys;
497
503
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
498
504
  while (1) switch (_context5.prev = _context5.next) {
499
505
  case 0:
@@ -517,18 +523,18 @@ var ProModalSelect = function ProModalSelect(props, ref) {
517
523
  } else {
518
524
  list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.list : res === null || res === void 0 ? void 0 : res.data;
519
525
  }
520
- _data3 = isMultiple ? list : (_list2 = list) === null || _list2 === void 0 ? void 0 : _list2[0];
526
+ _data2 = isMultiple ? list : (_list2 = list) === null || _list2 === void 0 ? void 0 : _list2[0];
521
527
  nextSelectRowKeys = isMultiple ? value : [value];
522
528
  if (labelInValue) {
523
- onChange(_data3);
529
+ onChange(_data2);
524
530
  } else {
525
- onChange(isMultiple ? _data3.map(function (item) {
531
+ onChange(isMultiple ? _data2.map(function (item) {
526
532
  return item[valueKey];
527
- }) : _data3[valueKey]);
533
+ }) : _data2[valueKey]);
528
534
  }
529
535
  // 更新内部展示值
530
536
  setState({
531
- _value: _data3,
537
+ _value: _data2,
532
538
  isInit: false,
533
539
  selectedRows: list,
534
540
  selectedRowKeys: nextSelectRowKeys
@@ -597,8 +603,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
597
603
  nextState.selectedRows = value;
598
604
  }
599
605
  } else if (value) {
606
+ console.log('value', value);
600
607
  nextState.selectedRowKeys = [value];
601
- nextState.selectedRows = [_defineProperty({}, valueKey, value[valueKey])];
602
608
  }
603
609
  setState(nextState);
604
610
  }
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { GroupProps } from './propsType';
3
+ declare const Group: React.FC<GroupProps>;
4
+ export default Group;
@@ -0,0 +1,109 @@
1
+ import "antd/es/space/style";
2
+ import _Space from "antd/es/space";
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import "antd/es/button/style";
5
+ import _Button from "antd/es/button";
6
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { useMemo } from 'react';
9
+ import { omit, isFunction, union, isNumber } from 'lodash';
10
+ import { useDeepCompareEffect } from 'ahooks';
11
+ import classnames from 'classnames';
12
+ import RenderFields from '../../render/RenderFields';
13
+ import { insertSeparator, transformNamesString } from './utils';
14
+ import ProForm from '../../../../ProForm';
15
+ var Group = function Group(props) {
16
+ var columns = props.children,
17
+ otherProps = props.otherProps,
18
+ className = props.className,
19
+ _props$space = props.space,
20
+ space = _props$space === void 0 ? {
21
+ size: 12
22
+ } : _props$space,
23
+ id = props.id,
24
+ value = props.value,
25
+ isView = props.isView,
26
+ index = props.index,
27
+ onFieldChange = props.onFieldChange,
28
+ namePath = props.namePath;
29
+ var _ref = ProForm.useFieldProps() || {},
30
+ names = _ref.names,
31
+ name = _ref.name,
32
+ form = _ref.form,
33
+ _namePath = _ref.namePath;
34
+ var newNamePath = namePath || _namePath || [];
35
+ if (!Array.isArray(names)) {
36
+ console.error('Warning: Composite form components whose type is Group must be configured with names');
37
+ }
38
+ var data = useMemo(function () {
39
+ var fieldList = [];
40
+ var result = columns.map(function (item) {
41
+ return _objectSpread(_objectSpread({
42
+ disabled: Boolean(props === null || props === void 0 ? void 0 : props.disabled)
43
+ }, item), {}, {
44
+ isView: isView !== null && isView !== void 0 ? isView : item.isView,
45
+ noStyle: (space === null || space === void 0 ? void 0 : space.compact) || (space === null || space === void 0 ? void 0 : space.separator),
46
+ parentNames: id,
47
+ namePath: newNamePath
48
+ });
49
+ });
50
+ var node = _jsx(_Button, {
51
+ className: "group-separator",
52
+ children: space.separator
53
+ });
54
+ return {
55
+ columns: insertSeparator(result, space, node, otherProps),
56
+ fieldList: fieldList
57
+ };
58
+ }, [name, columns, space, props, names]);
59
+ var _className = classnames(_defineProperty({
60
+ 'pro-group': true,
61
+ 'pro-group-diy-width': columns.some(function (item) {
62
+ var _item$fieldProps, _item$fieldProps$styl;
63
+ return item === null || item === void 0 ? void 0 : (_item$fieldProps = item.fieldProps) === null || _item$fieldProps === void 0 ? void 0 : (_item$fieldProps$styl = _item$fieldProps.style) === null || _item$fieldProps$styl === void 0 ? void 0 : _item$fieldProps$styl.width;
64
+ }),
65
+ 'pro-group-width-auto': columns.some(function (item) {
66
+ return ['Radio', 'Checkbox', 'Switch'].includes(item.type);
67
+ })
68
+ }, "".concat(className), className));
69
+ // 用于formList场景下names移除掉了前缀,需要再次合并回来
70
+ var _names = names.map(function (item) {
71
+ if (isNumber(item === null || item === void 0 ? void 0 : item[0])) {
72
+ return union(newNamePath, item);
73
+ }
74
+ return item;
75
+ });
76
+ useDeepCompareEffect(function () {
77
+ var _document, _document$activeEleme;
78
+ // 焦点激活的表单
79
+ var touchName = ((_document = document) === null || _document === void 0 ? void 0 : (_document$activeEleme = _document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.id) || '';
80
+ // 模拟change,初始化不执行onFieldChange
81
+ if (isFunction(onFieldChange) && form.isFieldsTouched(_names) && transformNamesString(_names).includes(touchName)) {
82
+ onFieldChange(value, (newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.length) ? form.getFieldValue(newNamePath, true) : form.getFieldsValue(), {
83
+ form: form,
84
+ namePath: newNamePath,
85
+ index: index
86
+ });
87
+ }
88
+ }, [value]);
89
+ var _otherProps = omit(otherProps, ['colProps', 'required']);
90
+ return _jsx("div", {
91
+ className: _className,
92
+ children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? _jsx(_Space.Compact, {
93
+ children: _jsx(RenderFields, _objectSpread({
94
+ columns: data.columns,
95
+ form: form
96
+ }, _otherProps))
97
+ }) : _jsx(_Space, _objectSpread(_objectSpread({
98
+ align: "start"
99
+ }, omit(space, ['separator', 'compact'])), {}, {
100
+ children: data.columns.map(function (column, index) {
101
+ return _jsx(RenderFields, _objectSpread({
102
+ columns: [column],
103
+ form: form
104
+ }, _otherProps), (column === null || column === void 0 ? void 0 : column.name) || index);
105
+ })
106
+ }))
107
+ });
108
+ };
109
+ export default Group;
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { RowProps, SpaceProps } from 'antd';
3
+ import { FormInstance } from 'antd/es/form/Form';
4
+ import { NamePath } from 'antd/lib/form/interface';
5
+ import { ProColumnProps, ProFormOtherProps } from '../../../propsType';
6
+ export interface SpaceType extends SpaceProps {
7
+ /**
8
+ * 是否紧凑合并
9
+ */
10
+ compact?: Boolean;
11
+ /**
12
+ * 分隔符
13
+ */
14
+ separator?: string | React.ReactNode;
15
+ /** 间隔距离 */
16
+ size?: number;
17
+ }
18
+ export interface GroupProps {
19
+ children?: ProColumnProps[];
20
+ space?: SpaceType;
21
+ otherProps?: ProFormOtherProps;
22
+ rowProps?: RowProps;
23
+ className?: string;
24
+ value?: any;
25
+ id?: string;
26
+ disabled?: boolean | (() => void);
27
+ isView?: boolean;
28
+ namePath?: NamePath;
29
+ index?: number;
30
+ onFieldChange?: (value: any[] | null, record: any, { form, }: {
31
+ form: FormInstance;
32
+ namePath?: NamePath;
33
+ index?: number;
34
+ }) => any;
35
+ }
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ import { SpaceType } from './propsType';
3
+ /**
4
+ * 插入间隔符
5
+ * @param columns 表单配置数组
6
+ * @returns
7
+ */
8
+ export declare const insertSeparator: (columns: any, space?: SpaceType, separatorNode?: ReactNode, otherProps?: any) => any;
9
+ /** 转换names */
10
+ export declare const transformNamesString: (arr: (string | string[])[]) => (string | string[])[];
@@ -0,0 +1,46 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ /**
3
+ * 插入间隔符
4
+ * @param columns 表单配置数组
5
+ * @returns
6
+ */
7
+ export var insertSeparator = function insertSeparator(columns, space, separatorNode, otherProps) {
8
+ var _columns = columns;
9
+ var _ref = otherProps || {},
10
+ names = _ref.names;
11
+ // 紧凑模式存在names时,自动给下级拆解name
12
+ if (names) {
13
+ _columns = _columns.map(function (column, index) {
14
+ return _objectSpread(_objectSpread({}, column), {}, {
15
+ name: names[index]
16
+ });
17
+ });
18
+ }
19
+ if (!(space === null || space === void 0 ? void 0 : space.separator)) {
20
+ return _columns;
21
+ }
22
+ return _columns.reduce(function (result, current, index, array) {
23
+ // 将当前元素添加到结果数组中
24
+ result.push(current);
25
+ // 如果当前元素不是最后一个元素,则添加间隔符
26
+ if (index < array.length - 1) {
27
+ result.push({
28
+ component: separatorNode,
29
+ fieldProps: {
30
+ disabled: true
31
+ }
32
+ });
33
+ }
34
+ return result;
35
+ }, []);
36
+ };
37
+ /** 转换names */
38
+ export var transformNamesString = function transformNamesString(arr) {
39
+ var result = arr.map(function (subArr) {
40
+ if (Array.isArray(subArr)) {
41
+ return subArr.join('_');
42
+ }
43
+ return subArr;
44
+ });
45
+ return result;
46
+ };
@@ -22,7 +22,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
22
22
  import React, { useMemo } from 'react';
23
23
  import classNames from 'classnames';
24
24
  import { ReactSVG } from 'react-svg';
25
- import { isFunction, isString, omit } from 'lodash';
25
+ import { isFunction, isString, omit, set } from 'lodash';
26
26
  import useShouldUpdate from '../../utils/useShouldUpdate';
27
27
  import { isTrim, isUpperCase, findOptionByValue, parseNamePath } from '../../utils/index';
28
28
  import { useProConfig } from '../../../ProConfigProvider';
@@ -255,15 +255,17 @@ var Render = function Render(props) {
255
255
  if (changeKey === 'onFieldChange') {
256
256
  _args = functionArgs([].concat(args));
257
257
  }
258
+ var inList = _otherFormItemProps === null || _otherFormItemProps === void 0 ? void 0 : (_otherFormItemProps$n3 = _otherFormItemProps.namePath) === null || _otherFormItemProps$n3 === void 0 ? void 0 : _otherFormItemProps$n3.length;
258
259
  if ( /*#__PURE__*/React.isValidElement(AutoComponent)) {
259
260
  var _AutoComponent$props$, _AutoComponent$props, _lastComponentProps$c;
260
261
  ((_AutoComponent$props$ = (_AutoComponent$props = AutoComponent === null || AutoComponent === void 0 ? void 0 : AutoComponent.props)[changeKey]) === null || _AutoComponent$props$ === void 0 ? void 0 : _AutoComponent$props$.call.apply(_AutoComponent$props$, [_AutoComponent$props].concat(_toConsumableArray(_args)))) || ((_lastComponentProps$c = lastComponentProps[changeKey]) === null || _lastComponentProps$c === void 0 ? void 0 : _lastComponentProps$c.call.apply(_lastComponentProps$c, [lastComponentProps].concat(_toConsumableArray(_args))));
261
262
  return false;
262
263
  }
263
- var inList = _otherFormItemProps === null || _otherFormItemProps === void 0 ? void 0 : (_otherFormItemProps$n3 = _otherFormItemProps.namePath) === null || _otherFormItemProps$n3 === void 0 ? void 0 : _otherFormItemProps$n3.length;
264
264
  // FormList 和 Group场景 对比值改变的话, 回显到表单上
265
- if (inList) {
266
- form.setFieldsValue(_args[1]);
265
+ if (inList && changeKey === 'onFieldChange') {
266
+ var values = form.getFieldsValue();
267
+ var newValues = set(values, _otherFormItemProps.namePath, _args[1]);
268
+ form.setFieldsValue(newValues);
267
269
  }
268
270
  // Group默认校验, 延时与重新setFieldValue,为了解决校验值未同步最新的问题,
269
271
  if (formItemProps === null || formItemProps === void 0 ? void 0 : formItemProps.parentNames) {
@@ -276,7 +278,7 @@ var Render = function Render(props) {
276
278
  // ProTreeSelect返回option
277
279
  if (['ProTree'].includes(type)) {
278
280
  var _args2, _args2$;
279
- _args[2].option = findOptionByValue(lastComponentProps === null || lastComponentProps === void 0 ? void 0 : lastComponentProps.dataSource, (_args2 = _args) === null || _args2 === void 0 ? void 0 : (_args2$ = _args2[0]) === null || _args2$ === void 0 ? void 0 : _args2$[0]);
281
+ _args[2].option = findOptionByValue(lastComponentProps === null || lastComponentProps === void 0 ? void 0 : lastComponentProps.dataSource, (_args2 = _args) === null || _args2 === void 0 ? void 0 : (_args2$ = _args2[0]) === null || _args2$ === void 0 ? void 0 : _args2$[0], (lastComponentProps === null || lastComponentProps === void 0 ? void 0 : lastComponentProps.fieldNames) || {});
280
282
  }
281
283
  (_lastComponentProps$c2 = lastComponentProps[changeKey]) === null || _lastComponentProps$c2 === void 0 ? void 0 : _lastComponentProps$c2.call.apply(_lastComponentProps$c2, [lastComponentProps].concat(_toConsumableArray(_args)));
282
284
  };
@@ -316,7 +318,7 @@ var Render = function Render(props) {
316
318
  }();
317
319
  var renderItem = function renderItem() {
318
320
  // 移除多余字段,group保留onFieldChange
319
- var lastComponentPropsFilter = type === 'Group' ? ['disabledStrictly'] : ['onFieldChange', 'disabledStrictly'];
321
+ var lastComponentPropsFilter = ['onFieldChange', 'disabledStrictly'];
320
322
  // 表单渲染 start
321
323
  var childProps = _objectSpread(_objectSpread(_objectSpread({}, AutoComponent === null || AutoComponent === void 0 ? void 0 : AutoComponent.props), omit(lastComponentProps, lastComponentPropsFilter)), {}, {
322
324
  // @ts-ignore
@@ -179,6 +179,7 @@ var RenderFields = function RenderFields(props) {
179
179
  colProps: _colProps,
180
180
  mode: componentProps.mode,
181
181
  namePath: column.namePath,
182
+ listName: column.listName,
182
183
  globalControl: globalControl,
183
184
  formDisabled: formDisabled
184
185
  };