@microsoft/fast-element 2.0.0-beta.1 → 2.0.0-beta.4

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.
Files changed (58) hide show
  1. package/CHANGELOG.json +147 -0
  2. package/CHANGELOG.md +42 -1
  3. package/dist/dts/components/fast-definitions.d.ts +11 -8
  4. package/dist/dts/components/fast-element.d.ts +13 -3
  5. package/dist/dts/context.d.ts +157 -0
  6. package/dist/dts/di/di.d.ts +854 -0
  7. package/dist/dts/hooks.d.ts +2 -2
  8. package/dist/dts/interfaces.d.ts +39 -7
  9. package/dist/dts/metadata.d.ts +25 -0
  10. package/dist/dts/observation/arrays.d.ts +1 -1
  11. package/dist/dts/observation/behavior.d.ts +4 -4
  12. package/dist/dts/observation/observable.d.ts +59 -72
  13. package/dist/dts/styles/element-styles.d.ts +6 -0
  14. package/dist/dts/templating/binding-signal.d.ts +21 -0
  15. package/dist/dts/templating/binding-two-way.d.ts +31 -0
  16. package/dist/dts/templating/binding.d.ts +74 -201
  17. package/dist/dts/templating/compiler.d.ts +1 -2
  18. package/dist/dts/templating/html-directive.d.ts +31 -3
  19. package/dist/dts/templating/render.d.ts +277 -0
  20. package/dist/dts/templating/repeat.d.ts +13 -63
  21. package/dist/dts/templating/template.d.ts +11 -60
  22. package/dist/dts/templating/view.d.ts +9 -9
  23. package/dist/dts/templating/when.d.ts +3 -3
  24. package/dist/dts/testing/exports.d.ts +2 -0
  25. package/dist/dts/testing/fixture.d.ts +90 -0
  26. package/dist/dts/testing/timeout.d.ts +7 -0
  27. package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +0 -0
  28. package/dist/esm/components/fast-definitions.js +27 -27
  29. package/dist/esm/components/fast-element.js +20 -4
  30. package/dist/esm/context.js +163 -0
  31. package/dist/esm/debug.js +35 -4
  32. package/dist/esm/di/di.js +1349 -0
  33. package/dist/esm/metadata.js +60 -0
  34. package/dist/esm/observation/arrays.js +1 -1
  35. package/dist/esm/observation/observable.js +73 -21
  36. package/dist/esm/platform.js +1 -1
  37. package/dist/esm/styles/element-styles.js +14 -0
  38. package/dist/esm/templating/binding-signal.js +79 -0
  39. package/dist/esm/templating/binding-two-way.js +98 -0
  40. package/dist/esm/templating/binding.js +137 -313
  41. package/dist/esm/templating/compiler.js +30 -7
  42. package/dist/esm/templating/html-directive.js +16 -2
  43. package/dist/esm/templating/render.js +392 -0
  44. package/dist/esm/templating/repeat.js +60 -38
  45. package/dist/esm/templating/template.js +9 -26
  46. package/dist/esm/templating/when.js +5 -4
  47. package/dist/esm/testing/exports.js +2 -0
  48. package/dist/esm/testing/fixture.js +88 -0
  49. package/dist/esm/testing/timeout.js +24 -0
  50. package/dist/fast-element.api.json +8509 -10358
  51. package/dist/fast-element.d.ts +315 -522
  52. package/dist/fast-element.debug.js +417 -438
  53. package/dist/fast-element.debug.min.js +1 -1
  54. package/dist/fast-element.js +382 -434
  55. package/dist/fast-element.min.js +1 -1
  56. package/dist/fast-element.untrimmed.d.ts +324 -529
  57. package/docs/api-report.md +124 -232
  58. package/package.json +32 -4
