@devgateway/dvz-ui-react 1.9.4 → 1.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,60 +1,92 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import "react";
3
- import h from "react-markdown";
4
- import v from "remark-gfm";
5
- import x from "rehype-raw";
6
- import f from "string-template";
7
- const N = /(\+?\%)[\(]([A-z0-9,.,-]+)\)/gi, F = /(\+?\#)[\(]([A-z0-9,.,-]+)\)/gi, _ = /(\+?\#C)[\(]([A-z0-9,.,-]+)\)/gi, u = (o, e, n, a, r, d) => {
8
- if (!r || !r.formatNumber)
9
- return e;
10
- let t, m = e;
11
- for (; (t = o.exec(e)) !== null; ) {
12
- const l = t[2], c = t[1], g = ((p, y = 2) => r.formatNumber(a ? p / 100 : p, {
13
- maximumFractionDigits: y,
1
+ import { jsx as u } from "react/jsx-runtime";
2
+ import { useRef as E, useLayoutEffect as A } from "react";
3
+ import F from "react-markdown";
4
+ import R from "remark-gfm";
5
+ import T from "rehype-raw";
6
+ import w from "string-template";
7
+ const _ = /(\+?\%)[\(]([A-z0-9,.,-]+)\)/gi, x = /(\+?\#)[\(]([A-z0-9,.,-]+)\)/gi, L = /(\+?\#C)[\(]([A-z0-9,.,-]+)\)/gi, f = 8, h = (r, t, n, i = 0) => r < f ? f - r : t > n - f ? n - f - t - i : 0, y = (r) => {
8
+ if (!r || typeof window > "u")
9
+ return;
10
+ r.style.transform = "";
11
+ const t = r.getBoundingClientRect(), { innerWidth: n, innerHeight: i } = window, e = n < 768 ? 12 : 40, s = h(t.left, t.right, n, e), l = h(t.top, t.bottom, i);
12
+ (s || l) && (r.style.transform = `translate(${Math.round(s)}px, ${Math.round(l)}px)`);
13
+ }, N = 6, M = 60, I = (r = []) => {
14
+ const t = E(null);
15
+ return A(() => {
16
+ const n = t.current;
17
+ if (!n || typeof window > "u" || !window.requestAnimationFrame) {
18
+ y(n);
19
+ return;
20
+ }
21
+ let i = null;
22
+ const e = () => {
23
+ i != null && window.cancelAnimationFrame(i);
24
+ let l = null, o = 0;
25
+ const c = (a) => {
26
+ y(n), o = n.style.transform === l ? o + 1 : 0, l = n.style.transform, i = o >= N || a >= M ? null : window.requestAnimationFrame(() => c(a + 1));
27
+ };
28
+ c(0);
29
+ };
30
+ e();
31
+ const s = typeof ResizeObserver < "u" ? new ResizeObserver(e) : null;
32
+ return s == null || s.observe(n), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
33
+ i != null && window.cancelAnimationFrame(i), s == null || s.disconnect(), window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
34
+ };
35
+ }, r), t;
36
+ }, p = (r, t, n, i, e, s) => {
37
+ if (!e || !e.formatNumber)
38
+ return t;
39
+ let l, o = t;
40
+ for (; (l = r.exec(t)) !== null; ) {
41
+ const c = l[2], a = l[1], g = ((d, v = 2) => e.formatNumber(i ? d / 100 : d, {
42
+ maximumFractionDigits: v,
14
43
  ...n,
15
- signDisplay: c && c.startsWith("+") ? "never" : "auto"
16
- })).apply(void 0, l.split(","));
17
- m = m.replaceAll(t[0], g);
44
+ signDisplay: a && a.startsWith("+") ? "never" : "auto"
45
+ })).apply(void 0, c.split(","));
46
+ o = o.replaceAll(l[0], g);
18
47
  }
19
- return m;
20
- }, A = (o, e, n, a) => {
21
- if (!o || !e)
48
+ return o;
49
+ }, S = (r, t, n, i) => {
50
+ if (!r || !t)
22
51
  return "";
23
- e.field && e[`_${e.field}`] && (e._value = e[`_${e.field}`]), !e.field && e.category && (e.field = e.category);
24
- let r = a ? f(o, e) : f(o, e).replace(/(?:\r\n|\r|\n)/g, "<br>");
25
- return r = u(N, r, { style: "percent" }, !0, n), r = u(F, r, { style: "decimal" }, !1, n), r = u(
26
- _,
27
- r,
52
+ t.field && t[`_${t.field}`] && (t._value = t[`_${t.field}`]), !t.field && t.category && (t.field = t.category);
53
+ let e = i ? w(r, t) : w(r, t).replace(/(?:\r\n|\r|\n)/g, "<br>");
54
+ return e = p(_, e, { style: "percent" }, !0, n), e = p(x, e, { style: "decimal" }, !1, n), e = p(
55
+ L,
56
+ e,
28
57
  { notation: "compact" },
29
58
  !1,
30
59
  n
31
- ), r;
32
- }, D = ({ tooltip: o, d: e, intl: n, tooltipEnableMarkdown: a }) => {
33
- if (!e || !o)
34
- return /* @__PURE__ */ i("div", {});
35
- const r = e.datum || e.point || e, { color: d, data: t } = r || {}, m = e.value || (e.datum ? e.datum.value : null) || (e.point ? e.point.data.y : null);
36
- if (t) {
37
- let l;
38
- t.variables ? l = typeof t.variables[e.id] == "object" ? t.variables[e.id] : t.variables : l = t;
39
- const c = {
40
- field: e.point ? e.point.serieId : e.id || "",
41
- ...l,
42
- value: m
43
- };
44
- t.measureFieldName && t.variables && (c.populationValue = t.variables[t.measureFieldName + "Population"]);
45
- const s = A(o, c, n, a);
46
- return s ? a ? /* @__PURE__ */ i("div", { className: "chart tooltip", children: /* @__PURE__ */ i(
47
- h,
48
- {
49
- children: s,
50
- remarkPlugins: [v],
51
- rehypePlugins: [x]
52
- }
53
- ) }) : /* @__PURE__ */ i("div", { className: "chart tooltip", children: /* @__PURE__ */ i("div", { dangerouslySetInnerHTML: { __html: s } }) }) : /* @__PURE__ */ i("div", {});
54
- } else
55
- return /* @__PURE__ */ i("div", {});
60
+ ), e;
61
+ }, B = ({ tooltip: r, d: t, intl: n, tooltipEnableMarkdown: i }) => {
62
+ let e = "";
63
+ if (t && r) {
64
+ const l = t.datum || t.point || t, { data: o } = l || {};
65
+ if (o) {
66
+ const c = t.value || (t.datum ? t.datum.value : null) || (t.point ? t.point.data.y : null);
67
+ let a;
68
+ o.variables ? a = typeof o.variables[t.id] == "object" ? o.variables[t.id] : o.variables : a = o;
69
+ const m = {
70
+ field: t.point ? t.point.serieId : t.id || "",
71
+ ...a,
72
+ value: c
73
+ };
74
+ o.measureFieldName && o.variables && (m.populationValue = o.variables[o.measureFieldName + "Population"]), e = S(r, m, n, i);
75
+ }
76
+ }
77
+ const s = I([e, i]);
78
+ return e ? i ? /* @__PURE__ */ u("div", { ref: s, className: "chart tooltip", children: /* @__PURE__ */ u(
79
+ F,
80
+ {
81
+ children: e,
82
+ remarkPlugins: [R],
83
+ rehypePlugins: [T]
84
+ }
85
+ ) }) : /* @__PURE__ */ u("div", { ref: s, className: "chart tooltip", children: /* @__PURE__ */ u("div", { dangerouslySetInnerHTML: { __html: e } }) }) : /* @__PURE__ */ u("div", {});
56
86
  };
57
87
  export {
58
- D as default,
59
- A as formatContent
88
+ y as clampTooltipToViewport,
89
+ B as default,
90
+ S as formatContent,
91
+ I as useClampTooltipToViewport
60
92
  };
@@ -1,34 +1,35 @@
1
- import { jsx as m } from "react/jsx-runtime";
1
+ import { jsx as l } from "react/jsx-runtime";
2
2
  import "react";
3
- import h from "react-markdown";
4
- import g from "remark-gfm";
5
- import y from "rehype-raw";
6
- import f from "string-template";
7
- const x = /(\+?\%)[\(]([A-z0-9,.,-]+)\)/gi, F = /(\+?\#)[\(]([A-z0-9,.,-]+)\)/gi, N = /(\+?\#C)[\(]([A-z0-9,.,-]+)\)/gi, p = (o, t, a, n, e, r) => {
8
- let i, s = t;
9
- for (; (i = o.exec(t)) !== null; ) {
10
- const c = i[2], l = i[1], v = ((u, d = 2) => e.formatNumber(n ? u / 100 : u, {
11
- maximumFractionDigits: d,
3
+ import g from "react-markdown";
4
+ import y from "remark-gfm";
5
+ import x from "rehype-raw";
6
+ import v from "string-template";
7
+ import { useClampTooltipToViewport as F } from "../chart/Tooltip.js";
8
+ const N = /(\+?\%)[\(]([A-z0-9,.,-]+)\)/gi, A = /(\+?\#)[\(]([A-z0-9,.,-]+)\)/gi, C = /(\+?\#C)[\(]([A-z0-9,.,-]+)\)/gi, u = (n, t, a, i, e, r) => {
9
+ let s, o = t;
10
+ for (; (s = n.exec(t)) !== null; ) {
11
+ const m = s[2], p = s[1], d = ((f, h = 2) => e.formatNumber(i ? f / 100 : f, {
12
+ maximumFractionDigits: h,
12
13
  ...a,
13
- signDisplay: l && l.startsWith("+") ? "never" : "auto"
14
- })).apply(void 0, c.split(","));
15
- s = s.replaceAll(i[0], v);
14
+ signDisplay: p && p.startsWith("+") ? "never" : "auto"
15
+ })).apply(void 0, m.split(","));
16
+ o = o.replaceAll(s[0], d);
16
17
  }
17
- return s;
18
- }, b = (o, t, a, n) => {
19
- let e = n ? f(o, t) : f(o, t).replace(/(?:\r\n|\r|\n)/g, "<br>");
20
- return e = p(x, e, { style: "percent" }, !0, a), e = p(F, e, { style: "decimal" }, !1, a), e = p(N, e, { notation: "compact" }, !1, a), e;
21
- }, E = ({ tooltip: o, d: t, intl: a, tooltipEnableMarkdown: n }) => {
22
- const { color: e, data: r } = t.datum || t.point || t, i = t.value || (t.datum ? t.datum.value : null) || (t.point ? t.point.data.y : null);
18
+ return o;
19
+ }, T = (n, t, a, i) => {
20
+ let e = i ? v(n, t) : v(n, t).replace(/(?:\r\n|\r|\n)/g, "<br>");
21
+ return e = u(N, e, { style: "percent" }, !0, a), e = u(A, e, { style: "decimal" }, !1, a), e = u(C, e, { notation: "compact" }, !1, a), e;
22
+ }, V = ({ tooltip: n, d: t, intl: a, tooltipEnableMarkdown: i }) => {
23
+ const { color: e, data: r } = t.datum || t.point || t, s = t.value || (t.datum ? t.datum.value : null) || (t.point ? t.point.data.y : null);
24
+ let o = "";
23
25
  if (r) {
24
- const s = r.variables ? r.variables[t.id] || r.variables : r, c = { field: t.point ? t.point.serieId : t.id, ...s, value: i };
25
- r.measureFieldName && (c.populationValue = r.variables[r.measureFieldName + "Population"]);
26
- const l = b(o, c, a, n);
27
- return n ? /* @__PURE__ */ m("div", { className: "chart tooltip", children: /* @__PURE__ */ m(h, { children: l, remarkPlugins: [g], rehypePlugins: [y] }) }) : /* @__PURE__ */ m("div", { className: "chart tooltip", children: /* @__PURE__ */ m("div", { dangerouslySetInnerHTML: { __html: l } }) });
28
- } else
29
- return /* @__PURE__ */ m("div", {});
26
+ const p = r.variables ? r.variables[t.id] || r.variables : r, c = { field: t.point ? t.point.serieId : t.id, ...p, value: s };
27
+ r.measureFieldName && (c.populationValue = r.variables[r.measureFieldName + "Population"]), o = T(n, c, a, i);
28
+ }
29
+ const m = F([o, i]);
30
+ return r ? i ? /* @__PURE__ */ l("div", { ref: m, className: "chart tooltip", children: /* @__PURE__ */ l(g, { children: o, remarkPlugins: [y], rehypePlugins: [x] }) }) : /* @__PURE__ */ l("div", { ref: m, className: "chart tooltip", children: /* @__PURE__ */ l("div", { dangerouslySetInnerHTML: { __html: o } }) }) : /* @__PURE__ */ l("div", {});
30
31
  };
31
32
  export {
32
- E as default,
33
- b as formatContent
33
+ V as default,
34
+ T as formatContent
34
35
  };