@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
@@ -292,58 +292,64 @@ var ProModalSelect = function ProModalSelect(props, ref) {
292
292
  };
293
293
  var handleFinish = /*#__PURE__*/function () {
294
294
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
295
- var _data, flag, res;
295
+ var _nextSelectedRows, _nextSelectedRows2, nextSelectedRows, record, flag, res;
296
296
  return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
297
297
  while (1) switch (_context2.prev = _context2.next) {
298
298
  case 0:
299
299
  _context2.prev = 0;
300
- if (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) {
300
+ if (selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.length) {
301
301
  _context2.next = 4;
302
302
  break;
303
303
  }
304
304
  _antd.message.error(_locale.default.ProModalSelect.checkMsg);
305
305
  return _context2.abrupt("return", false);
306
306
  case 4:
307
- _data = isMultiple ? selectedRows : selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows[0];
307
+ nextSelectedRows = selectedRows;
308
+ if (!((_nextSelectedRows = nextSelectedRows) === null || _nextSelectedRows === void 0 ? void 0 : _nextSelectedRows[0])) {
309
+ nextSelectedRows = data.filter(function (item) {
310
+ return selectedRowKeys.includes(item[valueKey]);
311
+ });
312
+ }
313
+ record = isMultiple ? nextSelectedRows : (_nextSelectedRows2 = nextSelectedRows) === null || _nextSelectedRows2 === void 0 ? void 0 : _nextSelectedRows2[0];
308
314
  if (!isMultiple) {
309
315
  // @ts-ignore
310
- _data.value = _data[valueKey];
316
+ record.value = record[valueKey];
311
317
  // @ts-ignore
312
- _data.label = _data[labelKey];
318
+ record.label = record[labelKey];
313
319
  }
314
320
  flag = true;
315
321
  if (!onOk) {
316
- _context2.next = 12;
322
+ _context2.next = 14;
317
323
  break;
318
324
  }
319
- _context2.next = 10;
320
- return onOk(_data);
321
- case 10:
325
+ _context2.next = 12;
326
+ return onOk(record);
327
+ case 12:
322
328
  res = _context2.sent;
323
329
  if (res !== null && res !== undefined) {
324
330
  // @ts-ignore
325
331
  flag = res;
326
332
  }
327
- case 12:
333
+ case 14:
328
334
  if (flag) {
329
- onChange === null || onChange === void 0 ? void 0 : onChange(labelInValue ? _data : getNextValues(_data), _data);
335
+ onChange === null || onChange === void 0 ? void 0 : onChange(labelInValue ? record : getNextValues(record), record);
330
336
  // 更新内部展示值
331
337
  setState({
332
- _value: _data,
333
- options: (0, _lodash.isArray)(_data) ? _data : [_data]
338
+ _value: record,
339
+ options: (0, _lodash.isArray)(record) ? record : [record]
334
340
  });
335
341
  handleClose();
336
342
  }
337
343
  return _context2.abrupt("return", flag);
338
- case 16:
339
- _context2.prev = 16;
344
+ case 18:
345
+ _context2.prev = 18;
340
346
  _context2.t0 = _context2["catch"](0);
341
347
  console.warn('error', _context2.t0);
342
- case 19:
348
+ case 21:
343
349
  case "end":
344
350
  return _context2.stop();
345
351
  }
346
- }, _callee2, null, [[0, 16]]);
352
+ }, _callee2, null, [[0, 18]]);
347
353
  }));
