@nice2dev/ui 1.4.22 → 1.4.24
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.
- package/CHANGELOG.md +96 -0
- package/dist/{NicePivotGrid-BshofJh1.cjs → NicePivotGrid-D53CQ2cY.cjs} +1 -1
- package/dist/charts/NiceAdvancedCharts.mjs +621 -764
- package/dist/charts/NiceBarGauge.mjs +100 -65
- package/dist/charts/NiceBullet.mjs +103 -98
- package/dist/charts/NiceChart.mjs +269 -266
- package/dist/charts/NiceChartRangeSelector.mjs +159 -0
- package/dist/charts/NiceCircularGauge.mjs +99 -70
- package/dist/charts/NiceHeatMap.mjs +140 -70
- package/dist/charts/NiceLinearGauge.mjs +168 -119
- package/dist/charts/NiceOrganizationChart.mjs +183 -90
- package/dist/charts/NicePieChart.mjs +94 -49
- package/dist/charts/NicePolarChart.mjs +2 -2
- package/dist/charts/NiceSankey.mjs +166 -93
- package/dist/charts/NiceStockChart.mjs +258 -157
- package/dist/charts-CSgOgfES.cjs +867 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +150 -104
- package/dist/charts.mjs +22 -24
- package/dist/core/lazy.mjs +50 -63
- package/dist/core-lazy-sO0xvg64.cjs +1 -0
- package/dist/data.cjs +1 -1
- package/dist/demo/docs/docPreviews.mjs +450 -466
- package/dist/demo/docs/docRegistry.mjs +5 -35
- package/dist/index.cjs +60 -67
- package/dist/index.d.ts +145 -174
- package/dist/index.mjs +831 -836
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +49 -23
- package/dist/lazy.mjs +1 -1
- package/dist/style.css +1 -1
- package/dist/tools/NiceShowcase.mjs +1 -2
- package/package.json +4 -4
- package/dist/charts/NiceRangeSelector.mjs +0 -135
- package/dist/charts/NiceTreeMap.mjs +0 -100
- package/dist/charts/NiceVectorMap.mjs +0 -59
- package/dist/charts-C3Q3r8Yz.cjs +0 -918
- package/dist/core-lazy-CUnBYI-T.cjs +0 -1
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { jsx as f, jsxs as Q } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as V } from "@nice2dev/ui-core";
|
|
3
|
+
import { useRef as W, useState as Y, useEffect as Z } from "react";
|
|
4
|
+
const ot = ({
|
|
5
|
+
data: c,
|
|
6
|
+
min: s,
|
|
7
|
+
max: d,
|
|
8
|
+
start: o,
|
|
9
|
+
end: r,
|
|
10
|
+
onChange: g,
|
|
11
|
+
width: U = 500,
|
|
12
|
+
height: R = 100,
|
|
13
|
+
step: p = 1,
|
|
14
|
+
formatValue: k,
|
|
15
|
+
chartColor: y = "var(--nice-color-primary, #3b82f6)",
|
|
16
|
+
responsive: v = !0,
|
|
17
|
+
className: B,
|
|
18
|
+
style: E,
|
|
19
|
+
testId: F,
|
|
20
|
+
"data-testid": G
|
|
21
|
+
}) => {
|
|
22
|
+
const { t: D } = V(), _ = W(null), [$, H] = Y(null);
|
|
23
|
+
Z(() => {
|
|
24
|
+
const t = _.current;
|
|
25
|
+
if (!v || !t || typeof ResizeObserver > "u")
|
|
26
|
+
return;
|
|
27
|
+
const e = new ResizeObserver(([u]) => {
|
|
28
|
+
const i = Math.round(u.contentRect.width);
|
|
29
|
+
i > 0 && H(i);
|
|
30
|
+
});
|
|
31
|
+
return e.observe(t), () => e.disconnect();
|
|
32
|
+
}, [v]);
|
|
33
|
+
const A = v && $ ? $ : U, n = { top: 10, bottom: 30, left: 10, right: 10 }, x = Math.max(10, A - n.left - n.right), a = R - n.top - n.bottom, N = d - s || 1, h = (t) => Math.min(d, Math.max(s, Math.round((t - s) / p) * p + s)), l = (t) => n.left + (t - s) / N * x, M = (t) => k ? k(t) : String(t), S = (t, e) => {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
const i = (e.currentTarget.ownerSVGElement ?? e.currentTarget).getBoundingClientRect(), m = (b) => s + Math.max(0, Math.min(1, (b - i.left - n.left) / x)) * N, q = m(e.clientX), j = o, J = r, z = (b) => {
|
|
36
|
+
const w = m(b.clientX);
|
|
37
|
+
if (t === "start")
|
|
38
|
+
g(Math.min(h(w), r), r);
|
|
39
|
+
else if (t === "end")
|
|
40
|
+
g(o, Math.max(h(w), o));
|
|
41
|
+
else {
|
|
42
|
+
const X = J - j, O = Math.min(d - X, Math.max(s, h(j + (w - q))));
|
|
43
|
+
g(O, O + X);
|
|
44
|
+
}
|
|
45
|
+
}, T = () => {
|
|
46
|
+
document.removeEventListener("pointermove", z), document.removeEventListener("pointerup", T);
|
|
47
|
+
};
|
|
48
|
+
document.addEventListener("pointermove", z), document.addEventListener("pointerup", T);
|
|
49
|
+
}, I = (t) => (e) => {
|
|
50
|
+
const u = p * 10, i = t === "start" ? o : r, m = e.key === "ArrowLeft" || e.key === "ArrowDown" ? i - p : e.key === "ArrowRight" || e.key === "ArrowUp" ? i + p : e.key === "PageDown" ? i - u : e.key === "PageUp" ? i + u : e.key === "Home" ? t === "start" ? s : o : e.key === "End" ? t === "start" ? r : d : null;
|
|
51
|
+
m !== null && (e.preventDefault(), t === "start" ? g(Math.min(h(m), r), r) : g(o, Math.max(h(m), o)));
|
|
52
|
+
}, L = c && c.length ? Math.min(...c) : 0, K = (c && c.length ? Math.max(...c) : 1) - L || 1, P = (t) => {
|
|
53
|
+
const e = t === "start" ? o : r;
|
|
54
|
+
return /* @__PURE__ */ f(
|
|
55
|
+
"rect",
|
|
56
|
+
{
|
|
57
|
+
x: l(e) - 5,
|
|
58
|
+
y: n.top,
|
|
59
|
+
width: 10,
|
|
60
|
+
height: a,
|
|
61
|
+
fill: y,
|
|
62
|
+
rx: 2,
|
|
63
|
+
cursor: "ew-resize",
|
|
64
|
+
className: "nice-rangeselector__handle",
|
|
65
|
+
role: "slider",
|
|
66
|
+
tabIndex: 0,
|
|
67
|
+
"aria-label": t === "start" ? D("chartRangeSelector.start", "Range start") : D("chartRangeSelector.end", "Range end"),
|
|
68
|
+
"aria-valuemin": t === "start" ? s : o,
|
|
69
|
+
"aria-valuemax": t === "start" ? r : d,
|
|
70
|
+
"aria-valuenow": e,
|
|
71
|
+
"aria-valuetext": M(e),
|
|
72
|
+
onPointerDown: (u) => S(t, u),
|
|
73
|
+
onKeyDown: I(t)
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
return /* @__PURE__ */ f(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
ref: _,
|
|
81
|
+
className: `nice-rangeselector ${B || ""}`,
|
|
82
|
+
style: v ? { width: "100%", ...E } : E,
|
|
83
|
+
"data-testid": G ?? F,
|
|
84
|
+
children: /* @__PURE__ */ Q("svg", { width: A, height: R, children: [
|
|
85
|
+
c && c.length > 1 && /* @__PURE__ */ f(
|
|
86
|
+
"polygon",
|
|
87
|
+
{
|
|
88
|
+
points: `${n.left},${n.top + a} ${c.map((t, e) => `${n.left + e / (c.length - 1) * x},${n.top + a - (t - L) / K * a}`).join(" ")} ${n.left + x},${n.top + a}`,
|
|
89
|
+
fill: y,
|
|
90
|
+
opacity: 0.15
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ f(
|
|
94
|
+
"rect",
|
|
95
|
+
{
|
|
96
|
+
x: l(o),
|
|
97
|
+
y: n.top,
|
|
98
|
+
width: Math.max(0, l(r) - l(o)),
|
|
99
|
+
height: a,
|
|
100
|
+
fill: y,
|
|
101
|
+
opacity: 0.12,
|
|
102
|
+
cursor: "grab",
|
|
103
|
+
className: "nice-rangeselector__window",
|
|
104
|
+
onPointerDown: (t) => S("window", t)
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ f(
|
|
108
|
+
"rect",
|
|
109
|
+
{
|
|
110
|
+
x: n.left,
|
|
111
|
+
y: n.top,
|
|
112
|
+
width: Math.max(0, l(o) - n.left),
|
|
113
|
+
height: a,
|
|
114
|
+
fill: "var(--nice-bg-secondary, #f5f5f5)",
|
|
115
|
+
opacity: 0.6,
|
|
116
|
+
pointerEvents: "none"
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
/* @__PURE__ */ f(
|
|
120
|
+
"rect",
|
|
121
|
+
{
|
|
122
|
+
x: l(r),
|
|
123
|
+
y: n.top,
|
|
124
|
+
width: Math.max(0, n.left + x - l(r)),
|
|
125
|
+
height: a,
|
|
126
|
+
fill: "var(--nice-bg-secondary, #f5f5f5)",
|
|
127
|
+
opacity: 0.6,
|
|
128
|
+
pointerEvents: "none"
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
P("start"),
|
|
132
|
+
P("end"),
|
|
133
|
+
/* @__PURE__ */ f(
|
|
134
|
+
"text",
|
|
135
|
+
{
|
|
136
|
+
x: l(o),
|
|
137
|
+
y: n.top + a + 18,
|
|
138
|
+
textAnchor: "middle",
|
|
139
|
+
className: "nice-chart__axis-label",
|
|
140
|
+
children: M(o)
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
/* @__PURE__ */ f(
|
|
144
|
+
"text",
|
|
145
|
+
{
|
|
146
|
+
x: l(r),
|
|
147
|
+
y: n.top + a + 18,
|
|
148
|
+
textAnchor: "middle",
|
|
149
|
+
className: "nice-chart__axis-label",
|
|
150
|
+
children: M(r)
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
] })
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
export {
|
|
158
|
+
ot as NiceChartRangeSelector
|
|
159
|
+
};
|
|
@@ -1,83 +1,112 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
const
|
|
3
|
-
value:
|
|
4
|
-
min:
|
|
5
|
-
max:
|
|
6
|
-
width:
|
|
7
|
-
height:
|
|
8
|
-
startAngle:
|
|
9
|
-
endAngle:
|
|
10
|
-
color:
|
|
11
|
-
trackColor:
|
|
12
|
-
label:
|
|
13
|
-
formatValue:
|
|
14
|
-
ranges:
|
|
1
|
+
import { jsx as c, jsxs as q } from "react/jsx-runtime";
|
|
2
|
+
const J = ({
|
|
3
|
+
value: a,
|
|
4
|
+
min: x = 0,
|
|
5
|
+
max: _ = 100,
|
|
6
|
+
width: s = 200,
|
|
7
|
+
height: i = 200,
|
|
8
|
+
startAngle: r = 225,
|
|
9
|
+
endAngle: h = -45,
|
|
10
|
+
color: A,
|
|
11
|
+
trackColor: C,
|
|
12
|
+
label: m,
|
|
13
|
+
formatValue: y,
|
|
14
|
+
ranges: M,
|
|
15
15
|
className: L,
|
|
16
|
-
style:
|
|
17
|
-
testId:
|
|
18
|
-
"data-testid":
|
|
16
|
+
style: j,
|
|
17
|
+
testId: P,
|
|
18
|
+
"data-testid": R
|
|
19
19
|
}) => {
|
|
20
|
-
const
|
|
21
|
-
x:
|
|
22
|
-
y:
|
|
23
|
-
}),
|
|
24
|
-
const
|
|
25
|
-
return `M${
|
|
26
|
-
},
|
|
27
|
-
let
|
|
28
|
-
if (
|
|
29
|
-
for (const
|
|
30
|
-
if (
|
|
31
|
-
|
|
20
|
+
const w = A || "var(--nice-color-primary, #3b82f6)", o = s / 2, n = i / 2, p = Math.min(o, n), l = Math.max(4, p * 0.12), e = Math.max(8, p - l / 2 - 4), B = Math.max(2.5, e * 0.05), E = Math.max(3, e * 0.08), f = Math.min(40, Math.max(10, e * 0.34)), u = Math.min(18, Math.max(8, e * 0.17)), k = Math.max(0, Math.min(1, (a - x) / (_ - x || 1))), $ = (t) => t * Math.PI / 180, G = (r - h + 360) % 360 || 360, d = (t) => ({
|
|
21
|
+
x: o + e * Math.cos($(t)),
|
|
22
|
+
y: n - e * Math.sin($(t))
|
|
23
|
+
}), b = (t, z) => {
|
|
24
|
+
const N = d(t), S = d(z), I = (t - z + 360) % 360 > 180 ? 1 : 0;
|
|
25
|
+
return `M${N.x},${N.y} A${e},${e} 0 ${I},1 ${S.x},${S.y}`;
|
|
26
|
+
}, v = r - k * G, W = d(v);
|
|
27
|
+
let g = w;
|
|
28
|
+
if (M) {
|
|
29
|
+
for (const t of M)
|
|
30
|
+
if (a >= t.start && a <= t.end) {
|
|
31
|
+
g = t.color;
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
return /* @__PURE__ */
|
|
35
|
+
return /* @__PURE__ */ c(
|
|
36
36
|
"div",
|
|
37
37
|
{
|
|
38
38
|
className: `nice-gauge nice-gauge--circular ${L || ""}`,
|
|
39
|
-
style:
|
|
40
|
-
"data-testid":
|
|
41
|
-
children: /* @__PURE__ */
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
39
|
+
style: j,
|
|
40
|
+
"data-testid": R ?? P,
|
|
41
|
+
children: /* @__PURE__ */ q(
|
|
42
|
+
"svg",
|
|
43
|
+
{
|
|
44
|
+
width: s,
|
|
45
|
+
height: i,
|
|
46
|
+
viewBox: `0 0 ${s} ${i}`,
|
|
47
|
+
style: { maxWidth: "100%", height: "auto" },
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ c(
|
|
50
|
+
"path",
|
|
51
|
+
{
|
|
52
|
+
d: b(r, h),
|
|
53
|
+
fill: "none",
|
|
54
|
+
stroke: C || "var(--nice-border-color, #e2e8f0)",
|
|
55
|
+
strokeWidth: l,
|
|
56
|
+
strokeLinecap: "round"
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
k > 0 && /* @__PURE__ */ c(
|
|
60
|
+
"path",
|
|
61
|
+
{
|
|
62
|
+
d: b(r, v),
|
|
63
|
+
fill: "none",
|
|
64
|
+
stroke: g,
|
|
65
|
+
strokeWidth: l,
|
|
66
|
+
strokeLinecap: "round"
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
/* @__PURE__ */ c(
|
|
70
|
+
"line",
|
|
71
|
+
{
|
|
72
|
+
x1: o,
|
|
73
|
+
y1: n,
|
|
74
|
+
x2: W.x,
|
|
75
|
+
y2: W.y,
|
|
76
|
+
stroke: "var(--nice-text-primary, #333)",
|
|
77
|
+
strokeWidth: B,
|
|
78
|
+
strokeLinecap: "round"
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
/* @__PURE__ */ c("circle", { cx: o, cy: n, r: E, fill: "var(--nice-text-primary, #333)" }),
|
|
82
|
+
/* @__PURE__ */ c(
|
|
83
|
+
"text",
|
|
84
|
+
{
|
|
85
|
+
x: o,
|
|
86
|
+
y: n + e * 0.58,
|
|
87
|
+
textAnchor: "middle",
|
|
88
|
+
className: "nice-gauge__value",
|
|
89
|
+
style: { fontSize: f },
|
|
90
|
+
children: y ? y(a) : a
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
m && /* @__PURE__ */ c(
|
|
94
|
+
"text",
|
|
95
|
+
{
|
|
96
|
+
x: o,
|
|
97
|
+
y: n + e * 0.58 + f * 0.5 + u * 1.1,
|
|
98
|
+
textAnchor: "middle",
|
|
99
|
+
className: "nice-gauge__label",
|
|
100
|
+
style: { fontSize: u },
|
|
101
|
+
children: m
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
)
|
|
78
107
|
}
|
|
79
108
|
);
|
|
80
109
|
};
|
|
81
110
|
export {
|
|
82
|
-
|
|
111
|
+
J as NiceCircularGauge
|
|
83
112
|
};
|
|
@@ -1,79 +1,149 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useControlId as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
parseInt(r.slice(4, 6), 16)
|
|
12
|
-
];
|
|
13
|
-
}, [m, d, h] = s(o), [p, f, u] = s(l), g = Math.round(m + (p - m) * n), b = Math.round(d + (f - d) * n), _ = Math.round(h + (u - h) * n);
|
|
14
|
-
return `rgb(${g},${b},${_})`;
|
|
1
|
+
import { jsxs as o, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useControlId as J } from "@nice2dev/ui-core";
|
|
3
|
+
import { forwardRef as K, useState as Q, useRef as W, useEffect as X, useMemo as Z } from "react";
|
|
4
|
+
const C = [], V = [
|
|
5
|
+
"var(--nice-primary-bg, #e0f2fe)",
|
|
6
|
+
"var(--nice-color-primary-active, #1d4ed8)"
|
|
7
|
+
];
|
|
8
|
+
function z(t, s) {
|
|
9
|
+
const i = Math.max(0, Math.min(1, s));
|
|
10
|
+
return t.length === 3 ? i < 0.5 ? `color-mix(in srgb, ${t[1]} ${Math.round(i * 200)}%, ${t[0]})` : `color-mix(in srgb, ${t[2]} ${Math.round((i - 0.5) * 200)}%, ${t[1]})` : `color-mix(in srgb, ${t[1]} ${Math.round(i * 100)}%, ${t[0]})`;
|
|
15
11
|
}
|
|
16
|
-
const
|
|
17
|
-
/* @__PURE__ */
|
|
12
|
+
const ae = /* @__PURE__ */ Object.assign(
|
|
13
|
+
/* @__PURE__ */ K(
|
|
18
14
|
({
|
|
19
|
-
data:
|
|
20
|
-
xLabels:
|
|
21
|
-
yLabels:
|
|
22
|
-
colors:
|
|
23
|
-
onCellClick:
|
|
24
|
-
cellSize:
|
|
25
|
-
showValues:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
data: t = C,
|
|
16
|
+
xLabels: s,
|
|
17
|
+
yLabels: i,
|
|
18
|
+
colors: v = V,
|
|
19
|
+
onCellClick: u,
|
|
20
|
+
cellSize: p = 32,
|
|
21
|
+
showValues: g = !1,
|
|
22
|
+
showLegend: A = !0,
|
|
23
|
+
showTooltip: F = !0,
|
|
24
|
+
responsive: H = !0,
|
|
25
|
+
min: $,
|
|
26
|
+
max: N,
|
|
27
|
+
cellGap: R = 2,
|
|
28
|
+
cellRadius: k = 3,
|
|
29
|
+
emptyColor: I = "var(--nice-bg-tertiary, #f1f5f9)",
|
|
30
|
+
formatValue: b,
|
|
31
|
+
xAxisLabel: x,
|
|
32
|
+
yAxisLabel: M,
|
|
33
|
+
className: D,
|
|
34
|
+
style: O,
|
|
35
|
+
id: P,
|
|
36
|
+
testId: S,
|
|
37
|
+
"data-testid": U
|
|
38
|
+
}, Y) => {
|
|
39
|
+
const q = J(P), [l, w] = Q(null), y = W(null);
|
|
40
|
+
X(() => {
|
|
41
|
+
const e = y.current;
|
|
42
|
+
if (!e)
|
|
43
|
+
return;
|
|
44
|
+
const n = (a) => {
|
|
45
|
+
const r = a.target.closest("[data-cell]");
|
|
46
|
+
r && w({ r: Number(r.dataset.r), c: Number(r.dataset.c) });
|
|
47
|
+
}, d = () => w(null);
|
|
48
|
+
return e.addEventListener("mouseover", n), e.addEventListener("focusin", n), e.addEventListener("mouseleave", d), () => {
|
|
49
|
+
e.removeEventListener("mouseover", n), e.removeEventListener("focusin", n), e.removeEventListener("mouseleave", d);
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
const m = (e) => b ? b(e) : String(e), { lo: h, hi: _ } = Z(() => {
|
|
53
|
+
let e = 1 / 0, n = -1 / 0;
|
|
54
|
+
for (const d of t)
|
|
55
|
+
for (const a of d)
|
|
56
|
+
a == null || !Number.isFinite(a) || (e = Math.min(e, a), n = Math.max(n, a));
|
|
57
|
+
return { lo: $ ?? (Number.isFinite(e) ? e : 0), hi: N ?? (Number.isFinite(n) ? n : 1) };
|
|
58
|
+
}, [t, $, N]), B = (e) => _ === h ? 0.5 : (e - h) / (_ - h), f = t.reduce((e, n) => Math.max(e, n.length), 0), G = H ? `minmax(${p}px, 1fr)` : `${p}px`, E = l ? t[l.r]?.[l.c] ?? null : null;
|
|
59
|
+
return /* @__PURE__ */ o(
|
|
43
60
|
"div",
|
|
44
61
|
{
|
|
45
|
-
ref:
|
|
46
|
-
id:
|
|
47
|
-
className: `nice-heatmap ${
|
|
48
|
-
style:
|
|
49
|
-
"data-testid":
|
|
50
|
-
children:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
n && /* @__PURE__ */ c("th", { className: "nice-heatmap__row-label", children: n[t] }),
|
|
57
|
-
e.map((a, i) => /* @__PURE__ */ c(
|
|
58
|
-
"td",
|
|
62
|
+
ref: Y,
|
|
63
|
+
id: q,
|
|
64
|
+
className: `nice-heatmap ${D || ""}`,
|
|
65
|
+
style: O,
|
|
66
|
+
"data-testid": U ?? S,
|
|
67
|
+
children: [
|
|
68
|
+
x && /* @__PURE__ */ c("div", { className: "nice-heatmap__axis nice-heatmap__axis--x", children: x }),
|
|
69
|
+
/* @__PURE__ */ o("div", { className: "nice-heatmap__body", children: [
|
|
70
|
+
M && /* @__PURE__ */ c("div", { className: "nice-heatmap__axis nice-heatmap__axis--y", children: M }),
|
|
71
|
+
/* @__PURE__ */ o(
|
|
72
|
+
"div",
|
|
59
73
|
{
|
|
60
|
-
|
|
74
|
+
ref: y,
|
|
75
|
+
className: "nice-heatmap__grid",
|
|
76
|
+
role: "table",
|
|
61
77
|
style: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
height: d,
|
|
65
|
-
textAlign: "center",
|
|
66
|
-
color: y(a) > 0.6 ? "var(--nice-color-white, #fff)" : "var(--nice-text-primary, #333)",
|
|
67
|
-
cursor: m ? "pointer" : void 0
|
|
78
|
+
gridTemplateColumns: `${i ? "auto " : ""}repeat(${f}, ${G})`,
|
|
79
|
+
gap: R
|
|
68
80
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
children: [
|
|
82
|
+
s && /* @__PURE__ */ o("div", { role: "row", className: "nice-heatmap__row nice-heatmap__row--header", children: [
|
|
83
|
+
i && /* @__PURE__ */ c("span", {}),
|
|
84
|
+
Array.from({ length: f }, (e, n) => /* @__PURE__ */ c("span", { role: "columnheader", className: "nice-heatmap__header", children: s[n] ?? "" }, n))
|
|
85
|
+
] }),
|
|
86
|
+
t.map((e, n) => /* @__PURE__ */ o("div", { role: "row", className: "nice-heatmap__row", children: [
|
|
87
|
+
i && /* @__PURE__ */ c("span", { role: "rowheader", className: "nice-heatmap__row-label", children: i[n] ?? "" }),
|
|
88
|
+
Array.from({ length: f }, (d, a) => {
|
|
89
|
+
const r = e[a] ?? null, T = r == null ? 0 : B(r), j = `${i?.[n] ?? `#${n + 1}`} × ${s?.[a] ?? `#${a + 1}`}: ${r == null ? "—" : m(r)}`;
|
|
90
|
+
return /* @__PURE__ */ c(
|
|
91
|
+
"span",
|
|
92
|
+
{
|
|
93
|
+
role: "cell",
|
|
94
|
+
"data-cell": "",
|
|
95
|
+
"data-r": n,
|
|
96
|
+
"data-c": a,
|
|
97
|
+
"aria-label": u ? void 0 : j,
|
|
98
|
+
className: `nice-heatmap__cell${l?.r === n && l?.c === a ? " nice-heatmap__cell--hover" : ""}`,
|
|
99
|
+
style: {
|
|
100
|
+
minHeight: p,
|
|
101
|
+
borderRadius: k,
|
|
102
|
+
background: r == null ? I : z(v, T),
|
|
103
|
+
color: T > 0.6 ? "var(--nice-color-white, #fff)" : "var(--nice-text-primary, #333)"
|
|
104
|
+
},
|
|
105
|
+
children: u ? /* @__PURE__ */ c(
|
|
106
|
+
"button",
|
|
107
|
+
{
|
|
108
|
+
type: "button",
|
|
109
|
+
className: "nice-heatmap__cell-btn",
|
|
110
|
+
"aria-label": j,
|
|
111
|
+
onClick: () => u(n, a, r),
|
|
112
|
+
children: g && r != null ? m(r) : ""
|
|
113
|
+
}
|
|
114
|
+
) : g && r != null ? m(r) : ""
|
|
115
|
+
},
|
|
116
|
+
a
|
|
117
|
+
);
|
|
118
|
+
})
|
|
119
|
+
] }, n))
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
] }),
|
|
124
|
+
F && l && /* @__PURE__ */ o("div", { className: "nice-heatmap__tooltip", role: "status", children: [
|
|
125
|
+
/* @__PURE__ */ o("strong", { children: [
|
|
126
|
+
i?.[l.r] ?? `#${l.r + 1}`,
|
|
127
|
+
" ×",
|
|
128
|
+
" ",
|
|
129
|
+
s?.[l.c] ?? `#${l.c + 1}`
|
|
130
|
+
] }),
|
|
131
|
+
/* @__PURE__ */ c("span", { children: E == null ? "—" : m(E) })
|
|
132
|
+
] }),
|
|
133
|
+
A && /* @__PURE__ */ o("div", { className: "nice-heatmap__legend", "aria-hidden": "true", children: [
|
|
134
|
+
/* @__PURE__ */ c("span", { children: m(h) }),
|
|
135
|
+
/* @__PURE__ */ c(
|
|
136
|
+
"span",
|
|
137
|
+
{
|
|
138
|
+
className: "nice-heatmap__legend-bar",
|
|
139
|
+
style: {
|
|
140
|
+
background: `linear-gradient(90deg, ${v.join(", ")})`
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ c("span", { children: m(_) })
|
|
145
|
+
] })
|
|
146
|
+
]
|
|
77
147
|
}
|
|
78
148
|
);
|
|
79
149
|
}
|
|
@@ -81,5 +151,5 @@ const H = /* @__PURE__ */ Object.assign(
|
|
|
81
151
|
{ displayName: "NiceHeatMap" }
|
|
82
152
|
);
|
|
83
153
|
export {
|
|
84
|
-
|
|
154
|
+
ae as NiceHeatMap
|
|
85
155
|
};
|