fix(striker-ui): add prop to control show cancel button in dialog actions

main
Tsu-ba-me 1 year ago
parent 753358a13b
commit 1b328913d1
  1. 33
      striker-ui/components/Dialog/DialogActionGroup.tsx
  2. 1
      striker-ui/types/Dialog.d.ts

@ -20,6 +20,7 @@ const DialogActionGroup: FC<DialogActionGroupProps> = (props) => {
onProceed = handleAction,
proceedColour,
proceedProps,
showCancel = true,
// Dependents
cancelChildren = cancelProps?.children,
proceedChildren = proceedProps?.children,
@ -61,26 +62,26 @@ const DialogActionGroup: FC<DialogActionGroupProps> = (props) => {
[closeOnProceed, dialogContext, onProceed, proceedProps?.onClick],
);
const actions = useMemo(
() => (
<ActionGroup
actions={[
{
...cancelProps,
children: cancelChildren,
onClick: cancelHandler,
},
const actions = useMemo(() => {
const acts: ContainedButtonProps[] = [
{
background: proceedColour,
...proceedProps,
children: proceedChildren,
onClick: proceedHandler,
},
]}
loading={loading}
/>
),
[
];
if (showCancel) {
acts.unshift({
...cancelProps,
children: cancelChildren,
onClick: cancelHandler,
});
}
return <ActionGroup actions={acts} loading={loading} />;
}, [
cancelChildren,
cancelHandler,
cancelProps,
@ -89,8 +90,8 @@ const DialogActionGroup: FC<DialogActionGroupProps> = (props) => {
proceedColour,
proceedHandler,
proceedProps,
],
);
showCancel,
]);
return actions;
};

@ -31,6 +31,7 @@ type DialogActionGroupOptionalProps = {
proceedChildren?: ContainedButtonProps['children'];
proceedColour?: ContainedButtonProps['background'];
proceedProps?: Partial<ContainedButtonProps>;
showCancel?: boolean;
};
type DialogActionGroupProps = DialogActionGroupOptionalProps;

Loading…
Cancel
Save