import { BoxProps as MuiBoxProps } from '@mui/material'; import { ForwardRefExoticComponent, PropsWithChildren, RefAttributes, forwardRef, useMemo, } from 'react'; import ConfirmDialog from './ConfirmDialog'; import { FlexBoxProps } from './FlexBox'; const FormDialog: ForwardRefExoticComponent< PropsWithChildren & RefAttributes > = forwardRef( (props, ref) => { const { children, contentContainerProps, dialogProps, onSubmitAppend, proceedButtonProps, scrollBoxProps, scrollContent, ...restProps } = props; const formBodyProps = useMemo( () => ({ ...contentContainerProps, component: 'form', onSubmit: (...args) => { const [event] = args; event.preventDefault(); onSubmitAppend?.call(null, ...args); }, }), [contentContainerProps, onSubmitAppend], ); const formScrollBoxProps = useMemo( () => ({ ...scrollBoxProps, sx: scrollContent ? { overflowX: 'hidden', paddingTop: '.6em', ...scrollBoxProps?.sx, } : scrollBoxProps?.sx, }), [scrollBoxProps, scrollContent], ); return ( {children} ); }, ); FormDialog.displayName = 'FormDialog'; export default FormDialog;