UNPKG

@vectara/vectara-ui

Version:

Vectara's design system, codified as a React and Sass component library

45 lines (44 loc) 2.99 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import classNames from "classnames"; import { BiCheck, BiError, BiSolidHand } from "react-icons/bi"; import { VuiIcon } from "../icon/Icon"; import { VuiStep } from "./Step"; const statusToColor = { complete: "success", current: "primary", incomplete: "subdued", warning: "warning", danger: "danger" }; export const VuiSteps = (_a) => { var { steps, className, size = "s", "data-testid": dataTestId } = _a, rest = __rest(_a, ["steps", "className", "size", "data-testid"]); const classes = classNames("vuiSteps", className, { [`vuiSteps--${size}`]: size }); const totalSteps = steps.length; const currentStepIndex = steps.findIndex((step) => step.status === "current"); return (_jsx("div", Object.assign({ className: classes, "data-testid": dataTestId }, rest, { children: _jsx("div", Object.assign({ className: "vuiSteps__container" }, { children: steps.map((step, index) => { var _a, _b, _c; const isFirstStep = index === 0; const isLastStep = index === totalSteps - 1; const stepContainerClasses = classNames("vuiSteps__stepContainer", { "vuiSteps__stepContainer--first": isFirstStep, "vuiSteps__stepContainer--last": isLastStep }); const icon = (_a = step.icon) !== null && _a !== void 0 ? _a : (step.status === "complete" ? (_jsx(BiCheck, {})) : step.status === "danger" ? (_jsx(BiError, {})) : step.status === "warning" ? (_jsx(BiSolidHand, {})) : null); return (_jsxs("div", Object.assign({ className: stepContainerClasses }, { children: [!isLastStep && (_jsx("div", { className: classNames("vuiSteps__connector", { "vuiSteps__connector--complete": index < currentStepIndex }) })), _jsx(VuiStep, { title: step.title, status: step.status, onClick: step.onClick, "data-testid": (_b = step["data-testid"]) !== null && _b !== void 0 ? _b : `${dataTestId}-step-${index}`, stepNode: icon ? (_jsx(VuiIcon, Object.assign({ color: statusToColor[(_c = step.status) !== null && _c !== void 0 ? _c : "incomplete"], size: size === "xs" ? undefined : size }, { children: icon }))) : size === "xs" ? null : (_jsx("span", Object.assign({ className: "vuiStep__numberText" }, { children: index + 1 }))), size: size, subTitle: step.subTitle })] }), index)); }) })) }))); };