@hybridcore/ui 1.6.5 → 1.6.7

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.
Files changed (34) hide show
  1. package/dist/IconX-C2wmVYSK.js +11 -0
  2. package/dist/components/charts/_common/format.js +55 -0
  3. package/dist/components/charts/_common/utils.js +12 -7
  4. package/dist/components/charts/chart-wrapper/helpers.js +46 -21
  5. package/dist/components/charts/chart-wrapper/logic.js +57 -40
  6. package/dist/components/charts/column-line-mix/logic.js +87 -86
  7. package/dist/components/charts/donut-chart/logic.js +37 -36
  8. package/dist/components/charts/drill-down-treemap/logic.js +123 -123
  9. package/dist/components/charts/drill-down-voronoi-treemap/logic.js +253 -252
  10. package/dist/components/charts/heatmap/logic.js +73 -73
  11. package/dist/components/charts/line/logic.js +201 -103
  12. package/dist/components/charts/logaritmic-scale/logic.js +65 -65
  13. package/dist/components/charts/multiple-value-axes/logic.js +96 -94
  14. package/dist/components/charts/nested-pie/logic.js +43 -42
  15. package/dist/components/charts/packed-circles/logic.js +111 -110
  16. package/dist/components/charts/pie-chart/logic.js +40 -39
  17. package/dist/components/charts/stacked-area-radar/logic.js +68 -67
  18. package/dist/components/charts/stacked-column-chart/logic.js +71 -70
  19. package/dist/components/charts/xy-chart/logic.js +82 -76
  20. package/dist/components/color-picker/index.js +1645 -1602
  21. package/dist/components/color-picker/logic.js +21 -12
  22. package/dist/components/color-picker/styled.js +4 -2
  23. package/dist/components/date-range-picker/index.js +359 -365
  24. package/dist/components/metric-card/helpers.js +12 -5
  25. package/dist/components/metric-card/index.js +58 -54
  26. package/dist/components/metric-card/logic.js +78 -61
  27. package/dist/components/metric-card/styled.js +63 -45
  28. package/dist/components/simple-pivot-table/index.js +129 -54
  29. package/dist/components/simple-pivot-table/logic.js +111 -45
  30. package/dist/components/simple-pivot-table/styled.js +31 -11
  31. package/dist/main.d.ts +125 -8
  32. package/dist/main.js +145 -141
  33. package/dist/{styled-Db1RdcPA.js → styled-SoqbyrkW.js} +116 -89
  34. package/package.json +1 -1
