import { PropertyDeclarationMap, PropertyValues, ReactiveController } from "./types.js"; //#region src/reactive-element.d.ts /** * Lightweight reactive custom element base class. * * Drop-in subset of Lit's `ReactiveElement` — supports `static properties`, * attribute reflection, batched async updates, and reactive controllers. * No Shadow DOM, no `static styles`, no decorators. * * Updates are batched using the same Promise-based scheduling as Lit: * property changes enqueue a microtask, and the update is gated behind * `connectedCallback` so the first update only runs once the element * is in the document. * * Subclasses that extend another element with properties must spread them: * * @example * ```ts * class MyButton extends ReactiveElement { * static override properties = { * label: { type: String }, * disabled: { type: Boolean }, * }; * * label = 'Click me'; * disabled = false; * * protected override update(changed: PropertyValues): void { * super.update(changed); * this.textContent = this.label; * } * } * * // Inheritance — spread parent properties * class FancyButton extends MyButton { * static override properties = { * ...MyButton.properties, * variant: { type: String }, * }; * * variant = 'primary'; * } * ``` */ declare class ReactiveElement extends HTMLElement { #private; /** * User-supplied object that maps property names to * {@linkcode PropertyDeclaration} objects containing options for configuring * reactive properties. When a reactive property is set the element will * update and render. */ static properties: PropertyDeclarationMap; /** * Returns a list of attributes corresponding to the registered properties. */ static get observedAttributes(): string[]; /** * True if there is a pending update as a result of calling * `requestUpdate()`. Should only be read. */ isUpdatePending: boolean; /** * Is set to `true` after the first update. The element code cannot assume * that the DOM is fully initialized before the element `hasUpdated`. */ hasUpdated: boolean; constructor(); /** * Note, this method should be considered final and not overridden. It is * overridden on the element instance with a function that triggers the * first update. */ protected enableUpdating(_requestedUpdate: boolean): void; /** * Registers a {@linkcode ReactiveController} to participate in the * element's reactive update cycle. The element automatically calls into * any registered controllers during its lifecycle callbacks. * * If the element is connected when `addController()` is called, the * controller's `hostConnected()` callback will be immediately called. */ addController(controller: ReactiveController): void; /** Removes a {@linkcode ReactiveController} from the element. */ removeController(controller: ReactiveController): void; /** * On first connection, enables updating and notifies controllers. */ connectedCallback(): void; disconnectedCallback(): void; /** * Synchronizes property values when attributes change. * * Specifically, when an attribute is set, the corresponding property is * set. You should rarely need to implement this callback. If this method * is overridden, `super.attributeChangedCallback(name, _old, value)` must * be called. */ attributeChangedCallback(attr: string, oldValue: string | null, newValue: string | null): void; /** * Requests an update which is processed asynchronously. This should be * called when an element should update based on some state not triggered * by setting a reactive property. In this case, pass no arguments. It * should also be called when manually implementing a property setter. In * this case, pass the property `name` and `oldValue` to ensure that any * configured property options are honored. */ requestUpdate(name?: string, oldValue?: unknown): void; /** * Schedules an element update. You can override this method to change the * timing of updates by returning a Promise. The update will await the * returned Promise, and you should resolve the Promise to allow the update * to proceed. If this method is overridden, `super.scheduleUpdate()` must * be called. * * For instance, to schedule updates to occur just before the next frame: * * ```ts * override protected async scheduleUpdate(): Promise { * await new Promise((resolve) => requestAnimationFrame(() => resolve())); * super.scheduleUpdate(); * } * ``` */ protected scheduleUpdate(): void | Promise; /** * Performs an element update. Note, if an exception is thrown during the * update, `firstUpdated` and `updated` will not be called. * * Call `performUpdate()` to immediately process a pending update. This * should generally not be needed, but it can be done in rare cases when * you need to update synchronously. */ protected performUpdate(): void; /** * Invoked before `update()` to compute values needed during the update. * * Implement `willUpdate` to compute property values that depend on other * properties and are used in the rest of the update process. * * ```ts * willUpdate(changed) { * if (changed.has('firstName') || changed.has('lastName')) { * this.sha = computeSHA(`${this.firstName} ${this.lastName}`); * } * } * ``` */ protected willUpdate(_changed: PropertyValues): void; /** * Updates the element. This method reflects property values to attributes * and can be overridden to render and keep updated element DOM. Setting * properties inside this method will *not* trigger another update. */ protected update(_changed: PropertyValues): void; /** * Invoked when the element is first updated. Implement to perform one * time work on the element after update. * * Setting properties inside this method will trigger the element to * update again after this update cycle completes. */ protected firstUpdated(_changed: PropertyValues): void; /** * Invoked whenever the element is updated. Implement to perform * post-updating tasks via DOM APIs, for example, focusing an element. * * Setting properties inside this method will trigger the element to * update again after this update cycle completes. */ protected updated(_changed: PropertyValues): void; /** * Returns a Promise that resolves when the element has completed updating. * The Promise value is a boolean that is `true` if the element completed * the update without triggering another update. The Promise result is * `false` if a property was set inside `updated()`. */ get updateComplete(): Promise; } //#endregion export { ReactiveElement }; //# sourceMappingURL=reactive-element.d.ts.map