@zat-design/sisyphus-react 3.6.10-beta.4 → 3.6.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.
Files changed (43) hide show
  1. package/dist/index.esm.css +41 -41
  2. package/dist/less.esm.css +41 -41
  3. package/es/ProEditTable/components/RenderField/ListChanged.d.ts +16 -0
  4. package/es/ProEditTable/components/RenderField/ListChanged.js +124 -0
  5. package/es/ProEditTable/components/RenderField/index.js +27 -46
  6. package/es/ProForm/components/combination/ProCascader/index.js +8 -14
  7. package/es/ProForm/components/render/Changed.d.ts +14 -0
  8. package/es/ProForm/components/render/Changed.js +64 -0
  9. package/es/ProForm/components/render/Render.js +17 -37
  10. package/es/ProForm/style/index.less +52 -52
  11. package/es/ProForm/utils/diffOriginal.d.ts +0 -1
  12. package/es/ProForm/utils/diffOriginal.js +4 -27
  13. package/es/ProForm/utils/useChanged.js +1 -2
  14. package/es/ProForm/utils/useListChanged.js +3 -3
  15. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +5 -4
  16. package/es/ProThemeTools/component/{PrdTools → ProTools}/index.d.ts +2 -2
  17. package/es/ProThemeTools/component/{PrdTools → ProTools}/index.js +2 -2
  18. package/es/ProThemeTools/component/index.d.ts +1 -2
  19. package/es/ProThemeTools/component/index.js +1 -2
  20. package/es/ProThemeTools/index.js +2 -2
  21. package/es/ProThemeTools/style/index.less +1 -1
  22. package/lib/ProEditTable/components/RenderField/ListChanged.d.ts +16 -0
  23. package/lib/ProEditTable/components/RenderField/ListChanged.js +129 -0
  24. package/lib/ProEditTable/components/RenderField/index.js +26 -41
  25. package/lib/ProForm/components/combination/ProCascader/index.js +6 -12
  26. package/lib/ProForm/components/render/Changed.d.ts +14 -0
  27. package/lib/ProForm/components/render/Changed.js +69 -0
  28. package/lib/ProForm/components/render/Render.js +17 -35
  29. package/lib/ProForm/style/index.less +52 -52
  30. package/lib/ProForm/utils/diffOriginal.d.ts +0 -1
  31. package/lib/ProForm/utils/diffOriginal.js +3 -27
  32. package/lib/ProForm/utils/useChanged.js +1 -2
  33. package/lib/ProForm/utils/useListChanged.js +2 -2
  34. package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +5 -4
  35. package/lib/ProThemeTools/component/{PrdTools → ProTools}/index.d.ts +2 -2
  36. package/lib/ProThemeTools/component/{PrdTools → ProTools}/index.js +2 -2
  37. package/lib/ProThemeTools/component/index.d.ts +1 -2
  38. package/lib/ProThemeTools/component/index.js +3 -3
  39. package/lib/ProThemeTools/index.js +1 -1
  40. package/lib/ProThemeTools/style/index.less +1 -1
  41. package/package.json +1 -1
  42. /package/es/ProThemeTools/component/{PrdTools → ProTools}/style/index.less +0 -0
  43. /package/lib/ProThemeTools/component/{PrdTools → ProTools}/style/index.less +0 -0
@@ -1,7 +1,5 @@
1
1
  import "antd/es/col/style";
2
2
  import _Col from "antd/es/col";
3
- import "antd/es/tooltip/style";
4
- import _Tooltip from "antd/es/tooltip";
5
3
  import "antd/es/space/style";
6
4
  import _Space from "antd/es/space";
7
5
  import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
@@ -13,7 +11,6 @@ import "antd/es/form/style";
13
11
  import _Form from "antd/es/form";
14
12
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
15
13
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
16
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
17
14
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
18
15
  var _excluded = ["labelWidth", "hiddenNames", "trim", "upperCase", "className", "rules", "required", "labelRequired", "tooltip"];
19
16
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
@@ -28,10 +25,10 @@ import { isTrim, isUpperCase, findOptionByValue, parseNamePath } from '../../uti
28
25
  import { useProConfig } from '../../../ProConfigProvider';
29
26
  import transformNames from '../../utils/transformNames';
