UNPKG

@yamada-ui/notice

Version:

Yamada UI notice component

55 lines (52 loc) 2.15 kB
import { AlertProps } from '@yamada-ui/alert'; import { NoticePlacement, NoticeComponentProps, NoticeConfigOptions, CSSUIObject, StyledTheme } from '@yamada-ui/core'; import { ReactNode } from 'react'; interface UseNoticeOptions extends NoticeConfigOptions { } interface NoticeOptions { id: number | string; duration: UseNoticeOptions["duration"]; message: (props: NoticeComponentProps) => ReactNode; placement: NoticePlacement; status: UseNoticeOptions["status"]; onDelete: () => void; style?: CSSUIObject; isDelete?: boolean; onCloseComplete?: () => void; } declare const createNoticeFunc: (defaultOptions: UseNoticeOptions, theme: StyledTheme) => { (options?: UseNoticeOptions): string | number; update(id: number | string, options: Omit<UseNoticeOptions, "id">): void; closeAll: (options?: { placement?: NoticePlacement[]; }) => void; close: (id: number | string) => void; isActive: (id: number | string) => boolean; }; type CreateNoticeReturn = ReturnType<typeof createNoticeFunc>; /** * `useNotice` is a custom hook that controls the notifications of the application. * * @see Docs https://yamada-ui.com/hooks/use-notice */ declare const useNotice: (defaultOptions?: UseNoticeOptions) => CreateNoticeReturn; type State = { [K in NoticePlacement]: NoticeOptions[]; }; interface Store { close: (id: number | string) => void; closeAll: (options?: { placement?: NoticePlacement[]; }) => void; create: (message: (props: NoticeComponentProps) => ReactNode, options: UseNoticeOptions) => number | string; getSnapshot: () => State; isActive: (id: number | string) => boolean; remove: (id: number | string, placement: NoticePlacement) => void; subscribe: (onStoreChange: () => void) => () => void; update: (id: number | string, options: Omit<UseNoticeOptions, "id">) => void; } declare const noticeStore: Store; interface NoticeProps extends Omit<AlertProps, keyof UseNoticeOptions>, UseNoticeOptions { onClose?: () => void; } export { type NoticeOptions, type NoticeProps, type UseNoticeOptions, noticeStore, useNotice };