@zat-design/sisyphus-react 3.10.2-beta.2 → 3.10.2-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/es/ProEditTable/components/RenderField/ListChangedWrapper.d.ts +1 -1
  2. package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +4 -4
  3. package/es/ProEditTable/components/RenderField/index.js +1 -1
  4. package/es/ProEditTable/propsType.d.ts +1 -1
  5. package/es/ProEditTable/utils/diffOriginal.d.ts +1 -1
  6. package/es/ProEditTable/utils/diffOriginal.js +3 -3
  7. package/es/ProForm/components/combination/ProModalSelect/index.js +2 -2
  8. package/es/ProForm/components/render/ChangedWrapper.d.ts +1 -1
  9. package/es/ProForm/components/render/ChangedWrapper.js +5 -6
  10. package/es/ProForm/components/render/Render.js +2 -2
  11. package/es/ProForm/components/render/RenderFields.js +2 -3
  12. package/es/ProForm/components/render/propsType.d.ts +1 -2
  13. package/es/ProForm/utils/_useChanged.d.ts +2 -2
  14. package/es/ProForm/utils/_useChanged.js +3 -3
  15. package/es/ProForm/utils/_useListChanged.d.ts +1 -1
  16. package/es/ProForm/utils/_useListChanged.js +3 -3
  17. package/es/ProForm/utils/diffOriginal.d.ts +1 -1
  18. package/es/ProForm/utils/diffOriginal.js +3 -3
  19. package/es/ProForm/utils/transformValue.js +9 -7
  20. package/lib/ProEditTable/components/RenderField/ListChangedWrapper.d.ts +1 -1
  21. package/lib/ProEditTable/components/RenderField/ListChangedWrapper.js +4 -4
  22. package/lib/ProEditTable/components/RenderField/index.js +1 -1
  23. package/lib/ProEditTable/propsType.d.ts +1 -1
  24. package/lib/ProEditTable/utils/diffOriginal.d.ts +1 -1
  25. package/lib/ProEditTable/utils/diffOriginal.js +3 -3
  26. package/lib/ProForm/components/combination/ProModalSelect/index.js +1 -1
  27. package/lib/ProForm/components/render/ChangedWrapper.d.ts +1 -1
  28. package/lib/ProForm/components/render/ChangedWrapper.js +5 -6
  29. package/lib/ProForm/components/render/Render.js +2 -2
  30. package/lib/ProForm/components/render/RenderFields.js +2 -3
  31. package/lib/ProForm/components/render/propsType.d.ts +1 -2
  32. package/lib/ProForm/utils/_useChanged.d.ts +2 -2
  33. package/lib/ProForm/utils/_useChanged.js +3 -3
  34. package/lib/ProForm/utils/_useListChanged.d.ts +1 -1
  35. package/lib/ProForm/utils/_useListChanged.js +3 -3
  36. package/lib/ProForm/utils/diffOriginal.d.ts +1 -1
  37. package/lib/ProForm/utils/diffOriginal.js +3 -3
  38. package/lib/ProForm/utils/transformValue.js +9 -7
  39. package/package.json +1 -1
@@ -10,7 +10,7 @@ interface Props {
10
10
  namesStr?: NamePath;
11
11
  originalValues?: any;
12
12
  form: FormInstance;
13
- equalWith?: DiffOriginalParams['equalWith'];
13
+ onDiff?: DiffOriginalParams['onDiff'];
14
14
  [name: string]: any;
15
15
  }
16
16
  declare const ListChangedWrapper: React.FC<Props>;
@@ -5,7 +5,7 @@ import _Tooltip from "antd/es/tooltip";
5
5
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
6
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
7
7
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
8
- var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type", "normalize", "getValueProps", "valuePropName", "viewRender", "diffConfig", "index"];
8
+ var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "onDiff", "rowKeyPath", "children", "type", "normalize", "getValueProps", "valuePropName", "viewRender", "diffConfig", "index"];
9
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  import React, { useMemo } from 'react';
11
11
  import classnames from 'classnames';
@@ -84,7 +84,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
84
84
  originalNames = _props$originalNames === void 0 ? names : _props$originalNames,
85
85
  originalValues = props.originalValues,
86
86
  form = props.form,
87
- equalWith = props.equalWith,
87
+ onDiff = props.onDiff,
88
88
  rowKeyPath = props.rowKeyPath,
89
89
  children = props.children,
90
90
  type = props.type,
@@ -115,7 +115,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
115
115
  form: form
116
116
  });
117
117
  var originalValue = isWatch ? originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originalValue : undefined;
