import React, { Fragment, useRef } from 'react'; import { Dialog, Transition } from '@headlessui/react'; import { XIcon } from '@heroicons/react/solid'; import { StepsModalProps } from './types'; export const StepsModal: React.FC = ({ open, onClose, onSave, onNext, onPrevious, children, title = '', useCancelButton = false, isLoading = false, leftActions = <>, showSaveButton = false, showPreviousButton = false, saveButtonDisabled = false, }) => { const cancelButtonRef = useRef(null); const saveButtonRef = useRef(null); const nextButtonRef = useRef(null); const previousButtonRef = useRef(null); return ( {}}>
{/* This element is to trick the browser into centering the modal contents. */}
{isLoading && ( )} {!useCancelButton && (
{title}
)}
{children}
{leftActions}
{showSaveButton && onSave && ( )} {!showSaveButton && ( )} {showPreviousButton && ( )} {useCancelButton && ( )}
); };