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