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

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 (113) hide show
  1. package/CHANGELOG.json +488 -0
  2. package/CHANGELOG.md +180 -1
  3. package/dist/dts/components/attributes.d.ts +15 -0
  4. package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +74 -28
  5. package/dist/dts/components/fast-definitions.d.ts +41 -9
  6. package/dist/dts/components/fast-element.d.ts +14 -26
  7. package/dist/dts/components/hydration.d.ts +14 -0
  8. package/dist/{esm/observation/behavior.js → dts/components/install-hydration.d.ts} +0 -0
  9. package/dist/dts/context.d.ts +1 -1
  10. package/dist/dts/di/di.d.ts +894 -0
  11. package/dist/dts/dom-policy.d.ts +68 -0
  12. package/dist/dts/dom.d.ts +100 -0
  13. package/dist/dts/index.d.ts +5 -4
  14. package/dist/dts/index.rollup.d.ts +0 -1
  15. package/dist/dts/index.rollup.debug.d.ts +0 -1
  16. package/dist/dts/interfaces.d.ts +60 -79
  17. package/dist/dts/observation/observable.d.ts +99 -54
  18. package/dist/dts/pending-task.d.ts +20 -0
  19. package/dist/dts/platform.d.ts +7 -0
  20. package/dist/dts/polyfills.d.ts +0 -8
  21. package/dist/dts/state/exports.d.ts +3 -0
  22. package/dist/dts/state/reactive.d.ts +8 -0
  23. package/dist/dts/state/state.d.ts +141 -0
  24. package/dist/dts/state/visitor.d.ts +6 -0
  25. package/dist/dts/state/watch.d.ts +10 -0
  26. package/dist/dts/styles/css-directive.d.ts +2 -2
  27. package/dist/dts/styles/css.d.ts +0 -5
  28. package/dist/dts/styles/element-styles.d.ts +10 -17
  29. package/dist/dts/styles/host.d.ts +68 -0
  30. package/dist/dts/styles/style-strategy.d.ts +42 -0
  31. package/dist/dts/templating/binding-signal.d.ts +12 -27
  32. package/dist/dts/templating/binding-two-way.d.ts +22 -37
  33. package/dist/dts/templating/binding.d.ts +76 -208
  34. package/dist/dts/templating/children.d.ts +1 -1
  35. package/dist/dts/templating/compiler.d.ts +11 -13
  36. package/dist/dts/templating/html-directive.d.ts +91 -97
  37. package/dist/dts/templating/node-observation.d.ts +15 -6
  38. package/dist/dts/templating/ref.d.ts +7 -11
  39. package/dist/dts/templating/render.d.ts +296 -0
  40. package/dist/dts/templating/repeat.d.ts +23 -34
  41. package/dist/dts/templating/slotted.d.ts +1 -1
  42. package/dist/dts/templating/template.d.ts +92 -14
  43. package/dist/dts/templating/view.d.ts +81 -11
  44. package/dist/dts/templating/when.d.ts +3 -3
  45. package/dist/dts/testing/exports.d.ts +3 -0
  46. package/dist/dts/testing/fakes.d.ts +14 -0
  47. package/dist/dts/testing/fixture.d.ts +84 -0
  48. package/dist/dts/testing/timeout.d.ts +7 -0
  49. package/dist/dts/utilities.d.ts +53 -18
  50. package/dist/esm/components/attributes.js +28 -5
  51. package/dist/esm/components/{controller.js → element-controller.js} +239 -137
  52. package/dist/esm/components/fast-definitions.js +38 -30
  53. package/dist/esm/components/fast-element.js +27 -16
  54. package/dist/esm/components/hydration.js +35 -0
  55. package/dist/esm/components/install-hydration.js +2 -0
  56. package/dist/esm/context.js +5 -1
  57. package/dist/esm/debug.js +40 -5
  58. package/dist/esm/di/di.js +1430 -0
  59. package/dist/esm/dom-policy.js +337 -0
  60. package/dist/esm/dom.js +101 -0
  61. package/dist/esm/index.js +4 -2
  62. package/dist/esm/index.rollup.debug.js +3 -1
  63. package/dist/esm/index.rollup.js +3 -1
  64. package/dist/esm/interfaces.js +52 -0
  65. package/dist/esm/observation/arrays.js +303 -2
  66. package/dist/esm/observation/observable.js +88 -142
  67. package/dist/esm/observation/update-queue.js +2 -2
  68. package/dist/esm/pending-task.js +16 -0
  69. package/dist/esm/platform.js +27 -2
  70. package/dist/esm/polyfills.js +3 -61
  71. package/dist/esm/state/exports.js +3 -0
  72. package/dist/esm/state/reactive.js +34 -0
  73. package/dist/esm/state/state.js +148 -0
  74. package/dist/esm/state/visitor.js +28 -0
  75. package/dist/esm/state/watch.js +36 -0
  76. package/dist/esm/styles/css.js +4 -9
  77. package/dist/esm/styles/element-styles.js +14 -33
  78. package/dist/esm/styles/host.js +1 -0
  79. package/dist/esm/styles/style-strategy.js +1 -0
  80. package/dist/esm/templating/binding-signal.js +67 -62
  81. package/dist/esm/templating/binding-two-way.js +72 -39
  82. package/dist/esm/templating/binding.js +142 -286
  83. package/dist/esm/templating/children.js +8 -4
  84. package/dist/esm/templating/compiler.js +59 -43
  85. package/dist/esm/templating/html-directive.js +56 -75
  86. package/dist/esm/templating/node-observation.js +20 -13
  87. package/dist/esm/templating/ref.js +4 -12
  88. package/dist/esm/templating/render.js +402 -0
  89. package/dist/esm/templating/repeat.js +88 -75
  90. package/dist/esm/templating/template.js +132 -60
  91. package/dist/esm/templating/view.js +113 -29
  92. package/dist/esm/templating/when.js +5 -4
  93. package/dist/esm/testing/exports.js +3 -0
  94. package/dist/esm/testing/fakes.js +107 -0
  95. package/dist/esm/testing/fixture.js +86 -0
  96. package/dist/esm/testing/timeout.js +24 -0
  97. package/dist/esm/utilities.js +95 -95
  98. package/dist/fast-element.api.json +9487 -8326
  99. package/dist/fast-element.d.ts +847 -644
  100. package/dist/fast-element.debug.js +1993 -1166
  101. package/dist/fast-element.debug.min.js +1 -1
  102. package/dist/fast-element.js +1903 -1111
  103. package/dist/fast-element.min.js +1 -1
  104. package/dist/fast-element.untrimmed.d.ts +911 -701
  105. package/docs/api-report.md +329 -252
  106. package/package.json +38 -16
  107. package/dist/dts/hooks.d.ts +0 -20
  108. package/dist/dts/observation/behavior.d.ts +0 -19
  109. package/dist/dts/observation/splice-strategies.d.ts +0 -13
  110. package/dist/dts/templating/dom.d.ts +0 -41
  111. package/dist/esm/hooks.js +0 -32
  112. package/dist/esm/observation/splice-strategies.js +0 -400
  113. package/dist/esm/templating/dom.js +0 -49
