import type { JSX } from "@solidjs/web"; /** * Type layer for the floating-ui-react Solid port. * * Mirrors `base-ui/packages/react/src/floating-ui-react/types.ts`, swapping * three things for Solid idioms: * * 1. Positioning types come from `@floating-ui/dom` instead of * `@floating-ui/react-dom` (since Solid doesn't use the React wrapper). * 2. React-style `RefObject` becomes a plain `{ current: T | null }` * contract. Solid uses mutable closed-over variables for refs, but the * port surfaces them via a thin ref-like shape so caller ergonomics * match the React source. * 3. `React.HTMLProps` becomes a record of JSX-friendly attribute shapes * typed loosely enough to mesh with Solid's `mergePropsN` + render-element * pipeline, which normalizes props via `HTMLProps` from * `src/internals/types.ts`. * * The three placeholder types — `FloatingRootStoreType`, * `FloatingTreeStoreType`, `ExtendedUserProps` — are defined as opaque * shapes here so the file type-checks in isolation. They are re-declared * with concrete shapes in later stages (Stage 3 for stores, Stage 4 for * `ExtendedUserProps`). Keeping them local-opaque avoids a circular * import between `types.ts` and the store/hook files. */ import type { ComputePositionConfig, ComputePositionReturn, Middleware, MiddlewareData, Placement, Strategy, VirtualElement } from "@floating-ui/dom"; import type { BaseUIChangeEventDetails } from "../change-event-details.js"; export type { Alignment, AutoUpdateOptions, Axis, ClientRectObject, ComputePositionConfig, ComputePositionReturn, Coords, Dimensions, Elements, Middleware, MiddlewareData, MiddlewareState, Padding, Placement, Rect, Side, Strategy, VirtualElement, } from "@floating-ui/dom"; export type Prettify = { [K in keyof T]: T[K]; } & {}; export type Delay = number | Partial<{ open: number; close: number; }>; export type ReferenceType = Element | VirtualElement; export type NarrowedElement = T extends Element ? T : Element; /** * Ref-like container. We use a plain mutable `{ current }` object rather than * Solid's closed-over `let` bindings because the React source passes refs * around between hooks, and a shared mutable slot is the closest analogue. * Ports consume these as `ref.current` reads/writes; Solid reactivity is * layered on top (e.g. signals) when the field needs to trigger re-runs. */ export interface MutableRef { current: T; } export interface ExtendedRefs { reference: MutableRef; floating: MutableRef; domReference: MutableRef | null>; setReference(node: ReferenceType | null): void; setFloating(node: HTMLElement | null): void; setPositionReference(node: ReferenceType | null): void; } export interface ExtendedElements { reference: ReferenceType | null; floating: HTMLElement | null; domReference: NarrowedElement | null; } export interface FloatingEvents { emit(event: T, data?: any): void; on(event: string, handler: (data: any) => void): void; off(event: string, handler: (data: any) => void): void; } export interface ContextData { openEvent?: Event | undefined; floatingContext?: FloatingContext | undefined; /** * Internal — written by `useTypeahead`. External consumers should subscribe * via the `onTypingChange` prop instead of reading this field. */ typing?: boolean | undefined; [key: string]: unknown; } /** * Real `FloatingRootStore` (Stage 3). Kept as a type-only re-export here so * consumers that import from `./types` get the concrete shape without * paying for the store module's runtime code. The class itself is exported * from `components/floating-root-store.ts` — import from there to * instantiate. */ export type FloatingRootStoreType = import("./components/floating-root-store.js").FloatingRootStore; /** * Real `FloatingTreeStore` (Stage 3). Same import-type pattern as above. */ export type FloatingTreeStoreType = import("./components/floating-tree-store.js").FloatingTreeStore; export type FloatingRootContext = FloatingRootStoreType; export interface UsePositionFloatingReturn extends ComputePositionReturn { /** * Whether the placement has been populated yet. `false` until the first * `computePosition` cycle resolves. */ isPositioned: boolean; /** * Imperatively re-run `computePosition`. Useful when external state * changes require a reflow outside the automatic auto-update cycle. */ update(): void; placement: Placement; strategy: Strategy; middlewareData: MiddlewareData; x: number; y: number; __ref?: RT; } export type FloatingContext = Omit, "refs" | "elements"> & { open: boolean; onOpenChange(open: boolean, eventDetails: BaseUIChangeEventDetails): void; events: FloatingEvents; dataRef: MutableRef; nodeId: string | undefined; floatingId: string | undefined; refs: ExtendedRefs; elements: ExtendedElements; rootStore: FloatingRootContext; }; export interface FloatingNodeType { id: string | undefined; parentId: string | null; context?: FloatingContext | undefined; } export type FloatingTreeType = FloatingTreeStoreType; /** * JSX-friendly element-props bag carried between interaction hooks. The * React source types this as `React.HTMLProps`; the Solid port * accepts any `JSX.HTMLAttributes`-shaped record since we feed the bag * through `mergePropsN`, which normalizes event-handler shapes and * attribute casing. */ export type ElementPropsBag = JSX.HTMLAttributes & Record; /** * Item-prop callback receives a payload of per-item state (active, selected). * Stage 4's `useInteractions` defines the concrete shape; until then this * is an opaque record. */ export type ExtendedUserProps = { active?: boolean; selected?: boolean; } & Record; export interface ElementProps { reference?: ElementPropsBag | undefined; floating?: ElementPropsBag | undefined; item?: ElementPropsBag | ((props: ExtendedUserProps) => ElementPropsBag) | undefined; trigger?: ElementPropsBag | undefined; } export type UseFloatingReturn = Prettify; refs: ExtendedRefs; elements: ExtendedElements; }>; export interface UseFloatingOptions { placement?: Placement | undefined; strategy?: Strategy | undefined; middleware?: Array | undefined; /** * Reference / floating elements supplied externally. Each field is a Solid * signal accessor in practice (reactive); typing stays permissive here. */ elements?: { reference?: ReferenceType | null | undefined; floating?: HTMLElement | null | undefined; } | undefined; /** * When `true`, the position is recomputed automatically on transform * changes. Matches `@floating-ui/dom`'s `transform` flag on * `ComputePositionConfig`. */ transform?: boolean | undefined; rootContext?: FloatingRootContext | undefined; onOpenChange?(open: boolean, eventDetails: BaseUIChangeEventDetails): void; nodeId?: string | undefined; externalTree?: FloatingTreeStoreType | undefined; platform?: ComputePositionConfig["platform"] | undefined; } //# sourceMappingURL=types.d.ts.map