UNPKG

@devgateway/dvz-ui-react

Version:

A modular, embeddable React component library for data visualization and UI, built with TypeScript. Provides reusable components for charts, maps, dashboards, and more, with built-in support for internationalization and Redux integration.

29 lines (28 loc) 1.07 kB
import { jsx as m } from "react/jsx-runtime"; import "react"; import g from "string-template"; const x = /(\+?\%)[\(]([A-z0-9,.,-]+)\)/gi, d = /(\+?\#)[\(]([A-z0-9,.,-]+)\)/gi, y = /(\+?\#C)[\(]([A-z0-9,.,-]+)\)/gi, a = (o, e, r, t, l, h) => { let n, s = e; for (; (n = o.exec(e)) !== null; ) { const p = n[2], c = n[1], u = ((i, f = 2) => l.formatNumber(t ? i / 100 : i, { maximumFractionDigits: f, ...r, signDisplay: c && c.startsWith("+") ? "never" : "auto" })).apply(void 0, p.split(",")); s = s.replaceAll(n[0], u); } return s; }, A = (o, e, r) => { let t = g(o, { ...e, ...e.meta }).replace(/(?:\r\n|\r|\n)/g, "<br>"); return t = a(x, t, { style: "percent" }, !0, r), t = a(d, t, { style: "decimal" }, !1, r), t = a(y, t, { notation: "compact" }, !1, r), t; }, C = ({ tooltip: o, data: e, intl: r }) => { if (e) { const t = A(o, e, r); return /* @__PURE__ */ m("div", { dangerouslySetInnerHTML: { __html: t } }); } else return /* @__PURE__ */ m("div", {}); }; export { C as default, A as formatContent };