export type ParserNode = import("node-html-parser").Node; export type ParserHTMLElement = import("node-html-parser").HTMLElement; export type ServerElement = import("./server/element").ServerElement; export type WaferServer = import("./server/wafer").default; /** * - Property declaration */ export type Prop = { /** * - Property type */ type: StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor; /** * - Initial value for property */ initial?: any; /** * - Should the property be reflected to an attribute with the same name */ reflect?: boolean | undefined; /** * - A list of targets that should be updated when the property value changes */ targets?: Target[] | undefined; /** * - A list of other properties whose targets should be updated when this property changes */ triggers?: string[] | undefined; /** * - The name of the attribute this property can be initialised from / reflected to */ attributeName?: string | undefined; }; /** * Target declaration defining how to update elements matching `selector` */ export type Target = { /** * CSS3 selector */ selector: string | ((value: any, el: ServerElement | Element) => string); /** * - which attribute on matches to update with the property value */ attribute?: string | undefined; /** * - which property on matches to update with the property value */ property?: string | undefined; /** * - should the textContent of matches be set to the property value */ text?: boolean | undefined; /** * - a function that will be called when the property value changes - usually used for general DOM updates */ dom?: DOMUpdateFn | undefined; /** * - a function that returns the value that should be used in updates (defaults to the property value itself) */ use?: UseFn | undefined; }; /** * - Function to run for a {@link ./Target} when a property value changes */ export type DOMUpdateFn = (target: Element | ServerElement, value: any, el: Element | ServerElement) => Promise | void; /** * - Function to run before updating {@link ./Target}s, returning the value to use in updates */ export type UseFn = (value: any, el: HTMLElement | {}, targetEl?: {} | HTMLElement | undefined) => any; /** * - If an what type of Shadow Root to attach */ export type ShadowOpts = 'open' | 'closed' | false; /** * - Possible arguments passed to client constructor */ export type ClientOpts = { /** * - What type of Shadow Root to attach */ shadow?: ShadowOpts | undefined; }; /** * - Possible arguments passed to server constructor */ export type ServerOpts = { /** * - What type of Shadow Root to attach */ shadow?: ShadowOpts | undefined; /** * - What tag should this component be defined with */ tagName: string; /** * - Object of initial attribute name/values */ attrs?: { [x: string]: string; } | undefined; }; /** * - Explicit event handler */ export type TargetEvent = { /** * - Function to call */ fn: (this: Element, ev: Event) => any; /** * - Element to bind the function to */ target?: HTMLElement | undefined; /** * - Event listener options */ opts?: boolean | AddEventListenerOptions | undefined; }; /** * - Object of event names to event handlers */ export type TargetEvents = { [x: string]: TargetEvent | ((this: Element, ev: Event) => any); }; export type RegistryEntry = { /** * - The component definition */ def: new (...args: any[]) => WaferServer; /** * - If this component is intended only to be rendered on server (i.e. not upgraded or rehydrated on client) */ serverOnly?: boolean | undefined; }; /** * - Object of tag names to Wafer component definitions */ export type Registry = { [x: string]: RegistryEntry; };