@microsoft/fast-element 1.10.5 → 2.0.0-beta.10
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 -12
- package/CHANGELOG.json +629 -6
- package/CHANGELOG.md +152 -5
- package/dist/dts/components/attributes.d.ts +14 -1
- package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +32 -32
- package/dist/dts/components/fast-definitions.d.ts +51 -11
- package/dist/dts/components/fast-element.d.ts +18 -23
- package/dist/dts/context.d.ts +157 -0
- package/dist/{esm/observation/behavior.js → dts/debug.d.ts} +0 -0
- package/dist/dts/di/di.d.ts +899 -0
- package/dist/dts/index.d.ts +17 -16
- package/dist/dts/index.debug.d.ts +2 -0
- package/dist/dts/index.rollup.d.ts +2 -0
- package/dist/dts/index.rollup.debug.d.ts +3 -0
- package/dist/dts/interfaces.d.ts +176 -0
- package/dist/dts/metadata.d.ts +25 -0
- package/dist/dts/observation/arrays.d.ts +207 -0
- package/dist/dts/observation/notifier.d.ts +18 -18
- package/dist/dts/observation/observable.d.ts +117 -34
- package/dist/dts/observation/update-queue.d.ts +40 -0
- package/dist/dts/pending-task.d.ts +20 -0
- package/dist/dts/platform.d.ts +23 -66
- package/dist/dts/polyfills.d.ts +8 -0
- 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 +44 -6
- package/dist/dts/styles/css.d.ts +19 -3
- package/dist/dts/styles/element-styles.d.ts +49 -63
- package/dist/dts/styles/host.d.ts +68 -0
- package/dist/dts/templating/binding-signal.d.ts +21 -0
- package/dist/dts/templating/binding-two-way.d.ts +39 -0
- package/dist/dts/templating/binding.d.ts +101 -70
- package/dist/dts/templating/children.d.ts +18 -15
- package/dist/dts/templating/compiler.d.ts +46 -28
- package/dist/dts/templating/dom.d.ts +41 -0
- package/dist/dts/templating/html-directive.d.ts +239 -45
- package/dist/dts/templating/markup.d.ts +48 -0
- package/dist/dts/templating/node-observation.d.ts +45 -30
- package/dist/dts/templating/ref.d.ts +6 -20
- package/dist/dts/templating/render.d.ts +272 -0
- package/dist/dts/templating/repeat.d.ts +36 -33
- package/dist/dts/templating/slotted.d.ts +13 -14
- package/dist/dts/templating/template.d.ts +28 -22
- package/dist/dts/templating/view.d.ts +82 -24
- package/dist/dts/templating/when.d.ts +3 -3
- package/dist/dts/testing/exports.d.ts +3 -0
- package/dist/dts/testing/fakes.d.ts +4 -0
- package/dist/dts/testing/fixture.d.ts +84 -0
- package/dist/dts/testing/timeout.d.ts +7 -0
- package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +1 -1
- package/dist/dts/utilities.d.ts +22 -0
- package/dist/esm/components/attributes.js +38 -28
- package/dist/esm/components/{controller.js → element-controller.js} +150 -140
- package/dist/esm/components/fast-definitions.js +48 -46
- package/dist/esm/components/fast-element.js +31 -12
- package/dist/esm/context.js +163 -0
- package/dist/esm/debug.js +61 -0
- package/dist/esm/di/di.js +1435 -0
- package/dist/esm/index.debug.js +2 -0
- package/dist/esm/index.js +20 -14
- package/dist/esm/index.rollup.debug.js +3 -0
- package/dist/esm/index.rollup.js +2 -0
- package/dist/esm/interfaces.js +12 -1
- package/dist/esm/metadata.js +60 -0
- package/dist/esm/observation/arrays.js +570 -0
- package/dist/esm/observation/notifier.js +27 -35
- package/dist/esm/observation/observable.js +116 -149
- package/dist/esm/observation/update-queue.js +67 -0
- package/dist/esm/pending-task.js +16 -0
- package/dist/esm/platform.js +60 -42
- package/dist/esm/polyfills.js +85 -0
- 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-directive.js +29 -13
- package/dist/esm/styles/css.js +29 -42
- package/dist/esm/styles/element-styles.js +79 -104
- package/dist/esm/styles/host.js +1 -0
- package/dist/esm/templating/binding-signal.js +83 -0
- package/dist/esm/templating/binding-two-way.js +103 -0
- package/dist/esm/templating/binding.js +189 -159
- package/dist/esm/templating/children.js +33 -23
- package/dist/esm/templating/compiler.js +258 -152
- package/dist/esm/templating/dom.js +49 -0
- package/dist/esm/templating/html-directive.js +193 -36
- package/dist/esm/templating/markup.js +75 -0
- package/dist/esm/templating/node-observation.js +51 -45
- package/dist/esm/templating/ref.js +8 -25
- package/dist/esm/templating/render.js +391 -0
- package/dist/esm/templating/repeat.js +83 -79
- package/dist/esm/templating/slotted.js +23 -20
- package/dist/esm/templating/template.js +51 -93
- package/dist/esm/templating/view.js +125 -46
- package/dist/esm/templating/when.js +6 -4
- package/dist/esm/testing/exports.js +3 -0
- package/dist/esm/testing/fakes.js +76 -0
- package/dist/esm/testing/fixture.js +86 -0
- package/dist/esm/testing/timeout.js +24 -0
- package/dist/esm/utilities.js +44 -0
- package/dist/fast-element.api.json +12153 -5373
- package/dist/fast-element.d.ts +1448 -696
- package/dist/fast-element.debug.js +4107 -0
- package/dist/fast-element.debug.min.js +1 -0
- package/dist/fast-element.js +3817 -4029
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +2814 -0
- package/docs/api-report.md +567 -254
- package/docs/fast-element-2-changes.md +15 -0
- package/karma.conf.cjs +6 -17
- package/package.json +76 -15
- package/dist/dts/dom.d.ts +0 -112
- package/dist/dts/observation/array-change-records.d.ts +0 -48
- package/dist/dts/observation/array-observer.d.ts +0 -9
- package/dist/dts/observation/behavior.d.ts +0 -19
- package/dist/esm/dom.js +0 -207
- package/dist/esm/observation/array-change-records.js +0 -326
- package/dist/esm/observation/array-observer.js +0 -177
package/dist/dts/styles/css.d.ts
CHANGED
|
@@ -6,13 +6,29 @@ import { ComposableStyles, ElementStyles } from "./element-styles.js";
|
|
|
6
6
|
* @param values - The values that are interpolated with the string fragments.
|
|
7
7
|
* @remarks
|
|
8
8
|
* The css helper supports interpolation of strings and ElementStyle instances.
|
|
9
|
+
* Use the .partial method to create partial CSS fragments.
|
|
9
10
|
* @public
|
|
10
11
|
*/
|
|
11
|
-
export declare
|
|
12
|
+
export declare type CSSTemplateTag = ((strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]) => ElementStyles) & {
|
|
13
|
+
/**
|
|
14
|
+
* Transforms a template literal string into partial CSS.
|
|
15
|
+
* @param strings - The string fragments that are interpolated with the values.
|
|
16
|
+
* @param values - The values that are interpolated with the string fragments.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
partial(strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]): CSSDirective;
|
|
20
|
+
};
|
|
12
21
|
/**
|
|
13
|
-
* Transforms a template literal string into
|
|
22
|
+
* Transforms a template literal string into styles.
|
|
14
23
|
* @param strings - The string fragments that are interpolated with the values.
|
|
15
24
|
* @param values - The values that are interpolated with the string fragments.
|
|
25
|
+
* @remarks
|
|
26
|
+
* The css helper supports interpolation of strings and ElementStyle instances.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare const css: CSSTemplateTag;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Use css.partial instead.
|
|
16
32
|
* @public
|
|
17
33
|
*/
|
|
18
|
-
export declare
|
|
34
|
+
export declare const cssPartial: (strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]) => CSSDirective;
|
|
@@ -1,55 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
* A node that can be targeted by styles.
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export interface StyleTarget {
|
|
7
|
-
/**
|
|
8
|
-
* Stylesheets to be adopted by the node.
|
|
9
|
-
*/
|
|
10
|
-
adoptedStyleSheets?: CSSStyleSheet[];
|
|
11
|
-
/**
|
|
12
|
-
* Adds styles to the target by appending the styles.
|
|
13
|
-
* @param styles - The styles element to add.
|
|
14
|
-
*/
|
|
15
|
-
append(styles: HTMLStyleElement): void;
|
|
16
|
-
/**
|
|
17
|
-
* Adds styles to the target by prepending the styles.
|
|
18
|
-
* @param styles - The styles element to add.
|
|
19
|
-
* @deprecated - use append()
|
|
20
|
-
*/
|
|
21
|
-
prepend(styles: HTMLStyleElement): void;
|
|
22
|
-
/**
|
|
23
|
-
* Removes styles from the target.
|
|
24
|
-
* @param styles - The styles element to remove.
|
|
25
|
-
*/
|
|
26
|
-
removeChild(styles: HTMLStyleElement): void;
|
|
27
|
-
/**
|
|
28
|
-
* Returns all element descendants of node that match selectors.
|
|
29
|
-
* @param selectors - The CSS selector to use for the query.
|
|
30
|
-
*/
|
|
31
|
-
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
|
|
32
|
-
}
|
|
1
|
+
import { StyleStrategy, StyleTarget } from "../interfaces.js";
|
|
2
|
+
import type { HostBehavior } from "./host.js";
|
|
33
3
|
/**
|
|
34
4
|
* Represents styles that can be composed into the ShadowDOM of a custom element.
|
|
35
5
|
* @public
|
|
36
6
|
*/
|
|
37
7
|
export declare type ComposableStyles = string | ElementStyles | CSSStyleSheet;
|
|
38
8
|
/**
|
|
39
|
-
*
|
|
9
|
+
* A type that instantiates a StyleStrategy.
|
|
40
10
|
* @public
|
|
41
11
|
*/
|
|
42
|
-
export declare type
|
|
12
|
+
export declare type ConstructibleStyleStrategy = {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of the strategy.
|
|
15
|
+
* @param styles - The styles to initialize the strategy with.
|
|
16
|
+
*/
|
|
17
|
+
new (styles: (string | CSSStyleSheet)[]): StyleStrategy;
|
|
18
|
+
};
|
|
43
19
|
/**
|
|
44
20
|
* Represents styles that can be applied to a custom element.
|
|
45
21
|
* @public
|
|
46
22
|
*/
|
|
47
|
-
export declare
|
|
23
|
+
export declare class ElementStyles {
|
|
24
|
+
readonly styles: ReadonlyArray<ComposableStyles>;
|
|
48
25
|
private targets;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
26
|
+
private _strategy;
|
|
27
|
+
/**
|
|
28
|
+
* The behaviors associated with this set of styles.
|
|
29
|
+
*/
|
|
30
|
+
readonly behaviors: ReadonlyArray<HostBehavior<HTMLElement>> | null;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the StyleStrategy associated with these element styles.
|
|
33
|
+
*/
|
|
34
|
+
get strategy(): StyleStrategy;
|
|
35
|
+
/**
|
|
36
|
+
* Creates an instance of ElementStyles.
|
|
37
|
+
* @param styles - The styles that will be associated with elements.
|
|
38
|
+
*/
|
|
39
|
+
constructor(styles: ReadonlyArray<ComposableStyles>);
|
|
53
40
|
/** @internal */
|
|
54
41
|
addStylesTo(target: StyleTarget): void;
|
|
55
42
|
/** @internal */
|
|
@@ -60,11 +47,27 @@ export declare abstract class ElementStyles {
|
|
|
60
47
|
* Associates behaviors with this set of styles.
|
|
61
48
|
* @param behaviors - The behaviors to associate.
|
|
62
49
|
*/
|
|
63
|
-
withBehaviors(...behaviors:
|
|
50
|
+
withBehaviors(...behaviors: HostBehavior<HTMLElement>[]): this;
|
|
64
51
|
/**
|
|
65
|
-
*
|
|
52
|
+
* Sets the strategy that handles adding/removing these styles for an element.
|
|
53
|
+
* @param strategy - The strategy to use.
|
|
66
54
|
*/
|
|
67
|
-
|
|
55
|
+
withStrategy(Strategy: ConstructibleStyleStrategy): this;
|
|
56
|
+
/**
|
|
57
|
+
* Sets the default strategy type to use when creating style strategies.
|
|
58
|
+
* @param Strategy - The strategy type to construct.
|
|
59
|
+
*/
|
|
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;
|
|
67
|
+
/**
|
|
68
|
+
* Indicates whether the DOM supports the adoptedStyleSheets feature.
|
|
69
|
+
*/
|
|
70
|
+
static readonly supportsAdoptedStyleSheets: boolean;
|
|
68
71
|
}
|
|
69
72
|
/**
|
|
70
73
|
* https://wicg.github.io/construct-stylesheets/
|
|
@@ -72,27 +75,10 @@ export declare abstract class ElementStyles {
|
|
|
72
75
|
*
|
|
73
76
|
* @internal
|
|
74
77
|
*/
|
|
75
|
-
export declare class
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
private get styleSheets();
|
|
80
|
-
readonly behaviors: ReadonlyArray<Behavior> | null;
|
|
81
|
-
constructor(styles: ComposableStyles[], styleSheetCache: Map<string, CSSStyleSheet>);
|
|
82
|
-
addStylesTo(target: StyleTarget): void;
|
|
83
|
-
removeStylesFrom(target: StyleTarget): void;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* @internal
|
|
87
|
-
*/
|
|
88
|
-
export declare class StyleElementStyles extends ElementStyles {
|
|
89
|
-
styles: ComposableStyles[];
|
|
90
|
-
private readonly styleSheets;
|
|
91
|
-
private readonly styleClass;
|
|
92
|
-
readonly behaviors: ReadonlyArray<Behavior> | null;
|
|
93
|
-
constructor(styles: ComposableStyles[]);
|
|
78
|
+
export declare class AdoptedStyleSheetsStrategy implements StyleStrategy {
|
|
79
|
+
/** @internal */
|
|
80
|
+
readonly sheets: CSSStyleSheet[];
|
|
81
|
+
constructor(styles: (string | CSSStyleSheet)[]);
|
|
94
82
|
addStylesTo(target: StyleTarget): void;
|
|
95
83
|
removeStylesFrom(target: StyleTarget): void;
|
|
96
|
-
isAttachedTo(target: StyleTarget): boolean;
|
|
97
|
-
private normalizeTarget;
|
|
98
84
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ElementStyles } from "./element-styles.js";
|
|
2
|
+
/**
|
|
3
|
+
* Controls the lifecycle and context of behaviors and styles
|
|
4
|
+
* associated with a component host.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface HostController<TSource = any> {
|
|
8
|
+
/**
|
|
9
|
+
* The component source.
|
|
10
|
+
*/
|
|
11
|
+
readonly source: TSource;
|
|
12
|
+
/**
|
|
13
|
+
* Indicates whether the host is connected or not.
|
|
14
|
+
*/
|
|
15
|
+
readonly isConnected: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The main set of styles used for the component, independent
|
|
18
|
+
* of any behavior-specific styles.
|
|
19
|
+
*/
|
|
20
|
+
mainStyles: ElementStyles | null;
|
|
21
|
+
/**
|
|
22
|
+
* Adds the behavior to the component.
|
|
23
|
+
* @param behavior - The behavior to add.
|
|
24
|
+
*/
|
|
25
|
+
addBehavior(behavior: HostBehavior<TSource>): void;
|
|
26
|
+
/**
|
|
27
|
+
* Removes the behavior from the component.
|
|
28
|
+
* @param behavior - The behavior to remove.
|
|
29
|
+
* @param force - Forces removal even if this behavior was added more than once.
|
|
30
|
+
*/
|
|
31
|
+
removeBehavior(behavior: HostBehavior<TSource>, force?: boolean): void;
|
|
32
|
+
/**
|
|
33
|
+
* Adds styles to this element. Providing an HTMLStyleElement will attach the element instance to the shadowRoot.
|
|
34
|
+
* @param styles - The styles to add.
|
|
35
|
+
*/
|
|
36
|
+
addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
|
|
37
|
+
/**
|
|
38
|
+
* Removes styles from this element. Providing an HTMLStyleElement will detach the element instance from the shadowRoot.
|
|
39
|
+
* @param styles - the styles to remove.
|
|
40
|
+
*/
|
|
41
|
+
removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Represents an object that can contribute behavior to a host.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export interface HostBehavior<TSource = any> {
|
|
48
|
+
/**
|
|
49
|
+
* Executed when this behavior is attached to a controller.
|
|
50
|
+
* @param controller - Controls the behavior lifecycle.
|
|
51
|
+
*/
|
|
52
|
+
addedCallback?(controller: HostController<TSource>): void;
|
|
53
|
+
/**
|
|
54
|
+
* Executed when this behavior is detached from a controller.
|
|
55
|
+
* @param controller - Controls the behavior lifecycle.
|
|
56
|
+
*/
|
|
57
|
+
removedCallback?(controller: HostController<TSource>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Executed when this behavior's host is connected.
|
|
60
|
+
* @param controller - Controls the behavior lifecycle.
|
|
61
|
+
*/
|
|
62
|
+
connectedCallback?(controller: HostController<TSource>): void;
|
|
63
|
+
/**
|
|
64
|
+
* Executed when this behavior's host is disconnected.
|
|
65
|
+
* @param controller - Controls the behavior lifecycle.
|
|
66
|
+
*/
|
|
67
|
+
disconnectedCallback?(controller: HostController<TSource>): void;
|
|
68
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Expression } from "../observation/observable.js";
|
|
2
|
+
import type { Subscriber } from "../observation/notifier.js";
|
|
3
|
+
import { Binding } from "./html-directive.js";
|
|
4
|
+
export declare const Signal: Readonly<{
|
|
5
|
+
subscribe(signal: string, subscriber: Subscriber): void;
|
|
6
|
+
unsubscribe(signal: string, subscriber: Subscriber): void;
|
|
7
|
+
/**
|
|
8
|
+
* Sends the specified signal to signaled bindings.
|
|
9
|
+
* @param signal - The signal to send.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
send(signal: string): void;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a signal binding configuration with the supplied options.
|
|
16
|
+
* @param expression - The binding to refresh when signaled.
|
|
17
|
+
* @param options - The signal name or a binding to use to retrieve the signal name.
|
|
18
|
+
* @returns A binding configuration.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function signal<T = any>(expression: Expression<T>, options: string | Expression<T>): Binding<T>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Expression } from "../observation/observable.js";
|
|
2
|
+
import type { HTMLBindingDirective } from "./binding.js";
|
|
3
|
+
import { Binding } from "./html-directive.js";
|
|
4
|
+
/**
|
|
5
|
+
* The twoWay binding options.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare type TwoWayBindingOptions = {
|
|
9
|
+
changeEvent?: string;
|
|
10
|
+
fromView?: (value: any) => any;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The settings required to enable two-way binding.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface TwoWaySettings {
|
|
17
|
+
/**
|
|
18
|
+
* Determines which event to listen to, to detect changes in the view.
|
|
19
|
+
* @param directive - The directive to determine the change event for.
|
|
20
|
+
* @param target - The target element to determine the change event for.
|
|
21
|
+
*/
|
|
22
|
+
determineChangeEvent(directive: HTMLBindingDirective, target: HTMLElement): string;
|
|
23
|
+
}
|
|
24
|
+
export declare const TwoWaySettings: Readonly<{
|
|
25
|
+
/**
|
|
26
|
+
* Configures two-way binding.
|
|
27
|
+
* @param settings - The settings to use for the two-way binding system.
|
|
28
|
+
*/
|
|
29
|
+
configure(settings: TwoWaySettings): void;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a default binding.
|
|
33
|
+
* @param expression - The binding to refresh when changed.
|
|
34
|
+
* @param optionsOrChangeEvent - The binding options or the name of the change event to use.
|
|
35
|
+
* @param isBindingVolatile - Indicates whether the binding is volatile or not.
|
|
36
|
+
* @returns A binding.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare function twoWay<T = any>(expression: Expression<T>, optionsOrChangeEvent?: TwoWayBindingOptions | string, isBindingVolatile?: boolean): Binding<T>;
|
|
@@ -1,95 +1,126 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Binding,
|
|
3
|
-
import { TargetedHTMLDirective } from "./html-directive.js";
|
|
4
|
-
declare function normalBind(this: BindingBehavior, source: unknown, context: ExecutionContext): void;
|
|
5
|
-
declare function normalUnbind(this: BindingBehavior): void;
|
|
6
|
-
declare function updatePropertyTarget(this: BindingBehavior, value: unknown): void;
|
|
1
|
+
import { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
|
|
2
|
+
import { AddViewBehaviorFactory, Aspect, Aspected, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
|
|
7
3
|
/**
|
|
8
|
-
* A
|
|
4
|
+
* A simple View that can be interpolated into HTML content.
|
|
9
5
|
* @public
|
|
10
6
|
*/
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
private cleanedTargetName?;
|
|
14
|
-
private originalTargetName?;
|
|
15
|
-
private bind;
|
|
16
|
-
private unbind;
|
|
17
|
-
private updateTarget;
|
|
18
|
-
private isBindingVolatile;
|
|
7
|
+
export interface ContentView {
|
|
8
|
+
readonly context: ExecutionContext;
|
|
19
9
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @param
|
|
10
|
+
* Binds a view's behaviors to its binding source.
|
|
11
|
+
* @param source - The binding source for the view's binding behaviors.
|
|
12
|
+
* @param context - The execution context to run the view within.
|
|
22
13
|
*/
|
|
23
|
-
|
|
14
|
+
bind(source: any, context?: ExecutionContext): void;
|
|
24
15
|
/**
|
|
25
|
-
*
|
|
26
|
-
* binding is targeting.
|
|
16
|
+
* Unbinds a view's behaviors from its binding source and context.
|
|
27
17
|
*/
|
|
28
|
-
|
|
29
|
-
set targetName(value: string | undefined);
|
|
18
|
+
unbind(): void;
|
|
30
19
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
20
|
+
* Inserts the view's DOM nodes before the referenced node.
|
|
21
|
+
* @param node - The node to insert the view's DOM before.
|
|
33
22
|
*/
|
|
34
|
-
|
|
23
|
+
insertBefore(node: Node): void;
|
|
35
24
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @param target - The target node that the binding behavior should attach to.
|
|
25
|
+
* Removes the view's DOM nodes.
|
|
26
|
+
* The nodes are not disposed and the view can later be re-inserted.
|
|
39
27
|
*/
|
|
40
|
-
|
|
28
|
+
remove(): void;
|
|
41
29
|
}
|
|
42
30
|
/**
|
|
43
|
-
* A
|
|
44
|
-
* BindingDirective.
|
|
31
|
+
* A simple template that can create ContentView instances.
|
|
45
32
|
* @public
|
|
46
33
|
*/
|
|
47
|
-
export
|
|
48
|
-
/** @internal */
|
|
49
|
-
source: unknown;
|
|
50
|
-
/** @internal */
|
|
51
|
-
context: ExecutionContext | null;
|
|
52
|
-
/** @internal */
|
|
53
|
-
bindingObserver: BindingObserver | null;
|
|
54
|
-
/** @internal */
|
|
55
|
-
classVersions: Record<string, number>;
|
|
56
|
-
/** @internal */
|
|
57
|
-
version: number;
|
|
58
|
-
/** @internal */
|
|
59
|
-
target: any;
|
|
60
|
-
/** @internal */
|
|
61
|
-
binding: Binding;
|
|
62
|
-
/** @internal */
|
|
63
|
-
isBindingVolatile: boolean;
|
|
64
|
-
/** @internal */
|
|
65
|
-
updateTarget: typeof updatePropertyTarget;
|
|
66
|
-
/** @internal */
|
|
67
|
-
targetName?: string;
|
|
34
|
+
export interface ContentTemplate {
|
|
68
35
|
/**
|
|
69
|
-
*
|
|
70
|
-
* @param source - The source to bind to.
|
|
71
|
-
* @param context - The execution context that the binding is operating within.
|
|
36
|
+
* Creates a simple content view instance.
|
|
72
37
|
*/
|
|
73
|
-
|
|
38
|
+
create(): ContentView;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A directive that applies bindings.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected {
|
|
45
|
+
dataBinding: Binding;
|
|
46
|
+
private data;
|
|
47
|
+
private updateTarget;
|
|
48
|
+
/**
|
|
49
|
+
* The unique id of the factory.
|
|
50
|
+
*/
|
|
51
|
+
id: string;
|
|
74
52
|
/**
|
|
75
|
-
*
|
|
76
|
-
* @param source - The source to unbind from.
|
|
53
|
+
* The structural id of the DOM node to which the created behavior will apply.
|
|
77
54
|
*/
|
|
78
|
-
|
|
55
|
+
nodeId: string;
|
|
79
56
|
/**
|
|
80
|
-
*
|
|
81
|
-
* @param target - The target of the data updates.
|
|
82
|
-
* @param binding - The binding that returns the latest value for an update.
|
|
83
|
-
* @param isBindingVolatile - Indicates whether the binding has volatile dependencies.
|
|
84
|
-
* @param bind - The operation to perform during binding.
|
|
85
|
-
* @param unbind - The operation to perform during unbinding.
|
|
86
|
-
* @param updateTarget - The operation to perform when updating.
|
|
87
|
-
* @param targetName - The name of the target attribute or property to update.
|
|
57
|
+
* The original source aspect exactly as represented in markup.
|
|
88
58
|
*/
|
|
89
|
-
|
|
59
|
+
sourceAspect: string;
|
|
60
|
+
/**
|
|
61
|
+
* The evaluated target aspect, determined after processing the source.
|
|
62
|
+
*/
|
|
63
|
+
targetAspect: string;
|
|
64
|
+
/**
|
|
65
|
+
* The type of aspect to target.
|
|
66
|
+
*/
|
|
67
|
+
aspectType: Aspect;
|
|
68
|
+
/**
|
|
69
|
+
* Creates an instance of HTMLBindingDirective.
|
|
70
|
+
* @param dataBinding - The binding configuration to apply.
|
|
71
|
+
*/
|
|
72
|
+
constructor(dataBinding: Binding);
|
|
73
|
+
/**
|
|
74
|
+
* Creates HTML to be used within a template.
|
|
75
|
+
* @param add - Can be used to add behavior factories to a template.
|
|
76
|
+
*/
|
|
77
|
+
createHTML(add: AddViewBehaviorFactory): string;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a behavior.
|
|
80
|
+
*/
|
|
81
|
+
createBehavior(): ViewBehavior;
|
|
82
|
+
/** @internal */
|
|
83
|
+
bindDefault(controller: ViewController): void;
|
|
90
84
|
/** @internal */
|
|
91
|
-
|
|
85
|
+
bind: (controller: ViewController) => void;
|
|
86
|
+
/** @internal */
|
|
87
|
+
bindContent(controller: ViewController): void;
|
|
88
|
+
/** @internal */
|
|
89
|
+
bindEvent(controller: ViewController): void;
|
|
90
|
+
/** @internal */
|
|
91
|
+
unbind(controller: ViewController): void;
|
|
92
92
|
/** @internal */
|
|
93
93
|
handleEvent(event: Event): void;
|
|
94
|
+
/** @internal */
|
|
95
|
+
handleChange(binding: Expression, observer: ExpressionObserver): void;
|
|
94
96
|
}
|
|
95
|
-
|
|
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,16 +1,16 @@
|
|
|
1
|
-
import { NodeBehaviorOptions,
|
|
1
|
+
import { NodeBehaviorOptions, NodeObservationDirective } from "./node-observation.js";
|
|
2
2
|
import type { CaptureType } from "./template.js";
|
|
3
3
|
/**
|
|
4
4
|
* The options used to configure child list observation.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export interface
|
|
7
|
+
export interface ChildListDirectiveOptions<T = any> extends NodeBehaviorOptions<T>, Omit<MutationObserverInit, "subtree" | "childList"> {
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* The options used to configure subtree observation.
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
13
|
-
export interface
|
|
13
|
+
export interface SubtreeDirectiveOptions<T = any> extends NodeBehaviorOptions<T>, Omit<MutationObserverInit, "subtree" | "childList"> {
|
|
14
14
|
/**
|
|
15
15
|
* Indicates that child subtrees should be observed for changes.
|
|
16
16
|
*/
|
|
@@ -25,31 +25,34 @@ export interface SubtreeBehaviorOptions<T = any> extends Omit<NodeBehaviorOption
|
|
|
25
25
|
* The options used to configure child/subtree node observation.
|
|
26
26
|
* @public
|
|
27
27
|
*/
|
|
28
|
-
export declare type
|
|
28
|
+
export declare type ChildrenDirectiveOptions<T = any> = ChildListDirectiveOptions<T> | SubtreeDirectiveOptions<T>;
|
|
29
29
|
/**
|
|
30
30
|
* The runtime behavior for child node observation.
|
|
31
31
|
* @public
|
|
32
32
|
*/
|
|
33
|
-
export declare class
|
|
34
|
-
private
|
|
33
|
+
export declare class ChildrenDirective extends NodeObservationDirective<ChildrenDirectiveOptions> {
|
|
34
|
+
private observerProperty;
|
|
35
35
|
/**
|
|
36
|
-
* Creates an instance of
|
|
37
|
-
* @param
|
|
38
|
-
* @param options - The options to use when observing the element children.
|
|
36
|
+
* Creates an instance of ChildrenDirective.
|
|
37
|
+
* @param options - The options to use in configuring the child observation behavior.
|
|
39
38
|
*/
|
|
40
|
-
constructor(
|
|
39
|
+
constructor(options: ChildrenDirectiveOptions);
|
|
41
40
|
/**
|
|
42
41
|
* Begins observation of the nodes.
|
|
42
|
+
* @param target - The target to observe.
|
|
43
43
|
*/
|
|
44
|
-
observe(): void;
|
|
44
|
+
observe(target: any): void;
|
|
45
45
|
/**
|
|
46
46
|
* Disconnects observation of the nodes.
|
|
47
|
+
* @param target - The target to unobserve.
|
|
47
48
|
*/
|
|
48
|
-
disconnect(): void;
|
|
49
|
+
disconnect(target: any): void;
|
|
49
50
|
/**
|
|
50
|
-
* Retrieves the nodes that should be assigned to the
|
|
51
|
+
* Retrieves the raw nodes that should be assigned to the source property.
|
|
52
|
+
* @param target - The target to get the node to.
|
|
51
53
|
*/
|
|
52
|
-
|
|
54
|
+
getNodes(target: Element): Node[];
|
|
55
|
+
private handleEvent;
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
58
|
* A directive that observes the `childNodes` of an element and updates a property
|
|
@@ -57,4 +60,4 @@ export declare class ChildrenBehavior extends NodeObservationBehavior<ChildrenBe
|
|
|
57
60
|
* @param propertyOrOptions - The options used to configure child node observation.
|
|
58
61
|
* @public
|
|
59
62
|
*/
|
|
60
|
-
export declare function children<
|
|
63
|
+
export declare function children<TSource = any, TParent = any>(propertyOrOptions: (keyof TSource & string) | ChildrenDirectiveOptions<keyof TSource & string>): CaptureType<TSource, TParent>;
|
|
@@ -1,38 +1,56 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TrustedTypesPolicy } from "../interfaces.js";
|
|
2
|
+
import { ViewBehaviorFactory } from "./html-directive.js";
|
|
3
|
+
import type { HTMLTemplateCompilationResult as TemplateCompilationResult } from "./template.js";
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
+
* A function capable of compiling a template from the preprocessed form produced
|
|
6
|
+
* by the html template function into a result that can instantiate views.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare type CompilationStrategy = (
|
|
10
|
+
/**
|
|
11
|
+
* The preprocessed HTML string or template to compile.
|
|
5
12
|
*/
|
|
6
|
-
|
|
13
|
+
html: string | HTMLTemplateElement,
|
|
14
|
+
/**
|
|
15
|
+
* The behavior factories used within the html that is being compiled.
|
|
16
|
+
*/
|
|
17
|
+
factories: Record<string, ViewBehaviorFactory>) => TemplateCompilationResult;
|
|
18
|
+
/**
|
|
19
|
+
* Common APIs related to compilation.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare const Compiler: {
|
|
7
23
|
/**
|
|
8
|
-
*
|
|
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.
|
|
9
29
|
*/
|
|
10
|
-
|
|
30
|
+
setHTMLPolicy(policy: TrustedTypesPolicy): void;
|
|
11
31
|
/**
|
|
12
|
-
*
|
|
32
|
+
* Compiles a template and associated directives into a compilation
|
|
33
|
+
* result which can be used to create views.
|
|
34
|
+
* @param html - The html string or template element to compile.
|
|
35
|
+
* @param directives - The directives referenced by the template.
|
|
36
|
+
* @remarks
|
|
37
|
+
* The template that is provided for compilation is altered in-place
|
|
38
|
+
* and cannot be compiled again. If the original template must be preserved,
|
|
39
|
+
* it is recommended that you clone the original and pass the clone to this API.
|
|
40
|
+
* @public
|
|
13
41
|
*/
|
|
14
|
-
|
|
42
|
+
compile<TSource = any, TParent = any>(html: string | HTMLTemplateElement, directives: Record<string, ViewBehaviorFactory>): TemplateCompilationResult<TSource, TParent>;
|
|
15
43
|
/**
|
|
16
|
-
*
|
|
17
|
-
* the template
|
|
44
|
+
* Sets the default compilation strategy that will be used by the ViewTemplate whenever
|
|
45
|
+
* it needs to compile a view preprocessed with the html template function.
|
|
46
|
+
* @param strategy - The compilation strategy to use when compiling templates.
|
|
18
47
|
*/
|
|
19
|
-
|
|
48
|
+
setDefaultStrategy(strategy: CompilationStrategy): void;
|
|
20
49
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
50
|
+
* Aggregates an array of strings and directives into a single directive.
|
|
51
|
+
* @param parts - A heterogeneous array of static strings interspersed with
|
|
52
|
+
* directives.
|
|
53
|
+
* @returns A single inline directive that aggregates the behavior of all the parts.
|
|
23
54
|
*/
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Compiles a template and associated directives into a raw compilation
|
|
28
|
-
* result which include a cloneable DocumentFragment and factories capable
|
|
29
|
-
* of attaching runtime behavior to nodes within the fragment.
|
|
30
|
-
* @param template - The template to compile.
|
|
31
|
-
* @param directives - The directives referenced by the template.
|
|
32
|
-
* @remarks
|
|
33
|
-
* The template that is provided for compilation is altered in-place
|
|
34
|
-
* and cannot be compiled again. If the original template must be preserved,
|
|
35
|
-
* it is recommended that you clone the original and pass the clone to this API.
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
export declare function compileTemplate(template: HTMLTemplateElement, directives: ReadonlyArray<HTMLDirective>): CompilationResult;
|
|
55
|
+
aggregate(parts: (string | ViewBehaviorFactory)[]): ViewBehaviorFactory;
|
|
56
|
+
};
|