import type { JSX } from "@solidjs/web"; import { type Accessor } from "solid-js"; import { type MaybeAccessor } from "../maybe-accessor.js"; import { type TransitionStatus } from "../use-transition-status/use-transition-status.js"; /** Props that `mergePanelProps` injects onto the panel element. */ export interface MountPanelProps { ref: (el: HTMLElement | null) => void; hidden: true | "until-found" | undefined; style: JSX.CSSProperties; } /** * Options for {@link createMountTransition}. */ export interface MountTransitionOptions { /** * When provided the helper reads but does not own the panel element signal; * `panelRef` becomes a no-op. When absent the helper creates its own internal * element signal and `panelRef` must be attached to the panel DOM element. */ panelElement?: Accessor; /** * Keep the panel element in the DOM even when closed. * * **What this does NOT control: exit animations.** Exit animations are * honored automatically regardless of `keepMounted`. The state machine * always waits for CSS animations/transitions on the panel element to * settle before flipping `mounted` → `false`. The two values differ * only in **what happens after the exit animation finishes**: * * - `keepMounted: false` (default): panel unmounts via ``. * `mounted` flips to `false`, `shouldRender` flips to `false`, * the element leaves the DOM. Re-mounts on next open. * - `keepMounted: true`: panel stays in the DOM with `hidden={true}`. * `mounted` flips to `false` but `shouldRender` stays `true`. * The element is hidden via the `hidden` attribute instead of * removed. * * Either way, the consumer's CSS exit transition (keyed off `data-state` / * `data-ending-style` / measured CSS vars) plays to completion first. * @default false */ keepMounted?: MaybeAccessor; /** * Use `hidden="until-found"` so the browser's built-in find-in-page can * reveal the panel. Overrides `keepMounted` (forces it true) — the * element must remain in the DOM for the browser's find-in-page to * locate matched content. * @default false */ hiddenUntilFound?: MaybeAccessor; /** * Called when the `beforematch` event fires on the panel element * (only relevant when `hiddenUntilFound` is true). The caller is * responsible for setting open=true in this callback. */ onBeforematch?: (event: Event) => void; /** * Prefix for the dimension CSS custom properties emitted in * `mergePanelProps().style`. Resolves to `--{prefix}-height` and * `--{prefix}-width`. Defaults to `"collapsible-panel"` for * backwards-compatibility with the existing Collapsible CSS contract; * new compounds (Tooltip, Dialog, Popover, Menu) should pass their * own (e.g. `"tooltip-popup"`) so consumer CSS stays * namespace-clean. The leading `--` is added by the helper. * * @default "collapsible-panel" */ cssVarPrefix?: string; } /** * Return value of {@link createMountTransition}. */ export interface MountTransition { /** True while the panel is mounted (during enter and while open, + exit animation). */ mounted: Accessor; /** * True when the panel element should be in the DOM. * `mounted || keepMounted || hiddenUntilFound` */ shouldRender: Accessor; /** Enter/exit animation phase. */ transitionStatus: Accessor; /** Measured height (undefined = auto / settled). */ height: Accessor; /** Measured width (undefined = auto / settled). */ width: Accessor; /** * The `hidden` attribute value to apply to the panel element: * - `true` → hidden (panel is closed and fully unmounted or keepMounted) * - `"until-found"` → hiddenUntilFound mode * - `undefined` → no hidden attribute (panel is open) */ hidden: Accessor; /** * Ref callback to bind to the panel element. No-op when `panelElement` was * passed in via options (caller owns the ref). */ panelRef: (el: HTMLElement | null) => void; /** * Merges mount-lifecycle props (ref, hidden, CSS vars) into a user prop bag. * Designed for easy composition inside a wrapper component's JSX spread. * * Returns a shallow-merged object whose getters stay reactive, so Solid's * compiled spread sees live values on each flush. * * @example * ```tsx *
* ``` */ mergePanelProps:

(userProps?: P) => P & MountPanelProps; } /** * Reusable animation-lifecycle primitive for any animated compound surface * (Collapsible, Dialog, Popover, Tooltip, etc.). * * Extracts: * - `useTransitionStatus` state machine (mounted / transitionStatus) * - Panel measurement (scrollHeight / scrollWidth → CSS vars) * - Exit-animation wait via `useAnimationsFinished` * - `beforematch` listener for `hiddenUntilFound` * * The caller owns the `open` signal; this helper wraps the rest. * * ### Design deviation from recommended signature * * The recommended interface included `setMounted` as an escape hatch. This * implementation omits it from the public surface — `setMounted` is an * internal implementation detail of the exit-animation path and should not be * called directly by callers. If callers need it, they should re-implement the * exit-animation logic. This keeps the surface smaller. * * `mergePanelProps` replaces the proposed `mergePanelProps

` function — same * idea, slightly renamed for clarity. The returned object uses getters so * Solid's compiled spread stays reactive after the merge. * * ### Solid 2 notes * * - `panelElement` signal uses `ownedWrite: true` so the ref callback (unowned * scope) can write — same pattern as `renderElement`'s host-capture signal. * - Dimension signals use `ownedWrite: true` for the same reason (writes from * animation-finished callbacks). * - Effects are `createRenderEffect` so dimension writes are synchronous with * DOM updates (no paint flash). */ export declare function createMountTransition(open: Accessor, options?: MountTransitionOptions): MountTransition; //# sourceMappingURL=use-mount-transition.d.ts.map