@@ -1,8 +0,0 @@
1
- import type { StyleStrategy, StyleTarget } from "./interfaces.js";
2
- export declare class StyleElementStrategy implements StyleStrategy {
3
- private readonly styles;
4
- private readonly styleClass;
5
- constructor(styles: string[]);
6
- addStylesTo(target: StyleTarget): void;
7
- removeStylesFrom(target: StyleTarget): void;
8
- }
@@ -0,0 +1,3 @@
1
+ export { reactive } from "./reactive.js";
2
+ export { watch } from "./watch.js";
3
+ export * from "./state.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Converts a plain object to a reactive, observable object.
3
+ * @param object - The object to make reactive.
4
+ * @param deep - Indicates whether or not to deeply convert the oject.
5
+ * @returns The converted object.
6
+ * @beta
7
+ */
8
+ export declare function reactive<T>(object: T, deep?: boolean): T;
@@ -0,0 +1,141 @@
1
+ import { Disposable } from "../interfaces.js";
2
+ import type { Subscriber } from "../observation/notifier.js";
3
+ /**
4
+ * Options for creating state.
5
+ * @beta
6
+ */
7
+ export declare type StateOptions = {
8
+ /**
9
+ * Indicates whether to deeply make the state value observable.
10
+ */
11
+ deep?: boolean;
12
+ /**
13
+ * A friendly name for the state.
14
+ */
15
+ name?: string;
16
+ };
17
+ /**
18
+ * A readonly stateful value.
19
+ * @beta
20
+ */
21
+ export declare type ReadonlyState<T> = {
22
+ /**
23
+ * Gets the current state value.
24
+ */
25
+ (): T;
26
+ /**
27
+ * Gets the current state value.
28
+ */
29
+ readonly current: T;
30
+ };
31
+ /**
32
+ * A read/write stateful value.
33
+ * @beta
34
+ */
35
+ export declare type State<T> = ReadonlyState<T> & {
36
+ /**
37
+ * Gets or sets the current state value.
38
+ */
39
+ current: T;
40
+ /**
41
+ * Sets the current state value.
42
+ * @param value The new state value.
43
+ */
44
+ set(value: T): void;
45
+ /**
46
+ * Creates a readonly version of the state.
47
+ */
48
+ asReadonly(): ReadonlyState<T>;
49
+ };
50
+ /**
51
+ * Creates a reactive state value.
52
+ * @param value - The initial state value.
53
+ * @param options - Options to customize the state or a friendly name.
54
+ * @returns A State instance.
55
+ * @beta
56
+ */
57
+ export declare function state<T>(value: T, options?: string | StateOptions): State<T>;
58
+ /**
59
+ * A readonly stateful value associated with an object owner.
60
+ * @beta
61
+ */
62
+ export declare type ReadonlyOwnedState<T> = {
63
+ /**
64
+ * Gets the current stateful value for the owner.
65
+ */
66
+ (owner: any): T;
67
+ };
68
+ /**
69
+ * A read/write stateful value associated with an owner.
70
+ * @beta
71
+ */
72
+ export declare type OwnedState<T> = ReadonlyOwnedState<T> & {
73
+ /**
74
+ * Sets
75
+ * @param owner - The object to set the state for the owner.
76
+ * @param value - The new state value.
77
+ */
78
+ set(owner: any, value: T): void;
79
+ /**
80
+ * Creates a readonly version of the state.
81
+ */
82
+ asReadonly(): ReadonlyOwnedState<T>;
83
+ };
84
+ /**
85
+ * Creates a reactive state that has its value associated with a specific owner.
86
+ * @param value - The initial value or a factory that provides an initial value for each owner.
87
+ * @param options - Options to customize the state or a friendly name.
88
+ * @returns An OwnedState instance.
89
+ * @beta
90
+ */
91
+ export declare function ownedState<T>(value: T | (() => T), options?: string | StateOptions): OwnedState<T>;
92
+ /**
93
+ * State whose value is computed from other dependencies.
94
+ * @beta
95
+ */
96
+ export declare type ComputedState<T> = ReadonlyState<T> & Disposable & {
97
+ /**
98
+ * Subscribes to notification of changes in the state.
99
+ * @param subscriber - The object that is subscribing for change notification.
100
+ */
101
+ subscribe(subscriber: Subscriber): void;
102
+ /**
103
+ * Unsubscribes from notification of changes in the state.
104
+ * @param subscriber - The object that is unsubscribing from change notification.
105
+ */
106
+ unsubscribe(subscriber: Subscriber): void;
107
+ };
108
+ /**
109
+ * A callback that enables computation setup.
110
+ * @beta
111
+ */
112
+ export declare type ComputedSetupCallback = () => (() => void) | void;
113
+ /**
114
+ * Provides computed state capabilities.
115
+ * @beta
116
+ */
117
+ export declare type ComputedBuilder = {
118
+ /**
119
+ * Callbacks related to computed state.
120
+ */
121
+ on: {
122
+ /**
123
+ * Provides a setup callback for the computation.
124
+ * @param callback The callback to run to setup the computation.
125
+ */
126
+ setup(callback: ComputedSetupCallback): void;
127
+ };
128
+ };
129
+ /**
130
+ * A callback that initializes the computation.
131
+ * @beta
132
+ */
133
+ export declare type ComputedInitializer<T> = (builder: ComputedBuilder) => () => T;
134
+ /**
135
+ * Creates a ComputedState.
136
+ * @param initialize - The initialization callback.
137
+ * @param name - A friendly name for this computation.
138
+ * @returns A ComputedState
139
+ * @beta
140
+ */
141
+ export declare function computedState<T>(initialize: ComputedInitializer<T>, name?: string): ComputedState<T>;
@@ -0,0 +1,6 @@
1
+ export interface ObjectVisitor<TVisitorData> {
2
+ visitObject(object: any, data: TVisitorData): void;
3
+ visitArray(array: any[], data: TVisitorData): void;
4
+ visitProperty(object: any, key: PropertyKey, value: any, data: TVisitorData): void;
5
+ }
6
+ export declare function visitObject<TVisitorData>(object: any, deep: boolean, visitor: ObjectVisitor<TVisitorData>, data: TVisitorData, traversed: WeakSet<any> | Set<any>): void;
@@ -0,0 +1,10 @@
1
+ import { Disposable } from "../interfaces.js";
2
+ import type { Subscriber } from "../observation/notifier.js";
3
+ /**
4
+ * Deeply subscribes to changes in existing observable objects.
5
+ * @param object - The observable object to watch.
6
+ * @param subscriber - The handler to call when changes are made to the object.
7
+ * @returns A disposable that can be used to unsubscribe from change updates.
8
+ * @beta
9
+ */
10
+ export declare function watch(object: any, subscriber: Subscriber | ((subject: any, args: any) => void)): Disposable;
@@ -1,11 +1,11 @@
1
1
  import type { Constructable } from "../interfaces.js";
