impact-nova 3.0.0-alpha.20 → 3.0.0-alpha.23
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/dist/components/data/ag-grid-react/cell-renderers/editors/select-cell-editor.js +32 -31
- package/dist/components/data-display/chart/chart-heatmap-layout.d.ts +31 -0
- package/dist/components/data-display/chart/chart-heatmap-layout.js +72 -0
- package/dist/components/data-display/chart/chart.category-cluster-heatmap.stories-data.d.ts +1 -1
- package/dist/components/data-display/chart/chart.js +165 -150
- package/dist/components/data-display/chart/chart.types.d.ts +17 -0
- package/dist/components/data-display/heatmap-grid/heatmap-grid-play.d.ts +9 -0
- package/dist/components/data-display/heatmap-grid/heatmap-grid.d.ts +32 -0
- package/dist/components/data-display/heatmap-grid/heatmap-grid.js +93 -0
- package/dist/components/data-display/heatmap-grid/heatmap-grid.layout.d.ts +46 -0
- package/dist/components/data-display/heatmap-grid/heatmap-grid.layout.js +80 -0
- package/dist/components/data-display/heatmap-grid/heatmap-grid.types.d.ts +54 -0
- package/dist/components/data-display/heatmap-grid/heatmap-grid.variants.d.ts +18 -0
- package/dist/components/data-display/heatmap-grid/heatmap-grid.variants.js +80 -0
- package/dist/components/data-display/heatmap-grid/index.d.ts +3 -0
- package/dist/components/data-display/heatmap-grid/index.js +14 -0
- package/dist/components/data-display/heatmap-grid/internals/heatmap-grid-cell.d.ts +14 -0
- package/dist/components/data-display/heatmap-grid/internals/heatmap-grid-cell.js +39 -0
- package/dist/components/data-display/heatmap-grid/internals/heatmap-grid-context.d.ts +29 -0
- package/dist/components/data-display/heatmap-grid/internals/heatmap-grid-context.js +33 -0
- package/dist/components/data-display/heatmap-grid/internals/heatmap-grid-tooltip.d.ts +4 -0
- package/dist/components/data-display/heatmap-grid/internals/heatmap-grid-tooltip.js +49 -0
- package/dist/components/data-display/heatmap-grid/internals/heatmap-grid-viewport.d.ts +3 -0
- package/dist/components/data-display/heatmap-grid/internals/heatmap-grid-viewport.js +173 -0
- package/dist/components/data-display/heatmap-grid/internals/use-heatmap-grid-viewport.d.ts +12 -0
- package/dist/components/data-display/heatmap-grid/internals/use-heatmap-grid-viewport.js +161 -0
- package/dist/components/data-display/hex-tilemap/hex-tilemap.js +35 -33
- package/dist/components/data-display/hex-tilemap/hex-tilemap.types.d.ts +2 -0
- package/dist/components/data-display/hex-tilemap/internals/hex-camera.js +30 -28
- package/dist/components/data-display/hex-tilemap/internals/hex-tilemap-context.d.ts +1 -0
- package/dist/components/data-display/hex-tilemap/internals/hex-tilemap-viewport.js +36 -34
- package/dist/components/data-display/hex-tilemap/internals/use-hex-camera.d.ts +2 -1
- package/dist/components/data-display/hex-tilemap/internals/use-hex-camera.js +87 -84
- package/dist/components/flows/iris-chat/iris-chat-chrome.js +203 -185
- package/dist/i18n/defaultMessages.d.ts +6 -0
- package/dist/i18n/defaultMessages.js +16 -11
- package/dist/i18n/locales/de.js +5 -0
- package/dist/i18n/locales/es.js +5 -0
- package/dist/i18n/locales/hi.js +5 -0
- package/dist/i18n/locales/kn.js +5 -0
- package/dist/impact-nova.css +1 -1
- package/dist/lib/primitives/use-field-chrome.js +22 -22
- package/dist/llms/rules/installation.js +1 -1
- package/dist/llms/rules/requirements.js +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { OverflowTooltip as m } from "../../../feedback/tooltip/overflow-tooltip.js";
|
|
3
|
+
import { useComposedRefs as z } from "../../../../lib/compose-refs.js";
|
|
4
|
+
import { createComponent as L } from "../../../../lib/primitives/create-component.js";
|
|
5
|
+
import { cn as h } from "../../../../lib/utils.js";
|
|
6
|
+
import { HEATMAP_GRID_HORIZONTAL_LABEL_MIN_COLUMN_PX as G, readHeatmapGridColumnLabelMaxWidthPx as S } from "../heatmap-grid.layout.js";
|
|
7
|
+
import { heatmapGridRowHeaderVariants as R, heatmapGridFetchingRowVariants as V, heatmapGridColumnLabelVariants as M, heatmapGridColumnHeaderVariants as W, heatmapGridColumnHeaderRowVariants as A, heatmapGridViewportVariants as _ } from "../heatmap-grid.variants.js";
|
|
8
|
+
import { HeatmapGridCellView as k } from "./heatmap-grid-cell.js";
|
|
9
|
+
import { useHeatmapGridViewport as O } from "./use-heatmap-grid-viewport.js";
|
|
10
|
+
const U = L(
|
|
11
|
+
"HeatmapGridViewport",
|
|
12
|
+
({ className: p, style: w, ...u }, g) => {
|
|
13
|
+
const {
|
|
14
|
+
context: e,
|
|
15
|
+
scrollRef: f,
|
|
16
|
+
layout: i,
|
|
17
|
+
rowItems: P,
|
|
18
|
+
columnItems: d,
|
|
19
|
+
activeCell: s,
|
|
20
|
+
isActiveCellPainted: b,
|
|
21
|
+
handlers: v
|
|
22
|
+
} = O(), { rowHeaderWidthPx: o, columnHeaderHeightPx: c } = e, C = z(f, g), y = i.contentWidthPx - o, x = i.columnSizePx >= G ? "horizontal" : "rotated", H = S({
|
|
23
|
+
columnSizePx: i.columnSizePx,
|
|
24
|
+
columnHeaderHeightPx: c
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ n(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
ref: C,
|
|
30
|
+
role: "grid",
|
|
31
|
+
"aria-label": e.gridLabel,
|
|
32
|
+
"aria-rowcount": e.rowCount + 1,
|
|
33
|
+
"aria-colcount": e.columnCount + 1,
|
|
34
|
+
"aria-busy": e.isFetchingMore || void 0,
|
|
35
|
+
tabIndex: b ? -1 : 0,
|
|
36
|
+
"data-component": "heatmap-grid-viewport",
|
|
37
|
+
"data-testid": "heatmap-grid-scroll",
|
|
38
|
+
className: h(
|
|
39
|
+
_({
|
|
40
|
+
overflowX: i.overflowsX,
|
|
41
|
+
overflowY: i.overflowsY
|
|
42
|
+
}),
|
|
43
|
+
p
|
|
44
|
+
),
|
|
45
|
+
style: w,
|
|
46
|
+
...v,
|
|
47
|
+
...u,
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ n(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
role: "rowgroup",
|
|
53
|
+
className: "relative",
|
|
54
|
+
style: {
|
|
55
|
+
width: i.contentWidthPx,
|
|
56
|
+
height: i.bodyHeightPx + (e.isFetchingMore ? e.minRowSizePx : 0)
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
P.map((a) => /* @__PURE__ */ n(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
role: "row",
|
|
63
|
+
"aria-rowindex": a.index + 1,
|
|
64
|
+
className: "absolute left-0 top-0 flex",
|
|
65
|
+
style: {
|
|
66
|
+
width: i.contentWidthPx,
|
|
67
|
+
height: i.rowSizePx,
|
|
68
|
+
transform: `translate3d(0, ${a.index * i.rowSizePx}px, 0)`
|
|
69
|
+
},
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ t(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
role: "rowheader",
|
|
75
|
+
"aria-colindex": 1,
|
|
76
|
+
className: R(),
|
|
77
|
+
style: { width: o },
|
|
78
|
+
children: /* @__PURE__ */ t(m, { triggerClassName: "block max-w-full truncate text-end", children: e.getRowLabel(a.index) })
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
d.map((l) => {
|
|
82
|
+
const r = e.getCell(a.index, l.index), N = { rowIndex: a.index, columnIndex: l.index };
|
|
83
|
+
return /* @__PURE__ */ t(
|
|
84
|
+
k,
|
|
85
|
+
{
|
|
86
|
+
rowIndex: a.index,
|
|
87
|
+
columnIndex: l.index,
|
|
88
|
+
startPx: o + l.index * i.columnSizePx,
|
|
89
|
+
widthPx: i.columnSizePx,
|
|
90
|
+
tone: !r || r.isEmpty ? "empty" : r.tone ?? "neutral",
|
|
91
|
+
color: r?.color,
|
|
92
|
+
isActive: s.rowIndex === a.index && s.columnIndex === l.index,
|
|
93
|
+
children: r && e.renderCell ? e.renderCell(r, N) : r?.label
|
|
94
|
+
},
|
|
95
|
+
l.key
|
|
96
|
+
);
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
a.key
|
|
101
|
+
)),
|
|
102
|
+
e.isFetchingMore ? /* @__PURE__ */ t(
|
|
103
|
+
"div",
|
|
104
|
+
{
|
|
105
|
+
role: "row",
|
|
106
|
+
"aria-label": e.loadingMoreLabel,
|
|
107
|
+
"data-testid": "heatmap-grid-fetching-more",
|
|
108
|
+
className: V(),
|
|
109
|
+
style: {
|
|
110
|
+
left: o,
|
|
111
|
+
top: i.bodyHeightPx,
|
|
112
|
+
width: y,
|
|
113
|
+
height: e.minRowSizePx
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
) : null
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
/* @__PURE__ */ n(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
role: "row",
|
|
124
|
+
"aria-rowindex": e.rowCount + 1,
|
|
125
|
+
className: A(),
|
|
126
|
+
style: { width: i.contentWidthPx, height: c },
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ t(
|
|
129
|
+
"div",
|
|
130
|
+
{
|
|
131
|
+
role: "columnheader",
|
|
132
|
+
"aria-colindex": 1,
|
|
133
|
+
className: "sticky left-0 z-[1] h-full bg-canvas-elevated",
|
|
134
|
+
style: { width: o },
|
|
135
|
+
children: /* @__PURE__ */ t("span", { className: "sr-only", children: e.rowHeaderLabel })
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
d.map((a) => /* @__PURE__ */ t(
|
|
139
|
+
"div",
|
|
140
|
+
{
|
|
141
|
+
role: "columnheader",
|
|
142
|
+
"aria-colindex": a.index + 2,
|
|
143
|
+
className: W(),
|
|
144
|
+
style: {
|
|
145
|
+
left: o + a.index * i.columnSizePx,
|
|
146
|
+
width: i.columnSizePx,
|
|
147
|
+
"--heatmap-grid-column-label-max-w": `${H}px`
|
|
148
|
+
},
|
|
149
|
+
children: /* @__PURE__ */ t(
|
|
150
|
+
m,
|
|
151
|
+
{
|
|
152
|
+
content: e.getColumnLabel(a.index),
|
|
153
|
+
triggerClassName: h(
|
|
154
|
+
M({ orientation: x }),
|
|
155
|
+
x === "rotated" && "max-w-[var(--heatmap-grid-column-label-max-w)]"
|
|
156
|
+
),
|
|
157
|
+
children: e.getColumnLabel(a.index)
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
},
|
|
161
|
+
a.key
|
|
162
|
+
))
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
export {
|
|
172
|
+
U as HeatmapGridViewport
|
|
173
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HeatmapGridCellPosition } from '../heatmap-grid.types';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export declare function useHeatmapGridViewport(): {
|
|
4
|
+
context: import('./heatmap-grid-context').HeatmapGridContextValue;
|
|
5
|
+
scrollRef: React.RefObject<HTMLDivElement | null>;
|
|
6
|
+
layout: import('../heatmap-grid.layout').HeatmapGridLayout;
|
|
7
|
+
rowItems: import('@tanstack/virtual-core').VirtualItem[];
|
|
8
|
+
columnItems: import('@tanstack/virtual-core').VirtualItem[];
|
|
9
|
+
activeCell: HeatmapGridCellPosition;
|
|
10
|
+
isActiveCellPainted: boolean;
|
|
11
|
+
handlers: Pick<React.HTMLAttributes<HTMLDivElement>, "onFocus" | "onBlur" | "onKeyDown" | "onPointerLeave" | "onPointerOver" | "onScroll">;
|
|
12
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { useVirtualizedRows as H } from "../../../../lib/virtualized/useVirtualizedRows.js";
|
|
3
|
+
import { readHeatmapGridLayout as F, readHeatmapGridCellPosition as C, readNextHeatmapGridFocusCell as T, readHeatmapGridCellKey as R } from "../heatmap-grid.layout.js";
|
|
4
|
+
import { useHeatmapGridContext as L } from "./heatmap-grid-context.js";
|
|
5
|
+
const y = 2;
|
|
6
|
+
function O(e) {
|
|
7
|
+
const [u, i] = o.useState({ widthPx: 0, heightPx: 0 });
|
|
8
|
+
return o.useLayoutEffect(() => {
|
|
9
|
+
const c = e.current;
|
|
10
|
+
if (!c)
|
|
11
|
+
return;
|
|
12
|
+
const s = () => i(
|
|
13
|
+
(n) => n.widthPx === c.clientWidth && n.heightPx === c.clientHeight ? n : { widthPx: c.clientWidth, heightPx: c.clientHeight }
|
|
14
|
+
);
|
|
15
|
+
s();
|
|
16
|
+
const l = new ResizeObserver(s);
|
|
17
|
+
return l.observe(c), () => l.disconnect();
|
|
18
|
+
}, [e]), u;
|
|
19
|
+
}
|
|
20
|
+
function G(e, u, i) {
|
|
21
|
+
return {
|
|
22
|
+
rowIndex: Math.max(Math.min(e.rowIndex, u - 1), 0),
|
|
23
|
+
columnIndex: Math.max(Math.min(e.columnIndex, i - 1), 0)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function V(e) {
|
|
27
|
+
const u = o.useRef(e.onEndReached), i = o.useRef(-1), c = o.useRef(!1), s = o.useRef(!1);
|
|
28
|
+
o.useLayoutEffect(() => {
|
|
29
|
+
u.current = e.onEndReached;
|
|
30
|
+
});
|
|
31
|
+
const { lastPaintedRowIndex: l, rowCount: n, hasMore: d, isFetchingMore: a, threshold: x } = e, h = d && !a && n > 0 && l >= 0 && l >= n - 1 - x;
|
|
32
|
+
return o.useEffect(() => {
|
|
33
|
+
s.current && !a && i.current === n && (c.current = !0), s.current = a;
|
|
34
|
+
}, [a, n]), o.useEffect(() => {
|
|
35
|
+
!h || i.current === n || (i.current = n, u.current?.());
|
|
36
|
+
}, [h, n]), () => {
|
|
37
|
+
!h || !c.current || (c.current = !1, i.current = n, u.current?.());
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function B() {
|
|
41
|
+
const e = L(), u = o.useRef(null), i = o.useRef(null), c = o.useRef("pointer"), s = O(u), l = F({
|
|
42
|
+
rowCount: e.rowCount,
|
|
43
|
+
columnCount: e.columnCount,
|
|
44
|
+
viewportWidthPx: s.widthPx,
|
|
45
|
+
viewportHeightPx: s.heightPx,
|
|
46
|
+
minRowSizePx: e.minRowSizePx,
|
|
47
|
+
minColumnSizePx: e.minColumnSizePx,
|
|
48
|
+
rowHeaderWidthPx: e.rowHeaderWidthPx,
|
|
49
|
+
columnHeaderHeightPx: e.columnHeaderHeightPx,
|
|
50
|
+
isFetchingMore: e.isFetchingMore
|
|
51
|
+
}), n = { width: s.widthPx, height: s.heightPx }, d = H({
|
|
52
|
+
scrollElementRef: u,
|
|
53
|
+
rowCount: e.rowCount,
|
|
54
|
+
estimateSize: () => l.rowSizePx,
|
|
55
|
+
overscan: y,
|
|
56
|
+
rerenderWhenPaintedRangeChanges: !0,
|
|
57
|
+
scrollPaddingEnd: e.columnHeaderHeightPx,
|
|
58
|
+
initialRect: n
|
|
59
|
+
}), a = H({
|
|
60
|
+
scrollElementRef: u,
|
|
61
|
+
rowCount: e.columnCount,
|
|
62
|
+
estimateSize: () => l.columnSizePx,
|
|
63
|
+
overscan: y,
|
|
64
|
+
rerenderWhenPaintedRangeChanges: !0,
|
|
65
|
+
horizontal: !0,
|
|
66
|
+
paddingStart: e.rowHeaderWidthPx,
|
|
67
|
+
scrollPaddingStart: e.rowHeaderWidthPx,
|
|
68
|
+
initialRect: n
|
|
69
|
+
}), { virtualizer: x } = d, { virtualizer: h } = a;
|
|
70
|
+
o.useLayoutEffect(() => {
|
|
71
|
+
x.measure();
|
|
72
|
+
}, [x, l.rowSizePx]), o.useLayoutEffect(() => {
|
|
73
|
+
h.measure();
|
|
74
|
+
}, [h, l.columnSizePx]);
|
|
75
|
+
const S = V({
|
|
76
|
+
lastPaintedRowIndex: d.virtualItems[d.virtualItems.length - 1]?.index ?? -1,
|
|
77
|
+
rowCount: e.rowCount,
|
|
78
|
+
hasMore: e.hasMore,
|
|
79
|
+
isFetchingMore: e.isFetchingMore,
|
|
80
|
+
threshold: e.endReachedThreshold,
|
|
81
|
+
onEndReached: e.onEndReached
|
|
82
|
+
}), f = G(e.activeCell, e.rowCount, e.columnCount), M = d.virtualItems.some((t) => t.index === f.rowIndex) && a.virtualItems.some((t) => t.index === f.columnIndex), E = () => {
|
|
83
|
+
const t = i.current, r = t ? u.current?.querySelector(
|
|
84
|
+
`[data-heatmap-cell][data-row-index="${t.rowIndex}"][data-column-index="${t.columnIndex}"]`
|
|
85
|
+
) : null;
|
|
86
|
+
r && (i.current = null, r.focus({ preventScroll: !0 }));
|
|
87
|
+
};
|
|
88
|
+
o.useLayoutEffect(E);
|
|
89
|
+
const I = (t) => {
|
|
90
|
+
i.current = t, x.scrollToIndex(t.rowIndex, { align: "auto" }), h.scrollToIndex(t.columnIndex, { align: "auto" }), R(t) !== R(f) && e.setActiveCell(t), E();
|
|
91
|
+
}, P = (t, r = !1) => {
|
|
92
|
+
const m = C(t), v = t?.closest("[data-heatmap-cell]"), p = e.rootRef.current;
|
|
93
|
+
if (!m || !v || !p) {
|
|
94
|
+
e.hoverStore.set(null);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const z = e.hoverStore.get();
|
|
98
|
+
if (!r && z?.rowIndex === m.rowIndex && z.columnIndex === m.columnIndex)
|
|
99
|
+
return;
|
|
100
|
+
const w = p.getBoundingClientRect(), g = v.getBoundingClientRect();
|
|
101
|
+
e.hoverStore.set({
|
|
102
|
+
...m,
|
|
103
|
+
anchorX: g.left + g.width / 2 - w.left,
|
|
104
|
+
anchorTop: g.top - w.top,
|
|
105
|
+
anchorBottom: g.bottom - w.top,
|
|
106
|
+
rootWidthPx: w.width
|
|
107
|
+
});
|
|
108
|
+
}, W = {
|
|
109
|
+
onPointerOver: (t) => {
|
|
110
|
+
c.current = "pointer", P(t.target);
|
|
111
|
+
},
|
|
112
|
+
onPointerLeave: () => e.hoverStore.set(null),
|
|
113
|
+
onScroll: (t) => {
|
|
114
|
+
if (S(), e.hoverStore.get() === null)
|
|
115
|
+
return;
|
|
116
|
+
const r = document.activeElement;
|
|
117
|
+
if (c.current === "focus" && r && t.currentTarget.contains(r)) {
|
|
118
|
+
P(r, !0);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
e.hoverStore.set(null);
|
|
122
|
+
},
|
|
123
|
+
onFocus: (t) => {
|
|
124
|
+
if (t.target === t.currentTarget) {
|
|
125
|
+
I(f);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const r = C(t.target);
|
|
129
|
+
r && (R(r) !== R(f) && e.setActiveCell(r), c.current = "focus", P(t.target));
|
|
130
|
+
},
|
|
131
|
+
onBlur: (t) => {
|
|
132
|
+
t.currentTarget.contains(t.relatedTarget) || e.hoverStore.set(null);
|
|
133
|
+
},
|
|
134
|
+
onKeyDown: (t) => {
|
|
135
|
+
const r = C(t.target);
|
|
136
|
+
if (!r)
|
|
137
|
+
return;
|
|
138
|
+
const m = T({
|
|
139
|
+
current: r,
|
|
140
|
+
rowCount: e.rowCount,
|
|
141
|
+
columnCount: e.columnCount,
|
|
142
|
+
key: t.key,
|
|
143
|
+
ctrlKey: t.ctrlKey || t.metaKey
|
|
144
|
+
});
|
|
145
|
+
m && (t.preventDefault(), I(m));
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
context: e,
|
|
150
|
+
scrollRef: u,
|
|
151
|
+
layout: l,
|
|
152
|
+
rowItems: d.virtualItems,
|
|
153
|
+
columnItems: a.virtualItems,
|
|
154
|
+
activeCell: f,
|
|
155
|
+
isActiveCellPainted: M,
|
|
156
|
+
handlers: W
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
B as useHeatmapGridViewport
|
|
161
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
1
|
+
import { jsx as r, jsxs as O, Fragment as R } from "react/jsx-runtime";
|
|
2
2
|
import * as t from "react";
|
|
3
3
|
import { useControllableState as c } from "@radix-ui/react-use-controllable-state";
|
|
4
|
-
import { createComponent as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { useImpactNovaI18n as
|
|
7
|
-
import { hexTilemapRootVariants as
|
|
8
|
-
import { HEX_ZOOM_DEFAULT as
|
|
9
|
-
import { layoutHexTilemap as
|
|
10
|
-
import { HexTilemapProvider as
|
|
11
|
-
import { HexTilemapLegend as
|
|
12
|
-
import { HexTilemapViewport as
|
|
13
|
-
const
|
|
4
|
+
import { createComponent as _ } from "../../../lib/primitives/create-component.js";
|
|
5
|
+
import { cn as k } from "../../../lib/utils.js";
|
|
6
|
+
import { useImpactNovaI18n as A } from "../../../i18n/use-impact-nova-i18n.js";
|
|
7
|
+
import { hexTilemapRootVariants as D } from "./hex-tilemap.variants.js";
|
|
8
|
+
import { HEX_ZOOM_DEFAULT as U } from "./internals/hex-camera.js";
|
|
9
|
+
import { layoutHexTilemap as X } from "./internals/hex-layout.js";
|
|
10
|
+
import { HexTilemapProvider as Z } from "./internals/hex-tilemap-context.js";
|
|
11
|
+
import { HexTilemapLegend as q } from "./internals/hex-tilemap-legend.js";
|
|
12
|
+
import { HexTilemapViewport as B } from "./internals/hex-tilemap-viewport.js";
|
|
13
|
+
const me = _(
|
|
14
14
|
"HexTilemap",
|
|
15
15
|
({
|
|
16
16
|
className: d,
|
|
@@ -21,16 +21,17 @@ const re = R(
|
|
|
21
21
|
metricLabel: h = "Value",
|
|
22
22
|
formatValue: x = String,
|
|
23
23
|
zoom: S,
|
|
24
|
-
defaultZoom: s =
|
|
24
|
+
defaultZoom: s = U,
|
|
25
25
|
onZoomChange: H,
|
|
26
26
|
hiddenSeriesIds: T,
|
|
27
27
|
defaultHiddenSeriesIds: v = [],
|
|
28
28
|
onHiddenSeriesIdsChange: b,
|
|
29
29
|
height: P,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
wheelZoomMode: g = "always",
|
|
31
|
+
"aria-label": C,
|
|
32
|
+
...I
|
|
33
|
+
}, w) => {
|
|
34
|
+
const { t: L } = A(), [M, y] = c({
|
|
34
35
|
prop: S,
|
|
35
36
|
defaultProp: s,
|
|
36
37
|
onChange: H
|
|
@@ -38,21 +39,21 @@ const re = R(
|
|
|
38
39
|
prop: T,
|
|
39
40
|
defaultProp: v,
|
|
40
41
|
onChange: b
|
|
41
|
-
}), [z, V] = t.useState(null), a = t.useMemo(() =>
|
|
42
|
+
}), [z, V] = t.useState(null), a = t.useMemo(() => X(m, i), [i, m]), p = t.useMemo(
|
|
42
43
|
() => new Set(e ?? []),
|
|
43
44
|
[e]
|
|
44
45
|
), j = t.useMemo(
|
|
45
46
|
() => a.points.filter((o) => !p.has(o.seriesId)),
|
|
46
47
|
[p, a.points]
|
|
47
|
-
),
|
|
48
|
+
), E = t.useCallback(
|
|
48
49
|
(o) => {
|
|
49
|
-
const n = e ?? [],
|
|
50
|
-
l(
|
|
50
|
+
const n = e ?? [], F = n.includes(o) ? n.filter((N) => N !== o) : [...n, o];
|
|
51
|
+
l(F);
|
|
51
52
|
},
|
|
52
53
|
[e, l]
|
|
53
54
|
);
|
|
54
55
|
return /* @__PURE__ */ r(
|
|
55
|
-
|
|
56
|
+
Z,
|
|
56
57
|
{
|
|
57
58
|
value: {
|
|
58
59
|
region: m,
|
|
@@ -63,23 +64,24 @@ const re = R(
|
|
|
63
64
|
metricLabel: h,
|
|
64
65
|
formatValue: x,
|
|
65
66
|
zoom: M ?? s,
|
|
66
|
-
setZoom:
|
|
67
|
+
setZoom: y,
|
|
67
68
|
hiddenSeriesIds: e ?? [],
|
|
68
|
-
toggleSeries:
|
|
69
|
+
toggleSeries: E,
|
|
69
70
|
hoverPoint: z,
|
|
70
71
|
setHoverPoint: V,
|
|
71
|
-
mapLabel:
|
|
72
|
+
mapLabel: C ?? L("hexTilemap.mapLabel"),
|
|
73
|
+
wheelZoomMode: g
|
|
72
74
|
},
|
|
73
75
|
children: /* @__PURE__ */ r(
|
|
74
76
|
"div",
|
|
75
77
|
{
|
|
76
|
-
ref:
|
|
78
|
+
ref: w,
|
|
77
79
|
"data-component": "hex-tilemap",
|
|
78
|
-
className:
|
|
79
|
-
...
|
|
80
|
-
children: u ?? /* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */ r(
|
|
82
|
-
/* @__PURE__ */ r(
|
|
80
|
+
className: k(D(), d),
|
|
81
|
+
...I,
|
|
82
|
+
children: u ?? /* @__PURE__ */ O(R, { children: [
|
|
83
|
+
/* @__PURE__ */ r(B, { height: P }),
|
|
84
|
+
/* @__PURE__ */ r(q, {})
|
|
83
85
|
] })
|
|
84
86
|
}
|
|
85
87
|
)
|
|
@@ -88,7 +90,7 @@ const re = R(
|
|
|
88
90
|
}
|
|
89
91
|
);
|
|
90
92
|
export {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
me as HexTilemap,
|
|
94
|
+
q as HexTilemapLegend,
|
|
95
|
+
B as HexTilemapViewport
|
|
94
96
|
};
|
|
@@ -34,6 +34,8 @@ export interface HexTilemapProps extends Omit<React.HTMLAttributes<HTMLDivElemen
|
|
|
34
34
|
defaultHiddenSeriesIds?: string[];
|
|
35
35
|
onHiddenSeriesIdsChange?: (hiddenSeriesIds: string[]) => void;
|
|
36
36
|
height?: number;
|
|
37
|
+
/** `always` — wheel zooms; `pinch-only` — zoom on pinch (ctrl+wheel) and toolbar only. */
|
|
38
|
+
wheelZoomMode?: "always" | "pinch-only";
|
|
37
39
|
"aria-label"?: string;
|
|
38
40
|
}
|
|
39
41
|
export interface HexTilemapViewportProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const O = 50, _ = 300,
|
|
2
|
-
function
|
|
1
|
+
const O = 50, _ = 300, f = 100, E = [50, 100, 150, 200], g = 6, X = 25;
|
|
2
|
+
function d(t, n, i) {
|
|
3
3
|
return Math.min(i, Math.max(n, t));
|
|
4
4
|
}
|
|
5
5
|
function x(t) {
|
|
6
|
-
return
|
|
6
|
+
return d(Math.round(t), 50, 300);
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function y(t, n) {
|
|
9
9
|
const i = 100 / x(n);
|
|
10
10
|
return {
|
|
11
11
|
width: t.width * i,
|
|
@@ -13,7 +13,7 @@ function M(t, n) {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
function p(t, n) {
|
|
16
|
-
const { width: i, height: h } =
|
|
16
|
+
const { width: i, height: h } = y(t, n);
|
|
17
17
|
return {
|
|
18
18
|
x: (t.width - i) / 2,
|
|
19
19
|
y: (t.height - h) / 2,
|
|
@@ -22,31 +22,31 @@ function p(t, n) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
const w = 0.3;
|
|
25
|
-
function
|
|
26
|
-
const i = t.width * w, h = t.height * w, o = Math.min(0, n.width - t.width) - i, e = Math.max(0, n.width - t.width) + i, u = Math.min(0, n.height - t.height) - h,
|
|
25
|
+
function c(t, n) {
|
|
26
|
+
const i = t.width * w, h = t.height * w, o = Math.min(0, n.width - t.width) - i, e = Math.max(0, n.width - t.width) + i, u = Math.min(0, n.height - t.height) - h, r = Math.max(0, n.height - t.height) + h;
|
|
27
27
|
return {
|
|
28
28
|
...t,
|
|
29
|
-
x:
|
|
30
|
-
y:
|
|
29
|
+
x: d(t.x, o, e),
|
|
30
|
+
y: d(t.y, u, r)
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
function l(t, n, i, h) {
|
|
34
|
-
const { width: o, height: e } =
|
|
34
|
+
const { width: o, height: e } = y(n, i);
|
|
35
35
|
if (h) {
|
|
36
|
-
const
|
|
37
|
-
return
|
|
38
|
-
{ x: h.x -
|
|
36
|
+
const s = t.width === 0 ? 0.5 : (h.x - t.x) / t.width, M = t.height === 0 ? 0.5 : (h.y - t.y) / t.height;
|
|
37
|
+
return c(
|
|
38
|
+
{ x: h.x - s * o, y: h.y - M * e, width: o, height: e },
|
|
39
39
|
n
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
|
-
const u = t.x + t.width / 2,
|
|
43
|
-
return
|
|
44
|
-
{ x: u - o / 2, y:
|
|
42
|
+
const u = t.x + t.width / 2, r = t.y + t.height / 2;
|
|
43
|
+
return c(
|
|
44
|
+
{ x: u - o / 2, y: r - e / 2, width: o, height: e },
|
|
45
45
|
n
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
48
|
+
function T(t, n, i, h) {
|
|
49
|
+
return c(
|
|
50
50
|
{
|
|
51
51
|
...t,
|
|
52
52
|
x: t.x - i,
|
|
@@ -55,7 +55,7 @@ function H(t, n, i, h) {
|
|
|
55
55
|
n
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function H(t, n, i) {
|
|
59
59
|
return {
|
|
60
60
|
x: t.x + (n.x - t.x) * i,
|
|
61
61
|
y: t.y + (n.y - t.y) * i,
|
|
@@ -73,6 +73,8 @@ function S(t, n, i) {
|
|
|
73
73
|
const h = t.getScreenCTM();
|
|
74
74
|
if (!h) return null;
|
|
75
75
|
const o = t.createSVGPoint();
|
|
76
|
+
if (typeof o.matrixTransform != "function" || typeof h.inverse != "function")
|
|
77
|
+
return null;
|
|
76
78
|
o.x = n, o.y = i;
|
|
77
79
|
const e = o.matrixTransform(h.inverse());
|
|
78
80
|
return { x: e.x, y: e.y };
|
|
@@ -81,23 +83,23 @@ function A(t, n) {
|
|
|
81
83
|
t.setAttribute("viewBox", `${n.x} ${n.y} ${n.width} ${n.height}`);
|
|
82
84
|
}
|
|
83
85
|
export {
|
|
84
|
-
|
|
86
|
+
X as HEX_BUTTON_ZOOM_STEP,
|
|
85
87
|
w as HEX_PAN_OVERSCROLL,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
g as HEX_WHEEL_ZOOM_STEP,
|
|
89
|
+
f as HEX_ZOOM_DEFAULT,
|
|
88
90
|
_ as HEX_ZOOM_MAX,
|
|
89
91
|
O as HEX_ZOOM_MIN,
|
|
90
|
-
|
|
92
|
+
E as HEX_ZOOM_PRESETS,
|
|
91
93
|
A as applyCameraViewBox,
|
|
92
94
|
p as centeredCamera,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
c as clampCamera,
|
|
96
|
+
d as clampNumber,
|
|
95
97
|
x as clampZoom,
|
|
96
98
|
S as clientToSvgPoint,
|
|
97
99
|
Z as easeOutCubic,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
H as interpolateCamera,
|
|
101
|
+
T as panCamera,
|
|
100
102
|
C as prefersReducedMotion,
|
|
101
|
-
|
|
103
|
+
y as sizeForZoom,
|
|
102
104
|
l as zoomCameraAt
|
|
103
105
|
};
|
|
@@ -16,6 +16,7 @@ export interface HexTilemapContextValue {
|
|
|
16
16
|
hoverPoint: HexTilemapHoverPoint | null;
|
|
17
17
|
setHoverPoint: (point: HexTilemapHoverPoint | null) => void;
|
|
18
18
|
mapLabel: string;
|
|
19
|
+
wheelZoomMode: "always" | "pinch-only";
|
|
19
20
|
}
|
|
20
21
|
export declare function HexTilemapProvider({ value, children, }: {
|
|
21
22
|
value: HexTilemapContextValue;
|