| 1 |
import { __rest } from "tslib"; |
| 2 |
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; |
| 3 |
import { useEffect } from 'react'; |
| 4 |
import { isWizardParentStep } from './types'; |
| 5 |
import { useWizardContext } from './WizardContext'; |
| 6 |
export const WizardStep = (_a) => { |
| 7 |
var { children, steps: _subSteps } = _a, props = __rest(_a, ["children", "steps"]); |
| 8 |
const { activeStep, setStep } = useWizardContext(); |
| 9 |
const { id, name, body, isDisabled, isHidden, navItem, footer, status } = props; |
| 10 |
const isParentStep = isWizardParentStep(activeStep); |
| 11 |
// Update step in context when props change or when the step is active has yet to be marked as visited. |
| 12 |
useEffect(() => { |
| 13 |
setStep(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ id, |
| 14 |
name }, (body && { body })), (isDisabled && { isDisabled })), (isHidden && { isHidden })), (navItem && { navItem })), (footer && { footer })), (status && { status })), (!isParentStep && id === (activeStep === null || activeStep === void 0 ? void 0 : activeStep.id) && !(activeStep === null || activeStep === void 0 ? void 0 : activeStep.isVisited) && { isVisited: true }))); |
| 15 |
}, [ |
| 16 |
body, |
| 17 |
footer, |
| 18 |
id, |
| 19 |
isDisabled, |
| 20 |
isHidden, |
| 21 |
name, |
| 22 |
navItem, |
| 23 |
status, |
| 24 |
isParentStep, |
| 25 |
setStep, |
| 26 |
activeStep === null || activeStep === void 0 ? void 0 : activeStep.id, |
| 27 |
activeStep === null || activeStep === void 0 ? void 0 : activeStep.isVisited |
| 28 |
]); |
| 29 |
return _jsx(_Fragment, { children: children }); |
| 30 |
}; |
| 31 |
WizardStep.displayName = 'WizardStep'; |
| 32 |
//# sourceMappingURL=WizardStep.js.map |