UNPKG

@grafana/ui

Version:
37 lines (32 loc) 1.38 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var jsxRuntime = require('react/jsx-runtime'); "use strict"; function fontSizeReductionFactor(fontSize) { if (fontSize < 20) { return 0.9; } if (fontSize < 26) { return 0.8; } return 0.6; } const FormattedValueDisplay = ({ value, className, style, ...htmlProps }) => { var _a, _b; const hasPrefix = ((_a = value.prefix) != null ? _a : "").length > 0; const hasSuffix = ((_b = value.suffix) != null ? _b : "").length > 0; let suffixStyle; if (style && typeof style.fontSize === "number" && !Number.isNaN(style.fontSize)) { const fontSize = style.fontSize; const reductionFactor = fontSizeReductionFactor(fontSize); suffixStyle = { fontSize: fontSize * reductionFactor }; } return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style, ...htmlProps, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [ hasPrefix && /* @__PURE__ */ jsxRuntime.jsx("span", { children: value.prefix }), /* @__PURE__ */ jsxRuntime.jsx("span", { children: value.text }), hasSuffix && /* @__PURE__ */ jsxRuntime.jsx("span", { style: suffixStyle, children: value.suffix }) ] }) }); }; FormattedValueDisplay.displayName = "FormattedDisplayValue"; exports.FormattedValueDisplay = FormattedValueDisplay; //# sourceMappingURL=FormattedValueDisplay.cjs.map