UNPKG

@vectara/vectara-ui

Version:

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

30 lines (29 loc) 2.01 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, Fragment as _Fragment } from "react/jsx-runtime"; import { Fragment } from "react"; import classNames from "classnames"; import { VuiFlexContainer } from "../flex/FlexContainer"; import { VuiFlexItem } from "../flex/FlexItem"; import { VuiLink } from "../link/Link"; import { VuiSpacer } from "../spacer/Spacer"; const VuiStat = ({ name, value }) => { return (_jsx(_Fragment, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "start", spacing: "m" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false, className: "vuiStatName" }, { children: _jsx("strong", { children: name }) })), _jsx(VuiFlexItem, Object.assign({ grow: false }, { children: value }))] })) })); }; export const VuiStatList = (_a) => { var { stats, size = "s", className } = _a, rest = __rest(_a, ["stats", "size", "className"]); const classes = classNames(`vuiStatList--size-${size}`, className); return (_jsx("div", Object.assign({ className: classes }, rest, { children: stats.map(({ name, value }, index) => { const renderedValue = name === "url" || (typeof value === "string" && value.indexOf("http") === 0) ? (_jsx(VuiLink, Object.assign({ href: value, target: "_blank" }, { children: value }))) : (value); return (_jsxs(Fragment, { children: [_jsx(VuiStat, { name: name, value: renderedValue }, `${name}:${value}`), index < stats.length - 1 && _jsx(VuiSpacer, { size: size === "s" ? "s" : "xxs" })] }, name)); }) }))); };