fix(striker-ui): add props to control action area visibility in confirm dialog

main
Tsu-ba-me 1 year ago
parent 1b328913d1
commit 6532fe84fe
  1. 66
      striker-ui/components/ConfirmDialog.tsx
  2. 2
      striker-ui/types/ConfirmDialog.d.ts

@ -39,6 +39,8 @@ const ConfirmDialog: ForwardRefExoticComponent<
proceedColour = 'blue',
scrollContent = false,
scrollBoxProps,
showActionArea = true,
showCancel,
showClose,
titleText,
wide,
@ -64,27 +66,9 @@ const ConfirmDialog: ForwardRefExoticComponent<
[contentElement, scrollBoxProps, scrollContent],
);
useImperativeHandle(
ref,
() => ({
setOpen: (open) => dialogRef.current?.setOpen(open),
}),
[],
);
return (
<DialogWithHeader
dialogProps={dialogProps}
header={titleText}
loading={loading}
openInitially={openInitially}
ref={dialogRef}
showClose={showClose}
wide={wide}
>
<FlexBox {...contentContainerProps}>
{bodyElement}
{preActionArea}
const actionArea = useMemo(
() =>
showActionArea && (
<DialogActionArea
cancelProps={{
children: actionCancelText,
@ -105,7 +89,47 @@ const ConfirmDialog: ForwardRefExoticComponent<
},
...proceedButtonProps,
}}
showCancel={showCancel}
/>
),
[
actionCancelText,
actionProceedText,
closeOnProceed,
disableProceed,
loadingAction,
onActionAppend,
onCancelAppend,
onProceedAppend,
proceedButtonProps,
proceedColour,
showActionArea,
showCancel,
],
);
useImperativeHandle(
ref,
() => ({
setOpen: (open) => dialogRef.current?.setOpen(open),
}),
[],
);
return (
<DialogWithHeader
dialogProps={dialogProps}
header={titleText}
loading={loading}
openInitially={openInitially}
ref={dialogRef}
showClose={showClose}
wide={wide}
>
<FlexBox {...contentContainerProps}>
{bodyElement}
{preActionArea}
{actionArea}
</FlexBox>
</DialogWithHeader>
);

@ -17,9 +17,11 @@ type ConfirmDialogOptionalProps = {
proceedColour?: 'blue' | 'red';
scrollContent?: boolean;
scrollBoxProps?: import('@mui/material').BoxProps;
showActionArea?: boolean;
};
type ConfirmDialogProps = Omit<DialogWithHeaderProps, 'header'> &
Pick<DialogActionGroupProps, 'showCancel'> &
ConfirmDialogOptionalProps & {
actionProceedText: string;
titleText: import('react').ReactNode;

Loading…
Cancel
Save