diff --git a/frontends/nextjs/src/components/ui/molecules/overlay/Dialog.tsx b/frontends/nextjs/src/components/ui/molecules/overlay/Dialog.tsx index b1ba9106a..6404f85f0 100644 --- a/frontends/nextjs/src/components/ui/molecules/overlay/Dialog.tsx +++ b/frontends/nextjs/src/components/ui/molecules/overlay/Dialog.tsx @@ -1,17 +1,11 @@ 'use client' import { forwardRef, ReactNode } from 'react' -import { - Dialog as MuiDialog, - DialogTitle as MuiDialogTitle, - DialogContent as MuiDialogContent, - DialogActions, - DialogProps as MuiDialogProps, - IconButton, - Typography, - Box, -} from '@mui/material' +import { Dialog as MuiDialog, DialogTitle as MuiDialogTitle, DialogProps as MuiDialogProps, IconButton, Typography, Box } from '@mui/material' import CloseIcon from '@mui/icons-material/Close' +import { DialogContent, type DialogContentProps } from './dialog/Body' +import { DialogFooter, type DialogFooterProps } from './dialog/Footer' +import { DialogHeader, type DialogHeaderProps } from './dialog/Header' export interface DialogProps extends Omit { onOpenChange?: (open: boolean) => void @@ -30,7 +24,7 @@ const Dialog = forwardRef( {children} ) - } + }, ) Dialog.displayName = 'Dialog' @@ -47,7 +41,7 @@ const DialogTrigger = forwardRef( {children} ) - } + }, ) DialogTrigger.displayName = 'DialogTrigger' @@ -83,79 +77,23 @@ const DialogClose = forwardRef( ) - } + }, ) DialogClose.displayName = 'DialogClose' -interface DialogContentProps { - children: ReactNode - className?: string - onClose?: () => void - showCloseButton?: boolean -} - -const DialogContent = forwardRef( - ({ children, showCloseButton = true, onClose, ...props }, ref) => { - return ( - - {showCloseButton && onClose && ( - - - - )} - {children} - - ) - } -) -DialogContent.displayName = 'DialogContent' - -interface DialogHeaderProps { - children: ReactNode - className?: string -} - -const DialogHeader = forwardRef( - ({ children, ...props }, ref) => { - return ( - - {children} - - ) - } -) -DialogHeader.displayName = 'DialogHeader' - -interface DialogFooterProps { - children: ReactNode - className?: string -} - -const DialogFooter = forwardRef( - ({ children, ...props }, ref) => { - return ( - - {children} - - ) - } -) -DialogFooter.displayName = 'DialogFooter' - interface DialogTitleProps { children: ReactNode className?: string } -const DialogTitle = forwardRef( - ({ children, ...props }, ref) => { - return {children} - } -) +const DialogTitle = forwardRef((props, ref) => { + const { children, ...rest } = props + return ( + + {children} + + ) +}) DialogTitle.displayName = 'DialogTitle' interface DialogDescriptionProps { @@ -163,15 +101,14 @@ interface DialogDescriptionProps { className?: string } -const DialogDescription = forwardRef( - ({ children, ...props }, ref) => { - return ( - - {children} - - ) - } -) +const DialogDescription = forwardRef((props, ref) => { + const { children, ...rest } = props + return ( + + {children} + + ) +}) DialogDescription.displayName = 'DialogDescription' export { @@ -186,3 +123,5 @@ export { DialogTitle, DialogTrigger, } + +export type { DialogContentProps, DialogFooterProps, DialogHeaderProps } diff --git a/frontends/nextjs/src/components/ui/molecules/overlay/dialog/Body.tsx b/frontends/nextjs/src/components/ui/molecules/overlay/dialog/Body.tsx new file mode 100644 index 000000000..4110abf26 --- /dev/null +++ b/frontends/nextjs/src/components/ui/molecules/overlay/dialog/Body.tsx @@ -0,0 +1,37 @@ +'use client' + +import { forwardRef, ReactNode } from 'react' +import { DialogContent as MuiDialogContent, IconButton } from '@mui/material' +import CloseIcon from '@mui/icons-material/Close' + +export interface DialogBodyProps { + children: ReactNode + className?: string + onClose?: () => void + showCloseButton?: boolean +} + +const DialogBody = forwardRef( + ({ children, showCloseButton = true, onClose, ...props }, ref) => { + return ( + + {showCloseButton && onClose && ( + + + + )} + {children} + + ) + }, +) +DialogBody.displayName = 'DialogBody' + +export type DialogContentProps = DialogBodyProps +const DialogContent = DialogBody + +export { DialogBody, DialogContent } diff --git a/frontends/nextjs/src/components/ui/molecules/overlay/dialog/Footer.tsx b/frontends/nextjs/src/components/ui/molecules/overlay/dialog/Footer.tsx new file mode 100644 index 000000000..b68366c9b --- /dev/null +++ b/frontends/nextjs/src/components/ui/molecules/overlay/dialog/Footer.tsx @@ -0,0 +1,21 @@ +'use client' + +import { forwardRef, ReactNode } from 'react' +import { DialogActions as MuiDialogActions } from '@mui/material' + +export interface DialogFooterProps { + children: ReactNode + className?: string +} + +const DialogFooter = forwardRef((props, ref) => { + const { children, ...rest } = props + return ( + + {children} + + ) +}) +DialogFooter.displayName = 'DialogFooter' + +export { DialogFooter } diff --git a/frontends/nextjs/src/components/ui/molecules/overlay/dialog/Header.tsx b/frontends/nextjs/src/components/ui/molecules/overlay/dialog/Header.tsx new file mode 100644 index 000000000..36c0f1b75 --- /dev/null +++ b/frontends/nextjs/src/components/ui/molecules/overlay/dialog/Header.tsx @@ -0,0 +1,21 @@ +'use client' + +import { forwardRef, ReactNode } from 'react' +import { Box } from '@mui/material' + +export interface DialogHeaderProps { + children: ReactNode + className?: string +} + +const DialogHeader = forwardRef((props, ref) => { + const { children, ...rest } = props + return ( + + {children} + + ) +}) +DialogHeader.displayName = 'DialogHeader' + +export { DialogHeader }