@zat-design/sisyphus-react 3.4.11-beta.4 → 3.4.11-beta.6

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.
@@ -20,6 +20,7 @@ var ProDrawerForm = /*#__PURE__*/forwardRef(function (props, ref) {
20
20
  originalForm = props.form,
21
21
  proFormProps = props.proFormProps,
22
22
  onCancel = props.onCancel,
23
+ onCloseClean = props.onCloseClean,
23
24
  children = props.children;
24
25
  showType = mode || showType;
25
26
  isView = isView || disabled;
@@ -37,7 +38,7 @@ var ProDrawerForm = /*#__PURE__*/forwardRef(function (props, ref) {
37
38
  _ProForm$useForm2 = _slicedToArray(_ProForm$useForm, 1),
38
39
  form = _ProForm$useForm2[0];
39
40
  var handleCancel = function handleCancel() {
40
- form.resetFields();
41
+ onCloseClean && form.resetFields();
41
42
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
42
43
  };
43
44
  // 暴露form实例给用户
@@ -70,6 +71,7 @@ ProDrawerForm.defaultProps = {
70
71
  showType: 'Drawer',
71
72
  size: 'middle',
72
73
  isConfirmClose: true,
74
+ onCloseClean: true,
73
75
  maskClosable: false,
74
76
  cancelText: locale === null || locale === void 0 ? void 0 : (_locale$ProDrawerForm3 = locale.ProDrawerForm) === null || _locale$ProDrawerForm3 === void 0 ? void 0 : _locale$ProDrawerForm3.cancel,
75
77
  proFormProps: {}
@@ -92,5 +92,10 @@ export interface ProDrawerFormPropsType {
92
92
  * @name 抽屉的属性
93
93
  */
94
94
  drawerProps?: Omit<DrawerProps, 'visible'>;
95
+ /**
96
+ * 不支持 'visible',请使用全局的 visible
97
+ * @name 关闭时弹框或者抽屉是否清空formValues
98
+ */
99
+ onCloseClean?: boolean;
95
100
  children?: React.ReactNode;
96
101
  }
@@ -286,6 +286,12 @@ var RenderField = function RenderField(_ref) {
286
286
  }
287
287
  return nextArgs;
288
288
  };
289
+ var debounceValidate = function debounceValidate() {
290
+ var validateFieldKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
291
+ setTimeout(function () {
292
+ form.validateFields([name].concat(_toConsumableArray(validateFieldKeys)));
293
+ }, 100);
294
+ };
289
295
  // 单元格更新数据时,加个防抖,防止更新频率过快,卡顿
290
296
  var _onChange = debounce( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
291
297
  var _len2,
@@ -366,10 +372,10 @@ var RenderField = function RenderField(_ref) {
366
372
  return [].concat(_toConsumableArray(rowPath), [key]);
367
373
  });
368
374
  if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
369
- setTimeout(function () {
370
- form.validateFields([name].concat(_toConsumableArray(validateFieldKeys)));
371
- }, 100);
375
+ debounceValidate(validateFieldKeys);
372
376
  }
377
+ } else {
378
+ debounceValidate();
373
379
  }
374
380
  setState({
375
381
  forceUpdate: {
@@ -432,8 +438,10 @@ var RenderField = function RenderField(_ref) {
432
438
  return [].concat(_toConsumableArray(rowPath), [key]);
433
439
  });
434
440
  if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
435
- form.validateFields(validateFieldKeys);
441
+ debounceValidate(validateFieldKeys);
436
442
  }
443
+ } else {
444
+ debounceValidate();
437
445
  }
438
446
  if (!isCell) {
439
447
  _context2.next = 20;
@@ -27,6 +27,7 @@ var ProDrawerForm = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
27
27
  originalForm = props.form,
28
28
  proFormProps = props.proFormProps,
29
29
  onCancel = props.onCancel,
30
+ onCloseClean = props.onCloseClean,
30
31
  children = props.children;
31
32
  showType = mode || showType;
32
33
  isView = isView || disabled;
@@ -44,7 +45,7 @@ var ProDrawerForm = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
44
45
  _ProForm$useForm2 = (0, _slicedToArray2.default)(_ProForm$useForm, 1),
45
46
  form = _ProForm$useForm2[0];
46
47
  var handleCancel = function handleCancel() {
47
- form.resetFields();
48
+ onCloseClean && form.resetFields();
48
49
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
49
50
  };
50
51
  // 暴露form实例给用户
@@ -77,6 +78,7 @@ ProDrawerForm.defaultProps = {
77
78
  showType: 'Drawer',
78
79
  size: 'middle',
79
80
  isConfirmClose: true,
81
+ onCloseClean: true,
80
82
  maskClosable: false,
81
83
  cancelText: _locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProDrawerForm3 = _locale.default.ProDrawerForm) === null || _locale$ProDrawerForm3 === void 0 ? void 0 : _locale$ProDrawerForm3.cancel,
82
84
  proFormProps: {}
@@ -92,5 +92,10 @@ export interface ProDrawerFormPropsType {
92
92
  * @name 抽屉的属性
93
93
  */
94
94
  drawerProps?: Omit<DrawerProps, 'visible'>;
95
+ /**
96
+ * 不支持 'visible',请使用全局的 visible
97
+ * @name 关闭时弹框或者抽屉是否清空formValues
98
+ */
99
+ onCloseClean?: boolean;
95
100
  children?: React.ReactNode;
96
101
  }
@@ -289,6 +289,12 @@ var RenderField = function RenderField(_ref) {
289
289
  }
290
290
  return nextArgs;
291
291
  };
292
+ var debounceValidate = function debounceValidate() {
293
+ var validateFieldKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
294
+ setTimeout(function () {
295
+ form.validateFields([name].concat((0, _toConsumableArray2.default)(validateFieldKeys)));
296
+ }, 100);
297
+ };
292
298
  // 单元格更新数据时,加个防抖,防止更新频率过快,卡顿
293
299
  var _onChange = (0, _lodash.debounce)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
294
300
  var _len2,
@@ -369,10 +375,10 @@ var RenderField = function RenderField(_ref) {
369
375
  return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
370
376
  });
371
377
  if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
372
- setTimeout(function () {
373
- form.validateFields([name].concat((0, _toConsumableArray2.default)(validateFieldKeys)));
374
- }, 100);
378
+ debounceValidate(validateFieldKeys);
375
379
  }
380
+ } else {
381
+ debounceValidate();
376
382
  }
377
383
  setState({
378
384
  forceUpdate: {
@@ -435,8 +441,10 @@ var RenderField = function RenderField(_ref) {
435
441
  return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
436
442
  });
437
443
  if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
438
- form.validateFields(validateFieldKeys);
444
+ debounceValidate(validateFieldKeys);
439
445
  }
446
+ } else {
447
+ debounceValidate();
440
448
  }
441
449
  if (!isCell) {
442
450
  _context2.next = 20;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.4.11-beta.4",
3
+ "version": "3.4.11-beta.6",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",