2
- import type { Behavior } from "../observation/behavior.js";
2
+ import type { HostBehavior } from "./host.js";
3
3
  import type { ComposableStyles } from "./element-styles.js";
4
4
  /**
5
5
  * Used to add behaviors when constructing styles.
6
6
  * @public
7
7
  */
8
- export declare type AddBehavior = (behavior: Behavior<HTMLElement>) => void;
8
+ export declare type AddBehavior = (behavior: HostBehavior<HTMLElement>) => void;
9
9
  /**
10
10
  * Directive for use in {@link css}.
11
11
  *
@@ -27,8 +27,3 @@ export declare type CSSTemplateTag = ((strings: TemplateStringsArray, ...values:
27
27
  * @public
28
28
  */
29
29
  export declare const css: CSSTemplateTag;
30
- /**
31
- * @deprecated Use css.partial instead.
32
- * @public
33
- */
34
- export declare const cssPartial: (strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]) => CSSDirective;
@@ -1,5 +1,5 @@
1
- import type { Behavior } from "../observation/behavior.js";
2
- import { StyleStrategy, StyleTarget } from "../interfaces.js";
1
+ import type { StyleStrategy, StyleTarget } from "./style-strategy.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.
@@ -58,21 +58,14 @@ 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
  */
64
70
  static readonly supportsAdoptedStyleSheets: boolean;
