(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,
};