import { type ComponentProps, type ReactNode, type RefObject } from 'react'; import { type NotificationRole, type NotificationVariant } from '../core/notification.js'; /** * Unstyled Carbon notification (InlineNotification, ToastNotification, ActionableNotification, * Callout), the behaviour of the styled one without a single class. The `Box` takes the role from * core/notification: `status` by default, none for a callout, `alertdialog` when `actionable` (or * the `role` you give). An `alertdialog` one moves focus to its `Action` (unless `autoFocus` is * false), keeps Tab and Shift+Tab going round its controls, closes on Esc while focus is inside (`closeOnEscape`), and is * named by its `Title` and described by its `Subtitle`. `timeout` (a toast) closes it after that many * ms, paused while it is hovered or holds focus, never while `actionable` (WCAG 2.2.1). * * `Close`, Esc and the timeout call `onClose(reason)` (`'close-button'`, `'escape'`, `'timeout'`); * return `false` to keep it open. Without `open` it hides itself when closed; focus inside it then * goes back to where it was before the action took it. * * ```tsx * * * Upload failed * The file is too big. * Retry * × * * * ``` */ export type NotificationCloseReason = 'close-button' | 'escape' | 'timeout'; export interface RootProps { /** Controlled visibility; without it the notification hides itself when closed. */ open?: boolean; /** Return `false` to keep it open. */ onClose?: (reason: NotificationCloseReason) => boolean | void; /** inline (default), toast or callout: a callout has no role of its own. */ variant?: NotificationVariant; /** The `Box`'s role, in place of the one core/notification picks. */ role?: NotificationRole; /** It has an `Action`: an `alertdialog` that never closes on its own. */ actionable?: boolean; /** Milliseconds after which it closes itself (toast); 0 = never. */ timeout?: number; /** Esc closes an `alertdialog` one while focus is inside it (Carbon `closeOnEscape`; default true). */ closeOnEscape?: boolean; /** An `alertdialog` one moves focus to its `Action` (default true; Carbon `hasFocus`). */ autoFocus?: boolean; /** Rendered while open. */ children?: ReactNode; } interface NotificationContextValue { id: string; open: boolean; variant: NotificationVariant; /** The `Box`'s role (undefined: none). */ role: Exclude | undefined; titleId: string | undefined; setTitleId: (id: string | undefined) => void; subtitleId: string | undefined; setSubtitleId: (id: string | undefined) => void; box: RefObject; action: RefObject; requestClose: (reason: NotificationCloseReason) => void; } /** The state of the enclosing `Notification.Root` (open, role, `requestClose` …). */ export declare function useNotificationContext(part?: string): NotificationContextValue; /** Holds the open state, moves focus, listens for Esc and runs the timeout; renders only its children, while open. */ export declare function Root({ open, onClose, variant, role, actionable, timeout, closeOnEscape, autoFocus, children }: Readonly): import("react").JSX.Element | null; /** The notification itself, with its role; an `alertdialog` one is named by `Title`, described by `Subtitle`, and keeps Tab inside. */ export declare function Box({ ref, ...rest }: Readonly, 'role'>>): import("react").JSX.Element; /** The title: names an `alertdialog` one (and describes a callout's `Action`). */ export declare function Title({ id, ...rest }: Readonly>): import("react").JSX.Element; /** The subtitle: describes an `alertdialog` one. */ export declare function Subtitle({ id, ...rest }: Readonly>): import("react").JSX.Element; /** The action button: first focus of an `alertdialog` one; in a callout it is described by the `Title`. It doesn't close the notification. */ export declare function Action({ ref, ...rest }: Readonly, 'type'>>): import("react").JSX.Element; /** Asks to close (`'close-button'`); give it an `aria-label`. */ export declare function Close(props: Readonly, 'type'>>): import("react").JSX.Element; export {};