30
27
  import valueTypeMap from '../../utils/valueType';
31
- import { useChanged } from '../../utils/useChanged';
32
28
  import tipSvg from '../../../assets/tip.svg';
33
29
  import useRules from '../../utils/useRules';
34
30
  import ConfirmWrapper from './ConfirmWrapper';
31
+ import Changed from './Changed';
35
32
  // 这个组件只管渲染, 参数的整理在外部处理
36
33
  var Render = function Render(props) {
37
34
  var _ref2, _ref3, _ref4, _ref5, _otherProps$names2;
@@ -101,18 +98,6 @@ var Render = function Render(props) {
101
98
  return Array.isArray(name) ? name.join('_') : name;
102
99
  }).join('-');
103
100
  }, [otherProps === null || otherProps === void 0 ? void 0 : otherProps.names]);
104
- // 判断当前字段是否变更
105
- var _useChanged = useChanged({
106
- name: formItemProps.name,
107
- names: otherProps.names,
108
- namesStr: namesStr,
109
- originalValues: originalValues,
110
- form: form,
111
- equalWith: equalWith
112
- }),
113
- _useChanged2 = _slicedToArray(_useChanged, 2),
114
- changed = _useChanged2[0],
115
- originalValue = _useChanged2[1];
116
101
  var internalRule = useRules({
117
102
  names: otherProps.names,
118
103
  label: otherFormItemProps.label,
@@ -184,7 +169,7 @@ var Render = function Render(props) {
184
169
  var lastComponentProps = _objectSpread(_objectSpread(_objectSpread({}, componentProps), _fieldProps), {}, {
185
170
  disabled: lastDisabled
186
171
  });
187
- var _className = classNames(_defineProperty(_defineProperty(_defineProperty({}, className, className), 'pro-form-item-changed', changed), 'pro-form-item-width-auto', ['Switch'].includes(type)));
172
+ var _className = classNames(_defineProperty(_defineProperty({}, className, className), 'pro-form-item-width-auto', ['Switch'].includes(type)));
188
173
  if (formItemProps.hidden === true || _show === false) {
189
174
  // 为了监听shouldUpdate 必须存在一个FormItem, 空Input解决 【[antd: Form.Item] `name` is only used for validate React element】
190
175
  return _jsx(_Form.Item, {
@@ -442,6 +427,20 @@ var Render = function Render(props) {
442
427
  span: 24 // 默认占一行
443
428
  });
444
429
  }
430
+ if (originalValues) {
431
+ child = _jsx(Changed, {
432
+ name: formItemProps.name,
433
+ names: otherProps.names,
434
+ namesStr: namesStr,
435
+ originalValues: originalValues,
436
+ form: form,
437
+ equalWith: equalWith,
438
+ originalDiffTip: originalDiffTip,
439
+ type: type,
440
+ onChange: handleChange,
441
+ children: child
442
+ });
443
+ }
445
444
  var orgFormItem = _jsx(_Form.Item, _objectSpread(_objectSpread({}, omit(_otherFormItemProps, filterFormItemKey)), {}, {
446
445
  // @ts-ignore
447
446
  _internalItemRender: internalItemRender,
@@ -468,26 +467,7 @@ var Render = function Render(props) {
468
467
  })
469
468
  });
470
469
  }
471
- // 不渲染tooltip
472
- if (!originalDiffTip || ['FormList', 'ProEditTable'].includes(type)) {
473
- return formItem;
474
- }
475
- var title = _jsxs(_Space, {
476
- children: ["\u521D\u59CB\u503C\uFF1A", /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, child), {}, {
477
- isView: true,
478
- value: originalValue,
479
- checked: type === 'Switch' ? originalValue : undefined
480
- }))]
481
- });
482
- return _jsx(_Tooltip, {
483
- title: title,
484
- open: changed ? undefined : false,
485
- // open={true}
486
- getPopupContainer: function getPopupContainer(target) {
487
- return target.parentElement;
488
- },
489
- children: formItem
490
- });
470
+ return formItem;
491
471
  };
