@zat-design/sisyphus-react 3.6.4-beta.1 → 3.6.4-beta.11

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.
@@ -17,7 +17,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
17
17
  /* eslint-disable prefer-const */
18
18
  import React, { useCallback, useEffect } from 'react';
19
19
  import classNames from 'classnames';
20
- import { cloneDeep, isEqual, debounce, omit, isFunction } from 'lodash';
20
+ import { cloneDeep, isEqual, omit, isFunction } from 'lodash';
21
21
  import valueTypeMap from '../../../ProForm/utils/valueType';
22
22
  import transformMap from '../../utils/transform';
23
23
  import { getNamePath, difference, getDisabled } from '../../utils/tools';
@@ -296,101 +296,107 @@ var RenderField = function RenderField(_ref) {
296
296
  }, 100);
297
297
  };
298
298
  // 单元格更新数据时,加个防抖,防止更新频率过快,卡顿
299
- var _onChange = debounce( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
300
- var _len2,
301
- args,
302
- _key2,
303
- _args,
304
- rowPath,
305
- row,
306
- orgRow,
307
- _TargetComponent,
308
- _TargetComponent$prop,
309
- _TargetComponent$prop2,
310
- _TargetComponent2,
311
- _TargetComponent2$pro,
312
- _TargetComponent$prop3,
313
- _Object$keys,
314
- _Object$keys$map,
315
- diff,
316
- validateFieldKeys,
317
- _args2 = arguments;
318
- return _regeneratorRuntime().wrap(function _callee$(_context) {
319
- while (1) switch (_context.prev = _context.next) {
320
- case 0:
321
- for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
322
- args[_key2] = _args2[_key2];
323
- }
324
- _args = [].concat(args);
325
- rowPath = [].concat(_toConsumableArray(namePath), [index]);
326
- row = form.getFieldValue(rowPath, true); // if (type === 'InputNumber' && column.name) row[column.name] = args[0];
327
- orgRow = cloneDeep(row);
328
- if (!onFieldChange) {
329
- _context.next = 18;
330
- break;
331
- }
332
- _args = formatArgs(args);
333
- _args[1] = row;
334
- _context.t0 = (_TargetComponent = TargetComponent) === null || _TargetComponent === void 0 ? void 0 : (_TargetComponent$prop = _TargetComponent.props) === null || _TargetComponent$prop === void 0 ? void 0 : _TargetComponent$prop.onFieldChange;
335
- if (!_context.t0) {
299
+ var _onChange = /*#__PURE__*/function () {
300
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
301
+ var _len2,
302
+ args,
303
+ _key2,
304
+ _args,
305
+ rowPath,
306
+ row,
307
+ orgRow,
308
+ _TargetComponent,
309
+ _TargetComponent$prop,
310
+ _TargetComponent$prop2,
311
+ _TargetComponent2,
312
+ _TargetComponent2$pro,
313
+ _TargetComponent$prop3,
314
+ _Object$keys,
315
+ _Object$keys$map,
316
+ diff,
317
+ validateFieldKeys,
318
+ _args2 = arguments;
319
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
320
+ while (1) switch (_context.prev = _context.next) {
321
+ case 0:
322
+ for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
323
+ args[_key2] = _args2[_key2];
324
+ }
325
+ _args = [].concat(args);
326
+ rowPath = [].concat(_toConsumableArray(namePath), [index]);
327
+ row = form.getFieldValue(rowPath, true);
328
+ orgRow = cloneDeep(row);
329
+ if (!onFieldChange) {
330
+ _context.next = 18;
331
+ break;
332
+ }
333
+ _args = formatArgs(args);
334
+ _args[1] = row;
335
+ _context.t0 = (_TargetComponent = TargetComponent) === null || _TargetComponent === void 0 ? void 0 : (_TargetComponent$prop = _TargetComponent.props) === null || _TargetComponent$prop === void 0 ? void 0 : _TargetComponent$prop.onFieldChange;
336
+ if (!_context.t0) {
337
+ _context.next = 12;
338
+ break;
339
+ }
336
340
  _context.next = 12;
337
- break;
338
- }
339
- _context.next = 12;
340
- return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, _toConsumableArray(_args));
341
- case 12:
342
- _context.t1 = onFieldChange;
343
- if (!_context.t1) {
341
+ return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, _toConsumableArray(_args));
342
+ case 12:
343
+ _context.t1 = onFieldChange;
344
+ if (!_context.t1) {
345
+ _context.next = 16;
346
+ break;
347
+ }
344
348
  _context.next = 16;
345
- break;
346
- }
347
- _context.next = 16;
348
- return onFieldChange.apply(void 0, _toConsumableArray(_args));
349
- case 16:
350
- _context.next = 27;
351
- break;
352
- case 18:
353
- _args = _args.concat([row, index, form]);
354
- _context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
355
- if (!_context.t2) {
356
- _context.next = 23;
357
- break;
358
- }
359
- _context.next = 23;
360
- return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, _toConsumableArray(_args));
361
- case 23:
362
- _context.t3 = onChange;
363
- if (!_context.t3) {
349
+ return onFieldChange.apply(void 0, _toConsumableArray(_args));
350
+ case 16:
364
351
  _context.next = 27;
365
352
  break;
366
- }
367
- _context.next = 27;
368
- return onChange.apply(void 0, _toConsumableArray(_args));
369
- case 27:
370
- // 判断属性是否变动
371
- form.setFieldValue(rowPath, row);
372
- if (!isEqual(orgRow, row)) {
373
- diff = difference(row, orgRow) || {};
374
- validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
375
- return [].concat(_toConsumableArray(rowPath), [key]);
376
- });
377
- if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
378
- setTimeout(function () {
379
- form.validateFields(validateFieldKeys);
380
- }, 100);
353
+ case 18:
354
+ _args = _args.concat([row, index, form]);
355
+ _context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
356
+ if (!_context.t2) {
357
+ _context.next = 23;
358
+ break;
381
359
  }
