import type { JSX } from "@solidjs/web"; import { type Accessor } from "solid-js"; import { type MaybeAccessor } from "../internals/maybe-accessor.js"; /** * Why the drawer's open state changed. * * - `"trigger-press"` — trigger was clicked or keyboard-activated. * - `"swipe"` — user swipe-dismissed the drawer. * - `"escape-key"` — Escape dismissed the drawer. * - `"outside-press"` — pointer pressed outside. * - `"close-button"` — `` was pressed. * - `"close-watcher"` — Android CloseWatcher back-gesture. * - `"imperative"` — `dr.setOpen()` called programmatically. */ export type DrawerChangeReason = "trigger-press" | "swipe" | "escape-key" | "outside-press" | "close-button" | "close-watcher" | "imperative"; import type { DrawerSnapPoint, DrawerSwipeDirection } from "./root/drawer-root-context.js"; export type { DrawerSnapPoint, DrawerSwipeDirection }; /** * Options for {@link createDrawer}. */ export interface CreateDrawerOptions { /** * Open state. Consumer-owned signal. */ open: MaybeAccessor; /** * Whether interaction is suppressed. * @default false */ disabled?: MaybeAccessor; /** * Modal surface kind (drawer is modal by default). * @default true */ modal?: MaybeAccessor; /** * When true, outside-press dismissal is disabled. * @default false */ disablePointerDismissal?: MaybeAccessor; /** * Direction the drawer slides from. * @default "down" */ swipeDirection?: MaybeAccessor; /** * Snap points list. When provided the drawer can be dragged to each point. */ snapPoints?: MaybeAccessor; /** * Active snap point. Consumer-owned — pair with `onSnapPointChange`. */ snapPoint?: MaybeAccessor; /** * Pre-change callback fired via `runWithOwner(null, ...)`. */ onOpenChange?: (open: boolean, event: Event, reason: DrawerChangeReason) => void; /** * Fires on every snap-point change request. */ onSnapPointChange?: (snapPoint: DrawerSnapPoint | null) => void; } /** * Public API returned by {@link createDrawer}. */ export interface DrawerApi { /** Reactive accessor for the current open state. */ open: Accessor; /** Whether interaction is suppressed. */ disabled: Accessor; /** Modal surface kind. */ modal: Accessor; /** Whether outside-press dismissal is disabled. */ disablePointerDismissal: Accessor; /** Direction the drawer slides from. */ swipeDirection: Accessor; /** Active snap point accessor. */ snapPoint: Accessor; /** Snap points list. */ snapPoints: Accessor; /** Imperative open setter. */ setOpen: (next: boolean, event?: Event, reason?: DrawerChangeReason) => void; /** Flip open (no-op when disabled). */ toggle: (event?: Event, reason?: DrawerChangeReason) => void; /** Imperative snap-point setter. Fires `onSnapPointChange`. */ setSnapPoint: (snapPoint: DrawerSnapPoint | null) => void; /** Context provider. */ Provider: (props: { children: JSX.Element; }) => JSX.Element; } /** * Read the nearest {@link DrawerApi}. Throws unless `optional` is true. */ export declare function useDrawer(): DrawerApi; export declare function useDrawer(optional: true): DrawerApi | null; /** * Headless primitive for a drawer compound. Modal slide-in panel with swipe * dismissal and snap-point control. DOM machinery lives in ``. */ export declare function createDrawer(options: CreateDrawerOptions): DrawerApi; //# sourceMappingURL=create-drawer.d.ts.map