492
472
  var FormItem = _jsxs(_Fragment, {
493
473
  children: [renderItem(), (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$names2 = otherProps.names) === null || _otherProps$names2 === void 0 ? void 0 : _otherProps$names2.length) ? otherProps.names.map(function (name) {
@@ -116,58 +116,6 @@
116
116
  }
117
117
  }
118
118
 
119
- // 比较原始值场景下 不同时的样式
120
- &.pro-form-item-changed {
121
- span.@{ant-prefix}-input-affix-wrapper,
122
- .@{ant-prefix}-select .@{ant-prefix}-select-selector,
123
- .@{ant-prefix}-picker,
124
- .@{ant-prefix}-input-number {
125
- background: @zaui-contract-bg !important;
126
-
127
- input {
128
- background: transparent;
129
- }
130
- .@{ant-prefix}-select-selection-placeholder {
131
- z-index: 9;
132
- }
133
- }
134
-
135
- .@{ant-prefix}-form-item-control:has(.@{ant-prefix}-switch-handle),
136
- .@{ant-prefix}-form-item-control:has(.@{ant-prefix}-checkbox-wrapper-in-form-item) {
137
- background: @zaui-contract-bg;
138
- border-radius: 4px;
139
- }
140
-
141
- // 地址组件
142
- .@{ant-prefix}-form-item-control-input-content {
143
- // 查看模式
144
- & > span {
145
- border-radius: 4px;
146
- padding: 5px 8px;
147
- background: @zaui-contract-bg;
148
- }
149
-
150
- & > .pro-address {
151
- .@{ant-prefix}-select-selector,
152
- .@{ant-prefix}-input-affix-wrapper,
153
- .@{ant-prefix}-input-disabled {
154
- background: @zaui-contract-bg;
155
- }
156
- }
157
- & > .@{ant-prefix}-input-group {
158
- .forever-checkbox {
159
- background: @zaui-contract-bg;
160
- }
161
- }
162
- }
163
-
164
- .pro-form-view-container {
165
- padding: 4px 8px;
166
- background: @zaui-contract-bg;
167
- border-radius: 4px;
168
- }
169
- }
170
-
171
119
  .@{ant-prefix}-row {
172
120
  width: 100%;
173
121
  }
@@ -373,4 +321,56 @@
373
321
  }
374
322
  }
375
323
  }
324
+
325
+ // 比较原始值场景下 不同时的样式
326
+ .pro-form-item-changed {
327
+ span.@{ant-prefix}-input-affix-wrapper,
328
+ .@{ant-prefix}-select .@{ant-prefix}-select-selector,
329
+ .@{ant-prefix}-picker,
330
+ .@{ant-prefix}-input-number {
331
+ background: @zaui-contract-bg !important;
332
+
333
+ input {
334
+ background: transparent !important;
335
+ }
336
+ .@{ant-prefix}-select-selection-placeholder {
337
+ z-index: 9;
338
+ }
339
+ }
340
+
341
+ .@{ant-prefix}-form-item-control:has(.@{ant-prefix}-switch-handle),
342
+ .@{ant-prefix}-form-item-control:has(.@{ant-prefix}-checkbox-wrapper-in-form-item) {
343
+ background: @zaui-contract-bg;
344
+ border-radius: 4px;
345
+ }
346
+
347
+ // 地址组件
348
+ .@{ant-prefix}-form-item-control-input-content {
349
+ // 查看模式
350
+ & > span {
351
+ border-radius: 4px;
352
+ padding: 5px 8px;
353
+ background: @zaui-contract-bg;
354
+ }
355
+
356
+ & > .pro-address {
357
+ .@{ant-prefix}-select-selector,
358
+ .@{ant-prefix}-input-affix-wrapper,
359
+ .@{ant-prefix}-input-disabled {
360
+ background: @zaui-contract-bg;
361
+ }
362
+ }
363
+ & > .@{ant-prefix}-input-group {
364
+ .forever-checkbox {
365
+ background: @zaui-contract-bg;
366
+ }
367
+ }
368
+ }
369
+
370
+ .pro-form-view-container {
371
+ padding: 4px 8px;
372
+ background: @zaui-contract-bg;
373
+ border-radius: 4px;
374
+ }
375
+ }
376
376
  }
@@ -3,7 +3,6 @@ interface Params {
3
3
  originalValue: any;
4
4
  value: any;
5
5
  form: FormInstance;
6
- name?: string | any[];
7
6
  equalWith?: (originalValue: any, currentValue: any) => boolean;
8
7
  }