382
- }
383
- setState({
384
- forceUpdate: {
385
- d: Date.now()
360
+ _context.next = 23;
361
+ return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, _toConsumableArray(_args));
362
+ case 23:
363
+ _context.t3 = onChange;
364
+ if (!_context.t3) {
365
+ _context.next = 27;
366
+ break;
386
367
  }
387
- });
388
- case 30:
389
- case "end":
390
- return _context.stop();
391
- }
392
- }, _callee);
393
- })), 300);
368
+ _context.next = 27;
369
+ return onChange.apply(void 0, _toConsumableArray(_args));
370
+ case 27:
371
+ // 判断属性是否变动
372
+ form.setFieldValue(rowPath, _objectSpread({}, row));
373
+ if (!isEqual(orgRow, row)) {
374
+ diff = difference(row, orgRow) || {};
375
+ validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
376
+ return [].concat(_toConsumableArray(rowPath), [key]);
377
+ });
378
+ if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
379
+ setTimeout(function () {
380
+ form.validateFields(validateFieldKeys);
381
+ }, 100);
382
+ }
383
+ }
384
+ // 单行编辑时需要 强制更新视图
385
+ setState({
386
+ forceUpdate: {
387
+ d: Date.now()
388
+ }
389
+ });
390
+ case 30:
391
+ case "end":
392
+ return _context.stop();
393
+ }
394
+ }, _callee);
395
+ }));
396
+ return function _onChange() {
397
+ return _ref2.apply(this, arguments);
398
+ };
399
+ }();
394
400
  var _onblur = /*#__PURE__*/function () {
395
401
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
396
402
  var _TargetComponent3, _TargetComponent3$pro, _TargetComponent$prop4;
@@ -434,7 +440,7 @@ var RenderField = function RenderField(_ref) {
434
440
  return onBlur.apply(void 0, _toConsumableArray(_args));
435
441
  case 14:
436
442
  // 判断属性是否变动
437
- form.setFieldValue(rowPath, row);
443
+ form.setFieldValue(rowPath, _objectSpread({}, row));
438
444
  if (!isEqual(orgRow, row)) {
439
445
  diff = difference(row, orgRow) || {};
440
446
  validateFieldKeys = (_Object$keys2 = Object.keys(diff)) === null || _Object$keys2 === void 0 ? void 0 : (_Object$keys2$map = _Object$keys2.map) === null || _Object$keys2$map === void 0 ? void 0 : _Object$keys2$map.call(_Object$keys2, function (key) {
@@ -25,7 +25,7 @@ export declare const onDelete: ({ name, form, virtualKey, selectedRowKeys }: {
25
25
  * @param params 当前列的参数
26
26
  * @param rowDisabled 行禁用参数
27
27
  */
28
- export declare const getDisabled: ({ globalControl, formDisabled, column, tabledDisabled, columnFieldProps, params, rowDisabled }: any) => any;
28
+ export declare const getDisabled: ({ globalControl, formDisabled, column, tabledDisabled, columnFieldProps, params, rowDisabled, }: any) => any;
29
29
  /** 表格自动滚动到报错位置
30
30
  */
31
31
  export declare const handleScrollToError: () => void;
@@ -86,6 +86,7 @@ export var onDelete = function onDelete(_ref) {
86
86
  * @param rowDisabled 行禁用参数
87
87
  */
88
88
  export var getDisabled = function getDisabled(_ref2) {
89
+ var _ref3, _column$disabled;
89
90
  var globalControl = _ref2.globalControl,
90
91
  formDisabled = _ref2.formDisabled,
91
92
  column = _ref2.column,
@@ -147,7 +148,7 @@ export var getDisabled = function getDisabled(_ref2) {
147
148
  if (isFunction(columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled)) {
148
149
  return convertToBoolean(columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled.apply(columnFieldProps, _toConsumableArray(params)));
149
150
  }
150
- return convertToBoolean(column === null || column === void 0 ? void 0 : column.disabled) || convertToBoolean(columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled) || convertToBoolean(tabledDisabled);
151
+ return convertToBoolean((_ref3 = (_column$disabled = column === null || column === void 0 ? void 0 : column.disabled) !== null && _column$disabled !== void 0 ? _column$disabled : columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled) !== null && _ref3 !== void 0 ? _ref3 : tabledDisabled);
151
152
  };
152
153
  /** 表格自动滚动到报错位置
153
154
  */
@@ -164,9 +165,9 @@ export var handleScrollToError = function handleScrollToError() {
164
165
  while (previousSibling) {
165
166
  if (previousSibling.nodeType === 1) {
166
167
  var _previousSibling, _previousSibling$clas, _previousSibling$clas2, _previousSibling$clas3;
167
- var _ref3 = previousSibling.getBoundingClientRect() || {},
168
- _ref3$width = _ref3.width,
169
- width = _ref3$width === void 0 ? 0 : _ref3$width;
168
+ var _ref4 = previousSibling.getBoundingClientRect() || {},
169
+ _ref4$width = _ref4.width,
170
+ width = _ref4$width === void 0 ? 0 : _ref4$width;
170
171
  childOffsetLeft += width;
171
172
  if ((_previousSibling = previousSibling) === null || _previousSibling === void 0 ? void 0 : (_previousSibling$clas = _previousSibling.classList) === null || _previousSibling$clas === void 0 ? void 0 : (_previousSibling$clas2 = (_previousSibling$clas3 = _previousSibling$clas).contains) === null || _previousSibling$clas2 === void 0 ? void 0 : _previousSibling$clas2.call(_previousSibling$clas3, 'ant-table-cell-fix-left')) {
172
173
  childFixedLeft += width;
@@ -35,6 +35,7 @@ var limitNumber = function limitNumber(num, _ref) {
35
35
  return num;
36
36
  };
37
37
  var InputNumber = function InputNumber(props) {
38
+ var _props$precision4;
38
39
  var placeholder = props.placeholder,
39
40
  className = props.className,
40
41
  otherProps = props.otherProps,
@@ -55,28 +56,33 @@ var InputNumber = function InputNumber(props) {
55
56
  var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
56
57
  var valueProps = {};
57
58
  var formatter = function formatter(value) {
59
+ var _props$precision;
58
60
  if (value === '') return '';
59
61
  var num = Number(value);
60
62
  if (Number.isNaN(num)) {
61
63
  return value;
62
64
  }
63
65
  var val = num.toLocaleString('en-US', {
64
- maximumFractionDigits: (props === null || props === void 0 ? void 0 : props.precision) || 2
66
+ maximumFractionDigits: (_props$precision = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision !== void 0 ? _props$precision : 2
65
67
  });
66
68
  if (!activateRef.current) {
69
+ var _props$precision2;
67
70
  var _val$split = val.split('.'),
68
71
  _val$split2 = _slicedToArray(_val$split, 2),
69
72
  int = _val$split2[0],
70
73
  _val$split2$ = _val$split2[1],
71
74
  float = _val$split2$ === void 0 ? '' : _val$split2$;
72
- return "".concat(int, ".").concat(float.padEnd((props === null || props === void 0 ? void 0 : props.precision) || 2, '0'));
75
+ if ((props === null || props === void 0 ? void 0 : props.precision) === 0) {
76
+ return int;
77
+ }
78
+ return "".concat(int, ".").concat(float.padEnd((_props$precision2 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision2 !== void 0 ? _props$precision2 : 2, '0'));
73
79
  }
74
80
  return val;
75
81
  };
76
82
  var _parser = function parser(value, precision) {
77
- var num = Number(value.replace(/[\s,]+/g, ''));
78
83
  if (value === '') return value;
79
- return Number.isNaN(num) || !precision ? value : num.toFixed(precision);
84
+ var num = Number(value.replace(/[\s,]+/g, ''));
85
+ return Number.isNaN(num) || !precision && precision !== 0 ? Number.isNaN(Number(value)) ? null : value : num.toFixed(precision);
80
86
  };
81
87
  if (valueType) {
82
88
  switch (valueType) {
@@ -88,8 +94,10 @@ var InputNumber = function InputNumber(props) {
88
94
  valueProps = {
89
95
  formatter: formatter,
90
96
  parser: function parser(val) {
91
- return _parser(val, (props === null || props === void 0 ? void 0 : props.precision) || 2);
92
- }
97
+ var _props$precision3;
98
+ return _parser(val, (_props$precision3 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision3 !== void 0 ? _props$precision3 : 2);
99
+ },
100
+ precision: (_props$precision4 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision4 !== void 0 ? _props$precision4 : 2
93
101
  };
94
102
  break;
95
103
  // 百分比
@@ -177,7 +185,7 @@ var InputNumber = function InputNumber(props) {
177
185
  var originValue = calc(Number(value), '/', 100);
178
186
  // 获取真实数据的小数位数
179
187
  var decimalDigits = getDecimalDigits(originValue);
180
- if (decimalDigits > (precision || 4)) {
188
+ if (decimalDigits > (precision !== null && precision !== void 0 ? precision : 4)) {
181
189
  return _jsx(Container, {
182
190
  viewEmpty: viewEmpty,
183
191
  children: value
@@ -195,7 +203,7 @@ var InputNumber = function InputNumber(props) {
195
203
  var _originValue = calc(Number(value), '/', 1000);
196
204
  // 获取真实数据的小数位数
197
205
  var _decimalDigits = getDecimalDigits(_originValue);
198
- if (_decimalDigits > (precision || 5)) {
206
+ if (_decimalDigits > (precision !== null && precision !== void 0 ? precision : 5)) {
199
207
  return _jsx(Container, {
200
208
  viewEmpty: viewEmpty,
201
209
  children: value
@@ -212,7 +220,7 @@ var InputNumber = function InputNumber(props) {
212
220
  case 'thousandth':
213
221
  return _jsx(Container, {
214
222
  viewEmpty: viewEmpty,
215
- children: tools.formatAmount(value, precision || 2)
223
+ children: tools.formatAmount(value, precision !== null && precision !== void 0 ? precision : 2)
216
224
  });
217
225
  // CNY千分位
218
226
  case 'thousandthCNY':
@@ -232,7 +240,7 @@ var InputNumber = function InputNumber(props) {
232
240
  }
233
241
  // 失去焦点时处理数字,
234
242
  var handleBlur = function handleBlur(e) {
235
- var _e$target, _e$target2;
243
+ var _e$target, _props$precision5, _valueProps3, _e$target2;
236
244
  activateRef.current = false;
237
245
  var value = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value;
238
246
  if (_max !== undefined && value > _max) {
@@ -241,7 +249,8 @@ var InputNumber = function InputNumber(props) {
241
249
  if (_min !== undefined && value < _min) {
242
250
  value = _min;
243
251
  }
244
- value = _parser(String(value), props.precision);
252
+ value = _parser(String(value), (_props$precision5 = props.precision) !== null && _props$precision5 !== void 0 ? _props$precision5 : (_valueProps3 = valueProps) === null || _valueProps3 === void 0 ? void 0 : _valueProps3.precision);
253
+ rest === null || rest === void 0 ? void 0 : rest.onChange(value);
245
254
  var limit = {
246
255
  min: Number(_min),
247
256
  max: Number(_max)
@@ -229,7 +229,7 @@ var ProForm = function ProForm(props, ref) {
229
229
  otherProps.layout = otherProps.layout || 'vertical';
230
230
  }
231
231
  }
232
- return _jsx(_Form, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
232
+ return _jsxs(_Form, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
233
233
  onKeyPress: function onKeyPress(event) {
234
234
  if (!submitOnEnter) return;
235
235
  if (event.key === 'Enter') {
@@ -247,7 +247,7 @@ var ProForm = function ProForm(props, ref) {
247
247
  block: 'center',
248
248
  behavior: 'smooth'
249
249
  },
250
- children: _jsxs(_Row, _objectSpread(_objectSpread({
250
+ children: [_jsxs(_Row, _objectSpread(_objectSpread({
251
251
  gutter: 24
252
252
  }, rowProps), {}, {
253
253
  children: [_jsx(RenderFields, {
@@ -266,8 +266,8 @@ var ProForm = function ProForm(props, ref) {
266
266
  required: required,
267
267
  originalDiffTip: originalDiffTip,
268
268
  globalControl: globalControl
269
- }), children, footerRender()]
270
- }))
269
+ }), footerRender()]
270
+ })), children]
271
271
  }));
272
272
  };
273
273
  // @ts-ignore
@@ -172,7 +172,9 @@ var useShouldUpdate = function useShouldUpdate(props) {
172
172
  clearTimeout(timerRef.current);
173
173
  }
174
174
  }
175
- if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !isEqualWith(rulesRef.current, _rules, customEqualForFun) || !isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) ||
175
+ var equalRes = isEqualWith(rulesRef.current, _rules, customEqualForFun);
176
+ var proEqualRes = isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun);
177
+ if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes ||
176
178
  // 值变更,需要同步更新函数式的fieldProps
177
179
  // (isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) && !isEqual(prevValues, currentValues)) ||
178
180
  // !isEqualWith(originComponentRef.current, _component, customEqualForFun) ||
@@ -299,101 +299,107 @@ var RenderField = function RenderField(_ref) {
299
299
  }, 100);
300
300
  };
301
301
  // 单元格更新数据时,加个防抖,防止更新频率过快,卡顿
302
- var _onChange = (0, _lodash.debounce)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
303
- var _len2,
304
- args,
305
- _key2,
306
- _args,
307
- rowPath,
308
- row,
309
- orgRow,
310
- _TargetComponent,
311
- _TargetComponent$prop,
312
- _TargetComponent$prop2,
313
- _TargetComponent2,
314
- _TargetComponent2$pro,
315
- _TargetComponent$prop3,
316
- _Object$keys,
317
- _Object$keys$map,
318
- diff,
319
- validateFieldKeys,
320
- _args2 = arguments;
321
- return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
322
- while (1) switch (_context.prev = _context.next) {
323
- case 0:
324
- for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
325
- args[_key2] = _args2[_key2];
326
- }
327
- _args = [].concat(args);
328
- rowPath = [].concat((0, _toConsumableArray2.default)(namePath), [index]);
329
- row = form.getFieldValue(rowPath, true); // if (type === 'InputNumber' && column.name) row[column.name] = args[0];
330
- orgRow = (0, _lodash.cloneDeep)(row);
331
- if (!onFieldChange) {
332
- _context.next = 18;
333
- break;
334
- }
335
- _args = formatArgs(args);
336
- _args[1] = row;
337
- _context.t0 = (_TargetComponent = TargetComponent) === null || _TargetComponent === void 0 ? void 0 : (_TargetComponent$prop = _TargetComponent.props) === null || _TargetComponent$prop === void 0 ? void 0 : _TargetComponent$prop.onFieldChange;
338
- if (!_context.t0) {
302
+ var _onChange = /*#__PURE__*/function () {
303
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
304
+ var _len2,
305
+ args,
306
+ _key2,
307
+ _args,
308
+ rowPath,
309
+ row,
310
+ orgRow,
311
+ _TargetComponent,
312
+ _TargetComponent$prop,
313
+ _TargetComponent$prop2,
314
+ _TargetComponent2,
315
+ _TargetComponent2$pro,
316
+ _TargetComponent$prop3,
317
+ _Object$keys,
318
+ _Object$keys$map,
319
+ diff,
320
+ validateFieldKeys,
321
+ _args2 = arguments;
322
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
323
+ while (1) switch (_context.prev = _context.next) {
324
+ case 0:
325
+ for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
326
+ args[_key2] = _args2[_key2];
327
+ }
328
+ _args = [].concat(args);
329
+ rowPath = [].concat((0, _toConsumableArray2.default)(namePath), [index]);
330
+ row = form.getFieldValue(rowPath, true);
331
+ orgRow = (0, _lodash.cloneDeep)(row);
332
+ if (!onFieldChange) {
333
+ _context.next = 18;
334
+ break;
335
+ }
336
+ _args = formatArgs(args);
337
+ _args[1] = row;
338
+ _context.t0 = (_TargetComponent = TargetComponent) === null || _TargetComponent === void 0 ? void 0 : (_TargetComponent$prop = _TargetComponent.props) === null || _TargetComponent$prop === void 0 ? void 0 : _TargetComponent$prop.onFieldChange;
339
+ if (!_context.t0) {
340
+ _context.next = 12;
341
+ break;
342
+ }
339
343
  _context.next = 12;
340
- break;
341
- }
342
- _context.next = 12;
343
- return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, (0, _toConsumableArray2.default)(_args));
344
- case 12:
345
- _context.t1 = onFieldChange;
346
- if (!_context.t1) {
344
+ return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, (0, _toConsumableArray2.default)(_args));
345
+ case 12:
346
+ _context.t1 = onFieldChange;
347
+ if (!_context.t1) {
348
+ _context.next = 16;
349
+ break;
350
+ }
347
351
  _context.next = 16;
348
- break;
349
- }
350
- _context.next = 16;
351
- return onFieldChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
352
- case 16:
353
- _context.next = 27;
354
- break;
355
- case 18:
356
- _args = _args.concat([row, index, form]);
357
- _context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
358
- if (!_context.t2) {
359
- _context.next = 23;
360
- break;
361
- }
362
- _context.next = 23;
363
- return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, (0, _toConsumableArray2.default)(_args));
364
- case 23:
365
- _context.t3 = onChange;
366
- if (!_context.t3) {
352
+ return onFieldChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
353
+ case 16:
367
354
  _context.next = 27;
368
355
  break;
369
- }
370
- _context.next = 27;
371
- return onChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
372
- case 27:
373
- // 判断属性是否变动
374
- form.setFieldValue(rowPath, row);
375
- if (!(0, _lodash.isEqual)(orgRow, row)) {
376
- diff = (0, _tools.difference)(row, orgRow) || {};
377
- validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
378
- return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
379
- });
380
- if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
381
- setTimeout(function () {
382
- form.validateFields(validateFieldKeys);
383
- }, 100);
356
+ case 18:
357
+ _args = _args.concat([row, index, form]);
358
+ _context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
359
+ if (!_context.t2) {
360
+ _context.next = 23;
361
+ break;
384
362
  }
385
- }
386
- setState({
387
- forceUpdate: {
388
- d: Date.now()
363
+ _context.next = 23;
364
+ return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, (0, _toConsumableArray2.default)(_args));
365
+ case 23:
366
+ _context.t3 = onChange;
367
+ if (!_context.t3) {
368
+ _context.next = 27;
369
+ break;
389
370
  }
390
- });
391
- case 30:
392
- case "end":
393
- return _context.stop();
394
- }
395
- }, _callee);
396
- })), 300);
371
+ _context.next = 27;
372
+ return onChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
373
+ case 27:
374
+ // 判断属性是否变动
375
+ form.setFieldValue(rowPath, (0, _objectSpread2.default)({}, row));
376
+ if (!(0, _lodash.isEqual)(orgRow, row)) {
377
+ diff = (0, _tools.difference)(row, orgRow) || {};
378
+ validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
379
+ return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
380
+ });
381
+ if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
382
+ setTimeout(function () {
383
+ form.validateFields(validateFieldKeys);
384
+ }, 100);
385
+ }
386
+ }
387
+ // 单行编辑时需要 强制更新视图
388
+ setState({
389
+ forceUpdate: {
390
+ d: Date.now()
391
+ }
392
+ });
393
+ case 30:
394
+ case "end":
395
+ return _context.stop();
396
+ }
397
+ }, _callee);
398
+ }));
399
+ return function _onChange() {
400
+ return _ref2.apply(this, arguments);
401
+ };
402
+ }();
397
403
  var _onblur = /*#__PURE__*/function () {
398
404
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
399
405
  var _TargetComponent3, _TargetComponent3$pro, _TargetComponent$prop4;
@@ -437,7 +443,7 @@ var RenderField = function RenderField(_ref) {
437
443
  return onBlur.apply(void 0, (0, _toConsumableArray2.default)(_args));
438
444
  case 14:
439
445
  // 判断属性是否变动
440
- form.setFieldValue(rowPath, row);
446
+ form.setFieldValue(rowPath, (0, _objectSpread2.default)({}, row));
441
447
  if (!(0, _lodash.isEqual)(orgRow, row)) {
442
448
  diff = (0, _tools.difference)(row, orgRow) || {};
443
449
  validateFieldKeys = (_Object$keys2 = Object.keys(diff)) === null || _Object$keys2 === void 0 ? void 0 : (_Object$keys2$map = _Object$keys2.map) === null || _Object$keys2$map === void 0 ? void 0 : _Object$keys2$map.call(_Object$keys2, function (key) {
@@ -25,7 +25,7 @@ export declare const onDelete: ({ name, form, virtualKey, selectedRowKeys }: {
25
25
  * @param params 当前列的参数
26
26
  * @param rowDisabled 行禁用参数
27
27
  */
28
- export declare const getDisabled: ({ globalControl, formDisabled, column, tabledDisabled, columnFieldProps, params, rowDisabled }: any) => any;
28
+ export declare const getDisabled: ({ globalControl, formDisabled, column, tabledDisabled, columnFieldProps, params, rowDisabled, }: any) => any;
29
29
  /** 表格自动滚动到报错位置
30
30
  */
31
31
  export declare const handleScrollToError: () => void;
@@ -93,6 +93,7 @@ var onDelete = exports.onDelete = function onDelete(_ref) {
93
93
  * @param rowDisabled 行禁用参数
94
94
  */
95
95
  var getDisabled = exports.getDisabled = function getDisabled(_ref2) {
96
+ var _ref3, _column$disabled;
96
97
  var globalControl = _ref2.globalControl,
97
98
  formDisabled = _ref2.formDisabled,
98
99
  column = _ref2.column,
@@ -154,7 +155,7 @@ var getDisabled = exports.getDisabled = function getDisabled(_ref2) {
154
155
  if ((0, _lodash.isFunction)(columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled)) {
155
156
  return convertToBoolean(columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled.apply(columnFieldProps, (0, _toConsumableArray2.default)(params)));
156
157
  }
157
- return convertToBoolean(column === null || column === void 0 ? void 0 : column.disabled) || convertToBoolean(columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled) || convertToBoolean(tabledDisabled);
158
+ return convertToBoolean((_ref3 = (_column$disabled = column === null || column === void 0 ? void 0 : column.disabled) !== null && _column$disabled !== void 0 ? _column$disabled : columnFieldProps === null || columnFieldProps === void 0 ? void 0 : columnFieldProps.disabled) !== null && _ref3 !== void 0 ? _ref3 : tabledDisabled);
158
159
  };
159
160
  /** 表格自动滚动到报错位置
160
161
  */
@@ -171,9 +172,9 @@ var handleScrollToError = exports.handleScrollToError = function handleScrollToE
171
172
  while (previousSibling) {
172
173
  if (previousSibling.nodeType === 1) {
173
174
  var _previousSibling, _previousSibling$clas, _previousSibling$clas2, _previousSibling$clas3;
174
- var _ref3 = previousSibling.getBoundingClientRect() || {},
175
- _ref3$width = _ref3.width,
176
- width = _ref3$width === void 0 ? 0 : _ref3$width;
175
+ var _ref4 = previousSibling.getBoundingClientRect() || {},
176
+ _ref4$width = _ref4.width,
177
+ width = _ref4$width === void 0 ? 0 : _ref4$width;
177
178
  childOffsetLeft += width;
178
179
  if ((_previousSibling = previousSibling) === null || _previousSibling === void 0 ? void 0 : (_previousSibling$clas = _previousSibling.classList) === null || _previousSibling$clas === void 0 ? void 0 : (_previousSibling$clas2 = (_previousSibling$clas3 = _previousSibling$clas).contains) === null || _previousSibling$clas2 === void 0 ? void 0 : _previousSibling$clas2.call(_previousSibling$clas3, 'ant-table-cell-fix-left')) {
179
180
  childFixedLeft += width;
@@ -39,6 +39,7 @@ var limitNumber = function limitNumber(num, _ref) {
39
39
  return num;
40
40
  };
41
41
  var InputNumber = function InputNumber(props) {
42
+ var _props$precision4;
42
43
  var placeholder = props.placeholder,
43
44
  className = props.className,
44
45
  otherProps = props.otherProps,
@@ -59,28 +60,33 @@ var InputNumber = function InputNumber(props) {
59
60
  var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
60
61
  var valueProps = {};
61
62
  var formatter = function formatter(value) {
63
+ var _props$precision;
62
64
  if (value === '') return '';
63
65
  var num = Number(value);
64
66
  if (Number.isNaN(num)) {
65
67
  return value;
66
68
  }
67
69
  var val = num.toLocaleString('en-US', {
68
- maximumFractionDigits: (props === null || props === void 0 ? void 0 : props.precision) || 2
70
+ maximumFractionDigits: (_props$precision = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision !== void 0 ? _props$precision : 2
69
71
  });
70
72
  if (!activateRef.current) {
73
+ var _props$precision2;
71
74
  var _val$split = val.split('.'),
72
75
  _val$split2 = (0, _slicedToArray2.default)(_val$split, 2),
73
76
  int = _val$split2[0],
74
77
  _val$split2$ = _val$split2[1],
75
78
  float = _val$split2$ === void 0 ? '' : _val$split2$;
76
- return "".concat(int, ".").concat(float.padEnd((props === null || props === void 0 ? void 0 : props.precision) || 2, '0'));
79
+ if ((props === null || props === void 0 ? void 0 : props.precision) === 0) {
80
+ return int;
81
+ }
82
+ return "".concat(int, ".").concat(float.padEnd((_props$precision2 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision2 !== void 0 ? _props$precision2 : 2, '0'));
77
83
  }
78
84
  return val;
79
85
  };
80
86
  var _parser = function parser(value, precision) {
81
- var num = Number(value.replace(/[\s,]+/g, ''));
82
87
  if (value === '') return value;
83
- return Number.isNaN(num) || !precision ? value : num.toFixed(precision);
88
+ var num = Number(value.replace(/[\s,]+/g, ''));
89
+ return Number.isNaN(num) || !precision && precision !== 0 ? Number.isNaN(Number(value)) ? null : value : num.toFixed(precision);
84
90
  };
85
91
  if (valueType) {
86
92
  switch (valueType) {
@@ -92,8 +98,10 @@ var InputNumber = function InputNumber(props) {
92
98
  valueProps = {
93
99
  formatter: formatter,
94
100
  parser: function parser(val) {
95
- return _parser(val, (props === null || props === void 0 ? void 0 : props.precision) || 2);
96
- }
101
+ var _props$precision3;
102
+ return _parser(val, (_props$precision3 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision3 !== void 0 ? _props$precision3 : 2);
103
+ },
104
+ precision: (_props$precision4 = props === null || props === void 0 ? void 0 : props.precision) !== null && _props$precision4 !== void 0 ? _props$precision4 : 2
97
105
  };
98
106
  break;
99
107
  // 百分比
@@ -181,7 +189,7 @@ var InputNumber = function InputNumber(props) {
181
189
  var originValue = calc(Number(value), '/', 100);
182
190
  // 获取真实数据的小数位数
183
191
  var decimalDigits = (0, _index.getDecimalDigits)(originValue);
184
- if (decimalDigits > (precision || 4)) {
192
+ if (decimalDigits > (precision !== null && precision !== void 0 ? precision : 4)) {
185
193
  return (0, _jsxRuntime.jsx)(_Container.default, {
186
194
  viewEmpty: viewEmpty,
187
195
  children: value
@@ -199,7 +207,7 @@ var InputNumber = function InputNumber(props) {
199
207
  var _originValue = calc(Number(value), '/', 1000);
200
208
  // 获取真实数据的小数位数
201
209
  var _decimalDigits = (0, _index.getDecimalDigits)(_originValue);
202
- if (_decimalDigits > (precision || 5)) {
210
+ if (_decimalDigits > (precision !== null && precision !== void 0 ? precision : 5)) {
203
211
  return (0, _jsxRuntime.jsx)(_Container.default, {
204
212
  viewEmpty: viewEmpty,
205
213
  children: value
@@ -216,7 +224,7 @@ var InputNumber = function InputNumber(props) {
216
224
  case 'thousandth':
217
225
  return (0, _jsxRuntime.jsx)(_Container.default, {
218
226
  viewEmpty: viewEmpty,
219
- children: _utils.tools.formatAmount(value, precision || 2)
227
+ children: _utils.tools.formatAmount(value, precision !== null && precision !== void 0 ? precision : 2)
220
228
  });
221
229
  // CNY千分位
222
230
  case 'thousandthCNY':
@@ -236,7 +244,7 @@ var InputNumber = function InputNumber(props) {
236
244
  }
237
245
  // 失去焦点时处理数字,
238
246
  var handleBlur = function handleBlur(e) {
239
- var _e$target, _e$target2;
247
+ var _e$target, _props$precision5, _valueProps3, _e$target2;
240
248
  activateRef.current = false;
241
249
  var value = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value;
242
250
  if (_max !== undefined && value > _max) {
@@ -245,7 +253,8 @@ var InputNumber = function InputNumber(props) {
245
253
  if (_min !== undefined && value < _min) {
246
254
  value = _min;
247
255
  }
248
- value = _parser(String(value), props.precision);
256
+ value = _parser(String(value), (_props$precision5 = props.precision) !== null && _props$precision5 !== void 0 ? _props$precision5 : (_valueProps3 = valueProps) === null || _valueProps3 === void 0 ? void 0 : _valueProps3.precision);
257
+ rest === null || rest === void 0 ? void 0 : rest.onChange(value);
249
258
  var limit = {
250
259
  min: Number(_min),
251
260
  max: Number(_max)
@@ -230,7 +230,7 @@ var ProForm = function ProForm(props, ref) {
230
230
  otherProps.layout = otherProps.layout || 'vertical';
231
231
  }
232
232
  }
233
- return (0, _jsxRuntime.jsx)(_antd.Form, (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({
233
+ return (0, _jsxRuntime.jsxs)(_antd.Form, (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({
234
234
  onKeyPress: function onKeyPress(event) {
235
235
  if (!submitOnEnter) return;
236
236
  if (event.key === 'Enter') {
@@ -248,7 +248,7 @@ var ProForm = function ProForm(props, ref) {
248
248
  block: 'center',
249
249
  behavior: 'smooth'
250
250
  },
251
- children: (0, _jsxRuntime.jsxs)(_antd.Row, (0, _objectSpread2.default)((0, _objectSpread2.default)({
251
+ children: [(0, _jsxRuntime.jsxs)(_antd.Row, (0, _objectSpread2.default)((0, _objectSpread2.default)({
252
252
  gutter: 24
253
253
  }, rowProps), {}, {
254
254
  children: [(0, _jsxRuntime.jsx)(_RenderFields.default, {
@@ -267,8 +267,8 @@ var ProForm = function ProForm(props, ref) {
267
267
  required: required,
268
268
  originalDiffTip: originalDiffTip,
269
269
  globalControl: globalControl
270
- }), children, footerRender()]
271
- }))
270
+ }), footerRender()]
271
+ })), children]
272
272
  }));
273
273
  };
274
274
  // @ts-ignore
@@ -179,7 +179,9 @@ var useShouldUpdate = function useShouldUpdate(props) {
179
179
  clearTimeout(timerRef.current);
180
180
  }
181
181
  }
182
- if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !(0, _lodash.isEqualWith)(rulesRef.current, _rules, _index.customEqualForFun) || !(0, _lodash.isEqualWith)(fieldPropsRef.current, _fieldProps, _index.customEqualForFun) ||
182
+ var equalRes = (0, _lodash.isEqualWith)(rulesRef.current, _rules, _index.customEqualForFun);
183
+ var proEqualRes = (0, _lodash.isEqualWith)(fieldPropsRef.current, _fieldProps, _index.customEqualForFun);
184
+ if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes ||
183
185
  // 值变更,需要同步更新函数式的fieldProps
184
186
  // (isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) && !isEqual(prevValues, currentValues)) ||
185
187
  // !isEqualWith(originComponentRef.current, _component, customEqualForFun) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.6.4-beta.1",
3
+ "version": "3.6.4-beta.11",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",