UNPKG

@gooddata/react-components

Version:

GoodData.UI - A powerful JavaScript library for building analytical applications

30 lines 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // (C) 2020 GoodData Corporation var React = require("react"); var classnames_1 = require("classnames"); var numberJS = require("@gooddata/numberjs"); var stripColors = numberJS.stripColors, numberFormat = numberJS.numberFormat, colors2Object = numberJS.colors2Object; exports.Label = function (_a) { var value = _a.value, style = _a.style, className = _a.className; return (React.createElement("div", { className: classnames_1.default("gd-measure-format-preview-formatted", className) }, React.createElement("span", { style: style }, value))); }; exports.FormattedPreview = function (_a) { var previewNumber = _a.previewNumber, format = _a.format, colors = _a.colors, separators = _a.separators, customClassName = _a.className; if (format === "") { return React.createElement(exports.Label, null); } var preview = previewNumber !== null ? previewNumber : ""; if (!colors) { var label_1 = numberFormat(preview, stripColors(format), undefined, separators); return React.createElement(exports.Label, { value: label_1, className: customClassName }); } var _b = colors2Object(numberFormat(preview, format, undefined, separators)), label = _b.label, _c = _b.color, color = _c === void 0 ? "" : _c, _d = _b.backgroundColor, backgroundColor = _d === void 0 ? "" : _d; var style = { color: color, backgroundColor: backgroundColor }; return React.createElement(exports.Label, { value: label, className: customClassName, style: style }); }; exports.FormattedPreview.defaultProps = { colors: true, }; //# sourceMappingURL=FormattedPreview.js.map