@microsoft/fast-element 2.0.0-beta.2 → 2.0.0-beta.5

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 (54) hide show
  1. package/CHANGELOG.json +147 -0
  2. package/CHANGELOG.md +42 -1
  3. package/dist/dts/components/fast-definitions.d.ts +9 -8
  4. package/dist/dts/components/fast-element.d.ts +12 -24
  5. package/dist/dts/context.d.ts +1 -1
  6. package/dist/dts/di/di.d.ts +858 -0
  7. package/dist/dts/hooks.d.ts +2 -2
  8. package/dist/dts/interfaces.d.ts +40 -7
  9. package/dist/dts/observation/observable.d.ts +19 -13
  10. package/dist/dts/styles/element-styles.d.ts +6 -0
  11. package/dist/dts/templating/binding-signal.d.ts +10 -27
  12. package/dist/dts/templating/binding-two-way.d.ts +16 -41
  13. package/dist/dts/templating/binding.d.ts +79 -118
  14. package/dist/dts/templating/html-directive.d.ts +31 -3
  15. package/dist/dts/templating/render.d.ts +277 -0
  16. package/dist/dts/templating/repeat.d.ts +12 -16
  17. package/dist/dts/templating/template.d.ts +3 -3
  18. package/dist/dts/templating/when.d.ts +3 -3
  19. package/dist/dts/testing/exports.d.ts +2 -0
  20. package/dist/dts/testing/fixture.d.ts +90 -0
  21. package/dist/dts/testing/timeout.d.ts +7 -0
  22. package/dist/esm/components/fast-definitions.js +25 -27
  23. package/dist/esm/components/fast-element.js +20 -11
  24. package/dist/esm/context.js +5 -1
  25. package/dist/esm/debug.js +36 -4
  26. package/dist/esm/di/di.js +1351 -0
  27. package/dist/esm/observation/arrays.js +303 -2
  28. package/dist/esm/observation/observable.js +11 -6
  29. package/dist/esm/platform.js +1 -1
  30. package/dist/esm/styles/element-styles.js +14 -0
  31. package/dist/esm/templating/binding-signal.js +56 -61
  32. package/dist/esm/templating/binding-two-way.js +56 -34
  33. package/dist/esm/templating/binding.js +137 -156
  34. package/dist/esm/templating/compiler.js +30 -7
  35. package/dist/esm/templating/html-directive.js +16 -2
  36. package/dist/esm/templating/render.js +392 -0
  37. package/dist/esm/templating/repeat.js +57 -40
  38. package/dist/esm/templating/template.js +8 -5
  39. package/dist/esm/templating/view.js +3 -1
  40. package/dist/esm/templating/when.js +5 -4
  41. package/dist/esm/testing/exports.js +2 -0
  42. package/dist/esm/testing/fixture.js +88 -0
  43. package/dist/esm/testing/timeout.js +24 -0
  44. package/dist/fast-element.api.json +2828 -2758
  45. package/dist/fast-element.d.ts +218 -230
  46. package/dist/fast-element.debug.js +656 -257
  47. package/dist/fast-element.debug.min.js +1 -1
  48. package/dist/fast-element.js +620 -253
  49. package/dist/fast-element.min.js +1 -1
  50. package/dist/fast-element.untrimmed.d.ts +226 -235
  51. package/docs/api-report.md +88 -91
  52. package/package.json +15 -6
  53. package/dist/dts/observation/splice-strategies.d.ts +0 -13
  54. package/dist/esm/observation/splice-strategies.js +0 -400
@@ -1,4 +1,4 @@
1
- import { BindingObserver } from "./observation/observable.js";
1
+ import { ExpressionNotifier } from "./observation/observable.js";
2
2
  /**
3
3
  * Functions used for getting and setting a stateful value.
4
4
  * @beta
@@ -17,4 +17,4 @@ export declare function useState<T>(value: T, deep?: boolean): State<T>;
17
17
  * @param action An action that is affected by state changes.
18
18
  * @returns A BindingObserver which can be used to dispose of the effect.
19
19
  */
