import { type ComponentProps, type ReactNode, type RefObject } from 'react'; import { type OverlayLayer } from '../core/overlay.js'; /** * Unstyled Carbon for IBM Products `Tearsheet`, the behaviour of the styled one without a single * class: a native `` + showModal() (top layer, inert page, Esc) whose `Sheet` rises from * below on open and sinks back before the dialog closes and unmounts (none with * `--ui-duration-moderate-02` at 0, reduced motion, or a hidden page). Tab stays inside the sheet; * Esc, `Close` and a press-and-click outside the sheet ask to close (`'escape'`, `'close-button'`, * `'outside'`; the last unless `closeOnOutsideClick` is false). First focus: `selectorInitialFocus`, * else `Close`, else the sheet's first control; on close focus goes back to what had it. The page * doesn't scroll while one is open. `Title` names the dialog. Over other overlays one Esc closes only * the topmost (core/overlay.ts). * * Open tearsheets stack (Carbon): `data-stack` on `Dialog` and `Sheet` tells an open one under newer * ones its place — `1-of-2`, `2-of-2`, `1-of-3` … (up to three deep; absent alone) — to scale it back and * dim the page less. State shows as `data-open` and `data-closing` (sinking back) on both. * * ```tsx * setOpen(false)}> * * * Edit * × * … * * * * ``` */ export type TearsheetCloseReason = 'escape' | 'close-button' | 'outside'; export interface RootProps { open: boolean; /** Esc, `Close` or a click outside asked to close; set `open` to false to close (Carbon `onClose`). */ onRequestClose?: (reason: TearsheetCloseReason) => void; /** A click outside the sheet asks to close (default true; Carbon `preventCloseOnClickOutside` turns it off). */ closeOnOutsideClick?: boolean; /** What takes focus on open (Carbon `selectorPrimaryFocus`), else `Close` or the first control. */ selectorInitialFocus?: string; /** Rendered while open and while the sheet sinks back. */ children?: ReactNode; } interface TearsheetContextValue { id: string; open: boolean; /** Sinking back after `open` turned false. */ closing: boolean; /** Its place in a stack of open tearsheets (`1-of-2` …), else undefined. */ stackPlace: string | undefined; titleId: string | undefined; setTitleId: (id: string | undefined) => void; dialog: RefObject; sheet: RefObject; close: RefObject; closeOnOutsideClick: boolean; requestClose: (reason: TearsheetCloseReason) => void; /** Its place on the page's overlay stack. */ layer: OverlayLayer; } /** The state of the enclosing `Tearsheet.Root` (open, closing, `stackPlace`, `requestClose` …). */ export declare function useTearsheetContext(part?: string): TearsheetContextValue; /** Holds the open state and the stack, opens the dialog and moves focus; renders only its children, while shown. */ export declare function Root({ open, onRequestClose, closeOnOutsideClick, selectorInitialFocus, children }: Readonly): import("react").JSX.Element | null; export type DialogProps = Omit, 'open' | 'onClose'>; /** The native `` (full screen, its backdrop dims the page): Esc, a click outside the `Sheet`, Tab kept inside the sheet. */ export declare function Dialog({ ref, ...rest }: Readonly): import("react").JSX.Element; /** The sheet inside the dialog: what rises and sinks, where Tab stays, and what a click counts as outside of. */ export declare function Sheet({ ref, ...rest }: Readonly>): import("react").JSX.Element; /** The heading that names the dialog. */ export declare function Title({ id, children, ...rest }: Readonly>): import("react").JSX.Element; /** Asks to close (`'close-button'`); takes first focus unless `selectorInitialFocus` says otherwise. Give it an `aria-label`. */ export declare function Close({ ref, ...rest }: Readonly, 'type'>>): import("react").JSX.Element; export {};