@zat-design/sisyphus-react 3.9.8-beta.9 → 3.10.0-beta.1

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.
@@ -2,8 +2,8 @@ import "antd/es/button/style";
2
2
  import _Button from "antd/es/button";
3
3
  import "antd/es/popconfirm/style";
4
4
  import _Popconfirm from "antd/es/popconfirm";
5
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
6
5
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
6
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
7
7
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
8
8
  import React from 'react';
9
9
  import { isFunction, omit } from 'lodash';
@@ -23,13 +23,20 @@ var ActionButton = function ActionButton(_ref) {
23
23
  deletePoConfirmMsg = config.deletePoConfirmMsg,
24
24
  mulDeletePoConfirmMsg = config.mulDeletePoConfirmMsg,
25
25
  max = config.max,
26
- tableLength = config.tableLength;
26
+ name = config.name,
27
+ tableLength = config.tableLength,
28
+ selectedRows = config.selectedRows;
29
+ var rowNamePath = [].concat(_toConsumableArray(name), [index]);
27
30
  // 操作按钮权限控制
28
31
  var getShow = function getShow(show) {
29
32
  if (typeof show === 'function') {
30
33
  return show(record, {
31
34
  index: index,
32
- form: form
35
+ form: form,
36
+ name: name,
37
+ namePath: rowNamePath,
38
+ tableLength: tableLength,
39
+ selectedRows: selectedRows
33
40
  });
34
41
  }
35
42
  return show;
@@ -39,7 +46,11 @@ var ActionButton = function ActionButton(_ref) {
39
46
  if (typeof disabled === 'function') {
40
47
  return disabled(record, {
41
48
  index: index,
42
- form: form
49
+ form: form,
50
+ name: name,
51
+ namePath: rowNamePath,
52
+ tableLength: tableLength,
53
+ selectedRows: selectedRows
43
54
  });
44
55
  }
45
56
  // 新增超过最大行,禁止操作按钮
@@ -61,21 +72,29 @@ var ActionButton = function ActionButton(_ref) {
61
72
  // 其他操作按钮Props
62
73
  var actionBtnProps = _objectSpread(_objectSpread({}, btnConfig.buttonProps), {}, {
63
74
  onClick: function onClick() {
64
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
75
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
76
+ index: index,
77
+ form: form,
78
+ name: name,
79
+ namePath: rowNamePath,
80
+ tableLength: tableLength,
81
+ selectedRows: selectedRows
82
+ });
65
83
  },
66
84
  disabled: getDisabled((_btnConfig$buttonProp3 = btnConfig.buttonProps) === null || _btnConfig$buttonProp3 === void 0 ? void 0 : _btnConfig$buttonProp3.disabled)
67
85
  });
68
86
  // 当传入函数时,先转成reactNode
69
87
  if (isFunction(btnConfig.label)) {
70
88
  var addIndex = tableLength ? tableLength - 1 : 0;
71
- var namePath = [].concat(_toConsumableArray(config.name), [addIndex]);
89
+ var namePath = [].concat(_toConsumableArray(name), [addIndex]);
72
90
  var addRecord = form.getFieldValue(namePath) || {};
73
91
  btnConfig.label = btnConfig.label(addRecord, {
74
92
  form: form,
75
93
  namePath: namePath,
76
- name: config.name,
77
- index: addIndex,
78
- tableLength: tableLength
94
+ name: name,
95
+ tableLength: tableLength,
96
+ selectedRows: selectedRows,
97
+ index: addIndex
79
98
  });
80
99
  }
81
100
  var isDisabled = !selectedRowKeys.length && btnConfig.type === 'mulDelete' || editingKeys.length || (delBtnProps === null || delBtnProps === void 0 ? void 0 : delBtnProps.disabled);
@@ -85,7 +104,14 @@ var ActionButton = function ActionButton(_ref) {
85
104
  placement: "topRight",
86
105
  title: deleteMsgMap[btnConfig.type],
87
106
  onConfirm: function onConfirm() {
88
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
107
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
108
+ index: index,
109
+ form: form,
110
+ name: name,
111
+ namePath: rowNamePath,
112
+ tableLength: tableLength,
113
+ selectedRows: selectedRows
114
+ });
89
115
  },
90
116
  disabled: isDisabled,
91
117
  okText: locale.ProEditTable.confirm,
@@ -105,13 +131,27 @@ var ActionButton = function ActionButton(_ref) {
105
131
  index: index,
106
132
  disabled: isDisabled,
107
133
  onClick: function onClick() {
108
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
134
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
135
+ index: index,
136
+ form: form,
137
+ name: name,
138
+ namePath: rowNamePath,
139
+ tableLength: tableLength,
140
+ selectedRows: selectedRows
141
+ });
109
142
  }
