@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
77 lines (76 loc) • 2.31 kB
JavaScript
;
"use client";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DisplaySteps = DisplaySteps;
var _react = require("react");
var _index = _interopRequireDefault(require("../Context/index.js"));
var _StepIndicator = _interopRequireDefault(require("../../../../components/StepIndicator.js"));
var _index2 = require("../../hooks/index.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function DisplaySteps({
mode,
noAnimation,
handleChange,
expandedInitially,
outset
}) {
var _getStepIndicatorStat;
const [, forceUpdate] = (0, _react.useReducer)(() => ({}), {});
const {
activeIndexRef,
stepsRef,
updateTitlesRef,
hasErrorInOtherStepRef,
hasInvalidStepsState
} = (0, _react.useContext)(_index.default) || {};
updateTitlesRef.current = () => {
forceUpdate();
};
const translations = (0, _index2.useTranslation)();
const getStepIndicatorStatus = (0, _react.useCallback)(() => {
if (!hasErrorInOtherStepRef.current) {
return undefined;
}
if (hasInvalidStepsState(undefined, ['error'])) {
return {
status: translations.Step.stepHasError,
statusState: 'error'
};
}
return {};
}, [hasErrorInOtherStepRef, hasInvalidStepsState, translations.Step.stepHasError]);
const {
status,
statusState
} = (_getStepIndicatorStat = getStepIndicatorStatus()) !== null && _getStepIndicatorStat !== void 0 ? _getStepIndicatorStat : {};
return (0, _jsxRuntime.jsx)("div", {
className: "dnb-forms-wizard-layout__indicator",
children: (0, _jsxRuntime.jsx)(_StepIndicator.default, {
bottom: true,
currentStep: activeIndexRef.current,
data: Array.from(stepsRef.current.values()).map(({
stringifiedTitle,
title,
inactive,
status,
statusState
}) => ({
title: stringifiedTitle || title,
inactive,
status,
statusState: statusState
})),
mode: mode,
noAnimation: noAnimation,
expandedInitially: expandedInitially,
onChange: handleChange,
outset: outset,
status: status,
statusState: statusState
})
});
}
//# sourceMappingURL=DisplaySteps.js.map