UNPKG

@omit/react-confirm-dialog

Version:
79 lines (74 loc) 4.6 kB
import * as React from 'react'; import React__default, { ReactNode, ComponentPropsWithRef } from 'react'; import * as react_jsx_runtime from 'react/jsx-runtime'; import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'; import * as class_variance_authority_types from 'class-variance-authority/types'; import { VariantProps } from 'class-variance-authority'; declare const buttonVariants: (props?: ({ variant?: "default" | "outline" | "secondary" | "ghost" | "destructive" | "link" | null | undefined; size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined; } & class_variance_authority_types.ClassProp) | undefined) => string; declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<'button'> & VariantProps<typeof buttonVariants> & { asChild?: boolean; }): react_jsx_runtime.JSX.Element; declare function AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>): react_jsx_runtime.JSX.Element; declare function AlertDialogContent({ className, size, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Content> & { size?: 'default' | 'sm'; }): react_jsx_runtime.JSX.Element; declare function AlertDialogHeader({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element; declare function AlertDialogFooter({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element; declare function AlertDialogMedia({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element; declare function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>): react_jsx_runtime.JSX.Element; declare function AlertDialogDescription({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Description>): react_jsx_runtime.JSX.Element; declare function AlertDialogAction({ className, variant, size, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Action> & Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>): react_jsx_runtime.JSX.Element; declare function AlertDialogCancel({ className, variant, size, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel> & Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>): react_jsx_runtime.JSX.Element; interface CustomActionsProps { confirm: () => void; cancel: () => void; config: ConfirmOptions; setConfig: ConfigUpdater; } type ConfigUpdater = (config: ConfirmOptions | ((prev: ConfirmOptions) => ConfirmOptions)) => void; type LegacyCustomActions = (onConfirm: () => void, onCancel: () => void) => ReactNode; type EnhancedCustomActions = (props: CustomActionsProps) => ReactNode; interface ConfirmOptions { title?: ReactNode; description?: ReactNode; contentSlot?: ReactNode; confirmText?: string; cancelText?: string; icon?: ReactNode; media?: ReactNode; customActions?: LegacyCustomActions | EnhancedCustomActions; confirmButton?: ComponentPropsWithRef<typeof AlertDialogAction>; cancelButton?: ComponentPropsWithRef<typeof AlertDialogCancel> | null; alertDialogOverlay?: ComponentPropsWithRef<typeof AlertDialogOverlay>; alertDialogContent?: ComponentPropsWithRef<typeof AlertDialogContent>; alertDialogHeader?: ComponentPropsWithRef<typeof AlertDialogHeader>; alertDialogTitle?: ComponentPropsWithRef<typeof AlertDialogTitle>; alertDialogMedia?: ComponentPropsWithRef<typeof AlertDialogMedia>; alertDialogDescription?: ComponentPropsWithRef<typeof AlertDialogDescription>; alertDialogFooter?: ComponentPropsWithRef<typeof AlertDialogFooter>; } interface ConfirmDialogState { isOpen: boolean; config: ConfirmOptions; resolver: ((value: boolean) => void) | null; } interface ConfirmContextValue { confirm: ConfirmFunction; updateConfig: ConfigUpdater; } interface ConfirmFunction { (options: ConfirmOptions): Promise<boolean>; updateConfig?: ConfigUpdater; } declare const ConfirmContext: React__default.Context<ConfirmContextValue | undefined>; declare const ConfirmDialogProvider: React__default.FC<{ defaultOptions?: ConfirmOptions; children: React__default.ReactNode; }>; declare const useConfirm: () => ConfirmFunction & { updateConfig: ConfirmContextValue["updateConfig"]; }; export { ConfigUpdater, ConfirmContext, ConfirmContextValue, ConfirmDialogProvider, ConfirmDialogState, ConfirmFunction, ConfirmOptions, CustomActionsProps, EnhancedCustomActions, LegacyCustomActions, useConfirm };