@neeloong/form 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/index.d.mts +76 -31
- package/index.js +644 -312
- package/index.min.js +4 -4
- package/index.min.mjs +4 -4
- package/index.mjs +644 -312
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -144,7 +144,7 @@ render(store, layouts, app);
|
|
|
144
144
|
|
|
145
145
|
### 别名与计算值
|
|
146
146
|
|
|
147
|
-
```
|
|
147
|
+
```html
|
|
148
148
|
<div *alias1="v1" *computed="v1 + v2"></div>
|
|
149
149
|
```
|
|
150
150
|
|
|
@@ -155,6 +155,11 @@ render(store, layouts, app);
|
|
|
155
155
|
<div +var1="123"></div>
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
+
### 增强
|
|
159
|
+
```html
|
|
160
|
+
<div ~en:attr="a" ~en@event="show($event)" ~en!bind="bindValue" ~en="value"></div>
|
|
161
|
+
|
|
162
|
+
```
|
|
158
163
|
|
|
159
164
|
### 各用法的优先级
|
|
160
165
|
|
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.9.0
|
|
3
3
|
* (c) 2024-2025 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -23,59 +23,88 @@ declare function parse(source: string, { createCalc, createEvent, simpleTag, }?:
|
|
|
23
23
|
*/
|
|
24
24
|
declare function toString(value: Node | (Node | string)[], formable?: boolean): string;
|
|
25
25
|
|
|
26
|
-
type Directives =
|
|
26
|
+
type Directives = object;
|
|
27
|
+
type Enhancement$1 = {
|
|
28
|
+
events: Record<string, Node.Name | Node.Event>;
|
|
29
|
+
attrs: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
30
|
+
value?: Node.Name | Node.Calc | Node.Value<any> | undefined;
|
|
31
|
+
bind?: string | boolean | undefined;
|
|
32
|
+
};
|
|
33
|
+
type Options = {
|
|
34
|
+
createCalc?: ((t: string) => Calc) | undefined;
|
|
35
|
+
createEvent?: ((t: string) => EventListener) | undefined;
|
|
36
|
+
simpleTag?: Set<string> | undefined;
|
|
37
|
+
};
|
|
38
|
+
type Node = {
|
|
39
|
+
name: string;
|
|
40
|
+
is?: string | null | undefined;
|
|
41
|
+
id?: string | undefined;
|
|
42
|
+
attrs: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
43
|
+
params: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
44
|
+
classes: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
45
|
+
styles: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
46
|
+
events: Record<string, Node.Name | Node.Event>;
|
|
47
|
+
vars: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
48
|
+
aliases: Record<string, Node.Name | Node.Calc | Node.Value>;
|
|
49
|
+
enhancements: Record<string, Enhancement$1>;
|
|
27
50
|
template?: string | undefined;
|
|
28
51
|
fragment?: string | boolean | undefined;
|
|
29
|
-
if?:
|
|
52
|
+
if?: Node.Name | Node.Calc | Node.Value<any> | undefined;
|
|
30
53
|
else?: boolean | undefined;
|
|
31
54
|
/**
|
|
32
|
-
*
|
|
55
|
+
* 值关联
|
|
33
56
|
*/
|
|
34
57
|
value?: string | undefined;
|
|
35
58
|
/**
|
|
36
59
|
* 列表属性枚举
|
|
37
60
|
*/
|
|
38
|
-
enum?:
|
|
61
|
+
enum?: Node.Name | Node.Calc | Node.Value<any> | undefined;
|
|
39
62
|
bind?: string | boolean | undefined;
|
|
40
|
-
text?:
|
|
41
|
-
html?:
|
|
63
|
+
text?: Node.Name | Node.Calc | Node.Value<any> | undefined;
|
|
64
|
+
html?: Node.Name | Node.Calc | Node.Value<any> | undefined;
|
|
42
65
|
/**
|
|
43
66
|
* 注释
|
|
44
67
|
*/
|
|
45
68
|
comment?: string | undefined;
|
|
46
|
-
};
|
|
47
|
-
type Options = {
|
|
48
|
-
createCalc?: ((t: string) => Calc) | undefined;
|
|
49
|
-
createEvent?: ((t: string) => EventListener) | undefined;
|
|
50
|
-
simpleTag?: Set<string> | undefined;
|
|
51
|
-
};
|
|
52
|
-
type Node = {
|
|
53
|
-
name: string;
|
|
54
|
-
is?: string | null | undefined;
|
|
55
|
-
id?: string | undefined;
|
|
56
|
-
attrs: Record<string, string | {
|
|
57
|
-
name: string;
|
|
58
|
-
} | Calc>;
|
|
59
|
-
params: Record<string, string | Calc>;
|
|
60
|
-
classes: Record<string, string | boolean | Calc>;
|
|
61
|
-
styles: Record<string, string | Calc>;
|
|
62
|
-
events: Record<string, string | EventListener>;
|
|
63
|
-
vars: Record<string, string | Calc>;
|
|
64
|
-
aliases: Record<string, string | Calc>;
|
|
65
|
-
directives: Directives;
|
|
66
69
|
children: (Node | string)[];
|
|
67
70
|
};
|
|
71
|
+
declare namespace Node {
|
|
72
|
+
type Value<T = any> = {
|
|
73
|
+
value: T;
|
|
74
|
+
name?: undefined;
|
|
75
|
+
calc?: undefined;
|
|
76
|
+
event?: undefined;
|
|
77
|
+
};
|
|
78
|
+
type Name = {
|
|
79
|
+
name: string;
|
|
80
|
+
value?: undefined;
|
|
81
|
+
calc?: undefined;
|
|
82
|
+
event?: undefined;
|
|
83
|
+
};
|
|
84
|
+
type Event = {
|
|
85
|
+
event: EventListener;
|
|
86
|
+
name?: undefined;
|
|
87
|
+
calc?: undefined;
|
|
88
|
+
value?: undefined;
|
|
89
|
+
};
|
|
90
|
+
type Calc = {
|
|
91
|
+
calc: Calc;
|
|
92
|
+
name?: undefined;
|
|
93
|
+
value?: undefined;
|
|
94
|
+
event?: undefined;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
68
97
|
type Calc = (env: Record<string, any>) => any;
|
|
69
98
|
type EventListener = ($event: any, env: Record<string, any>) => void;
|
|
70
99
|
|
|
71
100
|
type index_d_Calc = Calc;
|
|
72
101
|
type index_d_Directives = Directives;
|
|
73
102
|
type index_d_EventListener = EventListener;
|
|
74
|
-
|
|
103
|
+
declare const index_d_Node: typeof Node;
|
|
75
104
|
type index_d_Options = Options;
|
|
76
105
|
declare const index_d_parse: typeof parse;
|
|
77
106
|
declare namespace index_d {
|
|
78
|
-
export { type index_d_Calc as Calc, type index_d_Directives as Directives, type index_d_EventListener as EventListener,
|
|
107
|
+
export { type index_d_Calc as Calc, type index_d_Directives as Directives, type Enhancement$1 as Enhancement, type index_d_EventListener as EventListener, index_d_Node as Node, type index_d_Options as Options, index_d_parse as parse, toString as stringify };
|
|
79
108
|
}
|
|
80
109
|
|
|
81
110
|
type VerifyError = any;
|
|
@@ -232,6 +261,20 @@ type Relatedness = {
|
|
|
232
261
|
input?: Element | undefined;
|
|
233
262
|
root?: Element | undefined;
|
|
234
263
|
};
|
|
264
|
+
type Enhancement = (context: Enhancement.Context) => any;
|
|
265
|
+
declare namespace Enhancement {
|
|
266
|
+
type Context = {
|
|
267
|
+
events: [string, ($event: any) => void, AddEventListenerOptions][];
|
|
268
|
+
attrs: Record<string, any>;
|
|
269
|
+
watchAttr: (name: any, fn: (value: any, old: any, name: string) => void) => () => void;
|
|
270
|
+
destroyed: boolean;
|
|
271
|
+
listen: (event: "destroy", listener: () => void) => () => void;
|
|
272
|
+
tag: any;
|
|
273
|
+
root: Element;
|
|
274
|
+
slot?: Element | null | undefined;
|
|
275
|
+
value: any;
|
|
276
|
+
};
|
|
277
|
+
}
|
|
235
278
|
|
|
236
279
|
declare const ref: unique symbol;
|
|
237
280
|
type Ref = {
|
|
@@ -473,9 +516,10 @@ declare class Store<T = any> {
|
|
|
473
516
|
* @param {Record<string, Store | {get?(): any; set?(v: any): void; exec?(...p: any[]): any; calc?(...p: any[]): any }>} [options.global]
|
|
474
517
|
* @param {(path: string[]) => Component?} [options.component]
|
|
475
518
|
* @param {(store: Store, el: Element | Relatedness) => () => void} [options.relate]
|
|
519
|
+
* @param {Record<string, Enhancement>} [options.enhancements]
|
|
476
520
|
* @returns {() => void}
|
|
477
521
|
*/
|
|
478
|
-
declare function _default(store: Store, layouts: (Node | string)[], parent: Element, { component, global, relate }?: {
|
|
522
|
+
declare function _default(store: Store, layouts: (Node | string)[], parent: Element, { component, global, relate, enhancements }?: {
|
|
479
523
|
global?: Record<string, Store<any> | {
|
|
480
524
|
get?(): any;
|
|
481
525
|
set?(v: any): void;
|
|
@@ -484,6 +528,7 @@ declare function _default(store: Store, layouts: (Node | string)[], parent: Elem
|
|
|
484
528
|
}> | undefined;
|
|
485
529
|
component?: ((path: string[]) => Component | null) | undefined;
|
|
486
530
|
relate?: ((store: Store, el: Element | Relatedness) => () => void) | undefined;
|
|
531
|
+
enhancements?: Record<string, Enhancement> | undefined;
|
|
487
532
|
}): () => void;
|
|
488
533
|
|
|
489
534
|
/**
|
|
@@ -503,4 +548,4 @@ declare function watch<T>(getter: () => T, callback: (value: T) => void, immedia
|
|
|
503
548
|
*/
|
|
504
549
|
declare function effect(fn: () => void): () => void;
|
|
505
550
|
|
|
506
|
-
export { type AsyncValidator, Component, index_d as Layout, type Ref, type Relatedness, Schema, Store, type Validator, type VerifyError, effect, _default as render, watch };
|
|
551
|
+
export { type AsyncValidator, Component, Enhancement, index_d as Layout, type Ref, type Relatedness, Schema, Store, type Validator, type VerifyError, effect, _default as render, watch };
|