@@ -1,66 +1,141 @@
1
- import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
- import { Typography as r, Divider as p, TableContainer as S, Table as x, TableBody as y, TableRow as u, TableCell as b } from "@mui/material";
3
- import { useSimplePivotTableLogic as P } from "./logic.js";
4
- import { SimplePivotTableRoot as C, SimplePivotTableHeader as F, SimplePivotTableContent as N, SimplePivotTableFooter as j } from "./styled.js";
5
- const z = (n) => {
1
+ import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
+ import { Typography as i, Divider as f, TableContainer as I, Table as R, TableHead as j, TableRow as g, TableCell as r, TableBody as w, Box as D, IconButton as G } from "@mui/material";
3
+ import { useSimplePivotTableLogic as J } from "./logic.js";
4
+ import { SimplePivotTableRoot as M, SimplePivotTableHeader as O, SimplePivotTableContent as V, SimplePivotTableFooter as X, SimplePivotTableScrollHint as q } from "./styled.js";
5
+ import { I as A } from "../../IconX-C2wmVYSK.js";
6
+ const Z = (s) => {
6
7
  const {
7
- title: d,
8
- dimensions: m,
8
+ title: m,
9
+ dimensions: n,
9
10
  values: c,
10
- data: s,
11
- aggregations: h,
12
- formatCell: v,
13
- ownerState: a,
14
- sx: T,
15
- other: g
16
- } = P(n), f = {
17
- title: d,
18
- description: n.description,
19
- dimensions: m,
11
+ data: h,
12
+ summaries: v,
13
+ selectedField: p,
14
+ selectedSummary: d,
15
+ selectColumn: b,
16
+ clearSelection: S,
17
+ dimensionLabel: x,
18
+ valueLabel: T,
19
+ formatDimensionValue: y,
20
+ formatCell: C,
21
+ getCellStyle: F,
22
+ ownerState: o,
23
+ scrollRef: N,
24
+ canScroll: k,
25
+ scrollModifierLabel: P,
26
+ sx: H,
27
+ other: L
28
+ } = J(s), W = {
29
+ title: m,
30
+ description: s.description,
31
+ dimensions: n,
20
32
  values: c,
21
- data: s,
22
- aggregations: h
33
+ data: h,
34
+ summaries: v
23
35
  };
24
- return /* @__PURE__ */ l(
25
- C,
36
+ return /* @__PURE__ */ t(
37
+ M,
26
38
  {
27
- ownerState: a,
28
- sx: T,
29
- "data-snapshot": JSON.stringify(f),
30
- ...g,
39
+ ownerState: o,
40
+ sx: H,
41
+ "data-snapshot": JSON.stringify(W),
42
+ ...L,
31
43
  children: [
32
- /* @__PURE__ */ e(F, { ownerState: a, children: /* @__PURE__ */ e(r, { sx: { paddingLeft: "0.5rem" }, variant: "h3", children: d }) }),
33
- /* @__PURE__ */ e(p, {}),
34
- /* @__PURE__ */ e(N, { ownerState: a, children: /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e(x, { size: "small", children: /* @__PURE__ */ e(y, { children: s.map((i, o) => /* @__PURE__ */ l(
35
- u,
36
- {
37
- hover: !0,
38
- sx: { "&:last-child td": { borderBottom: 0 } },
39
- children: [
40
- m.map((t) => /* @__PURE__ */ e(b, { children: /* @__PURE__ */ e(r, { variant: "body2", children: i[t.value] ?? "—" }) }, t.value)),
41
- c.map((t) => /* @__PURE__ */ e(b, { align: "right", children: /* @__PURE__ */ e(
42
- r,
43
- {
44
- variant: "body2",
45
- fontWeight: 500,
46
- color: "primary.main",
47
- children: v(i[t.dataFieldName])
48
- }
49
- ) }, t.dataFieldName))
50
- ]
51
- },
52
- o
53
- )) }) }) }) }),
54
- /* @__PURE__ */ e(p, {}),
55
- /* @__PURE__ */ e(j, { ownerState: a, children: h.map(({ label: i, value: o }) => /* @__PURE__ */ l(r, { variant: "caption", color: "text.disabled", children: [
56
- i,
57
- ": ",
58
- o
59
- ] }, i)) })
44
+ /* @__PURE__ */ e(O, { ownerState: o, children: /* @__PURE__ */ e(i, { sx: { paddingLeft: "0.5rem" }, variant: "h3", children: m }) }),
45
+ /* @__PURE__ */ e(f, {}),
46
+ /* @__PURE__ */ e(V, { ownerState: o, children: /* @__PURE__ */ e(I, { ref: N, children: /* @__PURE__ */ t(R, { size: "small", stickyHeader: !0, children: [
47
+ /* @__PURE__ */ e(j, { children: /* @__PURE__ */ t(g, { children: [
48
+ n.map((l) => /* @__PURE__ */ e(r, { children: /* @__PURE__ */ e(i, { variant: "caption", fontWeight: 600, children: x(l) }) }, l.value)),
49
+ c.map((l) => /* @__PURE__ */ e(
50
+ r,
51
+ {
52
+ align: "right",
53
+ onClick: () => b(l.dataFieldName),
54
+ sx: {
55
+ cursor: "pointer",
56
+ ...p === l.dataFieldName && {
57
+ backgroundColor: "action.selected"
58
+ }
59
+ },
60
+ children: /* @__PURE__ */ e(i, { variant: "caption", fontWeight: 600, children: T(l) })
61
+ },
62
+ l.dataFieldName
63
+ ))
64
+ ] }) }),
65
+ /* @__PURE__ */ e(w, { children: h.map((l, z) => /* @__PURE__ */ t(
66
+ g,
67
+ {
68
+ hover: !0,
69
+ sx: { "&:last-child td": { borderBottom: 0 } },
70
+ children: [
71
+ n.map((a) => /* @__PURE__ */ e(r, { children: /* @__PURE__ */ e(i, { variant: "body2", children: y(l[a.value], a) }) }, a.value)),
72
+ c.map((a) => {
73
+ const u = F(
74
+ l[a.dataFieldName],
75
+ a.format
76
+ ), B = p === a.dataFieldName;
77
+ return /* @__PURE__ */ e(
78
+ r,
79
+ {
80
+ align: "right",
81
+ onClick: () => b(a.dataFieldName),
82
+ sx: {
83
+ cursor: "pointer",
84
+ // Conditional background wins; otherwise tint the
85
+ // selected column.
86
+ backgroundColor: u.backgroundColor ?? (B ? "action.hover" : void 0)
87
+ },
88
+ children: /* @__PURE__ */ e(
89
+ i,
90
+ {
91
+ variant: "body2",
92
+ fontWeight: 500,
93
+ color: u.color ?? "text.primary",
94
+ children: C(l[a.dataFieldName], a.format)
95
+ }
96
+ )
97
+ },
98
+ a.dataFieldName
99
+ );
100
+ })
101
+ ]
102
+ },
103
+ z
104
+ )) })
105
+ ] }) }) }),
106
+ /* @__PURE__ */ e(f, {}),
107
+ /* @__PURE__ */ t(X, { ownerState: o, children: [
108
+ k && /* @__PURE__ */ e(q, { ownerState: o, children: /* @__PURE__ */ t(i, { variant: "caption", children: [
109
+ "Hold ",
110
+ P,
111
+ " to scroll"
112
+ ] }) }),
113
+ d ? /* @__PURE__ */ t(
114
+ D,
115
+ {
116
+ sx: {
117
+ display: "flex",
118
+ alignItems: "center",
119
+ flexWrap: "wrap",
120
+ columnGap: 1.5,
121
+ rowGap: 0.5
122
+ },
123
+ children: [
124
+ /* @__PURE__ */ e(i, { variant: "caption", fontWeight: 600, children: d.name }),
125
+ d.items.map((l) => /* @__PURE__ */ t(i, { variant: "caption", color: "text.secondary", children: [
126
+ l.label,
127
+ ": ",
128
+ l.value
129
+ ] }, l.label)),
130
+ /* @__PURE__ */ e(G, { size: "small", onClick: S, sx: { p: 0.25 }, children: /* @__PURE__ */ e(A, { size: 14 }) })
131
+ ]
132
+ }
133
+ ) : /* @__PURE__ */ e(i, { variant: "caption", color: "text.disabled", children: "Select a column to summarize" })
134
+ ] })
60
135
  ]
61
136
  }
62
137
  );
63
138
  };
