/** * Base class for all DuskMoon custom elements */ /** * Property definition for reactive properties */ export interface PropertyDefinition { /** Attribute name (defaults to kebab-case of property name) */ attribute?: string | false; /** Whether changes should reflect to attribute */ reflect?: boolean; /** Property type for conversion */ type?: typeof String | typeof Number | typeof Boolean | typeof Object | typeof Array; /** Default value */ default?: unknown; } /** * Map of property names to their definitions */ export type PropertyDefinitions = Record; /** * Base class for all DuskMoon custom elements * * Provides: * - Shadow DOM setup with adoptedStyleSheets * - Reactive properties with attribute reflection * - Style injection utilities * - Common lifecycle methods * * @example * ```ts * class MyElement extends BaseElement { * static properties = { * name: { type: String, reflect: true } * }; * * constructor() { * super(); * this.attachStyles(myStyles); * } * * render() { * return `
Hello, ${this.name}!
`; * } * } * ``` */ export declare abstract class BaseElement extends HTMLElement { /** * Property definitions for reactive properties * Override in subclasses to define properties */ static properties: PropertyDefinitions; /** * Observed attributes derived from property definitions */ static get observedAttributes(): string[]; /** * Shadow root for the element */ shadowRoot: ShadowRoot; /** * Stylesheets attached to this element */ private _styles; /** * Whether the element has been connected to the DOM */ private _isConnected; /** * Property values set before element upgrade (e.g. by inline scripts * that run before customElements.define). Restored in connectedCallback * so they survive subclass constructor overwrites. */ private _preUpgradeValues?; /** * Queue of pending property updates */ private _pendingUpdate; /** * Internal property values storage */ private _propertyValues; constructor(); /** * Initialize reactive properties from static definitions */ private _initializeProperties; /** * Reflect a property value to an attribute */ private _reflectToAttribute; /** * Convert an attribute value to a property value */ private _attributeToProperty; /** * Schedule an update for the next microtask */ private _scheduleUpdate; /** * Attach additional stylesheets to the Shadow DOM * * @param styles - CSSStyleSheet or array of stylesheets to attach */ protected attachStyles(styles: CSSStyleSheet | CSSStyleSheet[]): void; /** * Called when the element is connected to the DOM */ connectedCallback(): void; /** * Called when the element is disconnected from the DOM */ disconnectedCallback(): void; /** * Called when an observed attribute changes */ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void; /** * Called when the element should update its DOM * Override to customize update behavior */ protected update(): void; /** * Returns the HTML content for the element * Override in subclasses to define the element's template * * @returns HTML string or undefined if no update needed */ protected render(): string | undefined; /** * Emit a custom event from this element * * @param name - Event name * @param detail - Event detail data * @param options - Additional event options */ protected emit(name: string, detail?: T, options?: Omit): boolean; /** * Query an element in the Shadow DOM */ protected query(selector: string): T | null; /** * Query all matching elements in the Shadow DOM */ protected queryAll(selector: string): NodeListOf; } //# sourceMappingURL=base-element.d.ts.map