UNPKG

@netdata/charts

Version:

Netdata frontend SDK and chart utilities

50 lines (49 loc) 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _netdataUi = require("@netdata/netdata-ui"); var _provider = require("../../provider"); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } var getDisplayUnit = function getDisplayUnit(unit, integrated) { return integrated && typeof unit === "string" && unit.endsWith("/s") ? unit.slice(0, -2) : unit; }; var StatValue = function StatValue(_ref) { var value = _ref.value, valueKey = _ref.valueKey, prominent = _ref.prominent, justifyContent = _ref.justifyContent; var _useValueWithUnit = (0, _provider.useValueWithUnit)(value, { valueKey: valueKey, scaleByValue: true }), convertedValue = _useValueWithUnit.convertedValue, convertedUnit = _useValueWithUnit.convertedUnit; var displayUnit = getDisplayUnit(convertedUnit, valueKey === "volume"); var Value = prominent ? _netdataUi.Text : _netdataUi.TextSmall; return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_netdataUi.Flex, { alignItems: "end", gap: 1, justifyContent: justifyContent, width: { min: "0px" }, "data-testid": "comparison-stat-value", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Value, { strong: true, textAlign: justifyContent === "end" ? "right" : undefined, whiteSpace: "nowrap", children: convertedValue }), !!displayUnit && /*#__PURE__*/(0, _jsxRuntime.jsx)(_netdataUi.TextMicro, { color: "textDescription", whiteSpace: "nowrap", truncate: true, "data-testid": "comparison-stat-unit", children: displayUnit })] }); }; var _default = exports["default"] = StatValue;