import * as React from "react"; import styles from "./BaseDialog.module.scss"; import { IconButton } from "../IconButton/IconButton"; import { useOnClickOutside, useOnKeyDown } from "../hooks"; import { TbX } from "react-icons/tb"; import { FocusTrap } from "../FocusTrap/FocusTrap"; import { Separator } from "../Separator/Separator"; import classNames from "classnames"; import { Typography } from "../Typography/Typography"; export type BaseDialogVariant = | "bottom" | "center" | "left" | "right"; export interface BaseDialogProps extends React.ComponentPropsWithoutRef<"div"> { /** * The accessible label for the Dialog */ ariaLabel?: string; /** * The buttons for the Dialog */ buttons?: React.ReactNode; /** * The content for the Dialog */ content: string; /** * The callback fired when the Dialog closes */ onClose: () => void; /** * The title for the Dialog */ title: string; /** * The variant of the Dialog */ variant?: BaseDialogVariant; } /** * @private */ export const BaseDialog: React.FC = (props) => { const { ariaLabel, buttons, className, content, onClose, title, variant, ...rest } = props; const dialogRef = React.useRef(null); useOnClickOutside(dialogRef, onClose); useOnKeyDown(["Escape"], onClose); return (
{title} } onClick={onClose} />
{(variant === "left" || variant === "right") && ( )} {content} {buttons && (
{buttons}
)}
); }; BaseDialog.displayName = "BaseDialog";