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

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 (37) hide show
  1. package/CHANGELOG.json +51 -0
  2. package/CHANGELOG.md +15 -1
  3. package/dist/dts/components/fast-definitions.d.ts +2 -0
  4. package/dist/dts/components/fast-element.d.ts +7 -1
  5. package/dist/dts/context.d.ts +157 -0
  6. package/dist/dts/metadata.d.ts +25 -0
  7. package/dist/dts/observation/arrays.d.ts +1 -1
  8. package/dist/dts/observation/behavior.d.ts +4 -4
  9. package/dist/dts/observation/observable.d.ts +43 -62
  10. package/dist/dts/templating/binding-signal.d.ts +38 -0
  11. package/dist/dts/templating/binding-two-way.d.ts +56 -0
  12. package/dist/dts/templating/binding.d.ts +0 -88
  13. package/dist/dts/templating/compiler.d.ts +1 -2
  14. package/dist/dts/templating/repeat.d.ts +3 -49
  15. package/dist/dts/templating/template.d.ts +10 -59
  16. package/dist/dts/templating/view.d.ts +9 -9
  17. package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +0 -0
  18. package/dist/esm/components/fast-definitions.js +2 -0
  19. package/dist/esm/components/fast-element.js +10 -2
  20. package/dist/esm/context.js +159 -0
  21. package/dist/esm/metadata.js +60 -0
  22. package/dist/esm/observation/arrays.js +1 -1
  23. package/dist/esm/observation/observable.js +69 -17
  24. package/dist/esm/templating/binding-signal.js +84 -0
  25. package/dist/esm/templating/binding-two-way.js +76 -0
  26. package/dist/esm/templating/binding.js +1 -158
  27. package/dist/esm/templating/repeat.js +9 -1
  28. package/dist/esm/templating/template.js +1 -21
  29. package/dist/fast-element.api.json +5586 -7541
  30. package/dist/fast-element.d.ts +119 -329
  31. package/dist/fast-element.debug.js +92 -199
  32. package/dist/fast-element.debug.min.js +1 -1
  33. package/dist/fast-element.js +92 -199
  34. package/dist/fast-element.min.js +1 -1
  35. package/dist/fast-element.untrimmed.d.ts +120 -331
  36. package/docs/api-report.md +50 -156
  37. package/package.json +20 -4
