|
|
@ -1,12 +1,20 @@ |
|
|
|
import { Box, Dialog } from '@mui/material'; |
|
|
|
import { Box, Dialog } from '@mui/material'; |
|
|
|
import { forwardRef, useImperativeHandle, useMemo, useState } from 'react'; |
|
|
|
import { forwardRef, useImperativeHandle, useMemo, useState } from 'react'; |
|
|
|
|
|
|
|
|
|
|
|
import { BLUE, TEXT } from '../lib/consts/DEFAULT_THEME'; |
|
|
|
import { BLUE, RED, TEXT } from '../lib/consts/DEFAULT_THEME'; |
|
|
|
|
|
|
|
|
|
|
|
import ContainedButton from './ContainedButton'; |
|
|
|
import ContainedButton from './ContainedButton'; |
|
|
|
import { Panel, PanelHeader } from './Panels'; |
|
|
|
import { Panel, PanelHeader } from './Panels'; |
|
|
|
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 |
|
|
@ -21,6 +29,7 @@ const ConfirmDialog = forwardRef< |
|
|
|
onProceedAppend, |
|
|
|
onProceedAppend, |
|
|
|
openInitially = false, |
|
|
|
openInitially = false, |
|
|
|
proceedButtonProps = {}, |
|
|
|
proceedButtonProps = {}, |
|
|
|
|
|
|
|
proceedColour: proceedColourKey = 'blue', |
|
|
|
titleText, |
|
|
|
titleText, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ref, |
|
|
|
ref, |
|
|
@ -35,6 +44,10 @@ const ConfirmDialog = forwardRef< |
|
|
|
() => (ref ? isOpen : baseOpen), |
|
|
|
() => (ref ? isOpen : baseOpen), |
|
|
|
[baseOpen, isOpen, ref], |
|
|
|
[baseOpen, isOpen, ref], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
const proceedColour = useMemo( |
|
|
|
|
|
|
|
() => MAP_TO_COLOUR[proceedColourKey], |
|
|
|
|
|
|
|
[proceedColourKey], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
useImperativeHandle( |
|
|
|
useImperativeHandle( |
|
|
|
ref, |
|
|
|
ref, |
|
|
@ -80,10 +93,10 @@ const ConfirmDialog = forwardRef< |
|
|
|
</ContainedButton> |
|
|
|
</ContainedButton> |
|
|
|
<ContainedButton |
|
|
|
<ContainedButton |
|
|
|
sx={{ |
|
|
|
sx={{ |
|
|
|
backgroundColor: BLUE, |
|
|
|
backgroundColor: proceedColour, |
|
|
|
color: TEXT, |
|
|
|
color: TEXT, |
|
|
|
|
|
|
|
|
|
|
|
'&:hover': { backgroundColor: `${BLUE}F0` }, |
|
|
|
'&:hover': { backgroundColor: `${proceedColour}F0` }, |
|
|
|
|
|
|
|
|
|
|
|
...proceedButtonSx, |
|
|
|
...proceedButtonSx, |
|
|
|
}} |
|
|
|
}} |
|
|
|