@microsoft/fast-element 2.0.0-beta.19 → 2.0.0-beta.20
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 +45 -0
- package/CHANGELOG.md +14 -1
- package/dist/dts/components/attributes.d.ts +5 -0
- package/dist/dts/components/element-controller.d.ts +1 -1
- package/dist/dts/di/di.d.ts +0 -5
- package/dist/dts/dom.d.ts +0 -16
- package/dist/dts/index.d.ts +2 -2
- package/dist/dts/interfaces.d.ts +17 -60
- package/dist/dts/styles/css.d.ts +0 -5
- package/dist/dts/styles/element-styles.d.ts +1 -1
- package/dist/dts/styles/style-strategy.d.ts +42 -0
- package/dist/dts/templating/template.d.ts +55 -8
- package/dist/esm/components/attributes.js +14 -0
- package/dist/esm/di/di.js +0 -5
- package/dist/esm/dom.js +0 -16
- package/dist/esm/index.js +1 -1
- package/dist/esm/interfaces.js +3 -0
- package/dist/esm/styles/css.js +0 -5
- package/dist/esm/styles/style-strategy.js +1 -0
- package/dist/esm/templating/template.js +43 -3
- package/dist/fast-element.api.json +421 -353
- package/dist/fast-element.d.ts +80 -43
- package/dist/fast-element.debug.js +126 -112
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +126 -112
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +80 -49
- package/docs/api-report.md +28 -24
- package/package.json +1 -1
- package/dist/dts/templating/dangerous-html.d.ts +0 -18
- package/dist/esm/templating/dangerous-html.js +0 -23
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/fast-element",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Wed, 11 Jan 2023 22:07:47 GMT",
|
|
6
|
+
"tag": "@microsoft/fast-element_v2.0.0-beta.20",
|
|
7
|
+
"version": "2.0.0-beta.20",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "863023+radium-v@users.noreply.github.com",
|
|
12
|
+
"package": "@microsoft/fast-element",
|
|
13
|
+
"commit": "555f1b2cd614a1d5a9bc3985fb892d040c110cb3",
|
|
14
|
+
"comment": "add nullableBooleanConverter for attributes"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "chhol@microsoft.com",
|
|
18
|
+
"package": "@microsoft/fast-element",
|
|
19
|
+
"commit": "52cd5171c3e9061af8066443023782bca2b0e59b",
|
|
20
|
+
"comment": "update return type for dangerousHTML to DangerousHTMLDirective"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "rob@bluespire.com",
|
|
24
|
+
"package": "@microsoft/fast-element",
|
|
25
|
+
"commit": "4c58813ec1b770b1f95c1b5993f8e3013a7544e2",
|
|
26
|
+
"comment": "chore: remove deprecated APIs from fast-element"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "roeisenb@microsoft.com",
|
|
30
|
+
"package": "@microsoft/fast-element",
|
|
31
|
+
"commit": "84fd72febb4dff874db9322a6cb27e698b3ec790",
|
|
32
|
+
"comment": "chore: cleanup fast-element interfaces"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"author": "roeisenb@microsoft.com",
|
|
36
|
+
"package": "@microsoft/fast-element",
|
|
37
|
+
"commit": "5c3b2f0431ae8f840d3dc778ff93be73b585c6e2",
|
|
38
|
+
"comment": "refactor(fast-element): replace dangerousHTML with html.partial"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"author": "roeisenb@microsoft.com",
|
|
42
|
+
"package": "@microsoft/fast-element",
|
|
43
|
+
"commit": "d14f697ed3449db50384f5c1304f6bb384f9cfe0",
|
|
44
|
+
"comment": "feat: add ability to inline templates"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
4
49
|
{
|
|
5
50
|
"date": "Fri, 02 Dec 2022 01:18:22 GMT",
|
|
6
51
|
"tag": "@microsoft/fast-element_v2.0.0-beta.19",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
# Change Log - @microsoft/fast-element
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 11 Jan 2023 22:07:47 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 2.0.0-beta.20
|
|
8
|
+
|
|
9
|
+
Wed, 11 Jan 2023 22:07:47 GMT
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- add nullableBooleanConverter for attributes (863023+radium-v@users.noreply.github.com)
|
|
14
|
+
- update return type for dangerousHTML to DangerousHTMLDirective (chhol@microsoft.com)
|
|
15
|
+
- chore: remove deprecated APIs from fast-element (rob@bluespire.com)
|
|
16
|
+
- chore: cleanup fast-element interfaces (roeisenb@microsoft.com)
|
|
17
|
+
- refactor(fast-element): replace dangerousHTML with html.partial (roeisenb@microsoft.com)
|
|
18
|
+
- feat: add ability to inline templates (roeisenb@microsoft.com)
|
|
19
|
+
|
|
7
20
|
## 2.0.0-beta.19
|
|
8
21
|
|
|
9
22
|
Fri, 02 Dec 2022 01:18:22 GMT
|
|
@@ -62,6 +62,11 @@ export declare type DecoratorAttributeConfiguration = Omit<AttributeConfiguratio
|
|
|
62
62
|
* @public
|
|
63
63
|
*/
|
|
64
64
|
export declare const booleanConverter: ValueConverter;
|
|
65
|
+
/**
|
|
66
|
+
* A {@link ValueConverter} that converts to and from `boolean` values. `null`, `undefined`, `""`, and `void` values are converted to `null`.
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export declare const nullableBooleanConverter: ValueConverter;
|
|
65
70
|
/**
|
|
66
71
|
* A {@link ValueConverter} that converts to and from `number` values.
|
|
67
72
|
* @remarks
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { StyleStrategy, StyleTarget } from "../interfaces.js";
|
|
2
1
|
import { PropertyChangeNotifier } from "../observation/notifier.js";
|
|
3
2
|
import { ElementStyles } from "../styles/element-styles.js";
|
|
4
3
|
import type { HostBehavior, HostController } from "../styles/host.js";
|
|
4
|
+
import type { StyleStrategy, StyleTarget } from "../styles/style-strategy.js";
|
|
5
5
|
import type { ElementViewTemplate } from "../templating/template.js";
|
|
6
6
|
import type { ElementView } from "../templating/view.js";
|
|
7
7
|
import { FASTElementDefinition } from "./fast-definitions.js";
|
package/dist/dts/di/di.d.ts
CHANGED
|
@@ -477,11 +477,6 @@ export declare const DI: Readonly<{
|
|
|
477
477
|
* in addition to its standard use in an inject array or through direct container APIs.
|
|
478
478
|
*/
|
|
479
479
|
createContext: typeof createContext;
|
|
480
|
-
/**
|
|
481
|
-
* @deprecated
|
|
482
|
-
* Use DI.createContext instead.
|
|
483
|
-
*/
|
|
484
|
-
createInterface: typeof createContext;
|
|
485
480
|
/**
|
|
486
481
|
* A decorator that specifies what to inject into its target.
|
|
487
482
|
* @param dependencies - The dependencies to inject.
|
package/dist/dts/dom.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Callable } from "./interfaces.js";
|
|
2
1
|
/**
|
|
3
2
|
* The type of HTML aspect to target.
|
|
4
3
|
* @public
|
|
@@ -67,21 +66,6 @@ export interface DOMPolicy {
|
|
|
67
66
|
* @public
|
|
68
67
|
*/
|
|
69
68
|
export declare const DOM: Readonly<{
|
|
70
|
-
/**
|
|
71
|
-
* @deprecated
|
|
72
|
-
* Use Updates.enqueue().
|
|
73
|
-
*/
|
|
74
|
-
queueUpdate: (callable: Callable) => void;
|
|
75
|
-
/**
|
|
76
|
-
* @deprecated
|
|
77
|
-
* Use Updates.next()
|
|
78
|
-
*/
|
|
79
|
-
nextUpdate: () => Promise<void>;
|
|
80
|
-
/**
|
|
81
|
-
* @deprecated
|
|
82
|
-
* Use Updates.process()
|
|
83
|
-
*/
|
|
84
|
-
processUpdates: () => void;
|
|
85
69
|
/**
|
|
86
70
|
* Gets the dom policy used by the templating system.
|
|
87
71
|
*/
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Callable, Constructable, Disposable, FASTGlobal,
|
|
1
|
+
export type { Callable, Constructable, Class, Disposable, FASTGlobal, TrustedTypesPolicy, } from "./interfaces.js";
|
|
2
2
|
export * from "./platform.js";
|
|
3
3
|
export * from "./dom.js";
|
|
4
4
|
export * from "./observation/observable.js";
|
|
@@ -9,6 +9,7 @@ export * from "./styles/element-styles.js";
|
|
|
9
9
|
export * from "./styles/css.js";
|
|
10
10
|
export * from "./styles/css-directive.js";
|
|
11
11
|
export * from "./styles/host.js";
|
|
12
|
+
export * from "./styles/style-strategy.js";
|
|
12
13
|
export * from "./templating/template.js";
|
|
13
14
|
export * from "./templating/compiler.js";
|
|
14
15
|
export { Markup, Parser } from "./templating/markup.js";
|
|
@@ -21,7 +22,6 @@ export * from "./templating/slotted.js";
|
|
|
21
22
|
export * from "./templating/children.js";
|
|
22
23
|
export * from "./templating/view.js";
|
|
23
24
|
export * from "./templating/node-observation.js";
|
|
24
|
-
export * from "./templating/dangerous-html.js";
|
|
25
25
|
export * from "./components/fast-element.js";
|
|
26
26
|
export * from "./components/fast-definitions.js";
|
|
27
27
|
export * from "./components/attributes.js";
|
package/dist/dts/interfaces.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare type Callable = typeof Function.prototype.call | {
|
|
|
6
6
|
call(): void;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Represents a type which can be constructed with the new operator.
|
|
10
10
|
*
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
@@ -14,18 +14,14 @@ export declare type Constructable<T = {}> = {
|
|
|
14
14
|
new (...args: any[]): T;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* Represents a class.
|
|
17
|
+
* Represents a constructable class with a prototype.
|
|
18
18
|
* @public
|
|
19
19
|
*/
|
|
20
|
-
export declare type Class<T, C = {}> = C & {
|
|
20
|
+
export declare type Class<T, C = {}> = C & Constructable<T> & {
|
|
21
21
|
/**
|
|
22
22
|
* The class's prototype;
|
|
23
23
|
*/
|
|
24
24
|
readonly prototype: T;
|
|
25
|
-
/**
|
|
26
|
-
* The class's constructor.
|
|
27
|
-
*/
|
|
28
|
-
new (...args: any[]): T;
|
|
29
25
|
};
|
|
30
26
|
/**
|
|
31
27
|
* Provides a mechanism for releasing resources.
|
|
@@ -37,6 +33,17 @@ export interface Disposable {
|
|
|
37
33
|
*/
|
|
38
34
|
dispose(): void;
|
|
39
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* A policy for use with the standard trustedTypes platform API.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare type TrustedTypesPolicy = {
|
|
41
|
+
/**
|
|
42
|
+
* Creates trusted HTML.
|
|
43
|
+
* @param html - The HTML to clear as trustworthy.
|
|
44
|
+
*/
|
|
45
|
+
createHTML(html: string): string;
|
|
46
|
+
};
|
|
40
47
|
/**
|
|
41
48
|
* Reverses all readonly members, making them mutable.
|
|
42
49
|
* @internal
|
|
@@ -93,48 +100,6 @@ declare type KernelServiceId = {
|
|
|
93
100
|
};
|
|
94
101
|
declare let KernelServiceId: KernelServiceId;
|
|
95
102
|
export { KernelServiceId };
|
|
96
|
-
/**
|
|
97
|
-
* A node that can be targeted by styles.
|
|
98
|
-
* @public
|
|
99
|
-
*/
|
|
100
|
-
export interface StyleTarget extends Pick<Node, "getRootNode"> {
|
|
101
|
-
/**
|
|
102
|
-
* Stylesheets to be adopted by the node.
|
|
103
|
-
*/
|
|
104
|
-
adoptedStyleSheets?: CSSStyleSheet[];
|
|
105
|
-
/**
|
|
106
|
-
* Adds styles to the target by appending the styles.
|
|
107
|
-
* @param styles - The styles element to add.
|
|
108
|
-
*/
|
|
109
|
-
append(styles: HTMLStyleElement): void;
|
|
110
|
-
/**
|
|
111
|
-
* Removes styles from the target.
|
|
112
|
-
* @param styles - The styles element to remove.
|
|
113
|
-
*/
|
|
114
|
-
removeChild(styles: HTMLStyleElement): void;
|
|
115
|
-
/**
|
|
116
|
-
* Returns all element descendants of node that match selectors.
|
|
117
|
-
* @param selectors - The CSS selector to use for the query.
|
|
118
|
-
*/
|
|
119
|
-
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Implemented to provide specific behavior when adding/removing styles
|
|
123
|
-
* for elements.
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
|
-
export interface StyleStrategy {
|
|
127
|
-
/**
|
|
128
|
-
* Adds styles to the target.
|
|
129
|
-
* @param target - The target to add the styles to.
|
|
130
|
-
*/
|
|
131
|
-
addStylesTo(target: StyleTarget): void;
|
|
132
|
-
/**
|
|
133
|
-
* Removes styles from the target.
|
|
134
|
-
* @param target - The target to remove the styles from.
|
|
135
|
-
*/
|
|
136
|
-
removeStylesFrom(target: StyleTarget): void;
|
|
137
|
-
}
|
|
138
103
|
/**
|
|
139
104
|
* Warning and error messages.
|
|
140
105
|
* @internal
|
|
@@ -166,25 +131,17 @@ export declare const enum Message {
|
|
|
166
131
|
connectUpdateRequiresController = 1514
|
|
167
132
|
}
|
|
168
133
|
/**
|
|
134
|
+
* Determines whether or not an object is a function.
|
|
169
135
|
* @internal
|
|
170
136
|
*/
|
|
171
137
|
export declare const isFunction: (object: any) => object is Function;
|
|
172
138
|
/**
|
|
139
|
+
* Determines whether or not an object is a string.
|
|
173
140
|
* @internal
|
|
174
141
|
*/
|
|
175
142
|
export declare const isString: (object: any) => object is string;
|
|
176
143
|
/**
|
|
144
|
+
* A function which does nothing.
|
|
177
145
|
* @internal
|
|
178
146
|
*/
|
|
179
147
|
export declare const noop: () => undefined;
|
|
180
|
-
/**
|
|
181
|
-
* A policy for use with the standard trustedTypes platform API.
|
|
182
|
-
* @public
|
|
183
|
-
*/
|
|
184
|
-
export declare type TrustedTypesPolicy = {
|
|
185
|
-
/**
|
|
186
|
-
* Creates trusted HTML.
|
|
187
|
-
* @param html - The HTML to clear as trustworthy.
|
|
188
|
-
*/
|
|
189
|
-
createHTML(html: string): string;
|
|
190
|
-
};
|
package/dist/dts/styles/css.d.ts
CHANGED
|
@@ -27,8 +27,3 @@ export declare type CSSTemplateTag = ((strings: TemplateStringsArray, ...values:
|
|
|
27
27
|
* @public
|
|
28
28
|
*/
|
|
29
29
|
export declare const css: CSSTemplateTag;
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated Use css.partial instead.
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare const cssPartial: (strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]) => CSSDirective;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { 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.
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
import type { DOMPolicy } from "../dom.js";
|
|
2
2
|
import type { Expression } from "../observation/observable.js";
|
|
3
|
-
import { Binding, HTMLDirective, ViewBehaviorFactory } from "./html-directive.js";
|
|
3
|
+
import { AddViewBehaviorFactory, Binding, HTMLDirective, ViewBehaviorFactory } from "./html-directive.js";
|
|
4
4
|
import type { ElementView, HTMLView, SyntheticView } from "./view.js";
|
|
5
5
|
/**
|
|
6
6
|
* A template capable of creating views specifically for rendering custom elements.
|
|
@@ -21,6 +21,13 @@ export interface ElementViewTemplate<TSource = any, TParent = any> {
|
|
|
21
21
|
*/
|
|
22
22
|
render(source: TSource, host: Node, hostBindingTarget?: Element): ElementView<TSource, TParent>;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* A marker interface used to capture types when interpolating Directive helpers
|
|
26
|
+
* into templates.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export interface CaptureType<TSource, TParent> {
|
|
30
|
+
}
|
|
24
31
|
/**
|
|
25
32
|
* A template capable of rendering views not specifically connected to custom elements.
|
|
26
33
|
* @public
|
|
@@ -30,6 +37,10 @@ export interface SyntheticViewTemplate<TSource = any, TParent = any> {
|
|
|
30
37
|
* Creates a SyntheticView instance based on this template definition.
|
|
31
38
|
*/
|
|
32
39
|
create(): SyntheticView<TSource, TParent>;
|
|
40
|
+
/**
|
|
41
|
+
* Returns a directive that can inline the template.
|
|
42
|
+
*/
|
|
43
|
+
inline(): CaptureType<TSource, TParent>;
|
|
33
44
|
}
|
|
34
45
|
/**
|
|
35
46
|
* The result of a template compilation operation.
|
|
@@ -43,17 +54,32 @@ export interface HTMLTemplateCompilationResult<TSource = any, TParent = any> {
|
|
|
43
54
|
createView(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
|
|
44
55
|
}
|
|
45
56
|
/**
|
|
46
|
-
*
|
|
47
|
-
* into templates.
|
|
57
|
+
* Represents the types of values that can be interpolated into a template.
|
|
48
58
|
* @public
|
|
49
59
|
*/
|
|
50
|
-
export
|
|
51
|
-
}
|
|
60
|
+
export declare type TemplateValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource, TParent>;
|
|
52
61
|
/**
|
|
53
|
-
*
|
|
62
|
+
* Inlines a template into another template.
|
|
54
63
|
* @public
|
|
55
64
|
*/
|
|
56
|
-
export declare
|
|
65
|
+
export declare class InlineTemplateDirective implements HTMLDirective {
|
|
66
|
+
private html;
|
|
67
|
+
private factories;
|
|
68
|
+
/**
|
|
69
|
+
* An empty template partial.
|
|
70
|
+
*/
|
|
71
|
+
static readonly empty: InlineTemplateDirective;
|
|
72
|
+
/**
|
|
73
|
+
* Creates an instance of InlineTemplateDirective.
|
|
74
|
+
* @param template - The template to inline.
|
|
75
|
+
*/
|
|
76
|
+
constructor(html: string, factories?: Record<string, ViewBehaviorFactory>);
|
|
77
|
+
/**
|
|
78
|
+
* Creates HTML to be used within a template.
|
|
79
|
+
* @param add - Can be used to add behavior factories to a template.
|
|
80
|
+
*/
|
|
81
|
+
createHTML(add: AddViewBehaviorFactory): string;
|
|
82
|
+
}
|
|
57
83
|
/**
|
|
58
84
|
* A template capable of creating HTMLView instances or rendering directly to DOM.
|
|
59
85
|
* @public
|
|
@@ -82,6 +108,10 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
|
|
|
82
108
|
* @param hostBindingTarget - The element that host behaviors will be bound to.
|
|
83
109
|
*/
|
|
84
110
|
create(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
|
|
111
|
+
/**
|
|
112
|
+
* Returns a directive that can inline the template.
|
|
113
|
+
*/
|
|
114
|
+
inline(): CaptureType<TSource, TParent>;
|
|
85
115
|
/**
|
|
86
116
|
* Sets the DOMPolicy for this template.
|
|
87
117
|
* @param policy - The policy to associated with this template.
|
|
@@ -128,4 +158,21 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
|
|
|
128
158
|
* other template instances, and Directive instances.
|
|
129
159
|
* @public
|
|
130
160
|
*/
|
|
131
|
-
export declare
|
|
161
|
+
export declare type HTMLTemplateTag = (<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: TemplateValue<TSource, TParent>[]) => ViewTemplate<TSource, TParent>) & {
|
|
162
|
+
/**
|
|
163
|
+
* Transforms a template literal string into partial HTML.
|
|
164
|
+
* @param html - The HTML string fragment to interpolate.
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
partial(html: string): InlineTemplateDirective;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Transforms a template literal string into a ViewTemplate.
|
|
171
|
+
* @param strings - The string fragments that are interpolated with the values.
|
|
172
|
+
* @param values - The values that are interpolated with the string fragments.
|
|
173
|
+
* @remarks
|
|
174
|
+
* The html helper supports interpolation of strings, numbers, binding expressions,
|
|
175
|
+
* other template instances, and Directive instances.
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
export declare const html: HTMLTemplateTag;
|
|
@@ -35,6 +35,20 @@ export const booleanConverter = {
|
|
|
35
35
|
: true;
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* A {@link ValueConverter} that converts to and from `boolean` values. `null`, `undefined`, `""`, and `void` values are converted to `null`.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export const nullableBooleanConverter = {
|
|
43
|
+
toView(value) {
|
|
44
|
+
return typeof value === "boolean" ? value.toString() : "";
|
|
45
|
+
},
|
|
46
|
+
fromView(value) {
|
|
47
|
+
return [null, undefined, void 0].includes(value)
|
|
48
|
+
? null
|
|
49
|
+
: booleanConverter.fromView(value);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
38
52
|
function toNumber(value) {
|
|
39
53
|
if (value === null || value === undefined) {
|
|
40
54
|
return null;
|
package/dist/esm/di/di.js
CHANGED
|
@@ -414,11 +414,6 @@ export const DI = Object.freeze({
|
|
|
414
414
|
* in addition to its standard use in an inject array or through direct container APIs.
|
|
415
415
|
*/
|
|
416
416
|
createContext,
|
|
417
|
-
/**
|
|
418
|
-
* @deprecated
|
|
419
|
-
* Use DI.createContext instead.
|
|
420
|
-
*/
|
|
421
|
-
createInterface: createContext,
|
|
422
417
|
/**
|
|
423
418
|
* A decorator that specifies what to inject into its target.
|
|
424
419
|
* @param dependencies - The dependencies to inject.
|
package/dist/esm/dom.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Updates } from "./observation/update-queue.js";
|
|
2
1
|
import "./interfaces.js";
|
|
3
2
|
import { FAST } from "./platform.js";
|
|
4
3
|
/**
|
|
@@ -53,21 +52,6 @@ const fastPolicy = defaultPolicy;
|
|
|
53
52
|
* @public
|
|
54
53
|
*/
|
|
55
54
|
export const DOM = Object.freeze({
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated
|
|
58
|
-
* Use Updates.enqueue().
|
|
59
|
-
*/
|
|
60
|
-
queueUpdate: Updates.enqueue,
|
|
61
|
-
/**
|
|
62
|
-
* @deprecated
|
|
63
|
-
* Use Updates.next()
|
|
64
|
-
*/
|
|
65
|
-
nextUpdate: Updates.next,
|
|
66
|
-
/**
|
|
67
|
-
* @deprecated
|
|
68
|
-
* Use Updates.process()
|
|
69
|
-
*/
|
|
70
|
-
processUpdates: Updates.process,
|
|
71
55
|
/**
|
|
72
56
|
* Gets the dom policy used by the templating system.
|
|
73
57
|
*/
|
package/dist/esm/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./styles/element-styles.js";
|
|
|
10
10
|
export * from "./styles/css.js";
|
|
11
11
|
export * from "./styles/css-directive.js";
|
|
12
12
|
export * from "./styles/host.js";
|
|
13
|
+
export * from "./styles/style-strategy.js";
|
|
13
14
|
// Templating
|
|
14
15
|
export * from "./templating/template.js";
|
|
15
16
|
export * from "./templating/compiler.js";
|
|
@@ -23,7 +24,6 @@ export * from "./templating/slotted.js";
|
|
|
23
24
|
export * from "./templating/children.js";
|
|
24
25
|
export * from "./templating/view.js";
|
|
25
26
|
export * from "./templating/node-observation.js";
|
|
26
|
-
export * from "./templating/dangerous-html.js";
|
|
27
27
|
// Components
|
|
28
28
|
export * from "./components/fast-element.js";
|
|
29
29
|
export * from "./components/fast-definitions.js";
|
package/dist/esm/interfaces.js
CHANGED
|
@@ -44,14 +44,17 @@ switch (kernelMode) {
|
|
|
44
44
|
}
|
|
45
45
|
export { KernelServiceId };
|
|
46
46
|
/**
|
|
47
|
+
* Determines whether or not an object is a function.
|
|
47
48
|
* @internal
|
|
48
49
|
*/
|
|
49
50
|
export const isFunction = (object) => typeof object === "function";
|
|
50
51
|
/**
|
|
52
|
+
* Determines whether or not an object is a string.
|
|
51
53
|
* @internal
|
|
52
54
|
*/
|
|
53
55
|
export const isString = (object) => typeof object === "string";
|
|
54
56
|
/**
|
|
57
|
+
* A function which does nothing.
|
|
55
58
|
* @internal
|
|
56
59
|
*/
|
|
57
60
|
export const noop = () => void 0;
|
package/dist/esm/styles/css.js
CHANGED
|
@@ -83,8 +83,3 @@ css.partial = (strings, ...values) => {
|
|
|
83
83
|
const { styles, behaviors } = collectStyles(strings, values);
|
|
84
84
|
return new CSSPartial(styles, behaviors);
|
|
85
85
|
};
|
|
86
|
-
/**
|
|
87
|
-
* @deprecated Use css.partial instead.
|
|
88
|
-
* @public
|
|
89
|
-
*/
|
|
90
|
-
export const cssPartial = css.partial;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFunction, noop } from "../interfaces.js";
|
|
1
|
+
import { isFunction, isString, noop } from "../interfaces.js";
|
|
2
2
|
import { FAST } from "../platform.js";
|
|
3
3
|
import { bind, HTMLBindingDirective, oneTime } from "./binding.js";
|
|
4
4
|
import { Compiler } from "./compiler.js";
|
|
@@ -8,6 +8,37 @@ import { nextId } from "./markup.js";
|
|
|
8
8
|
const lastAttributeNameRegex =
|
|
9
9
|
/* eslint-disable-next-line no-control-regex */
|
|
10
10
|
/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;
|
|
11
|
+
const noFactories = Object.create(null);
|
|
12
|
+
/**
|
|
13
|
+
* Inlines a template into another template.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export class InlineTemplateDirective {
|
|
17
|
+
/**
|
|
18
|
+
* Creates an instance of InlineTemplateDirective.
|
|
19
|
+
* @param template - The template to inline.
|
|
20
|
+
*/
|
|
21
|
+
constructor(html, factories = noFactories) {
|
|
22
|
+
this.html = html;
|
|
23
|
+
this.factories = factories;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates HTML to be used within a template.
|
|
27
|
+
* @param add - Can be used to add behavior factories to a template.
|
|
28
|
+
*/
|
|
29
|
+
createHTML(add) {
|
|
30
|
+
const factories = this.factories;
|
|
31
|
+
for (const key in factories) {
|
|
32
|
+
add(factories[key]);
|
|
33
|
+
}
|
|
34
|
+
return this.html;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* An empty template partial.
|
|
39
|
+
*/
|
|
40
|
+
InlineTemplateDirective.empty = new InlineTemplateDirective("");
|
|
41
|
+
HTMLDirective.define(InlineTemplateDirective);
|
|
11
42
|
function createHTML(value, prevString, add, definition = HTMLDirective.getForInstance(value)) {
|
|
12
43
|
if (definition.aspected) {
|
|
13
44
|
const match = lastAttributeNameRegex.exec(prevString);
|
|
@@ -49,6 +80,12 @@ export class ViewTemplate {
|
|
|
49
80
|
}
|
|
50
81
|
return this.result.createView(hostBindingTarget);
|
|
51
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns a directive that can inline the template.
|
|
85
|
+
*/
|
|
86
|
+
inline() {
|
|
87
|
+
return new InlineTemplateDirective(isString(this.html) ? this.html : this.html.innerHTML, this.factories);
|
|
88
|
+
}
|
|
52
89
|
/**
|
|
53
90
|
* Sets the DOMPolicy for this template.
|
|
54
91
|
* @param policy - The policy to associated with this template.
|
|
@@ -131,9 +168,12 @@ export class ViewTemplate {
|
|
|
131
168
|
* other template instances, and Directive instances.
|
|
132
169
|
* @public
|
|
133
170
|
*/
|
|
134
|
-
export
|
|
171
|
+
export const html = ((strings, ...values) => {
|
|
135
172
|
if (Array.isArray(strings) && Array.isArray(strings.raw)) {
|
|
136
173
|
return ViewTemplate.create(strings, values);
|
|
137
174
|
}
|
|
138
175
|
throw FAST.error(1206 /* Message.directCallToHTMLTagNotAllowed */);
|
|
139
|
-
}
|
|
176
|
+
});
|
|
177
|
+
html.partial = (html) => {
|
|
178
|
+
return new InlineTemplateDirective(html);
|
|
179
|
+
};
|