@zat-design/sisyphus-react 3.6.4 → 3.6.5-beta.2

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.
@@ -318,6 +318,12 @@ var RenderField = function RenderField(_ref) {
318
318
  return _regeneratorRuntime().wrap(function _callee$(_context) {
319
319
  while (1) switch (_context.prev = _context.next) {
320
320
  case 0:
321
+ if (!(!onFieldChange && !onChange)) {
322
+ _context.next = 2;
323
+ break;
324
+ }
325
+ return _context.abrupt("return", null);
326
+ case 2:
321
327
  for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
322
328
  args[_key2] = _args2[_key2];
323
329
  }
@@ -326,47 +332,47 @@ var RenderField = function RenderField(_ref) {
326
332
  row = form.getFieldValue(rowPath, true); // if (type === 'InputNumber' && column.name) row[column.name] = args[0];
327
333
  orgRow = cloneDeep(row);
328
334
  if (!onFieldChange) {
329
- _context.next = 18;
335
+ _context.next = 20;
330
336
  break;
331
337
  }
332
338
  _args = formatArgs(args);
333
339
  _args[1] = row;
334
340
  _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
341
  if (!_context.t0) {
336
- _context.next = 12;
342
+ _context.next = 14;
337
343
  break;
338
344
  }
339
- _context.next = 12;
345
+ _context.next = 14;
340
346
  return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, _toConsumableArray(_args));
341
- case 12:
347
+ case 14:
342
348
  _context.t1 = onFieldChange;
343
349
  if (!_context.t1) {
344
- _context.next = 16;
350
+ _context.next = 18;
345
351
  break;
346
352
  }
347
- _context.next = 16;
353
+ _context.next = 18;
348
354
  return onFieldChange.apply(void 0, _toConsumableArray(_args));
349
- case 16:
350
- _context.next = 27;
351
- break;
352
355
  case 18:
356
+ _context.next = 29;
357
+ break;
358
+ case 20:
353
359
  _args = _args.concat([row, index, form]);
354
360
  _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
361
  if (!_context.t2) {
356
- _context.next = 23;
362
+ _context.next = 25;
357
363
  break;
358
364
  }
359
- _context.next = 23;
365
+ _context.next = 25;
360
366
  return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, _toConsumableArray(_args));
361
- case 23:
367
+ case 25:
362
368
  _context.t3 = onChange;
363
369
  if (!_context.t3) {
364
- _context.next = 27;
370
+ _context.next = 29;
365
371
  break;
366
372
  }
367
- _context.next = 27;
373
+ _context.next = 29;
368
374
  return onChange.apply(void 0, _toConsumableArray(_args));
369
- case 27:
375
+ case 29:
370
376
  // 判断属性是否变动
371
377
  form.setFieldValue(rowPath, row);
372
378
  if (!isEqual(orgRow, row)) {
@@ -385,7 +391,7 @@ var RenderField = function RenderField(_ref) {
385
391
  d: Date.now()
386
392
  }
387
393
  });
388
- case 30:
394
+ case 32:
389
395
  case "end":
390
396
  return _context.stop();
391
397
  }
