diff --git a/packages/ui/src/components/primitives/sonner.d.ts b/packages/ui/src/components/primitives/sonner.d.ts deleted file mode 100644 index d9877b54be..0000000000 --- a/packages/ui/src/components/primitives/sonner.d.ts +++ /dev/null @@ -1,228 +0,0 @@ -import type { ReactNode } from 'react' -import type { Action, ExternalToast, ToastClassnames } from 'sonner' - -/** - * Unique identifier for the toast - */ -type ToastIdType = string | number - -/** - * Base toast properties shared across all toast types - */ -interface BaseToastProps { - /** Main toast message content */ - title: ReactNode - /** Optional detailed description */ - description?: ReactNode - /** Whether to apply colored background styling */ - colored?: boolean - /** Duration in milliseconds before auto-dismissal */ - duration?: number - /** If 'false', it'll prevent the user from dismissing the toast. Defaults to false. */ - dismissable?: boolean - /** Callback function when toast is dismissed */ - onDismiss?: () => void - /** Action button or custom React node */ - button?: Action | ReactNode - /** Whether to show a close button. Defaults to false */ - closeButton?: boolean - /** Custom class names for toast sub-components */ - classNames?: ToastClassnames -} - -/** - * Info toast properties - */ -interface InfoToastProps extends BaseToastProps { - type?: 'info' -} - -/** - * Warning toast properties - */ -interface WarningToastProps extends BaseToastProps { - type: 'warning' -} - -/** - * Error toast properties - */ -interface ErrorToastProps extends BaseToastProps { - type: 'error' -} - -/** - * Success toast properties - */ -interface SuccessToastProps extends BaseToastProps { - type: 'success' -} - -/** - * Loading toast properties - */ -interface LoadingToastProps extends BaseToastProps { - type: 'loading' - /** Optional promise to track for auto-dismissal when settled */ - promise?: Promise -} - -/** - * Custom toast properties - */ -interface CustomToastProps { - type: 'custom' - /** Custom JSX render function receiving toast ID */ - jsx: (id: ToastIdType) => React.ReactElement - /** Additional toast configuration */ - data: ExternalToast -} - -/** - * Discriminated union of all toast types - */ -type ToastProps = - | InfoToastProps - | WarningToastProps - | ErrorToastProps - | SuccessToastProps - | LoadingToastProps - | CustomToastProps - -/** - * Props for quick toast API methods (excluding type-specific fields) - */ -interface QuickApiProps extends Omit {} - -/** - * Props for loading toast quick API (with optional promise) - */ -interface QuickLoadingProps extends QuickApiProps { - /** Optional promise to track for auto-dismissal when settled */ - promise?: LoadingToastProps['promise'] -} - -/** - * Props for custom toast quick API - */ -interface QuickCustomProps { - /** Custom JSX render function receiving toast ID */ - jsx: CustomToastProps['jsx'] - /** Additional toast configuration */ - data: CustomToastProps['data'] -} - -/** - * Toast notification interface with type-safe methods - */ -interface toast { - /** - * Display a custom toast notification - * @param props - Toast configuration with discriminated type - * @returns Toast ID - * @example - * toast({ - * type: 'info', - * title: 'Hello', - * description: 'This is a toast' - * }) - */ - (props: ToastProps): ToastIdType - - /** - * Display an info toast notification - * @param message - Toast message content - * @param data - Optional additional configuration - * @returns Toast ID - * @example - * toast.info('Information message', { - * description: 'This is an info message' - * }) - */ - info: (message: ReactNode, data?: QuickApiProps) => ToastIdType - - /** - * Display a success toast notification - * @param message - Toast message content - * @param data - Optional additional configuration - * @returns Toast ID - * @example - * toast.success('Success!', { - * description: 'Operation completed successfully' - * }) - */ - success: (message: ReactNode, data?: QuickApiProps) => ToastIdType - - /** - * Display a warning toast notification - * @param message - Toast message content - * @param data - Optional additional configuration - * @returns Toast ID - * @example - * toast.warning('Warning', { - * description: 'Please be careful' - * }) - */ - warning: (message: ReactNode, data?: QuickApiProps) => ToastIdType - - /** - * Display an error toast notification - * @param message - Toast message content - * @param data - Optional additional configuration - * @returns Toast ID - * @example - * toast.error('Error', { - * description: 'Something went wrong' - * }) - */ - error: (message: ReactNode, data?: QuickApiProps) => ToastIdType - - /** - * Display a loading toast notification with optional promise tracking - * @param message - Toast message content - * @param data - Additional configuration with optional promise - * @returns Toast ID - * @example - * toast.loading('Loading...', { - * promise: fetchData() - * }) - */ - loading: (message: ReactNode, data?: QuickLoadingProps) => ToastIdType - - /** - * Display a custom toast notification - * @param props - Custom toast configuration - * @returns Toast ID - * @example - * toast.custom({ - * jsx: (id) =>
Custom toast {id}
, - * data: { duration: 5000 } - * }) - */ - custom: (props: QuickCustomProps) => ToastIdType - - /** - * Dismiss a toast notification by its ID - * @param id - The ID of the toast to dismiss - * @example - * const toastId = toast.info('Info') - * toast.dismiss(toastId) - */ - dismiss: (id: ToastIdType) => void -} - -// Export types for external use -export type { - BaseToastProps, - CustomToastProps, - ErrorToastProps, - InfoToastProps, - LoadingToastProps, - QuickApiProps, - QuickCustomProps, - QuickLoadingProps, - SuccessToastProps, - ToastIdType, - ToastProps, - WarningToastProps -}