9
8
  export declare const diffOriginal: (params: Params) => boolean;
@@ -1,31 +1,9 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import { isEqual, isFunction, isString } from 'lodash';
1
+ import { isEqual, isFunction } from 'lodash';
3
2
  var nullValue = [null, undefined, '']; // 输入框空值时可能存在的三种值 视为相等
4
- /** 将解构后的name值,反向转回names,例如 formData {a:1, b:2} names ['a', 'b'] 返回 [1,2] */
5
- var extractValues = function extractValues(form, pathString) {
6
- var _pathString;
7
- var result = [];
8
- var PrefixesName = isString(pathString) ? [] : pathString.slice(0, -1);
9
- if (isString(pathString)) {
10
- pathString.split('-').forEach(function (item) {
11
- result.push(form.getFieldValue([].concat(_toConsumableArray(PrefixesName), [item])));
12
- });
13
- return result;
14
- }
15
- (_pathString = pathString[pathString.length - 1]) === null || _pathString === void 0 ? void 0 : _pathString.split('-').forEach(function (item) {
16
- result.push(form.getFieldValue([].concat(_toConsumableArray(PrefixesName), [item])));
17
- });
18
- return result;
19
- };
20
3
  export var diffOriginal = function diffOriginal(params) {
21
- var _name$join;
22
4
  var originalValue = params.originalValue,
23
- _value = params.value,
24
- equalWith = params.equalWith,
25
- form = params.form,
26
- name = params.name;
27
- var isNames = Array.isArray(name) && ((_name$join = name.join(',')) === null || _name$join === void 0 ? void 0 : _name$join.includes('-')) || (name === null || name === void 0 ? void 0 : name.includes('-'));
28
- var value = !isNames ? _value : extractValues(form, name);
5
+ value = params.value,
6
+ equalWith = params.equalWith;
29
7
  // 支持传入自定义比较事件
30
8
  if (isFunction(equalWith)) {
31
9
  return !equalWith(originalValue, value);
@@ -40,8 +18,7 @@ export var diffOriginal = function diffOriginal(params) {
40
18
  });
41
19
  }
42
20
  if (!nullValue.includes(value) || !nullValue.includes(originalValue)) {
43
- var res = !isEqual(value, originalValue);
44
- return res;
21
+ return !isEqual(value, originalValue);
45
22
  }
46
23
  return false;
47
24
  };
@@ -19,8 +19,7 @@ export var useChanged = function useChanged(_ref) {
19
19
  originalValue: originalValue,
20
20
  value: value,
21
21
  form: form,
22
- equalWith: equalWith,
23
- name: namesStr || name
22
+ equalWith: equalWith
24
23
  });
25
24
  return [changed, originalValue];
26
25
  };
@@ -1,6 +1,6 @@
1
1
  import "antd/es/form/style";
2
2
  import _Form from "antd/es/form";
3
- import { get, isString } from 'lodash';
3
+ import { get } from 'lodash';
4
4
  import { diffOriginal } from './diffOriginal';
5
5
  var toNamePath = function toNamePath(name) {
6
6
  if (Array.isArray(name)) {
@@ -86,8 +86,8 @@ export var useListChanged = function useListChanged(params) {
86
86
  value: value,
87
87
  originalValue: originalValue,
88
88
  form: form,
89
- equalWith: equalWith,
90
- name: isString(namesStr) ? namesStr : originalName || name
89
+ equalWith: equalWith
90
+ // name: isString(namesStr) ? namesStr : originalName || name,
91
91
  });
92
92
  return [changed, originalValue];
93
93
  };
