@protorians/widgets
Version:
Create your web user interfaces with widgets
95 lines (94 loc) • 5.07 kB
TypeScript
import type { IAttributes, ICallable, IChildren, IChildrenSupported, IContext, IEngine, IGlobalAttributes, IGlobalEventMap, IGlobalEventPayload, IMeasure, INativeProperties, IPrimitive, IPropStack, IRef, IStateStack, IStringToken, IStyleDeclaration, IStyleSheet, IStyleSheetDeclarations, IWidgetDeclaration, IWidgetElement, IWidgetNode, IWidgetSideCallableOptions, IWidgetSignalMap } from "./types/index.js";
import { type ISignalStack, IUiTarget } from "@protorians/core";
import { ToggleOption, ObjectElevation, WidgetsNativeProperty, Displaying } from "./enums.js";
import { ISpectraElement } from "@protorians/spectra";
export declare const WidgetNativeProperties: WidgetsNativeProperty[];
export declare class ContextWidget<P extends IPropStack, S extends IStateStack> implements IContext<P, S> {
readonly widget: IWidgetNode<any, any>;
root: IWidgetNode<any, any> | undefined;
props: P;
state: S;
engine: IEngine<any, any> | undefined;
constructor(widget: IWidgetNode<any, any>, props?: P, state?: S);
}
export declare class WidgetNode<E extends HTMLElement, A extends IAttributes> implements IWidgetNode<E, A> {
readonly element: IWidgetElement<E>;
protected _fingerprint: string;
protected _isConnected: boolean;
protected _reference: IRef<E, A> | undefined;
protected _tag: string;
protected _attributes: A;
protected _props: INativeProperties<E, A>;
protected _signal: ISignalStack<IWidgetSignalMap<E, A>>;
protected _locked: boolean;
protected _context: IContext<any, any> | undefined;
protected _stylesheet: IStyleSheet | undefined;
protected _mounted: boolean;
constructor(declaration: IWidgetDeclaration<E, A>);
static get style(): IStyleSheetDeclarations | undefined;
static get attributes(): IAttributes | undefined;
static get children(): IWidgetNode<any, any> | undefined;
static mount<E extends HTMLElement, A extends IAttributes>(widget: IWidgetNode<E, A>): IWidgetNode<E, A> | void | undefined;
static unmount<E extends HTMLElement, A extends IAttributes>(widget: IWidgetNode<E, A>): IWidgetNode<E, A> | void | undefined;
get tag(): string;
get kind(): string;
get fingerprint(): string;
get isConnected(): boolean;
get clientElement(): E | undefined;
get serverElement(): ISpectraElement | undefined;
get children(): IChildren<IChildrenSupported>;
get attributes(): A;
get props(): INativeProperties<E, A>;
get datasets(): IGlobalAttributes;
get reference(): IRef<E, A> | undefined;
get locked(): boolean;
set locked(value: boolean);
get signal(): ISignalStack<IWidgetSignalMap<E, A>>;
get measure(): IMeasure;
get stylesheet(): IStyleSheet;
get context(): IContext<any, any> | undefined;
useContext(context?: IContext<any, any>): this;
construct(callback: ICallable<E, A, undefined>): this;
mount(callback: ICallable<E, A, IWidgetNode<E, A>>): this;
unmount(callback: ICallable<E, A, undefined>): this;
ready(callback: ICallable<E, A, IWidgetNode<E, A>>): this;
before(callback: ICallable<E, A, undefined>): this;
after(callback: ICallable<E, A, undefined>): this;
get(state: string): boolean | undefined;
set(state: string): this;
clear(): this;
remove(): this;
enable(): this;
disable(): this;
lock(): this;
focus(): this;
blur(): this;
unlock(): this;
trigger(type: keyof IGlobalEventMap): this;
stase(state: boolean): this;
computedStyle(token: keyof IStyleDeclaration): string | undefined;
hide(): this;
show(display?: Displaying): this;
toggle(option?: ToggleOption): this;
elevate(elevation?: ObjectElevation): this;
data(dataset: IGlobalAttributes): this;
attribute(attributes: Partial<A>): this;
attributeLess(attributes: IGlobalAttributes): this;
style(declaration: IStyleSheetDeclarations | IStyleSheet): this;
className(token: IStringToken): this;
removeClassName(token: IStringToken): this;
replaceClassName(oldToken: IStringToken, token: IStringToken): this;
clearClassName(): this;
value(data: IPrimitive): this;
html(code: string): this;
content(children: IChildren<IChildrenSupported>): this;
listen<T extends keyof IGlobalEventMap>(type: T, callback: ICallable<E, A, IGlobalEventPayload<T>>, options?: boolean | AddEventListenerOptions): this;
on<T extends keyof IGlobalEventMap>(type: T, callback: ICallable<E, A, IGlobalEventPayload<T>> | null): this;
detachEvent<T extends keyof IGlobalEventMap>(type: T): this;
clone(): this;
append(children: IWidgetNode<any, any> | IUiTarget<any>): this;
prepend(children: IWidgetNode<any, any> | IUiTarget<any>): this;
callable(callable: IWidgetSideCallableOptions<E>): this;
protected extractProperties(properties: IWidgetDeclaration<E, A>): this;
}
export declare function WidgetBuilder<E extends HTMLElement, A extends IAttributes, P extends IPropStack, S extends IStateStack>(widget: IWidgetNode<E, A>, context: IContext<P, S>): string | E | undefined;