@hybridcore/ui 1.6.5 → 1.6.6

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 (31) hide show
  1. package/dist/IconX-C2wmVYSK.js +11 -0
  2. package/dist/components/charts/_common/format.js +49 -0
  3. package/dist/components/charts/_common/utils.js +12 -7
  4. package/dist/components/charts/column-line-mix/logic.js +78 -78
  5. package/dist/components/charts/donut-chart/logic.js +37 -36
  6. package/dist/components/charts/drill-down-treemap/logic.js +123 -123
  7. package/dist/components/charts/drill-down-voronoi-treemap/logic.js +253 -252
  8. package/dist/components/charts/heatmap/logic.js +73 -73
  9. package/dist/components/charts/line/logic.js +66 -66
  10. package/dist/components/charts/logaritmic-scale/logic.js +65 -65
  11. package/dist/components/charts/multiple-value-axes/logic.js +75 -74
  12. package/dist/components/charts/nested-pie/logic.js +43 -42
  13. package/dist/components/charts/packed-circles/logic.js +111 -110
  14. package/dist/components/charts/pie-chart/logic.js +40 -39
  15. package/dist/components/charts/stacked-area-radar/logic.js +51 -51
  16. package/dist/components/charts/stacked-column-chart/logic.js +79 -79
  17. package/dist/components/charts/xy-chart/logic.js +71 -71
  18. package/dist/components/color-picker/index.js +1645 -1602
  19. package/dist/components/color-picker/logic.js +21 -12
  20. package/dist/components/color-picker/styled.js +4 -2
  21. package/dist/components/date-range-picker/index.js +359 -365
  22. package/dist/components/metric-card/helpers.js +12 -5
  23. package/dist/components/metric-card/logic.js +65 -57
  24. package/dist/components/metric-card/styled.js +55 -47
  25. package/dist/components/simple-pivot-table/index.js +129 -54
  26. package/dist/components/simple-pivot-table/logic.js +111 -45
  27. package/dist/components/simple-pivot-table/styled.js +31 -11
  28. package/dist/main.d.ts +102 -8
  29. package/dist/main.js +145 -141
  30. package/dist/{styled-Db1RdcPA.js → styled-SoqbyrkW.js} +116 -89
  31. package/package.json +1 -1
@@ -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
  };
