@microsoft/fast-element
Advanced tools
Comparing version 0.10.0 to 0.10.1
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.10.1](https://github.com/Microsoft/fast-dna/compare/@microsoft/fast-element@0.10.0...@microsoft/fast-element@0.10.1) (2020-06-09) | ||
**Note:** Version bump only for package @microsoft/fast-element | ||
# [0.10.0](https://github.com/Microsoft/fast-dna/compare/@microsoft/fast-element@0.9.0...@microsoft/fast-element@0.10.0) (2020-06-05) | ||
@@ -8,0 +16,0 @@ |
import { Accessor } from "./observation/observable"; | ||
/** | ||
* Represents objects that can convert values to a string | ||
* acceptable by the DOM, or from a DOM string into a primitive | ||
* type appropriate for a property. | ||
* @beta | ||
*/ | ||
export interface ValueConverter { | ||
/** | ||
* Converts a value to a DOM string. | ||
* @param value - The value to convert to a DOM string. | ||
*/ | ||
toView(value: any): string | null; | ||
/** | ||
* Converts a DOM string to a typed value. | ||
* @param value - The DOM string to convert to a typed value. | ||
*/ | ||
fromView(value: string): any; | ||
} | ||
/** | ||
* The mode that specifies the runtime behavior of the attribute. | ||
* @remarks | ||
* By default, attributes run in `reflect` mode, propagating their property | ||
* values to the DOM and DOM values to the property. The `boolean` mode also | ||
* reflects values, but uses the HTML standard boolean attribute behavior, | ||
* interpreting the presence of the attribute as `true` and the absence as | ||
* `false`. The `fromView` behavior only updates the property value based on | ||
* changes in the DOM, but does not reflect property changes back. | ||
* @public | ||
*/ | ||
export declare type AttributeMode = "reflect" | "boolean" | "fromView"; | ||
/** | ||
* Metadata used to configure a custom attribute's behavior. | ||
* @public | ||
*/ | ||
export declare type AttributeConfiguration = { | ||
@@ -13,20 +42,84 @@ property: string; | ||
}; | ||
/** | ||
* Metadata used to configure a custom attribute's behavior through a decorator. | ||
* @public | ||
*/ | ||
export declare type DecoratorAttributeConfiguration = Omit<AttributeConfiguration, "property">; | ||
/** | ||
* A {@link ValueConverter} that converts to and from `boolean` values. | ||
* @remarks | ||
* Used automatically when the `boolean` {@link AttributeMode} is selected. | ||
* @public | ||
*/ | ||
export declare const booleanConverter: ValueConverter; | ||
/** | ||
* A {@link ValueConverter} that converts to and from `number` values. | ||
* @remarks | ||
* This converter allows for nullable numbers, returning `null` if the | ||
* input was `null`, `undefined`, or `NaN`. | ||
* @public | ||
*/ | ||
export declare const nullableNumberConverter: ValueConverter; | ||
/** | ||
* An implementation of {@link Accessor} that supports reactivity, | ||
* change callbacks, attribute reflection, and type conversion for | ||
* custom elements. | ||
* @public | ||
*/ | ||
export declare class AttributeDefinition implements Accessor { | ||
private readonly fieldName; | ||
private readonly callbackName; | ||
private readonly hasCallback; | ||
private readonly guards; | ||
/** | ||
* The class constructor that owns this attribute. | ||
*/ | ||
readonly Owner: Function; | ||
/** | ||
* The name of the property associated with the attribute. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* The name of the attribute in HTML. | ||
*/ | ||
readonly attribute: string; | ||
/** | ||
* The {@link AttributeMode} that describes the behavior of this attribute. | ||
*/ | ||
readonly mode: AttributeMode; | ||
readonly converter?: ValueConverter | undefined; | ||
private readonly fieldName; | ||
private readonly callbackName; | ||
private readonly hasCallback; | ||
private readonly guards; | ||
constructor(Owner: Function, name: string, attribute?: string, mode?: AttributeMode, converter?: ValueConverter | undefined); | ||
/** | ||
* A {@link ValueConverter} that integrates with the property getter/setter | ||
* to convert values to and from a DOM string. | ||
*/ | ||
readonly converter?: ValueConverter; | ||
/** | ||
* Creates an instance of AttributeDefinition. | ||
* @param Owner - The class constructor that owns this attribute. | ||
* @param name - The name of the property associated with the attribute. | ||
* @param attribute - The name of the attribute in HTML. | ||
* @param mode - The {@link AttributeMode} that describes the behavior of this attribute. | ||
* @param converter - A {@link ValueConverter} that integrates with the property getter/setter | ||
* to convert values to and from a DOM string. | ||
*/ | ||
constructor(Owner: Function, name: string, attribute?: string, mode?: AttributeMode, converter?: ValueConverter); | ||
/** | ||
* Sets the value of the attribute/property on the source element. | ||
* @param source - The source element to access. | ||
* @param value - The value to set the attribute/property to. | ||
*/ | ||
setValue(source: HTMLElement, newValue: any): void; | ||
/** | ||
* Gets the value of the attribute/property on the source element. | ||
* @param source - The source element to access. | ||
*/ | ||
getValue(source: HTMLElement): any; | ||
/** @internal */ | ||
onAttributeChangedCallback(element: HTMLElement, value: any): void; | ||
private tryReflectToAttribute; | ||
/** | ||
* Collects all attribute definitions associated with the owner. | ||
* @param Owner - The class constructor to collect attribute for. | ||
* @param attributeLists - Any existing attributes to collect and merge with those associated with the owner. | ||
* @internal | ||
*/ | ||
static collect(Owner: Function, ...attributeLists: (ReadonlyArray<string | AttributeConfiguration> | undefined)[]): ReadonlyArray<AttributeDefinition>; | ||
@@ -36,12 +129,12 @@ } | ||
* Decorator: Specifies an HTML attribute. | ||
* | ||
* @param config - The overrides | ||
* @param config - The configuration for the attribute. | ||
* @public | ||
*/ | ||
export declare function attr(config?: DecoratorAttributeConfiguration): (target: {}, property: string) => void; | ||
/** | ||
* Decorator: Specifies an HTML attribute. | ||
* | ||
* @param target - The class | ||
* @param prop - The property name | ||
* Decorator: Specifies an HTML attribute. | ||
* @param target - The class to define the attribute on. | ||
* @param prop - The property name to be associated with the attribute. | ||
* @public | ||
*/ | ||
export declare function attr(target: {}, prop: string): void; |
@@ -6,19 +6,91 @@ import { FASTElementDefinition } from "./fast-definitions"; | ||
import { ElementStyles, StyleTarget } from "./styles"; | ||
/** | ||
* Controls the lifecycle and rendering of a `FASTElement`. | ||
* @public | ||
*/ | ||
export declare class Controller extends PropertyChangeNotifier { | ||
private boundObservables; | ||
private behaviors; | ||
/** | ||
* The element being controlled by this controller. | ||
*/ | ||
readonly element: HTMLElement; | ||
/** | ||
* The element definition that instructs this controller | ||
* in how to handle rendering and other platform integrations. | ||
*/ | ||
readonly definition: FASTElementDefinition; | ||
view: ElementView | null; | ||
isConnected: boolean; | ||
private boundObservables; | ||
private behaviors; | ||
/** | ||
* The view associated with the custom element. | ||
* @remarks | ||
* If `null` then the element is managing its own rendering. | ||
*/ | ||
readonly view: ElementView | null; | ||
/** | ||
* Indicates whether or not the custom element has been | ||
* connected to the document. | ||
*/ | ||
readonly isConnected: boolean; | ||
/** | ||
* Creates a Controller to control the specified element. | ||
* @param element - The element to be controlled by this controller. | ||
* @param definition - The element definition metadata that instructs this | ||
* controller in how to handle rendering and other platform integrations. | ||
* @internal | ||
*/ | ||
constructor(element: HTMLElement, definition: FASTElementDefinition); | ||
addStyles(styles: ElementStyles, target?: StyleTarget | null): void; | ||
/** | ||
* Adds styles to this element. | ||
* @param styles - The styles to add. | ||
*/ | ||
addStyles(styles: ElementStyles, | ||
/** @internal */ target?: StyleTarget | null): void; | ||
/** | ||
* Removes styles from this element. | ||
* @param styles - the styles to remove. | ||
*/ | ||
removeStyles(styles: ElementStyles): void; | ||
/** | ||
* Adds behaviors to this element. | ||
* @param behaviors - The behaviors to add. | ||
*/ | ||
addBehaviors(behaviors: ReadonlyArray<Behavior>): void; | ||
/** | ||
* Removes behaviors from this element. | ||
* @param behaviors - The behaviors to remove. | ||
*/ | ||
removeBehaviors(behaviors: ReadonlyArray<Behavior>): void; | ||
/** | ||
* Runs connected lifecycle behavior on the associated element. | ||
*/ | ||
onConnectedCallback(): void; | ||
/** | ||
* Runs disconnected lifecycle behavior on the associated element. | ||
*/ | ||
onDisconnectedCallback(): void; | ||
/** | ||
* Runs the attribute changed callback for the associated element. | ||
* @param name - The name of the attribute that changed. | ||
* @param oldValue - The previous value of the attribute. | ||
* @param newValue - The new value of the attribute. | ||
*/ | ||
onAttributeChangedCallback(name: string, oldValue: string, newValue: string): void; | ||
/** | ||
* Emits a custom HTML event. | ||
* @param type - The type name of the event. | ||
* @param detail - The event detail object to send with the event. | ||
* @param options - The event options. By default bubbles and composed. | ||
* @remarks | ||
* Only emits events if connected. | ||
*/ | ||
emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): void | boolean; | ||
/** | ||
* Locates or creates a controller for the specified element. | ||
* @param element - The element to return the controller for. | ||
* @remarks | ||
* The specified element must have a {@link FASTElementDefinition} | ||
* registered either through the use of the {@link customElement} | ||
* decorator or a call to `FASTElement.define`. | ||
*/ | ||
static forCustomElement(element: HTMLElement): Controller; | ||
} |
import { ExecutionContext } from "../observation/observable"; | ||
/** | ||
* Represents and object that can contribute behavior to a view or | ||
* element's bind/unbind operations. | ||
* @public | ||
*/ | ||
export interface Behavior { | ||
/** | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
bind(source: unknown, context: ExecutionContext): void; | ||
/** | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
unbind(source: unknown): void; | ||
} | ||
/** | ||
* A factory that can create a {@link Behavior} associated with a particular | ||
* location within a DOM fragment. | ||
* @public | ||
*/ | ||
export interface BehaviorFactory { | ||
/** | ||
* The index of the DOM node to which the created behavior will apply. | ||
*/ | ||
targetIndex: number; | ||
createBehavior(target: any): Behavior; | ||
/** | ||
* Creates a behavior for the provided target node. | ||
* @param target - The node instance to create the behavior for. | ||
*/ | ||
createBehavior(target: Node): Behavior; | ||
} |
@@ -9,2 +9,3 @@ import { ExecutionContext, Binding, BindingObserver } from "../observation/observable"; | ||
* A directive that configures data binding to element content and attributes. | ||
* @public | ||
*/ | ||
@@ -15,3 +16,2 @@ export declare class BindingDirective extends Directive { | ||
private originalTargetName?; | ||
createPlaceholder: (index: number) => string; | ||
private bind; | ||
@@ -21,15 +21,16 @@ private unbind; | ||
/** | ||
* Creates a placeholder string based on the directive's index within the template. | ||
* @param index - The index of the directive within the template. | ||
*/ | ||
createPlaceholder: (index: number) => string; | ||
/** | ||
* Creates an instance of BindingDirective. | ||
* @param binding A binding that returns the data used to update the DOM. | ||
* @param binding - A binding that returns the data used to update the DOM. | ||
*/ | ||
constructor(binding: Binding); | ||
/** | ||
* Gets the name of the attribute or property that this | ||
* Gets/sets the name of the attribute or property that this | ||
* binding is targeting. | ||
*/ | ||
get targetName(): string | undefined; | ||
/** | ||
* Sets the name of the attribute or property tha this | ||
* binding is targeting. | ||
*/ | ||
set targetName(value: string | undefined); | ||
@@ -44,5 +45,5 @@ /** | ||
* information stored in the BindingDirective. | ||
* @param target The target node that the binding behavior should attach to. | ||
* @param target - The target node that the binding behavior should attach to. | ||
*/ | ||
createBehavior(target: any): BindingBehavior; | ||
createBehavior(target: Node): BindingBehavior; | ||
} | ||
@@ -52,34 +53,49 @@ /** | ||
* BindingDirective. | ||
* @public | ||
*/ | ||
export declare class BindingBehavior implements Behavior { | ||
target: any; | ||
binding: Binding; | ||
bind: typeof normalBind; | ||
unbind: typeof normalUnbind; | ||
updateTarget: typeof updatePropertyTarget; | ||
targetName?: string | undefined; | ||
/** @internal */ | ||
source: unknown; | ||
/** @internal */ | ||
context: ExecutionContext | null; | ||
/** @internal */ | ||
bindingObserver: BindingObserver | null; | ||
/** @internal */ | ||
classVersions: Record<string, number>; | ||
/** @internal */ | ||
version: number; | ||
/** @internal */ | ||
target: any; | ||
/** @internal */ | ||
binding: Binding; | ||
/** @internal */ | ||
updateTarget: typeof updatePropertyTarget; | ||
/** @internal */ | ||
targetName?: string; | ||
/** | ||
* | ||
* @param target The target of the data updates. | ||
* @param binding The binding that returns the latest value for an update. | ||
* @param bind The operation to perform during binding. | ||
* @param unbind The operation to perform during unbinding. | ||
* @param updateTarget The operation to perform when updating. | ||
* @param targetName The name of the target attribute or property to update. | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
constructor(target: any, binding: Binding, bind: typeof normalBind, unbind: typeof normalUnbind, updateTarget: typeof updatePropertyTarget, targetName?: string | undefined); | ||
bind: typeof normalBind; | ||
/** | ||
* @internal | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
handleChange(): void; | ||
unbind: typeof normalUnbind; | ||
/** | ||
* @internal | ||
* Creates an instance of BindingBehavior. | ||
* @param target - The target of the data updates. | ||
* @param binding - The binding that returns the latest value for an update. | ||
* @param bind - The operation to perform during binding. | ||
* @param unbind - The operation to perform during unbinding. | ||
* @param updateTarget - The operation to perform when updating. | ||
* @param targetName - The name of the target attribute or property to update. | ||
*/ | ||
constructor(target: any, binding: Binding, bind: typeof normalBind, unbind: typeof normalUnbind, updateTarget: typeof updatePropertyTarget, targetName?: string); | ||
/** @internal */ | ||
handleChange(): void; | ||
/** @internal */ | ||
handleEvent(event: Event): void; | ||
} | ||
export {}; |
import { CaptureType } from "../template"; | ||
import { NodeBehaviorBehaviorOptions, NodeObservationBehavior } from "./node-observation"; | ||
/** | ||
* The options used to configure child node observation. | ||
* @public | ||
*/ | ||
export interface ChildrenBehaviorOptions<T = any> extends NodeBehaviorBehaviorOptions<T>, MutationObserverInit { | ||
} | ||
/** | ||
* The runtime behavior for child node observation. | ||
* @public | ||
*/ | ||
export declare class ChildrenBehavior extends NodeObservationBehavior<ChildrenBehaviorOptions> { | ||
private observer; | ||
/** | ||
* Creates an instance of ChildrenBehavior. | ||
* @param target - The element target to observe children on. | ||
* @param options - The options to use when observing the element children. | ||
*/ | ||
constructor(target: HTMLSlotElement, options: ChildrenBehaviorOptions); | ||
getNodes(): ChildNode[]; | ||
/** | ||
* Begins observation of the nodes. | ||
*/ | ||
observe(): void; | ||
unobserve(): void; | ||
/** | ||
* Disconnects observation of the nodes. | ||
*/ | ||
disconnect(): void; | ||
/** | ||
* Retrieves the nodes that should be assigned to the target. | ||
*/ | ||
protected getNodes(): ChildNode[]; | ||
} | ||
/** | ||
* A directive that observes the `childNodes` of an element and updates a property | ||
* whenever they change. | ||
* @param propertyOrOptions - The options used to configure child node observation. | ||
* @public | ||
*/ | ||
export declare function children<T = any>(propertyOrOptions: (keyof T & string) | ChildrenBehaviorOptions<keyof T & string>): CaptureType<T>; |
import { Behavior, BehaviorFactory } from "./behavior"; | ||
/** | ||
* Instructs the template engine to apply behavior to a node. | ||
* @public | ||
*/ | ||
export declare abstract class Directive implements BehaviorFactory { | ||
/** | ||
* The index of the DOM node to which the created behavior will apply. | ||
*/ | ||
targetIndex: number; | ||
/** | ||
* Creates a placeholder string based on the directive's index within the template. | ||
* @param index - The index of the directive within the template. | ||
*/ | ||
abstract createPlaceholder(index: number): string; | ||
abstract createBehavior(target: any): Behavior; | ||
/** | ||
* Creates a behavior for the provided target node. | ||
* @param target - The node instance to create the behavior for. | ||
*/ | ||
abstract createBehavior(target: Node): Behavior; | ||
} | ||
/** | ||
* Describes the shape of a behavior constructor that can be created by | ||
* an {@link AttachedBehaviorDirective}. | ||
* @public | ||
*/ | ||
export declare type AttachedBehaviorType<T = any> = new (target: any, options: T) => Behavior; | ||
/** | ||
* A directive that attaches special behavior to an element via a custom attribute. | ||
* @public | ||
*/ | ||
export declare class AttachedBehaviorDirective<T = any> extends Directive { | ||
@@ -12,5 +36,24 @@ private name; | ||
private options; | ||
/** | ||
* | ||
* @param name - The name of the behavior; used as a custom attribute on the element. | ||
* @param behavior - The behavior to instantiate and attach to the element. | ||
* @param options - Options to pass to the behavior during creation. | ||
*/ | ||
constructor(name: string, behavior: AttachedBehaviorType<T>, options: T); | ||
/** | ||
* Creates a placeholder string based on the directive's index within the template. | ||
* @param index - The index of the directive within the template. | ||
* @remarks | ||
* Creates a custom attribute placeholder. | ||
*/ | ||
createPlaceholder(index: number): string; | ||
createBehavior(target: any): Behavior; | ||
/** | ||
* Creates a behavior for the provided target node. | ||
* @param target - The node instance to create the behavior for. | ||
* @remarks | ||
* Creates an instance of the `behavior` type this directive was constructed with | ||
* and passes the target and options to that `behavior`'s constructor. | ||
*/ | ||
createBehavior(target: Node): Behavior; | ||
} |
import { Behavior } from "./behavior"; | ||
/** | ||
* Options for configuring node observation behavior. | ||
* @public | ||
*/ | ||
export interface NodeBehaviorBehaviorOptions<T = any> { | ||
/** | ||
* The property to assign the observed nodes to. | ||
*/ | ||
property: T; | ||
} | ||
/** | ||
* A base class for node observation. | ||
* @internal | ||
*/ | ||
export declare abstract class NodeObservationBehavior<T extends NodeBehaviorBehaviorOptions> implements Behavior { | ||
@@ -10,10 +21,34 @@ protected target: HTMLSlotElement; | ||
private shouldUpdate; | ||
/** | ||
* Creates an instance of NodeObservationBehavior. | ||
* @param target - The target to assign the nodes property on. | ||
* @param options - The options to use in configuring node observation. | ||
*/ | ||
constructor(target: HTMLSlotElement, options: T); | ||
/** | ||
* Begins observation of the nodes. | ||
*/ | ||
abstract observe(): void; | ||
abstract unobserve(): void; | ||
abstract getNodes(): Node[]; | ||
/** | ||
* Disconnects observation of the nodes. | ||
*/ | ||
abstract disconnect(): void; | ||
/** | ||
* Retrieves the nodes that should be assigned to the target. | ||
*/ | ||
protected abstract getNodes(): Node[]; | ||
/** | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
bind(source: any): void; | ||
/** | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
unbind(): void; | ||
/** @internal */ | ||
handleEvent(): void; | ||
updateTarget(value: ReadonlyArray<any>): void; | ||
private updateTarget; | ||
} |
import { CaptureType } from "../template"; | ||
import { Behavior } from "./behavior"; | ||
/** | ||
* The runtime behavior for template references. | ||
* @public | ||
*/ | ||
export declare class RefBehavior implements Behavior { | ||
private target; | ||
private propertyName; | ||
/** | ||
* Creates an instance of RefBehavior. | ||
* @param target - The element to reference. | ||
* @param propertyName - The name of the property to assign the reference to. | ||
*/ | ||
constructor(target: HTMLElement, propertyName: string); | ||
/** | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
bind(source: any): void; | ||
/** | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
unbind(): void; | ||
} | ||
/** | ||
* A directive that observes the updates a property with a reference to the element. | ||
* @param propertyName - The name of the property to assign the reference to. | ||
* @public | ||
*/ | ||
export declare function ref<T = any>(propertyName: keyof T & string): CaptureType<T>; |
@@ -7,5 +7,16 @@ import { CaptureType, SyntheticViewTemplate, ViewTemplate } from "../template"; | ||
import { Directive } from "./directive"; | ||
/** | ||
* Options for configuring repeat behavior. | ||
* @public | ||
*/ | ||
export interface RepeatOptions { | ||
/** | ||
* Enables index, length, and dependent positioning updates in item templates. | ||
*/ | ||
positioning: boolean; | ||
} | ||
/** | ||
* A behavior that renders a template for each item in an array. | ||
* @public | ||
*/ | ||
export declare class RepeatBehavior implements Behavior, Subscriber { | ||
@@ -24,5 +35,22 @@ private location; | ||
private bindView; | ||
/** | ||
* Creates an instance of RepeatBehavior. | ||
* @param location - The location in the DOM to render the repeat. | ||
* @param binding - The array to render. | ||
* @param template - The template to render for each item. | ||
* @param options - Options used to turn on special repeat features. | ||
*/ | ||
constructor(location: Node, binding: Binding, template: SyntheticViewTemplate, options: RepeatOptions); | ||
/** | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
bind(source: unknown, context: ExecutionContext): void; | ||
/** | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
unbind(): void; | ||
/** @internal */ | ||
handleChange(source: any, args: Splice[]): void; | ||
@@ -34,2 +62,6 @@ private observeItems; | ||
} | ||
/** | ||
* A directive that configures list rendering. | ||
* @public | ||
*/ | ||
export declare class RepeatDirective extends Directive { | ||
@@ -39,6 +71,27 @@ binding: Binding; | ||
options: RepeatOptions; | ||
/** | ||
* Creates a placeholder string based on the directive's index within the template. | ||
* @param index - The index of the directive within the template. | ||
*/ | ||
createPlaceholder: (index: number) => string; | ||
/** | ||
* Creates an instance of RepeatDirective. | ||
* @param binding - The binding that provides the array to render. | ||
* @param template - The template to render for each item in the array. | ||
* @param options - Options used to turn on special repeat features. | ||
*/ | ||
constructor(binding: Binding, template: SyntheticViewTemplate, options: RepeatOptions); | ||
createBehavior(target: any): RepeatBehavior; | ||
/** | ||
* Creates a behavior for the provided target node. | ||
* @param target - The node instance to create the behavior for. | ||
*/ | ||
createBehavior(target: Node): RepeatBehavior; | ||
} | ||
/** | ||
* A directive that enables list rendering. | ||
* @param binding - The array to render. | ||
* @param template - The template to render for each item in the array. | ||
* @param options - Options used to turn on special repeat features. | ||
* @public | ||
*/ | ||
export declare function repeat<TScope = any, TItem = any>(binding: Binding<TScope, TItem[]>, template: ViewTemplate<Partial<TItem>, TScope>, options?: RepeatOptions): CaptureType<TScope>; |
import { CaptureType } from "../template"; | ||
import { NodeBehaviorBehaviorOptions, NodeObservationBehavior } from "./node-observation"; | ||
/** | ||
* The options used to configure slotted node observation. | ||
* @public | ||
*/ | ||
export interface SlottedBehaviorOptions<T = any> extends NodeBehaviorBehaviorOptions<T>, AssignedNodesOptions { | ||
} | ||
/** | ||
* The runtime behavior for slotted node observation. | ||
* @public | ||
*/ | ||
export declare class SlottedBehavior extends NodeObservationBehavior<SlottedBehaviorOptions> { | ||
/** | ||
* Creates an instance of SlottedBehavior. | ||
* @param target - The slot element target to observe. | ||
* @param options - The options to use when observing the slot. | ||
*/ | ||
constructor(target: HTMLSlotElement, options: SlottedBehaviorOptions); | ||
getNodes(): Node[]; | ||
/** | ||
* Begins observation of the nodes. | ||
*/ | ||
observe(): void; | ||
unobserve(): void; | ||
/** | ||
* Disconnects observation of the nodes. | ||
*/ | ||
disconnect(): void; | ||
/** | ||
* Retrieves the nodes that should be assigned to the target. | ||
*/ | ||
protected getNodes(): Node[]; | ||
} | ||
/** | ||
* A directive that observes the `assignedNodes()` of a slot and updates a property | ||
* whenever they change. | ||
* @param propertyOrOptions - The options used to configure slotted node observation. | ||
* @public | ||
*/ | ||
export declare function slotted<T = any>(propertyOrOptions: (keyof T & string) | SlottedBehaviorOptions<keyof T & string>): CaptureType<T>; |
@@ -5,6 +5,7 @@ import { CaptureType, SyntheticViewTemplate } from "../template"; | ||
* A directive that enables basic conditional rendering in a template. | ||
* @param binding The condition to test for rendering. | ||
* @param templateOrTemplateBinding The template or a binding that gets | ||
* @param binding - The condition to test for rendering. | ||
* @param templateOrTemplateBinding - The template or a binding that gets | ||
* the template to render when the condition is true. | ||
* @public | ||
*/ | ||
export declare function when<TSource = any, TReturn = any>(binding: Binding<TSource, TReturn>, templateOrTemplateBinding: SyntheticViewTemplate | Binding<TSource, SyntheticViewTemplate>): CaptureType<TSource>; |
@@ -7,14 +7,58 @@ import { Callable } from "./interfaces"; | ||
* Common DOM APIs. | ||
* @public | ||
*/ | ||
export declare const DOM: Readonly<{ | ||
/** | ||
* Sets the HTML trusted types policy used by the templating engine. | ||
* @param policy - The policy to set for HTML. | ||
* @remarks | ||
* This API can only be called once, for security reasons. It should be | ||
* called by the application developer at the start of their program. | ||
*/ | ||
setHTMLPolicy(policy: TrustedTypesPolicy): void; | ||
/** | ||
* Turns a string into trusted HTML using the configured trusted types policy. | ||
* @param html - The string to turn into trusted HTML. | ||
* @remarks | ||
* Used internally by the template engine when creating templates | ||
* and setting innerHTML. | ||
*/ | ||
createHTML(html: string): string; | ||
/** | ||
* Determines if the provided node is a template marker used by the runtime. | ||
* @param node - The node to test. | ||
*/ | ||
isMarker(node: Node): node is Comment; | ||
/** | ||
* Given a marker node, extract the {@link Directive} index from the placeholder. | ||
* @param node - The marker node to extract the index from. | ||
*/ | ||
extractDirectiveIndexFromMarker(node: Comment): number; | ||
/** | ||
* Creates a placeholder string suitable for marking out a location *within* | ||
* an attribute value or HTML content. | ||
* @param index - The directive index to create the placeholder for. | ||
* @remarks | ||
* Used internally by binding directives. | ||
*/ | ||
createInterpolationPlaceholder(index: number): string; | ||
/** | ||
* Creates a placeholder that manifests itself as an attribute on an | ||
* element. | ||
* @param attributeName - The name of the custom attribute. | ||
* @param index - The directive index to create the placeholder for. | ||
* @remarks | ||
* Used internally by attribute directives such as `ref`, `slotted`, and `children`. | ||
*/ | ||
createCustomAttributePlaceholder(attributeName: string, index: number): string; | ||
/** | ||
* Creates a placeholder that manifests itself as a marker within the DOM structure. | ||
* @param index - The directive index to create the placeholder for. | ||
* @remarks | ||
* Used internally by structural directives such as `repeat`. | ||
*/ | ||
createBlockPlaceholder(index: number): string; | ||
/** | ||
* Schedules DOM update work in the next async batch. | ||
* @param callable The callable function or object to queue. | ||
* @param callable - The callable function or object to queue. | ||
*/ | ||
@@ -26,5 +70,22 @@ queueUpdate(callable: Callable): void; | ||
nextUpdate(): Promise<void>; | ||
/** | ||
* Sets an attribute value on an element. | ||
* @param element - The element to set the attribute value on. | ||
* @param attributeName - The attribute name to set. | ||
* @param value - The value of the attribute to set. | ||
* @remarks | ||
* If the value is `null` or `undefined`, the attribute is removed, otherwise | ||
* it is set to the provided value using the standard `setAttribute` API. | ||
*/ | ||
setAttribute(element: HTMLElement, attributeName: string, value: any): void; | ||
/** | ||
* Sets a boolean attribute value. | ||
* @param element - The element to set the boolean attribute value on. | ||
* @param attributeName - The attribute name to set. | ||
* @param value - The value of the attribute to set. | ||
* @remarks | ||
* If the value is true, the attribute is added; otherwise it is removed. | ||
*/ | ||
setBooleanAttribute(element: HTMLElement, attributeName: string, value: boolean): void; | ||
}>; | ||
export {}; |
import { ElementViewTemplate } from "./template"; | ||
import { ElementStyles } from "./styles"; | ||
import { AttributeConfiguration, AttributeDefinition } from "./attributes"; | ||
/** | ||
* Defines metadata for a FASTElement. | ||
* @public | ||
*/ | ||
export declare class FASTElementDefinition { | ||
/** | ||
* The name of the custom element. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* The custom attributes of the custom element. | ||
*/ | ||
readonly attributes: ReadonlyArray<AttributeDefinition>; | ||
/** | ||
* A map enabling lookup of attribute by associated property name. | ||
*/ | ||
readonly propertyLookup: Record<string, AttributeDefinition>; | ||
/** | ||
* A map enabling lookup of property by associated attribute name. | ||
*/ | ||
readonly attributeLookup: Record<string, AttributeDefinition>; | ||
readonly template?: ElementViewTemplate | undefined; | ||
readonly styles?: ElementStyles | undefined; | ||
readonly shadowOptions?: ShadowRootInit | undefined; | ||
readonly elementOptions?: ElementDefinitionOptions | undefined; | ||
constructor(name: string, attributes: ReadonlyArray<AttributeDefinition>, propertyLookup: Record<string, AttributeDefinition>, attributeLookup: Record<string, AttributeDefinition>, template?: ElementViewTemplate | undefined, styles?: ElementStyles | undefined, shadowOptions?: ShadowRootInit | undefined, elementOptions?: ElementDefinitionOptions | undefined); | ||
/** | ||
* The template to render for the custom element. | ||
*/ | ||
readonly template?: ElementViewTemplate; | ||
/** | ||
* The styles to associated with the custom element. | ||
*/ | ||
readonly styles?: ElementStyles; | ||
/** | ||
* Options controlling the creation of the custom element's shadow DOM. | ||
*/ | ||
readonly shadowOptions?: ShadowRootInit; | ||
/** | ||
* Options controlling how the custom element is defined with the platform. | ||
*/ | ||
readonly elementOptions?: ElementDefinitionOptions; | ||
/** | ||
* Creates an instance of FASTElementDefinition. | ||
* @param name - The name of the custom element. | ||
* @param attributes - The custom attributes of the custom element. | ||
* @param propertyLookup - A map enabling lookup of attribute by associated property name. | ||
* @param attributeLookup - A map enabling lookup of property by associated attribute name. | ||
* @param template - The template to render for the custom element. | ||
* @param styles - The styles to associated with the custom element. | ||
* @param shadowOptions - Options controlling the creation of the custom element's shadow DOM. | ||
* @param elementOptions - Options controlling how the custom element is defined with the platform. | ||
*/ | ||
constructor(name: string, attributes: ReadonlyArray<AttributeDefinition>, propertyLookup: Record<string, AttributeDefinition>, attributeLookup: Record<string, AttributeDefinition>, template?: ElementViewTemplate, styles?: ElementStyles, shadowOptions?: ShadowRootInit, elementOptions?: ElementDefinitionOptions); | ||
} | ||
export declare type PartialFASTElementDefinition = { | ||
/** | ||
* Represents metadata configuration for a custom element. | ||
* @public | ||
*/ | ||
export interface PartialFASTElementDefinition { | ||
/** | ||
* The name of the custom element. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* The template to render for the custom element. | ||
*/ | ||
readonly template?: ElementViewTemplate; | ||
/** | ||
* The styles to associated with the custom element. | ||
*/ | ||
readonly styles?: ElementStyles; | ||
/** | ||
* The custom attributes of the custom element. | ||
*/ | ||
readonly attributes?: (AttributeConfiguration | string)[]; | ||
/** | ||
* Options controlling the creation of the custom element's shadow DOM. | ||
*/ | ||
readonly shadowOptions?: Partial<ShadowRootInit> | null; | ||
/** | ||
* Options controlling how the custom element is defined with the platform. | ||
*/ | ||
readonly elementOptions?: ElementDefinitionOptions; | ||
}; | ||
/** | ||
* @internal | ||
*/ | ||
} | ||
/** @internal */ | ||
export declare const fastDefinitions: Map<Function, FASTElementDefinition>; | ||
/** | ||
* @internal | ||
*/ | ||
export declare function getDefinition<T extends Function>(Type: T): FASTElementDefinition | undefined; |
import { Controller } from "./controller"; | ||
import { getDefinition, PartialFASTElementDefinition } from "./fast-definitions"; | ||
import { FASTElementDefinition, PartialFASTElementDefinition } from "./fast-definitions"; | ||
/** | ||
* Represents a custom element based on the FASTElement infrastructure. | ||
* @public | ||
*/ | ||
export interface FASTElement { | ||
$fastController: Controller; | ||
/** | ||
* The underlying controller that handles the lifecycle and rendering of | ||
* this FASTElement. | ||
*/ | ||
readonly $fastController: Controller; | ||
/** | ||
* Emits a custom HTML event. | ||
* @param type - The type name of the event. | ||
* @param detail - The event detail object to send with the event. | ||
* @param options - The event options. By default bubbles and composed. | ||
* @remarks | ||
* Only emits events if the element is connected. | ||
*/ | ||
$emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): boolean | void; | ||
/** | ||
* The connected callback for this FASTElement. | ||
* @remarks | ||
* This method is invoked by the platform whenever this FASTElement | ||
* becomes connected to the document. | ||
*/ | ||
connectedCallback(): void; | ||
/** | ||
* The disconnected callback for this FASTElement. | ||
* @remarks | ||
* This method is invoked by the platform whenever this FASTElement | ||
* becomes disconnected from the document. | ||
*/ | ||
disconnectedCallback(): void; | ||
/** | ||
* The attribute changed callback for this FASTElement. | ||
* @param name - The name of the attribute that changed. | ||
* @param oldValue - The previous value of the attribute. | ||
* @param newValue - The new value of the attribute. | ||
* @remarks | ||
* This method is invoked by the platform whenever an observed | ||
* attribute of FASTElement has a value change. | ||
*/ | ||
attributeChangedCallback(name: string, oldValue: string, newValue: string): void; | ||
} | ||
/** | ||
* A minimal base class for FASTElements that also provides | ||
* static helpers for working with FASTElements. | ||
* @public | ||
*/ | ||
export declare const FASTElement: (new () => HTMLElement & FASTElement) & { | ||
/** | ||
* Creates a new FASTElement base class inherited from the | ||
* provided base type. | ||
* @param BaseType - The base element type to inherit from. | ||
*/ | ||
from<TBase extends { | ||
@@ -15,5 +62,21 @@ new (): HTMLElement; | ||
}>(BaseType: TBase): new () => InstanceType<TBase> & FASTElement; | ||
/** | ||
* Defines a platform custom element based on the provided type and definition. | ||
* @param Type - The custom element type to define. | ||
* @param nameOrDef - The name of the element to define or a definition object | ||
* that describes the element to define. | ||
*/ | ||
define<TType extends Function>(Type: TType, nameOrDef?: string | PartialFASTElementDefinition): TType; | ||
getDefinition: typeof getDefinition; | ||
/** | ||
* Gets the element definition associated with the specified type. | ||
* @param Type - The custom element type to retrieve the definition for. | ||
*/ | ||
getDefinition<T extends Function>(Type: T): FASTElementDefinition | undefined; | ||
}; | ||
/** | ||
* Decorator: Defines a platform custom element based on `FASTElement`. | ||
* @param nameOrDef - The name of the element to define or a definition object | ||
* that describes the element to define. | ||
* @public | ||
*/ | ||
export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Function) => void; |
/** | ||
* Represents a callable type such as a function or an object with a "call" method. | ||
* @public | ||
*/ | ||
@@ -8,2 +9,9 @@ export declare type Callable = typeof Function.prototype.call | { | ||
/** | ||
* Reverses all readonly members, making them mutable. | ||
* @internal | ||
*/ | ||
export declare type Mutable<T> = { | ||
-readonly [P in keyof T]: T[P]; | ||
}; | ||
/** | ||
* A readonly, empty array. | ||
@@ -13,3 +21,4 @@ * @remarks | ||
* no actual items to return. | ||
* @internal | ||
*/ | ||
export declare const emptyArray: readonly never[]; |
/** | ||
* Represents a set of splice-based changes against an Array. | ||
* @public | ||
*/ | ||
@@ -18,5 +19,3 @@ export interface Splice { | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
/** @internal */ | ||
export declare function newSplice(index: number, removed: any[], addedCount: number): Splice; | ||
@@ -49,5 +48,3 @@ /** | ||
export declare function calcSplices(current: any[], currentStart: number, currentEnd: number, old: any[], oldStart: number, oldEnd: number): ReadonlyArray<never> | Splice[]; | ||
/** | ||
* @internal | ||
*/ | ||
/** @internal */ | ||
export declare function projectArraySplices(array: any[], changeRecords: any[]): Splice[]; |
@@ -7,3 +7,4 @@ /** | ||
* not typically necessary. | ||
* @public | ||
*/ | ||
export declare function enableArrayObservation(): void; |
/** | ||
* Implemented by objects that are interested in change notifications. | ||
* @public | ||
*/ | ||
@@ -7,4 +8,4 @@ export interface Subscriber { | ||
* Called when a source this instance has subscribed to changes. | ||
* @param source The source of the change. | ||
* @param args The event args detailing the change that occurred. | ||
* @param source - The source of the change. | ||
* @param args - The event args detailing the change that occurred. | ||
*/ | ||
@@ -15,2 +16,3 @@ handleChange(source: any, args: any): void; | ||
* Provides change notification for a source object. | ||
* @public | ||
*/ | ||
@@ -24,3 +26,3 @@ export interface Notifier { | ||
* Notifies all subscribers, based on the args. | ||
* @param args Data passed along to subscribers during notification. | ||
* @param args - Data passed along to subscribers during notification. | ||
* @remarks | ||
@@ -33,4 +35,4 @@ * In some implementations, the args may be used to target specific subscribers. | ||
* Subscribes to notification of changes in an object's state. | ||
* @param subscriber The object that is subscribing for change notification. | ||
* @param propertyToWatch The name of the property that the subscriber is interested in watching for changes. | ||
* @param subscriber - The object that is subscribing for change notification. | ||
* @param propertyToWatch - The name of the property that the subscriber is interested in watching for changes. | ||
* @remarks | ||
@@ -42,4 +44,4 @@ * Some implementation may or may not require the propertyToWatch. | ||
* Unsubscribes from notification of changes in an object's state. | ||
* @param subscriber The object that is unsubscribing from change notification. | ||
* @param propertyToUnwatch The name of the property that the subscriber is no longer interested in watching. | ||
* @param subscriber - The object that is unsubscribing from change notification. | ||
* @param propertyToUnwatch - The name of the property that the subscriber is no longer interested in watching. | ||
* @remarks | ||
@@ -59,2 +61,3 @@ * Some implementation may or may not require the propertyToUnwatch. | ||
* If the set ever exceeds two subscribers, it upgrades to an array automatically. | ||
* @public | ||
*/ | ||
@@ -71,4 +74,4 @@ export declare class SubscriberSet implements Notifier { | ||
* Creates an instance of SubscriberSet for the specified source. | ||
* @param source The object source that subscribers will receive notifications from. | ||
* @param initialSubscriber An initial subscriber to changes. | ||
* @param source - The object source that subscribers will receive notifications from. | ||
* @param initialSubscriber - An initial subscriber to changes. | ||
*/ | ||
@@ -78,3 +81,3 @@ constructor(source: any, initialSubscriber?: Subscriber); | ||
* Checks whether the provided subscriber has been added to this set. | ||
* @param subscriber The subscriber to test for inclusion in this set. | ||
* @param subscriber - The subscriber to test for inclusion in this set. | ||
*/ | ||
@@ -84,3 +87,3 @@ has(subscriber: Subscriber): boolean; | ||
* Subscribes to notification of changes in an object's state. | ||
* @param subscriber The object that is subscribing for change notification. | ||
* @param subscriber - The object that is subscribing for change notification. | ||
*/ | ||
@@ -90,3 +93,3 @@ subscribe(subscriber: Subscriber): void; | ||
* Unsubscribes from notification of changes in an object's state. | ||
* @param subscriber The object that is unsubscribing from change notification. | ||
* @param subscriber - The object that is unsubscribing from change notification. | ||
*/ | ||
@@ -96,3 +99,3 @@ unsubscribe(subscriber: Subscriber): void; | ||
* Notifies all subscribers. | ||
* @param args Data passed along to subscribers during notification. | ||
* @param args - Data passed along to subscribers during notification. | ||
*/ | ||
@@ -104,2 +107,3 @@ notify(args: any): void; | ||
* of individual property changes on an object. | ||
* @public | ||
*/ | ||
@@ -114,3 +118,3 @@ export declare class PropertyChangeNotifier implements Notifier { | ||
* Creates an instance of PropertyChangeNotifier for the specified source. | ||
* @param source The object source that subscribers will receive notifications from. | ||
* @param source - The object source that subscribers will receive notifications from. | ||
*/ | ||
@@ -120,3 +124,3 @@ constructor(source: any); | ||
* Notifies all subscribers, based on the specified property. | ||
* @param propertyName The property name, passed along to subscribers during notification. | ||
* @param propertyName - The property name, passed along to subscribers during notification. | ||
*/ | ||
@@ -126,4 +130,4 @@ notify(propertyName: string): void; | ||
* Subscribes to notification of changes in an object's state. | ||
* @param subscriber The object that is subscribing for change notification. | ||
* @param propertyToWatch The name of the property that the subscriber is interested in watching for changes. | ||
* @param subscriber - The object that is subscribing for change notification. | ||
* @param propertyToWatch - The name of the property that the subscriber is interested in watching for changes. | ||
*/ | ||
@@ -133,6 +137,6 @@ subscribe(subscriber: Subscriber, propertyToWatch: string): void; | ||
* Unsubscribes from notification of changes in an object's state. | ||
* @param subscriber The object that is unsubscribing from change notification. | ||
* @param propertyToUnwatch The name of the property that the subscriber is no longer interested in watching. | ||
* @param subscriber - The object that is unsubscribing from change notification. | ||
* @param propertyToUnwatch - The name of the property that the subscriber is no longer interested in watching. | ||
*/ | ||
unsubscribe(subscriber: Subscriber, propertyToUnwatch: string): void; | ||
} |
import { Notifier, Subscriber } from "./notifier"; | ||
/** | ||
* Represents a getter/setter property accessor on an object. | ||
* @public | ||
*/ | ||
@@ -12,3 +13,3 @@ export interface Accessor { | ||
* Gets the value of the property on the source object. | ||
* @param source The source object to access. | ||
* @param source - The source object to access. | ||
*/ | ||
@@ -18,4 +19,4 @@ getValue(source: any): any; | ||
* Sets the value of the property on the source object. | ||
* @param source The source object to access. | ||
* @param value The value to set the property to. | ||
* @param source - The source object to access. | ||
* @param value - The value to set the property to. | ||
*/ | ||
@@ -26,2 +27,3 @@ setValue(source: any, value: any): void; | ||
* Common Observable APIs. | ||
* @public | ||
*/ | ||
@@ -31,3 +33,3 @@ export declare const Observable: Readonly<{ | ||
* @internal | ||
* @param factory The factory used to create array observers. | ||
* @param factory - The factory used to create array observers. | ||
*/ | ||
@@ -37,3 +39,3 @@ setArrayObserverFactory(factory: (collection: any[]) => Notifier): void; | ||
* Gets a notifier for an object or Array. | ||
* @param source The object or Array to get the notifier for. | ||
* @param source - The object or Array to get the notifier for. | ||
*/ | ||
@@ -43,4 +45,4 @@ getNotifier(source: any): Notifier; | ||
* Records a property change for a source object. | ||
* @param source The object to record the change against. | ||
* @param propertyName The property to track as changed. | ||
* @param source - The object to record the change against. | ||
* @param propertyName - The property to track as changed. | ||
*/ | ||
@@ -50,4 +52,4 @@ track(source: unknown, propertyName: string): void; | ||
* Notifies subscribers of a source object of changes. | ||
* @param source the object to notify of changes. | ||
* @param args The change args to pass to subscribers. | ||
* @param source - the object to notify of changes. | ||
* @param args - The change args to pass to subscribers. | ||
*/ | ||
@@ -57,4 +59,4 @@ notify(source: unknown, args: any): void; | ||
* Defines an observable property on an object or prototype. | ||
* @param target The target object to define the observable on. | ||
* @param nameOrAccessor The name of the property to define as observable; | ||
* @param target - The target object to define the observable on. | ||
* @param nameOrAccessor - The name of the property to define as observable; | ||
* or a custom accessor that specifies the property name and accessor implementation. | ||
@@ -66,3 +68,3 @@ */ | ||
* including its prototype chain. | ||
* @param target The target object to search for accessor on. | ||
* @param target - The target object to search for accessor on. | ||
*/ | ||
@@ -73,4 +75,4 @@ getAccessors(target: {}): Accessor[]; | ||
* provided {@link Binding} for changes. | ||
* @param binding The binding to observe. | ||
* @param initialSubscriber An initial subscriber to changes in the binding value. | ||
* @param binding - The binding to observe. | ||
* @param initialSubscriber - An initial subscriber to changes in the binding value. | ||
*/ | ||
@@ -81,9 +83,10 @@ binding<TScope = any, TReturn = any, TParent = any>(binding: Binding<any, any, any>, initialSubscriber?: Subscriber | undefined): BindingObserver<TScope, TReturn, TParent>; | ||
* Decorator: Defines an observable property on the target. | ||
* @param target The target to define the observable on. | ||
* @param nameOrAccessor The property name or accessor to define the observable as. | ||
* @param target - The target to define the observable on. | ||
* @param nameOrAccessor - The property name or accessor to define the observable as. | ||
* @public | ||
*/ | ||
export declare function observable(target: {}, nameOrAccessor: string | Accessor): void; | ||
/** | ||
* @param event - The event to set as current for the context. | ||
* @internal | ||
* @param event The event to set as current for the context. | ||
*/ | ||
@@ -93,2 +96,3 @@ export declare function setCurrentEvent(event: Event | null): void; | ||
* Provides additional contextual information available to behaviors and expressions. | ||
* @public | ||
*/ | ||
@@ -140,2 +144,3 @@ export declare class ExecutionContext<TParent = any> { | ||
* The default execution context used in binding expressions. | ||
* @public | ||
*/ | ||
@@ -146,2 +151,3 @@ export declare const defaultExecutionContext: ExecutionContext<any>; | ||
* as part of a template binding update. | ||
* @public | ||
*/ | ||
@@ -151,2 +157,3 @@ export declare type Binding<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn; | ||
* Enables evaluation of and subscription to a binding. | ||
* @public | ||
*/ | ||
@@ -156,4 +163,4 @@ export interface BindingObserver<TSource = any, TReturn = any, TParent = any> extends Notifier { | ||
* Begins observing the binding for the source and returns the current value. | ||
* @param source The source that the binding is based on. | ||
* @param context The execution context to execute the binding within. | ||
* @param source - The source that the binding is based on. | ||
* @param context - The execution context to execute the binding within. | ||
* @returns The value of the binding. | ||
@@ -160,0 +167,0 @@ */ |
import { Behavior } from "./directives/behavior"; | ||
/** | ||
* A node that can be targeted by styles. | ||
* @public | ||
*/ | ||
export interface StyleTarget { | ||
/** | ||
* Stylesheets to be adopted by the node. | ||
*/ | ||
adoptedStyleSheets?: CSSStyleSheet[]; | ||
prepend(node: Node): void; | ||
removeChild(node: Node): void; | ||
/** | ||
* Adds styles to the target. | ||
* @param styles - The styles element to add. | ||
*/ | ||
prepend(styles: HTMLStyleElement): void; | ||
/** | ||
* Removes styles from the target. | ||
* @param styles - The styles element to remove. | ||
*/ | ||
removeChild(styles: HTMLStyleElement): void; | ||
/** | ||
* Returns all element descendants of node that match selectors. | ||
* @param selectors - The CSS selector to use for the query. | ||
*/ | ||
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>; | ||
} | ||
/** | ||
* Represents styles that can be applied to a custom element. | ||
* @public | ||
*/ | ||
export declare abstract class ElementStyles { | ||
@@ -17,27 +40,28 @@ /** @internal */ | ||
abstract removeStylesFrom(target: StyleTarget): void; | ||
/** | ||
* Associates behaviors with this set of styles. | ||
* @param behaviors - The behaviors to associate. | ||
*/ | ||
withBehaviors(...behaviors: Behavior[]): this; | ||
/** | ||
* Adds these styles to a global cache for easy lookup by a known key. | ||
* @param key - The key to use for lookup and retrieval in the cache. | ||
*/ | ||
withKey(key: string): this; | ||
/** | ||
* Attempts to find cached styles by a known key. | ||
* @param key - The key to search the style cache for. | ||
*/ | ||
static find(key: string): ElementStyles | null; | ||
} | ||
declare type InjectableStyles = string | ElementStyles; | ||
declare type ElementStyleFactory = (styles: ReadonlyArray<InjectableStyles>) => ElementStyles; | ||
export declare class AdoptedStyleSheetsStyles extends ElementStyles { | ||
styles: InjectableStyles[]; | ||
private readonly styleSheets; | ||
readonly behaviors: ReadonlyArray<Behavior> | null; | ||
constructor(styles: InjectableStyles[], styleSheetCache: Map<string, CSSStyleSheet>); | ||
addStylesTo(target: StyleTarget): void; | ||
removeStylesFrom(target: StyleTarget): void; | ||
} | ||
export declare class StyleElementStyles extends ElementStyles { | ||
styles: InjectableStyles[]; | ||
readonly behaviors: ReadonlyArray<Behavior> | null; | ||
private styleSheets; | ||
private styleClass; | ||
constructor(styles: InjectableStyles[]); | ||
addStylesTo(target: StyleTarget): void; | ||
removeStylesFrom(target: StyleTarget): void; | ||
} | ||
export declare const createStyles: ElementStyleFactory; | ||
/** | ||
* Transforms a template literal string into styles. | ||
* @param strings - The string fragments that are interpolated with the values. | ||
* @param values - The values that are interpolated with the string fragments. | ||
* @remarks | ||
* The css helper supports interpolation of strings and ElementStyle instances. | ||
* @public | ||
*/ | ||
export declare function css(strings: TemplateStringsArray, ...values: InjectableStyles[]): ElementStyles; | ||
export {}; |
@@ -5,6 +5,7 @@ import { BehaviorFactory } from "./directives/behavior"; | ||
* The result of compiling a template and its directives. | ||
* @beta | ||
*/ | ||
export interface CompilationResult { | ||
/** | ||
* A clonable DocumentFragment representing the compiled HTML. | ||
* A cloneable DocumentFragment representing the compiled HTML. | ||
*/ | ||
@@ -29,6 +30,6 @@ fragment: DocumentFragment; | ||
* Compiles a template and associated directives into a raw compilation | ||
* result which include a clonable DocumentFragment and factories capable | ||
* result which include a cloneable DocumentFragment and factories capable | ||
* of attaching runtime behavior to nodes within the fragment. | ||
* @param template The template to compile. | ||
* @param directives The directives referenced by the template. | ||
* @param template - The template to compile. | ||
* @param directives - The directives referenced by the template. | ||
* @remarks | ||
@@ -38,3 +39,4 @@ * The template that is provided for compilation is altered in-place | ||
* it is recommended that you clone the original and pass the clone to this API. | ||
* @public | ||
*/ | ||
export declare function compileTemplate(template: HTMLTemplateElement, directives: ReadonlyArray<Directive>): CompilationResult; |
@@ -6,2 +6,3 @@ import { ElementView, HTMLView, SyntheticView } from "./view"; | ||
* A template capable of creating views specifically for rendering custom elements. | ||
* @public | ||
*/ | ||
@@ -11,3 +12,3 @@ export interface ElementViewTemplate { | ||
* Creates an ElementView instance based on this template definition. | ||
* @param host The custom element host that this template will be rendered to once created. | ||
* @param host - The custom element host that this template will be rendered to once created. | ||
*/ | ||
@@ -18,2 +19,3 @@ create(host: Element): ElementView; | ||
* A template capable of rendering views not specifically connected to custom elements. | ||
* @public | ||
*/ | ||
@@ -28,6 +30,5 @@ export interface SyntheticViewTemplate<TSource = any, TParent = any> { | ||
* A template capable of creating HTMLView instances or rendering directly to DOM. | ||
* @public | ||
*/ | ||
export declare class ViewTemplate<TSource = any, TParent = any> implements ElementViewTemplate, SyntheticViewTemplate { | ||
readonly html: string | HTMLTemplateElement; | ||
readonly directives: ReadonlyArray<Directive>; | ||
private behaviorCount; | ||
@@ -40,5 +41,14 @@ private hasHostBehaviors; | ||
/** | ||
* The html representing what this template will | ||
* instantiate, including placeholders for directives. | ||
*/ | ||
readonly html: string | HTMLTemplateElement; | ||
/** | ||
* The directives that will be connected to placeholders in the html. | ||
*/ | ||
readonly directives: ReadonlyArray<Directive>; | ||
/** | ||
* Creates an instance of ViewTemplate. | ||
* @param html The html representing what this template will instantiate, including placeholders for directives. | ||
* @param directives The directives that will be connected to placeholders in the html. | ||
* @param html - The html representing what this template will instantiate, including placeholders for directives. | ||
* @param directives - The directives that will be connected to placeholders in the html. | ||
*/ | ||
@@ -48,3 +58,3 @@ constructor(html: string | HTMLTemplateElement, directives: ReadonlyArray<Directive>); | ||
* Creates an HTMLView instance based on this template definition. | ||
* @param host The host element that this template will be rendered to once created. | ||
* @param host - The host element that this template will be rendered to once created. | ||
*/ | ||
@@ -54,4 +64,4 @@ create(host?: Element): HTMLView; | ||
* Creates an HTMLView from this template, binds it to the source, and then appends it to the host. | ||
* @param source The data source to bind the template to. | ||
* @param host The HTMLElement where the template will be rendered. | ||
* @param source - The data source to bind the template to. | ||
* @param host - The HTMLElement where the template will be rendered. | ||
*/ | ||
@@ -63,2 +73,3 @@ render(source: TSource, host: HTMLElement | string): HTMLView; | ||
* into templates. | ||
* @public | ||
*/ | ||
@@ -69,2 +80,3 @@ export interface CaptureType<TSource> { | ||
* Represents the types of values that can be interpolated into a template. | ||
* @public | ||
*/ | ||
@@ -74,8 +86,9 @@ export declare type TemplateValue<TScope, TParent = any> = Binding<TScope, any, TParent> | string | number | Directive | CaptureType<TScope>; | ||
* Transforms a template literal string into a renderable ViewTemplate. | ||
* @param strings The string fragments that interpolated with the values. | ||
* @param values The values that are interpolated with the string fragments. | ||
* @param strings - The string fragments that are interpolated with the values. | ||
* @param values - The values that are interpolated with the string fragments. | ||
* @remarks | ||
* The html helper supports interpolation of strings, numbers, binding expressions, | ||
* other template instances, and Directive instances. | ||
* @public | ||
*/ | ||
export declare function html<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: TemplateValue<TSource, TParent>[]): ViewTemplate<TSource, TParent>; |
@@ -5,2 +5,3 @@ import { Behavior } from "./directives/behavior"; | ||
* Represents a collection of DOM nodes which can be bound to a data source. | ||
* @public | ||
*/ | ||
@@ -18,7 +19,8 @@ export interface View { | ||
* Binds a view's behaviors to its binding source. | ||
* @param source The binding source for the view's binding behaviors. | ||
* @param source - The binding source for the view's binding behaviors. | ||
* @param context - The execution context to run the view within. | ||
*/ | ||
bind(source: unknown, context: ExecutionContext): void; | ||
/** | ||
* Unbinds a view's behaviors from its binding source. | ||
* Unbinds a view's behaviors from its binding source and context. | ||
*/ | ||
@@ -29,2 +31,3 @@ unbind(): void; | ||
* A View representing DOM nodes specifically for rendering the view of a custom element. | ||
* @public | ||
*/ | ||
@@ -34,3 +37,3 @@ export interface ElementView extends View { | ||
* Appends the view's DOM nodes to the referenced node. | ||
* @param node The parent node to append the view's DOM nodes to. | ||
* @param node - The parent node to append the view's DOM nodes to. | ||
*/ | ||
@@ -40,3 +43,4 @@ appendTo(node: Node): void; | ||
/** | ||
* A view representing a range of DOM nodes which can be added/removed adhoc. | ||
* A view representing a range of DOM nodes which can be added/removed ad hoc. | ||
* @public | ||
*/ | ||
@@ -54,3 +58,3 @@ export interface SyntheticView extends View { | ||
* Inserts the view's DOM nodes before the referenced node. | ||
* @param node The node to insert the view's DOM before. | ||
* @param node - The node to insert the view's DOM before. | ||
*/ | ||
@@ -71,2 +75,3 @@ insertBefore(node: Node): void; | ||
* The standard View implementation, which also implements ElementView and SyntheticView. | ||
* @public | ||
*/ | ||
@@ -76,10 +81,22 @@ export declare class HTMLView implements ElementView, SyntheticView { | ||
private behaviors; | ||
/** | ||
* The data that the view is bound to. | ||
*/ | ||
source: any | null; | ||
/** | ||
* The execution context the view is running within. | ||
*/ | ||
context: ExecutionContext | null; | ||
/** | ||
* The first DOM node in the range of nodes that make up the view. | ||
*/ | ||
firstChild: Node; | ||
/** | ||
* The last DOM node in the range of nodes that make up the view. | ||
*/ | ||
lastChild: Node; | ||
/** | ||
* | ||
* @param fragment The html fragment that contains the nodes for this view. | ||
* @param behaviors The behaviors to be applied to this view. | ||
* Constructs an instance of HTMLView. | ||
* @param fragment - The html fragment that contains the nodes for this view. | ||
* @param behaviors - The behaviors to be applied to this view. | ||
*/ | ||
@@ -89,3 +106,3 @@ constructor(fragment: DocumentFragment, behaviors: Behavior[]); | ||
* Appends the view's DOM nodes to the referenced node. | ||
* @param node The parent node to append the view's DOM nodes to. | ||
* @param node - The parent node to append the view's DOM nodes to. | ||
*/ | ||
@@ -95,3 +112,3 @@ appendTo(node: Node): void; | ||
* Inserts the view's DOM nodes before the referenced node. | ||
* @param node The node to insert the view's DOM before. | ||
* @param node - The node to insert the view's DOM before. | ||
*/ | ||
@@ -111,4 +128,4 @@ insertBefore(node: Node): void; | ||
* Binds a view's behaviors to its binding source. | ||
* @param source The binding source for the view's binding behaviors. | ||
* @param context The execution context to run the behaviors within. | ||
* @param source - The binding source for the view's binding behaviors. | ||
* @param context - The execution context to run the behaviors within. | ||
*/ | ||
@@ -122,5 +139,5 @@ bind(source: unknown, context: ExecutionContext): void; | ||
* Efficiently disposes of a contiguous range of synthetic view instances. | ||
* @param views A contiguous range of views to be disposed. | ||
* @param views - A contiguous range of views to be disposed. | ||
*/ | ||
static disposeContiguousBatch(views: SyntheticView[]): void; | ||
} |
import { Observable } from "./observation/observable"; | ||
import { DOM } from "./dom"; | ||
/** | ||
* A {@link ValueConverter} that converts to and from `boolean` values. | ||
* @remarks | ||
* Used automatically when the `boolean` {@link AttributeMode} is selected. | ||
* @public | ||
*/ | ||
export const booleanConverter = { | ||
@@ -18,2 +24,9 @@ toView(value) { | ||
}; | ||
/** | ||
* A {@link ValueConverter} that converts to and from `number` values. | ||
* @remarks | ||
* This converter allows for nullable numbers, returning `null` if the | ||
* input was `null`, `undefined`, or `NaN`. | ||
* @public | ||
*/ | ||
export const nullableNumberConverter = { | ||
@@ -35,4 +48,20 @@ toView(value) { | ||
}; | ||
/** | ||
* An implementation of {@link Accessor} that supports reactivity, | ||
* change callbacks, attribute reflection, and type conversion for | ||
* custom elements. | ||
* @public | ||
*/ | ||
export class AttributeDefinition { | ||
/** | ||
* Creates an instance of AttributeDefinition. | ||
* @param Owner - The class constructor that owns this attribute. | ||
* @param name - The name of the property associated with the attribute. | ||
* @param attribute - The name of the attribute in HTML. | ||
* @param mode - The {@link AttributeMode} that describes the behavior of this attribute. | ||
* @param converter - A {@link ValueConverter} that integrates with the property getter/setter | ||
* to convert values to and from a DOM string. | ||
*/ | ||
constructor(Owner, name, attribute = name.toLowerCase(), mode = "reflect", converter) { | ||
this.guards = new Set(); | ||
this.Owner = Owner; | ||
@@ -43,3 +72,2 @@ this.name = name; | ||
this.converter = converter; | ||
this.guards = new Set(); | ||
this.fieldName = `_${name}`; | ||
@@ -52,2 +80,7 @@ this.callbackName = `${name}Changed`; | ||
} | ||
/** | ||
* Sets the value of the attribute/property on the source element. | ||
* @param source - The source element to access. | ||
* @param value - The value to set the attribute/property to. | ||
*/ | ||
setValue(source, newValue) { | ||
@@ -68,2 +101,6 @@ const oldValue = source[this.fieldName]; | ||
} | ||
/** | ||
* Gets the value of the attribute/property on the source element. | ||
* @param source - The source element to access. | ||
*/ | ||
getValue(source) { | ||
@@ -73,2 +110,3 @@ Observable.track(source, this.name); | ||
} | ||
/** @internal */ | ||
onAttributeChangedCallback(element, value) { | ||
@@ -103,2 +141,8 @@ if (this.guards.has(element)) { | ||
} | ||
/** | ||
* Collects all attribute definitions associated with the owner. | ||
* @param Owner - The class constructor to collect attribute for. | ||
* @param attributeLists - Any existing attributes to collect and merge with those associated with the owner. | ||
* @internal | ||
*/ | ||
static collect(Owner, ...attributeLists) { | ||
@@ -105,0 +149,0 @@ const attributes = []; |
@@ -1,2 +0,2 @@ | ||
import { getDefinition } from "./fast-definitions"; | ||
import { fastDefinitions } from "./fast-definitions"; | ||
import { PropertyChangeNotifier } from "./observation/notifier"; | ||
@@ -8,11 +8,31 @@ import { defaultExecutionContext, Observable } from "./observation/observable"; | ||
}; | ||
/** | ||
* Controls the lifecycle and rendering of a `FASTElement`. | ||
* @public | ||
*/ | ||
export class Controller extends PropertyChangeNotifier { | ||
/** | ||
* Creates a Controller to control the specified element. | ||
* @param element - The element to be controlled by this controller. | ||
* @param definition - The element definition metadata that instructs this | ||
* controller in how to handle rendering and other platform integrations. | ||
* @internal | ||
*/ | ||
constructor(element, definition) { | ||
super(element); | ||
this.boundObservables = null; | ||
this.behaviors = null; | ||
/** | ||
* The view associated with the custom element. | ||
* @remarks | ||
* If `null` then the element is managing its own rendering. | ||
*/ | ||
this.view = null; | ||
/** | ||
* Indicates whether or not the custom element has been | ||
* connected to the document. | ||
*/ | ||
this.isConnected = false; | ||
this.element = element; | ||
this.definition = definition; | ||
this.view = null; | ||
this.isConnected = false; | ||
this.boundObservables = null; | ||
this.behaviors = null; | ||
const template = definition.template; | ||
@@ -52,3 +72,8 @@ const styles = definition.styles; | ||
} | ||
addStyles(styles, target = this.element.shadowRoot) { | ||
/** | ||
* Adds styles to this element. | ||
* @param styles - The styles to add. | ||
*/ | ||
addStyles(styles, | ||
/** @internal */ target = this.element.shadowRoot) { | ||
if (target !== null) { | ||
@@ -62,2 +87,6 @@ styles.addStylesTo(target); | ||
} | ||
/** | ||
* Removes styles from this element. | ||
* @param styles - the styles to remove. | ||
*/ | ||
removeStyles(styles) { | ||
@@ -73,2 +102,6 @@ const target = this.element.shadowRoot; | ||
} | ||
/** | ||
* Adds behaviors to this element. | ||
* @param behaviors - The behaviors to add. | ||
*/ | ||
addBehaviors(behaviors) { | ||
@@ -87,2 +120,6 @@ const targetBehaviors = this.behaviors || (this.behaviors = []); | ||
} | ||
/** | ||
* Removes behaviors from this element. | ||
* @param behaviors - The behaviors to remove. | ||
*/ | ||
removeBehaviors(behaviors) { | ||
@@ -107,2 +144,5 @@ const targetBehaviors = this.behaviors; | ||
} | ||
/** | ||
* Runs connected lifecycle behavior on the associated element. | ||
*/ | ||
onConnectedCallback() { | ||
@@ -135,2 +175,5 @@ if (this.isConnected) { | ||
} | ||
/** | ||
* Runs disconnected lifecycle behavior on the associated element. | ||
*/ | ||
onDisconnectedCallback() { | ||
@@ -153,2 +196,8 @@ if (this.isConnected === false) { | ||
} | ||
/** | ||
* Runs the attribute changed callback for the associated element. | ||
* @param name - The name of the attribute that changed. | ||
* @param oldValue - The previous value of the attribute. | ||
* @param newValue - The new value of the attribute. | ||
*/ | ||
onAttributeChangedCallback(name, oldValue, newValue) { | ||
@@ -160,2 +209,10 @@ const attrDef = this.definition.attributeLookup[name]; | ||
} | ||
/** | ||
* Emits a custom HTML event. | ||
* @param type - The type name of the event. | ||
* @param detail - The event detail object to send with the event. | ||
* @param options - The event options. By default bubbles and composed. | ||
* @remarks | ||
* Only emits events if connected. | ||
*/ | ||
emit(type, detail, options) { | ||
@@ -167,2 +224,10 @@ if (this.isConnected) { | ||
} | ||
/** | ||
* Locates or creates a controller for the specified element. | ||
* @param element - The element to return the controller for. | ||
* @remarks | ||
* The specified element must have a {@link FASTElementDefinition} | ||
* registered either through the use of the {@link customElement} | ||
* decorator or a call to `FASTElement.define`. | ||
*/ | ||
static forCustomElement(element) { | ||
@@ -173,5 +238,5 @@ const controller = element.$fastController; | ||
} | ||
const definition = getDefinition(element.constructor); | ||
const definition = fastDefinitions.get(element.constructor); | ||
if (definition === void 0) { | ||
throw new Error("Missing fast element definition."); | ||
throw new Error("Missing FASTElement definition."); | ||
} | ||
@@ -178,0 +243,0 @@ return (element.$fastController = new Controller(element, definition)); |
@@ -138,2 +138,3 @@ import { setCurrentEvent, } from "../observation/observable"; | ||
* A directive that configures data binding to element content and attributes. | ||
* @public | ||
*/ | ||
@@ -143,3 +144,3 @@ export class BindingDirective extends Directive { | ||
* Creates an instance of BindingDirective. | ||
* @param binding A binding that returns the data used to update the DOM. | ||
* @param binding - A binding that returns the data used to update the DOM. | ||
*/ | ||
@@ -149,9 +150,13 @@ constructor(binding) { | ||
this.binding = binding; | ||
this.createPlaceholder = DOM.createInterpolationPlaceholder; | ||
this.bind = normalBind; | ||
this.unbind = normalUnbind; | ||
this.updateTarget = updateAttributeTarget; | ||
/** | ||
* Creates a placeholder string based on the directive's index within the template. | ||
* @param index - The index of the directive within the template. | ||
*/ | ||
this.createPlaceholder = DOM.createInterpolationPlaceholder; | ||
} | ||
/** | ||
* Gets the name of the attribute or property that this | ||
* Gets/sets the name of the attribute or property that this | ||
* binding is targeting. | ||
@@ -162,6 +167,2 @@ */ | ||
} | ||
/** | ||
* Sets the name of the attribute or property tha this | ||
* binding is targeting. | ||
*/ | ||
set targetName(value) { | ||
@@ -210,3 +211,3 @@ this.originalTargetName = value; | ||
* information stored in the BindingDirective. | ||
* @param target The target node that the binding behavior should attach to. | ||
* @param target - The target node that the binding behavior should attach to. | ||
*/ | ||
@@ -221,14 +222,21 @@ createBehavior(target) { | ||
* BindingDirective. | ||
* @public | ||
*/ | ||
export class BindingBehavior { | ||
/** | ||
* | ||
* @param target The target of the data updates. | ||
* @param binding The binding that returns the latest value for an update. | ||
* @param bind The operation to perform during binding. | ||
* @param unbind The operation to perform during unbinding. | ||
* @param updateTarget The operation to perform when updating. | ||
* @param targetName The name of the target attribute or property to update. | ||
* Creates an instance of BindingBehavior. | ||
* @param target - The target of the data updates. | ||
* @param binding - The binding that returns the latest value for an update. | ||
* @param bind - The operation to perform during binding. | ||
* @param unbind - The operation to perform during unbinding. | ||
* @param updateTarget - The operation to perform when updating. | ||
* @param targetName - The name of the target attribute or property to update. | ||
*/ | ||
constructor(target, binding, bind, unbind, updateTarget, targetName) { | ||
/** @internal */ | ||
this.source = null; | ||
/** @internal */ | ||
this.context = null; | ||
/** @internal */ | ||
this.bindingObserver = null; | ||
this.target = target; | ||
@@ -240,15 +248,8 @@ this.binding = binding; | ||
this.targetName = targetName; | ||
this.source = null; | ||
this.context = null; | ||
this.bindingObserver = null; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
/** @internal */ | ||
handleChange() { | ||
this.updateTarget(this.bindingObserver.observe(this.source, this.context)); | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
/** @internal */ | ||
handleEvent(event) { | ||
@@ -255,0 +256,0 @@ setCurrentEvent(event); |
import { AttachedBehaviorDirective } from "./directive"; | ||
import { NodeObservationBehavior } from "./node-observation"; | ||
/** | ||
* The runtime behavior for child node observation. | ||
* @public | ||
*/ | ||
export class ChildrenBehavior extends NodeObservationBehavior { | ||
/** | ||
* Creates an instance of ChildrenBehavior. | ||
* @param target - The element target to observe children on. | ||
* @param options - The options to use when observing the element children. | ||
*/ | ||
constructor(target, options) { | ||
@@ -8,5 +17,5 @@ super(target, options); | ||
} | ||
getNodes() { | ||
return Array.from(this.target.childNodes); | ||
} | ||
/** | ||
* Begins observation of the nodes. | ||
*/ | ||
observe() { | ||
@@ -18,6 +27,21 @@ if (this.observer === null) { | ||
} | ||
unobserve() { | ||
/** | ||
* Disconnects observation of the nodes. | ||
*/ | ||
disconnect() { | ||
this.observer.disconnect(); | ||
} | ||
/** | ||
* Retrieves the nodes that should be assigned to the target. | ||
*/ | ||
getNodes() { | ||
return Array.from(this.target.childNodes); | ||
} | ||
} | ||
/** | ||
* A directive that observes the `childNodes` of an element and updates a property | ||
* whenever they change. | ||
* @param propertyOrOptions - The options used to configure child node observation. | ||
* @public | ||
*/ | ||
export function children(propertyOrOptions) { | ||
@@ -24,0 +48,0 @@ if (typeof propertyOrOptions === "string") { |
import { DOM } from "../dom"; | ||
/** | ||
* Instructs the template engine to apply behavior to a node. | ||
* @public | ||
*/ | ||
export class Directive { | ||
constructor() { | ||
/** | ||
* The index of the DOM node to which the created behavior will apply. | ||
*/ | ||
this.targetIndex = 0; | ||
} | ||
} | ||
/** | ||
* A directive that attaches special behavior to an element via a custom attribute. | ||
* @public | ||
*/ | ||
export class AttachedBehaviorDirective extends Directive { | ||
/** | ||
* | ||
* @param name - The name of the behavior; used as a custom attribute on the element. | ||
* @param behavior - The behavior to instantiate and attach to the element. | ||
* @param options - Options to pass to the behavior during creation. | ||
*/ | ||
constructor(name, behavior, options) { | ||
@@ -14,5 +31,18 @@ super(); | ||
} | ||
/** | ||
* Creates a placeholder string based on the directive's index within the template. | ||
* @param index - The index of the directive within the template. | ||
* @remarks | ||
* Creates a custom attribute placeholder. | ||
*/ | ||
createPlaceholder(index) { | ||
return DOM.createCustomAttributePlaceholder(this.name, index); | ||
} | ||
/** | ||
* Creates a behavior for the provided target node. | ||
* @param target - The node instance to create the behavior for. | ||
* @remarks | ||
* Creates an instance of the `behavior` type this directive was constructed with | ||
* and passes the target and options to that `behavior`'s constructor. | ||
*/ | ||
createBehavior(target) { | ||
@@ -19,0 +49,0 @@ return new this.behavior(target, this.options); |
import { Observable } from "../observation/observable"; | ||
import { emptyArray } from "../interfaces"; | ||
/** | ||
* A base class for node observation. | ||
* @internal | ||
*/ | ||
export class NodeObservationBehavior { | ||
/** | ||
* Creates an instance of NodeObservationBehavior. | ||
* @param target - The target to assign the nodes property on. | ||
* @param options - The options to use in configuring node observation. | ||
*/ | ||
constructor(target, options) { | ||
@@ -9,2 +18,7 @@ this.target = target; | ||
} | ||
/** | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
bind(source) { | ||
@@ -19,2 +33,6 @@ const name = this.options.property; | ||
} | ||
/** | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
unbind() { | ||
@@ -24,5 +42,6 @@ this.updateTarget(emptyArray); | ||
if (this.shouldUpdate) { | ||
this.unobserve(); | ||
this.disconnect(); | ||
} | ||
} | ||
/** @internal */ | ||
handleEvent() { | ||
@@ -29,0 +48,0 @@ this.updateTarget(this.getNodes()); |
import { AttachedBehaviorDirective } from "./directive"; | ||
/** | ||
* The runtime behavior for template references. | ||
* @public | ||
*/ | ||
export class RefBehavior { | ||
/** | ||
* Creates an instance of RefBehavior. | ||
* @param target - The element to reference. | ||
* @param propertyName - The name of the property to assign the reference to. | ||
*/ | ||
constructor(target, propertyName) { | ||
@@ -7,2 +16,7 @@ this.target = target; | ||
} | ||
/** | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
bind(source) { | ||
@@ -12,6 +26,15 @@ source[this.propertyName] = this.target; | ||
/* eslint-disable-next-line @typescript-eslint/no-empty-function */ | ||
/** | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
unbind() { } | ||
} | ||
/** | ||
* A directive that observes the updates a property with a reference to the element. | ||
* @param propertyName - The name of the property to assign the reference to. | ||
* @public | ||
*/ | ||
export function ref(propertyName) { | ||
return new AttachedBehaviorDirective("fast-ref", RefBehavior, propertyName); | ||
} |
@@ -18,3 +18,14 @@ import { DOM } from "../dom"; | ||
} | ||
/** | ||
* A behavior that renders a template for each item in an array. | ||
* @public | ||
*/ | ||
export class RepeatBehavior { | ||
/** | ||
* Creates an instance of RepeatBehavior. | ||
* @param location - The location in the DOM to render the repeat. | ||
* @param binding - The array to render. | ||
* @param template - The template to render for each item. | ||
* @param options - Options used to turn on special repeat features. | ||
*/ | ||
constructor(location, binding, template, options) { | ||
@@ -37,2 +48,7 @@ this.location = location; | ||
} | ||
/** | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
bind(source, context) { | ||
@@ -47,2 +63,6 @@ this.source = source; | ||
} | ||
/** | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
unbind() { | ||
@@ -57,2 +77,3 @@ this.source = null; | ||
} | ||
/** @internal */ | ||
handleChange(source, args) { | ||
@@ -171,3 +192,13 @@ if (source === this.binding) { | ||
} | ||
/** | ||
* A directive that configures list rendering. | ||
* @public | ||
*/ | ||
export class RepeatDirective extends Directive { | ||
/** | ||
* Creates an instance of RepeatDirective. | ||
* @param binding - The binding that provides the array to render. | ||
* @param template - The template to render for each item in the array. | ||
* @param options - Options used to turn on special repeat features. | ||
*/ | ||
constructor(binding, template, options) { | ||
@@ -178,5 +209,13 @@ super(); | ||
this.options = options; | ||
/** | ||
* Creates a placeholder string based on the directive's index within the template. | ||
* @param index - The index of the directive within the template. | ||
*/ | ||
this.createPlaceholder = DOM.createBlockPlaceholder; | ||
enableArrayObservation(); | ||
} | ||
/** | ||
* Creates a behavior for the provided target node. | ||
* @param target - The node instance to create the behavior for. | ||
*/ | ||
createBehavior(target) { | ||
@@ -186,4 +225,11 @@ return new RepeatBehavior(target, this.binding, this.template, this.options); | ||
} | ||
/** | ||
* A directive that enables list rendering. | ||
* @param binding - The array to render. | ||
* @param template - The template to render for each item in the array. | ||
* @param options - Options used to turn on special repeat features. | ||
* @public | ||
*/ | ||
export function repeat(binding, template, options = defaultRepeatOptions) { | ||
return new RepeatDirective(binding, template, options); | ||
} |
import { AttachedBehaviorDirective } from "./directive"; | ||
import { NodeObservationBehavior } from "./node-observation"; | ||
/** | ||
* The runtime behavior for slotted node observation. | ||
* @public | ||
*/ | ||
export class SlottedBehavior extends NodeObservationBehavior { | ||
/** | ||
* Creates an instance of SlottedBehavior. | ||
* @param target - The slot element target to observe. | ||
* @param options - The options to use when observing the slot. | ||
*/ | ||
constructor(target, options) { | ||
super(target, options); | ||
} | ||
getNodes() { | ||
return this.target.assignedNodes(this.options); | ||
} | ||
/** | ||
* Begins observation of the nodes. | ||
*/ | ||
observe() { | ||
this.target.addEventListener("slotchange", this); | ||
} | ||
unobserve() { | ||
/** | ||
* Disconnects observation of the nodes. | ||
*/ | ||
disconnect() { | ||
this.target.removeEventListener("slotchange", this); | ||
} | ||
/** | ||
* Retrieves the nodes that should be assigned to the target. | ||
*/ | ||
getNodes() { | ||
return this.target.assignedNodes(this.options); | ||
} | ||
} | ||
/** | ||
* A directive that observes the `assignedNodes()` of a slot and updates a property | ||
* whenever they change. | ||
* @param propertyOrOptions - The options used to configure slotted node observation. | ||
* @public | ||
*/ | ||
export function slotted(propertyOrOptions) { | ||
@@ -18,0 +42,0 @@ if (typeof propertyOrOptions === "string") { |
/** | ||
* A directive that enables basic conditional rendering in a template. | ||
* @param binding The condition to test for rendering. | ||
* @param templateOrTemplateBinding The template or a binding that gets | ||
* @param binding - The condition to test for rendering. | ||
* @param templateOrTemplateBinding - The template or a binding that gets | ||
* the template to render when the condition is true. | ||
* @public | ||
*/ | ||
@@ -7,0 +8,0 @@ export function when(binding, templateOrTemplateBinding) { |
@@ -39,4 +39,12 @@ const marker = `fast-${Math.random().toString(36).substring(7)}`; | ||
* Common DOM APIs. | ||
* @public | ||
*/ | ||
export const DOM = Object.freeze({ | ||
/** | ||
* Sets the HTML trusted types policy used by the templating engine. | ||
* @param policy - The policy to set for HTML. | ||
* @remarks | ||
* This API can only be called once, for security reasons. It should be | ||
* called by the application developer at the start of their program. | ||
*/ | ||
setHTMLPolicy(policy) { | ||
@@ -48,17 +56,53 @@ if (htmlPolicy !== fastHTMLPolicy) { | ||
}, | ||
/** | ||
* Turns a string into trusted HTML using the configured trusted types policy. | ||
* @param html - The string to turn into trusted HTML. | ||
* @remarks | ||
* Used internally by the template engine when creating templates | ||
* and setting innerHTML. | ||
*/ | ||
createHTML(html) { | ||
return htmlPolicy.createHTML(html); | ||
}, | ||
/** | ||
* Determines if the provided node is a template marker used by the runtime. | ||
* @param node - The node to test. | ||
*/ | ||
isMarker(node) { | ||
return node && node.nodeType === 8 && node.data.startsWith(marker); | ||
}, | ||
/** | ||
* Given a marker node, extract the {@link Directive} index from the placeholder. | ||
* @param node - The marker node to extract the index from. | ||
*/ | ||
extractDirectiveIndexFromMarker(node) { | ||
return parseInt(node.data.replace(`${marker}:`, "")); | ||
}, | ||
/** | ||
* Creates a placeholder string suitable for marking out a location *within* | ||
* an attribute value or HTML content. | ||
* @param index - The directive index to create the placeholder for. | ||
* @remarks | ||
* Used internally by binding directives. | ||
*/ | ||
createInterpolationPlaceholder(index) { | ||
return `@{${index}}`; | ||
}, | ||
/** | ||
* Creates a placeholder that manifests itself as an attribute on an | ||
* element. | ||
* @param attributeName - The name of the custom attribute. | ||
* @param index - The directive index to create the placeholder for. | ||
* @remarks | ||
* Used internally by attribute directives such as `ref`, `slotted`, and `children`. | ||
*/ | ||
createCustomAttributePlaceholder(attributeName, index) { | ||
return `${attributeName}="${this.createInterpolationPlaceholder(index)}"`; | ||
}, | ||
/** | ||
* Creates a placeholder that manifests itself as a marker within the DOM structure. | ||
* @param index - The directive index to create the placeholder for. | ||
* @remarks | ||
* Used internally by structural directives such as `repeat`. | ||
*/ | ||
createBlockPlaceholder(index) { | ||
@@ -69,3 +113,3 @@ return `<!--${marker}:${index}-->`; | ||
* Schedules DOM update work in the next async batch. | ||
* @param callable The callable function or object to queue. | ||
* @param callable - The callable function or object to queue. | ||
*/ | ||
@@ -86,2 +130,11 @@ queueUpdate(callable) { | ||
}, | ||
/** | ||
* Sets an attribute value on an element. | ||
* @param element - The element to set the attribute value on. | ||
* @param attributeName - The attribute name to set. | ||
* @param value - The value of the attribute to set. | ||
* @remarks | ||
* If the value is `null` or `undefined`, the attribute is removed, otherwise | ||
* it is set to the provided value using the standard `setAttribute` API. | ||
*/ | ||
setAttribute(element, attributeName, value) { | ||
@@ -95,2 +148,10 @@ if (value === null || value === undefined) { | ||
}, | ||
/** | ||
* Sets a boolean attribute value. | ||
* @param element - The element to set the boolean attribute value on. | ||
* @param attributeName - The attribute name to set. | ||
* @param value - The value of the attribute to set. | ||
* @remarks | ||
* If the value is true, the attribute is added; otherwise it is removed. | ||
*/ | ||
setBooleanAttribute(element, attributeName, value) { | ||
@@ -97,0 +158,0 @@ value |
@@ -0,2 +1,17 @@ | ||
/** | ||
* Defines metadata for a FASTElement. | ||
* @public | ||
*/ | ||
export class FASTElementDefinition { | ||
/** | ||
* Creates an instance of FASTElementDefinition. | ||
* @param name - The name of the custom element. | ||
* @param attributes - The custom attributes of the custom element. | ||
* @param propertyLookup - A map enabling lookup of attribute by associated property name. | ||
* @param attributeLookup - A map enabling lookup of property by associated attribute name. | ||
* @param template - The template to render for the custom element. | ||
* @param styles - The styles to associated with the custom element. | ||
* @param shadowOptions - Options controlling the creation of the custom element's shadow DOM. | ||
* @param elementOptions - Options controlling how the custom element is defined with the platform. | ||
*/ | ||
constructor(name, attributes, propertyLookup, attributeLookup, template, styles, shadowOptions, elementOptions) { | ||
@@ -13,11 +28,3 @@ this.name = name; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
/** @internal */ | ||
export const fastDefinitions = new Map(); | ||
/** | ||
* @internal | ||
*/ | ||
export function getDefinition(Type) { | ||
return fastDefinitions.get(Type); | ||
} |
import { AttributeDefinition } from "./attributes"; | ||
import { Controller } from "./controller"; | ||
import { Observable } from "./observation/observable"; | ||
import { fastDefinitions, FASTElementDefinition, getDefinition, } from "./fast-definitions"; | ||
import { fastDefinitions, FASTElementDefinition, } from "./fast-definitions"; | ||
const defaultShadowOptions = { mode: "open" }; | ||
@@ -29,6 +29,22 @@ const defaultElementOptions = {}; | ||
} | ||
/** | ||
* A minimal base class for FASTElements that also provides | ||
* static helpers for working with FASTElements. | ||
* @public | ||
*/ | ||
export const FASTElement = Object.assign(createFASTElement(HTMLElement), { | ||
/** | ||
* Creates a new FASTElement base class inherited from the | ||
* provided base type. | ||
* @param BaseType - The base element type to inherit from. | ||
*/ | ||
from(BaseType) { | ||
return createFASTElement(BaseType); | ||
}, | ||
/** | ||
* Defines a platform custom element based on the provided type and definition. | ||
* @param Type - The custom element type to define. | ||
* @param nameOrDef - The name of the element to define or a definition object | ||
* that describes the element to define. | ||
*/ | ||
define(Type, nameOrDef = Type.definition) { | ||
@@ -68,4 +84,16 @@ if (typeof nameOrDef === "string") { | ||
}, | ||
getDefinition, | ||
/** | ||
* Gets the element definition associated with the specified type. | ||
* @param Type - The custom element type to retrieve the definition for. | ||
*/ | ||
getDefinition(Type) { | ||
return fastDefinitions.get(Type); | ||
}, | ||
}); | ||
/** | ||
* Decorator: Defines a platform custom element based on `FASTElement`. | ||
* @param nameOrDef - The name of the element to define or a definition object | ||
* that describes the element to define. | ||
* @public | ||
*/ | ||
export function customElement(nameOrDef) { | ||
@@ -72,0 +100,0 @@ /* eslint-disable-next-line @typescript-eslint/explicit-function-return-type */ |
@@ -6,3 +6,4 @@ /** | ||
* no actual items to return. | ||
* @internal | ||
*/ | ||
export const emptyArray = Object.freeze([]); |
import { emptyArray } from "../interfaces"; | ||
/** | ||
* @internal | ||
*/ | ||
/** @internal */ | ||
export function newSplice(index, removed, addedCount) { | ||
@@ -313,5 +311,3 @@ return { | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
/** @internal */ | ||
export function projectArraySplices(array, changeRecords) { | ||
@@ -318,0 +314,0 @@ let splices = []; |
@@ -73,2 +73,3 @@ import { DOM } from "../dom"; | ||
* not typically necessary. | ||
* @public | ||
*/ | ||
@@ -75,0 +76,0 @@ export function enableArrayObservation() { |
@@ -34,2 +34,3 @@ function spilloverSubscribe(subscriber) { | ||
* If the set ever exceeds two subscribers, it upgrades to an array automatically. | ||
* @public | ||
*/ | ||
@@ -39,4 +40,4 @@ export class SubscriberSet { | ||
* Creates an instance of SubscriberSet for the specified source. | ||
* @param source The object source that subscribers will receive notifications from. | ||
* @param initialSubscriber An initial subscriber to changes. | ||
* @param source - The object source that subscribers will receive notifications from. | ||
* @param initialSubscriber - An initial subscriber to changes. | ||
*/ | ||
@@ -52,3 +53,3 @@ constructor(source, initialSubscriber) { | ||
* Checks whether the provided subscriber has been added to this set. | ||
* @param subscriber The subscriber to test for inclusion in this set. | ||
* @param subscriber - The subscriber to test for inclusion in this set. | ||
*/ | ||
@@ -60,3 +61,3 @@ has(subscriber) { | ||
* Subscribes to notification of changes in an object's state. | ||
* @param subscriber The object that is subscribing for change notification. | ||
* @param subscriber - The object that is subscribing for change notification. | ||
*/ | ||
@@ -85,3 +86,3 @@ subscribe(subscriber) { | ||
* Unsubscribes from notification of changes in an object's state. | ||
* @param subscriber The object that is unsubscribing from change notification. | ||
* @param subscriber - The object that is unsubscribing from change notification. | ||
*/ | ||
@@ -98,3 +99,3 @@ unsubscribe(subscriber) { | ||
* Notifies all subscribers. | ||
* @param args Data passed along to subscribers during notification. | ||
* @param args - Data passed along to subscribers during notification. | ||
*/ | ||
@@ -116,2 +117,3 @@ notify(args) { | ||
* of individual property changes on an object. | ||
* @public | ||
*/ | ||
@@ -121,3 +123,3 @@ export class PropertyChangeNotifier { | ||
* Creates an instance of PropertyChangeNotifier for the specified source. | ||
* @param source The object source that subscribers will receive notifications from. | ||
* @param source - The object source that subscribers will receive notifications from. | ||
*/ | ||
@@ -130,3 +132,3 @@ constructor(source) { | ||
* Notifies all subscribers, based on the specified property. | ||
* @param propertyName The property name, passed along to subscribers during notification. | ||
* @param propertyName - The property name, passed along to subscribers during notification. | ||
*/ | ||
@@ -141,4 +143,4 @@ notify(propertyName) { | ||
* Subscribes to notification of changes in an object's state. | ||
* @param subscriber The object that is subscribing for change notification. | ||
* @param propertyToWatch The name of the property that the subscriber is interested in watching for changes. | ||
* @param subscriber - The object that is subscribing for change notification. | ||
* @param propertyToWatch - The name of the property that the subscriber is interested in watching for changes. | ||
*/ | ||
@@ -154,4 +156,4 @@ subscribe(subscriber, propertyToWatch) { | ||
* Unsubscribes from notification of changes in an object's state. | ||
* @param subscriber The object that is unsubscribing from change notification. | ||
* @param propertyToUnwatch The name of the property that the subscriber is no longer interested in watching. | ||
* @param subscriber - The object that is unsubscribing from change notification. | ||
* @param propertyToUnwatch - The name of the property that the subscriber is no longer interested in watching. | ||
*/ | ||
@@ -158,0 +160,0 @@ unsubscribe(subscriber, propertyToUnwatch) { |
@@ -37,2 +37,3 @@ import { DOM } from "../dom"; | ||
* Common Observable APIs. | ||
* @public | ||
*/ | ||
@@ -42,3 +43,3 @@ export const Observable = Object.freeze({ | ||
* @internal | ||
* @param factory The factory used to create array observers. | ||
* @param factory - The factory used to create array observers. | ||
*/ | ||
@@ -50,3 +51,3 @@ setArrayObserverFactory(factory) { | ||
* Gets a notifier for an object or Array. | ||
* @param source The object or Array to get the notifier for. | ||
* @param source - The object or Array to get the notifier for. | ||
*/ | ||
@@ -67,4 +68,4 @@ getNotifier(source) { | ||
* Records a property change for a source object. | ||
* @param source The object to record the change against. | ||
* @param propertyName The property to track as changed. | ||
* @param source - The object to record the change against. | ||
* @param propertyName - The property to track as changed. | ||
*/ | ||
@@ -78,4 +79,4 @@ track(source, propertyName) { | ||
* Notifies subscribers of a source object of changes. | ||
* @param source the object to notify of changes. | ||
* @param args The change args to pass to subscribers. | ||
* @param source - the object to notify of changes. | ||
* @param args - The change args to pass to subscribers. | ||
*/ | ||
@@ -88,4 +89,4 @@ notify(source, args) { | ||
* Defines an observable property on an object or prototype. | ||
* @param target The target object to define the observable on. | ||
* @param nameOrAccessor The name of the property to define as observable; | ||
* @param target - The target object to define the observable on. | ||
* @param nameOrAccessor - The name of the property to define as observable; | ||
* or a custom accessor that specifies the property name and accessor implementation. | ||
@@ -111,3 +112,3 @@ */ | ||
* including its prototype chain. | ||
* @param target The target object to search for accessor on. | ||
* @param target - The target object to search for accessor on. | ||
*/ | ||
@@ -135,4 +136,4 @@ getAccessors(target) { | ||
* provided {@link Binding} for changes. | ||
* @param binding The binding to observe. | ||
* @param initialSubscriber An initial subscriber to changes in the binding value. | ||
* @param binding - The binding to observe. | ||
* @param initialSubscriber - An initial subscriber to changes in the binding value. | ||
*/ | ||
@@ -147,4 +148,5 @@ binding(binding, initialSubscriber) { | ||
* Decorator: Defines an observable property on the target. | ||
* @param target The target to define the observable on. | ||
* @param nameOrAccessor The property name or accessor to define the observable as. | ||
* @param target - The target to define the observable on. | ||
* @param nameOrAccessor - The property name or accessor to define the observable as. | ||
* @public | ||
*/ | ||
@@ -156,4 +158,4 @@ export function observable(target, nameOrAccessor) { | ||
/** | ||
* @param event - The event to set as current for the context. | ||
* @internal | ||
* @param event The event to set as current for the context. | ||
*/ | ||
@@ -165,2 +167,3 @@ export function setCurrentEvent(event) { | ||
* Provides additional contextual information available to behaviors and expressions. | ||
* @public | ||
*/ | ||
@@ -228,2 +231,3 @@ export class ExecutionContext { | ||
* The default execution context used in binding expressions. | ||
* @public | ||
*/ | ||
@@ -230,0 +234,0 @@ export const defaultExecutionContext = new ExecutionContext(); |
const styleLookup = new Map(); | ||
/** | ||
* Represents styles that can be applied to a custom element. | ||
* @public | ||
*/ | ||
export class ElementStyles { | ||
@@ -7,2 +11,6 @@ constructor() { | ||
} | ||
/** | ||
* Associates behaviors with this set of styles. | ||
* @param behaviors - The behaviors to associate. | ||
*/ | ||
withBehaviors(...behaviors) { | ||
@@ -13,2 +21,6 @@ this.behaviors = | ||
} | ||
/** | ||
* Adds these styles to a global cache for easy lookup by a known key. | ||
* @param key - The key to use for lookup and retrieval in the cache. | ||
*/ | ||
withKey(key) { | ||
@@ -18,2 +30,6 @@ styleLookup.set(key, this); | ||
} | ||
/** | ||
* Attempts to find cached styles by a known key. | ||
* @param key - The key to search the style cache for. | ||
*/ | ||
static find(key) { | ||
@@ -43,3 +59,3 @@ return styleLookup.get(key) || null; | ||
// https://developers.google.com/web/updates/2019/02/constructable-stylesheets | ||
export class AdoptedStyleSheetsStyles extends ElementStyles { | ||
class AdoptedStyleSheetsStyles extends ElementStyles { | ||
constructor(styles, styleSheetCache) { | ||
@@ -72,3 +88,3 @@ super(); | ||
} | ||
export class StyleElementStyles extends ElementStyles { | ||
class StyleElementStyles extends ElementStyles { | ||
constructor(styles) { | ||
@@ -100,3 +116,3 @@ super(); | ||
/* eslint-disable @typescript-eslint/explicit-function-return-type */ | ||
export const createStyles = (() => { | ||
const createStyles = (() => { | ||
if ("adoptedStyleSheets" in window.ShadowRoot.prototype) { | ||
@@ -109,2 +125,10 @@ const styleSheetCache = new Map(); | ||
/* eslint-enable @typescript-eslint/explicit-function-return-type */ | ||
/** | ||
* Transforms a template literal string into styles. | ||
* @param strings - The string fragments that are interpolated with the values. | ||
* @param values - The values that are interpolated with the string fragments. | ||
* @remarks | ||
* The css helper supports interpolation of strings and ElementStyle instances. | ||
* @public | ||
*/ | ||
export function css(strings, ...values) { | ||
@@ -111,0 +135,0 @@ const styles = []; |
@@ -171,6 +171,6 @@ import { DOM } from "./dom"; | ||
* Compiles a template and associated directives into a raw compilation | ||
* result which include a clonable DocumentFragment and factories capable | ||
* result which include a cloneable DocumentFragment and factories capable | ||
* of attaching runtime behavior to nodes within the fragment. | ||
* @param template The template to compile. | ||
* @param directives The directives referenced by the template. | ||
* @param template - The template to compile. | ||
* @param directives - The directives referenced by the template. | ||
* @remarks | ||
@@ -180,2 +180,3 @@ * The template that is provided for compilation is altered in-place | ||
* it is recommended that you clone the original and pass the clone to this API. | ||
* @public | ||
*/ | ||
@@ -182,0 +183,0 @@ export function compileTemplate(template, directives) { |
@@ -9,2 +9,3 @@ import { compileTemplate } from "./template-compiler"; | ||
* A template capable of creating HTMLView instances or rendering directly to DOM. | ||
* @public | ||
*/ | ||
@@ -14,8 +15,6 @@ export class ViewTemplate { | ||
* Creates an instance of ViewTemplate. | ||
* @param html The html representing what this template will instantiate, including placeholders for directives. | ||
* @param directives The directives that will be connected to placeholders in the html. | ||
* @param html - The html representing what this template will instantiate, including placeholders for directives. | ||
* @param directives - The directives that will be connected to placeholders in the html. | ||
*/ | ||
constructor(html, directives) { | ||
this.html = html; | ||
this.directives = directives; | ||
this.behaviorCount = 0; | ||
@@ -27,6 +26,8 @@ this.hasHostBehaviors = false; | ||
this.hostBehaviorFactories = null; | ||
this.html = html; | ||
this.directives = directives; | ||
} | ||
/** | ||
* Creates an HTMLView instance based on this template definition. | ||
* @param host The host element that this template will be rendered to once created. | ||
* @param host - The host element that this template will be rendered to once created. | ||
*/ | ||
@@ -89,4 +90,4 @@ create(host) { | ||
* Creates an HTMLView from this template, binds it to the source, and then appends it to the host. | ||
* @param source The data source to bind the template to. | ||
* @param host The HTMLElement where the template will be rendered. | ||
* @param source - The data source to bind the template to. | ||
* @param host - The HTMLElement where the template will be rendered. | ||
*/ | ||
@@ -109,7 +110,8 @@ render(source, host) { | ||
* Transforms a template literal string into a renderable ViewTemplate. | ||
* @param strings The string fragments that interpolated with the values. | ||
* @param values The values that are interpolated with the string fragments. | ||
* @param strings - The string fragments that are interpolated with the values. | ||
* @param values - The values that are interpolated with the string fragments. | ||
* @remarks | ||
* The html helper supports interpolation of strings, numbers, binding expressions, | ||
* other template instances, and Directive instances. | ||
* @public | ||
*/ | ||
@@ -116,0 +118,0 @@ export function html(strings, ...values) { |
@@ -6,8 +6,9 @@ // A singleton Range instance used to efficiently remove ranges of DOM nodes. | ||
* The standard View implementation, which also implements ElementView and SyntheticView. | ||
* @public | ||
*/ | ||
export class HTMLView { | ||
/** | ||
* | ||
* @param fragment The html fragment that contains the nodes for this view. | ||
* @param behaviors The behaviors to be applied to this view. | ||
* Constructs an instance of HTMLView. | ||
* @param fragment - The html fragment that contains the nodes for this view. | ||
* @param behaviors - The behaviors to be applied to this view. | ||
*/ | ||
@@ -17,3 +18,9 @@ constructor(fragment, behaviors) { | ||
this.behaviors = behaviors; | ||
/** | ||
* The data that the view is bound to. | ||
*/ | ||
this.source = null; | ||
/** | ||
* The execution context the view is running within. | ||
*/ | ||
this.context = null; | ||
@@ -25,3 +32,3 @@ this.firstChild = fragment.firstChild; | ||
* Appends the view's DOM nodes to the referenced node. | ||
* @param node The parent node to append the view's DOM nodes to. | ||
* @param node - The parent node to append the view's DOM nodes to. | ||
*/ | ||
@@ -33,3 +40,3 @@ appendTo(node) { | ||
* Inserts the view's DOM nodes before the referenced node. | ||
* @param node The node to insert the view's DOM before. | ||
* @param node - The node to insert the view's DOM before. | ||
*/ | ||
@@ -92,4 +99,4 @@ insertBefore(node) { | ||
* Binds a view's behaviors to its binding source. | ||
* @param source The binding source for the view's binding behaviors. | ||
* @param context The execution context to run the behaviors within. | ||
* @param source - The binding source for the view's binding behaviors. | ||
* @param context - The execution context to run the behaviors within. | ||
*/ | ||
@@ -135,3 +142,3 @@ bind(source, context) { | ||
* Efficiently disposes of a contiguous range of synthetic view instances. | ||
* @param views A contiguous range of views to be disposed. | ||
* @param views - A contiguous range of views to be disposed. | ||
*/ | ||
@@ -138,0 +145,0 @@ static disposeContiguousBatch(views) { |
/** | ||
* Represents a getter/setter property accessor on an object. | ||
* @public | ||
*/ | ||
@@ -12,3 +13,3 @@ export declare interface Accessor { | ||
* Gets the value of the property on the source object. | ||
* @param source The source object to access. | ||
* @param source - The source object to access. | ||
*/ | ||
@@ -18,4 +19,4 @@ getValue(source: any): any; | ||
* Sets the value of the property on the source object. | ||
* @param source The source object to access. | ||
* @param value The value to set the property to. | ||
* @param source - The source object to access. | ||
* @param value - The value to set the property to. | ||
*/ | ||
@@ -25,11 +26,6 @@ setValue(source: any, value: any): void; | ||
export declare class AdoptedStyleSheetsStyles extends ElementStyles { | ||
styles: InjectableStyles[]; | ||
private readonly styleSheets; | ||
readonly behaviors: ReadonlyArray<Behavior> | null; | ||
constructor(styles: InjectableStyles[], styleSheetCache: Map<string, CSSStyleSheet>); | ||
addStylesTo(target: StyleTarget): void; | ||
removeStylesFrom(target: StyleTarget): void; | ||
} | ||
/** | ||
* A directive that attaches special behavior to an element via a custom attribute. | ||
* @public | ||
*/ | ||
export declare class AttachedBehaviorDirective<T = any> extends Directive { | ||
@@ -39,7 +35,31 @@ private name; | ||
private options; | ||
/** | ||
* | ||
* @param name - The name of the behavior; used as a custom attribute on the element. | ||
* @param behavior - The behavior to instantiate and attach to the element. | ||
* @param options - Options to pass to the behavior during creation. | ||
*/ | ||
constructor(name: string, behavior: AttachedBehaviorType<T>, options: T); | ||
/** | ||
* Creates a placeholder string based on the directive's index within the template. | ||
* @param index - The index of the directive within the template. | ||
* @remarks | ||
* Creates a custom attribute placeholder. | ||
*/ | ||
createPlaceholder(index: number): string; | ||
createBehavior(target: any): Behavior; | ||
/** | ||
* Creates a behavior for the provided target node. | ||
* @param target - The node instance to create the behavior for. | ||
* @remarks | ||
* Creates an instance of the `behavior` type this directive was constructed with | ||
* and passes the target and options to that `behavior`'s constructor. | ||
*/ | ||
createBehavior(target: Node): Behavior; | ||
} | ||
/** | ||
* Describes the shape of a behavior constructor that can be created by | ||
* an {@link AttachedBehaviorDirective}. | ||
* @public | ||
*/ | ||
export declare type AttachedBehaviorType<T = any> = new (target: any, options: T) => Behavior; | ||
@@ -49,4 +69,4 @@ | ||
* Decorator: Specifies an HTML attribute. | ||
* | ||
* @param config - The overrides | ||
* @param config - The configuration for the attribute. | ||
* @public | ||
*/ | ||
@@ -56,9 +76,13 @@ export declare function attr(config?: DecoratorAttributeConfiguration): (target: {}, property: string) => void; | ||
/** | ||
* Decorator: Specifies an HTML attribute. | ||
* | ||
* @param target - The class | ||
* @param prop - The property name | ||
* Decorator: Specifies an HTML attribute. | ||
* @param target - The class to define the attribute on. | ||
* @param prop - The property name to be associated with the attribute. | ||
* @public | ||
*/ | ||
export declare function attr(target: {}, prop: string): void; | ||
/** | ||
* Metadata used to configure a custom attribute's behavior. | ||
* @public | ||
*/ | ||
export declare type AttributeConfiguration = { | ||
@@ -71,30 +95,114 @@ property: string; | ||
/** | ||
* An implementation of {@link Accessor} that supports reactivity, | ||
* change callbacks, attribute reflection, and type conversion for | ||
* custom elements. | ||
* @public | ||
*/ | ||
export declare class AttributeDefinition implements Accessor { | ||
private readonly fieldName; | ||
private readonly callbackName; | ||
private readonly hasCallback; | ||
private readonly guards; | ||
/** | ||
* The class constructor that owns this attribute. | ||
*/ | ||
readonly Owner: Function; | ||
/** | ||
* The name of the property associated with the attribute. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* The name of the attribute in HTML. | ||
*/ | ||
readonly attribute: string; | ||
/** | ||
* The {@link AttributeMode} that describes the behavior of this attribute. | ||
*/ | ||
readonly mode: AttributeMode; | ||
readonly converter?: ValueConverter | undefined; | ||
private readonly fieldName; | ||
private readonly callbackName; | ||
private readonly hasCallback; | ||
private readonly guards; | ||
constructor(Owner: Function, name: string, attribute?: string, mode?: AttributeMode, converter?: ValueConverter | undefined); | ||
/** | ||
* A {@link ValueConverter} that integrates with the property getter/setter | ||
* to convert values to and from a DOM string. | ||
*/ | ||
readonly converter?: ValueConverter; | ||
/** | ||
* Creates an instance of AttributeDefinition. | ||
* @param Owner - The class constructor that owns this attribute. | ||
* @param name - The name of the property associated with the attribute. | ||
* @param attribute - The name of the attribute in HTML. | ||
* @param mode - The {@link AttributeMode} that describes the behavior of this attribute. | ||
* @param converter - A {@link ValueConverter} that integrates with the property getter/setter | ||
* to convert values to and from a DOM string. | ||
*/ | ||
constructor(Owner: Function, name: string, attribute?: string, mode?: AttributeMode, converter?: ValueConverter); | ||
/** | ||
* Sets the value of the attribute/property on the source element. | ||
* @param source - The source element to access. | ||
* @param value - The value to set the attribute/property to. | ||
*/ | ||
setValue(source: HTMLElement, newValue: any): void; | ||
/** | ||
* Gets the value of the attribute/property on the source element. | ||
* @param source - The source element to access. | ||
*/ | ||
getValue(source: HTMLElement): any; | ||
/** @internal */ | ||
onAttributeChangedCallback(element: HTMLElement, value: any): void; | ||
private tryReflectToAttribute; | ||
/** | ||
* Collects all attribute definitions associated with the owner. | ||
* @param Owner - The class constructor to collect attribute for. | ||
* @param attributeLists - Any existing attributes to collect and merge with those associated with the owner. | ||
* @internal | ||
*/ | ||
static collect(Owner: Function, ...attributeLists: (ReadonlyArray<string | AttributeConfiguration> | undefined)[]): ReadonlyArray<AttributeDefinition>; | ||
} | ||
/** | ||
* The mode that specifies the runtime behavior of the attribute. | ||
* @remarks | ||
* By default, attributes run in `reflect` mode, propagating their property | ||
* values to the DOM and DOM values to the property. The `boolean` mode also | ||
* reflects values, but uses the HTML standard boolean attribute behavior, | ||
* interpreting the presence of the attribute as `true` and the absence as | ||
* `false`. The `fromView` behavior only updates the property value based on | ||
* changes in the DOM, but does not reflect property changes back. | ||
* @public | ||
*/ | ||
export declare type AttributeMode = "reflect" | "boolean" | "fromView"; | ||
/** | ||
* Represents and object that can contribute behavior to a view or | ||
* element's bind/unbind operations. | ||
* @public | ||
*/ | ||
export declare interface Behavior { | ||
/** | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
bind(source: unknown, context: ExecutionContext): void; | ||
/** | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
unbind(source: unknown): void; | ||
} | ||
/** | ||
* A factory that can create a {@link Behavior} associated with a particular | ||
* location within a DOM fragment. | ||
* @public | ||
*/ | ||
export declare interface BehaviorFactory { | ||
/** | ||
* The index of the DOM node to which the created behavior will apply. | ||
*/ | ||
targetIndex: number; | ||
createBehavior(target: any): Behavior; | ||
/** | ||
* Creates a behavior for the provided target node. | ||
* @param target - The node instance to create the behavior for. | ||
*/ | ||
createBehavior(target: Node): Behavior; | ||
} | ||
@@ -105,2 +213,3 @@ | ||
* as part of a template binding update. | ||
* @public | ||
*/ | ||
@@ -112,32 +221,47 @@ export declare type Binding<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn; | ||
* BindingDirective. | ||
* @public | ||
*/ | ||
export declare class BindingBehavior implements Behavior { | ||
target: any; | ||
binding: Binding; | ||
bind: typeof normalBind; | ||
unbind: typeof normalUnbind; | ||
updateTarget: typeof updatePropertyTarget; | ||
targetName?: string | undefined; | ||
/** @internal */ | ||
source: unknown; | ||
/** @internal */ | ||
context: ExecutionContext | null; | ||
/** @internal */ | ||
bindingObserver: BindingObserver | null; | ||
/** @internal */ | ||
classVersions: Record<string, number>; | ||
/** @internal */ | ||
version: number; | ||
/** @internal */ | ||
target: any; | ||
/** @internal */ | ||
binding: Binding; | ||
/** @internal */ | ||
updateTarget: typeof updatePropertyTarget; | ||
/** @internal */ | ||
targetName?: string; | ||
/** | ||
* | ||
* @param target The target of the data updates. | ||
* @param binding The binding that returns the latest value for an update. | ||
* @param bind The operation to perform during binding. | ||
* @param unbind The operation to perform during unbinding. | ||
* @param updateTarget The operation to perform when updating. | ||
* @param targetName The name of the target attribute or property to update. | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
constructor(target: any, binding: Binding, bind: typeof normalBind, unbind: typeof normalUnbind, updateTarget: typeof updatePropertyTarget, targetName?: string | undefined); | ||
bind: typeof normalBind; | ||
/** | ||
* @internal | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
handleChange(): void; | ||
unbind: typeof normalUnbind; | ||
/** | ||
* @internal | ||
* Creates an instance of BindingBehavior. | ||
* @param target - The target of the data updates. | ||
* @param binding - The binding that returns the latest value for an update. | ||
* @param bind - The operation to perform during binding. | ||
* @param unbind - The operation to perform during unbinding. | ||
* @param updateTarget - The operation to perform when updating. | ||
* @param targetName - The name of the target attribute or property to update. | ||
*/ | ||
constructor(target: any, binding: Binding, bind: typeof normalBind, unbind: typeof normalUnbind, updateTarget: typeof updatePropertyTarget, targetName?: string); | ||
/** @internal */ | ||
handleChange(): void; | ||
/** @internal */ | ||
handleEvent(event: Event): void; | ||
@@ -148,2 +272,3 @@ } | ||
* A directive that configures data binding to element content and attributes. | ||
* @public | ||
*/ | ||
@@ -154,3 +279,2 @@ export declare class BindingDirective extends Directive { | ||
private originalTargetName?; | ||
createPlaceholder: (index: number) => string; | ||
private bind; | ||
@@ -160,15 +284,16 @@ private unbind; | ||
/** | ||
* Creates a placeholder string based on the directive's index within the template. | ||
* @param index - The index of the directive within the template. | ||
*/ | ||
createPlaceholder: (index: number) => string; | ||
/** | ||
* Creates an instance of BindingDirective. | ||
* @param binding A binding that returns the data used to update the DOM. | ||
* @param binding - A binding that returns the data used to update the DOM. | ||
*/ | ||
constructor(binding: Binding); | ||
/** | ||
* Gets the name of the attribute or property that this | ||
* Gets/sets the name of the attribute or property that this | ||
* binding is targeting. | ||
*/ | ||
get targetName(): string | undefined; | ||
/** | ||
* Sets the name of the attribute or property tha this | ||
* binding is targeting. | ||
*/ | ||
set targetName(value: string | undefined); | ||
@@ -183,5 +308,5 @@ /** | ||
* information stored in the BindingDirective. | ||
* @param target The target node that the binding behavior should attach to. | ||
* @param target - The target node that the binding behavior should attach to. | ||
*/ | ||
createBehavior(target: any): BindingBehavior; | ||
createBehavior(target: Node): BindingBehavior; | ||
} | ||
@@ -191,2 +316,3 @@ | ||
* Enables evaluation of and subscription to a binding. | ||
* @public | ||
*/ | ||
@@ -196,4 +322,4 @@ export declare interface BindingObserver<TSource = any, TReturn = any, TParent = any> extends Notifier { | ||
* Begins observing the binding for the source and returns the current value. | ||
* @param source The source that the binding is based on. | ||
* @param context The execution context to execute the binding within. | ||
* @param source - The source that the binding is based on. | ||
* @param context - The execution context to execute the binding within. | ||
* @returns The value of the binding. | ||
@@ -208,2 +334,8 @@ */ | ||
/** | ||
* A {@link ValueConverter} that converts to and from `boolean` values. | ||
* @remarks | ||
* Used automatically when the `boolean` {@link AttributeMode} is selected. | ||
* @public | ||
*/ | ||
export declare const booleanConverter: ValueConverter; | ||
@@ -213,2 +345,3 @@ | ||
* Represents a callable type such as a function or an object with a "call" method. | ||
* @public | ||
*/ | ||
@@ -222,2 +355,3 @@ export declare type Callable = typeof Function.prototype.call | { | ||
* into templates. | ||
* @public | ||
*/ | ||
@@ -227,12 +361,40 @@ export declare interface CaptureType<TSource> { | ||
/** | ||
* A directive that observes the `childNodes` of an element and updates a property | ||
* whenever they change. | ||
* @param propertyOrOptions - The options used to configure child node observation. | ||
* @public | ||
*/ | ||
export declare function children<T = any>(propertyOrOptions: (keyof T & string) | ChildrenBehaviorOptions<keyof T & string>): CaptureType<T>; | ||
/** | ||
* The runtime behavior for child node observation. | ||
* @public | ||
*/ | ||
export declare class ChildrenBehavior extends NodeObservationBehavior<ChildrenBehaviorOptions> { | ||
private observer; | ||
/** | ||
* Creates an instance of ChildrenBehavior. | ||
* @param target - The element target to observe children on. | ||
* @param options - The options to use when observing the element children. | ||
*/ | ||
constructor(target: HTMLSlotElement, options: ChildrenBehaviorOptions); | ||
getNodes(): ChildNode[]; | ||
/** | ||
* Begins observation of the nodes. | ||
*/ | ||
observe(): void; | ||
unobserve(): void; | ||
/** | ||
* Disconnects observation of the nodes. | ||
*/ | ||
disconnect(): void; | ||
/** | ||
* Retrieves the nodes that should be assigned to the target. | ||
*/ | ||
protected getNodes(): ChildNode[]; | ||
} | ||
/** | ||
* The options used to configure child node observation. | ||
* @public | ||
*/ | ||
export declare interface ChildrenBehaviorOptions<T = any> extends NodeBehaviorBehaviorOptions<T>, MutationObserverInit { | ||
@@ -243,6 +405,7 @@ } | ||
* The result of compiling a template and its directives. | ||
* @beta | ||
*/ | ||
export declare interface CompilationResult { | ||
/** | ||
* A clonable DocumentFragment representing the compiled HTML. | ||
* A cloneable DocumentFragment representing the compiled HTML. | ||
*/ | ||
@@ -268,6 +431,6 @@ fragment: DocumentFragment; | ||
* Compiles a template and associated directives into a raw compilation | ||
* result which include a clonable DocumentFragment and factories capable | ||
* result which include a cloneable DocumentFragment and factories capable | ||
* of attaching runtime behavior to nodes within the fragment. | ||
* @param template The template to compile. | ||
* @param directives The directives referenced by the template. | ||
* @param template - The template to compile. | ||
* @param directives - The directives referenced by the template. | ||
* @remarks | ||
@@ -277,30 +440,119 @@ * The template that is provided for compilation is altered in-place | ||
* it is recommended that you clone the original and pass the clone to this API. | ||
* @public | ||
*/ | ||
export declare function compileTemplate(template: HTMLTemplateElement, directives: ReadonlyArray<Directive>): CompilationResult; | ||
/** | ||
* Controls the lifecycle and rendering of a `FASTElement`. | ||
* @public | ||
*/ | ||
export declare class Controller extends PropertyChangeNotifier { | ||
private boundObservables; | ||
private behaviors; | ||
/** | ||
* The element being controlled by this controller. | ||
*/ | ||
readonly element: HTMLElement; | ||
/** | ||
* The element definition that instructs this controller | ||
* in how to handle rendering and other platform integrations. | ||
*/ | ||
readonly definition: FASTElementDefinition; | ||
view: ElementView | null; | ||
isConnected: boolean; | ||
private boundObservables; | ||
private behaviors; | ||
/** | ||
* The view associated with the custom element. | ||
* @remarks | ||
* If `null` then the element is managing its own rendering. | ||
*/ | ||
readonly view: ElementView | null; | ||
/** | ||
* Indicates whether or not the custom element has been | ||
* connected to the document. | ||
*/ | ||
readonly isConnected: boolean; | ||
/** | ||
* Creates a Controller to control the specified element. | ||
* @param element - The element to be controlled by this controller. | ||
* @param definition - The element definition metadata that instructs this | ||
* controller in how to handle rendering and other platform integrations. | ||
* @internal | ||
*/ | ||
constructor(element: HTMLElement, definition: FASTElementDefinition); | ||
addStyles(styles: ElementStyles, target?: StyleTarget | null): void; | ||
/** | ||
* Adds styles to this element. | ||
* @param styles - The styles to add. | ||
*/ | ||
addStyles(styles: ElementStyles, | ||
/** @internal */ target?: StyleTarget | null): void; | ||
/** | ||
* Removes styles from this element. | ||
* @param styles - the styles to remove. | ||
*/ | ||
removeStyles(styles: ElementStyles): void; | ||
/** | ||
* Adds behaviors to this element. | ||
* @param behaviors - The behaviors to add. | ||
*/ | ||
addBehaviors(behaviors: ReadonlyArray<Behavior>): void; | ||
/** | ||
* Removes behaviors from this element. | ||
* @param behaviors - The behaviors to remove. | ||
*/ | ||
removeBehaviors(behaviors: ReadonlyArray<Behavior>): void; | ||
/** | ||
* Runs connected lifecycle behavior on the associated element. | ||
*/ | ||
onConnectedCallback(): void; | ||
/** | ||
* Runs disconnected lifecycle behavior on the associated element. | ||
*/ | ||
onDisconnectedCallback(): void; | ||
/** | ||
* Runs the attribute changed callback for the associated element. | ||
* @param name - The name of the attribute that changed. | ||
* @param oldValue - The previous value of the attribute. | ||
* @param newValue - The new value of the attribute. | ||
*/ | ||
onAttributeChangedCallback(name: string, oldValue: string, newValue: string): void; | ||
/** | ||
* Emits a custom HTML event. | ||
* @param type - The type name of the event. | ||
* @param detail - The event detail object to send with the event. | ||
* @param options - The event options. By default bubbles and composed. | ||
* @remarks | ||
* Only emits events if connected. | ||
*/ | ||
emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): void | boolean; | ||
/** | ||
* Locates or creates a controller for the specified element. | ||
* @param element - The element to return the controller for. | ||
* @remarks | ||
* The specified element must have a {@link FASTElementDefinition} | ||
* registered either through the use of the {@link customElement} | ||
* decorator or a call to `FASTElement.define`. | ||
*/ | ||
static forCustomElement(element: HTMLElement): Controller; | ||
} | ||
export declare const createStyles: ElementStyleFactory; | ||
/** | ||
* Transforms a template literal string into styles. | ||
* @param strings - The string fragments that are interpolated with the values. | ||
* @param values - The values that are interpolated with the string fragments. | ||
* @remarks | ||
* The css helper supports interpolation of strings and ElementStyle instances. | ||
* @public | ||
*/ | ||
export declare function css(strings: TemplateStringsArray, ...values: InjectableStyles[]): ElementStyles; | ||
/** | ||
* Decorator: Defines a platform custom element based on `FASTElement`. | ||
* @param nameOrDef - The name of the element to define or a definition object | ||
* that describes the element to define. | ||
* @public | ||
*/ | ||
export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Function) => void; | ||
/** | ||
* Metadata used to configure a custom attribute's behavior through a decorator. | ||
* @public | ||
*/ | ||
export declare type DecoratorAttributeConfiguration = Omit<AttributeConfiguration, "property">; | ||
@@ -310,9 +562,25 @@ | ||
* The default execution context used in binding expressions. | ||
* @public | ||
*/ | ||
export declare const defaultExecutionContext: ExecutionContext<any>; | ||
/** | ||
* Instructs the template engine to apply behavior to a node. | ||
* @public | ||
*/ | ||
export declare abstract class Directive implements BehaviorFactory { | ||
/** | ||
* The index of the DOM node to which the created behavior will apply. | ||
*/ | ||
targetIndex: number; | ||
/** | ||
* Creates a placeholder string based on the directive's index within the template. | ||
* @param index - The index of the directive within the template. | ||
*/ | ||
abstract createPlaceholder(index: number): string; | ||
abstract createBehavior(target: any): Behavior; | ||
/** | ||
* Creates a behavior for the provided target node. | ||
* @param target - The node instance to create the behavior for. | ||
*/ | ||
abstract createBehavior(target: Node): Behavior; | ||
} | ||
@@ -322,14 +590,58 @@ | ||
* Common DOM APIs. | ||
* @public | ||
*/ | ||
export declare const DOM: Readonly<{ | ||
/** | ||
* Sets the HTML trusted types policy used by the templating engine. | ||
* @param policy - The policy to set for HTML. | ||
* @remarks | ||
* This API can only be called once, for security reasons. It should be | ||
* called by the application developer at the start of their program. | ||
*/ | ||
setHTMLPolicy(policy: TrustedTypesPolicy): void; | ||
/** | ||
* Turns a string into trusted HTML using the configured trusted types policy. | ||
* @param html - The string to turn into trusted HTML. | ||
* @remarks | ||
* Used internally by the template engine when creating templates | ||
* and setting innerHTML. | ||
*/ | ||
createHTML(html: string): string; | ||
/** | ||
* Determines if the provided node is a template marker used by the runtime. | ||
* @param node - The node to test. | ||
*/ | ||
isMarker(node: Node): node is Comment; | ||
/** | ||
* Given a marker node, extract the {@link Directive} index from the placeholder. | ||
* @param node - The marker node to extract the index from. | ||
*/ | ||
extractDirectiveIndexFromMarker(node: Comment): number; | ||
/** | ||
* Creates a placeholder string suitable for marking out a location *within* | ||
* an attribute value or HTML content. | ||
* @param index - The directive index to create the placeholder for. | ||
* @remarks | ||
* Used internally by binding directives. | ||
*/ | ||
createInterpolationPlaceholder(index: number): string; | ||
/** | ||
* Creates a placeholder that manifests itself as an attribute on an | ||
* element. | ||
* @param attributeName - The name of the custom attribute. | ||
* @param index - The directive index to create the placeholder for. | ||
* @remarks | ||
* Used internally by attribute directives such as `ref`, `slotted`, and `children`. | ||
*/ | ||
createCustomAttributePlaceholder(attributeName: string, index: number): string; | ||
/** | ||
* Creates a placeholder that manifests itself as a marker within the DOM structure. | ||
* @param index - The directive index to create the placeholder for. | ||
* @remarks | ||
* Used internally by structural directives such as `repeat`. | ||
*/ | ||
createBlockPlaceholder(index: number): string; | ||
/** | ||
* Schedules DOM update work in the next async batch. | ||
* @param callable The callable function or object to queue. | ||
* @param callable - The callable function or object to queue. | ||
*/ | ||
@@ -341,8 +653,27 @@ queueUpdate(callable: Callable): void; | ||
nextUpdate(): Promise<void>; | ||
/** | ||
* Sets an attribute value on an element. | ||
* @param element - The element to set the attribute value on. | ||
* @param attributeName - The attribute name to set. | ||
* @param value - The value of the attribute to set. | ||
* @remarks | ||
* If the value is `null` or `undefined`, the attribute is removed, otherwise | ||
* it is set to the provided value using the standard `setAttribute` API. | ||
*/ | ||
setAttribute(element: HTMLElement, attributeName: string, value: any): void; | ||
/** | ||
* Sets a boolean attribute value. | ||
* @param element - The element to set the boolean attribute value on. | ||
* @param attributeName - The attribute name to set. | ||
* @param value - The value of the attribute to set. | ||
* @remarks | ||
* If the value is true, the attribute is added; otherwise it is removed. | ||
*/ | ||
setBooleanAttribute(element: HTMLElement, attributeName: string, value: boolean): void; | ||
}>; | ||
declare type ElementStyleFactory = (styles: ReadonlyArray<InjectableStyles>) => ElementStyles; | ||
/** | ||
* Represents styles that can be applied to a custom element. | ||
* @public | ||
*/ | ||
export declare abstract class ElementStyles { | ||
@@ -357,4 +688,16 @@ /** @internal */ | ||
abstract removeStylesFrom(target: StyleTarget): void; | ||
/** | ||
* Associates behaviors with this set of styles. | ||
* @param behaviors - The behaviors to associate. | ||
*/ | ||
withBehaviors(...behaviors: Behavior[]): this; | ||
/** | ||
* Adds these styles to a global cache for easy lookup by a known key. | ||
* @param key - The key to use for lookup and retrieval in the cache. | ||
*/ | ||
withKey(key: string): this; | ||
/** | ||
* Attempts to find cached styles by a known key. | ||
* @param key - The key to search the style cache for. | ||
*/ | ||
static find(key: string): ElementStyles | null; | ||
@@ -365,2 +708,3 @@ } | ||
* A View representing DOM nodes specifically for rendering the view of a custom element. | ||
* @public | ||
*/ | ||
@@ -370,3 +714,3 @@ export declare interface ElementView extends View { | ||
* Appends the view's DOM nodes to the referenced node. | ||
* @param node The parent node to append the view's DOM nodes to. | ||
* @param node - The parent node to append the view's DOM nodes to. | ||
*/ | ||
@@ -378,2 +722,3 @@ appendTo(node: Node): void; | ||
* A template capable of creating views specifically for rendering custom elements. | ||
* @public | ||
*/ | ||
@@ -383,3 +728,3 @@ export declare interface ElementViewTemplate { | ||
* Creates an ElementView instance based on this template definition. | ||
* @param host The custom element host that this template will be rendered to once created. | ||
* @param host - The custom element host that this template will be rendered to once created. | ||
*/ | ||
@@ -394,2 +739,3 @@ create(host: Element): ElementView; | ||
* no actual items to return. | ||
* @internal | ||
*/ | ||
@@ -400,2 +746,3 @@ export declare const emptyArray: readonly never[]; | ||
* Provides additional contextual information available to behaviors and expressions. | ||
* @public | ||
*/ | ||
@@ -446,11 +793,58 @@ export declare class ExecutionContext<TParent = any> { | ||
/** | ||
* Represents a custom element based on the FASTElement infrastructure. | ||
* @public | ||
*/ | ||
export declare interface FASTElement { | ||
$fastController: Controller; | ||
/** | ||
* The underlying controller that handles the lifecycle and rendering of | ||
* this FASTElement. | ||
*/ | ||
readonly $fastController: Controller; | ||
/** | ||
* Emits a custom HTML event. | ||
* @param type - The type name of the event. | ||
* @param detail - The event detail object to send with the event. | ||
* @param options - The event options. By default bubbles and composed. | ||
* @remarks | ||
* Only emits events if the element is connected. | ||
*/ | ||
$emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): boolean | void; | ||
/** | ||
* The connected callback for this FASTElement. | ||
* @remarks | ||
* This method is invoked by the platform whenever this FASTElement | ||
* becomes connected to the document. | ||
*/ | ||
connectedCallback(): void; | ||
/** | ||
* The disconnected callback for this FASTElement. | ||
* @remarks | ||
* This method is invoked by the platform whenever this FASTElement | ||
* becomes disconnected from the document. | ||
*/ | ||
disconnectedCallback(): void; | ||
/** | ||
* The attribute changed callback for this FASTElement. | ||
* @param name - The name of the attribute that changed. | ||
* @param oldValue - The previous value of the attribute. | ||
* @param newValue - The new value of the attribute. | ||
* @remarks | ||
* This method is invoked by the platform whenever an observed | ||
* attribute of FASTElement has a value change. | ||
*/ | ||
attributeChangedCallback(name: string, oldValue: string, newValue: string): void; | ||
} | ||
/** | ||
* A minimal base class for FASTElements that also provides | ||
* static helpers for working with FASTElements. | ||
* @public | ||
*/ | ||
export declare const FASTElement: (new () => HTMLElement & FASTElement) & { | ||
/** | ||
* Creates a new FASTElement base class inherited from the | ||
* provided base type. | ||
* @param BaseType - The base element type to inherit from. | ||
*/ | ||
from<TBase extends { | ||
@@ -460,30 +854,75 @@ new (): HTMLElement; | ||
}>(BaseType: TBase): new () => InstanceType<TBase> & FASTElement; | ||
/** | ||
* Defines a platform custom element based on the provided type and definition. | ||
* @param Type - The custom element type to define. | ||
* @param nameOrDef - The name of the element to define or a definition object | ||
* that describes the element to define. | ||
*/ | ||
define<TType extends Function>(Type: TType, nameOrDef?: string | PartialFASTElementDefinition): TType; | ||
getDefinition: typeof getDefinition; | ||
/** | ||
* Gets the element definition associated with the specified type. | ||
* @param Type - The custom element type to retrieve the definition for. | ||
*/ | ||
getDefinition<T extends Function>(Type: T): FASTElementDefinition | undefined; | ||
}; | ||
/** | ||
* Defines metadata for a FASTElement. | ||
* @public | ||
*/ | ||
export declare class FASTElementDefinition { | ||
/** | ||
* The name of the custom element. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* The custom attributes of the custom element. | ||
*/ | ||
readonly attributes: ReadonlyArray<AttributeDefinition>; | ||
/** | ||
* A map enabling lookup of attribute by associated property name. | ||
*/ | ||
readonly propertyLookup: Record<string, AttributeDefinition>; | ||
/** | ||
* A map enabling lookup of property by associated attribute name. | ||
*/ | ||
readonly attributeLookup: Record<string, AttributeDefinition>; | ||
readonly template?: ElementViewTemplate | undefined; | ||
readonly styles?: ElementStyles | undefined; | ||
readonly shadowOptions?: ShadowRootInit | undefined; | ||
readonly elementOptions?: ElementDefinitionOptions | undefined; | ||
constructor(name: string, attributes: ReadonlyArray<AttributeDefinition>, propertyLookup: Record<string, AttributeDefinition>, attributeLookup: Record<string, AttributeDefinition>, template?: ElementViewTemplate | undefined, styles?: ElementStyles | undefined, shadowOptions?: ShadowRootInit | undefined, elementOptions?: ElementDefinitionOptions | undefined); | ||
/** | ||
* The template to render for the custom element. | ||
*/ | ||
readonly template?: ElementViewTemplate; | ||
/** | ||
* The styles to associated with the custom element. | ||
*/ | ||
readonly styles?: ElementStyles; | ||
/** | ||
* Options controlling the creation of the custom element's shadow DOM. | ||
*/ | ||
readonly shadowOptions?: ShadowRootInit; | ||
/** | ||
* Options controlling how the custom element is defined with the platform. | ||
*/ | ||
readonly elementOptions?: ElementDefinitionOptions; | ||
/** | ||
* Creates an instance of FASTElementDefinition. | ||
* @param name - The name of the custom element. | ||
* @param attributes - The custom attributes of the custom element. | ||
* @param propertyLookup - A map enabling lookup of attribute by associated property name. | ||
* @param attributeLookup - A map enabling lookup of property by associated attribute name. | ||
* @param template - The template to render for the custom element. | ||
* @param styles - The styles to associated with the custom element. | ||
* @param shadowOptions - Options controlling the creation of the custom element's shadow DOM. | ||
* @param elementOptions - Options controlling how the custom element is defined with the platform. | ||
*/ | ||
constructor(name: string, attributes: ReadonlyArray<AttributeDefinition>, propertyLookup: Record<string, AttributeDefinition>, attributeLookup: Record<string, AttributeDefinition>, template?: ElementViewTemplate, styles?: ElementStyles, shadowOptions?: ShadowRootInit, elementOptions?: ElementDefinitionOptions); | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
declare function getDefinition<T extends Function>(Type: T): FASTElementDefinition | undefined; | ||
/** | ||
* Transforms a template literal string into a renderable ViewTemplate. | ||
* @param strings The string fragments that interpolated with the values. | ||
* @param values The values that are interpolated with the string fragments. | ||
* @param strings - The string fragments that are interpolated with the values. | ||
* @param values - The values that are interpolated with the string fragments. | ||
* @remarks | ||
* The html helper supports interpolation of strings, numbers, binding expressions, | ||
* other template instances, and Directive instances. | ||
* @public | ||
*/ | ||
@@ -494,2 +933,3 @@ export declare function html<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: TemplateValue<TSource, TParent>[]): ViewTemplate<TSource, TParent>; | ||
* The standard View implementation, which also implements ElementView and SyntheticView. | ||
* @public | ||
*/ | ||
@@ -499,10 +939,22 @@ export declare class HTMLView implements ElementView, SyntheticView { | ||
private behaviors; | ||
/** | ||
* The data that the view is bound to. | ||
*/ | ||
source: any | null; | ||
/** | ||
* The execution context the view is running within. | ||
*/ | ||
context: ExecutionContext | null; | ||
/** | ||
* The first DOM node in the range of nodes that make up the view. | ||
*/ | ||
firstChild: Node; | ||
/** | ||
* The last DOM node in the range of nodes that make up the view. | ||
*/ | ||
lastChild: Node; | ||
/** | ||
* | ||
* @param fragment The html fragment that contains the nodes for this view. | ||
* @param behaviors The behaviors to be applied to this view. | ||
* Constructs an instance of HTMLView. | ||
* @param fragment - The html fragment that contains the nodes for this view. | ||
* @param behaviors - The behaviors to be applied to this view. | ||
*/ | ||
@@ -512,3 +964,3 @@ constructor(fragment: DocumentFragment, behaviors: Behavior[]); | ||
* Appends the view's DOM nodes to the referenced node. | ||
* @param node The parent node to append the view's DOM nodes to. | ||
* @param node - The parent node to append the view's DOM nodes to. | ||
*/ | ||
@@ -518,3 +970,3 @@ appendTo(node: Node): void; | ||
* Inserts the view's DOM nodes before the referenced node. | ||
* @param node The node to insert the view's DOM before. | ||
* @param node - The node to insert the view's DOM before. | ||
*/ | ||
@@ -534,4 +986,4 @@ insertBefore(node: Node): void; | ||
* Binds a view's behaviors to its binding source. | ||
* @param source The binding source for the view's binding behaviors. | ||
* @param context The execution context to run the behaviors within. | ||
* @param source - The binding source for the view's binding behaviors. | ||
* @param context - The execution context to run the behaviors within. | ||
*/ | ||
@@ -545,3 +997,3 @@ bind(source: unknown, context: ExecutionContext): void; | ||
* Efficiently disposes of a contiguous range of synthetic view instances. | ||
* @param views A contiguous range of views to be disposed. | ||
* @param views - A contiguous range of views to be disposed. | ||
*/ | ||
@@ -553,6 +1005,25 @@ static disposeContiguousBatch(views: SyntheticView[]): void; | ||
/** | ||
* Reverses all readonly members, making them mutable. | ||
* @internal | ||
*/ | ||
export declare type Mutable<T> = { | ||
-readonly [P in keyof T]: T[P]; | ||
}; | ||
/** | ||
* Options for configuring node observation behavior. | ||
* @public | ||
*/ | ||
declare interface NodeBehaviorBehaviorOptions<T = any> { | ||
/** | ||
* The property to assign the observed nodes to. | ||
*/ | ||
property: T; | ||
} | ||
/** | ||
* A base class for node observation. | ||
* @internal | ||
*/ | ||
declare abstract class NodeObservationBehavior<T extends NodeBehaviorBehaviorOptions> implements Behavior { | ||
@@ -563,10 +1034,34 @@ protected target: HTMLSlotElement; | ||
private shouldUpdate; | ||
/** | ||
* Creates an instance of NodeObservationBehavior. | ||
* @param target - The target to assign the nodes property on. | ||
* @param options - The options to use in configuring node observation. | ||
*/ | ||
constructor(target: HTMLSlotElement, options: T); | ||
/** | ||
* Begins observation of the nodes. | ||
*/ | ||
abstract observe(): void; | ||
abstract unobserve(): void; | ||
abstract getNodes(): Node[]; | ||
/** | ||
* Disconnects observation of the nodes. | ||
*/ | ||
abstract disconnect(): void; | ||
/** | ||
* Retrieves the nodes that should be assigned to the target. | ||
*/ | ||
protected abstract getNodes(): Node[]; | ||
/** | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
bind(source: any): void; | ||
/** | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
unbind(): void; | ||
/** @internal */ | ||
handleEvent(): void; | ||
updateTarget(value: ReadonlyArray<any>): void; | ||
private updateTarget; | ||
} | ||
@@ -580,2 +1075,3 @@ | ||
* Provides change notification for a source object. | ||
* @public | ||
*/ | ||
@@ -589,3 +1085,3 @@ export declare interface Notifier { | ||
* Notifies all subscribers, based on the args. | ||
* @param args Data passed along to subscribers during notification. | ||
* @param args - Data passed along to subscribers during notification. | ||
* @remarks | ||
@@ -598,4 +1094,4 @@ * In some implementations, the args may be used to target specific subscribers. | ||
* Subscribes to notification of changes in an object's state. | ||
* @param subscriber The object that is subscribing for change notification. | ||
* @param propertyToWatch The name of the property that the subscriber is interested in watching for changes. | ||
* @param subscriber - The object that is subscribing for change notification. | ||
* @param propertyToWatch - The name of the property that the subscriber is interested in watching for changes. | ||
* @remarks | ||
@@ -607,4 +1103,4 @@ * Some implementation may or may not require the propertyToWatch. | ||
* Unsubscribes from notification of changes in an object's state. | ||
* @param subscriber The object that is unsubscribing from change notification. | ||
* @param propertyToUnwatch The name of the property that the subscriber is no longer interested in watching. | ||
* @param subscriber - The object that is unsubscribing from change notification. | ||
* @param propertyToUnwatch - The name of the property that the subscriber is no longer interested in watching. | ||
* @remarks | ||
@@ -616,2 +1112,9 @@ * Some implementation may or may not require the propertyToUnwatch. | ||
/** | ||
* A {@link ValueConverter} that converts to and from `number` values. | ||
* @remarks | ||
* This converter allows for nullable numbers, returning `null` if the | ||
* input was `null`, `undefined`, or `NaN`. | ||
* @public | ||
*/ | ||
export declare const nullableNumberConverter: ValueConverter; | ||
@@ -621,2 +1124,3 @@ | ||
* Common Observable APIs. | ||
* @public | ||
*/ | ||
@@ -626,3 +1130,3 @@ export declare const Observable: Readonly<{ | ||
* @internal | ||
* @param factory The factory used to create array observers. | ||
* @param factory - The factory used to create array observers. | ||
*/ | ||
@@ -632,3 +1136,3 @@ setArrayObserverFactory(factory: (collection: any[]) => Notifier): void; | ||
* Gets a notifier for an object or Array. | ||
* @param source The object or Array to get the notifier for. | ||
* @param source - The object or Array to get the notifier for. | ||
*/ | ||
@@ -638,4 +1142,4 @@ getNotifier(source: any): Notifier; | ||
* Records a property change for a source object. | ||
* @param source The object to record the change against. | ||
* @param propertyName The property to track as changed. | ||
* @param source - The object to record the change against. | ||
* @param propertyName - The property to track as changed. | ||
*/ | ||
@@ -645,4 +1149,4 @@ track(source: unknown, propertyName: string): void; | ||
* Notifies subscribers of a source object of changes. | ||
* @param source the object to notify of changes. | ||
* @param args The change args to pass to subscribers. | ||
* @param source - the object to notify of changes. | ||
* @param args - The change args to pass to subscribers. | ||
*/ | ||
@@ -652,4 +1156,4 @@ notify(source: unknown, args: any): void; | ||
* Defines an observable property on an object or prototype. | ||
* @param target The target object to define the observable on. | ||
* @param nameOrAccessor The name of the property to define as observable; | ||
* @param target - The target object to define the observable on. | ||
* @param nameOrAccessor - The name of the property to define as observable; | ||
* or a custom accessor that specifies the property name and accessor implementation. | ||
@@ -661,3 +1165,3 @@ */ | ||
* including its prototype chain. | ||
* @param target The target object to search for accessor on. | ||
* @param target - The target object to search for accessor on. | ||
*/ | ||
@@ -668,4 +1172,4 @@ getAccessors(target: {}): Accessor[]; | ||
* provided {@link Binding} for changes. | ||
* @param binding The binding to observe. | ||
* @param initialSubscriber An initial subscriber to changes in the binding value. | ||
* @param binding - The binding to observe. | ||
* @param initialSubscriber - An initial subscriber to changes in the binding value. | ||
*/ | ||
@@ -677,15 +1181,38 @@ binding<TScope = any, TReturn = any, TParent = any>(binding: Binding<any, any, any>, initialSubscriber?: Subscriber | undefined): BindingObserver<TScope, TReturn, TParent>; | ||
* Decorator: Defines an observable property on the target. | ||
* @param target The target to define the observable on. | ||
* @param nameOrAccessor The property name or accessor to define the observable as. | ||
* @param target - The target to define the observable on. | ||
* @param nameOrAccessor - The property name or accessor to define the observable as. | ||
* @public | ||
*/ | ||
export declare function observable(target: {}, nameOrAccessor: string | Accessor): void; | ||
export declare type PartialFASTElementDefinition = { | ||
/** | ||
* Represents metadata configuration for a custom element. | ||
* @public | ||
*/ | ||
export declare interface PartialFASTElementDefinition { | ||
/** | ||
* The name of the custom element. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* The template to render for the custom element. | ||
*/ | ||
readonly template?: ElementViewTemplate; | ||
/** | ||
* The styles to associated with the custom element. | ||
*/ | ||
readonly styles?: ElementStyles; | ||
/** | ||
* The custom attributes of the custom element. | ||
*/ | ||
readonly attributes?: (AttributeConfiguration | string)[]; | ||
/** | ||
* Options controlling the creation of the custom element's shadow DOM. | ||
*/ | ||
readonly shadowOptions?: Partial<ShadowRootInit> | null; | ||
/** | ||
* Options controlling how the custom element is defined with the platform. | ||
*/ | ||
readonly elementOptions?: ElementDefinitionOptions; | ||
}; | ||
} | ||
@@ -695,2 +1222,3 @@ /** | ||
* of individual property changes on an object. | ||
* @public | ||
*/ | ||
@@ -705,3 +1233,3 @@ export declare class PropertyChangeNotifier implements Notifier { | ||
* Creates an instance of PropertyChangeNotifier for the specified source. | ||
* @param source The object source that subscribers will receive notifications from. | ||
* @param source - The object source that subscribers will receive notifications from. | ||
*/ | ||
@@ -711,3 +1239,3 @@ constructor(source: any); | ||
* Notifies all subscribers, based on the specified property. | ||
* @param propertyName The property name, passed along to subscribers during notification. | ||
* @param propertyName - The property name, passed along to subscribers during notification. | ||
*/ | ||
@@ -717,4 +1245,4 @@ notify(propertyName: string): void; | ||
* Subscribes to notification of changes in an object's state. | ||
* @param subscriber The object that is subscribing for change notification. | ||
* @param propertyToWatch The name of the property that the subscriber is interested in watching for changes. | ||
* @param subscriber - The object that is subscribing for change notification. | ||
* @param propertyToWatch - The name of the property that the subscriber is interested in watching for changes. | ||
*/ | ||
@@ -724,4 +1252,4 @@ subscribe(subscriber: Subscriber, propertyToWatch: string): void; | ||
* Unsubscribes from notification of changes in an object's state. | ||
* @param subscriber The object that is unsubscribing from change notification. | ||
* @param propertyToUnwatch The name of the property that the subscriber is no longer interested in watching. | ||
* @param subscriber - The object that is unsubscribing from change notification. | ||
* @param propertyToUnwatch - The name of the property that the subscriber is no longer interested in watching. | ||
*/ | ||
@@ -731,14 +1259,48 @@ unsubscribe(subscriber: Subscriber, propertyToUnwatch: string): void; | ||
/** | ||
* A directive that observes the updates a property with a reference to the element. | ||
* @param propertyName - The name of the property to assign the reference to. | ||
* @public | ||
*/ | ||
export declare function ref<T = any>(propertyName: keyof T & string): CaptureType<T>; | ||
/** | ||
* The runtime behavior for template references. | ||
* @public | ||
*/ | ||
export declare class RefBehavior implements Behavior { | ||
private target; | ||
private propertyName; | ||
/** | ||
* Creates an instance of RefBehavior. | ||
* @param target - The element to reference. | ||
* @param propertyName - The name of the property to assign the reference to. | ||
*/ | ||
constructor(target: HTMLElement, propertyName: string); | ||
/** | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
bind(source: any): void; | ||
/** | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
unbind(): void; | ||
} | ||
/** | ||
* A directive that enables list rendering. | ||
* @param binding - The array to render. | ||
* @param template - The template to render for each item in the array. | ||
* @param options - Options used to turn on special repeat features. | ||
* @public | ||
*/ | ||
export declare function repeat<TScope = any, TItem = any>(binding: Binding<TScope, TItem[]>, template: ViewTemplate<Partial<TItem>, TScope>, options?: RepeatOptions): CaptureType<TScope>; | ||
/** | ||
* A behavior that renders a template for each item in an array. | ||
* @public | ||
*/ | ||
export declare class RepeatBehavior implements Behavior, Subscriber { | ||
@@ -757,5 +1319,22 @@ private location; | ||
private bindView; | ||
/** | ||
* Creates an instance of RepeatBehavior. | ||
* @param location - The location in the DOM to render the repeat. | ||
* @param binding - The array to render. | ||
* @param template - The template to render for each item. | ||
* @param options - Options used to turn on special repeat features. | ||
*/ | ||
constructor(location: Node, binding: Binding, template: SyntheticViewTemplate, options: RepeatOptions); | ||
/** | ||
* Bind this behavior to the source. | ||
* @param source - The source to bind to. | ||
* @param context - The execution context that the binding is operating within. | ||
*/ | ||
bind(source: unknown, context: ExecutionContext): void; | ||
/** | ||
* Unbinds this behavior from the source. | ||
* @param source - The source to unbind from. | ||
*/ | ||
unbind(): void; | ||
/** @internal */ | ||
handleChange(source: any, args: Splice[]): void; | ||
@@ -768,2 +1347,6 @@ private observeItems; | ||
/** | ||
* A directive that configures list rendering. | ||
* @public | ||
*/ | ||
export declare class RepeatDirective extends Directive { | ||
@@ -773,8 +1356,29 @@ binding: Binding; | ||
options: RepeatOptions; | ||
/** | ||
* Creates a placeholder string based on the directive's index within the template. | ||
* @param index - The index of the directive within the template. | ||
*/ | ||
createPlaceholder: (index: number) => string; | ||
/** | ||
* Creates an instance of RepeatDirective. | ||
* @param binding - The binding that provides the array to render. | ||
* @param template - The template to render for each item in the array. | ||
* @param options - Options used to turn on special repeat features. | ||
*/ | ||
constructor(binding: Binding, template: SyntheticViewTemplate, options: RepeatOptions); | ||
createBehavior(target: any): RepeatBehavior; | ||
/** | ||
* Creates a behavior for the provided target node. | ||
* @param target - The node instance to create the behavior for. | ||
*/ | ||
createBehavior(target: Node): RepeatBehavior; | ||
} | ||
/** | ||
* Options for configuring repeat behavior. | ||
* @public | ||
*/ | ||
export declare interface RepeatOptions { | ||
/** | ||
* Enables index, length, and dependent positioning updates in item templates. | ||
*/ | ||
positioning: boolean; | ||
@@ -784,16 +1388,44 @@ } | ||
/** | ||
* @param event - The event to set as current for the context. | ||
* @internal | ||
* @param event The event to set as current for the context. | ||
*/ | ||
export declare function setCurrentEvent(event: Event | null): void; | ||
/** | ||
* A directive that observes the `assignedNodes()` of a slot and updates a property | ||
* whenever they change. | ||
* @param propertyOrOptions - The options used to configure slotted node observation. | ||
* @public | ||
*/ | ||
export declare function slotted<T = any>(propertyOrOptions: (keyof T & string) | SlottedBehaviorOptions<keyof T & string>): CaptureType<T>; | ||
/** | ||
* The runtime behavior for slotted node observation. | ||
* @public | ||
*/ | ||
export declare class SlottedBehavior extends NodeObservationBehavior<SlottedBehaviorOptions> { | ||
/** | ||
* Creates an instance of SlottedBehavior. | ||
* @param target - The slot element target to observe. | ||
* @param options - The options to use when observing the slot. | ||
*/ | ||
constructor(target: HTMLSlotElement, options: SlottedBehaviorOptions); | ||
getNodes(): Node[]; | ||
/** | ||
* Begins observation of the nodes. | ||
*/ | ||
observe(): void; | ||
unobserve(): void; | ||
/** | ||
* Disconnects observation of the nodes. | ||
*/ | ||
disconnect(): void; | ||
/** | ||
* Retrieves the nodes that should be assigned to the target. | ||
*/ | ||
protected getNodes(): Node[]; | ||
} | ||
/** | ||
* The options used to configure slotted node observation. | ||
* @public | ||
*/ | ||
export declare interface SlottedBehaviorOptions<T = any> extends NodeBehaviorBehaviorOptions<T>, AssignedNodesOptions { | ||
@@ -804,2 +1436,3 @@ } | ||
* Represents a set of splice-based changes against an Array. | ||
* @public | ||
*/ | ||
@@ -821,16 +1454,25 @@ declare interface Splice { | ||
export declare class StyleElementStyles extends ElementStyles { | ||
styles: InjectableStyles[]; | ||
readonly behaviors: ReadonlyArray<Behavior> | null; | ||
private styleSheets; | ||
private styleClass; | ||
constructor(styles: InjectableStyles[]); | ||
addStylesTo(target: StyleTarget): void; | ||
removeStylesFrom(target: StyleTarget): void; | ||
} | ||
/** | ||
* A node that can be targeted by styles. | ||
* @public | ||
*/ | ||
export declare interface StyleTarget { | ||
/** | ||
* Stylesheets to be adopted by the node. | ||
*/ | ||
adoptedStyleSheets?: CSSStyleSheet[]; | ||
prepend(node: Node): void; | ||
removeChild(node: Node): void; | ||
/** | ||
* Adds styles to the target. | ||
* @param styles - The styles element to add. | ||
*/ | ||
prepend(styles: HTMLStyleElement): void; | ||
/** | ||
* Removes styles from the target. | ||
* @param styles - The styles element to remove. | ||
*/ | ||
removeChild(styles: HTMLStyleElement): void; | ||
/** | ||
* Returns all element descendants of node that match selectors. | ||
* @param selectors - The CSS selector to use for the query. | ||
*/ | ||
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>; | ||
@@ -841,2 +1483,3 @@ } | ||
* Implemented by objects that are interested in change notifications. | ||
* @public | ||
*/ | ||
@@ -846,4 +1489,4 @@ export declare interface Subscriber { | ||
* Called when a source this instance has subscribed to changes. | ||
* @param source The source of the change. | ||
* @param args The event args detailing the change that occurred. | ||
* @param source - The source of the change. | ||
* @param args - The event args detailing the change that occurred. | ||
*/ | ||
@@ -862,2 +1505,3 @@ handleChange(source: any, args: any): void; | ||
* If the set ever exceeds two subscribers, it upgrades to an array automatically. | ||
* @public | ||
*/ | ||
@@ -874,4 +1518,4 @@ export declare class SubscriberSet implements Notifier { | ||
* Creates an instance of SubscriberSet for the specified source. | ||
* @param source The object source that subscribers will receive notifications from. | ||
* @param initialSubscriber An initial subscriber to changes. | ||
* @param source - The object source that subscribers will receive notifications from. | ||
* @param initialSubscriber - An initial subscriber to changes. | ||
*/ | ||
@@ -881,3 +1525,3 @@ constructor(source: any, initialSubscriber?: Subscriber); | ||
* Checks whether the provided subscriber has been added to this set. | ||
* @param subscriber The subscriber to test for inclusion in this set. | ||
* @param subscriber - The subscriber to test for inclusion in this set. | ||
*/ | ||
@@ -887,3 +1531,3 @@ has(subscriber: Subscriber): boolean; | ||
* Subscribes to notification of changes in an object's state. | ||
* @param subscriber The object that is subscribing for change notification. | ||
* @param subscriber - The object that is subscribing for change notification. | ||
*/ | ||
@@ -893,3 +1537,3 @@ subscribe(subscriber: Subscriber): void; | ||
* Unsubscribes from notification of changes in an object's state. | ||
* @param subscriber The object that is unsubscribing from change notification. | ||
* @param subscriber - The object that is unsubscribing from change notification. | ||
*/ | ||
@@ -899,3 +1543,3 @@ unsubscribe(subscriber: Subscriber): void; | ||
* Notifies all subscribers. | ||
* @param args Data passed along to subscribers during notification. | ||
* @param args - Data passed along to subscribers during notification. | ||
*/ | ||
@@ -906,3 +1550,4 @@ notify(args: any): void; | ||
/** | ||
* A view representing a range of DOM nodes which can be added/removed adhoc. | ||
* A view representing a range of DOM nodes which can be added/removed ad hoc. | ||
* @public | ||
*/ | ||
@@ -920,3 +1565,3 @@ export declare interface SyntheticView extends View { | ||
* Inserts the view's DOM nodes before the referenced node. | ||
* @param node The node to insert the view's DOM before. | ||
* @param node - The node to insert the view's DOM before. | ||
*/ | ||
@@ -938,2 +1583,3 @@ insertBefore(node: Node): void; | ||
* A template capable of rendering views not specifically connected to custom elements. | ||
* @public | ||
*/ | ||
@@ -949,2 +1595,3 @@ export declare interface SyntheticViewTemplate<TSource = any, TParent = any> { | ||
* Represents the types of values that can be interpolated into a template. | ||
* @public | ||
*/ | ||
@@ -959,4 +1606,18 @@ export declare type TemplateValue<TScope, TParent = any> = Binding<TScope, any, TParent> | string | number | Directive | CaptureType<TScope>; | ||
/** | ||
* Represents objects that can convert values to a string | ||
* acceptable by the DOM, or from a DOM string into a primitive | ||
* type appropriate for a property. | ||
* @beta | ||
*/ | ||
export declare interface ValueConverter { | ||
/** | ||
* Converts a value to a DOM string. | ||
* @param value - The value to convert to a DOM string. | ||
*/ | ||
toView(value: any): string | null; | ||
/** | ||
* Converts a DOM string to a typed value. | ||
* @param value - The DOM string to convert to a typed value. | ||
*/ | ||
fromView(value: string): any; | ||
@@ -967,2 +1628,3 @@ } | ||
* Represents a collection of DOM nodes which can be bound to a data source. | ||
* @public | ||
*/ | ||
@@ -980,7 +1642,8 @@ export declare interface View { | ||
* Binds a view's behaviors to its binding source. | ||
* @param source The binding source for the view's binding behaviors. | ||
* @param source - The binding source for the view's binding behaviors. | ||
* @param context - The execution context to run the view within. | ||
*/ | ||
bind(source: unknown, context: ExecutionContext): void; | ||
/** | ||
* Unbinds a view's behaviors from its binding source. | ||
* Unbinds a view's behaviors from its binding source and context. | ||
*/ | ||
@@ -992,6 +1655,5 @@ unbind(): void; | ||
* A template capable of creating HTMLView instances or rendering directly to DOM. | ||
* @public | ||
*/ | ||
export declare class ViewTemplate<TSource = any, TParent = any> implements ElementViewTemplate, SyntheticViewTemplate { | ||
readonly html: string | HTMLTemplateElement; | ||
readonly directives: ReadonlyArray<Directive>; | ||
private behaviorCount; | ||
@@ -1004,5 +1666,14 @@ private hasHostBehaviors; | ||
/** | ||
* The html representing what this template will | ||
* instantiate, including placeholders for directives. | ||
*/ | ||
readonly html: string | HTMLTemplateElement; | ||
/** | ||
* The directives that will be connected to placeholders in the html. | ||
*/ | ||
readonly directives: ReadonlyArray<Directive>; | ||
/** | ||
* Creates an instance of ViewTemplate. | ||
* @param html The html representing what this template will instantiate, including placeholders for directives. | ||
* @param directives The directives that will be connected to placeholders in the html. | ||
* @param html - The html representing what this template will instantiate, including placeholders for directives. | ||
* @param directives - The directives that will be connected to placeholders in the html. | ||
*/ | ||
@@ -1012,3 +1683,3 @@ constructor(html: string | HTMLTemplateElement, directives: ReadonlyArray<Directive>); | ||
* Creates an HTMLView instance based on this template definition. | ||
* @param host The host element that this template will be rendered to once created. | ||
* @param host - The host element that this template will be rendered to once created. | ||
*/ | ||
@@ -1018,4 +1689,4 @@ create(host?: Element): HTMLView; | ||
* Creates an HTMLView from this template, binds it to the source, and then appends it to the host. | ||
* @param source The data source to bind the template to. | ||
* @param host The HTMLElement where the template will be rendered. | ||
* @param source - The data source to bind the template to. | ||
* @param host - The HTMLElement where the template will be rendered. | ||
*/ | ||
@@ -1027,5 +1698,6 @@ render(source: TSource, host: HTMLElement | string): HTMLView; | ||
* A directive that enables basic conditional rendering in a template. | ||
* @param binding The condition to test for rendering. | ||
* @param templateOrTemplateBinding The template or a binding that gets | ||
* @param binding - The condition to test for rendering. | ||
* @param templateOrTemplateBinding - The template or a binding that gets | ||
* the template to render when the condition is true. | ||
* @public | ||
*/ | ||
@@ -1032,0 +1704,0 @@ export declare function when<TSource = any, TReturn = any>(binding: Binding<TSource, TReturn>, templateOrTemplateBinding: SyntheticViewTemplate | Binding<TSource, SyntheticViewTemplate>): CaptureType<TSource>; |
@@ -1,1 +0,1 @@ | ||
const t="fast-"+Math.random().toString(36).substring(7),e=[];void 0===globalThis.trustedTypes&&(globalThis.trustedTypes={createPolicy:(t,e)=>e});const s=globalThis.trustedTypes.createPolicy("fast-html",{createHTML:t=>t});let i=s;function n(){let t=0;for(;t<e.length;){if(e[t].call(),t++,t>1024){for(let s=0,i=e.length-t;s<i;s++)e[s]=e[s+t];e.length-=t,t=0}}e.length=0}const o=Object.freeze({setHTMLPolicy(t){if(i!==s)throw new Error("The HTML policy can only be set once.");i=t},createHTML:t=>i.createHTML(t),isMarker:e=>e&&8===e.nodeType&&e.data.startsWith(t),extractDirectiveIndexFromMarker:e=>parseInt(e.data.replace(t+":","")),createInterpolationPlaceholder:t=>`@{${t}}`,createCustomAttributePlaceholder(t,e){return`${t}="${this.createInterpolationPlaceholder(e)}"`},createBlockPlaceholder:e=>`\x3c!--${t}:${e}--\x3e`,queueUpdate(t){e.length<1&&window.requestAnimationFrame(n),e.push(t)},nextUpdate:()=>new Promise(t=>{o.queueUpdate(t)}),setAttribute(t,e,s){null==s?t.removeAttribute(e):t.setAttribute(e,s)},setBooleanAttribute(t,e,s){s?t.setAttribute(e,""):t.removeAttribute(e)}});function r(t){const e=this.spillover;-1===e.indexOf(t)&&e.push(t)}function h(t){const e=this.spillover,s=e.indexOf(t);-1!==s&&e.splice(s,1)}function l(t){const e=this.spillover,s=this.source;for(let i=0,n=e.length;i<n;++i)e[i].handleChange(s,t)}function a(t){return-1!==this.spillover.indexOf(t)}class c{constructor(t,e){this.sub1=void 0,this.sub2=void 0,this.spillover=void 0,this.source=t,this.sub1=e}has(t){return this.sub1===t||this.sub2===t}subscribe(t){this.has(t)||(void 0!==this.sub1?void 0!==this.sub2?(this.spillover=[this.sub1,this.sub2,t],this.subscribe=r,this.unsubscribe=h,this.notify=l,this.has=a,this.sub1=void 0,this.sub2=void 0):this.sub2=t:this.sub1=t)}unsubscribe(t){this.sub1===t?this.sub1=void 0:this.sub2===t&&(this.sub2=void 0)}notify(t){const e=this.sub1,s=this.sub2,i=this.source;void 0!==e&&e.handleChange(i,t),void 0!==s&&s.handleChange(i,t)}}class d{constructor(t){this.subscribers={},this.source=t}notify(t){const e=this.subscribers[t];void 0!==e&&e.notify(t)}subscribe(t,e){let s=this.subscribers[e];void 0===s&&(this.subscribers[e]=s=new c(this.source)),s.subscribe(t)}unsubscribe(t,e){const s=this.subscribers[e];void 0!==s&&s.unsubscribe(t)}}const u=new WeakMap,f=new WeakMap;let b=void 0,g=t=>{throw new Error("Must call enableArrayObservation before observing arrays.")};class p{constructor(t,e){this.name=t,this.field="_"+t,this.callback=t+"Changed",this.hasCallback=this.callback in e}getValue(t){return void 0!==b&&b.watch(t,this.name),t[this.field]}setValue(t,e){const s=this.field,i=t[s];i!==e&&(t[s]=e,this.hasCallback&&t[this.callback](i,e),m(t).notify(this.name))}}const v=Object.freeze({setArrayObserverFactory(t){g=t},getNotifier(t){let e=t.$fastController||u.get(t);return void 0===e&&(Array.isArray(t)?e=g(t):u.set(t,e=new d(t))),e},track(t,e){void 0!==b&&b.watch(t,e)},notify(t,e){m(t).notify(e)},defineProperty(t,e){"string"==typeof e&&(e=new p(e,t)),this.getAccessors(t).push(e),Reflect.defineProperty(t,e.name,{enumerable:!0,get:function(){return e.getValue(this)},set:function(t){e.setValue(this,t)}})},getAccessors(t){let e=f.get(t);if(void 0===e){let s=Reflect.getPrototypeOf(t);for(;void 0===e&&null!==s;)e=f.get(s),s=Reflect.getPrototypeOf(s);e=void 0===e?[]:e.slice(0),f.set(t,e)}return e},binding:(t,e)=>new T(t,e)}),m=v.getNotifier,C=o.queueUpdate;function x(t,e){v.defineProperty(t,e)}let y=null;function w(t){y=t}class O{constructor(){this.index=0,this.length=0,this.parent=null}get event(){return y}get isEven(){return this.index%2==0}get isOdd(){return this.index%2!=0}get isFirst(){return 0===this.index}get isInMiddle(){return!this.isFirst&&!this.isLast}get isLast(){return this.index===this.length-1}}v.defineProperty(O.prototype,"index"),v.defineProperty(O.prototype,"length");const N=new O;class T extends c{constructor(t,e){super(t,e),this.binding=t,this.needsRefresh=!0,this.needsQueue=!0,this.first=this,this.last=null,this.propertySource=void 0,this.propertyName=void 0,this.notifier=void 0,this.next=void 0}observe(t,e){this.needsRefresh&&null!==this.last&&this.disconnect();const s=b;b=this.needsRefresh?this:void 0,this.needsRefresh=!1;const i=this.binding(t,e);return b=s,i}disconnect(){if(null!==this.last){let t=this.first;for(;void 0!==t;)t.notifier.unsubscribe(this,t.propertyName),t=t.next;this.last=null,this.needsRefresh=!0}}watch(t,e){const s=this.last,i=m(t),n=null===s?this.first:{};if(n.propertySource=t,n.propertyName=e,n.notifier=i,i.subscribe(this,e),null!==s){if(!this.needsRefresh){b=void 0;const e=s.propertySource[s.propertyName];b=this,t===e&&(this.needsRefresh=!0)}s.next=n}this.last=n}handleChange(){this.needsQueue&&(this.needsQueue=!1,C(this))}call(){this.needsQueue=!0,this.notify(this)}}class A{constructor(){this.targetIndex=0}}class k extends A{constructor(t,e,s){super(),this.name=t,this.behavior=e,this.options=s}createPlaceholder(t){return o.createCustomAttributePlaceholder(this.name,t)}createBehavior(t){return new this.behavior(t,this.options)}}function B(t,e){this.source=t,this.context=e,null===this.bindingObserver&&(this.bindingObserver=v.binding(this.binding,this)),this.updateTarget(this.bindingObserver.observe(t,e))}function S(t,e){this.source=t,this.context=e,this.target.addEventListener(this.targetName,this,!0)}function V(){this.bindingObserver.disconnect(),this.source=null,this.context=null}function $(){this.bindingObserver.disconnect(),this.source=null,this.context=null;const t=this.target.$fastView;void 0!==t&&t.isComposed&&(t.unbind(),t.needsBindOnly=!0)}function M(){this.target.removeEventListener(this.targetName,this,!0),this.source=null,this.context=null}function F(t){o.setAttribute(this.target,this.targetName,t)}function I(t){o.setBooleanAttribute(this.target,this.targetName,t)}function L(t){if(null==t&&(t=""),t.create){this.target.textContent="";let e=this.target.$fastView;void 0===e?e=t.create():this.target.$fastTemplate!==t&&(e.isComposed&&(e.remove(),e.unbind()),e=t.create()),e.isComposed?e.needsBindOnly&&(e.needsBindOnly=!1,e.bind(this.source,this.context)):(e.isComposed=!0,e.bind(this.source,this.context),e.insertBefore(this.target),this.target.$fastView=e,this.target.$fastTemplate=t)}else{const e=this.target.$fastView;void 0!==e&&e.isComposed&&(e.isComposed=!1,e.remove(),e.needsBindOnly?e.needsBindOnly=!1:e.unbind()),this.target.textContent=t}}function P(t){this.target[this.targetName]=t}function E(t){const e=this.classVersions||Object.create(null),s=this.target;let i=this.version||0;if(null!=t&&t.length){const n=t.split(/\s+/);for(let t=0,o=n.length;t<o;++t){const o=n[t];""!==o&&(e[o]=i,s.classList.add(o))}}if(this.classVersions=e,this.version=i+1,0!==i){i-=1;for(const t in e)e[t]===i&&s.classList.remove(t)}}class R extends A{constructor(t){super(),this.binding=t,this.createPlaceholder=o.createInterpolationPlaceholder,this.bind=B,this.unbind=V,this.updateTarget=F}get targetName(){return this.originalTargetName}set targetName(t){if(this.originalTargetName=t,void 0!==t)switch(t[0]){case":":if(this.cleanedTargetName=t.substr(1),this.updateTarget=P,"innerHTML"===this.cleanedTargetName){const t=this.binding;this.binding=(e,s)=>o.createHTML(t(e,s))}break;case"?":this.cleanedTargetName=t.substr(1),this.updateTarget=I;break;case"@":this.cleanedTargetName=t.substr(1),this.bind=S,this.unbind=M;break;default:this.cleanedTargetName=t,"class"===t&&(this.updateTarget=E)}}targetAtContent(){this.updateTarget=L,this.unbind=$}createBehavior(t){return new j(t,this.binding,this.bind,this.unbind,this.updateTarget,this.cleanedTargetName)}}class j{constructor(t,e,s,i,n,o){this.target=t,this.binding=e,this.bind=s,this.unbind=i,this.updateTarget=n,this.targetName=o,this.source=null,this.context=null,this.bindingObserver=null}handleChange(){this.updateTarget(this.bindingObserver.observe(this.source,this.context))}handleEvent(t){w(t);const e=this.binding(this.source,this.context);w(null),!0!==e&&t.preventDefault()}}const H={locatedDirectives:0,targetIndex:-1};function D(t){let e;const s=t.length,i=t.map(t=>"string"==typeof t?()=>t:(e=t.targetName||e,H.locatedDirectives++,t.binding)),n=new R((t,e)=>{let n="";for(let o=0;o<s;++o)n+=i[o](t,e);return n});return n.targetName=e,n}function Q(t,e){let s=t.indexOf("@{",0);const i=t.length;let n,o,r,h=0,l=0,a=null,c=0;for(;s>=0&&s<i-2;){l=1,o=s,s+=2;do{n=t[s],s++,"'"!==n&&'"'!==n?"\\"!==n?null===a&&("{"===n?l++:"}"===n&&l--):s++:null===a?a=n:a===n&&(a=null)}while(l>0&&s<i);if(0!==l)break;if(r=r||[],"\\"===t[o-1]&&"\\"!==t[o-2])r[c]=t.substring(h,o-1)+t.substring(o,s),c++;else{r[c]=t.substring(h,o),c++;const i=e[parseInt(t.substring(o+2,s-1))];r[c]=i,c++}h=s,s=t.indexOf("@{",s)}return 0===c?null:(r[c]=t.substr(h),r=r.filter(t=>""!==t),1==r.length?r[0]:r)}function U(t,e,s,i=!1){const n=t.attributes;for(let o=0,r=n.length;o<r;++o){const h=n[o],l=h.value;let a=Q(l,e);null===a?i&&(a=new R(()=>l),a.targetName=h.name):Array.isArray(a)?a=D(a):H.locatedDirectives++,null!==a&&(t.removeAttributeNode(h),o--,r--,a.targetIndex=H.targetIndex,s.push(a))}}function q(t,e){t.targetAtContent(),t.targetIndex=H.targetIndex,e.push(t),H.locatedDirectives++}function W(t,e,s,i){const n=Q(t.textContent,e);if(null!==n)if(Array.isArray(n)){let e=t;for(let o=0,r=n.length;o<r;++o){const r=n[o],h=0===o?t:e.parentNode.insertBefore(document.createTextNode(""),e.nextSibling);"string"==typeof r?h.textContent=r:(h.textContent=" ",q(r,s)),e=h,H.targetIndex++,h!==t&&i.nextNode()}H.targetIndex--}else t.textContent=" ",q(n,s)}function z(t,e){const s=[];H.locatedDirectives=0,U(t,e,s,!0);const i=t.content,n=[],r=e.length,h=document.createTreeWalker(i,133,null,!1);for(H.targetIndex=-1;H.locatedDirectives<r;){const t=h.nextNode();if(null===t)break;switch(H.targetIndex++,t.nodeType){case 1:U(t,e,n);break;case 3:W(t,e,n,h);break;case 8:if(o.isMarker(t)){const s=e[o.extractDirectiveIndexFromMarker(t)];s.targetIndex=H.targetIndex,H.locatedDirectives++,n.push(s)}else t.parentNode.removeChild(t),H.targetIndex--}}let l=0;return o.isMarker(i.firstChild)&&(i.insertBefore(document.createComment(""),i.firstChild),l=-1),{fragment:i,viewBehaviorFactories:n,hostBehaviorFactories:s,targetOffset:l}}const _=document.createRange();class K{constructor(t,e){this.fragment=t,this.behaviors=e,this.source=null,this.context=null,this.firstChild=t.firstChild,this.lastChild=t.lastChild}appendTo(t){t.appendChild(this.fragment)}insertBefore(t){if(this.fragment.hasChildNodes())t.parentNode.insertBefore(this.fragment,t);else{const e=t.parentNode,s=this.lastChild;let i,n=this.firstChild;for(;n!==s;)i=n.nextSibling,e.insertBefore(n,t),n=i;e.insertBefore(s,t)}}remove(){const t=this.fragment,e=this.lastChild;let s,i=this.firstChild;for(;i!==e;)s=i.nextSibling,t.appendChild(i),i=s;t.appendChild(e)}dispose(){const t=this.firstChild.parentNode,e=this.lastChild;let s,i=this.firstChild;for(;i!==e;)s=i.nextSibling,t.removeChild(i),i=s;t.removeChild(e);const n=this.behaviors,o=this.source;for(let t=0,e=n.length;t<e;++t)n[t].unbind(o)}bind(t,e){const s=this.behaviors;if(this.source!==t)if(null!==this.source){const i=this.source;this.source=t,this.context=e;for(let n=0,o=s.length;n<o;++n){const o=s[n];o.unbind(i),o.bind(t,e)}}else{this.source=t,this.context=e;for(let i=0,n=s.length;i<n;++i)s[i].bind(t,e)}}unbind(){if(null===this.source)return;const t=this.behaviors,e=this.source;for(let s=0,i=t.length;s<i;++s)t[s].unbind(e);this.source=null}static disposeContiguousBatch(t){if(0!==t.length){_.setStart(t[0].firstChild,0),_.setEnd(t[t.length-1].lastChild,0),_.deleteContents();for(let e=0,s=t.length;e<s;++e){const s=t[e],i=s.behaviors,n=s.source;for(let t=0,e=i.length;t<e;++t)i[t].unbind(n)}}}}class G{constructor(t,e){this.html=t,this.directives=e,this.behaviorCount=0,this.hasHostBehaviors=!1,this.fragment=null,this.targetOffset=0,this.viewBehaviorFactories=null,this.hostBehaviorFactories=null}create(t){if(null===this.fragment){let t;const e=this.html;if("string"==typeof e){t=document.createElement("template"),t.innerHTML=o.createHTML(e);const s=t.content.firstElementChild;null!==s&&"TEMPLATE"===s.tagName&&(t=s)}else t=e;const s=z(t,this.directives);this.fragment=s.fragment,this.viewBehaviorFactories=s.viewBehaviorFactories,this.hostBehaviorFactories=s.hostBehaviorFactories,this.targetOffset=s.targetOffset,this.behaviorCount=this.viewBehaviorFactories.length+this.hostBehaviorFactories.length,this.hasHostBehaviors=this.hostBehaviorFactories.length>0}const e=this.fragment.cloneNode(!0),s=this.viewBehaviorFactories,i=new Array(this.behaviorCount),n=document.createTreeWalker(e,133,null,!1);let r=0,h=this.targetOffset,l=n.nextNode();for(let t=s.length;r<t;++r){const t=s[r],e=t.targetIndex;for(;null!==l;){if(h===e){i[r]=t.createBehavior(l);break}l=n.nextNode(),h++}}if(this.hasHostBehaviors){const e=this.hostBehaviorFactories;for(let s=0,n=e.length;s<n;++s,++r)i[r]=e[s].createBehavior(t)}return new K(e,i)}render(t,e){"string"==typeof e&&(e=document.getElementById(e));const s=this.create(e);return s.bind(t,N),s.appendTo(e),s}}const J=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function X(t,...e){const s=[];let i="";for(let n=0,o=t.length-1;n<o;++n){const o=t[n];let r=e[n];if(i+=o,r instanceof G){const t=r;r=()=>t}if("function"==typeof r){r=new R(r);const t=J.exec(o);null!==t&&(r.targetName=t[2])}r instanceof A?(i+=r.createPlaceholder(s.length),s.push(r)):i+=r}return i+=t[t.length-1],new G(i,s)}const Y={toView:t=>t?"true":"false",fromView:t=>null!=t&&"false"!==t&&!1!==t&&0!==t},Z={toView(t){if(null==t)return null;const e=1*t;return isNaN(e)?null:e.toString()},fromView(t){if(null==t)return null;const e=1*t;return isNaN(e)?null:e}};class tt{constructor(t,e,s=e.toLowerCase(),i="reflect",n){this.Owner=t,this.name=e,this.attribute=s,this.mode=i,this.converter=n,this.guards=new Set,this.fieldName="_"+e,this.callbackName=e+"Changed",this.hasCallback=this.callbackName in t.prototype,"boolean"===i&&void 0===n&&(this.converter=Y)}setValue(t,e){const s=t[this.fieldName],i=this.converter;void 0!==i&&(e=i.fromView(e)),s!==e&&(t[this.fieldName]=e,this.tryReflectToAttribute(t),this.hasCallback&&t[this.callbackName](s,e),t.$fastController.notify(this.name))}getValue(t){return v.track(t,this.name),t[this.fieldName]}onAttributeChangedCallback(t,e){this.guards.has(t)||(this.guards.add(t),this.setValue(t,e),this.guards.delete(t))}tryReflectToAttribute(t){const e=this.mode,s=this.guards;s.has(t)||"fromView"===e||o.queueUpdate(()=>{s.add(t);const i=t[this.fieldName];switch(e){case"reflect":const e=this.converter;o.setAttribute(t,this.attribute,void 0!==e?e.toView(i):i);break;case"boolean":o.setBooleanAttribute(t,this.attribute,i)}s.delete(t)})}static collect(t,...e){const s=[];e.push(t.attributes);for(let i=0,n=e.length;i<n;++i){const n=e[i];if(void 0!==n)for(let e=0,i=n.length;e<i;++e){const i=n[e];"string"==typeof i?s.push(new tt(t,i)):s.push(new tt(t,i.property,i.attribute,i.mode,i.converter))}}return s}}function et(t,e){let s;function i(t,e){arguments.length>1&&(s.property=e);const i=t.constructor.attributes||(t.constructor.attributes=[]);i.push(s)}return arguments.length>1?(s={},void i(t,e)):(s=void 0===t?{}:t,i)}class st{constructor(t,e,s,i,n,o,r,h){this.name=t,this.attributes=e,this.propertyLookup=s,this.attributeLookup=i,this.template=n,this.styles=o,this.shadowOptions=r,this.elementOptions=h}}const it=new Map;function nt(t){return it.get(t)}const ot={bubbles:!0,composed:!0};class rt extends d{constructor(t,e){super(t),this.element=t,this.definition=e,this.view=null,this.isConnected=!1,this.boundObservables=null,this.behaviors=null;const s=e.template,i=e.styles,n=void 0===e.shadowOptions?void 0:t.attachShadow(e.shadowOptions);if(void 0!==s){const e=this.view=s.create(this.element);void 0===n?e.appendTo(t):e.appendTo(n)}void 0!==i&&this.addStyles(i,n);const o=v.getAccessors(t);if(o.length>0){const e=this.boundObservables=Object.create(null);for(let s=0,i=o.length;s<i;++s){const i=o[s].name,n=t[i];void 0!==n&&(delete t[i],e[i]=n)}}}addStyles(t,e=this.element.shadowRoot){null!==e&&t.addStylesTo(e);const s=t.behaviors;null!==s&&this.addBehaviors(s)}removeStyles(t){const e=this.element.shadowRoot;null!==e&&t.removeStylesFrom(e);const s=t.behaviors;null!==s&&this.removeBehaviors(s)}addBehaviors(t){const e=this.behaviors||(this.behaviors=[]),s=t.length;for(let i=0;i<s;++i)e.push(t[i]);if(this.isConnected){const e=this.element;for(let i=0;i<s;++i)t[i].bind(e,N)}}removeBehaviors(t){const e=this.behaviors;if(null===e)return;const s=t.length;for(let i=0;i<s;++i){const s=e.indexOf(t[i]);-1!==s&&e.splice(s,1)}if(this.isConnected){const e=this.element;for(let i=0;i<s;++i)t[i].unbind(e)}}onConnectedCallback(){if(this.isConnected)return;const t=this.element,e=this.boundObservables;if(null!==e){const s=Object.keys(e);for(let i=0,n=s.length;i<n;++i){const n=s[i];t[n]=e[n]}this.boundObservables=null}const s=this.view;null!==s&&s.bind(t,N);const i=this.behaviors;if(null!==i)for(let e=0,s=i.length;e<s;++e)i[e].bind(t,N);this.isConnected=!0}onDisconnectedCallback(){if(!1===this.isConnected)return;this.isConnected=!1;const t=this.view;null!==t&&t.unbind();const e=this.behaviors;if(null!==e){const t=this.element;for(let s=0,i=e.length;s<i;++s)e[s].unbind(t)}}onAttributeChangedCallback(t,e,s){const i=this.definition.attributeLookup[t];void 0!==i&&i.onAttributeChangedCallback(this.element,s)}emit(t,e,s){return!!this.isConnected&&this.element.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign({detail:e},ot),s)))}static forCustomElement(t){const e=t.$fastController;if(void 0!==e)return e;const s=nt(t.constructor);if(void 0===s)throw new Error("Missing fast element definition.");return t.$fastController=new rt(t,s)}}const ht={mode:"open"},lt={};function at(t){return class extends t{constructor(){super(),rt.forCustomElement(this)}$emit(t,e,s){return this.$fastController.emit(t,e,s)}connectedCallback(){this.$fastController.onConnectedCallback()}disconnectedCallback(){this.$fastController.onDisconnectedCallback()}attributeChangedCallback(t,e,s){this.$fastController.onAttributeChangedCallback(t,e,s)}}}const ct=Object.assign(at(HTMLElement),{from:t=>at(t),define(t,e=t.definition){"string"==typeof e&&(e={name:e});const s=e.name,i=tt.collect(t,e.attributes),n=void 0===e.shadowOptions?ht:null===e.shadowOptions?void 0:Object.assign(Object.assign({},ht),e.shadowOptions),o=void 0===e.elementOptions?lt:Object.assign(Object.assign({},lt),e.shadowOptions),r=new Array(i.length),h=t.prototype,l={},a={};for(let t=0,e=i.length;t<e;++t){const e=i[t];r[t]=e.attribute,l[e.name]=e,a[e.attribute]=e,v.defineProperty(h,e)}Reflect.defineProperty(t,"observedAttributes",{value:r,enumerable:!0});const c=new st(s,i,l,a,e.template,e.styles,n,o);return it.set(t,c),customElements.define(s,t,c.elementOptions),t},getDefinition:nt});function dt(t){return function(e){ct.define(e,t)}}const ut=Object.freeze([]),ft=new Map;class bt{constructor(){this.behaviors=null}withBehaviors(...t){return this.behaviors=null===this.behaviors?t:this.behaviors.concat(t),this}withKey(t){return ft.set(t,this),this}static find(t){return ft.get(t)||null}}function gt(t){return t.map(t=>t instanceof bt?gt(t.styles):[t]).reduce((t,e)=>t.concat(e),[])}function pt(t){return t.map(t=>t instanceof bt?t.behaviors:null).reduce((t,e)=>null===e?t:(null===t&&(t=[]),t.concat(e)),null)}class vt extends bt{constructor(t,e){super(),this.styles=t,this.behaviors=null,this.behaviors=pt(t),this.styleSheets=gt(t).map(t=>{let s=e.get(t);return void 0===s&&(s=new CSSStyleSheet,s.replaceSync(t),e.set(t,s)),s})}addStylesTo(t){t.adoptedStyleSheets=[...t.adoptedStyleSheets,...this.styleSheets]}removeStylesFrom(t){const e=this.styleSheets;t.adoptedStyleSheets=t.adoptedStyleSheets.filter(t=>-1!==e.indexOf(t))}}let mt=0;class Ct extends bt{constructor(t){super(),this.styles=t,this.behaviors=null,this.behaviors=pt(t),this.styleSheets=gt(t),this.styleClass="fast-style-class-"+ ++mt}addStylesTo(t){const e=this.styleSheets,s=this.styleClass;for(let i=e.length-1;i>-1;--i){const n=document.createElement("style");n.innerHTML=e[i],n.className=s,t.prepend(n)}}removeStylesFrom(t){const e=t.querySelectorAll("."+this.styleClass);for(let s=0,i=e.length;s<i;++s)t.removeChild(e[s])}}const xt=(()=>{if("adoptedStyleSheets"in window.ShadowRoot.prototype){const t=new Map;return e=>new vt(e,t)}return t=>new Ct(t)})();function yt(t,...e){const s=[];let i="";for(let n=0,o=t.length-1;n<o;++n){i+=t[n];const o=e[n];o instanceof bt?(""!==i.trim()&&(s.push(i),i=""),s.push(o)):i+=o}return i+=t[t.length-1],""!==i.trim()&&s.push(i),xt(s)}class wt{constructor(t,e){this.target=t,this.propertyName=e}bind(t){t[this.propertyName]=this.target}unbind(){}}function Ot(t){return new k("fast-ref",wt,t)}function Nt(t,e){const s="function"==typeof e?e:()=>e;return(e,i)=>t(e,i)?s(e,i):null}function Tt(t,e,s){return{index:t,removed:e,addedCount:s}}function At(t,e,s,i,n,o){let r=0,h=0;const l=Math.min(s-e,o-n);if(0===e&&0===n&&(r=function(t,e,s){for(let i=0;i<s;++i)if(t[i]!==e[i])return i;return s}(t,i,l)),s===t.length&&o===i.length&&(h=function(t,e,s){let i=t.length,n=e.length,o=0;for(;o<s&&t[--i]===e[--n];)o++;return o}(t,i,l-r)),n+=r,o-=h,(s-=h)-(e+=r)==0&&o-n==0)return ut;if(e===s){const t=Tt(e,[],0);for(;n<o;)t.removed.push(i[n++]);return[t]}if(n===o)return[Tt(e,[],s-e)];const a=function(t){let e=t.length-1,s=t[0].length-1,i=t[e][s];const n=[];for(;e>0||s>0;){if(0===e){n.push(2),s--;continue}if(0===s){n.push(3),e--;continue}const o=t[e-1][s-1],r=t[e-1][s],h=t[e][s-1];let l;l=r<h?r<o?r:o:h<o?h:o,l===o?(o===i?n.push(0):(n.push(1),i=o),e--,s--):l===r?(n.push(3),e--,i=r):(n.push(2),s--,i=h)}return n.reverse(),n}(function(t,e,s,i,n,o){const r=o-n+1,h=s-e+1,l=new Array(r);let a,c;for(let t=0;t<r;++t)l[t]=new Array(h),l[t][0]=t;for(let t=0;t<h;++t)l[0][t]=t;for(let s=1;s<r;++s)for(let o=1;o<h;++o)t[e+o-1]===i[n+s-1]?l[s][o]=l[s-1][o-1]:(a=l[s-1][o]+1,c=l[s][o-1]+1,l[s][o]=a<c?a:c);return l}(t,e,s,i,n,o)),c=[];let d=void 0,u=e,f=n;for(let t=0;t<a.length;++t)switch(a[t]){case 0:void 0!==d&&(c.push(d),d=void 0),u++,f++;break;case 1:void 0===d&&(d=Tt(u,[],0)),d.addedCount++,u++,d.removed.push(i[f]),f++;break;case 2:void 0===d&&(d=Tt(u,[],0)),d.addedCount++,u++;break;case 3:void 0===d&&(d=Tt(u,[],0)),d.removed.push(i[f]),f++}return void 0!==d&&c.push(d),c}const kt=Array.prototype.push;function Bt(t,e,s,i){const n=Tt(e,s,i);let o=!1,r=0;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s.index+=r,o)continue;const i=(h=n.index,l=n.index+n.removed.length,a=s.index,c=s.index+s.addedCount,l<a||c<h?-1:l===a||c===h?0:h<a?l<c?l-a:c-a:c<l?c-h:l-h);if(i>=0){t.splice(e,1),e--,r-=s.addedCount-s.removed.length,n.addedCount+=s.addedCount-i;const h=n.removed.length+s.removed.length-i;if(n.addedCount||h){let t=s.removed;if(n.index<s.index){const e=n.removed.slice(0,s.index-n.index);kt.apply(e,t),t=e}if(n.index+n.removed.length>s.index+s.addedCount){const e=n.removed.slice(s.index+s.addedCount-n.index);kt.apply(t,e)}n.removed=t,s.index<n.index&&(n.index=s.index)}else o=!0}else if(n.index<s.index){o=!0,t.splice(e,0,n),e++;const i=n.addedCount-n.removed.length;s.index+=i,r+=i}}var h,l,a,c;o||t.push(n)}function St(t,e){let s=[];const i=function(t){const e=[];for(let s=0,i=t.length;s<i;s++){const i=t[s];Bt(e,i.index,i.removed,i.addedCount)}return e}(e);for(let e=0,n=i.length;e<n;++e){const n=i[e];1!==n.addedCount||1!==n.removed.length?s=s.concat(At(t,n.index,n.index+n.addedCount,n.removed,0,n.removed.length)):n.removed[0]!==t[n.index]&&s.push(n)}return s}let Vt=!1;function $t(t,e){let s=t.index;const i=e.length;return s>i?s=i-t.addedCount:s<0&&(s=i+t.removed.length+s-t.addedCount),s<0&&(s=0),t.index=s,t}class Mt extends c{constructor(t){super(t),this.oldCollection=void 0,this.splices=void 0,this.needsQueue=!0,this.call=this.flush,t.$fastController=this}addSplice(t){void 0===this.splices?this.splices=[t]:this.splices.push(t),this.needsQueue&&(this.needsQueue=!1,o.queueUpdate(this))}reset(t){this.oldCollection=t,this.needsQueue&&(this.needsQueue=!1,o.queueUpdate(this))}flush(){const t=this.splices,e=this.oldCollection;if(void 0===t&&void 0===e)return;this.needsQueue=!0,this.splices=void 0,this.oldCollection=void 0;const s=void 0===e?St(this.source,t):At(this.source,0,this.source.length,e,0,e.length);this.notify(s)}}const Ft=Object.freeze({positioning:!1});function It(t,e,s,i){t.bind(e[s],i)}function Lt(t,e,s,i){const n=Object.create(i);n.index=s,n.length=e.length,t.bind(e[s],n)}class Pt{constructor(t,e,s,i){this.location=t,this.binding=e,this.template=s,this.options=i,this.source=void 0,this.views=[],this.items=null,this.itemsObserver=void 0,this.originalContext=void 0,this.childContext=void 0,this.bindView=It,this.bindingObserver=v.binding(e,this),i.positioning&&(this.bindView=Lt)}bind(t,e){this.source=t,this.originalContext=e,this.childContext=Object.create(e),this.childContext.parent=t,this.items=this.bindingObserver.observe(t,this.originalContext),this.observeItems(),this.refreshAllViews()}unbind(){this.source=null,this.items=null,void 0!==this.itemsObserver&&this.itemsObserver.unsubscribe(this),this.unbindAllViews(),this.bindingObserver.disconnect()}handleChange(t,e){t===this.binding?(this.items=this.bindingObserver.observe(this.source,this.originalContext),this.observeItems(),this.refreshAllViews()):this.updateViews(e)}observeItems(){this.items||(this.items=[]);const t=this.itemsObserver,e=this.itemsObserver=v.getNotifier(this.items);t!==e&&(void 0!==t&&t.unsubscribe(this),e.subscribe(this))}updateViews(t){const e=this.childContext,s=this.views,i=[],n=this.bindView;let o=0;for(let e=0,n=t.length;e<n;++e){const n=t[e],r=n.removed;i.push(...s.splice(n.index+o,r.length)),o-=n.addedCount}const r=this.items,h=this.template;for(let o=0,l=t.length;o<l;++o){const l=t[o];let a=l.index;const c=a+l.addedCount;for(;a<c;++a){const t=s[a],o=t?t.firstChild:this.location,l=i.length>0?i.shift():h.create();s.splice(a,0,l),n(l,r,a,e),l.insertBefore(o)}}for(let t=0,e=i.length;t<e;++t)i[t].dispose();if(this.options.positioning)for(let t=0,e=s.length;t<e;++t){const i=s[t].context;i.length=e,i.index=t}}refreshAllViews(){const t=this.items,e=this.childContext;let s=t.length,i=this.views;const n=i.length,o=this.template,r=this.location,h=this.bindView;if(0===s)K.disposeContiguousBatch(this.views),this.views=[];else if(0===n){this.views=i=new Array(s);for(let n=0;n<s;++n){const s=o.create();h(s,t,n,e),i[n]=s,s.insertBefore(r)}}else{let l=0;for(;l<s;++l)if(l<n){h(i[l],t,l,e)}else{const s=o.create();h(s,t,l,e),i.push(s),s.insertBefore(r)}const a=i.splice(l,n-l);for(l=0,s=a.length;l<s;++l)a[l].dispose()}}unbindAllViews(){const t=this.views;for(let e=0,s=t.length;e<s;++e)t[e].unbind()}}class Et extends A{constructor(t,e,s){super(),this.binding=t,this.template=e,this.options=s,this.createPlaceholder=o.createBlockPlaceholder,function(){if(Vt)return;Vt=!0,v.setArrayObserverFactory(t=>new Mt(t));const t=Array.prototype,e=t.pop,s=t.push,i=t.reverse,n=t.shift,o=t.sort,r=t.splice,h=t.unshift;t.pop=function(){const t=this.length>0,s=e.apply(this,arguments),i=this.$fastController;return void 0!==i&&t&&i.addSplice(Tt(this.length,[s],0)),s},t.push=function(){const t=s.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice($t(Tt(this.length-arguments.length,[],arguments.length),this)),t},t.reverse=function(){let t;const e=this.$fastController;void 0!==e&&(e.flush(),t=this.slice());const s=i.apply(this,arguments);return void 0!==e&&e.reset(t),s},t.shift=function(){const t=this.length>0,e=n.apply(this,arguments),s=this.$fastController;return void 0!==s&&t&&s.addSplice(Tt(0,[e],0)),e},t.sort=function(){let t;const e=this.$fastController;void 0!==e&&(e.flush(),t=this.slice());const s=o.apply(this,arguments);return void 0!==e&&e.reset(t),s},t.splice=function(){const t=r.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice($t(Tt(+arguments[0],t,arguments.length>2?arguments.length-2:0),this)),t},t.unshift=function(){const t=h.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice($t(Tt(0,[],arguments.length),this)),t}}()}createBehavior(t){return new Pt(t,this.binding,this.template,this.options)}}function Rt(t,e,s=Ft){return new Et(t,e,s)}class jt{constructor(t,e){this.target=t,this.options=e,this.source=null}bind(t){const e=this.options.property;this.shouldUpdate=v.getAccessors(t).some(t=>t.name===e),this.source=t,this.updateTarget(this.getNodes()),this.shouldUpdate&&this.observe()}unbind(){this.updateTarget(ut),this.source=null,this.shouldUpdate&&this.unobserve()}handleEvent(){this.updateTarget(this.getNodes())}updateTarget(t){this.source[this.options.property]=t}}class Ht extends jt{constructor(t,e){super(t,e)}getNodes(){return this.target.assignedNodes(this.options)}observe(){this.target.addEventListener("slotchange",this)}unobserve(){this.target.removeEventListener("slotchange",this)}}function Dt(t){return"string"==typeof t&&(t={property:t}),new k("fast-slotted",Ht,t)}class Qt extends jt{constructor(t,e){super(t,e),this.observer=null}getNodes(){return Array.from(this.target.childNodes)}observe(){null===this.observer&&(this.observer=new MutationObserver(this.handleEvent.bind(this))),this.observer.observe(this.target,this.options)}unobserve(){this.observer.disconnect()}}function Ut(t){return"string"==typeof t&&(t={property:t,childList:!0}),new k("fast-children",Qt,t)}export{vt as AdoptedStyleSheetsStyles,k as AttachedBehaviorDirective,tt as AttributeDefinition,j as BindingBehavior,R as BindingDirective,Qt as ChildrenBehavior,rt as Controller,o as DOM,A as Directive,bt as ElementStyles,O as ExecutionContext,ct as FASTElement,st as FASTElementDefinition,K as HTMLView,v as Observable,d as PropertyChangeNotifier,wt as RefBehavior,Pt as RepeatBehavior,Et as RepeatDirective,Ht as SlottedBehavior,Ct as StyleElementStyles,c as SubscriberSet,G as ViewTemplate,et as attr,Y as booleanConverter,Ut as children,z as compileTemplate,xt as createStyles,yt as css,dt as customElement,N as defaultExecutionContext,ut as emptyArray,X as html,Z as nullableNumberConverter,x as observable,Ot as ref,Rt as repeat,w as setCurrentEvent,Dt as slotted,Nt as when}; | ||
const t="fast-"+Math.random().toString(36).substring(7),e=[];void 0===globalThis.trustedTypes&&(globalThis.trustedTypes={createPolicy:(t,e)=>e});const s=globalThis.trustedTypes.createPolicy("fast-html",{createHTML:t=>t});let i=s;function n(){let t=0;for(;t<e.length;){if(e[t].call(),t++,t>1024){for(let s=0,i=e.length-t;s<i;s++)e[s]=e[s+t];e.length-=t,t=0}}e.length=0}const o=Object.freeze({setHTMLPolicy(t){if(i!==s)throw new Error("The HTML policy can only be set once.");i=t},createHTML:t=>i.createHTML(t),isMarker:e=>e&&8===e.nodeType&&e.data.startsWith(t),extractDirectiveIndexFromMarker:e=>parseInt(e.data.replace(t+":","")),createInterpolationPlaceholder:t=>`@{${t}}`,createCustomAttributePlaceholder(t,e){return`${t}="${this.createInterpolationPlaceholder(e)}"`},createBlockPlaceholder:e=>`\x3c!--${t}:${e}--\x3e`,queueUpdate(t){e.length<1&&window.requestAnimationFrame(n),e.push(t)},nextUpdate:()=>new Promise(t=>{o.queueUpdate(t)}),setAttribute(t,e,s){null==s?t.removeAttribute(e):t.setAttribute(e,s)},setBooleanAttribute(t,e,s){s?t.setAttribute(e,""):t.removeAttribute(e)}});function r(t){const e=this.spillover;-1===e.indexOf(t)&&e.push(t)}function h(t){const e=this.spillover,s=e.indexOf(t);-1!==s&&e.splice(s,1)}function l(t){const e=this.spillover,s=this.source;for(let i=0,n=e.length;i<n;++i)e[i].handleChange(s,t)}function a(t){return-1!==this.spillover.indexOf(t)}class c{constructor(t,e){this.sub1=void 0,this.sub2=void 0,this.spillover=void 0,this.source=t,this.sub1=e}has(t){return this.sub1===t||this.sub2===t}subscribe(t){this.has(t)||(void 0!==this.sub1?void 0!==this.sub2?(this.spillover=[this.sub1,this.sub2,t],this.subscribe=r,this.unsubscribe=h,this.notify=l,this.has=a,this.sub1=void 0,this.sub2=void 0):this.sub2=t:this.sub1=t)}unsubscribe(t){this.sub1===t?this.sub1=void 0:this.sub2===t&&(this.sub2=void 0)}notify(t){const e=this.sub1,s=this.sub2,i=this.source;void 0!==e&&e.handleChange(i,t),void 0!==s&&s.handleChange(i,t)}}class d{constructor(t){this.subscribers={},this.source=t}notify(t){const e=this.subscribers[t];void 0!==e&&e.notify(t)}subscribe(t,e){let s=this.subscribers[e];void 0===s&&(this.subscribers[e]=s=new c(this.source)),s.subscribe(t)}unsubscribe(t,e){const s=this.subscribers[e];void 0!==s&&s.unsubscribe(t)}}const u=new WeakMap,f=new WeakMap;let b=void 0,g=t=>{throw new Error("Must call enableArrayObservation before observing arrays.")};class p{constructor(t,e){this.name=t,this.field="_"+t,this.callback=t+"Changed",this.hasCallback=this.callback in e}getValue(t){return void 0!==b&&b.watch(t,this.name),t[this.field]}setValue(t,e){const s=this.field,i=t[s];i!==e&&(t[s]=e,this.hasCallback&&t[this.callback](i,e),m(t).notify(this.name))}}const v=Object.freeze({setArrayObserverFactory(t){g=t},getNotifier(t){let e=t.$fastController||u.get(t);return void 0===e&&(Array.isArray(t)?e=g(t):u.set(t,e=new d(t))),e},track(t,e){void 0!==b&&b.watch(t,e)},notify(t,e){m(t).notify(e)},defineProperty(t,e){"string"==typeof e&&(e=new p(e,t)),this.getAccessors(t).push(e),Reflect.defineProperty(t,e.name,{enumerable:!0,get:function(){return e.getValue(this)},set:function(t){e.setValue(this,t)}})},getAccessors(t){let e=f.get(t);if(void 0===e){let s=Reflect.getPrototypeOf(t);for(;void 0===e&&null!==s;)e=f.get(s),s=Reflect.getPrototypeOf(s);e=void 0===e?[]:e.slice(0),f.set(t,e)}return e},binding:(t,e)=>new T(t,e)}),m=v.getNotifier,C=o.queueUpdate;function x(t,e){v.defineProperty(t,e)}let y=null;function w(t){y=t}class O{constructor(){this.index=0,this.length=0,this.parent=null}get event(){return y}get isEven(){return this.index%2==0}get isOdd(){return this.index%2!=0}get isFirst(){return 0===this.index}get isInMiddle(){return!this.isFirst&&!this.isLast}get isLast(){return this.index===this.length-1}}v.defineProperty(O.prototype,"index"),v.defineProperty(O.prototype,"length");const N=new O;class T extends c{constructor(t,e){super(t,e),this.binding=t,this.needsRefresh=!0,this.needsQueue=!0,this.first=this,this.last=null,this.propertySource=void 0,this.propertyName=void 0,this.notifier=void 0,this.next=void 0}observe(t,e){this.needsRefresh&&null!==this.last&&this.disconnect();const s=b;b=this.needsRefresh?this:void 0,this.needsRefresh=!1;const i=this.binding(t,e);return b=s,i}disconnect(){if(null!==this.last){let t=this.first;for(;void 0!==t;)t.notifier.unsubscribe(this,t.propertyName),t=t.next;this.last=null,this.needsRefresh=!0}}watch(t,e){const s=this.last,i=m(t),n=null===s?this.first:{};if(n.propertySource=t,n.propertyName=e,n.notifier=i,i.subscribe(this,e),null!==s){if(!this.needsRefresh){b=void 0;const e=s.propertySource[s.propertyName];b=this,t===e&&(this.needsRefresh=!0)}s.next=n}this.last=n}handleChange(){this.needsQueue&&(this.needsQueue=!1,C(this))}call(){this.needsQueue=!0,this.notify(this)}}class A{constructor(){this.targetIndex=0}}class k extends A{constructor(t,e,s){super(),this.name=t,this.behavior=e,this.options=s}createPlaceholder(t){return o.createCustomAttributePlaceholder(this.name,t)}createBehavior(t){return new this.behavior(t,this.options)}}function S(t,e){this.source=t,this.context=e,null===this.bindingObserver&&(this.bindingObserver=v.binding(this.binding,this)),this.updateTarget(this.bindingObserver.observe(t,e))}function B(t,e){this.source=t,this.context=e,this.target.addEventListener(this.targetName,this,!0)}function V(){this.bindingObserver.disconnect(),this.source=null,this.context=null}function $(){this.bindingObserver.disconnect(),this.source=null,this.context=null;const t=this.target.$fastView;void 0!==t&&t.isComposed&&(t.unbind(),t.needsBindOnly=!0)}function M(){this.target.removeEventListener(this.targetName,this,!0),this.source=null,this.context=null}function F(t){o.setAttribute(this.target,this.targetName,t)}function I(t){o.setBooleanAttribute(this.target,this.targetName,t)}function E(t){if(null==t&&(t=""),t.create){this.target.textContent="";let e=this.target.$fastView;void 0===e?e=t.create():this.target.$fastTemplate!==t&&(e.isComposed&&(e.remove(),e.unbind()),e=t.create()),e.isComposed?e.needsBindOnly&&(e.needsBindOnly=!1,e.bind(this.source,this.context)):(e.isComposed=!0,e.bind(this.source,this.context),e.insertBefore(this.target),this.target.$fastView=e,this.target.$fastTemplate=t)}else{const e=this.target.$fastView;void 0!==e&&e.isComposed&&(e.isComposed=!1,e.remove(),e.needsBindOnly?e.needsBindOnly=!1:e.unbind()),this.target.textContent=t}}function L(t){this.target[this.targetName]=t}function P(t){const e=this.classVersions||Object.create(null),s=this.target;let i=this.version||0;if(null!=t&&t.length){const n=t.split(/\s+/);for(let t=0,o=n.length;t<o;++t){const o=n[t];""!==o&&(e[o]=i,s.classList.add(o))}}if(this.classVersions=e,this.version=i+1,0!==i){i-=1;for(const t in e)e[t]===i&&s.classList.remove(t)}}class R extends A{constructor(t){super(),this.binding=t,this.bind=S,this.unbind=V,this.updateTarget=F,this.createPlaceholder=o.createInterpolationPlaceholder}get targetName(){return this.originalTargetName}set targetName(t){if(this.originalTargetName=t,void 0!==t)switch(t[0]){case":":if(this.cleanedTargetName=t.substr(1),this.updateTarget=L,"innerHTML"===this.cleanedTargetName){const t=this.binding;this.binding=(e,s)=>o.createHTML(t(e,s))}break;case"?":this.cleanedTargetName=t.substr(1),this.updateTarget=I;break;case"@":this.cleanedTargetName=t.substr(1),this.bind=B,this.unbind=M;break;default:this.cleanedTargetName=t,"class"===t&&(this.updateTarget=P)}}targetAtContent(){this.updateTarget=E,this.unbind=$}createBehavior(t){return new j(t,this.binding,this.bind,this.unbind,this.updateTarget,this.cleanedTargetName)}}class j{constructor(t,e,s,i,n,o){this.source=null,this.context=null,this.bindingObserver=null,this.target=t,this.binding=e,this.bind=s,this.unbind=i,this.updateTarget=n,this.targetName=o}handleChange(){this.updateTarget(this.bindingObserver.observe(this.source,this.context))}handleEvent(t){w(t);const e=this.binding(this.source,this.context);w(null),!0!==e&&t.preventDefault()}}const H={locatedDirectives:0,targetIndex:-1};function D(t){let e;const s=t.length,i=t.map(t=>"string"==typeof t?()=>t:(e=t.targetName||e,H.locatedDirectives++,t.binding)),n=new R((t,e)=>{let n="";for(let o=0;o<s;++o)n+=i[o](t,e);return n});return n.targetName=e,n}function Q(t,e){let s=t.indexOf("@{",0);const i=t.length;let n,o,r,h=0,l=0,a=null,c=0;for(;s>=0&&s<i-2;){l=1,o=s,s+=2;do{n=t[s],s++,"'"!==n&&'"'!==n?"\\"!==n?null===a&&("{"===n?l++:"}"===n&&l--):s++:null===a?a=n:a===n&&(a=null)}while(l>0&&s<i);if(0!==l)break;if(r=r||[],"\\"===t[o-1]&&"\\"!==t[o-2])r[c]=t.substring(h,o-1)+t.substring(o,s),c++;else{r[c]=t.substring(h,o),c++;const i=e[parseInt(t.substring(o+2,s-1))];r[c]=i,c++}h=s,s=t.indexOf("@{",s)}return 0===c?null:(r[c]=t.substr(h),r=r.filter(t=>""!==t),1==r.length?r[0]:r)}function U(t,e,s,i=!1){const n=t.attributes;for(let o=0,r=n.length;o<r;++o){const h=n[o],l=h.value;let a=Q(l,e);null===a?i&&(a=new R(()=>l),a.targetName=h.name):Array.isArray(a)?a=D(a):H.locatedDirectives++,null!==a&&(t.removeAttributeNode(h),o--,r--,a.targetIndex=H.targetIndex,s.push(a))}}function q(t,e){t.targetAtContent(),t.targetIndex=H.targetIndex,e.push(t),H.locatedDirectives++}function W(t,e,s,i){const n=Q(t.textContent,e);if(null!==n)if(Array.isArray(n)){let e=t;for(let o=0,r=n.length;o<r;++o){const r=n[o],h=0===o?t:e.parentNode.insertBefore(document.createTextNode(""),e.nextSibling);"string"==typeof r?h.textContent=r:(h.textContent=" ",q(r,s)),e=h,H.targetIndex++,h!==t&&i.nextNode()}H.targetIndex--}else t.textContent=" ",q(n,s)}function z(t,e){const s=[];H.locatedDirectives=0,U(t,e,s,!0);const i=t.content,n=[],r=e.length,h=document.createTreeWalker(i,133,null,!1);for(H.targetIndex=-1;H.locatedDirectives<r;){const t=h.nextNode();if(null===t)break;switch(H.targetIndex++,t.nodeType){case 1:U(t,e,n);break;case 3:W(t,e,n,h);break;case 8:if(o.isMarker(t)){const s=e[o.extractDirectiveIndexFromMarker(t)];s.targetIndex=H.targetIndex,H.locatedDirectives++,n.push(s)}else t.parentNode.removeChild(t),H.targetIndex--}}let l=0;return o.isMarker(i.firstChild)&&(i.insertBefore(document.createComment(""),i.firstChild),l=-1),{fragment:i,viewBehaviorFactories:n,hostBehaviorFactories:s,targetOffset:l}}const _=document.createRange();class K{constructor(t,e){this.fragment=t,this.behaviors=e,this.source=null,this.context=null,this.firstChild=t.firstChild,this.lastChild=t.lastChild}appendTo(t){t.appendChild(this.fragment)}insertBefore(t){if(this.fragment.hasChildNodes())t.parentNode.insertBefore(this.fragment,t);else{const e=t.parentNode,s=this.lastChild;let i,n=this.firstChild;for(;n!==s;)i=n.nextSibling,e.insertBefore(n,t),n=i;e.insertBefore(s,t)}}remove(){const t=this.fragment,e=this.lastChild;let s,i=this.firstChild;for(;i!==e;)s=i.nextSibling,t.appendChild(i),i=s;t.appendChild(e)}dispose(){const t=this.firstChild.parentNode,e=this.lastChild;let s,i=this.firstChild;for(;i!==e;)s=i.nextSibling,t.removeChild(i),i=s;t.removeChild(e);const n=this.behaviors,o=this.source;for(let t=0,e=n.length;t<e;++t)n[t].unbind(o)}bind(t,e){const s=this.behaviors;if(this.source!==t)if(null!==this.source){const i=this.source;this.source=t,this.context=e;for(let n=0,o=s.length;n<o;++n){const o=s[n];o.unbind(i),o.bind(t,e)}}else{this.source=t,this.context=e;for(let i=0,n=s.length;i<n;++i)s[i].bind(t,e)}}unbind(){if(null===this.source)return;const t=this.behaviors,e=this.source;for(let s=0,i=t.length;s<i;++s)t[s].unbind(e);this.source=null}static disposeContiguousBatch(t){if(0!==t.length){_.setStart(t[0].firstChild,0),_.setEnd(t[t.length-1].lastChild,0),_.deleteContents();for(let e=0,s=t.length;e<s;++e){const s=t[e],i=s.behaviors,n=s.source;for(let t=0,e=i.length;t<e;++t)i[t].unbind(n)}}}}class G{constructor(t,e){this.behaviorCount=0,this.hasHostBehaviors=!1,this.fragment=null,this.targetOffset=0,this.viewBehaviorFactories=null,this.hostBehaviorFactories=null,this.html=t,this.directives=e}create(t){if(null===this.fragment){let t;const e=this.html;if("string"==typeof e){t=document.createElement("template"),t.innerHTML=o.createHTML(e);const s=t.content.firstElementChild;null!==s&&"TEMPLATE"===s.tagName&&(t=s)}else t=e;const s=z(t,this.directives);this.fragment=s.fragment,this.viewBehaviorFactories=s.viewBehaviorFactories,this.hostBehaviorFactories=s.hostBehaviorFactories,this.targetOffset=s.targetOffset,this.behaviorCount=this.viewBehaviorFactories.length+this.hostBehaviorFactories.length,this.hasHostBehaviors=this.hostBehaviorFactories.length>0}const e=this.fragment.cloneNode(!0),s=this.viewBehaviorFactories,i=new Array(this.behaviorCount),n=document.createTreeWalker(e,133,null,!1);let r=0,h=this.targetOffset,l=n.nextNode();for(let t=s.length;r<t;++r){const t=s[r],e=t.targetIndex;for(;null!==l;){if(h===e){i[r]=t.createBehavior(l);break}l=n.nextNode(),h++}}if(this.hasHostBehaviors){const e=this.hostBehaviorFactories;for(let s=0,n=e.length;s<n;++s,++r)i[r]=e[s].createBehavior(t)}return new K(e,i)}render(t,e){"string"==typeof e&&(e=document.getElementById(e));const s=this.create(e);return s.bind(t,N),s.appendTo(e),s}}const J=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function X(t,...e){const s=[];let i="";for(let n=0,o=t.length-1;n<o;++n){const o=t[n];let r=e[n];if(i+=o,r instanceof G){const t=r;r=()=>t}if("function"==typeof r){r=new R(r);const t=J.exec(o);null!==t&&(r.targetName=t[2])}r instanceof A?(i+=r.createPlaceholder(s.length),s.push(r)):i+=r}return i+=t[t.length-1],new G(i,s)}const Y={toView:t=>t?"true":"false",fromView:t=>null!=t&&"false"!==t&&!1!==t&&0!==t},Z={toView(t){if(null==t)return null;const e=1*t;return isNaN(e)?null:e.toString()},fromView(t){if(null==t)return null;const e=1*t;return isNaN(e)?null:e}};class tt{constructor(t,e,s=e.toLowerCase(),i="reflect",n){this.guards=new Set,this.Owner=t,this.name=e,this.attribute=s,this.mode=i,this.converter=n,this.fieldName="_"+e,this.callbackName=e+"Changed",this.hasCallback=this.callbackName in t.prototype,"boolean"===i&&void 0===n&&(this.converter=Y)}setValue(t,e){const s=t[this.fieldName],i=this.converter;void 0!==i&&(e=i.fromView(e)),s!==e&&(t[this.fieldName]=e,this.tryReflectToAttribute(t),this.hasCallback&&t[this.callbackName](s,e),t.$fastController.notify(this.name))}getValue(t){return v.track(t,this.name),t[this.fieldName]}onAttributeChangedCallback(t,e){this.guards.has(t)||(this.guards.add(t),this.setValue(t,e),this.guards.delete(t))}tryReflectToAttribute(t){const e=this.mode,s=this.guards;s.has(t)||"fromView"===e||o.queueUpdate(()=>{s.add(t);const i=t[this.fieldName];switch(e){case"reflect":const e=this.converter;o.setAttribute(t,this.attribute,void 0!==e?e.toView(i):i);break;case"boolean":o.setBooleanAttribute(t,this.attribute,i)}s.delete(t)})}static collect(t,...e){const s=[];e.push(t.attributes);for(let i=0,n=e.length;i<n;++i){const n=e[i];if(void 0!==n)for(let e=0,i=n.length;e<i;++e){const i=n[e];"string"==typeof i?s.push(new tt(t,i)):s.push(new tt(t,i.property,i.attribute,i.mode,i.converter))}}return s}}function et(t,e){let s;function i(t,e){arguments.length>1&&(s.property=e);const i=t.constructor.attributes||(t.constructor.attributes=[]);i.push(s)}return arguments.length>1?(s={},void i(t,e)):(s=void 0===t?{}:t,i)}class st{constructor(t,e,s,i,n,o,r,h){this.name=t,this.attributes=e,this.propertyLookup=s,this.attributeLookup=i,this.template=n,this.styles=o,this.shadowOptions=r,this.elementOptions=h}}const it=new Map,nt={bubbles:!0,composed:!0};class ot extends d{constructor(t,e){super(t),this.boundObservables=null,this.behaviors=null,this.view=null,this.isConnected=!1,this.element=t,this.definition=e;const s=e.template,i=e.styles,n=void 0===e.shadowOptions?void 0:t.attachShadow(e.shadowOptions);if(void 0!==s){const e=this.view=s.create(this.element);void 0===n?e.appendTo(t):e.appendTo(n)}void 0!==i&&this.addStyles(i,n);const o=v.getAccessors(t);if(o.length>0){const e=this.boundObservables=Object.create(null);for(let s=0,i=o.length;s<i;++s){const i=o[s].name,n=t[i];void 0!==n&&(delete t[i],e[i]=n)}}}addStyles(t,e=this.element.shadowRoot){null!==e&&t.addStylesTo(e);const s=t.behaviors;null!==s&&this.addBehaviors(s)}removeStyles(t){const e=this.element.shadowRoot;null!==e&&t.removeStylesFrom(e);const s=t.behaviors;null!==s&&this.removeBehaviors(s)}addBehaviors(t){const e=this.behaviors||(this.behaviors=[]),s=t.length;for(let i=0;i<s;++i)e.push(t[i]);if(this.isConnected){const e=this.element;for(let i=0;i<s;++i)t[i].bind(e,N)}}removeBehaviors(t){const e=this.behaviors;if(null===e)return;const s=t.length;for(let i=0;i<s;++i){const s=e.indexOf(t[i]);-1!==s&&e.splice(s,1)}if(this.isConnected){const e=this.element;for(let i=0;i<s;++i)t[i].unbind(e)}}onConnectedCallback(){if(this.isConnected)return;const t=this.element,e=this.boundObservables;if(null!==e){const s=Object.keys(e);for(let i=0,n=s.length;i<n;++i){const n=s[i];t[n]=e[n]}this.boundObservables=null}const s=this.view;null!==s&&s.bind(t,N);const i=this.behaviors;if(null!==i)for(let e=0,s=i.length;e<s;++e)i[e].bind(t,N);this.isConnected=!0}onDisconnectedCallback(){if(!1===this.isConnected)return;this.isConnected=!1;const t=this.view;null!==t&&t.unbind();const e=this.behaviors;if(null!==e){const t=this.element;for(let s=0,i=e.length;s<i;++s)e[s].unbind(t)}}onAttributeChangedCallback(t,e,s){const i=this.definition.attributeLookup[t];void 0!==i&&i.onAttributeChangedCallback(this.element,s)}emit(t,e,s){return!!this.isConnected&&this.element.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign({detail:e},nt),s)))}static forCustomElement(t){const e=t.$fastController;if(void 0!==e)return e;const s=it.get(t.constructor);if(void 0===s)throw new Error("Missing FASTElement definition.");return t.$fastController=new ot(t,s)}}const rt={mode:"open"},ht={};function lt(t){return class extends t{constructor(){super(),ot.forCustomElement(this)}$emit(t,e,s){return this.$fastController.emit(t,e,s)}connectedCallback(){this.$fastController.onConnectedCallback()}disconnectedCallback(){this.$fastController.onDisconnectedCallback()}attributeChangedCallback(t,e,s){this.$fastController.onAttributeChangedCallback(t,e,s)}}}const at=Object.assign(lt(HTMLElement),{from:t=>lt(t),define(t,e=t.definition){"string"==typeof e&&(e={name:e});const s=e.name,i=tt.collect(t,e.attributes),n=void 0===e.shadowOptions?rt:null===e.shadowOptions?void 0:Object.assign(Object.assign({},rt),e.shadowOptions),o=void 0===e.elementOptions?ht:Object.assign(Object.assign({},ht),e.shadowOptions),r=new Array(i.length),h=t.prototype,l={},a={};for(let t=0,e=i.length;t<e;++t){const e=i[t];r[t]=e.attribute,l[e.name]=e,a[e.attribute]=e,v.defineProperty(h,e)}Reflect.defineProperty(t,"observedAttributes",{value:r,enumerable:!0});const c=new st(s,i,l,a,e.template,e.styles,n,o);return it.set(t,c),customElements.define(s,t,c.elementOptions),t},getDefinition:t=>it.get(t)});function ct(t){return function(e){at.define(e,t)}}const dt=Object.freeze([]),ut=new Map;class ft{constructor(){this.behaviors=null}withBehaviors(...t){return this.behaviors=null===this.behaviors?t:this.behaviors.concat(t),this}withKey(t){return ut.set(t,this),this}static find(t){return ut.get(t)||null}}function bt(t){return t.map(t=>t instanceof ft?bt(t.styles):[t]).reduce((t,e)=>t.concat(e),[])}function gt(t){return t.map(t=>t instanceof ft?t.behaviors:null).reduce((t,e)=>null===e?t:(null===t&&(t=[]),t.concat(e)),null)}class pt extends ft{constructor(t,e){super(),this.styles=t,this.behaviors=null,this.behaviors=gt(t),this.styleSheets=bt(t).map(t=>{let s=e.get(t);return void 0===s&&(s=new CSSStyleSheet,s.replaceSync(t),e.set(t,s)),s})}addStylesTo(t){t.adoptedStyleSheets=[...t.adoptedStyleSheets,...this.styleSheets]}removeStylesFrom(t){const e=this.styleSheets;t.adoptedStyleSheets=t.adoptedStyleSheets.filter(t=>-1!==e.indexOf(t))}}let vt=0;class mt extends ft{constructor(t){super(),this.styles=t,this.behaviors=null,this.behaviors=gt(t),this.styleSheets=bt(t),this.styleClass="fast-style-class-"+ ++vt}addStylesTo(t){const e=this.styleSheets,s=this.styleClass;for(let i=e.length-1;i>-1;--i){const n=document.createElement("style");n.innerHTML=e[i],n.className=s,t.prepend(n)}}removeStylesFrom(t){const e=t.querySelectorAll("."+this.styleClass);for(let s=0,i=e.length;s<i;++s)t.removeChild(e[s])}}const Ct=(()=>{if("adoptedStyleSheets"in window.ShadowRoot.prototype){const t=new Map;return e=>new pt(e,t)}return t=>new mt(t)})();function xt(t,...e){const s=[];let i="";for(let n=0,o=t.length-1;n<o;++n){i+=t[n];const o=e[n];o instanceof ft?(""!==i.trim()&&(s.push(i),i=""),s.push(o)):i+=o}return i+=t[t.length-1],""!==i.trim()&&s.push(i),Ct(s)}class yt{constructor(t,e){this.target=t,this.propertyName=e}bind(t){t[this.propertyName]=this.target}unbind(){}}function wt(t){return new k("fast-ref",yt,t)}function Ot(t,e){const s="function"==typeof e?e:()=>e;return(e,i)=>t(e,i)?s(e,i):null}function Nt(t,e,s){return{index:t,removed:e,addedCount:s}}function Tt(t,e,s,i,n,o){let r=0,h=0;const l=Math.min(s-e,o-n);if(0===e&&0===n&&(r=function(t,e,s){for(let i=0;i<s;++i)if(t[i]!==e[i])return i;return s}(t,i,l)),s===t.length&&o===i.length&&(h=function(t,e,s){let i=t.length,n=e.length,o=0;for(;o<s&&t[--i]===e[--n];)o++;return o}(t,i,l-r)),n+=r,o-=h,(s-=h)-(e+=r)==0&&o-n==0)return dt;if(e===s){const t=Nt(e,[],0);for(;n<o;)t.removed.push(i[n++]);return[t]}if(n===o)return[Nt(e,[],s-e)];const a=function(t){let e=t.length-1,s=t[0].length-1,i=t[e][s];const n=[];for(;e>0||s>0;){if(0===e){n.push(2),s--;continue}if(0===s){n.push(3),e--;continue}const o=t[e-1][s-1],r=t[e-1][s],h=t[e][s-1];let l;l=r<h?r<o?r:o:h<o?h:o,l===o?(o===i?n.push(0):(n.push(1),i=o),e--,s--):l===r?(n.push(3),e--,i=r):(n.push(2),s--,i=h)}return n.reverse(),n}(function(t,e,s,i,n,o){const r=o-n+1,h=s-e+1,l=new Array(r);let a,c;for(let t=0;t<r;++t)l[t]=new Array(h),l[t][0]=t;for(let t=0;t<h;++t)l[0][t]=t;for(let s=1;s<r;++s)for(let o=1;o<h;++o)t[e+o-1]===i[n+s-1]?l[s][o]=l[s-1][o-1]:(a=l[s-1][o]+1,c=l[s][o-1]+1,l[s][o]=a<c?a:c);return l}(t,e,s,i,n,o)),c=[];let d=void 0,u=e,f=n;for(let t=0;t<a.length;++t)switch(a[t]){case 0:void 0!==d&&(c.push(d),d=void 0),u++,f++;break;case 1:void 0===d&&(d=Nt(u,[],0)),d.addedCount++,u++,d.removed.push(i[f]),f++;break;case 2:void 0===d&&(d=Nt(u,[],0)),d.addedCount++,u++;break;case 3:void 0===d&&(d=Nt(u,[],0)),d.removed.push(i[f]),f++}return void 0!==d&&c.push(d),c}const At=Array.prototype.push;function kt(t,e,s,i){const n=Nt(e,s,i);let o=!1,r=0;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(s.index+=r,o)continue;const i=(h=n.index,l=n.index+n.removed.length,a=s.index,c=s.index+s.addedCount,l<a||c<h?-1:l===a||c===h?0:h<a?l<c?l-a:c-a:c<l?c-h:l-h);if(i>=0){t.splice(e,1),e--,r-=s.addedCount-s.removed.length,n.addedCount+=s.addedCount-i;const h=n.removed.length+s.removed.length-i;if(n.addedCount||h){let t=s.removed;if(n.index<s.index){const e=n.removed.slice(0,s.index-n.index);At.apply(e,t),t=e}if(n.index+n.removed.length>s.index+s.addedCount){const e=n.removed.slice(s.index+s.addedCount-n.index);At.apply(t,e)}n.removed=t,s.index<n.index&&(n.index=s.index)}else o=!0}else if(n.index<s.index){o=!0,t.splice(e,0,n),e++;const i=n.addedCount-n.removed.length;s.index+=i,r+=i}}var h,l,a,c;o||t.push(n)}function St(t,e){let s=[];const i=function(t){const e=[];for(let s=0,i=t.length;s<i;s++){const i=t[s];kt(e,i.index,i.removed,i.addedCount)}return e}(e);for(let e=0,n=i.length;e<n;++e){const n=i[e];1!==n.addedCount||1!==n.removed.length?s=s.concat(Tt(t,n.index,n.index+n.addedCount,n.removed,0,n.removed.length)):n.removed[0]!==t[n.index]&&s.push(n)}return s}let Bt=!1;function Vt(t,e){let s=t.index;const i=e.length;return s>i?s=i-t.addedCount:s<0&&(s=i+t.removed.length+s-t.addedCount),s<0&&(s=0),t.index=s,t}class $t extends c{constructor(t){super(t),this.oldCollection=void 0,this.splices=void 0,this.needsQueue=!0,this.call=this.flush,t.$fastController=this}addSplice(t){void 0===this.splices?this.splices=[t]:this.splices.push(t),this.needsQueue&&(this.needsQueue=!1,o.queueUpdate(this))}reset(t){this.oldCollection=t,this.needsQueue&&(this.needsQueue=!1,o.queueUpdate(this))}flush(){const t=this.splices,e=this.oldCollection;if(void 0===t&&void 0===e)return;this.needsQueue=!0,this.splices=void 0,this.oldCollection=void 0;const s=void 0===e?St(this.source,t):Tt(this.source,0,this.source.length,e,0,e.length);this.notify(s)}}const Mt=Object.freeze({positioning:!1});function Ft(t,e,s,i){t.bind(e[s],i)}function It(t,e,s,i){const n=Object.create(i);n.index=s,n.length=e.length,t.bind(e[s],n)}class Et{constructor(t,e,s,i){this.location=t,this.binding=e,this.template=s,this.options=i,this.source=void 0,this.views=[],this.items=null,this.itemsObserver=void 0,this.originalContext=void 0,this.childContext=void 0,this.bindView=Ft,this.bindingObserver=v.binding(e,this),i.positioning&&(this.bindView=It)}bind(t,e){this.source=t,this.originalContext=e,this.childContext=Object.create(e),this.childContext.parent=t,this.items=this.bindingObserver.observe(t,this.originalContext),this.observeItems(),this.refreshAllViews()}unbind(){this.source=null,this.items=null,void 0!==this.itemsObserver&&this.itemsObserver.unsubscribe(this),this.unbindAllViews(),this.bindingObserver.disconnect()}handleChange(t,e){t===this.binding?(this.items=this.bindingObserver.observe(this.source,this.originalContext),this.observeItems(),this.refreshAllViews()):this.updateViews(e)}observeItems(){this.items||(this.items=[]);const t=this.itemsObserver,e=this.itemsObserver=v.getNotifier(this.items);t!==e&&(void 0!==t&&t.unsubscribe(this),e.subscribe(this))}updateViews(t){const e=this.childContext,s=this.views,i=[],n=this.bindView;let o=0;for(let e=0,n=t.length;e<n;++e){const n=t[e],r=n.removed;i.push(...s.splice(n.index+o,r.length)),o-=n.addedCount}const r=this.items,h=this.template;for(let o=0,l=t.length;o<l;++o){const l=t[o];let a=l.index;const c=a+l.addedCount;for(;a<c;++a){const t=s[a],o=t?t.firstChild:this.location,l=i.length>0?i.shift():h.create();s.splice(a,0,l),n(l,r,a,e),l.insertBefore(o)}}for(let t=0,e=i.length;t<e;++t)i[t].dispose();if(this.options.positioning)for(let t=0,e=s.length;t<e;++t){const i=s[t].context;i.length=e,i.index=t}}refreshAllViews(){const t=this.items,e=this.childContext;let s=t.length,i=this.views;const n=i.length,o=this.template,r=this.location,h=this.bindView;if(0===s)K.disposeContiguousBatch(this.views),this.views=[];else if(0===n){this.views=i=new Array(s);for(let n=0;n<s;++n){const s=o.create();h(s,t,n,e),i[n]=s,s.insertBefore(r)}}else{let l=0;for(;l<s;++l)if(l<n){h(i[l],t,l,e)}else{const s=o.create();h(s,t,l,e),i.push(s),s.insertBefore(r)}const a=i.splice(l,n-l);for(l=0,s=a.length;l<s;++l)a[l].dispose()}}unbindAllViews(){const t=this.views;for(let e=0,s=t.length;e<s;++e)t[e].unbind()}}class Lt extends A{constructor(t,e,s){super(),this.binding=t,this.template=e,this.options=s,this.createPlaceholder=o.createBlockPlaceholder,function(){if(Bt)return;Bt=!0,v.setArrayObserverFactory(t=>new $t(t));const t=Array.prototype,e=t.pop,s=t.push,i=t.reverse,n=t.shift,o=t.sort,r=t.splice,h=t.unshift;t.pop=function(){const t=this.length>0,s=e.apply(this,arguments),i=this.$fastController;return void 0!==i&&t&&i.addSplice(Nt(this.length,[s],0)),s},t.push=function(){const t=s.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(Vt(Nt(this.length-arguments.length,[],arguments.length),this)),t},t.reverse=function(){let t;const e=this.$fastController;void 0!==e&&(e.flush(),t=this.slice());const s=i.apply(this,arguments);return void 0!==e&&e.reset(t),s},t.shift=function(){const t=this.length>0,e=n.apply(this,arguments),s=this.$fastController;return void 0!==s&&t&&s.addSplice(Nt(0,[e],0)),e},t.sort=function(){let t;const e=this.$fastController;void 0!==e&&(e.flush(),t=this.slice());const s=o.apply(this,arguments);return void 0!==e&&e.reset(t),s},t.splice=function(){const t=r.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(Vt(Nt(+arguments[0],t,arguments.length>2?arguments.length-2:0),this)),t},t.unshift=function(){const t=h.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(Vt(Nt(0,[],arguments.length),this)),t}}()}createBehavior(t){return new Et(t,this.binding,this.template,this.options)}}function Pt(t,e,s=Mt){return new Lt(t,e,s)}class Rt{constructor(t,e){this.target=t,this.options=e,this.source=null}bind(t){const e=this.options.property;this.shouldUpdate=v.getAccessors(t).some(t=>t.name===e),this.source=t,this.updateTarget(this.getNodes()),this.shouldUpdate&&this.observe()}unbind(){this.updateTarget(dt),this.source=null,this.shouldUpdate&&this.disconnect()}handleEvent(){this.updateTarget(this.getNodes())}updateTarget(t){this.source[this.options.property]=t}}class jt extends Rt{constructor(t,e){super(t,e)}observe(){this.target.addEventListener("slotchange",this)}disconnect(){this.target.removeEventListener("slotchange",this)}getNodes(){return this.target.assignedNodes(this.options)}}function Ht(t){return"string"==typeof t&&(t={property:t}),new k("fast-slotted",jt,t)}class Dt extends Rt{constructor(t,e){super(t,e),this.observer=null}observe(){null===this.observer&&(this.observer=new MutationObserver(this.handleEvent.bind(this))),this.observer.observe(this.target,this.options)}disconnect(){this.observer.disconnect()}getNodes(){return Array.from(this.target.childNodes)}}function Qt(t){return"string"==typeof t&&(t={property:t,childList:!0}),new k("fast-children",Dt,t)}export{k as AttachedBehaviorDirective,tt as AttributeDefinition,j as BindingBehavior,R as BindingDirective,Dt as ChildrenBehavior,ot as Controller,o as DOM,A as Directive,ft as ElementStyles,O as ExecutionContext,at as FASTElement,st as FASTElementDefinition,K as HTMLView,v as Observable,d as PropertyChangeNotifier,yt as RefBehavior,Et as RepeatBehavior,Lt as RepeatDirective,jt as SlottedBehavior,c as SubscriberSet,G as ViewTemplate,et as attr,Y as booleanConverter,Qt as children,z as compileTemplate,xt as css,ct as customElement,N as defaultExecutionContext,dt as emptyArray,X as html,Z as nullableNumberConverter,x as observable,wt as ref,Pt as repeat,w as setCurrentEvent,Ht as slotted,Ot as when}; |
@@ -14,27 +14,10 @@ ## API Report File for "@microsoft/fast-element" | ||
// @public (undocumented) | ||
export class AdoptedStyleSheetsStyles extends ElementStyles { | ||
constructor(styles: InjectableStyles[], styleSheetCache: Map<string, CSSStyleSheet>); | ||
// (undocumented) | ||
addStylesTo(target: StyleTarget): void; | ||
// (undocumented) | ||
readonly behaviors: ReadonlyArray<Behavior> | null; | ||
// (undocumented) | ||
removeStylesFrom(target: StyleTarget): void; | ||
// Warning: (ae-forgotten-export) The symbol "InjectableStyles" needs to be exported by the entry point index.d.ts | ||
// | ||
// (undocumented) | ||
styles: InjectableStyles[]; | ||
} | ||
// @public (undocumented) | ||
// @public | ||
export class AttachedBehaviorDirective<T = any> extends Directive { | ||
constructor(name: string, behavior: AttachedBehaviorType<T>, options: T); | ||
// (undocumented) | ||
createBehavior(target: any): Behavior; | ||
// (undocumented) | ||
createBehavior(target: Node): Behavior; | ||
createPlaceholder(index: number): string; | ||
} | ||
// @public (undocumented) | ||
// @public | ||
export type AttachedBehaviorType<T = any> = new (target: any, options: T) => Behavior; | ||
@@ -48,3 +31,3 @@ | ||
// @public (undocumented) | ||
// @public | ||
export type AttributeConfiguration = { | ||
@@ -57,41 +40,32 @@ property: string; | ||
// @public (undocumented) | ||
// @public | ||
export class AttributeDefinition implements Accessor { | ||
constructor(Owner: Function, name: string, attribute?: string, mode?: AttributeMode, converter?: ValueConverter | undefined); | ||
// (undocumented) | ||
// Warning: (ae-incompatible-release-tags) The symbol "__constructor" is marked as @public, but its signature references "ValueConverter" which is marked as @beta | ||
constructor(Owner: Function, name: string, attribute?: string, mode?: AttributeMode, converter?: ValueConverter); | ||
readonly attribute: string; | ||
// (undocumented) | ||
// @internal | ||
static collect(Owner: Function, ...attributeLists: (ReadonlyArray<string | AttributeConfiguration> | undefined)[]): ReadonlyArray<AttributeDefinition>; | ||
// (undocumented) | ||
readonly converter?: ValueConverter | undefined; | ||
// (undocumented) | ||
// Warning: (ae-incompatible-release-tags) The symbol "converter" is marked as @public, but its signature references "ValueConverter" which is marked as @beta | ||
readonly converter?: ValueConverter; | ||
getValue(source: HTMLElement): any; | ||
// (undocumented) | ||
readonly mode: AttributeMode; | ||
// (undocumented) | ||
readonly name: string; | ||
// (undocumented) | ||
// @internal (undocumented) | ||
onAttributeChangedCallback(element: HTMLElement, value: any): void; | ||
// (undocumented) | ||
readonly Owner: Function; | ||
// (undocumented) | ||
setValue(source: HTMLElement, newValue: any): void; | ||
} | ||
// @public (undocumented) | ||
// @public | ||
export type AttributeMode = "reflect" | "boolean" | "fromView"; | ||
// @public (undocumented) | ||
// @public | ||
export interface Behavior { | ||
// (undocumented) | ||
bind(source: unknown, context: ExecutionContext): void; | ||
// (undocumented) | ||
unbind(source: unknown): void; | ||
} | ||
// @public (undocumented) | ||
// @public | ||
export interface BehaviorFactory { | ||
// (undocumented) | ||
createBehavior(target: any): Behavior; | ||
// (undocumented) | ||
createBehavior(target: Node): Behavior; | ||
targetIndex: number; | ||
@@ -105,14 +79,12 @@ } | ||
export class BindingBehavior implements Behavior { | ||
constructor(target: any, binding: Binding, bind: typeof normalBind, unbind: typeof normalUnbind, updateTarget: typeof updatePropertyTarget, targetName?: string | undefined); | ||
constructor(target: any, binding: Binding, bind: typeof normalBind, unbind: typeof normalUnbind, updateTarget: typeof updatePropertyTarget, targetName?: string); | ||
// Warning: (ae-forgotten-export) The symbol "normalBind" needs to be exported by the entry point index.d.ts | ||
// | ||
// (undocumented) | ||
bind: typeof normalBind; | ||
// (undocumented) | ||
// @internal (undocumented) | ||
binding: Binding; | ||
// (undocumented) | ||
// @internal (undocumented) | ||
bindingObserver: BindingObserver | null; | ||
// (undocumented) | ||
// @internal (undocumented) | ||
classVersions: Record<string, number>; | ||
// (undocumented) | ||
// @internal (undocumented) | ||
context: ExecutionContext | null; | ||
@@ -123,17 +95,15 @@ // @internal (undocumented) | ||
handleEvent(event: Event): void; | ||
// (undocumented) | ||
// @internal (undocumented) | ||
source: unknown; | ||
// (undocumented) | ||
// @internal (undocumented) | ||
target: any; | ||
// (undocumented) | ||
targetName?: string | undefined; | ||
// @internal (undocumented) | ||
targetName?: string; | ||
// Warning: (ae-forgotten-export) The symbol "normalUnbind" needs to be exported by the entry point index.d.ts | ||
// | ||
// (undocumented) | ||
unbind: typeof normalUnbind; | ||
// Warning: (ae-forgotten-export) The symbol "updatePropertyTarget" needs to be exported by the entry point index.d.ts | ||
// | ||
// (undocumented) | ||
// @internal (undocumented) | ||
updateTarget: typeof updatePropertyTarget; | ||
// (undocumented) | ||
// @internal (undocumented) | ||
version: number; | ||
@@ -147,4 +117,3 @@ } | ||
binding: Binding; | ||
createBehavior(target: any): BindingBehavior; | ||
// (undocumented) | ||
createBehavior(target: Node): BindingBehavior; | ||
createPlaceholder: (index: number) => string; | ||
@@ -162,3 +131,5 @@ targetAtContent(): void; | ||
// @public (undocumented) | ||
// Warning: (ae-incompatible-release-tags) The symbol "booleanConverter" is marked as @public, but its signature references "ValueConverter" which is marked as @beta | ||
// | ||
// @public | ||
export const booleanConverter: ValueConverter; | ||
@@ -175,3 +146,3 @@ | ||
// @public (undocumented) | ||
// @public | ||
export function children<T = any>(propertyOrOptions: (keyof T & string) | ChildrenBehaviorOptions<keyof T & string>): CaptureType<T>; | ||
@@ -181,20 +152,17 @@ | ||
// | ||
// @public (undocumented) | ||
// @public | ||
export class ChildrenBehavior extends NodeObservationBehavior<ChildrenBehaviorOptions> { | ||
constructor(target: HTMLSlotElement, options: ChildrenBehaviorOptions); | ||
// (undocumented) | ||
getNodes(): ChildNode[]; | ||
// (undocumented) | ||
disconnect(): void; | ||
protected getNodes(): ChildNode[]; | ||
observe(): void; | ||
// (undocumented) | ||
unobserve(): void; | ||
} | ||
} | ||
// Warning: (ae-forgotten-export) The symbol "NodeBehaviorBehaviorOptions" needs to be exported by the entry point index.d.ts | ||
// | ||
// @public (undocumented) | ||
// @public | ||
export interface ChildrenBehaviorOptions<T = any> extends NodeBehaviorBehaviorOptions<T>, MutationObserverInit { | ||
} | ||
// @public | ||
// @beta | ||
export interface CompilationResult { | ||
@@ -207,48 +175,36 @@ fragment: DocumentFragment; | ||
// Warning: (ae-incompatible-release-tags) The symbol "compileTemplate" is marked as @public, but its signature references "CompilationResult" which is marked as @beta | ||
// | ||
// @public | ||
export function compileTemplate(template: HTMLTemplateElement, directives: ReadonlyArray<Directive>): CompilationResult; | ||
// @public (undocumented) | ||
// @public | ||
export class Controller extends PropertyChangeNotifier { | ||
// @internal | ||
constructor(element: HTMLElement, definition: FASTElementDefinition); | ||
// (undocumented) | ||
addBehaviors(behaviors: ReadonlyArray<Behavior>): void; | ||
// (undocumented) | ||
addStyles(styles: ElementStyles, target?: StyleTarget | null): void; | ||
// (undocumented) | ||
addStyles(styles: ElementStyles, | ||
target?: StyleTarget | null): void; | ||
readonly definition: FASTElementDefinition; | ||
// (undocumented) | ||
readonly element: HTMLElement; | ||
// (undocumented) | ||
emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): void | boolean; | ||
// (undocumented) | ||
static forCustomElement(element: HTMLElement): Controller; | ||
// (undocumented) | ||
isConnected: boolean; | ||
// (undocumented) | ||
readonly isConnected: boolean; | ||
onAttributeChangedCallback(name: string, oldValue: string, newValue: string): void; | ||
// (undocumented) | ||
onConnectedCallback(): void; | ||
// (undocumented) | ||
onDisconnectedCallback(): void; | ||
// (undocumented) | ||
removeBehaviors(behaviors: ReadonlyArray<Behavior>): void; | ||
// (undocumented) | ||
removeStyles(styles: ElementStyles): void; | ||
// (undocumented) | ||
view: ElementView | null; | ||
readonly view: ElementView | null; | ||
} | ||
// Warning: (ae-forgotten-export) The symbol "ElementStyleFactory" needs to be exported by the entry point index.d.ts | ||
// Warning: (ae-forgotten-export) The symbol "InjectableStyles" needs to be exported by the entry point index.d.ts | ||
// | ||
// @public (undocumented) | ||
export const createStyles: ElementStyleFactory; | ||
// @public (undocumented) | ||
// @public | ||
export function css(strings: TemplateStringsArray, ...values: InjectableStyles[]): ElementStyles; | ||
// @public (undocumented) | ||
// @public | ||
export function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Function) => void; | ||
// @public (undocumented) | ||
// @public | ||
export type DecoratorAttributeConfiguration = Omit<AttributeConfiguration, "property">; | ||
@@ -259,9 +215,6 @@ | ||
// @public (undocumented) | ||
// @public | ||
export abstract class Directive implements BehaviorFactory { | ||
// (undocumented) | ||
abstract createBehavior(target: any): Behavior; | ||
// (undocumented) | ||
abstract createBehavior(target: Node): Behavior; | ||
abstract createPlaceholder(index: number): string; | ||
// (undocumented) | ||
targetIndex: number; | ||
@@ -285,3 +238,3 @@ } | ||
// @public (undocumented) | ||
// @public | ||
export abstract class ElementStyles { | ||
@@ -292,3 +245,2 @@ // @internal (undocumented) | ||
abstract readonly behaviors: ReadonlyArray<Behavior> | null; | ||
// (undocumented) | ||
static find(key: string): ElementStyles | null; | ||
@@ -299,5 +251,3 @@ // @internal (undocumented) | ||
abstract readonly styles: ReadonlyArray<InjectableStyles>; | ||
// (undocumented) | ||
withBehaviors(...behaviors: Behavior[]): this; | ||
// (undocumented) | ||
withKey(key: string): this; | ||
@@ -316,3 +266,5 @@ } | ||
// @public | ||
// Warning: (ae-internal-missing-underscore) The name "emptyArray" should be prefixed with an underscore because the declaration is marked as @internal | ||
// | ||
// @internal | ||
export const emptyArray: readonly never[]; | ||
@@ -333,17 +285,12 @@ | ||
// @public (undocumented) | ||
// @public | ||
export interface FASTElement { | ||
// (undocumented) | ||
$emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): boolean | void; | ||
// (undocumented) | ||
$fastController: Controller; | ||
// (undocumented) | ||
readonly $fastController: Controller; | ||
attributeChangedCallback(name: string, oldValue: string, newValue: string): void; | ||
// (undocumented) | ||
connectedCallback(): void; | ||
// (undocumented) | ||
disconnectedCallback(): void; | ||
} | ||
// @public (undocumented) | ||
// @public | ||
export const FASTElement: (new () => HTMLElement & FASTElement) & { | ||
@@ -355,24 +302,16 @@ from<TBase extends { | ||
define<TType extends Function>(Type: TType, nameOrDef?: string | PartialFASTElementDefinition): TType; | ||
getDefinition: typeof getDefinition; | ||
getDefinition<T extends Function>(Type: T): FASTElementDefinition | undefined; | ||
}; | ||
// @public (undocumented) | ||
// @public | ||
export class FASTElementDefinition { | ||
constructor(name: string, attributes: ReadonlyArray<AttributeDefinition>, propertyLookup: Record<string, AttributeDefinition>, attributeLookup: Record<string, AttributeDefinition>, template?: ElementViewTemplate | undefined, styles?: ElementStyles | undefined, shadowOptions?: ShadowRootInit | undefined, elementOptions?: ElementDefinitionOptions | undefined); | ||
// (undocumented) | ||
constructor(name: string, attributes: ReadonlyArray<AttributeDefinition>, propertyLookup: Record<string, AttributeDefinition>, attributeLookup: Record<string, AttributeDefinition>, template?: ElementViewTemplate, styles?: ElementStyles, shadowOptions?: ShadowRootInit, elementOptions?: ElementDefinitionOptions); | ||
readonly attributeLookup: Record<string, AttributeDefinition>; | ||
// (undocumented) | ||
readonly attributes: ReadonlyArray<AttributeDefinition>; | ||
// (undocumented) | ||
readonly elementOptions?: ElementDefinitionOptions | undefined; | ||
// (undocumented) | ||
readonly elementOptions?: ElementDefinitionOptions; | ||
readonly name: string; | ||
// (undocumented) | ||
readonly propertyLookup: Record<string, AttributeDefinition>; | ||
// (undocumented) | ||
readonly shadowOptions?: ShadowRootInit | undefined; | ||
// (undocumented) | ||
readonly styles?: ElementStyles | undefined; | ||
// (undocumented) | ||
readonly template?: ElementViewTemplate | undefined; | ||
readonly shadowOptions?: ShadowRootInit; | ||
readonly styles?: ElementStyles; | ||
readonly template?: ElementViewTemplate; | ||
} | ||
@@ -388,13 +327,9 @@ | ||
bind(source: unknown, context: ExecutionContext): void; | ||
// (undocumented) | ||
context: ExecutionContext | null; | ||
dispose(): void; | ||
static disposeContiguousBatch(views: SyntheticView[]): void; | ||
// (undocumented) | ||
firstChild: Node; | ||
insertBefore(node: Node): void; | ||
// (undocumented) | ||
lastChild: Node; | ||
remove(): void; | ||
// (undocumented) | ||
source: any | null; | ||
@@ -404,2 +339,9 @@ unbind(): void; | ||
// Warning: (ae-internal-missing-underscore) The name "Mutable" should be prefixed with an underscore because the declaration is marked as @internal | ||
// | ||
// @internal | ||
export type Mutable<T> = { | ||
-readonly [P in keyof T]: T[P]; | ||
}; | ||
// @public | ||
@@ -413,3 +355,5 @@ export interface Notifier { | ||
// @public (undocumented) | ||
// Warning: (ae-incompatible-release-tags) The symbol "nullableNumberConverter" is marked as @public, but its signature references "ValueConverter" which is marked as @beta | ||
// | ||
// @public | ||
export const nullableNumberConverter: ValueConverter; | ||
@@ -431,11 +375,11 @@ | ||
// @public (undocumented) | ||
export type PartialFASTElementDefinition = { | ||
// @public | ||
export interface PartialFASTElementDefinition { | ||
readonly attributes?: (AttributeConfiguration | string)[]; | ||
readonly elementOptions?: ElementDefinitionOptions; | ||
readonly name: string; | ||
readonly shadowOptions?: Partial<ShadowRootInit> | null; | ||
readonly styles?: ElementStyles; | ||
readonly template?: ElementViewTemplate; | ||
readonly styles?: ElementStyles; | ||
readonly attributes?: (AttributeConfiguration | string)[]; | ||
readonly shadowOptions?: Partial<ShadowRootInit> | null; | ||
readonly elementOptions?: ElementDefinitionOptions; | ||
}; | ||
} | ||
@@ -451,31 +395,27 @@ // @public | ||
// @public (undocumented) | ||
// @public | ||
export function ref<T = any>(propertyName: keyof T & string): CaptureType<T>; | ||
// @public (undocumented) | ||
// @public | ||
export class RefBehavior implements Behavior { | ||
constructor(target: HTMLElement, propertyName: string); | ||
// (undocumented) | ||
bind(source: any): void; | ||
// (undocumented) | ||
unbind(): void; | ||
} | ||
// @public (undocumented) | ||
// @public | ||
export function repeat<TScope = any, TItem = any>(binding: Binding<TScope, TItem[]>, template: ViewTemplate<Partial<TItem>, TScope>, options?: RepeatOptions): CaptureType<TScope>; | ||
// @public (undocumented) | ||
// @public | ||
export class RepeatBehavior implements Behavior, Subscriber { | ||
constructor(location: Node, binding: Binding, template: SyntheticViewTemplate, options: RepeatOptions); | ||
// (undocumented) | ||
bind(source: unknown, context: ExecutionContext): void; | ||
// Warning: (ae-forgotten-export) The symbol "Splice" needs to be exported by the entry point index.d.ts | ||
// | ||
// (undocumented) | ||
// @internal (undocumented) | ||
handleChange(source: any, args: Splice[]): void; | ||
// (undocumented) | ||
unbind(): void; | ||
} | ||
// @public (undocumented) | ||
// @public | ||
export class RepeatDirective extends Directive { | ||
@@ -485,5 +425,3 @@ constructor(binding: Binding, template: SyntheticViewTemplate, options: RepeatOptions); | ||
binding: Binding; | ||
// (undocumented) | ||
createBehavior(target: any): RepeatBehavior; | ||
// (undocumented) | ||
createBehavior(target: Node): RepeatBehavior; | ||
createPlaceholder: (index: number) => string; | ||
@@ -496,5 +434,4 @@ // (undocumented) | ||
// @public (undocumented) | ||
// @public | ||
export interface RepeatOptions { | ||
// (undocumented) | ||
positioning: boolean; | ||
@@ -508,43 +445,23 @@ } | ||
// @public (undocumented) | ||
// @public | ||
export function slotted<T = any>(propertyOrOptions: (keyof T & string) | SlottedBehaviorOptions<keyof T & string>): CaptureType<T>; | ||
// @public (undocumented) | ||
// @public | ||
export class SlottedBehavior extends NodeObservationBehavior<SlottedBehaviorOptions> { | ||
constructor(target: HTMLSlotElement, options: SlottedBehaviorOptions); | ||
// (undocumented) | ||
getNodes(): Node[]; | ||
// (undocumented) | ||
disconnect(): void; | ||
protected getNodes(): Node[]; | ||
observe(): void; | ||
// (undocumented) | ||
unobserve(): void; | ||
} | ||
// @public (undocumented) | ||
// @public | ||
export interface SlottedBehaviorOptions<T = any> extends NodeBehaviorBehaviorOptions<T>, AssignedNodesOptions { | ||
} | ||
// @public (undocumented) | ||
export class StyleElementStyles extends ElementStyles { | ||
constructor(styles: InjectableStyles[]); | ||
// (undocumented) | ||
addStylesTo(target: StyleTarget): void; | ||
// (undocumented) | ||
readonly behaviors: ReadonlyArray<Behavior> | null; | ||
// (undocumented) | ||
removeStylesFrom(target: StyleTarget): void; | ||
// (undocumented) | ||
styles: InjectableStyles[]; | ||
} | ||
// @public (undocumented) | ||
// @public | ||
export interface StyleTarget { | ||
// (undocumented) | ||
adoptedStyleSheets?: CSSStyleSheet[]; | ||
// (undocumented) | ||
prepend(node: Node): void; | ||
// (undocumented) | ||
prepend(styles: HTMLStyleElement): void; | ||
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>; | ||
// (undocumented) | ||
removeChild(node: Node): void; | ||
removeChild(styles: HTMLStyleElement): void; | ||
} | ||
@@ -584,7 +501,5 @@ | ||
// @public (undocumented) | ||
// @beta | ||
export interface ValueConverter { | ||
// (undocumented) | ||
fromView(value: string): any; | ||
// (undocumented) | ||
toView(value: any): string | null; | ||
@@ -605,5 +520,3 @@ } | ||
create(host?: Element): HTMLView; | ||
// (undocumented) | ||
readonly directives: ReadonlyArray<Directive>; | ||
// (undocumented) | ||
readonly html: string | HTMLTemplateElement; | ||
@@ -619,4 +532,4 @@ render(source: TSource, host: HTMLElement | string): HTMLView; | ||
// | ||
// dist/dts/dom.d.ts:9:5 - (ae-forgotten-export) The symbol "TrustedTypesPolicy" needs to be exported by the entry point index.d.ts | ||
// dist/dts/fast-element.d.ts:16:5 - (ae-forgotten-export) The symbol "getDefinition" needs to be exported by the entry point index.d.ts | ||
// dist/dts/attributes.d.ts:40:5 - (ae-incompatible-release-tags) The symbol "converter" is marked as @public, but its signature references "ValueConverter" which is marked as @beta | ||
// dist/dts/dom.d.ts:17:5 - (ae-forgotten-export) The symbol "TrustedTypesPolicy" needs to be exported by the entry point index.d.ts | ||
@@ -623,0 +536,0 @@ // (No @packageDocumentation comment for this package) |
@@ -5,5 +5,3 @@ # Roadmap | ||
* **Doc:** Re-organize the current docs into a series of smaller articles. | ||
* **Feature**: Transform text binding into a content binding that compose HTML dynamically. | ||
* **Feature**: Allow `when` and `repeat` to accept an expression that returns the template they generate from. | ||
* **Feature**: Allow `repeat` to accept an expression that returns the template they generate from. | ||
@@ -10,0 +8,0 @@ ## Medium-term |
@@ -5,3 +5,3 @@ { | ||
"sideEffects": false, | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"author": { | ||
@@ -82,3 +82,3 @@ "name": "Microsoft", | ||
}, | ||
"gitHead": "cb339f92824034d048f5e840633ed3d7ded6b009" | ||
"gitHead": "5ba70bd86b2a2d06dfac18c2d588df36b1d98f3d" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
778653
18584
0