@neeloong/form 0.22.0 → 0.24.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/index.d.mts +1178 -1125
- package/index.full.js +481 -524
- package/index.full.min.js +5 -5
- package/index.full.min.mjs +7 -7
- package/index.min.mjs +2 -2
- package/index.mjs +481 -524
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.24.0
|
|
3
3
|
* (c) 2024-2026 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -7,1263 +7,1272 @@
|
|
|
7
7
|
import { Signal } from 'signal-polyfill';
|
|
8
8
|
export { Signal } from 'signal-polyfill';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* @returns {Layout.Child[]}
|
|
15
|
-
*/
|
|
16
|
-
declare function parse(source: string, { createCalc, createInit, createEvent, simpleTag, enableHTML, }?: Options): Child[];
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 增强信息
|
|
20
|
-
*/
|
|
21
|
-
type Enhancement$1 = {
|
|
22
|
-
/**
|
|
23
|
-
* 事件
|
|
24
|
-
*/
|
|
25
|
-
events: Record<string, Node.Name | Node.Event>;
|
|
26
|
-
/**
|
|
27
|
-
* 属性
|
|
28
|
-
*/
|
|
29
|
-
attrs: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
30
|
-
/**
|
|
31
|
-
* 主值
|
|
32
|
-
*/
|
|
33
|
-
value?: Node.Name | Node.Calc | Node.Value<any> | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* 绑定信息
|
|
36
|
-
*/
|
|
37
|
-
bind?: string | boolean | undefined;
|
|
10
|
+
type StoreLayout<T = unknown> = {
|
|
11
|
+
html?: string | ParentNode | null | undefined;
|
|
12
|
+
fields?: StoreLayout.Item<T>[] | null | undefined;
|
|
13
|
+
renderer?: T | undefined;
|
|
38
14
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
15
|
+
declare namespace StoreLayout {
|
|
16
|
+
type Relatedness = {
|
|
17
|
+
/**
|
|
18
|
+
* 聚焦函数
|
|
19
|
+
*/
|
|
20
|
+
focus?: (() => void) | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* 展示函数
|
|
23
|
+
*/
|
|
24
|
+
scrollIntoView?: (() => void) | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* 输入元素
|
|
27
|
+
*/
|
|
28
|
+
input?: Element | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* 根元素
|
|
31
|
+
*/
|
|
32
|
+
root?: Element | undefined;
|
|
33
|
+
};
|
|
34
|
+
type Action = "add" | "move" | "trigger" | "remove" | "serial" | "open" | "collapse";
|
|
35
|
+
type Grid = {
|
|
36
|
+
colStart?: number | undefined;
|
|
37
|
+
colSpan?: number | undefined;
|
|
38
|
+
colEnd?: number | undefined;
|
|
39
|
+
rowStart?: number | undefined;
|
|
40
|
+
rowSpan?: number | undefined;
|
|
41
|
+
rowEnd?: number | undefined;
|
|
42
|
+
cell?: "" | "collapse" | "block" | "inline" | "fieldset" | "base" | undefined;
|
|
43
|
+
};
|
|
44
|
+
type Column<T_1 = unknown> = {
|
|
45
|
+
/**
|
|
46
|
+
* 操作
|
|
47
|
+
*/
|
|
48
|
+
actions?: StoreLayout.Action[] | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* 操作
|
|
51
|
+
*/
|
|
52
|
+
action?: StoreLayout.Action | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* 字段
|
|
55
|
+
*/
|
|
56
|
+
field?: string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* 占位符
|
|
59
|
+
*/
|
|
60
|
+
placeholder?: number | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* 模式
|
|
63
|
+
*/
|
|
64
|
+
pattern?: string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* 宽度
|
|
67
|
+
*/
|
|
68
|
+
width?: number | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* 标签
|
|
71
|
+
*/
|
|
72
|
+
label?: string | undefined;
|
|
73
|
+
html?: string | ParentNode | null | undefined;
|
|
74
|
+
fields?: StoreLayout.Item<T_1>[] | null | undefined;
|
|
75
|
+
renderer?: T_1 | undefined;
|
|
76
|
+
};
|
|
77
|
+
type Field<T_1 = unknown> = {
|
|
78
|
+
type?: "field" | undefined;
|
|
79
|
+
colStart?: number | undefined;
|
|
80
|
+
colSpan?: number | undefined;
|
|
81
|
+
colEnd?: number | undefined;
|
|
82
|
+
rowStart?: number | undefined;
|
|
83
|
+
rowSpan?: number | undefined;
|
|
84
|
+
rowEnd?: number | undefined;
|
|
85
|
+
cell?: StoreLayout.Grid["cell"];
|
|
86
|
+
renderer?: T_1 | undefined;
|
|
87
|
+
field?: string | undefined;
|
|
88
|
+
html?: string | ParentNode | null | undefined;
|
|
89
|
+
fields?: StoreLayout.Item<T_1>[] | null | undefined;
|
|
90
|
+
tableFoot?: "add" | "header" | "none" | undefined;
|
|
91
|
+
columns?: (string | number | StoreLayout.Column<T_1> | StoreLayout.Action[])[] | undefined;
|
|
92
|
+
arrayStyle?: "tree" | "table" | undefined;
|
|
93
|
+
mainMethod?: "move" | "trigger" | "open" | "collapse" | undefined;
|
|
94
|
+
levelKey?: string | undefined;
|
|
95
|
+
};
|
|
96
|
+
type Button = {
|
|
97
|
+
type: "button";
|
|
98
|
+
colStart?: number | undefined;
|
|
99
|
+
colSpan?: number | undefined;
|
|
100
|
+
colEnd?: number | undefined;
|
|
101
|
+
rowStart?: number | undefined;
|
|
102
|
+
rowSpan?: number | undefined;
|
|
103
|
+
rowEnd?: number | undefined;
|
|
104
|
+
cell?: StoreLayout.Grid["cell"];
|
|
105
|
+
required?: boolean | undefined;
|
|
106
|
+
label?: string | undefined;
|
|
107
|
+
description?: string | undefined;
|
|
108
|
+
disabled?: ((store: Store<any, any>, options?: StoreLayout.Options | null) => boolean) | undefined;
|
|
109
|
+
text?: string | ((store: Store<any, any>, options?: StoreLayout.Options | null) => string) | undefined;
|
|
110
|
+
click?: string | ((event: Event, store: Store<any, any>, options?: StoreLayout.Options | null) => void) | undefined;
|
|
111
|
+
};
|
|
112
|
+
type Html = {
|
|
113
|
+
type: "html";
|
|
114
|
+
colStart?: number | undefined;
|
|
115
|
+
colSpan?: number | undefined;
|
|
116
|
+
colEnd?: number | undefined;
|
|
117
|
+
rowStart?: number | undefined;
|
|
118
|
+
rowSpan?: number | undefined;
|
|
119
|
+
rowEnd?: number | undefined;
|
|
120
|
+
cell?: StoreLayout.Grid["cell"];
|
|
121
|
+
required?: boolean | undefined;
|
|
122
|
+
label?: string | undefined;
|
|
123
|
+
description?: string | undefined;
|
|
124
|
+
html?: string | ParentNode | null | undefined;
|
|
125
|
+
};
|
|
126
|
+
type Item<T_1 = unknown> = StoreLayout.Field<T_1> | StoreLayout.Button | StoreLayout.Html;
|
|
127
|
+
type Options = {
|
|
128
|
+
relate?: ((store: Store, el: Element | StoreLayout.Relatedness) => () => void) | undefined;
|
|
129
|
+
editable?: boolean | undefined;
|
|
130
|
+
signal?: AbortSignal | undefined;
|
|
131
|
+
call?: ((name: string, event: Event, store: Store<any, any>, options?: StoreLayout.Options | null) => void) | undefined;
|
|
132
|
+
};
|
|
133
|
+
type Renderer<T_1 = unknown> = (store: Store<any, any>, renderer?: T_1, options?: StoreLayout.Options | null) => HTMLElement | null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
type Schema<M = any> = Record<string, Schema.Field<M>>;
|
|
137
|
+
declare namespace Schema {
|
|
59
138
|
/**
|
|
60
|
-
*
|
|
139
|
+
* 同步验证器
|
|
61
140
|
*/
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* 布局节点
|
|
66
|
-
*/
|
|
67
|
-
type Node = {
|
|
141
|
+
type Validator = (store: Store) => string | string[] | void | null;
|
|
68
142
|
/**
|
|
69
|
-
*
|
|
143
|
+
* 异步验证器
|
|
70
144
|
*/
|
|
71
|
-
|
|
72
|
-
templates?: Record<string, Template> | undefined;
|
|
73
|
-
type?: null | undefined;
|
|
145
|
+
type AsyncValidator = (store: Store, signal: AbortSignal) => PromiseLike<string | string[] | void | null> | string | string[] | void | null;
|
|
74
146
|
/**
|
|
75
|
-
*
|
|
147
|
+
* 字段定义
|
|
76
148
|
*/
|
|
77
|
-
|
|
78
|
-
is?: string | null | undefined;
|
|
79
|
-
id?: string | undefined;
|
|
149
|
+
type Field<M_1 = any> = (Schema.Object<M_1> | Schema.Type) & Schema.Attr<M_1>;
|
|
80
150
|
/**
|
|
81
|
-
*
|
|
151
|
+
* 可选值
|
|
82
152
|
*/
|
|
83
|
-
|
|
153
|
+
type Value = {
|
|
154
|
+
/**
|
|
155
|
+
* 标签
|
|
156
|
+
*/
|
|
157
|
+
label: string;
|
|
158
|
+
/**
|
|
159
|
+
* 值
|
|
160
|
+
*/
|
|
161
|
+
value: string | number;
|
|
162
|
+
};
|
|
163
|
+
namespace Value {
|
|
164
|
+
/**
|
|
165
|
+
* 可选值定义
|
|
166
|
+
*/
|
|
167
|
+
type Define = Schema.Value | string | number;
|
|
168
|
+
/**
|
|
169
|
+
* 可选值分组
|
|
170
|
+
*/
|
|
171
|
+
type Group = {
|
|
172
|
+
/**
|
|
173
|
+
* 标签
|
|
174
|
+
*/
|
|
175
|
+
label: string;
|
|
176
|
+
/**
|
|
177
|
+
* 值
|
|
178
|
+
*/
|
|
179
|
+
value?: string | number | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* 子数据
|
|
182
|
+
*/
|
|
183
|
+
children: (Schema.Value.Group | Schema.Value)[];
|
|
184
|
+
};
|
|
185
|
+
namespace Group {
|
|
186
|
+
/**
|
|
187
|
+
* 可选值分组定义
|
|
188
|
+
*/
|
|
189
|
+
type Define = {
|
|
190
|
+
/**
|
|
191
|
+
* 标签
|
|
192
|
+
*/
|
|
193
|
+
label: string;
|
|
194
|
+
/**
|
|
195
|
+
* 值
|
|
196
|
+
*/
|
|
197
|
+
value?: string | number | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* 子数据
|
|
200
|
+
*/
|
|
201
|
+
children: (Schema.Value.Group | Schema.Value.Define)[];
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
84
205
|
/**
|
|
85
|
-
*
|
|
206
|
+
* 对象类型定义
|
|
86
207
|
*/
|
|
87
|
-
|
|
208
|
+
type Object<M_1 = any> = {
|
|
209
|
+
/**
|
|
210
|
+
* 字段定义
|
|
211
|
+
*/
|
|
212
|
+
type: Record<string, Schema.Field<M_1>>;
|
|
213
|
+
/**
|
|
214
|
+
* 是否为数组
|
|
215
|
+
*/
|
|
216
|
+
array?: boolean | undefined;
|
|
217
|
+
};
|
|
88
218
|
/**
|
|
89
|
-
*
|
|
219
|
+
* 基本类型字段定义
|
|
90
220
|
*/
|
|
91
|
-
|
|
221
|
+
type Type = {
|
|
222
|
+
/**
|
|
223
|
+
* 类型
|
|
224
|
+
*/
|
|
225
|
+
type: string;
|
|
226
|
+
/**
|
|
227
|
+
* 是否为数组
|
|
228
|
+
*/
|
|
229
|
+
array?: boolean | undefined;
|
|
230
|
+
};
|
|
92
231
|
/**
|
|
93
|
-
*
|
|
232
|
+
* 函数定义
|
|
94
233
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
*/
|
|
117
|
-
type Value<T = any> = {
|
|
118
|
-
value: T;
|
|
119
|
-
name?: undefined;
|
|
120
|
-
calc?: undefined;
|
|
121
|
-
event?: undefined;
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* 名称
|
|
125
|
-
*/
|
|
126
|
-
type Name = {
|
|
127
|
-
name: string;
|
|
128
|
-
value?: undefined;
|
|
129
|
-
calc?: undefined;
|
|
130
|
-
event?: undefined;
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* 事件
|
|
134
|
-
*/
|
|
135
|
-
type Event = {
|
|
136
|
-
event: EventListener;
|
|
137
|
-
name?: undefined;
|
|
138
|
-
calc?: undefined;
|
|
139
|
-
value?: undefined;
|
|
234
|
+
type Events = {
|
|
235
|
+
/**
|
|
236
|
+
* 输入
|
|
237
|
+
*/
|
|
238
|
+
input: InputEvent;
|
|
239
|
+
/**
|
|
240
|
+
* 变化
|
|
241
|
+
*/
|
|
242
|
+
change: InputEvent;
|
|
243
|
+
/**
|
|
244
|
+
* 点击
|
|
245
|
+
*/
|
|
246
|
+
click: Event;
|
|
247
|
+
/**
|
|
248
|
+
* 聚焦
|
|
249
|
+
*/
|
|
250
|
+
focus: Event;
|
|
251
|
+
/**
|
|
252
|
+
* 失焦
|
|
253
|
+
*/
|
|
254
|
+
blur: Event;
|
|
140
255
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
256
|
+
type Attr<M_1 = any> = {
|
|
257
|
+
/**
|
|
258
|
+
* 元信息
|
|
259
|
+
*/
|
|
260
|
+
meta?: M_1 | undefined;
|
|
261
|
+
default?: ((store: Store) => any) | any;
|
|
262
|
+
/**
|
|
263
|
+
* 自定义组件
|
|
264
|
+
*/
|
|
265
|
+
component?: any;
|
|
266
|
+
/**
|
|
267
|
+
* 是否可修改
|
|
268
|
+
*/
|
|
269
|
+
immutable?: boolean | undefined;
|
|
270
|
+
/**
|
|
271
|
+
* 是否可创建
|
|
272
|
+
*/
|
|
273
|
+
creatable?: boolean | undefined;
|
|
274
|
+
/**
|
|
275
|
+
* 是否隐藏
|
|
276
|
+
*/
|
|
277
|
+
hidden?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
278
|
+
/**
|
|
279
|
+
* 是否可清除
|
|
280
|
+
*/
|
|
281
|
+
clearable?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
282
|
+
/**
|
|
283
|
+
* 是否必填
|
|
284
|
+
*/
|
|
285
|
+
required?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
286
|
+
/**
|
|
287
|
+
* 是否禁用
|
|
288
|
+
*/
|
|
289
|
+
disabled?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
290
|
+
/**
|
|
291
|
+
* 是否只读
|
|
292
|
+
*/
|
|
293
|
+
readonly?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
294
|
+
/**
|
|
295
|
+
* 字段标签
|
|
296
|
+
*/
|
|
297
|
+
label?: string | ((store: Store) => string | null) | null | undefined;
|
|
298
|
+
/**
|
|
299
|
+
* 字段描述
|
|
300
|
+
*/
|
|
301
|
+
description?: string | ((store: Store) => string | null) | null | undefined;
|
|
302
|
+
/**
|
|
303
|
+
* 占位符
|
|
304
|
+
*/
|
|
305
|
+
placeholder?: string | ((store: Store) => string | null) | null | undefined;
|
|
306
|
+
/**
|
|
307
|
+
* 日期、时间、数字的最小值
|
|
308
|
+
*/
|
|
309
|
+
min?: number | ((store: Store) => number | null) | null | undefined;
|
|
310
|
+
/**
|
|
311
|
+
* 日期、时间、数字的最大值
|
|
312
|
+
*/
|
|
313
|
+
max?: number | ((store: Store) => number | null) | null | undefined;
|
|
314
|
+
/**
|
|
315
|
+
* 日期、时间、数字的步长
|
|
316
|
+
*/
|
|
317
|
+
step?: number | ((store: Store) => number | null) | null | undefined;
|
|
318
|
+
/**
|
|
319
|
+
* 最小长度
|
|
320
|
+
*/
|
|
321
|
+
minLength?: number | ((store: Store) => number | null) | null | undefined;
|
|
322
|
+
/**
|
|
323
|
+
* 最大长度
|
|
324
|
+
*/
|
|
325
|
+
maxLength?: number | ((store: Store) => number | null) | null | undefined;
|
|
326
|
+
/**
|
|
327
|
+
* 模式规则
|
|
328
|
+
*/
|
|
329
|
+
pattern?: RegExp | ((store: Store) => RegExp | null) | null | undefined;
|
|
330
|
+
/**
|
|
331
|
+
* 数组内是否可添加
|
|
332
|
+
*/
|
|
333
|
+
addable?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
334
|
+
/**
|
|
335
|
+
* 数组内是否可移除
|
|
336
|
+
*/
|
|
337
|
+
removable?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
338
|
+
/**
|
|
339
|
+
* 可选值
|
|
340
|
+
*/
|
|
341
|
+
values?: (Schema.Value.Group.Define | Schema.Value.Define)[] | ((store: Store) => (Schema.Value.Group.Define | Schema.Value.Define)[]) | undefined;
|
|
342
|
+
/**
|
|
343
|
+
* 监听函数
|
|
344
|
+
*/
|
|
345
|
+
events?: {
|
|
346
|
+
/**
|
|
347
|
+
* 输入
|
|
348
|
+
*/
|
|
349
|
+
input?: ((this: Store, value: InputEvent, store: Store) => void | boolean | null) | null | undefined;
|
|
350
|
+
/**
|
|
351
|
+
* 变化
|
|
352
|
+
*/
|
|
353
|
+
change?: ((this: Store, value: InputEvent, store: Store) => void | boolean | null) | null | undefined;
|
|
354
|
+
/**
|
|
355
|
+
* 点击
|
|
356
|
+
*/
|
|
357
|
+
click?: ((this: Store, value: Event, store: Store) => void | boolean | null) | null | undefined;
|
|
358
|
+
/**
|
|
359
|
+
* 聚焦
|
|
360
|
+
*/
|
|
361
|
+
focus?: ((this: Store, value: Event, store: Store) => void | boolean | null) | null | undefined;
|
|
362
|
+
/**
|
|
363
|
+
* 失焦
|
|
364
|
+
*/
|
|
365
|
+
blur?: ((this: Store, value: Event, store: Store) => void | boolean | null) | null | undefined;
|
|
366
|
+
} | undefined;
|
|
367
|
+
/**
|
|
368
|
+
* 同步验证器
|
|
369
|
+
*/
|
|
370
|
+
validator?: Schema.Validator | Schema.Validator[] | null | undefined;
|
|
371
|
+
/**
|
|
372
|
+
* 异步验证器
|
|
373
|
+
*/
|
|
374
|
+
validators?: {
|
|
375
|
+
change?: Schema.AsyncValidator | Schema.AsyncValidator[] | null | undefined;
|
|
376
|
+
blur?: Schema.AsyncValidator | Schema.AsyncValidator[] | null | undefined;
|
|
377
|
+
} | undefined;
|
|
378
|
+
layout?: StoreLayout.Field<any> | undefined;
|
|
149
379
|
};
|
|
150
380
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
* 变量定义
|
|
157
|
-
*/
|
|
158
|
-
type Variable<T = unknown> = {
|
|
159
|
-
variable: string;
|
|
160
|
-
name?: string | undefined;
|
|
161
|
-
calc?: Calc | undefined;
|
|
162
|
-
value?: T | undefined;
|
|
163
|
-
/**
|
|
164
|
-
* 是否普通变量
|
|
165
|
-
*/
|
|
166
|
-
init?: boolean | undefined;
|
|
167
|
-
/**
|
|
168
|
-
* 注释
|
|
169
|
-
*/
|
|
170
|
-
comment?: string | undefined;
|
|
171
|
-
};
|
|
172
|
-
type Template = {
|
|
173
|
-
/**
|
|
174
|
-
* 局部变量/别名/计算名
|
|
175
|
-
*/
|
|
176
|
-
vars?: Variable<unknown>[] | null | undefined;
|
|
177
|
-
templates?: Record<string, Template> | undefined;
|
|
178
|
-
/**
|
|
179
|
-
* 模板参数定义
|
|
180
|
-
*/
|
|
181
|
-
params: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
182
|
-
/**
|
|
183
|
-
* 子元素
|
|
184
|
-
*/
|
|
185
|
-
children: Child[];
|
|
186
|
-
/**
|
|
187
|
-
* 注释
|
|
188
|
-
*/
|
|
189
|
-
comment?: string | undefined;
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* 分歧项
|
|
193
|
-
*/
|
|
194
|
-
type DivergentChildren = {
|
|
195
|
-
/**
|
|
196
|
-
* 局部变量/别名/计算名
|
|
197
|
-
*/
|
|
198
|
-
vars?: Variable<unknown>[] | null | undefined;
|
|
199
|
-
templates?: Record<string, Template> | undefined;
|
|
200
|
-
/**
|
|
201
|
-
* 子元素
|
|
202
|
-
*/
|
|
203
|
-
children: Child[];
|
|
204
|
-
/**
|
|
205
|
-
* 注释
|
|
206
|
-
*/
|
|
207
|
-
comment?: string | undefined;
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* 分歧
|
|
211
|
-
*/
|
|
212
|
-
type Divergent = {
|
|
213
|
-
/**
|
|
214
|
-
* 局部变量/别名/计算名
|
|
215
|
-
*/
|
|
216
|
-
vars?: Variable<unknown>[] | null | undefined;
|
|
217
|
-
templates?: Record<string, Template> | undefined;
|
|
218
|
-
type: "divergent";
|
|
219
|
-
children: [children: DivergentChildren, condition?: Node.Name | Node.Calc | Node.Value | null][];
|
|
220
|
-
/**
|
|
221
|
-
* 注释
|
|
222
|
-
*/
|
|
223
|
-
comment?: string | undefined;
|
|
381
|
+
|
|
382
|
+
declare const ref: unique symbol;
|
|
383
|
+
type Ref = {
|
|
384
|
+
[ref]: Store;
|
|
385
|
+
[k: string]: Ref | undefined;
|
|
224
386
|
};
|
|
387
|
+
|
|
388
|
+
/** @import { Ref } from './ref.mjs' */
|
|
389
|
+
/** @import { Schema } from '../Schema.types.mjs' */
|
|
390
|
+
/** @import { StoreLayout } from '../StoreLayout.types.mjs' */
|
|
225
391
|
/**
|
|
226
|
-
*
|
|
392
|
+
* 管理单个表单字段的状态和行为
|
|
393
|
+
* @template [T=any]
|
|
394
|
+
* @template [M=any]
|
|
227
395
|
*/
|
|
228
|
-
|
|
396
|
+
declare class Store<T = any, M = any> {
|
|
229
397
|
/**
|
|
230
|
-
*
|
|
398
|
+
* 从数据结构模式创建存储
|
|
399
|
+
* @template [M=any]
|
|
400
|
+
* @param {Schema<M>} schema 数据结构模式
|
|
401
|
+
* @param {object} [options] 选项
|
|
402
|
+
* @param {boolean} [options.new] 是否为新建环境
|
|
231
403
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
name: string;
|
|
404
|
+
static create<M_1 = any>(schema: Schema<M_1>, options?: {
|
|
405
|
+
new?: boolean | undefined;
|
|
406
|
+
}): Store<any, any>;
|
|
236
407
|
/**
|
|
237
|
-
*
|
|
408
|
+
* 设置自定义类型的存储类
|
|
409
|
+
* @param {string} type
|
|
410
|
+
* @param {{new(...p: ConstructorParameters<typeof Store>): Store}} Class
|
|
238
411
|
*/
|
|
239
|
-
|
|
412
|
+
static setStore(type: string, Class: {
|
|
413
|
+
new (...p: ConstructorParameters<typeof Store>): Store;
|
|
414
|
+
}): void;
|
|
240
415
|
/**
|
|
241
|
-
*
|
|
416
|
+
* @param {Schema.Field<M>} schema 字段的 Schema 定义
|
|
417
|
+
* @param {object} [options] 可选配置
|
|
418
|
+
* @param {Store?} [options.parent]
|
|
419
|
+
* @param {((store: Store, value?: any) => any) | object | number | string | boolean | null | undefined} [options.default]
|
|
420
|
+
* @param {number | string | null} [options.index]
|
|
421
|
+
* @param {number | Signal.State<number> | Signal.Computed<number>} [options.size]
|
|
422
|
+
* @param {boolean} [options.null]
|
|
423
|
+
* @param {boolean} [options.new]
|
|
424
|
+
* @param {boolean} [options.hidden]
|
|
425
|
+
* @param {boolean} [options.clearable]
|
|
426
|
+
* @param {boolean} [options.required]
|
|
427
|
+
* @param {boolean} [options.disabled]
|
|
428
|
+
* @param {boolean} [options.readonly]
|
|
429
|
+
* @param {boolean} [options.removable]
|
|
430
|
+
*
|
|
431
|
+
* @param {string} [options.label] 字段标签
|
|
432
|
+
* @param {string} [options.description] 字段描述
|
|
433
|
+
* @param {string} [options.placeholder] 占位符
|
|
434
|
+
* @param {number} [options.min] 日期、时间、数字的最小值
|
|
435
|
+
* @param {number} [options.max] 日期、时间、数字的最大值
|
|
436
|
+
* @param {number} [options.step] 日期、时间、数字的步长
|
|
437
|
+
* @param {number} [options.minLength]
|
|
438
|
+
* @param {number} [options.maxLength]
|
|
439
|
+
* @param {RegExp} [options.pattern]
|
|
440
|
+
* @param {(Schema.Value.Group | Schema.Value | string | number)[]} [options.values] 可选值
|
|
441
|
+
* @param {Schema.Validator | Schema.Validator[] | null} [options.validator]
|
|
442
|
+
* @param {{[k in keyof Schema.Events]?: Schema.AsyncValidator | Schema.AsyncValidator[] | null}} [options.validators]
|
|
443
|
+
*
|
|
444
|
+
* @param {Ref?} [options.ref]
|
|
445
|
+
*
|
|
446
|
+
* @param {((value: any) => any)?} [options.setValue]
|
|
447
|
+
* @param {((value: any) => any)?} [options.convert]
|
|
448
|
+
*
|
|
449
|
+
* @param {((value: T?, index: any, store: Store) => void)?} [options.onUpdate]
|
|
242
450
|
*/
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
451
|
+
constructor(schema: Schema.Field<M>, { null: isNull, ref, default: defaultValue, setValue, convert, onUpdate, validator, validators, index, size, new: isNew, parent: parentNode, hidden, clearable, required, disabled, readonly, removable, label, description, placeholder, min, max, step, minLength, maxLength, pattern, values }?: {
|
|
452
|
+
parent?: Store<any, any> | null | undefined;
|
|
453
|
+
default?: ((store: Store, value?: any) => any) | object | number | string | boolean | null | undefined;
|
|
454
|
+
index?: string | number | null | undefined;
|
|
455
|
+
size?: number | Signal.State<number> | Signal.Computed<number> | undefined;
|
|
456
|
+
null?: boolean | undefined;
|
|
457
|
+
new?: boolean | undefined;
|
|
458
|
+
hidden?: boolean | undefined;
|
|
459
|
+
clearable?: boolean | undefined;
|
|
460
|
+
required?: boolean | undefined;
|
|
461
|
+
disabled?: boolean | undefined;
|
|
462
|
+
readonly?: boolean | undefined;
|
|
463
|
+
removable?: boolean | undefined;
|
|
464
|
+
label?: string | undefined;
|
|
465
|
+
description?: string | undefined;
|
|
466
|
+
placeholder?: string | undefined;
|
|
467
|
+
min?: number | undefined;
|
|
468
|
+
max?: number | undefined;
|
|
469
|
+
step?: number | undefined;
|
|
470
|
+
minLength?: number | undefined;
|
|
471
|
+
maxLength?: number | undefined;
|
|
472
|
+
pattern?: RegExp | undefined;
|
|
473
|
+
values?: (string | number | Schema.Value | Schema.Value.Group)[] | undefined;
|
|
474
|
+
validator?: Schema.Validator | Schema.Validator[] | null | undefined;
|
|
475
|
+
validators?: {
|
|
476
|
+
/**
|
|
477
|
+
* 输入
|
|
478
|
+
*/
|
|
479
|
+
input?: Schema.AsyncValidator | Schema.AsyncValidator[] | null | undefined;
|
|
480
|
+
/**
|
|
481
|
+
* 变化
|
|
482
|
+
*/
|
|
483
|
+
change?: Schema.AsyncValidator | Schema.AsyncValidator[] | null | undefined;
|
|
484
|
+
/**
|
|
485
|
+
* 点击
|
|
486
|
+
*/
|
|
487
|
+
click?: Schema.AsyncValidator | Schema.AsyncValidator[] | null | undefined;
|
|
488
|
+
/**
|
|
489
|
+
* 聚焦
|
|
490
|
+
*/
|
|
491
|
+
focus?: Schema.AsyncValidator | Schema.AsyncValidator[] | null | undefined;
|
|
492
|
+
/**
|
|
493
|
+
* 失焦
|
|
494
|
+
*/
|
|
495
|
+
blur?: Schema.AsyncValidator | Schema.AsyncValidator[] | null | undefined;
|
|
496
|
+
} | undefined;
|
|
497
|
+
ref?: Ref | null | undefined;
|
|
498
|
+
setValue?: ((value: any) => any) | null | undefined;
|
|
499
|
+
convert?: ((value: any) => any) | null | undefined;
|
|
500
|
+
onUpdate?: ((value: T | null, index: any, store: Store) => void) | null | undefined;
|
|
501
|
+
});
|
|
249
502
|
/**
|
|
250
|
-
*
|
|
503
|
+
* 触发事件并通知监听器
|
|
504
|
+
* @template {keyof Schema.Events} K
|
|
505
|
+
* @param {K} event
|
|
506
|
+
* @param {Schema.Events[K]} value
|
|
251
507
|
*/
|
|
252
|
-
|
|
253
|
-
templates?: Record<string, Template> | undefined;
|
|
254
|
-
type: "enum";
|
|
255
|
-
value: Node.Name | Node.Calc | Node.Value;
|
|
256
|
-
sort?: Node.Name | Node.Calc | Node.Value<any> | undefined;
|
|
508
|
+
emit<K extends keyof Schema.Events>(event: K, value: Schema.Events[K]): boolean;
|
|
257
509
|
/**
|
|
258
|
-
*
|
|
510
|
+
* 监听事件
|
|
511
|
+
* @template {keyof Schema.Events} K
|
|
512
|
+
* @param {K} event
|
|
513
|
+
* @param {(this: this, p: Schema.Events[K], store: this) => void | boolean | null} listener
|
|
514
|
+
* @returns {() => void}
|
|
259
515
|
*/
|
|
260
|
-
|
|
516
|
+
listen<K extends keyof Schema.Events>(event: K, listener: (this: this, p: Schema.Events[K], store: this) => void | boolean | null): () => void;
|
|
517
|
+
/** 是否为无效空存储 */
|
|
518
|
+
get null(): boolean;
|
|
519
|
+
/** 存储类类别,继承的自定义类需要设置自定义的此只读属性 */
|
|
520
|
+
get kind(): string;
|
|
521
|
+
get ref(): Ref;
|
|
522
|
+
schema: Schema.Field<M>;
|
|
523
|
+
get layout(): StoreLayout.Field<any>;
|
|
524
|
+
/** @param {any} [value] @returns {any} */
|
|
525
|
+
createDefault(value?: any): any;
|
|
526
|
+
set loading(loading: boolean);
|
|
527
|
+
get loading(): boolean;
|
|
528
|
+
/** 存储对象自身 */
|
|
529
|
+
get store(): this;
|
|
530
|
+
/** 父级存储对象 */
|
|
531
|
+
get parent(): Store<any, any> | null;
|
|
532
|
+
/** 根节点的存储对象 */
|
|
533
|
+
get root(): Store<any, any>;
|
|
534
|
+
/** 字段类型 */
|
|
535
|
+
get type(): any;
|
|
536
|
+
/** 字段元信息 */
|
|
537
|
+
get meta(): void | M;
|
|
538
|
+
/** 自定义渲染组件信息 */
|
|
539
|
+
get component(): any;
|
|
540
|
+
/** 长度信息 */
|
|
541
|
+
get size(): number;
|
|
542
|
+
set index(v: string | number);
|
|
543
|
+
/** 索引信息 */
|
|
544
|
+
get index(): string | number;
|
|
545
|
+
/** 数组项目的序号 */
|
|
546
|
+
get no(): string | number;
|
|
547
|
+
/** 值是否可创建(`$new` 为 `true` 时,字段只读) */
|
|
548
|
+
get creatable(): boolean;
|
|
549
|
+
/** 值是否不可改变(`$new` 为 `false` 时,字段只读) */
|
|
550
|
+
get immutable(): boolean;
|
|
551
|
+
set selfNew(v: boolean);
|
|
552
|
+
get selfNew(): boolean;
|
|
553
|
+
set new(v: boolean);
|
|
554
|
+
/** 是否新建项 */
|
|
555
|
+
get new(): boolean;
|
|
556
|
+
set selfHidden(v: boolean | null);
|
|
557
|
+
get selfHidden(): boolean | null;
|
|
558
|
+
set hidden(v: boolean);
|
|
559
|
+
/** 是否可隐藏 */
|
|
560
|
+
get hidden(): boolean;
|
|
561
|
+
set selfClearable(v: boolean | null);
|
|
562
|
+
get selfClearable(): boolean | null;
|
|
563
|
+
set clearable(v: boolean);
|
|
564
|
+
/** 是否可清除 */
|
|
565
|
+
get clearable(): boolean;
|
|
566
|
+
set selfRequired(v: boolean | null);
|
|
567
|
+
get selfRequired(): boolean | null;
|
|
568
|
+
set required(v: boolean);
|
|
569
|
+
/** 是否必填 */
|
|
570
|
+
get required(): boolean;
|
|
571
|
+
set selfDisabled(v: boolean | null);
|
|
572
|
+
get selfDisabled(): boolean | null;
|
|
573
|
+
set disabled(v: boolean);
|
|
574
|
+
/** 是否禁用字段 */
|
|
575
|
+
get disabled(): boolean;
|
|
576
|
+
set selfReadonly(v: boolean | null);
|
|
577
|
+
get selfReadonly(): boolean | null;
|
|
578
|
+
set readonly(v: boolean);
|
|
579
|
+
/** 是否只读 */
|
|
580
|
+
get readonly(): boolean;
|
|
581
|
+
set selfRemovable(v: boolean | null);
|
|
582
|
+
get selfRemovable(): boolean | null;
|
|
583
|
+
set removable(v: boolean);
|
|
584
|
+
/** 是否只读 */
|
|
585
|
+
get removable(): boolean;
|
|
586
|
+
set selfLabel(v: string | null);
|
|
587
|
+
get selfLabel(): string | null;
|
|
588
|
+
set label(v: string | null);
|
|
589
|
+
/** 字段的标签信息 */
|
|
590
|
+
get label(): string | null;
|
|
591
|
+
set selfDescription(v: string | null);
|
|
592
|
+
get selfDescription(): string | null;
|
|
593
|
+
set description(v: string | null);
|
|
594
|
+
/** 字段的描述信息 */
|
|
595
|
+
get description(): string | null;
|
|
596
|
+
set selfPlaceholder(v: string | null);
|
|
597
|
+
get selfPlaceholder(): string | null;
|
|
598
|
+
set placeholder(v: string | null);
|
|
599
|
+
/** 字段的占位符信息 */
|
|
600
|
+
get placeholder(): string | null;
|
|
601
|
+
set selfMin(v: number | null);
|
|
602
|
+
get selfMin(): number | null;
|
|
603
|
+
set min(v: number | null);
|
|
604
|
+
/** 数值字段的最小值限制 */
|
|
605
|
+
get min(): number | null;
|
|
606
|
+
set selfMax(v: number | null);
|
|
607
|
+
get selfMax(): number | null;
|
|
608
|
+
set max(v: number | null);
|
|
609
|
+
/** 数值字段的最大值限制 */
|
|
610
|
+
get max(): number | null;
|
|
611
|
+
set selfStep(v: number | null);
|
|
612
|
+
get selfStep(): number | null;
|
|
613
|
+
set step(v: number | null);
|
|
614
|
+
/** 数值字段的步长 */
|
|
615
|
+
get step(): number | null;
|
|
616
|
+
set selfMinLength(v: number | null);
|
|
617
|
+
get selfMinLength(): number | null;
|
|
618
|
+
set minLength(v: number | null);
|
|
619
|
+
/** 最小长度 */
|
|
620
|
+
get minLength(): number | null;
|
|
621
|
+
set selfMaxLength(v: number | null);
|
|
622
|
+
get selfMaxLength(): number | null;
|
|
623
|
+
set maxLength(v: number | null);
|
|
624
|
+
/** 最大长度 */
|
|
625
|
+
get maxLength(): number | null;
|
|
626
|
+
set selfPattern(v: RegExp | null);
|
|
627
|
+
get selfPattern(): RegExp | null;
|
|
628
|
+
set pattern(v: RegExp | null);
|
|
629
|
+
/** 模式 */
|
|
630
|
+
get pattern(): RegExp | null;
|
|
631
|
+
set selfValues(v: (Schema.Value | Schema.Value.Group)[] | null);
|
|
632
|
+
get selfValues(): (Schema.Value | Schema.Value.Group)[] | null;
|
|
633
|
+
set values(v: (Schema.Value | Schema.Value.Group)[] | null);
|
|
634
|
+
/** 可选值列表 */
|
|
635
|
+
get values(): (Schema.Value | Schema.Value.Group)[] | null;
|
|
636
|
+
/** 所有校验错误列表 */
|
|
637
|
+
get errors(): string[];
|
|
638
|
+
/** 字段校验错误信息 */
|
|
639
|
+
get error(): string;
|
|
261
640
|
/**
|
|
262
|
-
*
|
|
641
|
+
* 获取子存储
|
|
642
|
+
* @param {string | number} key
|
|
643
|
+
* @returns {Store?}
|
|
263
644
|
*/
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
*/
|
|
269
|
-
|
|
645
|
+
child(key: string | number): Store | null;
|
|
646
|
+
/** 内容是否已改变 */
|
|
647
|
+
get changed(): boolean;
|
|
648
|
+
set value(v: T | null);
|
|
649
|
+
/** 字段当前值 */
|
|
650
|
+
get value(): T | null;
|
|
651
|
+
/** 重置数据 */
|
|
652
|
+
reset(value?: unknown, isNew?: boolean): void;
|
|
270
653
|
/**
|
|
271
|
-
*
|
|
654
|
+
* 异步校验
|
|
655
|
+
* @overload
|
|
656
|
+
* @param {true} [path]
|
|
657
|
+
* @returns {Promise<string[] | null>}
|
|
272
658
|
*/
|
|
273
|
-
|
|
274
|
-
templates?: Record<string, Template> | undefined;
|
|
275
|
-
type: "content";
|
|
276
|
-
value: Node.Name | Node.Calc | Node.Value;
|
|
277
|
-
html?: boolean | undefined;
|
|
659
|
+
validate(path?: true | undefined): Promise<string[] | null>;
|
|
278
660
|
/**
|
|
279
|
-
*
|
|
661
|
+
* 异步校验
|
|
662
|
+
* @overload
|
|
663
|
+
* @param {(string | number)[] | false | null} [path] 到当前层级的路径
|
|
664
|
+
* @returns {Promise<{ path: (string | number)[]; store: Store; errors: string[]}[]>}
|
|
280
665
|
*/
|
|
281
|
-
|
|
282
|
-
|
|
666
|
+
validate(path?: false | (string | number)[] | null | undefined): Promise<{
|
|
667
|
+
path: (string | number)[];
|
|
668
|
+
store: Store;
|
|
669
|
+
errors: string[];
|
|
670
|
+
}[]>;
|
|
671
|
+
/** @returns {IterableIterator<[key: string | number, value: Store]>} */
|
|
672
|
+
[Symbol.iterator](): IterableIterator<[key: string | number, value: Store]>;
|
|
673
|
+
#private;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/** @import { Schema } from '../Schema.types.mjs' */
|
|
283
677
|
/**
|
|
284
|
-
*
|
|
678
|
+
* @template {Record<string, any>} [T=Record<string, any>]
|
|
679
|
+
* @template [M=any]
|
|
680
|
+
* @extends {Store<T, M>}
|
|
285
681
|
*/
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* 局部变量/别名/计算名
|
|
289
|
-
*/
|
|
290
|
-
vars?: Variable<unknown>[] | null | undefined;
|
|
291
|
-
templates?: Record<string, Template> | undefined;
|
|
292
|
-
type: "template";
|
|
293
|
-
/**
|
|
294
|
-
* 模板名
|
|
295
|
-
*/
|
|
296
|
-
template: string;
|
|
682
|
+
declare class ObjectStore<T extends Record<string, any> = Record<string, any>, M = any> extends Store<T, M> {
|
|
297
683
|
/**
|
|
298
|
-
*
|
|
684
|
+
* @param {Schema.Object<M> & Schema.Attr<M>} schema
|
|
685
|
+
* @param {object} [options]
|
|
686
|
+
* @param {Store?} [options.parent]
|
|
687
|
+
* @param {number | string | null} [options.index]
|
|
688
|
+
* @param {boolean} [options.new]
|
|
689
|
+
* @param {((value: T?, index: any, store: Store) => void)?} [options.onUpdate]
|
|
299
690
|
*/
|
|
300
|
-
|
|
691
|
+
constructor(schema: Schema.Object<M> & Schema.Attr<M>, { parent, index, new: isNew, onUpdate }?: {
|
|
692
|
+
parent?: Store<any, any> | null | undefined;
|
|
693
|
+
index?: string | number | null | undefined;
|
|
694
|
+
new?: boolean | undefined;
|
|
695
|
+
onUpdate?: ((value: T | null, index: any, store: Store) => void) | null | undefined;
|
|
696
|
+
});
|
|
697
|
+
[Symbol.iterator](): Generator<[string, Store<any, any>], void, unknown>;
|
|
698
|
+
#private;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/** @import { Schema } from '../Schema.types.mjs' */
|
|
702
|
+
/**
|
|
703
|
+
* @template [T=any]
|
|
704
|
+
* @template [M=any]
|
|
705
|
+
* @extends {Store<(T | null)[], M>}
|
|
706
|
+
*/
|
|
707
|
+
declare class ArrayStore<T = any, M = any> extends Store<(T | null)[], M> {
|
|
301
708
|
/**
|
|
302
|
-
*
|
|
709
|
+
* @param {Schema.Field<M>} schema
|
|
710
|
+
* @param {object} [options]
|
|
711
|
+
* @param {Store?} [options.parent]
|
|
712
|
+
* @param {string | number | null} [options.index]
|
|
713
|
+
* @param {boolean} [options.new]
|
|
714
|
+
* @param {boolean} [options.addable]
|
|
715
|
+
* @param {(value: any, index: any, store: Store) => void} [options.onUpdate]
|
|
303
716
|
*/
|
|
304
|
-
|
|
717
|
+
constructor(schema: Schema.Field<M>, { parent, onUpdate, index, new: isNew, addable }?: {
|
|
718
|
+
parent?: Store<any, any> | null | undefined;
|
|
719
|
+
index?: string | number | null | undefined;
|
|
720
|
+
new?: boolean | undefined;
|
|
721
|
+
addable?: boolean | undefined;
|
|
722
|
+
onUpdate?: ((value: any, index: any, store: Store) => void) | undefined;
|
|
723
|
+
});
|
|
724
|
+
get children(): Store<any, any>[];
|
|
725
|
+
set selfAddable(v: boolean | null);
|
|
726
|
+
get selfAddable(): boolean | null;
|
|
727
|
+
set addable(v: boolean);
|
|
728
|
+
/** 是否禁用字段 */
|
|
729
|
+
get addable(): boolean;
|
|
305
730
|
/**
|
|
306
|
-
*
|
|
731
|
+
*
|
|
732
|
+
* @param {number} index
|
|
733
|
+
* @param {T?} [value]
|
|
734
|
+
* @param {boolean} [isNew]
|
|
735
|
+
* @returns
|
|
307
736
|
*/
|
|
308
|
-
|
|
737
|
+
insert(index: number, value?: T | null, isNew?: boolean): boolean;
|
|
309
738
|
/**
|
|
310
|
-
*
|
|
739
|
+
*
|
|
740
|
+
* @param {T?} [value]
|
|
741
|
+
* @returns
|
|
311
742
|
*/
|
|
312
|
-
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* 片段
|
|
316
|
-
*/
|
|
317
|
-
type Fragment = {
|
|
743
|
+
add(value?: T | null): boolean;
|
|
318
744
|
/**
|
|
319
|
-
*
|
|
745
|
+
*
|
|
746
|
+
* @param {number} index
|
|
747
|
+
* @returns
|
|
320
748
|
*/
|
|
321
|
-
|
|
322
|
-
templates?: Record<string, Template> | undefined;
|
|
323
|
-
type: "fragment";
|
|
749
|
+
remove(index: number): T | null | undefined;
|
|
324
750
|
/**
|
|
325
|
-
*
|
|
751
|
+
*
|
|
752
|
+
* @param {number} from
|
|
753
|
+
* @param {number} to
|
|
754
|
+
* @param {number} quantity
|
|
755
|
+
* @returns
|
|
326
756
|
*/
|
|
327
|
-
|
|
757
|
+
move(from: number, to: number, quantity?: number): number;
|
|
328
758
|
/**
|
|
329
|
-
*
|
|
759
|
+
*
|
|
760
|
+
* @param {number} a
|
|
761
|
+
* @param {number} b
|
|
762
|
+
* @returns
|
|
330
763
|
*/
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
type Calc = (env: Record<string, any>) => any;
|
|
764
|
+
exchange(a: number, b: number): boolean;
|
|
765
|
+
[Symbol.iterator](): Generator<[number, Store<any, any>], undefined, unknown>;
|
|
766
|
+
#private;
|
|
767
|
+
}
|
|
768
|
+
|
|
337
769
|
/**
|
|
338
|
-
*
|
|
770
|
+
* 解析模板内容
|
|
771
|
+
* @param {string} source 输入源字符串
|
|
772
|
+
* @param {Layout.Options} [options] 解析选项
|
|
773
|
+
* @returns {Layout.Child[]}
|
|
339
774
|
*/
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
type index_d_Calc = Calc;
|
|
343
|
-
type index_d_CallTemplate = CallTemplate;
|
|
344
|
-
type index_d_Child = Child;
|
|
345
|
-
type index_d_Content = Content;
|
|
346
|
-
type index_d_Divergent = Divergent;
|
|
347
|
-
type index_d_DivergentChildren = DivergentChildren;
|
|
348
|
-
type index_d_Enum = Enum;
|
|
349
|
-
type index_d_EventListener = EventListener;
|
|
350
|
-
type index_d_Fragment = Fragment;
|
|
351
|
-
declare const index_d_Node: typeof Node;
|
|
352
|
-
type index_d_Options = Options;
|
|
353
|
-
type index_d_Select = Select;
|
|
354
|
-
type index_d_Template = Template;
|
|
355
|
-
type index_d_Variable<T = unknown> = Variable<T>;
|
|
356
|
-
declare const index_d_parse: typeof parse;
|
|
357
|
-
declare namespace index_d {
|
|
358
|
-
export { type index_d_Calc as Calc, type index_d_CallTemplate as CallTemplate, type index_d_Child as Child, type index_d_Content as Content, type index_d_Divergent as Divergent, type index_d_DivergentChildren as DivergentChildren, type Enhancement$1 as Enhancement, type index_d_Enum as Enum, type index_d_EventListener as EventListener, type index_d_Fragment as Fragment, index_d_Node as Node, type index_d_Options as Options, type index_d_Select as Select, type index_d_Template as Template, type index_d_Variable as Variable, index_d_parse as parse };
|
|
359
|
-
}
|
|
775
|
+
declare function parse(source: string, { createCalc, createInit, createEvent, simpleTag, enableHTML, }?: Options): Child[];
|
|
360
776
|
|
|
361
|
-
type VerifyError = any;
|
|
362
777
|
/**
|
|
363
|
-
*
|
|
778
|
+
* 增强信息
|
|
364
779
|
*/
|
|
365
|
-
type
|
|
780
|
+
type Enhancement$1 = {
|
|
366
781
|
/**
|
|
367
|
-
*
|
|
782
|
+
* 事件
|
|
368
783
|
*/
|
|
369
|
-
|
|
370
|
-
is?: string | undefined;
|
|
784
|
+
events: Record<string, Node.Name | Node.Event>;
|
|
371
785
|
/**
|
|
372
|
-
*
|
|
786
|
+
* 属性
|
|
373
787
|
*/
|
|
374
|
-
attrs
|
|
788
|
+
attrs: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
375
789
|
/**
|
|
376
|
-
*
|
|
790
|
+
* 主值
|
|
377
791
|
*/
|
|
378
|
-
|
|
792
|
+
value?: Node.Name | Node.Calc | Node.Value<any> | undefined;
|
|
793
|
+
/**
|
|
794
|
+
* 绑定信息
|
|
795
|
+
*/
|
|
796
|
+
bind?: string | boolean | undefined;
|
|
379
797
|
};
|
|
380
|
-
|
|
798
|
+
/**
|
|
799
|
+
* 解析选项
|
|
800
|
+
*/
|
|
801
|
+
type Options = {
|
|
381
802
|
/**
|
|
382
|
-
*
|
|
803
|
+
* 启用 `!html` 指令
|
|
383
804
|
*/
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* 属性类型
|
|
387
|
-
*/
|
|
388
|
-
type: string;
|
|
389
|
-
/**
|
|
390
|
-
* 是否为 js 属性
|
|
391
|
-
* // TODO: 可否计算,可否关联
|
|
392
|
-
*/
|
|
393
|
-
isProp?: boolean | undefined;
|
|
394
|
-
/**
|
|
395
|
-
* 绑定方式
|
|
396
|
-
*/
|
|
397
|
-
bind?: [event: string, set: EventListener, (boolean | undefined)?] | "hidden" | "clearable" | "readonly" | "disabled" | "required" | undefined;
|
|
398
|
-
/**
|
|
399
|
-
* 默认值
|
|
400
|
-
*/
|
|
401
|
-
default?: any;
|
|
402
|
-
/**
|
|
403
|
-
* 是否不可变
|
|
404
|
-
*/
|
|
405
|
-
immutable?: boolean | undefined;
|
|
406
|
-
};
|
|
805
|
+
enableHTML?: boolean | undefined;
|
|
407
806
|
/**
|
|
408
|
-
*
|
|
807
|
+
* 创建计算属性的工厂函数
|
|
409
808
|
*/
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* js 属性列表
|
|
413
|
-
*/
|
|
414
|
-
props?: Set<string> | null | undefined;
|
|
415
|
-
/**
|
|
416
|
-
* 上下文事件
|
|
417
|
-
*/
|
|
418
|
-
events: [string, ($event: any) => void, AddEventListenerOptions][];
|
|
419
|
-
/**
|
|
420
|
-
* 上下文属性
|
|
421
|
-
*/
|
|
422
|
-
attrs: Record<string, any>;
|
|
423
|
-
/**
|
|
424
|
-
* 属性监听
|
|
425
|
-
*/
|
|
426
|
-
watch: (name: any, fn: (value: any, old: any, name: string) => void) => () => void;
|
|
427
|
-
/**
|
|
428
|
-
* 关联
|
|
429
|
-
*/
|
|
430
|
-
relate: (el: Element | Relatedness) => () => void;
|
|
431
|
-
/**
|
|
432
|
-
* 是否已经销毁
|
|
433
|
-
*/
|
|
434
|
-
destroyed: boolean;
|
|
435
|
-
/**
|
|
436
|
-
* 是否完成初始化
|
|
437
|
-
*/
|
|
438
|
-
init: boolean;
|
|
439
|
-
/**
|
|
440
|
-
* 状态监听
|
|
441
|
-
*/
|
|
442
|
-
listen: <K extends keyof Component.Context.Events>(event: K, listener: (...p: Component.Context.Events[K]) => void) => () => void;
|
|
443
|
-
};
|
|
444
|
-
namespace Context {
|
|
445
|
-
type Events = {
|
|
446
|
-
init: [value: {
|
|
447
|
-
events: [string, ($event: any) => void, AddEventListenerOptions][];
|
|
448
|
-
}];
|
|
449
|
-
destroy: [];
|
|
450
|
-
};
|
|
451
|
-
}
|
|
809
|
+
createCalc?: ((t: string) => Calc) | undefined;
|
|
452
810
|
/**
|
|
453
|
-
*
|
|
811
|
+
* 创建变量初始化的工厂函数
|
|
454
812
|
*/
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* 过滤器配置
|
|
458
|
-
*/
|
|
459
|
-
filters: Record<string, Component.Event.Filter | string>;
|
|
460
|
-
};
|
|
461
|
-
namespace Event {
|
|
462
|
-
/**
|
|
463
|
-
* 组件事件过滤器
|
|
464
|
-
*/
|
|
465
|
-
type Filter = ($event: any, param: string[], env: any) => boolean | null | void;
|
|
466
|
-
}
|
|
813
|
+
createInit?: ((t: string) => Calc) | undefined;
|
|
467
814
|
/**
|
|
468
|
-
*
|
|
815
|
+
* 创建事件监听器的工厂函数
|
|
469
816
|
*/
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
type Schema<M = any> = Record<string, Schema.Field<M>>;
|
|
473
|
-
declare namespace Schema {
|
|
817
|
+
createEvent?: ((t: string) => EventListener) | undefined;
|
|
474
818
|
/**
|
|
475
|
-
*
|
|
819
|
+
* 简单标签的集合
|
|
476
820
|
*/
|
|
477
|
-
|
|
821
|
+
simpleTag?: Set<string> | undefined;
|
|
822
|
+
};
|
|
823
|
+
/**
|
|
824
|
+
* 布局节点
|
|
825
|
+
*/
|
|
826
|
+
type Node = {
|
|
478
827
|
/**
|
|
479
|
-
*
|
|
828
|
+
* 局部变量/别名/计算名
|
|
480
829
|
*/
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
};
|
|
491
|
-
namespace Value {
|
|
492
|
-
/**
|
|
493
|
-
* 可选值定义
|
|
494
|
-
*/
|
|
495
|
-
type Define = Schema.Value | string | number;
|
|
496
|
-
/**
|
|
497
|
-
* 可选值分组
|
|
498
|
-
*/
|
|
499
|
-
type Group = {
|
|
500
|
-
/**
|
|
501
|
-
* 标签
|
|
502
|
-
*/
|
|
503
|
-
label: string;
|
|
504
|
-
/**
|
|
505
|
-
* 值
|
|
506
|
-
*/
|
|
507
|
-
value?: string | number | undefined;
|
|
508
|
-
/**
|
|
509
|
-
* 子数据
|
|
510
|
-
*/
|
|
511
|
-
children: (Schema.Value.Group | Schema.Value)[];
|
|
512
|
-
};
|
|
513
|
-
namespace Group {
|
|
514
|
-
/**
|
|
515
|
-
* 可选值分组定义
|
|
516
|
-
*/
|
|
517
|
-
type Define = {
|
|
518
|
-
/**
|
|
519
|
-
* 标签
|
|
520
|
-
*/
|
|
521
|
-
label: string;
|
|
522
|
-
/**
|
|
523
|
-
* 值
|
|
524
|
-
*/
|
|
525
|
-
value?: string | number | undefined;
|
|
526
|
-
/**
|
|
527
|
-
* 子数据
|
|
528
|
-
*/
|
|
529
|
-
children: (Schema.Value.Group | Schema.Value.Define)[];
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
}
|
|
830
|
+
vars?: Variable<unknown>[] | null | undefined;
|
|
831
|
+
templates?: Record<string, Template> | undefined;
|
|
832
|
+
type?: null | undefined;
|
|
833
|
+
/**
|
|
834
|
+
* 标签名
|
|
835
|
+
*/
|
|
836
|
+
name: string;
|
|
837
|
+
is?: string | null | undefined;
|
|
838
|
+
id?: string | undefined;
|
|
533
839
|
/**
|
|
534
|
-
*
|
|
840
|
+
* 属性
|
|
535
841
|
*/
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
842
|
+
attrs: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
843
|
+
/**
|
|
844
|
+
* 类名
|
|
845
|
+
*/
|
|
846
|
+
classes: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
847
|
+
/**
|
|
848
|
+
* 样式
|
|
849
|
+
*/
|
|
850
|
+
styles: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
851
|
+
/**
|
|
852
|
+
* 事件
|
|
853
|
+
*/
|
|
854
|
+
events: Record<string, Node.Name | Node.Event>;
|
|
855
|
+
/**
|
|
856
|
+
* 增强
|
|
857
|
+
*/
|
|
858
|
+
enhancements: Record<string, Enhancement$1>;
|
|
859
|
+
/**
|
|
860
|
+
* 绑定内容
|
|
861
|
+
*/
|
|
862
|
+
bind?: string | boolean | undefined;
|
|
863
|
+
/**
|
|
864
|
+
* 注释
|
|
865
|
+
*/
|
|
866
|
+
comment?: string | undefined;
|
|
867
|
+
/**
|
|
868
|
+
* 子元素
|
|
869
|
+
*/
|
|
870
|
+
children: Child[];
|
|
871
|
+
};
|
|
872
|
+
declare namespace Node {
|
|
873
|
+
/**
|
|
874
|
+
* 基础值
|
|
875
|
+
*/
|
|
876
|
+
type Value<T = any> = {
|
|
877
|
+
value: T;
|
|
878
|
+
name?: undefined;
|
|
879
|
+
calc?: undefined;
|
|
880
|
+
event?: undefined;
|
|
545
881
|
};
|
|
546
882
|
/**
|
|
547
|
-
*
|
|
883
|
+
* 名称
|
|
548
884
|
*/
|
|
549
|
-
type
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* 是否为数组
|
|
556
|
-
*/
|
|
557
|
-
array?: boolean | undefined;
|
|
885
|
+
type Name = {
|
|
886
|
+
name: string;
|
|
887
|
+
value?: undefined;
|
|
888
|
+
calc?: undefined;
|
|
889
|
+
event?: undefined;
|
|
558
890
|
};
|
|
559
891
|
/**
|
|
560
|
-
*
|
|
892
|
+
* 事件
|
|
561
893
|
*/
|
|
562
|
-
type
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* 变化
|
|
569
|
-
*/
|
|
570
|
-
change: InputEvent;
|
|
571
|
-
/**
|
|
572
|
-
* 点击
|
|
573
|
-
*/
|
|
574
|
-
click: Event;
|
|
575
|
-
/**
|
|
576
|
-
* 聚焦
|
|
577
|
-
*/
|
|
578
|
-
focus: Event;
|
|
579
|
-
/**
|
|
580
|
-
* 失焦
|
|
581
|
-
*/
|
|
582
|
-
blur: Event;
|
|
894
|
+
type Event = {
|
|
895
|
+
event: EventListener;
|
|
896
|
+
name?: undefined;
|
|
897
|
+
calc?: undefined;
|
|
898
|
+
value?: undefined;
|
|
583
899
|
};
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
*/
|
|
593
|
-
component?: any;
|
|
594
|
-
/**
|
|
595
|
-
* 是否可修改
|
|
596
|
-
*/
|
|
597
|
-
immutable?: boolean | undefined;
|
|
598
|
-
/**
|
|
599
|
-
* 是否可创建
|
|
600
|
-
*/
|
|
601
|
-
creatable?: boolean | undefined;
|
|
602
|
-
/**
|
|
603
|
-
* 是否隐藏
|
|
604
|
-
*/
|
|
605
|
-
hidden?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
606
|
-
/**
|
|
607
|
-
* 是否可清除
|
|
608
|
-
*/
|
|
609
|
-
clearable?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
610
|
-
/**
|
|
611
|
-
* 是否必填
|
|
612
|
-
*/
|
|
613
|
-
required?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
614
|
-
/**
|
|
615
|
-
* 是否禁用
|
|
616
|
-
*/
|
|
617
|
-
disabled?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
618
|
-
/**
|
|
619
|
-
* 是否只读
|
|
620
|
-
*/
|
|
621
|
-
readonly?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
622
|
-
/**
|
|
623
|
-
* 字段标签
|
|
624
|
-
*/
|
|
625
|
-
label?: string | ((store: Store) => string | null) | null | undefined;
|
|
626
|
-
/**
|
|
627
|
-
* 字段描述
|
|
628
|
-
*/
|
|
629
|
-
description?: string | ((store: Store) => string | null) | null | undefined;
|
|
630
|
-
/**
|
|
631
|
-
* 占位符
|
|
632
|
-
*/
|
|
633
|
-
placeholder?: string | ((store: Store) => string | null) | null | undefined;
|
|
634
|
-
/**
|
|
635
|
-
* 日期、时间、数字的最小值
|
|
636
|
-
*/
|
|
637
|
-
min?: number | ((store: Store) => number | null) | null | undefined;
|
|
638
|
-
/**
|
|
639
|
-
* 日期、时间、数字的最大值
|
|
640
|
-
*/
|
|
641
|
-
max?: number | ((store: Store) => number | null) | null | undefined;
|
|
642
|
-
/**
|
|
643
|
-
* 日期、时间、数字的步长
|
|
644
|
-
*/
|
|
645
|
-
step?: number | ((store: Store) => number | null) | null | undefined;
|
|
646
|
-
/**
|
|
647
|
-
* 最小长度
|
|
648
|
-
*/
|
|
649
|
-
minLength?: number | ((store: Store) => number | null) | null | undefined;
|
|
650
|
-
/**
|
|
651
|
-
* 最大长度
|
|
652
|
-
*/
|
|
653
|
-
maxLength?: number | ((store: Store) => number | null) | null | undefined;
|
|
654
|
-
/**
|
|
655
|
-
* 模式规则
|
|
656
|
-
*/
|
|
657
|
-
pattern?: RegExp | ((store: Store) => RegExp | null) | null | undefined;
|
|
658
|
-
/**
|
|
659
|
-
* 数组内是否可添加
|
|
660
|
-
*/
|
|
661
|
-
addable?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
662
|
-
/**
|
|
663
|
-
* 数组内是否可移除
|
|
664
|
-
*/
|
|
665
|
-
removable?: boolean | ((store: Store) => boolean) | null | undefined;
|
|
666
|
-
/**
|
|
667
|
-
* 可选值
|
|
668
|
-
*/
|
|
669
|
-
values?: (Schema.Value.Define | Schema.Value.Group.Define)[] | ((store: Store) => (Schema.Value.Group.Define | Schema.Value.Define)[]) | undefined;
|
|
670
|
-
/**
|
|
671
|
-
* 监听函数
|
|
672
|
-
*/
|
|
673
|
-
events?: {
|
|
674
|
-
/**
|
|
675
|
-
* 输入
|
|
676
|
-
*/
|
|
677
|
-
input?: ((this: Store, value: InputEvent, store: Store) => void | boolean | null) | null | undefined;
|
|
678
|
-
/**
|
|
679
|
-
* 变化
|
|
680
|
-
*/
|
|
681
|
-
change?: ((this: Store, value: InputEvent, store: Store) => void | boolean | null) | null | undefined;
|
|
682
|
-
/**
|
|
683
|
-
* 点击
|
|
684
|
-
*/
|
|
685
|
-
click?: ((this: Store, value: Event, store: Store) => void | boolean | null) | null | undefined;
|
|
686
|
-
/**
|
|
687
|
-
* 聚焦
|
|
688
|
-
*/
|
|
689
|
-
focus?: ((this: Store, value: Event, store: Store) => void | boolean | null) | null | undefined;
|
|
690
|
-
/**
|
|
691
|
-
* 失焦
|
|
692
|
-
*/
|
|
693
|
-
blur?: ((this: Store, value: Event, store: Store) => void | boolean | null) | null | undefined;
|
|
694
|
-
} | undefined;
|
|
695
|
-
/**
|
|
696
|
-
* 同步验证器
|
|
697
|
-
*/
|
|
698
|
-
validator?: Validator | Validator[] | null | undefined;
|
|
699
|
-
/**
|
|
700
|
-
* 异步验证器
|
|
701
|
-
*/
|
|
702
|
-
validators?: {
|
|
703
|
-
change?: AsyncValidator | AsyncValidator[] | null | undefined;
|
|
704
|
-
blur?: AsyncValidator | AsyncValidator[] | null | undefined;
|
|
705
|
-
} | undefined;
|
|
900
|
+
/**
|
|
901
|
+
* 计算
|
|
902
|
+
*/
|
|
903
|
+
type Calc = {
|
|
904
|
+
calc: Calc;
|
|
905
|
+
name?: undefined;
|
|
906
|
+
value?: undefined;
|
|
907
|
+
event?: undefined;
|
|
706
908
|
};
|
|
707
909
|
}
|
|
708
910
|
/**
|
|
709
|
-
*
|
|
911
|
+
* 分歧
|
|
912
|
+
*/
|
|
913
|
+
type Child = Divergent | Select | Enum | Content | CallTemplate | Fragment | Node | string;
|
|
914
|
+
/**
|
|
915
|
+
* 变量定义
|
|
710
916
|
*/
|
|
711
|
-
type
|
|
917
|
+
type Variable<T = unknown> = {
|
|
918
|
+
variable: string;
|
|
919
|
+
name?: string | undefined;
|
|
920
|
+
calc?: Calc | undefined;
|
|
921
|
+
value?: T | undefined;
|
|
922
|
+
/**
|
|
923
|
+
* 是否普通变量
|
|
924
|
+
*/
|
|
925
|
+
init?: boolean | undefined;
|
|
926
|
+
/**
|
|
927
|
+
* 注释
|
|
928
|
+
*/
|
|
929
|
+
comment?: string | undefined;
|
|
930
|
+
};
|
|
931
|
+
type Template = {
|
|
932
|
+
/**
|
|
933
|
+
* 局部变量/别名/计算名
|
|
934
|
+
*/
|
|
935
|
+
vars?: Variable<unknown>[] | null | undefined;
|
|
936
|
+
templates?: Record<string, Template> | undefined;
|
|
937
|
+
/**
|
|
938
|
+
* 模板参数定义
|
|
939
|
+
*/
|
|
940
|
+
params: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
941
|
+
/**
|
|
942
|
+
* 子元素
|
|
943
|
+
*/
|
|
944
|
+
children: Child[];
|
|
945
|
+
/**
|
|
946
|
+
* 注释
|
|
947
|
+
*/
|
|
948
|
+
comment?: string | undefined;
|
|
949
|
+
};
|
|
712
950
|
/**
|
|
713
|
-
*
|
|
951
|
+
* 分歧项
|
|
714
952
|
*/
|
|
715
|
-
type
|
|
716
|
-
|
|
953
|
+
type DivergentChildren = {
|
|
954
|
+
/**
|
|
955
|
+
* 局部变量/别名/计算名
|
|
956
|
+
*/
|
|
957
|
+
vars?: Variable<unknown>[] | null | undefined;
|
|
958
|
+
templates?: Record<string, Template> | undefined;
|
|
717
959
|
/**
|
|
718
|
-
*
|
|
960
|
+
* 子元素
|
|
719
961
|
*/
|
|
720
|
-
|
|
962
|
+
children: Child[];
|
|
721
963
|
/**
|
|
722
|
-
*
|
|
964
|
+
* 注释
|
|
723
965
|
*/
|
|
724
|
-
|
|
966
|
+
comment?: string | undefined;
|
|
967
|
+
};
|
|
968
|
+
/**
|
|
969
|
+
* 分歧
|
|
970
|
+
*/
|
|
971
|
+
type Divergent = {
|
|
725
972
|
/**
|
|
726
|
-
*
|
|
973
|
+
* 局部变量/别名/计算名
|
|
727
974
|
*/
|
|
728
|
-
|
|
975
|
+
vars?: Variable<unknown>[] | null | undefined;
|
|
976
|
+
templates?: Record<string, Template> | undefined;
|
|
977
|
+
type: "divergent";
|
|
978
|
+
children: [children: DivergentChildren, condition?: Node.Name | Node.Calc | Node.Value | null][];
|
|
729
979
|
/**
|
|
730
|
-
*
|
|
980
|
+
* 注释
|
|
731
981
|
*/
|
|
732
|
-
|
|
982
|
+
comment?: string | undefined;
|
|
733
983
|
};
|
|
734
984
|
/**
|
|
735
|
-
*
|
|
985
|
+
* 选值
|
|
736
986
|
*/
|
|
737
|
-
type
|
|
738
|
-
declare namespace Enhancement {
|
|
987
|
+
type Select = {
|
|
739
988
|
/**
|
|
740
|
-
*
|
|
989
|
+
* 局部变量/别名/计算名
|
|
741
990
|
*/
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
watch: (name: any, fn: (value: any, old: any, name: string) => void) => () => void;
|
|
755
|
-
/**
|
|
756
|
-
* 是否已经销毁
|
|
757
|
-
*/
|
|
758
|
-
destroyed: boolean;
|
|
759
|
-
/**
|
|
760
|
-
* 监听状态
|
|
761
|
-
*/
|
|
762
|
-
listen: (event: "destroy", listener: () => void) => () => void;
|
|
763
|
-
/**
|
|
764
|
-
* 标签名
|
|
765
|
-
*/
|
|
766
|
-
tag: any;
|
|
767
|
-
/**
|
|
768
|
-
* 根元素
|
|
769
|
-
*/
|
|
770
|
-
root: Element;
|
|
771
|
-
/**
|
|
772
|
-
* 槽元素
|
|
773
|
-
*/
|
|
774
|
-
slot?: Element | null | undefined;
|
|
775
|
-
/**
|
|
776
|
-
* 传入的默认值
|
|
777
|
-
*/
|
|
778
|
-
value: any;
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
|
-
type StoreLayout = {
|
|
782
|
-
html?: string | ParentNode | null | undefined;
|
|
783
|
-
fields?: StoreLayout.Item[] | null | undefined;
|
|
784
|
-
};
|
|
785
|
-
declare namespace StoreLayout {
|
|
786
|
-
type Action = "add" | "move" | "trigger" | "remove" | "serial" | "open" | "collapse";
|
|
787
|
-
type Grid = {
|
|
788
|
-
colStart?: number | undefined;
|
|
789
|
-
colSpan?: number | undefined;
|
|
790
|
-
colEnd?: number | undefined;
|
|
791
|
-
rowStart?: number | undefined;
|
|
792
|
-
rowSpan?: number | undefined;
|
|
793
|
-
rowEnd?: number | undefined;
|
|
794
|
-
cell?: "" | "collapse" | "block" | "inline" | "fieldset" | "base" | undefined;
|
|
795
|
-
};
|
|
796
|
-
type Column = {
|
|
797
|
-
/**
|
|
798
|
-
* 操作
|
|
799
|
-
*/
|
|
800
|
-
actions?: StoreLayout.Action[] | undefined;
|
|
801
|
-
/**
|
|
802
|
-
* 操作
|
|
803
|
-
*/
|
|
804
|
-
action?: StoreLayout.Action | undefined;
|
|
805
|
-
/**
|
|
806
|
-
* 字段
|
|
807
|
-
*/
|
|
808
|
-
field?: string | undefined;
|
|
809
|
-
/**
|
|
810
|
-
* 占位符
|
|
811
|
-
*/
|
|
812
|
-
placeholder?: number | undefined;
|
|
813
|
-
/**
|
|
814
|
-
* 模式
|
|
815
|
-
*/
|
|
816
|
-
pattern?: string | undefined;
|
|
817
|
-
/**
|
|
818
|
-
* 宽度
|
|
819
|
-
*/
|
|
820
|
-
width?: number | undefined;
|
|
821
|
-
/**
|
|
822
|
-
* 标签
|
|
823
|
-
*/
|
|
824
|
-
label?: string | undefined;
|
|
825
|
-
};
|
|
826
|
-
type Field = {
|
|
827
|
-
type?: "field" | undefined;
|
|
828
|
-
colStart?: number | undefined;
|
|
829
|
-
colSpan?: number | undefined;
|
|
830
|
-
colEnd?: number | undefined;
|
|
831
|
-
rowStart?: number | undefined;
|
|
832
|
-
rowSpan?: number | undefined;
|
|
833
|
-
rowEnd?: number | undefined;
|
|
834
|
-
cell?: StoreLayout.Grid["cell"];
|
|
835
|
-
field: string;
|
|
836
|
-
html?: string | ParentNode | null | undefined;
|
|
837
|
-
inlineHtml?: string | ParentNode | null | undefined;
|
|
838
|
-
fields?: StoreLayout.Item[] | null | undefined;
|
|
839
|
-
tableFoot?: "add" | "header" | "none" | undefined;
|
|
840
|
-
columns?: (string | number | StoreLayout.Column | StoreLayout.Action[])[] | undefined;
|
|
841
|
-
arrayStyle?: "tree" | "table" | undefined;
|
|
842
|
-
mainMethod?: "move" | "trigger" | "open" | "collapse" | undefined;
|
|
843
|
-
levelKey?: string | undefined;
|
|
844
|
-
};
|
|
845
|
-
type Button = {
|
|
846
|
-
type: "button";
|
|
847
|
-
colStart?: number | undefined;
|
|
848
|
-
colSpan?: number | undefined;
|
|
849
|
-
colEnd?: number | undefined;
|
|
850
|
-
rowStart?: number | undefined;
|
|
851
|
-
rowSpan?: number | undefined;
|
|
852
|
-
rowEnd?: number | undefined;
|
|
853
|
-
cell?: StoreLayout.Grid["cell"];
|
|
854
|
-
required?: boolean | undefined;
|
|
855
|
-
label?: string | undefined;
|
|
856
|
-
description?: string | undefined;
|
|
857
|
-
disabled?: ((store: Store<any, any>, options?: StoreLayout.Options | null) => boolean) | undefined;
|
|
858
|
-
text?: string | ((store: Store<any, any>, options?: StoreLayout.Options | null) => string) | undefined;
|
|
859
|
-
click?: string | ((event: Event, store: Store<any, any>, options?: StoreLayout.Options | null) => void) | undefined;
|
|
860
|
-
};
|
|
861
|
-
type Html = {
|
|
862
|
-
type: "html";
|
|
863
|
-
colStart?: number | undefined;
|
|
864
|
-
colSpan?: number | undefined;
|
|
865
|
-
colEnd?: number | undefined;
|
|
866
|
-
rowStart?: number | undefined;
|
|
867
|
-
rowSpan?: number | undefined;
|
|
868
|
-
rowEnd?: number | undefined;
|
|
869
|
-
cell?: StoreLayout.Grid["cell"];
|
|
870
|
-
required?: boolean | undefined;
|
|
871
|
-
label?: string | undefined;
|
|
872
|
-
description?: string | undefined;
|
|
873
|
-
html?: string | ParentNode | null | undefined;
|
|
874
|
-
};
|
|
875
|
-
type Item = StoreLayout.Field | StoreLayout.Button | StoreLayout.Html;
|
|
876
|
-
type Options = {
|
|
877
|
-
relate?: ((store: Store, el: Element | Relatedness) => () => void) | undefined;
|
|
878
|
-
editable?: boolean | undefined;
|
|
879
|
-
call?: ((name: string, event: Event, store: Store<any, any>, options?: StoreLayout.Options | null) => void) | undefined;
|
|
880
|
-
};
|
|
881
|
-
type Renderer = (store: Store<any, any>, options?: StoreLayout.Options | null) => [HTMLElement, () => void] | null;
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
declare const ref: unique symbol;
|
|
885
|
-
type Ref = {
|
|
886
|
-
[ref]: Store;
|
|
887
|
-
[k: string]: Ref | undefined;
|
|
991
|
+
vars?: Variable<unknown>[] | null | undefined;
|
|
992
|
+
templates?: Record<string, Template> | undefined;
|
|
993
|
+
type: "value";
|
|
994
|
+
name: string;
|
|
995
|
+
/**
|
|
996
|
+
* 子元素
|
|
997
|
+
*/
|
|
998
|
+
children: Child[];
|
|
999
|
+
/**
|
|
1000
|
+
* 注释
|
|
1001
|
+
*/
|
|
1002
|
+
comment?: string | undefined;
|
|
888
1003
|
};
|
|
889
|
-
|
|
890
|
-
/** @import { Ref } from './ref.mjs' */
|
|
891
|
-
/** @import { AsyncValidator, Schema, Validator } from '../types.mjs' */
|
|
892
1004
|
/**
|
|
893
|
-
*
|
|
894
|
-
* @template [T=any]
|
|
895
|
-
* @template [M=any]
|
|
1005
|
+
* 枚举
|
|
896
1006
|
*/
|
|
897
|
-
|
|
1007
|
+
type Enum = {
|
|
898
1008
|
/**
|
|
899
|
-
*
|
|
900
|
-
* @template [M=any]
|
|
901
|
-
* @param {Schema<M>} schema 数据结构模式
|
|
902
|
-
* @param {object} [options] 选项
|
|
903
|
-
* @param {boolean} [options.new] 是否为新建环境
|
|
1009
|
+
* 局部变量/别名/计算名
|
|
904
1010
|
*/
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
1011
|
+
vars?: Variable<unknown>[] | null | undefined;
|
|
1012
|
+
templates?: Record<string, Template> | undefined;
|
|
1013
|
+
type: "enum";
|
|
1014
|
+
value: Node.Name | Node.Calc | Node.Value;
|
|
1015
|
+
sort?: Node.Name | Node.Calc | Node.Value<any> | undefined;
|
|
908
1016
|
/**
|
|
909
|
-
*
|
|
910
|
-
* @param {string} type
|
|
911
|
-
* @param {{new(...p: ConstructorParameters<typeof Store>): Store}} Class
|
|
1017
|
+
* 子元素
|
|
912
1018
|
*/
|
|
913
|
-
|
|
914
|
-
new (...p: ConstructorParameters<typeof Store>): Store;
|
|
915
|
-
}): void;
|
|
1019
|
+
children: Child[];
|
|
916
1020
|
/**
|
|
917
|
-
*
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
*
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
*
|
|
935
|
-
* @param {number} [options.min] 日期、时间、数字的最小值
|
|
936
|
-
* @param {number} [options.max] 日期、时间、数字的最大值
|
|
937
|
-
* @param {number} [options.step] 日期、时间、数字的步长
|
|
938
|
-
* @param {number} [options.minLength]
|
|
939
|
-
* @param {number} [options.maxLength]
|
|
940
|
-
* @param {RegExp} [options.pattern]
|
|
941
|
-
* @param {(Schema.Value.Group | Schema.Value | string | number)[]} [options.values] 可选值
|
|
942
|
-
* @param {Validator | Validator[] | null} [options.validator]
|
|
943
|
-
* @param {{[k in keyof Schema.Events]?: AsyncValidator | AsyncValidator[] | null}} [options.validators]
|
|
944
|
-
*
|
|
945
|
-
* @param {Ref?} [options.ref]
|
|
946
|
-
*
|
|
947
|
-
* @param {((value: any) => any)?} [options.setValue]
|
|
948
|
-
* @param {((value: any) => any)?} [options.convert]
|
|
949
|
-
*
|
|
950
|
-
* @param {((value: T?, index: any, store: Store) => void)?} [options.onUpdate]
|
|
1021
|
+
* 注释
|
|
1022
|
+
*/
|
|
1023
|
+
comment?: string | undefined;
|
|
1024
|
+
};
|
|
1025
|
+
/**
|
|
1026
|
+
* 内容填充
|
|
1027
|
+
*/
|
|
1028
|
+
type Content = {
|
|
1029
|
+
/**
|
|
1030
|
+
* 局部变量/别名/计算名
|
|
1031
|
+
*/
|
|
1032
|
+
vars?: Variable<unknown>[] | null | undefined;
|
|
1033
|
+
templates?: Record<string, Template> | undefined;
|
|
1034
|
+
type: "content";
|
|
1035
|
+
value: Node.Name | Node.Calc | Node.Value;
|
|
1036
|
+
html?: boolean | undefined;
|
|
1037
|
+
/**
|
|
1038
|
+
* 注释
|
|
951
1039
|
*/
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
new?: boolean | undefined;
|
|
959
|
-
hidden?: boolean | undefined;
|
|
960
|
-
clearable?: boolean | undefined;
|
|
961
|
-
required?: boolean | undefined;
|
|
962
|
-
disabled?: boolean | undefined;
|
|
963
|
-
readonly?: boolean | undefined;
|
|
964
|
-
removable?: boolean | undefined;
|
|
965
|
-
label?: string | undefined;
|
|
966
|
-
description?: string | undefined;
|
|
967
|
-
placeholder?: string | undefined;
|
|
968
|
-
min?: number | undefined;
|
|
969
|
-
max?: number | undefined;
|
|
970
|
-
step?: number | undefined;
|
|
971
|
-
minLength?: number | undefined;
|
|
972
|
-
maxLength?: number | undefined;
|
|
973
|
-
pattern?: RegExp | undefined;
|
|
974
|
-
values?: (string | number | Schema.Value | Schema.Value.Group)[] | undefined;
|
|
975
|
-
validator?: Validator | Validator[] | null | undefined;
|
|
976
|
-
validators?: {
|
|
977
|
-
/**
|
|
978
|
-
* 输入
|
|
979
|
-
*/
|
|
980
|
-
input?: AsyncValidator | AsyncValidator[] | null | undefined;
|
|
981
|
-
/**
|
|
982
|
-
* 变化
|
|
983
|
-
*/
|
|
984
|
-
change?: AsyncValidator | AsyncValidator[] | null | undefined;
|
|
985
|
-
/**
|
|
986
|
-
* 点击
|
|
987
|
-
*/
|
|
988
|
-
click?: AsyncValidator | AsyncValidator[] | null | undefined;
|
|
989
|
-
/**
|
|
990
|
-
* 聚焦
|
|
991
|
-
*/
|
|
992
|
-
focus?: AsyncValidator | AsyncValidator[] | null | undefined;
|
|
993
|
-
/**
|
|
994
|
-
* 失焦
|
|
995
|
-
*/
|
|
996
|
-
blur?: AsyncValidator | AsyncValidator[] | null | undefined;
|
|
997
|
-
} | undefined;
|
|
998
|
-
ref?: Ref | null | undefined;
|
|
999
|
-
setValue?: ((value: any) => any) | null | undefined;
|
|
1000
|
-
convert?: ((value: any) => any) | null | undefined;
|
|
1001
|
-
onUpdate?: ((value: T | null, index: any, store: Store) => void) | null | undefined;
|
|
1002
|
-
});
|
|
1040
|
+
comment?: string | undefined;
|
|
1041
|
+
};
|
|
1042
|
+
/**
|
|
1043
|
+
* 模板调用
|
|
1044
|
+
*/
|
|
1045
|
+
type CallTemplate = {
|
|
1003
1046
|
/**
|
|
1004
|
-
*
|
|
1005
|
-
* @template {keyof Schema.Events} K
|
|
1006
|
-
* @param {K} event
|
|
1007
|
-
* @param {Schema.Events[K]} value
|
|
1047
|
+
* 局部变量/别名/计算名
|
|
1008
1048
|
*/
|
|
1009
|
-
|
|
1049
|
+
vars?: Variable<unknown>[] | null | undefined;
|
|
1050
|
+
templates?: Record<string, Template> | undefined;
|
|
1051
|
+
type: "template";
|
|
1010
1052
|
/**
|
|
1011
|
-
*
|
|
1012
|
-
* @template {keyof Schema.Events} K
|
|
1013
|
-
* @param {K} event
|
|
1014
|
-
* @param {(this: this, p: Schema.Events[K], store: this) => void | boolean | null} listener
|
|
1015
|
-
* @returns {() => void}
|
|
1053
|
+
* 模板名
|
|
1016
1054
|
*/
|
|
1017
|
-
|
|
1018
|
-
/** 是否为无效空存储 */
|
|
1019
|
-
get null(): boolean;
|
|
1020
|
-
/** 存储类类别,继承的自定义类需要设置自定义的此只读属性 */
|
|
1021
|
-
get kind(): string;
|
|
1022
|
-
get ref(): Ref;
|
|
1023
|
-
schema: Schema.Field<M>;
|
|
1024
|
-
/** @param {any} [value] @returns {any} */
|
|
1025
|
-
createDefault(value?: any): any;
|
|
1026
|
-
set loading(loading: boolean);
|
|
1027
|
-
get loading(): boolean;
|
|
1028
|
-
/** 存储对象自身 */
|
|
1029
|
-
get store(): this;
|
|
1030
|
-
/** 父级存储对象 */
|
|
1031
|
-
get parent(): Store<any, any> | null;
|
|
1032
|
-
/** 根节点的存储对象 */
|
|
1033
|
-
get root(): Store<any, any>;
|
|
1034
|
-
/** 字段类型 */
|
|
1035
|
-
get type(): any;
|
|
1036
|
-
/** 字段元信息 */
|
|
1037
|
-
get meta(): void | M;
|
|
1038
|
-
/** 自定义渲染组件信息 */
|
|
1039
|
-
get component(): any;
|
|
1040
|
-
/** 长度信息 */
|
|
1041
|
-
get size(): number;
|
|
1042
|
-
set index(v: string | number);
|
|
1043
|
-
/** 索引信息 */
|
|
1044
|
-
get index(): string | number;
|
|
1045
|
-
/** 数组项目的序号 */
|
|
1046
|
-
get no(): string | number;
|
|
1047
|
-
/** 值是否可创建(`$new` 为 `true` 时,字段只读) */
|
|
1048
|
-
get creatable(): boolean;
|
|
1049
|
-
/** 值是否不可改变(`$new` 为 `false` 时,字段只读) */
|
|
1050
|
-
get immutable(): boolean;
|
|
1051
|
-
set selfNew(v: boolean);
|
|
1052
|
-
get selfNew(): boolean;
|
|
1053
|
-
set new(v: boolean);
|
|
1054
|
-
/** 是否新建项 */
|
|
1055
|
-
get new(): boolean;
|
|
1056
|
-
set selfHidden(v: boolean | null);
|
|
1057
|
-
get selfHidden(): boolean | null;
|
|
1058
|
-
set hidden(v: boolean);
|
|
1059
|
-
/** 是否可隐藏 */
|
|
1060
|
-
get hidden(): boolean;
|
|
1061
|
-
set selfClearable(v: boolean | null);
|
|
1062
|
-
get selfClearable(): boolean | null;
|
|
1063
|
-
set clearable(v: boolean);
|
|
1064
|
-
/** 是否可清除 */
|
|
1065
|
-
get clearable(): boolean;
|
|
1066
|
-
set selfRequired(v: boolean | null);
|
|
1067
|
-
get selfRequired(): boolean | null;
|
|
1068
|
-
set required(v: boolean);
|
|
1069
|
-
/** 是否必填 */
|
|
1070
|
-
get required(): boolean;
|
|
1071
|
-
set selfDisabled(v: boolean | null);
|
|
1072
|
-
get selfDisabled(): boolean | null;
|
|
1073
|
-
set disabled(v: boolean);
|
|
1074
|
-
/** 是否禁用字段 */
|
|
1075
|
-
get disabled(): boolean;
|
|
1076
|
-
set selfReadonly(v: boolean | null);
|
|
1077
|
-
get selfReadonly(): boolean | null;
|
|
1078
|
-
set readonly(v: boolean);
|
|
1079
|
-
/** 是否只读 */
|
|
1080
|
-
get readonly(): boolean;
|
|
1081
|
-
set selfRemovable(v: boolean | null);
|
|
1082
|
-
get selfRemovable(): boolean | null;
|
|
1083
|
-
set removable(v: boolean);
|
|
1084
|
-
/** 是否只读 */
|
|
1085
|
-
get removable(): boolean;
|
|
1086
|
-
set selfLabel(v: string | null);
|
|
1087
|
-
get selfLabel(): string | null;
|
|
1088
|
-
set label(v: string | null);
|
|
1089
|
-
/** 字段的标签信息 */
|
|
1090
|
-
get label(): string | null;
|
|
1091
|
-
set selfDescription(v: string | null);
|
|
1092
|
-
get selfDescription(): string | null;
|
|
1093
|
-
set description(v: string | null);
|
|
1094
|
-
/** 字段的描述信息 */
|
|
1095
|
-
get description(): string | null;
|
|
1096
|
-
set selfPlaceholder(v: string | null);
|
|
1097
|
-
get selfPlaceholder(): string | null;
|
|
1098
|
-
set placeholder(v: string | null);
|
|
1099
|
-
/** 字段的占位符信息 */
|
|
1100
|
-
get placeholder(): string | null;
|
|
1101
|
-
set selfMin(v: number | null);
|
|
1102
|
-
get selfMin(): number | null;
|
|
1103
|
-
set min(v: number | null);
|
|
1104
|
-
/** 数值字段的最小值限制 */
|
|
1105
|
-
get min(): number | null;
|
|
1106
|
-
set selfMax(v: number | null);
|
|
1107
|
-
get selfMax(): number | null;
|
|
1108
|
-
set max(v: number | null);
|
|
1109
|
-
/** 数值字段的最大值限制 */
|
|
1110
|
-
get max(): number | null;
|
|
1111
|
-
set selfStep(v: number | null);
|
|
1112
|
-
get selfStep(): number | null;
|
|
1113
|
-
set step(v: number | null);
|
|
1114
|
-
/** 数值字段的步长 */
|
|
1115
|
-
get step(): number | null;
|
|
1116
|
-
set selfMinLength(v: number | null);
|
|
1117
|
-
get selfMinLength(): number | null;
|
|
1118
|
-
set minLength(v: number | null);
|
|
1119
|
-
/** 最小长度 */
|
|
1120
|
-
get minLength(): number | null;
|
|
1121
|
-
set selfMaxLength(v: number | null);
|
|
1122
|
-
get selfMaxLength(): number | null;
|
|
1123
|
-
set maxLength(v: number | null);
|
|
1124
|
-
/** 最大长度 */
|
|
1125
|
-
get maxLength(): number | null;
|
|
1126
|
-
set selfPattern(v: RegExp | null);
|
|
1127
|
-
get selfPattern(): RegExp | null;
|
|
1128
|
-
set pattern(v: RegExp | null);
|
|
1129
|
-
/** 模式 */
|
|
1130
|
-
get pattern(): RegExp | null;
|
|
1131
|
-
set selfValues(v: (Schema.Value | Schema.Value.Group)[] | null);
|
|
1132
|
-
get selfValues(): (Schema.Value | Schema.Value.Group)[] | null;
|
|
1133
|
-
set values(v: (Schema.Value | Schema.Value.Group)[] | null);
|
|
1134
|
-
/** 可选值列表 */
|
|
1135
|
-
get values(): (Schema.Value | Schema.Value.Group)[] | null;
|
|
1136
|
-
/** 所有校验错误列表 */
|
|
1137
|
-
get errors(): string[];
|
|
1138
|
-
/** 字段校验错误信息 */
|
|
1139
|
-
get error(): string;
|
|
1055
|
+
template: string;
|
|
1140
1056
|
/**
|
|
1141
|
-
*
|
|
1142
|
-
* @param {string | number} key
|
|
1143
|
-
* @returns {Store?}
|
|
1057
|
+
* 属性
|
|
1144
1058
|
*/
|
|
1145
|
-
|
|
1146
|
-
/** 内容是否已改变 */
|
|
1147
|
-
get changed(): boolean;
|
|
1148
|
-
set value(v: T | null);
|
|
1149
|
-
/** 字段当前值 */
|
|
1150
|
-
get value(): T | null;
|
|
1151
|
-
/** 重置数据 */
|
|
1152
|
-
reset(value?: unknown, isNew?: boolean): void;
|
|
1059
|
+
attrs: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
1153
1060
|
/**
|
|
1154
|
-
*
|
|
1155
|
-
* @overload
|
|
1156
|
-
* @param {true} [path]
|
|
1157
|
-
* @returns {Promise<string[] | null>}
|
|
1061
|
+
* 绑定内容
|
|
1158
1062
|
*/
|
|
1159
|
-
|
|
1063
|
+
bind?: string | boolean | undefined;
|
|
1160
1064
|
/**
|
|
1161
|
-
*
|
|
1162
|
-
* @overload
|
|
1163
|
-
* @param {(string | number)[] | false | null} [path] 到当前层级的路径
|
|
1164
|
-
* @returns {Promise<{ path: (string | number)[]; store: Store; errors: string[]}[]>}
|
|
1065
|
+
* 子元素
|
|
1165
1066
|
*/
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
/**
|
|
1067
|
+
children: Child[];
|
|
1068
|
+
/**
|
|
1069
|
+
* 注释
|
|
1070
|
+
*/
|
|
1071
|
+
comment?: string | undefined;
|
|
1072
|
+
};
|
|
1073
|
+
/**
|
|
1074
|
+
* 片段
|
|
1075
|
+
*/
|
|
1076
|
+
type Fragment = {
|
|
1077
|
+
/**
|
|
1078
|
+
* 局部变量/别名/计算名
|
|
1079
|
+
*/
|
|
1080
|
+
vars?: Variable<unknown>[] | null | undefined;
|
|
1081
|
+
templates?: Record<string, Template> | undefined;
|
|
1082
|
+
type: "fragment";
|
|
1083
|
+
/**
|
|
1084
|
+
* 子元素
|
|
1085
|
+
*/
|
|
1086
|
+
children: Child[];
|
|
1087
|
+
/**
|
|
1088
|
+
* 注释
|
|
1089
|
+
*/
|
|
1090
|
+
comment?: string | undefined;
|
|
1091
|
+
};
|
|
1092
|
+
/**
|
|
1093
|
+
* 计算函数
|
|
1094
|
+
*/
|
|
1095
|
+
type Calc = (env: Record<string, any>) => any;
|
|
1177
1096
|
/**
|
|
1178
|
-
*
|
|
1179
|
-
* @template [M=any]
|
|
1180
|
-
* @extends {Store<T, M>}
|
|
1097
|
+
* 事件监听器
|
|
1181
1098
|
*/
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1099
|
+
type EventListener = ($event: any, env: Record<string, any>) => void;
|
|
1100
|
+
|
|
1101
|
+
type index_d_Calc = Calc;
|
|
1102
|
+
type index_d_CallTemplate = CallTemplate;
|
|
1103
|
+
type index_d_Child = Child;
|
|
1104
|
+
type index_d_Content = Content;
|
|
1105
|
+
type index_d_Divergent = Divergent;
|
|
1106
|
+
type index_d_DivergentChildren = DivergentChildren;
|
|
1107
|
+
type index_d_Enum = Enum;
|
|
1108
|
+
type index_d_EventListener = EventListener;
|
|
1109
|
+
type index_d_Fragment = Fragment;
|
|
1110
|
+
declare const index_d_Node: typeof Node;
|
|
1111
|
+
type index_d_Options = Options;
|
|
1112
|
+
type index_d_Select = Select;
|
|
1113
|
+
type index_d_Template = Template;
|
|
1114
|
+
type index_d_Variable<T = unknown> = Variable<T>;
|
|
1115
|
+
declare const index_d_parse: typeof parse;
|
|
1116
|
+
declare namespace index_d {
|
|
1117
|
+
export { type index_d_Calc as Calc, type index_d_CallTemplate as CallTemplate, type index_d_Child as Child, type index_d_Content as Content, type index_d_Divergent as Divergent, type index_d_DivergentChildren as DivergentChildren, type Enhancement$1 as Enhancement, type index_d_Enum as Enum, type index_d_EventListener as EventListener, type index_d_Fragment as Fragment, index_d_Node as Node, type index_d_Options as Options, type index_d_Select as Select, type index_d_Template as Template, type index_d_Variable as Variable, index_d_parse as parse };
|
|
1199
1118
|
}
|
|
1200
1119
|
|
|
1201
|
-
/** @import { Schema } from '../types.mjs' */
|
|
1202
1120
|
/**
|
|
1203
|
-
*
|
|
1204
|
-
* @template [M=any]
|
|
1205
|
-
* @extends {Store<(T | null)[], M>}
|
|
1121
|
+
* 自定义组件
|
|
1206
1122
|
*/
|
|
1207
|
-
|
|
1123
|
+
type Component = {
|
|
1208
1124
|
/**
|
|
1209
|
-
*
|
|
1210
|
-
* @param {object} [options]
|
|
1211
|
-
* @param {Store?} [options.parent]
|
|
1212
|
-
* @param {string | number | null} [options.index]
|
|
1213
|
-
* @param {boolean} [options.new]
|
|
1214
|
-
* @param {boolean} [options.addable]
|
|
1215
|
-
* @param {(value: any, index: any, store: Store) => void} [options.onUpdate]
|
|
1125
|
+
* 组件标签
|
|
1216
1126
|
*/
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
index?: string | number | null | undefined;
|
|
1220
|
-
new?: boolean | undefined;
|
|
1221
|
-
addable?: boolean | undefined;
|
|
1222
|
-
onUpdate?: ((value: any, index: any, store: Store) => void) | undefined;
|
|
1223
|
-
});
|
|
1224
|
-
get children(): Store<any, any>[];
|
|
1225
|
-
set selfAddable(v: boolean | null);
|
|
1226
|
-
get selfAddable(): boolean | null;
|
|
1227
|
-
set addable(v: boolean);
|
|
1228
|
-
/** 是否禁用字段 */
|
|
1229
|
-
get addable(): boolean;
|
|
1127
|
+
tag: string | ((ctx: Component.Context) => Element | [Element, (Element | null)?]);
|
|
1128
|
+
is?: string | undefined;
|
|
1230
1129
|
/**
|
|
1231
|
-
*
|
|
1232
|
-
* @param {number} index
|
|
1233
|
-
* @param {T?} [value]
|
|
1234
|
-
* @param {boolean} [isNew]
|
|
1235
|
-
* @returns
|
|
1130
|
+
* 组件属性
|
|
1236
1131
|
*/
|
|
1237
|
-
|
|
1132
|
+
attrs?: Record<string, Component.Attr> | undefined;
|
|
1238
1133
|
/**
|
|
1239
|
-
*
|
|
1240
|
-
* @param {T?} [value]
|
|
1241
|
-
* @returns
|
|
1134
|
+
* 组件事件
|
|
1242
1135
|
*/
|
|
1243
|
-
|
|
1136
|
+
events?: Record<string, Component.Event> | undefined;
|
|
1137
|
+
};
|
|
1138
|
+
declare namespace Component {
|
|
1244
1139
|
/**
|
|
1245
|
-
*
|
|
1246
|
-
* @param {number} index
|
|
1247
|
-
* @returns
|
|
1140
|
+
* 组件属性定义
|
|
1248
1141
|
*/
|
|
1249
|
-
|
|
1142
|
+
type Attr = {
|
|
1143
|
+
/**
|
|
1144
|
+
* 属性类型
|
|
1145
|
+
*/
|
|
1146
|
+
type: string;
|
|
1147
|
+
/**
|
|
1148
|
+
* 是否为 js 属性
|
|
1149
|
+
* // TODO: 可否计算,可否关联
|
|
1150
|
+
*/
|
|
1151
|
+
isProp?: boolean | undefined;
|
|
1152
|
+
/**
|
|
1153
|
+
* 绑定方式
|
|
1154
|
+
*/
|
|
1155
|
+
bind?: "hidden" | "clearable" | "required" | "disabled" | "readonly" | [event: string, set: EventListener, (boolean | undefined)?] | undefined;
|
|
1156
|
+
/**
|
|
1157
|
+
* 默认值
|
|
1158
|
+
*/
|
|
1159
|
+
default?: any;
|
|
1160
|
+
/**
|
|
1161
|
+
* 是否不可变
|
|
1162
|
+
*/
|
|
1163
|
+
immutable?: boolean | undefined;
|
|
1164
|
+
};
|
|
1250
1165
|
/**
|
|
1251
|
-
*
|
|
1252
|
-
* @param {number} from
|
|
1253
|
-
* @param {number} to
|
|
1254
|
-
* @param {number} quantity
|
|
1255
|
-
* @returns
|
|
1166
|
+
* 自定义组件的上下文
|
|
1256
1167
|
*/
|
|
1257
|
-
|
|
1168
|
+
type Context = {
|
|
1169
|
+
/**
|
|
1170
|
+
* js 属性列表
|
|
1171
|
+
*/
|
|
1172
|
+
props?: Set<string> | null | undefined;
|
|
1173
|
+
/**
|
|
1174
|
+
* 上下文事件
|
|
1175
|
+
*/
|
|
1176
|
+
events: [string, ($event: any) => void, AddEventListenerOptions][];
|
|
1177
|
+
/**
|
|
1178
|
+
* 上下文属性
|
|
1179
|
+
*/
|
|
1180
|
+
attrs: Record<string, any>;
|
|
1181
|
+
/**
|
|
1182
|
+
* 属性监听
|
|
1183
|
+
*/
|
|
1184
|
+
watch: (name: any, fn: (value: any, old: any, name: string) => void) => () => void;
|
|
1185
|
+
/**
|
|
1186
|
+
* 关联
|
|
1187
|
+
*/
|
|
1188
|
+
relate: (el: Element | StoreLayout.Relatedness) => () => void;
|
|
1189
|
+
/**
|
|
1190
|
+
* 是否已经销毁
|
|
1191
|
+
*/
|
|
1192
|
+
destroyed: boolean;
|
|
1193
|
+
/**
|
|
1194
|
+
* 是否完成初始化
|
|
1195
|
+
*/
|
|
1196
|
+
init: boolean;
|
|
1197
|
+
/**
|
|
1198
|
+
* 状态监听
|
|
1199
|
+
*/
|
|
1200
|
+
listen: <K extends keyof Component.Context.Events>(event: K, listener: (...p: Component.Context.Events[K]) => void) => () => void;
|
|
1201
|
+
};
|
|
1202
|
+
namespace Context {
|
|
1203
|
+
type Events = {
|
|
1204
|
+
init: [value: {
|
|
1205
|
+
events: [string, ($event: any) => void, AddEventListenerOptions][];
|
|
1206
|
+
}];
|
|
1207
|
+
destroy: [];
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1258
1210
|
/**
|
|
1259
|
-
*
|
|
1260
|
-
* @param {number} a
|
|
1261
|
-
* @param {number} b
|
|
1262
|
-
* @returns
|
|
1211
|
+
* 组件事件配置
|
|
1263
1212
|
*/
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1213
|
+
type Event = {
|
|
1214
|
+
/**
|
|
1215
|
+
* 过滤器配置
|
|
1216
|
+
*/
|
|
1217
|
+
filters: Record<string, Component.Event.Filter | string>;
|
|
1218
|
+
};
|
|
1219
|
+
namespace Event {
|
|
1220
|
+
/**
|
|
1221
|
+
* 组件事件过滤器
|
|
1222
|
+
*/
|
|
1223
|
+
type Filter = ($event: any, param: string[], env: any) => boolean | null | void;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* 自定义组件函数获取器
|
|
1227
|
+
*/
|
|
1228
|
+
type Getter = (path: string[], next?: ((path: string[]) => Component | null) | undefined) => Component | null;
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* 增强函数
|
|
1232
|
+
*/
|
|
1233
|
+
type Enhancement = (context: Enhancement.Context) => any;
|
|
1234
|
+
declare namespace Enhancement {
|
|
1235
|
+
/**
|
|
1236
|
+
* 增强函数上下文
|
|
1237
|
+
*/
|
|
1238
|
+
type Context = {
|
|
1239
|
+
/**
|
|
1240
|
+
* 关联的事件
|
|
1241
|
+
*/
|
|
1242
|
+
events: [string, ($event: any) => void, AddEventListenerOptions][];
|
|
1243
|
+
/**
|
|
1244
|
+
* 关联的属性
|
|
1245
|
+
*/
|
|
1246
|
+
attrs: Record<string, any>;
|
|
1247
|
+
/**
|
|
1248
|
+
* 监听属性
|
|
1249
|
+
*/
|
|
1250
|
+
watch: (name: any, fn: (value: any, old: any, name: string) => void) => () => void;
|
|
1251
|
+
/**
|
|
1252
|
+
* 是否已经销毁
|
|
1253
|
+
*/
|
|
1254
|
+
destroyed: boolean;
|
|
1255
|
+
/**
|
|
1256
|
+
* 监听状态
|
|
1257
|
+
*/
|
|
1258
|
+
listen: (event: "destroy", listener: () => void) => () => void;
|
|
1259
|
+
/**
|
|
1260
|
+
* 标签名
|
|
1261
|
+
*/
|
|
1262
|
+
tag: any;
|
|
1263
|
+
/**
|
|
1264
|
+
* 根元素
|
|
1265
|
+
*/
|
|
1266
|
+
root: Element;
|
|
1267
|
+
/**
|
|
1268
|
+
* 槽元素
|
|
1269
|
+
*/
|
|
1270
|
+
slot?: Element | null | undefined;
|
|
1271
|
+
/**
|
|
1272
|
+
* 传入的默认值
|
|
1273
|
+
*/
|
|
1274
|
+
value: any;
|
|
1275
|
+
};
|
|
1267
1276
|
}
|
|
1268
1277
|
|
|
1269
1278
|
/**
|
|
@@ -1273,7 +1282,7 @@ declare class ArrayStore<T = any, M = any> extends Store<(T | null)[], M> {
|
|
|
1273
1282
|
* @param {object} [options] 选项
|
|
1274
1283
|
* @param {Record<string, Store | {get?(): any; set?(v: any): void; exec?(...p: any[]): any; calc?(...p: any[]): any }>} [options.global] 全局数据
|
|
1275
1284
|
* @param {Component.Getter?} [options.component] 自定义组件
|
|
1276
|
-
* @param {(store: Store, el: Element | Relatedness) => () => void} [options.relate] 关联函数
|
|
1285
|
+
* @param {(store: Store, el: Element | StoreLayout.Relatedness) => () => void} [options.relate] 关联函数
|
|
1277
1286
|
* @param {Record<string, Enhancement>} [options.enhancements] 增强信息
|
|
1278
1287
|
* @returns {() => void}
|
|
1279
1288
|
*/
|
|
@@ -1285,37 +1294,81 @@ declare function render(store: Store, layouts: Child[], parent: Element, { compo
|
|
|
1285
1294
|
calc?(...p: any[]): any;
|
|
1286
1295
|
}> | undefined;
|
|
1287
1296
|
component?: Component.Getter | null | undefined;
|
|
1288
|
-
relate?: ((store: Store, el: Element | Relatedness) => () => void) | undefined;
|
|
1297
|
+
relate?: ((store: Store, el: Element | StoreLayout.Relatedness) => () => void) | undefined;
|
|
1289
1298
|
enhancements?: Record<string, Enhancement> | undefined;
|
|
1290
1299
|
}): () => void;
|
|
1291
1300
|
|
|
1292
1301
|
/**
|
|
1293
1302
|
* 创建可赋值计算值
|
|
1294
1303
|
* @template T
|
|
1304
|
+
* @overload
|
|
1295
1305
|
* @param {() => T} getter 取值方法
|
|
1296
1306
|
* @param {(value: T) => void} callback 取值方法
|
|
1297
1307
|
* @param {boolean} immediate 是否立即执行一次
|
|
1308
|
+
* @param {null} [signal]
|
|
1298
1309
|
* @returns {() => void}
|
|
1299
1310
|
*/
|
|
1300
|
-
declare function watch<T>(getter: () => T, callback: (value: T) => void, immediate: boolean): () => void;
|
|
1311
|
+
declare function watch<T>(getter: () => T, callback: (value: T) => void, immediate: boolean, signal?: null | undefined): () => void;
|
|
1312
|
+
/**
|
|
1313
|
+
* 创建可赋值计算值
|
|
1314
|
+
* @template T
|
|
1315
|
+
* @overload
|
|
1316
|
+
* @param {() => T} getter 取值方法
|
|
1317
|
+
* @param {(value: T) => void} callback 取值方法
|
|
1318
|
+
* @param {boolean} immediate 是否立即执行一次
|
|
1319
|
+
* @param {AbortSignal?} [signal]
|
|
1320
|
+
* @returns {(() => void) | void}
|
|
1321
|
+
*/
|
|
1322
|
+
declare function watch<T>(getter: () => T, callback: (value: T) => void, immediate: boolean, signal?: AbortSignal | null | undefined): (() => void) | void;
|
|
1323
|
+
/**
|
|
1324
|
+
* 创建可赋值计算值
|
|
1325
|
+
* @template T
|
|
1326
|
+
* @overload
|
|
1327
|
+
* @param {() => T} getter 取值方法
|
|
1328
|
+
* @param {(value: T) => void} callback 取值方法
|
|
1329
|
+
* @param {boolean} immediate 是否立即执行一次
|
|
1330
|
+
* @param {AbortSignal} signal
|
|
1331
|
+
* @returns {void}
|
|
1332
|
+
*/
|
|
1333
|
+
declare function watch<T>(getter: () => T, callback: (value: T) => void, immediate: boolean, signal: AbortSignal): void;
|
|
1301
1334
|
|
|
1302
1335
|
/**
|
|
1303
1336
|
* 相应式执行
|
|
1337
|
+
* @overload
|
|
1304
1338
|
* @param {() => void} fn 执行函数
|
|
1339
|
+
* @param {null} [signal]
|
|
1305
1340
|
* @returns {() => void} 取消函数
|
|
1306
1341
|
*/
|
|
1307
|
-
declare function effect(fn: () => void): () => void;
|
|
1342
|
+
declare function effect(fn: () => void, signal?: null | undefined): () => void;
|
|
1343
|
+
/**
|
|
1344
|
+
* 相应式执行
|
|
1345
|
+
* @overload
|
|
1346
|
+
* @param {() => void} fn 执行函数
|
|
1347
|
+
* @param {AbortSignal} signal
|
|
1348
|
+
* @returns {void} 取消函数
|
|
1349
|
+
*/
|
|
1350
|
+
declare function effect(fn: () => void, signal: AbortSignal): void;
|
|
1351
|
+
/**
|
|
1352
|
+
* 相应式执行
|
|
1353
|
+
* @overload
|
|
1354
|
+
* @param {() => void} fn 执行函数
|
|
1355
|
+
* @param {AbortSignal?} [signal]
|
|
1356
|
+
* @returns {(() => void) | void} 取消函数
|
|
1357
|
+
*/
|
|
1358
|
+
declare function effect(fn: () => void, signal?: AbortSignal | null | undefined): (() => void) | void;
|
|
1308
1359
|
|
|
1309
1360
|
/**
|
|
1310
1361
|
*
|
|
1362
|
+
* @template T
|
|
1311
1363
|
* @param {Store} store
|
|
1312
|
-
* @param {StoreLayout.Renderer} fieldRenderer
|
|
1364
|
+
* @param {StoreLayout.Renderer<T>} fieldRenderer
|
|
1313
1365
|
* @param {HTMLElement} root
|
|
1314
|
-
* @param {StoreLayout
|
|
1366
|
+
* @param {StoreLayout<T>} layout
|
|
1315
1367
|
* @param {StoreLayout.Options & {clone?: boolean} | null} [options]
|
|
1368
|
+
* @returns {void}
|
|
1316
1369
|
*/
|
|
1317
|
-
declare function renderStore(store: Store, fieldRenderer: StoreLayout.Renderer
|
|
1370
|
+
declare function renderStore<T>(store: Store, fieldRenderer: StoreLayout.Renderer<T>, root: HTMLElement, layout: StoreLayout<T>, options?: (StoreLayout.Options & {
|
|
1318
1371
|
clone?: boolean;
|
|
1319
|
-
}) | null):
|
|
1372
|
+
}) | null): void;
|
|
1320
1373
|
|
|
1321
|
-
export { ArrayStore,
|
|
1374
|
+
export { ArrayStore, Component, Enhancement, index_d as Layout, ObjectStore, type Ref, Schema, Store, StoreLayout, effect, render, renderStore, watch };
|