@zat-design/sisyphus-react 3.7.2-beta.1 → 3.7.2-beta.11
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/utils/getDefaultProps.js +2 -1
- 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 +2 -1
- 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/utils/getDefaultProps.js +3 -1
- 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 +2 -1
- 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
|
@@ -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,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
|
@@ -281,7 +281,8 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
|
281
281
|
value: props.value,
|
|
282
282
|
dataSource: selectList,
|
|
283
283
|
labelInValue: labelInValue,
|
|
284
|
-
fieldNames: fieldNames
|
|
284
|
+
fieldNames: fieldNames,
|
|
285
|
+
mode: selectProps.mode
|
|
285
286
|
});
|
|
286
287
|
}
|
|
287
288
|
return _jsx("div", {
|
|
@@ -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>;
|
|
@@ -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) {
|
|
@@ -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
|
@@ -282,7 +282,8 @@ var ProSelect = exports.ProSelect = function ProSelect(props, ref) {
|
|
|
282
282
|
value: props.value,
|
|
283
283
|
dataSource: selectList,
|
|
284
284
|
labelInValue: labelInValue,
|
|
285
|
-
fieldNames: fieldNames
|
|
285
|
+
fieldNames: fieldNames,
|
|
286
|
+
mode: selectProps.mode
|
|
286
287
|
});
|
|
287
288
|
}
|
|
288
289
|
return (0, _jsxRuntime.jsx)("div", {
|
|
@@ -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>;
|