@microsoft/fast-element 2.0.0-beta.6 → 2.0.0-beta.7

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 (64) hide show
  1. package/CHANGELOG.json +57 -0
  2. package/CHANGELOG.md +16 -1
  3. package/dist/dts/components/attributes.d.ts +10 -0
  4. package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +24 -25
  5. package/dist/dts/components/fast-definitions.d.ts +28 -3
  6. package/dist/dts/components/fast-element.d.ts +2 -2
  7. package/dist/dts/di/di.d.ts +41 -0
  8. package/dist/dts/index.d.ts +2 -2
  9. package/dist/dts/observation/observable.d.ts +86 -47
  10. package/dist/dts/pending-task.d.ts +20 -0
  11. package/dist/dts/platform.d.ts +6 -0
  12. package/dist/dts/styles/css-directive.d.ts +2 -2
  13. package/dist/dts/styles/element-styles.d.ts +3 -3
  14. package/dist/dts/styles/host.d.ts +68 -0
  15. package/dist/dts/templating/binding-signal.d.ts +2 -2
  16. package/dist/dts/templating/binding-two-way.d.ts +11 -3
  17. package/dist/dts/templating/binding.d.ts +21 -119
  18. package/dist/dts/templating/children.d.ts +1 -1
  19. package/dist/dts/templating/html-directive.d.ts +69 -39
  20. package/dist/dts/templating/node-observation.d.ts +4 -5
  21. package/dist/dts/templating/ref.d.ts +5 -13
  22. package/dist/dts/templating/render.d.ts +15 -20
  23. package/dist/dts/templating/repeat.d.ts +11 -16
  24. package/dist/dts/templating/slotted.d.ts +1 -1
  25. package/dist/dts/templating/template.d.ts +4 -4
  26. package/dist/dts/templating/view.d.ts +68 -9
  27. package/dist/dts/templating/when.d.ts +1 -1
  28. package/dist/dts/testing/exports.d.ts +1 -0
  29. package/dist/dts/testing/fakes.d.ts +4 -0
  30. package/dist/dts/testing/fixture.d.ts +0 -6
  31. package/dist/esm/components/attributes.js +13 -4
  32. package/dist/esm/components/{controller.js → element-controller.js} +95 -105
  33. package/dist/esm/components/fast-definitions.js +3 -1
  34. package/dist/esm/components/fast-element.js +4 -4
  35. package/dist/esm/di/di.js +87 -3
  36. package/dist/esm/index.js +2 -1
  37. package/dist/esm/observation/observable.js +59 -126
  38. package/dist/esm/pending-task.js +16 -0
  39. package/dist/esm/platform.js +21 -0
  40. package/dist/esm/styles/css.js +4 -4
  41. package/dist/esm/{observation/behavior.js → styles/host.js} +0 -0
  42. package/dist/esm/templating/binding-signal.js +21 -17
  43. package/dist/esm/templating/binding-two-way.js +32 -27
  44. package/dist/esm/templating/binding.js +73 -177
  45. package/dist/esm/templating/html-directive.js +78 -7
  46. package/dist/esm/templating/node-observation.js +9 -8
  47. package/dist/esm/templating/ref.js +4 -12
  48. package/dist/esm/templating/render.js +30 -31
  49. package/dist/esm/templating/repeat.js +37 -38
  50. package/dist/esm/templating/template.js +3 -4
  51. package/dist/esm/templating/view.js +96 -24
  52. package/dist/esm/testing/exports.js +1 -0
  53. package/dist/esm/testing/fakes.js +76 -0
  54. package/dist/esm/testing/fixture.js +1 -3
  55. package/dist/fast-element.api.json +5720 -5385
  56. package/dist/fast-element.d.ts +510 -399
  57. package/dist/fast-element.debug.js +492 -509
  58. package/dist/fast-element.debug.min.js +1 -1
  59. package/dist/fast-element.js +492 -509
  60. package/dist/fast-element.min.js +1 -1
  61. package/dist/fast-element.untrimmed.d.ts +519 -405
  62. package/docs/api-report.md +197 -129
  63. package/package.json +5 -1
  64. package/dist/dts/observation/behavior.d.ts +0 -19