20
- export declare function useEffect(action: () => void): BindingObserver;
20
+ export declare function useEffect(action: () => void): ExpressionNotifier;
@@ -13,6 +13,20 @@ export declare type Callable = typeof Function.prototype.call | {
13
13
  export declare type Constructable<T = {}> = {
14
14
  new (...args: any[]): T;
15
15
  };
16
+ /**
17
+ * Represents a class.
18
+ * @public
19
+ */
20
+ export declare type Class<T, C = {}> = C & {
21
+ /**
22
+ * The class's prototype;
23
+ */
24
+ readonly prototype: T;
25
+ /**
26
+ * The class's constructor.
27
+ */
28
+ new (...args: any[]): T;
29
+ };
16
30
  /**
17
31
  * Provides a mechanism for releasing resources.
18
32
  * @public
@@ -77,18 +91,21 @@ export interface FASTGlobal {
77
91
  /**
78
92
  * Sends a warning to the developer.
79
93
  * @param code - The warning code to send.
80
- * @param args - Args relevant for the warning.
94
+ * @param values - Values relevant for the warning message.
81
95
  */
82
- warn(code: number, ...args: any[]): void;
96
+ warn(code: number, values?: Record<string, any>): void;
83
97
  /**
84
98
  * Creates an error.
85
99
  * @param code - The error code to send.
86
- * @param args - Args relevant for the error.
100
+ * @param values - Values relevant for the error message.
87
101
  */
88
- error(code: number, ...args: any[]): Error;
102
+ error(code: number, values?: Record<string, any>): Error;
89
103
  /**
90
104
  * Adds debug messages for errors and warnings.
91
105
  * @param messages - The message dictionary to add.
106
+ * @remarks
107
+ * Message can include placeholders like $\{name\} which can be
108
+ * replaced by values passed at runtime.
92
109
  */
93
110
  addMessages(messages: Record<number, string>): void;
94
111
  }
@@ -101,8 +118,7 @@ export declare const enum KernelServiceId {
101
118
  observable = 2,
102
119
  contextEvent = 3,
103
120
  elementRegistry = 4,
104
- styleSheetStrategy = 5,
105
- developerChannel = 6
121
+ styleSheetStrategy = 5
106
122
  }
107
123
  /**
108
124
  * A node that can be targeted by styles.
@@ -154,7 +170,24 @@ export declare const enum Message {
154
170
  needsArrayObservation = 1101,
155
171
  onlySetHTMLPolicyOnce = 1201,
156
172
  bindingInnerHTMLRequiresTrustedTypes = 1202,
157
- missingElementDefinition = 1401
173
+ twoWayBindingRequiresObservables = 1203,
174
+ hostBindingWithoutHost = 1204,
175
+ unsupportedBindingBehavior = 1205,
176
+ missingElementDefinition = 1401,
177
+ noRegistrationForContext = 1501,
178
+ noFactoryForResolver = 1502,
179
+ invalidResolverStrategy = 1503,
180
+ cannotAutoregisterDependency = 1504,
181
+ cannotResolveKey = 1505,
182
+ cannotConstructNativeFunction = 1506,
183
+ cannotJITRegisterNonConstructor = 1507,
184
+ cannotJITRegisterIntrinsic = 1508,
185
+ cannotJITRegisterInterface = 1509,
186
+ invalidResolver = 1510,
187
+ invalidKey = 1511,
188
+ noDefaultResolver = 1512,
189
+ cyclicDependency = 1513,
190
+ connectUpdateRequiresController = 1514
158
191
  }
159
192
  /**
160
193
  * @internal
@@ -23,10 +23,10 @@ export interface Accessor {
23
23
  }
24
24
  /**
25
25
  * The signature of an arrow function capable of being evaluated
26
- * as part of a template binding update.
26
+ * against source data and within an execution context.
27
27
  * @public
28
28
  */
29
- export declare type Binding<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn;
29
+ export declare type Expression<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn;
30
30
  /**
31
31
  * A record of observable property access.
32
32
  * @public
@@ -42,19 +42,25 @@ export interface ObservationRecord {
42
42
  propertyName: string;
43
43
  }
44
44
  /**
45
- * Enables evaluation of and subscription to a binding.
45
+ * Observes a binding for changes.
46
+ *
46
47
  * @public
47
48
  */
