@zat-design/sisyphus-react 3.6.9-beta.4 → 3.6.10
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.
- package/dist/index.esm.css +41 -41
- package/dist/less.esm.css +41 -41
- package/es/ProEditTable/components/RenderField/index.js +46 -26
- package/es/ProForm/components/combination/ProCascader/index.js +14 -8
- package/es/ProForm/components/render/Render.js +39 -25
- package/es/ProForm/style/index.less +52 -52
- package/es/ProForm/utils/diffOriginal.d.ts +1 -0
- package/es/ProForm/utils/diffOriginal.js +27 -4
- package/es/ProForm/utils/index.d.ts +0 -6
- package/es/ProForm/utils/index.js +8 -57
- package/es/ProForm/utils/useChanged.js +2 -1
- package/es/ProForm/utils/useListChanged.js +3 -3
- package/es/ProTable/components/FormatColumn/index.js +16 -0
- package/es/ProTable/propsType.d.ts +4 -0
- package/es/ProThemeTools/component/{ProTools → PrdTools}/index.d.ts +2 -2
- package/es/ProThemeTools/component/{ProTools → PrdTools}/index.js +2 -2
- package/es/ProThemeTools/component/index.d.ts +2 -1
- package/es/ProThemeTools/component/index.js +2 -1
- package/es/ProThemeTools/index.js +2 -2
- package/es/ProThemeTools/style/index.less +1 -1
- package/lib/ProEditTable/components/RenderField/index.js +41 -25
- package/lib/ProForm/components/combination/ProCascader/index.js +12 -6
- package/lib/ProForm/components/render/Render.js +37 -25
- package/lib/ProForm/style/index.less +52 -52
- package/lib/ProForm/utils/diffOriginal.d.ts +1 -0
- package/lib/ProForm/utils/diffOriginal.js +27 -3
- package/lib/ProForm/utils/index.d.ts +0 -6
- package/lib/ProForm/utils/index.js +8 -59
- package/lib/ProForm/utils/useChanged.js +2 -1
- package/lib/ProForm/utils/useListChanged.js +2 -2
- package/lib/ProTable/components/FormatColumn/index.js +16 -0
- package/lib/ProTable/propsType.d.ts +4 -0
- package/lib/ProThemeTools/component/{ProTools → PrdTools}/index.d.ts +2 -2
- package/lib/ProThemeTools/component/{ProTools → PrdTools}/index.js +2 -2
- package/lib/ProThemeTools/component/index.d.ts +2 -1
- package/lib/ProThemeTools/component/index.js +3 -3
- package/lib/ProThemeTools/index.js +1 -1
- package/lib/ProThemeTools/style/index.less +1 -1
- package/package.json +1 -1
- package/es/ProEditTable/components/RenderField/ListChanged.d.ts +0 -16
- package/es/ProEditTable/components/RenderField/ListChanged.js +0 -124
- package/es/ProForm/components/render/Changed.d.ts +0 -14
- package/es/ProForm/components/render/Changed.js +0 -64
- package/lib/ProEditTable/components/RenderField/ListChanged.d.ts +0 -16
- package/lib/ProEditTable/components/RenderField/ListChanged.js +0 -129
- package/lib/ProForm/components/render/Changed.d.ts +0 -14
- package/lib/ProForm/components/render/Changed.js +0 -69
- /package/es/ProThemeTools/component/{ProTools → PrdTools}/style/index.less +0 -0
- /package/lib/ProThemeTools/component/{ProTools → PrdTools}/style/index.less +0 -0
|
@@ -50,12 +50,6 @@ export declare const isNullArray: (arr: any) => boolean;
|
|
|
50
50
|
*/
|
|
51
51
|
export declare const isEmptyArray: (arr: any) => boolean;
|
|
52
52
|
export declare function toArray<T>(value?: T | T[] | null): T[];
|
|
53
|
-
/**
|
|
54
|
-
* names值合并
|
|
55
|
-
* @param obj AnyObject
|
|
56
|
-
* @returns AnyObject
|
|
57
|
-
*/
|
|
58
|
-
export declare function processHyphenKeys(obj: AnyObject): AnyObject;
|
|
59
53
|
/**
|
|
60
54
|
* 初始化值names值合并
|
|
61
55
|
* @param obj AnyObject
|
|
@@ -11,14 +11,11 @@ exports.getAllNamePath = exports.findOptionByValue = void 0;
|
|
|
11
11
|
exports.getArrayBeforeNumber = getArrayBeforeNumber;
|
|
12
12
|
exports.hasRowKey = exports.getLayout = exports.getDecimalDigits = void 0;
|
|
13
13
|
exports.initialValuesToNames = initialValuesToNames;
|
|
14
|
-
exports.parseNamePath = exports.isUpperCase = exports.isTrim = exports.isSelect = exports.isNullValue = exports.isNullArray = exports.isNotFullArray = exports.isEmptyArray = void 0;
|
|
15
|
-
exports.processHyphenKeys = processHyphenKeys;
|
|
16
|
-
exports.splitNameStr = void 0;
|
|
14
|
+
exports.splitNameStr = exports.parseNamePath = exports.isUpperCase = exports.isTrim = exports.isSelect = exports.isNullValue = exports.isNullArray = exports.isNotFullArray = exports.isEmptyArray = void 0;
|
|
17
15
|
exports.toArray = toArray;
|
|
18
16
|
exports.weedOutProps = exports.view = exports.useControlled = void 0;
|
|
19
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
20
17
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
21
|
-
var
|
|
18
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
22
19
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
23
20
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
24
21
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -265,54 +262,6 @@ function toArray(value) {
|
|
|
265
262
|
}
|
|
266
263
|
return Array.isArray(value) ? value : [value];
|
|
267
264
|
}
|
|
268
|
-
/**
|
|
269
|
-
* names值合并
|
|
270
|
-
* @param obj AnyObject
|
|
271
|
-
* @returns AnyObject
|
|
272
|
-
*/
|
|
273
|
-
function processHyphenKeys(obj) {
|
|
274
|
-
var newObj = (0, _objectSpread2.default)({}, obj);
|
|
275
|
-
var keys = Object.keys(obj);
|
|
276
|
-
for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
|
|
277
|
-
var key = _keys[_i];
|
|
278
|
-
if (key.includes('-')) {
|
|
279
|
-
var keyParts = key.split('-');
|
|
280
|
-
var shouldCombine = true;
|
|
281
|
-
var combinedArray = [];
|
|
282
|
-
var _iterator = (0, _createForOfIteratorHelper2.default)(keyParts),
|
|
283
|
-
_step;
|
|
284
|
-
try {
|
|
285
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
286
|
-
var part = _step.value;
|
|
287
|
-
if (obj.hasOwnProperty(part)) {
|
|
288
|
-
combinedArray.push(obj[part]);
|
|
289
|
-
} else {
|
|
290
|
-
shouldCombine = false;
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
} catch (err) {
|
|
295
|
-
_iterator.e(err);
|
|
296
|
-
} finally {
|
|
297
|
-
_iterator.f();
|
|
298
|
-
}
|
|
299
|
-
if (shouldCombine) {
|
|
300
|
-
newObj[key] = combinedArray;
|
|
301
|
-
} else {
|
|
302
|
-
newObj[key] = undefined;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
// 匹配数组的namePath,只匹配到1层
|
|
306
|
-
if (key.includes('_')) {
|
|
307
|
-
var _keyParts = key.split('_')[0];
|
|
308
|
-
// 校验值是否存在,解决names多传额外空值报错
|
|
309
|
-
newObj[key] = (0, _lodash.isObject)(newObj[_keyParts]) ? Object.values(newObj[_keyParts]).filter(function (val) {
|
|
310
|
-
return val !== null && val !== undefined && val !== '';
|
|
311
|
-
}) : [];
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return (0, _lodash.cloneDeep)(newObj);
|
|
315
|
-
}
|
|
316
265
|
/**
|
|
317
266
|
* 初始化值names值合并
|
|
318
267
|
* @param obj AnyObject
|
|
@@ -478,11 +427,11 @@ var parseNamePath = exports.parseNamePath = function parseNamePath(input) {
|
|
|
478
427
|
};
|
|
479
428
|
/** 解析namePath */
|
|
480
429
|
function findNamesKeyInArray(arr, key) {
|
|
481
|
-
var
|
|
482
|
-
|
|
430
|
+
var _iterator = (0, _createForOfIteratorHelper2.default)(arr),
|
|
431
|
+
_step;
|
|
483
432
|
try {
|
|
484
|
-
for (
|
|
485
|
-
var item =
|
|
433
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
434
|
+
var item = _step.value;
|
|
486
435
|
if (!item.includes('_')) {
|
|
487
436
|
return null;
|
|
488
437
|
}
|
|
@@ -491,9 +440,9 @@ function findNamesKeyInArray(arr, key) {
|
|
|
491
440
|
}
|
|
492
441
|
}
|
|
493
442
|
} catch (err) {
|
|
494
|
-
|
|
443
|
+
_iterator.e(err);
|
|
495
444
|
} finally {
|
|
496
|
-
|
|
445
|
+
_iterator.f();
|
|
497
446
|
}
|
|
498
447
|
return null;
|
|
499
448
|
}
|
|
@@ -91,8 +91,8 @@ var useListChanged = exports.useListChanged = function useListChanged(params) {
|
|
|
91
91
|
value: value,
|
|
92
92
|
originalValue: originalValue,
|
|
93
93
|
form: form,
|
|
94
|
-
equalWith: equalWith
|
|
95
|
-
|
|
94
|
+
equalWith: equalWith,
|
|
95
|
+
name: (0, _lodash.isString)(namesStr) ? namesStr : originalName || name
|
|
96
96
|
});
|
|
97
97
|
return [changed, originalValue];
|
|
98
98
|
};
|
|
@@ -197,6 +197,22 @@ var formatColumn = exports.formatColumn = function formatColumn(column, original
|
|
|
197
197
|
var renderValue = (0, _getEnumLabel.default)(realCode, value, valueType === 'enumCodeName');
|
|
198
198
|
var originalValue = (0, _utils2.getOriginalValue)(value, record, originalObj, rowKey, dataIndex);
|
|
199
199
|
var originalRenderValue = (0, _getEnumLabel.default)(realCode, originalValue, valueType === 'enumCodeName');
|
|
200
|
+
if (Array.isArray(column === null || column === void 0 ? void 0 : column.codeValues) && !realCode) {
|
|
201
|
+
var _column$codeValues$fi;
|
|
202
|
+
var labelName = column === null || column === void 0 ? void 0 : (_column$codeValues$fi = column.codeValues.find(function (item) {
|
|
203
|
+
return item.value === value;
|
|
204
|
+
})) === null || _column$codeValues$fi === void 0 ? void 0 : _column$codeValues$fi.label;
|
|
205
|
+
if (valueType === 'enumName') {
|
|
206
|
+
renderValue = (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
207
|
+
children: labelName || '-'
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
if (valueType === 'enumCodeName') {
|
|
211
|
+
renderValue = (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
212
|
+
children: labelName ? "".concat(value, "-").concat(labelName) : labelName
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
200
216
|
var node = (0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
201
217
|
size: 8,
|
|
202
218
|
children: [prefixNode(value, record, index), renderValue, suffixNode(value, record, index)]
|
|
@@ -26,6 +26,10 @@ export interface ProTableColumn extends Omit<ColumnType<any>, 'dataIndex'> {
|
|
|
26
26
|
format?: string;
|
|
27
27
|
precision?: number;
|
|
28
28
|
code?: string | string[] | ((text: any, record: any) => string);
|
|
29
|
+
codeValues?: {
|
|
30
|
+
label: string;
|
|
31
|
+
value: string | number;
|
|
32
|
+
}[];
|
|
29
33
|
copyable?: boolean;
|
|
30
34
|
originalDiffTip?: boolean;
|
|
31
35
|
prefix?: string | ReactNode | ((value: any, record?: any, index?: number) => any);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DevToolsPropsType } from '../../propsType';
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const PrdTools: ({ onReset, onClose, setState, open, state, tableBorder, tableStripe, }: DevToolsPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default PrdTools;
|
|
@@ -21,7 +21,7 @@ var connect = function connect(Component) {
|
|
|
21
21
|
return ComponentWrapper;
|
|
22
22
|
};
|
|
23
23
|
var NewDrawer = connect(_antd.Drawer);
|
|
24
|
-
var
|
|
24
|
+
var PrdTools = function PrdTools(_ref) {
|
|
25
25
|
var onReset = _ref.onReset,
|
|
26
26
|
onClose = _ref.onClose,
|
|
27
27
|
setState = _ref.setState,
|
|
@@ -266,4 +266,4 @@ var ProTools = function ProTools(_ref) {
|
|
|
266
266
|
})]
|
|
267
267
|
});
|
|
268
268
|
};
|
|
269
|
-
var _default = exports.default =
|
|
269
|
+
var _default = exports.default = PrdTools;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="typings" />
|
|
2
|
+
export { default as PrdTools } from './PrdTools';
|
|
@@ -4,10 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "PrdTools", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function get() {
|
|
10
|
-
return
|
|
10
|
+
return _PrdTools.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
var
|
|
13
|
+
var _PrdTools = _interopRequireDefault(require("./PrdTools"));
|
|
@@ -186,7 +186,7 @@ var ProThemeTools = function ProThemeTools(_ref) {
|
|
|
186
186
|
className: "setting-icon",
|
|
187
187
|
src: _setting.default
|
|
188
188
|
})
|
|
189
|
-
}), (0, _jsxRuntime.jsx)(_component.
|
|
189
|
+
}), (0, _jsxRuntime.jsx)(_component.PrdTools, {
|
|
190
190
|
prefixCls: prefixCls,
|
|
191
191
|
onReset: onReset,
|
|
192
192
|
onClose: toggle,
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
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;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import "antd/es/space/style";
|
|
2
|
-
import _Space from "antd/es/space";
|
|
3
|
-
import "antd/es/tooltip/style";
|
|
4
|
-
import _Tooltip from "antd/es/tooltip";
|
|
5
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
|
-
var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type"];
|
|
8
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
import React, { useMemo } from 'react';
|
|
10
|
-
import { get } from 'lodash';
|
|
11
|
-
import { diffOriginal } from '../../../ProForm/utils/diffOriginal';
|
|
12
|
-
var toNamePath = function toNamePath(name) {
|
|
13
|
-
if (Array.isArray(name)) {
|
|
14
|
-
return name;
|
|
15
|
-
}
|
|
16
|
-
return [name];
|
|
17
|
-
};
|
|
18
|
-
var toNamePaths = function toNamePaths(names) {
|
|
19
|
-
return names.map(function (name) {
|
|
20
|
-
return toNamePath(name);
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
var getOriginalValue = function getOriginalValue(_ref) {
|
|
24
|
-
var namePath = _ref.namePath,
|
|
25
|
-
originalName = _ref.originalName,
|
|
26
|
-
originalNames = _ref.originalNames,
|
|
27
|
-
originalValues = _ref.originalValues,
|
|
28
|
-
rowKeyPath = _ref.rowKeyPath,
|
|
29
|
-
form = _ref.form;
|
|
30
|
-
if (!originalValues) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
if (rowKeyPath) {
|
|
34
|
-
var rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
|
|
35
|
-
var rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
|
|
36
|
-
var rowValue = form.getFieldValue(rowValueNamePath);
|
|
37
|
-
if (!rowValue) return undefined;
|
|
38
|
-
var keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
|
|
39
|
-
if (!keyValue) return undefined;
|
|
40
|
-
var originalValueList = get(originalValues, originalName.slice(0, rowKeyPath.length - 2));
|
|
41
|
-
var originalValueRow = originalValueList.find(function (item) {
|
|
42
|
-
return item[rowKeyPath[rowKeyPath.length - 1]] === keyValue;
|
|
43
|
-
});
|
|
44
|
-
var originalValue;
|
|
45
|
-
if (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) {
|
|
46
|
-
var originalNamesValue = originalNames.map(function (originalName) {
|
|
47
|
-
return get(originalValueRow, originalName.slice(rowKeyPath.length - 1));
|
|
48
|
-
});
|
|
49
|
-
// 有可能出现数组中全是undefined的情况 视为没有值
|
|
50
|
-
var fillUndefined = originalNamesValue.every(function (valItem) {
|
|
51
|
-
return valItem === undefined;
|
|
52
|
-
});
|
|
53
|
-
originalValue = fillUndefined ? undefined : originalNamesValue;
|
|
54
|
-
} else {
|
|
55
|
-
originalValue = get(originalValueRow, originalName.slice(rowKeyPath.length - 1));
|
|
56
|
-
}
|
|
57
|
-
return originalValue;
|
|
58
|
-
}
|
|
59
|
-
// 这个方法是给editTable专用的 暂时不存在不传rowKey的情况
|
|
60
|
-
return (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
|
|
61
|
-
return get(originalValues, originalName);
|
|
62
|
-
}) : get(originalValues, originalName);
|
|
63
|
-
};
|
|
64
|
-
var ListChanged = function ListChanged(props) {
|
|
65
|
-
var name = props.name,
|
|
66
|
-
names = props.names,
|
|
67
|
-
namesStr = props.namesStr,
|
|
68
|
-
_props$originalName = props.originalName,
|
|
69
|
-
originalName = _props$originalName === void 0 ? name : _props$originalName,
|
|
70
|
-
_props$originalNames = props.originalNames,
|
|
71
|
-
originalNames = _props$originalNames === void 0 ? names : _props$originalNames,
|
|
72
|
-
originalValues = props.originalValues,
|
|
73
|
-
form = props.form,
|
|
74
|
-
equalWith = props.equalWith,
|
|
75
|
-
rowKeyPath = props.rowKeyPath,
|
|
76
|
-
children = props.children,
|
|
77
|
-
type = props.type,
|
|
78
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
79
|
-
var namePath = toNamePath(namesStr || name);
|
|
80
|
-
var originalNamePath = toNamePath(originalName);
|
|
81
|
-
var originalNamePaths = originalNames && toNamePaths(originalNames);
|
|
82
|
-
var notWatch = !originalValues || ['FormList', 'ProEditTable'].includes(type);
|
|
83
|
-
var originalValue = !notWatch ? getOriginalValue({
|
|
84
|
-
namePath: namePath,
|
|
85
|
-
originalName: originalNamePath,
|
|
86
|
-
originalNames: originalNamePaths,
|
|
87
|
-
originalValues: originalValues,
|
|
88
|
-
rowKeyPath: rowKeyPath,
|
|
89
|
-
form: form
|
|
90
|
-
}) : undefined;
|
|
91
|
-
var noChange = !equalWith && (!originalValues || originalValue === undefined);
|
|
92
|
-
var changed = useMemo(function () {
|
|
93
|
-
if (notWatch || noChange) return false;
|
|
94
|
-
return diffOriginal({
|
|
95
|
-
value: props.value,
|
|
96
|
-
originalValue: originalValue,
|
|
97
|
-
form: form,
|
|
98
|
-
equalWith: equalWith
|
|
99
|
-
// name: isString(namesStr) ? namesStr : originalName || name,
|
|
100
|
-
});
|
|
101
|
-
}, [props.value, originalValue]);
|
|
102
|
-
if (notWatch || noChange) {
|
|
103
|
-
return /*#__PURE__*/React.isValidElement(children) && /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), rest));
|
|
104
|
-
}
|
|
105
|
-
return _jsx(_Tooltip, {
|
|
106
|
-
open: changed ? undefined : false,
|
|
107
|
-
getPopupContainer: function getPopupContainer(target) {
|
|
108
|
-
return target.parentElement;
|
|
109
|
-
},
|
|
110
|
-
title: _jsxs(_Space, {
|
|
111
|
-
children: ["\u521D\u59CB\u503C\uFF1A", /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children), {}, {
|
|
112
|
-
// @ts-ignore
|
|
113
|
-
isView: true,
|
|
114
|
-
value: originalValue,
|
|
115
|
-
checked: type === 'Switch' ? originalValue : undefined
|
|
116
|
-
})) : undefined]
|
|
117
|
-
}),
|
|
118
|
-
children: _jsx("div", {
|
|
119
|
-
className: changed ? 'pro-form-item-changed' : '',
|
|
120
|
-
children: /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), rest)) : undefined
|
|
121
|
-
})
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
export default ListChanged;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FormInstance } from 'antd';
|
|
2
|
-
import { NamePath } from 'antd/lib/form/interface';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
interface Props {
|
|
5
|
-
name?: NamePath;
|
|
6
|
-
names?: NamePath[];
|
|
7
|
-
namesStr?: string;
|
|
8
|
-
originalValues?: any;
|
|
9
|
-
form: FormInstance;
|
|
10
|
-
equalWith?: (preValue: any, curValue: any) => boolean | undefined;
|
|
11
|
-
[name: string]: any;
|
|
12
|
-
}
|
|
13
|
-
declare const Changed: React.FC<Props>;
|
|
14
|
-
export default Changed;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import "antd/es/space/style";
|
|
2
|
-
import _Space from "antd/es/space";
|
|
3
|
-
import "antd/es/tooltip/style";
|
|
4
|
-
import _Tooltip from "antd/es/tooltip";
|
|
5
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
|
-
var _excluded = ["name", "names", "namesStr", "originalValues", "form", "equalWith", "children", "type", "originalDiffTip"];
|
|
8
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { get } from 'lodash';
|
|
10
|
-
import React, { useMemo } from 'react';
|
|
11
|
-
import { diffOriginal } from '../../utils/diffOriginal';
|
|
12
|
-
var Changed = function Changed(props) {
|
|
13
|
-
var name = props.name,
|
|
14
|
-
names = props.names,
|
|
15
|
-
namesStr = props.namesStr,
|
|
16
|
-
originalValues = props.originalValues,
|
|
17
|
-
form = props.form,
|
|
18
|
-
equalWith = props.equalWith,
|
|
19
|
-
children = props.children,
|
|
20
|
-
type = props.type,
|
|
21
|
-
originalDiffTip = props.originalDiffTip,
|
|
22
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
23
|
-
// 不渲染tooltip
|
|
24
|
-
var notWatch = !originalDiffTip || ['FormList', 'ProEditTable'].includes(type);
|
|
25
|
-
var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
|
|
26
|
-
return get(originalValues, name);
|
|
27
|
-
}) : get(originalValues, name);
|
|
28
|
-
var noChange = !equalWith && (!originalValues || originalValue === undefined);
|
|
29
|
-
var changed = useMemo(function () {
|
|
30
|
-
if (notWatch || noChange) return false;
|
|
31
|
-
return diffOriginal({
|
|
32
|
-
originalValue: originalValue,
|
|
33
|
-
value: props.value,
|
|
34
|
-
form: form,
|
|
35
|
-
equalWith: equalWith
|
|
36
|
-
// name: namesStr || name,
|
|
37
|
-
});
|
|
38
|
-
}, [notWatch, noChange, props.value, originalValue]);
|
|
39
|
-
var tipContent = useMemo(function () {
|
|
40
|
-
if (notWatch || noChange) return undefined;
|
|
41
|
-
return /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), {}, {
|
|
42
|
-
isView: true,
|
|
43
|
-
value: originalValue,
|
|
44
|
-
checked: type === 'Switch' ? originalValue : undefined
|
|
45
|
-
})) : undefined;
|
|
46
|
-
}, [originalValue, children]);
|
|
47
|
-
if (notWatch || noChange) {
|
|
48
|
-
return /*#__PURE__*/React.isValidElement(children) && /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), rest));
|
|
49
|
-
}
|
|
50
|
-
return _jsx(_Tooltip, {
|
|
51
|
-
open: changed ? undefined : false,
|
|
52
|
-
getPopupContainer: function getPopupContainer(target) {
|
|
53
|
-
return target.parentElement;
|
|
54
|
-
},
|
|
55
|
-
title: _jsxs(_Space, {
|
|
56
|
-
children: ["\u521D\u59CB\u503C\uFF1A", tipContent]
|
|
57
|
-
}),
|
|
58
|
-
children: _jsx("div", {
|
|
59
|
-
className: changed ? 'pro-form-item-changed' : '',
|
|
60
|
-
children: /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), rest)) : undefined
|
|
61
|
-
})
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
export default Changed;
|
|
@@ -1,16 +0,0 @@
|
|
|
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;
|
|
@@ -1,129 +0,0 @@
|
|
|
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;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FormInstance } from 'antd';
|
|
2
|
-
import { NamePath } from 'antd/lib/form/interface';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
interface Props {
|
|
5
|
-
name?: NamePath;
|
|
6
|
-
names?: NamePath[];
|
|
7
|
-
namesStr?: string;
|
|
8
|
-
originalValues?: any;
|
|
9
|
-
form: FormInstance;
|
|
10
|
-
equalWith?: (preValue: any, curValue: any) => boolean | undefined;
|
|
11
|
-
[name: string]: any;
|
|
12
|
-
}
|
|
13
|
-
declare const Changed: React.FC<Props>;
|
|
14
|
-
export default Changed;
|