@@ -75,7 +75,7 @@ var DndWrapper = function DndWrapper(_ref2) {
75
75
  onDragEndGuard = _ref2.onDragEndGuard;
76
76
  var onDragStart = /*#__PURE__*/function () {
77
77
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref3) {
78
- var active, transformedValue, activeObject;
78
+ var active, _transformedValue, activeObject;
79
79
  return _regeneratorRuntime().wrap(function _callee$(_context) {
80
80
  while (1) switch (_context.prev = _context.next) {
81
81
  case 0:
@@ -85,8 +85,8 @@ var DndWrapper = function DndWrapper(_ref2) {
85
85
  break;
86
86
  }
87
87
  // 为数据源划分层级及parentId
88
- transformedValue = addLevelAndParentId(value, rowKey);
89
- activeObject = treeNodeFind(transformedValue, function (t) {
88
+ _transformedValue = addLevelAndParentId(value, rowKey);
89
+ activeObject = treeNodeFind(_transformedValue, function (t) {
90
90
  return t.rowKey === active.id;
91
91
  });
92
92
  _context.next = 6;
@@ -174,8 +174,9 @@ var DndWrapper = function DndWrapper(_ref2) {
174
174
  return _ref6.apply(this, arguments);
175
175
  };
176
176
  }();
177
+ var transformedValue = addLevelAndParentId(value, rowKey);
177
178
  // 将树平铺
178
- var flatTree = transformTreeToArray(value).map(function (item) {
179
+ var flatTree = transformTreeToArray(transformedValue).map(function (item) {
179
180
  return _objectSpread(_objectSpread({}, item), {}, {
180
181
  children: undefined
181
182
  });
@@ -1,3 +1,3 @@
1
1
  import type { DevToolsPropsType } from '../../propsType';
2
- declare const PrdTools: ({ onReset, onClose, setState, open, state, tableBorder, tableStripe, }: DevToolsPropsType) => import("react/jsx-runtime").JSX.Element;
3
- export default PrdTools;
2
+ declare const ProTools: ({ onReset, onClose, setState, open, state, tableBorder, tableStripe, }: DevToolsPropsType) => import("react/jsx-runtime").JSX.Element;
3
+ export default ProTools;
@@ -21,7 +21,7 @@ var connect = function connect(Component) {
21
21
  return ComponentWrapper;
22
22
  };
23
23
  var NewDrawer = connect(_Drawer);
24
- var PrdTools = function PrdTools(_ref) {
24
+ var ProTools = function ProTools(_ref) {
25
25
  var onReset = _ref.onReset,
26
26
  onClose = _ref.onClose,
27
27
  setState = _ref.setState,
@@ -266,4 +266,4 @@ var PrdTools = function PrdTools(_ref) {
266
266
  })]
267
267
  });
268
268
  };
269
- export default PrdTools;
269
+ export default ProTools;
@@ -1,2 +1 @@
1
- /// <reference types="typings" />
2
- export { default as PrdTools } from './PrdTools';
1
+ export { default as ProTools } from './ProTools';
@@ -1,2 +1 @@
1
- /// <reference path="../../../typings.d.ts" />;
2
- export { default as PrdTools } from './PrdTools';
1
+ export { default as ProTools } from './ProTools';
@@ -17,7 +17,7 @@ import { isEqual } from 'lodash';
17
17
  import classnames from 'classnames';
18
18
  import { getKebabCase, setThemes, setTableBorder, getMapKebabCase, getMapHumpCase } from './utils/index';
19
19
  import settingSvg from '../assets/setting.svg';
20
- import { PrdTools } from './component';
20
+ import { ProTools } from './component';
21
21
  import locale from '../locale';
22
22
  var defaultCacheTime = 1; // 配置保存时间为一天
23
23
  var defaultThemeConfig = {
@@ -183,7 +183,7 @@ var ProThemeTools = function ProThemeTools(_ref) {
183
183
  className: "setting-icon",
184
184
  src: settingSvg
185
185
  })
186
- }), _jsx(PrdTools, {
186
+ }), _jsx(ProTools, {
187
187
  prefixCls: prefixCls,
188
188
  onReset: onReset,
189
189
  onClose: toggle,
@@ -1,7 +1,7 @@
1
1
  @root-entry-name: 'default';
2
2
  @import (reference) '~antd/es/style/themes/index.less';
3
3
 
4
- @import '../component/PrdTools/style/index.less';
4
+ @import '../component/ProTools/style/index.less';
5
5
 
6
6
  .pro-theme-tools {
7
7
  display: flex;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { FormInstance } from 'antd';
3
+ import { NamePath } from 'antd/lib/form/interface';
4
+ interface Props {
5
+ name?: NamePath;
6
+ names?: NamePath[];
7
+ originalName?: NamePath;
8
+ originalNames?: NamePath[];
9
+ namesStr?: NamePath;
10
+ originalValues?: any;
11
+ form: FormInstance;
12
+ equalWith?: (preValue: any, curValue: any) => boolean | undefined;
13
+ [name: string]: any;
14
+ }
15
+ declare const ListChanged: React.FC<Props>;
16
+ export default ListChanged;
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ var _antd = require("antd");
14
+ var _lodash = require("lodash");
15
+ var _diffOriginal = require("../../../ProForm/utils/diffOriginal");
16
+ var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type"];
17
+ var toNamePath = function toNamePath(name) {
18
+ if (Array.isArray(name)) {
19
+ return name;
20
+ }
21
+ return [name];
22
+ };
23
+ var toNamePaths = function toNamePaths(names) {
24
+ return names.map(function (name) {
25
+ return toNamePath(name);
26
+ });
27
+ };
28
+ var getOriginalValue = function getOriginalValue(_ref) {
29
+ var namePath = _ref.namePath,
30
+ originalName = _ref.originalName,
31
+ originalNames = _ref.originalNames,
32
+ originalValues = _ref.originalValues,
33
+ rowKeyPath = _ref.rowKeyPath,
34
+ form = _ref.form;
35
+ if (!originalValues) {
36
+ return undefined;
37
+ }
38
+ if (rowKeyPath) {
39
+ var rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
40
+ var rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
41
+ var rowValue = form.getFieldValue(rowValueNamePath);
42
+ if (!rowValue) return undefined;
43
+ var keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
44
+ if (!keyValue) return undefined;
45
+ var originalValueList = (0, _lodash.get)(originalValues, originalName.slice(0, rowKeyPath.length - 2));
46
+ var originalValueRow = originalValueList.find(function (item) {
47
+ return item[rowKeyPath[rowKeyPath.length - 1]] === keyValue;
48
+ });
49
+ var originalValue;
50
+ if (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) {
51
+ var originalNamesValue = originalNames.map(function (originalName) {
52
+ return (0, _lodash.get)(originalValueRow, originalName.slice(rowKeyPath.length - 1));
53
+ });
54
+ // 有可能出现数组中全是undefined的情况 视为没有值
55
+ var fillUndefined = originalNamesValue.every(function (valItem) {
56
+ return valItem === undefined;
57
+ });
58
+ originalValue = fillUndefined ? undefined : originalNamesValue;
59
+ } else {
60
+ originalValue = (0, _lodash.get)(originalValueRow, originalName.slice(rowKeyPath.length - 1));
61
+ }
62
+ return originalValue;
63
+ }
64
+ // 这个方法是给editTable专用的 暂时不存在不传rowKey的情况
65
+ return (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
66
+ return (0, _lodash.get)(originalValues, originalName);
67
+ }) : (0, _lodash.get)(originalValues, originalName);
68
+ };
69
+ var ListChanged = function ListChanged(props) {
70
+ var name = props.name,
71
+ names = props.names,
72
+ namesStr = props.namesStr,
73
+ _props$originalName = props.originalName,
74
+ originalName = _props$originalName === void 0 ? name : _props$originalName,
75
+ _props$originalNames = props.originalNames,
76
+ originalNames = _props$originalNames === void 0 ? names : _props$originalNames,
77
+ originalValues = props.originalValues,
78
+ form = props.form,
79
+ equalWith = props.equalWith,
80
+ rowKeyPath = props.rowKeyPath,
81
+ children = props.children,
82
+ type = props.type,
83
+ rest = (0, _objectWithoutProperties2.default)(props, _excluded);
84
+ var namePath = toNamePath(namesStr || name);
85
+ var originalNamePath = toNamePath(originalName);
86
+ var originalNamePaths = originalNames && toNamePaths(originalNames);
87
+ var notWatch = !originalValues || ['FormList', 'ProEditTable'].includes(type);
88
+ var originalValue = !notWatch ? getOriginalValue({
89
+ namePath: namePath,
90
+ originalName: originalNamePath,
91
+ originalNames: originalNamePaths,
92
+ originalValues: originalValues,
93
+ rowKeyPath: rowKeyPath,
94
+ form: form
95
+ }) : undefined;
96
+ var noChange = !equalWith && (!originalValues || originalValue === undefined);
97
+ var changed = (0, _react.useMemo)(function () {
98
+ if (notWatch || noChange) return false;
99
+ return (0, _diffOriginal.diffOriginal)({
100
+ value: props.value,
101
+ originalValue: originalValue,
102
+ form: form,
103
+ equalWith: equalWith
104
+ // name: isString(namesStr) ? namesStr : originalName || name,
105
+ });
106
+ }, [props.value, originalValue]);
107
+ if (notWatch || noChange) {
108
+ return /*#__PURE__*/_react.default.isValidElement(children) && /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, children.props), rest));
109
+ }
110
+ return (0, _jsxRuntime.jsx)(_antd.Tooltip, {
111
+ open: changed ? undefined : false,
112
+ getPopupContainer: function getPopupContainer(target) {
113
+ return target.parentElement;
114
+ },
115
+ title: (0, _jsxRuntime.jsxs)(_antd.Space, {
116
+ children: ["\u521D\u59CB\u503C\uFF1A", /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, children), {}, {
117
+ // @ts-ignore
118
+ isView: true,
119
+ value: originalValue,
120
+ checked: type === 'Switch' ? originalValue : undefined
121
+ })) : undefined]
122
+ }),
123
+ children: (0, _jsxRuntime.jsx)("div", {
124
+ className: changed ? 'pro-form-item-changed' : '',
125
+ children: /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, children.props), rest)) : undefined
126
+ })
127
+ });
128
+ };
129
+ var _default = exports.default = ListChanged;
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
10
  var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