48
- export interface BindingObserver<TSource = any, TReturn = any, TParent = any> extends Notifier, Disposable {
49
+ export interface ExpressionObserver<TSource = any, TReturn = any, TParent = any> extends Disposable {
49
50
  /**
50
- * Begins observing the binding for the source and returns the current value.
51
- * @param source - The source that the binding is based on.
52
- * @param context - The execution context to execute the binding within.
53
- * @returns The value of the binding.
51
+ * Begins observing the binding.
52
+ * @param source - The source to pass to the binding.
53
+ * @param context - The context to pass to the binding.
54
54
  */
55
55
  observe(source: TSource, context?: ExecutionContext<TParent>): TReturn;
56
+ }
57
+ /**
58
+ * Enables evaluation of and subscription to a binding.
59
+ * @public
60
+ */
61
+ export interface ExpressionNotifier<TSource = any, TReturn = any, TParent = any> extends Notifier, ExpressionObserver<TSource, TReturn, TParent> {
56
62
  /**
57
- * Gets {@link ObservationRecord|ObservationRecords} that the {@link BindingObserver}
63
+ * Gets {@link ObservationRecord|ObservationRecords} that the {@link ExpressionNotifier}
58
64
  * is observing.
59
65
  */
60
66
  records(): IterableIterator<ObservationRecord>;
@@ -114,19 +120,19 @@ export declare const Observable: Readonly<{
114
120
  */
115
121
  getAccessors: (target: {}) => Accessor[];
116
122
  /**
117
- * Creates a {@link BindingObserver} that can watch the
118
- * provided {@link Binding} for changes.
123
+ * Creates a {@link ExpressionNotifier} that can watch the
124
+ * provided {@link Expression} for changes.
119
125
  * @param binding - The binding to observe.
120
126
  * @param initialSubscriber - An initial subscriber to changes in the binding value.
121
127
  * @param isVolatileBinding - Indicates whether the binding's dependency list must be re-evaluated on every value evaluation.
122
128
  */
123
- binding<TSource = any, TReturn = any>(binding: Binding<TSource, TReturn, any>, initialSubscriber?: Subscriber, isVolatileBinding?: boolean): BindingObserver<TSource, TReturn, any>;
129
+ binding<TSource = any, TReturn = any>(binding: Expression<TSource, TReturn, any>, initialSubscriber?: Subscriber, isVolatileBinding?: boolean): ExpressionNotifier<TSource, TReturn, any>;
124
130
  /**
125
131
  * Determines whether a binding expression is volatile and needs to have its dependency list re-evaluated
126
132
  * on every evaluation of the value.
127
133
  * @param binding - The binding to inspect.
128
134
  */
129
- isVolatileBinding<TSource_1 = any, TReturn_1 = any>(binding: Binding<TSource_1, TReturn_1, any>): boolean;
135
+ isVolatileBinding<TSource_1 = any, TReturn_1 = any>(binding: Expression<TSource_1, TReturn_1, any>): boolean;
130
136
  }>;
131
137
  /**
132
138
  * Decorator: Defines an observable property on the target.
@@ -58,6 +58,12 @@ export declare class ElementStyles {
58
58
  * @param Strategy - The strategy type to construct.
59
59
  */
60
60
  static setDefaultStrategy(Strategy: ConstructibleStyleStrategy): void;
61
+ /**
62
+ * Normalizes a set of composable style options.
63
+ * @param styles - The style options to normalize.
64
+ * @returns A singular ElementStyles instance or undefined.
65
+ */
66
+ static normalize(styles: ComposableStyles | ComposableStyles[] | undefined): ElementStyles | undefined;
61
67
  /**
62
68
  * Indicates whether the DOM supports the adoptedStyleSheets feature.
63
69
  */
@@ -1,38 +1,21 @@
1
- import type { Binding, ExecutionContext } from "../observation/observable.js";
2
- import { BindingConfig, UpdateBinding } from "./binding.js";
3
- import type { ViewBehaviorTargets } from "./html-directive.js";
4
- /**
5
- * A binding behavior for signal bindings.
6
- * @public
7
- */
8
- export declare class SignalBinding extends UpdateBinding {
9
- private handlerProperty;
10
- /**
11
- * Bind this behavior to the source.
12
- * @param source - The source to bind to.
13
- * @param context - The execution context that the binding is operating within.
14
- * @param targets - The targets that behaviors in a view can attach to.
15
- */
16
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
17
- /**
18
- * Unbinds this behavior from the source.
19
- * @param source - The source to unbind from.
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.
22
- */
23
- unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
24
- private getSignal;
1
+ import type { Expression } from "../observation/observable.js";
2
+ import type { Subscriber } from "../observation/notifier.js";
3
+ import { Binding } from "./html-directive.js";
4
+ export declare const Signal: Readonly<{
5
+ subscribe(signal: string, subscriber: Subscriber): void;
6
+ unsubscribe(signal: string, subscriber: Subscriber): void;
25
7
  /**
26
8
  * Sends the specified signal to signaled bindings.
27
9
  * @param signal - The signal to send.
28
10
  * @public
29
11
  */
30
- static send(signal: string): void;
31
- }
12
+ send(signal: string): void;
13
+ }>;
32
14
  /**
33
15
  * Creates a signal binding configuration with the supplied options.
16
+ * @param binding - The binding to refresh when signaled.
34
17
  * @param options - The signal name or a binding to use to retrieve the signal name.
35
18
  * @returns A binding configuration.
36
19
  * @public
37
20
  */
38
- export declare const signal: <T = any>(options: string | Binding<T, any, any>) => BindingConfig<string | Binding<T, any, any>>;
21
+ export declare function signal<T = any>(binding: Expression<T>, options: string | Expression<T>): Binding<T>;
@@ -1,6 +1,14 @@
1
- import type { ExecutionContext } from "../observation/observable.js";
2
- import { BindingConfig, ChangeBinding, DefaultBindingOptions, HTMLBindingDirective } from "./binding.js";
3
- import type { ViewBehaviorTargets } from "./html-directive.js";
1
+ import { Expression } from "../observation/observable.js";
2
+ import type { HTMLBindingDirective } from "./binding.js";
3
+ import { Binding } from "./html-directive.js";
4
+ /**
5
+ * The twoWay binding options.
6
+ * @public
7
+ */
8
+ export declare type TwoWayBindingOptions = {
9
+ changeEvent?: string;
10
+ fromView?: (value: any) => any;
11
+ };
4
12
  /**
5
13
  * The settings required to enable two-way binding.
6
14
  * @public
@@ -14,43 +22,10 @@ export interface TwoWaySettings {
14
22
  determineChangeEvent(directive: HTMLBindingDirective, target: HTMLElement): string;
15
23
  }
16
24
  /**
17
- * A binding behavior for bindings that update in two directions.
18
- * @public
19
- */
20
- export declare class TwoWayBinding extends ChangeBinding {
21
- private changeEvent;
22
- /**
23
- * Bind this behavior to the source.
24
- * @param source - The source to bind to.
25
- * @param context - The execution context that the binding is operating within.
26
- * @param targets - The targets that behaviors in a view can attach to.
27
- */
28
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
29
- /**
30
- * Unbinds this behavior from the source.
31
- * @param source - The source to unbind from.
32
- * @param context - The execution context that the binding is operating within.
33
- * @param targets - The targets that behaviors in a view can attach to.
34
- */
35
- unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
36
- /** @internal */
37
- handleEvent(event: Event): void;
38
- /**
39
- * Configures two-way binding.
40
- * @param settings - The settings to use for the two-way binding system.
41
- */
42
- static configure(settings: TwoWaySettings): void;
43
- }
44
- /**
45
- * The default twoWay binding options.
46
- * @public
47
- */
48
- export declare type DefaultTwoWayBindingOptions = DefaultBindingOptions & {
49
- changeEvent?: string;
50
- fromView?: (value: any) => any;
51
- };
52
- /**
53
- * The default twoWay binding configuration.
25
+ * Creates a default binding.
26
+ * @param binding - The binding to refresh when changed.
27
+ * @param isBindingVolatile - Indicates whether the binding is volatile or not.
28
+ * @returns A binding configuration.
54
29
  * @public
55
30
  */
56
- export declare const twoWay: BindingConfig<DefaultTwoWayBindingOptions> & import("./binding.js").BindingConfigResolver<DefaultTwoWayBindingOptions>;
31
+ export declare function twoWay<T = any>(binding: Expression<T>, optionsOrChangeEvent?: TwoWayBindingOptions | string, isBindingVolatile?: boolean): Binding<T>;
@@ -1,56 +1,5 @@
1
- import { Binding, BindingObserver, ExecutionContext } from "../observation/observable.js";
2
- import { AddViewBehaviorFactory, Aspect, Aspected, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewBehaviorTargets } from "./html-directive.js";
3
- import type { CaptureType } from "./template.js";
4
- /**
5
- * Describes how aspects of an HTML element will be affected by bindings.
6
- * @public
7
- */
8
- export declare type BindingMode = Record<Aspect, (directive: HTMLBindingDirective) => Pick<ViewBehaviorFactory, "createBehavior">>;
9
- /**
10
- * Describes how aspects of an HTML element will be affected by bindings.
11
- * @public
12
- */
13
- export declare const BindingMode: Readonly<{
14
- /**
15
- * Creates a binding mode based on the supplied behavior types.
16
- * @param UpdateType - The base behavior type used to update aspects.
17
- * @param EventType - The base behavior type used to respond to events.
18
- * @returns A new binding mode.
19
- */
20
- define(UpdateType: typeof UpdateBinding, EventType?: typeof EventBinding): BindingMode;
21
- }>;
22
- /**
23
- * Describes the configuration for a binding expression.
24
- * @public
25
- */
26
- export interface BindingConfig<T = any> {
27
- /**
28
- * The binding mode to configure the binding with.
29
- */
30
- mode: BindingMode;
31
- /**
32
- * Options to be supplied to the binding behaviors.
33
- */
34
- options: T;
35
- }
36
- /**
37
- * Creates a new binding configuration based on the supplied options.
38
- * @public
39
- */
40
- export declare type BindingConfigResolver<T> = (options: T) => BindingConfig<T>;
41
- /**
42
- * Describes the configuration for a binding expression.
43
- * @public
44
- */
45
- export declare const BindingConfig: Readonly<{
46
- /**
47
- * Creates a binding configuration based on the provided mode and options.
48
- * @param mode - The mode to use for the configuration.
49
- * @param defaultOptions - The default options to use for the configuration.
50
- * @returns A new binding configuration.
51
- */
52
- define<T>(mode: BindingMode, defaultOptions: T): BindingConfig<T> & BindingConfigResolver<T>;
53
- }>;
1
+ import { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
2
+ import { AddViewBehaviorFactory, Aspect, Aspected, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewBehaviorTargets } from "./html-directive.js";
54
3
  /**
55
4
  * The "this" context for an update target function.
56
5
  * @public
@@ -73,57 +22,48 @@ export interface UpdateTargetThis {
73
22
  */
74
23
  export declare type UpdateTarget = (this: UpdateTargetThis, target: Node, aspect: string, value: any, source: any, context: ExecutionContext) => void;
75
24
  /**
76
- * A base binding behavior for DOM updates.
25
+ * A simple View that can be interpolated into HTML content.
77
26
  * @public
78
27
  */
79
- export declare class UpdateBinding implements ViewBehavior {
80
- readonly directive: HTMLBindingDirective;
81
- protected updateTarget: UpdateTarget;
28
+ export interface ContentView {
82
29
  /**
83
- * Creates an instance of UpdateBinding.
84
- * @param directive - The directive that has the configuration for this behavior.
85
- * @param updateTarget - The function used to update the target with the latest value.
30
+ * Binds a view's behaviors to its binding source.
31
+ * @param source - The binding source for the view's binding behaviors.
32
+ * @param context - The execution context to run the view within.
86
33
  */
87
- constructor(directive: HTMLBindingDirective, updateTarget: UpdateTarget);
34
+ bind(source: any, context: ExecutionContext): void;
88
35
  /**
89
- * Bind this behavior to the source.
90
- * @param source - The source to bind to.
91
- * @param context - The execution context that the binding is operating within.
92
- * @param targets - The targets that behaviors in a view can attach to.
36
+ * Unbinds a view's behaviors from its binding source and context.
93
37
  */
94
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
38
+ unbind(): void;
95
39
  /**
96
- * Unbinds this behavior from the source.
97
- * @param source - The source to unbind from.
98
- * @param context - The execution context that the binding is operating within.
99
- * @param targets - The targets that behaviors in a view can attach to.
40
+ * Inserts the view's DOM nodes before the referenced node.
41
+ * @param node - The node to insert the view's DOM before.
100
42
  */
101
- unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
43
+ insertBefore(node: Node): void;
102
44
  /**
103
- * Creates a behavior.
104
- * @param targets - The targets available for behaviors to be attached to.
45
+ * Removes the view's DOM nodes.
46
+ * The nodes are not disposed and the view can later be re-inserted.
105
47
  */
106
- createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
48
+ remove(): void;
107
49
  }
108
50
  /**
109
- * A binding behavior for one-time bindings.
51
+ * A simple template that can create ContentView instances.
110
52
  * @public
111
53
  */
112
- export declare class OneTimeBinding extends UpdateBinding {
54
+ export interface ContentTemplate {
113
55
  /**
114
- * Bind this behavior to the source.
115
- * @param source - The source to bind to.
116
- * @param context - The execution context that the binding is operating within.
117
- * @param targets - The targets that behaviors in a view can attach to.
56
+ * Creates a simple content view instance.
118
57
  */
119
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
58
+ create(): ContentView;
120
59
  }
121
60
  /**
122
61
  * A binding behavior for bindings that change.
123
62
  * @public
124
63
  */
125
- export declare class ChangeBinding extends UpdateBinding {
126
- private isBindingVolatile;
64
+ export declare class BindingBehavior implements ViewBehavior {
65
+ readonly directive: HTMLBindingDirective;
66
+ protected updateTarget: UpdateTarget;
127
67
  private observerProperty;
128
68
  /**
129
69
  * Creates an instance of ChangeBinding.
@@ -131,12 +71,6 @@ export declare class ChangeBinding extends UpdateBinding {
131
71
  * @param updateTarget - The function used to update the target with the latest value.
132
72
  */
133
73
  constructor(directive: HTMLBindingDirective, updateTarget: UpdateTarget);
134
- /**
135
- * Returns the binding observer used to update the node.
136
- * @param target - The target node.
137
- * @returns A BindingObserver.
138
- */
139
- protected getObserver(target: Node): BindingObserver;
140
74
  /**
141
75
  * Bind this behavior to the source.
142
76
  * @param source - The source to bind to.
@@ -152,13 +86,37 @@ export declare class ChangeBinding extends UpdateBinding {
152
86
  */
153
87
  unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
154
88
  /** @internal */
155
- handleChange(binding: Binding, observer: BindingObserver): void;
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;
156
114
  }
157
115
  /**
158
116
  * A binding behavior for handling events.
159
117
  * @public
160
118
  */
161
- export declare class EventBinding {
119
+ export declare class EventBehavior {
162
120
  readonly directive: HTMLBindingDirective;
163
121
  private contextProperty;
164
122
  private sourceProperty;
@@ -191,29 +149,12 @@ export declare class EventBinding {
191
149
  */
192
150
  handleEvent(event: Event): void;
193
151
  }
194
- /**
195
- * The default binding options.
196
- * @public
197
- */
198
- export declare type DefaultBindingOptions = AddEventListenerOptions;
199
- /**
200
- * The default onChange binding configuration.
201
- * @public
202
- */
203
- export declare const onChange: BindingConfig<AddEventListenerOptions> & BindingConfigResolver<AddEventListenerOptions>;
204
- /**
205
- * The default onTime binding configuration.
206
- * @public
207
- */
208
- export declare const oneTime: BindingConfig<AddEventListenerOptions> & BindingConfigResolver<AddEventListenerOptions>;
209
152
  /**
210
153
  * A directive that applies bindings.
211
154
  * @public
212
155
  */
213
156
  export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, Aspected {
214
- binding: Binding;
215
- mode: BindingMode;
216
- options: any;
157
+ dataBinding: Binding;
217
158
  private factory;
218
159
  /**
219
160
  * The unique id of the factory.
@@ -237,11 +178,9 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
237
178
  aspectType: Aspect;
238
179
  /**
239
180
  * Creates an instance of HTMLBindingDirective.
240
- * @param binding - The binding to apply.
241
- * @param mode - The binding mode to use when applying the binding.
242
- * @param options - The options to configure the binding with.
181
+ * @param dataBinding - The binding configuration to apply.
243
182
  */
244
- constructor(binding: Binding, mode: BindingMode, options: any);
183
+ constructor(dataBinding: Binding);
245
184
  /**
246
185
  * Creates HTML to be used within a template.
247
186
  * @param add - Can be used to add behavior factories to a template.
@@ -254,10 +193,32 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
254
193
  createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
255
194
  }
256
195
  /**
257
- * Creates a binding directive with the specified configuration.
258
- * @param binding - The binding expression.
259
- * @param config - The binding configuration.
260
- * @returns A binding directive.
196
+ * Creates an standard binding.
197
+ * @param binding - The binding to refresh when changed.
198
+ * @param isVolatile - Indicates whether the binding is volatile or not.
199
+ * @returns A binding configuration.
200
+ * @public
201
+ */
202
+ export declare function bind<T = any>(binding: Expression<T>, isVolatile?: boolean): Binding<T>;
203
+ /**
204
+ * Creates a one time binding
205
+ * @param binding - The binding to refresh when signaled.
206
+ * @returns A binding configuration.
207
+ * @public
208
+ */
209
+ export declare function oneTime<T = any>(binding: Expression<T>): Binding<T>;
210
+ /**
211
+ * Creates an event listener binding.
212
+ * @param binding - The binding to invoke when the event is raised.
213
+ * @param options - Event listener options.
214
+ * @returns A binding configuration.
215
+ * @public
216
+ */
217
+ export declare function listener<T = any>(binding: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
218
+ /**
219
+ * Normalizes the input value into a binding.
220
+ * @param value - The value to create the default binding for.
221
+ * @returns A binding configuration for the provided value.
261
222
  * @public
262
223
  */
263
- export declare function bind<T = any>(binding: Binding<T>, config?: BindingConfig | DefaultBindingOptions): CaptureType<T>;
224
+ export declare function normalizeBinding<TSource = any, TReturn = any, TParent = any>(value: Expression<TSource, TReturn, TParent> | Binding<TSource, TReturn, TParent> | {}): Binding<TSource, TReturn, TParent>;
@@ -1,6 +1,7 @@
1
1
  import type { Constructable } from "../interfaces.js";
2
2
  import type { Behavior } from "../observation/behavior.js";
3
- import type { Binding, ExecutionContext } from "../observation/observable.js";
3
+ import type { Subscriber } from "../observation/notifier.js";
4
+ import type { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
4
5
  /**
5
6
  * The target nodes available to a behavior.
6
7
  * @public
@@ -113,6 +114,31 @@ export declare const HTMLDirective: Readonly<{
113
114
  * @public
114
115
  */
115
116
  export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition): (type: Constructable<HTMLDirective>) => void;
117
+ /**
118
+ * Captures a binding expression along with related information and capabilities.
119
+ *
120
+ * @public
121
+ */
122
+ export declare abstract class Binding<TSource = any, TReturn = any, TParent = any> {
123
+ /**
124
+ * Options associated with the binding.
125
+ */
126
+ options?: any;
127
+ /**
128
+ * Whether or not the binding is volatile.
129
+ */
130
+ isVolatile?: boolean;
131
+ /**
132
+ * Evaluates the binding expression.
133
+ */
134
+ evaluate: Expression<TSource, TReturn, TParent>;
135
+ /**
136
+ * Creates an observer capable of notifying a subscriber when the output of a binding changes.
137
+ * @param directive - The HTML Directive to create the observer for.
138
+ * @param subscriber - The subscriber to changes in the binding.
139
+ */
140
+ abstract createObserver(directive: HTMLDirective, subscriber: Subscriber): ExpressionObserver<TSource, TReturn, TParent>;
141
+ }
116
142
  /**
117
143
  * The type of HTML aspect to target.
118
144
  * @public
@@ -150,8 +176,10 @@ export declare const Aspect: Readonly<{
150
176
  *
151
177
  * @param directive - The directive to assign the aspect to.
152
178
  * @param value - The value to base the aspect determination on.
179
+ * @remarks
180
+ * If a falsy value is provided, then the content aspect will be assigned.
153
181
  */
154
- readonly assign: (directive: Aspected, value: string) => void;
182
+ readonly assign: (directive: Aspected, value?: string) => void;
155
183
  }>;
156
184
  /**
157
185
  * The type of HTML aspect to target.
@@ -178,7 +206,7 @@ export interface Aspected {
178
206
  /**
179
207
  * A binding if one is associated with the aspect.
180
208
  */
181
- binding?: Binding;
209
+ dataBinding?: Binding;
182
210
  }
183
211
  /**
184
212
  * A base class used for attribute directives that don't need internal state.