ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
63 lines (62 loc) • 2.33 kB
TypeScript
/**
* A minimal mock of DocumentFragment for SSR environments.
*/
export declare class DocumentFragmentMock {
childrenList: (HTMLElementMock | string)[];
appendChild(node: any): any;
serialize(): string;
querySelector(selector: string): HTMLElementMock | null;
querySelectorAll(selector: string): HTMLElementMock[];
}
/**
* A robust mock of HTMLElement for SSR environments.
*/
export declare class HTMLElementMock {
tagName: string;
attributes: Map<string, string>;
inlineStyles: Map<string, string>;
childrenList: (HTMLElementMock | string | DocumentFragmentMock)[];
shadowRoot: ShadowRootMock | null;
textContent: string | null;
content?: DocumentFragmentMock;
private eventListeners;
style: {
setProperty: (k: string, v: string) => void;
removeProperty: (k: string) => boolean;
};
classList: {
add: (...names: string[]) => void;
remove: (...names: string[]) => void;
toggle: (name: string) => void;
contains: (name: string) => boolean;
};
private _innerHTML;
get innerHTML(): string;
set innerHTML(value: string);
constructor(tag?: string);
get hidden(): boolean;
set hidden(val: boolean);
setAttribute(k: string, v: string): void;
getAttribute(k: string): string | null;
removeAttribute(k: string): void;
hasAttribute(k: string): boolean;
appendChild(node: any): any;
attachShadow(options: ShadowRootInit): ShadowRoot;
querySelector(selector: string): HTMLElementMock | null;
querySelectorAll(selector: string): HTMLElementMock[];
addEventListener(type: string, listener: EventListenerOrEventListenerObject): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject): void;
dispatchEvent(event: Event): boolean;
serialize(tagNameOverride?: string): string;
}
export declare class ShadowRootMock {
host: HTMLElementMock;
options: ShadowRootInit;
childrenList: (HTMLElementMock | string | DocumentFragmentMock)[];
adoptedStyleSheets: string[];
constructor(host: HTMLElementMock, options: ShadowRootInit);
appendChild(node: any): any;
querySelector(selector: string): HTMLElementMock | null;
querySelectorAll(selector: string): HTMLElementMock[];
serialize(): string;
}