"use client"; import * as React from "react"; import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"; import { Button } from "../primitives"; import { PortalLayerContainerProvider, type PortalLayerContainer, usePortalLayerContainer, } from "../primitives"; import { ScrollFade } from "../primitives"; import { cn } from "../../lib/utils"; import { XIcon } from "@phosphor-icons/react"; const DIALOG_SECTION_BORDER_COLOR = "color-mix(in oklab, var(--border) 5%, transparent)"; const DialogLayoutContext = React.createContext<{ sectioned: boolean; showCloseButton: boolean; }>({ sectioned: false, showCloseButton: false, }); function Dialog({ ...props }: DialogPrimitive.Root.Props) { return ; } function DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) { return ; } function DialogPortal({ children, container, ...props }: DialogPrimitive.Portal.Props): React.JSX.Element { const resolvedContainer = usePortalLayerContainer(container); const portalNodeRef = React.useRef(null); return ( {children} ); } function DialogClose({ ...props }: DialogPrimitive.Close.Props) { return ; } function DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props) { return ( ); } function DialogCloseButton({ className, }: { className?: string; } = {}): React.JSX.Element { return ( } > Close ); } function DialogContent({ className, children, layout = "default", portalContainer, size = "default", showCloseButton = true, style, ...props }: DialogPrimitive.Popup.Props & { layout?: "default" | "sections"; portalContainer?: PortalLayerContainer; size?: "default" | "xl" | "2xl"; showCloseButton?: boolean; }) { const sectioned = layout === "sections"; const resolvedStyle = size === "xl" ? { ...style, width: "min(var(--container-xl), calc(100% - 2rem))", } : size === "2xl" ? { ...style, width: "min(calc(var(--container-xl) + 4rem), calc(100% - 2rem))", } : style; return ( {children} {showCloseButton ? ( ) : null} ); } function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { const { sectioned, showCloseButton } = React.useContext(DialogLayoutContext); return (
); } function DialogBody({ className, ...props }: React.ComponentProps<"div">) { const { sectioned } = React.useContext(DialogLayoutContext); return (
); } function DialogFooter({ className, showCloseButton = false, justify = "end", children, ...props }: React.ComponentProps<"div"> & { justify?: "between" | "end" | "start"; showCloseButton?: boolean; }) { const { sectioned } = React.useContext(DialogLayoutContext); return (
{children} {showCloseButton && ( }> Close )}
); } function getDialogTitleText(children: React.ReactNode): string | null { const childNodes = React.Children.toArray(children); if (childNodes.length === 0) { return null; } if (childNodes.some((child) => typeof child !== "string" && typeof child !== "number")) { return null; } const text = childNodes.join(""); return text.length > 0 ? text : null; } function DialogTitle({ children, className, title, ...props }: DialogPrimitive.Title.Props) { const textContent = getDialogTitleText(children); const resolvedTitle = title ?? textContent ?? undefined; return ( {textContent ? ( {textContent} ) : ( children )} ); } function DialogDescription({ className, ...props }: DialogPrimitive.Description.Props) { return ( ); } export { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, };