@zat-design/sisyphus-react 3.4.7 → 3.4.8-beta.2
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 +57 -77
- 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/index.d.ts +2 -0
- package/es/ProForm/utils/index.js +22 -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/useForm.js +23 -13
- 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 +55 -73
- 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/index.d.ts +2 -0
- package/lib/ProForm/utils/index.js +25 -2
- 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/useForm.js +22 -12
- 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
|
@@ -31,10 +31,6 @@ var useRules = function useRules(props) {
|
|
|
31
31
|
var result = {
|
|
32
32
|
rules: rules || []
|
|
33
33
|
};
|
|
34
|
-
// Group required: true时,直接走完整校验
|
|
35
|
-
if (allRequired && type === 'Group') {
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
34
|
if (allRequired) {
|
|
39
35
|
if (!requiredRule) {
|
|
40
36
|
var message = isSelect ? "".concat(_locale.default.ProForm.selectPlaceHolder).concat(_label) : "".concat(_locale.default.ProForm.inputPlaceholder).concat(_label);
|
|
@@ -65,23 +61,9 @@ var useRules = function useRules(props) {
|
|
|
65
61
|
required: required
|
|
66
62
|
});
|
|
67
63
|
(0, _react.useEffect)(function () {
|
|
68
|
-
if (type === 'Group' && (allRequired || requiredRule)) {
|
|
69
|
-
var customRequired = {
|
|
70
|
-
validator: function validator(rules, value) {
|
|
71
|
-
// 完整性校验, 数组有值且值不完整则校验不通过
|
|
72
|
-
if (Array.isArray(value) && (0, _index.isNotFullArray)(value, names.length, required)) {
|
|
73
|
-
return Promise.reject(new Error("".concat(_locale.default.ProForm.completeText).concat(_label)));
|
|
74
|
-
}
|
|
75
|
-
return Promise.resolve();
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
// 插入rules第一条,完整性校验大于自定义
|
|
79
|
-
internalRule.rules.unshift(customRequired);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
64
|
// 添加完整性校验
|
|
83
65
|
if (names && !(0, _lodash.isBoolean)(labelRequired)) {
|
|
84
|
-
var
|
|
66
|
+
var customRequired = {
|
|
85
67
|
validator: function validator(rules, value) {
|
|
86
68
|
// 完整性校验, 空数组不校验, 数组有值且值不完整则校验不通过
|
|
87
69
|
if (Array.isArray(value) && !(0, _index.isNullArray)(value) && (0, _index.isNotFullArray)(value, names.length, required)) {
|
|
@@ -90,7 +72,7 @@ var useRules = function useRules(props) {
|
|
|
90
72
|
return Promise.resolve();
|
|
91
73
|
}
|
|
92
74
|
};
|
|
93
|
-
internalRule.rules.unshift(
|
|
75
|
+
internalRule.rules.unshift(customRequired);
|
|
94
76
|
}
|
|
95
77
|
}, [internalRule]);
|
|
96
78
|
return internalRule;
|
package/lib/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/lib/locale/zh_CN.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { GroupProps } from './propsType';
|
|
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,84 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import "antd/es/space/style";
|
|
3
|
-
import _Space from "antd/es/space";
|
|
4
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
import React, { useMemo } from 'react';
|
|
8
|
-
import { omit } from 'lodash';
|
|
9
|
-
import classnames from 'classnames';
|
|
10
|
-
import { insertSeparator, transformColumns } from './utils';
|
|
11
|
-
import ProForm from '../../../../ProForm';
|
|
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
|
-
var children = props.children,
|
|
21
|
-
className = props.className,
|
|
22
|
-
_props$space = props.space,
|
|
23
|
-
space = _props$space === void 0 ? {
|
|
24
|
-
size: 12
|
|
25
|
-
} : _props$space,
|
|
26
|
-
value = props.value,
|
|
27
|
-
onChange = props.onChange;
|
|
28
|
-
var contextProps = ProForm.useFieldProps() || {};
|
|
29
|
-
var names = contextProps.names,
|
|
30
|
-
name = contextProps.name,
|
|
31
|
-
form = contextProps.form,
|
|
32
|
-
namePath = contextProps.namePath,
|
|
33
|
-
index = contextProps.index;
|
|
34
|
-
var _value = value && _toConsumableArray(value) || [];
|
|
35
|
-
var _option = React.useRef([]);
|
|
36
|
-
// 组合onChange
|
|
37
|
-
var handleChange = function handleChange(value, option, index) {
|
|
38
|
-
_value[index] = value;
|
|
39
|
-
_option.current[index] = option;
|
|
40
|
-
onChange(_value, _option.current);
|
|
41
|
-
};
|
|
42
|
-
var columns = useMemo(function () {
|
|
43
|
-
var columnsProps = transformColumns({
|
|
44
|
-
columns: children,
|
|
45
|
-
name: name,
|
|
46
|
-
names: names,
|
|
47
|
-
onChange: handleChange,
|
|
48
|
-
namePath: namePath,
|
|
49
|
-
form: form,
|
|
50
|
-
index: index,
|
|
51
|
-
value: _value
|
|
52
|
-
});
|
|
53
|
-
return insertSeparator(columnsProps, space);
|
|
54
|
-
}, [name, value, children, space, names, namePath, index]);
|
|
55
|
-
var _className = classnames(_defineProperty({
|
|
56
|
-
'pro-group': true,
|
|
57
|
-
'pro-group-diy-width': columns.some(function (item) {
|
|
58
|
-
var _item$fieldProps, _item$fieldProps$styl;
|
|
59
|
-
return item === null || item === void 0 ? void 0 : (_item$fieldProps = item.fieldProps) === null || _item$fieldProps === void 0 ? void 0 : (_item$fieldProps$styl = _item$fieldProps.style) === null || _item$fieldProps$styl === void 0 ? void 0 : _item$fieldProps$styl.width;
|
|
60
|
-
}),
|
|
61
|
-
'pro-group-width-auto': columns.some(function (item) {
|
|
62
|
-
return ['Radio', 'Checkbox', 'Switch'].includes(item.type);
|
|
63
|
-
})
|
|
64
|
-
}, "".concat(className), className));
|
|
65
|
-
return _jsx("div", {
|
|
66
|
-
className: _className,
|
|
67
|
-
children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? _jsx(_Space.Compact, {
|
|
68
|
-
children: columns.map(function (column) {
|
|
69
|
-
return _jsx(ComRender, _objectSpread({
|
|
70
|
-
contextProps: contextProps
|
|
71
|
-
}, column));
|
|
72
|
-
})
|
|
73
|
-
}) : _jsx(_Space, _objectSpread(_objectSpread({
|
|
74
|
-
align: "start"
|
|
75
|
-
}, omit(space, ['separator', 'compact'])), {}, {
|
|
76
|
-
children: columns.map(function (column, index) {
|
|
77
|
-
return _jsx(ComRender, _objectSpread({
|
|
78
|
-
contextProps: contextProps
|
|
79
|
-
}, column));
|
|
80
|
-
})
|
|
81
|
-
}))
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
export default GroupCopy;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FormItemProps, ModalFuncProps, SpaceProps } from 'antd';
|
|
3
|
-
import { FormInstance } from 'antd/es/form/Form';
|
|
4
|
-
import { NamePath } from 'antd/lib/form/interface';
|
|
5
|
-
import { ColumnPropsMap, FunctionArgs, ProFormValueType, ReactiveFunction, ViewType } from '../../../propsType';
|
|
6
|
-
export interface SpaceType extends SpaceProps {
|
|
7
|
-
/**
|
|
8
|
-
* 是否紧凑合并
|
|
9
|
-
*/
|
|
10
|
-
compact?: Boolean;
|
|
11
|
-
/**
|
|
12
|
-
* 分隔符
|
|
13
|
-
*/
|
|
14
|
-
separator?: string | React.ReactNode;
|
|
15
|
-
/** 间隔距离 */
|
|
16
|
-
size?: number;
|
|
17
|
-
}
|
|
18
|
-
export interface GroupProps {
|
|
19
|
-
children?: GroupColumnProps[];
|
|
20
|
-
space?: SpaceType;
|
|
21
|
-
className?: string;
|
|
22
|
-
id?: string;
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
isView?: boolean;
|
|
25
|
-
value?: any[];
|
|
26
|
-
onChange?: (value: any[] | null, options?: any[]) => void;
|
|
27
|
-
}
|
|
28
|
-
export type GroupColumnProps<Values = any> = {
|
|
29
|
-
component?: React.ReactNode | ReactiveFunction<Values, React.ReactNode>;
|
|
30
|
-
names?: NamePath[];
|
|
31
|
-
show?: boolean | ReactiveFunction<Values, boolean>;
|
|
32
|
-
valueType?: ProFormValueType;
|
|
33
|
-
switchValue?: [any, any];
|
|
34
|
-
isView?: boolean;
|
|
35
|
-
viewRender?: (value: any, record: Values, { form, index, namePath, }: {
|
|
36
|
-
form: FormInstance<Values>;
|
|
37
|
-
index?: number | undefined;
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
}) => React.ReactElement<any, any> | string | undefined | null;
|
|
40
|
-
viewType?: ViewType;
|
|
41
|
-
disabled?: boolean | ReactiveFunction<Values, boolean>;
|
|
42
|
-
trim?: boolean;
|
|
43
|
-
upperCase?: boolean;
|
|
44
|
-
toISOString?: boolean;
|
|
45
|
-
clearNotShow?: boolean;
|
|
46
|
-
confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps>;
|
|
47
|
-
} & ColumnPropsMap & FormItemProps;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
|
|
3
|
-
import { FormInstance } from 'antd';
|
|
4
|
-
import { GroupColumnProps, SpaceType } from './propsType';
|
|
5
|
-
import { ProFormColumnProps, ReactiveFunction } from '../../render/propsType';
|
|
6
|
-
export type EventArgs = any[];
|
|
7
|
-
/**
|
|
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;
|
|
15
|
-
/** 转换names */
|
|
16
|
-
export declare const transformNamesString: (arr: (string | string[])[]) => (string | string[])[];
|
|
17
|
-
interface Params {
|
|
18
|
-
form?: FormInstance;
|
|
19
|
-
index?: number;
|
|
20
|
-
type?: string;
|
|
21
|
-
namePath?: InternalNamePath;
|
|
22
|
-
disabled?: boolean | ReactiveFunction<any, boolean>;
|
|
23
|
-
show?: boolean | ReactiveFunction<any, boolean>;
|
|
24
|
-
component?: React.ReactNode | ReactiveFunction<any, React.ReactNode>;
|
|
25
|
-
fieldProps?: boolean | ReactiveFunction<any, boolean>;
|
|
26
|
-
name?: NamePath;
|
|
27
|
-
}
|
|
28
|
-
/** 计算响应式参数的值 */
|
|
29
|
-
export declare const getReactiveProps: (params: Params) => {
|
|
30
|
-
disabled: boolean;
|
|
31
|
-
show: boolean;
|
|
32
|
-
component: any;
|
|
33
|
-
fieldProps: boolean;
|
|
34
|
-
};
|
|
35
|
-
type ValueTypeGetterParams = Pick<ProFormColumnProps, 'valueType' | 'switchValue' | 'toISOString'> & {
|
|
36
|
-
type?: any;
|
|
37
|
-
mode?: string;
|
|
38
|
-
};
|
|
39
|
-
/** 获取当前字段的转换函数 */
|
|
40
|
-
export declare const getValueTypeTrans: (params: ValueTypeGetterParams) => any;
|
|
41
|
-
interface ColumnsTransformerParams {
|
|
42
|
-
columns: GroupColumnProps[];
|
|
43
|
-
name?: NamePath;
|
|
44
|
-
names?: NamePath[];
|
|
45
|
-
value?: any[];
|
|
46
|
-
onChange: any;
|
|
47
|
-
namePath?: InternalNamePath;
|
|
48
|
-
form: FormInstance;
|
|
49
|
-
index?: number;
|
|
50
|
-
}
|
|
51
|
-
/** 转换columns */
|
|
52
|
-
export declare const transformColumns: (params: ColumnsTransformerParams) => any[];
|
|
53
|
-
export {};
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
-
import "antd/es/button/style";
|
|
4
|
-
import _Button from "antd/es/button";
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
import { isFunction } from 'lodash';
|
|
7
|
-
import valueTypeMap from '../../../utils/valueType';
|
|
8
|
-
/**
|
|
9
|
-
* 插入间隔符
|
|
10
|
-
* @param columns 表单配置数组
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
|
-
export var insertSeparator = function insertSeparator(columns, space) {
|
|
14
|
-
if (!(space === null || space === void 0 ? void 0 : space.separator)) {
|
|
15
|
-
return columns;
|
|
16
|
-
}
|
|
17
|
-
return columns.reduce(function (result, current, index, array) {
|
|
18
|
-
// 将当前元素添加到结果数组中
|
|
19
|
-
result.push(current);
|
|
20
|
-
// 如果当前元素不是最后一个元素,则添加间隔符
|
|
21
|
-
if (index < array.length - 1) {
|
|
22
|
-
result.push({
|
|
23
|
-
component: _jsx(_Button, {
|
|
24
|
-
className: "group-separator",
|
|
25
|
-
children: space.separator
|
|
26
|
-
}),
|
|
27
|
-
fieldProps: {
|
|
28
|
-
disabled: true
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
}, []);
|
|
34
|
-
};
|
|
35
|
-
/** 带出event的组件默认取值方法 */
|
|
36
|
-
export function defaultGetValueFromEvent(valuePropName) {
|
|
37
|
-
var event = arguments.length <= 1 ? undefined : arguments[1];
|
|
38
|
-
if (event && event.target && _typeof(event.target) === 'object' && valuePropName in event.target) {
|
|
39
|
-
return event.target[valuePropName];
|
|
40
|
-
}
|
|
41
|
-
return event;
|
|
42
|
-
}
|
|
43
|
-
/** 转换names */
|
|
44
|
-
export var transformNamesString = function transformNamesString(arr) {
|
|
45
|
-
var result = arr.map(function (subArr) {
|
|
46
|
-
if (Array.isArray(subArr)) {
|
|
47
|
-
return subArr.join('_');
|
|
48
|
-
}
|
|
49
|
-
return subArr;
|
|
50
|
-
});
|
|
51
|
-
return result;
|
|
52
|
-
};
|
|
53
|
-
/** 计算响应式参数的值 */
|
|
54
|
-
export var getReactiveProps = function getReactiveProps(params) {
|
|
55
|
-
var form = params.form,
|
|
56
|
-
index = params.index,
|
|
57
|
-
namePath = params.namePath,
|
|
58
|
-
disabled = params.disabled,
|
|
59
|
-
show = params.show,
|
|
60
|
-
component = params.component,
|
|
61
|
-
fieldProps = params.fieldProps,
|
|
62
|
-
name = params.name;
|
|
63
|
-
var values = form.getFieldsValue(namePath || undefined);
|
|
64
|
-
var _disabled = isFunction(disabled) ? disabled(values, {
|
|
65
|
-
form: form,
|
|
66
|
-
index: index,
|
|
67
|
-
namePath: namePath
|
|
68
|
-
}) : disabled;
|
|
69
|
-
var _show = isFunction(show) ? show(values, {
|
|
70
|
-
form: form,
|
|
71
|
-
index: index,
|
|
72
|
-
namePath: namePath
|
|
73
|
-
}) : show;
|
|
74
|
-
var _component = isFunction(component) ? component(values, {
|
|
75
|
-
form: form,
|
|
76
|
-
index: index,
|
|
77
|
-
namePath: namePath
|
|
78
|
-
}) : component;
|
|
79
|
-
var _fieldProps = isFunction(fieldProps) ? fieldProps(values, {
|
|
80
|
-
form: form,
|
|
81
|
-
index: index,
|
|
82
|
-
namePath: namePath
|
|
83
|
-
}) : fieldProps;
|
|
84
|
-
return {
|
|
85
|
-
disabled: _disabled,
|
|
86
|
-
show: _show,
|
|
87
|
-
component: _component,
|
|
88
|
-
fieldProps: _fieldProps
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
/** 获取当前字段的转换函数 */
|
|
92
|
-
export var getValueTypeTrans = function getValueTypeTrans(params) {
|
|
93
|
-
var _valueTypeMap$valueTy;
|
|
94
|
-
var valueType = params.valueType;
|
|
95
|
-
var transform = (_valueTypeMap$valueTy = valueTypeMap[valueType]) === null || _valueTypeMap$valueTy === void 0 ? void 0 : _valueTypeMap$valueTy.call(valueTypeMap, params);
|
|
96
|
-
return transform;
|
|
97
|
-
};
|
|
98
|
-
/** 转换columns */
|
|
99
|
-
export var transformColumns = function transformColumns(params) {
|
|
100
|
-
var form = params.form,
|
|
101
|
-
columns = params.columns,
|
|
102
|
-
name = params.name,
|
|
103
|
-
names = params.names,
|
|
104
|
-
outerIndex = params.index,
|
|
105
|
-
namePath = params.namePath,
|
|
106
|
-
value = params.value,
|
|
107
|
-
internalChange = params.onChange;
|
|
108
|
-
return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
|
|
109
|
-
var type = column.type,
|
|
110
|
-
valueType = column.valueType,
|
|
111
|
-
switchValue = column.switchValue,
|
|
112
|
-
toISOString = column.toISOString,
|
|
113
|
-
fieldProps = column.fieldProps,
|
|
114
|
-
getValueFromEvent = column.getValueFromEvent,
|
|
115
|
-
_column$valuePropName = column.valuePropName,
|
|
116
|
-
valuePropName = _column$valuePropName === void 0 ? 'value' : _column$valuePropName,
|
|
117
|
-
normalize = column.normalize,
|
|
118
|
-
disabled = column.disabled,
|
|
119
|
-
show = column.show,
|
|
120
|
-
component = column.component;
|
|
121
|
-
var _ref = fieldProps || {},
|
|
122
|
-
mode = _ref.mode,
|
|
123
|
-
onChange = _ref.onChange,
|
|
124
|
-
onFieldChange = _ref.onFieldChange,
|
|
125
|
-
comDisabled = _ref.disabled;
|
|
126
|
-
var _disabled = disabled !== null && disabled !== void 0 ? disabled : comDisabled;
|
|
127
|
-
var columnName = names ? names[index] : [].concat(name, index);
|
|
128
|
-
// 响应式字段
|
|
129
|
-
var reactiveProps = getReactiveProps({
|
|
130
|
-
form: form,
|
|
131
|
-
index: index,
|
|
132
|
-
type: type,
|
|
133
|
-
namePath: namePath,
|
|
134
|
-
disabled: _disabled,
|
|
135
|
-
show: show,
|
|
136
|
-
component: component,
|
|
137
|
-
fieldProps: fieldProps,
|
|
138
|
-
name: columnName
|
|
139
|
-
});
|
|
140
|
-
if (reactiveProps.show === false) return [];
|
|
141
|
-
var transform = getValueTypeTrans({
|
|
142
|
-
type: type,
|
|
143
|
-
valueType: valueType,
|
|
144
|
-
switchValue: switchValue,
|
|
145
|
-
toISOString: toISOString,
|
|
146
|
-
mode: mode
|
|
147
|
-
});
|
|
148
|
-
var newValue;
|
|
149
|
-
var handleChange = function handleChange() {
|
|
150
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
151
|
-
args[_key] = arguments[_key];
|
|
152
|
-
}
|
|
153
|
-
if (getValueFromEvent) {
|
|
154
|
-
newValue = getValueFromEvent.apply(void 0, args);
|
|
155
|
-
} else {
|
|
156
|
-
newValue = defaultGetValueFromEvent.apply(void 0, [valuePropName].concat(args));
|
|
157
|
-
}
|
|
158
|
-
if ((transform === null || transform === void 0 ? void 0 : transform.normalize) || normalize) {
|
|
159
|
-
var _transform$normalize;
|
|
160
|
-
// @ts-ignore
|
|
161
|
-
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));
|
|
162
|
-
}
|
|
163
|
-
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
|
164
|
-
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
|
|
165
|
-
onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, form.getFieldValue(namePath), {
|
|
166
|
-
index: outerIndex,
|
|
167
|
-
namePath: namePath,
|
|
168
|
-
form: form
|
|
169
|
-
});
|
|
170
|
-
};
|
|
171
|
-
return _objectSpread(_objectSpread(_objectSpread({}, column), {}, {
|
|
172
|
-
name: columnName
|
|
173
|
-
}, reactiveProps), {}, {
|
|
174
|
-
fieldProps: _objectSpread(_objectSpread({}, column === null || column === void 0 ? void 0 : column.fieldProps), {}, {
|
|
175
|
-
onChange: handleChange,
|
|
176
|
-
value: value === null || value === void 0 ? void 0 : value[index]
|
|
177
|
-
})
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { GroupProps } from './propsType';
|
|
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,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
var _antd = require("antd");
|
|
14
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
var _lodash = require("lodash");
|
|
16
|
-
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
17
|
-
var _utils = require("./utils");
|
|
18
|
-
var _ProForm = _interopRequireDefault(require("../../../../ProForm"));
|
|
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,
|
|
28
|
-
className = props.className,
|
|
29
|
-
_props$space = props.space,
|
|
30
|
-
space = _props$space === void 0 ? {
|
|
31
|
-
size: 12
|
|
32
|
-
} : _props$space,
|
|
33
|
-
value = props.value,
|
|
34
|
-
onChange = props.onChange;
|
|
35
|
-
var contextProps = _ProForm.default.useFieldProps() || {};
|
|
36
|
-
var names = contextProps.names,
|
|
37
|
-
name = contextProps.name,
|
|
38
|
-
form = contextProps.form,
|
|
39
|
-
namePath = contextProps.namePath,
|
|
40
|
-
index = contextProps.index;
|
|
41
|
-
var _value = value && (0, _toConsumableArray2.default)(value) || [];
|
|
42
|
-
var _option = _react.default.useRef([]);
|
|
43
|
-
// 组合onChange
|
|
44
|
-
var handleChange = function handleChange(value, option, index) {
|
|
45
|
-
_value[index] = value;
|
|
46
|
-
_option.current[index] = option;
|
|
47
|
-
onChange(_value, _option.current);
|
|
48
|
-
};
|
|
49
|
-
var columns = (0, _react.useMemo)(function () {
|
|
50
|
-
var columnsProps = (0, _utils.transformColumns)({
|
|
51
|
-
columns: children,
|
|
52
|
-
name: name,
|
|
53
|
-
names: names,
|
|
54
|
-
onChange: handleChange,
|
|
55
|
-
namePath: namePath,
|
|
56
|
-
form: form,
|
|
57
|
-
index: index,
|
|
58
|
-
value: _value
|
|
59
|
-
});
|
|
60
|
-
return (0, _utils.insertSeparator)(columnsProps, space);
|
|
61
|
-
}, [name, value, children, space, names, namePath, index]);
|
|
62
|
-
var _className = (0, _classnames2.default)((0, _defineProperty2.default)({
|
|
63
|
-
'pro-group': true,
|
|
64
|
-
'pro-group-diy-width': columns.some(function (item) {
|
|
65
|
-
var _item$fieldProps, _item$fieldProps$styl;
|
|
66
|
-
return item === null || item === void 0 ? void 0 : (_item$fieldProps = item.fieldProps) === null || _item$fieldProps === void 0 ? void 0 : (_item$fieldProps$styl = _item$fieldProps.style) === null || _item$fieldProps$styl === void 0 ? void 0 : _item$fieldProps$styl.width;
|
|
67
|
-
}),
|
|
68
|
-
'pro-group-width-auto': columns.some(function (item) {
|
|
69
|
-
return ['Radio', 'Checkbox', 'Switch'].includes(item.type);
|
|
70
|
-
})
|
|
71
|
-
}, "".concat(className), className));
|
|
72
|
-
return (0, _jsxRuntime.jsx)("div", {
|
|
73
|
-
className: _className,
|
|
74
|
-
children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? (0, _jsxRuntime.jsx)(_antd.Space.Compact, {
|
|
75
|
-
children: columns.map(function (column) {
|
|
76
|
-
return (0, _jsxRuntime.jsx)(_ComRender.default, (0, _objectSpread2.default)({
|
|
77
|
-
contextProps: contextProps
|
|
78
|
-
}, column));
|
|
79
|
-
})
|
|
80
|
-
}) : (0, _jsxRuntime.jsx)(_antd.Space, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
81
|
-
align: "start"
|
|
82
|
-
}, (0, _lodash.omit)(space, ['separator', 'compact'])), {}, {
|
|
83
|
-
children: columns.map(function (column, index) {
|
|
84
|
-
return (0, _jsxRuntime.jsx)(_ComRender.default, (0, _objectSpread2.default)({
|
|
85
|
-
contextProps: contextProps
|
|
86
|
-
}, column));
|
|
87
|
-
})
|
|
88
|
-
}))
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
var _default = exports.default = GroupCopy;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FormItemProps, ModalFuncProps, SpaceProps } from 'antd';
|
|
3
|
-
import { FormInstance } from 'antd/es/form/Form';
|
|
4
|
-
import { NamePath } from 'antd/lib/form/interface';
|
|
5
|
-
import { ColumnPropsMap, FunctionArgs, ProFormValueType, ReactiveFunction, ViewType } from '../../../propsType';
|
|
6
|
-
export interface SpaceType extends SpaceProps {
|
|
7
|
-
/**
|
|
8
|
-
* 是否紧凑合并
|
|
9
|
-
*/
|
|
10
|
-
compact?: Boolean;
|
|
11
|
-
/**
|
|
12
|
-
* 分隔符
|
|
13
|
-
*/
|
|
14
|
-
separator?: string | React.ReactNode;
|
|
15
|
-
/** 间隔距离 */
|
|
16
|
-
size?: number;
|
|
17
|
-
}
|
|
18
|
-
export interface GroupProps {
|
|
19
|
-
children?: GroupColumnProps[];
|
|
20
|
-
space?: SpaceType;
|
|
21
|
-
className?: string;
|
|
22
|
-
id?: string;
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
isView?: boolean;
|
|
25
|
-
value?: any[];
|
|
26
|
-
onChange?: (value: any[] | null, options?: any[]) => void;
|
|
27
|
-
}
|
|
28
|
-
export type GroupColumnProps<Values = any> = {
|
|
29
|
-
component?: React.ReactNode | ReactiveFunction<Values, React.ReactNode>;
|
|
30
|
-
names?: NamePath[];
|
|
31
|
-
show?: boolean | ReactiveFunction<Values, boolean>;
|
|
32
|
-
valueType?: ProFormValueType;
|
|
33
|
-
switchValue?: [any, any];
|
|
34
|
-
isView?: boolean;
|
|
35
|
-
viewRender?: (value: any, record: Values, { form, index, namePath, }: {
|
|
36
|
-
form: FormInstance<Values>;
|
|
37
|
-
index?: number | undefined;
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
}) => React.ReactElement<any, any> | string | undefined | null;
|
|
40
|
-
viewType?: ViewType;
|
|
41
|
-
disabled?: boolean | ReactiveFunction<Values, boolean>;
|
|
42
|
-
trim?: boolean;
|
|
43
|
-
upperCase?: boolean;
|
|
44
|
-
toISOString?: boolean;
|
|
45
|
-
clearNotShow?: boolean;
|
|
46
|
-
confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps>;
|
|
47
|
-
} & ColumnPropsMap & FormItemProps;
|