UNPKG

@accelint/design-toolkit

Version:

An open-source component library to serve as part of the entire ecosystem of UX for Accelint.

76 lines (73 loc) 2.44 kB
import { Payload } from '@accelint/bus'; import { UniqueId } from '@accelint/core'; import { ToastListProps } from 'react-aria-components'; import { ButtonProps } from '../button/types.js'; import { NoticeEventTypes } from './events.js'; import 'tailwind-variants'; import '../../lib/types.js'; import 'react'; import '../button/styles.js'; import 'tailwind-merge'; type NoticeColor = 'info' | 'advisory' | 'normal' | 'serious' | 'critical'; type ActionButtonProps = Pick<ButtonProps, 'color' | 'variant'> & { children: string; }; type NoticeContent = { id: UniqueId; message: string; color?: NoticeColor; primary?: ActionButtonProps; secondary?: ActionButtonProps; timeout?: number; target?: UniqueId; metadata?: Record<string, unknown>; }; type NoticeIconProps = { color?: NoticeColor; size: 'small' | 'medium'; }; type NoticeListProps = { id?: UniqueId; placement?: 'top left' | 'top' | 'top right' | 'right' | 'bottom right' | 'bottom' | 'bottom left' | 'left'; limit?: number; defaultColor?: NoticeColor; defaultTimeout?: number; hideClearAll?: boolean; size?: 'small' | 'medium'; global?: boolean; classNames?: { region?: string; list?: ToastListProps<NoticeContent>['className']; button?: ButtonProps['className']; notice?: NoticeProps['classNames']; }; }; type NoticeProps = Omit<NoticeContent, 'metadata' | 'timeout' | 'target'> & { id: UniqueId; classNames?: { notice?: string; content?: string; message?: string; actions?: string; }; hideIcon?: boolean; showClose?: boolean; shouldCloseOnAction?: boolean; size?: 'small' | 'medium'; onPrimaryAction?: () => void; onSecondaryAction?: () => void; onClose?: () => void; }; type NoticeQueueEvent = Payload<typeof NoticeEventTypes.queue, Omit<NoticeContent, 'id'> & { id?: UniqueId; }>; type NoticeDequeueEvent = Payload<typeof NoticeEventTypes.dequeue, { id?: UniqueId; target?: UniqueId; color?: NoticeColor; metadata?: Record<string, unknown>; }>; type NoticeActionEvent = Payload<typeof NoticeEventTypes.actionPrimary | typeof NoticeEventTypes.actionSecondary | typeof NoticeEventTypes.close, { id: UniqueId; }>; export type { NoticeActionEvent, NoticeColor, NoticeContent, NoticeDequeueEvent, NoticeIconProps, NoticeListProps, NoticeProps, NoticeQueueEvent };