@zat-design/sisyphus-react 3.4.2 → 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 +303 -267
- package/dist/less.esm.css +5024 -0
- package/dist/less.esm.js +3 -0
- package/es/ProConfigProvider/index.d.ts +1 -1
- package/es/ProConfigProvider/index.js +24 -2
- package/es/ProEditLabel/style/index.less +1 -2
- package/es/ProEditTable/components/RenderField/index.js +32 -21
- package/es/ProEditTable/index.js +3 -3
- package/es/ProEditTable/propsType.d.ts +1 -1
- package/es/ProEditTable/style/index.less +1 -1
- package/es/ProEditTable/utils/config.js +5 -5
- package/es/ProEditTable/utils/index.js +67 -30
- package/es/ProEditTable/utils/tools.js +3 -1
- package/es/ProEnum/components/Group.d.ts +2 -0
- package/es/ProEnum/components/Group.js +20 -19
- package/es/ProEnum/index.js +4 -3
- package/es/ProEnum/style/index.less +12 -3
- package/es/ProForm/components/base/DatePicker/index.js +2 -2
- package/es/ProForm/components/combination/FormList/index.js +6 -3
- package/es/ProForm/components/combination/FormList/utils.d.ts +2 -1
- package/es/ProForm/components/combination/FormList/utils.js +5 -3
- package/es/ProForm/components/combination/Group/index.js +31 -17
- package/es/ProForm/components/combination/Group/propsType.d.ts +6 -0
- package/es/ProForm/components/combination/Group/style/index.less +4 -4
- package/es/ProForm/components/combination/Group/utils.d.ts +2 -0
- package/es/ProForm/components/combination/Group/utils.js +10 -0
- package/es/ProForm/components/combination/ProTimeLimit/index.js +8 -2
- package/es/ProForm/components/combination/ProTimeLimit/style/index.less +1 -1
- package/es/ProForm/components/index.d.ts +0 -1
- package/es/ProForm/components/index.js +1 -1
- package/es/ProForm/components/render/ConfirmWrapper.js +1 -1
- package/es/ProForm/components/render/Render.js +21 -13
- package/es/ProForm/components/render/RenderFields.d.ts +3 -2
- package/es/ProForm/components/render/RenderFields.js +7 -3
- package/es/ProForm/components/render/propsType.d.ts +2 -5
- package/es/ProForm/index.js +12 -11
- package/es/ProForm/propsType.d.ts +7 -3
- package/es/ProForm/style/index.less +17 -13
- package/es/ProForm/utils/{contrastOriginal.d.ts → diffOriginal.d.ts} +2 -1
- package/es/ProForm/utils/diffOriginal.js +61 -0
- package/es/ProForm/utils/index.d.ts +2 -2
- package/es/ProForm/utils/index.js +7 -2
- package/es/ProForm/utils/rulesCreator.d.ts +7 -1
- package/es/ProForm/utils/rulesCreator.js +33 -3
- package/es/ProForm/utils/transformNames.d.ts +1 -1
- package/es/ProForm/utils/transformNames.js +11 -4
- package/es/ProForm/utils/transformValue.js +2 -2
- package/es/ProForm/utils/useChanged.js +4 -3
- package/es/ProForm/utils/useListChanged.d.ts +1 -1
- package/es/ProForm/utils/useListChanged.js +5 -3
- package/es/ProForm/utils/useRules.js +36 -11
- package/es/ProForm/utils/useShouldUpdate.js +4 -4
- package/es/ProForm/utils/valueType.d.ts +10 -5
- package/es/ProForm/utils/valueType.js +20 -10
- package/es/ProIcon/config/index.d.ts +2 -1
- package/es/ProIcon/config/index.js +191 -133
- package/es/ProIcon/index.d.ts +0 -1
- package/es/ProIcon/index.js +21 -36
- package/es/ProIcon/propsTypes.d.ts +2 -1
- package/es/ProLayout/components/Layout/Header/style/index.less +1 -1
- package/es/ProLayout/components/Layout/Menu/OpenMenu/style/index.less +58 -55
- package/es/ProLayout/components/Layout/Menu/SideMenu/style/index.less +25 -20
- package/es/ProLayout/components/Layout/Menu/style/index.less +52 -56
- package/es/ProLayout/components/ProCollapse/PropTypes.d.ts +5 -0
- package/es/ProLayout/components/ProCollapse/index.js +45 -4
- package/es/ProLayout/components/ProCollapse/style/index.less +29 -11
- package/es/ProLayout/components/ProFooter/index.js +1 -1
- package/es/ProLayout/components/ProFooter/style/index.less +1 -1
- package/es/ProLayout/components/ProHeader/style/index.less +6 -5
- package/es/ProLayout/style/index.less +176 -88
- package/es/ProStep/components/Item/index.js +2 -1
- package/es/ProStep/style/index.less +71 -70
- package/es/ProTable/components/RenderColumn/index.d.ts +1 -1
- package/es/ProTable/components/RenderColumn/index.js +3 -3
- package/es/ProTable/propsType.d.ts +1 -1
- package/es/ProTable/style/index.less +2 -2
- package/es/ProTable/utils.js +9 -9
- package/es/ProTabs/style/index.less +3 -1
- package/es/ProThemeTools/component/PrdTools/index.d.ts +1 -1
- package/es/ProThemeTools/component/PrdTools/index.js +14 -28
- package/es/ProThemeTools/component/PrdTools/style/index.less +1 -1
- package/es/ProThemeTools/index.js +21 -29
- package/es/ProThemeTools/propsType.d.ts +1 -1
- package/es/ProThemeTools/style/index.less +25 -8
- package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.js +7 -11
- package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.d.ts +1 -1
- package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/style/index.less +1 -1
- package/es/ProTree/index.js +1 -1
- package/es/ProTree/style/index.less +5 -0
- package/es/ProTreeModal/style/index.less +2 -2
- package/es/ProUpload/style/fileItem.less +2 -2
- package/es/ProUpload/style/index.less +2 -2
- package/es/assets/catalog.svg +30 -1
- package/es/assets/fold.svg +27 -0
- package/es/assets/setting.svg +14 -0
- package/es/locale/en_US.d.ts +4 -0
- package/es/locale/en_US.js +4 -0
- package/es/locale/zh_CN.d.ts +4 -0
- package/es/locale/zh_CN.js +4 -0
- package/es/style/components.less +0 -1
- package/es/style/less.less +2 -0
- package/es/style/theme/antd.less +14 -29
- package/es/style/theme/index.less +2 -2
- package/es/style/theme/tokens.less +2 -2
- package/es/tokens.js +2 -2
- package/lib/ProConfigProvider/index.d.ts +1 -1
- package/lib/ProConfigProvider/index.js +23 -1
- package/lib/ProEditLabel/style/index.less +1 -2
- package/lib/ProEditTable/components/RenderField/index.js +31 -20
- package/lib/ProEditTable/index.js +3 -3
- package/lib/ProEditTable/propsType.d.ts +1 -1
- package/lib/ProEditTable/style/index.less +1 -1
- package/lib/ProEditTable/utils/config.js +5 -5
- package/lib/ProEditTable/utils/index.js +67 -30
- package/lib/ProEditTable/utils/tools.js +3 -1
- package/lib/ProEnum/components/Group.d.ts +2 -0
- package/lib/ProEnum/components/Group.js +20 -19
- package/lib/ProEnum/index.js +4 -3
- package/lib/ProEnum/style/index.less +12 -3
- package/lib/ProForm/components/base/DatePicker/index.js +1 -1
- package/lib/ProForm/components/combination/FormList/index.js +6 -3
- package/lib/ProForm/components/combination/FormList/utils.d.ts +2 -1
- package/lib/ProForm/components/combination/FormList/utils.js +5 -3
- package/lib/ProForm/components/combination/Group/index.js +28 -14
- package/lib/ProForm/components/combination/Group/propsType.d.ts +6 -0
- package/lib/ProForm/components/combination/Group/style/index.less +4 -4
- package/lib/ProForm/components/combination/Group/utils.d.ts +2 -0
- package/lib/ProForm/components/combination/Group/utils.js +11 -1
- package/lib/ProForm/components/combination/ProTimeLimit/index.js +7 -1
- package/lib/ProForm/components/combination/ProTimeLimit/style/index.less +1 -1
- package/lib/ProForm/components/index.d.ts +0 -1
- package/lib/ProForm/components/index.js +0 -7
- package/lib/ProForm/components/render/ConfirmWrapper.js +1 -1
- package/lib/ProForm/components/render/Render.js +21 -13
- package/lib/ProForm/components/render/RenderFields.d.ts +3 -2
- package/lib/ProForm/components/render/RenderFields.js +7 -3
- package/lib/ProForm/components/render/propsType.d.ts +2 -5
- package/lib/ProForm/index.js +11 -10
- package/lib/ProForm/propsType.d.ts +7 -3
- package/lib/ProForm/style/index.less +17 -13
- package/lib/ProForm/utils/{contrastOriginal.d.ts → diffOriginal.d.ts} +2 -1
- package/lib/ProForm/utils/diffOriginal.js +68 -0
- package/lib/ProForm/utils/index.d.ts +2 -2
- package/lib/ProForm/utils/index.js +8 -3
- package/lib/ProForm/utils/rulesCreator.d.ts +7 -1
- package/lib/ProForm/utils/rulesCreator.js +33 -2
- package/lib/ProForm/utils/transformNames.d.ts +1 -1
- package/lib/ProForm/utils/transformNames.js +10 -3
- package/lib/ProForm/utils/transformValue.js +1 -1
- package/lib/ProForm/utils/useChanged.js +4 -3
- package/lib/ProForm/utils/useListChanged.d.ts +1 -1
- package/lib/ProForm/utils/useListChanged.js +5 -3
- package/lib/ProForm/utils/useRules.js +36 -11
- package/lib/ProForm/utils/useShouldUpdate.js +4 -4
- package/lib/ProForm/utils/valueType.d.ts +10 -5
- package/lib/ProForm/utils/valueType.js +20 -10
- package/lib/ProIcon/config/index.d.ts +2 -1
- package/lib/ProIcon/config/index.js +191 -133
- package/lib/ProIcon/index.d.ts +0 -1
- package/lib/ProIcon/index.js +21 -37
- package/lib/ProIcon/propsTypes.d.ts +2 -1
- package/lib/ProLayout/components/Layout/Header/style/index.less +1 -1
- package/lib/ProLayout/components/Layout/Menu/OpenMenu/style/index.less +58 -55
- package/lib/ProLayout/components/Layout/Menu/SideMenu/style/index.less +25 -20
- package/lib/ProLayout/components/Layout/Menu/style/index.less +52 -56
- package/lib/ProLayout/components/ProCollapse/PropTypes.d.ts +5 -0
- package/lib/ProLayout/components/ProCollapse/index.js +43 -4
- package/lib/ProLayout/components/ProCollapse/style/index.less +29 -11
- package/lib/ProLayout/components/ProFooter/index.js +1 -1
- package/lib/ProLayout/components/ProFooter/style/index.less +1 -1
- package/lib/ProLayout/components/ProHeader/style/index.less +6 -5
- package/lib/ProLayout/style/index.less +176 -88
- package/lib/ProStep/components/Item/index.js +2 -1
- package/lib/ProStep/style/index.less +71 -70
- package/lib/ProTable/components/RenderColumn/index.d.ts +1 -1
- package/lib/ProTable/components/RenderColumn/index.js +3 -3
- package/lib/ProTable/propsType.d.ts +1 -1
- package/lib/ProTable/style/index.less +2 -2
- package/lib/ProTable/utils.js +9 -9
- package/lib/ProTabs/style/index.less +3 -1
- package/lib/ProThemeTools/component/PrdTools/index.d.ts +1 -1
- package/lib/ProThemeTools/component/PrdTools/index.js +14 -28
- package/lib/ProThemeTools/component/PrdTools/style/index.less +1 -1
- package/lib/ProThemeTools/index.js +19 -28
- package/lib/ProThemeTools/propsType.d.ts +1 -1
- package/lib/ProThemeTools/style/index.less +25 -8
- package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.js +7 -11
- package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.d.ts +1 -1
- package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/style/index.less +1 -1
- package/lib/ProTree/index.js +1 -1
- package/lib/ProTree/style/index.less +5 -0
- package/lib/ProTreeModal/style/index.less +2 -2
- package/lib/ProUpload/style/fileItem.less +2 -2
- package/lib/ProUpload/style/index.less +2 -2
- package/lib/assets/catalog.svg +30 -1
- package/lib/assets/fold.svg +27 -0
- package/lib/assets/setting.svg +14 -0
- package/lib/locale/en_US.d.ts +4 -0
- package/lib/locale/en_US.js +4 -0
- package/lib/locale/zh_CN.d.ts +4 -0
- package/lib/locale/zh_CN.js +4 -0
- package/lib/style/components.less +0 -1
- package/lib/style/less.less +2 -0
- package/lib/style/theme/antd.less +14 -29
- package/lib/style/theme/index.less +2 -2
- package/lib/style/theme/tokens.less +2 -2
- package/lib/tokens.js +2 -2
- package/package.json +1 -1
- package/es/ProForm/utils/contrastOriginal.js +0 -24
- package/es/ProIcon/symbolIcon.js +0 -43
- package/lib/ProForm/utils/contrastOriginal.js +0 -30
- package/lib/ProIcon/symbolIcon.js +0 -45
- /package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.d.ts +0 -0
- /package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.js +0 -0
- /package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.d.ts +0 -0
- /package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.js +0 -0
|
@@ -31,16 +31,6 @@
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
&.@{ant-prefix}-form {
|
|
35
|
-
margin-bottom: calc(var(--zaui-space-size-md; 16px) * var(--zaui-size; 1));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.pro-collapse-level2 {
|
|
39
|
-
.@{ant-prefix}-collapse-item {
|
|
40
|
-
margin-bottom: 0 !important;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
34
|
.@{ant-prefix}-form-item-control-input {
|
|
45
35
|
flex-grow: 1;
|
|
46
36
|
max-width: 100%;
|
|
@@ -135,7 +125,7 @@
|
|
|
135
125
|
background: @zaui-contract-bg !important;
|
|
136
126
|
|
|
137
127
|
input {
|
|
138
|
-
background:
|
|
128
|
+
background: transparent;
|
|
139
129
|
}
|
|
140
130
|
.@{ant-prefix}-select-selection-placeholder {
|
|
141
131
|
z-index: 9;
|
|
@@ -147,8 +137,22 @@
|
|
|
147
137
|
border-radius: 4px;
|
|
148
138
|
}
|
|
149
139
|
|
|
150
|
-
//
|
|
151
|
-
.@{ant-prefix}-form-item-control-input-content
|
|
140
|
+
// 地址组件
|
|
141
|
+
.@{ant-prefix}-form-item-control-input-content {
|
|
142
|
+
& > .pro-address {
|
|
143
|
+
.ant-select-selector,
|
|
144
|
+
.ant-input-affix-wrapper,
|
|
145
|
+
.ant-input-disabled {
|
|
146
|
+
background: @zaui-contract-bg;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
& > .ant-input-group {
|
|
150
|
+
.forever-checkbox {
|
|
151
|
+
background: @zaui-contract-bg;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
152
156
|
.pro-form-view-container {
|
|
153
157
|
padding: 4px 8px;
|
|
154
158
|
background: @zaui-contract-bg;
|
|
@@ -3,7 +3,8 @@ interface Params {
|
|
|
3
3
|
originalValue: any;
|
|
4
4
|
value: any;
|
|
5
5
|
form: FormInstance;
|
|
6
|
+
name?: string | any[];
|
|
6
7
|
equalWith?: (originalValue: any, currentValue: any) => boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const diffOriginal: (params: Params) => boolean;
|
|
9
10
|
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
+
import { isEqual, isFunction } from 'lodash';
|
|
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
|
+
/** 将解构后的name值,反向转回names,例如 formData {a:1, b:2} names ['a', 'b'] 返回 [1,2] */
|
|
28
|
+
var extractValues = function extractValues(data, pathString) {
|
|
29
|
+
if (pathString.includes('_')) {
|
|
30
|
+
var namePrefixes = pathString.split('-')[0].split('_').slice(0, -1);
|
|
31
|
+
return extractValue(data, namePrefixes);
|
|
32
|
+
}
|
|
33
|
+
return pathString.split('-').map(function (item) {
|
|
34
|
+
return data[item];
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export var diffOriginal = function diffOriginal(params) {
|
|
38
|
+
var originalValue = params.originalValue,
|
|
39
|
+
_value = params.value,
|
|
40
|
+
equalWith = params.equalWith,
|
|
41
|
+
form = params.form,
|
|
42
|
+
name = params.name;
|
|
43
|
+
var value = !(name === null || name === void 0 ? void 0 : name.includes('-')) ? _value : extractValues(form.getFieldsValue(), name);
|
|
44
|
+
// 支持传入自定义比较事件
|
|
45
|
+
if (isFunction(equalWith)) {
|
|
46
|
+
return !equalWith(originalValue, value);
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(originalValue)) {
|
|
49
|
+
return originalValue.some(function (valueItem, index) {
|
|
50
|
+
// 如果两个值有一个不是空值, 则进行深比较
|
|
51
|
+
if (!nullValue.includes(value === null || value === void 0 ? void 0 : value[index]) || !nullValue.includes(valueItem)) {
|
|
52
|
+
return !isEqual(value === null || value === void 0 ? void 0 : value[index], valueItem);
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (!nullValue.includes(value) || !nullValue.includes(originalValue)) {
|
|
58
|
+
return !isEqual(value, originalValue);
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
};
|
|
@@ -26,7 +26,7 @@ export declare const isTrim: (type: string, trim: boolean, configData: any) => a
|
|
|
26
26
|
*/
|
|
27
27
|
export declare const isUpperCase: (type: string, upperCase: boolean) => any;
|
|
28
28
|
export declare const weedOutProps: (data: Record<string, any>, keys: string[]) => {}[];
|
|
29
|
-
export declare const
|
|
29
|
+
export declare const diffField: (prevValues: any, curValues: any, names: NamePath[]) => boolean;
|
|
30
30
|
export declare const splitNameStr: (name: string) => NamePath[];
|
|
31
31
|
export declare const filterInternalFields: (values: any) => any;
|
|
32
32
|
export declare const getAllNamePath: (object: Record<string, any>, currentPath?: InternalNamePath) => InternalNamePath[];
|
|
@@ -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 值
|
|
@@ -108,7 +108,7 @@ export var weedOutProps = function weedOutProps(data, keys) {
|
|
|
108
108
|
return [obj, weedOut];
|
|
109
109
|
};
|
|
110
110
|
// 对比字段变化
|
|
111
|
-
export var
|
|
111
|
+
export var diffField = function diffField(prevValues, curValues, names) {
|
|
112
112
|
return names.some(function (name) {
|
|
113
113
|
return _.get(prevValues, name) !== _.get(curValues, name);
|
|
114
114
|
});
|
|
@@ -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
|
|
@@ -6,5 +6,5 @@ interface TransformProps extends FormItemProps {
|
|
|
6
6
|
namePath: any[];
|
|
7
7
|
}
|
|
8
8
|
type TransformFun = 'normalize' | 'getValueProps' | 'shouldUpdate' | 'name';
|
|
9
|
-
declare const transformNames: (formItem: TransformProps, form: FormInstance, names: NamePath[], fieldName: string) => Pick<TransformProps, TransformFun>;
|
|
9
|
+
declare const transformNames: (formItem: TransformProps, form: FormInstance, names: NamePath[], fieldName: string, type?: string) => Pick<TransformProps, TransformFun>;
|
|
10
10
|
export default transformNames;
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { union } from 'lodash';
|
|
1
|
+
import { union, isNumber } from 'lodash';
|
|
2
2
|
import { transformValue } from './transformValue';
|
|
3
|
-
var transformNames = function transformNames(formItem, form, names, fieldName) {
|
|
3
|
+
var transformNames = function transformNames(formItem, form, names, fieldName, type) {
|
|
4
|
+
var _names2, _names3, _names3$;
|
|
4
5
|
var _ref = formItem || {},
|
|
5
6
|
normalize = _ref.normalize,
|
|
6
7
|
getValueProps = _ref.getValueProps,
|
|
7
8
|
_shouldUpdate2 = _ref.shouldUpdate;
|
|
8
|
-
|
|
9
|
+
var _names = names;
|
|
10
|
+
if (!((_names2 = _names) === null || _names2 === void 0 ? void 0 : _names2.length)) {
|
|
9
11
|
return {};
|
|
10
12
|
}
|
|
11
13
|
// 当在formList场景下,给transformValue函数的setFiledProps的name, 需要全namePath
|
|
12
14
|
var _fieldName = Array.isArray(formItem === null || formItem === void 0 ? void 0 : formItem.name) ? union(formItem === null || formItem === void 0 ? void 0 : formItem.namePath, formItem === null || formItem === void 0 ? void 0 : formItem.name) : fieldName;
|
|
13
|
-
|
|
15
|
+
if (type === 'Group' && isNumber((_names3 = _names) === null || _names3 === void 0 ? void 0 : (_names3$ = _names3[0]) === null || _names3$ === void 0 ? void 0 : _names3$[0])) {
|
|
16
|
+
_names = _names.map(function (item) {
|
|
17
|
+
return union(formItem === null || formItem === void 0 ? void 0 : formItem.namePath, item);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
var _transformValue = transformValue(_names, form, _fieldName, normalize, getValueProps),
|
|
14
21
|
_normalize = _transformValue.normalize,
|
|
15
22
|
_getValueProps = _transformValue.getValueProps,
|
|
16
23
|
_shouldUpdate = _transformValue.shouldUpdate;
|
|
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["value"];
|
|
4
4
|
import { set } from 'lodash';
|
|
5
|
-
import {
|
|
5
|
+
import { diffField } from '../utils';
|
|
6
6
|
export var transformValue = function transformValue(names, form, fieldName, _normalize, _getValueProps) {
|
|
7
7
|
return {
|
|
8
8
|
normalize: function normalize(value) {
|
|
@@ -41,7 +41,7 @@ export var transformValue = function transformValue(names, form, fieldName, _nor
|
|
|
41
41
|
}, cusRest);
|
|
42
42
|
},
|
|
43
43
|
shouldUpdate: function shouldUpdate(prevValues, curValues) {
|
|
44
|
-
return
|
|
44
|
+
return diffField(prevValues, curValues, names);
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "antd/es/form/style";
|
|
2
2
|
import _Form from "antd/es/form";
|
|
3
3
|
import { get } from 'lodash';
|
|
4
|
-
import {
|
|
4
|
+
import { diffOriginal } from './diffOriginal';
|
|
5
5
|
export var useChanged = function useChanged(_ref) {
|
|
6
6
|
var name = _ref.name,
|
|
7
7
|
names = _ref.names,
|
|
@@ -16,11 +16,12 @@ export var useChanged = function useChanged(_ref) {
|
|
|
16
16
|
if (notWatch) form = [];
|
|
17
17
|
var value = _Form.useWatch(namesStr || name, form);
|
|
18
18
|
if (notWatch) return [false];
|
|
19
|
-
var changed =
|
|
19
|
+
var changed = diffOriginal({
|
|
20
20
|
originalValue: originalValue,
|
|
21
21
|
value: value,
|
|
22
22
|
form: form,
|
|
23
|
-
equalWith: equalWith
|
|
23
|
+
equalWith: equalWith,
|
|
24
|
+
name: namesStr || name
|
|
24
25
|
});
|
|
25
26
|
return [changed, originalValue];
|
|
26
27
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "antd/es/form/style";
|
|
2
2
|
import _Form from "antd/es/form";
|
|
3
3
|
import { get } from 'lodash';
|
|
4
|
-
import {
|
|
4
|
+
import { diffOriginal } from './diffOriginal';
|
|
5
5
|
var toNamePath = function toNamePath(name) {
|
|
6
6
|
if (Array.isArray(name)) {
|
|
7
7
|
return name;
|
|
@@ -27,6 +27,7 @@ var getOriginalValue = function getOriginalValue(_ref) {
|
|
|
27
27
|
var rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
|
|
28
28
|
var rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
|
|
29
29
|
var rowValue = form.getFieldValue(rowValueNamePath);
|
|
30
|
+
if (!rowValue) return undefined;
|
|
30
31
|
var keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
|
|
31
32
|
if (!keyValue) return undefined;
|
|
32
33
|
var originalValueList = get(originalValues, originalName.slice(0, rowKeyPath.length - 2));
|
|
@@ -83,11 +84,12 @@ export var useListChanged = function useListChanged(params) {
|
|
|
83
84
|
if (notWatch) _form = [];
|
|
84
85
|
var value = _Form.useWatch(namePath, _form);
|
|
85
86
|
if (notWatch || noChange) return [false];
|
|
86
|
-
var changed =
|
|
87
|
+
var changed = diffOriginal({
|
|
87
88
|
value: value,
|
|
88
89
|
originalValue: originalValue,
|
|
89
90
|
form: form,
|
|
90
|
-
equalWith: equalWith
|
|
91
|
+
equalWith: equalWith,
|
|
92
|
+
name: namesStr || name
|
|
91
93
|
});
|
|
92
94
|
return [changed, originalValue];
|
|
93
95
|
};
|
|
@@ -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,
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
/** 年月日 */
|
|
3
|
-
date: ({ type, toISOString }: {
|
|
3
|
+
date: ({ type, toISOString, mode }: {
|
|
4
4
|
type: any;
|
|
5
5
|
toISOString: any;
|
|
6
|
+
mode: any;
|
|
6
7
|
}) => {};
|
|
7
8
|
/** 年月日 时分秒 */
|
|
8
|
-
dateTime: ({ type, toISOString }: {
|
|
9
|
+
dateTime: ({ type, toISOString, mode }: {
|
|
9
10
|
type: any;
|
|
10
11
|
toISOString: any;
|
|
12
|
+
mode: any;
|
|
11
13
|
}) => {};
|
|
12
14
|
/** 年月日 00:00:00 */
|
|
13
|
-
dateStartTime: ({ type, toISOString }: {
|
|
15
|
+
dateStartTime: ({ type, toISOString, mode }: {
|
|
14
16
|
type: any;
|
|
15
17
|
toISOString: any;
|
|
18
|
+
mode: any;
|
|
16
19
|
}) => {};
|
|
17
20
|
/** 年月日 23:59:59 */
|
|
18
|
-
dateEndTime: ({ type, toISOString }: {
|
|
21
|
+
dateEndTime: ({ type, toISOString, mode }: {
|
|
19
22
|
type: any;
|
|
20
23
|
toISOString: any;
|
|
24
|
+
mode: any;
|
|
21
25
|
}) => {};
|
|
22
26
|
/** 年月日 00:00:00 ~ 年月日 23:59:59 */
|
|
23
|
-
dateStartEndTime: ({ type, toISOString }: {
|
|
27
|
+
dateStartEndTime: ({ type, toISOString, mode }: {
|
|
24
28
|
type: any;
|
|
25
29
|
toISOString: any;
|
|
30
|
+
mode: any;
|
|
26
31
|
}) => {};
|
|
27
32
|
/** 百分比 */
|
|
28
33
|
percentage: ({ type, valueType }: {
|
|
@@ -153,51 +153,61 @@ export default {
|
|
|
153
153
|
/** 年月日 */
|
|
154
154
|
date: function date(_ref3) {
|
|
155
155
|
var type = _ref3.type,
|
|
156
|
-
toISOString = _ref3.toISOString
|
|
156
|
+
toISOString = _ref3.toISOString,
|
|
157
|
+
mode = _ref3.mode;
|
|
157
158
|
return dateTransform({
|
|
158
159
|
type: type,
|
|
159
160
|
_valueType: 'date',
|
|
160
|
-
toISOString: toISOString
|
|
161
|
+
toISOString: toISOString,
|
|
162
|
+
mode: mode
|
|
161
163
|
});
|
|
162
164
|
},
|
|
163
165
|
/** 年月日 时分秒 */
|
|
164
166
|
dateTime: function dateTime(_ref4) {
|
|
165
167
|
var type = _ref4.type,
|
|
166
|
-
toISOString = _ref4.toISOString
|
|
168
|
+
toISOString = _ref4.toISOString,
|
|
169
|
+
mode = _ref4.mode;
|
|
167
170
|
return dateTransform({
|
|
168
171
|
type: type,
|
|
169
172
|
_valueType: 'dateTime',
|
|
170
|
-
toISOString: toISOString
|
|
173
|
+
toISOString: toISOString,
|
|
174
|
+
mode: mode
|
|
171
175
|
});
|
|
172
176
|
},
|
|
173
177
|
/** 年月日 00:00:00 */
|
|
174
178
|
dateStartTime: function dateStartTime(_ref5) {
|
|
175
179
|
var type = _ref5.type,
|
|
176
|
-
toISOString = _ref5.toISOString
|
|
180
|
+
toISOString = _ref5.toISOString,
|
|
181
|
+
mode = _ref5.mode;
|
|
177
182
|
return dateTransform({
|
|
178
183
|
type: type,
|
|
179
184
|
_valueType: 'dateStartTime',
|
|
180
|
-
toISOString: toISOString
|
|
185
|
+
toISOString: toISOString,
|
|
186
|
+
mode: mode
|
|
181
187
|
});
|
|
182
188
|
},
|
|
183
189
|
/** 年月日 23:59:59 */
|
|
184
190
|
dateEndTime: function dateEndTime(_ref6) {
|
|
185
191
|
var type = _ref6.type,
|
|
186
|
-
toISOString = _ref6.toISOString
|
|
192
|
+
toISOString = _ref6.toISOString,
|
|
193
|
+
mode = _ref6.mode;
|
|
187
194
|
return dateTransform({
|
|
188
195
|
type: type,
|
|
189
196
|
_valueType: 'dateEndTime',
|
|
190
|
-
toISOString: toISOString
|
|
197
|
+
toISOString: toISOString,
|
|
198
|
+
mode: mode
|
|
191
199
|
});
|
|
192
200
|
},
|
|
193
201
|
/** 年月日 00:00:00 ~ 年月日 23:59:59 */
|
|
194
202
|
dateStartEndTime: function dateStartEndTime(_ref7) {
|
|
195
203
|
var type = _ref7.type,
|
|
196
|
-
toISOString = _ref7.toISOString
|
|
204
|
+
toISOString = _ref7.toISOString,
|
|
205
|
+
mode = _ref7.mode;
|
|
197
206
|
return dateTransform({
|
|
198
207
|
type: type,
|
|
199
208
|
_valueType: 'dateStartEndTime',
|
|
200
|
-
toISOString: toISOString
|
|
209
|
+
toISOString: toISOString,
|
|
210
|
+
mode: mode
|
|
201
211
|
});
|
|
202
212
|
},
|
|
203
213
|
/** 百分比 */
|