import type { ReactElement, HTMLAttributes, Ref } from "react"; import type SlDrawerElement from "@shoelace-style/shoelace/dist/components/drawer/drawer.js"; import { SlShowEvent, SlAfterShowEvent, SlHideEvent, SlAfterHideEvent, SlInitialFocusEvent, SlRequestCloseEvent, } from "../events"; export type { SlDrawerElement }; export type SlDrawerShowEvent = SlShowEvent; export type SlDrawerAfterShowEvent = SlAfterShowEvent; export type SlDrawerHideEvent = SlHideEvent; export type SlDrawerAfterHideEvent = SlAfterHideEvent; export type SlDrawerInitialFocusEvent = SlInitialFocusEvent; export type SlDrawerRequestCloseEventDetail = { source: "close-button" | "keyboard" | "overlay"; }; export type SlDrawerRequestCloseEvent = SlRequestCloseEvent< SlDrawerElement, SlRequestCloseEventDetail >; export interface SlDrawerProps extends HTMLAttributes { ref?: Ref; /** * Indicates whether or not the drawer is open. You can toggle this attribute to show and hide the drawer, or you can * use the `show()` and `hide()` methods and this attribute will reflect the drawer's open state. */ open?: boolean; /** * The drawer's label as displayed in the header. You should always include a relevant label even when using * `no-header`, as it is required for proper accessibility. If you need to display HTML, use the `label` slot instead. */ label?: string; /** * The direction from which the drawer will open. */ placement?: "top" | "end" | "bottom" | "start"; /** * By default, the drawer slides out of its containing block (usually the viewport). To make the drawer slide out of * its parent element, set this attribute and add `position: relative` to the parent. */ contained?: boolean; /** * Removes the header. This will also remove the default close button, so please ensure you provide an easy, * accessible way for users to dismiss the drawer. */ noHeader?: boolean; /** * Emitted when the drawer opens. */ onSlShow?: (event: SlDrawerShowEvent) => void; /** * Emitted when the drawer opens. */ onSlShowCapture?: (event: SlDrawerShowEvent) => void; /** * Emitted after the drawer opens and all animations are complete. */ onSlAfterShow?: (event: SlDrawerAfterShowEvent) => void; /** * Emitted after the drawer opens and all animations are complete. */ onSlAfterShowCapture?: (event: SlDrawerAfterShowEvent) => void; /** * Emitted when the drawer closes. */ onSlHide?: (event: SlDrawerHideEvent) => void; /** * Emitted when the drawer closes. */ onSlHideCapture?: (event: SlDrawerHideEvent) => void; /** * Emitted after the drawer closes and all animations are complete. */ onSlAfterHide?: (event: SlDrawerAfterHideEvent) => void; /** * Emitted after the drawer closes and all animations are complete. */ onSlAfterHideCapture?: (event: SlDrawerAfterHideEvent) => void; /** * Emitted when the drawer opens and is ready to receive focus. Calling `event.preventDefault()` will prevent focusing and allow you to set it on a different element, such as an input. */ onSlInitialFocus?: (event: SlDrawerInitialFocusEvent) => void; /** * Emitted when the drawer opens and is ready to receive focus. Calling `event.preventDefault()` will prevent focusing and allow you to set it on a different element, such as an input. */ onSlInitialFocusCapture?: (event: SlDrawerInitialFocusEvent) => void; /** * Emitted when the user attempts to close the drawer by clicking the close button, clicking the overlay, or pressing escape. Calling `event.preventDefault()` will keep the drawer open. Avoid using this unless closing the drawer will result in destructive behavior such as data loss. */ onSlRequestClose?: (event: SlDrawerRequestCloseEvent) => void; /** * Emitted when the user attempts to close the drawer by clicking the close button, clicking the overlay, or pressing escape. Calling `event.preventDefault()` will keep the drawer open. Avoid using this unless closing the drawer will result in destructive behavior such as data loss. */ onSlRequestCloseCapture?: (event: SlDrawerRequestCloseEvent) => void; } /** * Drawers slide in from a container to expose additional options and information. */ export default function SlDrawer( props: SlDrawerProps, ): ReactElement;