"use client"; import * as React from "react"; import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"; import { cn } from "@/lib/utils"; import { buttonVariants } from "@/components/ui/button"; import { useModalPortal } from "@/lib/modalPortalRef"; import { useTabId } from "@/contexts/TabIdContext"; import { useTabStore } from "@/stores/tabStore"; // AlertDialog: 비활성 탭이면 자동으로 open={false} 처리 const AlertDialog: React.FC> = ({ open, ...props }) => { const tabId = useTabId(); const activeTabId = useTabStore((s) => s[s.mode].activeTabId); const isTabActive = !tabId || tabId === activeTabId; const effectiveOpen = open != null ? open && isTabActive : undefined; return ; }; AlertDialog.displayName = "AlertDialog"; const AlertDialogTrigger = AlertDialogPrimitive.Trigger; const AlertDialogPortal = AlertDialogPrimitive.Portal; const AlertDialogOverlay = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName; interface ScopedAlertDialogContentProps extends React.ComponentPropsWithoutRef { /** 포탈 대상 컨테이너. 명시적으로 전달하면 해당 값 사용, 미전달 시 탭 시스템 자동 감지 */ container?: HTMLElement | null; /** 탭 비활성 시 포탈 내용 숨김 */ hidden?: boolean; } const AlertDialogContent = React.forwardRef< React.ElementRef, ScopedAlertDialogContentProps >(({ className, container: explicitContainer, hidden: hiddenProp, style, ...props }, ref) => { const autoContainer = useModalPortal(); const container = explicitContainer !== undefined ? explicitContainer : autoContainer; const scoped = !!container; const adjustedStyle = scoped && style ? { ...style, maxHeight: undefined, maxWidth: undefined } : style; return (
{scoped ? (
) : ( )}
); }); AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName; const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes) => (
); AlertDialogHeader.displayName = "AlertDialogHeader"; const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes) => (
); AlertDialogFooter.displayName = "AlertDialogFooter"; const AlertDialogTitle = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName; const AlertDialogDescription = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName; const AlertDialogAction = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName; const AlertDialogCancel = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName; export { AlertDialog, AlertDialogPortal, AlertDialogOverlay, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel, };