@innoways/utils 6.2.2 → 6.2.3
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/CHANGELOG.md +6 -0
- package/dist/cjs/index.d.ts +616 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.d.ts +616 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
/*
|
|
4
|
+
* @Author: jiangxiaowei
|
|
5
|
+
* @Date: 2020-05-30 15:05:13
|
|
6
|
+
* @Last Modified by: jiangxiaowei
|
|
7
|
+
* @Last Modified time: 2022-07-22 13:46:08
|
|
8
|
+
*/
|
|
9
|
+
import { CSSProperties, Dispatch } from "react";
|
|
10
|
+
declare const isEqual: (value: any, other: any) => boolean;
|
|
11
|
+
declare const get: {
|
|
12
|
+
<TObject extends object, TKey extends keyof TObject>(object: TObject, path: TKey | [TKey]): TObject[TKey];
|
|
13
|
+
<TObject_1 extends object, TKey_1 extends keyof TObject_1>(object: TObject_1 | null | undefined, path: TKey_1 | [TKey_1]): TObject_1[TKey_1] | undefined;
|
|
14
|
+
<TObject_2 extends object, TKey_2 extends keyof TObject_2, TDefault>(object: TObject_2 | null | undefined, path: TKey_2 | [TKey_2], defaultValue: TDefault): TDefault | Exclude<TObject_2[TKey_2], undefined>;
|
|
15
|
+
<TObject_3 extends object, TKey1 extends keyof TObject_3, TKey2 extends keyof TObject_3[TKey1]>(object: TObject_3, path: [TKey1, TKey2]): TObject_3[TKey1][TKey2];
|
|
16
|
+
<TObject_4 extends object, TKey1_1 extends keyof TObject_4, TKey2_1 extends keyof TObject_4[TKey1_1]>(object: TObject_4 | null | undefined, path: [TKey1_1, TKey2_1]): TObject_4[TKey1_1][TKey2_1] | undefined;
|
|
17
|
+
<TObject_5 extends object, TKey1_2 extends keyof TObject_5, TKey2_2 extends keyof TObject_5[TKey1_2], TDefault_1>(object: TObject_5 | null | undefined, path: [TKey1_2, TKey2_2], defaultValue: TDefault_1): TDefault_1 | Exclude<TObject_5[TKey1_2][TKey2_2], undefined>;
|
|
18
|
+
<TObject_6 extends object, TKey1_3 extends keyof TObject_6, TKey2_3 extends keyof TObject_6[TKey1_3], TKey3 extends keyof TObject_6[TKey1_3][TKey2_3]>(object: TObject_6, path: [TKey1_3, TKey2_3, TKey3]): TObject_6[TKey1_3][TKey2_3][TKey3];
|
|
19
|
+
<TObject_7 extends object, TKey1_4 extends keyof TObject_7, TKey2_4 extends keyof TObject_7[TKey1_4], TKey3_1 extends keyof TObject_7[TKey1_4][TKey2_4]>(object: TObject_7 | null | undefined, path: [TKey1_4, TKey2_4, TKey3_1]): TObject_7[TKey1_4][TKey2_4][TKey3_1] | undefined;
|
|
20
|
+
<TObject_8 extends object, TKey1_5 extends keyof TObject_8, TKey2_5 extends keyof TObject_8[TKey1_5], TKey3_2 extends keyof TObject_8[TKey1_5][TKey2_5], TDefault_2>(object: TObject_8 | null | undefined, path: [TKey1_5, TKey2_5, TKey3_2], defaultValue: TDefault_2): TDefault_2 | Exclude<TObject_8[TKey1_5][TKey2_5][TKey3_2], undefined>;
|
|
21
|
+
<TObject_9 extends object, TKey1_6 extends keyof TObject_9, TKey2_6 extends keyof TObject_9[TKey1_6], TKey3_3 extends keyof TObject_9[TKey1_6][TKey2_6], TKey4 extends keyof TObject_9[TKey1_6][TKey2_6][TKey3_3]>(object: TObject_9, path: [TKey1_6, TKey2_6, TKey3_3, TKey4]): TObject_9[TKey1_6][TKey2_6][TKey3_3][TKey4];
|
|
22
|
+
<TObject_10 extends object, TKey1_7 extends keyof TObject_10, TKey2_7 extends keyof TObject_10[TKey1_7], TKey3_4 extends keyof TObject_10[TKey1_7][TKey2_7], TKey4_1 extends keyof TObject_10[TKey1_7][TKey2_7][TKey3_4]>(object: TObject_10 | null | undefined, path: [TKey1_7, TKey2_7, TKey3_4, TKey4_1]): TObject_10[TKey1_7][TKey2_7][TKey3_4][TKey4_1] | undefined;
|
|
23
|
+
<TObject_11 extends object, TKey1_8 extends keyof TObject_11, TKey2_8 extends keyof TObject_11[TKey1_8], TKey3_5 extends keyof TObject_11[TKey1_8][TKey2_8], TKey4_2 extends keyof TObject_11[TKey1_8][TKey2_8][TKey3_5], TDefault_3>(object: TObject_11 | null | undefined, path: [TKey1_8, TKey2_8, TKey3_5, TKey4_2], defaultValue: TDefault_3): TDefault_3 | Exclude<TObject_11[TKey1_8][TKey2_8][TKey3_5][TKey4_2], undefined>;
|
|
24
|
+
<T>(object: _.NumericDictionary<T>, path: number): T;
|
|
25
|
+
<T_1>(object: _.NumericDictionary<T_1> | null | undefined, path: number): T_1 | undefined;
|
|
26
|
+
<T_2, TDefault_4>(object: _.NumericDictionary<T_2> | null | undefined, path: number, defaultValue: TDefault_4): T_2 | TDefault_4;
|
|
27
|
+
<TDefault_5>(object: null | undefined, path: _.PropertyPath, defaultValue: TDefault_5): TDefault_5;
|
|
28
|
+
(object: null | undefined, path: _.PropertyPath): undefined;
|
|
29
|
+
(object: any, path: _.PropertyPath, defaultValue?: any): any;
|
|
30
|
+
};
|
|
31
|
+
type Map = {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
};
|
|
34
|
+
type ClosestEdge = "left" | "top" | "bottom" | "right" | "over";
|
|
35
|
+
/**
|
|
36
|
+
* 生成fieldkey的正则
|
|
37
|
+
* 根据a.0.b 返回/a.(\d+|$container).b/正则
|
|
38
|
+
* @param arr <Array> 需要生成正则的数组
|
|
39
|
+
* @returns 返回正则
|
|
40
|
+
*/
|
|
41
|
+
declare const generateReg: (arr: Array<string>) => RegExp;
|
|
42
|
+
/**
|
|
43
|
+
* 用于删除、切换数组排序的arraykey
|
|
44
|
+
* @param arr
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
declare const generateArrayKeyReg: (arr: Array<string>) => RegExp;
|
|
48
|
+
/**
|
|
49
|
+
* 基本数据类型检测
|
|
50
|
+
* @param {unknown} checkVar 待检测的变量
|
|
51
|
+
* @returns {string} 基本数据类型:Object | Array | String | Number | Boolean | Null | Undefined
|
|
52
|
+
*/
|
|
53
|
+
declare function typeCheck(checkVar: any): string;
|
|
54
|
+
/**
|
|
55
|
+
* 判断变量是否为空
|
|
56
|
+
* @param checkVar
|
|
57
|
+
*/
|
|
58
|
+
declare function isEmpty(checkVar: any): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* 设置data.a.b.c = value
|
|
61
|
+
* 若data没有a.b 则依次赋值空对象,最后再将a.b.c设为value
|
|
62
|
+
* @param {string} keys a.b.c
|
|
63
|
+
* @param {object} data data.a.b.c
|
|
64
|
+
* @param {unknown} value data.a.b.c = value
|
|
65
|
+
* @param {object} typeMap 确定a.0.b.1中的0和1的父级应该是对象还是数组形式
|
|
66
|
+
* @param parentKey
|
|
67
|
+
*/
|
|
68
|
+
declare const setDeepProp: (keys: string[], data: Map, value: unknown, typeMap?: Map | undefined, parentKey?: string[] | undefined) => void;
|
|
69
|
+
/**
|
|
70
|
+
* 删除data.a.b.c
|
|
71
|
+
* 若data没有a.b.c,则不进行任何操作
|
|
72
|
+
* @param {string} keys [a,b,c]
|
|
73
|
+
* @param {object} data 需要删除的对象
|
|
74
|
+
*/
|
|
75
|
+
declare const deleteDeepProp: (keys: string[], data: Map) => void;
|
|
76
|
+
/**
|
|
77
|
+
* 判断对象是否有某一属性,如没有,则根据valueType为其创建
|
|
78
|
+
* 并返回最后一个key的校验生成后的value
|
|
79
|
+
* @param {Map} source 源对象
|
|
80
|
+
* @param {'array' | 'object'} valueType 创建的类型
|
|
81
|
+
* @param {array} keys 对象的key值,支持...以拓展深层对象的创建
|
|
82
|
+
*/
|
|
83
|
+
declare const judgeAndRegister: (source: Map, valueType: "array" | "object", ...keys: any[]) => Map;
|
|
84
|
+
/**
|
|
85
|
+
* 允许循环引用的深拷贝
|
|
86
|
+
* @param target
|
|
87
|
+
* @param map
|
|
88
|
+
*/
|
|
89
|
+
declare function deepClone(target: any, map?: WeakMap<object, any>): any;
|
|
90
|
+
/**
|
|
91
|
+
* 该方法用于快速向check的shcmea中注入vcontol。方便过滤已经设置的表单
|
|
92
|
+
* @param obj 待注入vontrol的uiSchema对象
|
|
93
|
+
*/
|
|
94
|
+
declare function injectVcontrol(obj: Record<string, unknown>): void;
|
|
95
|
+
/**
|
|
96
|
+
* 解析url中?后的参数,返回参数Map
|
|
97
|
+
* @param url
|
|
98
|
+
*/
|
|
99
|
+
declare function parseHrefParam(url: string | undefined): Map;
|
|
100
|
+
declare function randomString(length: number): string;
|
|
101
|
+
declare function number2Chinese(num: number): string;
|
|
102
|
+
// TODO 更新Read more文档
|
|
103
|
+
declare function upgradeTips(oldApiName: string, newApiName: string): void;
|
|
104
|
+
// 转换数组
|
|
105
|
+
declare function toArray(param: string | Array<string>): Array<string>;
|
|
106
|
+
// 处理容器宽度
|
|
107
|
+
declare const handleMargin: (style: CSSProperties) => void;
|
|
108
|
+
/**
|
|
109
|
+
* 根据uiSchema,获取当前schem相对的主题和组件类型
|
|
110
|
+
* @param uiSchema
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
declare const getThemeAndType: (uiSchema: {
|
|
114
|
+
type: string;
|
|
115
|
+
theme?: string;
|
|
116
|
+
} & Map) => string;
|
|
117
|
+
declare function isValidHttpUrl(string: string): boolean;
|
|
118
|
+
declare function removeSpaceAndmakeStringCamelCase(string: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* 将二进制流数据转成base64格式的数据
|
|
121
|
+
*
|
|
122
|
+
* @param file
|
|
123
|
+
*/
|
|
124
|
+
declare function binaryData2Blob(file: File): Promise<string | ArrayBuffer | null>;
|
|
125
|
+
/**
|
|
126
|
+
* 将base64g格式的图片地址转成img图片对象
|
|
127
|
+
*
|
|
128
|
+
* @param {string} imgBase64Url
|
|
129
|
+
*/
|
|
130
|
+
declare function getImgEl(imgBase64Url: string): Promise<HTMLImageElement>;
|
|
131
|
+
// 尺寸限制
|
|
132
|
+
type ImgDimension = Partial<{
|
|
133
|
+
width: number;
|
|
134
|
+
height: number;
|
|
135
|
+
minWidth: number;
|
|
136
|
+
minHeight: number;
|
|
137
|
+
maxWidth: number;
|
|
138
|
+
maxHeight: number;
|
|
139
|
+
widthDivisor: number;
|
|
140
|
+
heightDivisor: number;
|
|
141
|
+
widthHeightEqual: boolean;
|
|
142
|
+
}>;
|
|
143
|
+
// 大小限制
|
|
144
|
+
type ImgSize = Partial<{
|
|
145
|
+
max: number;
|
|
146
|
+
min: number;
|
|
147
|
+
}>;
|
|
148
|
+
declare function checkImg({ file, dimension, size, accept, errMsg }: {
|
|
149
|
+
file: File;
|
|
150
|
+
dimension?: ImgDimension;
|
|
151
|
+
size?: ImgSize;
|
|
152
|
+
accept?: string;
|
|
153
|
+
errMsg?: Partial<{
|
|
154
|
+
dimension: string;
|
|
155
|
+
size: string;
|
|
156
|
+
type: string;
|
|
157
|
+
}>;
|
|
158
|
+
}): Promise<{
|
|
159
|
+
isOk: boolean;
|
|
160
|
+
errors: Array<string>;
|
|
161
|
+
}>;
|
|
162
|
+
// nubmer 类型支持的操作符
|
|
163
|
+
type NumberOperator = ">=" | "<=" | "<" | ">" | "===" | "!==";
|
|
164
|
+
// string 类型支持的操作符
|
|
165
|
+
type StringOperator = "===" | "!==" | "includes" | "-includes";
|
|
166
|
+
// boolean 类型支持的操作符
|
|
167
|
+
type BooleanOperator = "true" | "false";
|
|
168
|
+
// object 类型支持的操作符
|
|
169
|
+
type ObjectOperator = "in" | "-in";
|
|
170
|
+
// array 类型支持的操作符
|
|
171
|
+
type ArrayOperator = "includes" | "-includes";
|
|
172
|
+
type Operator = NumberOperator | StringOperator | BooleanOperator | ObjectOperator | ArrayOperator | "change" | "";
|
|
173
|
+
// 条件逻辑配置字段
|
|
174
|
+
type Condintion = {
|
|
175
|
+
/**
|
|
176
|
+
* 格式:"fieldKey setType property" "fieldKey setType"
|
|
177
|
+
* fieldkey: 需要获取的表单的fieldkey
|
|
178
|
+
* setType: data|uiSchema|dataSchema
|
|
179
|
+
* property: 可选 获取属性
|
|
180
|
+
*/
|
|
181
|
+
fieldKey1: string;
|
|
182
|
+
// 空字符用来初始化逻辑,新增条件时,value1未选择,操作符不应该展示
|
|
183
|
+
operator: Operator;
|
|
184
|
+
// "fieldKey setType property" "fieldKey setType"
|
|
185
|
+
fieldKey2?: string;
|
|
186
|
+
value2?: unknown;
|
|
187
|
+
logicOperator?: "&&" | "||";
|
|
188
|
+
};
|
|
189
|
+
type SetEffect = {
|
|
190
|
+
type: "set" | "merge";
|
|
191
|
+
/**
|
|
192
|
+
* 格式:"fieldKey setType property" "fieldKey setType"
|
|
193
|
+
* fieldkey: 需要获取的表单的fieldkey
|
|
194
|
+
* setType: data|uiSchema|dataSchema
|
|
195
|
+
* property: 可选 获取属性
|
|
196
|
+
*/
|
|
197
|
+
fieldKey: string;
|
|
198
|
+
// 如果fieldkey 格式为fieldKey uiSchema vcontrol,则value为boolean类型
|
|
199
|
+
value: unknown;
|
|
200
|
+
};
|
|
201
|
+
type SubAction = {
|
|
202
|
+
type: "subAction";
|
|
203
|
+
actions: Array<Action>;
|
|
204
|
+
};
|
|
205
|
+
type Effect = Array<SetEffect | SubAction>;
|
|
206
|
+
// if else 逻辑
|
|
207
|
+
type ControlFlowAction = {
|
|
208
|
+
type: "controlFlow";
|
|
209
|
+
condintion: Array<Condintion>;
|
|
210
|
+
effect: Effect;
|
|
211
|
+
};
|
|
212
|
+
//
|
|
213
|
+
type Action = ControlFlowAction;
|
|
214
|
+
type Flow = {
|
|
215
|
+
// 版本号 一期默认为0.1.0
|
|
216
|
+
version: string;
|
|
217
|
+
trigger: {
|
|
218
|
+
event: "globalChange";
|
|
219
|
+
};
|
|
220
|
+
actions: Array<Action>;
|
|
221
|
+
};
|
|
222
|
+
type Get = {
|
|
223
|
+
(fieldKey?: string): {
|
|
224
|
+
data: Map | undefined;
|
|
225
|
+
dataSchema: DataSchema;
|
|
226
|
+
uiSchema: UiSchema;
|
|
227
|
+
};
|
|
228
|
+
(fieldKey: string, option: {
|
|
229
|
+
isPrev: boolean;
|
|
230
|
+
}): {
|
|
231
|
+
data: Map | undefined;
|
|
232
|
+
dataSchema: DataSchema | undefined;
|
|
233
|
+
uiSchema: UiSchema | undefined;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
type GetKey = (fieldKey: string, type: "uiSchema" | "dataSchema" | "data" | "unitedSchema") => string;
|
|
237
|
+
type GetTypeKey = (fieldKey: string) => string | never;
|
|
238
|
+
type State = {
|
|
239
|
+
typePath: Record<string, {
|
|
240
|
+
type: string;
|
|
241
|
+
unitedSchemaKey: string;
|
|
242
|
+
fatherKey: string;
|
|
243
|
+
}>;
|
|
244
|
+
uiSchema: UiSchema;
|
|
245
|
+
dataSchema: DataSchema;
|
|
246
|
+
// 表单数据
|
|
247
|
+
formData: Record<string, any>;
|
|
248
|
+
errors: Record<string, string>;
|
|
249
|
+
// ajv校验错误信息
|
|
250
|
+
ajvErrors: Record<string, string>;
|
|
251
|
+
// 用户自定义错误信息
|
|
252
|
+
customErrors: Record<string, string>;
|
|
253
|
+
// 是否正在校验
|
|
254
|
+
checking: boolean;
|
|
255
|
+
// 当前可见的表单
|
|
256
|
+
visibleFieldKey: Array<string>;
|
|
257
|
+
// 当前正在变动的表单
|
|
258
|
+
changeKey: string;
|
|
259
|
+
// 数组容器对应的react key映射
|
|
260
|
+
arrayKey: Record<string, Array<string>>;
|
|
261
|
+
// 异步校验需要保留的错误key(用于防止异步校验的错误信息被ajv覆盖)
|
|
262
|
+
ignoreErrKey: Array<string>;
|
|
263
|
+
};
|
|
264
|
+
// 即将废弃,请改用 ResetAction
|
|
265
|
+
type ReloadAction = {
|
|
266
|
+
type: "reload";
|
|
267
|
+
} & Omit<State, "visibleFieldKey">;
|
|
268
|
+
type ResetAction = {
|
|
269
|
+
type: "reset";
|
|
270
|
+
action: {
|
|
271
|
+
state: Omit<State, "visibleFieldKey">;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
// 即将废弃,请改用 SetValidate
|
|
275
|
+
type SetDataSchemaAction = {
|
|
276
|
+
type: "setDataSchema";
|
|
277
|
+
dataSchema?: DataSchema;
|
|
278
|
+
isDelete?: boolean;
|
|
279
|
+
} & Map;
|
|
280
|
+
type SetValidate = {
|
|
281
|
+
type: "setValidate";
|
|
282
|
+
action: {
|
|
283
|
+
deleteKeys?: Array<string> | string;
|
|
284
|
+
dataSchema?: DataSchema;
|
|
285
|
+
set?: Map;
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
// 即将废弃,请改用 SetUiAction
|
|
289
|
+
type SetUiSchemaAction = {
|
|
290
|
+
type: "setUiSchema";
|
|
291
|
+
uiSchema?: UiSchema;
|
|
292
|
+
} & Map;
|
|
293
|
+
// 即将废弃,请改用 SetUiAction
|
|
294
|
+
type DeleteUiSchemaAction = {
|
|
295
|
+
type: "deleteUiSchema";
|
|
296
|
+
key: string;
|
|
297
|
+
};
|
|
298
|
+
type SetUiAction = {
|
|
299
|
+
type: "setUi";
|
|
300
|
+
action: {
|
|
301
|
+
deleteKeys?: Array<string> | string;
|
|
302
|
+
uiSchema?: UiSchema;
|
|
303
|
+
set?: Map;
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
// 即将废弃,请改用 SetDataAction
|
|
307
|
+
type SetFormDataAction = {
|
|
308
|
+
type: "setFormData";
|
|
309
|
+
formData?: Map;
|
|
310
|
+
} & Map;
|
|
311
|
+
// 即将废弃 改用 SetDataAction
|
|
312
|
+
type DeleteFormDataAction = {
|
|
313
|
+
type: "deleteFormData";
|
|
314
|
+
key: string;
|
|
315
|
+
};
|
|
316
|
+
type SetDataAction = {
|
|
317
|
+
type: "setData";
|
|
318
|
+
action: {
|
|
319
|
+
deleteKeys?: string | Array<string>;
|
|
320
|
+
formData?: Map;
|
|
321
|
+
set?: Map;
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
type DeleteFieldAction = {
|
|
325
|
+
type: "deleteField";
|
|
326
|
+
action: {
|
|
327
|
+
fieldKey: string;
|
|
328
|
+
get: Get;
|
|
329
|
+
getKey: GetKey;
|
|
330
|
+
getTypeKey: GetTypeKey;
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
type AddFieldAction = {
|
|
334
|
+
type: "addField";
|
|
335
|
+
action: {
|
|
336
|
+
fieldKey: string;
|
|
337
|
+
closestEdge: ClosestEdge;
|
|
338
|
+
unitedSchema: UnitedSchema;
|
|
339
|
+
overFieldKey: string;
|
|
340
|
+
get: Get;
|
|
341
|
+
getKey: GetKey;
|
|
342
|
+
getTypeKey: GetTypeKey;
|
|
343
|
+
shouldDelete: boolean;
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
// 即将废弃
|
|
347
|
+
type SetErrType = {
|
|
348
|
+
type: "setError";
|
|
349
|
+
action?: {
|
|
350
|
+
ignore?: Array<string>;
|
|
351
|
+
};
|
|
352
|
+
} & Record<string, string>;
|
|
353
|
+
// 即将废弃
|
|
354
|
+
type SetErrsType = {
|
|
355
|
+
type: "setError";
|
|
356
|
+
ignore?: Array<string>;
|
|
357
|
+
errors?: Record<string, string>;
|
|
358
|
+
};
|
|
359
|
+
// 即将废弃 请改用 SetErrAction
|
|
360
|
+
type SetErrorAction = SetErrType | SetErrsType;
|
|
361
|
+
// 即将废弃 请改用 SetErrAction
|
|
362
|
+
type DeleteErrorAction = {
|
|
363
|
+
type: "deleteError";
|
|
364
|
+
key: Array<string> | string;
|
|
365
|
+
};
|
|
366
|
+
// 设置自定义错误信息
|
|
367
|
+
type SetErrAction = {
|
|
368
|
+
type: "setErr";
|
|
369
|
+
action: {
|
|
370
|
+
deleteKeys?: Array<string> | string;
|
|
371
|
+
errors?: Record<string, string>;
|
|
372
|
+
set?: Record<string, string>;
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
// 设置ajv错误
|
|
376
|
+
type SetAjvErrorAction = {
|
|
377
|
+
type: "setAjvErr";
|
|
378
|
+
action: {
|
|
379
|
+
deleteKeys?: Array<string> | string;
|
|
380
|
+
errors?: Record<string, string>;
|
|
381
|
+
set?: Record<string, string>;
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
// 即将废弃
|
|
385
|
+
type OldSetCheckingAction = {
|
|
386
|
+
type: "setChecking";
|
|
387
|
+
checking: boolean;
|
|
388
|
+
};
|
|
389
|
+
type NewSetCheckingAction = {
|
|
390
|
+
type: "setChecking";
|
|
391
|
+
action: {
|
|
392
|
+
checking: boolean;
|
|
393
|
+
};
|
|
394
|
+
};
|
|
395
|
+
type SetCheckingAction = OldSetCheckingAction | NewSetCheckingAction;
|
|
396
|
+
type SetVisibleKeyAction = {
|
|
397
|
+
type: "setVisibleKey";
|
|
398
|
+
action: {
|
|
399
|
+
deleteKeys?: Array<string> | string;
|
|
400
|
+
fieldKey?: Array<string> | string;
|
|
401
|
+
};
|
|
402
|
+
};
|
|
403
|
+
// 数组容器设置映射的组件唯一key(避免删除导致的组件渲染问题)
|
|
404
|
+
type SetArrayKey = {
|
|
405
|
+
type: "setArrayKey";
|
|
406
|
+
action: {
|
|
407
|
+
// 数组父级fieldKey
|
|
408
|
+
fieldKey: string;
|
|
409
|
+
// 添加或删除的位置 (order为undefiedn,则全量设置当前fieldKey的key)
|
|
410
|
+
order?: number;
|
|
411
|
+
// 是否删除 默认添加
|
|
412
|
+
isDelete?: boolean;
|
|
413
|
+
// 切换数组的顺序
|
|
414
|
+
move?: [
|
|
415
|
+
number,
|
|
416
|
+
number
|
|
417
|
+
];
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
type Action$0 = ReloadAction | ResetAction | SetDataSchemaAction | SetValidate | SetUiSchemaAction | DeleteUiSchemaAction | SetUiAction | SetFormDataAction | DeleteFormDataAction | SetDataAction | DeleteFieldAction | AddFieldAction | SetErrorAction | SetErrAction | SetAjvErrorAction | DeleteErrorAction | SetCheckingAction | SetVisibleKeyAction | SetArrayKey;
|
|
421
|
+
/**
|
|
422
|
+
* 在联合Schema中,某个节点的类型
|
|
423
|
+
*/
|
|
424
|
+
type FieldAtomType = {
|
|
425
|
+
fieldKey?: string | number;
|
|
426
|
+
} & Map;
|
|
427
|
+
type ContainerStyle = Partial<{
|
|
428
|
+
// 表单宽度
|
|
429
|
+
width: number | string;
|
|
430
|
+
// 容器margin-top
|
|
431
|
+
marginTop: number | string;
|
|
432
|
+
// 容器margin-right
|
|
433
|
+
marginRight: number | string;
|
|
434
|
+
// 容器margin-bottom
|
|
435
|
+
marginBottom: number | string;
|
|
436
|
+
// 容器margin-left
|
|
437
|
+
marginLeft: number | string;
|
|
438
|
+
// 容器margin
|
|
439
|
+
margin: string;
|
|
440
|
+
// 容器padding
|
|
441
|
+
padding: string;
|
|
442
|
+
paddingTop: number | string;
|
|
443
|
+
paddingBottom: number | string;
|
|
444
|
+
paddingRigth: number | string;
|
|
445
|
+
paddingLeft: number | string;
|
|
446
|
+
}> | null;
|
|
447
|
+
type DescriptionItem = {
|
|
448
|
+
type: "icon";
|
|
449
|
+
title: string;
|
|
450
|
+
trigger?: "click" | "hover";
|
|
451
|
+
} | {
|
|
452
|
+
type: "text";
|
|
453
|
+
title: string;
|
|
454
|
+
} | null;
|
|
455
|
+
type Description = DescriptionItem | Array<DescriptionItem>;
|
|
456
|
+
type TitlePlacement = "left" | "right" | "bottom" | "top";
|
|
457
|
+
type Theme = "antd" | "babel-ui" | "drip-design" | string;
|
|
458
|
+
type TitleUi = Partial<{
|
|
459
|
+
// 标题宽度
|
|
460
|
+
width: number | string;
|
|
461
|
+
// 标题margin-top
|
|
462
|
+
marginTop: number | string;
|
|
463
|
+
// 标题margin-right
|
|
464
|
+
marginRight: number | string;
|
|
465
|
+
// 标题margin-bottom
|
|
466
|
+
marginBottom: number | string;
|
|
467
|
+
// 标题margin-left
|
|
468
|
+
marginLeft: number | string;
|
|
469
|
+
// 标题margin
|
|
470
|
+
margin: string;
|
|
471
|
+
// Title vertical alignment
|
|
472
|
+
verticalAlign: "center" | "top" | "bottom";
|
|
473
|
+
// Title horizontal alignment
|
|
474
|
+
textAlign: "left" | "right" | "center";
|
|
475
|
+
// 是否展示必填*号
|
|
476
|
+
requiredIcon: boolean;
|
|
477
|
+
placement: TitlePlacement;
|
|
478
|
+
color: string;
|
|
479
|
+
fontSize: number | string;
|
|
480
|
+
showColon?: boolean;
|
|
481
|
+
}> | null;
|
|
482
|
+
type Properties = {
|
|
483
|
+
[propName: string]: {
|
|
484
|
+
type: string;
|
|
485
|
+
title?: TitleUi;
|
|
486
|
+
showTitle?: boolean;
|
|
487
|
+
containerStyle?: ContainerStyle;
|
|
488
|
+
theme?: Theme;
|
|
489
|
+
description?: Description;
|
|
490
|
+
[propName: string]: unknown;
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
/**
|
|
494
|
+
* @param {string} fieldKey 必填 表单change触发,更改formData的key值
|
|
495
|
+
* @param {function} onChange 可选 表单触发change事件后的回调
|
|
496
|
+
* @param {object} options 可选 表单字段特殊处理配置。注意:options中只能有一个字段的值是true。否则不会对特殊数据进行格式化
|
|
497
|
+
* @param {func} dispatch 操作context
|
|
498
|
+
*/
|
|
499
|
+
type OnChange = (({ val, dispatch, fieldKey, getKey, prevFieldData,
|
|
500
|
+
// 注意目前只有select表单支持这个字段(看后续是否有场景其它表单也需要)
|
|
501
|
+
fieldData }: {
|
|
502
|
+
val: any;
|
|
503
|
+
dispatch: Dispatch<Action$0>;
|
|
504
|
+
getKey: GetKey;
|
|
505
|
+
fieldKey: string;
|
|
506
|
+
prevFieldData: any;
|
|
507
|
+
// 注意目前只有select表单支持这个字段(看后续是否有场景其它表单也需要)
|
|
508
|
+
fieldData: any;
|
|
509
|
+
}) => void) | string;
|
|
510
|
+
/**
|
|
511
|
+
* UiSchema的最小原子
|
|
512
|
+
*/
|
|
513
|
+
type UiSchema = {
|
|
514
|
+
formMode?: "edit" | "view" | "generator";
|
|
515
|
+
mode: "add" | "normal" | "collapse" | "tuple" | "fixed";
|
|
516
|
+
theme: Theme;
|
|
517
|
+
type: string;
|
|
518
|
+
containerStyle?: ContainerStyle;
|
|
519
|
+
properties: Properties;
|
|
520
|
+
order: Array<string | number>;
|
|
521
|
+
title?: TitleUi;
|
|
522
|
+
onChange?: OnChange;
|
|
523
|
+
flow?: Flow;
|
|
524
|
+
footer?: {
|
|
525
|
+
url?: string;
|
|
526
|
+
method?: "GET" | "POST";
|
|
527
|
+
token?: string;
|
|
528
|
+
fetchData?: boolean;
|
|
529
|
+
jsonkey?: string;
|
|
530
|
+
apiJson?: string;
|
|
531
|
+
[propName: string]: unknown;
|
|
532
|
+
};
|
|
533
|
+
[propName: string]: unknown;
|
|
534
|
+
};
|
|
535
|
+
/**
|
|
536
|
+
* DataSchema的最小原子
|
|
537
|
+
*/
|
|
538
|
+
type DataSchema = {
|
|
539
|
+
type: string;
|
|
540
|
+
validateTime: "submit" | "change";
|
|
541
|
+
showError: "change" | "submit" | "none";
|
|
542
|
+
requiredMode: "default" | "empty";
|
|
543
|
+
properties?: Map;
|
|
544
|
+
items?: Array<Map> | Map;
|
|
545
|
+
required?: Array<string | number>;
|
|
546
|
+
errorMessage?: {
|
|
547
|
+
required: Map;
|
|
548
|
+
properties?: Map;
|
|
549
|
+
items?: Map;
|
|
550
|
+
[propName: string]: unknown;
|
|
551
|
+
};
|
|
552
|
+
} & Map;
|
|
553
|
+
/**
|
|
554
|
+
* 联合Schema格式
|
|
555
|
+
*/
|
|
556
|
+
type UnitedSchema = {
|
|
557
|
+
theme?: "antd" | "babel-ui" | "drip-design" | string;
|
|
558
|
+
themeColor?: string;
|
|
559
|
+
validateTime?: "change" | "submit";
|
|
560
|
+
showError?: "change" | "submit" | "none";
|
|
561
|
+
requiredMode?: "default" | "empty";
|
|
562
|
+
title?: string;
|
|
563
|
+
ui?: Map;
|
|
564
|
+
schema?: Array<Map>;
|
|
565
|
+
items?: Array<Map> | Map;
|
|
566
|
+
} & Map;
|
|
567
|
+
type TypePathItem = {
|
|
568
|
+
type: string;
|
|
569
|
+
fatherKey: string;
|
|
570
|
+
title: string;
|
|
571
|
+
unitedSchemaKey: string;
|
|
572
|
+
};
|
|
573
|
+
type TypePath = Record<string, TypePathItem>;
|
|
574
|
+
/**
|
|
575
|
+
* 解析联合Schema
|
|
576
|
+
* @param unitedSchema
|
|
577
|
+
*/
|
|
578
|
+
declare const parseUnitedSchema: (unitedSchema: UnitedSchema) => {
|
|
579
|
+
uiSchema: UiSchema;
|
|
580
|
+
dataSchema: DataSchema;
|
|
581
|
+
typePath: TypePath;
|
|
582
|
+
customProps: string[];
|
|
583
|
+
};
|
|
584
|
+
type Options = Partial<{
|
|
585
|
+
// 是否开启$fieldKey值转换为fieldKey(默认不开启,generator中viewport区域需要开启)
|
|
586
|
+
$fieldKey: boolean;
|
|
587
|
+
}>;
|
|
588
|
+
/**
|
|
589
|
+
* 融合dataSchema和uiSchema为联合Schema
|
|
590
|
+
*/
|
|
591
|
+
declare function combine(dataSchema: DataSchema, uiSchema: UiSchema, options?: Options): UnitedSchema;
|
|
592
|
+
declare const parseFlow: (flow: Flow) => string;
|
|
593
|
+
type FetchApi = (args: {
|
|
594
|
+
params: Array<{
|
|
595
|
+
key: string;
|
|
596
|
+
value: string;
|
|
597
|
+
}>;
|
|
598
|
+
url: string;
|
|
599
|
+
method: "GET" | "POST";
|
|
600
|
+
}) => Promise<unknown>;
|
|
601
|
+
type GetApi<R> = (args: {
|
|
602
|
+
params: Map;
|
|
603
|
+
url: string;
|
|
604
|
+
}) => Promise<R>;
|
|
605
|
+
type PostApi<R> = (args: {
|
|
606
|
+
params: Map;
|
|
607
|
+
url: string;
|
|
608
|
+
}) => Promise<R>;
|
|
609
|
+
declare const fetchFn: FetchApi;
|
|
610
|
+
declare const fetchFnJsonKey: ({ config, dataHandler, dataSetter, doFinally }: {
|
|
611
|
+
config: any;
|
|
612
|
+
dataHandler?: Function | null | undefined;
|
|
613
|
+
dataSetter?: Function | null | undefined;
|
|
614
|
+
doFinally?: Function | null | undefined;
|
|
615
|
+
}) => Promise<void>;
|
|
616
|
+
export { isEqual, get, generateReg, generateArrayKeyReg, typeCheck, isEmpty, setDeepProp, deleteDeepProp, judgeAndRegister, deepClone, injectVcontrol, parseHrefParam, randomString, number2Chinese, upgradeTips, toArray, handleMargin, getThemeAndType, isValidHttpUrl, removeSpaceAndmakeStringCamelCase, Map, ClosestEdge, binaryData2Blob, getImgEl, ImgDimension, ImgSize, checkImg, parseUnitedSchema, combine, FieldAtomType, ContainerStyle, Description, TitlePlacement, Theme, TitleUi, OnChange, UiSchema, DataSchema, UnitedSchema, TypePathItem, TypePath, Get, GetKey, GetTypeKey, State, SetErrType, SetErrsType, Action$0 as Action, parseFlow, Operator, Condintion, SetEffect, ControlFlowAction, Flow, fetchFn, fetchFnJsonKey, FetchApi, GetApi, PostApi };
|