@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
|
@@ -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 {};
|
|
@@ -4,35 +4,35 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.defaultGetValueFromEvent = defaultGetValueFromEvent;
|
|
8
|
+
exports.transformNamesString = exports.transformColumns = exports.isUpperCase = exports.insertSeparator = exports.getValueTypeTrans = exports.getValueMiddleware = exports.getReactiveProps = void 0;
|
|
8
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
var _lodash = require("lodash");
|
|
14
|
+
var _antd = require("antd");
|
|
15
|
+
var _valueType = _interopRequireDefault(require("../../../utils/valueType"));
|
|
16
|
+
var _useDeepCompareMemo = require("../../../utils/useDeepCompareMemo");
|
|
9
17
|
/**
|
|
10
|
-
* 插入间隔符
|
|
11
|
-
* @param columns 表单配置数组
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
var insertSeparator = exports.insertSeparator = function insertSeparator(columns, space
|
|
15
|
-
var _columns = columns;
|
|
16
|
-
var _ref = otherProps || {},
|
|
17
|
-
names = _ref.names;
|
|
18
|
-
// 紧凑模式存在names时,自动给下级拆解name
|
|
19
|
-
if (names) {
|
|
20
|
-
_columns = _columns.map(function (column, index) {
|
|
21
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
|
|
22
|
-
name: names[index]
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
}
|
|
18
|
+
* 插入间隔符
|
|
19
|
+
* @param columns 表单配置数组
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
var insertSeparator = exports.insertSeparator = function insertSeparator(columns, space) {
|
|
26
23
|
if (!(space === null || space === void 0 ? void 0 : space.separator)) {
|
|
27
|
-
return
|
|
24
|
+
return columns;
|
|
28
25
|
}
|
|
29
|
-
return
|
|
26
|
+
return columns.reduce(function (result, current, index, array) {
|
|
30
27
|
// 将当前元素添加到结果数组中
|
|
31
28
|
result.push(current);
|
|
32
29
|
// 如果当前元素不是最后一个元素,则添加间隔符
|
|
33
30
|
if (index < array.length - 1) {
|
|
34
31
|
result.push({
|
|
35
|
-
component:
|
|
32
|
+
component: (0, _jsxRuntime.jsx)(_antd.Button, {
|
|
33
|
+
className: "group-separator",
|
|
34
|
+
children: space.separator
|
|
35
|
+
}),
|
|
36
36
|
fieldProps: {
|
|
37
37
|
disabled: true
|
|
38
38
|
}
|
|
@@ -41,6 +41,14 @@ var insertSeparator = exports.insertSeparator = function insertSeparator(columns
|
|
|
41
41
|
return result;
|
|
42
42
|
}, []);
|
|
43
43
|
};
|
|
44
|
+
/** 带出event的组件默认取值方法 */
|
|
45
|
+
function defaultGetValueFromEvent(valuePropName) {
|
|
46
|
+
var event = arguments.length <= 1 ? undefined : arguments[1];
|
|
47
|
+
if (event && event.target && (0, _typeof2.default)(event.target) === 'object' && valuePropName in event.target) {
|
|
48
|
+
return event.target[valuePropName];
|
|
49
|
+
}
|
|
50
|
+
return event;
|
|
51
|
+
}
|
|
44
52
|
/** 转换names */
|
|
45
53
|
var transformNamesString = exports.transformNamesString = function transformNamesString(arr) {
|
|
46
54
|
var result = arr.map(function (subArr) {
|
|
@@ -50,4 +58,186 @@ var transformNamesString = exports.transformNamesString = function transformName
|
|
|
50
58
|
return subArr;
|
|
51
59
|
});
|
|
52
60
|
return result;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Input TextArea 小写自动转大写
|
|
64
|
+
* @param type 组件类型
|
|
65
|
+
* @param upperCase 是否小写转大写
|
|
66
|
+
* @returns {}
|
|
67
|
+
*/
|
|
68
|
+
var isUpperCase = exports.isUpperCase = function isUpperCase(type, upperCase) {
|
|
69
|
+
var result = {};
|
|
70
|
+
if (['Input', 'TextArea', 'ProCombination'].includes(type) && upperCase) {
|
|
71
|
+
result.getValueFromEvent = function (event) {
|
|
72
|
+
var _event$target, _event$target$value;
|
|
73
|
+
if (Array.isArray(event)) {
|
|
74
|
+
return event.map(function (value) {
|
|
75
|
+
var newValue = value === null || value === void 0 ? void 0 : value.replace(/[^a-zA-Z]/g, '');
|
|
76
|
+
return (newValue === null || newValue === void 0 ? void 0 : newValue.toUpperCase()) || '';
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
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, '');
|
|
80
|
+
return newValue.toUpperCase() || '';
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
};
|
|
85
|
+
/** 计算响应式参数的值 */
|
|
86
|
+
var getReactiveProps = exports.getReactiveProps = function getReactiveProps(params) {
|
|
87
|
+
var form = params.form,
|
|
88
|
+
index = params.index,
|
|
89
|
+
namePath = params.namePath,
|
|
90
|
+
disabled = params.disabled,
|
|
91
|
+
show = params.show,
|
|
92
|
+
component = params.component,
|
|
93
|
+
fieldProps = params.fieldProps,
|
|
94
|
+
name = params.name;
|
|
95
|
+
var values = form.getFieldsValue(namePath || undefined);
|
|
96
|
+
var _disabled = (0, _lodash.isFunction)(disabled) ? disabled(values, {
|
|
97
|
+
form: form,
|
|
98
|
+
index: index,
|
|
99
|
+
namePath: namePath
|
|
100
|
+
}) : disabled;
|
|
101
|
+
var _show = (0, _lodash.isFunction)(show) ? show(values, {
|
|
102
|
+
form: form,
|
|
103
|
+
index: index,
|
|
104
|
+
namePath: namePath
|
|
105
|
+
}) : show;
|
|
106
|
+
var _component = (0, _lodash.isFunction)(component) ? component(values, {
|
|
107
|
+
form: form,
|
|
108
|
+
index: index,
|
|
109
|
+
namePath: namePath
|
|
110
|
+
}) : component;
|
|
111
|
+
var _fieldProps = (0, _lodash.isFunction)(fieldProps) ? fieldProps(values, {
|
|
112
|
+
form: form,
|
|
113
|
+
index: index,
|
|
114
|
+
namePath: namePath
|
|
115
|
+
}) : fieldProps;
|
|
116
|
+
return {
|
|
117
|
+
disabled: _disabled,
|
|
118
|
+
show: _show,
|
|
119
|
+
component: _component,
|
|
120
|
+
fieldProps: _fieldProps
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
/** 获取当前字段的转换函数 */
|
|
124
|
+
var getValueTypeTrans = exports.getValueTypeTrans = function getValueTypeTrans(params) {
|
|
125
|
+
var _valueTypeMap$valueTy;
|
|
126
|
+
var valueType = params.valueType;
|
|
127
|
+
var transform = (_valueTypeMap$valueTy = _valueType.default[valueType]) === null || _valueTypeMap$valueTy === void 0 ? void 0 : _valueTypeMap$valueTy.call(_valueType.default, params);
|
|
128
|
+
return transform;
|
|
129
|
+
};
|
|
130
|
+
var getTrim = function getTrim(value) {
|
|
131
|
+
return (value === null || value === void 0 ? void 0 : value.trim()) || '';
|
|
132
|
+
};
|
|
133
|
+
var getUpperCase = function getUpperCase(value) {
|
|
134
|
+
var _value = value === null || value === void 0 ? void 0 : value.replace(/[^a-zA-Z]/g, '');
|
|
135
|
+
return _value.toUpperCase() || '';
|
|
136
|
+
};
|
|
137
|
+
/** 执行所有中间件 返回处理后的值 */
|
|
138
|
+
var getValueMiddleware = exports.getValueMiddleware = function getValueMiddleware(value) {
|
|
139
|
+
var callbacks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
140
|
+
return callbacks.reduce(function (preValue, cb) {
|
|
141
|
+
return cb === null || cb === void 0 ? void 0 : cb(preValue);
|
|
142
|
+
}, value);
|
|
143
|
+
};
|
|
144
|
+
/** 获取中间件处理后的value */
|
|
145
|
+
var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
|
|
146
|
+
var getValueFromEvent = column.getValueFromEvent,
|
|
147
|
+
_column$valuePropName = column.valuePropName,
|
|
148
|
+
valuePropName = _column$valuePropName === void 0 ? 'value' : _column$valuePropName,
|
|
149
|
+
trim = column.trim,
|
|
150
|
+
upperCase = column.upperCase;
|
|
151
|
+
var newValue;
|
|
152
|
+
if (getValueFromEvent) {
|
|
153
|
+
newValue = getValueFromEvent.apply(void 0, (0, _toConsumableArray2.default)(args));
|
|
154
|
+
} else {
|
|
155
|
+
newValue = defaultGetValueFromEvent.apply(void 0, [valuePropName].concat((0, _toConsumableArray2.default)(args)));
|
|
156
|
+
}
|
|
157
|
+
var list = [];
|
|
158
|
+
if (trim) list.push(getTrim);
|
|
159
|
+
if (upperCase) list.push(getUpperCase);
|
|
160
|
+
return getValueMiddleware(newValue, list);
|
|
161
|
+
};
|
|
162
|
+
/** 转换columns */
|
|
163
|
+
var transformColumns = exports.transformColumns = function transformColumns(params) {
|
|
164
|
+
var form = params.form,
|
|
165
|
+
columns = params.columns,
|
|
166
|
+
name = params.name,
|
|
167
|
+
names = params.names,
|
|
168
|
+
outerIndex = params.index,
|
|
169
|
+
namePath = params.namePath,
|
|
170
|
+
value = params.value,
|
|
171
|
+
internalChange = params.onChange,
|
|
172
|
+
groupProps = params.groupProps;
|
|
173
|
+
return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
|
|
174
|
+
var type = column.type,
|
|
175
|
+
valueType = column.valueType,
|
|
176
|
+
switchValue = column.switchValue,
|
|
177
|
+
toISOString = column.toISOString,
|
|
178
|
+
fieldProps = column.fieldProps,
|
|
179
|
+
normalize = column.normalize,
|
|
180
|
+
disabled = column.disabled,
|
|
181
|
+
show = column.show,
|
|
182
|
+
component = column.component;
|
|
183
|
+
var _ref = fieldProps || {},
|
|
184
|
+
mode = _ref.mode,
|
|
185
|
+
onChange = _ref.onChange,
|
|
186
|
+
onFieldChange = _ref.onFieldChange,
|
|
187
|
+
comDisabled = _ref.disabled;
|
|
188
|
+
var _disabled = disabled || comDisabled;
|
|
189
|
+
var columnName = names ? names[index] : [].concat(name, index);
|
|
190
|
+
// 响应式字段
|
|
191
|
+
var reactiveProps = (0, _useDeepCompareMemo.useDeepCompareMemo)(function () {
|
|
192
|
+
return getReactiveProps({
|
|
193
|
+
form: form,
|
|
194
|
+
index: index,
|
|
195
|
+
type: type,
|
|
196
|
+
namePath: namePath,
|
|
197
|
+
disabled: _disabled,
|
|
198
|
+
show: show,
|
|
199
|
+
component: component,
|
|
200
|
+
fieldProps: fieldProps,
|
|
201
|
+
name: columnName
|
|
202
|
+
});
|
|
203
|
+
}, [value, show, fieldProps, columnName, type]);
|
|
204
|
+
if (reactiveProps.show === false) {
|
|
205
|
+
return [];
|
|
206
|
+
}
|
|
207
|
+
var transform = getValueTypeTrans({
|
|
208
|
+
type: type,
|
|
209
|
+
valueType: valueType,
|
|
210
|
+
switchValue: switchValue,
|
|
211
|
+
toISOString: toISOString,
|
|
212
|
+
mode: mode
|
|
213
|
+
});
|
|
214
|
+
var newValue;
|
|
215
|
+
var handleChange = function handleChange() {
|
|
216
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
217
|
+
args[_key] = arguments[_key];
|
|
218
|
+
}
|
|
219
|
+
newValue = valueFromEventWrapper(column, args);
|
|
220
|
+
if ((transform === null || transform === void 0 ? void 0 : transform.normalize) || normalize) {
|
|
221
|
+
var _transform$normalize;
|
|
222
|
+
// @ts-ignore
|
|
223
|
+
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));
|
|
224
|
+
}
|
|
225
|
+
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
|
226
|
+
onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
|
|
227
|
+
onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, form.getFieldValue(namePath), {
|
|
228
|
+
index: outerIndex,
|
|
229
|
+
namePath: namePath,
|
|
230
|
+
form: form
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
|
|
234
|
+
name: columnName
|
|
235
|
+
}, reactiveProps), {}, {
|
|
236
|
+
disabled: reactiveProps.disabled || groupProps.disabled,
|
|
237
|
+
fieldProps: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, column === null || column === void 0 ? void 0 : column.fieldProps), {}, {
|
|
238
|
+
onChange: handleChange,
|
|
239
|
+
value: value === null || value === void 0 ? void 0 : value[index]
|
|
240
|
+
})
|
|
241
|
+
});
|
|
242
|
+
});
|
|
53
243
|
};
|
|
@@ -292,58 +292,64 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
292
292
|
};
|
|
293
293
|
var handleFinish = /*#__PURE__*/function () {
|
|
294
294
|
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
|
|
295
|
-
var
|
|
295
|
+
var _nextSelectedRows, _nextSelectedRows2, nextSelectedRows, record, flag, res;
|
|
296
296
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
297
297
|
while (1) switch (_context2.prev = _context2.next) {
|
|
298
298
|
case 0:
|
|
299
299
|
_context2.prev = 0;
|
|
300
|
-
if (
|
|
300
|
+
if (selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.length) {
|
|
301
301
|
_context2.next = 4;
|
|
302
302
|
break;
|
|
303
303
|
}
|
|
304
304
|
_antd.message.error(_locale.default.ProModalSelect.checkMsg);
|
|
305
305
|
return _context2.abrupt("return", false);
|
|
306
306
|
case 4:
|
|
307
|
-
|
|
307
|
+
nextSelectedRows = selectedRows;
|
|
308
|
+
if (!((_nextSelectedRows = nextSelectedRows) === null || _nextSelectedRows === void 0 ? void 0 : _nextSelectedRows[0])) {
|
|
309
|
+
nextSelectedRows = data.filter(function (item) {
|
|
310
|
+
return selectedRowKeys.includes(item[valueKey]);
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
record = isMultiple ? nextSelectedRows : (_nextSelectedRows2 = nextSelectedRows) === null || _nextSelectedRows2 === void 0 ? void 0 : _nextSelectedRows2[0];
|
|
308
314
|
if (!isMultiple) {
|
|
309
315
|
// @ts-ignore
|
|
310
|
-
|
|
316
|
+
record.value = record[valueKey];
|
|
311
317
|
// @ts-ignore
|
|
312
|
-
|
|
318
|
+
record.label = record[labelKey];
|
|
313
319
|
}
|
|
314
320
|
flag = true;
|
|
315
321
|
if (!onOk) {
|
|
316
|
-
_context2.next =
|
|
322
|
+
_context2.next = 14;
|
|
317
323
|
break;
|
|
318
324
|
}
|
|
319
|
-
_context2.next =
|
|
320
|
-
return onOk(
|
|
321
|
-
case
|
|
325
|
+
_context2.next = 12;
|
|
326
|
+
return onOk(record);
|
|
327
|
+
case 12:
|
|
322
328
|
res = _context2.sent;
|
|
323
329
|
if (res !== null && res !== undefined) {
|
|
324
330
|
// @ts-ignore
|
|
325
331
|
flag = res;
|
|
326
332
|
}
|
|
327
|
-
case
|
|
333
|
+
case 14:
|
|
328
334
|
if (flag) {
|
|
329
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(labelInValue ?
|
|
335
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(labelInValue ? record : getNextValues(record), record);
|
|
330
336
|
// 更新内部展示值
|
|
331
337
|
setState({
|
|
332
|
-
_value:
|
|
333
|
-
options: (0, _lodash.isArray)(
|
|
338
|
+
_value: record,
|
|
339
|
+
options: (0, _lodash.isArray)(record) ? record : [record]
|
|
334
340
|
});
|
|
335
341
|
handleClose();
|
|
336
342
|
}
|
|
337
343
|
return _context2.abrupt("return", flag);
|
|
338
|
-
case
|
|
339
|
-
_context2.prev =
|
|
344
|
+
case 18:
|
|
345
|
+
_context2.prev = 18;
|
|
340
346
|
_context2.t0 = _context2["catch"](0);
|
|
341
347
|
console.warn('error', _context2.t0);
|
|
342
|
-
case
|
|
348
|
+
case 21:
|
|
343
349
|
case "end":
|
|
344
350
|
return _context2.stop();
|
|
345
351
|
}
|
|
346
|
-
}, _callee2, null, [[0,
|
|
352
|
+
}, _callee2, null, [[0, 18]]);
|
|
347
353
|
}));
|
|
348
354
|
return function handleFinish() {
|
|
349
355
|
return _ref7.apply(this, arguments);
|
|
@@ -424,7 +430,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
424
430
|
// 初始化回显,当传入initParams时,前端用来回险
|
|
425
431
|
var getInitValues = /*#__PURE__*/function () {
|
|
426
432
|
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4() {
|
|
427
|
-
var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _list, list, _res$data2,
|
|
433
|
+
var _contentForm$getField, _useRequest$options2, _useRequest$options3, queryBean, page, params, res, _list, list, _res$data2, _data, nextSelectRowKeys;
|
|
428
434
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
|
|
429
435
|
while (1) switch (_context4.prev = _context4.next) {
|
|
430
436
|
case 0:
|
|
@@ -455,15 +461,15 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
455
461
|
} else {
|
|
456
462
|
list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.list : res === null || res === void 0 ? void 0 : res.data;
|
|
457
463
|
}
|
|
458
|
-
|
|
459
|
-
if (
|
|
464
|
+
_data = isMultiple ? list : (_list = list) === null || _list === void 0 ? void 0 : _list[0];
|
|
465
|
+
if (_data) {
|
|
460
466
|
nextSelectRowKeys = isMultiple ? value : [value];
|
|
461
467
|
if (labelInValue) {
|
|
462
|
-
onChange(
|
|
468
|
+
onChange(_data);
|
|
463
469
|
}
|
|
464
470
|
// 更新内部展示值
|
|
465
471
|
setState({
|
|
466
|
-
_value:
|
|
472
|
+
_value: _data,
|
|
467
473
|
isInit: false,
|
|
468
474
|
selectedRows: list,
|
|
469
475
|
selectedRowKeys: nextSelectRowKeys
|
|
@@ -490,7 +496,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
490
496
|
var getDefaultOneValues = /*#__PURE__*/function () {
|
|
491
497
|
var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee5() {
|
|
492
498
|
var _useRequest$options4, _useRequest$options5;
|
|
493
|
-
var queryBean, page, params, res, _list2, list, _res$data3,
|
|
499
|
+
var queryBean, page, params, res, _list2, list, _res$data3, _data2, nextSelectRowKeys;
|
|
494
500
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee5$(_context5) {
|
|
495
501
|
while (1) switch (_context5.prev = _context5.next) {
|
|
496
502
|
case 0:
|
|
@@ -514,18 +520,18 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
514
520
|
} else {
|
|
515
521
|
list = withPagination ? res === null || res === void 0 ? void 0 : (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.list : res === null || res === void 0 ? void 0 : res.data;
|
|
516
522
|
}
|
|
517
|
-
|
|
523
|
+
_data2 = isMultiple ? list : (_list2 = list) === null || _list2 === void 0 ? void 0 : _list2[0];
|
|
518
524
|
nextSelectRowKeys = isMultiple ? value : [value];
|
|
519
525
|
if (labelInValue) {
|
|
520
|
-
onChange(
|
|
526
|
+
onChange(_data2);
|
|
521
527
|
} else {
|
|
522
|
-
onChange(isMultiple ?
|
|
528
|
+
onChange(isMultiple ? _data2.map(function (item) {
|
|
523
529
|
return item[valueKey];
|
|
524
|
-
}) :
|
|
530
|
+
}) : _data2[valueKey]);
|
|
525
531
|
}
|
|
526
532
|
// 更新内部展示值
|
|
527
533
|
setState({
|
|
528
|
-
_value:
|
|
534
|
+
_value: _data2,
|
|
529
535
|
isInit: false,
|
|
530
536
|
selectedRows: list,
|
|
531
537
|
selectedRowKeys: nextSelectRowKeys
|
|
@@ -594,8 +600,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
594
600
|
nextState.selectedRows = value;
|
|
595
601
|
}
|
|
596
602
|
} else if (value) {
|
|
603
|
+
console.log('value', value);
|
|
597
604
|
nextState.selectedRowKeys = [value];
|
|
598
|
-
nextState.selectedRows = [(0, _defineProperty2.default)({}, valueKey, value[valueKey])];
|
|
599
605
|
}
|
|
600
606
|
setState(nextState);
|
|
601
607
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
var _antd = require("antd");
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
var _lodash = require("lodash");
|
|
14
|
+
var _ahooks = require("ahooks");
|
|
15
|
+
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
16
|
+
var _RenderFields = _interopRequireDefault(require("../../render/RenderFields"));
|
|
17
|
+
var _utils = require("./utils");
|
|
18
|
+
var _ProForm = _interopRequireDefault(require("../../../../ProForm"));
|
|
19
|
+
var Group = function Group(props) {
|
|
20
|
+
var columns = props.children,
|
|
21
|
+
otherProps = props.otherProps,
|
|
22
|
+
className = props.className,
|
|
23
|
+
_props$space = props.space,
|
|
24
|
+
space = _props$space === void 0 ? {
|
|
25
|
+
size: 12
|
|
26
|
+
} : _props$space,
|
|
27
|
+
id = props.id,
|
|
28
|
+
value = props.value,
|
|
29
|
+
isView = props.isView,
|
|
30
|
+
index = props.index,
|
|
31
|
+
onFieldChange = props.onFieldChange,
|
|
32
|
+
namePath = props.namePath;
|
|
33
|
+
var _ref = _ProForm.default.useFieldProps() || {},
|
|
34
|
+
names = _ref.names,
|
|
35
|
+
name = _ref.name,
|
|
36
|
+
form = _ref.form,
|
|
37
|
+
_namePath = _ref.namePath;
|
|
38
|
+
var newNamePath = namePath || _namePath || [];
|
|
39
|
+
if (!Array.isArray(names)) {
|
|
40
|
+
console.error('Warning: Composite form components whose type is Group must be configured with names');
|
|
41
|
+
}
|
|
42
|
+
var data = (0, _react.useMemo)(function () {
|
|
43
|
+
var fieldList = [];
|
|
44
|
+
var result = columns.map(function (item) {
|
|
45
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
46
|
+
disabled: Boolean(props === null || props === void 0 ? void 0 : props.disabled)
|
|
47
|
+
}, item), {}, {
|
|
48
|
+
isView: isView !== null && isView !== void 0 ? isView : item.isView,
|
|
49
|
+
noStyle: (space === null || space === void 0 ? void 0 : space.compact) || (space === null || space === void 0 ? void 0 : space.separator),
|
|
50
|
+
parentNames: id,
|
|
51
|
+
namePath: newNamePath
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
var node = (0, _jsxRuntime.jsx)(_antd.Button, {
|
|
55
|
+
className: "group-separator",
|
|
56
|
+
children: space.separator
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
columns: (0, _utils.insertSeparator)(result, space, node, otherProps),
|
|
60
|
+
fieldList: fieldList
|
|
61
|
+
};
|
|
62
|
+
}, [name, columns, space, props, names]);
|
|
63
|
+
var _className = (0, _classnames2.default)((0, _defineProperty2.default)({
|
|
64
|
+
'pro-group': true,
|
|
65
|
+
'pro-group-diy-width': columns.some(function (item) {
|
|
66
|
+
var _item$fieldProps, _item$fieldProps$styl;
|
|
67
|
+
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;
|
|
68
|
+
}),
|
|
69
|
+
'pro-group-width-auto': columns.some(function (item) {
|
|
70
|
+
return ['Radio', 'Checkbox', 'Switch'].includes(item.type);
|
|
71
|
+
})
|
|
72
|
+
}, "".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
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
95
|
+
className: _className,
|
|
96
|
+
children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? (0, _jsxRuntime.jsx)(_antd.Space.Compact, {
|
|
97
|
+
children: (0, _jsxRuntime.jsx)(_RenderFields.default, (0, _objectSpread2.default)({
|
|
98
|
+
columns: data.columns,
|
|
99
|
+
form: form
|
|
100
|
+
}, _otherProps))
|
|
101
|
+
}) : (0, _jsxRuntime.jsx)(_antd.Space, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
102
|
+
align: "start"
|
|
103
|
+
}, (0, _lodash.omit)(space, ['separator', 'compact'])), {}, {
|
|
104
|
+
children: data.columns.map(function (column, index) {
|
|
105
|
+
return (0, _jsxRuntime.jsx)(_RenderFields.default, (0, _objectSpread2.default)({
|
|
106
|
+
columns: [column],
|
|
107
|
+
form: form
|
|
108
|
+
}, _otherProps), (column === null || column === void 0 ? void 0 : column.name) || index);
|
|
109
|
+
})
|
|
110
|
+
}))
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
var _default = exports.default = Group;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RowProps, SpaceProps } from 'antd';
|
|
3
|
+
import { FormInstance } from 'antd/es/form/Form';
|
|
4
|
+
import { NamePath } from 'antd/lib/form/interface';
|
|
5
|
+
import { ProColumnProps, ProFormOtherProps } 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?: ProColumnProps[];
|
|
20
|
+
space?: SpaceType;
|
|
21
|
+
otherProps?: ProFormOtherProps;
|
|
22
|
+
rowProps?: RowProps;
|
|
23
|
+
className?: string;
|
|
24
|
+
value?: any;
|
|
25
|
+
id?: string;
|
|
26
|
+
disabled?: boolean | (() => void);
|
|
27
|
+
isView?: boolean;
|
|
28
|
+
namePath?: NamePath;
|
|
29
|
+
index?: number;
|
|
30
|
+
onFieldChange?: (value: any[] | null, record: any, { form, }: {
|
|
31
|
+
form: FormInstance;
|
|
32
|
+
namePath?: NamePath;
|
|
33
|
+
index?: number;
|
|
34
|
+
}) => any;
|
|
35
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SpaceType } from './propsType';
|
|
3
|
+
/**
|
|
4
|
+
* 插入间隔符
|
|
5
|
+
* @param columns 表单配置数组
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const insertSeparator: (columns: any, space?: SpaceType, separatorNode?: ReactNode, otherProps?: any) => any;
|
|
9
|
+
/** 转换names */
|
|
10
|
+
export declare const transformNamesString: (arr: (string | string[])[]) => (string | string[])[];
|