|
|
@ -10,22 +10,12 @@ import { |
|
|
|
useState, |
|
|
|
useState, |
|
|
|
} from 'react'; |
|
|
|
} from 'react'; |
|
|
|
|
|
|
|
|
|
|
|
import { BLUE, RED, TEXT } from '../lib/consts/DEFAULT_THEME'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import ContainedButton from './ContainedButton'; |
|
|
|
import ContainedButton from './ContainedButton'; |
|
|
|
import FlexBox from './FlexBox'; |
|
|
|
import FlexBox from './FlexBox'; |
|
|
|
import { Panel, PanelHeader } from './Panels'; |
|
|
|
import { Panel, PanelHeader } from './Panels'; |
|
|
|
import Spinner from './Spinner'; |
|
|
|
import Spinner from './Spinner'; |
|
|
|
import { BodyText, HeaderText } from './Text'; |
|
|
|
import { BodyText, HeaderText } from './Text'; |
|
|
|
|
|
|
|
|
|
|
|
const MAP_TO_COLOUR: Record< |
|
|
|
|
|
|
|
Exclude<ConfirmDialogProps['proceedColour'], undefined>, |
|
|
|
|
|
|
|
string |
|
|
|
|
|
|
|
> = { |
|
|
|
|
|
|
|
blue: BLUE, |
|
|
|
|
|
|
|
red: RED, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ConfirmDialog = forwardRef< |
|
|
|
const ConfirmDialog = forwardRef< |
|
|
|
ConfirmDialogForwardedRefContent, |
|
|
|
ConfirmDialogForwardedRefContent, |
|
|
|
ConfirmDialogProps |
|
|
|
ConfirmDialogProps |
|
|
@ -53,7 +43,7 @@ const ConfirmDialog = forwardRef< |
|
|
|
openInitially = false, |
|
|
|
openInitially = false, |
|
|
|
preActionArea, |
|
|
|
preActionArea, |
|
|
|
proceedButtonProps = {}, |
|
|
|
proceedButtonProps = {}, |
|
|
|
proceedColour: proceedColourKey = 'blue', |
|
|
|
proceedColour = 'blue', |
|
|
|
scrollContent: isScrollContent = false, |
|
|
|
scrollContent: isScrollContent = false, |
|
|
|
scrollBoxProps: { sx: scrollBoxSx, ...restScrollBoxProps } = {}, |
|
|
|
scrollBoxProps: { sx: scrollBoxSx, ...restScrollBoxProps } = {}, |
|
|
|
titleText, |
|
|
|
titleText, |
|
|
@ -63,7 +53,6 @@ const ConfirmDialog = forwardRef< |
|
|
|
const { sx: paperSx, ...restPaperProps } = paperProps; |
|
|
|
const { sx: paperSx, ...restPaperProps } = paperProps; |
|
|
|
const { |
|
|
|
const { |
|
|
|
disabled: proceedButtonDisabled = isDisableProceed, |
|
|
|
disabled: proceedButtonDisabled = isDisableProceed, |
|
|
|
sx: proceedButtonSx, |
|
|
|
|
|
|
|
...restProceedButtonProps |
|
|
|
...restProceedButtonProps |
|
|
|
} = proceedButtonProps; |
|
|
|
} = proceedButtonProps; |
|
|
|
|
|
|
|
|
|
|
@ -75,10 +64,6 @@ const ConfirmDialog = forwardRef< |
|
|
|
() => (ref ? isOpen : baseOpen), |
|
|
|
() => (ref ? isOpen : baseOpen), |
|
|
|
[baseOpen, isOpen, ref], |
|
|
|
[baseOpen, isOpen, ref], |
|
|
|
); |
|
|
|
); |
|
|
|
const proceedColour = useMemo( |
|
|
|
|
|
|
|
() => MAP_TO_COLOUR[proceedColourKey], |
|
|
|
|
|
|
|
[proceedColourKey], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
const { |
|
|
|
const { |
|
|
|
contentContainerComponent, |
|
|
|
contentContainerComponent, |
|
|
|
contentContainerSubmitEventHandler, |
|
|
|
contentContainerSubmitEventHandler, |
|
|
@ -146,18 +131,11 @@ const ConfirmDialog = forwardRef< |
|
|
|
const proceedButtonElement = useMemo( |
|
|
|
const proceedButtonElement = useMemo( |
|
|
|
() => ( |
|
|
|
() => ( |
|
|
|
<ContainedButton |
|
|
|
<ContainedButton |
|
|
|
|
|
|
|
background={proceedColour} |
|
|
|
disabled={proceedButtonDisabled} |
|
|
|
disabled={proceedButtonDisabled} |
|
|
|
onClick={proceedButtonClickEventHandler} |
|
|
|
onClick={proceedButtonClickEventHandler} |
|
|
|
type={proceedButtonType} |
|
|
|
type={proceedButtonType} |
|
|
|
{...restProceedButtonProps} |
|
|
|
{...restProceedButtonProps} |
|
|
|
sx={{ |
|
|
|
|
|
|
|
backgroundColor: proceedColour, |
|
|
|
|
|
|
|
color: TEXT, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'&:hover': { backgroundColor: `${proceedColour}F0` }, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
...proceedButtonSx, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
{actionProceedText} |
|
|
|
{actionProceedText} |
|
|
|
</ContainedButton> |
|
|
|
</ContainedButton> |
|
|
@ -166,7 +144,6 @@ const ConfirmDialog = forwardRef< |
|
|
|
actionProceedText, |
|
|
|
actionProceedText, |
|
|
|
proceedButtonClickEventHandler, |
|
|
|
proceedButtonClickEventHandler, |
|
|
|
proceedButtonDisabled, |
|
|
|
proceedButtonDisabled, |
|
|
|
proceedButtonSx, |
|
|
|
|
|
|
|
proceedButtonType, |
|
|
|
proceedButtonType, |
|
|
|
proceedColour, |
|
|
|
proceedColour, |
|
|
|
restProceedButtonProps, |
|
|
|
restProceedButtonProps, |
|
|
|