From 2cd1c0eb44954a157e9a80e0dce8245090b0e041 Mon Sep 17 00:00:00 2001 From: Alice Gong <105073504+agong-coveo@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:09:16 -0400 Subject: [PATCH] feat(reac, modal-wizard): add renderFinishButton prop (#3890) --- .../components/modalWizard/ModalWizard.tsx | 41 +++++---- .../modalWizard/tests/ModalWizard.spec.tsx | 24 ++++- ...dalWizardWithProvidedFinishButton.demo.tsx | 87 +++++++++++++++++++ .../src/pages/legacy/layout/ModalWizard.tsx | 9 +- 4 files changed, 142 insertions(+), 19 deletions(-) create mode 100644 packages/website/src/examples/legacy/layout/ModalWizard/ModalWizardWithProvidedFinishButton.demo.tsx diff --git a/packages/react/src/components/modalWizard/ModalWizard.tsx b/packages/react/src/components/modalWizard/ModalWizard.tsx index 42e1739b5a..9befeb5d80 100644 --- a/packages/react/src/components/modalWizard/ModalWizard.tsx +++ b/packages/react/src/components/modalWizard/ModalWizard.tsx @@ -1,5 +1,5 @@ import classNames from 'clsx'; -import {ReactNode, FunctionComponent, ReactElement, useState, Children, isValidElement} from 'react'; +import {Children, FunctionComponent, isValidElement, ReactElement, ReactNode, useState} from 'react'; import {useDispatch} from 'react-redux'; import {IDispatch, TooltipPlacement} from '../../utils'; @@ -83,6 +83,10 @@ export interface ModalWizardProps * A callback function that is executed when the user clicks on the cancel button */ onCancel?: () => unknown; + /** + * Finish button to display on the last step + */ + renderFinishButton?: (isValid: boolean, close: () => void) => React.ReactElement; children?: ReactNode; } @@ -104,6 +108,7 @@ export const ModalWizard: FunctionComponent = ({ onNext, onPrevious, onCancel, + renderFinishButton, ...modalProps }) => { const [currentStep, setCurrentStep] = useState(0); @@ -153,21 +158,25 @@ export const ModalWizard: FunctionComponent = ({ }} enabled /> -