UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

43 lines (42 loc) 1.42 kB
"use client"; var _PreviousButton, _NextButton; import React, { useContext } from 'react'; import clsx from 'clsx'; import ButtonRow from "../../Form/ButtonRow/index.js"; import NextButton from "../NextButton/index.js"; import PreviousButton from "../PreviousButton/index.js"; import WizardContext from "../Context/index.js"; import DataContext from "../../DataContext/Context.js"; import withComponentMarkers from "../../../../shared/helpers/withComponentMarkers.js"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; function Buttons(props) { const { className } = props; const { activeIndex, totalStepsRef } = useContext(WizardContext) || {}; const totalSteps = totalStepsRef?.current || 0; const showPreviousButton = activeIndex > 0; const showNextButton = activeIndex < totalSteps - 1; const { prerenderFieldProps } = useContext(DataContext); if (prerenderFieldProps) { return null; } if (!showPreviousButton && !showNextButton) { return null; } return _jsxs(ButtonRow, { className: clsx('dnb-forms-buttons', className), ...props, children: [showPreviousButton && (_PreviousButton || (_PreviousButton = _jsx(PreviousButton, {}))), showNextButton && (_NextButton || (_NextButton = _jsx(NextButton, {})))] }); } withComponentMarkers(Buttons, { _supportsSpacingProps: true }); export default Buttons; //# sourceMappingURL=Buttons.js.map