@@ -409,6 +415,12 @@ var RenderField = function RenderField(_ref) {
409
415
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
410
416
  while (1) switch (_context2.prev = _context2.next) {
411
417
  case 0:
418
+ if (onBlur) {
419
+ _context2.next = 2;
420
+ break;
421
+ }
422
+ return _context2.abrupt("return", null);
423
+ case 2:
412
424
  for (_len3 = _args3.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
413
425
  args[_key3] = _args3[_key3];
414
426
  }
@@ -419,20 +431,20 @@ var RenderField = function RenderField(_ref) {
419
431
  _args[1] = row;
420
432
  _context2.t0 = (_TargetComponent3 = TargetComponent) === null || _TargetComponent3 === void 0 ? void 0 : (_TargetComponent3$pro = _TargetComponent3.props) === null || _TargetComponent3$pro === void 0 ? void 0 : _TargetComponent3$pro.onBlur;
421
433
  if (!_context2.t0) {
422
- _context2.next = 10;
434
+ _context2.next = 12;
423
435
  break;
424
436
  }
425
- _context2.next = 10;
437
+ _context2.next = 12;
426
438
  return (_TargetComponent$prop4 = TargetComponent.props).onBlur.apply(_TargetComponent$prop4, _toConsumableArray(_args));
427
- case 10:
439
+ case 12:
428
440
  _context2.t1 = onBlur;
429
441
  if (!_context2.t1) {
430
- _context2.next = 14;
442
+ _context2.next = 16;
431
443
  break;
432
444
  }
433
- _context2.next = 14;
445
+ _context2.next = 16;
434
446
  return onBlur.apply(void 0, _toConsumableArray(_args));
435
- case 14:
447
+ case 16:
436
448
  // 判断属性是否变动
437
449
  form.setFieldValue(rowPath, row);
438
450
  if (!isEqual(orgRow, row)) {
@@ -445,23 +457,23 @@ var RenderField = function RenderField(_ref) {
445
457
  }
446
458
  }
447
459
  if (!isCell) {
448
- _context2.next = 20;
460
+ _context2.next = 22;
449
461
  break;
450
462
  }
451
- _context2.next = 19;
463
+ _context2.next = 21;
452
464
  return form.validateFields([cellName]);
453
- case 19:
465
+ case 21:
454
466
  setState({
455
467
  cellNamePath: []
456
468
  });
457
- case 20:
469
+ case 22:
458
470
  // 单行编辑时需要 强制更新视图
459
471
  setState({
460
472
  forceUpdate: {
461
473
  d: Date.now()
462
474
  }
463
475
  });
464
- case 21:
476
+ case 23:
465
477
  case "end":
466
478
  return _context2.stop();
467
479
  }
@@ -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;
@@ -34,7 +34,7 @@ var FormFooter = function FormFooter(props) {
34
34
  form.setFieldsValue(cache[formId]);
35
35
  }
36
36
  return cache;
37
- }, []);
37
+ }, [formId]);
38
38
  var _onOk = function _onOk() {
39
39
  if (formId) {
40
40
  var values = form.getFieldsValue();
@@ -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)
@@ -5,7 +5,6 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  import { forwardRef, useCallback, useImperativeHandle } from 'react';
7
7
  import { DndContext } from '@dnd-kit/core';
8
- import { cloneDeep, isFunction } from 'lodash';
9
8
  import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
10
9
  import { toArray } from '../../../utils';
11
10
  import { namesPathTransform } from './utils';
@@ -56,10 +55,6 @@ var FormList = function FormList(props, ref) {
56
55
  listName: [].concat(_toConsumableArray(namePath), [item.name]),
57
56
  label: mode === 'less' ? undefined : item.label
58
57
  });
59
- // 可编辑表格的columns需要消除引用关系,防止串数据
60
- if (column.type === 'ProEditTable' && !isFunction(column.fieldProps)) {
61
- column.fieldProps.columns = cloneDeep(column.fieldProps.columns);
62
- }
63
58
  return column;
64
59
  });
65
60
  }, [columns]);
@@ -160,7 +160,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
160
160
  var defaultOptionRender = function defaultOptionRender(rowData) {
161
161
  return rowData === null || rowData === void 0 ? void 0 : rowData[labelKey];
162
162
  };
163
- var handleFormat = optionRender || onFormat || defaultOptionRender;
163
+ var handleFormat = onFormat || defaultOptionRender;
164
164
  if (showCodeName) {
165
165
  handleFormat = function handleFormat(_ref5) {
166
166
  var value = _ref5.value,
@@ -681,6 +681,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
681
681
  showCodeName: showCodeName,
682
682
  labelInValue: labelInValue,
683
683
  dataSource: options,
684
+ optionRender: optionRender,
684
685
  scrollFollowParent: false,
685
686
  mode: isMultiple ? 'multiple' : undefined,
686
687
  onFocus: function onFocus() {
@@ -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
@@ -22,6 +22,7 @@ var useShouldUpdate = function useShouldUpdate(props) {
22
22
  names = formItemProps.names,
23
23
  dependencies = formItemProps.dependencies;
24
24
  var timerRef = useRef();
25
+ var needClear = useRef(); // 是否需要执行清值操作
25
26
  var showRef = useRef();
26
27
  var disabledRef = useRef();
27
28
  var requiredRef = useRef();
@@ -158,21 +159,30 @@ var useShouldUpdate = function useShouldUpdate(props) {
158
159
  }) : fieldProps;
159
160
  // 清值防抖 多次刷新时以最后一次为准
160
161
  if (clearNotShow !== false && (name || names)) {
162
+ // 当show为其他变为false的时候记录一次需要清值
163
+ if (_show !== showRef.current && _show === false) {
164
+ needClear.current = true;
165
+ }
161
166
  if (_show === false) {
162
167
  clearTimeout(timerRef.current);
163
168
  timerRef.current = setTimeout(function () {
169
+ if (needClear.current !== true) return;
164
170
  if (Array.isArray(names)) {
165
171
  form.resetFields(names);
166
172
  } else {
167
173
  var clearName = formItemProps.namePath ? formItemProps.namePath.slice(0, -1).concat(formItemProps.name) : formItemProps.name;
168
174
  form.resetFields([clearName]);
169
175
  }
170
- }, 200);
176
+ needClear.current = false;
177
+ }, 300);
171
178
  } else {
179
+ needClear.current = false;
172
180
  clearTimeout(timerRef.current);
173
181
  }
174
182
  }
175
- if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !isEqualWith(rulesRef.current, _rules, customEqualForFun) || !isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) ||
183
+ var equalRes = isEqualWith(rulesRef.current, _rules, customEqualForFun);
184
+ var proEqualRes = isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun);
185
+ if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes ||
176
186
  // 值变更,需要同步更新函数式的fieldProps