118
- var noChange = !equalWith && (!originalValues || isDiffAll ? false : isEmpty(originalValue));
118
+ var noChange = !onDiff && (!originalValues || isDiffAll ? false : isEmpty(originalValue));
119
119
  var diffType = useMemo(function () {
120
120
  if (!isWatch || noChange) return 'same';
121
121
  var _value = normalize ? normalize(props[valuePropName], undefined, undefined, true) // true 代表是值比对时的调用
@@ -130,7 +130,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
130
130
  value: _value,
131
131
  originalValue: _originalValue,
132
132
  form: form,
133
- equalWith: equalWith,
133
+ onDiff: onDiff,
134
134
  originRecord: originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originRecord,
135
135
  record: originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.record,
136
136
  index: index
@@ -568,7 +568,7 @@ var RenderField = function RenderField(_ref) {
568
568
  originalNames: originalNames,
569
569
  originalValues: originalValues,
570
570
  form: form,
571
- equalWith: onDiff,
571
+ onDiff: onDiff,
572
572
  type: type,
573
573
  onChange: _onChange,
574
574
  valuePropName: _formItemProps.valuePropName,
@@ -110,7 +110,7 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro
110
110
  rules?: ProRule[] | RulesFn<T>;
111
111
  confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps | void>;
112
112
  dependencies?: NamePath[];
113
- onDiff?: DiffOriginalParams['equalWith'];
113
+ onDiff?: DiffOriginalParams['onDiff'];
114
114
  [key: string]: any;
115
115
  }
116
116
  export type ProEditTableColumnsProps<K = any> = ProColumnsProps & ColumnPropsMap<K, 'ProEditTable'>;
@@ -4,7 +4,7 @@ export interface DiffOriginalParams {
4
4
  originalValue: any;
5
5
  value: any;
6
6
  form: FormInstance;
7
- equalWith?: ({ originValue, originRecord, value, record, index, }: {
7
+ onDiff?: ({ originValue, originRecord, value, record, index, }: {
8
8
  originValue: any;
9
9
  originRecord: any;
10
10
  value: any;
@@ -31,13 +31,13 @@ var filterObject = function filterObject(data) {
31
31
  export var diffOriginal = function diffOriginal(params) {
32
32
  var originalValue = params.originalValue,
33
33
  value = params.value,
34
- equalWith = params.equalWith,
34
+ onDiff = params.onDiff,
35
35
  originRecord = params.originRecord,
36
36
  record = params.record,
37
37
  index = params.index;
38
38
  // 支持传入自定义比较事件
39
- if (isFunction(equalWith)) {
40
- var diffRes = equalWith({
39
+ if (isFunction(onDiff)) {
40
+ var diffRes = onDiff({
41
41
  originValue: originalValue,
42
42
  originRecord: originRecord,
43
43
  value: value,
@@ -27,7 +27,7 @@ import { SearchOutlined } from '@ant-design/icons';
27
27
  import { useDebounceEffect, useDeepCompareEffect, useMount, useSetState } from 'ahooks';
28
28
  import { debounce, isArray, isEqual, isFunction, omit } from 'lodash';
29
29
  import { ReactSVG } from 'react-svg';
30
- import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
30
+ import React, { forwardRef, useEffect, useImperativeHandle, useMemo } from 'react';
31
31
  import { ProForm, ProDrawerForm, ProTable, useProConfig, ProSelect } from '../../../../index';
32
32
  import Container from '../../Container';
33
33
  import viewSvg from '../../../../assets/view.svg';
@@ -604,7 +604,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
604
604
  });
605
605
  }
606
606
  });
607
- useDebounceEffect(function () {
607
+ useEffect(function () {
608
608
  if (onOff && !visible) {
609
609
  var _useRequest$options6;
610
610
  if ((useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options6 = useRequest.options) === null || _useRequest$options6 === void 0 ? void 0 : _useRequest$options6.manual) !== true) {
@@ -9,7 +9,7 @@ interface Props {
9
9
  namesStr?: string;
10
10
  diffConfig?: DiffConfigProps;
11
11
  form: FormInstance;
12
- equalWith?: DiffOriginalParams['equalWith'];
12
+ onDiff?: DiffOriginalParams['onDiff'];
13
13
  valuePropName?: string;
14
14
  [name: string]: any;
15
15
  }
@@ -6,7 +6,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
6
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
7
7
  import _typeof from "@babel/runtime/helpers/esm/typeof";
8
8
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
9
- var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig", "valuePropName", "normalize", "getValueProps", "viewRender"];
9
+ var _excluded = ["name", "names", "namesStr", "form", "onDiff", "children", "type", "diffConfig", "valuePropName", "normalize", "getValueProps", "viewRender"];
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import classNames from 'classnames';
12
12
  import { get } from 'lodash';
@@ -21,7 +21,7 @@ var ChangedWrapper = function ChangedWrapper(props) {
21
21
  names = props.names,
22
22
  namesStr = props.namesStr,
23
23
  form = props.form,
24
- equalWith = props.equalWith,
24
+ onDiff = props.onDiff,
25
25
  children = props.children,
26
26
  type = props.type,
27
27
  diffConfig = props.diffConfig,
@@ -43,7 +43,7 @@ var ChangedWrapper = function ChangedWrapper(props) {
43
43
  var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
44
44
  return get(originalValues, name);
45
45
  }) : get(originalValues, name);
46
- var noChange = !equalWith && (!originalValues || isDiffAll ? false : isEmpty(originalValue));
46
+ var noChange = !onDiff && (!originalValues || isDiffAll ? false : isEmpty(originalValue));
47
47
  var diffType = useMemo(function () {
48
48
  if (!isWatch || noChange) return 'same';
49
49
  var _value = normalize ? normalize(props[valuePropName], undefined, undefined, true) // true 代表是值比对时的调用
@@ -58,10 +58,10 @@ var ChangedWrapper = function ChangedWrapper(props) {
58
58
  value: _value,
59
59
  originalValue: _originalValue,
60
60
  form: form,
61
- equalWith: equalWith
61
+ onDiff: onDiff
62
62
  // name: namesStr || name,
63
63
  });
64
- }, [isWatch, noChange, props[valuePropName], originalValue, _typeof(equalWith)]);
64
+ }, [isWatch, noChange, props[valuePropName], originalValue, _typeof(onDiff)]);
65
65
  var isAdd = diffType === 'add';
66
66
  var isChanged = diffType === 'changed';
67
67
  var tipContent = useMemo(function () {
@@ -86,7 +86,6 @@ var ChangedWrapper = function ChangedWrapper(props) {
86
86
  }, children.props), rest));
87
87
  }
88
88
  // eslint-disable-next-line react-hooks/rules-of-hooks
89
- // const isFocus = useFocus(contentRef.current);
90
89
  var tipOpenCalc = function tipOpenCalc() {
91
90
  if (!toolTip) return false;
92
91
  // 传入undefined 鼠标移入显示移出隐藏 获得焦点时不显示气泡
@@ -46,7 +46,7 @@ var Render = function Render(props) {
46
46
  formDisabled = props.formDisabled,
47
47
  type = props.type,
48
48
  isSelect = props.isSelect,
49
- equalWith = props.equalWith,
49
+ onDiff = props.onDiff,
50
50
  requiredOnView = props.requiredOnView,
51
51
  confirm = props.confirm,
52
52
  globalControl = props.globalControl,
@@ -447,7 +447,7 @@ var Render = function Render(props) {
447
447
  namesStr: namesStr,
448
448
  diffConfig: diffConfig,
449
449
  form: form,
450
- equalWith: equalWith,
450
+ onDiff: onDiff,
451
451
  type: type,
452
452
  onChange: handleChange,
453
453
  valuePropName: _otherFormItemProps.valuePropName,
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["show", "type", "viewRender", "viewType", "valueType", "formItemProps", "colProps", "formItemChildProps", "fieldProps", "equalWith", "onDiff", "clearNotShow", "required", "confirm", "desensitization"];
3
+ var _excluded = ["show", "type", "viewRender", "viewType", "valueType", "formItemProps", "colProps", "formItemChildProps", "fieldProps", "onDiff", "clearNotShow", "required", "confirm", "desensitization"];
4
4
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
5
5
  import React from 'react';
6
6
  import { isBoolean, isFunction, union, isString } from 'lodash';
@@ -69,7 +69,6 @@ var RenderFields = function RenderFields(props) {
69
69
  formItemChildProps = _column$formItemChild === void 0 ? {} : _column$formItemChild,
70
70
  _column$fieldProps = column.fieldProps,
71
71
  fieldProps = _column$fieldProps === void 0 ? {} : _column$fieldProps,
72
- equalWith = column.equalWith,
73
72
  onDiff = column.onDiff,
74
73
  _column$clearNotShow = column.clearNotShow,
75
74
  clearNotShow = _column$clearNotShow === void 0 ? outerClearNotShow : _column$clearNotShow,
@@ -212,7 +211,7 @@ var RenderFields = function RenderFields(props) {
212
211
  fieldProps: isFunction(fieldProps) ? fieldProps : null,
213
212
  isSelect: _isSelect,
214
213
  diffConfig: diffConfig,
215
- equalWith: onDiff || equalWith,
214
+ onDiff: onDiff,
216
215
  requiredOnView: requiredOnView,
217
216
  globalControl: globalControl,
218
217
  viewRender: viewRender,
@@ -206,8 +206,7 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
206
206
  upperCase?: boolean;
207
207
  hiddenNames?: string[] | any[];
208
208
  rules?: ProRule[] | ReactiveFunction<Values, ProRule[]>;
209
- equalWith?: DiffOriginalParams['equalWith'];
210
- onDiff?: DiffOriginalParams['equalWith'];
209
+ onDiff?: DiffOriginalParams['onDiff'];
211
210
  required?: boolean | boolean[] | ReactiveFunction<Values, boolean | boolean[]>;
212
211
  labelRequired?: boolean;
213
212
  toISOString?: boolean;
@@ -1,8 +1,8 @@
1
- export declare const useChanged: ({ name, names, namesStr, originalValues, form, equalWith }: {
1
+ export declare const useChanged: ({ name, names, namesStr, originalValues, form, onDiff }: {
2
2
  name: any;
3
3
  names: any;
4
4
  namesStr: any;
5
5
  originalValues: any;
6
6
  form: any;
7
- equalWith: any;
7
+ onDiff: any;
8
8
  }) => any[];
@@ -8,18 +8,18 @@ export var useChanged = function useChanged(_ref) {
8
8
  namesStr = _ref.namesStr,
9
9
  originalValues = _ref.originalValues,
10
10
  form = _ref.form,
11
- equalWith = _ref.equalWith;
11
+ onDiff = _ref.onDiff;
12
12
  var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
13
13
  return get(originalValues, name);
14
14
  }) : get(originalValues, name);
15
- var notWatch = !equalWith && (!originalValues || originalValue === undefined);
15
+ var notWatch = !onDiff && (!originalValues || originalValue === undefined);
16
16
  if (notWatch) return [false];
17
17
  var value = _Form.useWatch(namesStr || name, form);
18
18
  var changed = diffOriginal({
19
19
  originalValue: originalValue,
20
20
  value: value,
21
21
  form: form,
22
- equalWith: equalWith
22
+ onDiff: onDiff
23
23
  });
24
24
  return [changed, originalValue];
25
25
  };
@@ -10,7 +10,7 @@ interface Params {
10
10
  originalValues: any;
11
11
  form: FormInstance;
12
12
  rowKeyPath?: InternalNamePath;
13
- equalWith?: (originalValue: any, currentValue: any) => boolean;
13
+ onDiff?: (originalValue: any, currentValue: any) => boolean;
14
14
  }
15
15
  export declare const useListChanged: (params: Params) => any[];
16
16
  export {};
@@ -64,7 +64,7 @@ export var useListChanged = function useListChanged(params) {
64
64
  originalNames = _params$originalNames === void 0 ? names : _params$originalNames,
65
65
  originalValues = params.originalValues,
66
66
  form = params.form,
67
- equalWith = params.equalWith,
67
+ onDiff = params.onDiff,
68
68
  rowKeyPath = params.rowKeyPath;
69
69
  var namePath = toNamePath(namesStr || name);
70
70
  var originalNamePath = toNamePath(originalName);
@@ -78,7 +78,7 @@ export var useListChanged = function useListChanged(params) {
78
78
  rowKeyPath: rowKeyPath,
79
79
  form: form
80
80
  }) : undefined;
81
- var noChange = !equalWith && (!originalValues || originalValue === undefined);
81
+ var noChange = !onDiff && (!originalValues || originalValue === undefined);
82
82
  var _form = form;
83
83
  if (notWatch || noChange) return [false];
84
84
  var value = _Form.useWatch(namePath, _form);
@@ -86,7 +86,7 @@ export var useListChanged = function useListChanged(params) {
86
86
  value: value,
87
87
  originalValue: originalValue,
88
88
  form: form,
89
- equalWith: equalWith
89
+ onDiff: onDiff
90
90
  // name: isString(namesStr) ? namesStr : originalName || name,
91
91
  });
92
92
  return [changed, originalValue];
@@ -3,7 +3,7 @@ export interface DiffOriginalParams {
3
3
  originalValue: any;
4
4
  value: any;
5
5
  form: FormInstance;
6
- equalWith?: (originalValue: any, currentValue: any) => DiffType | boolean | undefined;
6
+ onDiff?: (originalValue: any, currentValue: any) => DiffType | boolean | undefined;
7
7
  }
8
8
  export type DiffType = 'same' | 'add' | 'changed';
9
9
  export declare const diffOriginal: (params: DiffOriginalParams) => DiffType;
@@ -30,10 +30,10 @@ var filterObject = function filterObject(data) {
30
30
  export var diffOriginal = function diffOriginal(params) {
31
31
  var originalValue = params.originalValue,
32
32
  value = params.value,
33
- equalWith = params.equalWith;
33
+ onDiff = params.onDiff;
34
34
  // 支持传入自定义比较事件
35
- if (isFunction(equalWith)) {
36
- var diffRes = equalWith(originalValue, value);
35
+ if (isFunction(onDiff)) {
36
+ var diffRes = onDiff(originalValue, value);
37
37
  // 如果返回undefined走内置比较逻辑
38
38
  if (diffRes !== undefined) {
39
39
  if (typeof diffRes === 'boolean') {
@@ -15,21 +15,21 @@ export var transformValue = function transformValue(names, form, fieldName, _nor
15
15
  }
16
16
  names.forEach(function (name, index) {
17
17
  var _value2;
18
- // @ts-ignore
19
18
  set(form.getFieldsValue(true), name, (_value2 = _value) === null || _value2 === void 0 ? void 0 : _value2[index]);
20
19
  });
21
20
  return _value;
22
21
  },
23
- getValueProps: function getValueProps(value, isOrg) {
22
+ getValueProps: function getValueProps(value, isOrigin) {
24
23
  var _curValue;
25
24
  var _value = [];
26
- if (!isOrg) {
25
+ if (isOrigin) {
26
+ _value = value;
27
+ } else {
28
+ // 非比对names场景
27
29
  names.forEach(function (name, index) {
28
30
  var value = form.getFieldValue(name);
29
31
  _value[index] = value;
30
32
  });
31
- } else {
32
- _value = value;
33
33
  }
34
34
  // 支持外部传入转换函数
35
35
  var res = (_getValueProps === null || _getValueProps === void 0 ? void 0 : _getValueProps(_value)) || {
@@ -43,8 +43,10 @@ export var transformValue = function transformValue(names, form, fieldName, _nor
43
43
  })) {
44
44
  curValue = undefined;
45
45
  }
46
- // @ts-ignore
47
- set(form.getFieldsValue(true), fieldName, curValue);
46
+ // 如果来源是比对且有names场景, 则不更新表单值
47
+ if (!isOrigin) {
48
+ set(form.getFieldsValue(true), fieldName, curValue);
49
+ }
48
50
  // 如果表单里的值和组合得到的值不全等 更新表单里的值、
49
51
  return _objectSpread(_objectSpread({}, res), {}, {
50
52
  value: curValue
@@ -10,7 +10,7 @@ interface Props {
10
10
  namesStr?: NamePath;
11
11
  originalValues?: any;
12
12
  form: FormInstance;
13
- equalWith?: DiffOriginalParams['equalWith'];
13
+ onDiff?: DiffOriginalParams['onDiff'];
14
14
  [name: string]: any;
15
15
  }
16
16
  declare const ListChangedWrapper: React.FC<Props>;
@@ -17,7 +17,7 @@ var _lodash = require("lodash");
17
17
  var _diffOriginal = require("../../utils/diffOriginal");
18
18
  var _ProConfigProvider = require("../../../ProConfigProvider");
19
19
  var _utils = require("../../../utils");
20
- var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type", "normalize", "getValueProps", "valuePropName", "viewRender", "diffConfig", "index"];
20
+ var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "onDiff", "rowKeyPath", "children", "type", "normalize", "getValueProps", "valuePropName", "viewRender", "diffConfig", "index"];
21
21
  var toNamePath = function toNamePath(name) {
22
22
  if (Array.isArray(name)) {
23
23
  return name;
@@ -89,7 +89,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
89
89
  originalNames = _props$originalNames === void 0 ? names : _props$originalNames,
90
90
  originalValues = props.originalValues,
91
91
  form = props.form,
92
- equalWith = props.equalWith,
92
+ onDiff = props.onDiff,
93
93
  rowKeyPath = props.rowKeyPath,
94
94
  children = props.children,
95
95
  type = props.type,
@@ -120,7 +120,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
120
120
  form: form
121
121
  });
122
122
  var originalValue = isWatch ? originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originalValue : undefined;
123
- var noChange = !equalWith && (!originalValues || isDiffAll ? false : (0, _utils.isEmpty)(originalValue));
123
+ var noChange = !onDiff && (!originalValues || isDiffAll ? false : (0, _utils.isEmpty)(originalValue));
124
124
  var diffType = (0, _react.useMemo)(function () {
125
125
  if (!isWatch || noChange) return 'same';
126
126
  var _value = normalize ? normalize(props[valuePropName], undefined, undefined, true) // true 代表是值比对时的调用
@@ -135,7 +135,7 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
135
135
  value: _value,
136
136
  originalValue: _originalValue,
137
137
  form: form,
138
- equalWith: equalWith,
138
+ onDiff: onDiff,
139
139
  originRecord: originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originRecord,
140
140
  record: originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.record,
141
141
  index: index
@@ -575,7 +575,7 @@ var RenderField = function RenderField(_ref) {
575
575
  originalNames: originalNames,
576
576
  originalValues: originalValues,
577
577
  form: form,
578
- equalWith: onDiff,
578
+ onDiff: onDiff,
579
579
  type: type,
580
580
  onChange: _onChange,
581
581
  valuePropName: _formItemProps.valuePropName,
@@ -110,7 +110,7 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro
110
110
  rules?: ProRule[] | RulesFn<T>;
111
111
  confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps | void>;
112
112
  dependencies?: NamePath[];
113
- onDiff?: DiffOriginalParams['equalWith'];
113
+ onDiff?: DiffOriginalParams['onDiff'];
114
114
  [key: string]: any;
115
115
  }
116
116
  export type ProEditTableColumnsProps<K = any> = ProColumnsProps & ColumnPropsMap<K, 'ProEditTable'>;
@@ -4,7 +4,7 @@ export interface DiffOriginalParams {
4
4
  originalValue: any;
5
5
  value: any;
6
6
  form: FormInstance;
7
- equalWith?: ({ originValue, originRecord, value, record, index, }: {
7
+ onDiff?: ({ originValue, originRecord, value, record, index, }: {
8
8
  originValue: any;
9
9
  originRecord: any;
10
10
  value: any;
@@ -37,13 +37,13 @@ var filterObject = function filterObject(data) {
37
37
  var diffOriginal = exports.diffOriginal = function diffOriginal(params) {
38
38
  var originalValue = params.originalValue,
39
39
  value = params.value,
40
- equalWith = params.equalWith,
40
+ onDiff = params.onDiff,
41
41
  originRecord = params.originRecord,
42
42
  record = params.record,
43
43
  index = params.index;
44
44
  // 支持传入自定义比较事件
45
- if ((0, _lodash.isFunction)(equalWith)) {
46
- var diffRes = equalWith({
45
+ if ((0, _lodash.isFunction)(onDiff)) {
46
+ var diffRes = onDiff({
47
47
  originValue: originalValue,
48
48
  originRecord: originRecord,
49
49
  value: value,
@@ -599,7 +599,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
599
599
  });
600
600
  }
601
601
  });
602
- (0, _ahooks.useDebounceEffect)(function () {
602
+ (0, _react.useEffect)(function () {
603
603
  if (onOff && !visible) {
604
604
  var _useRequest$options6;
605
605
  if ((useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options6 = useRequest.options) === null || _useRequest$options6 === void 0 ? void 0 : _useRequest$options6.manual) !== true) {
@@ -9,7 +9,7 @@ interface Props {
9
9
  namesStr?: string;
10
10
  diffConfig?: DiffConfigProps;
11
11
  form: FormInstance;
12
- equalWith?: DiffOriginalParams['equalWith'];
12
+ onDiff?: DiffOriginalParams['onDiff'];
13
13
  valuePropName?: string;
14
14
  [name: string]: any;
15
15
  }
@@ -18,7 +18,7 @@ var _react = _interopRequireWildcard(require("react"));
18
18
  var _diffOriginal = require("../../utils/diffOriginal");
19
19
  var _ProConfigProvider = require("../../../ProConfigProvider");
20
20
  var _utils = require("../../../utils");
21
- var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig", "valuePropName", "normalize", "getValueProps", "viewRender"];
21
+ var _excluded = ["name", "names", "namesStr", "form", "onDiff", "children", "type", "diffConfig", "valuePropName", "normalize", "getValueProps", "viewRender"];
22
22
  var componentsWithFloatWindow = ['Select', 'ProSelect', 'ProEnum', 'ProTimeLimit', 'ProModalSelect', 'ProCascader', 'DataPicker', 'RangePicker', 'TimePicker'];
23
23
  var ChangedWrapper = function ChangedWrapper(props) {
24
24
  var _diffConfig$toolTip, _children$props, _children$props2, _children$props3;
@@ -26,7 +26,7 @@ var ChangedWrapper = function ChangedWrapper(props) {
26
26
  names = props.names,
27
27
  namesStr = props.namesStr,
28
28
  form = props.form,
29
- equalWith = props.equalWith,
29
+ onDiff = props.onDiff,
30
30
  children = props.children,
31
31
  type = props.type,
32
32
  diffConfig = props.diffConfig,
@@ -48,7 +48,7 @@ var ChangedWrapper = function ChangedWrapper(props) {
48
48
  var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
49
49
  return (0, _lodash.get)(originalValues, name);
50
50
  }) : (0, _lodash.get)(originalValues, name);
51
- var noChange = !equalWith && (!originalValues || isDiffAll ? false : (0, _utils.isEmpty)(originalValue));
51
+ var noChange = !onDiff && (!originalValues || isDiffAll ? false : (0, _utils.isEmpty)(originalValue));
52
52
  var diffType = (0, _react.useMemo)(function () {
53
53
  if (!isWatch || noChange) return 'same';
54
54
  var _value = normalize ? normalize(props[valuePropName], undefined, undefined, true) // true 代表是值比对时的调用
@@ -63,10 +63,10 @@ var ChangedWrapper = function ChangedWrapper(props) {
63
63
  value: _value,
64
64
  originalValue: _originalValue,
65
65
  form: form,
66
- equalWith: equalWith
66
+ onDiff: onDiff
67
67
  // name: namesStr || name,
68
68
  });
69
- }, [isWatch, noChange, props[valuePropName], originalValue, (0, _typeof2.default)(equalWith)]);
69
+ }, [isWatch, noChange, props[valuePropName], originalValue, (0, _typeof2.default)(onDiff)]);
70
70
  var isAdd = diffType === 'add';
71
71
  var isChanged = diffType === 'changed';
72
72
  var tipContent = (0, _react.useMemo)(function () {
@@ -91,7 +91,6 @@ var ChangedWrapper = function ChangedWrapper(props) {
91
91
  }, children.props), rest));
92
92
  }
93
93
  // eslint-disable-next-line react-hooks/rules-of-hooks
94
- // const isFocus = useFocus(contentRef.current);
95
94
  var tipOpenCalc = function tipOpenCalc() {
96
95
  if (!toolTip) return false;
97
96
  // 传入undefined 鼠标移入显示移出隐藏 获得焦点时不显示气泡
@@ -46,7 +46,7 @@ var Render = function Render(props) {
46
46
  formDisabled = props.formDisabled,
47
47
  type = props.type,
48
48
  isSelect = props.isSelect,
49
- equalWith = props.equalWith,
49
+ onDiff = props.onDiff,
50
50
  requiredOnView = props.requiredOnView,
51
51
  confirm = props.confirm,
52
52
  globalControl = props.globalControl,
@@ -447,7 +447,7 @@ var Render = function Render(props) {
447
447
  namesStr: namesStr,
448
448
  diffConfig: diffConfig,
449
449
  form: form,
450
- equalWith: equalWith,
450
+ onDiff: onDiff,
451
451
  type: type,
452
452
  onChange: handleChange,
453
453
  valuePropName: _otherFormItemProps.valuePropName,
@@ -17,7 +17,7 @@ var componentMap = _interopRequireWildcard(require("../index"));
17
17
  var _utils = require("../../utils");
18
18
  var _useFieldProps = require("../../utils/useFieldProps");
19
19
  var _locale = _interopRequireDefault(require("../../../locale"));
20
- var _excluded = ["show", "type", "viewRender", "viewType", "valueType", "formItemProps", "colProps", "formItemChildProps", "fieldProps", "equalWith", "onDiff", "clearNotShow", "required", "confirm", "desensitization"];
20
+ var _excluded = ["show", "type", "viewRender", "viewType", "valueType", "formItemProps", "colProps", "formItemChildProps", "fieldProps", "onDiff", "clearNotShow", "required", "confirm", "desensitization"];
21
21
  var RenderFields = function RenderFields(props) {
22
22
  var isView = props.isView,
23
23
  _props$columns = props.columns,
@@ -77,7 +77,6 @@ var RenderFields = function RenderFields(props) {
77
77
  formItemChildProps = _column$formItemChild === void 0 ? {} : _column$formItemChild,
78
78
  _column$fieldProps = column.fieldProps,
79
79
  fieldProps = _column$fieldProps === void 0 ? {} : _column$fieldProps,
80
- equalWith = column.equalWith,
81
80
  onDiff = column.onDiff,
82
81
  _column$clearNotShow = column.clearNotShow,
83
82
  clearNotShow = _column$clearNotShow === void 0 ? outerClearNotShow : _column$clearNotShow,
@@ -220,7 +219,7 @@ var RenderFields = function RenderFields(props) {
220
219
  fieldProps: (0, _lodash.isFunction)(fieldProps) ? fieldProps : null,
221
220
  isSelect: _isSelect,
222
221
  diffConfig: diffConfig,
223
- equalWith: onDiff || equalWith,
222
+ onDiff: onDiff,
224
223
  requiredOnView: requiredOnView,
225
224
  globalControl: globalControl,
226
225
  viewRender: viewRender,
@@ -206,8 +206,7 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
206
206
  upperCase?: boolean;
207
207
  hiddenNames?: string[] | any[];
208
208
  rules?: ProRule[] | ReactiveFunction<Values, ProRule[]>;
209
- equalWith?: DiffOriginalParams['equalWith'];
210
- onDiff?: DiffOriginalParams['equalWith'];
209
+ onDiff?: DiffOriginalParams['onDiff'];
211
210
  required?: boolean | boolean[] | ReactiveFunction<Values, boolean | boolean[]>;
212
211
  labelRequired?: boolean;
213
212
  toISOString?: boolean;
@@ -1,8 +1,8 @@
1
- export declare const useChanged: ({ name, names, namesStr, originalValues, form, equalWith }: {
1
+ export declare const useChanged: ({ name, names, namesStr, originalValues, form, onDiff }: {
2
2
  name: any;
3
3
  names: any;
4
4
  namesStr: any;
5
5
  originalValues: any;
6
6
  form: any;
7
- equalWith: any;
7
+ onDiff: any;
8
8
  }) => any[];
@@ -13,18 +13,18 @@ var useChanged = exports.useChanged = function useChanged(_ref) {
13
13
  namesStr = _ref.namesStr,
14
14
  originalValues = _ref.originalValues,
15
15
  form = _ref.form,
16
- equalWith = _ref.equalWith;
16
+ onDiff = _ref.onDiff;
17
17
  var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
18
18
  return (0, _lodash.get)(originalValues, name);
19
19
  }) : (0, _lodash.get)(originalValues, name);
20
- var notWatch = !equalWith && (!originalValues || originalValue === undefined);
20
+ var notWatch = !onDiff && (!originalValues || originalValue === undefined);
21
21
  if (notWatch) return [false];
22
22
  var value = _antd.Form.useWatch(namesStr || name, form);
23
23
  var changed = (0, _diffOriginal.diffOriginal)({
24
24
  originalValue: originalValue,
25
25
  value: value,
26
26
  form: form,
27
- equalWith: equalWith
27
+ onDiff: onDiff
28
28
  });
29
29
  return [changed, originalValue];
30
30
  };
@@ -10,7 +10,7 @@ interface Params {
10
10
  originalValues: any;
11
11
  form: FormInstance;
12
12
  rowKeyPath?: InternalNamePath;
13
- equalWith?: (originalValue: any, currentValue: any) => boolean;
13
+ onDiff?: (originalValue: any, currentValue: any) => boolean;
14
14
  }
15
15
  export declare const useListChanged: (params: Params) => any[];
16
16
  export {};
@@ -69,7 +69,7 @@ var useListChanged = exports.useListChanged = function useListChanged(params) {
69
69
  originalNames = _params$originalNames === void 0 ? names : _params$originalNames,
70
70
  originalValues = params.originalValues,
71
71
  form = params.form,
72
- equalWith = params.equalWith,
72
+ onDiff = params.onDiff,
73
73
  rowKeyPath = params.rowKeyPath;
74
74
  var namePath = toNamePath(namesStr || name);
75
75
  var originalNamePath = toNamePath(originalName);
@@ -83,7 +83,7 @@ var useListChanged = exports.useListChanged = function useListChanged(params) {
83
83
  rowKeyPath: rowKeyPath,
84
84
  form: form
85
85
  }) : undefined;
86
- var noChange = !equalWith && (!originalValues || originalValue === undefined);
86
+ var noChange = !onDiff && (!originalValues || originalValue === undefined);
87
87
  var _form = form;
88
88
  if (notWatch || noChange) return [false];
89
89
  var value = _antd.Form.useWatch(namePath, _form);
@@ -91,7 +91,7 @@ var useListChanged = exports.useListChanged = function useListChanged(params) {
91
91
  value: value,
92
92
  originalValue: originalValue,
93
93
  form: form,
94
- equalWith: equalWith
94
+ onDiff: onDiff
95
95
  // name: isString(namesStr) ? namesStr : originalName || name,
96
96
  });
97
97
  return [changed, originalValue];
@@ -3,7 +3,7 @@ export interface DiffOriginalParams {
3
3
  originalValue: any;
4
4
  value: any;
5
5
  form: FormInstance;
6
- equalWith?: (originalValue: any, currentValue: any) => DiffType | boolean | undefined;
6
+ onDiff?: (originalValue: any, currentValue: any) => DiffType | boolean | undefined;
7
7
  }
8
8
  export type DiffType = 'same' | 'add' | 'changed';
9
9
  export declare const diffOriginal: (params: DiffOriginalParams) => DiffType;
@@ -36,10 +36,10 @@ var filterObject = function filterObject(data) {
36
36
  var diffOriginal = exports.diffOriginal = function diffOriginal(params) {
37
37
  var originalValue = params.originalValue,
38
38
  value = params.value,
39
- equalWith = params.equalWith;
39
+ onDiff = params.onDiff;
40
40
  // 支持传入自定义比较事件
41
- if ((0, _lodash.isFunction)(equalWith)) {
42
- var diffRes = equalWith(originalValue, value);
41
+ if ((0, _lodash.isFunction)(onDiff)) {
42
+ var diffRes = onDiff(originalValue, value);
43
43
  // 如果返回undefined走内置比较逻辑
44
44
  if (diffRes !== undefined) {
45
45
  if (typeof diffRes === 'boolean') {
@@ -22,21 +22,21 @@ var transformValue = exports.transformValue = function transformValue(names, for
22
22
  }
23
23
  names.forEach(function (name, index) {
24
24
  var _value2;
25
- // @ts-ignore
26
25
  (0, _lodash.set)(form.getFieldsValue(true), name, (_value2 = _value) === null || _value2 === void 0 ? void 0 : _value2[index]);
27
26
  });
28
27
  return _value;
29
28
  },
30
- getValueProps: function getValueProps(value, isOrg) {
29
+ getValueProps: function getValueProps(value, isOrigin) {
31
30
  var _curValue;
32
31
  var _value = [];
33
- if (!isOrg) {
32
+ if (isOrigin) {
33
+ _value = value;
34
+ } else {
35
+ // 非比对names场景
34
36
  names.forEach(function (name, index) {
35
37
  var value = form.getFieldValue(name);
36
38
  _value[index] = value;
37
39
  });
38
- } else {
39
- _value = value;
40
40
  }
41
41
  // 支持外部传入转换函数
42
42
  var res = (_getValueProps === null || _getValueProps === void 0 ? void 0 : _getValueProps(_value)) || {
@@ -50,8 +50,10 @@ var transformValue = exports.transformValue = function transformValue(names, for
50
50
  })) {
51
51
  curValue = undefined;
52
52
  }
53
- // @ts-ignore
54
- (0, _lodash.set)(form.getFieldsValue(true), fieldName, curValue);
53
+ // 如果来源是比对且有names场景, 则不更新表单值
54
+ if (!isOrigin) {
55
+ (0, _lodash.set)(form.getFieldsValue(true), fieldName, curValue);
56
+ }
55
57
  // 如果表单里的值和组合得到的值不全等 更新表单里的值、
56
58
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, res), {}, {
57
59
  value: curValue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.10.2-beta.2",
3
+ "version": "3.10.2-beta.4",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",