@omit/react-confirm-dialog
Version:
A simple confirm dialog for React
1 lines • 21.8 kB
Source Map (JSON)
{"version":3,"sources":["../src/confirm-dialog.tsx","../src/components/ui/alert-dialog.tsx","../src/lib/utils.ts","../src/components/ui/button.tsx"],"sourcesContent":["import React, {\n useState,\n useCallback,\n useMemo,\n useContext,\n createContext,\n memo\n} from 'react'\nimport { type ReactNode, type ComponentPropsWithRef } from 'react'\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogOverlay,\n AlertDialogPortal,\n AlertDialogTitle\n} from '@/components/ui/alert-dialog'\n\nexport interface CustomActionsProps {\n confirm: () => void\n cancel: () => void\n config: ConfirmOptions\n setConfig: ConfigUpdater\n}\n\nexport type ConfigUpdater = (\n config: ConfirmOptions | ((prev: ConfirmOptions) => ConfirmOptions)\n) => void\n\nexport type LegacyCustomActions = (\n onConfirm: () => void,\n onCancel: () => void\n) => ReactNode\n\nexport type EnhancedCustomActions = (props: CustomActionsProps) => ReactNode\n\nexport interface ConfirmOptions {\n title?: ReactNode\n description?: ReactNode\n contentSlot?: ReactNode\n confirmText?: string\n cancelText?: string\n icon?: ReactNode\n customActions?: LegacyCustomActions | EnhancedCustomActions\n confirmButton?: ComponentPropsWithRef<typeof AlertDialogAction>\n cancelButton?: ComponentPropsWithRef<typeof AlertDialogCancel> | null\n alertDialogOverlay?: ComponentPropsWithRef<typeof AlertDialogOverlay>\n alertDialogContent?: ComponentPropsWithRef<typeof AlertDialogContent>\n alertDialogHeader?: ComponentPropsWithRef<typeof AlertDialogHeader>\n alertDialogTitle?: ComponentPropsWithRef<typeof AlertDialogTitle>\n alertDialogDescription?: ComponentPropsWithRef<typeof AlertDialogDescription>\n alertDialogFooter?: ComponentPropsWithRef<typeof AlertDialogFooter>\n}\n\nexport interface ConfirmDialogState {\n isOpen: boolean\n config: ConfirmOptions\n resolver: ((value: boolean) => void) | null\n}\n\nexport interface ConfirmContextValue {\n confirm: ConfirmFunction\n updateConfig: ConfigUpdater\n}\n\nexport interface ConfirmFunction {\n (options: ConfirmOptions): Promise<boolean>\n updateConfig?: ConfigUpdater\n}\n\nexport const ConfirmContext = createContext<ConfirmContextValue | undefined>(\n undefined\n)\n\nconst baseDefaultOptions: ConfirmOptions = {\n title: '',\n description: '',\n confirmText: 'Confirm',\n cancelText: 'Cancel',\n confirmButton: {},\n cancelButton: {},\n alertDialogContent: {},\n alertDialogHeader: {},\n alertDialogTitle: {},\n alertDialogDescription: {},\n alertDialogFooter: {}\n}\n\nfunction isLegacyCustomActions(\n fn: LegacyCustomActions | EnhancedCustomActions\n): fn is LegacyCustomActions {\n return fn.length === 2\n}\n\nconst ConfirmDialogContent: React.FC<{\n config: ConfirmOptions\n onConfirm: () => void\n onCancel: () => void\n setConfig: (\n config: ConfirmOptions | ((prev: ConfirmOptions) => ConfirmOptions)\n ) => void\n}> = memo(({ config, onConfirm, onCancel, setConfig }) => {\n const {\n title,\n description,\n cancelButton,\n confirmButton,\n confirmText,\n cancelText,\n icon,\n contentSlot,\n customActions,\n alertDialogOverlay,\n alertDialogContent,\n alertDialogHeader,\n alertDialogTitle,\n alertDialogDescription,\n alertDialogFooter\n } = config\n\n const renderActions = () => {\n if (!customActions) {\n return (\n <>\n {cancelButton !== null && (\n <AlertDialogCancel onClick={onCancel} {...cancelButton}>\n {cancelText}\n </AlertDialogCancel>\n )}\n <AlertDialogAction onClick={onConfirm} {...confirmButton}>\n {confirmText}\n </AlertDialogAction>\n </>\n )\n }\n\n if (isLegacyCustomActions(customActions)) {\n return customActions(onConfirm, onCancel)\n }\n\n return customActions({\n confirm: onConfirm,\n cancel: onCancel,\n config,\n setConfig\n })\n }\n\n const renderTitle = () => {\n if (!title && !icon) {\n return null\n }\n\n return (\n <AlertDialogTitle {...alertDialogTitle}>\n {icon}\n {title}\n </AlertDialogTitle>\n )\n }\n\n return (\n <AlertDialogPortal>\n <AlertDialogOverlay {...alertDialogOverlay} />\n <AlertDialogContent {...alertDialogContent}>\n <AlertDialogHeader {...alertDialogHeader}>\n {renderTitle()}\n {description && (\n <AlertDialogDescription {...alertDialogDescription}>\n {description}\n </AlertDialogDescription>\n )}\n {contentSlot}\n </AlertDialogHeader>\n <AlertDialogFooter {...alertDialogFooter}>\n {renderActions()}\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialogPortal>\n )\n})\n\nConfirmDialogContent.displayName = 'ConfirmDialogContent'\n\nconst ConfirmDialog: React.FC<{\n isOpen: boolean\n onOpenChange: (isOpen: boolean) => void\n config: ConfirmOptions\n onConfirm: () => void\n onCancel: () => void\n setConfig: (\n config: ConfirmOptions | ((prev: ConfirmOptions) => ConfirmOptions)\n ) => void\n}> = memo(\n ({ isOpen, onOpenChange, config, onConfirm, onCancel, setConfig }) => (\n <AlertDialog open={isOpen} onOpenChange={onOpenChange}>\n <ConfirmDialogContent\n config={config}\n onConfirm={onConfirm}\n onCancel={onCancel}\n setConfig={setConfig}\n />\n </AlertDialog>\n )\n)\n\nConfirmDialog.displayName = 'ConfirmDialog'\n\nexport const ConfirmDialogProvider: React.FC<{\n defaultOptions?: ConfirmOptions\n children: React.ReactNode\n}> = ({ defaultOptions = {}, children }) => {\n const [dialogState, setDialogState] = useState<ConfirmDialogState>({\n isOpen: false,\n config: baseDefaultOptions,\n resolver: null\n })\n\n const mergedDefaultOptions = useMemo(\n () => ({\n ...baseDefaultOptions,\n ...defaultOptions\n }),\n [defaultOptions]\n )\n\n const updateConfig = useCallback(\n (\n newConfig: ConfirmOptions | ((prev: ConfirmOptions) => ConfirmOptions)\n ) => {\n setDialogState((prev) => ({\n ...prev,\n config:\n typeof newConfig === 'function'\n ? newConfig(prev.config)\n : { ...prev.config, ...newConfig }\n }))\n },\n []\n )\n\n const confirm = useCallback(\n (options: ConfirmOptions) => {\n setDialogState((prev) => ({\n isOpen: true,\n config: { ...mergedDefaultOptions, ...options },\n resolver: prev.resolver\n }))\n return new Promise<boolean>((resolve) => {\n setDialogState((prev) => ({\n ...prev,\n resolver: resolve\n }))\n })\n },\n [mergedDefaultOptions]\n )\n\n const handleConfirm = useCallback(() => {\n setDialogState((prev) => {\n if (prev.resolver) {\n prev.resolver(true)\n }\n return {\n ...prev,\n isOpen: false,\n resolver: null\n }\n })\n }, [])\n\n const handleCancel = useCallback(() => {\n setDialogState((prev) => {\n if (prev.resolver) {\n prev.resolver(false)\n }\n return {\n ...prev,\n isOpen: false,\n resolver: null\n }\n })\n }, [])\n\n const handleOpenChange = useCallback(\n (open: boolean) => {\n if (!open) {\n handleCancel()\n }\n },\n [handleCancel]\n )\n\n const contextValue = useMemo(\n () => ({\n confirm,\n updateConfig\n }),\n [confirm, updateConfig]\n )\n\n return (\n <ConfirmContext.Provider value={contextValue}>\n {children}\n <ConfirmDialog\n isOpen={dialogState.isOpen}\n onOpenChange={handleOpenChange}\n config={dialogState.config}\n onConfirm={handleConfirm}\n onCancel={handleCancel}\n setConfig={updateConfig}\n />\n </ConfirmContext.Provider>\n )\n}\n\nexport const useConfirm = () => {\n const context = useContext(ConfirmContext)\n if (!context) {\n throw new Error('useConfirm must be used within a ConfirmDialogProvider')\n }\n\n const { confirm, updateConfig } = context\n\n const enhancedConfirm = confirm\n enhancedConfirm.updateConfig = updateConfig\n\n return enhancedConfirm as ConfirmFunction & {\n updateConfig: ConfirmContextValue['updateConfig']\n }\n}\n","'use client'\n\nimport * as React from 'react'\nimport * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'\nimport { cn } from '@/lib/utils'\nimport { type ButtonProps, buttonVariants } from '@/components/ui/button'\n\nconst AlertDialog = AlertDialogPrimitive.Root\n\nconst AlertDialogTrigger = AlertDialogPrimitive.Trigger\n\nconst AlertDialogPortal = AlertDialogPrimitive.Portal\n\nconst AlertDialogOverlay = React.forwardRef<\n React.ElementRef<typeof AlertDialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <AlertDialogPrimitive.Overlay\n className={cn(\n 'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n className\n )}\n {...props}\n ref={ref}\n />\n))\nAlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName\n\nconst AlertDialogContent = React.forwardRef<\n React.ElementRef<typeof AlertDialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>\n>(({ className, ...props }, ref) => (\n <AlertDialogPrimitive.Content\n ref={ref}\n className={cn(\n 'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',\n className\n )}\n {...props}\n />\n))\nAlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName\n\nconst AlertDialogHeader = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n 'flex flex-col space-y-2 text-center sm:text-left',\n className\n )}\n {...props}\n />\n)\nAlertDialogHeader.displayName = 'AlertDialogHeader'\n\nconst AlertDialogFooter = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n 'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',\n className\n )}\n {...props}\n />\n)\nAlertDialogFooter.displayName = 'AlertDialogFooter'\n\nconst AlertDialogTitle = React.forwardRef<\n React.ElementRef<typeof AlertDialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <AlertDialogPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold', className)}\n {...props}\n />\n))\nAlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName\n\nconst AlertDialogDescription = React.forwardRef<\n React.ElementRef<typeof AlertDialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <AlertDialogPrimitive.Description\n ref={ref}\n className={cn('text-sm text-muted-foreground', className)}\n {...props}\n />\n))\nAlertDialogDescription.displayName =\n AlertDialogPrimitive.Description.displayName\n\nconst AlertDialogAction = React.forwardRef<\n React.ElementRef<typeof AlertDialogPrimitive.Action>,\n React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action> &\n Partial<Pick<ButtonProps, 'variant' | 'size'>>\n>(({ className, variant, size, ...props }, ref) => (\n <AlertDialogPrimitive.Action\n ref={ref}\n className={cn(buttonVariants({ variant, size }), className)}\n {...props}\n />\n))\nAlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName\n\nconst AlertDialogCancel = React.forwardRef<\n React.ElementRef<typeof AlertDialogPrimitive.Cancel>,\n React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel> &\n Partial<Pick<ButtonProps, 'variant' | 'size'>>\n>(({ className, variant, size, ...props }, ref) => (\n <AlertDialogPrimitive.Cancel\n ref={ref}\n className={cn(buttonVariants({ variant, size }), className)}\n {...props}\n />\n))\nAlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName\n\nexport {\n AlertDialog,\n AlertDialogPortal,\n AlertDialogOverlay,\n AlertDialogTrigger,\n AlertDialogContent,\n AlertDialogHeader,\n AlertDialogFooter,\n AlertDialogTitle,\n AlertDialogDescription,\n AlertDialogAction,\n AlertDialogCancel\n}\n","import { type ClassValue, clsx } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n","import * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '@/lib/utils'\n\nconst buttonVariants = cva(\n 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n default:\n 'bg-primary text-primary-foreground shadow hover:bg-primary/90',\n destructive:\n 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',\n outline:\n 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',\n secondary:\n 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',\n ghost: 'hover:bg-accent hover:text-accent-foreground',\n link: 'text-primary underline-offset-4 hover:underline'\n },\n size: {\n default: 'h-9 px-4 py-2',\n sm: 'h-8 rounded-md px-3 text-xs',\n lg: 'h-10 rounded-md px-8',\n icon: 'h-9 w-9'\n }\n },\n defaultVariants: {\n variant: 'default',\n size: 'default'\n }\n }\n)\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : 'button'\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n {...props}\n />\n )\n }\n)\nButton.displayName = 'Button'\n\nexport { Button, buttonVariants }\n"],"mappings":"AAAA,OACE,YAAAA,EACA,eAAAC,EACA,WAAAC,EACA,cAAAC,EACA,iBAAAC,GACA,QAAAC,MACK,QCLP,UAAYC,MAAW,QACvB,UAAYC,MAA0B,+BCHtC,OAA0B,QAAAC,MAAY,OACtC,OAAS,WAAAC,MAAe,iBAEjB,SAASC,KAAMC,EAAsB,CAC1C,OAAOF,EAAQD,EAAKG,CAAM,CAAC,CAC7B,CCLA,UAAYC,MAAW,QACvB,OAAS,QAAAC,MAAY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,CACH,EAAG,CAAC,CAAC,EAECM,EAAmBR,EACtBS,GAAkB,CACZA,GACHF,EAAa,CAEjB,EACA,CAACA,CAAY,CACf,EAEMG,EAAeZ,EACnB,KAAO,CACL,QAAAK,EACA,aAAAJ,CACF,GACA,CAACI,EAASJ,CAAY,CACxB,EAEA,OACElD,EAACC,EAAe,SAAf,CAAwB,MAAO4D,EAC7B,UAAAjB,EACD7C,EAACuC,EAAA,CACC,OAAQO,EAAY,OACpB,aAAcc,EACd,OAAQd,EAAY,OACpB,UAAWY,EACX,SAAUC,EACV,UAAWR,EACb,GACF,CAEJ,EAEaY,GAAa,IAAM,CAC9B,IAAMC,EAAUC,EAAW/D,CAAc,EACzC,GAAI,CAAC8D,EACH,MAAM,IAAI,MAAM,wDAAwD,EAG1E,GAAM,CAAE,QAAAT,EAAS,aAAAJ,CAAa,EAAIa,EAE5BE,EAAkBX,EACxB,OAAAW,EAAgB,aAAef,EAExBe,CAGT","names":["useState","useCallback","useMemo","useContext","createContext","memo","React","AlertDialogPrimitive","clsx","twMerge","cn","inputs","React","Slot","cva","jsx","buttonVariants","cva","Button","className","variant","size","asChild","props","ref","Slot","cn","jsx","AlertDialog","AlertDialogPortal","AlertDialogOverlay","className","props","ref","jsx","cn","AlertDialogContent","AlertDialogHeader","AlertDialogFooter","AlertDialogTitle","AlertDialogDescription","AlertDialogAction","variant","size","buttonVariants","AlertDialogCancel","Fragment","jsx","jsxs","ConfirmContext","createContext","baseDefaultOptions","isLegacyCustomActions","fn","ConfirmDialogContent","memo","config","onConfirm","onCancel","setConfig","title","description","cancelButton","confirmButton","confirmText","cancelText","icon","contentSlot","customActions","alertDialogOverlay","alertDialogContent","alertDialogHeader","alertDialogTitle","alertDialogDescription","alertDialogFooter","renderActions","AlertDialogCancel","AlertDialogAction","renderTitle","AlertDialogTitle","AlertDialogPortal","AlertDialogOverlay","AlertDialogContent","AlertDialogHeader","AlertDialogDescription","AlertDialogFooter","ConfirmDialog","isOpen","onOpenChange","AlertDialog","ConfirmDialogProvider","defaultOptions","children","dialogState","setDialogState","useState","mergedDefaultOptions","useMemo","updateConfig","useCallback","newConfig","prev","confirm","options","resolve","handleConfirm","handleCancel","handleOpenChange","open","contextValue","useConfirm","context","useContext","enhancedConfirm"]}