@microsoft/fast-element 1.10.0 → 2.0.0-beta.1
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 +396 -1
- package/CHANGELOG.md +68 -2
- package/README.md +2 -2
- package/dist/dts/components/attributes.d.ts +4 -1
- package/dist/dts/components/controller.d.ts +12 -11
- package/dist/dts/components/fast-definitions.d.ts +8 -2
- package/dist/dts/components/fast-element.d.ts +5 -4
- package/dist/dts/debug.d.ts +1 -0
- package/dist/dts/hooks.d.ts +20 -0
- package/dist/dts/index.d.ts +16 -15
- 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 +144 -0
- package/dist/dts/observation/arrays.d.ts +207 -0
- package/dist/dts/observation/behavior.d.ts +5 -5
- package/dist/dts/observation/notifier.d.ts +18 -18
- package/dist/dts/observation/observable.d.ts +86 -29
- package/dist/dts/observation/splice-strategies.d.ts +13 -0
- package/dist/dts/observation/update-queue.d.ts +40 -0
- package/dist/dts/platform.d.ts +18 -67
- package/dist/dts/polyfills.d.ts +8 -0
- package/dist/dts/styles/css-directive.d.ts +43 -5
- package/dist/dts/styles/css.d.ts +19 -3
- package/dist/dts/styles/element-styles.d.ts +42 -62
- package/dist/dts/templating/binding.d.ts +320 -64
- package/dist/dts/templating/children.d.ts +18 -15
- package/dist/dts/templating/compiler.d.ts +47 -28
- package/dist/dts/templating/dom.d.ts +41 -0
- package/dist/dts/templating/html-directive.d.ts +179 -43
- package/dist/dts/templating/markup.d.ts +48 -0
- package/dist/dts/templating/node-observation.d.ts +45 -29
- package/dist/dts/templating/ref.d.ts +6 -12
- package/dist/dts/templating/repeat.d.ts +72 -14
- package/dist/dts/templating/slotted.d.ts +13 -14
- package/dist/dts/templating/template.d.ts +78 -23
- package/dist/dts/templating/view.d.ts +16 -23
- package/dist/dts/utilities.d.ts +40 -0
- package/dist/esm/components/attributes.js +25 -24
- package/dist/esm/components/controller.js +77 -57
- package/dist/esm/components/fast-definitions.js +14 -22
- package/dist/esm/debug.js +29 -0
- package/dist/esm/hooks.js +32 -0
- package/dist/esm/index.debug.js +2 -0
- package/dist/esm/index.js +19 -14
- package/dist/esm/index.rollup.debug.js +3 -0
- package/dist/esm/index.rollup.js +2 -0
- package/dist/esm/interfaces.js +8 -1
- package/dist/esm/observation/arrays.js +269 -0
- package/dist/esm/observation/notifier.js +75 -83
- package/dist/esm/observation/observable.js +80 -107
- package/dist/esm/observation/{array-change-records.js → splice-strategies.js} +136 -62
- package/dist/esm/observation/update-queue.js +67 -0
- package/dist/esm/platform.js +36 -42
- package/dist/esm/polyfills.js +85 -0
- package/dist/esm/styles/css-directive.js +29 -13
- package/dist/esm/styles/css.js +27 -40
- package/dist/esm/styles/element-styles.js +65 -104
- package/dist/esm/templating/binding.js +465 -155
- package/dist/esm/templating/children.js +33 -23
- package/dist/esm/templating/compiler.js +235 -152
- package/dist/esm/templating/dom.js +49 -0
- package/dist/esm/templating/html-directive.js +125 -40
- package/dist/esm/templating/markup.js +75 -0
- package/dist/esm/templating/node-observation.js +50 -45
- package/dist/esm/templating/ref.js +7 -16
- package/dist/esm/templating/repeat.js +38 -43
- package/dist/esm/templating/slotted.js +23 -20
- package/dist/esm/templating/template.js +71 -95
- package/dist/esm/templating/view.js +44 -43
- package/dist/esm/templating/when.js +2 -1
- package/dist/esm/utilities.js +139 -0
- package/dist/fast-element.api.json +14062 -5235
- package/dist/fast-element.d.ts +1434 -579
- package/dist/fast-element.debug.js +3824 -0
- package/dist/fast-element.debug.min.js +1 -0
- package/dist/fast-element.js +3565 -4014
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +2908 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/docs/api-report.md +590 -231
- package/docs/fast-element-2-changes.md +15 -0
- package/docs/guide/declaring-templates.md +5 -4
- package/docs/guide/defining-elements.md +3 -2
- package/docs/guide/leveraging-css.md +1 -0
- package/docs/guide/next-steps.md +3 -2
- package/docs/guide/observables-and-state.md +2 -1
- package/docs/guide/using-directives.md +2 -1
- package/docs/guide/working-with-shadow-dom.md +1 -0
- package/karma.conf.cjs +6 -17
- package/package.json +48 -14
- 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/esm/dom.js +0 -207
- package/dist/esm/observation/array-observer.js +0 -173
|
@@ -1,95 +1,351 @@
|
|
|
1
|
-
import type { Behavior } from "../observation/behavior.js";
|
|
2
1
|
import { Binding, BindingObserver, ExecutionContext } from "../observation/observable.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
declare function normalUnbind(this: BindingBehavior): void;
|
|
6
|
-
declare function updatePropertyTarget(this: BindingBehavior, value: unknown): void;
|
|
2
|
+
import { AddViewBehaviorFactory, Aspect, Aspected, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewBehaviorTargets } from "./html-directive.js";
|
|
3
|
+
import type { CaptureType } from "./template.js";
|
|
7
4
|
/**
|
|
8
|
-
*
|
|
5
|
+
* Describes how aspects of an HTML element will be affected by bindings.
|
|
9
6
|
* @public
|
|
10
7
|
*/
|
|
11
|
-
export declare
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
private updateTarget;
|
|
18
|
-
private isBindingVolatile;
|
|
8
|
+
export declare type BindingMode = Record<Aspect, (directive: HTMLBindingDirective) => Pick<ViewBehaviorFactory, "createBehavior">>;
|
|
9
|
+
/**
|
|
10
|
+
* Describes how aspects of an HTML element will be affected by bindings.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const BindingMode: Readonly<{
|
|
19
14
|
/**
|
|
20
|
-
* Creates
|
|
21
|
-
* @param
|
|
15
|
+
* Creates a binding mode based on the supplied behavior types.
|
|
16
|
+
* @param UpdateType - The base behavior type used to update aspects.
|
|
17
|
+
* @param EventType - The base behavior type used to respond to events.
|
|
18
|
+
* @returns A new binding mode.
|
|
22
19
|
*/
|
|
23
|
-
|
|
20
|
+
define(UpdateType: typeof UpdateBinding, EventType?: typeof EventBinding): BindingMode;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Describes the configuration for a binding expression.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export interface BindingConfig<T = any> {
|
|
24
27
|
/**
|
|
25
|
-
*
|
|
26
|
-
* binding is targeting.
|
|
28
|
+
* The binding mode to configure the binding with.
|
|
27
29
|
*/
|
|
28
|
-
|
|
29
|
-
set targetName(value: string | undefined);
|
|
30
|
+
mode: BindingMode;
|
|
30
31
|
/**
|
|
31
|
-
*
|
|
32
|
-
* a particular attribute or property.
|
|
32
|
+
* Options to be supplied to the binding behaviors.
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
options: T;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new binding configuration based on the supplied options.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare type BindingConfigResolver<T> = (options: T) => BindingConfig<T>;
|
|
41
|
+
/**
|
|
42
|
+
* Describes the configuration for a binding expression.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export declare const BindingConfig: Readonly<{
|
|
46
|
+
/**
|
|
47
|
+
* Creates a binding configuration based on the provided mode and options.
|
|
48
|
+
* @param mode - The mode to use for the configuration.
|
|
49
|
+
* @param defaultOptions - The default options to use for the configuration.
|
|
50
|
+
* @returns A new binding configuration.
|
|
51
|
+
*/
|
|
52
|
+
define<T>(mode: BindingMode, defaultOptions: T): BindingConfig<T> & BindingConfigResolver<T>;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* The "this" context for an update target function.
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export interface UpdateTargetThis {
|
|
35
59
|
/**
|
|
36
|
-
*
|
|
37
|
-
* information stored in the BindingDirective.
|
|
38
|
-
* @param target - The target node that the binding behavior should attach to.
|
|
60
|
+
* The directive configuration for the update.
|
|
39
61
|
*/
|
|
40
|
-
|
|
62
|
+
directive: HTMLBindingDirective;
|
|
41
63
|
}
|
|
42
64
|
/**
|
|
43
|
-
* A
|
|
44
|
-
*
|
|
65
|
+
* A target update function.
|
|
66
|
+
* @param this - The "this" context for the update.
|
|
67
|
+
* @param target - The node that is targeted by the update.
|
|
68
|
+
* @param aspect - The aspect of the node that is being targeted.
|
|
69
|
+
* @param value - The value to assign to the aspect.
|
|
70
|
+
* @param source - The source object that the value was derived from.
|
|
71
|
+
* @param context - The execution context that the binding is being run under.
|
|
45
72
|
* @public
|
|
46
73
|
*/
|
|
47
|
-
export declare
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
binding: Binding;
|
|
62
|
-
/** @internal */
|
|
63
|
-
isBindingVolatile: boolean;
|
|
64
|
-
/** @internal */
|
|
65
|
-
updateTarget: typeof updatePropertyTarget;
|
|
66
|
-
/** @internal */
|
|
67
|
-
targetName?: string;
|
|
74
|
+
export declare type UpdateTarget = (this: UpdateTargetThis, target: Node, aspect: string, value: any, source: any, context: ExecutionContext) => void;
|
|
75
|
+
/**
|
|
76
|
+
* A base binding behavior for DOM updates.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export declare class UpdateBinding implements ViewBehavior {
|
|
80
|
+
readonly directive: HTMLBindingDirective;
|
|
81
|
+
protected updateTarget: UpdateTarget;
|
|
82
|
+
/**
|
|
83
|
+
* Creates an instance of UpdateBinding.
|
|
84
|
+
* @param directive - The directive that has the configuration for this behavior.
|
|
85
|
+
* @param updateTarget - The function used to update the target with the latest value.
|
|
86
|
+
*/
|
|
87
|
+
constructor(directive: HTMLBindingDirective, updateTarget: UpdateTarget);
|
|
68
88
|
/**
|
|
69
89
|
* Bind this behavior to the source.
|
|
70
90
|
* @param source - The source to bind to.
|
|
71
91
|
* @param context - The execution context that the binding is operating within.
|
|
92
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
72
93
|
*/
|
|
73
|
-
bind:
|
|
94
|
+
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
74
95
|
/**
|
|
75
96
|
* Unbinds this behavior from the source.
|
|
76
97
|
* @param source - The source to unbind from.
|
|
98
|
+
* @param context - The execution context that the binding is operating within.
|
|
99
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
77
100
|
*/
|
|
78
|
-
unbind:
|
|
101
|
+
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
79
102
|
/**
|
|
80
|
-
* Creates
|
|
81
|
-
* @param
|
|
82
|
-
* @param binding - The binding that returns the latest value for an update.
|
|
83
|
-
* @param isBindingVolatile - Indicates whether the binding has volatile dependencies.
|
|
84
|
-
* @param bind - The operation to perform during binding.
|
|
85
|
-
* @param unbind - The operation to perform during unbinding.
|
|
86
|
-
* @param updateTarget - The operation to perform when updating.
|
|
87
|
-
* @param targetName - The name of the target attribute or property to update.
|
|
103
|
+
* Creates a behavior.
|
|
104
|
+
* @param targets - The targets available for behaviors to be attached to.
|
|
88
105
|
*/
|
|
89
|
-
|
|
106
|
+
createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A binding behavior for one-time bindings.
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
export declare class OneTimeBinding extends UpdateBinding {
|
|
113
|
+
/**
|
|
114
|
+
* Bind this behavior to the source.
|
|
115
|
+
* @param source - The source to bind to.
|
|
116
|
+
* @param context - The execution context that the binding is operating within.
|
|
117
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
118
|
+
*/
|
|
119
|
+
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* A binding behavior for signal bindings.
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
export declare class SignalBinding extends UpdateBinding {
|
|
126
|
+
private handlerProperty;
|
|
127
|
+
/**
|
|
128
|
+
* Bind this behavior to the source.
|
|
129
|
+
* @param source - The source to bind to.
|
|
130
|
+
* @param context - The execution context that the binding is operating within.
|
|
131
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
132
|
+
*/
|
|
133
|
+
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
134
|
+
/**
|
|
135
|
+
* Unbinds this behavior from the source.
|
|
136
|
+
* @param source - The source to unbind from.
|
|
137
|
+
* @param context - The execution context that the binding is operating within.
|
|
138
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
139
|
+
*/
|
|
140
|
+
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
141
|
+
private getSignal;
|
|
142
|
+
/**
|
|
143
|
+
* Sends the specified signal to signaled bindings.
|
|
144
|
+
* @param signal - The signal to send.
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
static send(signal: string): void;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* A binding behavior for bindings that change.
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
export declare class ChangeBinding extends UpdateBinding {
|
|
154
|
+
private isBindingVolatile;
|
|
155
|
+
private observerProperty;
|
|
156
|
+
/**
|
|
157
|
+
* Creates an instance of ChangeBinding.
|
|
158
|
+
* @param directive - The directive that has the configuration for this behavior.
|
|
159
|
+
* @param updateTarget - The function used to update the target with the latest value.
|
|
160
|
+
*/
|
|
161
|
+
constructor(directive: HTMLBindingDirective, updateTarget: UpdateTarget);
|
|
162
|
+
/**
|
|
163
|
+
* Returns the binding observer used to update the node.
|
|
164
|
+
* @param target - The target node.
|
|
165
|
+
* @returns A BindingObserver.
|
|
166
|
+
*/
|
|
167
|
+
protected getObserver(target: Node): BindingObserver;
|
|
168
|
+
/**
|
|
169
|
+
* Bind this behavior to the source.
|
|
170
|
+
* @param source - The source to bind to.
|
|
171
|
+
* @param context - The execution context that the binding is operating within.
|
|
172
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
173
|
+
*/
|
|
174
|
+
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
175
|
+
/**
|
|
176
|
+
* Unbinds this behavior from the source.
|
|
177
|
+
* @param source - The source to unbind from.
|
|
178
|
+
* @param context - The execution context that the binding is operating within.
|
|
179
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
180
|
+
*/
|
|
181
|
+
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
90
182
|
/** @internal */
|
|
91
|
-
handleChange(): void;
|
|
183
|
+
handleChange(binding: Binding, observer: BindingObserver): void;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* A binding behavior for handling events.
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
export declare class EventBinding {
|
|
190
|
+
readonly directive: HTMLBindingDirective;
|
|
191
|
+
private contextProperty;
|
|
192
|
+
private sourceProperty;
|
|
193
|
+
/**
|
|
194
|
+
* Creates an instance of EventBinding.
|
|
195
|
+
* @param directive - The directive that has the configuration for this behavior.
|
|
196
|
+
*/
|
|
197
|
+
constructor(directive: HTMLBindingDirective);
|
|
198
|
+
/**
|
|
199
|
+
* Bind this behavior to the source.
|
|
200
|
+
* @param source - The source to bind to.
|
|
201
|
+
* @param context - The execution context that the binding is operating within.
|
|
202
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
203
|
+
*/
|
|
204
|
+
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
205
|
+
/**
|
|
206
|
+
* Unbinds this behavior from the source.
|
|
207
|
+
* @param source - The source to unbind from.
|
|
208
|
+
* @param context - The execution context that the binding is operating within.
|
|
209
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
210
|
+
*/
|
|
211
|
+
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
212
|
+
/**
|
|
213
|
+
* Creates a behavior.
|
|
214
|
+
* @param targets - The targets available for behaviors to be attached to.
|
|
215
|
+
*/
|
|
216
|
+
createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
|
|
217
|
+
/**
|
|
218
|
+
* @internal
|
|
219
|
+
*/
|
|
220
|
+
handleEvent(event: Event): void;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* The settings required to enable two-way binding.
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
export interface TwoWaySettings {
|
|
227
|
+
/**
|
|
228
|
+
* Determines which event to listen to, to detect changes in the view.
|
|
229
|
+
* @param directive - The directive to determine the change event for.
|
|
230
|
+
* @param target - The target element to determine the change event for.
|
|
231
|
+
*/
|
|
232
|
+
determineChangeEvent(directive: HTMLBindingDirective, target: HTMLElement): string;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* A binding behavior for bindings that update in two directions.
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
238
|
+
export declare class TwoWayBinding extends ChangeBinding {
|
|
239
|
+
private changeEvent;
|
|
240
|
+
/**
|
|
241
|
+
* Bind this behavior to the source.
|
|
242
|
+
* @param source - The source to bind to.
|
|
243
|
+
* @param context - The execution context that the binding is operating within.
|
|
244
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
245
|
+
*/
|
|
246
|
+
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
247
|
+
/**
|
|
248
|
+
* Unbinds this behavior from the source.
|
|
249
|
+
* @param source - The source to unbind from.
|
|
250
|
+
* @param context - The execution context that the binding is operating within.
|
|
251
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
252
|
+
*/
|
|
253
|
+
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
92
254
|
/** @internal */
|
|
93
255
|
handleEvent(event: Event): void;
|
|
256
|
+
/**
|
|
257
|
+
* Configures two-way binding.
|
|
258
|
+
* @param settings - The settings to use for the two-way binding system.
|
|
259
|
+
*/
|
|
260
|
+
static configure(settings: TwoWaySettings): void;
|
|
94
261
|
}
|
|
95
|
-
|
|
262
|
+
/**
|
|
263
|
+
* The default binding options.
|
|
264
|
+
* @public
|
|
265
|
+
*/
|
|
266
|
+
export declare type DefaultBindingOptions = AddEventListenerOptions;
|
|
267
|
+
/**
|
|
268
|
+
* The default onChange binding configuration.
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
export declare const onChange: BindingConfig<AddEventListenerOptions> & BindingConfigResolver<AddEventListenerOptions>;
|
|
272
|
+
/**
|
|
273
|
+
* The default twoWay binding options.
|
|
274
|
+
* @public
|
|
275
|
+
*/
|
|
276
|
+
export declare type DefaultTwoWayBindingOptions = DefaultBindingOptions & {
|
|
277
|
+
changeEvent?: string;
|
|
278
|
+
fromView?: (value: any) => any;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* The default twoWay binding configuration.
|
|
282
|
+
* @public
|
|
283
|
+
*/
|
|
284
|
+
export declare const twoWay: BindingConfig<DefaultTwoWayBindingOptions> & BindingConfigResolver<DefaultTwoWayBindingOptions>;
|
|
285
|
+
/**
|
|
286
|
+
* The default onTime binding configuration.
|
|
287
|
+
* @public
|
|
288
|
+
*/
|
|
289
|
+
export declare const oneTime: BindingConfig<AddEventListenerOptions> & BindingConfigResolver<AddEventListenerOptions>;
|
|
290
|
+
/**
|
|
291
|
+
* Creates a signal binding configuration with the supplied options.
|
|
292
|
+
* @param options - The signal name or a binding to use to retrieve the signal name.
|
|
293
|
+
* @returns A binding configuration.
|
|
294
|
+
* @public
|
|
295
|
+
*/
|
|
296
|
+
export declare const signal: <T = any>(options: string | Binding<T, any, ExecutionContext<any>>) => BindingConfig<string | Binding<T, any, ExecutionContext<any>>>;
|
|
297
|
+
/**
|
|
298
|
+
* A directive that applies bindings.
|
|
299
|
+
* @public
|
|
300
|
+
*/
|
|
301
|
+
export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, Aspected {
|
|
302
|
+
binding: Binding;
|
|
303
|
+
mode: BindingMode;
|
|
304
|
+
options: any;
|
|
305
|
+
private factory;
|
|
306
|
+
/**
|
|
307
|
+
* The unique id of the factory.
|
|
308
|
+
*/
|
|
309
|
+
id: string;
|
|
310
|
+
/**
|
|
311
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
312
|
+
*/
|
|
313
|
+
nodeId: string;
|
|
314
|
+
/**
|
|
315
|
+
* The original source aspect exactly as represented in markup.
|
|
316
|
+
*/
|
|
317
|
+
sourceAspect: string;
|
|
318
|
+
/**
|
|
319
|
+
* The evaluated target aspect, determined after processing the source.
|
|
320
|
+
*/
|
|
321
|
+
targetAspect: string;
|
|
322
|
+
/**
|
|
323
|
+
* The type of aspect to target.
|
|
324
|
+
*/
|
|
325
|
+
aspectType: Aspect;
|
|
326
|
+
/**
|
|
327
|
+
* Creates an instance of HTMLBindingDirective.
|
|
328
|
+
* @param binding - The binding to apply.
|
|
329
|
+
* @param mode - The binding mode to use when applying the binding.
|
|
330
|
+
* @param options - The options to configure the binding with.
|
|
331
|
+
*/
|
|
332
|
+
constructor(binding: Binding, mode: BindingMode, options: any);
|
|
333
|
+
/**
|
|
334
|
+
* Creates HTML to be used within a template.
|
|
335
|
+
* @param add - Can be used to add behavior factories to a template.
|
|
336
|
+
*/
|
|
337
|
+
createHTML(add: AddViewBehaviorFactory): string;
|
|
338
|
+
/**
|
|
339
|
+
* Creates a behavior.
|
|
340
|
+
* @param targets - The targets available for behaviors to be attached to.
|
|
341
|
+
*/
|
|
342
|
+
createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Creates a binding directive with the specified configuration.
|
|
346
|
+
* @param binding - The binding expression.
|
|
347
|
+
* @param config - The binding configuration.
|
|
348
|
+
* @returns A binding directive.
|
|
349
|
+
* @public
|
|
350
|
+
*/
|
|
351
|
+
export declare function bind<T = any>(binding: Binding<T>, config?: BindingConfig | DefaultBindingOptions): CaptureType<T>;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { NodeBehaviorOptions,
|
|
1
|
+
import { NodeBehaviorOptions, NodeObservationDirective } from "./node-observation.js";
|
|
2
2
|
import type { CaptureType } from "./template.js";
|
|
3
3
|
/**
|
|
4
4
|
* The options used to configure child list observation.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export interface
|
|
7
|
+
export interface ChildListDirectiveOptions<T = any> extends NodeBehaviorOptions<T>, Omit<MutationObserverInit, "subtree" | "childList"> {
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* The options used to configure subtree observation.
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
13
|
-
export interface
|
|
13
|
+
export interface SubtreeDirectiveOptions<T = any> extends NodeBehaviorOptions<T>, Omit<MutationObserverInit, "subtree" | "childList"> {
|
|
14
14
|
/**
|
|
15
15
|
* Indicates that child subtrees should be observed for changes.
|
|
16
16
|
*/
|
|
@@ -25,31 +25,34 @@ export interface SubtreeBehaviorOptions<T = any> extends Omit<NodeBehaviorOption
|
|
|
25
25
|
* The options used to configure child/subtree node observation.
|
|
26
26
|
* @public
|
|
27
27
|
*/
|
|
28
|
-
export declare type
|
|
28
|
+
export declare type ChildrenDirectiveOptions<T = any> = ChildListDirectiveOptions<T> | SubtreeDirectiveOptions<T>;
|
|
29
29
|
/**
|
|
30
30
|
* The runtime behavior for child node observation.
|
|
31
31
|
* @public
|
|
32
32
|
*/
|
|
33
|
-
export declare class
|
|
34
|
-
private
|
|
33
|
+
export declare class ChildrenDirective extends NodeObservationDirective<ChildrenDirectiveOptions> {
|
|
34
|
+
private observerProperty;
|
|
35
35
|
/**
|
|
36
|
-
* Creates an instance of
|
|
37
|
-
* @param
|
|
38
|
-
* @param options - The options to use when observing the element children.
|
|
36
|
+
* Creates an instance of ChildrenDirective.
|
|
37
|
+
* @param options - The options to use in configuring the child observation behavior.
|
|
39
38
|
*/
|
|
40
|
-
constructor(
|
|
39
|
+
constructor(options: ChildrenDirectiveOptions);
|
|
41
40
|
/**
|
|
42
41
|
* Begins observation of the nodes.
|
|
42
|
+
* @param target - The target to observe.
|
|
43
43
|
*/
|
|
44
|
-
observe(): void;
|
|
44
|
+
observe(target: any): void;
|
|
45
45
|
/**
|
|
46
46
|
* Disconnects observation of the nodes.
|
|
47
|
+
* @param target - The target to unobserve.
|
|
47
48
|
*/
|
|
48
|
-
disconnect(): void;
|
|
49
|
+
disconnect(target: any): void;
|
|
49
50
|
/**
|
|
50
|
-
* Retrieves the nodes that should be assigned to the
|
|
51
|
+
* Retrieves the raw nodes that should be assigned to the source property.
|
|
52
|
+
* @param target - The target to get the node to.
|
|
51
53
|
*/
|
|
52
|
-
|
|
54
|
+
getNodes(target: Element): Node[];
|
|
55
|
+
private handleEvent;
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
58
|
* A directive that observes the `childNodes` of an element and updates a property
|
|
@@ -57,4 +60,4 @@ export declare class ChildrenBehavior extends NodeObservationBehavior<ChildrenBe
|
|
|
57
60
|
* @param propertyOrOptions - The options used to configure child node observation.
|
|
58
61
|
* @public
|
|
59
62
|
*/
|
|
60
|
-
export declare function children<T = any>(propertyOrOptions: (keyof T & string) |
|
|
63
|
+
export declare function children<T = any>(propertyOrOptions: (keyof T & string) | ChildrenDirectiveOptions<keyof T & string>): CaptureType<T>;
|
|
@@ -1,38 +1,57 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TrustedTypesPolicy } from "../interfaces.js";
|
|
2
|
+
import type { ExecutionContext } from "../observation/observable.js";
|
|
3
|
+
import { ViewBehaviorFactory } from "./html-directive.js";
|
|
4
|
+
import type { HTMLTemplateCompilationResult as TemplateCompilationResult } from "./template.js";
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
6
|
+
* A function capable of compiling a template from the preprocessed form produced
|
|
7
|
+
* by the html template function into a result that can instantiate views.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare type CompilationStrategy = (
|
|
11
|
+
/**
|
|
12
|
+
* The preprocessed HTML string or template to compile.
|
|
5
13
|
*/
|
|
6
|
-
|
|
14
|
+
html: string | HTMLTemplateElement,
|
|
15
|
+
/**
|
|
16
|
+
* The behavior factories used within the html that is being compiled.
|
|
17
|
+
*/
|
|
18
|
+
factories: Record<string, ViewBehaviorFactory>) => TemplateCompilationResult;
|
|
19
|
+
/**
|
|
20
|
+
* Common APIs related to compilation.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare const Compiler: {
|
|
7
24
|
/**
|
|
8
|
-
*
|
|
25
|
+
* Sets the HTML trusted types policy used by the compiler.
|
|
26
|
+
* @param policy - The policy to set for HTML.
|
|
27
|
+
* @remarks
|
|
28
|
+
* This API can only be called once, for security reasons. It should be
|
|
29
|
+
* called by the application developer at the start of their program.
|
|
9
30
|
*/
|
|
10
|
-
|
|
31
|
+
setHTMLPolicy(policy: TrustedTypesPolicy): void;
|
|
11
32
|
/**
|
|
12
|
-
*
|
|
33
|
+
* Compiles a template and associated directives into a compilation
|
|
34
|
+
* result which can be used to create views.
|
|
35
|
+
* @param html - The html string or template element to compile.
|
|
36
|
+
* @param directives - The directives referenced by the template.
|
|
37
|
+
* @remarks
|
|
38
|
+
* The template that is provided for compilation is altered in-place
|
|
39
|
+
* and cannot be compiled again. If the original template must be preserved,
|
|
40
|
+
* it is recommended that you clone the original and pass the clone to this API.
|
|
41
|
+
* @public
|
|
13
42
|
*/
|
|
14
|
-
|
|
43
|
+
compile<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext<TParent>>(html: string | HTMLTemplateElement, directives: Record<string, ViewBehaviorFactory>): TemplateCompilationResult<TSource, TParent, TContext>;
|
|
15
44
|
/**
|
|
16
|
-
*
|
|
17
|
-
* the template
|
|
45
|
+
* Sets the default compilation strategy that will be used by the ViewTemplate whenever
|
|
46
|
+
* it needs to compile a view preprocessed with the html template function.
|
|
47
|
+
* @param strategy - The compilation strategy to use when compiling templates.
|
|
18
48
|
*/
|
|
19
|
-
|
|
49
|
+
setDefaultStrategy(strategy: CompilationStrategy): void;
|
|
20
50
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
51
|
+
* Aggregates an array of strings and directives into a single directive.
|
|
52
|
+
* @param parts - A heterogeneous array of static strings interspersed with
|
|
53
|
+
* directives.
|
|
54
|
+
* @returns A single inline directive that aggregates the behavior of all the parts.
|
|
23
55
|
*/
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Compiles a template and associated directives into a raw compilation
|
|
28
|
-
* result which include a cloneable DocumentFragment and factories capable
|
|
29
|
-
* of attaching runtime behavior to nodes within the fragment.
|
|
30
|
-
* @param template - The template to compile.
|
|
31
|
-
* @param directives - The directives referenced by the template.
|
|
32
|
-
* @remarks
|
|
33
|
-
* The template that is provided for compilation is altered in-place
|
|
34
|
-
* and cannot be compiled again. If the original template must be preserved,
|
|
35
|
-
* it is recommended that you clone the original and pass the clone to this API.
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
export declare function compileTemplate(template: HTMLTemplateElement, directives: ReadonlyArray<HTMLDirective>): CompilationResult;
|
|
56
|
+
aggregate(parts: (string | ViewBehaviorFactory)[]): ViewBehaviorFactory;
|
|
57
|
+
};
|
|
@@ -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
|
+
}>;
|