@@ -0,0 +1,277 @@
1
+ import type { FASTElement } from "../components/fast-element.js";
2
+ import { Constructable } from "../interfaces.js";
3
+ import type { Behavior } from "../observation/behavior.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, ViewBehaviorFactory, ViewBehaviorTargets } 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, TParent = any> implements Behavior, Subscriber {
14
+ private directive;
15
+ private location;
16
+ private source;
17
+ private view;
18
+ private template;
19
+ private templateBindingObserver;
20
+ private data;
21
+ private dataBindingObserver;
22
+ private originalContext;
23
+ private childContext;
24
+ /**
25
+ * Creates an instance of RenderBehavior.
26
+ * @param location - A Node representing the location where this behavior will render.
27
+ * @param dataBinding - A binding expression that returns the data to render.
28
+ * @param templateBinding - A binding expression that returns the template to use with the data.
29
+ */
30
+ constructor(directive: RenderDirective, location: Node);
31
+ /**
32
+ * Bind this behavior to the source.
33
+ * @param source - The source to bind to.
34
+ * @param context - The execution context that the binding is operating within.
35
+ */
36
+ bind(source: TSource, context: ExecutionContext): void;
37
+ /**
38
+ * Unbinds this behavior from the source.
39
+ * @param source - The source to unbind from.
40
+ */
41
+ unbind(source: TSource, context: ExecutionContext<TParent>): void;
42
+ /** @internal */
43
+ handleChange(source: any, observer: ExpressionObserver): void;
44
+ private refreshView;
45
+ }
46
+ /**
47
+ * A Directive that enables use of the RenderBehavior.
48
+ * @public
49
+ */
50
+ export declare class RenderDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
51
+ readonly dataBinding: Binding<TSource>;
52
+ readonly templateBinding: Binding<TSource, ContentTemplate>;
53
+ readonly templateBindingDependsOnData: boolean;
54
+ /**
55
+ * The unique id of the factory.
56
+ */
57
+ id: string;
58
+ /**
59
+ * The structural id of the DOM node to which the created behavior will apply.
60
+ */
61
+ nodeId: string;
62
+ /**
63
+ * Creates an instance of RenderDirective.
64
+ * @param dataBinding - A binding expression that returns the data to render.
65
+ * @param templateBinding - A binding expression that returns the template to use to render the data.
66
+ */
67
+ constructor(dataBinding: Binding<TSource>, templateBinding: Binding<TSource, ContentTemplate>, templateBindingDependsOnData: boolean);
68
+ /**
69
+ * Creates HTML to be used within a template.
70
+ * @param add - Can be used to add behavior factories to a template.
71
+ */
72
+ createHTML(add: AddViewBehaviorFactory): string;
73
+ /**
74
+ * Creates a behavior.
75
+ * @param targets - The targets available for behaviors to be attached to.
76
+ */
77
+ createBehavior(targets: ViewBehaviorTargets): RenderBehavior<TSource>;
78
+ }
79
+ /**
80
+ * Provides instructions for how to render a type.
81
+ * @public
82
+ */
83
+ export interface RenderInstruction {
84
+ /**
85
+ * Identifies this as a RenderInstruction.
86
+ */
87
+ brand: symbol;
88
+ /**
89
+ * The type this instruction is associated with.
90
+ */
91
+ type: Constructable;
92
+ /**
93
+ * The template to use when rendering.
94
+ */
95
+ template: ContentTemplate;
96
+ /**
97
+ * A name that can be used to identify the instruction.
98
+ */
99
+ name: string;
100
+ }
101
+ /**
102
+ * Render options that are common to all configurations.
103
+ * @public
104
+ */
105
+ export declare type CommonRenderOptions = {
106
+ /**
107
+ * The type this instruction is associated with.
108
+ */
109
+ type: Constructable;
110
+ /**
111
+ * A name that can be used to identify the instruction.
112
+ */
113
+ name?: string;
114
+ };
115
+ /**
116
+ * Render options used to specify a template.
117
+ * @public
118
+ */
119
+ export declare type TemplateRenderOptions = CommonRenderOptions & {
120
+ /**
121
+ * The template to use when rendering.
122
+ */
123
+ template: ContentTemplate;
124
+ };
125
+ /**
126
+ * Render options that are common to all element render instructions.
127
+ * @public
128
+ */
129
+ export declare type BaseElementRenderOptions<TSource = any, TParent = any> = CommonRenderOptions & {
130
+ /**
131
+ * Attributes to use when creating the element template.
132
+ */
133
+ attributes?: Record<string, string | TemplateValue<TSource, TParent>>;
134
+ /**
135
+ * Content to use when creating the element template.
136
+ */
137
+ content?: string | SyntheticViewTemplate;
138
+ };
139
+ /**
140
+ * Render options used to specify an element.
141
+ * @public
142
+ */
143
+ export declare type ElementConstructorRenderOptions<TSource = any, TParent = any> = BaseElementRenderOptions<TSource, TParent> & {
144
+ /**
145
+ * The element to use when rendering.
146
+ */
147
+ element: Constructable<FASTElement>;
148
+ };
149
+ /**
150
+ * Render options use to specify an element by tag name.
151
+ * @public
152
+ */
153
+ export declare type TagNameRenderOptions<TSource = any, TParent = any> = BaseElementRenderOptions<TSource, TParent> & {
154
+ /**
155
+ * The tag name to use when rendering.
156
+ */
157
+ tagName: string;
158
+ };
159
+ declare function createElementTemplate<TSource = any, TParent = any>(tagName: string, attributes?: Record<string, string | TemplateValue<TSource, TParent>>, content?: string | ContentTemplate): ViewTemplate<TSource, TParent>;
160
+ declare function create(options: TagNameRenderOptions): RenderInstruction;
161
+ declare function create(options: ElementConstructorRenderOptions): RenderInstruction;
162
+ declare function create(options: TemplateRenderOptions): RenderInstruction;
163
+ declare function instanceOf(object: any): object is RenderInstruction;
164
+ declare function register(options: TagNameRenderOptions): RenderInstruction;
165
+ declare function register(options: ElementConstructorRenderOptions): RenderInstruction;
166
+ declare function register(options: TemplateRenderOptions): RenderInstruction;
167
+ declare function register(instruction: RenderInstruction): RenderInstruction;
168
+ declare function getByType(type: Constructable, name?: string): RenderInstruction | undefined;
169
+ declare function getForInstance(object: any, name?: string): RenderInstruction | undefined;
170
+ /**
171
+ * Provides APIs for creating and interacting with render instructions.
172
+ * @public
173
+ */
174
+ export declare const RenderInstruction: Readonly<{
175
+ /**
176
+ * Checks whether the provided object is a RenderInstruction.
177
+ * @param object - The object to check.
178
+ * @returns true if the object is a RenderInstruction; false otherwise
179
+ */
180
+ instanceOf: typeof instanceOf;
181
+ /**
182
+ * Creates a RenderInstruction for a set of options.
183
+ * @param options - The options to use when creating the RenderInstruction.
184
+ */
185
+ create: typeof create;
186
+ /**
187
+ * Creates a template based on a tag name.
188
+ * @param tagName - The tag name to use when creating the template.
189
+ * @param attributes - The attributes to apply to the element.
190
+ * @param content - The content to insert into the element.
191
+ * @returns A template based on the provided specifications.
192
+ */
193
+ createElementTemplate: typeof createElementTemplate;
194
+ /**
195
+ * Creates and registers an instruction.
196
+ * @param options The options to use when creating the RenderInstruction.
197
+ * @remarks
198
+ * A previously created RenderInstruction can also be registered.
199
+ */
200
+ register: typeof register;
201
+ /**
202
+ * Finds a previously registered RenderInstruction by type and optionally by name.
203
+ * @param type - The type to retrieve the RenderInstruction for.
204
+ * @param name - An optional name used in differentiating between multiple registered instructions.
205
+ * @returns The located RenderInstruction that matches the criteria or undefined if none is found.
206
+ */
207
+ getByType: typeof getByType;
208
+ /**
209
+ * Finds a previously registered RenderInstruction for the instance's type and optionally by name.
210
+ * @param object - The instance to retrieve the RenderInstruction for.
211
+ * @param name - An optional name used in differentiating between multiple registered instructions.
212
+ * @returns The located RenderInstruction that matches the criteria or undefined if none is found.
213
+ */
214
+ getForInstance: typeof getForInstance;
215
+ }>;
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<TagNameRenderOptions, "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<ElementConstructorRenderOptions, "type">): ClassDecorator;
228
+ /**
229
+ * Decorates a type with render instruction metadata.
230
+ * @param options - The options used in creating the RenderInstruction.
231
+ * @public
232
+ */
233
+ export declare function renderWith(options: Omit<TemplateRenderOptions, "type">): ClassDecorator;
234
+ /**
235
+ * Decorates a type with render instruction metadata.
236
+ * @param element - The element to use to render the decorated class.
237
+ * @param name - An optional name to differentiate the render instruction.
238
+ * @public
239
+ */
240
+ export declare function renderWith(element: Constructable<FASTElement>, name?: string): ClassDecorator;
241
+ /**
242
+ * Decorates a type with render instruction metadata.
243
+ * @param template - The template to use to render the decorated class.
244
+ * @param name - An optional name to differentiate the render instruction.
245
+ * @public
246
+ */
247
+ export declare function renderWith(template: ContentTemplate, name?: string): ClassDecorator;
248
+ /**
249
+ * @internal
250
+ */
251
+ export declare class NodeTemplate implements ContentTemplate, ContentView {
252
+ readonly node: Node;
253
+ constructor(node: Node);
254
+ bind(source: any, context: ExecutionContext<any>): void;
255
+ unbind(): void;
256
+ insertBefore(refNode: Node): void;
257
+ remove(): void;
258
+ create(): ContentView;
259
+ }
260
+ /**
261
+ * Creates a RenderDirective for use in advanced rendering scenarios.
262
+ * @param value - The binding expression that returns the data to be rendered. The expression
263
+ * can also return a Node to render directly.
264
+ * @param template - A template to render the data with
265
+ * or a string to indicate which RenderInstruction to use when looking up a RenderInstruction.
266
+ * Expressions can also be provided to dynamically determine either the template or the name.
267
+ * @returns A RenderDirective suitable for use in a template.
268
+ * @remarks
269
+ * If no binding is provided, then a default binding that returns the source is created.
270
+ * If no template is provided, then a binding is created that will use registered
271
+ * RenderInstructions to determine the view.
272
+ * If the template binding returns a string, then it will be used to look up a
273
+ * RenderInstruction to determine the view.
274
+ * @public
275
+ */
276
+ export declare function render<TSource = any, TItem = any>(value?: Expression<TSource, TItem> | Binding<TSource, TItem> | {}, template?: ContentTemplate | string | Expression<TSource, ContentTemplate | string | Node> | Binding<TSource, ContentTemplate | string | Node>): CaptureType<TSource>;
277
+ export {};
@@ -1,9 +1,9 @@
1
1
  import type { Behavior } from "../observation/behavior.js";
