@zat-design/sisyphus-react 3.4.7 → 3.4.8
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 +6 -1
- package/dist/less.esm.css +6 -1
- package/es/ProEditTable/components/RenderField/index.js +4 -8
- package/es/ProEditTable/style/index.less +1 -1
- package/es/ProForm/components/base/TextArea/index.d.ts +1 -0
- package/es/ProForm/components/base/TextArea/index.js +4 -2
- package/es/ProForm/components/combination/FormList/components/BlockFields.d.ts +1 -1
- package/es/ProForm/components/combination/FormList/index.js +1 -1
- package/es/ProForm/components/combination/FormList/propsType.d.ts +1 -1
- package/es/ProForm/components/combination/FormList/utils.js +2 -3
- package/es/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.js +2 -2
- package/es/ProForm/components/combination/Group/index.d.ts +8 -2
- package/es/ProForm/components/combination/Group/index.js +58 -76
- package/es/ProForm/components/combination/Group/propsType.d.ts +27 -14
- package/es/ProForm/components/combination/Group/utils.d.ts +60 -7
- package/es/ProForm/components/combination/Group/utils.js +209 -19
- package/es/ProForm/components/combination/ProModalSelect/index.js +35 -29
- package/es/ProForm/components/combination/_Group/index.d.ts +4 -0
- package/es/ProForm/components/combination/_Group/index.js +109 -0
- package/es/ProForm/components/combination/_Group/propsType.d.ts +35 -0
- package/es/ProForm/components/combination/_Group/utils.d.ts +10 -0
- package/es/ProForm/components/combination/_Group/utils.js +46 -0
- package/es/ProForm/components/render/Render.js +10 -8
- package/es/ProForm/components/render/propsType.d.ts +2 -2
- package/es/ProForm/style/index.less +7 -0
- package/es/ProForm/utils/diffOriginal.js +2 -1
- package/es/ProForm/utils/transformNames.js +3 -10
- package/es/ProForm/utils/useDeepCompareMemo.d.ts +2 -0
- package/es/ProForm/utils/useDeepCompareMemo.js +14 -0
- package/es/ProForm/utils/useListChanged.js +2 -2
- package/es/ProForm/utils/useRules.js +2 -20
- package/es/global.less +27 -8
- package/es/locale/zh_CN.js +1 -1
- package/lib/ProEditTable/components/RenderField/index.js +4 -8
- package/lib/ProEditTable/style/index.less +1 -1
- package/lib/ProForm/components/base/TextArea/index.d.ts +1 -0
- package/lib/ProForm/components/base/TextArea/index.js +4 -2
- package/lib/ProForm/components/combination/FormList/components/BlockFields.d.ts +1 -1
- package/lib/ProForm/components/combination/FormList/index.js +1 -1
- package/lib/ProForm/components/combination/FormList/propsType.d.ts +1 -1
- package/lib/ProForm/components/combination/FormList/utils.js +2 -3
- package/lib/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.js +2 -2
- package/lib/ProForm/components/combination/Group/index.d.ts +8 -2
- package/lib/ProForm/components/combination/Group/index.js +57 -72
- package/lib/ProForm/components/combination/Group/propsType.d.ts +27 -14
- package/lib/ProForm/components/combination/Group/utils.d.ts +60 -7
- package/lib/ProForm/components/combination/Group/utils.js +210 -20
- package/lib/ProForm/components/combination/ProModalSelect/index.js +35 -29
- package/lib/ProForm/components/combination/_Group/index.d.ts +4 -0
- package/lib/ProForm/components/combination/_Group/index.js +113 -0
- package/lib/ProForm/components/combination/_Group/propsType.d.ts +35 -0
- package/lib/ProForm/components/combination/_Group/utils.d.ts +10 -0
- package/lib/ProForm/components/combination/_Group/utils.js +53 -0
- package/lib/ProForm/components/render/Render.js +9 -7
- package/lib/ProForm/components/render/propsType.d.ts +2 -2
- package/lib/ProForm/style/index.less +7 -0
- package/lib/ProForm/utils/diffOriginal.js +2 -1
- package/lib/ProForm/utils/transformNames.js +2 -9
- package/lib/ProForm/utils/useDeepCompareMemo.d.ts +2 -0
- package/lib/ProForm/utils/useDeepCompareMemo.js +20 -0
- package/lib/ProForm/utils/useListChanged.js +1 -1
- package/lib/ProForm/utils/useRules.js +2 -20
- package/lib/global.less +27 -8
- package/lib/locale/zh_CN.js +1 -1
- package/package.json +1 -1
- package/es/ProForm/components/combination/GroupCopy/index.d.ts +0 -10
- package/es/ProForm/components/combination/GroupCopy/index.js +0 -84
- package/es/ProForm/components/combination/GroupCopy/propsType.d.ts +0 -47
- package/es/ProForm/components/combination/GroupCopy/utils.d.ts +0 -53
- package/es/ProForm/components/combination/GroupCopy/utils.js +0 -180
- package/lib/ProForm/components/combination/GroupCopy/index.d.ts +0 -10
- package/lib/ProForm/components/combination/GroupCopy/index.js +0 -91
- package/lib/ProForm/components/combination/GroupCopy/propsType.d.ts +0 -47
- package/lib/ProForm/components/combination/GroupCopy/utils.d.ts +0 -53
- package/lib/ProForm/components/combination/GroupCopy/utils.js +0 -187
- /package/es/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.d.ts +0 -0
- /package/es/ProForm/components/combination/{GroupCopy → _Group}/propsType.js +0 -0
- /package/es/ProForm/components/combination/{GroupCopy → _Group}/style/index.less +0 -0
- /package/lib/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.d.ts +0 -0
- /package/lib/ProForm/components/combination/{GroupCopy → _Group}/propsType.js +0 -0
- /package/lib/ProForm/components/combination/{GroupCopy → _Group}/style/index.less +0 -0
|
@@ -28,7 +28,7 @@ import { ProEditTableProps } from '../../../ProEditTable/propsType';
|
|
|
28
28
|
import { ProTreeModalProps } from '../../../ProTreeModal/propsType';
|
|
29
29
|
import { ProUploadProps } from '../../../ProUpload/propsType';
|
|
30
30
|
import { ProTreeProps } from '../../../ProTree/propsType';
|
|
31
|
-
import { GroupProps } from '../combination/Group/propsType';
|
|
31
|
+
import { GroupProps as GroupCopyProps } from '../combination/Group/propsType';
|
|
32
32
|
import { ProCollapseProps } from '../../../ProLayout/components/ProCollapse/PropTypes';
|
|
33
33
|
import { DistributiveOmit } from '../../propsType';
|
|
34
34
|
export type ComponentMap = keyof typeof componentMap;
|
|
@@ -159,7 +159,7 @@ export type ColumnPropsMap<Values = any, T = 'ProForm'> = {
|
|
|
159
159
|
fieldProps?: FieldProps<ProTreeProps, Values, T>;
|
|
160
160
|
} | {
|
|
161
161
|
type?: 'Group';
|
|
162
|
-
fieldProps?:
|
|
162
|
+
fieldProps?: GroupCopyProps | ReactiveFunction<Values, GroupCopyProps>;
|
|
163
163
|
} | {
|
|
164
164
|
type?: 'ProCollapse';
|
|
165
165
|
fieldProps?: ProCollapseProps | ReactiveFunction<Values, ProCollapseProps>;
|
|
@@ -140,6 +140,13 @@
|
|
|
140
140
|
|
|
141
141
|
// 地址组件
|
|
142
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
|
+
|
|
143
150
|
& > .pro-address {
|
|
144
151
|
.@{ant-prefix}-select-selector,
|
|
145
152
|
.@{ant-prefix}-input-affix-wrapper,
|
|
@@ -40,7 +40,8 @@ export var diffOriginal = function diffOriginal(params) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
if (!nullValue.includes(value) || !nullValue.includes(originalValue)) {
|
|
43
|
-
|
|
43
|
+
var res = !isEqual(value, originalValue);
|
|
44
|
+
return res;
|
|
44
45
|
}
|
|
45
46
|
return false;
|
|
46
47
|
};
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
import { union
|
|
1
|
+
import { union } from 'lodash';
|
|
2
2
|
import { transformValue } from './transformValue';
|
|
3
3
|
var transformNames = function transformNames(formItem, form, names, fieldName, type) {
|
|
4
|
-
var _names2, _names3, _names3$;
|
|
5
4
|
var _ref = formItem || {},
|
|
6
5
|
normalize = _ref.normalize,
|
|
7
6
|
getValueProps = _ref.getValueProps,
|
|
8
7
|
_shouldUpdate2 = _ref.shouldUpdate;
|
|
9
|
-
|
|
10
|
-
if (!((_names2 = _names) === null || _names2 === void 0 ? void 0 : _names2.length)) {
|
|
8
|
+
if (!(names === null || names === void 0 ? void 0 : names.length)) {
|
|
11
9
|
return {};
|
|
12
10
|
}
|
|
13
11
|
// 当在formList场景下,给transformValue函数的setFiledProps的name, 需要全namePath
|
|
14
12
|
var _fieldName = Array.isArray(formItem === null || formItem === void 0 ? void 0 : formItem.name) ? union(formItem === null || formItem === void 0 ? void 0 : formItem.namePath, formItem === null || formItem === void 0 ? void 0 : formItem.name) : fieldName;
|
|
15
|
-
|
|
16
|
-
_names = _names.map(function (item) {
|
|
17
|
-
return union(formItem === null || formItem === void 0 ? void 0 : formItem.namePath, item);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
var _transformValue = transformValue(_names, form, _fieldName, normalize, getValueProps),
|
|
13
|
+
var _transformValue = transformValue(names, form, _fieldName, normalize, getValueProps),
|
|
21
14
|
_normalize = _transformValue.normalize,
|
|
22
15
|
_getValueProps = _transformValue.getValueProps,
|
|
23
16
|
_shouldUpdate = _transformValue.shouldUpdate;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { isEqualWith } from 'lodash';
|
|
3
|
+
import { customEqualForFun } from '.';
|
|
4
|
+
/** 深度比较依赖变化memo */
|
|
5
|
+
export var useDeepCompareMemo = function useDeepCompareMemo(fun, depList) {
|
|
6
|
+
var lastDependency = useRef(); // 上一次的依赖
|
|
7
|
+
var lastRes = useRef(); // 上一次的结果
|
|
8
|
+
if (!isEqualWith(depList, lastDependency.current, customEqualForFun)) {
|
|
9
|
+
var res = fun();
|
|
10
|
+
lastRes.current = res;
|
|
11
|
+
}
|
|
12
|
+
lastDependency.current = depList;
|
|
13
|
+
return lastRes.current;
|
|
14
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "antd/es/form/style";
|
|
2
2
|
import _Form from "antd/es/form";
|
|
3
|
-
import { get } from 'lodash';
|
|
3
|
+
import { get, isString } from 'lodash';
|
|
4
4
|
import { diffOriginal } from './diffOriginal';
|
|
5
5
|
var toNamePath = function toNamePath(name) {
|
|
6
6
|
if (Array.isArray(name)) {
|
|
@@ -87,7 +87,7 @@ export var useListChanged = function useListChanged(params) {
|
|
|
87
87
|
originalValue: originalValue,
|
|
88
88
|
form: form,
|
|
89
89
|
equalWith: equalWith,
|
|
90
|
-
name: namesStr || name
|
|
90
|
+
name: isString(namesStr) ? namesStr : originalName || name
|
|
91
91
|
});
|
|
92
92
|
return [changed, originalValue];
|
|
93
93
|
};
|
|
@@ -24,10 +24,6 @@ var useRules = function useRules(props) {
|
|
|
24
24
|
var result = {
|
|
25
25
|
rules: rules || []
|
|
26
26
|
};
|
|
27
|
-
// Group required: true时,直接走完整校验
|
|
28
|
-
if (allRequired && type === 'Group') {
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
27
|
if (allRequired) {
|
|
32
28
|
if (!requiredRule) {
|
|
33
29
|
var message = isSelect ? "".concat(locale.ProForm.selectPlaceHolder).concat(_label) : "".concat(locale.ProForm.inputPlaceholder).concat(_label);
|
|
@@ -58,23 +54,9 @@ var useRules = function useRules(props) {
|
|
|
58
54
|
required: required
|
|
59
55
|
});
|
|
60
56
|
useEffect(function () {
|
|
61
|
-
if (type === 'Group' && (allRequired || requiredRule)) {
|
|
62
|
-
var customRequired = {
|
|
63
|
-
validator: function validator(rules, value) {
|
|
64
|
-
// 完整性校验, 数组有值且值不完整则校验不通过
|
|
65
|
-
if (Array.isArray(value) && isNotFullArray(value, names.length, required)) {
|
|
66
|
-
return Promise.reject(new Error("".concat(locale.ProForm.completeText).concat(_label)));
|
|
67
|
-
}
|
|
68
|
-
return Promise.resolve();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
// 插入rules第一条,完整性校验大于自定义
|
|
72
|
-
internalRule.rules.unshift(customRequired);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
57
|
// 添加完整性校验
|
|
76
58
|
if (names && !isBoolean(labelRequired)) {
|
|
77
|
-
var
|
|
59
|
+
var customRequired = {
|
|
78
60
|
validator: function validator(rules, value) {
|
|
79
61
|
// 完整性校验, 空数组不校验, 数组有值且值不完整则校验不通过
|
|
80
62
|
if (Array.isArray(value) && !isNullArray(value) && isNotFullArray(value, names.length, required)) {
|
|
@@ -83,7 +65,7 @@ var useRules = function useRules(props) {
|
|
|
83
65
|
return Promise.resolve();
|
|
84
66
|
}
|
|
85
67
|
};
|
|
86
|
-
internalRule.rules.unshift(
|
|
68
|
+
internalRule.rules.unshift(customRequired);
|
|
87
69
|
}
|
|
88
70
|
}, [internalRule]);
|
|
89
71
|
return internalRule;
|
package/es/global.less
CHANGED
|
@@ -9,13 +9,21 @@ pre {
|
|
|
9
9
|
scrollbar-face-color: #d2d3d7;
|
|
10
10
|
scrollbar-highlight-color: #979797;
|
|
11
11
|
scrollbar-3dlight-color: #979797;
|
|
12
|
+
|
|
12
13
|
::-webkit-scrollbar {
|
|
13
14
|
width: 16px;
|
|
15
|
+
background: transparent;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
//
|
|
17
|
-
::-webkit-scrollbar-
|
|
18
|
-
background-color: #
|
|
18
|
+
// 轨道
|
|
19
|
+
::-webkit-scrollbar-track {
|
|
20
|
+
background-color: #fff;
|
|
21
|
+
border-radius: 10px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 悬浮轨道
|
|
25
|
+
::-webkit-scrollbar-thumb:hover {
|
|
26
|
+
background-color: #979797;
|
|
19
27
|
background-clip: padding-box;
|
|
20
28
|
border-color: transparent;
|
|
21
29
|
border-style: dashed;
|
|
@@ -24,14 +32,25 @@ pre {
|
|
|
24
32
|
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0);
|
|
25
33
|
}
|
|
26
34
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
:hover::-webkit-scrollbar-track {
|
|
36
|
+
background: transparent;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:hover::-webkit-scrollbar-thumb {
|
|
40
|
+
background-color: #d2d3d7;
|
|
41
|
+
background-clip: padding-box;
|
|
42
|
+
border-color: transparent;
|
|
43
|
+
border-style: dashed;
|
|
44
|
+
border-width: 4px;
|
|
30
45
|
border-radius: 10px;
|
|
46
|
+
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0);
|
|
31
47
|
}
|
|
32
48
|
|
|
33
|
-
|
|
34
|
-
::-webkit-scrollbar-thumb:hover {
|
|
49
|
+
:hover::-webkit-scrollbar-thumb:hover {
|
|
35
50
|
background-color: #979797;
|
|
36
51
|
}
|
|
52
|
+
|
|
53
|
+
:hover::-webkit-scrollbar-track {
|
|
54
|
+
background-color: #fff;
|
|
55
|
+
}
|
|
37
56
|
}
|
package/es/locale/zh_CN.js
CHANGED
|
@@ -318,7 +318,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
318
318
|
}
|
|
319
319
|
_args = [].concat(args);
|
|
320
320
|
rowPath = [].concat((0, _toConsumableArray2.default)(namePath), [index]);
|
|
321
|
-
row =
|
|
321
|
+
row = form.getFieldValue(rowPath, true);
|
|
322
322
|
orgRow = (0, _lodash.cloneDeep)(row);
|
|
323
323
|
if (!onFieldChange) {
|
|
324
324
|
_context.next = 18;
|
|
@@ -363,7 +363,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
363
363
|
return onChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
|
|
364
364
|
case 27:
|
|
365
365
|
// 判断属性是否变动
|
|
366
|
-
|
|
366
|
+
form.setFieldValue(rowPath, row);
|
|
367
367
|
if (!(0, _lodash.isEqual)(orgRow, row)) {
|
|
368
368
|
diff = (0, _tools.difference)(row, orgRow) || {};
|
|
369
369
|
validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
|
@@ -409,7 +409,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
409
409
|
}
|
|
410
410
|
_args = formatArgs([].concat(args));
|
|
411
411
|
rowPath = [].concat((0, _toConsumableArray2.default)(namePath), [index]);
|
|
412
|
-
row = type ===
|
|
412
|
+
row = type === form.getFieldValue(rowPath, true);
|
|
413
413
|
orgRow = (0, _lodash.cloneDeep)(row);
|
|
414
414
|
_args[1] = row;
|
|
415
415
|
_context2.t0 = (_TargetComponent3 = TargetComponent) === null || _TargetComponent3 === void 0 ? void 0 : (_TargetComponent3$pro = _TargetComponent3.props) === null || _TargetComponent3$pro === void 0 ? void 0 : _TargetComponent3$pro.onBlur;
|
|
@@ -500,11 +500,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
500
500
|
isView: isView
|
|
501
501
|
}
|
|
502
502
|
});
|
|
503
|
-
|
|
504
|
-
componentProps.onFieldChange = _onchange;
|
|
505
|
-
} else {
|
|
506
|
-
componentProps = (0, _lodash.omit)(componentProps, ['onFieldChange', 'namePath', 'index']);
|
|
507
|
-
}
|
|
503
|
+
componentProps = (0, _lodash.omit)(componentProps, ['onFieldChange', 'namePath', 'index']);
|
|
508
504
|
// 单元格编辑时,设置各个单元格disabled属性
|
|
509
505
|
if (isCell) {
|
|
510
506
|
record["".concat(dataIndex, "-Disabled")] = _disabled;
|
|
@@ -17,12 +17,14 @@ var _locale = _interopRequireDefault(require("../../../../locale"));
|
|
|
17
17
|
var _ProForm = _interopRequireDefault(require("../../../../ProForm"));
|
|
18
18
|
var _Container = _interopRequireDefault(require("../../Container"));
|
|
19
19
|
require("./index.less");
|
|
20
|
-
var _excluded = ["placeholder", "otherProps", "className"];
|
|
20
|
+
var _excluded = ["placeholder", "otherProps", "className", "tooltip"];
|
|
21
21
|
var TextArea = _antd.Input.TextArea;
|
|
22
22
|
var TextAreaDef = function TextAreaDef(props) {
|
|
23
23
|
var placeholder = props.placeholder,
|
|
24
24
|
otherProps = props.otherProps,
|
|
25
25
|
className = props.className,
|
|
26
|
+
_props$tooltip = props.tooltip,
|
|
27
|
+
tooltip = _props$tooltip === void 0 ? true : _props$tooltip,
|
|
26
28
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
27
29
|
var _ref = _ProForm.default.useFieldProps() || {},
|
|
28
30
|
label = _ref.label,
|
|
@@ -33,7 +35,7 @@ var TextAreaDef = function TextAreaDef(props) {
|
|
|
33
35
|
if (isView) {
|
|
34
36
|
return (0, _jsxRuntime.jsx)(_Container.default, {
|
|
35
37
|
nowrap: false,
|
|
36
|
-
tooltip:
|
|
38
|
+
tooltip: tooltip,
|
|
37
39
|
viewEmpty: viewEmpty,
|
|
38
40
|
children: rest.value
|
|
39
41
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ColProps, FormListFieldData } from 'antd';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { InternalNamePath } from 'antd/es/form/interface';
|
|
4
|
-
import type { levelType } from '
|
|
4
|
+
import type { levelType } from '../../../../../ProLayout/components/ProCollapse/PropTypes';
|
|
5
5
|
import type { FormListProps } from '../propsType';
|
|
6
6
|
interface Props extends Omit<FormListProps, 'toolbarProps'> {
|
|
7
7
|
index: number;
|
|
@@ -54,7 +54,7 @@ var FormList = function FormList(props, ref) {
|
|
|
54
54
|
name: _name,
|
|
55
55
|
names: (item === null || item === void 0 ? void 0 : item.names) ? item.names.map(function (nameItem) {
|
|
56
56
|
// 传给Group的names会被渲染成真实FormItem 不能传完整name
|
|
57
|
-
return
|
|
57
|
+
return [].concat((0, _toConsumableArray2.default)(namePath), (0, _toConsumableArray2.default)((0, _utils.toArray)(nameItem)));
|
|
58
58
|
}) : item.names,
|
|
59
59
|
index: fieldName,
|
|
60
60
|
namePath: namePath,
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { FormInstance } from 'antd/es/form/Form';
|
|
3
3
|
import type { ButtonProps, FormListFieldData, FormListOperation, PopconfirmProps } from 'antd';
|
|
4
4
|
import type { InternalNamePath } from 'antd/es/form/interface';
|
|
5
|
-
import type { levelType } from '
|
|
5
|
+
import type { levelType } from '../../../../ProLayout/components/ProCollapse/PropTypes';
|
|
6
6
|
import type { ProColumnProps, ProFormOtherProps } from '../../../propsType';
|
|
7
7
|
export type TitleRender = (record: Record<string, any>, index: number, form: FormInstance) => any;
|
|
8
8
|
export type TitleType = string | React.ReactNode | TitleRender;
|
|
@@ -14,12 +14,11 @@ var namesPathTransform = exports.namesPathTransform = function namesPathTransfor
|
|
|
14
14
|
var names = _ref.names,
|
|
15
15
|
prefixNamePath = _ref.prefixNamePath,
|
|
16
16
|
type = _ref.type;
|
|
17
|
-
if (!Array.isArray(names) ||
|
|
17
|
+
if (!Array.isArray(names) || !Array.isArray(prefixNamePath)) {
|
|
18
18
|
return '';
|
|
19
19
|
}
|
|
20
|
-
var _prefixNamePath = type === 'Group' ? '' : prefixNamePath;
|
|
21
20
|
var newNamePath = names.map(function (val) {
|
|
22
|
-
return
|
|
21
|
+
return prefixNamePath.concat(val);
|
|
23
22
|
});
|
|
24
23
|
return newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.map(function (name) {
|
|
25
24
|
return Array.isArray(name) ? name.join('_') : name;
|
|
@@ -10,8 +10,8 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
10
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
var _ConfirmWrapper = _interopRequireDefault(require("
|
|
14
|
-
var _useFieldProps = require("
|
|
13
|
+
var _ConfirmWrapper = _interopRequireDefault(require("../../../../components/render/ConfirmWrapper"));
|
|
14
|
+
var _useFieldProps = require("../../../../utils/useFieldProps");
|
|
15
15
|
var componentMap = _interopRequireWildcard(require("../../../../../index"));
|
|
16
16
|
var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps"];
|
|
17
17
|
/** 渲染组件 */
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { GroupProps } from './propsType';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* 1. 外层过滤FormItem相关属性, 但是子元素上的 required [disabled] [show] rules [fieldProps] [component] 需要取到并
|
|
5
|
+
* 2.
|
|
6
|
+
*
|
|
7
|
+
* render内部能力 show, component, value, onChange, disabled, clearNotShow, fieldProps
|
|
8
|
+
*/
|
|
9
|
+
declare const GroupCopy: React.FC<GroupProps>;
|
|
10
|
+
export default GroupCopy;
|
|
@@ -1,65 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
3
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
13
|
var _antd = require("antd");
|
|
12
|
-
var _react = require("react");
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
15
|
var _lodash = require("lodash");
|
|
14
|
-
var _ahooks = require("ahooks");
|
|
15
16
|
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
16
|
-
var _RenderFields = _interopRequireDefault(require("../../render/RenderFields"));
|
|
17
17
|
var _utils = require("./utils");
|
|
18
18
|
var _ProForm = _interopRequireDefault(require("../../../../ProForm"));
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
var _ComRender = _interopRequireDefault(require("./component/ComRender"));
|
|
20
|
+
/**
|
|
21
|
+
* 1. 外层过滤FormItem相关属性, 但是子元素上的 required [disabled] [show] rules [fieldProps] [component] 需要取到并
|
|
22
|
+
* 2.
|
|
23
|
+
*
|
|
24
|
+
* render内部能力 show, component, value, onChange, disabled, clearNotShow, fieldProps
|
|
25
|
+
*/
|
|
26
|
+
var GroupCopy = function GroupCopy(props) {
|
|
27
|
+
var children = props.children,
|
|
22
28
|
className = props.className,
|
|
23
29
|
_props$space = props.space,
|
|
24
30
|
space = _props$space === void 0 ? {
|
|
25
31
|
size: 12
|
|
26
32
|
} : _props$space,
|
|
27
|
-
id = props.id,
|
|
28
33
|
value = props.value,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
34
|
+
onChange = props.onChange,
|
|
35
|
+
otherProps = props.otherProps,
|
|
36
|
+
disabled = props.disabled;
|
|
37
|
+
var contextProps = _ProForm.default.useFieldProps() || {};
|
|
38
|
+
var names = contextProps.names,
|
|
39
|
+
name = contextProps.name,
|
|
40
|
+
form = contextProps.form,
|
|
41
|
+
namePath = contextProps.namePath,
|
|
42
|
+
index = contextProps.index;
|
|
43
|
+
var _option = _react.default.useRef([]);
|
|
44
|
+
// 组合onChange
|
|
45
|
+
var handleChange = function handleChange(value, option, index) {
|
|
46
|
+
var _value = props.value ? (0, _toConsumableArray2.default)(props.value) : [];
|
|
47
|
+
_value[index] = value;
|
|
48
|
+
_option.current[index] = option;
|
|
49
|
+
onChange(_value, _option.current);
|
|
50
|
+
};
|
|
51
|
+
var columns = (0, _react.useMemo)(function () {
|
|
52
|
+
var columnsProps = (0, _utils.transformColumns)({
|
|
53
|
+
columns: children,
|
|
54
|
+
name: name,
|
|
55
|
+
names: names,
|
|
56
|
+
onChange: handleChange,
|
|
57
|
+
namePath: namePath,
|
|
58
|
+
form: form,
|
|
59
|
+
index: index,
|
|
60
|
+
value: value,
|
|
61
|
+
groupProps: props
|
|
57
62
|
});
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
fieldList: fieldList
|
|
61
|
-
};
|
|
62
|
-
}, [name, columns, space, props, names]);
|
|
63
|
+
return (0, _utils.insertSeparator)(columnsProps, space);
|
|
64
|
+
}, [name, value, children, space, names, namePath, index]);
|
|
63
65
|
var _className = (0, _classnames2.default)((0, _defineProperty2.default)({
|
|
64
66
|
'pro-group': true,
|
|
65
67
|
'pro-group-diy-width': columns.some(function (item) {
|
|
@@ -70,44 +72,27 @@ var Group = function Group(props) {
|
|
|
70
72
|
return ['Radio', 'Checkbox', 'Switch'].includes(item.type);
|
|
71
73
|
})
|
|
72
74
|
}, "".concat(className), className));
|
|
73
|
-
// 用于formList场景下names移除掉了前缀,需要再次合并回来
|
|
74
|
-
var _names = names.map(function (item) {
|
|
75
|
-
if ((0, _lodash.isNumber)(item === null || item === void 0 ? void 0 : item[0])) {
|
|
76
|
-
return (0, _lodash.union)(newNamePath, item);
|
|
77
|
-
}
|
|
78
|
-
return item;
|
|
79
|
-
});
|
|
80
|
-
(0, _ahooks.useDeepCompareEffect)(function () {
|
|
81
|
-
var _document, _document$activeEleme;
|
|
82
|
-
// 焦点激活的表单
|
|
83
|
-
var touchName = ((_document = document) === null || _document === void 0 ? void 0 : (_document$activeEleme = _document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.id) || '';
|
|
84
|
-
// 模拟change,初始化不执行onFieldChange
|
|
85
|
-
if ((0, _lodash.isFunction)(onFieldChange) && form.isFieldsTouched(_names) && (0, _utils.transformNamesString)(_names).includes(touchName)) {
|
|
86
|
-
onFieldChange(value, (newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.length) ? form.getFieldValue(newNamePath, true) : form.getFieldsValue(), {
|
|
87
|
-
form: form,
|
|
88
|
-
namePath: newNamePath,
|
|
89
|
-
index: index
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}, [value]);
|
|
93
|
-
var _otherProps = (0, _lodash.omit)(otherProps, ['colProps', 'required']);
|
|
94
75
|
return (0, _jsxRuntime.jsx)("div", {
|
|
95
76
|
className: _className,
|
|
96
77
|
children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? (0, _jsxRuntime.jsx)(_antd.Space.Compact, {
|
|
97
|
-
children:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
78
|
+
children: columns.map(function (column) {
|
|
79
|
+
return (0, _jsxRuntime.jsx)(_ComRender.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
80
|
+
contextProps: contextProps
|
|
81
|
+
}, column), {}, {
|
|
82
|
+
otherProps: otherProps
|
|
83
|
+
}));
|
|
84
|
+
})
|
|
101
85
|
}) : (0, _jsxRuntime.jsx)(_antd.Space, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
102
86
|
align: "start"
|
|
103
87
|
}, (0, _lodash.omit)(space, ['separator', 'compact'])), {}, {
|
|
104
|
-
children:
|
|
105
|
-
return (0, _jsxRuntime.jsx)(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
88
|
+
children: columns.map(function (column, index) {
|
|
89
|
+
return (0, _jsxRuntime.jsx)(_ComRender.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
90
|
+
contextProps: contextProps
|
|
91
|
+
}, column), {}, {
|
|
92
|
+
otherProps: otherProps
|
|
93
|
+
}));
|
|
109
94
|
})
|
|
110
95
|
}))
|
|
111
96
|
});
|
|
112
97
|
};
|
|
113
|
-
var _default = exports.default =
|
|
98
|
+
var _default = exports.default = GroupCopy;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FormItemProps, ModalFuncProps, SpaceProps } from 'antd';
|
|
3
3
|
import { FormInstance } from 'antd/es/form/Form';
|
|
4
4
|
import { NamePath } from 'antd/lib/form/interface';
|
|
5
|
-
import {
|
|
5
|
+
import { ColumnPropsMap, FunctionArgs, ProFormValueType, ReactiveFunction, ViewType } from '../../../propsType';
|
|
6
6
|
export interface SpaceType extends SpaceProps {
|
|
7
7
|
/**
|
|
8
8
|
* 是否紧凑合并
|
|
@@ -16,20 +16,33 @@ export interface SpaceType extends SpaceProps {
|
|
|
16
16
|
size?: number;
|
|
17
17
|
}
|
|
18
18
|
export interface GroupProps {
|
|
19
|
-
children?:
|
|
19
|
+
children?: GroupColumnProps[];
|
|
20
20
|
space?: SpaceType;
|
|
21
|
-
otherProps?: ProFormOtherProps;
|
|
22
|
-
rowProps?: RowProps;
|
|
23
21
|
className?: string;
|
|
24
|
-
value?: any;
|
|
25
22
|
id?: string;
|
|
26
|
-
disabled?: boolean
|
|
23
|
+
disabled?: boolean;
|
|
27
24
|
isView?: boolean;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
form: FormInstance;
|
|
32
|
-
namePath?: NamePath;
|
|
33
|
-
index?: number;
|
|
34
|
-
}) => any;
|
|
25
|
+
value?: any[];
|
|
26
|
+
onChange?: (value: any[] | null, options?: any[]) => void;
|
|
27
|
+
otherProps?: any;
|
|
35
28
|
}
|
|
29
|
+
export type GroupColumnProps<Values = any> = {
|
|
30
|
+
component?: React.ReactNode | ReactiveFunction<Values, React.ReactNode>;
|
|
31
|
+
names?: NamePath[];
|
|
32
|
+
show?: boolean | ReactiveFunction<Values, boolean>;
|
|
33
|
+
valueType?: ProFormValueType;
|
|
34
|
+
switchValue?: [any, any];
|
|
35
|
+
isView?: boolean;
|
|
36
|
+
viewRender?: (value: any, record: Values, { form, index, namePath, }: {
|
|
37
|
+
form: FormInstance<Values>;
|
|
38
|
+
index?: number | undefined;
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}) => React.ReactElement<any, any> | string | undefined | null;
|
|
41
|
+
viewType?: ViewType;
|
|
42
|
+
disabled?: boolean | ReactiveFunction<Values, boolean>;
|
|
43
|
+
trim?: boolean;
|
|
44
|
+
upperCase?: boolean;
|
|
45
|
+
toISOString?: boolean;
|
|
46
|
+
clearNotShow?: boolean;
|
|
47
|
+
confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps>;
|
|
48
|
+
} & ColumnPropsMap & FormItemProps;
|