110
143
  }))) : _jsx(_Button, _objectSpread(_objectSpread({}, omit(delBtnProps, ['buttonProps', 'isEditable', 'onEvent'])), {}, {
111
144
  disabled: isDisabled,
112
145
  type: "link",
113
146
  onClick: function onClick() {
114
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
147
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
148
+ index: index,
149
+ form: form,
150
+ name: name,
151
+ namePath: rowNamePath,
152
+ tableLength: tableLength,
153
+ selectedRows: selectedRows
154
+ });
115
155
  },
116
156
  children: btnConfig.label
117
157
  }))
@@ -17,12 +17,9 @@ var RenderToolbar = function RenderToolbar(config) {
17
17
  toolbarProps = config.toolbarProps,
18
18
  name = config.name,
19
19
  virtualKey = config.virtualKey,
20
- form = config.form,
21
20
  disabled = config.disabled,
22
- selectedRows = config.selectedRows,
23
21
  tableLength = config.tableLength;
24
22
  var virtualName = getNamePath(name, virtualKey);
25
- var dataSource = form.getFieldValue(name);
26
23
  // toolbarProps配置为false 默认不插入
27
24
  if (toolbarProps === false || disabled) {
28
25
  return null;
@@ -76,28 +73,33 @@ var RenderToolbar = function RenderToolbar(config) {
76
73
  toolbar.show = show !== null && show !== void 0 ? show : true;
77
74
  toolbar.needConfirm = needConfirm !== null && needConfirm !== void 0 ? needConfirm : true;
78
75
  toolbar.onEvent = /*#__PURE__*/function () {
79
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(record, index) {
80
- var onEvent, result;
76
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(record, _ref) {
77
+ var index, form, name, namePath, tableLength, selectedRows, onEvent, result;
81
78
  return _regeneratorRuntime().wrap(function _callee$(_context) {
82
79
  while (1) switch (_context.prev = _context.next) {
83
80
  case 0:
81
+ index = _ref.index, form = _ref.form, name = _ref.name, namePath = _ref.namePath, tableLength = _ref.tableLength, selectedRows = _ref.selectedRows;
84
82
  onEvent = onClick || onHandle;
85
83
  if (onEvent) {
86
- _context.next = 5;
84
+ _context.next = 6;
87
85
  break;
88
86
  }
89
87
  result = true;
90
- _context.next = 8;
88
+ _context.next = 9;
91
89
  break;
92
- case 5:
93
- _context.next = 7;
94
- return onEvent === null || onEvent === void 0 ? void 0 : onEvent(selectedRows, dataSource, {
90
+ case 6:
91
+ _context.next = 8;
92
+ return onEvent === null || onEvent === void 0 ? void 0 : onEvent(record, {
93
+ index: index,
95
94
  form: form,
96
- namePath: virtualName
95
+ name: name,
96
+ namePath: namePath,
97
+ tableLength: tableLength,
98
+ selectedRows: selectedRows
97
99
  });
98
- case 7:
99
- result = _context.sent;
100
100
  case 8:
101
+ result = _context.sent;
102
+ case 9:
101
103
  if (result !== false && type !== 'custom') {
102
104
  actions[type](_objectSpread(_objectSpread({}, config), {}, {
103
105
  index: index,
@@ -107,14 +109,14 @@ var RenderToolbar = function RenderToolbar(config) {
107
109
  virtualName: virtualName
108
110
  }));
109
111
  }
110
- case 9:
112
+ case 10:
111
113
  case "end":
112
114
  return _context.stop();
113
115
  }
114
116
  }, _callee);
115
117
  }));
116
118
  return function (_x, _x2) {
117
- return _ref.apply(this, arguments);
119
+ return _ref2.apply(this, arguments);
118
120
  };
119
121
  }();
120
122
  toolbar.buttonProps = buttonProps;
@@ -297,7 +297,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
297
297
  }, [value, config.name]);
298
298
  var _columns = useMemo(function () {
299
299
  return transformColumns(columns, config);
300
- }, [valueChangeRef.current, disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath]);
300
+ }, [valueChangeRef.current, disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath, value === null || value === void 0 ? void 0 : value.length]);
301
301
  var initDataSource = function initDataSource() {
302
302
  var _value$every, _value$some;
303
303
  var isAllHasKey = value === null || value === void 0 ? void 0 : (_value$every = value.every) === null || _value$every === void 0 ? void 0 : _value$every.call(value, function (item) {
@@ -11,9 +11,12 @@ import { ProFormValueType, ColumnPropsMap } from '../ProForm/components/render/p
11
11
  import { DiffOriginalParams } from '../ProForm/utils/diffOriginal';
12
12
  export type ActionType = 'edit' | 'delete' | 'save' | 'cancel' | 'add' | 'mulDelete' | 'custom';
13
13
  export type ShowFunction<T> = (record?: T, options?: {
14
- index?: number;
15
- form?: FormInstance;
16
- namePath?: NamePath;
14
+ index: number;
15
+ form: FormInstance;
16
+ name: NamePath;
17
+ namePath: NamePath;
18
+ tableLength: number;
19
+ selectedRows: T[];
17
20
  }) => Promise<any> | boolean | void;
18
21
  export interface OptionsProps {
19
22
  index: number;
@@ -83,49 +83,54 @@ var getActionColumn = function getActionColumn(config) {
83
83
  action.show = show !== null && show !== void 0 ? show : true;
84
84
  action.needConfirm = needConfirm !== null && needConfirm !== void 0 ? needConfirm : true;
85
85
  action.onEvent = /*#__PURE__*/function () {
86
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(record, index) {
86
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(record, _ref) {
87
87
  var _form$getFieldValue;
88
- var rowName, _record, onEvent, result;
88
+ var index, form, name, namePath, tableLength, selectedRows, rowName, _record, onEvent, result;
89
89
  return _regeneratorRuntime().wrap(function _callee$(_context) {
90
90
  while (1) switch (_context.prev = _context.next) {
91
91
  case 0:
92
+ index = _ref.index, form = _ref.form, name = _ref.name, namePath = _ref.namePath, tableLength = _ref.tableLength, selectedRows = _ref.selectedRows;
92
93
  index = tools.calc(firstIndex, '+', index);
93
94
  rowName = [].concat(_toConsumableArray(virtualRowName), [index]);
94
95
  if (!(type === 'save')) {
95
- _context.next = 12;
96
+ _context.next = 13;
96
97
  break;
97
98
  }
98
- _context.prev = 3;
99
- _context.next = 6;
99
+ _context.prev = 4;
100
+ _context.next = 7;
100
101
  return customValidate(validateKeys, form, rowName);
101
- case 6:
102
- _context.next = 12;
102
+ case 7:
103
+ _context.next = 13;
103
104
  break;
104
- case 8:
105
- _context.prev = 8;
106
- _context.t0 = _context["catch"](3);
105
+ case 9:
106
+ _context.prev = 9;
107
+ _context.t0 = _context["catch"](4);
107
108
  handleScrollToError();
108
109
  return _context.abrupt("return", Promise.reject(_context.t0));
109
- case 12:
110
+ case 13:
110
111
  // 编辑状态使用自定义form值,非编辑状态直接使用行数据
111
112
  _record = (_form$getFieldValue = form.getFieldValue(rowName)) !== null && _form$getFieldValue !== void 0 ? _form$getFieldValue : record; // 新增事件可以设置初始默认值,当做函数的出参导出
112
113
  onEvent = onClick || onHandle;
113
114
  if (onEvent) {
114
- _context.next = 18;
115
+ _context.next = 19;
115
116
  break;
116
117
  }
117
118
  result = true;
118
- _context.next = 21;
119
+ _context.next = 22;
119
120
  break;
120
- case 18:
121
- _context.next = 20;
122
- return onEvent === null || onEvent === void 0 ? void 0 : onEvent(_record, index, {
121
+ case 19:
122
+ _context.next = 21;
123
+ return onEvent === null || onEvent === void 0 ? void 0 : onEvent(_record, {
123
124
  form: form,
124
- namePath: virtualRowName
125
+ index: index,
126
+ tableLength: tableLength,
127
+ name: name,
128
+ namePath: namePath,
129
+ selectedRows: selectedRows
125
130
  });
126
- case 20:
127
- result = _context.sent;
128
131
  case 21:
132
+ result = _context.sent;
133
+ case 22:
129
134
  if (result !== false && type !== 'custom') {
130
135
  actions[type](_objectSpread(_objectSpread({}, config), {}, {
131
136
  rowName: [].concat(_toConsumableArray(name), [index]),
@@ -135,14 +140,14 @@ var getActionColumn = function getActionColumn(config) {
135
140
  validateKeys: validateKeys
136
141
  }));
137
142
  }
138
- case 22:
143
+ case 23:
139
144
  case "end":
140
145
  return _context.stop();
141
146
  }
142
- }, _callee, null, [[3, 8]]);
147
+ }, _callee, null, [[4, 9]]);
143
148
  }));
144
149
  return function (_x, _x2) {
145
- return _ref.apply(this, arguments);
150
+ return _ref2.apply(this, arguments);
146
151
  };
147
152
  }();
148
153
  action.buttonProps = buttonProps;
@@ -225,10 +230,10 @@ export var transformColumns = function transformColumns() {
225
230
  if (typeof columnTitle === 'string') {
226
231
  item.originTitle = columnTitle;
227
232
  if (tooltip) {
228
- var _ref2 = tooltip || {},
229
- tooltipTitle = _ref2.title,
230
- icon = _ref2.icon,
231
- resetProps = _objectWithoutProperties(_ref2, _excluded2);
233
+ var _ref3 = tooltip || {},
234
+ tooltipTitle = _ref3.title,
235
+ icon = _ref3.icon,
236
+ resetProps = _objectWithoutProperties(_ref3, _excluded2);
232
237
  item.title = _jsxs("span", {
233
238
  className: "pro-edit-table-title pro-edit-table-tooltip",
234
239
  children: [before, columnTitle, _jsx(_Tooltip, _objectSpread(_objectSpread({
@@ -388,13 +393,13 @@ export var transformColumns = function transformColumns() {
388
393
  // cacheMap 用来存储缓存值,若有值后不再请求
389
394
  if (JSON.stringify(cacheMap.current) === '{}') {
390
395
  Promise.all(Object.entries(_cacheMap).map(/*#__PURE__*/function () {
391
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(item) {
392
- var _item, key, value, _ref4, service, option;
396
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(item) {
397
+ var _item, key, value, _ref5, service, option;
393
398
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
394
399
  while (1) switch (_context2.prev = _context2.next) {
395
400
  case 0:
396
401
  _item = _slicedToArray(item, 2), key = _item[0], value = _item[1];
397
- _ref4 = (value === null || value === void 0 ? void 0 : value.useRequest) || {}, service = _ref4.service, option = _ref4.option;
402
+ _ref5 = (value === null || value === void 0 ? void 0 : value.useRequest) || {}, service = _ref5.service, option = _ref5.option;
398
403
  if (!service) {
399
404
  _context2.next = 8;
400
405
  break;
@@ -414,7 +419,7 @@ export var transformColumns = function transformColumns() {
414
419
  }, _callee2);
415
420
  }));
416
421
  return function (_x3) {
417
- return _ref3.apply(this, arguments);
422
+ return _ref4.apply(this, arguments);
418
423
  };
419
424
  }())).then(function (res) {
420
425
  res.forEach(function (item) {
@@ -424,17 +424,22 @@ var Render = function Render(props) {
424
424
  colProps = _objectSpread(_objectSpread({}, colProps), {}, {
425
425
  span: lessMode ? colProps.span : 24 // 默认占一行
426
426
  });
427
- return _jsx(_Form.List, _objectSpread(_objectSpread({
428
- name: _otherFormItemProps.name
429
- }, omit(_otherFormItemProps, ['rules'])), {}, {
430
- children: function children(fields, operation, meta) {
431
- return _jsx(AutoComponent, _objectSpread(_objectSpread({}, omit(lastComponentProps, lastComponentPropsFilter)), {}, {
432
- otherProps: otherProps,
433
- fields: fields,
434
- operation: operation,
435
- meta: meta
436
- }));
437
- }
427
+ return _jsx(_Form.Item, _objectSpread(_objectSpread({}, omit(_otherFormItemProps, [].concat(filterFormItemKey, ['name', 'names']))), {}, {
428
+ // @ts-ignore
429
+ _internalItemRender: internalItemRender,
430
+ className: _className,
431
+ children: _jsx(_Form.List, _objectSpread(_objectSpread({
432
+ name: _otherFormItemProps.name
433
+ }, omit(_otherFormItemProps, ['rules'])), {}, {
434
+ children: function children(fields, operation, meta) {
435
+ return _jsx(AutoComponent, _objectSpread(_objectSpread({}, omit(lastComponentProps, lastComponentPropsFilter)), {}, {
436
+ otherProps: otherProps,
437
+ fields: fields,
438
+ operation: operation,
439
+ meta: meta
440
+ }));
441
+ }
442
+ }))
438
443
  }));
439
444
  }
440
445
  // 默认占据一行
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var _react = _interopRequireDefault(require("react"));
12
12
  var _antd = require("antd");
@@ -27,13 +27,20 @@ var ActionButton = function ActionButton(_ref) {
27
27
  deletePoConfirmMsg = config.deletePoConfirmMsg,
28
28
  mulDeletePoConfirmMsg = config.mulDeletePoConfirmMsg,
29
29
  max = config.max,
30
- tableLength = config.tableLength;
30
+ name = config.name,
31
+ tableLength = config.tableLength,
32
+ selectedRows = config.selectedRows;
33
+ var rowNamePath = [].concat((0, _toConsumableArray2.default)(name), [index]);
31
34
  // 操作按钮权限控制
32
35
  var getShow = function getShow(show) {
33
36
  if (typeof show === 'function') {
34
37
  return show(record, {
35
38
  index: index,
36
- form: form
39
+ form: form,
40
+ name: name,
41
+ namePath: rowNamePath,
42
+ tableLength: tableLength,
43
+ selectedRows: selectedRows
37
44
  });
38
45
  }
39
46
  return show;
@@ -43,7 +50,11 @@ var ActionButton = function ActionButton(_ref) {
43
50
  if (typeof disabled === 'function') {
44
51
  return disabled(record, {
45
52
  index: index,
46
- form: form
53
+ form: form,
54
+ name: name,
55
+ namePath: rowNamePath,
56
+ tableLength: tableLength,
57
+ selectedRows: selectedRows
47
58
  });
48
59
  }
49
60
  // 新增超过最大行,禁止操作按钮
@@ -65,21 +76,29 @@ var ActionButton = function ActionButton(_ref) {
65
76
  // 其他操作按钮Props
66
77
  var actionBtnProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, btnConfig.buttonProps), {}, {
67
78
  onClick: function onClick() {
68
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
79
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
80
+ index: index,
81
+ form: form,
82
+ name: name,
83
+ namePath: rowNamePath,
84
+ tableLength: tableLength,
85
+ selectedRows: selectedRows
86
+ });
69
87
  },
70
88
  disabled: getDisabled((_btnConfig$buttonProp3 = btnConfig.buttonProps) === null || _btnConfig$buttonProp3 === void 0 ? void 0 : _btnConfig$buttonProp3.disabled)
71
89
  });
72
90
  // 当传入函数时,先转成reactNode
73
91
  if ((0, _lodash.isFunction)(btnConfig.label)) {
74
92
  var addIndex = tableLength ? tableLength - 1 : 0;
75
- var namePath = [].concat((0, _toConsumableArray2.default)(config.name), [addIndex]);
93
+ var namePath = [].concat((0, _toConsumableArray2.default)(name), [addIndex]);
76
94
  var addRecord = form.getFieldValue(namePath) || {};
77
95
  btnConfig.label = btnConfig.label(addRecord, {
78
96
  form: form,
79
97
  namePath: namePath,
80
- name: config.name,
81
- index: addIndex,
82
- tableLength: tableLength
98
+ name: name,
99
+ tableLength: tableLength,
100
+ selectedRows: selectedRows,
101
+ index: addIndex
83
102
  });
84
103
  }
85
104
  var isDisabled = !selectedRowKeys.length && btnConfig.type === 'mulDelete' || editingKeys.length || (delBtnProps === null || delBtnProps === void 0 ? void 0 : delBtnProps.disabled);
@@ -89,7 +108,14 @@ var ActionButton = function ActionButton(_ref) {
89
108
  placement: "topRight",
90
109
  title: deleteMsgMap[btnConfig.type],
91
110
  onConfirm: function onConfirm() {
92
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
111
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
112
+ index: index,
113
+ form: form,
114
+ name: name,
115
+ namePath: rowNamePath,
116
+ tableLength: tableLength,
117
+ selectedRows: selectedRows
118
+ });
93
119
  },
94
120
  disabled: isDisabled,
95
121
  okText: _locale.default.ProEditTable.confirm,
@@ -109,13 +135,27 @@ var ActionButton = function ActionButton(_ref) {
109
135
  index: index,
110
136
  disabled: isDisabled,
111
137
  onClick: function onClick() {
112
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
138
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
139
+ index: index,
140
+ form: form,
141
+ name: name,
142
+ namePath: rowNamePath,
143
+ tableLength: tableLength,
144
+ selectedRows: selectedRows
145
+ });
113
146
  }
114
147
  }))) : (0, _jsxRuntime.jsx)(_antd.Button, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(delBtnProps, ['buttonProps', 'isEditable', 'onEvent'])), {}, {
115
148
  disabled: isDisabled,
116
149
  type: "link",
117
150
  onClick: function onClick() {
118
- btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
151
+ btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, {
152
+ index: index,
153
+ form: form,
154
+ name: name,
155
+ namePath: rowNamePath,
156
+ tableLength: tableLength,
157
+ selectedRows: selectedRows
158
+ });
119
159
  },
120
160
  children: btnConfig.label
121
161
  }))
@@ -23,12 +23,9 @@ var RenderToolbar = function RenderToolbar(config) {
23
23
  toolbarProps = config.toolbarProps,
24
24
  name = config.name,
25
25
  virtualKey = config.virtualKey,
26
- form = config.form,
27
26
  disabled = config.disabled,
28
- selectedRows = config.selectedRows,
29
27
  tableLength = config.tableLength;
30
28
  var virtualName = (0, _tools.getNamePath)(name, virtualKey);
31
- var dataSource = form.getFieldValue(name);
32
29
  // toolbarProps配置为false 默认不插入
33
30
  if (toolbarProps === false || disabled) {
34
31
  return null;
@@ -82,28 +79,33 @@ var RenderToolbar = function RenderToolbar(config) {
82
79
  toolbar.show = show !== null && show !== void 0 ? show : true;
83
80
  toolbar.needConfirm = needConfirm !== null && needConfirm !== void 0 ? needConfirm : true;
84
81
  toolbar.onEvent = /*#__PURE__*/function () {
85
- var _ref = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(record, index) {
86
- var onEvent, result;
82
+ var _ref2 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(record, _ref) {
83
+ var index, form, name, namePath, tableLength, selectedRows, onEvent, result;
87
84
  return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
88
85
  while (1) switch (_context.prev = _context.next) {
89
86
  case 0:
87
+ index = _ref.index, form = _ref.form, name = _ref.name, namePath = _ref.namePath, tableLength = _ref.tableLength, selectedRows = _ref.selectedRows;
90
88
  onEvent = onClick || onHandle;
91
89
  if (onEvent) {
92
- _context.next = 5;
90
+ _context.next = 6;
93
91
  break;
94
92
  }
95
93
  result = true;
96
- _context.next = 8;
94
+ _context.next = 9;
97
95
  break;
98
- case 5:
99
- _context.next = 7;
100
- return onEvent === null || onEvent === void 0 ? void 0 : onEvent(selectedRows, dataSource, {
96
+ case 6:
97
+ _context.next = 8;
98
+ return onEvent === null || onEvent === void 0 ? void 0 : onEvent(record, {
99
+ index: index,
101
100
  form: form,
102
- namePath: virtualName
101
+ name: name,
102
+ namePath: namePath,
103
+ tableLength: tableLength,
104
+ selectedRows: selectedRows
103
105
  });
104
- case 7:
105
- result = _context.sent;
106
106
  case 8:
107
+ result = _context.sent;
108
+ case 9:
107
109
  if (result !== false && type !== 'custom') {
108
110
  _config.actions[type]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, config), {}, {
109
111
  index: index,
@@ -113,14 +115,14 @@ var RenderToolbar = function RenderToolbar(config) {
113
115
  virtualName: virtualName
114
116
  }));
115
117
  }
116
- case 9:
118
+ case 10:
117
119
  case "end":
118
120
  return _context.stop();
119
121
  }
120
122
  }, _callee);
121
123
  }));
122
124
  return function (_x, _x2) {
123
- return _ref.apply(this, arguments);
125
+ return _ref2.apply(this, arguments);
124
126
  };
125
127
  }();
126
128
  toolbar.buttonProps = buttonProps;
@@ -300,7 +300,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
300
300
  }, [value, config.name]);
301
301
  var _columns = (0, _react.useMemo)(function () {
302
302
  return (0, _utils.transformColumns)(columns, config);
303
- }, [valueChangeRef.current, disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath]);
303
+ }, [valueChangeRef.current, disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath, value === null || value === void 0 ? void 0 : value.length]);
304
304
  var initDataSource = function initDataSource() {
305
305
  var _value$every, _value$some;
306
306
  var isAllHasKey = value === null || value === void 0 ? void 0 : (_value$every = value.every) === null || _value$every === void 0 ? void 0 : _value$every.call(value, function (item) {
@@ -11,9 +11,12 @@ import { ProFormValueType, ColumnPropsMap } from '../ProForm/components/render/p
11
11
  import { DiffOriginalParams } from '../ProForm/utils/diffOriginal';
12
12
  export type ActionType = 'edit' | 'delete' | 'save' | 'cancel' | 'add' | 'mulDelete' | 'custom';
13
13
  export type ShowFunction<T> = (record?: T, options?: {
14
- index?: number;
15
- form?: FormInstance;
16
- namePath?: NamePath;
14
+ index: number;
15
+ form: FormInstance;
16
+ name: NamePath;
17
+ namePath: NamePath;
18
+ tableLength: number;
19
+ selectedRows: T[];
17
20
  }) => Promise<any> | boolean | void;
18
21
  export interface OptionsProps {
19
22
  index: number;
@@ -87,49 +87,54 @@ var getActionColumn = function getActionColumn(config) {
87
87
  action.show = show !== null && show !== void 0 ? show : true;
88
88
  action.needConfirm = needConfirm !== null && needConfirm !== void 0 ? needConfirm : true;
89
89
  action.onEvent = /*#__PURE__*/function () {
90
- var _ref = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(record, index) {
90
+ var _ref2 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(record, _ref) {
91
91
  var _form$getFieldValue;
92
- var rowName, _record, onEvent, result;
92
+ var index, form, name, namePath, tableLength, selectedRows, rowName, _record, onEvent, result;
93
93
  return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
94
94
  while (1) switch (_context.prev = _context.next) {
95
95
  case 0:
96
+ index = _ref.index, form = _ref.form, name = _ref.name, namePath = _ref.namePath, tableLength = _ref.tableLength, selectedRows = _ref.selectedRows;
96
97
  index = _utils.tools.calc(firstIndex, '+', index);
97
98
  rowName = [].concat((0, _toConsumableArray2.default)(virtualRowName), [index]);
98
99
  if (!(type === 'save')) {
99
- _context.next = 12;
100
+ _context.next = 13;
100
101
  break;
101
102
  }
102
- _context.prev = 3;
103
- _context.next = 6;
103
+ _context.prev = 4;
104
+ _context.next = 7;
104
105
  return (0, _tools.customValidate)(validateKeys, form, rowName);
105
- case 6:
106
- _context.next = 12;
106
+ case 7:
107
+ _context.next = 13;
107
108
  break;
108
- case 8:
109
- _context.prev = 8;
110
- _context.t0 = _context["catch"](3);
109
+ case 9:
110
+ _context.prev = 9;
111
+ _context.t0 = _context["catch"](4);
111
112
  (0, _tools.handleScrollToError)();
112
113
  return _context.abrupt("return", Promise.reject(_context.t0));
113
- case 12:
114
+ case 13:
114
115
  // 编辑状态使用自定义form值,非编辑状态直接使用行数据
115
116
  _record = (_form$getFieldValue = form.getFieldValue(rowName)) !== null && _form$getFieldValue !== void 0 ? _form$getFieldValue : record; // 新增事件可以设置初始默认值,当做函数的出参导出
116
117
  onEvent = onClick || onHandle;
117
118
  if (onEvent) {
118
- _context.next = 18;
119
+ _context.next = 19;
119
120
  break;
120
121
  }
121
122
  result = true;
122
- _context.next = 21;
123
+ _context.next = 22;
123
124
  break;
124
- case 18:
125
- _context.next = 20;
126
- return onEvent === null || onEvent === void 0 ? void 0 : onEvent(_record, index, {
125
+ case 19:
126
+ _context.next = 21;
127
+ return onEvent === null || onEvent === void 0 ? void 0 : onEvent(_record, {
127
128
  form: form,
128
- namePath: virtualRowName
129
+ index: index,
130
+ tableLength: tableLength,
131
+ name: name,
132
+ namePath: namePath,
133
+ selectedRows: selectedRows
129
134
  });
130
- case 20:
131
- result = _context.sent;
132
135
  case 21:
136
+ result = _context.sent;
137
+ case 22:
133
138
  if (result !== false && type !== 'custom') {
134
139
  _config.actions[type]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, config), {}, {
135
140
  rowName: [].concat((0, _toConsumableArray2.default)(name), [index]),
@@ -139,14 +144,14 @@ var getActionColumn = function getActionColumn(config) {
139
144
  validateKeys: validateKeys
140
145
  }));
141
146
  }
142
- case 22:
147
+ case 23:
143
148
  case "end":
144
149
  return _context.stop();
145
150
  }
146
- }, _callee, null, [[3, 8]]);
151
+ }, _callee, null, [[4, 9]]);
147
152
  }));
148
153
  return function (_x, _x2) {
149
- return _ref.apply(this, arguments);
154
+ return _ref2.apply(this, arguments);
150
155
  };
151
156
  }();
152
157
  action.buttonProps = buttonProps;
@@ -229,10 +234,10 @@ var transformColumns = exports.transformColumns = function transformColumns() {
229
234
  if (typeof columnTitle === 'string') {
230
235
  item.originTitle = columnTitle;
231
236
  if (tooltip) {
232
- var _ref2 = tooltip || {},
233
- tooltipTitle = _ref2.title,
234
- icon = _ref2.icon,
235
- resetProps = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
237
+ var _ref3 = tooltip || {},
238
+ tooltipTitle = _ref3.title,
239
+ icon = _ref3.icon,
240
+ resetProps = (0, _objectWithoutProperties2.default)(_ref3, _excluded2);
236
241
  item.title = (0, _jsxRuntime.jsxs)("span", {
237
242
  className: "pro-edit-table-title pro-edit-table-tooltip",
238
243
  children: [before, columnTitle, (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
@@ -392,13 +397,13 @@ var transformColumns = exports.transformColumns = function transformColumns() {
392
397
  // cacheMap 用来存储缓存值,若有值后不再请求
393
398
  if (JSON.stringify(cacheMap.current) === '{}') {
394
399
  Promise.all(Object.entries(_cacheMap).map(/*#__PURE__*/function () {
395
- var _ref3 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(item) {
396
- var _item, key, value, _ref4, service, option;
400
+ var _ref4 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(item) {
401
+ var _item, key, value, _ref5, service, option;
397
402
  return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
398
403
  while (1) switch (_context2.prev = _context2.next) {
399
404
  case 0:
400
405
  _item = (0, _slicedToArray2.default)(item, 2), key = _item[0], value = _item[1];
401
- _ref4 = (value === null || value === void 0 ? void 0 : value.useRequest) || {}, service = _ref4.service, option = _ref4.option;
406
+ _ref5 = (value === null || value === void 0 ? void 0 : value.useRequest) || {}, service = _ref5.service, option = _ref5.option;
402
407
  if (!service) {
403
408
  _context2.next = 8;
404
409
  break;
@@ -418,7 +423,7 @@ var transformColumns = exports.transformColumns = function transformColumns() {
418
423
  }, _callee2);
419
424
  }));
420
425
  return function (_x3) {
421
- return _ref3.apply(this, arguments);
426
+ return _ref4.apply(this, arguments);
422
427
  };
423
428
  }())).then(function (res) {
424
429
  res.forEach(function (item) {
@@ -424,17 +424,22 @@ var Render = function Render(props) {
424
424
  colProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, colProps), {}, {
425
425
  span: lessMode ? colProps.span : 24 // 默认占一行
426
426
  });
427
- return (0, _jsxRuntime.jsx)(_antd.Form.List, (0, _objectSpread2.default)((0, _objectSpread2.default)({
428
- name: _otherFormItemProps.name
429
- }, (0, _lodash.omit)(_otherFormItemProps, ['rules'])), {}, {
430
- children: function children(fields, operation, meta) {
431
- return (0, _jsxRuntime.jsx)(AutoComponent, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(lastComponentProps, lastComponentPropsFilter)), {}, {
432
- otherProps: otherProps,
433
- fields: fields,
434
- operation: operation,
435
- meta: meta
436
- }));
437
- }
427
+ return (0, _jsxRuntime.jsx)(_antd.Form.Item, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(_otherFormItemProps, [].concat(filterFormItemKey, ['name', 'names']))), {}, {
428
+ // @ts-ignore
429
+ _internalItemRender: internalItemRender,
430
+ className: _className,
431
+ children: (0, _jsxRuntime.jsx)(_antd.Form.List, (0, _objectSpread2.default)((0, _objectSpread2.default)({
432
+ name: _otherFormItemProps.name
433
+ }, (0, _lodash.omit)(_otherFormItemProps, ['rules'])), {}, {
434
+ children: function children(fields, operation, meta) {
435
+ return (0, _jsxRuntime.jsx)(AutoComponent, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(lastComponentProps, lastComponentPropsFilter)), {}, {
436
+ otherProps: otherProps,
437
+ fields: fields,
438
+ operation: operation,
439
+ meta: meta
440
+ }));
441
+ }
442
+ }))
438
443
  }));
439
444
  }
440
445
  // 默认占据一行
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.9.8-beta.9",
3
+ "version": "3.10.0-beta.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -9,6 +9,7 @@
9
9
  "analyze": "ANALYZE=1 dumi build",
10
10
  "build": "npm run build-lib && npm run build-es && npm run build-dist",
11
11
  "build-dist": "father-build",
12
+ "build-umd": "cross-env BUILD_TYPE=umd father-build",
12
13
  "build-es": "cross-env BUILD_TYPE=es father-build",
13
14
  "build-lib": "father-build && cross-env BUILD_TYPE=lib father-build",
14
15
  "docs": "dumi build",
@@ -1,5 +0,0 @@
1
- {
2
- "recommendations": [
3
- "kisstkondoros.vscode-codemetrics"
4
- ]
5
- }