@zat-design/sisyphus-react 3.7.2 → 3.7.3-beta.1
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 +27 -22
- package/es/ProEditTable/propsType.d.ts +1 -1
- package/es/ProEditTable/utils/getDefaultProps.js +2 -1
- package/es/ProForm/components/combination/FormList/utils.js +5 -4
- package/es/ProForm/components/combination/Group/component/ComRender.js +3 -1
- package/es/ProForm/components/combination/Group/utils.js +22 -5
- package/es/ProForm/utils/rulesCreator.d.ts +1 -1
- package/es/ProForm/utils/rulesCreator.js +25 -22
- package/es/ProForm/utils/valueType.js +2 -2
- package/es/ProSelect/index.js +11 -8
- package/es/ProSelect/propsType.d.ts +4 -0
- package/es/ProSelect/utils/index.d.ts +1 -7
- package/es/ProSelect/utils/index.js +13 -5
- package/es/ProUpload/index.js +1 -1
- package/es/ProUpload/propsType.d.ts +5 -0
- package/lib/ProEditTable/components/RenderField/index.js +28 -23
- package/lib/ProEditTable/propsType.d.ts +1 -1
- package/lib/ProEditTable/utils/getDefaultProps.js +3 -1
- package/lib/ProForm/components/combination/FormList/utils.js +4 -3
- package/lib/ProForm/components/combination/Group/component/ComRender.js +3 -1
- package/lib/ProForm/components/combination/Group/utils.js +22 -5
- package/lib/ProForm/utils/rulesCreator.d.ts +1 -1
- package/lib/ProForm/utils/rulesCreator.js +25 -22
- package/lib/ProForm/utils/valueType.js +2 -2
- package/lib/ProSelect/index.js +11 -8
- package/lib/ProSelect/propsType.d.ts +4 -0
- package/lib/ProSelect/utils/index.d.ts +1 -7
- package/lib/ProSelect/utils/index.js +13 -5
- package/lib/ProUpload/index.js +1 -1
- package/lib/ProUpload/propsType.d.ts +5 -0
- package/package.json +1 -1
|
@@ -79,6 +79,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
79
79
|
var _fieldProps = fieldProps || formItemProps || {};
|
|
80
80
|
var _rules = rules || [];
|
|
81
81
|
var _required = required;
|
|
82
|
+
var _valueType = valueType;
|
|
82
83
|
var _disabled = false;
|
|
83
84
|
var isCell = mode === 'cell';
|
|
84
85
|
if (isCell) {
|
|
@@ -103,11 +104,18 @@ var RenderField = function RenderField(_ref) {
|
|
|
103
104
|
};
|
|
104
105
|
// 行参数
|
|
105
106
|
var rowParams = [currentValue, rowData, options];
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
// required & rules & fieldProps & disabled & valueType 函数化处理
|
|
108
|
+
if (isFunction(required)) {
|
|
109
|
+
_required = required.apply(void 0, rowParams);
|
|
110
|
+
}
|
|
111
|
+
if (isFunction(fieldProps)) {
|
|
112
|
+
_fieldProps = fieldProps.apply(void 0, rowParams);
|
|
113
|
+
}
|
|
114
|
+
if (isFunction(rules)) {
|
|
115
|
+
_rules = rules.apply(void 0, rowParams);
|
|
116
|
+
}
|
|
117
|
+
if (isFunction(valueType)) {
|
|
118
|
+
_valueType = valueType.apply(void 0, rowParams);
|
|
111
119
|
}
|
|
112
120
|
// 获取最终的disabled
|
|
113
121
|
_disabled = getDisabled({
|
|
@@ -118,6 +126,12 @@ var RenderField = function RenderField(_ref) {
|
|
|
118
126
|
columnFieldProps: _fieldProps,
|
|
119
127
|
params: rowParams
|
|
120
128
|
});
|
|
129
|
+
if (typeof isEditable === 'function') {
|
|
130
|
+
isEditable = isEditable.apply(void 0, rowParams);
|
|
131
|
+
setTimeout(function () {
|
|
132
|
+
!isEditable && form.validateFields([cellName]);
|
|
133
|
+
}, 100);
|
|
134
|
+
}
|
|
121
135
|
// 是否只读文本
|
|
122
136
|
var isView = !isEditable || (record === null || record === void 0 ? void 0 : record['is-view']) || config.isView || virtualKey && !isEditing || getDisabled({
|
|
123
137
|
globalControl: otherProps === null || otherProps === void 0 ? void 0 : otherProps.globalControl,
|
|
@@ -131,15 +145,6 @@ var RenderField = function RenderField(_ref) {
|
|
|
131
145
|
// 只读文本时,采用当前formItem的name,单行编辑时,使用生成的虚拟的name
|
|
132
146
|
var baseName = isView ? name : namePath;
|
|
133
147
|
var TargetComponent;
|
|
134
|
-
if (isFunction(required)) {
|
|
135
|
-
_required = required.apply(void 0, rowParams);
|
|
136
|
-
}
|
|
137
|
-
if (isFunction(fieldProps)) {
|
|
138
|
-
_fieldProps = fieldProps.apply(void 0, rowParams);
|
|
139
|
-
}
|
|
140
|
-
if (isFunction(rules)) {
|
|
141
|
-
_rules = rules.apply(void 0, rowParams);
|
|
142
|
-
}
|
|
143
148
|
// 设置校验规则
|
|
144
149
|
var internalRule = useRules({
|
|
145
150
|
names: names,
|
|
@@ -165,7 +170,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
165
170
|
var _formItemProps = _objectSpread(_objectSpread(_objectSpread({}, defaultProps), resetProps), internalRule);
|
|
166
171
|
if (['Switch', 'SwitchCheckbox'].includes(type)) {
|
|
167
172
|
_formItemProps.valuePropName = 'checked';
|
|
168
|
-
|
|
173
|
+
_valueType = 'switch';
|
|
169
174
|
}
|
|
170
175
|
/**
|
|
171
176
|
* 针对一些特殊类型,基于formItem的normalize与getValueProps进行默认值类型转换
|
|
@@ -173,7 +178,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
173
178
|
*/
|
|
174
179
|
var defaultTransform = function defaultTransform() {
|
|
175
180
|
var types = ['DatePicker', 'RangePicker'];
|
|
176
|
-
if (!
|
|
181
|
+
if (!_valueType && types.includes(type)) {
|
|
177
182
|
var _transformMap$type;
|
|
178
183
|
return transformMap === null || transformMap === void 0 ? void 0 : (_transformMap$type = transformMap[type]) === null || _transformMap$type === void 0 ? void 0 : _transformMap$type.call(transformMap, _fieldProps || {});
|
|
179
184
|
}
|
|
@@ -186,18 +191,18 @@ var RenderField = function RenderField(_ref) {
|
|
|
186
191
|
var valueTypeTransform = useCallback(function () {
|
|
187
192
|
var _fieldProps3;
|
|
188
193
|
// 不存在valueType返回空
|
|
189
|
-
if (!
|
|
194
|
+
if (!_valueType) {
|
|
190
195
|
return {};
|
|
191
196
|
}
|
|
192
197
|
// SwitchCheckbox默认YN, 兼容已有组件
|
|
193
198
|
if (type === 'SwitchCheckbox') {
|
|
194
|
-
|
|
199
|
+
_valueType = 'switch';
|
|
195
200
|
}
|
|
196
201
|
var params = _objectSpread(_objectSpread({}, column), {}, {
|
|
197
202
|
mode: (_fieldProps3 = _fieldProps) === null || _fieldProps3 === void 0 ? void 0 : _fieldProps3.mode
|
|
198
203
|
});
|
|
199
|
-
return isFunction(valueTypeMap[
|
|
200
|
-
}, [
|
|
204
|
+
return isFunction(valueTypeMap[_valueType]) ? valueTypeMap[_valueType](params) : {};
|
|
205
|
+
}, [_valueType]);
|
|
201
206
|
if ((_names = names) === null || _names === void 0 ? void 0 : _names.length) {
|
|
202
207
|
// 支持names配置,临时生成对应的formItem,用来存储单个对应的值
|
|
203
208
|
names = names.map(function (key) {
|
|
@@ -228,7 +233,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
228
233
|
}
|
|
229
234
|
var namesStr = [].concat(_toConsumableArray(baseName), [index, dataIndex]);
|
|
230
235
|
var transform = {};
|
|
231
|
-
if (
|
|
236
|
+
if (_valueType) {
|
|
232
237
|
transform = valueTypeTransform();
|
|
233
238
|
}
|
|
234
239
|
return transformNames(_objectSpread(_objectSpread({}, _formItemProps), transform), form, names, namesStr, type);
|
|
@@ -508,7 +513,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
508
513
|
name: cellName,
|
|
509
514
|
listName: cellName,
|
|
510
515
|
viewEmpty: viewEmpty,
|
|
511
|
-
valueType:
|
|
516
|
+
valueType: _valueType,
|
|
512
517
|
isView: isView
|
|
513
518
|
}
|
|
514
519
|
});
|
|
@@ -96,7 +96,7 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro
|
|
|
96
96
|
names?: NamePath[];
|
|
97
97
|
cache?: boolean;
|
|
98
98
|
isEditable?: boolean | RequiredFn<T>;
|
|
99
|
-
valueType?: ProFormValueType;
|
|
99
|
+
valueType?: ProFormValueType | ((text?: any, record?: any, options?: OptionsProps) => ProFormValueType);
|
|
100
100
|
tooltip?: string | ({
|
|
101
101
|
icon?: string | ReactNode;
|
|
102
102
|
} & TooltipProps);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import { get, isEqual } from 'lodash';
|
|
2
3
|
var defaultPropsMap = {
|
|
3
4
|
ProSelect: function ProSelect(props) {
|
|
@@ -9,7 +10,7 @@ var defaultPropsMap = {
|
|
|
9
10
|
var defaultProps = {};
|
|
10
11
|
// formList场景传入列表过滤时
|
|
11
12
|
if (filterInList && namePath && name) {
|
|
12
|
-
var _namePath = namePath.
|
|
13
|
+
var _namePath = _toConsumableArray(namePath).splice(2, namePath.length - 1);
|
|
13
14
|
defaultProps.shouldUpdate = function (preValues, curValues) {
|
|
14
15
|
var _get, _get$map, _get2, _get2$map;
|
|
15
16
|
var preListValue = (_get = get(preValues, name)) === null || _get === void 0 ? void 0 : (_get$map = _get.map) === null || _get$map === void 0 ? void 0 : _get$map.call(_get, function (item) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isEqualWith
|
|
1
|
+
import { isEqualWith } from 'lodash';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* namesPath生产 [['list', 0, 'min'], ['list', 0, 'max']] => list_0_min-list_0_max
|
|
@@ -26,8 +26,9 @@ export var memoWith = function memoWith(pre, next) {
|
|
|
26
26
|
if ( /*#__PURE__*/React.isValidElement(objValue) && /*#__PURE__*/React.isValidElement(othValue)) {
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// 移除解决formlist函数里不更新问题
|
|
30
|
+
// if (isFunction(objValue) && isFunction(othValue)) {
|
|
31
|
+
// return true;
|
|
32
|
+
// }
|
|
32
33
|
});
|
|
33
34
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
-
var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps", "before", "after", "getValueProps", "valuePropName"];
|
|
4
|
+
var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps", "before", "after", "getValueProps", "valuePropName", "valueType"];
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import ConfirmWrapper from '../../../../components/render/ConfirmWrapper';
|
|
@@ -40,6 +40,7 @@ var ComRender = function ComRender(props) {
|
|
|
40
40
|
getValueProps = props.getValueProps,
|
|
41
41
|
_props$valuePropName = props.valuePropName,
|
|
42
42
|
valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
|
|
43
|
+
valueType = props.valueType,
|
|
43
44
|
rest = _objectWithoutProperties(props, _excluded);
|
|
44
45
|
var TypeComponent = componentMap[type];
|
|
45
46
|
var mergedGetValueProps = getValueProps || function (val) {
|
|
@@ -51,6 +52,7 @@ var ComRender = function ComRender(props) {
|
|
|
51
52
|
var Com = getComRender(Component, props, componentProps);
|
|
52
53
|
return _jsx(FieldProvider, {
|
|
53
54
|
value: _objectSpread(_objectSpread({}, contextProps), {}, {
|
|
55
|
+
valueType: valueType,
|
|
54
56
|
type: type
|
|
55
57
|
}),
|
|
56
58
|
children: Com
|
|
@@ -87,7 +87,7 @@ export var getReactiveProps = function getReactiveProps(params) {
|
|
|
87
87
|
component = params.component,
|
|
88
88
|
fieldProps = params.fieldProps,
|
|
89
89
|
name = params.name;
|
|
90
|
-
var values = form.
|
|
90
|
+
var values = namePath ? form.getFieldValue(namePath) : form.getFieldsValue();
|
|
91
91
|
var _disabled = isFunction(disabled) ? disabled(values, {
|
|
92
92
|
form: form,
|
|
93
93
|
index: index,
|
|
@@ -182,13 +182,14 @@ export var useTransformColumns = function useTransformColumns(params) {
|
|
|
182
182
|
mode = _ref.mode,
|
|
183
183
|
onChange = _ref.onChange,
|
|
184
184
|
onFieldChange = _ref.onFieldChange,
|
|
185
|
-
comDisabled = _ref.disabled
|
|
185
|
+
comDisabled = _ref.disabled,
|
|
186
|
+
onBlur = _ref.onBlur;
|
|
186
187
|
var _disabled = disabled || comDisabled;
|
|
187
188
|
var columnName = names ? names[index] : [].concat(name, index);
|
|
188
189
|
// 响应式字段改变后的回调
|
|
189
190
|
var changedCallback = function changedCallback(lastDependency, current) {
|
|
190
191
|
// 清值防抖 多次刷新时以最后一次为准
|
|
191
|
-
if (clearNotShow !== false) {
|
|
192
|
+
if (clearNotShow !== false && names) {
|
|
192
193
|
if ((current === null || current === void 0 ? void 0 : current.show) === false) {
|
|
193
194
|
clearInterval(timerRef.current[index]);
|
|
194
195
|
timerRef.current[index] = setTimeout(function () {
|
|
@@ -237,10 +238,12 @@ export var useTransformColumns = function useTransformColumns(params) {
|
|
|
237
238
|
args[_key] = arguments[_key];
|
|
238
239
|
}
|
|
239
240
|
newValue = valueFromEventWrapper(column, args);
|
|
240
|
-
if (
|
|
241
|
+
if (transform === null || transform === void 0 ? void 0 : transform.normalize) {
|
|
241
242
|
var _transform$normalize;
|
|
243
|
+
newValue = transform === null || transform === void 0 ? void 0 : (_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue);
|
|
244
|
+
} else if (normalize) {
|
|
242
245
|
// @ts-ignore
|
|
243
|
-
newValue =
|
|
246
|
+
newValue = normalize === null || normalize === void 0 ? void 0 : normalize(newValue);
|
|
244
247
|
}
|
|
245
248
|
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
|
246
249
|
var values = form.getFieldValue(namePath);
|
|
@@ -267,6 +270,19 @@ export var useTransformColumns = function useTransformColumns(params) {
|
|
|
267
270
|
}
|
|
268
271
|
}
|
|
269
272
|
};
|
|
273
|
+
var handleBlur = function handleBlur() {
|
|
274
|
+
if (!onBlur) return;
|
|
275
|
+
var values = form.getFieldValue(namePath);
|
|
276
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
277
|
+
args[_key2] = arguments[_key2];
|
|
278
|
+
}
|
|
279
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(args[0], values, {
|
|
280
|
+
index: outerIndex,
|
|
281
|
+
namePath: namePath,
|
|
282
|
+
form: form,
|
|
283
|
+
option: args === null || args === void 0 ? void 0 : args[1]
|
|
284
|
+
});
|
|
285
|
+
};
|
|
270
286
|
return _objectSpread(_objectSpread(_objectSpread({}, column), {}, {
|
|
271
287
|
name: columnName
|
|
272
288
|
}, reactiveProps), {}, {
|
|
@@ -274,6 +290,7 @@ export var useTransformColumns = function useTransformColumns(params) {
|
|
|
274
290
|
getValueProps: transform === null || transform === void 0 ? void 0 : transform.getValueProps,
|
|
275
291
|
fieldProps: _objectSpread(_objectSpread({}, column === null || column === void 0 ? void 0 : column.fieldProps), {}, {
|
|
276
292
|
onChange: handleChange,
|
|
293
|
+
onBlur: handleBlur,
|
|
277
294
|
value: value === null || value === void 0 ? void 0 : value[index]
|
|
278
295
|
})
|
|
279
296
|
});
|
|
@@ -14,35 +14,38 @@ var getNonEmptyValuesByIndex = function getNonEmptyValuesByIndex(required, value
|
|
|
14
14
|
};
|
|
15
15
|
export var rulesCreator = function rulesCreator(_ref) {
|
|
16
16
|
var _result;
|
|
17
|
-
var rules = _ref.rules,
|
|
17
|
+
var _ref$rules = _ref.rules,
|
|
18
|
+
rules = _ref$rules === void 0 ? [] : _ref$rules,
|
|
18
19
|
label = _ref.label,
|
|
19
20
|
isSelect = _ref.isSelect,
|
|
20
21
|
names = _ref.names,
|
|
21
22
|
required = _ref.required;
|
|
22
23
|
var message = "".concat(isSelect ? "".concat(locale.ProForm.selectPlaceHolder) : "".concat(locale.ProForm.inputPlaceholder)).concat(locale.ProForm.ruleText).concat(isString(label) ? label : '');
|
|
23
24
|
var result = [];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (Object
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
if (Array.isArray(rules)) {
|
|
26
|
+
result = rules.map(function (ruleItem) {
|
|
27
|
+
var rule = _objectSpread({}, ruleItem);
|
|
28
|
+
if (rule instanceof Object && 'type' in rule) {
|
|
29
|
+
if (Object.keys(regExp).includes(rule.type)) {
|
|
30
|
+
rule.validator = function (rule, value) {
|
|
31
|
+
if (!isNullValue(value) && !regExp[rule.type].test(value)) {
|
|
32
|
+
return Promise.reject(new Error(rule.message || message));
|
|
33
|
+
}
|
|
34
|
+
return Promise.resolve();
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (Object.keys(validate).includes(rule.type)) {
|
|
38
|
+
rule.validator = function (rule, value) {
|
|
39
|
+
if (!isNullValue(value) && !validate[rule.type](value)) {
|
|
40
|
+
return Promise.reject(new Error(rule.message || message));
|
|
41
|
+
}
|
|
42
|
+
return Promise.resolve();
|
|
43
|
+
};
|
|
44
|
+
}
|
|
42
45
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
+
return rule;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
46
49
|
if ((names === null || names === void 0 ? void 0 : names.length) && (required === null || required === void 0 ? void 0 : required.length)) {
|
|
47
50
|
var customRequired = {
|
|
48
51
|
validator: function validator(rules, value) {
|
|
@@ -18,7 +18,7 @@ var transformRatio = function transformRatio(_ref) {
|
|
|
18
18
|
return {
|
|
19
19
|
normalize: function normalize(value) {
|
|
20
20
|
if (!value || !value.some(function (item) {
|
|
21
|
-
return item;
|
|
21
|
+
return item || item === 0;
|
|
22
22
|
})) {
|
|
23
23
|
return {};
|
|
24
24
|
}
|
|
@@ -26,7 +26,7 @@ var transformRatio = function transformRatio(_ref) {
|
|
|
26
26
|
},
|
|
27
27
|
getValueProps: function getValueProps(value) {
|
|
28
28
|
if (!value || !value.some(function (item) {
|
|
29
|
-
return item;
|
|
29
|
+
return item || item === 0;
|
|
30
30
|
})) {
|
|
31
31
|
return {
|
|
32
32
|
value: []
|
package/es/ProSelect/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
9
9
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
10
10
|
import "antd/es/select/style";
|
|
11
11
|
import _Select from "antd/es/select";
|
|
12
|
-
var _excluded = ["dataSource", "defaultDisableValue", "useRequest", "fieldNames", "tooltip", "otherProps", "labelInValue", "filterInList", "scrollFollowParent", "defaultOne", "onSearch", "optionRender", "onChange", "updateDataSource", "transformResponse", "isView"];
|
|
12
|
+
var _excluded = ["dataSource", "defaultDisableValue", "useRequest", "fieldNames", "tooltip", "otherProps", "labelInValue", "filterInList", "scrollFollowParent", "defaultOne", "onSearch", "optionRender", "onChange", "updateDataSource", "transformResponse", "getValueProps", "isView"];
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { useDeepCompareEffect, useRequest as useRequestFunc } from 'ahooks';
|
|
15
15
|
import React, { useImperativeHandle, useState, forwardRef } from 'react';
|
|
@@ -53,10 +53,11 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
|
53
53
|
onChange = props.onChange,
|
|
54
54
|
updateDataSource = props.updateDataSource,
|
|
55
55
|
transformResponse = props.transformResponse,
|
|
56
|
+
getValueProps = props.getValueProps,
|
|
56
57
|
isViewPro = props.isView,
|
|
57
58
|
selectProps = _objectWithoutProperties(props, _excluded);
|
|
58
59
|
selectProps.showCodeName = (_selectProps$showCode = selectProps.showCodeName) !== null && _selectProps$showCode !== void 0 ? _selectProps$showCode : showCodeName;
|
|
59
|
-
var value = props.value;
|
|
60
|
+
var value = getValueProps && props.value ? getValueProps(props.value) : props.value;
|
|
60
61
|
var _ref2 = ProForm.useFieldProps() || {},
|
|
61
62
|
isViewCon = _ref2.isView,
|
|
62
63
|
viewEmpty = _ref2.viewEmpty;
|
|
@@ -216,6 +217,7 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
|
216
217
|
return props.children;
|
|
217
218
|
};
|
|
218
219
|
var handleChange = function handleChange(value, option) {
|
|
220
|
+
var getChangeValue = selectProps.getChangeValue;
|
|
219
221
|
if (selectProps.mode && selectProps.mode === 'multiple') {
|
|
220
222
|
if (Array.isArray(option)) {
|
|
221
223
|
option.forEach(function (item) {
|
|
@@ -225,14 +227,14 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
|
225
227
|
});
|
|
226
228
|
}
|
|
227
229
|
if (labelInValue) {
|
|
228
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(getValueObject(value), option);
|
|
230
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(getChangeValue ? getChangeValue(getValueObject(value)) : getValueObject(value), option);
|
|
229
231
|
} else {
|
|
230
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value, option);
|
|
232
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(getChangeValue ? getChangeValue(value) : value, option);
|
|
231
233
|
}
|
|
232
234
|
} else if (!selectProps.mode && labelInValue) {
|
|
233
|
-
onChange(getValueObject(value), option);
|
|
235
|
+
onChange(getChangeValue ? getChangeValue(getValueObject(value)) : getValueObject(value), option);
|
|
234
236
|
} else {
|
|
235
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value, option === null || option === void 0 ? void 0 : option.record);
|
|
237
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(getChangeValue ? getChangeValue(value) : value, option === null || option === void 0 ? void 0 : option.record);
|
|
236
238
|
}
|
|
237
239
|
};
|
|
238
240
|
/**
|
|
@@ -278,10 +280,11 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
|
278
280
|
if ((otherProps === null || otherProps === void 0 ? void 0 : otherProps.listName) && filterInList) {
|
|
279
281
|
newSelectList = getSelectList({
|
|
280
282
|
otherProps: otherProps,
|
|
281
|
-
value:
|
|
283
|
+
value: value,
|
|
282
284
|
dataSource: selectList,
|
|
283
285
|
labelInValue: labelInValue,
|
|
284
|
-
fieldNames: fieldNames
|
|
286
|
+
fieldNames: fieldNames,
|
|
287
|
+
mode: selectProps.mode
|
|
285
288
|
});
|
|
286
289
|
}
|
|
287
290
|
return _jsx("div", {
|
|
@@ -46,6 +46,10 @@ export interface PropSelectProps extends Omit<SelectProps, 'onSearch'> {
|
|
|
46
46
|
onSearch?: (value: string, useRequest: Result<any, any>) => void;
|
|
47
47
|
/** 自定义展示 */
|
|
48
48
|
optionRender?: (value: DataOption) => string | ReactNode;
|
|
49
|
+
/** 用来转换修改value值 和 getValueProps配合使用 */
|
|
50
|
+
getChangeValue?: (value: DataOption) => any;
|
|
51
|
+
/** 用来转换传入的value值 getChangeValue配合使用 */
|
|
52
|
+
getValueProps?: (value: DataOption) => any;
|
|
49
53
|
}
|
|
50
54
|
export interface ProSelectAction {
|
|
51
55
|
/** 实例方法、根据 code | code[] 批量获取数据 */
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 返回当前组件可以显示的数据源
|
|
3
3
|
*/
|
|
4
|
-
export declare const getSelectList: ({ otherProps, value, dataSource, labelInValue, fieldNames, }:
|
|
5
|
-
otherProps: any;
|
|
6
|
-
value: any;
|
|
7
|
-
dataSource: any;
|
|
8
|
-
labelInValue: any;
|
|
9
|
-
fieldNames: any;
|
|
10
|
-
}) => any;
|
|
4
|
+
export declare const getSelectList: ({ otherProps, value, dataSource, labelInValue, fieldNames, mode, }: any) => any;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
3
|
/* eslint-disable no-restricted-syntax */
|
|
3
4
|
import _ from 'lodash';
|
|
@@ -8,7 +9,8 @@ var findSelectNameValues = function findSelectNameValues(_ref) {
|
|
|
8
9
|
value = _ref.value,
|
|
9
10
|
dataSource = _ref.dataSource,
|
|
10
11
|
labelInValue = _ref.labelInValue,
|
|
11
|
-
fieldNames = _ref.fieldNames
|
|
12
|
+
fieldNames = _ref.fieldNames,
|
|
13
|
+
mode = _ref.mode;
|
|
12
14
|
var selectValues = [];
|
|
13
15
|
list.forEach(function (item) {
|
|
14
16
|
var result = item;
|
|
@@ -27,9 +29,13 @@ var findSelectNameValues = function findSelectNameValues(_ref) {
|
|
|
27
29
|
} finally {
|
|
28
30
|
_iterator.f();
|
|
29
31
|
}
|
|
30
|
-
|
|
32
|
+
if (mode === 'multiple') {
|
|
33
|
+
selectValues = [].concat(_toConsumableArray(selectValues), _toConsumableArray(result));
|
|
34
|
+
} else {
|
|
35
|
+
selectValues.push(result);
|
|
36
|
+
}
|
|
31
37
|
});
|
|
32
|
-
var diffList = _.difference(selectValues, [value]);
|
|
38
|
+
var diffList = _.difference(selectValues, mode === 'multiple' ? value : [value]);
|
|
33
39
|
return dataSource.filter(function (item) {
|
|
34
40
|
return !diffList.includes(labelInValue ? item : item[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value] || (item === null || item === void 0 ? void 0 : item.value));
|
|
35
41
|
});
|
|
@@ -42,7 +48,8 @@ export var getSelectList = function getSelectList(_ref2) {
|
|
|
42
48
|
value = _ref2.value,
|
|
43
49
|
dataSource = _ref2.dataSource,
|
|
44
50
|
labelInValue = _ref2.labelInValue,
|
|
45
|
-
fieldNames = _ref2.fieldNames
|
|
51
|
+
fieldNames = _ref2.fieldNames,
|
|
52
|
+
mode = _ref2.mode;
|
|
46
53
|
if (!otherProps) {
|
|
47
54
|
return null;
|
|
48
55
|
}
|
|
@@ -59,6 +66,7 @@ export var getSelectList = function getSelectList(_ref2) {
|
|
|
59
66
|
value: value,
|
|
60
67
|
dataSource: dataSource,
|
|
61
68
|
labelInValue: labelInValue,
|
|
62
|
-
fieldNames: fieldNames
|
|
69
|
+
fieldNames: fieldNames,
|
|
70
|
+
mode: mode
|
|
63
71
|
});
|
|
64
72
|
};
|
package/es/ProUpload/index.js
CHANGED
|
@@ -71,7 +71,7 @@ var ProUpload = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
71
71
|
fieldNames = props.fieldNames,
|
|
72
72
|
isConfirmDelete = props.isConfirmDelete,
|
|
73
73
|
residueProps = _objectWithoutProperties(props, _excluded);
|
|
74
|
-
var isView = otherProps === null || otherProps === void 0 ? void 0 : otherProps.isView;
|
|
74
|
+
var isView = (props === null || props === void 0 ? void 0 : props.isView) || (otherProps === null || otherProps === void 0 ? void 0 : otherProps.isView);
|
|
75
75
|
var sensor = useSensor(PointerSensor, {
|
|
76
76
|
activationConstraint: {
|
|
77
77
|
distance: 10
|
|
@@ -195,6 +195,11 @@ export interface ProUploadProps {
|
|
|
195
195
|
*/
|
|
196
196
|
isConfirmDelete?: boolean;
|
|
197
197
|
id?: string;
|
|
198
|
+
/**
|
|
199
|
+
* @description 查看模式
|
|
200
|
+
* @default false
|
|
201
|
+
*/
|
|
202
|
+
isView?: boolean;
|
|
198
203
|
}
|
|
199
204
|
export interface DraggableUploadListItemProps {
|
|
200
205
|
file: UploadFile<any>;
|
|
@@ -17,7 +17,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
17
17
|
var _antd = require("antd");
|
|
18
18
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
19
19
|
var _lodash = require("lodash");
|
|
20
|
-
var
|
|
20
|
+
var _valueType2 = _interopRequireDefault(require("../../../ProForm/utils/valueType"));
|
|
21
21
|
var _transform = _interopRequireDefault(require("../../utils/transform"));
|
|
22
22
|
var _tools = require("../../utils/tools");
|
|
23
23
|
var componentMap = _interopRequireWildcard(require("../../../ProForm/components"));
|
|
@@ -86,6 +86,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
86
86
|
var _fieldProps = fieldProps || formItemProps || {};
|
|
87
87
|
var _rules = rules || [];
|
|
88
88
|
var _required = required;
|
|
89
|
+
var _valueType = valueType;
|
|
89
90
|
var _disabled = false;
|
|
90
91
|
var isCell = mode === 'cell';
|
|
91
92
|
if (isCell) {
|
|
@@ -110,11 +111,18 @@ var RenderField = function RenderField(_ref) {
|
|
|
110
111
|
};
|
|
111
112
|
// 行参数
|
|
112
113
|
var rowParams = [currentValue, rowData, options];
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
// required & rules & fieldProps & disabled & valueType 函数化处理
|
|
115
|
+
if ((0, _lodash.isFunction)(required)) {
|
|
116
|
+
_required = required.apply(void 0, rowParams);
|
|
117
|
+
}
|
|
118
|
+
if ((0, _lodash.isFunction)(fieldProps)) {
|
|
119
|
+
_fieldProps = fieldProps.apply(void 0, rowParams);
|
|
120
|
+
}
|
|
121
|
+
if ((0, _lodash.isFunction)(rules)) {
|
|
122
|
+
_rules = rules.apply(void 0, rowParams);
|
|
123
|
+
}
|
|
124
|
+
if ((0, _lodash.isFunction)(valueType)) {
|
|
125
|
+
_valueType = valueType.apply(void 0, rowParams);
|
|
118
126
|
}
|
|
119
127
|
// 获取最终的disabled
|
|
120
128
|
_disabled = (0, _tools.getDisabled)({
|
|
@@ -125,6 +133,12 @@ var RenderField = function RenderField(_ref) {
|
|
|
125
133
|
columnFieldProps: _fieldProps,
|
|
126
134
|
params: rowParams
|
|
127
135
|
});
|
|
136
|
+
if (typeof isEditable === 'function') {
|
|
137
|
+
isEditable = isEditable.apply(void 0, rowParams);
|
|
138
|
+
setTimeout(function () {
|
|
139
|
+
!isEditable && form.validateFields([cellName]);
|
|
140
|
+
}, 100);
|
|
141
|
+
}
|
|
128
142
|
// 是否只读文本
|
|
129
143
|
var isView = !isEditable || (record === null || record === void 0 ? void 0 : record['is-view']) || config.isView || virtualKey && !isEditing || (0, _tools.getDisabled)({
|
|
130
144
|
globalControl: otherProps === null || otherProps === void 0 ? void 0 : otherProps.globalControl,
|
|
@@ -138,15 +152,6 @@ var RenderField = function RenderField(_ref) {
|
|
|
138
152
|
// 只读文本时,采用当前formItem的name,单行编辑时,使用生成的虚拟的name
|
|
139
153
|
var baseName = isView ? name : namePath;
|
|
140
154
|
var TargetComponent;
|
|
141
|
-
if ((0, _lodash.isFunction)(required)) {
|
|
142
|
-
_required = required.apply(void 0, rowParams);
|
|
143
|
-
}
|
|
144
|
-
if ((0, _lodash.isFunction)(fieldProps)) {
|
|
145
|
-
_fieldProps = fieldProps.apply(void 0, rowParams);
|
|
146
|
-
}
|
|
147
|
-
if ((0, _lodash.isFunction)(rules)) {
|
|
148
|
-
_rules = rules.apply(void 0, rowParams);
|
|
149
|
-
}
|
|
150
155
|
// 设置校验规则
|
|
151
156
|
var internalRule = (0, _useRules.default)({
|
|
152
157
|
names: names,
|
|
@@ -172,7 +177,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
172
177
|
var _formItemProps = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaultProps), resetProps), internalRule);
|
|
173
178
|
if (['Switch', 'SwitchCheckbox'].includes(type)) {
|
|
174
179
|
_formItemProps.valuePropName = 'checked';
|
|
175
|
-
|
|
180
|
+
_valueType = 'switch';
|
|
176
181
|
}
|
|
177
182
|
/**
|
|
178
183
|
* 针对一些特殊类型,基于formItem的normalize与getValueProps进行默认值类型转换
|
|
@@ -180,7 +185,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
180
185
|
*/
|
|
181
186
|
var defaultTransform = function defaultTransform() {
|
|
182
187
|
var types = ['DatePicker', 'RangePicker'];
|
|
183
|
-
if (!
|
|
188
|
+
if (!_valueType && types.includes(type)) {
|
|
184
189
|
var _transformMap$type;
|
|
185
190
|
return _transform.default === null || _transform.default === void 0 ? void 0 : (_transformMap$type = _transform.default[type]) === null || _transformMap$type === void 0 ? void 0 : _transformMap$type.call(_transform.default, _fieldProps || {});
|
|
186
191
|
}
|
|
@@ -193,18 +198,18 @@ var RenderField = function RenderField(_ref) {
|
|
|
193
198
|
var valueTypeTransform = (0, _react.useCallback)(function () {
|
|
194
199
|
var _fieldProps3;
|
|
195
200
|
// 不存在valueType返回空
|
|
196
|
-
if (!
|
|
201
|
+
if (!_valueType) {
|
|
197
202
|
return {};
|
|
198
203
|
}
|
|
199
204
|
// SwitchCheckbox默认YN, 兼容已有组件
|
|
200
205
|
if (type === 'SwitchCheckbox') {
|
|
201
|
-
|
|
206
|
+
_valueType = 'switch';
|
|
202
207
|
}
|
|
203
208
|
var params = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
|
|
204
209
|
mode: (_fieldProps3 = _fieldProps) === null || _fieldProps3 === void 0 ? void 0 : _fieldProps3.mode
|
|
205
210
|
});
|
|
206
|
-
return (0, _lodash.isFunction)(
|
|
207
|
-
}, [
|
|
211
|
+
return (0, _lodash.isFunction)(_valueType2.default[_valueType]) ? _valueType2.default[_valueType](params) : {};
|
|
212
|
+
}, [_valueType]);
|
|
208
213
|
if ((_names = names) === null || _names === void 0 ? void 0 : _names.length) {
|
|
209
214
|
// 支持names配置,临时生成对应的formItem,用来存储单个对应的值
|
|
210
215
|
names = names.map(function (key) {
|
|
@@ -235,7 +240,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
235
240
|
}
|
|
236
241
|
var namesStr = [].concat((0, _toConsumableArray2.default)(baseName), [index, dataIndex]);
|
|
237
242
|
var transform = {};
|
|
238
|
-
if (
|
|
243
|
+
if (_valueType) {
|
|
239
244
|
transform = valueTypeTransform();
|
|
240
245
|
}
|
|
241
246
|
return (0, _transformNames.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, _formItemProps), transform), form, names, namesStr, type);
|
|
@@ -515,7 +520,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
515
520
|
name: cellName,
|
|
516
521
|
listName: cellName,
|
|
517
522
|
viewEmpty: viewEmpty,
|
|
518
|
-
valueType:
|
|
523
|
+
valueType: _valueType,
|
|
519
524
|
isView: isView
|
|
520
525
|
}
|
|
521
526
|
});
|
|
@@ -96,7 +96,7 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro
|
|
|
96
96
|
names?: NamePath[];
|
|
97
97
|
cache?: boolean;
|
|
98
98
|
isEditable?: boolean | RequiredFn<T>;
|
|
99
|
-
valueType?: ProFormValueType;
|
|
99
|
+
valueType?: ProFormValueType | ((text?: any, record?: any, options?: OptionsProps) => ProFormValueType);
|
|
100
100
|
tooltip?: string | ({
|
|
101
101
|
icon?: string | ReactNode;
|
|
102
102
|
} & TooltipProps);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.getDefaultProps = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
9
|
var _lodash = require("lodash");
|
|
8
10
|
var defaultPropsMap = {
|
|
9
11
|
ProSelect: function ProSelect(props) {
|
|
@@ -15,7 +17,7 @@ var defaultPropsMap = {
|
|
|
15
17
|
var defaultProps = {};
|
|
16
18
|
// formList场景传入列表过滤时
|
|
17
19
|
if (filterInList && namePath && name) {
|
|
18
|
-
var _namePath = namePath.
|
|
20
|
+
var _namePath = (0, _toConsumableArray2.default)(namePath).splice(2, namePath.length - 1);
|
|
19
21
|
defaultProps.shouldUpdate = function (preValues, curValues) {
|
|
20
22
|
var _get, _get$map, _get2, _get2$map;
|
|
21
23
|
var preListValue = (_get = (0, _lodash.get)(preValues, name)) === null || _get === void 0 ? void 0 : (_get$map = _get.map) === null || _get$map === void 0 ? void 0 : _get$map.call(_get, function (item) {
|
|
@@ -33,8 +33,9 @@ var memoWith = exports.memoWith = function memoWith(pre, next) {
|
|
|
33
33
|
if ( /*#__PURE__*/_react.default.isValidElement(objValue) && /*#__PURE__*/_react.default.isValidElement(othValue)) {
|
|
34
34
|
return true;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
// 移除解决formlist函数里不更新问题
|
|
37
|
+
// if (isFunction(objValue) && isFunction(othValue)) {
|
|
38
|
+
// return true;
|
|
39
|
+
// }
|
|
39
40
|
});
|
|
40
41
|
};
|
|
@@ -15,7 +15,7 @@ var _ConfirmWrapper = _interopRequireDefault(require("../../../../components/ren
|
|
|
15
15
|
var _useFieldProps = require("../../../../utils/useFieldProps");
|
|
16
16
|
var componentMap = _interopRequireWildcard(require("../../../../../index"));
|
|
17
17
|
var _AddonWrapper = _interopRequireDefault(require("./AddonWrapper"));
|
|
18
|
-
var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps", "before", "after", "getValueProps", "valuePropName"];
|
|
18
|
+
var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps", "before", "after", "getValueProps", "valuePropName", "valueType"];
|
|
19
19
|
// 这里的key与组件内参数一致, 决定使用哪个包裹组件
|
|
20
20
|
var wrapperMap = {
|
|
21
21
|
confirm: _ConfirmWrapper.default,
|
|
@@ -48,6 +48,7 @@ var ComRender = function ComRender(props) {
|
|
|
48
48
|
getValueProps = props.getValueProps,
|
|
49
49
|
_props$valuePropName = props.valuePropName,
|
|
50
50
|
valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
|
|
51
|
+
valueType = props.valueType,
|
|
51
52
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
52
53
|
var TypeComponent = componentMap[type];
|
|
53
54
|
var mergedGetValueProps = getValueProps || function (val) {
|
|
@@ -59,6 +60,7 @@ var ComRender = function ComRender(props) {
|
|
|
59
60
|
var Com = getComRender(Component, props, componentProps);
|
|
60
61
|
return (0, _jsxRuntime.jsx)(_useFieldProps.FieldProvider, {
|
|
61
62
|
value: (0, _objectSpread3.default)((0, _objectSpread3.default)({}, contextProps), {}, {
|
|
63
|
+
valueType: valueType,
|
|
62
64
|
type: type
|
|
63
65
|
}),
|
|
64
66
|
children: Com
|
|
@@ -94,7 +94,7 @@ var getReactiveProps = exports.getReactiveProps = function getReactiveProps(para
|
|
|
94
94
|
component = params.component,
|
|
95
95
|
fieldProps = params.fieldProps,
|
|
96
96
|
name = params.name;
|
|
97
|
-
var values = form.
|
|
97
|
+
var values = namePath ? form.getFieldValue(namePath) : form.getFieldsValue();
|
|
98
98
|
var _disabled = (0, _lodash.isFunction)(disabled) ? disabled(values, {
|
|
99
99
|
form: form,
|
|
100
100
|
index: index,
|
|
@@ -189,13 +189,14 @@ var useTransformColumns = exports.useTransformColumns = function useTransformCol
|
|
|
189
189
|
mode = _ref.mode,
|
|
190
190
|
onChange = _ref.onChange,
|
|
191
191
|
onFieldChange = _ref.onFieldChange,
|
|
192
|
-
comDisabled = _ref.disabled
|
|
192
|
+
comDisabled = _ref.disabled,
|
|
193
|
+
onBlur = _ref.onBlur;
|
|
193
194
|
var _disabled = disabled || comDisabled;
|
|
194
195
|
var columnName = names ? names[index] : [].concat(name, index);
|
|
195
196
|
// 响应式字段改变后的回调
|
|
196
197
|
var changedCallback = function changedCallback(lastDependency, current) {
|
|
197
198
|
// 清值防抖 多次刷新时以最后一次为准
|
|
198
|
-
if (clearNotShow !== false) {
|
|
199
|
+
if (clearNotShow !== false && names) {
|
|
199
200
|
if ((current === null || current === void 0 ? void 0 : current.show) === false) {
|
|
200
201
|
clearInterval(timerRef.current[index]);
|
|
201
202
|
timerRef.current[index] = setTimeout(function () {
|
|
@@ -244,10 +245,12 @@ var useTransformColumns = exports.useTransformColumns = function useTransformCol
|
|
|
244
245
|
args[_key] = arguments[_key];
|
|
245
246
|
}
|
|
246
247
|
newValue = valueFromEventWrapper(column, args);
|
|
247
|
-
if (
|
|
248
|
+
if (transform === null || transform === void 0 ? void 0 : transform.normalize) {
|
|
248
249
|
var _transform$normalize;
|
|
250
|
+
newValue = transform === null || transform === void 0 ? void 0 : (_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue);
|
|
251
|
+
} else if (normalize) {
|
|
249
252
|
// @ts-ignore
|
|
250
|
-
newValue =
|
|
253
|
+
newValue = normalize === null || normalize === void 0 ? void 0 : normalize(newValue);
|
|
251
254
|
}
|
|
252
255
|
internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
|
|
253
256
|
var values = form.getFieldValue(namePath);
|
|
@@ -274,6 +277,19 @@ var useTransformColumns = exports.useTransformColumns = function useTransformCol
|
|
|
274
277
|
}
|
|
275
278
|
}
|
|
276
279
|
};
|
|
280
|
+
var handleBlur = function handleBlur() {
|
|
281
|
+
if (!onBlur) return;
|
|
282
|
+
var values = form.getFieldValue(namePath);
|
|
283
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
284
|
+
args[_key2] = arguments[_key2];
|
|
285
|
+
}
|
|
286
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(args[0], values, {
|
|
287
|
+
index: outerIndex,
|
|
288
|
+
namePath: namePath,
|
|
289
|
+
form: form,
|
|
290
|
+
option: args === null || args === void 0 ? void 0 : args[1]
|
|
291
|
+
});
|
|
292
|
+
};
|
|
277
293
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
|
|
278
294
|
name: columnName
|
|
279
295
|
}, reactiveProps), {}, {
|
|
@@ -281,6 +297,7 @@ var useTransformColumns = exports.useTransformColumns = function useTransformCol
|
|
|
281
297
|
getValueProps: transform === null || transform === void 0 ? void 0 : transform.getValueProps,
|
|
282
298
|
fieldProps: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, column === null || column === void 0 ? void 0 : column.fieldProps), {}, {
|
|
283
299
|
onChange: handleChange,
|
|
300
|
+
onBlur: handleBlur,
|
|
284
301
|
value: value === null || value === void 0 ? void 0 : value[index]
|
|
285
302
|
})
|
|
286
303
|
});
|
|
@@ -22,35 +22,38 @@ var getNonEmptyValuesByIndex = function getNonEmptyValuesByIndex(required, value
|
|
|
22
22
|
};
|
|
23
23
|
var rulesCreator = exports.rulesCreator = function rulesCreator(_ref) {
|
|
24
24
|
var _result;
|
|
25
|
-
var rules = _ref.rules,
|
|
25
|
+
var _ref$rules = _ref.rules,
|
|
26
|
+
rules = _ref$rules === void 0 ? [] : _ref$rules,
|
|
26
27
|
label = _ref.label,
|
|
27
28
|
isSelect = _ref.isSelect,
|
|
28
29
|
names = _ref.names,
|
|
29
30
|
required = _ref.required;
|
|
30
31
|
var message = "".concat(isSelect ? "".concat(_locale.default.ProForm.selectPlaceHolder) : "".concat(_locale.default.ProForm.inputPlaceholder)).concat(_locale.default.ProForm.ruleText).concat((0, _lodash.isString)(label) ? label : '');
|
|
31
32
|
var result = [];
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (Object
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
if (Array.isArray(rules)) {
|
|
34
|
+
result = rules.map(function (ruleItem) {
|
|
35
|
+
var rule = (0, _objectSpread2.default)({}, ruleItem);
|
|
36
|
+
if (rule instanceof Object && 'type' in rule) {
|
|
37
|
+
if (Object.keys(_utils.regExp).includes(rule.type)) {
|
|
38
|
+
rule.validator = function (rule, value) {
|
|
39
|
+
if (!(0, _index.isNullValue)(value) && !_utils.regExp[rule.type].test(value)) {
|
|
40
|
+
return Promise.reject(new Error(rule.message || message));
|
|
41
|
+
}
|
|
42
|
+
return Promise.resolve();
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (Object.keys(_utils.validate).includes(rule.type)) {
|
|
46
|
+
rule.validator = function (rule, value) {
|
|
47
|
+
if (!(0, _index.isNullValue)(value) && !_utils.validate[rule.type](value)) {
|
|
48
|
+
return Promise.reject(new Error(rule.message || message));
|
|
49
|
+
}
|
|
50
|
+
return Promise.resolve();
|
|
51
|
+
};
|
|
52
|
+
}
|
|
50
53
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
+
return rule;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
54
57
|
if ((names === null || names === void 0 ? void 0 : names.length) && (required === null || required === void 0 ? void 0 : required.length)) {
|
|
55
58
|
var customRequired = {
|
|
56
59
|
validator: function validator(rules, value) {
|
|
@@ -25,7 +25,7 @@ var transformRatio = function transformRatio(_ref) {
|
|
|
25
25
|
return {
|
|
26
26
|
normalize: function normalize(value) {
|
|
27
27
|
if (!value || !value.some(function (item) {
|
|
28
|
-
return item;
|
|
28
|
+
return item || item === 0;
|
|
29
29
|
})) {
|
|
30
30
|
return {};
|
|
31
31
|
}
|
|
@@ -33,7 +33,7 @@ var transformRatio = function transformRatio(_ref) {
|
|
|
33
33
|
},
|
|
34
34
|
getValueProps: function getValueProps(value) {
|
|
35
35
|
if (!value || !value.some(function (item) {
|
|
36
|
-
return item;
|
|
36
|
+
return item || item === 0;
|
|
37
37
|
})) {
|
|
38
38
|
return {
|
|
39
39
|
value: []
|
package/lib/ProSelect/index.js
CHANGED
|
@@ -21,7 +21,7 @@ var _ = require("..");
|
|
|
21
21
|
var _locale = _interopRequireDefault(require("../locale"));
|
|
22
22
|
var _utils = require("./utils");
|
|
23
23
|
require("./index.less");
|
|
24
|
-
var _excluded = ["dataSource", "defaultDisableValue", "useRequest", "fieldNames", "tooltip", "otherProps", "labelInValue", "filterInList", "scrollFollowParent", "defaultOne", "onSearch", "optionRender", "onChange", "updateDataSource", "transformResponse", "isView"];
|
|
24
|
+
var _excluded = ["dataSource", "defaultDisableValue", "useRequest", "fieldNames", "tooltip", "otherProps", "labelInValue", "filterInList", "scrollFollowParent", "defaultOne", "onSearch", "optionRender", "onChange", "updateDataSource", "transformResponse", "getValueProps", "isView"];
|
|
25
25
|
var Option = _antd.Select.Option;
|
|
26
26
|
var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
|
27
27
|
var _selectProps$showCode, _locale$ProSelect;
|
|
@@ -54,10 +54,11 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
|
|
54
54
|
onChange = props.onChange,
|
|
55
55
|
updateDataSource = props.updateDataSource,
|
|
56
56
|
transformResponse = props.transformResponse,
|
|
57
|
+
getValueProps = props.getValueProps,
|
|
57
58
|
isViewPro = props.isView,
|
|
58
59
|
selectProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
59
60
|
selectProps.showCodeName = (_selectProps$showCode = selectProps.showCodeName) !== null && _selectProps$showCode !== void 0 ? _selectProps$showCode : showCodeName;
|
|
60
|
-
var value = props.value;
|
|
61
|
+
var value = getValueProps && props.value ? getValueProps(props.value) : props.value;
|
|
61
62
|
var _ref2 = _.ProForm.useFieldProps() || {},
|
|
62
63
|
isViewCon = _ref2.isView,
|
|
63
64
|
viewEmpty = _ref2.viewEmpty;
|
|
@@ -217,6 +218,7 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
|
|
217
218
|
return props.children;
|
|
218
219
|
};
|
|
219
220
|
var handleChange = function handleChange(value, option) {
|
|
221
|
+
var getChangeValue = selectProps.getChangeValue;
|
|
220
222
|
if (selectProps.mode && selectProps.mode === 'multiple') {
|
|
221
223
|
if (Array.isArray(option)) {
|
|
222
224
|
option.forEach(function (item) {
|
|
@@ -226,14 +228,14 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
|
|
226
228
|
});
|
|
227
229
|
}
|
|
228
230
|
if (labelInValue) {
|
|
229
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(getValueObject(value), option);
|
|
231
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(getChangeValue ? getChangeValue(getValueObject(value)) : getValueObject(value), option);
|
|
230
232
|
} else {
|
|
231
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value, option);
|
|
233
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(getChangeValue ? getChangeValue(value) : value, option);
|
|
232
234
|
}
|
|
233
235
|
} else if (!selectProps.mode && labelInValue) {
|
|
234
|
-
onChange(getValueObject(value), option);
|
|
236
|
+
onChange(getChangeValue ? getChangeValue(getValueObject(value)) : getValueObject(value), option);
|
|
235
237
|
} else {
|
|
236
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value, option === null || option === void 0 ? void 0 : option.record);
|
|
238
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(getChangeValue ? getChangeValue(value) : value, option === null || option === void 0 ? void 0 : option.record);
|
|
237
239
|
}
|
|
238
240
|
};
|
|
239
241
|
/**
|
|
@@ -279,10 +281,11 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
|
|
279
281
|
if ((otherProps === null || otherProps === void 0 ? void 0 : otherProps.listName) && filterInList) {
|
|
280
282
|
newSelectList = (0, _utils.getSelectList)({
|
|
281
283
|
otherProps: otherProps,
|
|
282
|
-
value:
|
|
284
|
+
value: value,
|
|
283
285
|
dataSource: selectList,
|
|
284
286
|
labelInValue: labelInValue,
|
|
285
|
-
fieldNames: fieldNames
|
|
287
|
+
fieldNames: fieldNames,
|
|
288
|
+
mode: selectProps.mode
|
|
286
289
|
});
|
|
287
290
|
}
|
|
288
291
|
return (0, _jsxRuntime.jsx)("div", {
|
|
@@ -46,6 +46,10 @@ export interface PropSelectProps extends Omit<SelectProps, 'onSearch'> {
|
|
|
46
46
|
onSearch?: (value: string, useRequest: Result<any, any>) => void;
|
|
47
47
|
/** 自定义展示 */
|
|
48
48
|
optionRender?: (value: DataOption) => string | ReactNode;
|
|
49
|
+
/** 用来转换修改value值 和 getValueProps配合使用 */
|
|
50
|
+
getChangeValue?: (value: DataOption) => any;
|
|
51
|
+
/** 用来转换传入的value值 getChangeValue配合使用 */
|
|
52
|
+
getValueProps?: (value: DataOption) => any;
|
|
49
53
|
}
|
|
50
54
|
export interface ProSelectAction {
|
|
51
55
|
/** 实例方法、根据 code | code[] 批量获取数据 */
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 返回当前组件可以显示的数据源
|
|
3
3
|
*/
|
|
4
|
-
export declare const getSelectList: ({ otherProps, value, dataSource, labelInValue, fieldNames, }:
|
|
5
|
-
otherProps: any;
|
|
6
|
-
value: any;
|
|
7
|
-
dataSource: any;
|
|
8
|
-
labelInValue: any;
|
|
9
|
-
fieldNames: any;
|
|
10
|
-
}) => any;
|
|
4
|
+
export declare const getSelectList: ({ otherProps, value, dataSource, labelInValue, fieldNames, mode, }: any) => any;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getSelectList = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
8
9
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
9
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
11
|
/* eslint-disable no-restricted-syntax */
|
|
@@ -16,7 +17,8 @@ var findSelectNameValues = function findSelectNameValues(_ref) {
|
|
|
16
17
|
value = _ref.value,
|
|
17
18
|
dataSource = _ref.dataSource,
|
|
18
19
|
labelInValue = _ref.labelInValue,
|
|
19
|
-
fieldNames = _ref.fieldNames
|
|
20
|
+
fieldNames = _ref.fieldNames,
|
|
21
|
+
mode = _ref.mode;
|
|
20
22
|
var selectValues = [];
|
|
21
23
|
list.forEach(function (item) {
|
|
22
24
|
var result = item;
|
|
@@ -35,9 +37,13 @@ var findSelectNameValues = function findSelectNameValues(_ref) {
|
|
|
35
37
|
} finally {
|
|
36
38
|
_iterator.f();
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
if (mode === 'multiple') {
|
|
41
|
+
selectValues = [].concat((0, _toConsumableArray2.default)(selectValues), (0, _toConsumableArray2.default)(result));
|
|
42
|
+
} else {
|
|
43
|
+
selectValues.push(result);
|
|
44
|
+
}
|
|
39
45
|
});
|
|
40
|
-
var diffList = _lodash.default.difference(selectValues, [value]);
|
|
46
|
+
var diffList = _lodash.default.difference(selectValues, mode === 'multiple' ? value : [value]);
|
|
41
47
|
return dataSource.filter(function (item) {
|
|
42
48
|
return !diffList.includes(labelInValue ? item : item[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value] || (item === null || item === void 0 ? void 0 : item.value));
|
|
43
49
|
});
|
|
@@ -50,7 +56,8 @@ var getSelectList = exports.getSelectList = function getSelectList(_ref2) {
|
|
|
50
56
|
value = _ref2.value,
|
|
51
57
|
dataSource = _ref2.dataSource,
|
|
52
58
|
labelInValue = _ref2.labelInValue,
|
|
53
|
-
fieldNames = _ref2.fieldNames
|
|
59
|
+
fieldNames = _ref2.fieldNames,
|
|
60
|
+
mode = _ref2.mode;
|
|
54
61
|
if (!otherProps) {
|
|
55
62
|
return null;
|
|
56
63
|
}
|
|
@@ -67,6 +74,7 @@ var getSelectList = exports.getSelectList = function getSelectList(_ref2) {
|
|
|
67
74
|
value: value,
|
|
68
75
|
dataSource: dataSource,
|
|
69
76
|
labelInValue: labelInValue,
|
|
70
|
-
fieldNames: fieldNames
|
|
77
|
+
fieldNames: fieldNames,
|
|
78
|
+
mode: mode
|
|
71
79
|
});
|
|
72
80
|
};
|
package/lib/ProUpload/index.js
CHANGED
|
@@ -78,7 +78,7 @@ var ProUpload = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
78
78
|
fieldNames = props.fieldNames,
|
|
79
79
|
isConfirmDelete = props.isConfirmDelete,
|
|
80
80
|
residueProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
81
|
-
var isView = otherProps === null || otherProps === void 0 ? void 0 : otherProps.isView;
|
|
81
|
+
var isView = (props === null || props === void 0 ? void 0 : props.isView) || (otherProps === null || otherProps === void 0 ? void 0 : otherProps.isView);
|
|
82
82
|
var sensor = (0, _core.useSensor)(_core.PointerSensor, {
|
|
83
83
|
activationConstraint: {
|
|
84
84
|
distance: 10
|
|
@@ -195,6 +195,11 @@ export interface ProUploadProps {
|
|
|
195
195
|
*/
|
|
196
196
|
isConfirmDelete?: boolean;
|
|
197
197
|
id?: string;
|
|
198
|
+
/**
|
|
199
|
+
* @description 查看模式
|
|
200
|
+
* @default false
|
|
201
|
+
*/
|
|
202
|
+
isView?: boolean;
|
|
198
203
|
}
|
|
199
204
|
export interface DraggableUploadListItemProps {
|
|
200
205
|
file: UploadFile<any>;
|