65
71
  }
66
- /**
67
- * https://wicg.github.io/construct-stylesheets/
68
- * https://developers.google.com/web/updates/2019/02/constructable-stylesheets
69
- *
70
- * @internal
71
- */
72
- export declare class AdoptedStyleSheetsStrategy implements StyleStrategy {
73
- /** @internal */
74
- readonly sheets: CSSStyleSheet[];
75
- constructor(styles: (string | CSSStyleSheet)[]);
76
- addStylesTo(target: StyleTarget): void;
77
- removeStylesFrom(target: StyleTarget): void;
78
- }
@@ -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
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * A node that can be targeted by styles.
3
+ * @public
4
+ */
5
+ export interface StyleTarget extends Pick<Node, "getRootNode"> {
6
+ /**
7
+ * Stylesheets to be adopted by the node.
8
+ */
9
+ adoptedStyleSheets?: CSSStyleSheet[];
10
+ /**
11
+ * Adds styles to the target by appending the styles.
12
+ * @param styles - The styles element to add.
13
+ */
14
+ append(styles: HTMLStyleElement): void;
15
+ /**
16
+ * Removes styles from the target.
17
+ * @param styles - The styles element to remove.
18
+ */
19
+ removeChild(styles: HTMLStyleElement): void;
20
+ /**
21
+ * Returns all element descendants of node that match selectors.
22
+ * @param selectors - The CSS selector to use for the query.
23
+ */
24
+ querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
25
+ }
26
+ /**
27
+ * Implemented to provide specific behavior when adding/removing styles
28
+ * for elements.
29
+ * @public
30
+ */
31
+ export interface StyleStrategy {
32
+ /**
33
+ * Adds styles to the target.
34
+ * @param target - The target to add the styles to.
35
+ */
36
+ addStylesTo(target: StyleTarget): void;
37
+ /**
38
+ * Removes styles from the target.
39
+ * @param target - The target to remove the styles from.
40
+ */
41
+ removeStylesFrom(target: StyleTarget): void;
42
+ }
@@ -1,38 +1,23 @@
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 type { DOMPolicy } from "../dom.js";
4
+ import { Binding } from "./html-directive.js";
5
+ export declare const Signal: Readonly<{
6
+ subscribe(signal: string, subscriber: Subscriber): void;
7
+ unsubscribe(signal: string, subscriber: Subscriber): void;
25
8
  /**
26
9
  * Sends the specified signal to signaled bindings.
27
10
  * @param signal - The signal to send.
28
11
  * @public
29
12
  */
30
- static send(signal: string): void;
31
- }
13
+ send(signal: string): void;
14
+ }>;
32
15
  /**
33
16
  * Creates a signal binding configuration with the supplied options.
17
+ * @param expression - The binding to refresh when signaled.
34
18
  * @param options - The signal name or a binding to use to retrieve the signal name.
19
+ * @param policy - The security policy to associate with th binding.
35
20
  * @returns A binding configuration.
36
21
  * @public
37
22
  */
