@microsoft/fast-html 1.0.0-alpha.4 → 1.0.0-alpha.41
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/README.md +266 -19
- package/dist/dts/components/element.d.ts +10 -0
- package/dist/dts/components/index.d.ts +3 -1
- package/dist/dts/components/observer-map.d.ts +27 -0
- package/dist/dts/components/schema.d.ts +144 -0
- package/dist/dts/components/template.d.ts +83 -7
- package/dist/dts/components/utilities.d.ts +128 -37
- package/dist/dts/index.d.ts +1 -1
- package/dist/dts/tsdoc-metadata.json +1 -1
- package/dist/esm/components/element.js +73 -0
- package/dist/esm/components/index.js +3 -1
- package/dist/esm/components/observer-map.js +68 -0
- package/dist/esm/components/observer-map.spec.js +39 -0
- package/dist/esm/components/schema.js +250 -0
- package/dist/esm/components/schema.spec.js +484 -0
- package/dist/esm/components/template.js +242 -213
- package/dist/esm/components/utilities.js +1008 -64
- package/dist/esm/components/utilities.spec.js +522 -93
- package/dist/esm/index.js +1 -1
- package/dist/fast-html.api.json +350 -1
- package/dist/fast-html.d.ts +283 -6
- package/dist/fast-html.untrimmed.d.ts +283 -6
- package/package.json +27 -38
- package/rules/attribute-directives.yml +38 -0
- package/rules/call-expression-with-event-argument.yml +41 -0
- package/rules/member-expression.yml +33 -0
- package/rules/tag-function-to-template-literal.yml +16 -0
- package/dist/dts/fixtures/binding/binding.spec.d.ts +0 -1
- package/dist/dts/fixtures/binding/main.d.ts +0 -1
- package/dist/dts/fixtures/children/children.spec.d.ts +0 -1
- package/dist/dts/fixtures/children/main.d.ts +0 -1
- package/dist/dts/fixtures/dot-syntax/dot-syntax.spec.d.ts +0 -1
- package/dist/dts/fixtures/dot-syntax/main.d.ts +0 -1
- package/dist/dts/fixtures/event/event.spec.d.ts +0 -1
- package/dist/dts/fixtures/event/main.d.ts +0 -1
- package/dist/dts/fixtures/partial/main.d.ts +0 -1
- package/dist/dts/fixtures/partial/partial.spec.d.ts +0 -1
- package/dist/dts/fixtures/ref/main.d.ts +0 -1
- package/dist/dts/fixtures/ref/ref.spec.d.ts +0 -1
- package/dist/dts/fixtures/repeat/main.d.ts +0 -1
- package/dist/dts/fixtures/repeat/repeat.spec.d.ts +0 -1
- package/dist/dts/fixtures/slotted/main.d.ts +0 -1
- package/dist/dts/fixtures/slotted/slotted.spec.d.ts +0 -1
- package/dist/dts/fixtures/when/main.d.ts +0 -1
- package/dist/dts/fixtures/when/when.spec.d.ts +0 -1
- package/dist/esm/fixtures/attribute/attribute.spec.js +0 -23
- package/dist/esm/fixtures/attribute/main.js +0 -19
- package/dist/esm/fixtures/binding/binding.spec.js +0 -17
- package/dist/esm/fixtures/binding/main.js +0 -19
- package/dist/esm/fixtures/children/children.spec.js +0 -33
- package/dist/esm/fixtures/children/main.js +0 -24
- package/dist/esm/fixtures/dot-syntax/dot-syntax.spec.js +0 -9
- package/dist/esm/fixtures/dot-syntax/main.js +0 -16
- package/dist/esm/fixtures/event/event.spec.js +0 -12
- package/dist/esm/fixtures/event/main.js +0 -16
- package/dist/esm/fixtures/partial/main.js +0 -31
- package/dist/esm/fixtures/partial/partial.spec.js +0 -14
- package/dist/esm/fixtures/ref/main.js +0 -14
- package/dist/esm/fixtures/ref/ref.spec.js +0 -13
- package/dist/esm/fixtures/repeat/main.js +0 -19
- package/dist/esm/fixtures/repeat/repeat.spec.js +0 -26
- package/dist/esm/fixtures/slotted/main.js +0 -22
- package/dist/esm/fixtures/slotted/slotted.spec.js +0 -25
- package/dist/esm/fixtures/when/main.js +0 -146
- package/dist/esm/fixtures/when/when.spec.js +0 -82
- package/dist/esm/tsconfig.tsbuildinfo +0 -1
- /package/dist/dts/{fixtures/attribute/attribute.spec.d.ts → components/observer-map.spec.d.ts} +0 -0
- /package/dist/dts/{fixtures/attribute/main.d.ts → components/schema.spec.d.ts} +0 -0
package/dist/fast-html.d.ts
CHANGED
|
@@ -1,4 +1,242 @@
|
|
|
1
|
+
import { Constructable } from '@microsoft/fast-element';
|
|
1
2
|
import { FASTElement } from '@microsoft/fast-element';
|
|
3
|
+
import { HydrationControllerCallbacks } from '@microsoft/fast-element';
|
|
4
|
+
import { TemplateLifecycleCallbacks } from '@microsoft/fast-element';
|
|
5
|
+
|
|
6
|
+
declare interface AccessCachedPath extends CachedPathCommon {
|
|
7
|
+
type: AccessCachedPathType;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare type AccessCachedPathType = "access";
|
|
11
|
+
|
|
12
|
+
declare type CachedPath = DefaultCachedPath | RepeatCachedPath | AccessCachedPath | EventCachedPath;
|
|
13
|
+
|
|
14
|
+
declare interface CachedPathCommon {
|
|
15
|
+
parentContext: string | null;
|
|
16
|
+
currentContext: string | null;
|
|
17
|
+
path: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare type CachedPathMap = Map<string, Map<string, JSONSchema>>;
|
|
21
|
+
|
|
22
|
+
declare interface ChildrenMap {
|
|
23
|
+
customElementName: string;
|
|
24
|
+
attributeName: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare interface DefaultCachedPath extends CachedPathCommon {
|
|
28
|
+
type: DefaultCachedPathType;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare type DefaultCachedPathType = "default";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Element options the TemplateElement will use to update the registered element
|
|
35
|
+
*/
|
|
36
|
+
declare interface ElementOptions {
|
|
37
|
+
observerMap?: ObserverMapOption;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A dictionary of element options the TemplateElement will use to update the registered element
|
|
42
|
+
*/
|
|
43
|
+
declare interface ElementOptionsDictionary<ElementOptionsType = ElementOptions> {
|
|
44
|
+
[key: string]: ElementOptionsType;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare interface EventCachedPath extends CachedPathCommon {
|
|
48
|
+
type: EventCachedPathType;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare type EventCachedPathType = "event";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Lifecycle callbacks for template and hydration events.
|
|
55
|
+
* Combines template lifecycle callbacks with hydration callbacks and adds template-processing events.
|
|
56
|
+
*/
|
|
57
|
+
declare interface HydrationLifecycleCallbacks extends HydrationControllerCallbacks, TemplateLifecycleCallbacks {
|
|
58
|
+
/**
|
|
59
|
+
* Called after the JS class definition has been registered
|
|
60
|
+
*/
|
|
61
|
+
elementDidRegister?(name: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Called before the template has been evaluated and assigned
|
|
64
|
+
*/
|
|
65
|
+
templateWillUpdate?(name: string): void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare interface JSONSchema extends JSONSchemaCommon {
|
|
69
|
+
$schema: string;
|
|
70
|
+
$id: string;
|
|
71
|
+
$defs?: Record<string, JSONSchemaDefinition>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare interface JSONSchemaCommon {
|
|
75
|
+
type?: string;
|
|
76
|
+
properties?: any;
|
|
77
|
+
items?: any;
|
|
78
|
+
anyOf?: Array<any>;
|
|
79
|
+
$ref?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
declare interface JSONSchemaDefinition extends JSONSchemaCommon {
|
|
83
|
+
$fast_context: string;
|
|
84
|
+
$fast_parent_contexts: Array<string>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* ObserverMap provides functionality for caching binding paths, extracting root properties,
|
|
89
|
+
* and defining observable properties on class prototypes
|
|
90
|
+
*/
|
|
91
|
+
export declare class ObserverMap {
|
|
92
|
+
private schema;
|
|
93
|
+
private classPrototype;
|
|
94
|
+
constructor(classPrototype: any, schema: Schema);
|
|
95
|
+
defineProperties(): void;
|
|
96
|
+
/**
|
|
97
|
+
* Creates a proxy for an object that intercepts property mutations and triggers Observable notifications
|
|
98
|
+
* @param target - The target instance that owns the root property
|
|
99
|
+
* @param rootProperty - The name of the root property for notification purposes
|
|
100
|
+
* @param object - The object to wrap with a proxy
|
|
101
|
+
* @returns A proxy that triggers notifications on property mutations
|
|
102
|
+
*/
|
|
103
|
+
private getAndAssignObservables;
|
|
104
|
+
/**
|
|
105
|
+
* Creates a property change handler function for observable properties
|
|
106
|
+
* This handler is called when an observable property transitions from undefined to a defined value
|
|
107
|
+
* @param propertyName - The name of the property for which to create the change handler
|
|
108
|
+
* @param existingChangedMethod - Optional existing changed method to call after the instance resolver logic
|
|
109
|
+
* @returns A function that handles property changes and sets up proxies for object values
|
|
110
|
+
*/
|
|
111
|
+
private defineChanged;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Values for the observerMap element option.
|
|
116
|
+
*/
|
|
117
|
+
declare const ObserverMapOption: {
|
|
118
|
+
readonly all: "all";
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Type for the observerMap element option.
|
|
123
|
+
*/
|
|
124
|
+
declare type ObserverMapOption = (typeof ObserverMapOption)[keyof typeof ObserverMapOption];
|
|
125
|
+
|
|
126
|
+
declare interface RegisterPathConfig {
|
|
127
|
+
rootPropertyName: string;
|
|
128
|
+
pathConfig: CachedPath;
|
|
129
|
+
childrenMap: ChildrenMap | null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* A mixin function that extends a base class with additional functionality for
|
|
134
|
+
* rendering and hydration.
|
|
135
|
+
*
|
|
136
|
+
* @param BaseCtor - The base class to extend.
|
|
137
|
+
* @returns A new class that extends the provided base class with additional functionality for rendering and hydration.
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
export declare function RenderableFASTElement<T extends Constructable<FASTElement>>(BaseCtor: T): T;
|
|
141
|
+
|
|
142
|
+
declare interface RepeatCachedPath extends CachedPathCommon {
|
|
143
|
+
type: RepeatCachedPathType;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare type RepeatCachedPathType = "repeat";
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* A constructed JSON schema from a template
|
|
150
|
+
*/
|
|
151
|
+
declare class Schema {
|
|
152
|
+
/**
|
|
153
|
+
* The name of the custom element
|
|
154
|
+
*/
|
|
155
|
+
private customElementName;
|
|
156
|
+
/**
|
|
157
|
+
* A JSON schema describing each root schema
|
|
158
|
+
*/
|
|
159
|
+
static jsonSchemaMap: CachedPathMap;
|
|
160
|
+
constructor(name: string);
|
|
161
|
+
/**
|
|
162
|
+
* Add a path to a schema
|
|
163
|
+
* @param config RegisterPathConfig
|
|
164
|
+
*/
|
|
165
|
+
addPath(config: RegisterPathConfig): void;
|
|
166
|
+
/**
|
|
167
|
+
* Gets the JSON schema for a property name
|
|
168
|
+
* @param rootPropertyName - the root property the JSON schema is mapped to
|
|
169
|
+
* @returns The JSON schema for the root property
|
|
170
|
+
*/
|
|
171
|
+
getSchema(rootPropertyName: string): JSONSchema | null;
|
|
172
|
+
/**
|
|
173
|
+
* Gets root properties
|
|
174
|
+
* @returns IterableIterator<string>
|
|
175
|
+
*/
|
|
176
|
+
getRootProperties(): IterableIterator<string>;
|
|
177
|
+
/**
|
|
178
|
+
* Get a path split into property names
|
|
179
|
+
* @param path The dot syntax path e.g. a.b.c
|
|
180
|
+
* @returns An array of items in the path
|
|
181
|
+
*/
|
|
182
|
+
private getSplitPath;
|
|
183
|
+
/**
|
|
184
|
+
* Gets the path to the $def
|
|
185
|
+
* @param context The context name e.g. {{item in items}} in a repeat creates the "item" context
|
|
186
|
+
* @returns A string to use as a $ref
|
|
187
|
+
*/
|
|
188
|
+
private getDefsPath;
|
|
189
|
+
/**
|
|
190
|
+
* Get the schema $id
|
|
191
|
+
* @param customElementName - The custom element name
|
|
192
|
+
* @param propertyName - The property name
|
|
193
|
+
* @returns The ID that can be used in the JSON schema as $id
|
|
194
|
+
*/
|
|
195
|
+
private getSchemaId;
|
|
196
|
+
/**
|
|
197
|
+
* Add a new JSON schema to the JSON schema map
|
|
198
|
+
* @param propertyName The name of the property to assign this JSON schema to
|
|
199
|
+
*/
|
|
200
|
+
private addNewSchema;
|
|
201
|
+
/**
|
|
202
|
+
* Add properties to a context
|
|
203
|
+
* @param schema The schema to add the properties to
|
|
204
|
+
* @param splitPath The path split into property/context names
|
|
205
|
+
* @param context The paths context
|
|
206
|
+
*/
|
|
207
|
+
private addPropertiesToAContext;
|
|
208
|
+
/**
|
|
209
|
+
* Add properties to an object
|
|
210
|
+
* @param schema The schema to add the properties to
|
|
211
|
+
* @param splitPath The path split into property/context names
|
|
212
|
+
* @param context The paths context
|
|
213
|
+
* @param type The data type (see JSON schema for details)
|
|
214
|
+
*/
|
|
215
|
+
private addPropertiesToAnObject;
|
|
216
|
+
/**
|
|
217
|
+
* Add an array to an object property
|
|
218
|
+
* @param schema The schema to add the properties to
|
|
219
|
+
* @param context The name of the context
|
|
220
|
+
*/
|
|
221
|
+
private addArrayToAnObject;
|
|
222
|
+
/**
|
|
223
|
+
* Add a context to the $defs property
|
|
224
|
+
* @param schema The schema to use
|
|
225
|
+
* @param propertyName The name of the property the context belongs to
|
|
226
|
+
* @param currentContext The current context
|
|
227
|
+
* @param parentContext The parent context
|
|
228
|
+
* @returns
|
|
229
|
+
*/
|
|
230
|
+
private addContext;
|
|
231
|
+
/**
|
|
232
|
+
* Get parent contexts
|
|
233
|
+
* @param schema The schema to use
|
|
234
|
+
* @param parentContext The parent context
|
|
235
|
+
* @param contexts A list of parent contexts
|
|
236
|
+
* @returns
|
|
237
|
+
*/
|
|
238
|
+
private getParentContexts;
|
|
239
|
+
}
|
|
2
240
|
|
|
3
241
|
/**
|
|
4
242
|
* The <f-template> custom element that will provide view logic to the element
|
|
@@ -8,12 +246,52 @@ export declare class TemplateElement extends FASTElement {
|
|
|
8
246
|
* The name of the custom element this template will be applied to
|
|
9
247
|
*/
|
|
10
248
|
name?: string;
|
|
11
|
-
|
|
249
|
+
/**
|
|
250
|
+
* A dictionary of custom element options
|
|
251
|
+
*/
|
|
252
|
+
static elementOptions: ElementOptionsDictionary;
|
|
253
|
+
/**
|
|
254
|
+
* ObserverMap instance for caching binding paths
|
|
255
|
+
*/
|
|
256
|
+
private observerMap?;
|
|
257
|
+
/**
|
|
258
|
+
* Default element options
|
|
259
|
+
*/
|
|
260
|
+
private static defaultElementOptions;
|
|
261
|
+
/**
|
|
262
|
+
* Metadata containing JSON schema for properties on a custom eleemnt
|
|
263
|
+
*/
|
|
264
|
+
private schema?;
|
|
265
|
+
/**
|
|
266
|
+
* Lifecycle callbacks for hydration events
|
|
267
|
+
*/
|
|
268
|
+
private static lifecycleCallbacks;
|
|
269
|
+
/**
|
|
270
|
+
* Configure lifecycle callbacks for hydration events.
|
|
271
|
+
*
|
|
272
|
+
* @param callbacks - Lifecycle callbacks to configure.
|
|
273
|
+
* @returns The {@link TemplateElement} class.
|
|
274
|
+
*/
|
|
275
|
+
static config(callbacks: HydrationLifecycleCallbacks): typeof TemplateElement;
|
|
276
|
+
/**
|
|
277
|
+
* Set options for custom elements.
|
|
278
|
+
*
|
|
279
|
+
* @param elementOptions - A dictionary of custom element options
|
|
280
|
+
* @returns The TemplateElement class.
|
|
281
|
+
*/
|
|
282
|
+
static options(elementOptions?: ElementOptionsDictionary): typeof TemplateElement;
|
|
283
|
+
constructor();
|
|
284
|
+
/**
|
|
285
|
+
* Set options for a custom element
|
|
286
|
+
* @param name - The name of the custom element to set options for.
|
|
287
|
+
*/
|
|
288
|
+
private static setOptions;
|
|
12
289
|
connectedCallback(): void;
|
|
13
290
|
/**
|
|
14
291
|
* Resolve strings and values from an innerHTML string
|
|
15
292
|
* @param innerHTML - The innerHTML.
|
|
16
293
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
294
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
17
295
|
*/
|
|
18
296
|
private resolveStringsAndValues;
|
|
19
297
|
/**
|
|
@@ -27,6 +305,8 @@ export declare class TemplateElement extends FASTElement {
|
|
|
27
305
|
* @param behaviorConfig - The directive behavior configuration object.
|
|
28
306
|
* @param externalValues - The interpreted values from the parent.
|
|
29
307
|
* @param innerHTML - The innerHTML.
|
|
308
|
+
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
309
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
30
310
|
*/
|
|
31
311
|
private resolveTemplateDirective;
|
|
32
312
|
/**
|
|
@@ -43,6 +323,7 @@ export declare class TemplateElement extends FASTElement {
|
|
|
43
323
|
* @param values - The interpreted values.
|
|
44
324
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
45
325
|
* @param behaviorConfig - The binding behavior configuration object.
|
|
326
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
46
327
|
*/
|
|
47
328
|
private resolveDataBinding;
|
|
48
329
|
/**
|
|
@@ -51,13 +332,9 @@ export declare class TemplateElement extends FASTElement {
|
|
|
51
332
|
* @param strings - The strings array.
|
|
52
333
|
* @param values - The interpreted values.
|
|
53
334
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
335
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
54
336
|
*/
|
|
55
337
|
private resolveInnerHTML;
|
|
56
|
-
/**
|
|
57
|
-
* Resolve all partial templates
|
|
58
|
-
* @param unresolvedInnerHTML - The innerHTML.
|
|
59
|
-
*/
|
|
60
|
-
private resolveAllPartials;
|
|
61
338
|
}
|
|
62
339
|
|
|
63
340
|
export { }
|
|
@@ -1,4 +1,242 @@
|
|
|
1
|
+
import { Constructable } from '@microsoft/fast-element';
|
|
1
2
|
import { FASTElement } from '@microsoft/fast-element';
|
|
3
|
+
import { HydrationControllerCallbacks } from '@microsoft/fast-element';
|
|
4
|
+
import { TemplateLifecycleCallbacks } from '@microsoft/fast-element';
|
|
5
|
+
|
|
6
|
+
declare interface AccessCachedPath extends CachedPathCommon {
|
|
7
|
+
type: AccessCachedPathType;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare type AccessCachedPathType = "access";
|
|
11
|
+
|
|
12
|
+
declare type CachedPath = DefaultCachedPath | RepeatCachedPath | AccessCachedPath | EventCachedPath;
|
|
13
|
+
|
|
14
|
+
declare interface CachedPathCommon {
|
|
15
|
+
parentContext: string | null;
|
|
16
|
+
currentContext: string | null;
|
|
17
|
+
path: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare type CachedPathMap = Map<string, Map<string, JSONSchema>>;
|
|
21
|
+
|
|
22
|
+
declare interface ChildrenMap {
|
|
23
|
+
customElementName: string;
|
|
24
|
+
attributeName: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare interface DefaultCachedPath extends CachedPathCommon {
|
|
28
|
+
type: DefaultCachedPathType;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare type DefaultCachedPathType = "default";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Element options the TemplateElement will use to update the registered element
|
|
35
|
+
*/
|
|
36
|
+
declare interface ElementOptions {
|
|
37
|
+
observerMap?: ObserverMapOption;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A dictionary of element options the TemplateElement will use to update the registered element
|
|
42
|
+
*/
|
|
43
|
+
declare interface ElementOptionsDictionary<ElementOptionsType = ElementOptions> {
|
|
44
|
+
[key: string]: ElementOptionsType;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare interface EventCachedPath extends CachedPathCommon {
|
|
48
|
+
type: EventCachedPathType;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare type EventCachedPathType = "event";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Lifecycle callbacks for template and hydration events.
|
|
55
|
+
* Combines template lifecycle callbacks with hydration callbacks and adds template-processing events.
|
|
56
|
+
*/
|
|
57
|
+
declare interface HydrationLifecycleCallbacks extends HydrationControllerCallbacks, TemplateLifecycleCallbacks {
|
|
58
|
+
/**
|
|
59
|
+
* Called after the JS class definition has been registered
|
|
60
|
+
*/
|
|
61
|
+
elementDidRegister?(name: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Called before the template has been evaluated and assigned
|
|
64
|
+
*/
|
|
65
|
+
templateWillUpdate?(name: string): void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare interface JSONSchema extends JSONSchemaCommon {
|
|
69
|
+
$schema: string;
|
|
70
|
+
$id: string;
|
|
71
|
+
$defs?: Record<string, JSONSchemaDefinition>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare interface JSONSchemaCommon {
|
|
75
|
+
type?: string;
|
|
76
|
+
properties?: any;
|
|
77
|
+
items?: any;
|
|
78
|
+
anyOf?: Array<any>;
|
|
79
|
+
$ref?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
declare interface JSONSchemaDefinition extends JSONSchemaCommon {
|
|
83
|
+
$fast_context: string;
|
|
84
|
+
$fast_parent_contexts: Array<string>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* ObserverMap provides functionality for caching binding paths, extracting root properties,
|
|
89
|
+
* and defining observable properties on class prototypes
|
|
90
|
+
*/
|
|
91
|
+
export declare class ObserverMap {
|
|
92
|
+
private schema;
|
|
93
|
+
private classPrototype;
|
|
94
|
+
constructor(classPrototype: any, schema: Schema);
|
|
95
|
+
defineProperties(): void;
|
|
96
|
+
/**
|
|
97
|
+
* Creates a proxy for an object that intercepts property mutations and triggers Observable notifications
|
|
98
|
+
* @param target - The target instance that owns the root property
|
|
99
|
+
* @param rootProperty - The name of the root property for notification purposes
|
|
100
|
+
* @param object - The object to wrap with a proxy
|
|
101
|
+
* @returns A proxy that triggers notifications on property mutations
|
|
102
|
+
*/
|
|
103
|
+
private getAndAssignObservables;
|
|
104
|
+
/**
|
|
105
|
+
* Creates a property change handler function for observable properties
|
|
106
|
+
* This handler is called when an observable property transitions from undefined to a defined value
|
|
107
|
+
* @param propertyName - The name of the property for which to create the change handler
|
|
108
|
+
* @param existingChangedMethod - Optional existing changed method to call after the instance resolver logic
|
|
109
|
+
* @returns A function that handles property changes and sets up proxies for object values
|
|
110
|
+
*/
|
|
111
|
+
private defineChanged;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Values for the observerMap element option.
|
|
116
|
+
*/
|
|
117
|
+
declare const ObserverMapOption: {
|
|
118
|
+
readonly all: "all";
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Type for the observerMap element option.
|
|
123
|
+
*/
|
|
124
|
+
declare type ObserverMapOption = (typeof ObserverMapOption)[keyof typeof ObserverMapOption];
|
|
125
|
+
|
|
126
|
+
declare interface RegisterPathConfig {
|
|
127
|
+
rootPropertyName: string;
|
|
128
|
+
pathConfig: CachedPath;
|
|
129
|
+
childrenMap: ChildrenMap | null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* A mixin function that extends a base class with additional functionality for
|
|
134
|
+
* rendering and hydration.
|
|
135
|
+
*
|
|
136
|
+
* @param BaseCtor - The base class to extend.
|
|
137
|
+
* @returns A new class that extends the provided base class with additional functionality for rendering and hydration.
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
export declare function RenderableFASTElement<T extends Constructable<FASTElement>>(BaseCtor: T): T;
|
|
141
|
+
|
|
142
|
+
declare interface RepeatCachedPath extends CachedPathCommon {
|
|
143
|
+
type: RepeatCachedPathType;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare type RepeatCachedPathType = "repeat";
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* A constructed JSON schema from a template
|
|
150
|
+
*/
|
|
151
|
+
declare class Schema {
|
|
152
|
+
/**
|
|
153
|
+
* The name of the custom element
|
|
154
|
+
*/
|
|
155
|
+
private customElementName;
|
|
156
|
+
/**
|
|
157
|
+
* A JSON schema describing each root schema
|
|
158
|
+
*/
|
|
159
|
+
static jsonSchemaMap: CachedPathMap;
|
|
160
|
+
constructor(name: string);
|
|
161
|
+
/**
|
|
162
|
+
* Add a path to a schema
|
|
163
|
+
* @param config RegisterPathConfig
|
|
164
|
+
*/
|
|
165
|
+
addPath(config: RegisterPathConfig): void;
|
|
166
|
+
/**
|
|
167
|
+
* Gets the JSON schema for a property name
|
|
168
|
+
* @param rootPropertyName - the root property the JSON schema is mapped to
|
|
169
|
+
* @returns The JSON schema for the root property
|
|
170
|
+
*/
|
|
171
|
+
getSchema(rootPropertyName: string): JSONSchema | null;
|
|
172
|
+
/**
|
|
173
|
+
* Gets root properties
|
|
174
|
+
* @returns IterableIterator<string>
|
|
175
|
+
*/
|
|
176
|
+
getRootProperties(): IterableIterator<string>;
|
|
177
|
+
/**
|
|
178
|
+
* Get a path split into property names
|
|
179
|
+
* @param path The dot syntax path e.g. a.b.c
|
|
180
|
+
* @returns An array of items in the path
|
|
181
|
+
*/
|
|
182
|
+
private getSplitPath;
|
|
183
|
+
/**
|
|
184
|
+
* Gets the path to the $def
|
|
185
|
+
* @param context The context name e.g. {{item in items}} in a repeat creates the "item" context
|
|
186
|
+
* @returns A string to use as a $ref
|
|
187
|
+
*/
|
|
188
|
+
private getDefsPath;
|
|
189
|
+
/**
|
|
190
|
+
* Get the schema $id
|
|
191
|
+
* @param customElementName - The custom element name
|
|
192
|
+
* @param propertyName - The property name
|
|
193
|
+
* @returns The ID that can be used in the JSON schema as $id
|
|
194
|
+
*/
|
|
195
|
+
private getSchemaId;
|
|
196
|
+
/**
|
|
197
|
+
* Add a new JSON schema to the JSON schema map
|
|
198
|
+
* @param propertyName The name of the property to assign this JSON schema to
|
|
199
|
+
*/
|
|
200
|
+
private addNewSchema;
|
|
201
|
+
/**
|
|
202
|
+
* Add properties to a context
|
|
203
|
+
* @param schema The schema to add the properties to
|
|
204
|
+
* @param splitPath The path split into property/context names
|
|
205
|
+
* @param context The paths context
|
|
206
|
+
*/
|
|
207
|
+
private addPropertiesToAContext;
|
|
208
|
+
/**
|
|
209
|
+
* Add properties to an object
|
|
210
|
+
* @param schema The schema to add the properties to
|
|
211
|
+
* @param splitPath The path split into property/context names
|
|
212
|
+
* @param context The paths context
|
|
213
|
+
* @param type The data type (see JSON schema for details)
|
|
214
|
+
*/
|
|
215
|
+
private addPropertiesToAnObject;
|
|
216
|
+
/**
|
|
217
|
+
* Add an array to an object property
|
|
218
|
+
* @param schema The schema to add the properties to
|
|
219
|
+
* @param context The name of the context
|
|
220
|
+
*/
|
|
221
|
+
private addArrayToAnObject;
|
|
222
|
+
/**
|
|
223
|
+
* Add a context to the $defs property
|
|
224
|
+
* @param schema The schema to use
|
|
225
|
+
* @param propertyName The name of the property the context belongs to
|
|
226
|
+
* @param currentContext The current context
|
|
227
|
+
* @param parentContext The parent context
|
|
228
|
+
* @returns
|
|
229
|
+
*/
|
|
230
|
+
private addContext;
|
|
231
|
+
/**
|
|
232
|
+
* Get parent contexts
|
|
233
|
+
* @param schema The schema to use
|
|
234
|
+
* @param parentContext The parent context
|
|
235
|
+
* @param contexts A list of parent contexts
|
|
236
|
+
* @returns
|
|
237
|
+
*/
|
|
238
|
+
private getParentContexts;
|
|
239
|
+
}
|
|
2
240
|
|
|
3
241
|
/**
|
|
4
242
|
* The <f-template> custom element that will provide view logic to the element
|
|
@@ -8,12 +246,52 @@ export declare class TemplateElement extends FASTElement {
|
|
|
8
246
|
* The name of the custom element this template will be applied to
|
|
9
247
|
*/
|
|
10
248
|
name?: string;
|
|
11
|
-
|
|
249
|
+
/**
|
|
250
|
+
* A dictionary of custom element options
|
|
251
|
+
*/
|
|
252
|
+
static elementOptions: ElementOptionsDictionary;
|
|
253
|
+
/**
|
|
254
|
+
* ObserverMap instance for caching binding paths
|
|
255
|
+
*/
|
|
256
|
+
private observerMap?;
|
|
257
|
+
/**
|
|
258
|
+
* Default element options
|
|
259
|
+
*/
|
|
260
|
+
private static defaultElementOptions;
|
|
261
|
+
/**
|
|
262
|
+
* Metadata containing JSON schema for properties on a custom eleemnt
|
|
263
|
+
*/
|
|
264
|
+
private schema?;
|
|
265
|
+
/**
|
|
266
|
+
* Lifecycle callbacks for hydration events
|
|
267
|
+
*/
|
|
268
|
+
private static lifecycleCallbacks;
|
|
269
|
+
/**
|
|
270
|
+
* Configure lifecycle callbacks for hydration events.
|
|
271
|
+
*
|
|
272
|
+
* @param callbacks - Lifecycle callbacks to configure.
|
|
273
|
+
* @returns The {@link TemplateElement} class.
|
|
274
|
+
*/
|
|
275
|
+
static config(callbacks: HydrationLifecycleCallbacks): typeof TemplateElement;
|
|
276
|
+
/**
|
|
277
|
+
* Set options for custom elements.
|
|
278
|
+
*
|
|
279
|
+
* @param elementOptions - A dictionary of custom element options
|
|
280
|
+
* @returns The TemplateElement class.
|
|
281
|
+
*/
|
|
282
|
+
static options(elementOptions?: ElementOptionsDictionary): typeof TemplateElement;
|
|
283
|
+
constructor();
|
|
284
|
+
/**
|
|
285
|
+
* Set options for a custom element
|
|
286
|
+
* @param name - The name of the custom element to set options for.
|
|
287
|
+
*/
|
|
288
|
+
private static setOptions;
|
|
12
289
|
connectedCallback(): void;
|
|
13
290
|
/**
|
|
14
291
|
* Resolve strings and values from an innerHTML string
|
|
15
292
|
* @param innerHTML - The innerHTML.
|
|
16
293
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
294
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
17
295
|
*/
|
|
18
296
|
private resolveStringsAndValues;
|
|
19
297
|
/**
|
|
@@ -27,6 +305,8 @@ export declare class TemplateElement extends FASTElement {
|
|
|
27
305
|
* @param behaviorConfig - The directive behavior configuration object.
|
|
28
306
|
* @param externalValues - The interpreted values from the parent.
|
|
29
307
|
* @param innerHTML - The innerHTML.
|
|
308
|
+
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
309
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
30
310
|
*/
|
|
31
311
|
private resolveTemplateDirective;
|
|
32
312
|
/**
|
|
@@ -43,6 +323,7 @@ export declare class TemplateElement extends FASTElement {
|
|
|
43
323
|
* @param values - The interpreted values.
|
|
44
324
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
45
325
|
* @param behaviorConfig - The binding behavior configuration object.
|
|
326
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
46
327
|
*/
|
|
47
328
|
private resolveDataBinding;
|
|
48
329
|
/**
|
|
@@ -51,13 +332,9 @@ export declare class TemplateElement extends FASTElement {
|
|
|
51
332
|
* @param strings - The strings array.
|
|
52
333
|
* @param values - The interpreted values.
|
|
53
334
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
335
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
54
336
|
*/
|
|
55
337
|
private resolveInnerHTML;
|
|
56
|
-
/**
|
|
57
|
-
* Resolve all partial templates
|
|
58
|
-
* @param unresolvedInnerHTML - The innerHTML.
|
|
59
|
-
*/
|
|
60
|
-
private resolveAllPartials;
|
|
61
338
|
}
|
|
62
339
|
|
|
63
340
|
export { }
|