@zat-design/sisyphus-react 3.4.3-beta.1 → 3.4.3-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.css +3 -0
- package/dist/less.esm.css +3 -0
- package/es/ProForm/components/combination/Group/index.js +3 -2
- package/es/ProForm/components/render/RenderFields.d.ts +1 -1
- package/es/ProForm/components/render/propsType.d.ts +1 -1
- package/es/ProForm/propsType.d.ts +2 -2
- package/es/ProForm/utils/index.d.ts +1 -1
- package/es/ProForm/utils/index.js +6 -1
- package/es/ProForm/utils/rulesCreator.d.ts +7 -1
- package/es/ProForm/utils/rulesCreator.js +33 -3
- package/es/ProForm/utils/useRules.js +36 -11
- package/es/ProForm/utils/useShouldUpdate.js +4 -4
- package/es/ProTree/components/ProTreeSelect/style/index.less +1 -1
- package/es/ProTree/style/index.less +5 -0
- package/es/locale/en_US.d.ts +1 -0
- package/es/locale/en_US.js +1 -0
- package/es/locale/zh_CN.d.ts +1 -0
- package/es/locale/zh_CN.js +1 -0
- package/es/style/theme/antd.less +4 -4
- package/lib/ProForm/components/combination/Group/index.js +3 -2
- package/lib/ProForm/components/render/RenderFields.d.ts +1 -1
- package/lib/ProForm/components/render/propsType.d.ts +1 -1
- package/lib/ProForm/propsType.d.ts +2 -2
- package/lib/ProForm/utils/index.d.ts +1 -1
- package/lib/ProForm/utils/index.js +6 -1
- package/lib/ProForm/utils/rulesCreator.d.ts +7 -1
- package/lib/ProForm/utils/rulesCreator.js +33 -2
- package/lib/ProForm/utils/useRules.js +36 -11
- package/lib/ProForm/utils/useShouldUpdate.js +4 -4
- package/lib/ProTree/components/ProTreeSelect/style/index.less +1 -1
- package/lib/ProTree/style/index.less +5 -0
- package/lib/locale/en_US.d.ts +1 -0
- package/lib/locale/en_US.js +1 -0
- package/lib/locale/zh_CN.d.ts +1 -0
- package/lib/locale/zh_CN.js +1 -0
- package/lib/style/theme/antd.less +4 -4
- package/package.json +1 -1
package/dist/index.esm.css
CHANGED
|
@@ -3864,6 +3864,9 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
|
|
|
3864
3864
|
.pro-form.pro-form-view .ant-form-item .pro-tree .ant-tree-checkbox * {
|
|
3865
3865
|
height: 16px !important;
|
|
3866
3866
|
}
|
|
3867
|
+
.ant-select-dropdown.pro-tree-select-drop-down-container.checkable-tree {
|
|
3868
|
+
overflow: hidden!important;
|
|
3869
|
+
}
|
|
3867
3870
|
.pro-drawer .pro-drawer-close {
|
|
3868
3871
|
position: absolute;
|
|
3869
3872
|
top: 6px;
|
package/dist/less.esm.css
CHANGED
|
@@ -3864,6 +3864,9 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
|
|
|
3864
3864
|
.pro-form.pro-form-view .ant-form-item .pro-tree .ant-tree-checkbox * {
|
|
3865
3865
|
height: 16px !important;
|
|
3866
3866
|
}
|
|
3867
|
+
.ant-select-dropdown.pro-tree-select-drop-down-container.checkable-tree {
|
|
3868
|
+
overflow: hidden!important;
|
|
3869
|
+
}
|
|
3867
3870
|
.pro-drawer .pro-drawer-close {
|
|
3868
3871
|
position: absolute;
|
|
3869
3872
|
top: 6px;
|
|
@@ -86,13 +86,14 @@ var Group = function Group(props) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
}, [value]);
|
|
89
|
+
var _otherProps = omit(otherProps, ['colProps', 'required']);
|
|
89
90
|
return _jsx("div", {
|
|
90
91
|
className: _className,
|
|
91
92
|
children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? _jsx(_Space.Compact, {
|
|
92
93
|
children: _jsx(RenderFields, _objectSpread({
|
|
93
94
|
columns: data.columns,
|
|
94
95
|
form: form
|
|
95
|
-
},
|
|
96
|
+
}, _otherProps))
|
|
96
97
|
}) : _jsx(_Space, _objectSpread(_objectSpread({
|
|
97
98
|
align: "start"
|
|
98
99
|
}, omit(space, ['separator', 'compact'])), {}, {
|
|
@@ -100,7 +101,7 @@ var Group = function Group(props) {
|
|
|
100
101
|
return _jsx(RenderFields, _objectSpread({
|
|
101
102
|
columns: [column],
|
|
102
103
|
form: form
|
|
103
|
-
},
|
|
104
|
+
}, _otherProps), (column === null || column === void 0 ? void 0 : column.name) || index);
|
|
104
105
|
})
|
|
105
106
|
}))
|
|
106
107
|
});
|
|
@@ -16,7 +16,7 @@ interface Props<T = any> {
|
|
|
16
16
|
originalValues?: ProFormProps<T>['originalValues'];
|
|
17
17
|
clearNotShow?: boolean;
|
|
18
18
|
requiredOnView?: boolean;
|
|
19
|
-
required?: boolean | (() => boolean);
|
|
19
|
+
required?: boolean | boolean[] | (() => boolean | boolean[]);
|
|
20
20
|
originalDiffTip?: boolean;
|
|
21
21
|
globalControl?: boolean;
|
|
22
22
|
}
|
|
@@ -206,7 +206,7 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
|
|
|
206
206
|
hiddenNames?: string[] | any[];
|
|
207
207
|
rules?: ProRule[] | ReactiveFunction<Values, ProRule[]>;
|
|
208
208
|
equalWith?: (originValue: any, currentValue: any) => boolean;
|
|
209
|
-
required?: boolean | ReactiveFunction<Values, boolean>;
|
|
209
|
+
required?: boolean | boolean[] | ReactiveFunction<Values, boolean | boolean[]>;
|
|
210
210
|
labelRequired?: boolean;
|
|
211
211
|
toISOString?: boolean;
|
|
212
212
|
clearNotShow?: boolean;
|
|
@@ -38,7 +38,7 @@ export interface ProFormOtherProps {
|
|
|
38
38
|
colProps: ColProps;
|
|
39
39
|
disabled: boolean;
|
|
40
40
|
show?: boolean | (() => boolean);
|
|
41
|
-
required?: boolean | (() => boolean);
|
|
41
|
+
required?: boolean | boolean[] | (() => boolean | boolean[]);
|
|
42
42
|
mode?: string;
|
|
43
43
|
namePath?: any[] | string | number;
|
|
44
44
|
}
|
|
@@ -70,7 +70,7 @@ export interface ProFormProps<Values = any> extends FormProps<Values> {
|
|
|
70
70
|
clearNotShow?: boolean;
|
|
71
71
|
requiredOnView?: boolean;
|
|
72
72
|
formId?: string;
|
|
73
|
-
required?: boolean;
|
|
73
|
+
required?: boolean | boolean[];
|
|
74
74
|
originalDiffTip?: boolean;
|
|
75
75
|
}
|
|
76
76
|
export interface Transform<T = any> {
|
|
@@ -36,7 +36,7 @@ export declare const isNullValue: (value: any) => boolean;
|
|
|
36
36
|
* @param arr 值
|
|
37
37
|
* @returns boole
|
|
38
38
|
*/
|
|
39
|
-
export declare const isNotFullArray: (arr: any, length: any) => boolean;
|
|
39
|
+
export declare const isNotFullArray: (arr: any, length: any, required: any) => boolean;
|
|
40
40
|
/**
|
|
41
41
|
* 判断数组中值是否都为空 全部为空则为true
|
|
42
42
|
* @param arr 值
|
|
@@ -171,10 +171,15 @@ export var isNullValue = function isNullValue(value) {
|
|
|
171
171
|
* @param arr 值
|
|
172
172
|
* @returns boole
|
|
173
173
|
*/
|
|
174
|
-
export var isNotFullArray = function isNotFullArray(arr, length) {
|
|
174
|
+
export var isNotFullArray = function isNotFullArray(arr, length, required) {
|
|
175
175
|
if (!Array.isArray(arr)) {
|
|
176
176
|
return false;
|
|
177
177
|
}
|
|
178
|
+
if (Array.isArray(required) && required.some(function (item) {
|
|
179
|
+
return item === false;
|
|
180
|
+
})) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
178
183
|
if (arr.length < length) return true;
|
|
179
184
|
return arr.some(function (item) {
|
|
180
185
|
if (item === undefined || item === null) {
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import { validate, regExp } from '@zat-design/utils';
|
|
3
|
-
import { isString } from 'lodash';
|
|
3
|
+
import { isString, isNumber } from 'lodash';
|
|
4
4
|
import { isNullValue } from './index';
|
|
5
|
-
import locale from '../../locale';
|
|
6
|
-
|
|
5
|
+
import locale, { formatMessage } from '../../locale';
|
|
6
|
+
var getNonEmptyValuesByIndex = function getNonEmptyValuesByIndex(required, valueArray) {
|
|
7
|
+
var result = [];
|
|
8
|
+
required.forEach(function (item, index) {
|
|
9
|
+
if (item && !valueArray[index] && !isNumber(valueArray[index])) {
|
|
10
|
+
result.push(index + 1);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
export var rulesCreator = function rulesCreator(_ref) {
|
|
7
16
|
var _result;
|
|
17
|
+
var rules = _ref.rules,
|
|
18
|
+
label = _ref.label,
|
|
19
|
+
isSelect = _ref.isSelect,
|
|
20
|
+
names = _ref.names,
|
|
21
|
+
required = _ref.required;
|
|
8
22
|
var message = "".concat(isSelect ? "".concat(locale.ProForm.selectPlaceHolder) : "".concat(locale.ProForm.inputPlaceholder)).concat(locale.ProForm.ruleText).concat(isString(label) ? label : '');
|
|
9
23
|
var result = [];
|
|
10
24
|
result = rules.map(function (ruleItem) {
|
|
@@ -29,6 +43,22 @@ export var rulesCreator = function rulesCreator(rules, label, isSelect) {
|
|
|
29
43
|
}
|
|
30
44
|
return rule;
|
|
31
45
|
});
|
|
46
|
+
if ((names === null || names === void 0 ? void 0 : names.length) && (required === null || required === void 0 ? void 0 : required.length)) {
|
|
47
|
+
var customRequired = {
|
|
48
|
+
validator: function validator(rules, value) {
|
|
49
|
+
var errorIndexes = getNonEmptyValuesByIndex(required, value);
|
|
50
|
+
// 校验为true的值是否存在
|
|
51
|
+
if (Array.isArray(value) && (errorIndexes === null || errorIndexes === void 0 ? void 0 : errorIndexes.length)) {
|
|
52
|
+
var _locale$ProForm;
|
|
53
|
+
return Promise.reject(new Error("".concat(formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProForm = locale.ProForm) === null || _locale$ProForm === void 0 ? void 0 : _locale$ProForm.halfRuleText, {
|
|
54
|
+
total: errorIndexes === null || errorIndexes === void 0 ? void 0 : errorIndexes.join(',')
|
|
55
|
+
}))));
|
|
56
|
+
}
|
|
57
|
+
return Promise.resolve();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
result.push(customRequired);
|
|
61
|
+
}
|
|
32
62
|
if (!((_result = result) === null || _result === void 0 ? void 0 : _result.length)) {
|
|
33
63
|
result = [{
|
|
34
64
|
required: false
|
|
@@ -13,19 +13,26 @@ var useRules = function useRules(props) {
|
|
|
13
13
|
labelRequired = props.labelRequired,
|
|
14
14
|
type = props.type;
|
|
15
15
|
var _label = isString(label) ? label : '';
|
|
16
|
+
var requiredRule = Array.isArray(rules) && (rules === null || rules === void 0 ? void 0 : rules.find(function (rule) {
|
|
17
|
+
return 'required' in rule;
|
|
18
|
+
}));
|
|
19
|
+
var allRequired = required === true || Array.isArray(required) && required.every(function (item) {
|
|
20
|
+
return item === true;
|
|
21
|
+
});
|
|
16
22
|
// 根据 required 添加 rules, names 字段会添加数组的必填校验
|
|
17
23
|
var internalRule = useMemo(function () {
|
|
18
24
|
var result = {
|
|
19
25
|
rules: rules || []
|
|
20
26
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
// Group required: true时,直接走完整校验
|
|
28
|
+
if (allRequired && type === 'Group') {
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
if (allRequired) {
|
|
25
32
|
if (!requiredRule) {
|
|
26
33
|
var message = isSelect ? "".concat(locale.ProForm.selectPlaceHolder).concat(_label) : "".concat(locale.ProForm.inputPlaceholder).concat(_label);
|
|
27
34
|
var rule = {
|
|
28
|
-
required:
|
|
35
|
+
required: allRequired,
|
|
29
36
|
message: message
|
|
30
37
|
};
|
|
31
38
|
// names字段的必填校验
|
|
@@ -43,22 +50,40 @@ var useRules = function useRules(props) {
|
|
|
43
50
|
return result;
|
|
44
51
|
}, [rules, required]);
|
|
45
52
|
// type转换为内置rules
|
|
46
|
-
internalRule.rules = internalRule.rules && rulesCreator(
|
|
53
|
+
internalRule.rules = internalRule.rules && rulesCreator({
|
|
54
|
+
rules: internalRule.rules,
|
|
55
|
+
label: _label,
|
|
56
|
+
isSelect: isSelect,
|
|
57
|
+
names: names,
|
|
58
|
+
required: required
|
|
59
|
+
});
|
|
47
60
|
useEffect(function () {
|
|
61
|
+
if (type === 'Group' && (allRequired || requiredRule)) {
|
|
62
|
+
var customRequired = {
|
|
63
|
+
validator: function validator(rules, value) {
|
|
64
|
+
// 完整性校验, 数组有值且值不完整则校验不通过
|
|
65
|
+
if (Array.isArray(value) && isNotFullArray(value, names.length, required)) {
|
|
66
|
+
return Promise.reject(new Error("".concat(locale.ProForm.completeText).concat(_label)));
|
|
67
|
+
}
|
|
68
|
+
return Promise.resolve();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
// 插入rules第一条,完整性校验大于自定义
|
|
72
|
+
internalRule.rules.unshift(customRequired);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
48
75
|
// 添加完整性校验
|
|
49
76
|
if (names && !isBoolean(labelRequired)) {
|
|
50
|
-
var
|
|
77
|
+
var _customRequired = {
|
|
51
78
|
validator: function validator(rules, value) {
|
|
52
79
|
// 完整性校验, 空数组不校验, 数组有值且值不完整则校验不通过
|
|
53
|
-
if (Array.isArray(value) && !isNullArray(value) && isNotFullArray(value, names.length)) {
|
|
80
|
+
if (Array.isArray(value) && !isNullArray(value) && isNotFullArray(value, names.length, required)) {
|
|
54
81
|
return Promise.reject(new Error("".concat(locale.ProForm.completeText).concat(_label)));
|
|
55
82
|
}
|
|
56
83
|
return Promise.resolve();
|
|
57
84
|
}
|
|
58
85
|
};
|
|
59
|
-
|
|
60
|
-
internalRule.rules.push(customRequired);
|
|
61
|
-
}
|
|
86
|
+
internalRule.rules.unshift(_customRequired);
|
|
62
87
|
}
|
|
63
88
|
}, [internalRule]);
|
|
64
89
|
return internalRule;
|
|
@@ -84,11 +84,11 @@ var useShouldUpdate = function useShouldUpdate(props) {
|
|
|
84
84
|
disabledRef.current = disabled;
|
|
85
85
|
}
|
|
86
86
|
if (isFunction(required)) {
|
|
87
|
-
requiredRef.current =
|
|
87
|
+
requiredRef.current = required(values, {
|
|
88
88
|
form: form,
|
|
89
89
|
index: index,
|
|
90
90
|
namePath: namePath
|
|
91
|
-
})
|
|
91
|
+
});
|
|
92
92
|
} else {
|
|
93
93
|
requiredRef.current = required;
|
|
94
94
|
}
|
|
@@ -133,11 +133,11 @@ var useShouldUpdate = function useShouldUpdate(props) {
|
|
|
133
133
|
index: index,
|
|
134
134
|
namePath: namePath
|
|
135
135
|
})) : disabled;
|
|
136
|
-
var _required = isFunction(required) ?
|
|
136
|
+
var _required = isFunction(required) ? required(_currentValues, {
|
|
137
137
|
form: form,
|
|
138
138
|
index: index,
|
|
139
139
|
namePath: namePath
|
|
140
|
-
})
|
|
140
|
+
}) : required;
|
|
141
141
|
var _rules = isFunction(rules) ? rules(_currentValues, {
|
|
142
142
|
form: form,
|
|
143
143
|
index: index,
|
|
@@ -336,3 +336,8 @@
|
|
|
336
336
|
.pro-form.pro-form-view .@{ant-prefix}-form-item .pro-tree .@{ant-prefix}-tree-checkbox * {
|
|
337
337
|
height: 16px !important;
|
|
338
338
|
}
|
|
339
|
+
|
|
340
|
+
// 解决双滚动条
|
|
341
|
+
.ant-select-dropdown.pro-tree-select-drop-down-container.checkable-tree{
|
|
342
|
+
overflow: hidden!important;
|
|
343
|
+
}
|
package/es/locale/en_US.d.ts
CHANGED
package/es/locale/en_US.js
CHANGED
|
@@ -31,6 +31,7 @@ export default {
|
|
|
31
31
|
reset: 'Reset',
|
|
32
32
|
ruleText: 'correct',
|
|
33
33
|
completeText: 'enter in full',
|
|
34
|
+
halfRuleText: 'Enter the value of ({total})',
|
|
34
35
|
formList_actions: ['Add', 'Delete', 'Copy', 'Move up', 'Move down', 'Add a new line'],
|
|
35
36
|
formList_confirmMessage: 'Are you sure delete it?'
|
|
36
37
|
},
|
package/es/locale/zh_CN.d.ts
CHANGED
package/es/locale/zh_CN.js
CHANGED
package/es/style/theme/antd.less
CHANGED
|
@@ -703,8 +703,8 @@
|
|
|
703
703
|
|
|
704
704
|
// tooltip样式重载
|
|
705
705
|
.@{ant-prefix}-tooltip {
|
|
706
|
-
>
|
|
707
|
-
>
|
|
706
|
+
> .@{ant-prefix}-tooltip-content {
|
|
707
|
+
> .@{ant-prefix}-tooltip-inner {
|
|
708
708
|
color: rgb(29, 33, 41);
|
|
709
709
|
background-color: #fff;
|
|
710
710
|
box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08),
|
|
@@ -720,8 +720,8 @@
|
|
|
720
720
|
}
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
>
|
|
724
|
-
>
|
|
723
|
+
> .@{ant-prefix}-tooltip-arrow {
|
|
724
|
+
> .@{ant-prefix}-tooltip-arrow-content {
|
|
725
725
|
--antd-arrow-background-color: linear-gradient(
|
|
726
726
|
to right bottom,
|
|
727
727
|
rgba(255, 255, 255, 0.95),
|
|
@@ -90,13 +90,14 @@ var Group = function Group(props) {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
}, [value]);
|
|
93
|
+
var _otherProps = (0, _lodash.omit)(otherProps, ['colProps', 'required']);
|
|
93
94
|
return (0, _jsxRuntime.jsx)("div", {
|
|
94
95
|
className: _className,
|
|
95
96
|
children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? (0, _jsxRuntime.jsx)(_antd.Space.Compact, {
|
|
96
97
|
children: (0, _jsxRuntime.jsx)(_RenderFields.default, (0, _objectSpread2.default)({
|
|
97
98
|
columns: data.columns,
|
|
98
99
|
form: form
|
|
99
|
-
},
|
|
100
|
+
}, _otherProps))
|
|
100
101
|
}) : (0, _jsxRuntime.jsx)(_antd.Space, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
101
102
|
align: "start"
|
|
102
103
|
}, (0, _lodash.omit)(space, ['separator', 'compact'])), {}, {
|
|
@@ -104,7 +105,7 @@ var Group = function Group(props) {
|
|
|
104
105
|
return (0, _jsxRuntime.jsx)(_RenderFields.default, (0, _objectSpread2.default)({
|
|
105
106
|
columns: [column],
|
|
106
107
|
form: form
|
|
107
|
-
},
|
|
108
|
+
}, _otherProps), (column === null || column === void 0 ? void 0 : column.name) || index);
|
|
108
109
|
})
|
|
109
110
|
}))
|
|
110
111
|
});
|
|
@@ -16,7 +16,7 @@ interface Props<T = any> {
|
|
|
16
16
|
originalValues?: ProFormProps<T>['originalValues'];
|
|
17
17
|
clearNotShow?: boolean;
|
|
18
18
|
requiredOnView?: boolean;
|
|
19
|
-
required?: boolean | (() => boolean);
|
|
19
|
+
required?: boolean | boolean[] | (() => boolean | boolean[]);
|
|
20
20
|
originalDiffTip?: boolean;
|
|
21
21
|
globalControl?: boolean;
|
|
22
22
|
}
|
|
@@ -206,7 +206,7 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
|
|
|
206
206
|
hiddenNames?: string[] | any[];
|
|
207
207
|
rules?: ProRule[] | ReactiveFunction<Values, ProRule[]>;
|
|
208
208
|
equalWith?: (originValue: any, currentValue: any) => boolean;
|
|
209
|
-
required?: boolean | ReactiveFunction<Values, boolean>;
|
|
209
|
+
required?: boolean | boolean[] | ReactiveFunction<Values, boolean | boolean[]>;
|
|
210
210
|
labelRequired?: boolean;
|
|
211
211
|
toISOString?: boolean;
|
|
212
212
|
clearNotShow?: boolean;
|
|
@@ -38,7 +38,7 @@ export interface ProFormOtherProps {
|
|
|
38
38
|
colProps: ColProps;
|
|
39
39
|
disabled: boolean;
|
|
40
40
|
show?: boolean | (() => boolean);
|
|
41
|
-
required?: boolean | (() => boolean);
|
|
41
|
+
required?: boolean | boolean[] | (() => boolean | boolean[]);
|
|
42
42
|
mode?: string;
|
|
43
43
|
namePath?: any[] | string | number;
|
|
44
44
|
}
|
|
@@ -70,7 +70,7 @@ export interface ProFormProps<Values = any> extends FormProps<Values> {
|
|
|
70
70
|
clearNotShow?: boolean;
|
|
71
71
|
requiredOnView?: boolean;
|
|
72
72
|
formId?: string;
|
|
73
|
-
required?: boolean;
|
|
73
|
+
required?: boolean | boolean[];
|
|
74
74
|
originalDiffTip?: boolean;
|
|
75
75
|
}
|
|
76
76
|
export interface Transform<T = any> {
|
|
@@ -36,7 +36,7 @@ export declare const isNullValue: (value: any) => boolean;
|
|
|
36
36
|
* @param arr 值
|
|
37
37
|
* @returns boole
|
|
38
38
|
*/
|
|
39
|
-
export declare const isNotFullArray: (arr: any, length: any) => boolean;
|
|
39
|
+
export declare const isNotFullArray: (arr: any, length: any, required: any) => boolean;
|
|
40
40
|
/**
|
|
41
41
|
* 判断数组中值是否都为空 全部为空则为true
|
|
42
42
|
* @param arr 值
|
|
@@ -187,10 +187,15 @@ var isNullValue = exports.isNullValue = function isNullValue(value) {
|
|
|
187
187
|
* @param arr 值
|
|
188
188
|
* @returns boole
|
|
189
189
|
*/
|
|
190
|
-
var isNotFullArray = exports.isNotFullArray = function isNotFullArray(arr, length) {
|
|
190
|
+
var isNotFullArray = exports.isNotFullArray = function isNotFullArray(arr, length, required) {
|
|
191
191
|
if (!Array.isArray(arr)) {
|
|
192
192
|
return false;
|
|
193
193
|
}
|
|
194
|
+
if (Array.isArray(required) && required.some(function (item) {
|
|
195
|
+
return item === false;
|
|
196
|
+
})) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
194
199
|
if (arr.length < length) return true;
|
|
195
200
|
return arr.some(function (item) {
|
|
196
201
|
if (item === undefined || item === null) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
3
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
@@ -9,9 +10,23 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
9
10
|
var _utils = require("@zat-design/utils");
|
|
10
11
|
var _lodash = require("lodash");
|
|
11
12
|
var _index = require("./index");
|
|
12
|
-
var _locale =
|
|
13
|
-
var
|
|
13
|
+
var _locale = _interopRequireWildcard(require("../../locale"));
|
|
14
|
+
var getNonEmptyValuesByIndex = function getNonEmptyValuesByIndex(required, valueArray) {
|
|
15
|
+
var result = [];
|
|
16
|
+
required.forEach(function (item, index) {
|
|
17
|
+
if (item && !valueArray[index] && !(0, _lodash.isNumber)(valueArray[index])) {
|
|
18
|
+
result.push(index + 1);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
var rulesCreator = exports.rulesCreator = function rulesCreator(_ref) {
|
|
14
24
|
var _result;
|
|
25
|
+
var rules = _ref.rules,
|
|
26
|
+
label = _ref.label,
|
|
27
|
+
isSelect = _ref.isSelect,
|
|
28
|
+
names = _ref.names,
|
|
29
|
+
required = _ref.required;
|
|
15
30
|
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 : '');
|
|
16
31
|
var result = [];
|
|
17
32
|
result = rules.map(function (ruleItem) {
|
|
@@ -36,6 +51,22 @@ var rulesCreator = exports.rulesCreator = function rulesCreator(rules, label, is
|
|
|
36
51
|
}
|
|
37
52
|
return rule;
|
|
38
53
|
});
|
|
54
|
+
if ((names === null || names === void 0 ? void 0 : names.length) && (required === null || required === void 0 ? void 0 : required.length)) {
|
|
55
|
+
var customRequired = {
|
|
56
|
+
validator: function validator(rules, value) {
|
|
57
|
+
var errorIndexes = getNonEmptyValuesByIndex(required, value);
|
|
58
|
+
// 校验为true的值是否存在
|
|
59
|
+
if (Array.isArray(value) && (errorIndexes === null || errorIndexes === void 0 ? void 0 : errorIndexes.length)) {
|
|
60
|
+
var _locale$ProForm;
|
|
61
|
+
return Promise.reject(new Error("".concat((0, _locale.formatMessage)(_locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProForm = _locale.default.ProForm) === null || _locale$ProForm === void 0 ? void 0 : _locale$ProForm.halfRuleText, {
|
|
62
|
+
total: errorIndexes === null || errorIndexes === void 0 ? void 0 : errorIndexes.join(',')
|
|
63
|
+
}))));
|
|
64
|
+
}
|
|
65
|
+
return Promise.resolve();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
result.push(customRequired);
|
|
69
|
+
}
|
|
39
70
|
if (!((_result = result) === null || _result === void 0 ? void 0 : _result.length)) {
|
|
40
71
|
result = [{
|
|
41
72
|
required: false
|
|
@@ -20,19 +20,26 @@ var useRules = function useRules(props) {
|
|
|
20
20
|
labelRequired = props.labelRequired,
|
|
21
21
|
type = props.type;
|
|
22
22
|
var _label = (0, _lodash.isString)(label) ? label : '';
|
|
23
|
+
var requiredRule = Array.isArray(rules) && (rules === null || rules === void 0 ? void 0 : rules.find(function (rule) {
|
|
24
|
+
return 'required' in rule;
|
|
25
|
+
}));
|
|
26
|
+
var allRequired = required === true || Array.isArray(required) && required.every(function (item) {
|
|
27
|
+
return item === true;
|
|
28
|
+
});
|
|
23
29
|
// 根据 required 添加 rules, names 字段会添加数组的必填校验
|
|
24
30
|
var internalRule = (0, _react.useMemo)(function () {
|
|
25
31
|
var result = {
|
|
26
32
|
rules: rules || []
|
|
27
33
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
// Group required: true时,直接走完整校验
|
|
35
|
+
if (allRequired && type === 'Group') {
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
if (allRequired) {
|
|
32
39
|
if (!requiredRule) {
|
|
33
40
|
var message = isSelect ? "".concat(_locale.default.ProForm.selectPlaceHolder).concat(_label) : "".concat(_locale.default.ProForm.inputPlaceholder).concat(_label);
|
|
34
41
|
var rule = {
|
|
35
|
-
required:
|
|
42
|
+
required: allRequired,
|
|
36
43
|
message: message
|
|
37
44
|
};
|
|
38
45
|
// names字段的必填校验
|
|
@@ -50,22 +57,40 @@ var useRules = function useRules(props) {
|
|
|
50
57
|
return result;
|
|
51
58
|
}, [rules, required]);
|
|
52
59
|
// type转换为内置rules
|
|
53
|
-
internalRule.rules = internalRule.rules && (0, _rulesCreator.rulesCreator)(
|
|
60
|
+
internalRule.rules = internalRule.rules && (0, _rulesCreator.rulesCreator)({
|
|
61
|
+
rules: internalRule.rules,
|
|
62
|
+
label: _label,
|
|
63
|
+
isSelect: isSelect,
|
|
64
|
+
names: names,
|
|
65
|
+
required: required
|
|
66
|
+
});
|
|
54
67
|
(0, _react.useEffect)(function () {
|
|
68
|
+
if (type === 'Group' && (allRequired || requiredRule)) {
|
|
69
|
+
var customRequired = {
|
|
70
|
+
validator: function validator(rules, value) {
|
|
71
|
+
// 完整性校验, 数组有值且值不完整则校验不通过
|
|
72
|
+
if (Array.isArray(value) && (0, _index.isNotFullArray)(value, names.length, required)) {
|
|
73
|
+
return Promise.reject(new Error("".concat(_locale.default.ProForm.completeText).concat(_label)));
|
|
74
|
+
}
|
|
75
|
+
return Promise.resolve();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
// 插入rules第一条,完整性校验大于自定义
|
|
79
|
+
internalRule.rules.unshift(customRequired);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
55
82
|
// 添加完整性校验
|
|
56
83
|
if (names && !(0, _lodash.isBoolean)(labelRequired)) {
|
|
57
|
-
var
|
|
84
|
+
var _customRequired = {
|
|
58
85
|
validator: function validator(rules, value) {
|
|
59
86
|
// 完整性校验, 空数组不校验, 数组有值且值不完整则校验不通过
|
|
60
|
-
if (Array.isArray(value) && !(0, _index.isNullArray)(value) && (0, _index.isNotFullArray)(value, names.length)) {
|
|
87
|
+
if (Array.isArray(value) && !(0, _index.isNullArray)(value) && (0, _index.isNotFullArray)(value, names.length, required)) {
|
|
61
88
|
return Promise.reject(new Error("".concat(_locale.default.ProForm.completeText).concat(_label)));
|
|
62
89
|
}
|
|
63
90
|
return Promise.resolve();
|
|
64
91
|
}
|
|
65
92
|
};
|
|
66
|
-
|
|
67
|
-
internalRule.rules.push(customRequired);
|
|
68
|
-
}
|
|
93
|
+
internalRule.rules.unshift(_customRequired);
|
|
69
94
|
}
|
|
70
95
|
}, [internalRule]);
|
|
71
96
|
return internalRule;
|
|
@@ -91,11 +91,11 @@ var useShouldUpdate = function useShouldUpdate(props) {
|
|
|
91
91
|
disabledRef.current = disabled;
|
|
92
92
|
}
|
|
93
93
|
if ((0, _lodash.isFunction)(required)) {
|
|
94
|
-
requiredRef.current =
|
|
94
|
+
requiredRef.current = required(values, {
|
|
95
95
|
form: form,
|
|
96
96
|
index: index,
|
|
97
97
|
namePath: namePath
|
|
98
|
-
})
|
|
98
|
+
});
|
|
99
99
|
} else {
|
|
100
100
|
requiredRef.current = required;
|
|
101
101
|
}
|
|
@@ -140,11 +140,11 @@ var useShouldUpdate = function useShouldUpdate(props) {
|
|
|
140
140
|
index: index,
|
|
141
141
|
namePath: namePath
|
|
142
142
|
})) : disabled;
|
|
143
|
-
var _required = (0, _lodash.isFunction)(required) ?
|
|
143
|
+
var _required = (0, _lodash.isFunction)(required) ? required(_currentValues, {
|
|
144
144
|
form: form,
|
|
145
145
|
index: index,
|
|
146
146
|
namePath: namePath
|
|
147
|
-
})
|
|
147
|
+
}) : required;
|
|
148
148
|
var _rules = (0, _lodash.isFunction)(rules) ? rules(_currentValues, {
|
|
149
149
|
form: form,
|
|
150
150
|
index: index,
|
|
@@ -336,3 +336,8 @@
|
|
|
336
336
|
.pro-form.pro-form-view .@{ant-prefix}-form-item .pro-tree .@{ant-prefix}-tree-checkbox * {
|
|
337
337
|
height: 16px !important;
|
|
338
338
|
}
|
|
339
|
+
|
|
340
|
+
// 解决双滚动条
|
|
341
|
+
.ant-select-dropdown.pro-tree-select-drop-down-container.checkable-tree{
|
|
342
|
+
overflow: hidden!important;
|
|
343
|
+
}
|
package/lib/locale/en_US.d.ts
CHANGED
package/lib/locale/en_US.js
CHANGED
|
@@ -37,6 +37,7 @@ var _default = exports.default = {
|
|
|
37
37
|
reset: 'Reset',
|
|
38
38
|
ruleText: 'correct',
|
|
39
39
|
completeText: 'enter in full',
|
|
40
|
+
halfRuleText: 'Enter the value of ({total})',
|
|
40
41
|
formList_actions: ['Add', 'Delete', 'Copy', 'Move up', 'Move down', 'Add a new line'],
|
|
41
42
|
formList_confirmMessage: 'Are you sure delete it?'
|
|
42
43
|
},
|
package/lib/locale/zh_CN.d.ts
CHANGED
package/lib/locale/zh_CN.js
CHANGED
|
@@ -703,8 +703,8 @@
|
|
|
703
703
|
|
|
704
704
|
// tooltip样式重载
|
|
705
705
|
.@{ant-prefix}-tooltip {
|
|
706
|
-
>
|
|
707
|
-
>
|
|
706
|
+
> .@{ant-prefix}-tooltip-content {
|
|
707
|
+
> .@{ant-prefix}-tooltip-inner {
|
|
708
708
|
color: rgb(29, 33, 41);
|
|
709
709
|
background-color: #fff;
|
|
710
710
|
box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08),
|
|
@@ -720,8 +720,8 @@
|
|
|
720
720
|
}
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
>
|
|
724
|
-
>
|
|
723
|
+
> .@{ant-prefix}-tooltip-arrow {
|
|
724
|
+
> .@{ant-prefix}-tooltip-arrow-content {
|
|
725
725
|
--antd-arrow-background-color: linear-gradient(
|
|
726
726
|
to right bottom,
|
|
727
727
|
rgba(255, 255, 255, 0.95),
|