177
187
  // (isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) && !isEqual(prevValues, currentValues)) ||
178
188
  // !isEqualWith(originComponentRef.current, _component, customEqualForFun) ||
@@ -14,7 +14,7 @@ var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stri
14
14
  _excluded2 = ["resizeColumn", "columnConfig", "cacheTime", "storage"];
15
15
  import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
16
16
  import { useEffect, useMemo, useState, createContext } from 'react';
17
- import { cloneDeep, get, keyBy, assign } from 'lodash';
17
+ import { get, keyBy, assign } from 'lodash';
18
18
  import { useDebounceEffect, useDeepCompareEffect, useSetState } from 'ahooks';
19
19
  import { ReactSVG } from 'react-svg';
20
20
  import classnames from 'classnames';
@@ -135,9 +135,9 @@ function ProTable(props) {
135
135
  });
136
136
  });
137
137
  localColumns = ((_localColumns = localColumns) === null || _localColumns === void 0 ? void 0 : _localColumns.length) === 0 ? undefined : localColumns;
138
- setCurColumns(cloneDeep(localColumns || propsColumns));
138
+ setCurColumns(localColumns || propsColumns);
139
139
  } else {
140
- setCurColumns(cloneDeep(propsColumns));
140
+ setCurColumns(propsColumns);
141
141
  }
142
142
  }, [pathKey, cacheTime, propsColumns]);
143
143
  useEffect(function () {
@@ -321,6 +321,12 @@ var RenderField = function RenderField(_ref) {
321
321
  return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
322
322
  while (1) switch (_context.prev = _context.next) {
323
323
  case 0:
324
+ if (!(!onFieldChange && !onChange)) {
325
+ _context.next = 2;
326
+ break;
327
+ }
328
+ return _context.abrupt("return", null);
329
+ case 2:
324
330
  for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
325
331
  args[_key2] = _args2[_key2];
326
332
  }
@@ -329,47 +335,47 @@ var RenderField = function RenderField(_ref) {
329
335
  row = form.getFieldValue(rowPath, true); // if (type === 'InputNumber' && column.name) row[column.name] = args[0];
330
336
  orgRow = (0, _lodash.cloneDeep)(row);
331
337
  if (!onFieldChange) {
332
- _context.next = 18;
338
+ _context.next = 20;
333
339
  break;
334
340
  }
335
341
  _args = formatArgs(args);
336
342
  _args[1] = row;
337
343
  _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
344
  if (!_context.t0) {
339
- _context.next = 12;
345
+ _context.next = 14;
340
346
  break;
341
347
  }
342
- _context.next = 12;
348
+ _context.next = 14;
343
349
  return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, (0, _toConsumableArray2.default)(_args));
344
- case 12:
350
+ case 14:
345
351
  _context.t1 = onFieldChange;
346
352
  if (!_context.t1) {
347
- _context.next = 16;
353
+ _context.next = 18;
348
354
  break;
349
355
  }
350
- _context.next = 16;
356
+ _context.next = 18;
351
357
  return onFieldChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
352
- case 16:
353
- _context.next = 27;
354
- break;
355
358
  case 18:
359
+ _context.next = 29;
360
+ break;
361
+ case 20:
356
362
  _args = _args.concat([row, index, form]);
357
363
  _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
364
  if (!_context.t2) {
359
- _context.next = 23;
365
+ _context.next = 25;
360
366
  break;
361
367
  }
362
- _context.next = 23;
368
+ _context.next = 25;
363
369
  return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, (0, _toConsumableArray2.default)(_args));
364
- case 23:
370
+ case 25:
365
371
  _context.t3 = onChange;
366
372
  if (!_context.t3) {
367
- _context.next = 27;
373
+ _context.next = 29;
368
374
  break;
369
375
  }
370
- _context.next = 27;
376
+ _context.next = 29;
371
377
  return onChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
372
- case 27:
378
+ case 29:
373
379
  // 判断属性是否变动
374
380
  form.setFieldValue(rowPath, row);
375
381
  if (!(0, _lodash.isEqual)(orgRow, row)) {
@@ -388,7 +394,7 @@ var RenderField = function RenderField(_ref) {
388
394
  d: Date.now()
389
395
  }
390
396
  });
391
- case 30:
397
+ case 32:
392
398
  case "end":
393
399
  return _context.stop();
394
400
  }