package/dist/main.d.ts CHANGED
@@ -84,11 +84,6 @@ export declare namespace AccessUtils {
84
84
 
85
85
  export { AdapterDayjs }
86
86
 
87
- declare interface Aggregation {
88
- label: string;
89
- value: number | string;
90
- }
91
-
92
87
  declare function alert_2(title: string, message: string): Promise<unknown>;
93
88
  export { alert_2 as alert }
94
89
 
@@ -222,6 +217,10 @@ export declare interface CardProps {
222
217
  export declare interface ChartDimension {
223
218
  value: string;
224
219
  type: string;
220
+ /** Display label override; falls back to a humanized `value` when unset. */
221
+ label?: string;
222
+ /** dayjs format for date-typed dimensions; falls back to a grain-based default. */
223
+ dateFormat?: string;
225
224
  }
226
225
 
227
226
  export declare type ChartNameType =
@@ -270,6 +269,10 @@ export declare interface ChartValue {
270
269
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
271
270
  operator: any;
272
271
  dataFieldName: string;
272
+ /** Optional per-value formatting + conditional styling. */
273
+ format?: ValueFormat;
274
+ /** Display label override; falls back to a humanized `name` when unset. */
275
+ label?: string;
273
276
  }
274
277
 
275
278
  export declare const ChartWrapper: (inProps: ChartWrapperProps) => JSX_2.Element;
@@ -314,10 +317,18 @@ export declare type ColorPickerComponentOverride<Theme = unknown> = {
314
317
  export declare interface ColorPickerProps {
315
318
  value: string;
316
319
  swatches?: string[];
320
+ /**
321
+ * "inline" (default) — the legacy swatch row + advanced-picker icon.
322
+ * "popover" — a single swatch/hex trigger button that opens the familiar
323
+ * saturation + hue + hex picker with preset swatches in a popover.
324
+ */
325
+ variant?: ColorPickerVariant;
317
326
  sx?: SxProps<Theme>;
318
327
  onChange(value: string): void;
319
328
  }
320
329
 
330
+ declare type ColorPickerVariant = "inline" | "popover";
331
+
321
332
  export declare const ColumnLineMix: (inProps: ColumnLineMixProps) => JSX_2.Element;
322
333
 
323
334
  export declare type ColumnLineMixComponentOverride<Theme = unknown> = {
@@ -327,6 +338,16 @@ export declare type ColumnLineMixComponentOverride<Theme = unknown> = {
327
338
 
328
339
  export declare type ColumnLineMixProps = ChartProps;
329
340
 
341
+ declare interface ColumnSummary {
342
+ field: string;
343
+ name: string;
344
+ count: number;
345
+ sum: number;
346
+ avg: number;
347
+ min: number;
348
+ max: number;
349
+ }
350
+
330
351
  export declare interface CompositeListRangeProps {
331
352
  value: SIMULATION.RandomInfoComposite;
332
353
  mapboxAccessToken: string;
@@ -336,6 +357,26 @@ export declare interface CompositeListRangeProps {
336
357
  onChange(value: SIMULATION.RandomInfoComposite): void;
337
358
  }
338
359
 
360
+ export declare type ConditionalOp =
361
+ | "lt"
362
+ | "lte"
363
+ | "gt"
364
+ | "gte"
365
+ | "eq"
366
+ | "neq"
367
+ | "between";
368
+
369
+ export declare interface ConditionalRule {
370
+ op: ConditionalOp;
371
+ value: number;
372
+ /** Upper bound, used only when `op` is "between". */
373
+ value2?: number;
374
+ /** Text color applied when the rule matches (theme token path or CSS color). */
375
+ color?: string;
376
+ /** Background color applied when the rule matches. */
377
+ backgroundColor?: string;
378
+ }
379
+
339
380
  export declare const ConditionalWrapper: ({ condition, wrapper, children, }: ConditionalWrapperProps) => JSX_2.Element;
340
381
 
341
382
  declare interface ConditionalWrapperProps {
@@ -645,6 +686,13 @@ export declare const FlexRow: StyledComponent<BoxOwnProps<Theme> & Omit<Omit<Det
645
686
  ref?: ((instance: HTMLDivElement | null) => void | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLDivElement> | null | undefined;
646
687
  }, keyof BoxOwnProps<Theme>> & MUIStyledCommonProps<Theme>, {}, {}>;
647
688
 
689
+ /**
690
+ * Format a raw value for display: numbers get locale grouping + the configured
691
+ * decimals, then the prefix/suffix are wrapped around the result. Non-numeric
692
+ * values are returned as-is; empty values become an em dash.
693
+ */
694
+ export declare const formatValue: (value: unknown, format?: ValueFormat, empty?: string) => string;
695
+
648
696
  export declare const GeometryDraw: ({ mapId, mapboxAccessToken, value: defaultValue, disableActions, variant, defaultExtent, onCancel, onSubmit, onChange, }: GeometryDrawProps) => JSX_2.Element;
649
697
 
650
698
  export declare interface GeometryDrawProps {
@@ -763,6 +811,13 @@ export declare interface HighlightLineChartProps {
763
811
  sx?: SxProps<Theme>;
764
812
  }
765
813
 
814
+ /**
815
+ * Turn a raw field key into a human label: snake_case / kebab-case / camelCase
816
+ * → Title Case (e.g. "total_revenue" / "totalRevenue" → "Total Revenue"). Used
817
+ * as the default display label when no explicit label is set.
818
+ */
819
+ export declare const humanizeLabel: (raw: string) => string;
820
+
766
821
  export declare const IconButton: (props: IconButtonProps) => JSX_2.Element;
767
822
 
768
823
  export declare type IconButtonComponentOverride<Theme = unknown> = {
@@ -1146,9 +1201,15 @@ export declare interface MetricCardProps {
1146
1201
 
1147
1202
  // Rendered verbatim around the formatted number, e.g. valuePrefix "€ " → "€ 1,577",
1148
1203
  // valueSuffix " kg" → "1,577 kg". Include any spacing in the string itself.
1204
+ // Superseded by `format.prefix` / `format.suffix` when those are set.
1149
1205
  valuePrefix?: string;
1150
1206
  valueSuffix?: string;
1151
1207
 
1208
+ // Per-value formatting + conditional coloring (shared with charts/pivot).
1209
+ // `format.prefix`/`format.suffix`/`format.decimals` control the displayed
1210
+ // number; `format.conditionalRules` color the value by threshold.
1211
+ format?: ValueFormat;
1212
+
1152
1213
  showChange?: boolean;
1153
1214
  changeType?: MetricChangeType;
1154
1215
 
@@ -1572,6 +1633,16 @@ export declare type RelativeDatePreset =
1572
1633
 
1573
1634
  export declare const removeNotification: (id: string) => void;
1574
1635
 
1636
+ /**
1637
+ * Resolve the color/background contributed by the first matching conditional
1638
+ * rule. Returns an empty object when the value is non-numeric or nothing
1639
+ * matches, so callers can spread it safely.
1640
+ */
1641
+ export declare const resolveConditionalStyle: (value: unknown, format?: ValueFormat) => {
1642
+ color?: string;
1643
+ backgroundColor?: string;
1644
+ };
1645
+
1575
1646
  export declare const ScrollDrag: (props: ScrollDragProps) => JSX_2.Element;
1576
1647
 
1577
1648
  export declare type ScrollDragComponentOverride<Theme = unknown> = {
@@ -1671,7 +1742,8 @@ export declare interface SimplePivotTableProps {
1671
1742
 
1672
1743
  export declare interface SimplePivotTableSnapshot
1673
1744
  extends Omit<SimplePivotTableProps, "sx"> {
1674
- aggregations: Aggregation[];
1745
+ /** Per-(numeric)-column summary stats — for export/snapshot context. */
1746
+ summaries: ColumnSummary[];
1675
1747
  }
1676
1748
 
1677
1749
  export declare const SortableList: (props: SortableListProps) => JSX_2.Element;
@@ -2091,6 +2163,23 @@ export declare interface UploaderProps {
2091
2163
 
2092
2164
  export declare type UploaderType = "IMAGE" | "VIDEO" | "FILE" | "AUDIO" | "OTHER";
2093
2165
 
2166
+ /**
2167
+ * Per-value display configuration. Numbers are formatted, then wrapped with
2168
+ * `prefix`/`suffix`; the first matching `conditionalRules` entry contributes
2169
+ * the cell/value color. Presentation only — the underlying numeric value is
2170
+ * untouched so aggregation, sorting, and conditional rules keep working.
2171
+ */
2172
+ export declare interface ValueFormat {
2173
+ /** Rendered verbatim before the number, e.g. "$" or "€ ". Include spacing. */
2174
+ prefix?: string;
2175
+ /** Rendered verbatim after the number, e.g. " kg" or "%". Include spacing. */
2176
+ suffix?: string;
2177
+ /** Fixed number of fraction digits; defaults to "up to 2" when unset. */
2178
+ decimals?: number;
2179
+ /** First matching rule wins. */
2180
+ conditionalRules?: ConditionalRule[];
2181
+ }
2182
+
2094
2183
  export declare interface VariableDataType {
2095
2184
  title: string;
2096
2185
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -2551,7 +2640,7 @@ declare module "@mui/material/styles" {
2551
2640
 
2552
2641
  declare module "@mui/material/styles" {
2553
2642
  interface ComponentNameToClassKey {
2554
- HCColorPicker: "root" | "radio" | "pickerWrapper";
2643
+ HCColorPicker: "root" | "radio" | "pickerWrapper" | "trigger" | "swatch";
2555
2644
  }
2556
2645
 
2557
2646
  interface ComponentsPropsList {
@@ -3403,7 +3492,12 @@ declare module "@mui/material/styles" {
3403
3492
 
3404
3493
  declare module "@mui/material/styles" {
3405
3494
  interface ComponentNameToClassKey {
3406
- HCSimplePivotTable: "root" | "header" | "content" | "footer";
3495
+ HCSimplePivotTable:
3496
+ | "root"
3497
+ | "header"
3498
+ | "content"
3499
+ | "footer"
3500
+ | "scrollHint";
3407
3501
  }
3408
3502
 
3409
3503
  interface ComponentsPropsList {