@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,90 +1,226 @@
|
|
|
1
|
+
import type { Constructable } from "../interfaces.js";
|
|
1
2
|
import type { Behavior } from "../observation/behavior.js";
|
|
3
|
+
import type { Binding, ExecutionContext } from "../observation/observable.js";
|
|
4
|
+
/**
|
|
5
|
+
* The target nodes available to a behavior.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare type ViewBehaviorTargets = {
|
|
9
|
+
[id: string]: Node;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Represents an object that can contribute behavior to a view.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface ViewBehavior<TSource = any, TParent = any> {
|
|
16
|
+
/**
|
|
17
|
+
* Bind this behavior to the source.
|
|
18
|
+
* @param source - The source to bind to.
|
|
19
|
+
* @param context - The execution context that the binding is operating within.
|
|
20
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
21
|
+
*/
|
|
22
|
+
bind(source: TSource, context: ExecutionContext<TParent>, targets: ViewBehaviorTargets): void;
|
|
23
|
+
/**
|
|
24
|
+
* Unbinds this behavior from the source.
|
|
25
|
+
* @param source - The source to unbind from.
|
|
26
|
+
* @param context - The execution context that the binding is operating within.
|
|
27
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
28
|
+
*/
|
|
29
|
+
unbind(source: TSource, context: ExecutionContext<TParent>, targets: ViewBehaviorTargets): void;
|
|
30
|
+
}
|
|
2
31
|
/**
|
|
3
32
|
* A factory that can create a {@link Behavior} associated with a particular
|
|
4
33
|
* location within a DOM fragment.
|
|
5
34
|
* @public
|
|
6
35
|
*/
|
|
7
|
-
export interface
|
|
36
|
+
export interface ViewBehaviorFactory {
|
|
37
|
+
/**
|
|
38
|
+
* The unique id of the factory.
|
|
39
|
+
*/
|
|
40
|
+
id: string;
|
|
8
41
|
/**
|
|
9
|
-
* The
|
|
42
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
10
43
|
*/
|
|
11
|
-
|
|
44
|
+
nodeId: string;
|
|
12
45
|
/**
|
|
13
|
-
* Creates a behavior
|
|
14
|
-
* @param
|
|
46
|
+
* Creates a behavior.
|
|
47
|
+
* @param targets - The targets available for behaviors to be attached to.
|
|
15
48
|
*/
|
|
16
|
-
createBehavior(
|
|
49
|
+
createBehavior(targets: ViewBehaviorTargets): Behavior | ViewBehavior;
|
|
17
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Used to add behavior factories when constructing templates.
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare type AddViewBehaviorFactory = (factory: ViewBehaviorFactory) => string;
|
|
18
56
|
/**
|
|
19
57
|
* Instructs the template engine to apply behavior to a node.
|
|
20
58
|
* @public
|
|
21
59
|
*/
|
|
22
|
-
export
|
|
60
|
+
export interface HTMLDirective {
|
|
23
61
|
/**
|
|
24
|
-
*
|
|
62
|
+
* Creates HTML to be used within a template.
|
|
63
|
+
* @param add - Can be used to add behavior factories to a template.
|
|
25
64
|
*/
|
|
26
|
-
|
|
65
|
+
createHTML(add: AddViewBehaviorFactory): string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Represents metadata configuration for an HTMLDirective.
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export interface PartialHTMLDirectiveDefinition {
|
|
27
72
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
73
|
+
* Indicates whether the directive needs access to template contextual information
|
|
74
|
+
* such as the sourceAspect, targetAspect, and aspectType.
|
|
30
75
|
*/
|
|
31
|
-
|
|
76
|
+
aspected?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Defines metadata for an HTMLDirective.
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export interface HTMLDirectiveDefinition<TType extends Constructable<HTMLDirective> = Constructable<HTMLDirective>> extends Required<PartialHTMLDirectiveDefinition> {
|
|
32
83
|
/**
|
|
33
|
-
*
|
|
34
|
-
* @param target - The node instance to create the behavior for.
|
|
84
|
+
* The type that the definition provides metadata for.
|
|
35
85
|
*/
|
|
36
|
-
|
|
86
|
+
readonly type: TType;
|
|
37
87
|
}
|
|
38
88
|
/**
|
|
39
|
-
*
|
|
89
|
+
* Instructs the template engine to apply behavior to a node.
|
|
40
90
|
* @public
|
|
41
91
|
*/
|
|
42
|
-
export declare
|
|
92
|
+
export declare const HTMLDirective: Readonly<{
|
|
43
93
|
/**
|
|
44
|
-
* Gets
|
|
45
|
-
* directive
|
|
94
|
+
* Gets the directive definition associated with the instance.
|
|
95
|
+
* @param instance - The directive instance to retrieve the definition for.
|
|
46
96
|
*/
|
|
47
|
-
|
|
97
|
+
getForInstance: (object: any) => HTMLDirectiveDefinition<Constructable<HTMLDirective>> | undefined;
|
|
48
98
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param
|
|
99
|
+
* Gets the directive definition associated with the specified type.
|
|
100
|
+
* @param type - The directive type to retrieve the definition for.
|
|
51
101
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
102
|
+
getByType: (key: Function) => HTMLDirectiveDefinition<Constructable<HTMLDirective>> | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Defines an HTMLDirective based on the options.
|
|
105
|
+
* @param type - The type to define as a directive.
|
|
106
|
+
* @param options - Options that specify the directive's application.
|
|
107
|
+
*/
|
|
108
|
+
define<TType extends Constructable<HTMLDirective>>(type: TType, options?: PartialHTMLDirectiveDefinition): TType;
|
|
109
|
+
}>;
|
|
54
110
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
111
|
+
* Decorator: Defines an HTMLDirective.
|
|
112
|
+
* @param options - Provides options that specify the directive's application.
|
|
57
113
|
* @public
|
|
58
114
|
*/
|
|
59
|
-
export declare
|
|
115
|
+
export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition): (type: Constructable<HTMLDirective>) => void;
|
|
60
116
|
/**
|
|
61
|
-
*
|
|
117
|
+
* The type of HTML aspect to target.
|
|
62
118
|
* @public
|
|
63
119
|
*/
|
|
64
|
-
export declare
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
120
|
+
export declare const Aspect: Readonly<{
|
|
121
|
+
/**
|
|
122
|
+
* Not aspected.
|
|
123
|
+
*/
|
|
124
|
+
readonly none: 0;
|
|
125
|
+
/**
|
|
126
|
+
* An attribute.
|
|
127
|
+
*/
|
|
128
|
+
readonly attribute: 1;
|
|
129
|
+
/**
|
|
130
|
+
* A boolean attribute.
|
|
131
|
+
*/
|
|
132
|
+
readonly booleanAttribute: 2;
|
|
133
|
+
/**
|
|
134
|
+
* A property.
|
|
135
|
+
*/
|
|
136
|
+
readonly property: 3;
|
|
137
|
+
/**
|
|
138
|
+
* Content
|
|
139
|
+
*/
|
|
140
|
+
readonly content: 4;
|
|
141
|
+
/**
|
|
142
|
+
* A token list.
|
|
143
|
+
*/
|
|
144
|
+
readonly tokenList: 5;
|
|
145
|
+
/**
|
|
146
|
+
* An event.
|
|
147
|
+
*/
|
|
148
|
+
readonly event: 6;
|
|
68
149
|
/**
|
|
69
150
|
*
|
|
70
|
-
* @param
|
|
71
|
-
* @param
|
|
72
|
-
* @param options - Options to pass to the behavior during creation.
|
|
151
|
+
* @param directive - The directive to assign the aspect to.
|
|
152
|
+
* @param value - The value to base the aspect determination on.
|
|
73
153
|
*/
|
|
74
|
-
|
|
154
|
+
readonly assign: (directive: Aspected, value: string) => void;
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* The type of HTML aspect to target.
|
|
158
|
+
* @public
|
|
159
|
+
*/
|
|
160
|
+
export declare type Aspect = typeof Aspect[Exclude<keyof typeof Aspect, "assign" | "none">];
|
|
161
|
+
/**
|
|
162
|
+
* Represents something that applies to a specific aspect of the DOM.
|
|
163
|
+
* @public
|
|
164
|
+
*/
|
|
165
|
+
export interface Aspected {
|
|
166
|
+
/**
|
|
167
|
+
* The original source aspect exactly as represented in markup.
|
|
168
|
+
*/
|
|
169
|
+
sourceAspect: string;
|
|
170
|
+
/**
|
|
171
|
+
* The evaluated target aspect, determined after processing the source.
|
|
172
|
+
*/
|
|
173
|
+
targetAspect: string;
|
|
174
|
+
/**
|
|
175
|
+
* The type of aspect to target.
|
|
176
|
+
*/
|
|
177
|
+
aspectType: Aspect;
|
|
178
|
+
/**
|
|
179
|
+
* A binding if one is associated with the aspect.
|
|
180
|
+
*/
|
|
181
|
+
binding?: Binding;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* A base class used for attribute directives that don't need internal state.
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
export declare abstract class StatelessAttachedAttributeDirective<T> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
|
|
188
|
+
protected options: T;
|
|
189
|
+
/**
|
|
190
|
+
* The unique id of the factory.
|
|
191
|
+
*/
|
|
192
|
+
id: string;
|
|
193
|
+
/**
|
|
194
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
195
|
+
*/
|
|
196
|
+
nodeId: string;
|
|
197
|
+
/**
|
|
198
|
+
* Creates an instance of RefDirective.
|
|
199
|
+
* @param options - The options to use in configuring the directive.
|
|
200
|
+
*/
|
|
201
|
+
constructor(options: T);
|
|
202
|
+
/**
|
|
203
|
+
* Creates a behavior.
|
|
204
|
+
* @param targets - The targets available for behaviors to be attached to.
|
|
205
|
+
*/
|
|
206
|
+
createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
|
|
75
207
|
/**
|
|
76
208
|
* Creates a placeholder string based on the directive's index within the template.
|
|
77
209
|
* @param index - The index of the directive within the template.
|
|
78
210
|
* @remarks
|
|
79
211
|
* Creates a custom attribute placeholder.
|
|
80
212
|
*/
|
|
81
|
-
|
|
213
|
+
createHTML(add: AddViewBehaviorFactory): string;
|
|
82
214
|
/**
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
85
|
-
* @
|
|
86
|
-
*
|
|
87
|
-
|
|
215
|
+
* Bind this behavior to the source.
|
|
216
|
+
* @param source - The source to bind to.
|
|
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.
|
|
219
|
+
*/
|
|
220
|
+
abstract bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
221
|
+
/**
|
|
222
|
+
* Unbinds this behavior from the source.
|
|
223
|
+
* @param source - The source to unbind from.
|
|
88
224
|
*/
|
|
89
|
-
|
|
225
|
+
abstract unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
90
226
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ViewBehaviorFactory } from "./html-directive.js";
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare const nextId: () => string;
|
|
4
|
+
/**
|
|
5
|
+
* Common APIs related to markup generation.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare const Markup: Readonly<{
|
|
9
|
+
/**
|
|
10
|
+
* Creates a placeholder string suitable for marking out a location *within*
|
|
11
|
+
* an attribute value or HTML content.
|
|
12
|
+
* @param index - The directive index to create the placeholder for.
|
|
13
|
+
* @remarks
|
|
14
|
+
* Used internally by binding directives.
|
|
15
|
+
*/
|
|
16
|
+
interpolation: (id: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a placeholder that manifests itself as an attribute on an
|
|
19
|
+
* element.
|
|
20
|
+
* @param attributeName - The name of the custom attribute.
|
|
21
|
+
* @param index - The directive index to create the placeholder for.
|
|
22
|
+
* @remarks
|
|
23
|
+
* Used internally by attribute directives such as `ref`, `slotted`, and `children`.
|
|
24
|
+
*/
|
|
25
|
+
attribute: (id: string) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a placeholder that manifests itself as a marker within the DOM structure.
|
|
28
|
+
* @param index - The directive index to create the placeholder for.
|
|
29
|
+
* @remarks
|
|
30
|
+
* Used internally by structural directives such as `repeat`.
|
|
31
|
+
*/
|
|
32
|
+
comment: (id: string) => string;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Common APIs related to content parsing.
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare const Parser: Readonly<{
|
|
39
|
+
/**
|
|
40
|
+
* Parses text content or HTML attribute content, separating out the static strings
|
|
41
|
+
* from the directives.
|
|
42
|
+
* @param value - The content or attribute string to parse.
|
|
43
|
+
* @param factories - A list of directives to search for in the string.
|
|
44
|
+
* @returns A heterogeneous array of static strings interspersed with
|
|
45
|
+
* directives or null if no directives are found in the string.
|
|
46
|
+
*/
|
|
47
|
+
parse(value: string, factories: Record<string, ViewBehaviorFactory>): (string | ViewBehaviorFactory)[] | null;
|
|
48
|
+
}>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExecutionContext } from "../observation/observable.js";
|
|
2
|
+
import { StatelessAttachedAttributeDirective, ViewBehaviorTargets } from "./html-directive.js";
|
|
2
3
|
/**
|
|
3
4
|
* Options for configuring node observation behavior.
|
|
4
5
|
* @public
|
|
@@ -28,47 +29,62 @@ export declare type ElementsFilter = (value: Node, index: number, array: Node[])
|
|
|
28
29
|
* @param selector - An optional selector to restrict the filter to.
|
|
29
30
|
* @public
|
|
30
31
|
*/
|
|
31
|
-
export declare
|
|
32
|
+
export declare const elements: (selector?: string) => ElementsFilter;
|
|
32
33
|
/**
|
|
33
34
|
* A base class for node observation.
|
|
34
|
-
* @
|
|
35
|
+
* @public
|
|
36
|
+
* @remarks
|
|
37
|
+
* Internally used by the SlottedDirective and the ChildrenDirective.
|
|
35
38
|
*/
|
|
36
|
-
export declare abstract class
|
|
37
|
-
|
|
38
|
-
protected options: T;
|
|
39
|
-
private source;
|
|
40
|
-
private shouldUpdate;
|
|
39
|
+
export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
|
|
40
|
+
private sourceProperty;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
42
|
+
* Bind this behavior to the source.
|
|
43
|
+
* @param source - The source to bind to.
|
|
44
|
+
* @param context - The execution context that the binding is operating within.
|
|
45
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
+
* Unbinds this behavior from the source.
|
|
50
|
+
* @param source - The source to unbind from.
|
|
51
|
+
* @param context - The execution context that the binding is operating within.
|
|
52
|
+
* @param targets - The targets that behaviors in a view can attach to.
|
|
49
53
|
*/
|
|
50
|
-
|
|
54
|
+
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
51
55
|
/**
|
|
52
|
-
*
|
|
56
|
+
* Gets the data source for the target.
|
|
57
|
+
* @param target - The target to get the source for.
|
|
58
|
+
* @returns The source.
|
|
53
59
|
*/
|
|
54
|
-
|
|
60
|
+
protected getSource(target: Node): any;
|
|
55
61
|
/**
|
|
56
|
-
*
|
|
62
|
+
* Updates the source property with the computed nodes.
|
|
63
|
+
* @param source - The source object to assign the nodes property to.
|
|
64
|
+
* @param value - The nodes to assign to the source object property.
|
|
57
65
|
*/
|
|
58
|
-
protected
|
|
66
|
+
protected updateTarget(source: any, value: ReadonlyArray<any>): void;
|
|
59
67
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @param
|
|
62
|
-
* @
|
|
68
|
+
* Computes the set of nodes that should be assigned to the source property.
|
|
69
|
+
* @param target - The target to compute the nodes for.
|
|
70
|
+
* @returns The computed nodes.
|
|
71
|
+
* @remarks
|
|
72
|
+
* Applies filters if provided.
|
|
63
73
|
*/
|
|
64
|
-
|
|
74
|
+
protected computeNodes(target: any): Node[];
|
|
65
75
|
/**
|
|
66
|
-
*
|
|
67
|
-
* @param
|
|
76
|
+
* Begins observation of the nodes.
|
|
77
|
+
* @param target - The target to observe.
|
|
78
|
+
*/
|
|
79
|
+
protected abstract observe(target: any): void;
|
|
80
|
+
/**
|
|
81
|
+
* Disconnects observation of the nodes.
|
|
82
|
+
* @param target - The target to unobserve.
|
|
83
|
+
*/
|
|
84
|
+
protected abstract disconnect(target: any): void;
|
|
85
|
+
/**
|
|
86
|
+
* Retrieves the raw nodes that should be assigned to the source property.
|
|
87
|
+
* @param target - The target to get the node to.
|
|
68
88
|
*/
|
|
69
|
-
|
|
70
|
-
/** @internal */
|
|
71
|
-
handleEvent(): void;
|
|
72
|
-
private computeNodes;
|
|
73
|
-
private updateTarget;
|
|
89
|
+
protected abstract getNodes(target: any): Node[];
|
|
74
90
|
}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExecutionContext } from "../observation/observable.js";
|
|
2
|
+
import { StatelessAttachedAttributeDirective, ViewBehaviorTargets } from "./html-directive.js";
|
|
2
3
|
import type { CaptureType } from "./template.js";
|
|
3
4
|
/**
|
|
4
5
|
* The runtime behavior for template references.
|
|
5
6
|
* @public
|
|
6
7
|
*/
|
|
7
|
-
export declare class
|
|
8
|
-
private target;
|
|
9
|
-
private propertyName;
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of RefBehavior.
|
|
12
|
-
* @param target - The element to reference.
|
|
13
|
-
* @param propertyName - The name of the property to assign the reference to.
|
|
14
|
-
*/
|
|
15
|
-
constructor(target: HTMLElement, propertyName: string);
|
|
8
|
+
export declare class RefDirective extends StatelessAttachedAttributeDirective<string> {
|
|
16
9
|
/**
|
|
17
10
|
* Bind this behavior to the source.
|
|
18
11
|
* @param source - The source to bind to.
|
|
19
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.
|
|
20
14
|
*/
|
|
21
|
-
bind(source: any): void;
|
|
15
|
+
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
22
16
|
/**
|
|
23
17
|
* Unbinds this behavior from the source.
|
|
24
18
|
* @param source - The source to unbind from.
|
|
@@ -30,4 +24,4 @@ export declare class RefBehavior implements Behavior {
|
|
|
30
24
|
* @param propertyName - The name of the property to assign the reference to.
|
|
31
25
|
* @public
|
|
32
26
|
*/
|
|
33
|
-
export declare
|
|
27
|
+
export declare const ref: <T = any>(propertyName: keyof T & string) => CaptureType<T>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Binding, ExecutionContext } from "../observation/observable.js";
|
|
2
|
-
import type { Subscriber } from "../observation/notifier.js";
|
|
3
|
-
import type { Splice } from "../observation/array-change-records.js";
|
|
4
1
|
import type { Behavior } from "../observation/behavior.js";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
2
|
+
import type { Subscriber } from "../observation/notifier.js";
|
|
3
|
+
import { Binding, ChildContext, ExecutionContext, ItemContext, RootContext } from "../observation/observable.js";
|
|
4
|
+
import { Splice } from "../observation/arrays.js";
|
|
5
|
+
import { AddViewBehaviorFactory, HTMLDirective, ViewBehaviorFactory, ViewBehaviorTargets } from "./html-directive.js";
|
|
6
|
+
import type { CaptureType, ChildViewTemplate, ItemViewTemplate, SyntheticViewTemplate, ViewTemplate } from "./template.js";
|
|
7
7
|
/**
|
|
8
8
|
* Options for configuring repeat behavior.
|
|
9
9
|
* @public
|
|
@@ -34,7 +34,7 @@ export declare class RepeatBehavior<TSource = any> implements Behavior, Subscrib
|
|
|
34
34
|
private items;
|
|
35
35
|
private itemsObserver;
|
|
36
36
|
private itemsBindingObserver;
|
|
37
|
-
private
|
|
37
|
+
private context;
|
|
38
38
|
private childContext;
|
|
39
39
|
private bindView;
|
|
40
40
|
/**
|
|
@@ -58,7 +58,11 @@ export declare class RepeatBehavior<TSource = any> implements Behavior, Subscrib
|
|
|
58
58
|
* @param source - The source to unbind from.
|
|
59
59
|
*/
|
|
60
60
|
unbind(): void;
|
|
61
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Handles changes in the array, its items, and the repeat template.
|
|
63
|
+
* @param source - The source of the change.
|
|
64
|
+
* @param args - The details about what was changed.
|
|
65
|
+
*/
|
|
62
66
|
handleChange(source: any, args: Splice[]): void;
|
|
63
67
|
private observeItems;
|
|
64
68
|
private updateViews;
|
|
@@ -69,17 +73,25 @@ export declare class RepeatBehavior<TSource = any> implements Behavior, Subscrib
|
|
|
69
73
|
* A directive that configures list rendering.
|
|
70
74
|
* @public
|
|
71
75
|
*/
|
|
72
|
-
export declare class RepeatDirective<TSource = any>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
export declare class RepeatDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
|
|
77
|
+
readonly itemsBinding: Binding;
|
|
78
|
+
readonly templateBinding: Binding<TSource, SyntheticViewTemplate>;
|
|
79
|
+
readonly options: RepeatOptions;
|
|
76
80
|
private isItemsBindingVolatile;
|
|
77
81
|
private isTemplateBindingVolatile;
|
|
82
|
+
/**
|
|
83
|
+
* The unique id of the factory.
|
|
84
|
+
*/
|
|
85
|
+
id: string;
|
|
86
|
+
/**
|
|
87
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
88
|
+
*/
|
|
89
|
+
nodeId: string;
|
|
78
90
|
/**
|
|
79
91
|
* Creates a placeholder string based on the directive's index within the template.
|
|
80
92
|
* @param index - The index of the directive within the template.
|
|
81
93
|
*/
|
|
82
|
-
|
|
94
|
+
createHTML(add: AddViewBehaviorFactory): string;
|
|
83
95
|
/**
|
|
84
96
|
* Creates an instance of RepeatDirective.
|
|
85
97
|
* @param itemsBinding - The binding that provides the array to render.
|
|
@@ -91,7 +103,7 @@ export declare class RepeatDirective<TSource = any> extends HTMLDirective {
|
|
|
91
103
|
* Creates a behavior for the provided target node.
|
|
92
104
|
* @param target - The node instance to create the behavior for.
|
|
93
105
|
*/
|
|
94
|
-
createBehavior(
|
|
106
|
+
createBehavior(targets: ViewBehaviorTargets): RepeatBehavior<TSource>;
|
|
95
107
|
}
|
|
96
108
|
/**
|
|
97
109
|
* A directive that enables list rendering.
|
|
@@ -101,4 +113,50 @@ export declare class RepeatDirective<TSource = any> extends HTMLDirective {
|
|
|
101
113
|
* @param options - Options used to turn on special repeat features.
|
|
102
114
|
* @public
|
|
103
115
|
*/
|
|
104
|
-
export declare function repeat<TSource = any,
|
|
116
|
+
export declare function repeat<TSource = any, TArray extends ReadonlyArray<any> = ReadonlyArray<any>>(itemsBinding: Binding<TSource, TArray, ExecutionContext<TSource>>, templateOrTemplateBinding: ViewTemplate | Binding<TSource, ViewTemplate, RootContext>, options?: {
|
|
117
|
+
positioning: false;
|
|
118
|
+
} | {
|
|
119
|
+
recycle: true;
|
|
120
|
+
} | {
|
|
121
|
+
positioning: false;
|
|
122
|
+
recycle: false;
|
|
123
|
+
} | {
|
|
124
|
+
positioning: false;
|
|
125
|
+
recycle: true;
|
|
126
|
+
}): CaptureType<TSource>;
|
|
127
|
+
/**
|
|
128
|
+
* A directive that enables list rendering.
|
|
129
|
+
* @param itemsBinding - The array to render.
|
|
130
|
+
* @param templateOrTemplateBinding - The template or a template binding used obtain a template
|
|
131
|
+
* to render for each item in the array.
|
|
132
|
+
* @param options - Options used to turn on special repeat features.
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
export declare function repeat<TSource = any, TArray extends ReadonlyArray<any> = ReadonlyArray<any>>(itemsBinding: Binding<TSource, TArray, ExecutionContext<TSource>>, templateOrTemplateBinding: ChildViewTemplate | Binding<TSource, ChildViewTemplate, ChildContext>, options?: {
|
|
136
|
+
positioning: false;
|
|
137
|
+
} | {
|
|
138
|
+
recycle: true;
|
|
139
|
+
} | {
|
|
140
|
+
positioning: false;
|
|
141
|
+
recycle: false;
|
|
142
|
+
} | {
|
|
143
|
+
positioning: false;
|
|
144
|
+
recycle: true;
|
|
145
|
+
}): CaptureType<TSource>;
|
|
146
|
+
/**
|
|
147
|
+
* A directive that enables list rendering.
|
|
148
|
+
* @param itemsBinding - The array to render.
|
|
149
|
+
* @param templateOrTemplateBinding - The template or a template binding used obtain a template
|
|
150
|
+
* to render for each item in the array.
|
|
151
|
+
* @param options - Options used to turn on special repeat features.
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
export declare function repeat<TSource = any, TArray extends ReadonlyArray<any> = ReadonlyArray<any>>(itemsBinding: Binding<TSource, TArray, ExecutionContext<TSource>>, templateOrTemplateBinding: ItemViewTemplate | Binding<TSource, ItemViewTemplate, ItemContext>, options: {
|
|
155
|
+
positioning: true;
|
|
156
|
+
} | {
|
|
157
|
+
positioning: true;
|
|
158
|
+
recycle: true;
|
|
159
|
+
} | {
|
|
160
|
+
positioning: true;
|
|
161
|
+
recycle: false;
|
|
162
|
+
}): CaptureType<TSource>;
|
|
@@ -1,34 +1,33 @@
|
|
|
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 slotted node observation.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export interface
|
|
7
|
+
export interface SlottedDirectiveOptions<T = any> extends NodeBehaviorOptions<T>, AssignedNodesOptions {
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* The runtime behavior for slotted node observation.
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
13
|
-
export declare class
|
|
14
|
-
/**
|
|
15
|
-
* Creates an instance of SlottedBehavior.
|
|
16
|
-
* @param target - The slot element target to observe.
|
|
17
|
-
* @param options - The options to use when observing the slot.
|
|
18
|
-
*/
|
|
19
|
-
constructor(target: HTMLSlotElement, options: SlottedBehaviorOptions);
|
|
13
|
+
export declare class SlottedDirective extends NodeObservationDirective<SlottedDirectiveOptions> {
|
|
20
14
|
/**
|
|
21
15
|
* Begins observation of the nodes.
|
|
16
|
+
* @param target - The target to observe.
|
|
22
17
|
*/
|
|
23
|
-
observe(): void;
|
|
18
|
+
observe(target: EventSource): void;
|
|
24
19
|
/**
|
|
25
20
|
* Disconnects observation of the nodes.
|
|
21
|
+
* @param target - The target to unobserve.
|
|
26
22
|
*/
|
|
27
|
-
disconnect(): void;
|
|
23
|
+
disconnect(target: EventSource): void;
|
|
28
24
|
/**
|
|
29
|
-
* Retrieves the nodes that should be assigned to the
|
|
25
|
+
* Retrieves the raw nodes that should be assigned to the source property.
|
|
26
|
+
* @param target - The target to get the node to.
|
|
30
27
|
*/
|
|
31
|
-
|
|
28
|
+
getNodes(target: HTMLSlotElement): Node[];
|
|
29
|
+
/** @internal */
|
|
30
|
+
handleEvent(event: Event): void;
|
|
32
31
|
}
|
|
33
32
|
/**
|
|
34
33
|
* A directive that observes the `assignedNodes()` of a slot and updates a property
|
|
@@ -36,4 +35,4 @@ export declare class SlottedBehavior extends NodeObservationBehavior<SlottedBeha
|
|
|
36
35
|
* @param propertyOrOptions - The options used to configure slotted node observation.
|
|
37
36
|
* @public
|
|
38
37
|
*/
|
|
39
|
-
export declare function slotted<T = any>(propertyOrOptions: (keyof T & string) |
|
|
38
|
+
export declare function slotted<T = any>(propertyOrOptions: (keyof T & string) | SlottedDirectiveOptions<keyof T & string>): CaptureType<T>;
|