@microsoft/fast-element 1.10.5 → 2.0.0-beta.10

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 (122) hide show
  1. package/.eslintrc.json +1 -12
  2. package/CHANGELOG.json +629 -6
  3. package/CHANGELOG.md +152 -5
  4. package/dist/dts/components/attributes.d.ts +14 -1
  5. package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +32 -32
  6. package/dist/dts/components/fast-definitions.d.ts +51 -11
  7. package/dist/dts/components/fast-element.d.ts +18 -23
  8. package/dist/dts/context.d.ts +157 -0
  9. package/dist/{esm/observation/behavior.js → dts/debug.d.ts} +0 -0
  10. package/dist/dts/di/di.d.ts +899 -0
  11. package/dist/dts/index.d.ts +17 -16
  12. package/dist/dts/index.debug.d.ts +2 -0
  13. package/dist/dts/index.rollup.d.ts +2 -0
  14. package/dist/dts/index.rollup.debug.d.ts +3 -0
  15. package/dist/dts/interfaces.d.ts +176 -0
  16. package/dist/dts/metadata.d.ts +25 -0
  17. package/dist/dts/observation/arrays.d.ts +207 -0
  18. package/dist/dts/observation/notifier.d.ts +18 -18
  19. package/dist/dts/observation/observable.d.ts +117 -34
  20. package/dist/dts/observation/update-queue.d.ts +40 -0
  21. package/dist/dts/pending-task.d.ts +20 -0
  22. package/dist/dts/platform.d.ts +23 -66
  23. package/dist/dts/polyfills.d.ts +8 -0
  24. package/dist/dts/state/exports.d.ts +3 -0
  25. package/dist/dts/state/reactive.d.ts +8 -0
  26. package/dist/dts/state/state.d.ts +141 -0
  27. package/dist/dts/state/visitor.d.ts +6 -0
  28. package/dist/dts/state/watch.d.ts +10 -0
  29. package/dist/dts/styles/css-directive.d.ts +44 -6
  30. package/dist/dts/styles/css.d.ts +19 -3
  31. package/dist/dts/styles/element-styles.d.ts +49 -63
  32. package/dist/dts/styles/host.d.ts +68 -0
  33. package/dist/dts/templating/binding-signal.d.ts +21 -0
  34. package/dist/dts/templating/binding-two-way.d.ts +39 -0
  35. package/dist/dts/templating/binding.d.ts +101 -70
  36. package/dist/dts/templating/children.d.ts +18 -15
  37. package/dist/dts/templating/compiler.d.ts +46 -28
  38. package/dist/dts/templating/dom.d.ts +41 -0
  39. package/dist/dts/templating/html-directive.d.ts +239 -45
  40. package/dist/dts/templating/markup.d.ts +48 -0
  41. package/dist/dts/templating/node-observation.d.ts +45 -30
  42. package/dist/dts/templating/ref.d.ts +6 -20
  43. package/dist/dts/templating/render.d.ts +272 -0
  44. package/dist/dts/templating/repeat.d.ts +36 -33
  45. package/dist/dts/templating/slotted.d.ts +13 -14
  46. package/dist/dts/templating/template.d.ts +28 -22
  47. package/dist/dts/templating/view.d.ts +82 -24
  48. package/dist/dts/templating/when.d.ts +3 -3
  49. package/dist/dts/testing/exports.d.ts +3 -0
  50. package/dist/dts/testing/fakes.d.ts +4 -0
  51. package/dist/dts/testing/fixture.d.ts +84 -0
  52. package/dist/dts/testing/timeout.d.ts +7 -0
  53. package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +1 -1
  54. package/dist/dts/utilities.d.ts +22 -0
  55. package/dist/esm/components/attributes.js +38 -28
  56. package/dist/esm/components/{controller.js → element-controller.js} +150 -140
  57. package/dist/esm/components/fast-definitions.js +48 -46
  58. package/dist/esm/components/fast-element.js +31 -12
  59. package/dist/esm/context.js +163 -0
  60. package/dist/esm/debug.js +61 -0
  61. package/dist/esm/di/di.js +1435 -0
  62. package/dist/esm/index.debug.js +2 -0
  63. package/dist/esm/index.js +20 -14
  64. package/dist/esm/index.rollup.debug.js +3 -0
  65. package/dist/esm/index.rollup.js +2 -0
  66. package/dist/esm/interfaces.js +12 -1
  67. package/dist/esm/metadata.js +60 -0
  68. package/dist/esm/observation/arrays.js +570 -0
  69. package/dist/esm/observation/notifier.js +27 -35
  70. package/dist/esm/observation/observable.js +116 -149
  71. package/dist/esm/observation/update-queue.js +67 -0
  72. package/dist/esm/pending-task.js +16 -0
  73. package/dist/esm/platform.js +60 -42
  74. package/dist/esm/polyfills.js +85 -0
  75. package/dist/esm/state/exports.js +3 -0
  76. package/dist/esm/state/reactive.js +34 -0
  77. package/dist/esm/state/state.js +148 -0
  78. package/dist/esm/state/visitor.js +28 -0
  79. package/dist/esm/state/watch.js +36 -0
  80. package/dist/esm/styles/css-directive.js +29 -13
  81. package/dist/esm/styles/css.js +29 -42
  82. package/dist/esm/styles/element-styles.js +79 -104
  83. package/dist/esm/styles/host.js +1 -0
  84. package/dist/esm/templating/binding-signal.js +83 -0
  85. package/dist/esm/templating/binding-two-way.js +103 -0
  86. package/dist/esm/templating/binding.js +189 -159
  87. package/dist/esm/templating/children.js +33 -23
  88. package/dist/esm/templating/compiler.js +258 -152
  89. package/dist/esm/templating/dom.js +49 -0
  90. package/dist/esm/templating/html-directive.js +193 -36
  91. package/dist/esm/templating/markup.js +75 -0
  92. package/dist/esm/templating/node-observation.js +51 -45
  93. package/dist/esm/templating/ref.js +8 -25
  94. package/dist/esm/templating/render.js +391 -0
  95. package/dist/esm/templating/repeat.js +83 -79
  96. package/dist/esm/templating/slotted.js +23 -20
  97. package/dist/esm/templating/template.js +51 -93
  98. package/dist/esm/templating/view.js +125 -46
  99. package/dist/esm/templating/when.js +6 -4
  100. package/dist/esm/testing/exports.js +3 -0
  101. package/dist/esm/testing/fakes.js +76 -0
  102. package/dist/esm/testing/fixture.js +86 -0
  103. package/dist/esm/testing/timeout.js +24 -0
  104. package/dist/esm/utilities.js +44 -0
  105. package/dist/fast-element.api.json +12153 -5373
  106. package/dist/fast-element.d.ts +1448 -696
  107. package/dist/fast-element.debug.js +4107 -0
  108. package/dist/fast-element.debug.min.js +1 -0
  109. package/dist/fast-element.js +3817 -4029
  110. package/dist/fast-element.min.js +1 -1
  111. package/dist/fast-element.untrimmed.d.ts +2814 -0
  112. package/docs/api-report.md +567 -254
  113. package/docs/fast-element-2-changes.md +15 -0
  114. package/karma.conf.cjs +6 -17
  115. package/package.json +76 -15
  116. package/dist/dts/dom.d.ts +0 -112
  117. package/dist/dts/observation/array-change-records.d.ts +0 -48
  118. package/dist/dts/observation/array-observer.d.ts +0 -9
  119. package/dist/dts/observation/behavior.d.ts +0 -19
  120. package/dist/esm/dom.js +0 -207
  121. package/dist/esm/observation/array-change-records.js +0 -326
  122. package/dist/esm/observation/array-observer.js +0 -177