12
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
12
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
@@ -26,10 +25,10 @@ var _ProConfigProvider = require("../../../ProConfigProvider");
26
25
  var _Container = _interopRequireDefault(require("../../../ProForm/components/Container"));
27
26
  var _transformNames = _interopRequireDefault(require("../../../ProForm/utils/transformNames"));
28
27
  var _useFieldProps = require("../../../ProForm/utils/useFieldProps");
29
- var _useListChanged3 = require("../../../ProForm/utils/useListChanged");
30
28
  var _useRules = _interopRequireDefault(require("../../../ProForm/utils/useRules"));
31
29
  var _utils = require("../../../ProForm/utils");
32
30
  var _ConfirmWrapper = _interopRequireDefault(require("../../../ProForm/components/render/ConfirmWrapper"));
31
+ var _ListChanged = _interopRequireDefault(require("./ListChanged"));
33
32
  var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "equalWith", "className", "trim", "confirm"];
34
33
  /* eslint-disable prefer-destructuring */
35
34
  /* eslint-disable prefer-const */
@@ -492,21 +491,6 @@ var RenderField = function RenderField(_ref) {
492
491
  return _ref3.apply(this, arguments);
493
492
  };
494
493
  }();
495
- // 判断当前字段是否变更
496
- var _useListChanged = (0, _useListChanged3.useListChanged)({
497
- name: cellName,
498
- names: names,
499
- namesStr: [].concat((0, _toConsumableArray2.default)(baseName), [index, dataIndex]),
500
- rowKeyPath: [].concat((0, _toConsumableArray2.default)(baseName), [index, 'rowKey']),
501
- originalName: originalName,
502
- originalNames: originalNames,
503
- originalValues: originalValues,
504
- form: form,
505
- equalWith: equalWith
506
- }),
507
- _useListChanged2 = (0, _slicedToArray2.default)(_useListChanged, 2),
508
- changed = _useListChanged2[0],
509
- originalValue = _useListChanged2[1];
510
494
  var componentProps = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({
511
495
  form: form,
512
496
  name: cellName
@@ -552,16 +536,36 @@ var RenderField = function RenderField(_ref) {
552
536
  if (isView) {
553
537
  delete _formItemProps.rules;
554
538
  }
555
- var _className = (0, _classnames.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, className, className), 'pro-form-item-changed', changed));
539
+ var _className = (0, _classnames.default)((0, _defineProperty2.default)({}, className, className));
556
540
  var FormItem = null;
541
+ var FieldComponent = /*#__PURE__*/_react.default.isValidElement(TargetComponent) ? ( /*#__PURE__*/_react.default.cloneElement(TargetComponent, componentProps)) : (0, _jsxRuntime.jsx)(TargetComponent, (0, _objectSpread2.default)({}, componentProps));
542
+ if (originalValues) {
543
+ FieldComponent = (0, _jsxRuntime.jsx)(_ListChanged.default, {
544
+ name: cellName,
545
+ names: names,
546
+ namesStr: [].concat((0, _toConsumableArray2.default)(baseName), [index, dataIndex]),
547
+ rowKeyPath: [].concat((0, _toConsumableArray2.default)(baseName), [index, 'rowKey']),
548
+ originalName: originalName,
549
+ originalNames: originalNames,
550
+ originalValues: originalValues,
551
+ form: form,
552
+ equalWith: equalWith,
553
+ type: type,
554
+ onChange: _onChange,
555
+ children: FieldComponent
556
+ });
557
+ }
558
+ if ((_componentProps = componentProps) === null || _componentProps === void 0 ? void 0 : _componentProps.confirm) {
559
+ FieldComponent = (0, _jsxRuntime.jsx)(_ConfirmWrapper.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, componentProps), {}, {
560
+ children: FieldComponent
561
+ }));
562
+ }
557
563
  FormItem = TargetComponent ? (0, _jsxRuntime.jsx)(_antd.Form.Item, (0, _objectSpread2.default)((0, _objectSpread2.default)({
558
564
  validateFirst: true
559
565
  }, (0, _lodash.omit)(_formItemProps, ['render', 'cache', 'key', 'width', 'hiddenNames', 'name', 'onCell'])), {}, {
560
566
  className: _className,
561
567
  name: formNamePath ? cellName.slice((formNamePath === null || formNamePath === void 0 ? void 0 : formNamePath.length) - 1) : cellName,
562
- children: ((_componentProps = componentProps) === null || _componentProps === void 0 ? void 0 : _componentProps.confirm) ? (0, _jsxRuntime.jsx)(_ConfirmWrapper.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, componentProps), {}, {
563
- children: /*#__PURE__*/_react.default.isValidElement(TargetComponent) ? ( /*#__PURE__*/_react.default.cloneElement(TargetComponent, componentProps)) : (0, _jsxRuntime.jsx)(TargetComponent, (0, _objectSpread2.default)({}, componentProps))
564
- })) : /*#__PURE__*/_react.default.isValidElement(TargetComponent) ? ( /*#__PURE__*/_react.default.cloneElement(TargetComponent, componentProps)) : (0, _jsxRuntime.jsx)(TargetComponent, (0, _objectSpread2.default)({}, componentProps))
568
+ children: FieldComponent
565
569
  })) : (0, _jsxRuntime.jsx)(_Container.default, {
566
570
  viewEmpty: viewEmpty
567
571
  });
