@microsoft/fast-element 2.0.0-beta.9 → 2.0.1
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/.eslintrc.json +1 -1
- package/CHANGELOG.json +518 -0
- package/CHANGELOG.md +181 -1
- package/README.md +1 -9
- package/api-extractor.context.json +14 -0
- package/api-extractor.di.json +14 -0
- package/dist/context/context.api.json +1068 -0
- package/dist/di/di.api.json +4929 -0
- 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} +19 -4
- package/dist/dts/{templating/binding-two-way.d.ts → binding/two-way.d.ts} +9 -5
- package/dist/dts/components/attributes.d.ts +7 -1
- package/dist/dts/components/element-controller.d.ts +104 -8
- package/dist/dts/components/element-hydration.d.ts +2 -0
- package/dist/dts/components/fast-definitions.d.ts +6 -0
- package/dist/dts/components/hydration.d.ts +56 -0
- package/dist/dts/components/install-hydration.d.ts +1 -0
- package/dist/dts/context.d.ts +29 -15
- package/dist/dts/di/di.d.ts +0 -5
- package/dist/dts/dom-policy.d.ts +83 -0
- package/dist/dts/dom.d.ts +100 -0
- package/dist/dts/hydration/target-builder.d.ts +63 -0
- package/dist/dts/index.d.ts +33 -26
- 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 +32 -82
- package/dist/dts/metadata.d.ts +6 -5
- package/dist/dts/observation/arrays.d.ts +1 -1
- package/dist/dts/observation/observable.bench.d.ts +18 -0
- package/dist/dts/observation/observable.d.ts +5 -5
- package/dist/dts/pending-task.d.ts +19 -7
- package/dist/dts/platform.d.ts +11 -2
- package/dist/dts/polyfills.d.ts +0 -8
- package/dist/dts/styles/css-binding-directive.d.ts +60 -0
- package/dist/dts/styles/css.d.ts +9 -7
- package/dist/dts/styles/element-styles.d.ts +1 -14
- package/dist/dts/styles/host.d.ts +2 -5
- package/dist/dts/styles/style-strategy.d.ts +42 -0
- package/dist/dts/templating/compiler.d.ts +11 -13
- package/dist/dts/templating/{binding.d.ts → html-binding-directive.d.ts} +21 -41
- package/dist/dts/templating/html-directive.d.ts +44 -140
- package/dist/dts/templating/install-hydratable-view-templates.d.ts +1 -0
- package/dist/dts/templating/node-observation.d.ts +11 -1
- package/dist/dts/templating/ref.d.ts +4 -0
- package/dist/dts/templating/render.bench.d.ts +3 -0
- package/dist/dts/templating/render.d.ts +49 -9
- package/dist/dts/templating/repeat-basic-reverse.bench.d.ts +3 -0
- package/dist/dts/templating/repeat-basic-shift.bench.d.ts +3 -0
- package/dist/dts/templating/repeat.d.ts +31 -9
- package/dist/dts/templating/template.d.ts +97 -12
- package/dist/dts/templating/view.d.ts +146 -29
- package/dist/dts/templating/when-basic.bench.d.ts +3 -0
- package/dist/dts/templating/when-conditional.bench.d.ts +3 -0
- package/dist/dts/templating/when-switch.bench.d.ts +3 -0
- package/dist/dts/templating/when.d.ts +3 -1
- package/dist/dts/testing/fakes.d.ts +12 -1
- package/dist/dts/tsdoc-metadata.json +1 -1
- package/dist/dts/utilities.d.ts +55 -1
- 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} +22 -6
- package/dist/esm/{templating/binding-two-way.js → binding/two-way.js} +18 -12
- package/dist/esm/components/attributes.js +19 -6
- package/dist/esm/components/element-controller.js +319 -49
- package/dist/esm/components/element-hydration.js +2 -0
- package/dist/esm/components/fast-definitions.js +12 -4
- package/dist/esm/components/fast-element.js +3 -1
- package/dist/esm/components/hydration.js +104 -0
- package/dist/esm/components/install-hydration.js +3 -0
- package/dist/esm/context.js +26 -4
- package/dist/esm/debug.js +8 -2
- package/dist/esm/di/di.js +9 -12
- package/dist/esm/dom-policy.js +345 -0
- package/dist/esm/dom.js +101 -0
- package/dist/esm/hydration/target-builder.js +175 -0
- package/dist/esm/index.js +34 -25
- package/dist/esm/index.rollup.debug.js +3 -1
- package/dist/esm/index.rollup.js +3 -1
- package/dist/esm/interfaces.js +51 -3
- package/dist/esm/metadata.js +11 -8
- package/dist/esm/observation/arrays.js +1 -1
- package/dist/esm/observation/observable.bench.js +79 -0
- package/dist/esm/observation/observable.js +20 -15
- package/dist/esm/observation/update-queue.js +2 -2
- package/dist/esm/pending-task.js +13 -1
- package/dist/esm/platform.js +12 -2
- package/dist/esm/polyfills.js +3 -61
- package/dist/esm/styles/css-binding-directive.js +76 -0
- package/dist/esm/styles/css.js +14 -7
- package/dist/esm/styles/element-styles.js +0 -33
- package/dist/esm/styles/style-strategy.js +1 -0
- package/dist/esm/templating/children.js +8 -4
- package/dist/esm/templating/compiler.js +37 -44
- package/dist/esm/templating/html-binding-directive.js +218 -0
- package/dist/esm/templating/html-directive.js +25 -152
- package/dist/esm/templating/install-hydratable-view-templates.js +17 -0
- package/dist/esm/templating/node-observation.js +14 -8
- package/dist/esm/templating/ref.js +1 -1
- package/dist/esm/templating/render.bench.js +56 -0
- package/dist/esm/templating/render.js +74 -30
- package/dist/esm/templating/repeat-basic-reverse.bench.js +43 -0
- package/dist/esm/templating/repeat-basic-shift.bench.js +43 -0
- package/dist/esm/templating/repeat.js +116 -17
- package/dist/esm/templating/template.js +135 -60
- package/dist/esm/templating/view.js +254 -34
- package/dist/esm/templating/when-basic.bench.js +36 -0
- package/dist/esm/templating/when-conditional.bench.js +39 -0
- package/dist/esm/templating/when-switch.bench.js +68 -0
- package/dist/esm/templating/when.js +12 -5
- package/dist/esm/testing/fakes.js +32 -1
- package/dist/esm/testing/fixture.js +1 -1
- package/dist/esm/utilities.js +97 -1
- package/dist/fast-element.api.json +9789 -5667
- package/dist/fast-element.d.ts +813 -2392
- package/dist/fast-element.debug.js +2788 -974
- package/dist/fast-element.debug.min.js +3 -1
- package/dist/fast-element.js +2641 -833
- package/dist/fast-element.min.js +3 -1
- package/dist/fast-element.untrimmed.d.ts +662 -314
- package/docs/{api-report.md → api-report.api.md} +238 -151
- package/docs/context/api-report.api.md +69 -0
- package/docs/di/api-report.api.md +315 -0
- package/karma.conf.cjs +2 -1
- package/package.json +59 -47
- package/scripts/run-api-extractor.js +51 -0
- package/scripts/run-benchmarks.js +46 -0
- package/tensile.config.js +12 -0
- package/dist/dts/templating/dom.d.ts +0 -41
- package/dist/esm/templating/binding.js +0 -282
- package/dist/esm/templating/dom.js +0 -49
- package/docs/guide/declaring-templates.md +0 -230
- package/docs/guide/defining-elements.md +0 -214
- package/docs/guide/leveraging-css.md +0 -253
- package/docs/guide/next-steps.md +0 -13
- package/docs/guide/observables-and-state.md +0 -213
- package/docs/guide/using-directives.md +0 -576
- package/docs/guide/working-with-shadow-dom.md +0 -296
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.
|
|
@@ -27,8 +34,3 @@ export declare type CSSTemplateTag = ((strings: TemplateStringsArray, ...values:
|
|
|
27
34
|
* @public
|
|
28
35
|
*/
|
|
29
36
|
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,4 +1,4 @@
|
|
|
1
|
-
import { StyleStrategy, StyleTarget } from "
|
|
1
|
+
import type { StyleStrategy, StyleTarget } from "./style-strategy.js";
|
|
2
2
|
import type { HostBehavior } from "./host.js";
|
|
3
3
|
/**
|
|
4
4
|
* Represents styles that can be composed into the ShadowDOM of a custom element.
|
|
@@ -69,16 +69,3 @@ export declare class ElementStyles {
|
|
|
69
69
|
*/
|
|
70
70
|
static readonly supportsAdoptedStyleSheets: boolean;
|
|
71
71
|
}
|
|
72
|
-
/**
|
|
73
|
-
* https://wicg.github.io/construct-stylesheets/
|
|
74
|
-
* https://developers.google.com/web/updates/2019/02/constructable-stylesheets
|
|
75
|
-
*
|
|
76
|
-
* @internal
|
|
77
|
-
*/
|
|
78
|
-
export declare class AdoptedStyleSheetsStrategy implements StyleStrategy {
|
|
79
|
-
/** @internal */
|
|
80
|
-
readonly sheets: CSSStyleSheet[];
|
|
81
|
-
constructor(styles: (string | CSSStyleSheet)[]);
|
|
82
|
-
addStylesTo(target: StyleTarget): void;
|
|
83
|
-
removeStylesFrom(target: StyleTarget): void;
|
|
84
|
-
}
|
|
@@ -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
|
*/
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DOMPolicy } from "../dom.js";
|
|
2
2
|
import { ViewBehaviorFactory } from "./html-directive.js";
|
|
3
3
|
import type { HTMLTemplateCompilationResult as TemplateCompilationResult } from "./template.js";
|
|
4
4
|
/**
|
|
@@ -14,32 +14,29 @@ html: string | HTMLTemplateElement,
|
|
|
14
14
|
/**
|
|
15
15
|
* The behavior factories used within the html that is being compiled.
|
|
16
16
|
*/
|
|
17
|
-
factories: Record<string, ViewBehaviorFactory
|
|
17
|
+
factories: Record<string, ViewBehaviorFactory>,
|
|
18
|
+
/**
|
|
19
|
+
* The security policy to compile the html with.
|
|
20
|
+
*/
|
|
21
|
+
policy: DOMPolicy) => TemplateCompilationResult;
|
|
18
22
|
/**
|
|
19
23
|
* Common APIs related to compilation.
|
|
20
24
|
* @public
|
|
21
25
|
*/
|
|
22
26
|
export declare const Compiler: {
|
|
23
|
-
/**
|
|
24
|
-
* Sets the HTML trusted types policy used by the compiler.
|
|
25
|
-
* @param policy - The policy to set for HTML.
|
|
26
|
-
* @remarks
|
|
27
|
-
* This API can only be called once, for security reasons. It should be
|
|
28
|
-
* called by the application developer at the start of their program.
|
|
29
|
-
*/
|
|
30
|
-
setHTMLPolicy(policy: TrustedTypesPolicy): void;
|
|
31
27
|
/**
|
|
32
28
|
* Compiles a template and associated directives into a compilation
|
|
33
29
|
* result which can be used to create views.
|
|
34
30
|
* @param html - The html string or template element to compile.
|
|
35
|
-
* @param
|
|
31
|
+
* @param factories - The behavior factories referenced by the template.
|
|
32
|
+
* @param policy - The security policy to compile the html with.
|
|
36
33
|
* @remarks
|
|
37
34
|
* The template that is provided for compilation is altered in-place
|
|
38
35
|
* and cannot be compiled again. If the original template must be preserved,
|
|
39
36
|
* it is recommended that you clone the original and pass the clone to this API.
|
|
40
37
|
* @public
|
|
41
38
|
*/
|
|
42
|
-
compile<TSource = any, TParent = any>(html: string | HTMLTemplateElement,
|
|
39
|
+
compile<TSource = any, TParent = any>(html: string | HTMLTemplateElement, factories: Record<string, ViewBehaviorFactory>, policy?: DOMPolicy): TemplateCompilationResult<TSource, TParent>;
|
|
43
40
|
/**
|
|
44
41
|
* Sets the default compilation strategy that will be used by the ViewTemplate whenever
|
|
45
42
|
* it needs to compile a view preprocessed with the html template function.
|
|
@@ -50,7 +47,8 @@ export declare const Compiler: {
|
|
|
50
47
|
* Aggregates an array of strings and directives into a single directive.
|
|
51
48
|
* @param parts - A heterogeneous array of static strings interspersed with
|
|
52
49
|
* directives.
|
|
50
|
+
* @param policy - The security policy to use with the aggregated bindings.
|
|
53
51
|
* @returns A single inline directive that aggregates the behavior of all the parts.
|
|
54
52
|
*/
|
|
55
|
-
aggregate(parts: (string | ViewBehaviorFactory)[]): ViewBehaviorFactory;
|
|
53
|
+
aggregate(parts: (string | ViewBehaviorFactory)[], policy?: DOMPolicy): ViewBehaviorFactory;
|
|
56
54
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { DOMAspect, DOMPolicy } from "../dom.js";
|
|
1
2
|
import { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
|
|
2
|
-
import {
|
|
3
|
+
import type { Binding, BindingDirective } from "../binding/binding.js";
|
|
4
|
+
import { AddViewBehaviorFactory, Aspected, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
|
|
3
5
|
/**
|
|
4
6
|
* A simple View that can be interpolated into HTML content.
|
|
5
7
|
* @public
|
|
@@ -37,11 +39,17 @@ export interface ContentTemplate {
|
|
|
37
39
|
*/
|
|
38
40
|
create(): ContentView;
|
|
39
41
|
}
|
|
42
|
+
export interface HydratableContentTemplate extends ContentTemplate {
|
|
43
|
+
/**
|
|
44
|
+
* Hydrates a content view from first/last nodes.
|
|
45
|
+
*/
|
|
46
|
+
hydrate(first: Node, last: Node): ContentView;
|
|
47
|
+
}
|
|
40
48
|
/**
|
|
41
49
|
* A directive that applies bindings.
|
|
42
50
|
* @public
|
|
43
51
|
*/
|
|
44
|
-
export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected {
|
|
52
|
+
export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected, BindingDirective {
|
|
45
53
|
dataBinding: Binding;
|
|
46
54
|
private data;
|
|
47
55
|
private updateTarget;
|
|
@@ -52,7 +60,15 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
|
|
|
52
60
|
/**
|
|
53
61
|
* The structural id of the DOM node to which the created behavior will apply.
|
|
54
62
|
*/
|
|
55
|
-
|
|
63
|
+
targetNodeId: string;
|
|
64
|
+
/**
|
|
65
|
+
* The tagname associated with the target node.
|
|
66
|
+
*/
|
|
67
|
+
targetTagName: string | null;
|
|
68
|
+
/**
|
|
69
|
+
* The policy that the created behavior must run under.
|
|
70
|
+
*/
|
|
71
|
+
policy: DOMPolicy;
|
|
56
72
|
/**
|
|
57
73
|
* The original source aspect exactly as represented in markup.
|
|
58
74
|
*/
|
|
@@ -64,7 +80,7 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
|
|
|
64
80
|
/**
|
|
65
81
|
* The type of aspect to target.
|
|
66
82
|
*/
|
|
67
|
-
aspectType:
|
|
83
|
+
aspectType: DOMAspect;
|
|
68
84
|
/**
|
|
69
85
|
* Creates an instance of HTMLBindingDirective.
|
|
70
86
|
* @param dataBinding - The binding configuration to apply.
|
|
@@ -80,13 +96,7 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
|
|
|
80
96
|
*/
|
|
81
97
|
createBehavior(): ViewBehavior;
|
|
82
98
|
/** @internal */
|
|
83
|
-
|
|
84
|
-
/** @internal */
|
|
85
|
-
bind: (controller: ViewController) => void;
|
|
86
|
-
/** @internal */
|
|
87
|
-
bindContent(controller: ViewController): void;
|
|
88
|
-
/** @internal */
|
|
89
|
-
bindEvent(controller: ViewController): void;
|
|
99
|
+
bind(controller: ViewController): void;
|
|
90
100
|
/** @internal */
|
|
91
101
|
unbind(controller: ViewController): void;
|
|
92
102
|
/** @internal */
|
|
@@ -94,33 +104,3 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
|
|
|
94
104
|
/** @internal */
|
|
95
105
|
handleChange(binding: Expression, observer: ExpressionObserver): void;
|
|
96
106
|
}
|
|
97
|
-
/**
|
|
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.
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
|
-
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
|
-
import
|
|
1
|
+
import { DOMAspect, DOMPolicy } from "../dom.js";
|
|
2
2
|
import type { Constructable } from "../interfaces.js";
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
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
|
|
@@ -19,43 +19,6 @@ export interface ViewController<TSource = any, TParent = any> extends Expression
|
|
|
19
19
|
*/
|
|
20
20
|
readonly targets: ViewBehaviorTargets;
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Bridges between ViewBehaviors and HostBehaviors, enabling a host to
|
|
24
|
-
* control ViewBehaviors.
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
export interface ViewBehaviorOrchestrator<TSource = any, TParent = any> extends ViewController<TSource, TParent>, HostBehavior<TSource> {
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @param nodeId - The structural id of the DOM node to which a behavior will apply.
|
|
31
|
-
* @param target - The DOM node associated with the id.
|
|
32
|
-
*/
|
|
33
|
-
addTarget(nodeId: string, target: Node): void;
|
|
34
|
-
/**
|
|
35
|
-
* Adds a behavior.
|
|
36
|
-
* @param behavior - The behavior to add.
|
|
37
|
-
*/
|
|
38
|
-
addBehavior(behavior: ViewBehavior): void;
|
|
39
|
-
/**
|
|
40
|
-
* Adds a behavior factory.
|
|
41
|
-
* @param factory - The behavior factory to add.
|
|
42
|
-
* @param target - The target the factory will create behaviors for.
|
|
43
|
-
*/
|
|
44
|
-
addBehaviorFactory(factory: ViewBehaviorFactory, target: Node): void;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Bridges between ViewBehaviors and HostBehaviors, enabling a host to
|
|
48
|
-
* control ViewBehaviors.
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
export declare const ViewBehaviorOrchestrator: Readonly<{
|
|
52
|
-
/**
|
|
53
|
-
* Creates a ViewBehaviorOrchestrator.
|
|
54
|
-
* @param source - The source to to associate behaviors with.
|
|
55
|
-
* @returns A ViewBehaviorOrchestrator.
|
|
56
|
-
*/
|
|
57
|
-
create<TSource = any, TParent = any>(source: TSource): ViewBehaviorOrchestrator<TSource, TParent>;
|
|
58
|
-
}>;
|
|
59
22
|
/**
|
|
60
23
|
* Represents an object that can contribute behavior to a view.
|
|
61
24
|
* @public
|
|
@@ -76,16 +39,29 @@ export interface ViewBehaviorFactory {
|
|
|
76
39
|
/**
|
|
77
40
|
* The unique id of the factory.
|
|
78
41
|
*/
|
|
79
|
-
id
|
|
42
|
+
id?: string;
|
|
80
43
|
/**
|
|
81
44
|
* The structural id of the DOM node to which the created behavior will apply.
|
|
82
45
|
*/
|
|
83
|
-
|
|
46
|
+
targetNodeId?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The tag name of the DOM node to which the created behavior will apply.
|
|
49
|
+
*/
|
|
50
|
+
targetTagName?: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* The policy that the created behavior must run under.
|
|
53
|
+
*/
|
|
54
|
+
policy?: DOMPolicy;
|
|
84
55
|
/**
|
|
85
56
|
* Creates a behavior.
|
|
86
57
|
*/
|
|
87
58
|
createBehavior(): ViewBehavior;
|
|
88
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Represents a ViewBehaviorFactory after the compilation process has completed.
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export declare type CompiledViewBehaviorFactory = Required<ViewBehaviorFactory>;
|
|
89
65
|
/**
|
|
90
66
|
* Used to add behavior factories when constructing templates.
|
|
91
67
|
* @public
|
|
@@ -102,6 +78,28 @@ export interface HTMLDirective {
|
|
|
102
78
|
*/
|
|
103
79
|
createHTML(add: AddViewBehaviorFactory): string;
|
|
104
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Represents something that applies to a specific aspect of the DOM.
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
export interface Aspected {
|
|
86
|
+
/**
|
|
87
|
+
* The original source aspect exactly as represented in markup.
|
|
88
|
+
*/
|
|
89
|
+
sourceAspect: string;
|
|
90
|
+
/**
|
|
91
|
+
* The evaluated target aspect, determined after processing the source.
|
|
92
|
+
*/
|
|
93
|
+
targetAspect: string;
|
|
94
|
+
/**
|
|
95
|
+
* The type of aspect to target.
|
|
96
|
+
*/
|
|
97
|
+
aspectType: DOMAspect;
|
|
98
|
+
/**
|
|
99
|
+
* A binding if one is associated with the aspect.
|
|
100
|
+
*/
|
|
101
|
+
dataBinding?: Binding;
|
|
102
|
+
}
|
|
105
103
|
/**
|
|
106
104
|
* Represents metadata configuration for an HTMLDirective.
|
|
107
105
|
* @public
|
|
@@ -144,71 +142,6 @@ export declare const HTMLDirective: Readonly<{
|
|
|
144
142
|
* @param options - Options that specify the directive's application.
|
|
145
143
|
*/
|
|
146
144
|
define<TType extends Constructable<HTMLDirective>>(type: TType, options?: PartialHTMLDirectiveDefinition): TType;
|
|
147
|
-
}>;
|
|
148
|
-
/**
|
|
149
|
-
* Decorator: Defines an HTMLDirective.
|
|
150
|
-
* @param options - Provides options that specify the directive's application.
|
|
151
|
-
* @public
|
|
152
|
-
*/
|
|
153
|
-
export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition): (type: Constructable<HTMLDirective>) => void;
|
|
154
|
-
/**
|
|
155
|
-
* Captures a binding expression along with related information and capabilities.
|
|
156
|
-
*
|
|
157
|
-
* @public
|
|
158
|
-
*/
|
|
159
|
-
export declare abstract class Binding<TSource = any, TReturn = any, TParent = any> {
|
|
160
|
-
evaluate: Expression<TSource, TReturn, TParent>;
|
|
161
|
-
isVolatile: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Options associated with the binding.
|
|
164
|
-
*/
|
|
165
|
-
options?: any;
|
|
166
|
-
/**
|
|
167
|
-
* Creates a binding.
|
|
168
|
-
* @param evaluate - Evaluates the binding.
|
|
169
|
-
* @param isVolatile - Indicates whether the binding is volatile.
|
|
170
|
-
*/
|
|
171
|
-
constructor(evaluate: Expression<TSource, TReturn, TParent>, isVolatile?: boolean);
|
|
172
|
-
/**
|
|
173
|
-
* Creates an observer capable of notifying a subscriber when the output of a binding changes.
|
|
174
|
-
* @param directive - The HTML Directive to create the observer for.
|
|
175
|
-
* @param subscriber - The subscriber to changes in the binding.
|
|
176
|
-
*/
|
|
177
|
-
abstract createObserver(directive: HTMLDirective, subscriber: Subscriber): ExpressionObserver<TSource, TReturn, TParent>;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* The type of HTML aspect to target.
|
|
181
|
-
* @public
|
|
182
|
-
*/
|
|
183
|
-
export declare const Aspect: Readonly<{
|
|
184
|
-
/**
|
|
185
|
-
* Not aspected.
|
|
186
|
-
*/
|
|
187
|
-
readonly none: 0;
|
|
188
|
-
/**
|
|
189
|
-
* An attribute.
|
|
190
|
-
*/
|
|
191
|
-
readonly attribute: 1;
|
|
192
|
-
/**
|
|
193
|
-
* A boolean attribute.
|
|
194
|
-
*/
|
|
195
|
-
readonly booleanAttribute: 2;
|
|
196
|
-
/**
|
|
197
|
-
* A property.
|
|
198
|
-
*/
|
|
199
|
-
readonly property: 3;
|
|
200
|
-
/**
|
|
201
|
-
* Content
|
|
202
|
-
*/
|
|
203
|
-
readonly content: 4;
|
|
204
|
-
/**
|
|
205
|
-
* A token list.
|
|
206
|
-
*/
|
|
207
|
-
readonly tokenList: 5;
|
|
208
|
-
/**
|
|
209
|
-
* An event.
|
|
210
|
-
*/
|
|
211
|
-
readonly event: 6;
|
|
212
145
|
/**
|
|
213
146
|
*
|
|
214
147
|
* @param directive - The directive to assign the aspect to.
|
|
@@ -216,49 +149,20 @@ export declare const Aspect: Readonly<{
|
|
|
216
149
|
* @remarks
|
|
217
150
|
* If a falsy value is provided, then the content aspect will be assigned.
|
|
218
151
|
*/
|
|
219
|
-
|
|
152
|
+
assignAspect(directive: Aspected, value?: string): void;
|
|
220
153
|
}>;
|
|
221
154
|
/**
|
|
222
|
-
*
|
|
223
|
-
* @
|
|
224
|
-
*/
|
|
225
|
-
export declare type Aspect = typeof Aspect[Exclude<keyof typeof Aspect, "assign" | "none">];
|
|
226
|
-
/**
|
|
227
|
-
* Represents something that applies to a specific aspect of the DOM.
|
|
155
|
+
* Decorator: Defines an HTMLDirective.
|
|
156
|
+
* @param options - Provides options that specify the directive's application.
|
|
228
157
|
* @public
|
|
229
158
|
*/
|
|
230
|
-
export
|
|
231
|
-
/**
|
|
232
|
-
* The original source aspect exactly as represented in markup.
|
|
233
|
-
*/
|
|
234
|
-
sourceAspect: string;
|
|
235
|
-
/**
|
|
236
|
-
* The evaluated target aspect, determined after processing the source.
|
|
237
|
-
*/
|
|
238
|
-
targetAspect: string;
|
|
239
|
-
/**
|
|
240
|
-
* The type of aspect to target.
|
|
241
|
-
*/
|
|
242
|
-
aspectType: Aspect;
|
|
243
|
-
/**
|
|
244
|
-
* A binding if one is associated with the aspect.
|
|
245
|
-
*/
|
|
246
|
-
dataBinding?: Binding;
|
|
247
|
-
}
|
|
159
|
+
export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition): (type: Constructable<HTMLDirective>) => void;
|
|
248
160
|
/**
|
|
249
161
|
* A base class used for attribute directives that don't need internal state.
|
|
250
162
|
* @public
|
|
251
163
|
*/
|
|
252
164
|
export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
|
|
253
165
|
protected options: TOptions;
|
|
254
|
-
/**
|
|
255
|
-
* The unique id of the factory.
|
|
256
|
-
*/
|
|
257
|
-
id: string;
|
|
258
|
-
/**
|
|
259
|
-
* The structural id of the DOM node to which the created behavior will apply.
|
|
260
|
-
*/
|
|
261
|
-
nodeId: string;
|
|
262
166
|
/**
|
|
263
167
|
* Creates an instance of RefDirective.
|
|
264
168
|
* @param options - The options to use in configuring the directive.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -36,7 +36,17 @@ export declare const elements: (selector?: string) => ElementsFilter;
|
|
|
36
36
|
* Internally used by the SlottedDirective and the ChildrenDirective.
|
|
37
37
|
*/
|
|
38
38
|
export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
|
|
39
|
-
private
|
|
39
|
+
private _id;
|
|
40
|
+
private _controllerProperty;
|
|
41
|
+
/**
|
|
42
|
+
* The unique id of the factory.
|
|
43
|
+
*/
|
|
44
|
+
get id(): string;
|
|
45
|
+
set id(value: string);
|
|
46
|
+
/**
|
|
47
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
48
|
+
*/
|
|
49
|
+
targetNodeId: string;
|
|
40
50
|
/**
|
|
41
51
|
* Bind this behavior to the source.
|
|
42
52
|
* @param source - The source to bind to.
|
|
@@ -5,6 +5,10 @@ import type { CaptureType } from "./template.js";
|
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
7
|
export declare class RefDirective extends StatelessAttachedAttributeDirective<string> {
|
|
8
|
+
/**
|
|
9
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
10
|
+
*/
|
|
11
|
+
targetNodeId: string;
|
|
8
12
|
/**
|
|
9
13
|
* Bind this behavior.
|
|
10
14
|
* @param controller - The view controller that manages the lifecycle of this behavior.
|