@microsoft/fast-element 2.0.0-beta.1 → 2.0.0-beta.11
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.
- package/CHANGELOG.json +348 -0
- package/CHANGELOG.md +114 -1
- package/dist/dts/components/attributes.d.ts +10 -0
- package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +49 -25
- package/dist/dts/components/fast-definitions.d.ts +43 -9
- package/dist/dts/components/fast-element.d.ts +15 -21
- package/dist/dts/context.d.ts +157 -0
- package/dist/dts/di/di.d.ts +899 -0
- package/dist/dts/index.d.ts +2 -2
- package/dist/dts/interfaces.d.ts +45 -14
- package/dist/dts/metadata.d.ts +25 -0
- package/dist/dts/observation/arrays.d.ts +1 -1
- package/dist/dts/observation/observable.d.ts +101 -75
- package/dist/dts/pending-task.d.ts +20 -0
- package/dist/dts/platform.d.ts +7 -0
- package/dist/dts/polyfills.d.ts +1 -8
- package/dist/dts/state/exports.d.ts +3 -0
- package/dist/dts/state/reactive.d.ts +8 -0
- package/dist/dts/state/state.d.ts +141 -0
- package/dist/dts/state/visitor.d.ts +6 -0
- package/dist/dts/state/watch.d.ts +10 -0
- package/dist/dts/styles/css-directive.d.ts +2 -2
- package/dist/dts/styles/element-styles.d.ts +10 -17
- package/dist/dts/styles/host.d.ts +68 -0
- package/dist/dts/templating/binding-signal.d.ts +21 -0
- package/dist/dts/templating/binding-two-way.d.ts +39 -0
- package/dist/dts/templating/binding.d.ts +69 -294
- package/dist/dts/templating/children.d.ts +1 -1
- package/dist/dts/templating/compiler.d.ts +1 -2
- package/dist/dts/templating/html-directive.d.ts +93 -35
- package/dist/dts/templating/node-observation.d.ts +4 -5
- package/dist/dts/templating/ref.d.ts +5 -13
- package/dist/dts/templating/render.d.ts +272 -0
- package/dist/dts/templating/repeat.d.ts +20 -75
- package/dist/dts/templating/slotted.d.ts +1 -1
- package/dist/dts/templating/template.d.ts +12 -61
- package/dist/dts/templating/view.d.ts +77 -12
- package/dist/dts/templating/when.d.ts +3 -3
- package/dist/dts/testing/exports.d.ts +3 -0
- package/dist/dts/testing/fakes.d.ts +4 -0
- package/dist/dts/testing/fixture.d.ts +84 -0
- package/dist/dts/testing/timeout.d.ts +7 -0
- package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +0 -0
- package/dist/dts/utilities.d.ts +0 -18
- package/dist/esm/components/attributes.js +13 -4
- package/dist/esm/components/{controller.js → element-controller.js} +188 -109
- package/dist/esm/components/fast-definitions.js +38 -28
- package/dist/esm/components/fast-element.js +31 -12
- package/dist/esm/context.js +163 -0
- package/dist/esm/debug.js +36 -4
- package/dist/esm/di/di.js +1435 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/interfaces.js +4 -0
- package/dist/esm/metadata.js +60 -0
- package/dist/esm/observation/arrays.js +304 -3
- package/dist/esm/observation/observable.js +81 -87
- package/dist/esm/pending-task.js +16 -0
- package/dist/esm/platform.js +26 -1
- package/dist/esm/polyfills.js +1 -55
- package/dist/esm/state/exports.js +3 -0
- package/dist/esm/state/reactive.js +34 -0
- package/dist/esm/state/state.js +148 -0
- package/dist/esm/state/visitor.js +28 -0
- package/dist/esm/state/watch.js +36 -0
- package/dist/esm/styles/css.js +4 -4
- package/dist/esm/styles/element-styles.js +14 -33
- package/dist/esm/{observation/behavior.js → styles/host.js} +0 -0
- package/dist/esm/templating/binding-signal.js +83 -0
- package/dist/esm/templating/binding-two-way.js +103 -0
- package/dist/esm/templating/binding.js +134 -414
- package/dist/esm/templating/compiler.js +30 -7
- package/dist/esm/templating/html-directive.js +100 -28
- package/dist/esm/templating/node-observation.js +9 -8
- package/dist/esm/templating/ref.js +4 -12
- package/dist/esm/templating/render.js +391 -0
- package/dist/esm/templating/repeat.js +96 -72
- package/dist/esm/templating/template.js +11 -29
- package/dist/esm/templating/view.js +107 -29
- package/dist/esm/templating/when.js +5 -4
- package/dist/esm/testing/exports.js +3 -0
- package/dist/esm/testing/fakes.js +76 -0
- package/dist/esm/testing/fixture.js +86 -0
- package/dist/esm/testing/timeout.js +24 -0
- package/dist/esm/utilities.js +0 -95
- package/dist/fast-element.api.json +9278 -10745
- package/dist/fast-element.d.ts +707 -813
- package/dist/fast-element.debug.js +1229 -944
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +1191 -938
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +716 -824
- package/docs/api-report.md +265 -319
- package/package.json +39 -14
- package/dist/dts/hooks.d.ts +0 -20
- package/dist/dts/observation/behavior.d.ts +0 -19
- package/dist/dts/observation/splice-strategies.d.ts +0 -13
- package/dist/esm/hooks.js +0 -32
- package/dist/esm/observation/splice-strategies.js +0 -400
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { 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<
|
|
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:
|
|
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,21 @@
|
|
|
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;
|
|
7
|
+
/**
|
|
8
|
+
* Sends the specified signal to signaled bindings.
|
|
9
|
+
* @param signal - The signal to send.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
send(signal: string): void;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a signal binding configuration with the supplied options.
|
|
16
|
+
* @param expression - The binding to refresh when signaled.
|
|
17
|
+
* @param options - The signal name or a binding to use to retrieve the signal name.
|
|
18
|
+
* @returns A binding configuration.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function signal<T = any>(expression: Expression<T>, options: string | Expression<T>): Binding<T>;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The settings required to enable two-way binding.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface TwoWaySettings {
|
|
17
|
+
/**
|
|
18
|
+
* Determines which event to listen to, to detect changes in the view.
|
|
19
|
+
* @param directive - The directive to determine the change event for.
|
|
20
|
+
* @param target - The target element to determine the change event for.
|
|
21
|
+
*/
|
|
22
|
+
determineChangeEvent(directive: HTMLBindingDirective, target: HTMLElement): string;
|
|
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
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a default binding.
|
|
33
|
+
* @param expression - The binding to refresh when changed.
|
|
34
|
+
* @param optionsOrChangeEvent - The binding options or the name of the change event to use.
|
|
35
|
+
* @param isBindingVolatile - Indicates whether the binding is volatile or not.
|
|
36
|
+
* @returns A binding.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare function twoWay<T = any>(expression: Expression<T>, optionsOrChangeEvent?: TwoWayBindingOptions | string, isBindingVolatile?: boolean): Binding<T>;
|
|
@@ -1,308 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AddViewBehaviorFactory, Aspect, Aspected, HTMLDirective, ViewBehavior, ViewBehaviorFactory,
|
|
3
|
-
import type { CaptureType } from "./template.js";
|
|
1
|
+
import { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
|
|
2
|
+
import { AddViewBehaviorFactory, Aspect, Aspected, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
4
|
+
* A simple View that can be interpolated into HTML content.
|
|
6
5
|
* @public
|
|
7
6
|
*/
|
|
8
|
-
export
|
|
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
|
-
}>;
|
|
54
|
-
/**
|
|
55
|
-
* The "this" context for an update target function.
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
export interface UpdateTargetThis {
|
|
59
|
-
/**
|
|
60
|
-
* The directive configuration for the update.
|
|
61
|
-
*/
|
|
62
|
-
directive: HTMLBindingDirective;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* A target update function.
|
|
66
|
-
* @param this - The "this" context for the update.
|
|
67
|
-
* @param target - The node that is targeted by the update.
|
|
68
|
-
* @param aspect - The aspect of the node that is being targeted.
|
|
69
|
-
* @param value - The value to assign to the aspect.
|
|
70
|
-
* @param source - The source object that the value was derived from.
|
|
71
|
-
* @param context - The execution context that the binding is being run under.
|
|
72
|
-
* @public
|
|
73
|
-
*/
|
|
74
|
-
export declare type UpdateTarget = (this: UpdateTargetThis, target: Node, aspect: string, value: any, source: any, context: ExecutionContext) => void;
|
|
75
|
-
/**
|
|
76
|
-
* A base binding behavior for DOM updates.
|
|
77
|
-
* @public
|
|
78
|
-
*/
|
|
79
|
-
export declare class UpdateBinding implements ViewBehavior {
|
|
80
|
-
readonly directive: HTMLBindingDirective;
|
|
81
|
-
protected updateTarget: UpdateTarget;
|
|
82
|
-
/**
|
|
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.
|
|
86
|
-
*/
|
|
87
|
-
constructor(directive: HTMLBindingDirective, updateTarget: UpdateTarget);
|
|
88
|
-
/**
|
|
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.
|
|
93
|
-
*/
|
|
94
|
-
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
95
|
-
/**
|
|
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.
|
|
100
|
-
*/
|
|
101
|
-
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
102
|
-
/**
|
|
103
|
-
* Creates a behavior.
|
|
104
|
-
* @param targets - The targets available for behaviors to be attached to.
|
|
105
|
-
*/
|
|
106
|
-
createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* A binding behavior for one-time bindings.
|
|
110
|
-
* @public
|
|
111
|
-
*/
|
|
112
|
-
export declare class OneTimeBinding extends UpdateBinding {
|
|
113
|
-
/**
|
|
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.
|
|
118
|
-
*/
|
|
119
|
-
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* A binding behavior for signal bindings.
|
|
123
|
-
* @public
|
|
124
|
-
*/
|
|
125
|
-
export declare class SignalBinding extends UpdateBinding {
|
|
126
|
-
private handlerProperty;
|
|
127
|
-
/**
|
|
128
|
-
* Bind this behavior to the source.
|
|
129
|
-
* @param source - The source to bind to.
|
|
130
|
-
* @param context - The execution context that the binding is operating within.
|
|
131
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
132
|
-
*/
|
|
133
|
-
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
134
|
-
/**
|
|
135
|
-
* Unbinds this behavior from the source.
|
|
136
|
-
* @param source - The source to unbind from.
|
|
137
|
-
* @param context - The execution context that the binding is operating within.
|
|
138
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
139
|
-
*/
|
|
140
|
-
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
141
|
-
private getSignal;
|
|
142
|
-
/**
|
|
143
|
-
* Sends the specified signal to signaled bindings.
|
|
144
|
-
* @param signal - The signal to send.
|
|
145
|
-
* @public
|
|
146
|
-
*/
|
|
147
|
-
static send(signal: string): void;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* A binding behavior for bindings that change.
|
|
151
|
-
* @public
|
|
152
|
-
*/
|
|
153
|
-
export declare class ChangeBinding extends UpdateBinding {
|
|
154
|
-
private isBindingVolatile;
|
|
155
|
-
private observerProperty;
|
|
156
|
-
/**
|
|
157
|
-
* Creates an instance of ChangeBinding.
|
|
158
|
-
* @param directive - The directive that has the configuration for this behavior.
|
|
159
|
-
* @param updateTarget - The function used to update the target with the latest value.
|
|
160
|
-
*/
|
|
161
|
-
constructor(directive: HTMLBindingDirective, updateTarget: UpdateTarget);
|
|
162
|
-
/**
|
|
163
|
-
* Returns the binding observer used to update the node.
|
|
164
|
-
* @param target - The target node.
|
|
165
|
-
* @returns A BindingObserver.
|
|
166
|
-
*/
|
|
167
|
-
protected getObserver(target: Node): BindingObserver;
|
|
7
|
+
export interface ContentView {
|
|
8
|
+
readonly context: ExecutionContext;
|
|
168
9
|
/**
|
|
169
|
-
*
|
|
170
|
-
* @param source - The source
|
|
171
|
-
* @param context - The execution context
|
|
172
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
10
|
+
* Binds a view's behaviors to its binding source.
|
|
11
|
+
* @param source - The binding source for the view's binding behaviors.
|
|
12
|
+
* @param context - The execution context to run the view within.
|
|
173
13
|
*/
|
|
174
|
-
bind(source: any, context
|
|
14
|
+
bind(source: any, context?: ExecutionContext): void;
|
|
175
15
|
/**
|
|
176
|
-
* Unbinds
|
|
177
|
-
* @param source - The source to unbind from.
|
|
178
|
-
* @param context - The execution context that the binding is operating within.
|
|
179
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
16
|
+
* Unbinds a view's behaviors from its binding source and context.
|
|
180
17
|
*/
|
|
181
|
-
unbind(
|
|
182
|
-
/** @internal */
|
|
183
|
-
handleChange(binding: Binding, observer: BindingObserver): void;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* A binding behavior for handling events.
|
|
187
|
-
* @public
|
|
188
|
-
*/
|
|
189
|
-
export declare class EventBinding {
|
|
190
|
-
readonly directive: HTMLBindingDirective;
|
|
191
|
-
private contextProperty;
|
|
192
|
-
private sourceProperty;
|
|
193
|
-
/**
|
|
194
|
-
* Creates an instance of EventBinding.
|
|
195
|
-
* @param directive - The directive that has the configuration for this behavior.
|
|
196
|
-
*/
|
|
197
|
-
constructor(directive: HTMLBindingDirective);
|
|
18
|
+
unbind(): void;
|
|
198
19
|
/**
|
|
199
|
-
*
|
|
200
|
-
* @param
|
|
201
|
-
* @param context - The execution context that the binding is operating within.
|
|
202
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
20
|
+
* Inserts the view's DOM nodes before the referenced node.
|
|
21
|
+
* @param node - The node to insert the view's DOM before.
|
|
203
22
|
*/
|
|
204
|
-
|
|
23
|
+
insertBefore(node: Node): void;
|
|
205
24
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* @param context - The execution context that the binding is operating within.
|
|
209
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
25
|
+
* Removes the view's DOM nodes.
|
|
26
|
+
* The nodes are not disposed and the view can later be re-inserted.
|
|
210
27
|
*/
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Creates a behavior.
|
|
214
|
-
* @param targets - The targets available for behaviors to be attached to.
|
|
215
|
-
*/
|
|
216
|
-
createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
|
|
217
|
-
/**
|
|
218
|
-
* @internal
|
|
219
|
-
*/
|
|
220
|
-
handleEvent(event: Event): void;
|
|
28
|
+
remove(): void;
|
|
221
29
|
}
|
|
222
30
|
/**
|
|
223
|
-
*
|
|
31
|
+
* A simple template that can create ContentView instances.
|
|
224
32
|
* @public
|
|
225
33
|
*/
|
|
226
|
-
export interface
|
|
34
|
+
export interface ContentTemplate {
|
|
227
35
|
/**
|
|
228
|
-
*
|
|
229
|
-
* @param directive - The directive to determine the change event for.
|
|
230
|
-
* @param target - The target element to determine the change event for.
|
|
36
|
+
* Creates a simple content view instance.
|
|
231
37
|
*/
|
|
232
|
-
|
|
38
|
+
create(): ContentView;
|
|
233
39
|
}
|
|
234
|
-
/**
|
|
235
|
-
* A binding behavior for bindings that update in two directions.
|
|
236
|
-
* @public
|
|
237
|
-
*/
|
|
238
|
-
export declare class TwoWayBinding extends ChangeBinding {
|
|
239
|
-
private changeEvent;
|
|
240
|
-
/**
|
|
241
|
-
* Bind this behavior to the source.
|
|
242
|
-
* @param source - The source to bind to.
|
|
243
|
-
* @param context - The execution context that the binding is operating within.
|
|
244
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
245
|
-
*/
|
|
246
|
-
bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
247
|
-
/**
|
|
248
|
-
* Unbinds this behavior from the source.
|
|
249
|
-
* @param source - The source to unbind from.
|
|
250
|
-
* @param context - The execution context that the binding is operating within.
|
|
251
|
-
* @param targets - The targets that behaviors in a view can attach to.
|
|
252
|
-
*/
|
|
253
|
-
unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
|
|
254
|
-
/** @internal */
|
|
255
|
-
handleEvent(event: Event): void;
|
|
256
|
-
/**
|
|
257
|
-
* Configures two-way binding.
|
|
258
|
-
* @param settings - The settings to use for the two-way binding system.
|
|
259
|
-
*/
|
|
260
|
-
static configure(settings: TwoWaySettings): void;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* The default binding options.
|
|
264
|
-
* @public
|
|
265
|
-
*/
|
|
266
|
-
export declare type DefaultBindingOptions = AddEventListenerOptions;
|
|
267
|
-
/**
|
|
268
|
-
* The default onChange binding configuration.
|
|
269
|
-
* @public
|
|
270
|
-
*/
|
|
271
|
-
export declare const onChange: BindingConfig<AddEventListenerOptions> & BindingConfigResolver<AddEventListenerOptions>;
|
|
272
|
-
/**
|
|
273
|
-
* The default twoWay binding options.
|
|
274
|
-
* @public
|
|
275
|
-
*/
|
|
276
|
-
export declare type DefaultTwoWayBindingOptions = DefaultBindingOptions & {
|
|
277
|
-
changeEvent?: string;
|
|
278
|
-
fromView?: (value: any) => any;
|
|
279
|
-
};
|
|
280
|
-
/**
|
|
281
|
-
* The default twoWay binding configuration.
|
|
282
|
-
* @public
|
|
283
|
-
*/
|
|
284
|
-
export declare const twoWay: BindingConfig<DefaultTwoWayBindingOptions> & BindingConfigResolver<DefaultTwoWayBindingOptions>;
|
|
285
|
-
/**
|
|
286
|
-
* The default onTime binding configuration.
|
|
287
|
-
* @public
|
|
288
|
-
*/
|
|
289
|
-
export declare const oneTime: BindingConfig<AddEventListenerOptions> & BindingConfigResolver<AddEventListenerOptions>;
|
|
290
|
-
/**
|
|
291
|
-
* Creates a signal binding configuration with the supplied options.
|
|
292
|
-
* @param options - The signal name or a binding to use to retrieve the signal name.
|
|
293
|
-
* @returns A binding configuration.
|
|
294
|
-
* @public
|
|
295
|
-
*/
|
|
296
|
-
export declare const signal: <T = any>(options: string | Binding<T, any, ExecutionContext<any>>) => BindingConfig<string | Binding<T, any, ExecutionContext<any>>>;
|
|
297
40
|
/**
|
|
298
41
|
* A directive that applies bindings.
|
|
299
42
|
* @public
|
|
300
43
|
*/
|
|
301
|
-
export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, Aspected {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
private factory;
|
|
44
|
+
export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected {
|
|
45
|
+
dataBinding: Binding;
|
|
46
|
+
private data;
|
|
47
|
+
private updateTarget;
|
|
306
48
|
/**
|
|
307
49
|
* The unique id of the factory.
|
|
308
50
|
*/
|
|
@@ -325,11 +67,9 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
|
|
|
325
67
|
aspectType: Aspect;
|
|
326
68
|
/**
|
|
327
69
|
* Creates an instance of HTMLBindingDirective.
|
|
328
|
-
* @param
|
|
329
|
-
* @param mode - The binding mode to use when applying the binding.
|
|
330
|
-
* @param options - The options to configure the binding with.
|
|
70
|
+
* @param dataBinding - The binding configuration to apply.
|
|
331
71
|
*/
|
|
332
|
-
constructor(
|
|
72
|
+
constructor(dataBinding: Binding);
|
|
333
73
|
/**
|
|
334
74
|
* Creates HTML to be used within a template.
|
|
335
75
|
* @param add - Can be used to add behavior factories to a template.
|
|
@@ -337,15 +77,50 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
|
|
|
337
77
|
createHTML(add: AddViewBehaviorFactory): string;
|
|
338
78
|
/**
|
|
339
79
|
* Creates a behavior.
|
|
340
|
-
* @param targets - The targets available for behaviors to be attached to.
|
|
341
80
|
*/
|
|
342
|
-
createBehavior(
|
|
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;
|
|
343
96
|
}
|
|
344
97
|
/**
|
|
345
|
-
* Creates
|
|
346
|
-
* @param binding - The binding
|
|
347
|
-
* @param
|
|
348
|
-
* @returns A binding
|
|
98
|
+
* Creates an standard binding.
|
|
99
|
+
* @param binding - The binding to refresh when changed.
|
|
100
|
+
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
101
|
+
* @returns A binding configuration.
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export declare function bind<T = any>(binding: Expression<T>, isVolatile?: boolean): Binding<T>;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a one time binding
|
|
107
|
+
* @param binding - The binding to refresh when signaled.
|
|
108
|
+
* @returns A binding configuration.
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export declare function oneTime<T = any>(binding: Expression<T>): Binding<T>;
|
|
112
|
+
/**
|
|
113
|
+
* Creates an event listener binding.
|
|
114
|
+
* @param binding - The binding to invoke when the event is raised.
|
|
115
|
+
* @param options - Event listener options.
|
|
116
|
+
* @returns A binding configuration.
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
export declare function listener<T = any>(binding: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
|
|
120
|
+
/**
|
|
121
|
+
* Normalizes the input value into a binding.
|
|
122
|
+
* @param value - The value to create the default binding for.
|
|
123
|
+
* @returns A binding configuration for the provided value.
|
|
349
124
|
* @public
|
|
350
125
|
*/
|
|
351
|
-
export declare function
|
|
126
|
+
export declare function normalizeBinding<TSource = any, TReturn = any, TParent = any>(value: Expression<TSource, TReturn, TParent> | Binding<TSource, TReturn, TParent> | {}): Binding<TSource, TReturn, TParent>;
|
|
@@ -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<
|
|
63
|
+
export declare function children<TSource = any, TParent = any>(propertyOrOptions: (keyof TSource & string) | ChildrenDirectiveOptions<keyof TSource & string>): CaptureType<TSource, TParent>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TrustedTypesPolicy } from "../interfaces.js";
|
|
2
|
-
import type { ExecutionContext } from "../observation/observable.js";
|
|
3
2
|
import { ViewBehaviorFactory } from "./html-directive.js";
|
|
4
3
|
import type { HTMLTemplateCompilationResult as TemplateCompilationResult } from "./template.js";
|
|
5
4
|
/**
|
|
@@ -40,7 +39,7 @@ export declare const Compiler: {
|
|
|
40
39
|
* it is recommended that you clone the original and pass the clone to this API.
|
|
41
40
|
* @public
|
|
42
41
|
*/
|
|
43
|
-
compile<TSource = any, TParent = any
|
|
42
|
+
compile<TSource = any, TParent = any>(html: string | HTMLTemplateElement, directives: Record<string, ViewBehaviorFactory>): TemplateCompilationResult<TSource, TParent>;
|
|
44
43
|
/**
|
|
45
44
|
* Sets the default compilation strategy that will be used by the ViewTemplate whenever
|
|
46
45
|
* it needs to compile a view preprocessed with the html template function.
|