64
139
  export {
65
- z as SimplePivotTable
140
+ Z as SimplePivotTable
66
141
  };
@@ -1,51 +1,117 @@
1
- import { useThemeProps as h } from "@mui/material";
2
- import { useMemo as S } from "react";
3
- const e = new Intl.NumberFormat("en-US", {
4
- maximumFractionDigits: 2
5
- }), w = (s) => {
6
- const l = h({ props: s, name: "HCSimplePivotTable" }), {
7
- title: u,
8
- description: c,
9
- data: a = [],
10
- dimensions: b = [],
11
- values: r = [],
12
- sx: f,
13
- ...p
14
- } = l, g = S(() => {
15
- if (a.length === 0)
16
- return [
17
- { label: "Total", value: e.format(0) },
18
- { label: "Avg", value: e.format(0) },
19
- { label: "Max", value: e.format(0) },
20
- { label: "Min", value: e.format(0) }
21
- ];
22
- const t = a.map(
23
- (n) => r.reduce((m, N) => m + (Number(n[N.dataFieldName]) || 0), 0)
24
- ), o = Math.max(...t, 1), x = Math.min(...t, o), i = t.reduce((n, m) => n + m, 0), M = i / a.length;
25
- return [
26
- { label: "Total", value: e.format(i) },
27
- { label: "Avg", value: e.format(M) },
28
- { label: "Max", value: e.format(o) },
29
- { label: "Min", value: e.format(x) }
1
+ import { useThemeProps as z } from "@mui/material";
2
+ import j from "dayjs";
3
+ import { useRef as A, useState as h, useMemo as M, useEffect as w } from "react";
4
+ import { humanizeLabel as y, formatValue as Y, resolveConditionalStyle as O } from "../charts/_common/format.js";
5
+ const U = (t) => {
6
+ const n = t.toLowerCase();
7
+ return n.includes("year") ? "YYYY" : n.includes("month") ? "MMM YYYY" : n.includes("hour") || n.includes("minute") || n.includes("time") ? "DD MMM YYYY HH:mm" : "DD MMM YYYY";
8
+ }, W = (t) => {
9
+ var n;
10
+ return ((n = t.label) == null ? void 0 : n.trim()) || y(t.value);
11
+ }, g = (t) => {
12
+ var n;
13
+ return ((n = t.label) == null ? void 0 : n.trim()) || y(t.name);
14
+ }, X = (t, n) => {
15
+ if (t == null || t === "") return "—";
16
+ if (n.type !== "date") return String(t);
17
+ const s = j(t);
18
+ return s.isValid() ? s.format(n.dateFormat || U(n.value)) : String(t);
19
+ }, L = (t, n) => {
20
+ const s = t.map((a) => Number(a[n])).filter((a) => Number.isFinite(a));
21
+ if (s.length === 0) return null;
22
+ const f = s.length, i = s.reduce((a, u) => a + u, 0);
23
+ return {
24
+ count: f,
25
+ sum: i,
26
+ avg: i / f,
27
+ min: Math.min(...s),
28
+ max: Math.max(...s)
29
+ };
30
+ }, C = (t) => t.key === "Meta" || t.key === "Control", J = (t) => {
31
+ const n = z({ props: t, name: "HCSimplePivotTable" }), {
32
+ title: s,
33
+ description: f,
34
+ data: i = [],
35
+ dimensions: a = [],
36
+ values: u = [],
37
+ sx: E,
38
+ ...x
39
+ } = n, b = A(null), [D, F] = h(!1), [c, S] = h(null), k = M(() => typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform) ? "⌘" : "Ctrl", []);
40
+ w(() => {
41
+ const e = b.current;
42
+ if (!e) return;
43
+ const o = () => F(e.scrollHeight > e.clientHeight + 1);
44
+ o();
45
+ const l = new ResizeObserver(o);
46
+ return l.observe(e), () => l.disconnect();
47
+ }, [i, a, u]), w(() => {
48
+ const e = b.current;
49
+ if (!e) return;
50
+ const o = () => {
51
+ e.style.overflow = "auto";
52
+ }, l = () => {
53
+ e.style.overflow = "hidden";
54
+ };
55
+ l();
56
+ const m = (r) => {
57
+ C(r) && o();
58
+ }, v = (r) => {
59
+ C(r) && l();
60
+ }, p = (r) => {
61
+ if (!(r.ctrlKey || r.metaKey)) return;
62
+ r.preventDefault(), o();
63
+ const d = r.deltaMode === 1 ? 16 : 1;
64
+ e.scrollTop += r.deltaY * d, e.scrollLeft += r.deltaX * d;
65
+ };
66
+ return window.addEventListener("keydown", m), window.addEventListener("keyup", v), window.addEventListener("blur", l), e.addEventListener("wheel", p, { passive: !1 }), () => {
67
+ window.removeEventListener("keydown", m), window.removeEventListener("keyup", v), window.removeEventListener("blur", l), e.removeEventListener("wheel", p);
68
+ };
69
+ }, []);
70
+ const P = M(
71
+ () => u.map((e) => {
72
+ const o = L(i, e.dataFieldName);
73
+ return o ? { field: e.dataFieldName, name: e.name, ...o } : null;
74
+ }).filter((e) => e !== null),
75
+ [u, i]
76
+ ), H = M(() => {
77
+ var r;
78
+ if (!c) return null;
79
+ const e = u.find((d) => d.dataFieldName === c), o = e ? g(e) : y(c), l = L(i, c);
80
+ if (!l)
81
+ return { field: c, name: o, items: [{ label: "Count", value: String(i.length) }] };
82
+ const m = (d) => Y(d, e == null ? void 0 : e.format), v = !!((r = e == null ? void 0 : e.format) != null && r.suffix) && e.format.suffix.includes("%"), p = [
83
+ { label: "Count", value: String(l.count) },
84
+ ...v ? [] : [{ label: "Sum", value: m(l.sum) }],
85
+ { label: "Avg", value: m(l.avg) },
86
+ { label: "Min", value: m(l.min) },
87
+ { label: "Max", value: m(l.max) }
30
88
  ];
31
- }, [a, r]), v = (t) => {
32
- if (t == null || t === "") return "—";
33
- const o = Number(t);
34
- return Number.isNaN(o) ? String(t) : e.format(o);
35
- }, d = { ...l };
89
+ return { field: c, name: o, items: p };
90
+ }, [c, u, i]), N = (e, o) => Y(e, o), K = (e, o) => O(e, o), T = (e) => S((o) => o === e ? null : e), R = () => S(null), V = { ...n };
36
91
  return {
37
- title: u,
38
- description: c,
39
- dimensions: b,
40
- values: r,
41
- data: a,
42
- aggregations: g,
43
- formatCell: v,
44
- ownerState: d,
45
- sx: f,
46
- other: p
92
+ title: s,
93
+ description: f,
94
+ dimensions: a,
95
+ values: u,
96
+ data: i,
97
+ summaries: P,
98
+ selectedField: c,
99
+ selectedSummary: H,
100
+ selectColumn: T,
101
+ clearSelection: R,
102
+ dimensionLabel: W,
103
+ valueLabel: g,
104
+ formatDimensionValue: X,
105
+ formatCell: N,
106
+ getCellStyle: K,
107
+ ownerState: V,
108
+ scrollRef: b,
109
+ canScroll: D,
110
+ scrollModifierLabel: k,
111
+ sx: E,
112
+ other: x
47
113
  };
48
114
  };
49
115
  export {
50
- w as useSimplePivotTableLogic
116
+ J as useSimplePivotTableLogic
51
117
  };
@@ -1,20 +1,23 @@
1
- import { styled as e, Paper as l, Box as t } from "@mui/material";
2
- const i = e(l, {
1
+ import { styled as e, Paper as a, Box as t, alpha as l } from "@mui/material";
2
+ const n = e(a, {
3
3
  name: "HCSimplePivotTable",
4
4
  slot: "Root",
5
5
  shouldForwardProp: (o) => o !== "ownerState"
6
6
  })(() => ({
7
7
  height: "100%",
8
8
  display: "flex",
9
- flexDirection: "column"
10
- })), n = e(t, {
9
+ flexDirection: "column",
10
+ "&:hover .HCSimplePivotTable-scrollHint": {
11
+ opacity: 1
12
+ }
13
+ })), r = e(t, {
11
14
  name: "HCSimplePivotTable",
12
15
  slot: "Header",
13
16
  shouldForwardProp: (o) => o !== "ownerState"
14
17
  })(({ theme: o }) => ({
15
18
  flex: "0 0 auto",
16
19
  padding: o.spacing(1.25, 2)
17
- })), r = e(t, {
20
+ })), p = e(t, {
18
21
  name: "HCSimplePivotTable",
19
22
  slot: "Content",
20
23
  shouldForwardProp: (o) => o !== "ownerState"
@@ -24,8 +27,24 @@ const i = e(l, {
24
27
  flexDirection: "column",
25
28
  flex: "1 1 auto",
26
29
  minHeight: 0,
27
- overflow: "auto"
28
- })), p = e(t, {
30
+ overflow: "hidden"
31
+ })), d = e(t, {
32
+ name: "HCSimplePivotTable",
33
+ slot: "ScrollHint",
34
+ shouldForwardProp: (o) => o !== "ownerState"
35
+ })(({ theme: o }) => ({
36
+ // Pinned to the left of the footer; aggregations stay grouped on the right.
37
+ marginRight: "auto",
38
+ padding: o.spacing(0.25, 1),
39
+ borderRadius: o.shape.borderRadius,
40
+ border: `1px solid ${o.palette.divider}`,
41
+ backgroundColor: l(o.palette.background.paper, 0.85),
42
+ color: o.palette.text.secondary,
43
+ pointerEvents: "none",
44
+ userSelect: "none",
45
+ opacity: 0.5,
46
+ transition: o.transitions.create("opacity")
47
+ })), s = e(t, {
29
48
  name: "HCSimplePivotTable",
30
49
  slot: "Footer",
31
50
  shouldForwardProp: (o) => o !== "ownerState"
@@ -38,8 +57,9 @@ const i = e(l, {
38
57
  gap: o.spacing(1)
39
58
  }));
40
59
  export {
41
- r as SimplePivotTableContent,
42
- p as SimplePivotTableFooter,
43
- n as SimplePivotTableHeader,
44
- i as SimplePivotTableRoot
60
+ p as SimplePivotTableContent,
61
+ s as SimplePivotTableFooter,
62
+ r as SimplePivotTableHeader,
63
+ n as SimplePivotTableRoot,
64
+ d as SimplePivotTableScrollHint
45
65
  };