@microsoft/fast-element 1.10.5 → 2.0.0-beta.10
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/.eslintrc.json +1 -12
- package/CHANGELOG.json +629 -6
- package/CHANGELOG.md +152 -5
- package/dist/dts/components/attributes.d.ts +14 -1
- package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +32 -32
- package/dist/dts/components/fast-definitions.d.ts +51 -11
- package/dist/dts/components/fast-element.d.ts +18 -23
- package/dist/dts/context.d.ts +157 -0
- package/dist/{esm/observation/behavior.js → dts/debug.d.ts} +0 -0
- package/dist/dts/di/di.d.ts +899 -0
- package/dist/dts/index.d.ts +17 -16
- package/dist/dts/index.debug.d.ts +2 -0
- package/dist/dts/index.rollup.d.ts +2 -0
- package/dist/dts/index.rollup.debug.d.ts +3 -0
- package/dist/dts/interfaces.d.ts +176 -0
- package/dist/dts/metadata.d.ts +25 -0
- package/dist/dts/observation/arrays.d.ts +207 -0
- package/dist/dts/observation/notifier.d.ts +18 -18
- package/dist/dts/observation/observable.d.ts +117 -34
- package/dist/dts/observation/update-queue.d.ts +40 -0
- package/dist/dts/pending-task.d.ts +20 -0
- package/dist/dts/platform.d.ts +23 -66
- package/dist/dts/polyfills.d.ts +8 -0
- package/dist/dts/state/exports.d.ts +3 -0
- package/dist/dts/state/reactive.d.ts +8 -0
- package/dist/dts/state/state.d.ts +141 -0
- package/dist/dts/state/visitor.d.ts +6 -0
- package/dist/dts/state/watch.d.ts +10 -0
- package/dist/dts/styles/css-directive.d.ts +44 -6
- package/dist/dts/styles/css.d.ts +19 -3
- package/dist/dts/styles/element-styles.d.ts +49 -63
- package/dist/dts/styles/host.d.ts +68 -0
- package/dist/dts/templating/binding-signal.d.ts +21 -0
- package/dist/dts/templating/binding-two-way.d.ts +39 -0
- package/dist/dts/templating/binding.d.ts +101 -70
- package/dist/dts/templating/children.d.ts +18 -15
- package/dist/dts/templating/compiler.d.ts +46 -28
- package/dist/dts/templating/dom.d.ts +41 -0
- package/dist/dts/templating/html-directive.d.ts +239 -45
- package/dist/dts/templating/markup.d.ts +48 -0
- package/dist/dts/templating/node-observation.d.ts +45 -30
- package/dist/dts/templating/ref.d.ts +6 -20
- package/dist/dts/templating/render.d.ts +272 -0
- package/dist/dts/templating/repeat.d.ts +36 -33
- package/dist/dts/templating/slotted.d.ts +13 -14
- package/dist/dts/templating/template.d.ts +28 -22
- package/dist/dts/templating/view.d.ts +82 -24
- package/dist/dts/templating/when.d.ts +3 -3
- package/dist/dts/testing/exports.d.ts +3 -0
- package/dist/dts/testing/fakes.d.ts +4 -0
- package/dist/dts/testing/fixture.d.ts +84 -0
- package/dist/dts/testing/timeout.d.ts +7 -0
- package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +1 -1
- package/dist/dts/utilities.d.ts +22 -0
- package/dist/esm/components/attributes.js +38 -28
- package/dist/esm/components/{controller.js → element-controller.js} +150 -140
- package/dist/esm/components/fast-definitions.js +48 -46
- package/dist/esm/components/fast-element.js +31 -12
- package/dist/esm/context.js +163 -0
- package/dist/esm/debug.js +61 -0
- package/dist/esm/di/di.js +1435 -0
- package/dist/esm/index.debug.js +2 -0
- package/dist/esm/index.js +20 -14
- package/dist/esm/index.rollup.debug.js +3 -0
- package/dist/esm/index.rollup.js +2 -0
- package/dist/esm/interfaces.js +12 -1
- package/dist/esm/metadata.js +60 -0
- package/dist/esm/observation/arrays.js +570 -0
- package/dist/esm/observation/notifier.js +27 -35
- package/dist/esm/observation/observable.js +116 -149
- package/dist/esm/observation/update-queue.js +67 -0
- package/dist/esm/pending-task.js +16 -0
- package/dist/esm/platform.js +60 -42
- package/dist/esm/polyfills.js +85 -0
- package/dist/esm/state/exports.js +3 -0
- package/dist/esm/state/reactive.js +34 -0
- package/dist/esm/state/state.js +148 -0
- package/dist/esm/state/visitor.js +28 -0
- package/dist/esm/state/watch.js +36 -0
- package/dist/esm/styles/css-directive.js +29 -13
- package/dist/esm/styles/css.js +29 -42
- package/dist/esm/styles/element-styles.js +79 -104
- package/dist/esm/styles/host.js +1 -0
- package/dist/esm/templating/binding-signal.js +83 -0
- package/dist/esm/templating/binding-two-way.js +103 -0
- package/dist/esm/templating/binding.js +189 -159
- package/dist/esm/templating/children.js +33 -23
- package/dist/esm/templating/compiler.js +258 -152
- package/dist/esm/templating/dom.js +49 -0
- package/dist/esm/templating/html-directive.js +193 -36
- package/dist/esm/templating/markup.js +75 -0
- package/dist/esm/templating/node-observation.js +51 -45
- package/dist/esm/templating/ref.js +8 -25
- package/dist/esm/templating/render.js +391 -0
- package/dist/esm/templating/repeat.js +83 -79
- package/dist/esm/templating/slotted.js +23 -20
- package/dist/esm/templating/template.js +51 -93
- package/dist/esm/templating/view.js +125 -46
- package/dist/esm/templating/when.js +6 -4
- package/dist/esm/testing/exports.js +3 -0
- package/dist/esm/testing/fakes.js +76 -0
- package/dist/esm/testing/fixture.js +86 -0
- package/dist/esm/testing/timeout.js +24 -0
- package/dist/esm/utilities.js +44 -0
- package/dist/fast-element.api.json +12153 -5373
- package/dist/fast-element.d.ts +1448 -696
- package/dist/fast-element.debug.js +4107 -0
- package/dist/fast-element.debug.min.js +1 -0
- package/dist/fast-element.js +3817 -4029
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +2814 -0
- package/docs/api-report.md +567 -254
- package/docs/fast-element-2-changes.md +15 -0
- package/karma.conf.cjs +6 -17
- package/package.json +76 -15
- package/dist/dts/dom.d.ts +0 -112
- package/dist/dts/observation/array-change-records.d.ts +0 -48
- package/dist/dts/observation/array-observer.d.ts +0 -9
- package/dist/dts/observation/behavior.d.ts +0 -19
- package/dist/esm/dom.js +0 -207
- package/dist/esm/observation/array-change-records.js +0 -326
- package/dist/esm/observation/array-observer.js +0 -177
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Callable } from "../interfaces.js";
|
|
2
|
+
/**
|
|
3
|
+
* Common DOM APIs.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare const DOM: Readonly<{
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
* Use Updates.enqueue().
|
|
10
|
+
*/
|
|
11
|
+
queueUpdate: (callable: Callable) => void;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated
|
|
14
|
+
* Use Updates.next()
|
|
15
|
+
*/
|
|
16
|
+
nextUpdate: () => Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated
|
|
19
|
+
* Use Updates.process()
|
|
20
|
+
*/
|
|
21
|
+
processUpdates: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Sets an attribute value on an element.
|
|
24
|
+
* @param element - The element to set the attribute value on.
|
|
25
|
+
* @param attributeName - The attribute name to set.
|
|
26
|
+
* @param value - The value of the attribute to set.
|
|
27
|
+
* @remarks
|
|
28
|
+
* If the value is `null` or `undefined`, the attribute is removed, otherwise
|
|
29
|
+
* it is set to the provided value using the standard `setAttribute` API.
|
|
30
|
+
*/
|
|
31
|
+
setAttribute(element: HTMLElement, attributeName: string, value: any): void;
|
|
32
|
+
/**
|
|
33
|
+
* Sets a boolean attribute value.
|
|
34
|
+
* @param element - The element to set the boolean attribute value on.
|
|
35
|
+
* @param attributeName - The attribute name to set.
|
|
36
|
+
* @param value - The value of the attribute to set.
|
|
37
|
+
* @remarks
|
|
38
|
+
* If the value is true, the attribute is added; otherwise it is removed.
|
|
39
|
+
*/
|
|
40
|
+
setBooleanAttribute(element: HTMLElement, attributeName: string, value: boolean): void;
|
|
41
|
+
}>;
|
|
@@ -1,90 +1,284 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HostBehavior } from "../index.js";
|
|
2
|
+
import type { Constructable } from "../interfaces.js";
|
|
3
|
+
import type { Subscriber } from "../observation/notifier.js";
|
|
4
|
+
import { Expression, ExpressionController, ExpressionObserver } from "../observation/observable.js";
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
6
|
+
* The target nodes available to a behavior.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare type ViewBehaviorTargets = {
|
|
10
|
+
[id: string]: Node;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Controls the lifecycle of a view and provides relevant context.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface ViewController<TSource = any, TParent = any> extends ExpressionController<TSource, TParent> {
|
|
17
|
+
/**
|
|
18
|
+
* The parts of the view that are targeted by view behaviors.
|
|
19
|
+
*/
|
|
20
|
+
readonly targets: ViewBehaviorTargets;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Bridges between ViewBehaviors and HostBehaviors, enabling a host to
|
|
24
|
+
* control ViewBehaviors.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export interface ViewBehaviorOrchestrator<TSource = any, TParent = any> extends ViewController<TSource, TParent>, HostBehavior<TSource> {
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param nodeId - The structural id of the DOM node to which a behavior will apply.
|
|
31
|
+
* @param target - The DOM node associated with the id.
|
|
32
|
+
*/
|
|
33
|
+
addTarget(nodeId: string, target: Node): void;
|
|
34
|
+
/**
|
|
35
|
+
* Adds a behavior.
|
|
36
|
+
* @param behavior - The behavior to add.
|
|
37
|
+
*/
|
|
38
|
+
addBehavior(behavior: ViewBehavior): void;
|
|
39
|
+
/**
|
|
40
|
+
* Adds a behavior factory.
|
|
41
|
+
* @param factory - The behavior factory to add.
|
|
42
|
+
* @param target - The target the factory will create behaviors for.
|
|
43
|
+
*/
|
|
44
|
+
addBehaviorFactory(factory: ViewBehaviorFactory, target: Node): void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Bridges between ViewBehaviors and HostBehaviors, enabling a host to
|
|
48
|
+
* control ViewBehaviors.
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export declare const ViewBehaviorOrchestrator: Readonly<{
|
|
52
|
+
/**
|
|
53
|
+
* Creates a ViewBehaviorOrchestrator.
|
|
54
|
+
* @param source - The source to to associate behaviors with.
|
|
55
|
+
* @returns A ViewBehaviorOrchestrator.
|
|
56
|
+
*/
|
|
57
|
+
create<TSource = any, TParent = any>(source: TSource): ViewBehaviorOrchestrator<TSource, TParent>;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Represents an object that can contribute behavior to a view.
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
export interface ViewBehavior<TSource = any, TParent = any> {
|
|
64
|
+
/**
|
|
65
|
+
* Bind this behavior.
|
|
66
|
+
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
67
|
+
*/
|
|
68
|
+
bind(controller: ViewController<TSource, TParent>): void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A factory that can create a {@link ViewBehavior} associated with a particular
|
|
4
72
|
* location within a DOM fragment.
|
|
5
73
|
* @public
|
|
6
74
|
*/
|
|
7
|
-
export interface
|
|
75
|
+
export interface ViewBehaviorFactory {
|
|
76
|
+
/**
|
|
77
|
+
* The unique id of the factory.
|
|
78
|
+
*/
|
|
79
|
+
id: string;
|
|
8
80
|
/**
|
|
9
|
-
* The
|
|
81
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
10
82
|
*/
|
|
11
|
-
|
|
83
|
+
nodeId: string;
|
|
12
84
|
/**
|
|
13
|
-
* Creates a behavior
|
|
14
|
-
* @param target - The node instance to create the behavior for.
|
|
85
|
+
* Creates a behavior.
|
|
15
86
|
*/
|
|
16
|
-
createBehavior(
|
|
87
|
+
createBehavior(): ViewBehavior;
|
|
17
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Used to add behavior factories when constructing templates.
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
export declare type AddViewBehaviorFactory = (factory: ViewBehaviorFactory) => string;
|
|
18
94
|
/**
|
|
19
95
|
* Instructs the template engine to apply behavior to a node.
|
|
20
96
|
* @public
|
|
21
97
|
*/
|
|
22
|
-
export
|
|
98
|
+
export interface HTMLDirective {
|
|
23
99
|
/**
|
|
24
|
-
*
|
|
100
|
+
* Creates HTML to be used within a template.
|
|
101
|
+
* @param add - Can be used to add behavior factories to a template.
|
|
25
102
|
*/
|
|
26
|
-
|
|
103
|
+
createHTML(add: AddViewBehaviorFactory): string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Represents metadata configuration for an HTMLDirective.
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export interface PartialHTMLDirectiveDefinition {
|
|
27
110
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
111
|
+
* Indicates whether the directive needs access to template contextual information
|
|
112
|
+
* such as the sourceAspect, targetAspect, and aspectType.
|
|
30
113
|
*/
|
|
31
|
-
|
|
114
|
+
aspected?: boolean;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Defines metadata for an HTMLDirective.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
export interface HTMLDirectiveDefinition<TType extends Constructable<HTMLDirective> = Constructable<HTMLDirective>> extends Required<PartialHTMLDirectiveDefinition> {
|
|
32
121
|
/**
|
|
33
|
-
*
|
|
34
|
-
* @param target - The node instance to create the behavior for.
|
|
122
|
+
* The type that the definition provides metadata for.
|
|
35
123
|
*/
|
|
36
|
-
|
|
124
|
+
readonly type: TType;
|
|
37
125
|
}
|
|
38
126
|
/**
|
|
39
|
-
*
|
|
127
|
+
* Instructs the template engine to apply behavior to a node.
|
|
40
128
|
* @public
|
|
41
129
|
*/
|
|
42
|
-
export declare
|
|
130
|
+
export declare const HTMLDirective: Readonly<{
|
|
43
131
|
/**
|
|
44
|
-
* Gets
|
|
45
|
-
* directive
|
|
132
|
+
* Gets the directive definition associated with the instance.
|
|
133
|
+
* @param instance - The directive instance to retrieve the definition for.
|
|
46
134
|
*/
|
|
47
|
-
|
|
135
|
+
getForInstance: (object: any) => HTMLDirectiveDefinition<Constructable<HTMLDirective>> | undefined;
|
|
48
136
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param
|
|
137
|
+
* Gets the directive definition associated with the specified type.
|
|
138
|
+
* @param type - The directive type to retrieve the definition for.
|
|
51
139
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
140
|
+
getByType: (key: Function) => HTMLDirectiveDefinition<Constructable<HTMLDirective>> | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Defines an HTMLDirective based on the options.
|
|
143
|
+
* @param type - The type to define as a directive.
|
|
144
|
+
* @param options - Options that specify the directive's application.
|
|
145
|
+
*/
|
|
146
|
+
define<TType extends Constructable<HTMLDirective>>(type: TType, options?: PartialHTMLDirectiveDefinition): TType;
|
|
147
|
+
}>;
|
|
54
148
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
149
|
+
* Decorator: Defines an HTMLDirective.
|
|
150
|
+
* @param options - Provides options that specify the directive's application.
|
|
57
151
|
* @public
|
|
58
152
|
*/
|
|
59
|
-
export declare
|
|
153
|
+
export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition): (type: Constructable<HTMLDirective>) => void;
|
|
60
154
|
/**
|
|
61
|
-
*
|
|
155
|
+
* Captures a binding expression along with related information and capabilities.
|
|
156
|
+
*
|
|
62
157
|
* @public
|
|
63
158
|
*/
|
|
64
|
-
export declare class
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
159
|
+
export declare abstract class Binding<TSource = any, TReturn = any, TParent = any> {
|
|
160
|
+
evaluate: Expression<TSource, TReturn, TParent>;
|
|
161
|
+
isVolatile: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Options associated with the binding.
|
|
164
|
+
*/
|
|
165
|
+
options?: any;
|
|
166
|
+
/**
|
|
167
|
+
* Creates a binding.
|
|
168
|
+
* @param evaluate - Evaluates the binding.
|
|
169
|
+
* @param isVolatile - Indicates whether the binding is volatile.
|
|
170
|
+
*/
|
|
171
|
+
constructor(evaluate: Expression<TSource, TReturn, TParent>, isVolatile?: boolean);
|
|
172
|
+
/**
|
|
173
|
+
* Creates an observer capable of notifying a subscriber when the output of a binding changes.
|
|
174
|
+
* @param directive - The HTML Directive to create the observer for.
|
|
175
|
+
* @param subscriber - The subscriber to changes in the binding.
|
|
176
|
+
*/
|
|
177
|
+
abstract createObserver(directive: HTMLDirective, subscriber: Subscriber): ExpressionObserver<TSource, TReturn, TParent>;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The type of HTML aspect to target.
|
|
181
|
+
* @public
|
|
182
|
+
*/
|
|
183
|
+
export declare const Aspect: Readonly<{
|
|
184
|
+
/**
|
|
185
|
+
* Not aspected.
|
|
186
|
+
*/
|
|
187
|
+
readonly none: 0;
|
|
188
|
+
/**
|
|
189
|
+
* An attribute.
|
|
190
|
+
*/
|
|
191
|
+
readonly attribute: 1;
|
|
192
|
+
/**
|
|
193
|
+
* A boolean attribute.
|
|
194
|
+
*/
|
|
195
|
+
readonly booleanAttribute: 2;
|
|
196
|
+
/**
|
|
197
|
+
* A property.
|
|
198
|
+
*/
|
|
199
|
+
readonly property: 3;
|
|
200
|
+
/**
|
|
201
|
+
* Content
|
|
202
|
+
*/
|
|
203
|
+
readonly content: 4;
|
|
204
|
+
/**
|
|
205
|
+
* A token list.
|
|
206
|
+
*/
|
|
207
|
+
readonly tokenList: 5;
|
|
208
|
+
/**
|
|
209
|
+
* An event.
|
|
210
|
+
*/
|
|
211
|
+
readonly event: 6;
|
|
68
212
|
/**
|
|
69
213
|
*
|
|
70
|
-
* @param
|
|
71
|
-
* @param
|
|
72
|
-
* @
|
|
214
|
+
* @param directive - The directive to assign the aspect to.
|
|
215
|
+
* @param value - The value to base the aspect determination on.
|
|
216
|
+
* @remarks
|
|
217
|
+
* If a falsy value is provided, then the content aspect will be assigned.
|
|
218
|
+
*/
|
|
219
|
+
readonly assign: (directive: Aspected, value?: string) => void;
|
|
220
|
+
}>;
|
|
221
|
+
/**
|
|
222
|
+
* The type of HTML aspect to target.
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
export declare type Aspect = typeof Aspect[Exclude<keyof typeof Aspect, "assign" | "none">];
|
|
226
|
+
/**
|
|
227
|
+
* Represents something that applies to a specific aspect of the DOM.
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
export interface Aspected {
|
|
231
|
+
/**
|
|
232
|
+
* The original source aspect exactly as represented in markup.
|
|
233
|
+
*/
|
|
234
|
+
sourceAspect: string;
|
|
235
|
+
/**
|
|
236
|
+
* The evaluated target aspect, determined after processing the source.
|
|
237
|
+
*/
|
|
238
|
+
targetAspect: string;
|
|
239
|
+
/**
|
|
240
|
+
* The type of aspect to target.
|
|
241
|
+
*/
|
|
242
|
+
aspectType: Aspect;
|
|
243
|
+
/**
|
|
244
|
+
* A binding if one is associated with the aspect.
|
|
73
245
|
*/
|
|
74
|
-
|
|
246
|
+
dataBinding?: Binding;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* A base class used for attribute directives that don't need internal state.
|
|
250
|
+
* @public
|
|
251
|
+
*/
|
|
252
|
+
export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
|
|
253
|
+
protected options: TOptions;
|
|
254
|
+
/**
|
|
255
|
+
* The unique id of the factory.
|
|
256
|
+
*/
|
|
257
|
+
id: string;
|
|
258
|
+
/**
|
|
259
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
260
|
+
*/
|
|
261
|
+
nodeId: string;
|
|
262
|
+
/**
|
|
263
|
+
* Creates an instance of RefDirective.
|
|
264
|
+
* @param options - The options to use in configuring the directive.
|
|
265
|
+
*/
|
|
266
|
+
constructor(options: TOptions);
|
|
75
267
|
/**
|
|
76
268
|
* Creates a placeholder string based on the directive's index within the template.
|
|
77
269
|
* @param index - The index of the directive within the template.
|
|
78
270
|
* @remarks
|
|
79
271
|
* Creates a custom attribute placeholder.
|
|
80
272
|
*/
|
|
81
|
-
|
|
273
|
+
createHTML(add: AddViewBehaviorFactory): string;
|
|
82
274
|
/**
|
|
83
|
-
* Creates a behavior
|
|
84
|
-
* @param
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
275
|
+
* Creates a behavior.
|
|
276
|
+
* @param targets - The targets available for behaviors to be attached to.
|
|
277
|
+
*/
|
|
278
|
+
createBehavior(): ViewBehavior;
|
|
279
|
+
/**
|
|
280
|
+
* Bind this behavior.
|
|
281
|
+
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
88
282
|
*/
|
|
89
|
-
|
|
283
|
+
abstract bind(controller: ViewController): void;
|
|
90
284
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ViewBehaviorFactory } from "./html-directive.js";
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare const nextId: () => string;
|
|
4
|
+
/**
|
|
5
|
+
* Common APIs related to markup generation.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare const Markup: Readonly<{
|
|
9
|
+
/**
|
|
10
|
+
* Creates a placeholder string suitable for marking out a location *within*
|
|
11
|
+
* an attribute value or HTML content.
|
|
12
|
+
* @param index - The directive index to create the placeholder for.
|
|
13
|
+
* @remarks
|
|
14
|
+
* Used internally by binding directives.
|
|
15
|
+
*/
|
|
16
|
+
interpolation: (id: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a placeholder that manifests itself as an attribute on an
|
|
19
|
+
* element.
|
|
20
|
+
* @param attributeName - The name of the custom attribute.
|
|
21
|
+
* @param index - The directive index to create the placeholder for.
|
|
22
|
+
* @remarks
|
|
23
|
+
* Used internally by attribute directives such as `ref`, `slotted`, and `children`.
|
|
24
|
+
*/
|
|
25
|
+
attribute: (id: string) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a placeholder that manifests itself as a marker within the DOM structure.
|
|
28
|
+
* @param index - The directive index to create the placeholder for.
|
|
29
|
+
* @remarks
|
|
30
|
+
* Used internally by structural directives such as `repeat`.
|
|
31
|
+
*/
|
|
32
|
+
comment: (id: string) => string;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Common APIs related to content parsing.
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare const Parser: Readonly<{
|
|
39
|
+
/**
|
|
40
|
+
* Parses text content or HTML attribute content, separating out the static strings
|
|
41
|
+
* from the directives.
|
|
42
|
+
* @param value - The content or attribute string to parse.
|
|
43
|
+
* @param factories - A list of directives to search for in the string.
|
|
44
|
+
* @returns A heterogeneous array of static strings interspersed with
|
|
45
|
+
* directives or null if no directives are found in the string.
|
|
46
|
+
*/
|
|
47
|
+
parse(value: string, factories: Record<string, ViewBehaviorFactory>): (string | ViewBehaviorFactory)[] | null;
|
|
48
|
+
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { StatelessAttachedAttributeDirective, ViewController } from "./html-directive.js";
|
|
2
2
|
/**
|
|
3
3
|
* Options for configuring node observation behavior.
|
|
4
4
|
* @public
|
|
@@ -22,53 +22,68 @@ export interface NodeBehaviorOptions<T = any> {
|
|
|
22
22
|
*
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
|
-
export declare type ElementsFilter = (value: Node, index
|
|
25
|
+
export declare type ElementsFilter = (value: Node, index?: number, array?: Node[]) => boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Creates a function that can be used to filter a Node array, selecting only elements.
|
|
28
28
|
* @param selector - An optional selector to restrict the filter to.
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
31
|
-
export declare
|
|
31
|
+
export declare const elements: (selector?: string) => ElementsFilter;
|
|
32
32
|
/**
|
|
33
33
|
* A base class for node observation.
|
|
34
|
-
* @
|
|
34
|
+
* @public
|
|
35
|
+
* @remarks
|
|
36
|
+
* Internally used by the SlottedDirective and the ChildrenDirective.
|
|
35
37
|
*/
|
|
36
|
-
export declare abstract class
|
|
37
|
-
|
|
38
|
-
protected options: T;
|
|
39
|
-
private source;
|
|
40
|
-
private shouldUpdate;
|
|
38
|
+
export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
|
|
39
|
+
private sourceProperty;
|
|
41
40
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
41
|
+
* Bind this behavior to the source.
|
|
42
|
+
* @param source - The source to bind to.
|
|
43
|
+
* @param context - The execution context that the binding is operating within.
|
|
44
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
bind(controller: ViewController): void;
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Unbinds this behavior from the source.
|
|
49
|
+
* @param source - The source to unbind from.
|
|
50
|
+
* @param context - The execution context that the binding is operating within.
|
|
51
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
49
52
|
*/
|
|
50
|
-
|
|
53
|
+
unbind(controller: ViewController): void;
|
|
51
54
|
/**
|
|
52
|
-
*
|
|
55
|
+
* Gets the data source for the target.
|
|
56
|
+
* @param target - The target to get the source for.
|
|
57
|
+
* @returns The source.
|
|
53
58
|
*/
|
|
54
|
-
|
|
59
|
+
protected getSource(target: Node): any;
|
|
55
60
|
/**
|
|
56
|
-
*
|
|
61
|
+
* Updates the source property with the computed nodes.
|
|
62
|
+
* @param source - The source object to assign the nodes property to.
|
|
63
|
+
* @param value - The nodes to assign to the source object property.
|
|
57
64
|
*/
|
|
58
|
-
protected
|
|
65
|
+
protected updateTarget(source: any, value: ReadonlyArray<any>): void;
|
|
59
66
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @param
|
|
62
|
-
* @
|
|
67
|
+
* Computes the set of nodes that should be assigned to the source property.
|
|
68
|
+
* @param target - The target to compute the nodes for.
|
|
69
|
+
* @returns The computed nodes.
|
|
70
|
+
* @remarks
|
|
71
|
+
* Applies filters if provided.
|
|
63
72
|
*/
|
|
64
|
-
|
|
73
|
+
protected computeNodes(target: any): Node[];
|
|
65
74
|
/**
|
|
66
|
-
*
|
|
67
|
-
* @param
|
|
75
|
+
* Begins observation of the nodes.
|
|
76
|
+
* @param target - The target to observe.
|
|
77
|
+
*/
|
|
78
|
+
protected abstract observe(target: any): void;
|
|
79
|
+
/**
|
|
80
|
+
* Disconnects observation of the nodes.
|
|
81
|
+
* @param target - The target to unobserve.
|
|
82
|
+
*/
|
|
83
|
+
protected abstract disconnect(target: any): void;
|
|
84
|
+
/**
|
|
85
|
+
* Retrieves the raw nodes that should be assigned to the source property.
|
|
86
|
+
* @param target - The target to get the node to.
|
|
68
87
|
*/
|
|
69
|
-
|
|
70
|
-
/** @internal */
|
|
71
|
-
handleEvent(): void;
|
|
72
|
-
private computeNodes;
|
|
73
|
-
private updateTarget;
|
|
88
|
+
protected abstract getNodes(target: any): Node[];
|
|
74
89
|
}
|
|
@@ -1,33 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { StatelessAttachedAttributeDirective, ViewController } from "./html-directive.js";
|
|
2
2
|
import type { CaptureType } from "./template.js";
|
|
3
3
|
/**
|
|
4
4
|
* The runtime behavior for template references.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export declare class
|
|
8
|
-
private target;
|
|
9
|
-
private propertyName;
|
|
7
|
+
export declare class RefDirective extends StatelessAttachedAttributeDirective<string> {
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param propertyName - The name of the property to assign the reference to.
|
|
9
|
+
* Bind this behavior.
|
|
10
|
+
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
14
11
|
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Bind this behavior to the source.
|
|
18
|
-
* @param source - The source to bind to.
|
|
19
|
-
* @param context - The execution context that the binding is operating within.
|
|
20
|
-
*/
|
|
21
|
-
bind(source: any): void;
|
|
22
|
-
/**
|
|
23
|
-
* Unbinds this behavior from the source.
|
|
24
|
-
* @param source - The source to unbind from.
|
|
25
|
-
*/
|
|
26
|
-
unbind(): void;
|
|
12
|
+
bind(controller: ViewController): void;
|
|
27
13
|
}
|
|
28
14
|
/**
|
|
29
15
|
* A directive that observes the updates a property with a reference to the element.
|
|
30
16
|
* @param propertyName - The name of the property to assign the reference to.
|
|
31
17
|
* @public
|
|
32
18
|
*/
|
|
33
|
-
export declare
|
|
19
|
+
export declare const ref: <TSource = any, TParent = any>(propertyName: keyof TSource & string) => CaptureType<TSource, TParent>;
|