@microsoft/fast-element 2.0.0-beta.2 → 2.0.0-beta.21
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 +509 -0
- package/CHANGELOG.md +189 -1
- package/dist/dts/components/attributes.d.ts +15 -0
- package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +74 -28
- package/dist/dts/components/fast-definitions.d.ts +41 -9
- package/dist/dts/components/fast-element.d.ts +14 -26
- package/dist/dts/components/hydration.d.ts +14 -0
- package/dist/{esm/observation/behavior.js → dts/components/install-hydration.d.ts} +0 -0
- package/dist/dts/context.d.ts +7 -7
- package/dist/dts/di/di.d.ts +894 -0
- package/dist/dts/dom-policy.d.ts +83 -0
- package/dist/dts/dom.d.ts +100 -0
- package/dist/dts/index.d.ts +5 -4
- package/dist/dts/index.rollup.d.ts +0 -1
- package/dist/dts/index.rollup.debug.d.ts +0 -1
- package/dist/dts/interfaces.d.ts +62 -80
- package/dist/dts/metadata.d.ts +5 -5
- package/dist/dts/observation/observable.d.ts +99 -54
- package/dist/dts/pending-task.d.ts +32 -0
- package/dist/dts/platform.d.ts +8 -1
- package/dist/dts/polyfills.d.ts +0 -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/css.d.ts +0 -5
- package/dist/dts/styles/element-styles.d.ts +10 -17
- package/dist/dts/styles/host.d.ts +68 -0
- package/dist/dts/styles/style-strategy.d.ts +42 -0
- package/dist/dts/templating/binding-signal.d.ts +12 -27
- package/dist/dts/templating/binding-two-way.d.ts +22 -37
- package/dist/dts/templating/binding.d.ts +76 -208
- package/dist/dts/templating/children.d.ts +1 -1
- package/dist/dts/templating/compiler.d.ts +11 -13
- package/dist/dts/templating/html-directive.d.ts +91 -97
- package/dist/dts/templating/node-observation.d.ts +15 -6
- package/dist/dts/templating/ref.d.ts +7 -11
- package/dist/dts/templating/render.d.ts +296 -0
- package/dist/dts/templating/repeat.d.ts +23 -34
- package/dist/dts/templating/slotted.d.ts +1 -1
- package/dist/dts/templating/template.d.ts +92 -14
- package/dist/dts/templating/view.d.ts +81 -11
- 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 +14 -0
- package/dist/dts/testing/fixture.d.ts +84 -0
- package/dist/dts/testing/timeout.d.ts +7 -0
- package/dist/dts/utilities.d.ts +55 -19
- package/dist/esm/components/attributes.js +28 -5
- package/dist/esm/components/{controller.js → element-controller.js} +238 -137
- package/dist/esm/components/fast-definitions.js +38 -30
- package/dist/esm/components/fast-element.js +27 -16
- package/dist/esm/components/hydration.js +35 -0
- package/dist/esm/components/install-hydration.js +2 -0
- package/dist/esm/context.js +7 -3
- package/dist/esm/debug.js +41 -5
- package/dist/esm/di/di.js +1430 -0
- package/dist/esm/dom-policy.js +345 -0
- package/dist/esm/dom.js +101 -0
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.rollup.debug.js +3 -1
- package/dist/esm/index.rollup.js +3 -1
- package/dist/esm/interfaces.js +52 -0
- package/dist/esm/metadata.js +9 -8
- package/dist/esm/observation/arrays.js +303 -2
- package/dist/esm/observation/observable.js +88 -142
- package/dist/esm/observation/update-queue.js +2 -2
- package/dist/esm/pending-task.js +28 -0
- package/dist/esm/platform.js +28 -3
- package/dist/esm/polyfills.js +3 -61
- 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 -9
- package/dist/esm/styles/element-styles.js +14 -33
- package/dist/esm/styles/host.js +1 -0
- package/dist/esm/styles/style-strategy.js +1 -0
- package/dist/esm/templating/binding-signal.js +67 -62
- package/dist/esm/templating/binding-two-way.js +72 -39
- package/dist/esm/templating/binding.js +142 -286
- package/dist/esm/templating/children.js +8 -4
- package/dist/esm/templating/compiler.js +59 -43
- package/dist/esm/templating/html-directive.js +56 -75
- package/dist/esm/templating/node-observation.js +20 -13
- package/dist/esm/templating/ref.js +4 -12
- package/dist/esm/templating/render.js +402 -0
- package/dist/esm/templating/repeat.js +88 -75
- package/dist/esm/templating/template.js +132 -60
- package/dist/esm/templating/view.js +113 -29
- package/dist/esm/templating/when.js +5 -4
- package/dist/esm/testing/exports.js +3 -0
- package/dist/esm/testing/fakes.js +107 -0
- package/dist/esm/testing/fixture.js +86 -0
- package/dist/esm/testing/timeout.js +24 -0
- package/dist/esm/utilities.js +97 -96
- package/dist/fast-element.api.json +9741 -8201
- package/dist/fast-element.d.ts +889 -646
- package/dist/fast-element.debug.js +2001 -1167
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +1907 -1109
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +913 -703
- package/docs/api-report.md +331 -258
- package/package.json +38 -16
- 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/dts/templating/dom.d.ts +0 -41
- package/dist/esm/hooks.js +0 -32
- package/dist/esm/observation/splice-strategies.js +0 -400
- package/dist/esm/templating/dom.js +0 -49
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An implementation of the https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/pending-task.md proposal.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export interface PendingTask extends Event {
|
|
6
|
+
/**
|
|
7
|
+
* A promise that resolves when the pending task is complete.
|
|
8
|
+
*/
|
|
9
|
+
readonly complete: Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A concrete implementation of {@link PendingTask}
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare class PendingTaskEvent extends Event implements PendingTask {
|
|
16
|
+
readonly complete: Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* The type of the pending task event.
|
|
19
|
+
*/
|
|
20
|
+
static readonly type = "pending-task";
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instance of PendingTaskEvent.
|
|
23
|
+
* @param complete - A promise that resolves when the pending task is complete.
|
|
24
|
+
*/
|
|
25
|
+
constructor(complete: Promise<void>);
|
|
26
|
+
/**
|
|
27
|
+
* Determines whether a value is a PendingTaskEvent.
|
|
28
|
+
* @param value - The value to check.
|
|
29
|
+
* @returns True if the value is a PendingTaskEvent; false otherwise.
|
|
30
|
+
*/
|
|
31
|
+
static isPendingTask<T extends Event>(value: T | PendingTask): value is PendingTask;
|
|
32
|
+
}
|
package/dist/dts/platform.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { FASTGlobal } from "./interfaces.js";
|
|
2
|
+
import "./polyfills.js";
|
|
2
3
|
/**
|
|
3
4
|
* The FAST global.
|
|
4
|
-
* @
|
|
5
|
+
* @public
|
|
5
6
|
*/
|
|
6
7
|
export declare const FAST: FASTGlobal;
|
|
7
8
|
/**
|
|
@@ -33,3 +34,9 @@ export interface TypeRegistry<TDefinition extends TypeDefinition> {
|
|
|
33
34
|
* @internal
|
|
34
35
|
*/
|
|
35
36
|
export declare function createTypeRegistry<TDefinition extends TypeDefinition>(): TypeRegistry<TDefinition>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a function capable of locating metadata associated with a type.
|
|
39
|
+
* @returns A metadata locator function.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export declare function createMetadataLocator<TMetadata>(): (target: {}) => TMetadata[];
|
package/dist/dts/polyfills.d.ts
CHANGED
|
@@ -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,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 {
|
|
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:
|
|
8
|
+
export declare type AddBehavior = (behavior: HostBehavior<HTMLElement>) => void;
|
|
9
9
|
/**
|
|
10
10
|
* Directive for use in {@link css}.
|
|
11
11
|
*
|
package/dist/dts/styles/css.d.ts
CHANGED
|
@@ -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 {
|
|
2
|
-
import {
|
|
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<
|
|
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,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 {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
41
|
+
export declare function twoWay<T = any>(expression: Expression<T>, optionsOrChangeEvent?: TwoWayBindingOptions | string, policy?: DOMPolicy, isBindingVolatile?: boolean): Binding<T>;
|