@@ -412,6 +418,12 @@ var RenderField = function RenderField(_ref) {
412
418
  return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
413
419
  while (1) switch (_context2.prev = _context2.next) {
414
420
  case 0:
421
+ if (onBlur) {
422
+ _context2.next = 2;
423
+ break;
424
+ }
425
+ return _context2.abrupt("return", null);
426
+ case 2:
415
427
  for (_len3 = _args3.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
416
428
  args[_key3] = _args3[_key3];
417
429
  }
@@ -422,20 +434,20 @@ var RenderField = function RenderField(_ref) {
422
434
  _args[1] = row;
423
435
  _context2.t0 = (_TargetComponent3 = TargetComponent) === null || _TargetComponent3 === void 0 ? void 0 : (_TargetComponent3$pro = _TargetComponent3.props) === null || _TargetComponent3$pro === void 0 ? void 0 : _TargetComponent3$pro.onBlur;
424
436
  if (!_context2.t0) {
425
- _context2.next = 10;
437
+ _context2.next = 12;
426
438
  break;
427
439
  }
428
- _context2.next = 10;
440
+ _context2.next = 12;
429
441
  return (_TargetComponent$prop4 = TargetComponent.props).onBlur.apply(_TargetComponent$prop4, (0, _toConsumableArray2.default)(_args));
430
- case 10:
442
+ case 12:
431
443
  _context2.t1 = onBlur;
432
444
  if (!_context2.t1) {
433
- _context2.next = 14;
445
+ _context2.next = 16;
434
446
  break;
435
447
  }
436
- _context2.next = 14;
448
+ _context2.next = 16;
437
449
  return onBlur.apply(void 0, (0, _toConsumableArray2.default)(_args));
438
- case 14:
450
+ case 16:
439
451
  // 判断属性是否变动
440
452
  form.setFieldValue(rowPath, row);
441
453
  if (!(0, _lodash.isEqual)(orgRow, row)) {
@@ -448,23 +460,23 @@ var RenderField = function RenderField(_ref) {
448
460
  }
449
461
  }
450
462
  if (!isCell) {
451
- _context2.next = 20;
463
+ _context2.next = 22;
452
464
  break;
453
465
  }
454
- _context2.next = 19;
466
+ _context2.next = 21;
455
467
  return form.validateFields([cellName]);
456
- case 19:
468
+ case 21:
457
469
  setState({
458
470
  cellNamePath: []
459
471
  });
460
- case 20:
472
+ case 22:
461
473
  // 单行编辑时需要 强制更新视图
462
474
  setState({
463
475
  forceUpdate: {
464
476
  d: Date.now()
465
477
  }
466
478
  });
467
- case 21:
479
+ case 23:
468
480
  case "end":
469
481
  return _context2.stop();
470
482
  }
@@ -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;
@@ -38,7 +38,7 @@ var FormFooter = function FormFooter(props) {
38
38
  form.setFieldsValue(cache[formId]);
39
39
  }
40
40
  return cache;
41
- }, []);
41
+ }, [formId]);
42
42
  var _onOk = function _onOk() {
43
43
  if (formId) {
44
44
  var values = form.getFieldsValue();
@@ -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)
@@ -11,7 +11,6 @@ var _jsxRuntime = require("react/jsx-runtime");
11
11
  var _react = require("react");
12
12
  var _antd = require("antd");
13
13
  var _core = require("@dnd-kit/core");
14
- var _lodash = require("lodash");
15
14
  var _sortable = require("@dnd-kit/sortable");
16
15
  var _utils = require("../../../utils");
17
16
  var _utils2 = require("./utils");
@@ -62,10 +61,6 @@ var FormList = function FormList(props, ref) {
62
61
  listName: [].concat((0, _toConsumableArray2.default)(namePath), [item.name]),
63
62
  label: mode === 'less' ? undefined : item.label
64
63
  });
