@zat-design/sisyphus-react 3.4.3 → 3.4.4-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/babel.config.js +3 -0
- package/dist/index.esm.css +35 -31
- package/dist/less.esm.css +20 -4
- package/es/ProConfigProvider/index.d.ts +1 -1
- package/es/ProConfigProvider/index.js +22 -1
- package/es/ProEditLabel/style/index.less +0 -1
- package/es/ProEditTable/components/DndWrapper/index.js +1 -1
- package/es/ProEditTable/components/RenderField/index.js +20 -14
- package/es/ProEditTable/index.js +27 -10
- package/es/ProEditTable/propsType.d.ts +1 -0
- package/es/ProEnum/components/Group.js +8 -19
- package/es/ProEnum/style/index.less +3 -2
- package/es/ProForm/components/base/DatePicker/index.js +3 -1
- package/es/ProForm/components/base/TextArea/index.js +4 -4
- package/es/ProForm/components/combination/FormList/components/ActionButton.d.ts +1 -0
- package/es/ProForm/components/combination/FormList/components/ActionButton.js +12 -10
- package/es/ProForm/components/combination/FormList/components/BlockFields.js +6 -1
- package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +2 -5
- package/es/ProForm/components/combination/Group/index.js +3 -2
- package/es/ProForm/components/combination/GroupCopy/component/ComRender.d.ts +14 -0
- package/es/ProForm/components/combination/GroupCopy/component/ComRender.js +36 -0
- package/es/ProForm/components/combination/GroupCopy/index.d.ts +10 -0
- package/es/ProForm/components/combination/GroupCopy/index.js +84 -0
- package/es/ProForm/components/combination/GroupCopy/propsType.d.ts +47 -0
- package/es/ProForm/components/combination/GroupCopy/propsType.js +1 -0
- package/es/ProForm/components/combination/GroupCopy/style/index.less +131 -0
- package/es/ProForm/components/combination/GroupCopy/utils.d.ts +53 -0
- package/es/ProForm/components/combination/GroupCopy/utils.js +180 -0
- package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +2 -1
- package/es/ProForm/components/combination/ProModalSelect/index.js +131 -74
- package/es/ProForm/components/combination/ProModalSelect/propsType.d.ts +2 -2
- package/es/ProForm/components/combination/ProModalSelect/style/index.less +1 -1
- package/es/ProForm/components/combination/ProNumberRange/style/index.less +1 -1
- package/es/ProForm/components/index.js +1 -0
- package/es/ProForm/components/render/ConfirmWrapper.js +8 -2
- package/es/ProForm/components/render/Render.js +12 -9
- package/es/ProForm/components/render/RenderFields.d.ts +1 -1
- package/es/ProForm/components/render/propsType.d.ts +4 -4
- package/es/ProForm/index.js +4 -5
- package/es/ProForm/propsType.d.ts +2 -2
- package/es/ProForm/style/index.less +23 -5
- package/es/ProForm/utils/diffOriginal.js +17 -32
- package/es/ProForm/utils/index.d.ts +1 -1
- package/es/ProForm/utils/index.js +14 -4
- package/es/ProForm/utils/rulesCreator.d.ts +7 -1
- package/es/ProForm/utils/rulesCreator.js +45 -3
- package/es/ProForm/utils/useRules.js +36 -11
- package/es/ProForm/utils/useShouldUpdate.js +4 -4
- package/es/ProIcon/index.js +0 -3
- package/es/ProLayout/components/ProCollapse/index.js +23 -1
- package/es/ProLayout/components/ProCollapse/style/index.less +1 -1
- package/es/ProThemeTools/component/PrdTools/index.js +12 -50
- package/es/ProThemeTools/index.js +0 -1
- package/es/ProTree/components/ProTreeSelect/style/index.less +1 -1
- package/es/ProTree/style/index.less +5 -0
- package/es/ProUpload/style/index.less +1 -1
- package/es/ProWaterMark/__snapshots__/index.test.tsx.snap +7 -0
- package/es/assets/view.svg +20 -1
- package/es/locale/en_US.d.ts +4 -2
- package/es/locale/en_US.js +4 -2
- package/es/locale/zh_CN.d.ts +4 -2
- package/es/locale/zh_CN.js +4 -2
- package/es/style/components.less +0 -3
- package/es/style/theme/antd.less +14 -28
- package/jest.config.js +8 -0
- package/lib/ProConfigProvider/index.d.ts +1 -1
- package/lib/ProConfigProvider/index.js +21 -0
- package/lib/ProEditLabel/style/index.less +0 -1
- package/lib/ProEditTable/components/DndWrapper/index.js +1 -1
- package/lib/ProEditTable/components/RenderField/index.js +18 -12
- package/lib/ProEditTable/index.js +27 -10
- package/lib/ProEditTable/propsType.d.ts +1 -0
- package/lib/ProEnum/components/Group.js +7 -18
- package/lib/ProEnum/style/index.less +3 -2
- package/lib/ProForm/components/base/DatePicker/index.js +3 -1
- package/lib/ProForm/components/base/TextArea/index.js +5 -5
- package/lib/ProForm/components/combination/FormList/components/ActionButton.d.ts +1 -0
- package/lib/ProForm/components/combination/FormList/components/ActionButton.js +12 -10
- package/lib/ProForm/components/combination/FormList/components/BlockFields.js +6 -1
- package/lib/ProForm/components/combination/FormList/components/ToolbarButton.js +2 -5
- package/lib/ProForm/components/combination/Group/index.js +3 -2
- package/lib/ProForm/components/combination/GroupCopy/component/ComRender.d.ts +14 -0
- package/lib/ProForm/components/combination/GroupCopy/component/ComRender.js +44 -0
- package/lib/ProForm/components/combination/GroupCopy/index.d.ts +10 -0
- package/lib/ProForm/components/combination/GroupCopy/index.js +91 -0
- package/lib/ProForm/components/combination/GroupCopy/propsType.d.ts +47 -0
- package/lib/ProForm/components/combination/GroupCopy/propsType.js +5 -0
- package/lib/ProForm/components/combination/GroupCopy/style/index.less +131 -0
- package/lib/ProForm/components/combination/GroupCopy/utils.d.ts +53 -0
- package/lib/ProForm/components/combination/GroupCopy/utils.js +187 -0
- package/lib/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +2 -1
- package/lib/ProForm/components/combination/ProModalSelect/index.js +140 -87
- package/lib/ProForm/components/combination/ProModalSelect/propsType.d.ts +2 -2
- package/lib/ProForm/components/combination/ProModalSelect/style/index.less +1 -1
- package/lib/ProForm/components/combination/ProNumberRange/style/index.less +1 -1
- package/lib/ProForm/components/render/ConfirmWrapper.js +8 -2
- package/lib/ProForm/components/render/Render.js +12 -9
- package/lib/ProForm/components/render/RenderFields.d.ts +1 -1
- package/lib/ProForm/components/render/propsType.d.ts +4 -4
- package/lib/ProForm/index.js +4 -5
- package/lib/ProForm/propsType.d.ts +2 -2
- package/lib/ProForm/style/index.less +23 -5
- package/lib/ProForm/utils/diffOriginal.js +16 -31
- package/lib/ProForm/utils/index.d.ts +1 -1
- package/lib/ProForm/utils/index.js +14 -4
- package/lib/ProForm/utils/rulesCreator.d.ts +7 -1
- package/lib/ProForm/utils/rulesCreator.js +45 -2
- package/lib/ProForm/utils/useRules.js +36 -11
- package/lib/ProForm/utils/useShouldUpdate.js +4 -4
- package/lib/ProIcon/index.js +0 -3
- package/lib/ProLayout/components/ProCollapse/index.js +23 -1
- package/lib/ProLayout/components/ProCollapse/style/index.less +1 -1
- package/lib/ProThemeTools/component/PrdTools/index.js +12 -50
- package/lib/ProThemeTools/index.js +0 -1
- package/lib/ProTree/components/ProTreeSelect/style/index.less +1 -1
- package/lib/ProTree/style/index.less +5 -0
- package/lib/ProUpload/style/index.less +1 -1
- package/lib/ProWaterMark/__snapshots__/index.test.tsx.snap +7 -0
- package/lib/assets/view.svg +20 -1
- package/lib/locale/en_US.d.ts +4 -2
- package/lib/locale/en_US.js +4 -2
- package/lib/locale/zh_CN.d.ts +4 -2
- package/lib/locale/zh_CN.js +4 -2
- package/lib/style/components.less +0 -3
- package/lib/style/theme/antd.less +14 -28
- package/package.json +5 -1
- package/test/__mocks__/fileMock.js +0 -0
- package/test/__mocks__/styleMock.js +0 -0
|
@@ -52,12 +52,12 @@ interface ControlProps {
|
|
|
52
52
|
/**
|
|
53
53
|
* 扩展函数的参数
|
|
54
54
|
*/
|
|
55
|
-
type FunctionArgs<Values> = (value: any, record: any, { form, index, namePath, option, selectedOptions, dateString, }: {
|
|
55
|
+
export type FunctionArgs<Values, R = any> = (value: any, record: any, { form, index, namePath, option, selectedOptions, dateString, }: {
|
|
56
56
|
form: FormInstance<Values>;
|
|
57
57
|
index?: number;
|
|
58
58
|
namePath?: NamePath;
|
|
59
59
|
[key: string]: any;
|
|
60
|
-
}) =>
|
|
60
|
+
}) => R;
|
|
61
61
|
type TransformToFormField<T extends ControlProps, Values> = DistributiveOmit<T, 'onChange' | 'value'> & {
|
|
62
62
|
value?: T['value'];
|
|
63
63
|
onChange?: (value: Parameters<T['onChange']>[0], options: Parameters<T['onChange']>[1], form: FormInstance<Values>) => void;
|
|
@@ -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;
|
|
@@ -220,7 +220,7 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
|
|
|
220
220
|
extra?: string | React.ReactNode;
|
|
221
221
|
/** 是否固定字段, 不隐藏 */
|
|
222
222
|
fixed?: boolean;
|
|
223
|
-
confirm?: boolean | ModalFuncProps |
|
|
223
|
+
confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps>;
|
|
224
224
|
}
|
|
225
225
|
export type ProColumnProps<T = any> = ProFormColumnProps<T> & ColumnPropsMap<T, 'ProForm'>;
|
|
226
226
|
/**
|
package/es/ProForm/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import { useForm } from './utils/useForm';
|
|
|
26
26
|
import { useFieldProps } from './utils/useFieldProps';
|
|
27
27
|
import locale from '../locale';
|
|
28
28
|
var ProForm = function ProForm(props, ref) {
|
|
29
|
-
var _forms$formKey, _localStorage;
|
|
29
|
+
var _forms$formKey, _localStorage, _ref;
|
|
30
30
|
var _props$mode = props.mode,
|
|
31
31
|
mode = _props$mode === void 0 ? 'search' : _props$mode,
|
|
32
32
|
span = props.span,
|
|
@@ -49,8 +49,7 @@ var ProForm = function ProForm(props, ref) {
|
|
|
49
49
|
expandOpenChange = props.expandOpenChange,
|
|
50
50
|
_props$viewEmpty = props.viewEmpty,
|
|
51
51
|
viewEmpty = _props$viewEmpty === void 0 ? '-' : _props$viewEmpty,
|
|
52
|
-
|
|
53
|
-
labelAlign = _props$labelAlign === void 0 ? 'left' : _props$labelAlign,
|
|
52
|
+
labelAlign = props.labelAlign,
|
|
54
53
|
labelWidth = props.labelWidth,
|
|
55
54
|
onValuesChange = props.onValuesChange,
|
|
56
55
|
onFinish = props.onFinish,
|
|
@@ -231,9 +230,9 @@ var ProForm = function ProForm(props, ref) {
|
|
|
231
230
|
}
|
|
232
231
|
},
|
|
233
232
|
className: cls,
|
|
234
|
-
form: form
|
|
235
|
-
labelAlign: labelAlign
|
|
233
|
+
form: form
|
|
236
234
|
}, formProps), config), otherProps), {}, {
|
|
235
|
+
labelAlign: (_ref = labelAlign !== null && labelAlign !== void 0 ? labelAlign : config.labelAlign) !== null && _ref !== void 0 ? _ref : 'left',
|
|
237
236
|
onValuesChange: handleValuesChange,
|
|
238
237
|
onFinish: handleFinish,
|
|
239
238
|
initialValues: _initialValues,
|
|
@@ -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> {
|
|
@@ -132,7 +132,8 @@
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
.@{ant-prefix}-form-item-control:has(.@{ant-prefix}-switch-handle),
|
|
136
|
+
.@{ant-prefix}-form-item-control:has(.@{ant-prefix}-checkbox-wrapper-in-form-item) {
|
|
136
137
|
background: @zaui-contract-bg;
|
|
137
138
|
border-radius: 4px;
|
|
138
139
|
}
|
|
@@ -140,13 +141,13 @@
|
|
|
140
141
|
// 地址组件
|
|
141
142
|
.@{ant-prefix}-form-item-control-input-content {
|
|
142
143
|
& > .pro-address {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
.@{ant-prefix}-select-selector,
|
|
145
|
+
.@{ant-prefix}-input-affix-wrapper,
|
|
146
|
+
.@{ant-prefix}-input-disabled {
|
|
146
147
|
background: @zaui-contract-bg;
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
|
-
& >
|
|
150
|
+
& > .@{ant-prefix}-input-group {
|
|
150
151
|
.forever-checkbox {
|
|
151
152
|
background: @zaui-contract-bg;
|
|
152
153
|
}
|
|
@@ -346,4 +347,21 @@
|
|
|
346
347
|
.delete-icon {
|
|
347
348
|
width: 18px;
|
|
348
349
|
}
|
|
350
|
+
.pro-form-list-tool-btn {
|
|
351
|
+
margin-left: 8px;
|
|
352
|
+
padding: 0;
|
|
353
|
+
cursor: pointer;
|
|
354
|
+
.anticon {
|
|
355
|
+
color: var(--zaui-text-weak, #a0a0a0);
|
|
356
|
+
font-size: 16px;
|
|
357
|
+
vertical-align: middle;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
.pro-form-list-mode-block{
|
|
361
|
+
.pro-collapse-content{
|
|
362
|
+
.@{ant-prefix}-row{
|
|
363
|
+
width: auto;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
349
367
|
}
|
|
@@ -1,46 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isEqual, isFunction } from 'lodash';
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import { isEqual, isFunction, isString } from 'lodash';
|
|
3
3
|
var nullValue = [null, undefined, '']; // 输入框空值时可能存在的三种值 视为相等
|
|
4
|
-
var extractValue = function extractValue(obj, path) {
|
|
5
|
-
var value = obj || {};
|
|
6
|
-
if (!Object.keys(obj)) {
|
|
7
|
-
return [];
|
|
8
|
-
}
|
|
9
|
-
var _iterator = _createForOfIteratorHelper(path),
|
|
10
|
-
_step;
|
|
11
|
-
try {
|
|
12
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
13
|
-
var key = _step.value;
|
|
14
|
-
if (value && value.hasOwnProperty(key)) {
|
|
15
|
-
value = value[key];
|
|
16
|
-
} else {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
} catch (err) {
|
|
21
|
-
_iterator.e(err);
|
|
22
|
-
} finally {
|
|
23
|
-
_iterator.f();
|
|
24
|
-
}
|
|
25
|
-
return Object.values(value);
|
|
26
|
-
};
|
|
27
4
|
/** 将解构后的name值,反向转回names,例如 formData {a:1, b:2} names ['a', 'b'] 返回 [1,2] */
|
|
28
|
-
var extractValues = function extractValues(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
5
|
+
var extractValues = function extractValues(form, pathString) {
|
|
6
|
+
var _pathString;
|
|
7
|
+
var result = [];
|
|
8
|
+
var PrefixesName = isString(pathString) ? [] : pathString.slice(0, -1);
|
|
9
|
+
if (isString(pathString)) {
|
|
10
|
+
pathString.split('-').forEach(function (item) {
|
|
11
|
+
result.push(form.getFieldValue([].concat(_toConsumableArray(PrefixesName), [item])));
|
|
12
|
+
});
|
|
13
|
+
return result;
|
|
32
14
|
}
|
|
33
|
-
|
|
34
|
-
|
|
15
|
+
(_pathString = pathString[pathString.length - 1]) === null || _pathString === void 0 ? void 0 : _pathString.split('-').forEach(function (item) {
|
|
16
|
+
result.push(form.getFieldValue([].concat(_toConsumableArray(PrefixesName), [item])));
|
|
35
17
|
});
|
|
18
|
+
return result;
|
|
36
19
|
};
|
|
37
20
|
export var diffOriginal = function diffOriginal(params) {
|
|
21
|
+
var _name$join;
|
|
38
22
|
var originalValue = params.originalValue,
|
|
39
23
|
_value = params.value,
|
|
40
24
|
equalWith = params.equalWith,
|
|
41
25
|
form = params.form,
|
|
42
26
|
name = params.name;
|
|
43
|
-
var
|
|
27
|
+
var isNames = Array.isArray(name) && ((_name$join = name.join(',')) === null || _name$join === void 0 ? void 0 : _name$join.includes('-')) || (name === null || name === void 0 ? void 0 : name.includes('-'));
|
|
28
|
+
var value = !isNames ? _value : extractValues(form, name);
|
|
44
29
|
// 支持传入自定义比较事件
|
|
45
30
|
if (isFunction(equalWith)) {
|
|
46
31
|
return !equalWith(originalValue, value);
|
|
@@ -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 值
|
|
@@ -5,6 +5,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import { useState } from 'react';
|
|
7
7
|
import _, { isObject, isFunction, cloneDeep, get, set, omit, isNaN } from 'lodash';
|
|
8
|
+
import moment from 'moment';
|
|
8
9
|
export var getLayout = function getLayout(params) {
|
|
9
10
|
var _params$span = params.span,
|
|
10
11
|
span = _params$span === void 0 ? 8 : _params$span,
|
|
@@ -42,7 +43,7 @@ export var useControlled = function useControlled(props) {
|
|
|
42
43
|
export var isSelect = function isSelect(props) {
|
|
43
44
|
var dataSource = props.dataSource,
|
|
44
45
|
type = props.type;
|
|
45
|
-
return (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) || ['Select', 'ProSelect', 'ProEnum', 'DatePicker', 'RangePicker', 'ProAddressBar', 'ProTimeLimit', 'ProModalSelect', 'ProTreeModal', 'ProUpload'].includes(type);
|
|
46
|
+
return (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) || ['Select', 'ProSelect', 'ProEnum', 'DatePicker', 'RangePicker', 'ProAddressBar', 'ProTimeLimit', 'ProModalSelect', 'ProTreeModal', 'ProUpload', 'TimePicker'].includes(type);
|
|
46
47
|
};
|
|
47
48
|
/**
|
|
48
49
|
* Input TextArea 移除前后空格
|
|
@@ -122,8 +123,8 @@ export var splitNameStr = function splitNameStr(name) {
|
|
|
122
123
|
// 过滤掉字段名中包含 '-' 的字段
|
|
123
124
|
export var filterInternalFields = function filterInternalFields(values) {
|
|
124
125
|
var nextValues = values;
|
|
125
|
-
// fix: braft-editor对象不可遍历
|
|
126
|
-
if (values === null || values === void 0 ? void 0 : values._immutable) {
|
|
126
|
+
// fix: braft-editor对象不可遍历 Moment不过滤
|
|
127
|
+
if ((values === null || values === void 0 ? void 0 : values._immutable) || moment.isMoment(values)) {
|
|
127
128
|
return nextValues;
|
|
128
129
|
}
|
|
129
130
|
if (Array.isArray(nextValues)) {
|
|
@@ -171,10 +172,15 @@ export var isNullValue = function isNullValue(value) {
|
|
|
171
172
|
* @param arr 值
|
|
172
173
|
* @returns boole
|
|
173
174
|
*/
|
|
174
|
-
export var isNotFullArray = function isNotFullArray(arr, length) {
|
|
175
|
+
export var isNotFullArray = function isNotFullArray(arr, length, required) {
|
|
175
176
|
if (!Array.isArray(arr)) {
|
|
176
177
|
return false;
|
|
177
178
|
}
|
|
179
|
+
if (Array.isArray(required) && required.some(function (item) {
|
|
180
|
+
return item === false;
|
|
181
|
+
})) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
178
184
|
if (arr.length < length) return true;
|
|
179
185
|
return arr.some(function (item) {
|
|
180
186
|
if (item === undefined || item === null) {
|
|
@@ -295,6 +301,10 @@ export function initialValuesToNames() {
|
|
|
295
301
|
values[key] = formInitialValue;
|
|
296
302
|
}
|
|
297
303
|
}
|
|
304
|
+
// 给FormList默认增加一行
|
|
305
|
+
if (item.type === 'FormList' && !item.initialValue && !get(values, item.name)) {
|
|
306
|
+
item.initialValue = [{}];
|
|
307
|
+
}
|
|
298
308
|
});
|
|
299
309
|
return values;
|
|
300
310
|
}
|
|
@@ -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,34 @@ 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 _errorValues3;
|
|
50
|
+
var errorValues = getNonEmptyValuesByIndex(required, value);
|
|
51
|
+
if ((value === null || value === void 0 ? void 0 : value.length) === 2) {
|
|
52
|
+
var _errorValues;
|
|
53
|
+
errorValues = errorValues.map(function (item) {
|
|
54
|
+
var _locale$ProForm;
|
|
55
|
+
return locale === null || locale === void 0 ? void 0 : (_locale$ProForm = locale.ProForm) === null || _locale$ProForm === void 0 ? void 0 : _locale$ProForm.ruleStartEndText[item - 1];
|
|
56
|
+
});
|
|
57
|
+
if ((_errorValues = errorValues) === null || _errorValues === void 0 ? void 0 : _errorValues.length) {
|
|
58
|
+
var _locale$ProForm2, _errorValues2;
|
|
59
|
+
return Promise.reject(new Error("".concat(locale === null || locale === void 0 ? void 0 : (_locale$ProForm2 = locale.ProForm) === null || _locale$ProForm2 === void 0 ? void 0 : _locale$ProForm2.inputPlaceholder).concat((_errorValues2 = errorValues) === null || _errorValues2 === void 0 ? void 0 : _errorValues2.join(','))));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// 校验为true的值是否存在
|
|
63
|
+
if (Array.isArray(value) && ((_errorValues3 = errorValues) === null || _errorValues3 === void 0 ? void 0 : _errorValues3.length)) {
|
|
64
|
+
var _locale$ProForm3, _errorValues4;
|
|
65
|
+
return Promise.reject(new Error("".concat(formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProForm3 = locale.ProForm) === null || _locale$ProForm3 === void 0 ? void 0 : _locale$ProForm3.halfRuleText, {
|
|
66
|
+
total: (_errorValues4 = errorValues) === null || _errorValues4 === void 0 ? void 0 : _errorValues4.join(',')
|
|
67
|
+
}))));
|
|
68
|
+
}
|
|
69
|
+
return Promise.resolve();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
result.push(customRequired);
|
|
73
|
+
}
|
|
32
74
|
if (!((_result = result) === null || _result === void 0 ? void 0 : _result.length)) {
|
|
33
75
|
result = [{
|
|
34
76
|
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,
|
package/es/ProIcon/index.js
CHANGED
|
@@ -40,9 +40,6 @@ var ProIcon = function ProIcon(props) {
|
|
|
40
40
|
var language = locale.ProIcon.language;
|
|
41
41
|
// 加载内部icon
|
|
42
42
|
var status = useExternal('https://at.alicdn.com/t/c/font_4063056_jmnz9g5uycp.js');
|
|
43
|
-
if (status !== 'ready') {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
43
|
var rotateStyle = rotate ? {
|
|
47
44
|
msTransform: "rotate(".concat(rotate, "deg)"),
|
|
48
45
|
transform: "rotate(".concat(rotate, "deg)")
|
|
@@ -7,6 +7,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
7
7
|
import "antd/es/collapse/style";
|
|
8
8
|
import _Collapse from "antd/es/collapse";
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { useLayoutEffect } from 'react';
|
|
10
11
|
import { CaretRightOutlined } from '@ant-design/icons';
|
|
11
12
|
import classNames from 'classnames';
|
|
12
13
|
import { ReactSVG } from 'react-svg';
|
|
@@ -38,7 +39,8 @@ var ProCollapse = function ProCollapse(props) {
|
|
|
38
39
|
'pro-collapse': true,
|
|
39
40
|
'pro-collapse-level2': level === '2',
|
|
40
41
|
'pro-collapse-list': titleList === null || titleList === void 0 ? void 0 : titleList.length,
|
|
41
|
-
'pro-collapse-no-title': !title
|
|
42
|
+
'pro-collapse-no-title': !title,
|
|
43
|
+
'pro-collapse-no-level1-title': !title && level !== '2'
|
|
42
44
|
}, "".concat(className), className));
|
|
43
45
|
var content = _jsx("div", {
|
|
44
46
|
className: "pro-collapse-content",
|
|
@@ -107,6 +109,26 @@ var ProCollapse = function ProCollapse(props) {
|
|
|
107
109
|
}), content]
|
|
108
110
|
});
|
|
109
111
|
};
|
|
112
|
+
// 当pro-layout-content只存在一个card时,高度动态计算
|
|
113
|
+
useLayoutEffect(function () {
|
|
114
|
+
var proCollapseContent = document.querySelector('.pro-layout-content');
|
|
115
|
+
if (!proCollapseContent) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
var proCollapseNoTitles = proCollapseContent.querySelectorAll('.pro-collapse-no-level1-title');
|
|
119
|
+
var proCollapses = proCollapseContent.querySelectorAll('.pro-collapse');
|
|
120
|
+
if (proCollapseNoTitles.length === 1 && proCollapses.length === 1) {
|
|
121
|
+
var rect = proCollapseNoTitles[0].getBoundingClientRect();
|
|
122
|
+
if ((rect === null || rect === void 0 ? void 0 : rect.height) < window.innerHeight - rect.top) {
|
|
123
|
+
proCollapseNoTitles[0].style.minHeight = "calc(100vh - ".concat(rect.top + 16, "px)");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return function () {
|
|
127
|
+
if (proCollapseNoTitles.length === 1 && proCollapses.length === 1) {
|
|
128
|
+
proCollapseNoTitles[0].style.minHeight = 'auto'; // 移除 minHeight 的设置
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
});
|
|
110
132
|
return _jsx("div", {
|
|
111
133
|
id: id,
|
|
112
134
|
style: style,
|
|
@@ -12,6 +12,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
import { CheckOutlined, CloseOutlined } from '@ant-design/icons';
|
|
13
13
|
import { useState, useEffect } from 'react';
|
|
14
14
|
import { setThemes } from '../../utils/index';
|
|
15
|
+
import { useProConfig } from '../../../ProConfigProvider';
|
|
15
16
|
import locale from '../../../locale';
|
|
16
17
|
var connect = function connect(Component) {
|
|
17
18
|
var ComponentWrapper = function ComponentWrapper(props) {
|
|
@@ -29,6 +30,10 @@ var PrdTools = function PrdTools(_ref) {
|
|
|
29
30
|
tableBorder = _ref.tableBorder,
|
|
30
31
|
tableStripe = _ref.tableStripe,
|
|
31
32
|
prefixCls = _ref.prefixCls;
|
|
33
|
+
var _useProConfig = useProConfig(),
|
|
34
|
+
config = _useProConfig.state,
|
|
35
|
+
dispatch = _useProConfig.dispatch;
|
|
36
|
+
var ProForm = config.ProForm;
|
|
32
37
|
var _useState = useState([{
|
|
33
38
|
color: '#006AFF',
|
|
34
39
|
active: true
|
|
@@ -146,35 +151,16 @@ var PrdTools = function PrdTools(_ref) {
|
|
|
146
151
|
}), _jsx("div", {
|
|
147
152
|
className: "pro-theme-tools-item",
|
|
148
153
|
children: _jsxs(_Radio.Group, {
|
|
149
|
-
value:
|
|
154
|
+
value: ProForm === null || ProForm === void 0 ? void 0 : ProForm.labelAlign,
|
|
150
155
|
onChange: function onChange(e) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
var _label$classList, _label$classList$valu, _label$classList2, _label$classList2$val;
|
|
158
|
-
if (!label) {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
if (e.target.value === 'left' && !((_label$classList = label.classList) === null || _label$classList === void 0 ? void 0 : (_label$classList$valu = _label$classList.value) === null || _label$classList$valu === void 0 ? void 0 : _label$classList$valu.includes("".concat(prefixCls, "-form-item-label-left")))) {
|
|
162
|
-
label.classList.add("".concat(prefixCls, "-form-item-label-left"));
|
|
163
|
-
}
|
|
164
|
-
if (e.target.value === 'right' && ((_label$classList2 = label.classList) === null || _label$classList2 === void 0 ? void 0 : (_label$classList2$val = _label$classList2.value) === null || _label$classList2$val === void 0 ? void 0 : _label$classList2$val.includes("".concat(prefixCls, "-form-item-label-left")))) {
|
|
165
|
-
label.classList.remove("".concat(prefixCls, "-form-item-label-left"));
|
|
156
|
+
dispatch({
|
|
157
|
+
type: 'setWithLocal',
|
|
158
|
+
payload: {
|
|
159
|
+
ProForm: {
|
|
160
|
+
labelAlign: e.target.value
|
|
161
|
+
}
|
|
166
162
|
}
|
|
167
163
|
});
|
|
168
|
-
setState(_objectSpread(_objectSpread({}, state), {}, {
|
|
169
|
-
zauiFormAlign: e.target.value,
|
|
170
|
-
zauiFormRequiredAfter: after,
|
|
171
|
-
zauiFormRequiredBefore: before
|
|
172
|
-
}));
|
|
173
|
-
setThemes({
|
|
174
|
-
'zaui-form-align': e.target.value,
|
|
175
|
-
'zaui-form-required-after': after,
|
|
176
|
-
'zaui-form-required-before': before
|
|
177
|
-
});
|
|
178
164
|
},
|
|
179
165
|
children: [_jsx(_Radio.Button, {
|
|
180
166
|
value: "left",
|
|
@@ -185,30 +171,6 @@ var PrdTools = function PrdTools(_ref) {
|
|
|
185
171
|
})]
|
|
186
172
|
})
|
|
187
173
|
})]
|
|
188
|
-
}), _jsxs("div", {
|
|
189
|
-
className: "pro-theme-tools-box pro-theme-tools-space pro-theme-tools-small-space",
|
|
190
|
-
children: [_jsx("div", {
|
|
191
|
-
className: "pro-theme-tools-item",
|
|
192
|
-
children: _jsx("p", {
|
|
193
|
-
children: "".concat(locale.ProThemeTools.bigText)
|
|
194
|
-
})
|
|
195
|
-
}), _jsx("div", {
|
|
196
|
-
className: "pro-theme-tools-item",
|
|
197
|
-
children: _jsx(_Switch, {
|
|
198
|
-
checkedChildren: "".concat(locale.ProThemeTools.switchText[0]),
|
|
199
|
-
unCheckedChildren: "".concat(locale.ProThemeTools.switchText[1]),
|
|
200
|
-
checked: state.zauiBigText,
|
|
201
|
-
onClick: function onClick(value) {
|
|
202
|
-
setState(_objectSpread(_objectSpread({}, state), {}, {
|
|
203
|
-
zauiBaseFontSize: value ? 2 : 0,
|
|
204
|
-
zauiBigText: value
|
|
205
|
-
}));
|
|
206
|
-
setThemes({
|
|
207
|
-
'zaui-base-font-size': value ? '2px' : '0px'
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
})
|
|
211
|
-
})]
|
|
212
174
|
}), tableBorder && _jsxs("div", {
|
|
213
175
|
className: "pro-theme-tools-box pro-theme-tools-space pro-theme-tools-small-space",
|
|
214
176
|
children: [_jsx("div", {
|
|
@@ -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-prefix}-select-dropdown.pro-tree-select-drop-down-container.checkable-tree{
|
|
342
|
+
overflow: hidden!important;
|
|
343
|
+
}
|