//#region src/utilities/dom-lifecycle.d.ts type LifecycleCallback = (self: DomLifecycleElement) => void; type AdoptedCallback = (oldDocument: Document, newDocument: Document) => void; /** * Custom element backing the `` JSX tag. Place inside any * element to receive lifecycle notifications for that surrounding subtree — * `onConnect` / `onDisconnect` mirror `connectedCallback` / * `disconnectedCallback`, `onMove` mirrors the upcoming `connectedMoveCallback` * (fires when the element is moved with `Node.moveBefore()` instead of * disconnect+connect), and `onAdopted` mirrors `adoptedCallback`. * * Position-tracking callbacks (`onConnect` / `onDisconnect` / `onMove`) * receive the lifecycle element itself. Read `self.parentElement` for the * surrounding element, `self.firstElementChild` / `self.children` for a * wrapped subtree, or `self.getRootNode()` to walk through a shadow root. * `self` is always the live element — non-null even when the lifecycle * element is the root of a shadow tree (where `parentElement` is `null`). * * If you need the connect-time parent inside `onDisconnect` (the spec sets * `parentElement` to `null` before `disconnectedCallback` runs), capture it * yourself in `onConnect`. * * `onConnect` runs inside an `effectScope`, so any `onCleanup` registered * inside it (directly or via factories like `setContext`, `on`, observers, * etc.) fires on disconnect — before `onDisconnect` is invoked. The scope * persists across moves (`onMove`); a fresh scope is created on every * reconnection. * * Layout / a11y inert by default: `display: contents` removes the box so the * element doesn't affect its parent's layout, and `role="none"` strips its * implicit role from the accessibility tree. Children still participate in * both layout and a11y. (CSS structural selectors like `:empty`, * `:first-child`, and `:nth-child` still see the element in the DOM tree — * place the lifecycle element where those selectors don't reach if needed.) * * @example * Canonical form — wrap the subtree the lifecycle owns. `onConnect` runs * inside an `effectScope` tied to the wrapped subtree, so observers, context * lookups, and `onCleanup` registrations clean up on disconnect. * ```tsx *
* measure(el.firstElementChild)}> *

Title

*

Body

*
*
* ``` * * @example * Sibling form — fallback for cases where the host element is already * present for layout reasons and you only need lifecycle on the surrounding * element. Read `self.parentElement` for the host; capture it in `onConnect` * if you need it on disconnect (the spec nulls it before `onDisconnect`). * ```tsx *
* el.parentElement?.classList.add("ready")} * /> *
* ``` */ declare class DomLifecycleElement extends HTMLElement { #private; set onConnect(fn: LifecycleCallback | null); get onConnect(): LifecycleCallback | null; set onDisconnect(fn: LifecycleCallback | null); get onDisconnect(): LifecycleCallback | null; set onMove(fn: LifecycleCallback | null); get onMove(): LifecycleCallback | null; set onAdopted(fn: AdoptedCallback | null); get onAdopted(): AdoptedCallback | null; connectedCallback(): void; disconnectedCallback(): void; connectedMoveCallback(): void; adoptedCallback(oldDocument: Document, newDocument: Document): void; } declare global { namespace ElementsKit { interface CustomElementRegistry { "dom-lifecycle": typeof DomLifecycleElement; } } } //#endregion export { DomLifecycleElement };