UNPKG

melt

Version:

The next generation of Melt UI. Built for Svelte 5.

42 lines (41 loc) 1.65 kB
import type { MaybeGetter } from "../types"; import { type ArrowOptions, type ComputePositionConfig, type ComputePositionReturn, type FlipOptions, type OffsetOptions, type ShiftOptions, type VirtualElement } from "@floating-ui/dom"; export type FloatingApply = (el?: HTMLElement) => void; export type ArrowApply = (el?: HTMLElement) => void; export type OnComputeArgs = ComputePositionReturn & { floatingApply: FloatingApply; arrowApply: ArrowApply; }; export type OnCompute = (args: OnComputeArgs) => void; /** * Config for UseFloating. You may pass in options to the underlying Floating UI * `computePosition`, or to the middleware's Melt calls initially. */ export type UseFloatingConfig = { computePosition?: Partial<ComputePositionConfig>; shift?: ShiftOptions; flip?: FlipOptions; arrow?: ArrowOptions; offset?: OffsetOptions; sameWidth?: boolean; /** * Use a custom function when `computePosition` is returned. * * This will override default behaviour! If you want to add * functionality while keeping the original intact, just call * the `floatingApply` and `arrowApply` functions present in * the args respectively. * * When passing in null, nothing will happen. */ onCompute?: OnCompute | null; }; /** All the parameters UseFloating returns */ export type UseFloatingArgs = { node: MaybeGetter<HTMLElement | VirtualElement>; floating: MaybeGetter<HTMLElement>; config?: MaybeGetter<UseFloatingConfig | undefined>; }; export declare function useFloating(args: UseFloatingArgs): { readonly data: ComputePositionReturn | undefined; };