@@ -1,5 +1,5 @@
1
- import type { Behavior } from "../observation/behavior.js";
2
1
  import { StyleStrategy, StyleTarget } from "../interfaces.js";
2
+ import type { HostBehavior } from "./host.js";
3
3
  /**
4
4
  * Represents styles that can be composed into the ShadowDOM of a custom element.
5
5
  * @public
@@ -27,7 +27,7 @@ export declare class ElementStyles {
27
27
  /**
28
28
  * The behaviors associated with this set of styles.
29
29
  */
30
- readonly behaviors: ReadonlyArray<Behavior<HTMLElement>> | null;
30
+ readonly behaviors: ReadonlyArray<HostBehavior<HTMLElement>> | null;
31
31
  /**
32
32
  * Gets the StyleStrategy associated with these element styles.
33
33
  */
@@ -47,7 +47,7 @@ export declare class ElementStyles {
47
47
  * Associates behaviors with this set of styles.
48
48
  * @param behaviors - The behaviors to associate.
49
49
  */
50
- withBehaviors(...behaviors: Behavior<HTMLElement>[]): this;
50
+ withBehaviors(...behaviors: HostBehavior<HTMLElement>[]): this;
51
51
  /**
52
52
  * Sets the strategy that handles adding/removing these styles for an element.
53
53
  * @param strategy - The strategy to use.
@@ -0,0 +1,68 @@
1
+ import type { ElementStyles } from "./element-styles.js";
2
+ /**
3
+ * Controls the lifecycle and context of behaviors and styles
4
+ * associated with a component host.
5
+ * @public
6
+ */
7
+ export interface HostController<TSource = any> {
8
+ /**
9
+ * The component source.
10
+ */
11
+ readonly source: TSource;
12
+ /**
13
+ * Indicates whether the host is connected or not.
14
+ */
15
+ readonly isConnected: boolean;
16
+ /**
17
+ * The main set of styles used for the component, independent
18
+ * of any behavior-specific styles.
19
+ */
20
+ mainStyles: ElementStyles | null;
21
+ /**
22
+ * Adds the behavior to the component.
23
+ * @param behavior - The behavior to add.
24
+ */
25
+ addBehavior(behavior: HostBehavior<TSource>): void;
26
+ /**
27
+ * Removes the behavior from the component.
28
+ * @param behavior - The behavior to remove.
29
+ * @param force - Forces removal even if this behavior was added more than once.
30
+ */
31
+ removeBehavior(behavior: HostBehavior<TSource>, force?: boolean): void;
32
+ /**
33
+ * Adds styles to this element. Providing an HTMLStyleElement will attach the element instance to the shadowRoot.
34
+ * @param styles - The styles to add.
35
+ */
36
+ addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
37
+ /**
38
+ * Removes styles from this element. Providing an HTMLStyleElement will detach the element instance from the shadowRoot.
39
+ * @param styles - the styles to remove.
40
+ */
41
+ removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
42
+ }
43
+ /**
44
+ * Represents an object that can contribute behavior to a host.
45
+ * @public
46
+ */
47
+ export interface HostBehavior<TSource = any> {
48
+ /**
49
+ * Executed when this behavior is attached to a controller.
50
+ * @param controller - Controls the behavior lifecycle.
51
+ */
52
+ addedCallback?(controller: HostController<TSource>): void;
53
+ /**
54
+ * Executed when this behavior is detached from a controller.
55
+ * @param controller - Controls the behavior lifecycle.
56
+ */
57
+ removedCallback?(controller: HostController<TSource>): void;
58
+ /**
59
+ * Executed when this behavior's host is connected.
60
+ * @param controller - Controls the behavior lifecycle.
61
+ */
62
+ connectedCallback?(controller: HostController<TSource>): void;
63
+ /**
64
+ * Executed when this behavior's host is disconnected.
65
+ * @param controller - Controls the behavior lifecycle.
66
+ */
67
+ disconnectedCallback?(controller: HostController<TSource>): void;
68
+ }
@@ -13,9 +13,9 @@ export declare const Signal: Readonly<{
13
13
  }>;
14
14
  /**
15
15
  * Creates a signal binding configuration with the supplied options.
16
- * @param binding - The binding to refresh when signaled.
16
+ * @param expression - The binding to refresh when signaled.
17
17
  * @param options - The signal name or a binding to use to retrieve the signal name.
18
18
  * @returns A binding configuration.
19
19
  * @public
20
20
  */
21
- export declare function signal<T = any>(binding: Expression<T>, options: string | Expression<T>): Binding<T>;
21
+ export declare function signal<T = any>(expression: Expression<T>, options: string | Expression<T>): Binding<T>;
@@ -21,11 +21,19 @@ export interface TwoWaySettings {
21
21
  */
22
22
  determineChangeEvent(directive: HTMLBindingDirective, target: HTMLElement): string;
23
23
  }
24
+ export declare const TwoWaySettings: Readonly<{
25
+ /**
26
+ * Configures two-way binding.
27
+ * @param settings - The settings to use for the two-way binding system.
28
+ */
29
+ configure(settings: TwoWaySettings): void;
30
+ }>;
24
31
  /**
25
32
  * Creates a default binding.
26
- * @param binding - The binding to refresh when changed.
33
+ * @param expression - The binding to refresh when changed.
34
+ * @param optionsOrChangeEvent - The binding options or the name of the change event to use.
27
35
  * @param isBindingVolatile - Indicates whether the binding is volatile or not.
28
- * @returns A binding configuration.
36
+ * @returns A binding.
29
37
  * @public
30
38
  */
31
- export declare function twoWay<T = any>(binding: Expression<T>, optionsOrChangeEvent?: TwoWayBindingOptions | string, isBindingVolatile?: boolean): Binding<T>;
39
+ export declare function twoWay<T = any>(expression: Expression<T>, optionsOrChangeEvent?: TwoWayBindingOptions | string, isBindingVolatile?: boolean): Binding<T>;
@@ -1,37 +1,17 @@
1
1
  import { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
2
- import { AddViewBehaviorFactory, Aspect, Aspected, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewBehaviorTargets } from "./html-directive.js";
3
- /**
4
- * The "this" context for an update target function.
5
- * @public
6
- */
7
- export interface UpdateTargetThis {
8
- /**
9
- * The directive configuration for the update.
10
- */
11
- directive: HTMLBindingDirective;
12
- }
13
- /**
14
- * A target update function.
15
- * @param this - The "this" context for the update.
16
- * @param target - The node that is targeted by the update.
17
- * @param aspect - The aspect of the node that is being targeted.
18
- * @param value - The value to assign to the aspect.
19
- * @param source - The source object that the value was derived from.
20
- * @param context - The execution context that the binding is being run under.
21
- * @public
22
- */
23
- export declare type UpdateTarget = (this: UpdateTargetThis, target: Node, aspect: string, value: any, source: any, context: ExecutionContext) => void;
2
+ import { AddViewBehaviorFactory, Aspect, Aspected, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
24
3
  /**
25
4
  * A simple View that can be interpolated into HTML content.
26
5
  * @public
27
6
  */
28
7
  export interface ContentView {
8
+ readonly context: ExecutionContext;
29
9
  /**
30
10
  * Binds a view's behaviors to its binding source.
31
11
  * @param source - The binding source for the view's binding behaviors.
32
12
  * @param context - The execution context to run the view within.
33
13
  */
34
- bind(source: any, context: ExecutionContext): void;
14
+ bind(source: any): void;
35
15
  /**
36
16
  * Unbinds a view's behaviors from its binding source and context.
37
17
  */
@@ -57,105 +37,14 @@ export interface ContentTemplate {
57
37
  */
58
38
  create(): ContentView;
59
39
  }
60
- /**
61
- * A binding behavior for bindings that change.
62
- * @public
63
- */
64
- export declare class BindingBehavior implements ViewBehavior {
65
- readonly directive: HTMLBindingDirective;
66
- protected updateTarget: UpdateTarget;
67
- private observerProperty;
68
- /**
69
- * Creates an instance of ChangeBinding.
70
- * @param directive - The directive that has the configuration for this behavior.
71
- * @param updateTarget - The function used to update the target with the latest value.
72
- */
73
- constructor(directive: HTMLBindingDirective, updateTarget: UpdateTarget);
74
- /**
75
- * Bind this behavior to the source.
76
- * @param source - The source to bind to.
77
- * @param context - The execution context that the binding is operating within.
78
- * @param targets - The targets that behaviors in a view can attach to.
79
- */
80
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
81
- /**
82
- * Unbinds this behavior from the source.
83
- * @param source - The source to unbind from.
84
- * @param context - The execution context that the binding is operating within.
85
- * @param targets - The targets that behaviors in a view can attach to.
86
- */
87
- unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
88
- /** @internal */
89
- handleChange(binding: Expression, observer: ExpressionObserver): void;
90
- /**
91
- * Returns the binding observer used to update the node.
92
- * @param target - The target node.
93
- * @returns A BindingObserver.
94
- */
95
- protected getObserver(target: Node): ExpressionObserver;
96
- /**
97
- * Creates a behavior.
98
- * @param targets - The targets available for behaviors to be attached to.
99
- */
100
- createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
101
- }
102
- /**
103
- * A special binding behavior that can bind node content.
104
- * @public
105
- */
106
- export declare class ContentBehavior extends BindingBehavior {
107
- /**
108
- * Unbinds this behavior from the source.
109
- * @param source - The source to unbind from.
110
- * @param context - The execution context that the binding is operating within.
111
- * @param targets - The targets that behaviors in a view can attach to.
112
- */
113
- unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
114
- }
115
- /**
116
- * A binding behavior for handling events.
117
- * @public
118
- */
119
- export declare class EventBehavior {
120
- readonly directive: HTMLBindingDirective;
121
- private contextProperty;
122
- private sourceProperty;
123
- /**
124
- * Creates an instance of EventBinding.
125
- * @param directive - The directive that has the configuration for this behavior.
126
- */
127
- constructor(directive: HTMLBindingDirective);
128
- /**
129
- * Bind this behavior to the source.
130
- * @param source - The source to bind to.
131
- * @param context - The execution context that the binding is operating within.
132
- * @param targets - The targets that behaviors in a view can attach to.
133
- */
134
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
135
- /**
136
- * Unbinds this behavior from the source.
137
- * @param source - The source to unbind from.
138
- * @param context - The execution context that the binding is operating within.
139
- * @param targets - The targets that behaviors in a view can attach to.
140
- */
141
- unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
142
- /**
143
- * Creates a behavior.
144
- * @param targets - The targets available for behaviors to be attached to.
145
- */
146
- createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
147
- /**
148
- * @internal
149
- */
150
- handleEvent(event: Event): void;
151
- }
152
40
  /**
153
41
  * A directive that applies bindings.
154
42
  * @public
155
43
  */
156
- export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, Aspected {
44
+ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected {
157
45
  dataBinding: Binding;
158
- private factory;
46
+ private data;
47
+ private updateTarget;
159
48
  /**
160
49
  * The unique id of the factory.
161
50
  */
@@ -188,9 +77,22 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
188
77
  createHTML(add: AddViewBehaviorFactory): string;
189
78
  /**
190
79
  * Creates a behavior.
191
- * @param targets - The targets available for behaviors to be attached to.
192
80
  */
193
- createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
81
+ createBehavior(): ViewBehavior;
82
+ /** @internal */
83
+ bindDefault(controller: ViewController): void;
84
+ /** @internal */
85
+ bind: (controller: ViewController) => void;
86
+ /** @internal */
87
+ bindContent(controller: ViewController): void;
88
+ /** @internal */
89
+ bindEvent(controller: ViewController): void;
90
+ /** @internal */
91
+ unbind(controller: ViewController): void;
92
+ /** @internal */
93
+ handleEvent(event: Event): void;
94
+ /** @internal */
95
+ handleChange(binding: Expression, observer: ExpressionObserver): void;
194
96
  }
195
97
  /**
196
98
  * Creates an standard binding.
@@ -60,4 +60,4 @@ export declare class ChildrenDirective extends NodeObservationDirective<Children
60
60
  * @param propertyOrOptions - The options used to configure child node observation.
61
61
  * @public
62
62
  */
63
- export declare function children<T = any>(propertyOrOptions: (keyof T & string) | ChildrenDirectiveOptions<keyof T & string>): CaptureType<T>;
63
+ export declare function children<TSource = any, TParent = any>(propertyOrOptions: (keyof TSource & string) | ChildrenDirectiveOptions<keyof TSource & string>): CaptureType<TSource, TParent>;
@@ -1,7 +1,7 @@
1
+ import type { HostBehavior } from "../index.js";
1
2
  import type { Constructable } from "../interfaces.js";
2
- import type { Behavior } from "../observation/behavior.js";
3
3
  import type { Subscriber } from "../observation/notifier.js";
4
- import type { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
4
+ import { Expression, ExpressionController, ExpressionObserver } from "../observation/observable.js";
5
5
  /**
6
6
  * The target nodes available to a behavior.
7
7
  * @public
@@ -10,27 +10,65 @@ export declare type ViewBehaviorTargets = {
10
10
  [id: string]: Node;
11
11
  };
12
12
  /**
13
- * Represents an object that can contribute behavior to a view.
13
+ * Controls the lifecycle of a view and provides relevant context.
14
14
  * @public
15
15
  */
16
- export interface ViewBehavior<TSource = any, TParent = any> {
16
+ export interface ViewController<TSource = any, TParent = any> extends ExpressionController<TSource, TParent> {
17
+ /**
18
+ * The parts of the view that are targeted by view behaviors.
19
+ */
20
+ readonly targets: ViewBehaviorTargets;
21
+ }
22
+ /**
23
+ * Bridges between ViewBehaviors and HostBehaviors, enabling a host to
24
+ * control ViewBehaviors.
25
+ * @public
26
+ */
27
+ export interface ViewBehaviorOrchestrator<TSource = any, TParent = any> extends ViewController<TSource, TParent>, HostBehavior<TSource> {
28
+ /**
29
+ *
30
+ * @param nodeId - The structural id of the DOM node to which a behavior will apply.
31
+ * @param target - The DOM node associated with the id.
32
+ */
33
+ addTarget(nodeId: string, target: Node): void;
34
+ /**
35
+ * Adds a behavior.
36
+ * @param behavior - The behavior to add.
37
+ */
38
+ addBehavior(behavior: ViewBehavior): void;
39
+ /**
40
+ * Adds a behavior factory.
41
+ * @param factory - The behavior factory to add.
42
+ * @param target - The target the factory will create behaviors for.
43
+ */
44
+ addBehaviorFactory(factory: ViewBehaviorFactory, target: Node): void;
45
+ }
46
+ /**
47
+ * Bridges between ViewBehaviors and HostBehaviors, enabling a host to
48
+ * control ViewBehaviors.
49
+ * @public
50
+ */
51
+ export declare const ViewBehaviorOrchestrator: Readonly<{
17
52
  /**
18
- * Bind this behavior to the source.
19
- * @param source - The source to bind to.
20
- * @param context - The execution context that the binding is operating within.
21
- * @param targets - The targets that behaviors in a view can attach to.
53
+ * Creates a ViewBehaviorOrchestrator.
54
+ * @param source - The source to to associate behaviors with.
55
+ * @returns A ViewBehaviorOrchestrator.
22
56
  */
23
- bind(source: TSource, context: ExecutionContext<TParent>, targets: ViewBehaviorTargets): void;
57
+ create<TSource = any, TParent = any>(source: TSource): ViewBehaviorOrchestrator<TSource, TParent>;
58
+ }>;
59
+ /**
60
+ * Represents an object that can contribute behavior to a view.
61
+ * @public
62
+ */
63
+ export interface ViewBehavior<TSource = any, TParent = any> {
24
64
  /**
25
- * Unbinds this behavior from the source.
26
- * @param source - The source to unbind from.
27
- * @param context - The execution context that the binding is operating within.
28
- * @param targets - The targets that behaviors in a view can attach to.
65
+ * Bind this behavior.
66
+ * @param controller - The view controller that manages the lifecycle of this behavior.
29
67
  */
30
- unbind(source: TSource, context: ExecutionContext<TParent>, targets: ViewBehaviorTargets): void;
68
+ bind(controller: ViewController<TSource, TParent>): void;
31
69
  }
32
70
  /**
33
- * A factory that can create a {@link Behavior} associated with a particular
71
+ * A factory that can create a {@link ViewBehavior} associated with a particular
34
72
  * location within a DOM fragment.
35
73
  * @public
36
74
  */
@@ -45,9 +83,8 @@ export interface ViewBehaviorFactory {
45
83
  nodeId: string;
46
84
  /**
47
85
  * Creates a behavior.
48
- * @param targets - The targets available for behaviors to be attached to.
49
86
  */
50
- createBehavior(targets: ViewBehaviorTargets): Behavior | ViewBehavior;
87
+ createBehavior(): ViewBehavior;
51
88
  }
52
89
  /**
53
90
  * Used to add behavior factories when constructing templates.
@@ -120,18 +157,18 @@ export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition):
120
157
  * @public
121
158
  */
122
159
  export declare abstract class Binding<TSource = any, TReturn = any, TParent = any> {
160
+ evaluate: Expression<TSource, TReturn, TParent>;
161
+ isVolatile: boolean;
123
162
  /**
124
163
  * Options associated with the binding.
125
164
  */
126
165
  options?: any;
127
166
  /**
128
- * Whether or not the binding is volatile.
167
+ * Creates a binding.
168
+ * @param evaluate - Evaluates the binding.
169
+ * @param isVolatile - Indicates whether the binding is volatile.
129
170
  */
130
- isVolatile?: boolean;
131
- /**
132
- * Evaluates the binding expression.
133
- */
134
- evaluate: Expression<TSource, TReturn, TParent>;
171
+ constructor(evaluate: Expression<TSource, TReturn, TParent>, isVolatile?: boolean);
135
172
  /**
136
173
  * Creates an observer capable of notifying a subscriber when the output of a binding changes.
137
174
  * @param directive - The HTML Directive to create the observer for.
@@ -212,8 +249,8 @@ export interface Aspected {
212
249
  * A base class used for attribute directives that don't need internal state.
213
250
  * @public
214
251
  */
215
- export declare abstract class StatelessAttachedAttributeDirective<T> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
216
- protected options: T;
252
+ export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
253
+ protected options: TOptions;
217
254
  /**
218
255
  * The unique id of the factory.
219
256
  */
@@ -226,12 +263,7 @@ export declare abstract class StatelessAttachedAttributeDirective<T> implements
226
263
  * Creates an instance of RefDirective.
227
264
  * @param options - The options to use in configuring the directive.
228
265
  */
229
- constructor(options: T);
230
- /**
231
- * Creates a behavior.
232
- * @param targets - The targets available for behaviors to be attached to.
233
- */
234
- createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
266
+ constructor(options: TOptions);
235
267
  /**
236
268
  * Creates a placeholder string based on the directive's index within the template.
237
269
  * @param index - The index of the directive within the template.
@@ -240,15 +272,13 @@ export declare abstract class StatelessAttachedAttributeDirective<T> implements
240
272
  */
241
273
  createHTML(add: AddViewBehaviorFactory): string;
242
274
  /**
243
- * Bind this behavior to the source.
244
- * @param source - The source to bind to.
245
- * @param context - The execution context that the binding is operating within.
246
- * @param targets - The targets that behaviors in a view can attach to.
275
+ * Creates a behavior.
276
+ * @param targets - The targets available for behaviors to be attached to.
247
277
  */
248
- abstract bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
278
+ createBehavior(): ViewBehavior;
249
279
  /**
250
- * Unbinds this behavior from the source.
251
- * @param source - The source to unbind from.
280
+ * Bind this behavior.
281
+ * @param controller - The view controller that manages the lifecycle of this behavior.
252
282
  */
253
- abstract unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
283
+ abstract bind(controller: ViewController): void;
254
284
  }
@@ -1,5 +1,4 @@
1
- import type { ExecutionContext } from "../observation/observable.js";
2
- import { StatelessAttachedAttributeDirective, ViewBehaviorTargets } from "./html-directive.js";
1
+ import { StatelessAttachedAttributeDirective, ViewController } from "./html-directive.js";
3
2
  /**
4
3
  * Options for configuring node observation behavior.
5
4
  * @public
@@ -23,7 +22,7 @@ export interface NodeBehaviorOptions<T = any> {
23
22
  *
24
23
  * @public
25
24
  */
26
- export declare type ElementsFilter = (value: Node, index: number, array: Node[]) => boolean;
25
+ export declare type ElementsFilter = (value: Node, index?: number, array?: Node[]) => boolean;
27
26
  /**
28
27
  * Creates a function that can be used to filter a Node array, selecting only elements.
29
28
  * @param selector - An optional selector to restrict the filter to.
@@ -44,14 +43,14 @@ export declare abstract class NodeObservationDirective<T extends NodeBehaviorOpt
44
43
  * @param context - The execution context that the binding is operating within.
45
44
  * @param targets - The targets that behaviors in a view can attach to.
46
45
  */
47
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
46
+ bind(controller: ViewController): void;
48
47
  /**
49
48
  * Unbinds this behavior from the source.
50
49
  * @param source - The source to unbind from.
51
50
  * @param context - The execution context that the binding is operating within.
52
51
  * @param targets - The targets that behaviors in a view can attach to.
53
52
  */
54
- unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
53
+ unbind(controller: ViewController): void;
55
54
  /**
56
55
  * Gets the data source for the target.
57
56
  * @param target - The target to get the source for.
@@ -1,5 +1,4 @@
1
- import type { ExecutionContext } from "../observation/observable.js";
2
- import { StatelessAttachedAttributeDirective, ViewBehaviorTargets } from "./html-directive.js";
1
+ import { StatelessAttachedAttributeDirective, ViewController } from "./html-directive.js";
3
2
  import type { CaptureType } from "./template.js";
4
3
  /**
5
4
  * The runtime behavior for template references.
@@ -7,21 +6,14 @@ import type { CaptureType } from "./template.js";
7
6
  */
8
7
  export declare class RefDirective extends StatelessAttachedAttributeDirective<string> {
9
8
  /**
10
- * Bind this behavior to the source.
11
- * @param source - The source to bind to.
12
- * @param context - The execution context that the binding is operating within.
13
- * @param targets - The targets that behaviors in a view can attach to.
9
+ * Bind this behavior.
10
+ * @param controller - The view controller that manages the lifecycle of this behavior.
14
11
  */
15
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
16
- /**
17
- * Unbinds this behavior from the source.
18
- * @param source - The source to unbind from.
19
- */
20
- unbind(): void;
12
+ bind(controller: ViewController): void;
21
13
  }
22
14
  /**
23
15
  * A directive that observes the updates a property with a reference to the element.
24
16
  * @param propertyName - The name of the property to assign the reference to.
25
17
  * @public
26
18
  */
27
- export declare const ref: <T = any>(propertyName: keyof T & string) => CaptureType<T>;
19
+ export declare const ref: <TSource = any, TParent = any>(propertyName: keyof TSource & string) => CaptureType<TSource, TParent>;
@@ -1,44 +1,38 @@
1
1
  import type { FASTElement } from "../components/fast-element.js";
2
2
  import { Constructable } from "../interfaces.js";
3
- import type { Behavior } from "../observation/behavior.js";
4
3
  import type { Subscriber } from "../observation/notifier.js";
5
4
  import type { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
6
5
  import { ContentTemplate, ContentView } from "./binding.js";
7
- import { AddViewBehaviorFactory, Binding, HTMLDirective, ViewBehaviorFactory, ViewBehaviorTargets } from "./html-directive.js";
6
+ import { AddViewBehaviorFactory, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
8
7
  import { CaptureType, SyntheticViewTemplate, TemplateValue, ViewTemplate } from "./template.js";
9
8
  /**
10
9
  * A Behavior that enables advanced rendering.
11
10
  * @public
12
11
  */
13
- export declare class RenderBehavior<TSource = any, TParent = any> implements Behavior, Subscriber {
12
+ export declare class RenderBehavior<TSource = any> implements ViewBehavior, Subscriber {
14
13
  private directive;
15
14
  private location;
16
- private source;
15
+ private controller;
17
16
  private view;
18
17
  private template;
19
18
  private templateBindingObserver;
20
19
  private data;
21
20
  private dataBindingObserver;
22
- private originalContext;
23
- private childContext;
24
21
  /**
25
22
  * 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.
23
+ * @param directive - The render directive that created this behavior.
29
24
  */
30
- constructor(directive: RenderDirective, location: Node);
25
+ constructor(directive: RenderDirective);
31
26
  /**
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.
27
+ * Bind this behavior.
28
+ * @param controller - The view controller that manages the lifecycle of this behavior.
35
29
  */
36
- bind(source: TSource, context: ExecutionContext): void;
30
+ bind(controller: ViewController): void;
37
31
  /**
38
- * Unbinds this behavior from the source.
39
- * @param source - The source to unbind from.
32
+ * Unbinds this behavior.
33
+ * @param controller - The view controller that manages the lifecycle of this behavior.
40
34
  */
41
- unbind(source: TSource, context: ExecutionContext<TParent>): void;
35
+ unbind(controller: ViewController): void;
42
36
  /** @internal */
43
37
  handleChange(source: any, observer: ExpressionObserver): void;
44
38
  private refreshView;
@@ -74,7 +68,7 @@ export declare class RenderDirective<TSource = any> implements HTMLDirective, Vi
74
68
  * Creates a behavior.
75
69
  * @param targets - The targets available for behaviors to be attached to.
76
70
  */
77
- createBehavior(targets: ViewBehaviorTargets): RenderBehavior<TSource>;
71
+ createBehavior(): RenderBehavior<TSource>;
78
72
  }
79
73
  /**
80
74
  * Provides instructions for how to render a type.
@@ -251,7 +245,8 @@ export declare function renderWith(template: ContentTemplate, name?: string): Cl
251
245
  export declare class NodeTemplate implements ContentTemplate, ContentView {
252
246
  readonly node: Node;
253
247
  constructor(node: Node);
254
- bind(source: any, context: ExecutionContext<any>): void;
248
+ get context(): ExecutionContext<any>;
249
+ bind(source: any): void;
255
250
  unbind(): void;
256
251
  insertBefore(refNode: Node): void;
257
252
  remove(): void;
@@ -273,5 +268,5 @@ export declare class NodeTemplate implements ContentTemplate, ContentView {
273
268
  * RenderInstruction to determine the view.
274
269
  * @public
275
270
  */
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>;
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>;
277
272
  export {};