@microsoft/fast-element 2.0.0-beta.2 → 2.0.0-beta.20
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 +488 -0
- package/CHANGELOG.md +180 -1
- package/dist/dts/components/attributes.d.ts +15 -0
- package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +74 -28
- package/dist/dts/components/fast-definitions.d.ts +41 -9
- package/dist/dts/components/fast-element.d.ts +14 -26
- package/dist/dts/components/hydration.d.ts +14 -0
- package/dist/{esm/observation/behavior.js → dts/components/install-hydration.d.ts} +0 -0
- package/dist/dts/context.d.ts +1 -1
- package/dist/dts/di/di.d.ts +894 -0
- package/dist/dts/dom-policy.d.ts +68 -0
- package/dist/dts/dom.d.ts +100 -0
- package/dist/dts/index.d.ts +5 -4
- package/dist/dts/index.rollup.d.ts +0 -1
- package/dist/dts/index.rollup.debug.d.ts +0 -1
- package/dist/dts/interfaces.d.ts +60 -79
- package/dist/dts/observation/observable.d.ts +99 -54
- package/dist/dts/pending-task.d.ts +20 -0
- package/dist/dts/platform.d.ts +7 -0
- package/dist/dts/polyfills.d.ts +0 -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/css.d.ts +0 -5
- package/dist/dts/styles/element-styles.d.ts +10 -17
- package/dist/dts/styles/host.d.ts +68 -0
- package/dist/dts/styles/style-strategy.d.ts +42 -0
- package/dist/dts/templating/binding-signal.d.ts +12 -27
- package/dist/dts/templating/binding-two-way.d.ts +22 -37
- package/dist/dts/templating/binding.d.ts +76 -208
- package/dist/dts/templating/children.d.ts +1 -1
- package/dist/dts/templating/compiler.d.ts +11 -13
- package/dist/dts/templating/html-directive.d.ts +91 -97
- package/dist/dts/templating/node-observation.d.ts +15 -6
- package/dist/dts/templating/ref.d.ts +7 -11
- package/dist/dts/templating/render.d.ts +296 -0
- package/dist/dts/templating/repeat.d.ts +23 -34
- package/dist/dts/templating/slotted.d.ts +1 -1
- package/dist/dts/templating/template.d.ts +92 -14
- package/dist/dts/templating/view.d.ts +81 -11
- 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 +14 -0
- package/dist/dts/testing/fixture.d.ts +84 -0
- package/dist/dts/testing/timeout.d.ts +7 -0
- package/dist/dts/utilities.d.ts +53 -18
- package/dist/esm/components/attributes.js +28 -5
- package/dist/esm/components/{controller.js → element-controller.js} +239 -137
- package/dist/esm/components/fast-definitions.js +38 -30
- package/dist/esm/components/fast-element.js +27 -16
- package/dist/esm/components/hydration.js +35 -0
- package/dist/esm/components/install-hydration.js +2 -0
- package/dist/esm/context.js +5 -1
- package/dist/esm/debug.js +40 -5
- package/dist/esm/di/di.js +1430 -0
- package/dist/esm/dom-policy.js +337 -0
- package/dist/esm/dom.js +101 -0
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.rollup.debug.js +3 -1
- package/dist/esm/index.rollup.js +3 -1
- package/dist/esm/interfaces.js +52 -0
- package/dist/esm/observation/arrays.js +303 -2
- package/dist/esm/observation/observable.js +88 -142
- package/dist/esm/observation/update-queue.js +2 -2
- package/dist/esm/pending-task.js +16 -0
- package/dist/esm/platform.js +27 -2
- package/dist/esm/polyfills.js +3 -61
- 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 -9
- package/dist/esm/styles/element-styles.js +14 -33
- package/dist/esm/styles/host.js +1 -0
- package/dist/esm/styles/style-strategy.js +1 -0
- package/dist/esm/templating/binding-signal.js +67 -62
- package/dist/esm/templating/binding-two-way.js +72 -39
- package/dist/esm/templating/binding.js +142 -286
- package/dist/esm/templating/children.js +8 -4
- package/dist/esm/templating/compiler.js +59 -43
- package/dist/esm/templating/html-directive.js +56 -75
- package/dist/esm/templating/node-observation.js +20 -13
- package/dist/esm/templating/ref.js +4 -12
- package/dist/esm/templating/render.js +402 -0
- package/dist/esm/templating/repeat.js +88 -75
- package/dist/esm/templating/template.js +132 -60
- package/dist/esm/templating/view.js +113 -29
- package/dist/esm/templating/when.js +5 -4
- package/dist/esm/testing/exports.js +3 -0
- package/dist/esm/testing/fakes.js +107 -0
- package/dist/esm/testing/fixture.js +86 -0
- package/dist/esm/testing/timeout.js +24 -0
- package/dist/esm/utilities.js +95 -95
- package/dist/fast-element.api.json +9487 -8326
- package/dist/fast-element.d.ts +847 -644
- package/dist/fast-element.debug.js +1993 -1166
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +1903 -1111
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +911 -701
- package/docs/api-report.md +329 -252
- package/package.json +38 -16
- 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/dts/templating/dom.d.ts +0 -41
- package/dist/esm/hooks.js +0 -32
- package/dist/esm/observation/splice-strategies.js +0 -400
- package/dist/esm/templating/dom.js +0 -49
|
@@ -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.
|
|
@@ -37,21 +36,31 @@ export declare const elements: (selector?: string) => ElementsFilter;
|
|
|
37
36
|
* Internally used by the SlottedDirective and the ChildrenDirective.
|
|
38
37
|
*/
|
|
39
38
|
export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
|
|
40
|
-
private
|
|
39
|
+
private _id;
|
|
40
|
+
private _controllerProperty;
|
|
41
|
+
/**
|
|
42
|
+
* The unique id of the factory.
|
|
43
|
+
*/
|
|
44
|
+
get id(): string;
|
|
45
|
+
set id(value: string);
|
|
46
|
+
/**
|
|
47
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
48
|
+
*/
|
|
49
|
+
targetNodeId: string;
|
|
41
50
|
/**
|
|
42
51
|
* Bind this behavior to the source.
|
|
43
52
|
* @param source - The source to bind to.
|
|
44
53
|
* @param context - The execution context that the binding is operating within.
|
|
45
54
|
* @param targets - The targets that behaviors in a view can attach to.
|
|
46
55
|
*/
|
|
47
|
-
bind(
|
|
56
|
+
bind(controller: ViewController): void;
|
|
48
57
|
/**
|
|
49
58
|
* Unbinds this behavior from the source.
|
|
50
59
|
* @param source - The source to unbind from.
|
|
51
60
|
* @param context - The execution context that the binding is operating within.
|
|
52
61
|
* @param targets - The targets that behaviors in a view can attach to.
|
|
53
62
|
*/
|
|
54
|
-
unbind(
|
|
63
|
+
unbind(controller: ViewController): void;
|
|
55
64
|
/**
|
|
56
65
|
* Gets the data source for the target.
|
|
57
66
|
* @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,18 @@ import type { CaptureType } from "./template.js";
|
|
|
7
6
|
*/
|
|
8
7
|
export declare class RefDirective extends StatelessAttachedAttributeDirective<string> {
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @param source - The source to bind to.
|
|
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
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
14
10
|
*/
|
|
15
|
-
|
|
11
|
+
targetNodeId: string;
|
|
16
12
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @param
|
|
13
|
+
* Bind this behavior.
|
|
14
|
+
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
19
15
|
*/
|
|
20
|
-
|
|
16
|
+
bind(controller: ViewController): void;
|
|
21
17
|
}
|
|
22
18
|
/**
|
|
23
19
|
* A directive that observes the updates a property with a reference to the element.
|
|
24
20
|
* @param propertyName - The name of the property to assign the reference to.
|
|
25
21
|
* @public
|
|
26
22
|
*/
|
|
27
|
-
export declare const ref: <
|
|
23
|
+
export declare const ref: <TSource = any, TParent = any>(propertyName: keyof TSource & string) => CaptureType<TSource, TParent>;
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import type { FASTElement } from "../components/fast-element.js";
|
|
2
|
+
import type { DOMPolicy } from "../dom.js";
|
|
3
|
+
import { Constructable } from "../interfaces.js";
|
|
4
|
+
import type { Subscriber } from "../observation/notifier.js";
|
|
5
|
+
import type { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
|
|
6
|
+
import { ContentTemplate, ContentView } from "./binding.js";
|
|
7
|
+
import { AddViewBehaviorFactory, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
|
|
8
|
+
import { CaptureType, SyntheticViewTemplate, TemplateValue, ViewTemplate } from "./template.js";
|
|
9
|
+
/**
|
|
10
|
+
* A Behavior that enables advanced rendering.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare class RenderBehavior<TSource = any> implements ViewBehavior, Subscriber {
|
|
14
|
+
private directive;
|
|
15
|
+
private location;
|
|
16
|
+
private controller;
|
|
17
|
+
private view;
|
|
18
|
+
private template;
|
|
19
|
+
private templateBindingObserver;
|
|
20
|
+
private data;
|
|
21
|
+
private dataBindingObserver;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instance of RenderBehavior.
|
|
24
|
+
* @param directive - The render directive that created this behavior.
|
|
25
|
+
*/
|
|
26
|
+
constructor(directive: RenderDirective);
|
|
27
|
+
/**
|
|
28
|
+
* Bind this behavior.
|
|
29
|
+
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
30
|
+
*/
|
|
31
|
+
bind(controller: ViewController): void;
|
|
32
|
+
/**
|
|
33
|
+
* Unbinds this behavior.
|
|
34
|
+
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
35
|
+
*/
|
|
36
|
+
unbind(controller: ViewController): void;
|
|
37
|
+
/** @internal */
|
|
38
|
+
handleChange(source: any, observer: ExpressionObserver): void;
|
|
39
|
+
private refreshView;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A Directive that enables use of the RenderBehavior.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export declare class RenderDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
|
|
46
|
+
readonly dataBinding: Binding<TSource>;
|
|
47
|
+
readonly templateBinding: Binding<TSource, ContentTemplate>;
|
|
48
|
+
readonly templateBindingDependsOnData: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
51
|
+
*/
|
|
52
|
+
targetNodeId: string;
|
|
53
|
+
/**
|
|
54
|
+
* Creates an instance of RenderDirective.
|
|
55
|
+
* @param dataBinding - A binding expression that returns the data to render.
|
|
56
|
+
* @param templateBinding - A binding expression that returns the template to use to render the data.
|
|
57
|
+
*/
|
|
58
|
+
constructor(dataBinding: Binding<TSource>, templateBinding: Binding<TSource, ContentTemplate>, templateBindingDependsOnData: boolean);
|
|
59
|
+
/**
|
|
60
|
+
* Creates HTML to be used within a template.
|
|
61
|
+
* @param add - Can be used to add behavior factories to a template.
|
|
62
|
+
*/
|
|
63
|
+
createHTML(add: AddViewBehaviorFactory): string;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a behavior.
|
|
66
|
+
* @param targets - The targets available for behaviors to be attached to.
|
|
67
|
+
*/
|
|
68
|
+
createBehavior(): RenderBehavior<TSource>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Provides instructions for how to render a type.
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export interface RenderInstruction {
|
|
75
|
+
/**
|
|
76
|
+
* Identifies this as a RenderInstruction.
|
|
77
|
+
*/
|
|
78
|
+
brand: symbol;
|
|
79
|
+
/**
|
|
80
|
+
* The type this instruction is associated with.
|
|
81
|
+
*/
|
|
82
|
+
type: Constructable;
|
|
83
|
+
/**
|
|
84
|
+
* The template to use when rendering.
|
|
85
|
+
*/
|
|
86
|
+
template: ContentTemplate;
|
|
87
|
+
/**
|
|
88
|
+
* A name that can be used to identify the instruction.
|
|
89
|
+
*/
|
|
90
|
+
name: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Render options that are common to all configurations.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export declare type CommonRenderOptions = {
|
|
97
|
+
/**
|
|
98
|
+
* The type this instruction is associated with.
|
|
99
|
+
*/
|
|
100
|
+
type: Constructable;
|
|
101
|
+
/**
|
|
102
|
+
* A name that can be used to identify the instruction.
|
|
103
|
+
*/
|
|
104
|
+
name?: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Render options used to specify a template.
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
export declare type TemplateRenderOptions = CommonRenderOptions & {
|
|
111
|
+
/**
|
|
112
|
+
* The template to use when rendering.
|
|
113
|
+
*/
|
|
114
|
+
template: ContentTemplate;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Render options that are common to all element render instructions.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
export declare type BaseElementRenderOptions<TSource = any, TParent = any> = CommonRenderOptions & {
|
|
121
|
+
/**
|
|
122
|
+
* Attributes to use when creating the element template.
|
|
123
|
+
* @remarks
|
|
124
|
+
* This API should be used with caution. When providing attributes, if not done properly,
|
|
125
|
+
* you can open up the application to XSS attacks. When using this API, provide a strong
|
|
126
|
+
* DOMPolicy that can properly sanitize and also be sure to manually sanitize attribute
|
|
127
|
+
* values particularly if they can come from user input.
|
|
128
|
+
*/
|
|
129
|
+
attributes?: Record<string, string | TemplateValue<TSource, TParent>>;
|
|
130
|
+
/**
|
|
131
|
+
* Content to use when creating the element template.
|
|
132
|
+
* @remarks
|
|
133
|
+
* This API should be used with caution. When providing content, if not done properly,
|
|
134
|
+
* you can open up the application to XSS attacks. When using this API, provide a strong
|
|
135
|
+
* DOMPolicy that can properly sanitize and also be sure to manually sanitize content
|
|
136
|
+
* particularly if it can come from user input. Prefer passing a template
|
|
137
|
+
* created by the the html tag helper rather than passing a raw string, as that will
|
|
138
|
+
* enable the JS runtime to help secure the static strings.
|
|
139
|
+
*/
|
|
140
|
+
content?: string | SyntheticViewTemplate;
|
|
141
|
+
/**
|
|
142
|
+
* The DOMPolicy to create the render instruction with.
|
|
143
|
+
*/
|
|
144
|
+
policy?: DOMPolicy;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Render options used to specify an element.
|
|
148
|
+
* @public
|
|
149
|
+
*/
|
|
150
|
+
export declare type ElementConstructorRenderOptions<TSource = any, TParent = any> = BaseElementRenderOptions<TSource, TParent> & {
|
|
151
|
+
/**
|
|
152
|
+
* The element to use when rendering.
|
|
153
|
+
*/
|
|
154
|
+
element: Constructable<FASTElement>;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Render options use to specify an element by tag name.
|
|
158
|
+
* @public
|
|
159
|
+
*/
|
|
160
|
+
export declare type TagNameRenderOptions<TSource = any, TParent = any> = BaseElementRenderOptions<TSource, TParent> & {
|
|
161
|
+
/**
|
|
162
|
+
* The tag name to use when rendering.
|
|
163
|
+
*/
|
|
164
|
+
tagName: string;
|
|
165
|
+
};
|
|
166
|
+
declare function createElementTemplate<TSource = any, TParent = any>(tagName: string, attributes?: Record<string, string | TemplateValue<TSource, TParent>>, content?: string | ContentTemplate, policy?: DOMPolicy): ViewTemplate<TSource, TParent>;
|
|
167
|
+
declare function create(options: TagNameRenderOptions): RenderInstruction;
|
|
168
|
+
declare function create(options: ElementConstructorRenderOptions): RenderInstruction;
|
|
169
|
+
declare function create(options: TemplateRenderOptions): RenderInstruction;
|
|
170
|
+
declare function instanceOf(object: any): object is RenderInstruction;
|
|
171
|
+
declare function register(options: TagNameRenderOptions): RenderInstruction;
|
|
172
|
+
declare function register(options: ElementConstructorRenderOptions): RenderInstruction;
|
|
173
|
+
declare function register(options: TemplateRenderOptions): RenderInstruction;
|
|
174
|
+
declare function register(instruction: RenderInstruction): RenderInstruction;
|
|
175
|
+
declare function getByType(type: Constructable, name?: string): RenderInstruction | undefined;
|
|
176
|
+
declare function getForInstance(object: any, name?: string): RenderInstruction | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Provides APIs for creating and interacting with render instructions.
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
export declare const RenderInstruction: Readonly<{
|
|
182
|
+
/**
|
|
183
|
+
* Checks whether the provided object is a RenderInstruction.
|
|
184
|
+
* @param object - The object to check.
|
|
185
|
+
* @returns true if the object is a RenderInstruction; false otherwise
|
|
186
|
+
*/
|
|
187
|
+
instanceOf: typeof instanceOf;
|
|
188
|
+
/**
|
|
189
|
+
* Creates a RenderInstruction for a set of options.
|
|
190
|
+
* @param options - The options to use when creating the RenderInstruction.
|
|
191
|
+
* @remarks
|
|
192
|
+
* This API should be used with caution. When providing attributes or content,
|
|
193
|
+
* if not done properly, you can open up the application to XSS attacks. When using this API,
|
|
194
|
+
* provide a strong DOMPolicy that can properly sanitize and also be sure to manually sanitize
|
|
195
|
+
* content and attribute values particularly if they can come from user input.
|
|
196
|
+
*/
|
|
197
|
+
create: typeof create;
|
|
198
|
+
/**
|
|
199
|
+
* Creates a template based on a tag name.
|
|
200
|
+
* @param tagName - The tag name to use when creating the template.
|
|
201
|
+
* @param attributes - The attributes to apply to the element.
|
|
202
|
+
* @param content - The content to insert into the element.
|
|
203
|
+
* @param policy - The DOMPolicy to create the template with.
|
|
204
|
+
* @returns A template based on the provided specifications.
|
|
205
|
+
* @remarks
|
|
206
|
+
* This API should be used with caution. When providing attributes or content,
|
|
207
|
+
* if not done properly, you can open up the application to XSS attacks. When using this API,
|
|
208
|
+
* provide a strong DOMPolicy that can properly sanitize and also be sure to manually sanitize
|
|
209
|
+
* content and attribute values particularly if they can come from user input.
|
|
210
|
+
*/
|
|
211
|
+
createElementTemplate: typeof createElementTemplate;
|
|
212
|
+
/**
|
|
213
|
+
* Creates and registers an instruction.
|
|
214
|
+
* @param options The options to use when creating the RenderInstruction.
|
|
215
|
+
* @remarks
|
|
216
|
+
* A previously created RenderInstruction can also be registered.
|
|
217
|
+
*/
|
|
218
|
+
register: typeof register;
|
|
219
|
+
/**
|
|
220
|
+
* Finds a previously registered RenderInstruction by type and optionally by name.
|
|
221
|
+
* @param type - The type to retrieve the RenderInstruction for.
|
|
222
|
+
* @param name - An optional name used in differentiating between multiple registered instructions.
|
|
223
|
+
* @returns The located RenderInstruction that matches the criteria or undefined if none is found.
|
|
224
|
+
*/
|
|
225
|
+
getByType: typeof getByType;
|
|
226
|
+
/**
|
|
227
|
+
* Finds a previously registered RenderInstruction for the instance's type and optionally by name.
|
|
228
|
+
* @param object - The instance to retrieve the RenderInstruction for.
|
|
229
|
+
* @param name - An optional name used in differentiating between multiple registered instructions.
|
|
230
|
+
* @returns The located RenderInstruction that matches the criteria or undefined if none is found.
|
|
231
|
+
*/
|
|
232
|
+
getForInstance: typeof getForInstance;
|
|
233
|
+
}>;
|
|
234
|
+
/**
|
|
235
|
+
* Decorates a type with render instruction metadata.
|
|
236
|
+
* @param options - The options used in creating the RenderInstruction.
|
|
237
|
+
* @public
|
|
238
|
+
*/
|
|
239
|
+
export declare function renderWith(options: Omit<TagNameRenderOptions, "type">): ClassDecorator;
|
|
240
|
+
/**
|
|
241
|
+
* Decorates a type with render instruction metadata.
|
|
242
|
+
* @param options - The options used in creating the RenderInstruction.
|
|
243
|
+
* @public
|
|
244
|
+
*/
|
|
245
|
+
export declare function renderWith(options: Omit<ElementConstructorRenderOptions, "type">): ClassDecorator;
|
|
246
|
+
/**
|
|
247
|
+
* Decorates a type with render instruction metadata.
|
|
248
|
+
* @param options - The options used in creating the RenderInstruction.
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
export declare function renderWith(options: Omit<TemplateRenderOptions, "type">): ClassDecorator;
|
|
252
|
+
/**
|
|
253
|
+
* Decorates a type with render instruction metadata.
|
|
254
|
+
* @param element - The element to use to render the decorated class.
|
|
255
|
+
* @param name - An optional name to differentiate the render instruction.
|
|
256
|
+
* @public
|
|
257
|
+
*/
|
|
258
|
+
export declare function renderWith(element: Constructable<FASTElement>, name?: string): ClassDecorator;
|
|
259
|
+
/**
|
|
260
|
+
* Decorates a type with render instruction metadata.
|
|
261
|
+
* @param template - The template to use to render the decorated class.
|
|
262
|
+
* @param name - An optional name to differentiate the render instruction.
|
|
263
|
+
* @public
|
|
264
|
+
*/
|
|
265
|
+
export declare function renderWith(template: ContentTemplate, name?: string): ClassDecorator;
|
|
266
|
+
/**
|
|
267
|
+
* @internal
|
|
268
|
+
*/
|
|
269
|
+
export declare class NodeTemplate implements ContentTemplate, ContentView {
|
|
270
|
+
readonly node: Node;
|
|
271
|
+
constructor(node: Node);
|
|
272
|
+
get context(): ExecutionContext<any>;
|
|
273
|
+
bind(source: any): void;
|
|
274
|
+
unbind(): void;
|
|
275
|
+
insertBefore(refNode: Node): void;
|
|
276
|
+
remove(): void;
|
|
277
|
+
create(): ContentView;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Creates a RenderDirective for use in advanced rendering scenarios.
|
|
281
|
+
* @param value - The binding expression that returns the data to be rendered. The expression
|
|
282
|
+
* can also return a Node to render directly.
|
|
283
|
+
* @param template - A template to render the data with
|
|
284
|
+
* or a string to indicate which RenderInstruction to use when looking up a RenderInstruction.
|
|
285
|
+
* Expressions can also be provided to dynamically determine either the template or the name.
|
|
286
|
+
* @returns A RenderDirective suitable for use in a template.
|
|
287
|
+
* @remarks
|
|
288
|
+
* If no binding is provided, then a default binding that returns the source is created.
|
|
289
|
+
* If no template is provided, then a binding is created that will use registered
|
|
290
|
+
* RenderInstructions to determine the view.
|
|
291
|
+
* If the template binding returns a string, then it will be used to look up a
|
|
292
|
+
* RenderInstruction to determine the view.
|
|
293
|
+
* @public
|
|
294
|
+
*/
|
|
295
|
+
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>;
|
|
296
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Behavior } from "../observation/behavior.js";
|
|
2
1
|
import type { Subscriber } from "../observation/notifier.js";
|
|
3
|
-
import {
|
|
2
|
+
import { Expression, ExpressionObserver } from "../observation/observable.js";
|
|
4
3
|
import { Splice } from "../observation/arrays.js";
|
|
5
|
-
import { AddViewBehaviorFactory, HTMLDirective, ViewBehaviorFactory,
|
|
4
|
+
import { AddViewBehaviorFactory, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
|
|
6
5
|
import type { CaptureType, SyntheticViewTemplate, ViewTemplate } from "./template.js";
|
|
6
|
+
import { SyntheticView } from "./view.js";
|
|
7
7
|
/**
|
|
8
8
|
* Options for configuring repeat behavior.
|
|
9
9
|
* @public
|
|
@@ -22,40 +22,35 @@ export interface RepeatOptions {
|
|
|
22
22
|
* A behavior that renders a template for each item in an array.
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
|
-
export declare class RepeatBehavior<TSource = any> implements
|
|
25
|
+
export declare class RepeatBehavior<TSource = any> implements ViewBehavior, Subscriber {
|
|
26
|
+
private directive;
|
|
26
27
|
private location;
|
|
27
|
-
private
|
|
28
|
-
private templateBinding;
|
|
29
|
-
private options;
|
|
30
|
-
private source;
|
|
31
|
-
private views;
|
|
28
|
+
private controller;
|
|
32
29
|
private template;
|
|
33
30
|
private templateBindingObserver;
|
|
34
31
|
private items;
|
|
35
32
|
private itemsObserver;
|
|
36
33
|
private itemsBindingObserver;
|
|
37
|
-
private context;
|
|
38
|
-
private childContext;
|
|
39
34
|
private bindView;
|
|
35
|
+
/** @internal */
|
|
36
|
+
views: SyntheticView[];
|
|
40
37
|
/**
|
|
41
38
|
* Creates an instance of RepeatBehavior.
|
|
42
39
|
* @param location - The location in the DOM to render the repeat.
|
|
43
|
-
* @param
|
|
40
|
+
* @param dataBinding - The array to render.
|
|
44
41
|
* @param isItemsBindingVolatile - Indicates whether the items binding has volatile dependencies.
|
|
45
42
|
* @param templateBinding - The template to render for each item.
|
|
46
43
|
* @param isTemplateBindingVolatile - Indicates whether the template binding has volatile dependencies.
|
|
47
44
|
* @param options - Options used to turn on special repeat features.
|
|
48
45
|
*/
|
|
49
|
-
constructor(
|
|
46
|
+
constructor(directive: RepeatDirective);
|
|
50
47
|
/**
|
|
51
|
-
* Bind this behavior
|
|
52
|
-
* @param
|
|
53
|
-
* @param context - The execution context that the binding is operating within.
|
|
48
|
+
* Bind this behavior.
|
|
49
|
+
* @param controller - The view controller that manages the lifecycle of this behavior.
|
|
54
50
|
*/
|
|
55
|
-
bind(
|
|
51
|
+
bind(controller: ViewController): void;
|
|
56
52
|
/**
|
|
57
|
-
* Unbinds this behavior
|
|
58
|
-
* @param source - The source to unbind from.
|
|
53
|
+
* Unbinds this behavior.
|
|
59
54
|
*/
|
|
60
55
|
unbind(): void;
|
|
61
56
|
/**
|
|
@@ -63,7 +58,7 @@ export declare class RepeatBehavior<TSource = any> implements Behavior, Subscrib
|
|
|
63
58
|
* @param source - The source of the change.
|
|
64
59
|
* @param args - The details about what was changed.
|
|
65
60
|
*/
|
|
66
|
-
handleChange(source: any, args: Splice[]): void;
|
|
61
|
+
handleChange(source: any, args: Splice[] | ExpressionObserver): void;
|
|
67
62
|
private observeItems;
|
|
68
63
|
private updateViews;
|
|
69
64
|
private refreshAllViews;
|
|
@@ -74,19 +69,13 @@ export declare class RepeatBehavior<TSource = any> implements Behavior, Subscrib
|
|
|
74
69
|
* @public
|
|
75
70
|
*/
|
|
76
71
|
export declare class RepeatDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
|
|
77
|
-
readonly
|
|
72
|
+
readonly dataBinding: Binding<TSource>;
|
|
78
73
|
readonly templateBinding: Binding<TSource, SyntheticViewTemplate>;
|
|
79
74
|
readonly options: RepeatOptions;
|
|
80
|
-
private isItemsBindingVolatile;
|
|
81
|
-
private isTemplateBindingVolatile;
|
|
82
|
-
/**
|
|
83
|
-
* The unique id of the factory.
|
|
84
|
-
*/
|
|
85
|
-
id: string;
|
|
86
75
|
/**
|
|
87
76
|
* The structural id of the DOM node to which the created behavior will apply.
|
|
88
77
|
*/
|
|
89
|
-
|
|
78
|
+
targetNodeId: string;
|
|
90
79
|
/**
|
|
91
80
|
* Creates a placeholder string based on the directive's index within the template.
|
|
92
81
|
* @param index - The index of the directive within the template.
|
|
@@ -94,23 +83,23 @@ export declare class RepeatDirective<TSource = any> implements HTMLDirective, Vi
|
|
|
94
83
|
createHTML(add: AddViewBehaviorFactory): string;
|
|
95
84
|
/**
|
|
96
85
|
* Creates an instance of RepeatDirective.
|
|
97
|
-
* @param
|
|
86
|
+
* @param dataBinding - The binding that provides the array to render.
|
|
98
87
|
* @param templateBinding - The template binding used to obtain a template to render for each item in the array.
|
|
99
88
|
* @param options - Options used to turn on special repeat features.
|
|
100
89
|
*/
|
|
101
|
-
constructor(
|
|
90
|
+
constructor(dataBinding: Binding<TSource>, templateBinding: Binding<TSource, SyntheticViewTemplate>, options: RepeatOptions);
|
|
102
91
|
/**
|
|
103
92
|
* Creates a behavior for the provided target node.
|
|
104
93
|
* @param target - The node instance to create the behavior for.
|
|
105
94
|
*/
|
|
106
|
-
createBehavior(
|
|
95
|
+
createBehavior(): RepeatBehavior<TSource>;
|
|
107
96
|
}
|
|
108
97
|
/**
|
|
109
98
|
* A directive that enables list rendering.
|
|
110
|
-
* @param
|
|
111
|
-
* @param
|
|
99
|
+
* @param items - The array to render.
|
|
100
|
+
* @param template - The template or a template binding used obtain a template
|
|
112
101
|
* to render for each item in the array.
|
|
113
102
|
* @param options - Options used to turn on special repeat features.
|
|
114
103
|
* @public
|
|
115
104
|
*/
|
|
116
|
-
export declare function repeat<TSource = any, TArray extends ReadonlyArray<any> = ReadonlyArray<any
|
|
105
|
+
export declare function repeat<TSource = any, TArray extends ReadonlyArray<any> = ReadonlyArray<any>, TParent = any>(items: Expression<TSource, TArray, TParent> | Binding<TSource, TArray, TParent> | ReadonlyArray<any>, template: Expression<TSource, ViewTemplate<any, TSource>> | Binding<TSource, ViewTemplate<any, TSource>> | ViewTemplate<any, TSource>, options?: RepeatOptions): CaptureType<TSource, TParent>;
|
|
@@ -35,4 +35,4 @@ export declare class SlottedDirective extends NodeObservationDirective<SlottedDi
|
|
|
35
35
|
* @param propertyOrOptions - The options used to configure slotted node observation.
|
|
36
36
|
* @public
|
|
37
37
|
*/
|
|
38
|
-
export declare function slotted<
|
|
38
|
+
export declare function slotted<TSource = any, TParent = any>(propertyOrOptions: (keyof TSource & string) | SlottedDirectiveOptions<keyof TSource & string>): CaptureType<TSource, TParent>;
|