38
- export declare const signal: <T = any>(options: string | Binding<T, any, any>) => BindingConfig<string | Binding<T, any, any>>;
23
+ export declare function signal<T = any>(expression: Expression<T>, options: string | Expression<T>, policy?: DOMPolicy): Binding<T>;
@@ -1,6 +1,15 @@
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 type { DOMPolicy } from "../dom.js";
2
+ import { Expression } from "../observation/observable.js";
3
+ import type { HTMLBindingDirective } from "./binding.js";
4
+ import { Binding } from "./html-directive.js";
5
+ /**
6
+ * The twoWay binding options.
7
+ * @public
8
+ */
9
+ export declare type TwoWayBindingOptions = {
10
+ changeEvent?: string;
11
+ fromView?: (value: any) => any;
12
+ };
4
13
  /**
5
14
  * The settings required to enable two-way binding.
6
15
  * @public
@@ -13,44 +22,20 @@ export interface TwoWaySettings {
13
22
  */
14
23
  determineChangeEvent(directive: HTMLBindingDirective, target: HTMLElement): string;
15
24
  }
16
- /**
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;
25
+ export declare const TwoWaySettings: Readonly<{
38
26
  /**
39
27
  * Configures two-way binding.
40
28
  * @param settings - The settings to use for the two-way binding system.
41
29
  */
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
- };
30
+ configure(settings: TwoWaySettings): void;
31
+ }>;
52
32
  /**
53
- * The default twoWay binding configuration.
33
+ * Creates a default binding.
34
+ * @param expression - The binding to refresh when changed.
35
+ * @param optionsOrChangeEvent - The binding options or the name of the change event to use.
36
+ * @param policy - The security policy to associate with the binding.
37
+ * @param isBindingVolatile - Indicates whether the binding is volatile or not.
38
+ * @returns A binding.
54
39
  * @public
55
40
  */
56
- export declare const twoWay: BindingConfig<DefaultTwoWayBindingOptions> & import("./binding.js").BindingConfigResolver<DefaultTwoWayBindingOptions>;
41
+ export declare function twoWay<T = any>(expression: Expression<T>, optionsOrChangeEvent?: TwoWayBindingOptions | string, policy?: DOMPolicy, isBindingVolatile?: boolean): Binding<T>;