@zat-design/sisyphus-react 3.4.6-beta.6 → 3.4.6-beta.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/es/ProEditTable/components/RenderField/index.js +4 -8
- package/es/ProForm/components/combination/FormList/index.js +1 -1
- package/es/ProForm/components/combination/FormList/utils.js +2 -3
- package/es/ProForm/components/combination/Group/index.d.ts +8 -2
- package/es/ProForm/components/combination/Group/index.js +59 -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/_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 +3 -3
- 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/useRules.js +2 -20
- package/lib/ProEditTable/components/RenderField/index.js +4 -8
- package/lib/ProForm/components/combination/FormList/index.js +1 -1
- package/lib/ProForm/components/combination/FormList/utils.js +2 -3
- package/lib/ProForm/components/combination/Group/index.d.ts +8 -2
- package/lib/ProForm/components/combination/Group/index.js +58 -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/_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 +3 -3
- 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/useRules.js +2 -20
- package/menu.json +5504 -0
- package/package.json +1 -1
- package/coverage/lcov-report/src/.umi/core/devScripts.ts.html +0 -241
- package/coverage/lcov-report/src/.umi/core/history.ts.html +0 -148
- package/coverage/lcov-report/src/.umi/core/index.html +0 -206
- package/coverage/lcov-report/src/.umi/core/plugin.ts.html +0 -109
- package/coverage/lcov-report/src/.umi/core/pluginRegister.ts.html +0 -160
- package/coverage/lcov-report/src/.umi/core/polyfill.ts.html +0 -97
- package/coverage/lcov-report/src/.umi/core/routes.ts.html +0 -26050
- package/coverage/lcov-report/src/.umi/core/umiExports.ts.html +0 -112
- package/coverage/lcov-report/src/.umi/dumi/demos/index.html +0 -116
- package/coverage/lcov-report/src/.umi/dumi/demos/index.ts.html +0 -6340
- package/coverage/lcov-report/src/.umi/dumi/index.html +0 -116
- package/coverage/lcov-report/src/.umi/dumi/layout.tsx.html +0 -109
- package/coverage/lcov-report/src/.umi/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-antd/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-antd/runtime.tsx.html +0 -172
- package/coverage/lcov-report/src/.umi/plugin-helmet/exports.ts.html +0 -94
- package/coverage/lcov-report/src/.umi/plugin-helmet/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-initial-state/Provider.tsx.html +0 -196
- package/coverage/lcov-report/src/.umi/plugin-initial-state/exports.ts.html +0 -106
- package/coverage/lcov-report/src/.umi/plugin-initial-state/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/initialState.ts.html +0 -88
- package/coverage/lcov-report/src/.umi/plugin-initial-state/runtime.tsx.html +0 -124
- package/coverage/lcov-report/src/.umi/plugin-locale/SelectLang.tsx.html +0 -1246
- package/coverage/lcov-report/src/.umi/plugin-locale/index.html +0 -161
- package/coverage/lcov-report/src/.umi/plugin-locale/locale.tsx.html +0 -268
- package/coverage/lcov-report/src/.umi/plugin-locale/localeExports.ts.html +0 -778
- package/coverage/lcov-report/src/.umi/plugin-locale/runtime.tsx.html +0 -115
- package/coverage/lcov-report/src/.umi/plugin-model/Provider.tsx.html +0 -202
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/constant.tsx.html +0 -97
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/dispatcher.tsx.html +0 -142
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/executor.tsx.html +0 -334
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-model/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-model/runtime.tsx.html +0 -121
- package/coverage/lcov-report/src/.umi/plugin-model/useModel.tsx.html +0 -298
- package/coverage/lcov-report/src/.umi/plugin-request/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-request/request.ts.html +0 -919
- package/coverage/lcov-report/src/.umi/umi.ts.html +0 -268
- 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}/component/ComRender.js +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}/component/ComRender.js +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
|
@@ -315,7 +315,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
315
315
|
}
|
|
316
316
|
_args = [].concat(args);
|
|
317
317
|
rowPath = [].concat(_toConsumableArray(namePath), [index]);
|
|
318
|
-
row =
|
|
318
|
+
row = form.getFieldValue(rowPath, true);
|
|
319
319
|
orgRow = cloneDeep(row);
|
|
320
320
|
if (!onFieldChange) {
|
|
321
321
|
_context.next = 18;
|
|
@@ -360,7 +360,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
360
360
|
return onChange.apply(void 0, _toConsumableArray(_args));
|
|
361
361
|
case 27:
|
|
362
362
|
// 判断属性是否变动
|
|
363
|
-
|
|
363
|
+
form.setFieldValue(rowPath, row);
|
|
364
364
|
if (!isEqual(orgRow, row)) {
|
|
365
365
|
diff = difference(row, orgRow) || {};
|
|
366
366
|
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) {
|
|
@@ -406,7 +406,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
406
406
|
}
|
|
407
407
|
_args = formatArgs([].concat(args));
|
|
408
408
|
rowPath = [].concat(_toConsumableArray(namePath), [index]);
|
|
409
|
-
row = type ===
|
|
409
|
+
row = type === form.getFieldValue(rowPath, true);
|
|
410
410
|
orgRow = cloneDeep(row);
|
|
411
411
|
_args[1] = row;
|
|
412
412
|
_context2.t0 = (_TargetComponent3 = TargetComponent) === null || _TargetComponent3 === void 0 ? void 0 : (_TargetComponent3$pro = _TargetComponent3.props) === null || _TargetComponent3$pro === void 0 ? void 0 : _TargetComponent3$pro.onBlur;
|
|
@@ -497,11 +497,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
497
497
|
isView: isView
|
|
498
498
|
}
|
|
499
499
|
});
|
|
500
|
-
|
|
501
|
-
componentProps.onFieldChange = _onchange;
|
|
502
|
-
} else {
|
|
503
|
-
componentProps = omit(componentProps, ['onFieldChange', 'namePath', 'index']);
|
|
504
|
-
}
|
|
500
|
+
componentProps = omit(componentProps, ['onFieldChange', 'namePath', 'index']);
|
|
505
501
|
// 单元格编辑时,设置各个单元格disabled属性
|
|
506
502
|
if (isCell) {
|
|
507
503
|
record["".concat(dataIndex, "-Disabled")] = _disabled;
|
|
@@ -48,7 +48,7 @@ var FormList = function FormList(props, ref) {
|
|
|
48
48
|
name: _name,
|
|
49
49
|
names: (item === null || item === void 0 ? void 0 : item.names) ? item.names.map(function (nameItem) {
|
|
50
50
|
// 传给Group的names会被渲染成真实FormItem 不能传完整name
|
|
51
|
-
return
|
|
51
|
+
return [].concat(_toConsumableArray(namePath), _toConsumableArray(toArray(nameItem)));
|
|
52
52
|
}) : item.names,
|
|
53
53
|
index: fieldName,
|
|
54
54
|
namePath: namePath,
|
|
@@ -8,12 +8,11 @@ export var namesPathTransform = function namesPathTransform(_ref) {
|
|
|
8
8
|
var names = _ref.names,
|
|
9
9
|
prefixNamePath = _ref.prefixNamePath,
|
|
10
10
|
type = _ref.type;
|
|
11
|
-
if (!Array.isArray(names) ||
|
|
11
|
+
if (!Array.isArray(names) || !Array.isArray(prefixNamePath)) {
|
|
12
12
|
return '';
|
|
13
13
|
}
|
|
14
|
-
var _prefixNamePath = type === 'Group' ? '' : prefixNamePath;
|
|
15
14
|
var newNamePath = names.map(function (val) {
|
|
16
|
-
return
|
|
15
|
+
return prefixNamePath.concat(val);
|
|
17
16
|
});
|
|
18
17
|
return newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.map(function (name) {
|
|
19
18
|
return Array.isArray(name) ? name.join('_') : name;
|
|
@@ -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,61 +1,61 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import "antd/es/space/style";
|
|
2
3
|
import _Space from "antd/es/space";
|
|
3
4
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
-
import "
|
|
5
|
-
import _Button from "antd/es/button";
|
|
6
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
7
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
import { useMemo } from 'react';
|
|
9
|
-
import { omit
|
|
10
|
-
import { useDeepCompareEffect } from 'ahooks';
|
|
7
|
+
import React, { useMemo } from 'react';
|
|
8
|
+
import { omit } from 'lodash';
|
|
11
9
|
import classnames from 'classnames';
|
|
12
|
-
import
|
|
13
|
-
import { insertSeparator, transformNamesString } from './utils';
|
|
10
|
+
import { insertSeparator, transformColumns } from './utils';
|
|
14
11
|
import ProForm from '../../../../ProForm';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
import ComRender from './component/ComRender';
|
|
13
|
+
/**
|
|
14
|
+
* 1. 外层过滤FormItem相关属性, 但是子元素上的 required [disabled] [show] rules [fieldProps] [component] 需要取到并
|
|
15
|
+
* 2.
|
|
16
|
+
*
|
|
17
|
+
* render内部能力 show, component, value, onChange, disabled, clearNotShow, fieldProps
|
|
18
|
+
*/
|
|
19
|
+
var GroupCopy = function GroupCopy(props) {
|
|
20
|
+
console.log('🚀 ~~> props:', props);
|
|
21
|
+
var children = props.children,
|
|
18
22
|
className = props.className,
|
|
19
23
|
_props$space = props.space,
|
|
20
24
|
space = _props$space === void 0 ? {
|
|
21
25
|
size: 12
|
|
22
26
|
} : _props$space,
|
|
23
|
-
id = props.id,
|
|
24
27
|
value = props.value,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
28
|
+
onChange = props.onChange,
|
|
29
|
+
otherProps = props.otherProps,
|
|
30
|
+
disabled = props.disabled;
|
|
31
|
+
var contextProps = ProForm.useFieldProps() || {};
|
|
32
|
+
var names = contextProps.names,
|
|
33
|
+
name = contextProps.name,
|
|
34
|
+
form = contextProps.form,
|
|
35
|
+
namePath = contextProps.namePath,
|
|
36
|
+
index = contextProps.index;
|
|
37
|
+
var _option = React.useRef([]);
|
|
38
|
+
// 组合onChange
|
|
39
|
+
var handleChange = function handleChange(value, option, index) {
|
|
40
|
+
var _value = props.value ? _toConsumableArray(props.value) : [];
|
|
41
|
+
_value[index] = value;
|
|
42
|
+
_option.current[index] = option;
|
|
43
|
+
onChange(_value, _option.current);
|
|
44
|
+
};
|
|
45
|
+
var columns = useMemo(function () {
|
|
46
|
+
var columnsProps = transformColumns({
|
|
47
|
+
columns: children,
|
|
48
|
+
name: name,
|
|
49
|
+
names: names,
|
|
50
|
+
onChange: handleChange,
|
|
51
|
+
namePath: namePath,
|
|
52
|
+
form: form,
|
|
53
|
+
index: index,
|
|
54
|
+
value: value,
|
|
55
|
+
groupProps: props
|
|
53
56
|
});
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
fieldList: fieldList
|
|
57
|
-
};
|
|
58
|
-
}, [name, columns, space, props, names]);
|
|
57
|
+
return insertSeparator(columnsProps, space);
|
|
58
|
+
}, [name, value, children, space, names, namePath, index]);
|
|
59
59
|
var _className = classnames(_defineProperty({
|
|
60
60
|
'pro-group': true,
|
|
61
61
|
'pro-group-diy-width': columns.some(function (item) {
|
|
@@ -66,44 +66,27 @@ var Group = function Group(props) {
|
|
|
66
66
|
return ['Radio', 'Checkbox', 'Switch'].includes(item.type);
|
|
67
67
|
})
|
|
68
68
|
}, "".concat(className), className));
|
|
69
|
-
// 用于formList场景下names移除掉了前缀,需要再次合并回来
|
|
70
|
-
var _names = names.map(function (item) {
|
|
71
|
-
if (isNumber(item === null || item === void 0 ? void 0 : item[0])) {
|
|
72
|
-
return union(newNamePath, item);
|
|
73
|
-
}
|
|
74
|
-
return item;
|
|
75
|
-
});
|
|
76
|
-
useDeepCompareEffect(function () {
|
|
77
|
-
var _document, _document$activeEleme;
|
|
78
|
-
// 焦点激活的表单
|
|
79
|
-
var touchName = ((_document = document) === null || _document === void 0 ? void 0 : (_document$activeEleme = _document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.id) || '';
|
|
80
|
-
// 模拟change,初始化不执行onFieldChange
|
|
81
|
-
if (isFunction(onFieldChange) && form.isFieldsTouched(_names) && transformNamesString(_names).includes(touchName)) {
|
|
82
|
-
onFieldChange(value, (newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.length) ? form.getFieldValue(newNamePath, true) : form.getFieldsValue(), {
|
|
83
|
-
form: form,
|
|
84
|
-
namePath: newNamePath,
|
|
85
|
-
index: index
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}, [value]);
|
|
89
|
-
var _otherProps = omit(otherProps, ['colProps', 'required']);
|
|
90
69
|
return _jsx("div", {
|
|
91
70
|
className: _className,
|
|
92
71
|
children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? _jsx(_Space.Compact, {
|
|
93
|
-
children:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
72
|
+
children: columns.map(function (column) {
|
|
73
|
+
return _jsx(ComRender, _objectSpread(_objectSpread({
|
|
74
|
+
contextProps: contextProps
|
|
75
|
+
}, column), {}, {
|
|
76
|
+
otherProps: otherProps
|
|
77
|
+
}));
|
|
78
|
+
})
|
|
97
79
|
}) : _jsx(_Space, _objectSpread(_objectSpread({
|
|
98
80
|
align: "start"
|
|
99
81
|
}, omit(space, ['separator', 'compact'])), {}, {
|
|
100
|
-
children:
|
|
101
|
-
return _jsx(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
82
|
+
children: columns.map(function (column, index) {
|
|
83
|
+
return _jsx(ComRender, _objectSpread(_objectSpread({
|
|
84
|
+
contextProps: contextProps
|
|
85
|
+
}, column), {}, {
|
|
86
|
+
otherProps: otherProps
|
|
87
|
+
}));
|
|
105
88
|
})
|
|
106
89
|
}))
|
|
107
90
|
});
|
|
108
91
|
};
|
|
109
|
-
export default
|
|
92
|
+
export 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;
|
|
@@ -1,10 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
|
|
3
|
+
import { FormInstance } from 'antd';
|
|
4
|
+
import { GroupColumnProps, GroupProps, SpaceType } from './propsType';
|
|
5
|
+
import { ProFormColumnProps, ReactiveFunction } from '../../render/propsType';
|
|
6
|
+
export type EventArgs = any[];
|
|
3
7
|
/**
|
|
4
|
-
* 插入间隔符
|
|
5
|
-
* @param columns 表单配置数组
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare const insertSeparator: (columns:
|
|
8
|
+
* 插入间隔符
|
|
9
|
+
* @param columns 表单配置数组
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare const insertSeparator: (columns: GroupColumnProps[], space?: SpaceType) => any[];
|
|
13
|
+
/** 带出event的组件默认取值方法 */
|
|
14
|
+
export declare function defaultGetValueFromEvent(valuePropName: string, ...args: EventArgs): any;
|
|
9
15
|
/** 转换names */
|
|
10
16
|
export declare const transformNamesString: (arr: (string | string[])[]) => (string | string[])[];
|
|
17
|
+
/**
|
|
18
|
+
* Input TextArea 小写自动转大写
|
|
19
|
+
* @param type 组件类型
|
|
20
|
+
* @param upperCase 是否小写转大写
|
|
21
|
+
* @returns {}
|
|
22
|
+
*/
|
|
23
|
+
export declare const isUpperCase: (type: string, upperCase: boolean) => any;
|
|
24
|
+
interface Params {
|
|
25
|
+
form?: FormInstance;
|
|
26
|
+
index?: number;
|
|
27
|
+
type?: string;
|
|
28
|
+
namePath?: InternalNamePath;
|
|
29
|
+
disabled?: boolean | ReactiveFunction<any, boolean>;
|
|
30
|
+
show?: boolean | ReactiveFunction<any, boolean>;
|
|
31
|
+
component?: React.ReactNode | ReactiveFunction<any, React.ReactNode>;
|
|
32
|
+
fieldProps?: boolean | ReactiveFunction<any, boolean>;
|
|
33
|
+
name?: NamePath;
|
|
34
|
+
}
|
|
35
|
+
/** 计算响应式参数的值 */
|
|
36
|
+
export declare const getReactiveProps: (params: Params) => {
|
|
37
|
+
disabled: boolean;
|
|
38
|
+
show: boolean;
|
|
39
|
+
component: any;
|
|
40
|
+
fieldProps: boolean;
|
|
41
|
+
};
|
|
42
|
+
type ValueTypeGetterParams = Pick<ProFormColumnProps, 'valueType' | 'switchValue' | 'toISOString'> & {
|
|
43
|
+
type?: any;
|
|
44
|
+
mode?: string;
|
|
45
|
+
};
|
|
46
|
+
/** 获取当前字段的转换函数 */
|
|
47
|
+
export declare const getValueTypeTrans: (params: ValueTypeGetterParams) => any;
|
|
48
|
+
/** 执行所有中间件 返回处理后的值 */
|
|
49
|
+
export declare const getValueMiddleware: (value: any, callbacks?: any[]) => any;
|
|
50
|
+
interface ColumnsTransformerParams {
|
|
51
|
+
columns: GroupColumnProps[];
|
|
52
|
+
name?: NamePath;
|
|
53
|
+
names?: NamePath[];
|
|
54
|
+
value?: any[];
|
|
55
|
+
onChange: any;
|
|
56
|
+
namePath?: InternalNamePath;
|
|
57
|
+
form: FormInstance;
|
|
58
|
+
index?: number;
|
|
59
|
+
groupProps: GroupProps;
|
|
60
|
+
}
|
|
61
|
+
/** 转换columns */
|
|
62
|
+
export declare const transformColumns: (params: ColumnsTransformerParams) => any[];
|
|
63
|
+
export {};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
4
|
+
import "antd/es/button/style";
|
|
5
|
+
import _Button from "antd/es/button";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { isFunction } from 'lodash';
|
|
8
|
+
import valueTypeMap from '../../../utils/valueType';
|
|
9
|
+
import { useDeepCompareMemo } from '@/ProForm/utils/useDeepCompareMemo';
|
|
2
10
|
/**
|
|
3
|
-
* 插入间隔符
|
|
4
|
-
* @param columns 表单配置数组
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
|
-
export var insertSeparator = function insertSeparator(columns, space
|
|
8
|
-
var _columns = columns;
|
|
9
|
-
var _ref = otherProps || {},
|
|
10
|
-
names = _ref.names;
|
|
11
|
-
// 紧凑模式存在names时,自动给下级拆解name
|
|
12
|
-
if (names) {
|
|
13
|
-
_columns = _columns.map(function (column, index) {
|
|
14
|
-
return _objectSpread(_objectSpread({}, column), {}, {
|
|
15
|
-
name: names[index]
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}
|
|
11
|
+
* 插入间隔符
|
|
12
|
+
* @param columns 表单配置数组
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export var insertSeparator = function insertSeparator(columns, space) {
|
|
19
16
|
if (!(space === null || space === void 0 ? void 0 : space.separator)) {
|
|
20
|
-
return
|
|
17
|
+
return columns;
|
|
21
18
|
}
|
|
22
|
-
return
|
|
19
|
+
return columns.reduce(function (result, current, index, array) {
|
|
23
20
|
// 将当前元素添加到结果数组中
|
|
24
21
|
result.push(current);
|
|
25
22
|
// 如果当前元素不是最后一个元素,则添加间隔符
|
|
26
23
|
if (index < array.length - 1) {
|
|
27
24
|
result.push({
|
|
28
|
-
component:
|
|
25
|
+
component: _jsx(_Button, {
|
|
26
|
+
className: "group-separator",
|
|
27
|
+
children: space.separator
|
|
28
|
+
}),
|
|
29
29
|
fieldProps: {
|
|
30
30
|
disabled: true
|
|
31
31
|
}
|
|
@@ -34,6 +34,14 @@ export var insertSeparator = function insertSeparator(columns, space, separatorN
|
|
|
34
34
|
return result;
|
|
35
35
|
}, []);
|
|
36
36
|
};
|
|
37
|
+
/** 带出event的组件默认取值方法 */
|
|
38
|
+
export function defaultGetValueFromEvent(valuePropName) {
|
|
39
|
+
var event = arguments.length <= 1 ? undefined : arguments[1];
|
|
40
|
+
if (event && event.target && _typeof(event.target) === 'object' && valuePropName in event.target) {
|
|
41
|
+
return event.target[valuePropName];
|
|
42
|
+
}
|
|
43
|
+
return event;
|
|
44
|
+
}
|
|
37
45
|
/** 转换names */
|
|
38
46
|
export var transformNamesString = function transformNamesString(arr) {
|
|
39
47
|
var result = arr.map(function (subArr) {
|
|
@@ -43,4 +51,186 @@ export var transformNamesString = function transformNamesString(arr) {
|
|
|
43
51
|
return subArr;
|
|
44
52
|
});
|
|
45
53
|
return result;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Input TextArea 小写自动转大写
|
|
57
|
+
* @param type 组件类型
|
|
58
|
+
* @param upperCase 是否小写转大写
|
|
59
|
+
* @returns {}
|
|
60
|
+
*/
|
|
61
|
+
export var isUpperCase = function isUpperCase(type, upperCase) {
|
|
62
|
+
var result = {};
|
|
63
|
+
if (['Input', 'TextArea', 'ProCombination'].includes(type) && upperCase) {
|
|
64
|
+
result.getValueFromEvent = function (event) {
|
|
65
|
+
var _event$target, _event$target$value;
|
|
66
|
+
if (Array.isArray(event)) {
|
|
67
|
+
return event.map(function (value) {
|
|
68
|
+
var newValue = value === null || value === void 0 ? void 0 : value.replace(/[^a-zA-Z]/g, '');
|
|
69
|
+
return (newValue === null || newValue === void 0 ? void 0 : newValue.toUpperCase()) || '';
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
var newValue = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : (_event$target$value = _event$target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.replace(/[^a-zA-Z]/g, '');
|
|
73
|
+
return newValue.toUpperCase() || '';
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
};
|
|
78
|
+
/** 计算响应式参数的值 */
|
|
79
|
+
export var getReactiveProps = function getReactiveProps(params) {
|
|
80
|
+
var form = params.form,
|
|
81
|
+
index = params.index,
|
|
82
|
+
namePath = params.namePath,
|
|
83
|
+
disabled = params.disabled,
|
|
84
|
+
show = params.show,
|
|
85
|
+
component = params.component,
|
|
86
|
+
fieldProps = params.fieldProps,
|
|
87
|
+
name = params.name;
|
|
88
|
+
var values = form.getFieldsValue(namePath || undefined);
|
|
89
|
+
var _disabled = isFunction(disabled) ? disabled(values, {
|
|
90
|
+
form: form,
|
|
91
|
+
index: index,
|
|
92
|
+
namePath: namePath
|
|
93
|
+
}) : disabled;
|
|
94
|
+
var _show = isFunction(show) ? show(values, {
|
|
95
|
+
form: form,
|
|
96
|
+
index: index,
|
|
97
|
+
namePath: namePath
|
|
98
|
+
}) : show;
|
|
99
|
+
var _component = isFunction(component) ? component(values, {
|
|
100
|
+
form: form,
|
|
101
|
+
index: index,
|
|
102
|
+
namePath: namePath
|
|
103
|
+
}) : component;
|
|
104
|
+
var _fieldProps = isFunction(fieldProps) ? fieldProps(values, {
|
|
105
|
+
form: form,
|
|
106
|
+
index: index,
|
|
107
|
+
namePath: namePath
|
|
108
|
+
}) : fieldProps;
|
|
109
|
+
return {
|
|
110
|
+
disabled: _disabled,
|
|
111
|
+
show: _show,
|
|
112
|
+
component: _component,
|
|
113
|
+
fieldProps: _fieldProps
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
/** 获取当前字段的转换函数 */
|
|
117
|
+
export var getValueTypeTrans = function getValueTypeTrans(params) {
|
|
118
|
+
var _valueTypeMap$valueTy;
|
|
119
|
+
var valueType = params.valueType;
|
|
120
|
+
var transform = (_valueTypeMap$valueTy = valueTypeMap[valueType]) === null || _valueTypeMap$valueTy === void 0 ? void 0 : _valueTypeMap$valueTy.call(valueTypeMap, params);
|
|
121
|
+
return transform;
|
|
122
|
+
};
|
|
123
|
+
var getTrim = function getTrim(value) {
|
|
124
|
+
return (value === null || value === void 0 ? void 0 : value.trim()) || '';
|
|
125
|
+
};
|
|
126
|
+
var getUpperCase = function getUpperCase(value) {
|
|
127
|
+
var _value = value === null || value === void 0 ? void 0 : value.replace(/[^a-zA-Z]/g, '');
|
|
128
|
+
return _value.toUpperCase() || '';
|
|
129
|
+
};
|
|
130
|
+
/** 执行所有中间件 返回处理后的值 */
|
|
131
|
+
export var getValueMiddleware = function getValueMiddleware(value) {
|
|
132
|
+
var callbacks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
133
|
+
return callbacks.reduce(function (preValue, cb) {
|
|
134
|
+
return cb === null || cb === void 0 ? void 0 : cb(preValue);
|
|
135
|
+
}, value);
|
|
136
|
+
};
|
|
137
|
+
/** 获取中间件处理后的value */
|
|
138
|
+
var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
|
|
139
|
+
var getValueFromEvent = column.getValueFromEvent,
|
|
140
|
+
_column$valuePropName = column.valuePropName,
|
|
141
|
+
valuePropName = _column$valuePropName === void 0 ? 'value' : _column$valuePropName,
|
|
142
|
+
trim = column.trim,
|
|
143
|
+
upperCase = column.upperCase;
|
|
144
|
+
var newValue;
|
|
145
|
+
if (getValueFromEvent) {
|
|
146
|
+
newValue = getValueFromEvent.apply(void 0, _toConsumableArray(args));
|
|
147
|
+
} else {
|
|
148
|
+
newValue = defaultGetValueFromEvent.apply(void 0, [valuePropName].concat(_toConsumableArray(args)));
|
|
149
|
+
}
|
|
150
|
+
var list = [];
|
|
151
|
+
if (trim) list.push(getTrim);
|
|
152
|
+
if (upperCase) list.push(getUpperCase);
|
|
153
|
+
return getValueMiddleware(newValue, list);
|
|
154
|
+
};
|
|
155
|
+
/** 转换columns */
|
|
156
|
+
export var transformColumns = function transformColumns(params) {
|
|
157
|
+
var form = params.form,
|
|
158
|
+
columns = params.columns,
|
|
159
|
+
name = params.name,
|
|
160
|
+
names = params.names,
|
|
161
|
+
outerIndex = params.index,
|
|
162
|
+
namePath = params.namePath,
|
|
163
|
+
value = params.value,
|
|
164
|
+
internalChange = params.onChange,
|
|
165
|
+
groupProps = params.groupProps;
|
|
166
|
+
return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
|
|
167
|
+
var type = column.type,
|
|
168
|
+
valueType = column.valueType,
|
|
169
|
+
switchValue = column.switchValue,
|
|
170
|
+
toISOString = column.toISOString,
|
|
171
|
+
fieldProps = column.fieldProps,
|
|
172
|
+
normalize = column.normalize,
|
|
173
|
+
disabled = column.disabled,
|
|
174
|
+
show = column.show,
|
|
175
|
+
component = column.component;
|
|
176
|
+
var _ref = fieldProps || {},
|
|
177
|
+
mode = _ref.mode,
|
|
178
|
+
onChange = _ref.onChange,
|
|
179
|
+
onFieldChange = _ref.onFieldChange,
|
|
180
|
+
comDisabled = _ref.disabled;
|
|
181
|
+
var _disabled = disabled || comDisabled;
|
|
182
|
+
var columnName = names ? names[index] : [].concat(name, index);
|
|
183
|
+
// 响应式字段
|
|
184
|
+
var reactiveProps = useDeepCompareMemo(function () {
|
|
185
|
+
return getReactiveProps({
|
|
186
|
+
form: form,
|
|
187
|
+
index: index,
|
|
188
|
+
type: type,
|
|
189
|
+
namePath: namePath,
|
|
190
|
+
disabled: _disabled,
|
|
191
|
+
show: show,
|
|
192
|
+
component: component,
|
|
193
|
+
fieldProps: fieldProps,
|
|
194
|
+
name: columnName
|
|
195
|
+
});
|
|
196
|
+
}, [value, show, fieldProps, columnName, type]);
|
|
197
|
+
if (reactiveProps.show === false) {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
var transform = getValueTypeTrans({
|
|
201
|
+
type: type,
|
|
202
|
+
valueType: valueType,
|
|
203
|
+
switchValue: switchValue,
|
|
204
|
+
toISOString: toISOString,
|
|
205
|
+
mode: mode
|
|
206
|
+
});
|
|
207
|
+
var newValue;
|
|
208
|
+
var handleChange = function handleChange() {
|
|
209
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
210
|
+
args[_key] = arguments[_key];
|
|
211
|
+
}
|
|
212
|
+
newValue = valueFromEventWrapper(column, args);
|
|
213
|
+
if ((transform === null || transform === void 0 ? void 0 : transform.normalize) || normalize) {
|
|
214
|
+
var _transform$normalize;
|
|
215
|
+
// @ts-ignore
|
|
216
|
+
newValue = ((_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue)) || (normalize === null || normalize === void 0 ? void 0 : normalize(newValue));
|
|
217
|
+
}
|
|
218
|
+
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
|
219
|
+
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
|
|
220
|
+
onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, form.getFieldValue(namePath), {
|
|
221
|
+
index: outerIndex,
|
|
222
|
+
namePath: namePath,
|
|
223
|
+
form: form
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
return _objectSpread(_objectSpread(_objectSpread({}, column), {}, {
|
|
227
|
+
name: columnName
|
|
228
|
+
}, reactiveProps), {}, {
|
|
229
|
+
disabled: reactiveProps.disabled || groupProps.disabled,
|
|
230
|
+
fieldProps: _objectSpread(_objectSpread({}, column === null || column === void 0 ? void 0 : column.fieldProps), {}, {
|
|
231
|
+
onChange: handleChange,
|
|
232
|
+
value: value === null || value === void 0 ? void 0 : value[index]
|
|
233
|
+
})
|
|
234
|
+
});
|
|
235
|
+
});
|
|
46
236
|
};
|