46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import type { HTMLAttributes, ReactNode } from "react";
|
|
import { renderAsChild } from "@/lib/as-child";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
export interface DialogProps {
|
|
open?: boolean;
|
|
onOpenChange?: (open: boolean) => void;
|
|
children?: ReactNode;
|
|
}
|
|
|
|
export function Dialog({ open, children }: DialogProps) {
|
|
return open ? <>{children}</> : null;
|
|
}
|
|
|
|
export function DialogClose({
|
|
asChild,
|
|
children,
|
|
...props
|
|
}: HTMLAttributes<HTMLElement> & { asChild?: boolean }) {
|
|
return renderAsChild(asChild, children, props);
|
|
}
|
|
|
|
export interface DialogContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
showCloseButton?: boolean;
|
|
}
|
|
|
|
export function DialogContent({ className, showCloseButton, ...props }: DialogContentProps) {
|
|
return <div role="dialog" data-show-close-button={showCloseButton} className={cn(className)} {...props} />;
|
|
}
|
|
|
|
export function DialogHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
|
|
return <div className={cn(className)} {...props} />;
|
|
}
|
|
|
|
export function DialogFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
|
|
return <div className={cn(className)} {...props} />;
|
|
}
|
|
|
|
export function DialogTitle({ className, ...props }: HTMLAttributes<HTMLHeadingElement>) {
|
|
return <h2 className={cn(className)} {...props} />;
|
|
}
|
|
|
|
export function DialogDescription({ className, ...props }: HTMLAttributes<HTMLParagraphElement>) {
|
|
return <p className={cn(className)} {...props} />;
|
|
}
|