65
- // 可编辑表格的columns需要消除引用关系,防止串数据
66
- if (column.type === 'ProEditTable' && !(0, _lodash.isFunction)(column.fieldProps)) {
67
- column.fieldProps.columns = (0, _lodash.cloneDeep)(column.fieldProps.columns);
68
- }
69
64
  return column;
70
65
  });
71
66
  }, [columns]);
@@ -157,7 +157,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
157
157
  var defaultOptionRender = function defaultOptionRender(rowData) {
158
158
  return rowData === null || rowData === void 0 ? void 0 : rowData[labelKey];
159
159
  };
160
- var handleFormat = optionRender || onFormat || defaultOptionRender;
160
+ var handleFormat = onFormat || defaultOptionRender;
161
161
  if (showCodeName) {
162
162
  handleFormat = function handleFormat(_ref5) {
163
163
  var value = _ref5.value,
@@ -678,6 +678,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
678
678
  showCodeName: showCodeName,
679
679
  labelInValue: labelInValue,
680
680
  dataSource: options,
681
+ optionRender: optionRender,
681
682
  scrollFollowParent: false,
682
683
  mode: isMultiple ? 'multiple' : undefined,
683
684
  onFocus: function onFocus() {
@@ -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
@@ -29,6 +29,7 @@ var useShouldUpdate = function useShouldUpdate(props) {
29
29
  names = formItemProps.names,
30
30
  dependencies = formItemProps.dependencies;
31
31
  var timerRef = (0, _react.useRef)();
32
+ var needClear = (0, _react.useRef)(); // 是否需要执行清值操作
32
33
  var showRef = (0, _react.useRef)();
33
34
  var disabledRef = (0, _react.useRef)();
34
35
  var requiredRef = (0, _react.useRef)();
@@ -165,21 +166,30 @@ var useShouldUpdate = function useShouldUpdate(props) {
165
166
  }) : fieldProps;
166
167
  // 清值防抖 多次刷新时以最后一次为准
167
168
  if (clearNotShow !== false && (name || names)) {
169
+ // 当show为其他变为false的时候记录一次需要清值
170
+ if (_show !== showRef.current && _show === false) {
171
+ needClear.current = true;
172
+ }
168
173
  if (_show === false) {
169
174
  clearTimeout(timerRef.current);
170
175
  timerRef.current = setTimeout(function () {
176
+ if (needClear.current !== true) return;
171
177
  if (Array.isArray(names)) {
172
178
  form.resetFields(names);
173
179
  } else {
174
180
  var clearName = formItemProps.namePath ? formItemProps.namePath.slice(0, -1).concat(formItemProps.name) : formItemProps.name;
175
181
  form.resetFields([clearName]);
176
182
  }
177
- }, 200);
183
+ needClear.current = false;
184
+ }, 300);
178
185
  } else {
186
+ needClear.current = false;
179
187
  clearTimeout(timerRef.current);
180
188
  }
181
189
  }
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) ||
190
+ var equalRes = (0, _lodash.isEqualWith)(rulesRef.current, _rules, _index.customEqualForFun);
191
+ var proEqualRes = (0, _lodash.isEqualWith)(fieldPropsRef.current, _fieldProps, _index.customEqualForFun);
192
+ if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes ||
183
193
  // 值变更,需要同步更新函数式的fieldProps
184
194
  // (isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) && !isEqual(prevValues, currentValues)) ||
185
195
  // !isEqualWith(originComponentRef.current, _component, customEqualForFun) ||
@@ -139,9 +139,9 @@ function ProTable(props) {
139
139
  });
140
140
  });
141
141
  localColumns = ((_localColumns = localColumns) === null || _localColumns === void 0 ? void 0 : _localColumns.length) === 0 ? undefined : localColumns;
142
- setCurColumns((0, _lodash.cloneDeep)(localColumns || propsColumns));
142
+ setCurColumns(localColumns || propsColumns);
143
143
  } else {
144
- setCurColumns((0, _lodash.cloneDeep)(propsColumns));
144
+ setCurColumns(propsColumns);
145
145
  }
146
146
  }, [pathKey, cacheTime, propsColumns]);
147
147
  (0, _react.useEffect)(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.6.4",
3
+ "version": "3.6.5-beta.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -58,7 +58,7 @@
58
58
  "@dnd-kit/sortable": "^7.0.2",
59
59
  "@dnd-kit/utilities": "^3.2.1",
60
60
  "@pansy/react-watermark": "^3.1.13",
61
- "@zat-design/utils": "^1.1.28",
61
+ "@zat-design/utils": "^1.1.29",
62
62
  "ahooks": "3.7.4",
63
63
  "antd": "4.24.8",
64
64
  "big.js": "^6.2.1",