UNPKG

@patternfly/react-core

Version:

This library provides a set of common React components for use with the PatternFly reference implementation.

32 lines 1.68 kB
import { __rest } from "tslib"; import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; import { useEffect } from 'react'; import { isWizardParentStep } from './types'; import { useWizardContext } from './WizardContext'; export const WizardStep = (_a) => { var { children, steps: _subSteps } = _a, props = __rest(_a, ["children", "steps"]); const { activeStep, setStep } = useWizardContext(); const { id, name, body, isDisabled, isHidden, navItem, footer, status } = props; const isParentStep = isWizardParentStep(activeStep); // Update step in context when props change or when the step is active has yet to be marked as visited. useEffect(() => { setStep(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ id, 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 }))); }, [ body, footer, id, isDisabled, isHidden, name, navItem, status, isParentStep, setStep, activeStep === null || activeStep === void 0 ? void 0 : activeStep.id, activeStep === null || activeStep === void 0 ? void 0 : activeStep.isVisited ]); return _jsx(_Fragment, { children: children }); }; WizardStep.displayName = 'WizardStep'; //# sourceMappingURL=WizardStep.js.map