|
|
@ -1,18 +1,46 @@ |
|
|
|
import { forwardRef, useMemo } from 'react'; |
|
|
|
import { forwardRef, useMemo } from 'react'; |
|
|
|
|
|
|
|
|
|
|
|
import ConfirmDialog from './ConfirmDialog'; |
|
|
|
import ConfirmDialog from './ConfirmDialog'; |
|
|
|
|
|
|
|
import IconButton from './IconButton'; |
|
|
|
|
|
|
|
import { HeaderText } from './Text'; |
|
|
|
|
|
|
|
|
|
|
|
const FormDialog = forwardRef< |
|
|
|
const FormDialog = forwardRef< |
|
|
|
ConfirmDialogForwardedRefContent, |
|
|
|
ConfirmDialogForwardedRefContent, |
|
|
|
ConfirmDialogProps |
|
|
|
ConfirmDialogProps & { showClose?: boolean } |
|
|
|
>((props, ref) => { |
|
|
|
>((props, ref) => { |
|
|
|
const { scrollContent: isScrollContent } = props; |
|
|
|
const { scrollContent, showClose, titleText, ...restProps } = props; |
|
|
|
|
|
|
|
|
|
|
|
const scrollBoxPaddingRight = useMemo( |
|
|
|
const scrollBoxPaddingRight = useMemo( |
|
|
|
() => (isScrollContent ? '.5em' : undefined), |
|
|
|
() => (scrollContent ? '.5em' : undefined), |
|
|
|
[isScrollContent], |
|
|
|
[scrollContent], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const titleElement = useMemo(() => { |
|
|
|
|
|
|
|
const title = |
|
|
|
|
|
|
|
typeof titleText === 'string' ? ( |
|
|
|
|
|
|
|
<HeaderText>{titleText}</HeaderText> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
titleText |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return showClose ? ( |
|
|
|
|
|
|
|
<> |
|
|
|
|
|
|
|
{title} |
|
|
|
|
|
|
|
<IconButton |
|
|
|
|
|
|
|
mapPreset="close" |
|
|
|
|
|
|
|
onClick={() => { |
|
|
|
|
|
|
|
if (ref && 'current' in ref) { |
|
|
|
|
|
|
|
ref.current?.setOpen?.call(null, false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
variant="redcontained" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
title |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, [ref, showClose, titleText]); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<ConfirmDialog |
|
|
|
<ConfirmDialog |
|
|
|
dialogProps={{ |
|
|
|
dialogProps={{ |
|
|
@ -23,12 +51,18 @@ const FormDialog = forwardRef< |
|
|
|
paddingRight: scrollBoxPaddingRight, |
|
|
|
paddingRight: scrollBoxPaddingRight, |
|
|
|
paddingTop: '.3em', |
|
|
|
paddingTop: '.3em', |
|
|
|
}} |
|
|
|
}} |
|
|
|
{...props} |
|
|
|
scrollContent={scrollContent} |
|
|
|
|
|
|
|
titleText={titleElement} |
|
|
|
|
|
|
|
{...restProps} |
|
|
|
ref={ref} |
|
|
|
ref={ref} |
|
|
|
/> |
|
|
|
/> |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FormDialog.defaultProps = { |
|
|
|
|
|
|
|
showClose: false, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
FormDialog.displayName = 'FormDialog'; |
|
|
|
FormDialog.displayName = 'FormDialog'; |
|
|
|
|
|
|
|
|
|
|
|
export default FormDialog; |
|
|
|
export default FormDialog; |
|
|
|