@microsoft/fast-element 2.0.0-beta.1 → 2.0.0-beta.11
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/CHANGELOG.json +348 -0
- package/CHANGELOG.md +114 -1
- package/dist/dts/components/attributes.d.ts +10 -0
- package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +49 -25
- package/dist/dts/components/fast-definitions.d.ts +43 -9
- package/dist/dts/components/fast-element.d.ts +15 -21
- package/dist/dts/context.d.ts +157 -0
- package/dist/dts/di/di.d.ts +899 -0
- package/dist/dts/index.d.ts +2 -2
- package/dist/dts/interfaces.d.ts +45 -14
- package/dist/dts/metadata.d.ts +25 -0
- package/dist/dts/observation/arrays.d.ts +1 -1
- package/dist/dts/observation/observable.d.ts +101 -75
- package/dist/dts/pending-task.d.ts +20 -0
- package/dist/dts/platform.d.ts +7 -0
- package/dist/dts/polyfills.d.ts +1 -8
- 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 +2 -2
- package/dist/dts/styles/element-styles.d.ts +10 -17
- 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 +69 -294
- package/dist/dts/templating/children.d.ts +1 -1
- package/dist/dts/templating/compiler.d.ts +1 -2
- package/dist/dts/templating/html-directive.d.ts +93 -35
- package/dist/dts/templating/node-observation.d.ts +4 -5
- package/dist/dts/templating/ref.d.ts +5 -13
- package/dist/dts/templating/render.d.ts +272 -0
- package/dist/dts/templating/repeat.d.ts +20 -75
- package/dist/dts/templating/slotted.d.ts +1 -1
- package/dist/dts/templating/template.d.ts +12 -61
- package/dist/dts/templating/view.d.ts +77 -12
- 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} +0 -0
- package/dist/dts/utilities.d.ts +0 -18
- package/dist/esm/components/attributes.js +13 -4
- package/dist/esm/components/{controller.js → element-controller.js} +188 -109
- package/dist/esm/components/fast-definitions.js +38 -28
- package/dist/esm/components/fast-element.js +31 -12
- package/dist/esm/context.js +163 -0
- package/dist/esm/debug.js +36 -4
- package/dist/esm/di/di.js +1435 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/interfaces.js +4 -0
- package/dist/esm/metadata.js +60 -0
- package/dist/esm/observation/arrays.js +304 -3
- package/dist/esm/observation/observable.js +81 -87
- package/dist/esm/pending-task.js +16 -0
- package/dist/esm/platform.js +26 -1
- package/dist/esm/polyfills.js +1 -55
- 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.js +4 -4
- package/dist/esm/styles/element-styles.js +14 -33
- package/dist/esm/{observation/behavior.js → styles/host.js} +0 -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 +134 -414
- package/dist/esm/templating/compiler.js +30 -7
- package/dist/esm/templating/html-directive.js +100 -28
- package/dist/esm/templating/node-observation.js +9 -8
- package/dist/esm/templating/ref.js +4 -12
- package/dist/esm/templating/render.js +391 -0
- package/dist/esm/templating/repeat.js +96 -72
- package/dist/esm/templating/template.js +11 -29
- package/dist/esm/templating/view.js +107 -29
- package/dist/esm/templating/when.js +5 -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 +0 -95
- package/dist/fast-element.api.json +9278 -10745
- package/dist/fast-element.d.ts +707 -813
- package/dist/fast-element.debug.js +1229 -944
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +1191 -938
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +716 -824
- package/docs/api-report.md +265 -319
- package/package.json +39 -14
- package/dist/dts/hooks.d.ts +0 -20
- package/dist/dts/observation/behavior.d.ts +0 -19
- package/dist/dts/observation/splice-strategies.d.ts +0 -13
- package/dist/esm/hooks.js +0 -32
- package/dist/esm/observation/splice-strategies.js +0 -400
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { HostBehavior } from "../index.js";
|
|
1
2
|
import type { Constructable } from "../interfaces.js";
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
3
|
+
import type { Subscriber } from "../observation/notifier.js";
|
|
4
|
+
import { Expression, ExpressionController, ExpressionObserver } from "../observation/observable.js";
|
|
4
5
|
/**
|
|
5
6
|
* The target nodes available to a behavior.
|
|
6
7
|
* @public
|
|
@@ -9,27 +10,65 @@ export declare type ViewBehaviorTargets = {
|
|
|
9
10
|
[id: string]: Node;
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* Controls the lifecycle of a view and provides relevant context.
|
|
13
14
|
* @public
|
|
14
15
|
*/
|
|
15
|
-
export interface
|
|
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;
|
|
16
34
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @param
|
|
19
|
-
* @param context - The execution context that the binding is operating within.
|
|
20
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
35
|
+
* Adds a behavior.
|
|
36
|
+
* @param behavior - The behavior to add.
|
|
21
37
|
*/
|
|
22
|
-
|
|
38
|
+
addBehavior(behavior: ViewBehavior): void;
|
|
23
39
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
40
|
+
* Adds a behavior factory.
|
|
41
|
+
* @param factory - The behavior factory to add.
|
|
42
|
+
* @param target - The target the factory will create behaviors for.
|
|
28
43
|
*/
|
|
29
|
-
|
|
44
|
+
addBehaviorFactory(factory: ViewBehaviorFactory, target: Node): void;
|
|
30
45
|
}
|
|
31
46
|
/**
|
|
32
|
-
*
|
|
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
|
|
33
72
|
* location within a DOM fragment.
|
|
34
73
|
* @public
|
|
35
74
|
*/
|
|
@@ -44,9 +83,8 @@ export interface ViewBehaviorFactory {
|
|
|
44
83
|
nodeId: string;
|
|
45
84
|
/**
|
|
46
85
|
* Creates a behavior.
|
|
47
|
-
* @param targets - The targets available for behaviors to be attached to.
|
|
48
86
|
*/
|
|
49
|
-
createBehavior(
|
|
87
|
+
createBehavior(): ViewBehavior;
|
|
50
88
|
}
|
|
51
89
|
/**
|
|
52
90
|
* Used to add behavior factories when constructing templates.
|
|
@@ -113,6 +151,31 @@ export declare const HTMLDirective: Readonly<{
|
|
|
113
151
|
* @public
|
|
114
152
|
*/
|
|
115
153
|
export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition): (type: Constructable<HTMLDirective>) => void;
|
|
154
|
+
/**
|
|
155
|
+
* Captures a binding expression along with related information and capabilities.
|
|
156
|
+
*
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
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
|
+
}
|
|
116
179
|
/**
|
|
117
180
|
* The type of HTML aspect to target.
|
|
118
181
|
* @public
|
|
@@ -150,8 +213,10 @@ export declare const Aspect: Readonly<{
|
|
|
150
213
|
*
|
|
151
214
|
* @param directive - The directive to assign the aspect to.
|
|
152
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.
|
|
153
218
|
*/
|
|
154
|
-
readonly assign: (directive: Aspected, value
|
|
219
|
+
readonly assign: (directive: Aspected, value?: string) => void;
|
|
155
220
|
}>;
|
|
156
221
|
/**
|
|
157
222
|
* The type of HTML aspect to target.
|
|
@@ -178,14 +243,14 @@ export interface Aspected {
|
|
|
178
243
|
/**
|
|
179
244
|
* A binding if one is associated with the aspect.
|
|
180
245
|
*/
|
|
181
|
-
|
|
246
|
+
dataBinding?: Binding;
|
|
182
247
|
}
|
|
183
248
|
/**
|
|
184
249
|
* A base class used for attribute directives that don't need internal state.
|
|
185
250
|
* @public
|
|
186
251
|
*/
|
|
187
|
-
export declare abstract class StatelessAttachedAttributeDirective<
|
|
188
|
-
protected options:
|
|
252
|
+
export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
|
|
253
|
+
protected options: TOptions;
|
|
189
254
|
/**
|
|
190
255
|
* The unique id of the factory.
|
|
191
256
|
*/
|
|
@@ -198,12 +263,7 @@ export declare abstract class StatelessAttachedAttributeDirective<T> implements
|
|
|
198
263
|
* Creates an instance of RefDirective.
|
|
199
264
|
* @param options - The options to use in configuring the directive.
|
|
200
265
|
*/
|
|
201
|
-
constructor(options:
|
|
202
|
-
/**
|
|
203
|
-
* Creates a behavior.
|
|
204
|
-
* @param targets - The targets available for behaviors to be attached to.
|
|
205
|
-
*/
|
|
206
|
-
createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
|
|
266
|
+
constructor(options: TOptions);
|
|
207
267
|
/**
|
|
208
268
|
* Creates a placeholder string based on the directive's index within the template.
|
|
209
269
|
* @param index - The index of the directive within the template.
|
|
@@ -212,15 +272,13 @@ export declare abstract class StatelessAttachedAttributeDirective<T> implements
|
|
|
212
272
|
*/
|
|
213
273
|
createHTML(add: AddViewBehaviorFactory): string;
|
|
214
274
|
/**
|
|
215
|
-
*
|
|
216
|
-
* @param
|
|
217
|
-
* @param context - The execution context that the binding is operating within.
|
|
218
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
275
|
+
* Creates a behavior.
|
|
276
|
+
* @param targets - The targets available for behaviors to be attached to.
|
|
219
277
|
*/
|
|
220
|
-
|
|
278
|
+
createBehavior(): ViewBehavior;
|
|
221
279
|
/**
|
|
222
|
-
*
|
|
223
|
-
* @param
|
|
280
|
+
* Bind this behavior.
|
|
281
|
+
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
224
282
|
*/
|
|
225
|
-
abstract
|
|
283
|
+
abstract bind(controller: ViewController): void;
|
|
226
284
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { StatelessAttachedAttributeDirective, ViewBehaviorTargets } from "./html-directive.js";
|
|
1
|
+
import { StatelessAttachedAttributeDirective, ViewController } from "./html-directive.js";
|
|
3
2
|
/**
|
|
4
3
|
* Options for configuring node observation behavior.
|
|
5
4
|
* @public
|
|
@@ -23,7 +22,7 @@ export interface NodeBehaviorOptions<T = any> {
|
|
|
23
22
|
*
|
|
24
23
|
* @public
|
|
25
24
|
*/
|
|
26
|
-
export declare type ElementsFilter = (value: Node, index
|
|
25
|
+
export declare type ElementsFilter = (value: Node, index?: number, array?: Node[]) => boolean;
|
|
27
26
|
/**
|
|
28
27
|
* Creates a function that can be used to filter a Node array, selecting only elements.
|
|
29
28
|
* @param selector - An optional selector to restrict the filter to.
|
|
@@ -44,14 +43,14 @@ export declare abstract class NodeObservationDirective<T extends NodeBehaviorOpt
|
|
|
44
43
|
* @param context - The execution context that the binding is operating within.
|
|
45
44
|
* @param targets - The targets that behaviors in a view can attach to.
|
|
46
45
|
*/
|
|
47
|
-
bind(
|
|
46
|
+
bind(controller: ViewController): void;
|
|
48
47
|
/**
|
|
49
48
|
* Unbinds this behavior from the source.
|
|
50
49
|
* @param source - The source to unbind from.
|
|
51
50
|
* @param context - The execution context that the binding is operating within.
|
|
52
51
|
* @param targets - The targets that behaviors in a view can attach to.
|
|
53
52
|
*/
|
|
54
|
-
unbind(
|
|
53
|
+
unbind(controller: ViewController): void;
|
|
55
54
|
/**
|
|
56
55
|
* Gets the data source for the target.
|
|
57
56
|
* @param target - The target to get the source for.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { StatelessAttachedAttributeDirective, ViewBehaviorTargets } from "./html-directive.js";
|
|
1
|
+
import { StatelessAttachedAttributeDirective, ViewController } from "./html-directive.js";
|
|
3
2
|
import type { CaptureType } from "./template.js";
|
|
4
3
|
/**
|
|
5
4
|
* The runtime behavior for template references.
|
|
@@ -7,21 +6,14 @@ import type { CaptureType } from "./template.js";
|
|
|
7
6
|
*/
|
|
8
7
|
export declare class RefDirective extends StatelessAttachedAttributeDirective<string> {
|
|
9
8
|
/**
|
|
10
|
-
* Bind this behavior
|
|
11
|
-
* @param
|
|
12
|
-
* @param context - The execution context that the binding is operating within.
|
|
13
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
9
|
+
* Bind this behavior.
|
|
10
|
+
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
14
11
|
*/
|
|
15
|
-
bind(
|
|
16
|
-
/**
|
|
17
|
-
* Unbinds this behavior from the source.
|
|
18
|
-
* @param source - The source to unbind from.
|
|
19
|
-
*/
|
|
20
|
-
unbind(): void;
|
|
12
|
+
bind(controller: ViewController): void;
|
|
21
13
|
}
|
|
22
14
|
/**
|
|
23
15
|
* A directive that observes the updates a property with a reference to the element.
|
|
24
16
|
* @param propertyName - The name of the property to assign the reference to.
|
|
25
17
|
* @public
|
|
26
18
|
*/
|
|
27
|
-
export declare const ref: <
|
|
19
|
+
export declare const ref: <TSource = any, TParent = any>(propertyName: keyof TSource & string) => CaptureType<TSource, TParent>;
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import type { FASTElement } from "../components/fast-element.js";
|
|
2
|
+
import { Constructable } from "../interfaces.js";
|
|
3
|
+
import type { Subscriber } from "../observation/notifier.js";
|
|
4
|
+
import type { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
|
|
5
|
+
import { ContentTemplate, ContentView } from "./binding.js";
|
|
6
|
+
import { AddViewBehaviorFactory, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
|
|
7
|
+
import { CaptureType, SyntheticViewTemplate, TemplateValue, ViewTemplate } from "./template.js";
|
|
8
|
+
/**
|
|
9
|
+
* A Behavior that enables advanced rendering.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare class RenderBehavior<TSource = any> implements ViewBehavior, Subscriber {
|
|
13
|
+
private directive;
|
|
14
|
+
private location;
|
|
15
|
+
private controller;
|
|
16
|
+
private view;
|
|
17
|
+
private template;
|
|
18
|
+
private templateBindingObserver;
|
|
19
|
+
private data;
|
|
20
|
+
private dataBindingObserver;
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instance of RenderBehavior.
|
|
23
|
+
* @param directive - The render directive that created this behavior.
|
|
24
|
+
*/
|
|
25
|
+
constructor(directive: RenderDirective);
|
|
26
|
+
/**
|
|
27
|
+
* Bind this behavior.
|
|
28
|
+
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
29
|
+
*/
|
|
30
|
+
bind(controller: ViewController): void;
|
|
31
|
+
/**
|
|
32
|
+
* Unbinds this behavior.
|
|
33
|
+
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
34
|
+
*/
|
|
35
|
+
unbind(controller: ViewController): void;
|
|
36
|
+
/** @internal */
|
|
37
|
+
handleChange(source: any, observer: ExpressionObserver): void;
|
|
38
|
+
private refreshView;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A Directive that enables use of the RenderBehavior.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare class RenderDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
|
|
45
|
+
readonly dataBinding: Binding<TSource>;
|
|
46
|
+
readonly templateBinding: Binding<TSource, ContentTemplate>;
|
|
47
|
+
readonly templateBindingDependsOnData: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The unique id of the factory.
|
|
50
|
+
*/
|
|
51
|
+
id: string;
|
|
52
|
+
/**
|
|
53
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
54
|
+
*/
|
|
55
|
+
nodeId: string;
|
|
56
|
+
/**
|
|
57
|
+
* Creates an instance of RenderDirective.
|
|
58
|
+
* @param dataBinding - A binding expression that returns the data to render.
|
|
59
|
+
* @param templateBinding - A binding expression that returns the template to use to render the data.
|
|
60
|
+
*/
|
|
61
|
+
constructor(dataBinding: Binding<TSource>, templateBinding: Binding<TSource, ContentTemplate>, templateBindingDependsOnData: boolean);
|
|
62
|
+
/**
|
|
63
|
+
* Creates HTML to be used within a template.
|
|
64
|
+
* @param add - Can be used to add behavior factories to a template.
|
|
65
|
+
*/
|
|
66
|
+
createHTML(add: AddViewBehaviorFactory): string;
|
|
67
|
+
/**
|
|
68
|
+
* Creates a behavior.
|
|
69
|
+
* @param targets - The targets available for behaviors to be attached to.
|
|
70
|
+
*/
|
|
71
|
+
createBehavior(): RenderBehavior<TSource>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Provides instructions for how to render a type.
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export interface RenderInstruction {
|
|
78
|
+
/**
|
|
79
|
+
* Identifies this as a RenderInstruction.
|
|
80
|
+
*/
|
|
81
|
+
brand: symbol;
|
|
82
|
+
/**
|
|
83
|
+
* The type this instruction is associated with.
|
|
84
|
+
*/
|
|
85
|
+
type: Constructable;
|
|
86
|
+
/**
|
|
87
|
+
* The template to use when rendering.
|
|
88
|
+
*/
|
|
89
|
+
template: ContentTemplate;
|
|
90
|
+
/**
|
|
91
|
+
* A name that can be used to identify the instruction.
|
|
92
|
+
*/
|
|
93
|
+
name: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Render options that are common to all configurations.
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
export declare type CommonRenderOptions = {
|
|
100
|
+
/**
|
|
101
|
+
* The type this instruction is associated with.
|
|
102
|
+
*/
|
|
103
|
+
type: Constructable;
|
|
104
|
+
/**
|
|
105
|
+
* A name that can be used to identify the instruction.
|
|
106
|
+
*/
|
|
107
|
+
name?: string;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Render options used to specify a template.
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export declare type TemplateRenderOptions = CommonRenderOptions & {
|
|
114
|
+
/**
|
|
115
|
+
* The template to use when rendering.
|
|
116
|
+
*/
|
|
117
|
+
template: ContentTemplate;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Render options that are common to all element render instructions.
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
export declare type BaseElementRenderOptions<TSource = any, TParent = any> = CommonRenderOptions & {
|
|
124
|
+
/**
|
|
125
|
+
* Attributes to use when creating the element template.
|
|
126
|
+
*/
|
|
127
|
+
attributes?: Record<string, string | TemplateValue<TSource, TParent>>;
|
|
128
|
+
/**
|
|
129
|
+
* Content to use when creating the element template.
|
|
130
|
+
*/
|
|
131
|
+
content?: string | SyntheticViewTemplate;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Render options used to specify an element.
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
export declare type ElementConstructorRenderOptions<TSource = any, TParent = any> = BaseElementRenderOptions<TSource, TParent> & {
|
|
138
|
+
/**
|
|
139
|
+
* The element to use when rendering.
|
|
140
|
+
*/
|
|
141
|
+
element: Constructable<FASTElement>;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Render options use to specify an element by tag name.
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
export declare type TagNameRenderOptions<TSource = any, TParent = any> = BaseElementRenderOptions<TSource, TParent> & {
|
|
148
|
+
/**
|
|
149
|
+
* The tag name to use when rendering.
|
|
150
|
+
*/
|
|
151
|
+
tagName: string;
|
|
152
|
+
};
|
|
153
|
+
declare function createElementTemplate<TSource = any, TParent = any>(tagName: string, attributes?: Record<string, string | TemplateValue<TSource, TParent>>, content?: string | ContentTemplate): ViewTemplate<TSource, TParent>;
|
|
154
|
+
declare function create(options: TagNameRenderOptions): RenderInstruction;
|
|
155
|
+
declare function create(options: ElementConstructorRenderOptions): RenderInstruction;
|
|
156
|
+
declare function create(options: TemplateRenderOptions): RenderInstruction;
|
|
157
|
+
declare function instanceOf(object: any): object is RenderInstruction;
|
|
158
|
+
declare function register(options: TagNameRenderOptions): RenderInstruction;
|
|
159
|
+
declare function register(options: ElementConstructorRenderOptions): RenderInstruction;
|
|
160
|
+
declare function register(options: TemplateRenderOptions): RenderInstruction;
|
|
161
|
+
declare function register(instruction: RenderInstruction): RenderInstruction;
|
|
162
|
+
declare function getByType(type: Constructable, name?: string): RenderInstruction | undefined;
|
|
163
|
+
declare function getForInstance(object: any, name?: string): RenderInstruction | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Provides APIs for creating and interacting with render instructions.
|
|
166
|
+
* @public
|
|
167
|
+
*/
|
|
168
|
+
export declare const RenderInstruction: Readonly<{
|
|
169
|
+
/**
|
|
170
|
+
* Checks whether the provided object is a RenderInstruction.
|
|
171
|
+
* @param object - The object to check.
|
|
172
|
+
* @returns true if the object is a RenderInstruction; false otherwise
|
|
173
|
+
*/
|
|
174
|
+
instanceOf: typeof instanceOf;
|
|
175
|
+
/**
|
|
176
|
+
* Creates a RenderInstruction for a set of options.
|
|
177
|
+
* @param options - The options to use when creating the RenderInstruction.
|
|
178
|
+
*/
|
|
179
|
+
create: typeof create;
|
|
180
|
+
/**
|
|
181
|
+
* Creates a template based on a tag name.
|
|
182
|
+
* @param tagName - The tag name to use when creating the template.
|
|
183
|
+
* @param attributes - The attributes to apply to the element.
|
|
184
|
+
* @param content - The content to insert into the element.
|
|
185
|
+
* @returns A template based on the provided specifications.
|
|
186
|
+
*/
|
|
187
|
+
createElementTemplate: typeof createElementTemplate;
|
|
188
|
+
/**
|
|
189
|
+
* Creates and registers an instruction.
|
|
190
|
+
* @param options The options to use when creating the RenderInstruction.
|
|
191
|
+
* @remarks
|
|
192
|
+
* A previously created RenderInstruction can also be registered.
|
|
193
|
+
*/
|
|
194
|
+
register: typeof register;
|
|
195
|
+
/**
|
|
196
|
+
* Finds a previously registered RenderInstruction by type and optionally by name.
|
|
197
|
+
* @param type - The type to retrieve the RenderInstruction for.
|
|
198
|
+
* @param name - An optional name used in differentiating between multiple registered instructions.
|
|
199
|
+
* @returns The located RenderInstruction that matches the criteria or undefined if none is found.
|
|
200
|
+
*/
|
|
201
|
+
getByType: typeof getByType;
|
|
202
|
+
/**
|
|
203
|
+
* Finds a previously registered RenderInstruction for the instance's type and optionally by name.
|
|
204
|
+
* @param object - The instance to retrieve the RenderInstruction for.
|
|
205
|
+
* @param name - An optional name used in differentiating between multiple registered instructions.
|
|
206
|
+
* @returns The located RenderInstruction that matches the criteria or undefined if none is found.
|
|
207
|
+
*/
|
|
208
|
+
getForInstance: typeof getForInstance;
|
|
209
|
+
}>;
|
|
210
|
+
/**
|
|
211
|
+
* Decorates a type with render instruction metadata.
|
|
212
|
+
* @param options - The options used in creating the RenderInstruction.
|
|
213
|
+
* @public
|
|
214
|
+
*/
|
|
215
|
+
export declare function renderWith(options: Omit<TagNameRenderOptions, "type">): ClassDecorator;
|
|
216
|
+
/**
|
|
217
|
+
* Decorates a type with render instruction metadata.
|
|
218
|
+
* @param options - The options used in creating the RenderInstruction.
|
|
219
|
+
* @public
|
|
220
|
+
*/
|
|
221
|
+
export declare function renderWith(options: Omit<ElementConstructorRenderOptions, "type">): ClassDecorator;
|
|
222
|
+
/**
|
|
223
|
+
* Decorates a type with render instruction metadata.
|
|
224
|
+
* @param options - The options used in creating the RenderInstruction.
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
227
|
+
export declare function renderWith(options: Omit<TemplateRenderOptions, "type">): ClassDecorator;
|
|
228
|
+
/**
|
|
229
|
+
* Decorates a type with render instruction metadata.
|
|
230
|
+
* @param element - The element to use to render the decorated class.
|
|
231
|
+
* @param name - An optional name to differentiate the render instruction.
|
|
232
|
+
* @public
|
|
233
|
+
*/
|
|
234
|
+
export declare function renderWith(element: Constructable<FASTElement>, name?: string): ClassDecorator;
|
|
235
|
+
/**
|
|
236
|
+
* Decorates a type with render instruction metadata.
|
|
237
|
+
* @param template - The template to use to render the decorated class.
|
|
238
|
+
* @param name - An optional name to differentiate the render instruction.
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
export declare function renderWith(template: ContentTemplate, name?: string): ClassDecorator;
|
|
242
|
+
/**
|
|
243
|
+
* @internal
|
|
244
|
+
*/
|
|
245
|
+
export declare class NodeTemplate implements ContentTemplate, ContentView {
|
|
246
|
+
readonly node: Node;
|
|
247
|
+
constructor(node: Node);
|
|
248
|
+
get context(): ExecutionContext<any>;
|
|
249
|
+
bind(source: any): void;
|
|
250
|
+
unbind(): void;
|
|
251
|
+
insertBefore(refNode: Node): void;
|
|
252
|
+
remove(): void;
|
|
253
|
+
create(): ContentView;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Creates a RenderDirective for use in advanced rendering scenarios.
|
|
257
|
+
* @param value - The binding expression that returns the data to be rendered. The expression
|
|
258
|
+
* can also return a Node to render directly.
|
|
259
|
+
* @param template - A template to render the data with
|
|
260
|
+
* or a string to indicate which RenderInstruction to use when looking up a RenderInstruction.
|
|
261
|
+
* Expressions can also be provided to dynamically determine either the template or the name.
|
|
262
|
+
* @returns A RenderDirective suitable for use in a template.
|
|
263
|
+
* @remarks
|
|
264
|
+
* If no binding is provided, then a default binding that returns the source is created.
|
|
265
|
+
* If no template is provided, then a binding is created that will use registered
|
|
266
|
+
* RenderInstructions to determine the view.
|
|
267
|
+
* If the template binding returns a string, then it will be used to look up a
|
|
268
|
+
* RenderInstruction to determine the view.
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
export declare function render<TSource = any, TItem = any, TParent = any>(value?: Expression<TSource, TItem> | Binding<TSource, TItem> | {}, template?: ContentTemplate | string | Expression<TSource, ContentTemplate | string | Node, TParent> | Binding<TSource, ContentTemplate | string | Node, TParent>): CaptureType<TSource, TParent>;
|
|
272
|
+
export {};
|