2
2
  import type { Subscriber } from "../observation/notifier.js";
3
- import { Binding, ChildContext, ExecutionContext, ItemContext, RootContext } from "../observation/observable.js";
3
+ import { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
4
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";
5
+ import { AddViewBehaviorFactory, Binding, HTMLDirective, ViewBehaviorFactory, ViewBehaviorTargets } from "./html-directive.js";
6
+ import type { CaptureType, SyntheticViewTemplate, ViewTemplate } from "./template.js";
7
7
  /**
8
8
  * Options for configuring repeat behavior.
9
9
  * @public
@@ -23,10 +23,8 @@ export interface RepeatOptions {
23
23
  * @public
24
24
  */
25
25
  export declare class RepeatBehavior<TSource = any> implements Behavior, Subscriber {
26
+ private directive;
26
27
  private location;
27
- private itemsBinding;
28
- private templateBinding;
29
- private options;
30
28
  private source;
31
29
  private views;
32
30
  private template;
@@ -40,13 +38,13 @@ export declare class RepeatBehavior<TSource = any> implements Behavior, Subscrib
40
38
  /**
41
39
  * Creates an instance of RepeatBehavior.
42
40
  * @param location - The location in the DOM to render the repeat.
43
- * @param itemsBinding - The array to render.
41
+ * @param dataBinding - The array to render.
44
42
  * @param isItemsBindingVolatile - Indicates whether the items binding has volatile dependencies.
45
43
  * @param templateBinding - The template to render for each item.
46
44
  * @param isTemplateBindingVolatile - Indicates whether the template binding has volatile dependencies.
47
45
  * @param options - Options used to turn on special repeat features.
48
46
  */
49
- constructor(location: Node, itemsBinding: Binding<TSource, any[]>, isItemsBindingVolatile: boolean, templateBinding: Binding<TSource, SyntheticViewTemplate>, isTemplateBindingVolatile: boolean, options: RepeatOptions);
47
+ constructor(directive: RepeatDirective, location: Node);
50
48
  /**
51
49
  * Bind this behavior to the source.
52
50
  * @param source - The source to bind to.
@@ -63,7 +61,7 @@ export declare class RepeatBehavior<TSource = any> implements Behavior, Subscrib
63
61
  * @param source - The source of the change.
64
62
  * @param args - The details about what was changed.
65
63
  */
66
- handleChange(source: any, args: Splice[]): void;
64
+ handleChange(source: any, args: Splice[] | ExpressionObserver): void;
67
65
  private observeItems;
68
66
  private updateViews;
69
67
  private refreshAllViews;
@@ -74,11 +72,9 @@ export declare class RepeatBehavior<TSource = any> implements Behavior, Subscrib
74
72
  * @public
75
73
  */
76
74
  export declare class RepeatDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
77
- readonly itemsBinding: Binding;
75
+ readonly dataBinding: Binding<TSource>;
78
76
  readonly templateBinding: Binding<TSource, SyntheticViewTemplate>;
79
77
  readonly options: RepeatOptions;
80
- private isItemsBindingVolatile;
81
- private isTemplateBindingVolatile;
82
78
  /**
83
79
  * The unique id of the factory.
84
80
  */
@@ -94,11 +90,11 @@ export declare class RepeatDirective<TSource = any> implements HTMLDirective, Vi
94
90
  createHTML(add: AddViewBehaviorFactory): string;
95
91
  /**
96
92
  * Creates an instance of RepeatDirective.
97
- * @param itemsBinding - The binding that provides the array to render.
93
+ * @param dataBinding - The binding that provides the array to render.
98
94
  * @param templateBinding - The template binding used to obtain a template to render for each item in the array.
99
95
  * @param options - Options used to turn on special repeat features.
100
96
  */
101
- constructor(itemsBinding: Binding, templateBinding: Binding<TSource, SyntheticViewTemplate>, options: RepeatOptions);
97
+ constructor(dataBinding: Binding<TSource>, templateBinding: Binding<TSource, SyntheticViewTemplate>, options: RepeatOptions);
102
98
  /**
103
99
  * Creates a behavior for the provided target node.
104
100
  * @param target - The node instance to create the behavior for.
@@ -107,56 +103,10 @@ export declare class RepeatDirective<TSource = any> implements HTMLDirective, Vi
107
103
  }
108
104
  /**
109
105
  * A directive that enables list rendering.
110
- * @param itemsBinding - The array to render.
111
- * @param templateOrTemplateBinding - The template or a template binding used obtain a template
106
+ * @param items - The array to render.
107
+ * @param template - The template or a template binding used obtain a template
112
108
  * to render for each item in the array.
113
109
  * @param options - Options used to turn on special repeat features.
114
110
  * @public
115
111
  */
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>;
112
+ export declare function repeat<TSource = any, TArray extends ReadonlyArray<any> = ReadonlyArray<any>>(items: Expression<TSource, TArray, ExecutionContext<TSource>> | Binding<TSource, TArray> | ReadonlyArray<any>, template: Expression<TSource, ViewTemplate> | Binding<TSource, ViewTemplate> | ViewTemplate, options?: RepeatOptions): CaptureType<TSource>;
@@ -1,12 +1,11 @@
1
- import { Binding, ChildContext, ExecutionContext, ItemContext } from "../observation/observable.js";
2
- import { HTMLDirective, ViewBehaviorFactory } from "./html-directive.js";
1
+ import { ExecutionContext, Expression } from "../observation/observable.js";
2
+ import { Binding, HTMLDirective, ViewBehaviorFactory } from "./html-directive.js";
3
3
  import type { ElementView, HTMLView, SyntheticView } from "./view.js";
4
4
  /**
5
5
  * A template capable of creating views specifically for rendering custom elements.
6
6
  * @public
7
7
  */
8
8
  export interface ElementViewTemplate<TSource = any, TParent = any> {
9
- type: "element";
10
9
  /**
11
10
  * Creates an ElementView instance based on this template definition.
12
11
  * @param hostBindingTarget - The element that host behaviors will be bound to.
@@ -25,57 +24,29 @@ export interface ElementViewTemplate<TSource = any, TParent = any> {
25
24
  * A template capable of rendering views not specifically connected to custom elements.
26
25
  * @public
27
26
  */
28
- export interface SyntheticViewTemplate<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext<TParent>> {
29
- type: "synthetic";
27
+ export interface SyntheticViewTemplate<TSource = any, TParent = any> {
30
28
  /**
31
29
  * Creates a SyntheticView instance based on this template definition.
32
30
  */
33
- create(): SyntheticView<TSource, TParent, TContext>;
34
- }
35
- /**
36
- * A template capable of rendering child views not specifically connected to custom elements.
37
- * @public
38
- */
39
- export interface ChildViewTemplate<TSource = any, TParent = any> {
40
- type: "child";
41
- /**
42
- * Creates a SyntheticView instance based on this template definition.
43
- */
44
- create(): SyntheticView<TSource, TParent, ChildContext<TParent>>;
45
- }
46
- /**
47
- * A template capable of rendering item views not specifically connected to custom elements.
48
- * @public
49
- */
50
- export interface ItemViewTemplate<TSource = any, TParent = any> {
51
- type: "item";
52
- /**
53
- * Creates a SyntheticView instance based on this template definition.
54
- */
55
- create(): SyntheticView<TSource, TParent, ItemContext<TParent>>;
31
+ create(): SyntheticView<TSource, TParent>;
56
32
  }
57
33
  /**
58
34
  * The result of a template compilation operation.
59
35
  * @public
60
36
  */
61
- export interface HTMLTemplateCompilationResult<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext<TParent>> {
37
+ export interface HTMLTemplateCompilationResult<TSource = any, TParent = any> {
62
38
  /**
63
39
  * Creates a view instance.
64
40
  * @param hostBindingTarget - The host binding target for the view.
65
41
  */
66
- createView(hostBindingTarget?: Element): HTMLView<TSource, TParent, TContext>;
42
+ createView(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
67
43
  }
68
44
  /**
69
45
  * A template capable of creating HTMLView instances or rendering directly to DOM.
70
46
  * @public
71
47
  */
72
- export declare class ViewTemplate<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext> implements ElementViewTemplate<TSource, TParent>, SyntheticViewTemplate<TSource, TParent, TContext> {
48
+ export declare class ViewTemplate<TSource = any, TParent = any> implements ElementViewTemplate<TSource, TParent>, SyntheticViewTemplate<TSource, TParent> {
73
49
  private result;
74
- /**
75
- * Used for TypeScript purposes only.
76
- * Do not use.
77
- */
78
- type: any;
79
50
  /**
80
51
  * The html representing what this template will
81
52
  * instantiate, including placeholders for directives.
@@ -95,7 +66,7 @@ export declare class ViewTemplate<TSource = any, TParent = any, TContext extends
95
66
  * Creates an HTMLView instance based on this template definition.
96
67
  * @param hostBindingTarget - The element that host behaviors will be bound to.
97
68
  */
98
- create(hostBindingTarget?: Element): HTMLView<TSource, TParent, TContext>;
69
+ create(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
99
70
  /**
100
71
  * Creates an HTMLView from this template, binds it to the source, and then appends it to the host.
101
72
  * @param source - The data source to bind the template to.
@@ -103,7 +74,7 @@ export declare class ViewTemplate<TSource = any, TParent = any, TContext extends
103
74
  * @param hostBindingTarget - An HTML element to target the host bindings at if different from the
104
75
  * host that the template is being attached to.
105
76
  */
106
- render(source: TSource, host: Node, hostBindingTarget?: Element, context?: TContext): HTMLView<TSource, TParent, TContext>;
77
+ render(source: TSource, host: Node, hostBindingTarget?: Element, context?: ExecutionContext): HTMLView<TSource, TParent>;
107
78
  }
108
79
  /**
109
80
  * A marker interface used to capture types when interpolating Directive helpers
@@ -116,7 +87,7 @@ export interface CaptureType<TSource> {
116
87
  * Represents the types of values that can be interpolated into a template.
117
88
  * @public
118
89
  */
119
- export declare type TemplateValue<TSource, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext<TParent>> = Binding<TSource, any, TContext> | HTMLDirective | CaptureType<TSource>;
90
+ export declare type TemplateValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource>;
120
91
  /**
121
92
  * Transforms a template literal string into a ViewTemplate.
122
93
  * @param strings - The string fragments that are interpolated with the values.
@@ -126,24 +97,4 @@ export declare type TemplateValue<TSource, TParent = any, TContext extends Execu
126
97
  * other template instances, and Directive instances.
127
98
  * @public
128
99
  */
129
- export declare function html<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext<TParent>>(strings: TemplateStringsArray, ...values: TemplateValue<TSource, TParent, TContext>[]): ViewTemplate<TSource, TParent>;
130
- /**
131
- * Transforms a template literal string into a ChildViewTemplate.
132
- * @param strings - The string fragments that are interpolated with the values.
133
- * @param values - The values that are interpolated with the string fragments.
134
- * @remarks
135
- * The html helper supports interpolation of strings, numbers, binding expressions,
136
- * other template instances, and Directive instances.
137
- * @public
138
- */
139
- export declare const child: <TChild = any, TParent = any>(strings: TemplateStringsArray, ...values: TemplateValue<TChild, TParent, ChildContext<TParent>>[]) => ChildViewTemplate<TChild, TParent>;
140
- /**
141
- * Transforms a template literal string into an ItemViewTemplate.
142
- * @param strings - The string fragments that are interpolated with the values.
143
- * @param values - The values that are interpolated with the string fragments.
144
- * @remarks
145
- * The html helper supports interpolation of strings, numbers, binding expressions,
146
- * other template instances, and Directive instances.
147
- * @public
148
- */
149
- export declare const item: <TItem = any, TParent = any>(strings: TemplateStringsArray, ...values: TemplateValue<TItem, TParent, ItemContext<TParent>>[]) => ItemViewTemplate<TItem, TParent>;
100
+ export declare function html<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: TemplateValue<TSource, TParent>[]): ViewTemplate<TSource, TParent>;
@@ -1,15 +1,15 @@
1
1
  import type { Disposable } from "../interfaces.js";
2
- import type { ExecutionContext, RootContext } from "../observation/observable.js";
2
+ import type { ExecutionContext } from "../observation/observable.js";
3
3
  import type { ViewBehaviorFactory, ViewBehaviorTargets } from "./html-directive.js";
4
4
  /**
5
5
  * Represents a collection of DOM nodes which can be bound to a data source.
6
6
  * @public
7
7
  */
8
- export interface View<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext<TParent>> extends Disposable {
8
+ export interface View<TSource = any, TParent = any> extends Disposable {
9
9
  /**
10
10
  * The execution context the view is running within.
11
11
  */
12
- readonly context: TContext | null;
12
+ readonly context: ExecutionContext<TParent> | null;
13
13
  /**
14
14
  * The data that the view is bound to.
15
15
  */
@@ -19,7 +19,7 @@ export interface View<TSource = any, TParent = any, TContext extends ExecutionCo
19
19
  * @param source - The binding source for the view's binding behaviors.
20
20
  * @param context - The execution context to run the view within.
21
21
  */
22
- bind(source: TSource, context: TContext): void;
22
+ bind(source: TSource, context: ExecutionContext<TParent>): void;
23
23
  /**
24
24
  * Unbinds a view's behaviors from its binding source and context.
25
25
  */
@@ -29,7 +29,7 @@ export interface View<TSource = any, TParent = any, TContext extends ExecutionCo
29
29
  * A View representing DOM nodes specifically for rendering the view of a custom element.
30
30
  * @public
31
31
  */
32
- export interface ElementView<TSource = any, TParent = any> extends View<TSource, TParent, RootContext> {
32
+ export interface ElementView<TSource = any, TParent = any> extends View<TSource, TParent> {
33
33
  /**
34
34
  * Appends the view's DOM nodes to the referenced node.
35
35
  * @param node - The parent node to append the view's DOM nodes to.
@@ -40,7 +40,7 @@ export interface ElementView<TSource = any, TParent = any> extends View<TSource,
40
40
  * A view representing a range of DOM nodes which can be added/removed ad hoc.
41
41
  * @public
42
42
  */
43
- export interface SyntheticView<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext<TParent>> extends View<TSource, TParent, TContext> {
43
+ export interface SyntheticView<TSource = any, TParent = any> extends View<TSource, TParent> {
44
44
  /**
45
45
  * The first DOM node in the range of nodes that make up the view.
46
46
  */
@@ -64,7 +64,7 @@ export interface SyntheticView<TSource = any, TParent = any, TContext extends Ex
64
64
  * The standard View implementation, which also implements ElementView and SyntheticView.
65
65
  * @public
66
66
  */
67
- export declare class HTMLView<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = ExecutionContext<TParent>> implements ElementView<TSource, TParent>, SyntheticView<TSource, TParent, TContext> {
67
+ export declare class HTMLView<TSource = any, TParent = any> implements ElementView<TSource, TParent>, SyntheticView<TSource, TParent> {
68
68
  private fragment;
69
69
  private factories;
70
70
  private targets;
@@ -76,7 +76,7 @@ export declare class HTMLView<TSource = any, TParent = any, TContext extends Exe
76
76
  /**
77
77
  * The execution context the view is running within.
78
78
  */
79
- context: TContext | null;
79
+ context: ExecutionContext<TParent> | null;
80
80
  /**
81
81
  * The first DOM node in the range of nodes that make up the view.
82
82
  */
@@ -116,7 +116,7 @@ export declare class HTMLView<TSource = any, TParent = any, TContext extends Exe
116
116
  * @param source - The binding source for the view's binding behaviors.
117
117
  * @param context - The execution context to run the behaviors within.
118
118
  */
119
- bind(source: TSource, context: TContext): void;
119
+ bind(source: TSource, context: ExecutionContext<TParent>): void;
120
120
  /**
121
121
  * Unbinds a view's behaviors from its binding source.
122
122
  */
@@ -1,10 +1,10 @@
1
- import type { Binding } from "../observation/observable.js";
1
+ import type { Expression } from "../observation/observable.js";
2
2
  import type { CaptureType, SyntheticViewTemplate } from "./template.js";
3
3
  /**
4
4
  * A directive that enables basic conditional rendering in a template.
5
- * @param binding - The condition to test for rendering.
5
+ * @param condition - The condition to test for rendering.
6
6
  * @param templateOrTemplateBinding - The template or a binding that gets
7
7
  * the template to render when the condition is true.
8
8
  * @public
9
9
  */
10
- export declare function when<TSource = any, TReturn = any>(binding: Binding<TSource, TReturn>, templateOrTemplateBinding: SyntheticViewTemplate | Binding<TSource, SyntheticViewTemplate>): CaptureType<TSource>;
10
+ export declare function when<TSource = any, TReturn = any>(condition: Expression<TSource, TReturn> | boolean, templateOrTemplateBinding: SyntheticViewTemplate | Expression<TSource, SyntheticViewTemplate>): CaptureType<TSource>;
@@ -0,0 +1,2 @@
1
+ export { timeout } from "./timeout.js";
2
+ export * from "./fixture.js";