348
354
  return function handleFinish() {
349
355
  return _ref7.apply(this, arguments);
@@ -424,7 +430,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
424
430
  // 初始化回显,当传入initParams时,前端用来回险
425
431
  var getInitValues = /*#__PURE__*/function () {
426
432
  var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4() {
427
- var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _list, list, _res$data2, _data2, nextSelectRowKeys;
433
+ var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _list, list, _res$data2, _data, nextSelectRowKeys;
428
434
  return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
429
435
  while (1) switch (_context4.prev = _context4.next) {
430
436
  case 0:
@@ -455,15 +461,15 @@ var ProModalSelect = function ProModalSelect(props, ref) {
455
461
  } else {
456
462
  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;
457
463
  }
458
- _data2 = isMultiple ? list : (_list = list) === null || _list === void 0 ? void 0 : _list[0];
459
- if (_data2) {
464
+ _data = isMultiple ? list : (_list = list) === null || _list === void 0 ? void 0 : _list[0];
465
+ if (_data) {
460
466
  nextSelectRowKeys = isMultiple ? value : [value];
461
467
  if (labelInValue) {
462
- onChange(_data2);
468
+ onChange(_data);
463
469
  }
464
470
  // 更新内部展示值
465
471
  setState({
466
- _value: _data2,
472
+ _value: _data,
467
473
  isInit: false,
468
474
  selectedRows: list,
469
475
  selectedRowKeys: nextSelectRowKeys
@@ -490,7 +496,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
490
496
  var getDefaultOneValues = /*#__PURE__*/function () {
491
497
  var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee5() {
492
498
  var _useRequest$options4, _useRequest$options5;
493
- var queryBean, page, params, res, _list2, list, _res$data3, _data3, nextSelectRowKeys;
499
+ var queryBean, page, params, res, _list2, list, _res$data3, _data2, nextSelectRowKeys;
494
500
  return (0, _regeneratorRuntime2.default)().wrap(function _callee5$(_context5) {
495
501
  while (1) switch (_context5.prev = _context5.next) {
496
502
  case 0:
@@ -514,18 +520,18 @@ var ProModalSelect = function ProModalSelect(props, ref) {
514
520
  } else {
515
521
  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;
516
522
  }
517
- _data3 = isMultiple ? list : (_list2 = list) === null || _list2 === void 0 ? void 0 : _list2[0];
523
+ _data2 = isMultiple ? list : (_list2 = list) === null || _list2 === void 0 ? void 0 : _list2[0];
518
524
  nextSelectRowKeys = isMultiple ? value : [value];
519
525
  if (labelInValue) {
520
- onChange(_data3);
526
+ onChange(_data2);
521
527
  } else {
522
- onChange(isMultiple ? _data3.map(function (item) {
528
+ onChange(isMultiple ? _data2.map(function (item) {
523
529
  return item[valueKey];
524
- }) : _data3[valueKey]);
530
+ }) : _data2[valueKey]);
525
531
  }
526
532
  // 更新内部展示值
527
533
  setState({
528
- _value: _data3,
534
+ _value: _data2,
529
535
  isInit: false,
530
536
  selectedRows: list,
531
537
  selectedRowKeys: nextSelectRowKeys
@@ -594,8 +600,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
594
600
  nextState.selectedRows = value;
595
601
  }
596
602
  } else if (value) {
603
+ console.log('value', value);
597
604
  nextState.selectedRowKeys = [value];
598
- nextState.selectedRows = [(0, _defineProperty2.default)({}, valueKey, value[valueKey])];
599
605
  }
600
606
  setState(nextState);
601
607
  }
@@ -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,113 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ var _antd = require("antd");
12
+ var _react = require("react");
13
+ var _lodash = require("lodash");
14
+ var _ahooks = require("ahooks");
15
+ var _classnames2 = _interopRequireDefault(require("classnames"));
16
+ var _RenderFields = _interopRequireDefault(require("../../render/RenderFields"));
17
+ var _utils = require("./utils");
18
+ var _ProForm = _interopRequireDefault(require("../../../../ProForm"));
19
+ var Group = function Group(props) {
20
+ var columns = props.children,
21
+ otherProps = props.otherProps,
22
+ className = props.className,
23
+ _props$space = props.space,
24
+ space = _props$space === void 0 ? {
25
+ size: 12
26
+ } : _props$space,
27
+ id = props.id,
28
+ value = props.value,
29
+ isView = props.isView,
30
+ index = props.index,
31
+ onFieldChange = props.onFieldChange,
32
+ namePath = props.namePath;
33
+ var _ref = _ProForm.default.useFieldProps() || {},
34
+ names = _ref.names,
35
+ name = _ref.name,
36
+ form = _ref.form,
37
+ _namePath = _ref.namePath;
38
+ var newNamePath = namePath || _namePath || [];
39
+ if (!Array.isArray(names)) {
40
+ console.error('Warning: Composite form components whose type is Group must be configured with names');
41
+ }
42
+ var data = (0, _react.useMemo)(function () {
43
+ var fieldList = [];
44
+ var result = columns.map(function (item) {
45
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({
46
+ disabled: Boolean(props === null || props === void 0 ? void 0 : props.disabled)
47
+ }, item), {}, {
48
+ isView: isView !== null && isView !== void 0 ? isView : item.isView,
49
+ noStyle: (space === null || space === void 0 ? void 0 : space.compact) || (space === null || space === void 0 ? void 0 : space.separator),
50
+ parentNames: id,
51
+ namePath: newNamePath
52
+ });
53
+ });
54
+ var node = (0, _jsxRuntime.jsx)(_antd.Button, {
55
+ className: "group-separator",
56
+ children: space.separator
57
+ });
58
+ return {
59
+ columns: (0, _utils.insertSeparator)(result, space, node, otherProps),
60
+ fieldList: fieldList
61
+ };
62
+ }, [name, columns, space, props, names]);
63
+ var _className = (0, _classnames2.default)((0, _defineProperty2.default)({
64
+ 'pro-group': true,
65
+ 'pro-group-diy-width': columns.some(function (item) {
66
+ var _item$fieldProps, _item$fieldProps$styl;
67
+ 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;
68
+ }),
69
+ 'pro-group-width-auto': columns.some(function (item) {
70
+ return ['Radio', 'Checkbox', 'Switch'].includes(item.type);
71
+ })
72
+ }, "".concat(className), className));
73
+ // 用于formList场景下names移除掉了前缀,需要再次合并回来
74
+ var _names = names.map(function (item) {
75
+ if ((0, _lodash.isNumber)(item === null || item === void 0 ? void 0 : item[0])) {
76
+ return (0, _lodash.union)(newNamePath, item);
77
+ }
78
+ return item;
79
+ });
80
+ (0, _ahooks.useDeepCompareEffect)(function () {
81
+ var _document, _document$activeEleme;
82
+ // 焦点激活的表单
83
+ var touchName = ((_document = document) === null || _document === void 0 ? void 0 : (_document$activeEleme = _document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.id) || '';
84
+ // 模拟change,初始化不执行onFieldChange
85
+ if ((0, _lodash.isFunction)(onFieldChange) && form.isFieldsTouched(_names) && (0, _utils.transformNamesString)(_names).includes(touchName)) {
86
+ onFieldChange(value, (newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.length) ? form.getFieldValue(newNamePath, true) : form.getFieldsValue(), {
87
+ form: form,
88
+ namePath: newNamePath,
89
+ index: index
90
+ });
91
+ }
92
+ }, [value]);
93
+ var _otherProps = (0, _lodash.omit)(otherProps, ['colProps', 'required']);
94
+ return (0, _jsxRuntime.jsx)("div", {
95
+ className: _className,
96
+ children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? (0, _jsxRuntime.jsx)(_antd.Space.Compact, {
97
+ children: (0, _jsxRuntime.jsx)(_RenderFields.default, (0, _objectSpread2.default)({
98
+ columns: data.columns,
99
+ form: form
100
+ }, _otherProps))
101
+ }) : (0, _jsxRuntime.jsx)(_antd.Space, (0, _objectSpread2.default)((0, _objectSpread2.default)({
102
+ align: "start"
103
+ }, (0, _lodash.omit)(space, ['separator', 'compact'])), {}, {
104
+ children: data.columns.map(function (column, index) {
105
+ return (0, _jsxRuntime.jsx)(_RenderFields.default, (0, _objectSpread2.default)({
106
+ columns: [column],
107
+ form: form
108
+ }, _otherProps), (column === null || column === void 0 ? void 0 : column.name) || index);
109
+ })
110
+ }))
111
+ });
112
+ };
113
+ var _default = exports.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,53 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.transformNamesString = exports.insertSeparator = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ /**
10
+ * 插入间隔符
11
+ * @param columns 表单配置数组
12
+ * @returns
13
+ */
14
+ var insertSeparator = exports.insertSeparator = function insertSeparator(columns, space, separatorNode, otherProps) {
15
+ var _columns = columns;
16
+ var _ref = otherProps || {},
17
+ names = _ref.names;
18
+ // 紧凑模式存在names时,自动给下级拆解name
19
+ if (names) {
20
+ _columns = _columns.map(function (column, index) {
21
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
22
+ name: names[index]
23
+ });
24
+ });
25
+ }
26
+ if (!(space === null || space === void 0 ? void 0 : space.separator)) {
27
+ return _columns;
28
+ }
29
+ return _columns.reduce(function (result, current, index, array) {
30
+ // 将当前元素添加到结果数组中
31
+ result.push(current);
32
+ // 如果当前元素不是最后一个元素,则添加间隔符
33
+ if (index < array.length - 1) {
34
+ result.push({
35
+ component: separatorNode,
36
+ fieldProps: {
37
+ disabled: true
38
+ }
39
+ });
40
+ }
41
+ return result;
42
+ }, []);
43
+ };
44
+ /** 转换names */
45
+ var transformNamesString = exports.transformNamesString = function transformNamesString(arr) {
46
+ var result = arr.map(function (subArr) {
47
+ if (Array.isArray(subArr)) {
48
+ return subArr.join('_');
49
+ }
50
+ return subArr;
51
+ });
52
+ return result;
53
+ };
@@ -253,15 +253,17 @@ var Render = function Render(props) {
253
253
  if (changeKey === 'onFieldChange') {
254
254
  _args = functionArgs([].concat(args));
255
255
  }
256
+ var inList = _otherFormItemProps === null || _otherFormItemProps === void 0 ? void 0 : (_otherFormItemProps$n3 = _otherFormItemProps.namePath) === null || _otherFormItemProps$n3 === void 0 ? void 0 : _otherFormItemProps$n3.length;
256
257
  if ( /*#__PURE__*/_react.default.isValidElement(AutoComponent)) {
257
258
  var _AutoComponent$props$, _AutoComponent$props, _lastComponentProps$c;
258
259
  ((_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((0, _toConsumableArray2.default)(_args)))) || ((_lastComponentProps$c = lastComponentProps[changeKey]) === null || _lastComponentProps$c === void 0 ? void 0 : _lastComponentProps$c.call.apply(_lastComponentProps$c, [lastComponentProps].concat((0, _toConsumableArray2.default)(_args))));
259
260
  return false;
260
261
  }
261
- var inList = _otherFormItemProps === null || _otherFormItemProps === void 0 ? void 0 : (_otherFormItemProps$n3 = _otherFormItemProps.namePath) === null || _otherFormItemProps$n3 === void 0 ? void 0 : _otherFormItemProps$n3.length;
262
262
  // FormList 和 Group场景 对比值改变的话, 回显到表单上
263
- if (inList) {
264
- form.setFieldsValue(_args[1]);
263
+ if (inList && changeKey === 'onFieldChange') {
264
+ var values = form.getFieldsValue();
265
+ var newValues = (0, _lodash.set)(values, _otherFormItemProps.namePath, _args[1]);
266
+ form.setFieldsValue(newValues);
265
267
  }
266
268
  // Group默认校验, 延时与重新setFieldValue,为了解决校验值未同步最新的问题,
267
269
  if (formItemProps === null || formItemProps === void 0 ? void 0 : formItemProps.parentNames) {
@@ -274,7 +276,7 @@ var Render = function Render(props) {
274
276
  // ProTreeSelect返回option
275
277
  if (['ProTree'].includes(type)) {
276
278
  var _args2, _args2$;
277
- _args[2].option = (0, _index.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]);
279
+ _args[2].option = (0, _index.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) || {});
278
280
  }
279
281
  (_lastComponentProps$c2 = lastComponentProps[changeKey]) === null || _lastComponentProps$c2 === void 0 ? void 0 : _lastComponentProps$c2.call.apply(_lastComponentProps$c2, [lastComponentProps].concat((0, _toConsumableArray2.default)(_args)));
280
282
  };
@@ -314,7 +316,7 @@ var Render = function Render(props) {
314
316
  }();
315
317
  var renderItem = function renderItem() {
316
318
  // 移除多余字段,group保留onFieldChange
317
- var lastComponentPropsFilter = type === 'Group' ? ['disabledStrictly'] : ['onFieldChange', 'disabledStrictly'];
319
+ var lastComponentPropsFilter = ['onFieldChange', 'disabledStrictly'];
318
320
  // 表单渲染 start
319
321
  var childProps = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, AutoComponent === null || AutoComponent === void 0 ? void 0 : AutoComponent.props), (0, _lodash.omit)(lastComponentProps, lastComponentPropsFilter)), {}, {
320
322
  // @ts-ignore
@@ -187,6 +187,7 @@ var RenderFields = function RenderFields(props) {
187
187
  colProps: _colProps,
188
188
  mode: componentProps.mode,
189
189
  namePath: column.namePath,
190
+ listName: column.listName,
190
191
  globalControl: globalControl,
191
192
  formDisabled: formDisabled
192
193
  };
@@ -28,7 +28,7 @@ import { ProEditTableProps } from '../../../ProEditTable/propsType';
28
28
  import { ProTreeModalProps } from '../../../ProTreeModal/propsType';
29
29
  import { ProUploadProps } from '../../../ProUpload/propsType';
30
30
  import { ProTreeProps } from '../../../ProTree/propsType';
31
- import { GroupProps } from '../combination/Group/propsType';
31
+ import { GroupProps as GroupCopyProps } from '../combination/Group/propsType';
32
32
  import { ProCollapseProps } from '../../../ProLayout/components/ProCollapse/PropTypes';
33
33
  import { DistributiveOmit } from '../../propsType';
34
34
  export type ComponentMap = keyof typeof componentMap;
@@ -159,7 +159,7 @@ export type ColumnPropsMap<Values = any, T = 'ProForm'> = {
159
159
  fieldProps?: FieldProps<ProTreeProps, Values, T>;
160
160
  } | {
161
161
  type?: 'Group';
162
- fieldProps?: GroupProps | ReactiveFunction<Values, GroupProps>;
162
+ fieldProps?: GroupCopyProps | ReactiveFunction<Values, GroupCopyProps>;
163
163
  } | {
164
164
  type?: 'ProCollapse';
165
165
  fieldProps?: ProCollapseProps | ReactiveFunction<Values, ProCollapseProps>;
@@ -208,6 +208,7 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
208
208
  clearNotShow?: boolean;
209
209
  index?: number;
210
210
  namePath?: NamePath;
211
+ listName?: NamePath;
211
212
  /** 表单前缀信息 */
212
213
  before?: string | React.ReactNode;
213
214
  /** 表单后缀信息 */
@@ -216,7 +217,7 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
216
217
  extra?: string | React.ReactNode;
217
218
  /** 是否固定字段, 不隐藏 */
218
219
  fixed?: boolean;
219
- confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps>;
220
+ confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps | void>;
220
221
  }
221
222
  export type ProColumnProps<T = any> = ProFormColumnProps<T> & ColumnPropsMap<T, 'ProForm'>;
222
223
  /**
@@ -41,6 +41,7 @@ export interface ProFormOtherProps {
41
41
  required?: boolean | boolean[] | (() => boolean | boolean[]);
42
42
  mode?: string;
43
43
  namePath?: any[] | string | number;
44
+ listName?: any[] | string | number;
44
45
  globalControl?: boolean;
45
46
  formDisabled?: boolean;
46
47
  }
@@ -140,6 +140,13 @@
140
140
 
141
141
  // 地址组件
142
142
  .@{ant-prefix}-form-item-control-input-content {
143
+ // 查看模式
144
+ & > span {
145
+ border-radius: 4px;
146
+ padding: 5px 8px;
147
+ background: @zaui-contract-bg;
148
+ }
149
+
143
150
  & > .pro-address {
144
151
  .@{ant-prefix}-select-selector,
145
152
  .@{ant-prefix}-input-affix-wrapper,
@@ -47,7 +47,8 @@ var diffOriginal = exports.diffOriginal = function diffOriginal(params) {
47
47
  });
48
48
  }
49
49
  if (!nullValue.includes(value) || !nullValue.includes(originalValue)) {
50
- return !(0, _lodash.isEqual)(value, originalValue);
50
+ var res = !(0, _lodash.isEqual)(value, originalValue);
51
+ return res;
51
52
  }
52
53
  return false;
53
54
  };
@@ -83,7 +83,12 @@ export declare const deleteForPath: (values: any, namePath: string | number | (s
83
83
  * @param value 选中值
84
84
  * @returns {}
85
85
  */
86
- export declare const findOptionByValue: (treeData: any[], value: string | number) => any;
86
+ export declare const findOptionByValue: (treeData: any[], value: string | number, fieldNames: {
87
+ [key: string]: any;
88
+ label?: string;
89
+ value?: string;
90
+ children?: string;
91
+ }) => any;
87
92
  /**
88
93
  * 对比依赖列表中的 值是否变更
89
94
  */
@@ -408,19 +408,19 @@ var deleteForPath = exports.deleteForPath = function deleteForPath(values, nameP
408
408
  * @param value 选中值
409
409
  * @returns {}
410
410
  */
411
- var findOptionByValue = exports.findOptionByValue = function findOptionByValue(treeData, value) {
411
+ var findOptionByValue = exports.findOptionByValue = function findOptionByValue(treeData, value, fieldNames) {
412
412
  if ((0, _lodash.isObject)(value)) {
413
413
  return value;
414
414
  }
415
415
  for (var i = 0; i < (treeData === null || treeData === void 0 ? void 0 : treeData.length); i++) {
416
416
  var node = treeData[i];
417
- if (node.value === value) {
418
- return (0, _lodash.omit)(node, ['children']);
417
+ if (node[(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value) || 'value'] === value) {
418
+ return (0, _lodash.omit)(node, ['children', fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children]);
419
419
  }
420
420
  if (node.children) {
421
- var foundNode = findOptionByValue(node.children, value);
421
+ var foundNode = findOptionByValue(node[(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'], value, fieldNames);
422
422
  if (foundNode) {
423
- return (0, _lodash.omit)(foundNode, ['children']);
423
+ return (0, _lodash.omit)(foundNode, ['children', fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children]);
424
424
  }
425
425
  }
426
426
  }
@@ -7,23 +7,16 @@ exports.default = void 0;
7
7
  var _lodash = require("lodash");
8
8
  var _transformValue2 = require("./transformValue");
9
9
  var transformNames = function transformNames(formItem, form, names, fieldName, type) {
10
- var _names2, _names3, _names3$;
11
10
  var _ref = formItem || {},
12
11
  normalize = _ref.normalize,
13
12
  getValueProps = _ref.getValueProps,
14
13
  _shouldUpdate2 = _ref.shouldUpdate;
15
- var _names = names;
16
- if (!((_names2 = _names) === null || _names2 === void 0 ? void 0 : _names2.length)) {
14
+ if (!(names === null || names === void 0 ? void 0 : names.length)) {
17
15
  return {};
18
16
  }
19
17
  // 当在formList场景下,给transformValue函数的setFiledProps的name, 需要全namePath
20
18
  var _fieldName = Array.isArray(formItem === null || formItem === void 0 ? void 0 : formItem.name) ? (0, _lodash.union)(formItem === null || formItem === void 0 ? void 0 : formItem.namePath, formItem === null || formItem === void 0 ? void 0 : formItem.name) : fieldName;
21
- if (type === 'Group' && (0, _lodash.isNumber)((_names3 = _names) === null || _names3 === void 0 ? void 0 : (_names3$ = _names3[0]) === null || _names3$ === void 0 ? void 0 : _names3$[0])) {
22
- _names = _names.map(function (item) {
23
- return (0, _lodash.union)(formItem === null || formItem === void 0 ? void 0 : formItem.namePath, item);
24
- });
25
- }
26
- var _transformValue = (0, _transformValue2.transformValue)(_names, form, _fieldName, normalize, getValueProps),
19
+ var _transformValue = (0, _transformValue2.transformValue)(names, form, _fieldName, normalize, getValueProps),
27
20
  _normalize = _transformValue.normalize,
28
21
  _getValueProps = _transformValue.getValueProps,
29
22
  _shouldUpdate = _transformValue.shouldUpdate;
@@ -0,0 +1,2 @@
1
+ /** 深度比较依赖变化memo */
2
+ export declare const useDeepCompareMemo: (fun: () => any, depList: any[]) => any;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useDeepCompareMemo = void 0;
7
+ var _react = require("react");
8
+ var _lodash = require("lodash");
9
+ var _ = require(".");
10
+ /** 深度比较依赖变化memo */
11
+ var useDeepCompareMemo = exports.useDeepCompareMemo = function useDeepCompareMemo(fun, depList) {
12
+ var lastDependency = (0, _react.useRef)(); // 上一次的依赖
13
+ var lastRes = (0, _react.useRef)(); // 上一次的结果
14
+ if (!(0, _lodash.isEqualWith)(depList, lastDependency.current, _.customEqualForFun)) {
15
+ var res = fun();
16
+ lastRes.current = res;
17
+ }
18
+ lastDependency.current = depList;
19
+ return lastRes.current;
20
+ };
@@ -63,7 +63,8 @@ var useForm = exports.useForm = function useForm(originForm) {
63
63
  behavior: 'smooth'
64
64
  });
65
65
  }
66
- case 14:
66
+ throw _context.t0;
67
+ case 15:
67
68
  case "end":
68
69
  return _context.stop();
69
70
  }
@@ -92,7 +92,7 @@ var useListChanged = exports.useListChanged = function useListChanged(params) {
92
92
  originalValue: originalValue,
93
93
  form: form,
94
94
  equalWith: equalWith,
95
- name: namesStr || name
95
+ name: (0, _lodash.isString)(namesStr) ? namesStr : originalName || name
96
96
  });
97
97
  return [changed, originalValue];
98
98
  };
@@ -31,10 +31,6 @@ var useRules = function useRules(props) {
31
31
  var result = {
32
32
  rules: rules || []
33
33
  };
34
- // Group required: true时,直接走完整校验
35
- if (allRequired && type === 'Group') {
36
- return result;
37
- }
38
34
  if (allRequired) {
39
35
  if (!requiredRule) {
40
36
  var message = isSelect ? "".concat(_locale.default.ProForm.selectPlaceHolder).concat(_label) : "".concat(_locale.default.ProForm.inputPlaceholder).concat(_label);
@@ -65,23 +61,9 @@ var useRules = function useRules(props) {
65
61
  required: required
66
62
  });
67
63
  (0, _react.useEffect)(function () {
68
- if (type === 'Group' && (allRequired || requiredRule)) {
69
- var customRequired = {
70
- validator: function validator(rules, value) {
71
- // 完整性校验, 数组有值且值不完整则校验不通过
72
- if (Array.isArray(value) && (0, _index.isNotFullArray)(value, names.length, required)) {
73
- return Promise.reject(new Error("".concat(_locale.default.ProForm.completeText).concat(_label)));
74
- }
75
- return Promise.resolve();
76
- }
77
- };
78
- // 插入rules第一条,完整性校验大于自定义
79
- internalRule.rules.unshift(customRequired);
80
- return;
81
- }
82
64
  // 添加完整性校验
83
65
  if (names && !(0, _lodash.isBoolean)(labelRequired)) {
84
- var _customRequired = {
66
+ var customRequired = {
85
67
  validator: function validator(rules, value) {
86
68
  // 完整性校验, 空数组不校验, 数组有值且值不完整则校验不通过
87
69
  if (Array.isArray(value) && !(0, _index.isNullArray)(value) && (0, _index.isNotFullArray)(value, names.length, required)) {
@@ -90,7 +72,7 @@ var useRules = function useRules(props) {
90
72
  return Promise.resolve();
91
73
  }
92
74
  };
93
- internalRule.rules.unshift(_customRequired);
75
+ internalRule.rules.unshift(customRequired);
94
76
  }
95
77
  }, [internalRule]);
96
78
  return internalRule;