package/CHANGELOG.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@microsoft/fast-element",
3
3
  "entries": [
4
+ {
5
+ "date": "Wed, 15 Jun 2022 17:41:10 GMT",
6
+ "tag": "@microsoft/fast-element_v2.0.0-beta.2",
7
+ "version": "2.0.0-beta.2",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "comment": "doc: add note to FASTElement.metadata API",
12
+ "author": "roeisenb@microsoft.com",
13
+ "commit": "359467f9ae67c46a33dfc28ce86dfd908072695d",
14
+ "package": "@microsoft/fast-element"
15
+ },
16
+ {
17
+ "comment": "when recycle is set to false while itemBinding stays the same, views should be recreated",
18
+ "author": "wendy.hsu@microsoft.com",
19
+ "commit": "9c92b9bb5bc9bf221b439c0a776b3621fdd9d9aa",
20
+ "package": "@microsoft/fast-element"
21
+ },
22
+ {
23
+ "comment": "feat: simplify execution context to align closer with v1",
24
+ "author": "roeisenb@microsoft.com",
25
+ "commit": "488d051999c43b93a0beef4db30a2bddd6bbdc64",
26
+ "package": "@microsoft/fast-element"
27
+ },
28
+ {
29
+ "comment": "feat: ergo improvements to context, array length, and metadata",
30
+ "author": "roeisenb@microsoft.com",
31
+ "commit": "12f5671e215ebd2b95c9cc83f856e233e01e9c4a",
32
+ "package": "@microsoft/fast-element"
33
+ },
34
+ {
35
+ "comment": "feat: move optional bindings out of rollup and list as exports",
36
+ "author": "roeisenb@microsoft.com",
37
+ "commit": "e86a638b9e84cbf36d950025889742944e68e512",
38
+ "package": "@microsoft/fast-element"
39
+ },
40
+ {
41
+ "comment": "fix: make SyntheticViewTemplate type a string so it is generally usable",
42
+ "author": "roeisenb@microsoft.com",
43
+ "commit": "de7f234ef871204fcac2b5df59433d919809341d",
44
+ "package": "@microsoft/fast-element"
45
+ },
46
+ {
47
+ "comment": "feat: implement W3C WC community context protocol and integrate with DI",
48
+ "author": "roeisenb@microsoft.com",
49
+ "commit": "c45297c0ca48b7e5f4343ba48e5183f2bccdb946",
50
+ "package": "@microsoft/fast-element"
51
+ }
52
+ ]
53
+ }
54
+ },
4
55
  {
5
56
  "date": "Wed, 01 Jun 2022 17:53:14 GMT",
6
57
  "tag": "@microsoft/fast-element_v2.0.0-beta.1",
package/CHANGELOG.md CHANGED
@@ -1,9 +1,23 @@
1
1
  # Change Log - @microsoft/fast-element
2
2
 
3
- This log was last generated on Wed, 01 Jun 2022 17:53:14 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 15 Jun 2022 17:41:10 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.0.0-beta.2
8
+
9
+ Wed, 15 Jun 2022 17:41:10 GMT
10
+
11
+ ### Changes
12
+
13
+ - doc: add note to FASTElement.metadata API (roeisenb@microsoft.com)
14
+ - when recycle is set to false while itemBinding stays the same, views should be recreated (wendy.hsu@microsoft.com)
15
+ - feat: simplify execution context to align closer with v1 (roeisenb@microsoft.com)
16
+ - feat: ergo improvements to context, array length, and metadata (roeisenb@microsoft.com)
17
+ - feat: move optional bindings out of rollup and list as exports (roeisenb@microsoft.com)
18
+ - fix: make SyntheticViewTemplate type a string so it is generally usable (roeisenb@microsoft.com)
19
+ - feat: implement W3C WC community context protocol and integrate with DI (roeisenb@microsoft.com)
20
+
7
21
  ## 2.0.0-beta.1
8
22
 
9
23
  Wed, 01 Jun 2022 17:53:14 GMT
@@ -88,6 +88,8 @@ export declare class FASTElementDefinition<TType extends Constructable<HTMLEleme
88
88
  /**
89
89
  * Defines a custom element based on this definition.
90
90
  * @param registry - The element registry to define the element in.
91
+ * @remarks
92
+ * This operation is idempotent per registry.
91
93
  */
92
94
  define(registry?: CustomElementRegistry): this;
93
95
  /**
@@ -1,6 +1,6 @@
1
1
  import type { Constructable } from "../interfaces.js";
2
2
  import { Controller } from "./controller.js";
3
- import { PartialFASTElementDefinition } from "./fast-definitions.js";
3
+ import { FASTElementDefinition, PartialFASTElementDefinition } from "./fast-definitions.js";
4
4
  /**
5
5
  * Represents a custom element based on the FASTElement infrastructure.
6
6
  * @public
@@ -67,6 +67,12 @@ export declare const FASTElement: (new () => HTMLElement & FASTElement) & {
67
67
  * that describes the element to define.
68
68
  */
69
69
  define<TType extends Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): TType;
70
+ /**
71
+ * Defines metadata for a FASTElement which can be used to later define the element.
72
+ * IMPORTANT: This API will be renamed to "compose" in a future beta.
73
+ * @public
74
+ */
75
+ metadata<TType_1 extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType_1, nameOrDef?: string | PartialFASTElementDefinition): FASTElementDefinition<TType_1>;
70
76
  };
