fix(striker-ui): expose paper and proceed button props in ConfirmDialog

main
Tsu-ba-me 2 years ago
parent df24ead7e3
commit 1bba020b55
  1. 26
      striker-ui/components/ConfirmDialog.tsx
  2. 2
      striker-ui/types/ConfirmDialog.d.ts

@ -24,7 +24,11 @@ const ConfirmDialog = forwardRef<
actionCancelText = 'Cancel', actionCancelText = 'Cancel',
actionProceedText, actionProceedText,
content, content,
dialogProps: { open: baseOpen = false, ...restDialogProps } = {}, dialogProps: {
open: baseOpen = false,
PaperProps: paperProps = {},
...restDialogProps
} = {},
onCancelAppend, onCancelAppend,
onProceedAppend, onProceedAppend,
openInitially = false, openInitially = false,
@ -34,7 +38,9 @@ const ConfirmDialog = forwardRef<
}, },
ref, ref,
) => { ) => {
const { sx: proceedButtonSx } = proceedButtonProps; const { sx: paperSx, ...restPaperProps } = paperProps;
const { sx: proceedButtonSx, ...restProceedButtonProps } =
proceedButtonProps;
const [isOpen, setIsOpen] = useState<boolean>(openInitially); const [isOpen, setIsOpen] = useState<boolean>(openInitially);
@ -61,7 +67,10 @@ const ConfirmDialog = forwardRef<
<Dialog <Dialog
open={open} open={open}
PaperComponent={Panel} PaperComponent={Panel}
PaperProps={{ sx: { overflow: 'visible' } }} PaperProps={{
...restPaperProps,
sx: { overflow: 'visible', ...paperSx },
}}
{...restDialogProps} {...restDialogProps}
> >
<PanelHeader> <PanelHeader>
@ -92,6 +101,12 @@ const ConfirmDialog = forwardRef<
{actionCancelText} {actionCancelText}
</ContainedButton> </ContainedButton>
<ContainedButton <ContainedButton
onClick={(...args) => {
setIsOpen(false);
onProceedAppend?.call(null, ...args);
}}
{...restProceedButtonProps}
sx={{ sx={{
backgroundColor: proceedColour, backgroundColor: proceedColour,
color: TEXT, color: TEXT,
@ -100,11 +115,6 @@ const ConfirmDialog = forwardRef<
...proceedButtonSx, ...proceedButtonSx,
}} }}
onClick={(...args) => {
setIsOpen(false);
onProceedAppend?.call(null, ...args);
}}
> >
{actionProceedText} {actionProceedText}
</ContainedButton> </ContainedButton>

@ -1,6 +1,6 @@
type ConfirmDialogOptionalProps = { type ConfirmDialogOptionalProps = {
actionCancelText?: string; actionCancelText?: string;
dialogProps?: import('@mui/material').DialogProps; dialogProps?: Partial<import('@mui/material').DialogProps>;
onProceedAppend?: ContainedButtonProps['onClick']; onProceedAppend?: ContainedButtonProps['onClick'];
onCancelAppend?: ContainedButtonProps['onClick']; onCancelAppend?: ContainedButtonProps['onClick'];
openInitially?: boolean; openInitially?: boolean;

Loading…
Cancel
Save