@@ -0,0 +1,272 @@
1
+ import type { FASTElement } from "../components/fast-element.js";
2
+ import { Constructable } from "../interfaces.js";
3
+ import type { Subscriber } from "../observation/notifier.js";
4
+ import type { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
5
+ import { ContentTemplate, ContentView } from "./binding.js";
6
+ import { AddViewBehaviorFactory, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
7
+ import { CaptureType, SyntheticViewTemplate, TemplateValue, ViewTemplate } from "./template.js";
8
+ /**
9
+ * A Behavior that enables advanced rendering.
10
+ * @public
11
+ */
12
+ export declare class RenderBehavior<TSource = any> implements ViewBehavior, Subscriber {
13
+ private directive;
14
+ private location;
15
+ private controller;
16
+ private view;
17
+ private template;
18
+ private templateBindingObserver;
19
+ private data;
20
+ private dataBindingObserver;
21
+ /**
22
+ * Creates an instance of RenderBehavior.
23
+ * @param directive - The render directive that created this behavior.
24
+ */
25
+ constructor(directive: RenderDirective);
26
+ /**
27
+ * Bind this behavior.
28
+ * @param controller - The view controller that manages the lifecycle of this behavior.
29
+ */
30
+ bind(controller: ViewController): void;
31
+ /**
32
+ * Unbinds this behavior.
33
+ * @param controller - The view controller that manages the lifecycle of this behavior.
34
+ */
35
+ unbind(controller: ViewController): void;
36
+ /** @internal */
37
+ handleChange(source: any, observer: ExpressionObserver): void;
38
+ private refreshView;
39
+ }
40
+ /**
41
+ * A Directive that enables use of the RenderBehavior.
42
+ * @public
43
+ */
44
+ export declare class RenderDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
45
+ readonly dataBinding: Binding<TSource>;
46
+ readonly templateBinding: Binding<TSource, ContentTemplate>;
47
+ readonly templateBindingDependsOnData: boolean;
48
+ /**
49
+ * The unique id of the factory.
50
+ */
51
+ id: string;
52
+ /**
53
+ * The structural id of the DOM node to which the created behavior will apply.
54
+ */
55
+ nodeId: string;
56
+ /**
57
+ * Creates an instance of RenderDirective.
58
+ * @param dataBinding - A binding expression that returns the data to render.
59
+ * @param templateBinding - A binding expression that returns the template to use to render the data.
60
+ */
61
+ constructor(dataBinding: Binding<TSource>, templateBinding: Binding<TSource, ContentTemplate>, templateBindingDependsOnData: boolean);
62
+ /**
63
+ * Creates HTML to be used within a template.
64
+ * @param add - Can be used to add behavior factories to a template.
65
+ */
66
+ createHTML(add: AddViewBehaviorFactory): string;
67
+ /**
68
+ * Creates a behavior.
69
+ * @param targets - The targets available for behaviors to be attached to.
70
+ */
71
+ createBehavior(): RenderBehavior<TSource>;
72
+ }
73
+ /**
74
+ * Provides instructions for how to render a type.
75
+ * @public
76
+ */
77
+ export interface RenderInstruction {
78
+ /**
79
+ * Identifies this as a RenderInstruction.
80
+ */
81
+ brand: symbol;
82
+ /**
83
+ * The type this instruction is associated with.
84
+ */
85
+ type: Constructable;
86
+ /**
87
+ * The template to use when rendering.
88
+ */
89
+ template: ContentTemplate;
90
+ /**
91
+ * A name that can be used to identify the instruction.
92
+ */
93
+ name: string;
94
+ }
95
+ /**
96
+ * Render options that are common to all configurations.
97
+ * @public
98
+ */
99
+ export declare type CommonRenderOptions = {
100
+ /**
101
+ * The type this instruction is associated with.
102
+ */
103
+ type: Constructable;
104
+ /**
105
+ * A name that can be used to identify the instruction.
106
+ */
107
+ name?: string;
108
+ };
109
+ /**
110
+ * Render options used to specify a template.
111
+ * @public
112
+ */
113
+ export declare type TemplateRenderOptions = CommonRenderOptions & {
114
+ /**
115
+ * The template to use when rendering.
116
+ */
117
+ template: ContentTemplate;
118
+ };
119
+ /**
120
+ * Render options that are common to all element render instructions.
121
+ * @public
122
+ */
123
+ export declare type BaseElementRenderOptions<TSource = any, TParent = any> = CommonRenderOptions & {
124
+ /**
125
+ * Attributes to use when creating the element template.
126
+ */
127
+ attributes?: Record<string, string | TemplateValue<TSource, TParent>>;
128
+ /**
129
+ * Content to use when creating the element template.
130
+ */
131
+ content?: string | SyntheticViewTemplate;
132
+ };
133
+ /**
134
+ * Render options used to specify an element.
135
+ * @public
136
+ */
137
+ export declare type ElementConstructorRenderOptions<TSource = any, TParent = any> = BaseElementRenderOptions<TSource, TParent> & {
138
+ /**
139
+ * The element to use when rendering.
140
+ */
141
+ element: Constructable<FASTElement>;
142
+ };
143
+ /**
144
+ * Render options use to specify an element by tag name.
145
+ * @public
146
+ */
147
+ export declare type TagNameRenderOptions<TSource = any, TParent = any> = BaseElementRenderOptions<TSource, TParent> & {
148
+ /**
149
+ * The tag name to use when rendering.
150
+ */
151
+ tagName: string;
152
+ };
153
+ declare function createElementTemplate<TSource = any, TParent = any>(tagName: string, attributes?: Record<string, string | TemplateValue<TSource, TParent>>, content?: string | ContentTemplate): ViewTemplate<TSource, TParent>;
154
+ declare function create(options: TagNameRenderOptions): RenderInstruction;
155
+ declare function create(options: ElementConstructorRenderOptions): RenderInstruction;
156
+ declare function create(options: TemplateRenderOptions): RenderInstruction;
157
+ declare function instanceOf(object: any): object is RenderInstruction;
158
+ declare function register(options: TagNameRenderOptions): RenderInstruction;
159
+ declare function register(options: ElementConstructorRenderOptions): RenderInstruction;
160
+ declare function register(options: TemplateRenderOptions): RenderInstruction;
161
+ declare function register(instruction: RenderInstruction): RenderInstruction;
162
+ declare function getByType(type: Constructable, name?: string): RenderInstruction | undefined;
163
+ declare function getForInstance(object: any, name?: string): RenderInstruction | undefined;
164
+ /**
165
+ * Provides APIs for creating and interacting with render instructions.
166
+ * @public
167
+ */
168
+ export declare const RenderInstruction: Readonly<{
169
+ /**
170
+ * Checks whether the provided object is a RenderInstruction.
171
+ * @param object - The object to check.
172
+ * @returns true if the object is a RenderInstruction; false otherwise
173
+ */
174
+ instanceOf: typeof instanceOf;
175
+ /**
176
+ * Creates a RenderInstruction for a set of options.
177
+ * @param options - The options to use when creating the RenderInstruction.
178
+ */
179
+ create: typeof create;
180
+ /**
181
+ * Creates a template based on a tag name.
182
+ * @param tagName - The tag name to use when creating the template.
183
+ * @param attributes - The attributes to apply to the element.
184
+ * @param content - The content to insert into the element.
185
+ * @returns A template based on the provided specifications.
186
+ */
187
+ createElementTemplate: typeof createElementTemplate;
188
+ /**
189
+ * Creates and registers an instruction.
190
+ * @param options The options to use when creating the RenderInstruction.
191
+ * @remarks
192
+ * A previously created RenderInstruction can also be registered.
193
+ */
194
+ register: typeof register;
195
+ /**
196
+ * Finds a previously registered RenderInstruction by type and optionally by name.
197
+ * @param type - The type to retrieve the RenderInstruction for.
198
+ * @param name - An optional name used in differentiating between multiple registered instructions.
199
+ * @returns The located RenderInstruction that matches the criteria or undefined if none is found.
200
+ */
201
+ getByType: typeof getByType;
202
+ /**
203
+ * Finds a previously registered RenderInstruction for the instance's type and optionally by name.
204
+ * @param object - The instance to retrieve the RenderInstruction for.
205
+ * @param name - An optional name used in differentiating between multiple registered instructions.
206
+ * @returns The located RenderInstruction that matches the criteria or undefined if none is found.
207
+ */
208
+ getForInstance: typeof getForInstance;
209
+ }>;
210
+ /**
211
+ * Decorates a type with render instruction metadata.
212
+ * @param options - The options used in creating the RenderInstruction.
213
+ * @public
214
+ */
215
+ export declare function renderWith(options: Omit<TagNameRenderOptions, "type">): ClassDecorator;
216
+ /**
217
+ * Decorates a type with render instruction metadata.
218
+ * @param options - The options used in creating the RenderInstruction.
219
+ * @public
220
+ */
221
+ export declare function renderWith(options: Omit<ElementConstructorRenderOptions, "type">): ClassDecorator;
222
+ /**
223
+ * Decorates a type with render instruction metadata.
224
+ * @param options - The options used in creating the RenderInstruction.
225
+ * @public
226
+ */
227
+ export declare function renderWith(options: Omit<TemplateRenderOptions, "type">): ClassDecorator;
228
+ /**
229
+ * Decorates a type with render instruction metadata.
230
+ * @param element - The element to use to render the decorated class.
231
+ * @param name - An optional name to differentiate the render instruction.
232
+ * @public
233
+ */
234
+ export declare function renderWith(element: Constructable<FASTElement>, name?: string): ClassDecorator;
235
+ /**
236
+ * Decorates a type with render instruction metadata.
237
+ * @param template - The template to use to render the decorated class.
238
+ * @param name - An optional name to differentiate the render instruction.
239
+ * @public
240
+ */
241
+ export declare function renderWith(template: ContentTemplate, name?: string): ClassDecorator;
242
+ /**
243
+ * @internal
244
+ */
245
+ export declare class NodeTemplate implements ContentTemplate, ContentView {
246
+ readonly node: Node;
247
+ constructor(node: Node);
248
+ get context(): ExecutionContext<any>;
249
+ bind(source: any): void;
250
+ unbind(): void;
251
+ insertBefore(refNode: Node): void;
252
+ remove(): void;
253
+ create(): ContentView;
254
+ }
255
+ /**
256
+ * Creates a RenderDirective for use in advanced rendering scenarios.
257
+ * @param value - The binding expression that returns the data to be rendered. The expression
258
+ * can also return a Node to render directly.
259
+ * @param template - A template to render the data with
260
+ * or a string to indicate which RenderInstruction to use when looking up a RenderInstruction.
261
+ * Expressions can also be provided to dynamically determine either the template or the name.
262
+ * @returns A RenderDirective suitable for use in a template.
263
+ * @remarks
264
+ * If no binding is provided, then a default binding that returns the source is created.
265
+ * If no template is provided, then a binding is created that will use registered
266
+ * RenderInstructions to determine the view.
267
+ * If the template binding returns a string, then it will be used to look up a
268
+ * RenderInstruction to determine the view.
269
+ * @public
270
+ */
271
+ export declare function render<TSource = any, TItem = any, TParent = any>(value?: Expression<TSource, TItem> | Binding<TSource, TItem> | {}, template?: ContentTemplate | string | Expression<TSource, ContentTemplate | string | Node, TParent> | Binding<TSource, ContentTemplate | string | Node, TParent>): CaptureType<TSource, TParent>;
272
+ export {};
@@ -1,9 +1,8 @@
1
- import { Binding, ExecutionContext } from "../observation/observable.js";
2
1
  import type { Subscriber } from "../observation/notifier.js";
3
- import type { Splice } from "../observation/array-change-records.js";
4
- import type { Behavior } from "../observation/behavior.js";
5
- import { HTMLDirective } from "./html-directive.js";
6
- import type { CaptureType, SyntheticViewTemplate } from "./template.js";
2
+ import { Expression, ExpressionObserver } from "../observation/observable.js";
3
+ import { Splice } from "../observation/arrays.js";
4
+ import { AddViewBehaviorFactory, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
5
+ import type { CaptureType, SyntheticViewTemplate, ViewTemplate } from "./template.js";
7
6
  /**
8
7
  * Options for configuring repeat behavior.
9
8
  * @public
@@ -22,44 +21,42 @@ export interface RepeatOptions {
22
21
  * A behavior that renders a template for each item in an array.
23
22
  * @public
24
23
  */
25
- export declare class RepeatBehavior<TSource = any> implements Behavior, Subscriber {
24
+ export declare class RepeatBehavior<TSource = any> implements ViewBehavior, Subscriber {
25
+ private directive;
26
26
  private location;
27
- private itemsBinding;
28
- private templateBinding;
29
- private options;
30
- private source;
27
+ private controller;
31
28
  private views;
32
29
  private template;
33
30
  private templateBindingObserver;
34
31
  private items;
35
32
  private itemsObserver;
36
33
  private itemsBindingObserver;
37
- private originalContext;
38
- private childContext;
39
34
  private bindView;
40
35
  /**
41
36
  * Creates an instance of RepeatBehavior.
42
37
  * @param location - The location in the DOM to render the repeat.
43
- * @param itemsBinding - The array to render.
38
+ * @param dataBinding - The array to render.
44
39
  * @param isItemsBindingVolatile - Indicates whether the items binding has volatile dependencies.
45
40
  * @param templateBinding - The template to render for each item.
46
41
  * @param isTemplateBindingVolatile - Indicates whether the template binding has volatile dependencies.
47
42
  * @param options - Options used to turn on special repeat features.
48
43
  */
49
- constructor(location: Node, itemsBinding: Binding<TSource, any[]>, isItemsBindingVolatile: boolean, templateBinding: Binding<TSource, SyntheticViewTemplate>, isTemplateBindingVolatile: boolean, options: RepeatOptions);
44
+ constructor(directive: RepeatDirective);
50
45
  /**
51
- * Bind this behavior to the source.
52
- * @param source - The source to bind to.
53
- * @param context - The execution context that the binding is operating within.
46
+ * Bind this behavior.
47
+ * @param controller - The view controller that manages the lifecycle of this behavior.
54
48
  */
55
- bind(source: TSource, context: ExecutionContext): void;
49
+ bind(controller: ViewController): void;
56
50
  /**
57
- * Unbinds this behavior from the source.
58
- * @param source - The source to unbind from.
51
+ * Unbinds this behavior.
59
52
  */
60
53
  unbind(): void;
61
- /** @internal */
62
- handleChange(source: any, args: Splice[]): void;
54
+ /**
55
+ * Handles changes in the array, its items, and the repeat template.
56
+ * @param source - The source of the change.
57
+ * @param args - The details about what was changed.
58
+ */
59
+ handleChange(source: any, args: Splice[] | ExpressionObserver): void;
63
60
  private observeItems;
64
61
  private updateViews;
65
62
  private refreshAllViews;
@@ -69,36 +66,42 @@ export declare class RepeatBehavior<TSource = any> implements Behavior, Subscrib
69
66
  * A directive that configures list rendering.
70
67
  * @public
71
68
  */
72
- export declare class RepeatDirective<TSource = any> extends HTMLDirective {
73
- readonly itemsBinding: Binding;
69
+ export declare class RepeatDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
70
+ readonly dataBinding: Binding<TSource>;
74
71
  readonly templateBinding: Binding<TSource, SyntheticViewTemplate>;
75
72
  readonly options: RepeatOptions;
76
- private isItemsBindingVolatile;
77
- private isTemplateBindingVolatile;
73
+ /**
74
+ * The unique id of the factory.
75
+ */
76
+ id: string;
77
+ /**
78
+ * The structural id of the DOM node to which the created behavior will apply.
79
+ */
80
+ nodeId: string;
78
81
  /**
79
82
  * Creates a placeholder string based on the directive's index within the template.
80
83
  * @param index - The index of the directive within the template.
81
84
  */
82
- createPlaceholder: (index: number) => string;
85
+ createHTML(add: AddViewBehaviorFactory): string;
83
86
  /**
84
87
  * Creates an instance of RepeatDirective.
85
- * @param itemsBinding - The binding that provides the array to render.
88
+ * @param dataBinding - The binding that provides the array to render.
86
89
  * @param templateBinding - The template binding used to obtain a template to render for each item in the array.
87
90
  * @param options - Options used to turn on special repeat features.
88
91
  */
89
- constructor(itemsBinding: Binding, templateBinding: Binding<TSource, SyntheticViewTemplate>, options: RepeatOptions);
92
+ constructor(dataBinding: Binding<TSource>, templateBinding: Binding<TSource, SyntheticViewTemplate>, options: RepeatOptions);
90
93
  /**
91
94
  * Creates a behavior for the provided target node.
92
95
  * @param target - The node instance to create the behavior for.
93
96
  */
94
- createBehavior(target: Node): RepeatBehavior<TSource>;
97
+ createBehavior(): RepeatBehavior<TSource>;
95
98
  }
96
99
  /**
97
100
  * A directive that enables list rendering.
98
- * @param itemsBinding - The array to render.
99
- * @param templateOrTemplateBinding - The template or a template binding used obtain a template
101
+ * @param items - The array to render.
102
+ * @param template - The template or a template binding used obtain a template
100
103
  * to render for each item in the array.
101
104
  * @param options - Options used to turn on special repeat features.
102
105
  * @public
103
106
  */
104
- export declare function repeat<TSource = any, TItem = any>(itemsBinding: Binding<TSource, readonly TItem[]>, templateOrTemplateBinding: SyntheticViewTemplate | Binding<TSource, SyntheticViewTemplate>, options?: RepeatOptions): CaptureType<TSource>;
107
+ 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>;
@@ -1,34 +1,33 @@
1
- import { NodeBehaviorOptions, NodeObservationBehavior } from "./node-observation.js";
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 SlottedBehaviorOptions<T = any> extends NodeBehaviorOptions<T>, AssignedNodesOptions {
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 SlottedBehavior extends NodeObservationBehavior<SlottedBehaviorOptions> {
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 target.
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
- protected getNodes(): Node[];
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) | SlottedBehaviorOptions<keyof T & string>): CaptureType<T>;
38
+ export declare function slotted<TSource = any, TParent = any>(propertyOrOptions: (keyof TSource & string) | SlottedDirectiveOptions<keyof TSource & string>): CaptureType<TSource, TParent>;
@@ -1,16 +1,16 @@
1
- import { Binding } from "../observation/observable.js";
2
- import { ElementView, HTMLView, SyntheticView } from "./view.js";
3
- import { HTMLDirective } from "./html-directive.js";
1
+ import type { Expression } from "../observation/observable.js";
2
+ import { Binding, HTMLDirective, ViewBehaviorFactory } from "./html-directive.js";
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
- export interface ElementViewTemplate {
8
+ export interface ElementViewTemplate<TSource = any, TParent = any> {
9
9
  /**
10
10
  * Creates an ElementView instance based on this template definition.
11
11
  * @param hostBindingTarget - The element that host behaviors will be bound to.
12
12
  */
13
- create(hostBindingTarget: Element): ElementView;
13
+ create(hostBindingTarget: Element): ElementView<TSource, TParent>;
14
14
  /**
15
15
  * Creates an HTMLView from this template, binds it to the source, and then appends it to the host.
16
16
  * @param source - The data source to bind the template to.
@@ -18,7 +18,7 @@ export interface ElementViewTemplate {
18
18
  * @param hostBindingTarget - An HTML element to target the host bindings at if different from the
19
19
  * host that the template is being attached to.
20
20
  */
21
- render(source: any, host: Node, hostBindingTarget?: Element): HTMLView;
21
+ render(source: TSource, host: Node, hostBindingTarget?: Element): ElementView<TSource, TParent>;
22
22
  }
23
23
  /**
24
24
  * A template capable of rendering views not specifically connected to custom elements.
@@ -28,19 +28,25 @@ export interface SyntheticViewTemplate<TSource = any, TParent = any> {
28
28
  /**
29
29
  * Creates a SyntheticView instance based on this template definition.
30
30
  */
31
- create(): SyntheticView;
31
+ create(): SyntheticView<TSource, TParent>;
32
+ }
33
+ /**
34
+ * The result of a template compilation operation.
35
+ * @public
36
+ */
37
+ export interface HTMLTemplateCompilationResult<TSource = any, TParent = any> {
38
+ /**
39
+ * Creates a view instance.
40
+ * @param hostBindingTarget - The host binding target for the view.
41
+ */
42
+ createView(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
32
43
  }
33
44
  /**
34
45
  * A template capable of creating HTMLView instances or rendering directly to DOM.
35
46
  * @public
36
47
  */
37
- export declare class ViewTemplate<TSource = any, TParent = any> implements ElementViewTemplate, SyntheticViewTemplate {
38
- private behaviorCount;
39
- private hasHostBehaviors;
40
- private fragment;
41
- private targetOffset;
42
- private viewBehaviorFactories;
43
- private hostBehaviorFactories;
48
+ export declare class ViewTemplate<TSource = any, TParent = any> implements ElementViewTemplate<TSource, TParent>, SyntheticViewTemplate<TSource, TParent> {
49
+ private result;
44
50
  /**
45
51
  * The html representing what this template will
46
52
  * instantiate, including placeholders for directives.
@@ -49,18 +55,18 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
49
55
  /**
50
56
  * The directives that will be connected to placeholders in the html.
51
57
  */
52
- readonly directives: ReadonlyArray<HTMLDirective>;
58
+ readonly factories: Record<string, ViewBehaviorFactory>;
53
59
  /**
54
60
  * Creates an instance of ViewTemplate.
55
61
  * @param html - The html representing what this template will instantiate, including placeholders for directives.
56
- * @param directives - The directives that will be connected to placeholders in the html.
62
+ * @param factories - The directives that will be connected to placeholders in the html.
57
63
  */
58
- constructor(html: string | HTMLTemplateElement, directives: ReadonlyArray<HTMLDirective>);
64
+ constructor(html: string | HTMLTemplateElement, factories: Record<string, ViewBehaviorFactory>);
59
65
  /**
60
66
  * Creates an HTMLView instance based on this template definition.
61
67
  * @param hostBindingTarget - The element that host behaviors will be bound to.
62
68
  */
63
- create(hostBindingTarget?: Element): HTMLView;
69
+ create(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
64
70
  /**
65
71
  * Creates an HTMLView from this template, binds it to the source, and then appends it to the host.
66
72
  * @param source - The data source to bind the template to.
@@ -68,22 +74,22 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
68
74
  * @param hostBindingTarget - An HTML element to target the host bindings at if different from the
69
75
  * host that the template is being attached to.
70
76
  */
71
- render(source: TSource, host: Node | string, hostBindingTarget?: Element): HTMLView;
77
+ render(source: TSource, host: Node, hostBindingTarget?: Element): HTMLView<TSource, TParent>;
72
78
  }
73
79
  /**
74
80
  * A marker interface used to capture types when interpolating Directive helpers
75
81
  * into templates.
76
82
  * @public
77
83
  */
78
- export interface CaptureType<TSource> {
84
+ export interface CaptureType<TSource, TParent> {
79
85
  }
80
86
  /**
81
87
  * Represents the types of values that can be interpolated into a template.
82
88
  * @public
83
89
  */
84
- export declare type TemplateValue<TScope, TParent = any> = Binding<TScope, any, TParent> | string | number | HTMLDirective | CaptureType<TScope>;
90
+ export declare type TemplateValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource, TParent>;
85
91
  /**
86
- * Transforms a template literal string into a renderable ViewTemplate.
92
+ * Transforms a template literal string into a ViewTemplate.
87
93
  * @param strings - The string fragments that are interpolated with the values.
88
94
  * @param values - The values that are interpolated with the string fragments.
89
95
  * @remarks