71
77
  /**
72
78
  * Decorator: Defines a platform custom element based on `FASTElement`.
@@ -0,0 +1,157 @@
1
+ import type { Constructable } from "./interfaces.js";
2
+ /**
3
+ * A Context object defines an optional initial value for a Context, as well as a name identifier for debugging purposes.
4
+ * @public
5
+ */
6
+ export declare type Context<T> = {
7
+ readonly name: string;
8
+ readonly initialValue?: T;
9
+ };
10
+ /**
11
+ * A constant key that can be used to represent a Context dependency.
12
+ * The key can be used for context or DI but also doubles as a decorator for
13
+ * resolving the associated dependency.
14
+ * @beta
15
+ */
16
+ export declare type ContextDecorator<T = any> = Readonly<Context<T>> & PropertyDecorator & ParameterDecorator;
17
+ /**
18
+ * A Context object defines an optional initial value for a Context, as well as a name identifier for debugging purposes.
19
+ * The FASTContext can also be used as a decorator to declare context dependencies or as a key for DI.
20
+ * @beta
21
+ */
22
+ export declare type FASTContext<T> = ContextDecorator<T> & {
23
+ get(target: EventTarget): T;
24
+ provide(target: EventTarget, value: T): void;
25
+ request(target: EventTarget, callback: ContextCallback<T>, multiple?: boolean): void;
26
+ handle(target: EventTarget, callback: (event: ContextEvent<FASTContext<T>>) => void): any;
27
+ };
28
+ /**
29
+ * A strategy that controls how all Context.request API calls are handled.
30
+ * @remarks
31
+ * By default this is handled via Context.dispatch, which dispatched a ContextEvent.
32
+ * @beta
33
+ */
34
+ export declare type FASTContextRequestStrategy = <T extends UnknownContext>(target: EventTarget, context: T, callback: ContextCallback<ContextType<T>>, multiple: any) => void;
35
+ declare const contextEventType = "context-request";
36
+ /**
37
+ * Enables using the {@link https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/context.md | W3C Community Context protocol.}
38
+ * @beta
39
+ */
40
+ export declare const Context: Readonly<{
41
+ /**
42
+ * The event type used for W3C Context Protocol requests.
43
+ */
44
+ eventType: "context-request";
45
+ /**
46
+ * Creates a W3C Community Protocol-based Context object to use in requesting/providing
47
+ * context through the DOM.
48
+ * @param name - The name to use for the connext. Useful in debugging.
49
+ * @param initialValue - An optional initial value to use if a context handler isn't found.
50
+ */
51
+ create<T = unknown>(name: string, initialValue?: T | undefined): FASTContext<T>;
52
+ /**
53
+ * Sets the strategy used by all FAST-specific context requests made through the
54
+ * Context.request, Context.get, Context.defineProperty, and ContextDecorator APIs.
55
+ * @param strategy - The strategy to use. By default, the strategy is Context.dispatch.
56
+ */
57
+ setDefaultRequestStrategy(strategy: FASTContextRequestStrategy): void;
58
+ /**
59
+ * Gets the context value for the target node or returns the initial value if
60
+ * a context handler is not found.
61
+ * @param target - The target to get the context for.
62
+ * @param context - The context to locate.
63
+ * @returns The context value.
64
+ * @remarks
65
+ * Uses the default request strategy to locate the context. If no context is found
66
+ * then the initial value of the context is returned.
67
+ */
68
+ get<T_1 extends UnknownContext>(target: EventTarget, context: T_1): ContextType<T_1>;
69
+ /**
70
+ * Requests the context value for the target node.
71
+ * @param target - The target to request the context for.
72
+ * @param context - The context to locate.
73
+ * @param callback - A callback to invoke with the context value.
74
+ * @param multiple - Whether the context requestor expects to handle updates
75
+ * to the context value after the initial request.
76
+ * @remarks
77
+ * Uses the default request strategy to locate the context.
78
+ */
79
+ request<T_2 extends UnknownContext>(target: EventTarget, context: T_2, callback: ContextCallback<ContextType<T_2>>, multiple?: boolean): void;
80
+ /**
81
+ *
82
+ * @param target - The target to dispatch the context event on.
83
+ * @param context - The context to locate.
84
+ * @param callback - The callback to invoke with the context value.
85
+ * @param multiple - Whether the context requestor expects to handle updates
86
+ * to the context value after the initial request.
87
+ * @remarks
88
+ * This API does NOT use the default request strategy. It always dispatches
89
+ * an event through the DOM.
90
+ */
91
+ dispatch<T_3 extends UnknownContext>(target: EventTarget, context: T_3, callback: ContextCallback<ContextType<T_3>>, multiple?: boolean): void;
92
+ provide<T_4 extends UnknownContext>(target: EventTarget, context: T_4, value: ContextType<T_4>): void;
93
+ /**
94
+ *
95
+ * @param target - The target on which to handle context requests.
96
+ * @param callback - The callback to invoke when a context request is received.
97
+ * @param context - The context to handle requests for.
98
+ * @remarks
99
+ * If a context is not provided then the callback will be invoked for all context
100
+ * requests that are received on the target.
101
+ */
102
+ handle<T_5 extends UnknownContext>(target: EventTarget, callback: (event: ContextEvent<T_5>) => void, context?: T_5 | undefined): void;
103
+ /**
104
+ * Defines a getter-only property on the target that will return the context
105
+ * value for the target.
106
+ * @param target The target to define the property on.
107
+ * @param propertyName The name of the property to define.
108
+ * @param context The context that will be used to retrieve the property value.
109
+ * @remarks
110
+ * Uses the default request strategy to locate the context and will return the
111
+ * initialValue if the context isn't handled.
112
+ */
113
+ defineProperty<T_6 extends UnknownContext>(target: Constructable<EventTarget> | EventTarget, propertyName: string, context: T_6): void;
114
+ }>;
115
+ /**
116
+ * An unknown context type.
117
+ * @public
118
+ */
119
+ export declare type UnknownContext = Context<unknown>;
120
+ /**
121
+ * A helper type which can extract a Context value type from a Context type
122
+ * @public
123
+ */
124
+ export declare type ContextType<T extends UnknownContext> = T extends Context<infer Y> ? Y : never;
125
+ /**
126
+ * A callback which is provided by a context requester and is called with the value satisfying the request.
127
+ * This callback can be called multiple times by context providers as the requested value is changed.
128
+ * @public
129
+ */
130
+ export declare type ContextCallback<ValueType> = (value: ValueType, dispose?: () => void) => void;
131
+ /**
132
+ * An event fired by a context requester to signal it desires a named context.
133
+ *
134
+ * A provider should inspect the `context` property of the event to determine if it has a value that can
135
+ * satisfy the request, calling the `callback` with the requested value if so.
136
+ *
137
+ * If the requested context event contains a truthy `multiple` value, then a provider can call the callback
138
+ * multiple times if the value is changed, if this is the case the provider should pass a `dispose`
139
+ * method to the callback which requesters can invoke to indicate they no longer wish to receive these updates.
140
+ * @public
141
+ */
142
+ export declare class ContextEvent<T extends UnknownContext> extends Event {
143
+ readonly context: T;
144
+ readonly callback: ContextCallback<ContextType<T>>;
145
+ readonly multiple?: boolean | undefined;
146
+ constructor(context: T, callback: ContextCallback<ContextType<T>>, multiple?: boolean | undefined);
147
+ }
148
+ declare global {
149
+ interface HTMLElementEventMap {
150
+ /**
151
+ * A 'context-request' event can be emitted by any element which desires
152
+ * a context value to be injected by an external provider.
153
+ */
154
+ [contextEventType]: ContextEvent<UnknownContext>;
155
+ }
156
+ }
157
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { Constructable } from "./interfaces.js";
2
+ /**
3
+ * Provides basic metadata capabilities used by Context and Dependency Injection.
4
+ */
5
+ export declare const Metadata: Readonly<{
6
+ /**
7
+ * Gets the "design:paramtypes" metadata for the specified type.
8
+ * @param Type - The type to get the metadata for.
9
+ * @returns The metadata array or a frozen empty array if no metadata is found.
10
+ */
11
+ getDesignParamTypes: (Type: any) => any;
12
+ /**
13
+ * Gets the "annotation:paramtypes" metadata for the specified type.
14
+ * @param Type - The type to get the metadata for.
15
+ * @returns The metadata array or a frozen empty array if no metadata is found.
16
+ */
17
+ getAnnotationParamTypes: (Type: any) => any;
18
+ /**
19
+ *
20
+ * @param Type - Gets the "annotation:paramtypes" metadata for the specified type. If none is found,
21
+ * an empty, mutable metadata array is created and added.
22
+ * @returns The metadata array.
23
+ */
24
+ getOrCreateAnnotationParamTypes(Type: Constructable): any[];
25
+ }>;
@@ -204,4 +204,4 @@ export declare const ArrayObserver: Readonly<{
204
204
  * @returns The length of the array.
205
205
  * @public
206
206
  */
207
- export declare function length<T>(array: readonly T[]): number;
207
+ export declare function lengthOf<T>(array: readonly T[]): number;
@@ -1,19 +1,19 @@
1
- import type { ExecutionContext, RootContext } from "./observable.js";
1
+ import type { ExecutionContext } from "./observable.js";
2
2
  /**
3
3
  * Represents an object that can contribute behavior to a view or
4
4
  * element's bind/unbind operations.
5
5
  * @public
6
6
  */
7
- export interface Behavior<TSource = any, TParent = any, TContext extends ExecutionContext<TParent> = RootContext> {
7
+ export interface Behavior<TSource = any, TParent = any> {
8
8
  /**
9
9
  * Bind this behavior to the source.
10
10
  * @param source - The source to bind to.
11
11
  * @param context - The execution context that the binding is operating within.
12
12
  */
13
- bind(source: TSource, context: TContext): void;
13
+ bind(source: TSource, context: ExecutionContext<TParent>): void;
14
14
  /**
15
15
  * Unbinds this behavior from the source.
16
16
  * @param source - The source to unbind from.
17
17
  */
18
- unbind(source: TSource, context: TContext): void;
18
+ unbind(source: TSource, context: ExecutionContext<TParent>): void;
19
19
  }
@@ -26,7 +26,7 @@ export interface Accessor {
26
26
  * as part of a template binding update.
27
27
  * @public
28
28
  */
29
- export declare type Binding<TSource = any, TReturn = any, TContext extends ExecutionContext = ExecutionContext> = (source: TSource, context: TContext) => TReturn;
29
+ export declare type Binding<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
@@ -120,13 +120,13 @@ export declare const Observable: Readonly<{
120
120
  * @param initialSubscriber - An initial subscriber to changes in the binding value.
121
121
  * @param isVolatileBinding - Indicates whether the binding's dependency list must be re-evaluated on every value evaluation.
122
122
  */
123
- binding<TSource = any, TReturn = any>(binding: Binding<TSource, TReturn, ExecutionContext<any>>, initialSubscriber?: Subscriber, isVolatileBinding?: boolean): BindingObserver<TSource, TReturn, any>;
123
+ binding<TSource = any, TReturn = any>(binding: Binding<TSource, TReturn, any>, initialSubscriber?: Subscriber, isVolatileBinding?: boolean): BindingObserver<TSource, TReturn, any>;
124
124
  /**
125
125
  * Determines whether a binding expression is volatile and needs to have its dependency list re-evaluated
126
126
  * on every evaluation of the value.
127
127
  * @param binding - The binding to inspect.
128
128
  */
129
- isVolatileBinding<TSource_1 = any, TReturn_1 = any>(binding: Binding<TSource_1, TReturn_1, ExecutionContext<any>>): boolean;
129
+ isVolatileBinding<TSource_1 = any, TReturn_1 = any>(binding: Binding<TSource_1, TReturn_1, any>): boolean;
130
130
  }>;
131
131
  /**
132
132
  * Decorator: Defines an observable property on the target.
@@ -147,31 +147,19 @@ export declare function volatile(target: {}, name: string | Accessor, descriptor
147
147
  * Provides additional contextual information available to behaviors and expressions.
148
148
  * @public
149
149
  */
150
- export interface RootContext {
150
+ export declare class ExecutionContext<TParentSource = any> {
151
151
  /**
152
- * The current event within an event handler.
153
- */
154
- readonly event: Event;
155
- /**
156
- * Returns the typed event detail of a custom event.
152
+ * The default execution context.
157
153
  */
158
- eventDetail<TDetail = any>(): TDetail;
154
+ static readonly default: ExecutionContext<any>;
159
155
  /**
160
- * Returns the typed event target of the event.
156
+ * The index of the current item within a repeat context.
161
157
  */
162
- eventTarget<TTarget extends EventTarget = EventTarget>(): TTarget;
158
+ index: number;
163
159
  /**
164
- * Creates a new execution context descendent from the current context.
165
- * @param source - The source for the context if different than the parent.
166
- * @returns A child execution context.
160
+ * The length of the current collection within a repeat context.
167
161
  */
168
- createChildContext<TParentSource>(source: TParentSource): ChildContext<TParentSource>;
169
- }
170
- /**
171
- * Provides additional contextual information when inside a child template.
172
- * @public
173
- */
174
- export interface ChildContext<TParentSource = any> extends RootContext {
162
+ length: number;
175
163
  /**
176
164
  * The parent data source within a nested context.
177
165
  */
@@ -179,80 +167,73 @@ export interface ChildContext<TParentSource = any> extends RootContext {
179
167
  /**
180
168
  * The parent execution context when in nested context scenarios.
181
169
  */
182
- readonly parentContext: ChildContext<TParentSource>;
170
+ readonly parentContext: ExecutionContext<TParentSource>;
171
+ private constructor();
183
172
  /**
184
- * Creates a new execution context descent suitable for use in list rendering.
185
- * @param item - The list item to serve as the source.
186
- * @param index - The index of the item in the list.
187
- * @param length - The length of the list.
188
- */
189
- createItemContext(index: number, length: number): ItemContext<TParentSource>;
190
- }
191
- /**
192
- * Provides additional contextual information when inside a repeat item template.s
193
- * @public
194
- */
195
- export interface ItemContext<TParentSource = any> extends ChildContext<TParentSource> {
196
- /**
197
- * The index of the current item within a repeat context.
198
- */
199
- readonly index: number;
200
- /**
201
- * The length of the current collection within a repeat context.
173
+ * The current event within an event handler.
202
174
  */
203
- readonly length: number;
175
+ get event(): Event;
204
176
  /**
205
177
  * Indicates whether the current item within a repeat context
206
178
  * has an even index.
207
179
  */
208
- readonly isEven: boolean;
180
+ get isEven(): boolean;
209
181
  /**
210
182
  * Indicates whether the current item within a repeat context
211
183
  * has an odd index.
212
184
  */
213
- readonly isOdd: boolean;
185
+ get isOdd(): boolean;
214
186
  /**
215
187
  * Indicates whether the current item within a repeat context
216
188
  * is the first item in the collection.
217
189
  */
218
- readonly isFirst: boolean;
190
+ get isFirst(): boolean;
219
191
  /**
220
192
  * Indicates whether the current item within a repeat context
221
193
  * is somewhere in the middle of the collection.
222
194
  */
223
- readonly isInMiddle: boolean;
195
+ get isInMiddle(): boolean;
224
196
  /**
225
197
  * Indicates whether the current item within a repeat context
226
198
  * is the last item in the collection.
227
199
  */
228
- readonly isLast: boolean;
200
+ get isLast(): boolean;
201
+ /**
202
+ * Returns the typed event detail of a custom event.
203
+ */
204
+ eventDetail<TDetail>(): TDetail;
205
+ /**
206
+ * Returns the typed event target of the event.
207
+ */
208
+ eventTarget<TTarget extends EventTarget>(): TTarget;
229
209
  /**
230
210
  * Updates the position/size on a context associated with a list item.
231
211
  * @param index - The new index of the item.
232
212
  * @param length - The new length of the list.
233
213
  */
234
214
  updatePosition(index: number, length: number): void;
235
- }
236
- /**
237
- * The common execution context APIs.
238
- * @public
239
- */
240
- export declare const ExecutionContext: Readonly<{
241
- default: RootContext;
215
+ /**
216
+ * Creates a new execution context descendent from the current context.
217
+ * @param source - The source for the context if different than the parent.
218
+ * @returns A child execution context.
219
+ */
220
+ createChildContext<TParentSource>(parentSource: TParentSource): ExecutionContext<TParentSource>;
221
+ /**
222
+ * Creates a new execution context descent suitable for use in list rendering.
223
+ * @param item - The list item to serve as the source.
224
+ * @param index - The index of the item in the list.
225
+ * @param length - The length of the list.
226
+ */
227
+ createItemContext(index: number, length: number): ExecutionContext<TParentSource>;
242
228
  /**
243
229
  * Sets the event for the current execution context.
244
230
  * @param event - The event to set.
245
231
  * @internal
246
232
  */
247
- setEvent(event: Event | null): void;
233
+ static setEvent(event: Event | null): void;
248
234
  /**
249
235
  * Creates a new root execution context.
250
236
  * @returns A new execution context.
251
237
  */
252
- create(): RootContext;
253
- }>;
254
- /**
255
- * Represents some sort of execution context.
256
- * @public
257
- */
258
- export declare type ExecutionContext<TParentSource = any> = RootContext | ChildContext<TParentSource> | ItemContext<TParentSource>;
238
+ static create(): ExecutionContext;
239
+ }
@@ -0,0 +1,38 @@
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;
25
+ /**
26
+ * Sends the specified signal to signaled bindings.
27
+ * @param signal - The signal to send.
28
+ * @public
29
+ */
30
+ static send(signal: string): void;
31
+ }
32
+ /**
33
+ * Creates a signal binding configuration with the supplied options.
34
+ * @param options - The signal name or a binding to use to retrieve the signal name.
35
+ * @returns A binding configuration.
36
+ * @public
37
+ */
38
+ export declare const signal: <T = any>(options: string | Binding<T, any, any>) => BindingConfig<string | Binding<T, any, any>>;
@@ -0,0 +1,56 @@
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";
4
+ /**
5
+ * The settings required to enable two-way binding.
6
+ * @public
7
+ */
8
+ export interface TwoWaySettings {
9
+ /**
10
+ * Determines which event to listen to, to detect changes in the view.
11
+ * @param directive - The directive to determine the change event for.
12
+ * @param target - The target element to determine the change event for.
13
+ */
14
+ determineChangeEvent(directive: HTMLBindingDirective, target: HTMLElement): string;
15
+ }
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;
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.
54
+ * @public
55
+ */
56
+ export declare const twoWay: BindingConfig<DefaultTwoWayBindingOptions> & import("./binding.js").BindingConfigResolver<DefaultTwoWayBindingOptions>;