import React, { useRef } from 'react'; import { Dialog as HDialog } from '@headlessui/react'; import { Button } from '@/components/elements/button/index'; import { XIcon } from '@heroicons/react/solid'; import DialogIcon from '@/components/elements/dialog/DialogIcon'; import { AnimatePresence, motion } from 'framer-motion'; import ConfirmationDialog from '@/components/elements/dialog/ConfirmationDialog'; import DialogContext from './context'; import DialogFooter from '@/components/elements/dialog/DialogFooter'; import styles from './style.module.css'; export interface DialogProps { open: boolean; onClose: () => void; } export interface FullDialogProps extends DialogProps { hideCloseIcon?: boolean; title?: string; description?: string | undefined; children?: React.ReactNode; } const Dialog = ({ open, title, description, onClose, hideCloseIcon, children }: FullDialogProps) => { const ref = useRef(null); const icon = useRef(null); const buttons = useRef(null); return ( {open && (
{title && ( {title} )} {description && ( {description} )}
{children}
{/* Keep this below the other buttons so that it isn't the default focus if they're present. */} {!hideCloseIcon && (
)}
)} ); }; const _Dialog = Object.assign(Dialog, { Confirm: ConfirmationDialog, Footer: DialogFooter, Icon: DialogIcon, }); export default _Dialog;