@@ -579,28 +583,9 @@ var RenderField = function RenderField(_ref) {
579
583
  }
580
584
  }));
581
585
  }
582
- var originalTitle = originalDiffTip && originalValues ? (0, _jsxRuntime.jsxs)(_antd.Space, {
583
- children: ["\u521D\u59CB\u503C\uFF1A", /*#__PURE__*/_react.default.isValidElement(TargetComponent) ? ( /*#__PURE__*/_react.default.cloneElement(TargetComponent, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, componentProps), {}, {
584
- isView: true,
585
- value: originalValue,
586
- checked: type === 'Switch' ? originalValue : undefined
587
- }))) : (0, _jsxRuntime.jsx)(TargetComponent, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, componentProps), {}, {
588
- isView: true,
589
- value: originalValue,
590
- checked: type === 'Switch' ? originalValue : undefined
591
- }))]
592
- }) : null;
593
586
  return (0, _jsxRuntime.jsx)(_useFieldProps.FieldProvider, {
594
587
  value: (_componentProps2 = componentProps) === null || _componentProps2 === void 0 ? void 0 : _componentProps2.otherProps,
595
- children: !originalTitle || ['FormList', 'ProEditTable'].includes(type) ? FormItem : (0, _jsxRuntime.jsx)(_antd.Tooltip, {
596
- title: originalTitle,
597
- placement: "topLeft",
598
- open: changed ? undefined : false,
599
- getPopupContainer: function getPopupContainer(target) {
600
- return target.parentElement;
601
- },
602
- children: FormItem
603
- })
588
+ children: FormItem
604
589
  });
605
590
  };
606
591
  var _default = exports.default = RenderField;