/** * `FloatingRootStore` — Solid-native. * * Backed by per-key `createSignal`s exposed via a getter-bag * `state` proxy. Property reads on `store.state` track per-key * when invoked inside a reactive context; outside one, they * return the current value non-reactively. Writes do NOT flush: * they batch to the next microtask per Solid 2.0's default, and * every consumer reads through a reactive surface that settles on * that flush. Imperative call sites needing same-tick visibility * (chiefly tests) must call `flush()` themselves before reading * back. Each signal is constructed with * `ownedWrite: true` because writers are routinely invoked from * inside reactive owners (Solid 2.0 dev would otherwise raise * `SIGNAL_WRITE_IN_OWNED_SCOPE`). * * ### Public contract * * - `state` — reactive proxy. Read `state.open` etc.; tracks * per-key in reactive scopes. * - `context` — non-reactive bag (`dataRef`, `events`, `nested`, * `triggerElements`). Fields here are intentionally imperative. * - `useState(key)` — convenience wrapper. Returns `state[key]` * (with the `referenceElement → positionReference` fallback). * Equivalent in tracking behavior to a direct `state.*` read. * - `useStateAccessor(key)` — returns `() => useState(key)`. * - `sync(key, value)` / `set(key, value)` — identity-compare * setters. No-op on unchanged. * - `update(partial)` — shallow merge; no-op if nothing changed. * - `getSnapshot()` — alias for `state`. Same reference; * tracking still depends on the caller's context. * - `syncOpenEvent` / `dispatchOpenChange` / `setOpen` — * open-change dispatch. */ import { type Accessor } from "solid-js"; import type { BaseUIChangeEventDetails } from "../../change-event-details.js"; import type { TransitionStatus } from "../../use-transition-status/use-transition-status.js"; import type { PopupTriggerMap } from "../popup-trigger-map.js"; import type { ContextData, FloatingEvents, MutableRef, ReferenceType } from "../types.js"; export interface FloatingUIOpenChangeDetails { open: boolean; reason: string; nativeEvent: Event; nested: boolean; triggerElement?: Element | undefined; } export interface FloatingRootState { open: boolean; transitionStatus: TransitionStatus | undefined; domReferenceElement: Element | null; referenceElement: ReferenceType | null; floatingElement: HTMLElement | null; positionReference: ReferenceType | null; floatingId: string | undefined; } export interface FloatingRootStoreContext { onOpenChange: ((open: boolean, eventDetails: BaseUIChangeEventDetails) => void) | undefined; readonly dataRef: MutableRef; readonly events: FloatingEvents; nested: boolean; readonly triggerElements: PopupTriggerMap; } export interface FloatingRootStoreOptions { open: boolean; transitionStatus: TransitionStatus | undefined; referenceElement: ReferenceType | null; floatingElement: HTMLElement | null; triggerElements: PopupTriggerMap; floatingId: string | undefined; /** * When `true`, `setOpen` only forwards to `onOpenChange` — the owning * popup store handles `dispatchOpenChange`. Matches the React source. */ syncOnly: boolean; nested: boolean; onOpenChange: ((open: boolean, eventDetails: BaseUIChangeEventDetails) => void) | undefined; } export type FloatingRootStateView = { readonly [K in keyof FloatingRootState]: FloatingRootState[K]; }; export declare class FloatingRootStore { private readonly _open; private readonly _setOpenSignal; private readonly _transitionStatus; private readonly _setTransitionStatus; private readonly _referenceElement; private readonly _setReferenceElement; private readonly _floatingElement; private readonly _setFloatingElement; private readonly _positionReference; private readonly _setPositionReference; private readonly _domReferenceElement; private readonly _setDomReferenceElement; private readonly _floatingId; private readonly _setFloatingId; private readonly _stateProxy; readonly context: FloatingRootStoreContext; private readonly syncOnly; constructor(options: FloatingRootStoreOptions); private _getAccessor; private _writeKey; /** * Reactive store proxy. Property reads inside tracking contexts * subscribe to the specific key; reads in untracked contexts * (event handlers) return the current value without subscribing. */ get state(): FloatingRootStateView; /** * Current state view. Same reference as `state`. Property reads * outside tracking contexts don't subscribe — use this when the * spelling "snapshot" makes intent clearer at the call site. */ getSnapshot: () => FloatingRootStateView; /** * Returns the current value for `key`, subscribing the caller's * tracking context to updates of that specific key. The * `"referenceElement"` selector prefers `positionReference` over * the raw slot to match the React selector. */ useState(key: K): FloatingRootState[K]; /** * Returns a live `Accessor` for `key`. Equivalent to * `() => store.useState(key)` with a stable function identity. */ useStateAccessor(key: K): Accessor; /** * Set a specific key. `createStore` handles the identity-compare * skip internally — writes equal to the current value are no-ops. */ set(key: K, value: FloatingRootState[K]): void; /** * Alias for `set`. Kept for the call-site spelling that the React * source uses (`useSyncedValue`). */ sync(key: K, value: FloatingRootState[K]): void; /** * Merge a partial into state. Uses the draft-first setter form so * only the keys that actually changed notify subscribers. */ update(changes: Partial): void; /** * Syncs the event used by hover logic to distinguish hover-open from * click-like interaction. Click events can upgrade a hover-open, but * a pending hover-open cannot overwrite a click-open. */ syncOpenEvent: (newOpen: boolean, event: Event | undefined) => void; /** * Runs the root-owned side effects for an open state change: syncs the * open-event bookkeeping and emits `openchange` on the events bus. */ dispatchOpenChange: (newOpen: boolean, eventDetails: BaseUIChangeEventDetails) => void; /** * Emits `openchange` and calls the context `onOpenChange` callback. * In `syncOnly` mode the dispatch step is skipped — the owning popup * store is responsible for emitting the event itself. */ setOpen: (newOpen: boolean, eventDetails: BaseUIChangeEventDetails) => void; } //# sourceMappingURL=floating-root-store.d.ts.map