@microsoft/fast-element 2.0.0-beta.20 → 2.0.0-beta.22
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 +54 -0
- package/CHANGELOG.md +21 -1
- package/dist/dts/binding/binding.d.ts +49 -0
- package/dist/dts/binding/normalize.d.ts +9 -0
- package/dist/dts/binding/one-time.d.ts +11 -0
- package/dist/dts/binding/one-way.d.ts +20 -0
- package/dist/dts/{templating/binding-signal.d.ts → binding/signal.d.ts} +1 -1
- package/dist/dts/{templating/binding-two-way.d.ts → binding/two-way.d.ts} +3 -4
- package/dist/dts/components/element-controller.d.ts +20 -5
- package/dist/dts/context.d.ts +26 -13
- package/dist/dts/dom-policy.d.ts +15 -0
- package/dist/dts/index.d.ts +6 -2
- package/dist/dts/interfaces.d.ts +6 -5
- package/dist/dts/metadata.d.ts +6 -5
- package/dist/dts/pending-task.d.ts +19 -7
- package/dist/dts/platform.d.ts +10 -2
- package/dist/dts/styles/css-binding-directive.d.ts +60 -0
- package/dist/dts/styles/css.d.ts +9 -2
- package/dist/dts/styles/host.d.ts +2 -5
- package/dist/dts/templating/{binding.d.ts → html-binding-directive.d.ts} +3 -34
- package/dist/dts/templating/html-directive.d.ts +3 -35
- package/dist/dts/templating/render.d.ts +19 -5
- package/dist/dts/templating/repeat.d.ts +3 -2
- package/dist/dts/templating/template.d.ts +2 -6
- package/dist/dts/templating/view.d.ts +16 -6
- package/dist/dts/testing/fakes.d.ts +2 -1
- package/dist/dts/utilities.d.ts +3 -2
- package/dist/esm/binding/binding.js +18 -0
- package/dist/esm/binding/normalize.js +17 -0
- package/dist/esm/binding/one-time.js +21 -0
- package/dist/esm/binding/one-way.js +30 -0
- package/dist/esm/{templating/binding-signal.js → binding/signal.js} +5 -8
- package/dist/esm/{templating/binding-two-way.js → binding/two-way.js} +11 -15
- package/dist/esm/components/element-controller.js +33 -9
- package/dist/esm/context.js +24 -3
- package/dist/esm/debug.js +1 -0
- package/dist/esm/di/di.js +5 -5
- package/dist/esm/dom-policy.js +9 -1
- package/dist/esm/index.js +8 -2
- package/dist/esm/interfaces.js +3 -3
- package/dist/esm/metadata.js +11 -8
- package/dist/esm/observation/observable.js +3 -6
- package/dist/esm/pending-task.js +13 -1
- package/dist/esm/platform.js +10 -1
- package/dist/esm/styles/css-binding-directive.js +76 -0
- package/dist/esm/styles/css.js +14 -2
- package/dist/esm/templating/compiler.js +2 -1
- package/dist/esm/templating/{binding.js → html-binding-directive.js} +3 -70
- package/dist/esm/templating/html-directive.js +2 -25
- package/dist/esm/templating/render.js +25 -12
- package/dist/esm/templating/repeat.js +3 -3
- package/dist/esm/templating/template.js +9 -10
- package/dist/esm/templating/view.js +2 -6
- package/dist/esm/testing/fakes.js +1 -1
- package/dist/esm/utilities.js +3 -2
- package/dist/fast-element.api.json +1827 -663
- package/dist/fast-element.d.ts +167 -43
- package/dist/fast-element.debug.js +227 -120
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +226 -120
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +134 -82
- package/docs/api-report.md +54 -57
- package/package.json +5 -5
package/dist/dts/styles/css.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import type { Expression } from "../observation/observable.js";
|
|
2
|
+
import { Binding } from "../binding/binding.js";
|
|
1
3
|
import { CSSDirective } from "./css-directive.js";
|
|
2
4
|
import { ComposableStyles, ElementStyles } from "./element-styles.js";
|
|
5
|
+
/**
|
|
6
|
+
* Represents the types of values that can be interpolated into a template.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare type CSSValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | ComposableStyles | CSSDirective;
|
|
3
10
|
/**
|
|
4
11
|
* Transforms a template literal string into styles.
|
|
5
12
|
* @param strings - The string fragments that are interpolated with the values.
|
|
@@ -9,14 +16,14 @@ import { ComposableStyles, ElementStyles } from "./element-styles.js";
|
|
|
9
16
|
* Use the .partial method to create partial CSS fragments.
|
|
10
17
|
* @public
|
|
11
18
|
*/
|
|
12
|
-
export declare type CSSTemplateTag = ((strings: TemplateStringsArray, ...values:
|
|
19
|
+
export declare type CSSTemplateTag = (<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: CSSValue<TSource, TParent>[]) => ElementStyles) & {
|
|
13
20
|
/**
|
|
14
21
|
* Transforms a template literal string into partial CSS.
|
|
15
22
|
* @param strings - The string fragments that are interpolated with the values.
|
|
16
23
|
* @param values - The values that are interpolated with the string fragments.
|
|
17
24
|
* @public
|
|
18
25
|
*/
|
|
19
|
-
partial(strings: TemplateStringsArray, ...values:
|
|
26
|
+
partial<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: CSSValue<TSource, TParent>[]): CSSDirective;
|
|
20
27
|
};
|
|
21
28
|
/**
|
|
22
29
|
* Transforms a template literal string into styles.
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
+
import type { ExpressionController } from "../observation/observable.js";
|
|
1
2
|
import type { ElementStyles } from "./element-styles.js";
|
|
2
3
|
/**
|
|
3
4
|
* Controls the lifecycle and context of behaviors and styles
|
|
4
5
|
* associated with a component host.
|
|
5
6
|
* @public
|
|
6
7
|
*/
|
|
7
|
-
export interface HostController<TSource = any> {
|
|
8
|
-
/**
|
|
9
|
-
* The component source.
|
|
10
|
-
*/
|
|
11
|
-
readonly source: TSource;
|
|
8
|
+
export interface HostController<TSource = any> extends ExpressionController<TSource> {
|
|
12
9
|
/**
|
|
13
10
|
* Indicates whether the host is connected or not.
|
|
14
11
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
|
|
2
2
|
import { DOMAspect, DOMPolicy } from "../dom.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { Binding, BindingDirective } from "../binding/binding.js";
|
|
4
|
+
import { AddViewBehaviorFactory, Aspected, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
|
|
4
5
|
/**
|
|
5
6
|
* A simple View that can be interpolated into HTML content.
|
|
6
7
|
* @public
|
|
@@ -42,7 +43,7 @@ export interface ContentTemplate {
|
|
|
42
43
|
* A directive that applies bindings.
|
|
43
44
|
* @public
|
|
44
45
|
*/
|
|
45
|
-
export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected {
|
|
46
|
+
export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected, BindingDirective {
|
|
46
47
|
dataBinding: Binding;
|
|
47
48
|
private data;
|
|
48
49
|
private updateTarget;
|
|
@@ -97,35 +98,3 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
|
|
|
97
98
|
/** @internal */
|
|
98
99
|
handleChange(binding: Expression, observer: ExpressionObserver): void;
|
|
99
100
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Creates an standard binding.
|
|
102
|
-
* @param expression - The binding to refresh when changed.
|
|
103
|
-
* @param policy - The security policy to associate with th binding.
|
|
104
|
-
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
105
|
-
* @returns A binding configuration.
|
|
106
|
-
* @public
|
|
107
|
-
*/
|
|
108
|
-
export declare function bind<T = any>(expression: Expression<T>, policy?: DOMPolicy, isVolatile?: boolean): Binding<T>;
|
|
109
|
-
/**
|
|
110
|
-
* Creates a one time binding
|
|
111
|
-
* @param expression - The binding to refresh when signaled.
|
|
112
|
-
* @param policy - The security policy to associate with th binding.
|
|
113
|
-
* @returns A binding configuration.
|
|
114
|
-
* @public
|
|
115
|
-
*/
|
|
116
|
-
export declare function oneTime<T = any>(expression: Expression<T>, policy?: DOMPolicy): Binding<T>;
|
|
117
|
-
/**
|
|
118
|
-
* Creates an event listener binding.
|
|
119
|
-
* @param expression - The binding to invoke when the event is raised.
|
|
120
|
-
* @param options - Event listener options.
|
|
121
|
-
* @returns A binding configuration.
|
|
122
|
-
* @public
|
|
123
|
-
*/
|
|
124
|
-
export declare function listener<T = any>(expression: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
|
|
125
|
-
/**
|
|
126
|
-
* Normalizes the input value into a binding.
|
|
127
|
-
* @param value - The value to create the default binding for.
|
|
128
|
-
* @returns A binding configuration for the provided value.
|
|
129
|
-
* @public
|
|
130
|
-
*/
|
|
131
|
-
export declare function normalizeBinding<TSource = any, TReturn = any, TParent = any>(value: Expression<TSource, TReturn, TParent> | Binding<TSource, TReturn, TParent> | {}): Binding<TSource, TReturn, TParent>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DOMAspect, DOMPolicy } from "../dom.js";
|
|
2
|
-
import { Constructable } from "../interfaces.js";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
2
|
+
import type { Constructable } from "../interfaces.js";
|
|
3
|
+
import type { Binding } from "../binding/binding.js";
|
|
4
|
+
import type { ExpressionController } from "../observation/observable.js";
|
|
5
5
|
/**
|
|
6
6
|
* The target nodes available to a behavior.
|
|
7
7
|
* @public
|
|
@@ -157,44 +157,12 @@ export declare const HTMLDirective: Readonly<{
|
|
|
157
157
|
* @public
|
|
158
158
|
*/
|
|
159
159
|
export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition): (type: Constructable<HTMLDirective>) => void;
|
|
160
|
-
/**
|
|
161
|
-
* Captures a binding expression along with related information and capabilities.
|
|
162
|
-
*
|
|
163
|
-
* @public
|
|
164
|
-
*/
|
|
165
|
-
export declare abstract class Binding<TSource = any, TReturn = any, TParent = any> {
|
|
166
|
-
evaluate: Expression<TSource, TReturn, TParent>;
|
|
167
|
-
policy?: DOMPolicy | undefined;
|
|
168
|
-
isVolatile: boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Options associated with the binding.
|
|
171
|
-
*/
|
|
172
|
-
options?: any;
|
|
173
|
-
/**
|
|
174
|
-
* Creates a binding.
|
|
175
|
-
* @param evaluate - Evaluates the binding.
|
|
176
|
-
* @param policy - The security policy to associate with this binding.
|
|
177
|
-
* @param isVolatile - Indicates whether the binding is volatile.
|
|
178
|
-
*/
|
|
179
|
-
constructor(evaluate: Expression<TSource, TReturn, TParent>, policy?: DOMPolicy | undefined, isVolatile?: boolean);
|
|
180
|
-
/**
|
|
181
|
-
* Creates an observer capable of notifying a subscriber when the output of a binding changes.
|
|
182
|
-
* @param directive - The HTML Directive to create the observer for.
|
|
183
|
-
* @param subscriber - The subscriber to changes in the binding.
|
|
184
|
-
*/
|
|
185
|
-
abstract createObserver(directive: HTMLDirective, subscriber: Subscriber): ExpressionObserver<TSource, TReturn, TParent>;
|
|
186
|
-
}
|
|
187
160
|
/**
|
|
188
161
|
* A base class used for attribute directives that don't need internal state.
|
|
189
162
|
* @public
|
|
190
163
|
*/
|
|
191
164
|
export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
|
|
192
165
|
protected options: TOptions;
|
|
193
|
-
/**
|
|
194
|
-
* Opts out of JSON stringification.
|
|
195
|
-
* @internal
|
|
196
|
-
*/
|
|
197
|
-
toJSON: () => undefined;
|
|
198
166
|
/**
|
|
199
167
|
* Creates an instance of RefDirective.
|
|
200
168
|
* @param options - The options to use in configuring the directive.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { FASTElement } from "../components/fast-element.js";
|
|
2
2
|
import type { DOMPolicy } from "../dom.js";
|
|
3
3
|
import { Constructable } from "../interfaces.js";
|
|
4
|
+
import { Binding, BindingDirective } from "../binding/binding.js";
|
|
4
5
|
import type { Subscriber } from "../observation/notifier.js";
|
|
5
6
|
import type { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
|
|
6
|
-
import { ContentTemplate, ContentView } from "./binding.js";
|
|
7
|
-
import { AddViewBehaviorFactory,
|
|
7
|
+
import type { ContentTemplate, ContentView } from "./html-binding-directive.js";
|
|
8
|
+
import { AddViewBehaviorFactory, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
|
|
8
9
|
import { CaptureType, SyntheticViewTemplate, TemplateValue, ViewTemplate } from "./template.js";
|
|
9
10
|
/**
|
|
10
11
|
* A Behavior that enables advanced rendering.
|
|
@@ -42,13 +43,13 @@ export declare class RenderBehavior<TSource = any> implements ViewBehavior, Subs
|
|
|
42
43
|
* A Directive that enables use of the RenderBehavior.
|
|
43
44
|
* @public
|
|
44
45
|
*/
|
|
45
|
-
export declare class RenderDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
|
|
46
|
+
export declare class RenderDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory, BindingDirective {
|
|
46
47
|
readonly dataBinding: Binding<TSource>;
|
|
47
48
|
readonly templateBinding: Binding<TSource, ContentTemplate>;
|
|
48
49
|
readonly templateBindingDependsOnData: boolean;
|
|
49
50
|
/**
|
|
50
51
|
* The structural id of the DOM node to which the created behavior will apply.
|
|
51
|
-
*/
|
|
52
|
+
*/ BindingDirective: any;
|
|
52
53
|
targetNodeId: string;
|
|
53
54
|
/**
|
|
54
55
|
* Creates an instance of RenderDirective.
|
|
@@ -143,6 +144,19 @@ export declare type BaseElementRenderOptions<TSource = any, TParent = any> = Com
|
|
|
143
144
|
*/
|
|
144
145
|
policy?: DOMPolicy;
|
|
145
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* Render options for directly creating an element with {@link RenderInstruction.createElementTemplate}
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
export declare type ElementCreateOptions<TSource = any, TParent = any> = Omit<BaseElementRenderOptions, "type" | "name"> & {
|
|
152
|
+
/**
|
|
153
|
+
* Directives to use when creating the element template. These directives are applied directly to the specified tag.
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
* Directives supported by this API are: `ref`, `children`, `slotted`, or any custom `HTMLDirective` that can be used on a HTML tag.
|
|
157
|
+
*/
|
|
158
|
+
directives?: TemplateValue<TSource, TParent>[];
|
|
159
|
+
};
|
|
146
160
|
/**
|
|
147
161
|
* Render options used to specify an element.
|
|
148
162
|
* @public
|
|
@@ -163,7 +177,7 @@ export declare type TagNameRenderOptions<TSource = any, TParent = any> = BaseEle
|
|
|
163
177
|
*/
|
|
164
178
|
tagName: string;
|
|
165
179
|
};
|
|
166
|
-
declare function createElementTemplate<TSource = any, TParent = any>(tagName: string,
|
|
180
|
+
declare function createElementTemplate<TSource = any, TParent = any>(tagName: string, options?: ElementCreateOptions): ViewTemplate<TSource, TParent>;
|
|
167
181
|
declare function create(options: TagNameRenderOptions): RenderInstruction;
|
|
168
182
|
declare function create(options: ElementConstructorRenderOptions): RenderInstruction;
|
|
169
183
|
declare function create(options: TemplateRenderOptions): RenderInstruction;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Subscriber } from "../observation/notifier.js";
|
|
2
2
|
import { Expression, ExpressionObserver } from "../observation/observable.js";
|
|
3
3
|
import { Splice } from "../observation/arrays.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { Binding, BindingDirective } from "../binding/binding.js";
|
|
5
|
+
import { AddViewBehaviorFactory, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
|
|
5
6
|
import type { CaptureType, SyntheticViewTemplate, ViewTemplate } from "./template.js";
|
|
6
7
|
import { SyntheticView } from "./view.js";
|
|
7
8
|
/**
|
|
@@ -68,7 +69,7 @@ export declare class RepeatBehavior<TSource = any> implements ViewBehavior, Subs
|
|
|
68
69
|
* A directive that configures list rendering.
|
|
69
70
|
* @public
|
|
70
71
|
*/
|
|
71
|
-
export declare class RepeatDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
|
|
72
|
+
export declare class RepeatDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory, BindingDirective {
|
|
72
73
|
readonly dataBinding: Binding<TSource>;
|
|
73
74
|
readonly templateBinding: Binding<TSource, SyntheticViewTemplate>;
|
|
74
75
|
readonly options: RepeatOptions;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DOMPolicy } from "../dom.js";
|
|
2
|
+
import { Binding } from "../binding/binding.js";
|
|
2
3
|
import type { Expression } from "../observation/observable.js";
|
|
3
|
-
import { AddViewBehaviorFactory,
|
|
4
|
+
import { AddViewBehaviorFactory, HTMLDirective, ViewBehaviorFactory } from "./html-directive.js";
|
|
4
5
|
import type { ElementView, HTMLView, SyntheticView } from "./view.js";
|
|
5
6
|
/**
|
|
6
7
|
* A template capable of creating views specifically for rendering custom elements.
|
|
@@ -129,11 +130,6 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
|
|
|
129
130
|
* host that the template is being attached to.
|
|
130
131
|
*/
|
|
131
132
|
render(source: TSource, host: Node, hostBindingTarget?: Element): HTMLView<TSource, TParent>;
|
|
132
|
-
/**
|
|
133
|
-
* Opts out of JSON stringification.
|
|
134
|
-
* @internal
|
|
135
|
-
*/
|
|
136
|
-
toJSON: () => undefined;
|
|
137
133
|
/**
|
|
138
134
|
* Creates a template based on a set of static strings and dynamic values.
|
|
139
135
|
* @param strings - The static strings to create the template with.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Disposable } from "../interfaces.js";
|
|
1
|
+
import type { Disposable } from "../interfaces.js";
|
|
2
2
|
import { ExecutionContext, SourceLifetime } from "../observation/observable.js";
|
|
3
3
|
import type { CompiledViewBehaviorFactory, ViewBehaviorTargets, ViewController } from "./html-directive.js";
|
|
4
4
|
/**
|
|
@@ -14,6 +14,10 @@ export interface View<TSource = any, TParent = any> extends Disposable {
|
|
|
14
14
|
* The data that the view is bound to.
|
|
15
15
|
*/
|
|
16
16
|
readonly source: TSource | null;
|
|
17
|
+
/**
|
|
18
|
+
* Indicates whether the controller is bound.
|
|
19
|
+
*/
|
|
20
|
+
readonly isBound: boolean;
|
|
17
21
|
/**
|
|
18
22
|
* Binds a view's behaviors to its binding source.
|
|
19
23
|
* @param source - The binding source for the view's binding behaviors.
|
|
@@ -29,6 +33,17 @@ export interface View<TSource = any, TParent = any> extends Disposable {
|
|
|
29
33
|
* @public
|
|
30
34
|
*/
|
|
31
35
|
export interface ElementView<TSource = any, TParent = any> extends View<TSource, TParent> {
|
|
36
|
+
/**
|
|
37
|
+
* Indicates how the source's lifetime relates to the controller's lifetime.
|
|
38
|
+
*/
|
|
39
|
+
readonly sourceLifetime?: SourceLifetime;
|
|
40
|
+
/**
|
|
41
|
+
* Registers an unbind handler with the controller.
|
|
42
|
+
* @param behavior - An object to call when the controller unbinds.
|
|
43
|
+
*/
|
|
44
|
+
onUnbind(behavior: {
|
|
45
|
+
unbind(controller: ViewController<TSource, TParent>): any;
|
|
46
|
+
}): void;
|
|
32
47
|
/**
|
|
33
48
|
* Appends the view's DOM nodes to the referenced node.
|
|
34
49
|
* @param node - The parent node to append the view's DOM nodes to.
|
|
@@ -185,11 +200,6 @@ export declare class HTMLView<TSource = any, TParent = any> implements ElementVi
|
|
|
185
200
|
* Unbinds a view's behaviors from its binding source.
|
|
186
201
|
*/
|
|
187
202
|
unbind(): void;
|
|
188
|
-
/**
|
|
189
|
-
* Opts out of JSON stringification.
|
|
190
|
-
* @internal
|
|
191
|
-
*/
|
|
192
|
-
toJSON: () => undefined;
|
|
193
203
|
private evaluateUnbindables;
|
|
194
204
|
/**
|
|
195
205
|
* Efficiently disposes of a contiguous range of synthetic view instances.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ExecutionContext
|
|
1
|
+
import { ExecutionContext } from "../observation/observable.js";
|
|
2
|
+
import type { ViewBehavior, ViewBehaviorTargets } from "../templating/html-directive.js";
|
|
2
3
|
export declare const Fake: Readonly<{
|
|
3
4
|
executionContext<TParent = any>(parent?: TParent | undefined, parentContext?: ExecutionContext<TParent> | undefined): ExecutionContext<TParent>;
|
|
4
5
|
viewController<TSource = any, TParent_1 = any>(targets?: ViewBehaviorTargets, ...behaviors: ViewBehavior<TSource, TParent_1>[]): {
|
package/dist/dts/utilities.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function composedParent<T extends HTMLElement>(element: T): HTMLE
|
|
|
14
14
|
* Determines if the reference element contains the test element in a "composed" DOM tree that
|
|
15
15
|
* ignores shadow DOM boundaries.
|
|
16
16
|
*
|
|
17
|
-
* Returns true of the test element is a descendent of the reference, or
|
|
17
|
+
* Returns true of the test element is a descendent of the reference, or exists in
|
|
18
18
|
* a shadow DOM that is a logical descendent of the reference. Otherwise returns false.
|
|
19
19
|
* @param reference - The element to test for containment against.
|
|
20
20
|
* @param test - The element being tested for containment.
|
|
@@ -23,13 +23,14 @@ export declare function composedParent<T extends HTMLElement>(element: T): HTMLE
|
|
|
23
23
|
*/
|
|
24
24
|
export declare function composedContains(reference: HTMLElement, test: HTMLElement): boolean;
|
|
25
25
|
/**
|
|
26
|
+
* An extension of MutationObserver that supports unobserving nodes.
|
|
26
27
|
* @internal
|
|
27
28
|
*/
|
|
28
29
|
export declare class UnobservableMutationObserver extends MutationObserver {
|
|
29
30
|
private readonly callback;
|
|
30
31
|
private observedNodes;
|
|
31
32
|
/**
|
|
32
|
-
*
|
|
33
|
+
* Creates an instance of UnobservableMutationObserver.
|
|
33
34
|
* @param callback - The callback to invoke when observed nodes are changed.
|
|
34
35
|
*/
|
|
35
36
|
constructor(callback: MutationCallback);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Captures a binding expression along with related information and capabilities.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class Binding {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a binding.
|
|
9
|
+
* @param evaluate - Evaluates the binding.
|
|
10
|
+
* @param policy - The security policy to associate with this binding.
|
|
11
|
+
* @param isVolatile - Indicates whether the binding is volatile.
|
|
12
|
+
*/
|
|
13
|
+
constructor(evaluate, policy, isVolatile = false) {
|
|
14
|
+
this.evaluate = evaluate;
|
|
15
|
+
this.policy = policy;
|
|
16
|
+
this.isVolatile = isVolatile;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isFunction } from "../interfaces.js";
|
|
2
|
+
import { Binding } from "./binding.js";
|
|
3
|
+
import { oneWay } from "./one-way.js";
|
|
4
|
+
import { oneTime } from "./one-time.js";
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes the input value into a binding.
|
|
7
|
+
* @param value - The value to create the default binding for.
|
|
8
|
+
* @returns A binding configuration for the provided value.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export function normalizeBinding(value) {
|
|
12
|
+
return isFunction(value)
|
|
13
|
+
? oneWay(value)
|
|
14
|
+
: value instanceof Binding
|
|
15
|
+
? value
|
|
16
|
+
: oneTime(() => value);
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { makeSerializationNoop } from "../platform.js";
|
|
2
|
+
import { Binding } from "./binding.js";
|
|
3
|
+
class OneTimeBinding extends Binding {
|
|
4
|
+
createObserver() {
|
|
5
|
+
return this;
|
|
6
|
+
}
|
|
7
|
+
bind(controller) {
|
|
8
|
+
return this.evaluate(controller.source, controller.context);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
makeSerializationNoop(OneTimeBinding);
|
|
12
|
+
/**
|
|
13
|
+
* Creates a one time binding
|
|
14
|
+
* @param expression - The binding to refresh when signaled.
|
|
15
|
+
* @param policy - The security policy to associate with th binding.
|
|
16
|
+
* @returns A binding configuration.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export function oneTime(expression, policy) {
|
|
20
|
+
return new OneTimeBinding(expression, policy);
|
|
21
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Observable } from "../observation/observable.js";
|
|
2
|
+
import { Binding } from "./binding.js";
|
|
3
|
+
class OneWayBinding extends Binding {
|
|
4
|
+
createObserver(subscriber) {
|
|
5
|
+
return Observable.binding(this.evaluate, subscriber, this.isVolatile);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Creates an standard binding.
|
|
10
|
+
* @param expression - The binding to refresh when changed.
|
|
11
|
+
* @param policy - The security policy to associate with th binding.
|
|
12
|
+
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
13
|
+
* @returns A binding configuration.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export function oneWay(expression, policy, isVolatile = Observable.isVolatileBinding(expression)) {
|
|
17
|
+
return new OneWayBinding(expression, policy, isVolatile);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates an event listener binding.
|
|
21
|
+
* @param expression - The binding to invoke when the event is raised.
|
|
22
|
+
* @param options - Event listener options.
|
|
23
|
+
* @returns A binding configuration.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export function listener(expression, options) {
|
|
27
|
+
const config = new OneWayBinding(expression);
|
|
28
|
+
config.options = options;
|
|
29
|
+
return config;
|
|
30
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { isString
|
|
2
|
-
import {
|
|
1
|
+
import { isString } from "../interfaces.js";
|
|
2
|
+
import { makeSerializationNoop } from "../platform.js";
|
|
3
|
+
import { Binding } from "./binding.js";
|
|
3
4
|
const subscribers = Object.create(null);
|
|
4
5
|
export const Signal = Object.freeze({
|
|
5
6
|
subscribe(signal, subscriber) {
|
|
@@ -41,11 +42,6 @@ class SignalObserver {
|
|
|
41
42
|
this.dataBinding = dataBinding;
|
|
42
43
|
this.subscriber = subscriber;
|
|
43
44
|
this.isNotBound = true;
|
|
44
|
-
/**
|
|
45
|
-
* Opts out of JSON stringification.
|
|
46
|
-
* @internal
|
|
47
|
-
*/
|
|
48
|
-
this.toJSON = noop;
|
|
49
45
|
}
|
|
50
46
|
bind(controller) {
|
|
51
47
|
if (this.isNotBound) {
|
|
@@ -69,8 +65,9 @@ class SignalObserver {
|
|
|
69
65
|
: options(controller.source, controller.context);
|
|
70
66
|
}
|
|
71
67
|
}
|
|
68
|
+
makeSerializationNoop(SignalObserver);
|
|
72
69
|
class SignalBinding extends Binding {
|
|
73
|
-
createObserver(
|
|
70
|
+
createObserver(subscriber) {
|
|
74
71
|
return new SignalObserver(this, subscriber);
|
|
75
72
|
}
|
|
76
73
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isString
|
|
1
|
+
import { isString } from "../interfaces.js";
|
|
2
2
|
import { Observable, } from "../observation/observable.js";
|
|
3
|
-
import { FAST } from "../platform.js";
|
|
4
|
-
import { Binding } from "./
|
|
3
|
+
import { FAST, makeSerializationNoop } from "../platform.js";
|
|
4
|
+
import { Binding } from "./binding.js";
|
|
5
5
|
const defaultOptions = {
|
|
6
6
|
fromView: v => v,
|
|
7
7
|
};
|
|
@@ -25,11 +25,6 @@ class TwoWayObserver {
|
|
|
25
25
|
this.subscriber = subscriber;
|
|
26
26
|
this.dataBinding = dataBinding;
|
|
27
27
|
this.isNotBound = true;
|
|
28
|
-
/**
|
|
29
|
-
* Opts out of JSON stringification.
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
this.toJSON = noop;
|
|
33
28
|
this.notifier = Observable.binding(dataBinding.evaluate, this, dataBinding.isVolatile);
|
|
34
29
|
}
|
|
35
30
|
bind(controller) {
|
|
@@ -53,7 +48,7 @@ class TwoWayObserver {
|
|
|
53
48
|
this.subscriber.handleChange(this.dataBinding.evaluate, this);
|
|
54
49
|
}
|
|
55
50
|
handleEvent(event) {
|
|
56
|
-
const
|
|
51
|
+
const bindingSource = this.directive;
|
|
57
52
|
const target = event.currentTarget;
|
|
58
53
|
const notifier = this.notifier;
|
|
59
54
|
const last = notifier.last; // using internal API!!!
|
|
@@ -62,26 +57,27 @@ class TwoWayObserver {
|
|
|
62
57
|
return;
|
|
63
58
|
}
|
|
64
59
|
let value;
|
|
65
|
-
switch (
|
|
60
|
+
switch (bindingSource.aspectType) {
|
|
66
61
|
case 1:
|
|
67
|
-
value = target.getAttribute(
|
|
62
|
+
value = target.getAttribute(bindingSource.targetAspect);
|
|
68
63
|
break;
|
|
69
64
|
case 2:
|
|
70
|
-
value = target.hasAttribute(
|
|
65
|
+
value = target.hasAttribute(bindingSource.targetAspect);
|
|
71
66
|
break;
|
|
72
67
|
case 4:
|
|
73
68
|
value = target.innerText;
|
|
74
69
|
break;
|
|
75
70
|
default:
|
|
76
|
-
value = target[
|
|
71
|
+
value = target[bindingSource.targetAspect];
|
|
77
72
|
break;
|
|
78
73
|
}
|
|
79
74
|
last.propertySource[last.propertyName] = this.dataBinding.options.fromView(value);
|
|
80
75
|
}
|
|
81
76
|
}
|
|
77
|
+
makeSerializationNoop(TwoWayObserver);
|
|
82
78
|
class TwoWayBinding extends Binding {
|
|
83
|
-
createObserver(
|
|
84
|
-
return new TwoWayObserver(
|
|
79
|
+
createObserver(subscriber, bindingSource) {
|
|
80
|
+
return new TwoWayObserver(bindingSource, subscriber, this);
|
|
85
81
|
}
|
|
86
82
|
}
|
|
87
83
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../interfaces.js";
|
|
2
2
|
import { PropertyChangeNotifier } from "../observation/notifier.js";
|
|
3
|
-
import { Observable, SourceLifetime } from "../observation/observable.js";
|
|
4
|
-
import { FAST } from "../platform.js";
|
|
3
|
+
import { ExecutionContext, Observable, SourceLifetime, } from "../observation/observable.js";
|
|
4
|
+
import { FAST, makeSerializationNoop } from "../platform.js";
|
|
5
5
|
import { ElementStyles } from "../styles/element-styles.js";
|
|
6
6
|
import { FASTElementDefinition } from "./fast-definitions.js";
|
|
7
7
|
const defaultEventOptions = {
|
|
@@ -58,11 +58,6 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
58
58
|
* If `null` then the element is managing its own rendering.
|
|
59
59
|
*/
|
|
60
60
|
this.view = null;
|
|
61
|
-
/**
|
|
62
|
-
* Opts out of JSON stringification.
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
this.toJSON = noop;
|
|
66
61
|
this.source = element;
|
|
67
62
|
this.definition = definition;
|
|
68
63
|
const shadowOptions = definition.shadowOptions;
|
|
@@ -103,6 +98,27 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
103
98
|
Observable.track(this, isConnectedPropertyName);
|
|
104
99
|
return this.stage === 1 /* Stages.connected */;
|
|
105
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* The context the expression is evaluated against.
|
|
103
|
+
*/
|
|
104
|
+
get context() {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
return (_b = (_a = this.view) === null || _a === void 0 ? void 0 : _a.context) !== null && _b !== void 0 ? _b : ExecutionContext.default;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Indicates whether the controller is bound.
|
|
110
|
+
*/
|
|
111
|
+
get isBound() {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
return (_b = (_a = this.view) === null || _a === void 0 ? void 0 : _a.isBound) !== null && _b !== void 0 ? _b : false;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Indicates how the source's lifetime relates to the controller's lifetime.
|
|
117
|
+
*/
|
|
118
|
+
get sourceLifetime() {
|
|
119
|
+
var _a;
|
|
120
|
+
return (_a = this.view) === null || _a === void 0 ? void 0 : _a.sourceLifetime;
|
|
121
|
+
}
|
|
106
122
|
/**
|
|
107
123
|
* Gets/sets the template used to render the component.
|
|
108
124
|
* @remarks
|
|
@@ -165,6 +181,14 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
165
181
|
this.addStyles(value);
|
|
166
182
|
}
|
|
167
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Registers an unbind handler with the controller.
|
|
186
|
+
* @param behavior - An object to call when the controller unbinds.
|
|
187
|
+
*/
|
|
188
|
+
onUnbind(behavior) {
|
|
189
|
+
var _a;
|
|
190
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.onUnbind(behavior);
|
|
191
|
+
}
|
|
168
192
|
/**
|
|
169
193
|
* Adds the behavior to the component.
|
|
170
194
|
* @param behavior - The behavior to add.
|
|
@@ -397,6 +421,7 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
397
421
|
elementControllerStrategy = strategy;
|
|
398
422
|
}
|
|
399
423
|
}
|
|
424
|
+
makeSerializationNoop(ElementController);
|
|
400
425
|
// Set default strategy for ElementController
|
|
401
426
|
ElementController.setStrategy(ElementController);
|
|
402
427
|
/**
|
|
@@ -478,7 +503,6 @@ export class StyleElementStrategy {
|
|
|
478
503
|
removeStylesFrom(target) {
|
|
479
504
|
target = usableStyleTarget(normalizeStyleTarget(target));
|
|
480
505
|
const styles = target.querySelectorAll(`.${this.styleClass}`);
|
|
481
|
-
styles[0].parentNode;
|
|
482
506
|
for (let i = 0, ii = styles.length; i < ii; ++i) {
|
|
483
507
|
target.removeChild(styles[i]);
|
|
484
508
|
}
|