form-driver 0.3.13 → 0.4.0
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/README.md +3 -3
- package/dist/m3.css +57 -0
- package/dist/m3.js +1 -1
- package/es/m3.css +57 -0
- package/es/m3.js +2190 -1386
- package/lib/m3.css +57 -0
- package/lib/m3.js +2188 -1382
- package/package.json +13 -9
- package/src/framework/Init.tsx +152 -150
- package/src/framework/M3.tsx +83 -59
- package/src/framework/MUtil.tsx +275 -140
- package/src/framework/MViewer.tsx +198 -106
- package/src/framework/Schema.ts +100 -87
- package/src/types/MSetType.ts +128 -71
- package/src/ui/editor/basic/ACheckBox.tsx +98 -50
- package/src/ui/editor/complex/ACheckDrag.tsx +356 -0
- package/src/ui/editor/complex/AForm.tsx +3 -1
- package/src/ui/editor/complex/JsonEditor.tsx +32 -21
- package/src/ui/widget/DIYCheckbox.less +36 -0
- package/src/ui/widget/DIYCheckbox.tsx +154 -0
- package/src/ui/widget/SortDrag.less +32 -0
- package/src/ui/widget/SortDrag.tsx +145 -0
- package/types/framework/Assembly.d.ts +2 -2
- package/types/framework/M3.d.ts +2 -2
- package/types/framework/MUtil.d.ts +5 -5
- package/types/framework/MViewer.d.ts +1 -1
- package/types/framework/Schema.d.ts +13 -11
- package/types/framework/Validator.d.ts +1 -1
- package/types/types/MDecorationType.d.ts +3 -3
- package/types/types/MSetType.d.ts +1 -1
- package/types/ui/editor/basic/ACheckBox.d.ts +2 -2
- package/types/ui/editor/basic/ARangePicker.d.ts +6 -2
- package/types/ui/editor/complex/ACheckDrag.d.ts +28 -0
- package/types/ui/editor/complex/JsonEditor.d.ts +1 -1
- package/types/ui/widget/DIYCheckbox.d.ts +19 -0
- package/types/ui/widget/SegmentEditSwitch.d.ts +1 -1
- package/types/ui/widget/SortDrag.d.ts +14 -0
package/src/framework/Schema.ts
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import { MORPH, VIEWER, Assembly } from
|
|
1
|
+
import { MORPH, VIEWER, Assembly } from "./Assembly";
|
|
2
2
|
|
|
3
3
|
export type ValueConst = string | boolean | number;
|
|
4
4
|
export interface MEnumField {
|
|
5
5
|
// 展示选项时,html > label > value
|
|
6
6
|
|
|
7
7
|
/** 选项文案 */
|
|
8
|
-
label?: string
|
|
8
|
+
label?: string;
|
|
9
9
|
/** 选项html */
|
|
10
|
-
html?: string
|
|
10
|
+
html?: string;
|
|
11
11
|
/** 选项的showIf */
|
|
12
|
-
showIf?: boolean
|
|
12
|
+
showIf?: boolean;
|
|
13
13
|
/** 选项html */
|
|
14
|
-
value: ValueConst
|
|
14
|
+
value: ValueConst;
|
|
15
15
|
// 排他选项。
|
|
16
16
|
// 只对多选有效,exclusive不同(exclusive都是undefined的两个选项,也算相同)的两个选项,不能同时选中
|
|
17
17
|
// 应用场景:有些多选中有 "以上都没有" 这类选项,选中时,其他选项都要取消掉
|
|
18
|
-
exclusive?: string
|
|
18
|
+
exclusive?: string;
|
|
19
19
|
// 选项分值
|
|
20
|
-
score?: number
|
|
20
|
+
score?: number;
|
|
21
|
+
|
|
22
|
+
// 备注
|
|
23
|
+
remark?: string;
|
|
21
24
|
|
|
22
25
|
children?: MEnumField[];
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
/** 匿名的MFieldSchema,没有name字段 */
|
|
26
|
-
export type MFieldSchemaAnonymity = Omit<MFieldSchema, "name"
|
|
29
|
+
export type MFieldSchemaAnonymity = Omit<MFieldSchema, "name">;
|
|
27
30
|
|
|
28
31
|
/** JS表达式 */
|
|
29
32
|
export type JSEXPR = string;
|
|
@@ -31,22 +34,23 @@ export type JSEXPR = string;
|
|
|
31
34
|
/** 如何适配屏幕 */
|
|
32
35
|
export type SCREEN_ADAPTION =
|
|
33
36
|
/** 强制使用适应大屏的控件 */
|
|
34
|
-
"big"
|
|
37
|
+
| "big"
|
|
35
38
|
/** 强制使用适应小屏的控件 */
|
|
36
|
-
"phone"
|
|
39
|
+
| "phone";
|
|
37
40
|
|
|
38
41
|
/** M3 单元的 schema */
|
|
39
42
|
export interface MFieldSchema {
|
|
40
|
-
type?: string
|
|
41
|
-
name: string
|
|
42
|
-
label?: string
|
|
43
|
-
labelTip?: string
|
|
43
|
+
type?: string;
|
|
44
|
+
name: string;
|
|
45
|
+
label?: string;
|
|
46
|
+
labelTip?: string;
|
|
47
|
+
value?: number;
|
|
44
48
|
|
|
45
49
|
/** 编辑器,editor:<viewer名字> 是 viewerFor: {morph:"editor", name:<viewer名字>} 的简写 */
|
|
46
|
-
editor?: string | VIEWER
|
|
50
|
+
editor?: string | VIEWER;
|
|
47
51
|
|
|
48
52
|
/** 查看器,readable:<viewer名字> 是 viewerFor: {morph:"readable", name:<viewer名字>} 的简写 */
|
|
49
|
-
readable?: string | VIEWER
|
|
53
|
+
readable?: string | VIEWER;
|
|
50
54
|
|
|
51
55
|
/** 选项 */
|
|
52
56
|
option?: MEnumField[] | string;
|
|
@@ -66,16 +70,16 @@ export interface MFieldSchema {
|
|
|
66
70
|
/** @deprecated 旧版本字段,新版本用 openOption */
|
|
67
71
|
setOpen?: MFieldSchemaAnonymity;
|
|
68
72
|
|
|
69
|
-
/**
|
|
70
|
-
* 默认值
|
|
73
|
+
/**
|
|
74
|
+
* 默认值
|
|
71
75
|
* object上设置defaultValue后,其字段的defaultValue就无效了
|
|
72
76
|
*/
|
|
73
|
-
defaultValue?: ValueConst
|
|
77
|
+
defaultValue?: ValueConst;
|
|
74
78
|
|
|
75
|
-
/**
|
|
79
|
+
/**
|
|
76
80
|
* 表单控件的属性(对应 antd 组件的 api)
|
|
77
81
|
*/
|
|
78
|
-
props?: any
|
|
82
|
+
props?: any;
|
|
79
83
|
|
|
80
84
|
/** 最多输入多少行,默认1,表示单行字符串 */
|
|
81
85
|
stringLines?: number;
|
|
@@ -103,19 +107,19 @@ export interface MFieldSchema {
|
|
|
103
107
|
* READABLE_UNKNOWN/READABLE_BLANK/READABLE_INVALID/READABLE_ERROR:这些值参考MTheme
|
|
104
108
|
* 函数=就不用解释了,自己可以随意发挥了
|
|
105
109
|
*/
|
|
106
|
-
toReadable?: string | ((v: any, parent: any, assembly: Assembly) => string)
|
|
110
|
+
toReadable?: string | ((v: any, parent: any, assembly: Assembly) => string);
|
|
107
111
|
|
|
108
|
-
/**
|
|
112
|
+
/**
|
|
109
113
|
* true表示值不是严格匹配
|
|
110
114
|
* 例如枚举的value是number时,传入字符串也可以匹配
|
|
111
115
|
*/
|
|
112
116
|
tolerate?: boolean;
|
|
113
117
|
|
|
114
118
|
/** 是否强制使用大屏或者小屏的控件,默认是自动 */
|
|
115
|
-
screenAdaption?: SCREEN_ADAPTION
|
|
119
|
+
screenAdaption?: SCREEN_ADAPTION;
|
|
116
120
|
|
|
117
121
|
/** 展示时显示的后缀 */
|
|
118
|
-
postfix?: string
|
|
122
|
+
postfix?: string;
|
|
119
123
|
|
|
120
124
|
/** 会展示为一个问号图标,点击弹出提示 */
|
|
121
125
|
popoverDesc?: React.ReactNode;
|
|
@@ -142,21 +146,21 @@ export interface MFieldSchema {
|
|
|
142
146
|
y: string | MEnumField[];
|
|
143
147
|
|
|
144
148
|
/** 每行最多选几个,默认1 */
|
|
145
|
-
maxX?: number
|
|
149
|
+
maxX?: number;
|
|
146
150
|
|
|
147
151
|
/** 每行最少选几个,默认1 */
|
|
148
|
-
minX?: number
|
|
152
|
+
minX?: number;
|
|
149
153
|
|
|
150
154
|
/** 每列最多选几个,默认无限多个 */
|
|
151
|
-
maxY?: number
|
|
155
|
+
maxY?: number;
|
|
152
156
|
|
|
153
157
|
/** 每列最少选几个,默认1 */
|
|
154
|
-
minY?: number
|
|
158
|
+
minY?: number;
|
|
155
159
|
|
|
156
160
|
/** 开放项的配置,开放项是y轴最后一个选项 */
|
|
157
161
|
open?: {
|
|
158
|
-
label: string
|
|
159
|
-
}
|
|
162
|
+
label: string;
|
|
163
|
+
};
|
|
160
164
|
};
|
|
161
165
|
|
|
162
166
|
/** 数组成员类型 */
|
|
@@ -167,7 +171,7 @@ export interface MFieldSchema {
|
|
|
167
171
|
|
|
168
172
|
/** 组件 AArrayGrid 新增时,是否自动添加带有唯一值的 value 属性 */
|
|
169
173
|
autoValue?: boolean;
|
|
170
|
-
|
|
174
|
+
|
|
171
175
|
/** 数组增加一项的按钮文案 */
|
|
172
176
|
arrayAddLabel?: string;
|
|
173
177
|
|
|
@@ -185,12 +189,13 @@ export interface MFieldSchema {
|
|
|
185
189
|
hideTillNow?: boolean;
|
|
186
190
|
/** 是否能选择时间 */
|
|
187
191
|
showTime?: boolean;
|
|
188
|
-
}
|
|
192
|
+
};
|
|
189
193
|
|
|
190
194
|
/** 数据格式 */
|
|
191
195
|
dataFormat?:
|
|
192
|
-
|
|
193
|
-
|
|
196
|
+
| "x"
|
|
197
|
+
| "YYYYMMDD" /** 用于时间日期类型字段的数据格式,参考moment,例如x表示数据是时间戳,YYYYMMDD表示数据是形如19990130的字符串 */
|
|
198
|
+
| string;
|
|
194
199
|
|
|
195
200
|
/**
|
|
196
201
|
* 例如:
|
|
@@ -198,11 +203,11 @@ export interface MFieldSchema {
|
|
|
198
203
|
* (1)增长了约___万元 (2)下降了约___万元 (3)基本没有变化
|
|
199
204
|
*/
|
|
200
205
|
intDiff?: {
|
|
201
|
-
incLabel: string;
|
|
206
|
+
incLabel: string; // 增长了约
|
|
202
207
|
incLabelPostfix: string; // 万元
|
|
203
|
-
decLabel: string;
|
|
208
|
+
decLabel: string; // 下降了约
|
|
204
209
|
decLabelPostfix: string; // 万元
|
|
205
|
-
keep: string;
|
|
210
|
+
keep: string; // 基本没有变化
|
|
206
211
|
};
|
|
207
212
|
|
|
208
213
|
/** 可以自己写个样式,会作用于antd元素上 */
|
|
@@ -226,29 +231,29 @@ export interface MFieldSchema {
|
|
|
226
231
|
/** 用于hpOrg类型*/
|
|
227
232
|
hpOrg?: {
|
|
228
233
|
/** 空格表示根 */
|
|
229
|
-
rootId: string
|
|
234
|
+
rootId: string;
|
|
230
235
|
};
|
|
231
236
|
|
|
232
237
|
ossFile?: {
|
|
233
|
-
type: "HP_GO" | "HP_SECOBJ"
|
|
238
|
+
type: "HP_GO" | "HP_SECOBJ";
|
|
234
239
|
/** 预览大小,单位像素 */
|
|
235
|
-
previewSize?: number
|
|
240
|
+
previewSize?: number;
|
|
236
241
|
arguments:
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
242
|
+
| { genName: boolean; ossKeyPath: string; permissionPolicyOr: string } // HPHOM_SECOBJ的参数,也就是/academy/oss/secObject的参数
|
|
243
|
+
| { appName: string } // HPHOM_GO的参数,也就是/academy/go/upload的参数
|
|
244
|
+
| any;
|
|
245
|
+
};
|
|
241
246
|
|
|
242
247
|
/** 装饰物的html */
|
|
243
248
|
decoration?: {
|
|
244
|
-
subType?: "rich" | "segmentLabel" | "submitBar" | "operations"
|
|
245
|
-
HTML?: string
|
|
246
|
-
more?: boolean
|
|
247
|
-
HTML2?: string
|
|
248
|
-
submitLabel?: string
|
|
249
|
-
segmentLabel?: string
|
|
250
|
-
operations?: { label: React.ReactNode
|
|
251
|
-
}
|
|
249
|
+
subType?: "rich" | "segmentLabel" | "submitBar" | "operations"; // 子类型
|
|
250
|
+
HTML?: string; // html片段
|
|
251
|
+
more?: boolean; // 是否显示更多
|
|
252
|
+
HTML2?: string; // 更多的 html片段
|
|
253
|
+
submitLabel?: string; // 提交按钮
|
|
254
|
+
segmentLabel?: string; // 分段标题
|
|
255
|
+
operations?: { label: React.ReactNode; handler: (data) => void }[]; // 操作
|
|
256
|
+
};
|
|
252
257
|
|
|
253
258
|
/**
|
|
254
259
|
* 来自远程的数据,用于下拉搜索框.
|
|
@@ -274,16 +279,16 @@ export interface MFieldSchema {
|
|
|
274
279
|
*/
|
|
275
280
|
remote?: {
|
|
276
281
|
/** 数据url,可以用${q}引用用户输入的查询关键字 */
|
|
277
|
-
url: string
|
|
282
|
+
url: string;
|
|
278
283
|
/** url返回的json中,数据list的路径 */
|
|
279
|
-
dataPath: string
|
|
284
|
+
dataPath: string;
|
|
280
285
|
|
|
281
286
|
/** 在dataPath下,值字段路径 */
|
|
282
|
-
valuePath: JSEXPR
|
|
287
|
+
valuePath: JSEXPR;
|
|
283
288
|
|
|
284
289
|
/** 在dataPath下,标题字段的表达式 */
|
|
285
|
-
labelExpr: ((value: any) => React.ReactNode) | JSEXPR
|
|
286
|
-
}
|
|
290
|
+
labelExpr: ((value: any) => React.ReactNode) | JSEXPR;
|
|
291
|
+
};
|
|
287
292
|
|
|
288
293
|
a?: {
|
|
289
294
|
urlExpr?: ((value: any, parent: any) => React.ReactNode) | JSEXPR;
|
|
@@ -291,98 +296,106 @@ export interface MFieldSchema {
|
|
|
291
296
|
onClick?: (value: any, parent: any) => void;
|
|
292
297
|
/** 在当前页面打开 */
|
|
293
298
|
currentPage?: boolean;
|
|
294
|
-
}
|
|
299
|
+
};
|
|
295
300
|
|
|
296
301
|
/** 元素的style */
|
|
297
|
-
style?: React.CSSProperties
|
|
302
|
+
style?: React.CSSProperties;
|
|
298
303
|
|
|
299
304
|
/** 布局方式,垂直(vertical)、水平(horizontal) */
|
|
300
305
|
layoutHint?: "v" | "h";
|
|
301
306
|
|
|
302
307
|
/** 其他插件的配置 */
|
|
303
308
|
options?: any;
|
|
304
|
-
|
|
309
|
+
|
|
305
310
|
/** 业务数据 */
|
|
306
311
|
bizData?: any;
|
|
307
312
|
}
|
|
308
313
|
|
|
309
|
-
/**
|
|
314
|
+
/**
|
|
310
315
|
* 数据变化时回调
|
|
311
316
|
* final=true表示回调是因为类似失去焦点导致的,此后不会再有变化回调
|
|
312
317
|
* final=false表示回调是因为用户操作导致的,不处理的话也不会导致最终数据不一致,因为后续会有final=true的回调。
|
|
313
318
|
* 对于暂存表单等比较重的操作,应该仅在final=true时触发,以减少调用次数
|
|
314
319
|
*/
|
|
315
|
-
export type AFTER_CHANGE_CALLBACK = (
|
|
320
|
+
export type AFTER_CHANGE_CALLBACK = (
|
|
321
|
+
path: string,
|
|
322
|
+
v: any,
|
|
323
|
+
final: boolean
|
|
324
|
+
) => void;
|
|
316
325
|
|
|
317
326
|
export type CHANGE_SCHEMA_CALLBACK = (v: any) => void;
|
|
318
327
|
|
|
319
328
|
export interface MProp {
|
|
320
329
|
/** database的数据描述 */
|
|
321
|
-
schema: MFieldSchemaAnonymity
|
|
330
|
+
schema: MFieldSchemaAnonymity;
|
|
322
331
|
|
|
323
332
|
/** json格式数据 */
|
|
324
|
-
database: any
|
|
333
|
+
database: any;
|
|
325
334
|
|
|
326
335
|
/** 编辑database中的字段路径 */
|
|
327
|
-
path: string
|
|
336
|
+
path: string;
|
|
328
337
|
|
|
329
338
|
/** 元素形态 */
|
|
330
339
|
morph: MORPH;
|
|
331
340
|
|
|
332
341
|
/** database有任何变化时回调 */
|
|
333
|
-
afterChange?: AFTER_CHANGE_CALLBACK
|
|
342
|
+
afterChange?: AFTER_CHANGE_CALLBACK;
|
|
334
343
|
|
|
335
344
|
/** 修改schema */
|
|
336
|
-
changeSchema?: CHANGE_SCHEMA_CALLBACK
|
|
345
|
+
changeSchema?: CHANGE_SCHEMA_CALLBACK;
|
|
337
346
|
|
|
338
347
|
/** 修改database */
|
|
339
|
-
changeDatabase?: CHANGE_SCHEMA_CALLBACK
|
|
348
|
+
changeDatabase?: CHANGE_SCHEMA_CALLBACK;
|
|
340
349
|
|
|
341
350
|
/** @deprecated 直接上层。有时parent是谁,会影响渲染字段 */
|
|
342
|
-
parent?: MFieldSchemaAnonymity
|
|
351
|
+
parent?: MFieldSchemaAnonymity;
|
|
343
352
|
|
|
344
353
|
/** 强制展示校验信息 */
|
|
345
|
-
forceValid?: boolean
|
|
354
|
+
forceValid?: boolean;
|
|
346
355
|
|
|
347
356
|
/**
|
|
348
|
-
* 要求元素展示删除按钮
|
|
357
|
+
* 要求元素展示删除按钮
|
|
349
358
|
* true=父元素是array(或object),要求子元素展示删除按钮
|
|
350
359
|
* false=父元素是array(或object),子元素可以展示删除按钮,但disable
|
|
351
360
|
* undefined=子元素不能展示删除按钮
|
|
352
361
|
*/
|
|
353
|
-
removeButton?: boolean
|
|
362
|
+
removeButton?: boolean;
|
|
354
363
|
|
|
355
364
|
/** 禁用元素 */
|
|
356
|
-
disable?: boolean
|
|
365
|
+
disable?: boolean;
|
|
357
366
|
|
|
358
367
|
/** 是否隐藏边框,例如在表格中就不需要边框 */
|
|
359
|
-
hideBorder?: boolean
|
|
368
|
+
hideBorder?: boolean;
|
|
360
369
|
|
|
361
370
|
/** 额外的控件,比如AArrayGrid里加个按钮 */
|
|
362
371
|
extra?: JSX.Element;
|
|
363
372
|
|
|
364
373
|
// 以下都是向下传递到html元素的
|
|
365
|
-
style?: React.CSSProperties
|
|
366
|
-
className?: string
|
|
374
|
+
style?: React.CSSProperties;
|
|
375
|
+
className?: string;
|
|
367
376
|
}
|
|
368
377
|
export interface M3UISpecSegmentItem {
|
|
369
|
-
label: string
|
|
370
|
-
fields: string[]
|
|
371
|
-
showIf?: string
|
|
372
|
-
name?: string
|
|
378
|
+
label: string;
|
|
379
|
+
fields: string[];
|
|
380
|
+
showIf?: string;
|
|
381
|
+
name?: string;
|
|
373
382
|
|
|
374
383
|
/** 如果要支持分段编辑提交,要设置此回调 */
|
|
375
|
-
onSubmit?: (
|
|
384
|
+
onSubmit?: (
|
|
385
|
+
segment: M3UISpecSegmentItem,
|
|
386
|
+
segmentData: any,
|
|
387
|
+
done: () => void
|
|
388
|
+
) => void;
|
|
376
389
|
|
|
377
390
|
/** 设置分段根元素的style */
|
|
378
|
-
style?: React.CSSProperties
|
|
391
|
+
style?: React.CSSProperties;
|
|
379
392
|
}
|
|
380
393
|
|
|
381
394
|
export interface M3UISpec {
|
|
382
|
-
type: "segmentForm" | "stepForm" | "flowForm"
|
|
383
|
-
layout: "horizontal" | "vertical"
|
|
384
|
-
comma?: string
|
|
385
|
-
labelAlign?: "left" | "right"
|
|
395
|
+
type: "segmentForm" | "stepForm" | "flowForm";
|
|
396
|
+
layout: "horizontal" | "vertical";
|
|
397
|
+
comma?: string;
|
|
398
|
+
labelAlign?: "left" | "right";
|
|
386
399
|
segments?: M3UISpecSegmentItem[];
|
|
387
400
|
}
|
|
388
401
|
|