impact-nova 3.0.0-alpha.22 → 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.
@@ -1,7 +1,7 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
- import { __require as o } from "../node_modules/style-to-js/cjs/index.js";
3
- var t = o();
4
- const a = /* @__PURE__ */ r(t);
1
+ import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
2
+ import { __require as r } from "../node_modules/extend/index.js";
3
+ var t = r();
4
+ const a = /* @__PURE__ */ e(t);
5
5
  export {
6
6
  a as default
7
7
  };
@@ -1,7 +1,7 @@
1
- import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
2
- import { __require as r } from "../node_modules/extend/index.js";
3
- var t = r();
4
- const a = /* @__PURE__ */ e(t);
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
+ import { __require as o } from "../node_modules/style-to-js/cjs/index.js";
3
+ var t = o();
4
+ const a = /* @__PURE__ */ r(t);
5
5
  export {
6
6
  a as default
7
7
  };
@@ -1,16 +1,16 @@
1
- import { jsx as r, jsxs as N, Fragment as O } from "react/jsx-runtime";
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 R } from "../../../lib/primitives/create-component.js";
5
- import { cn as _ } from "../../../lib/utils.js";
6
- import { useImpactNovaI18n as k } from "../../../i18n/use-impact-nova-i18n.js";
7
- import { hexTilemapRootVariants as A } from "./hex-tilemap.variants.js";
8
- import { HEX_ZOOM_DEFAULT as D } from "./internals/hex-camera.js";
9
- import { layoutHexTilemap as U } from "./internals/hex-layout.js";
10
- import { HexTilemapProvider as X } from "./internals/hex-tilemap-context.js";
11
- import { HexTilemapLegend as Z } from "./internals/hex-tilemap-legend.js";
12
- import { HexTilemapViewport as q } from "./internals/hex-tilemap-viewport.js";
13
- const re = R(
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 = D,
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
- "aria-label": g,
31
- ...C
32
- }, I) => {
33
- const { t: L } = k(), [M, w] = c({
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(() => U(m, i), [i, m]), p = 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
- ), y = t.useCallback(
48
+ ), E = t.useCallback(
48
49
  (o) => {
49
- const n = e ?? [], E = n.includes(o) ? n.filter((F) => F !== o) : [...n, o];
50
- l(E);
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
- X,
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: w,
67
+ setZoom: y,
67
68
  hiddenSeriesIds: e ?? [],
68
- toggleSeries: y,
69
+ toggleSeries: E,
69
70
  hoverPoint: z,
70
71
  setHoverPoint: V,
71
- mapLabel: g ?? L("hexTilemap.mapLabel")
72
+ mapLabel: C ?? L("hexTilemap.mapLabel"),
73
+ wheelZoomMode: g
72
74
  },
73
75
  children: /* @__PURE__ */ r(
74
76
  "div",
75
77
  {
76
- ref: I,
78
+ ref: w,
77
79
  "data-component": "hex-tilemap",
78
- className: _(A(), d),
79
- ...C,
80
- children: u ?? /* @__PURE__ */ N(O, { children: [
81
- /* @__PURE__ */ r(q, { height: P }),
82
- /* @__PURE__ */ r(Z, {})
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
- re as HexTilemap,
92
- Z as HexTilemapLegend,
93
- q as HexTilemapViewport
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, E = 100, g = [50, 100, 150, 200], X = 6, f = 25;
2
- function c(t, n, i) {
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 c(Math.round(t), 50, 300);
6
+ return d(Math.round(t), 50, 300);
7
7
  }
8
- function M(t, n) {
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 } = M(t, n);
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 r(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, d = Math.max(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: c(t.x, o, e),
30
- y: c(t.y, u, d)
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 } = M(n, i);
34
+ const { width: o, height: e } = y(n, i);
35
35
  if (h) {
36
- const y = t.width === 0 ? 0.5 : (h.x - t.x) / t.width, s = t.height === 0 ? 0.5 : (h.y - t.y) / t.height;
37
- return r(
38
- { x: h.x - y * o, y: h.y - s * e, width: o, height: e },
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, d = t.y + t.height / 2;
43
- return r(
44
- { x: u - o / 2, y: d - e / 2, width: o, height: e },
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 H(t, n, i, h) {
49
- return r(
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 T(t, n, i) {
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
- f as HEX_BUTTON_ZOOM_STEP,
86
+ X as HEX_BUTTON_ZOOM_STEP,
85
87
  w as HEX_PAN_OVERSCROLL,
86
- X as HEX_WHEEL_ZOOM_STEP,
87
- E as HEX_ZOOM_DEFAULT,
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
- g as HEX_ZOOM_PRESETS,
92
+ E as HEX_ZOOM_PRESETS,
91
93
  A as applyCameraViewBox,
92
94
  p as centeredCamera,
93
- r as clampCamera,
94
- c as clampNumber,
95
+ c as clampCamera,
96
+ d as clampNumber,
95
97
  x as clampZoom,
96
98
  S as clientToSvgPoint,
97
99
  Z as easeOutCubic,
98
- T as interpolateCamera,
99
- H as panCamera,
100
+ H as interpolateCamera,
101
+ T as panCamera,
100
102
  C as prefersReducedMotion,
101
- M as sizeForZoom,
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;
@@ -1,17 +1,17 @@
1
1
  import { jsxs as w, jsx as i } from "react/jsx-runtime";
2
2
  import * as n from "react";
3
- import { createComponent as I } from "../../../../lib/primitives/create-component.js";
4
- import { cn as k } from "../../../../lib/utils.js";
5
- import { hexTilemapViewportVariants as L } from "../hex-tilemap.variants.js";
3
+ import { createComponent as k } from "../../../../lib/primitives/create-component.js";
4
+ import { cn as L } from "../../../../lib/utils.js";
5
+ import { hexTilemapViewportVariants as $ } from "../hex-tilemap.variants.js";
6
6
  import { HEX_BUTTON_ZOOM_STEP as g } from "./hex-camera.js";
7
- import { extentsFromTiles as $, buildLandPath as E, hexTileToPixel as V } from "./hex-geometry.js";
8
- import { useHexTilemapContext as D } from "./hex-tilemap-context.js";
9
- import { HexTilemapTooltip as O } from "./hex-tilemap-tooltip.js";
10
- import { HexTilemapZoom as _ } from "./hex-tilemap-zoom.js";
11
- import { useHexCamera as z } from "./use-hex-camera.js";
12
- const F = 315, N = "M9.56148 9.69087C9.20834 10.3244 8.53986 10.7171 7.81452 10.7171H3.94774C3.23129 10.7171 2.56957 10.3339 2.21301 9.71249L0.265298 6.3179C-0.090937 5.69704-0.0882008 4.93312 0.272474 4.31482L2.21064 0.992257C2.56906 0.377822 3.22686 0 3.93819 0H7.824C8.54428 0 9.20893 0.387309 9.56404 1.01397L11.4467 4.33636C11.7909 4.94364 11.7935 5.6864 11.4536 6.2961L9.56148 9.69087Z", J = I(
7
+ import { extentsFromTiles as E, buildLandPath as V, hexTileToPixel as D } from "./hex-geometry.js";
8
+ import { useHexTilemapContext as O } from "./hex-tilemap-context.js";
9
+ import { HexTilemapTooltip as _ } from "./hex-tilemap-tooltip.js";
10
+ import { HexTilemapZoom as z } from "./hex-tilemap-zoom.js";
11
+ import { useHexCamera as F } from "./use-hex-camera.js";
12
+ const N = 315, A = "M9.56148 9.69087C9.20834 10.3244 8.53986 10.7171 7.81452 10.7171H3.94774C3.23129 10.7171 2.56957 10.3339 2.21301 9.71249L0.265298 6.3179C-0.090937 5.69704-0.0882008 4.93312 0.272474 4.31482L2.21064 0.992257C2.56906 0.377822 3.22686 0 3.93819 0H7.824C8.54428 0 9.20893 0.387309 9.56404 1.01397L11.4467 4.33636C11.7909 4.94364 11.7935 5.6864 11.4536 6.2961L9.56148 9.69087Z", Q = k(
13
13
  "HexTilemapViewport",
14
- ({ className: v, height: T = F, ...C }, r) => {
14
+ ({ className: v, height: T = N, ...C }, r) => {
15
15
  const {
16
16
  layout: s,
17
17
  visiblePoints: P,
@@ -19,37 +19,39 @@ const F = 315, N = "M9.56148 9.69087C9.20834 10.3244 8.53986 10.7171 7.81452 10.
19
19
  setHoverPoint: m,
20
20
  mapLabel: b,
21
21
  setZoom: H,
22
- zoom: Z
23
- } = D(), c = n.useRef(null), p = n.useRef(null), f = n.useId(), y = n.useMemo(
22
+ zoom: Z,
23
+ wheelZoomMode: M
24
+ } = O(), c = n.useRef(null), p = n.useRef(null), f = n.useId(), y = n.useMemo(
24
25
  () => new Map(h.map((e) => [e.id, e.color])),
25
26
  [h]
26
- ), t = n.useMemo(() => $(s.land), [s.land]), M = n.useMemo(
27
+ ), t = n.useMemo(() => E(s.land), [s.land]), R = n.useMemo(
27
28
  () => ({ width: t.width, height: t.height }),
28
29
  [t.height, t.width]
29
- ), R = n.useMemo(
30
- () => E(s.land, t.originColumn, t.originRow),
30
+ ), B = n.useMemo(
31
+ () => V(s.land, t.originColumn, t.originRow),
31
32
  [t.originColumn, t.originRow, s.land]
32
- ), o = z({
33
- extents: M,
33
+ ), o = F({
34
+ extents: R,
34
35
  zoom: Z,
35
36
  onZoomChange: H,
36
37
  svgRef: p,
37
- viewportRef: c
38
- }), B = n.useCallback(
38
+ viewportRef: c,
39
+ wheelZoomMode: M
40
+ }), I = n.useCallback(
39
41
  (e) => {
40
42
  c.current = e, typeof r == "function" ? r(e) : r && (r.current = e);
41
43
  },
42
44
  [r]
43
45
  ), x = n.useCallback(
44
46
  (e, d) => {
45
- const a = c.current?.getBoundingClientRect(), l = d.getBoundingClientRect();
46
- a && m({
47
+ const l = c.current?.getBoundingClientRect(), a = d.getBoundingClientRect();
48
+ l && m({
47
49
  id: e.id,
48
50
  label: e.label,
49
51
  value: e.value,
50
52
  seriesId: e.seriesId,
51
- clientX: l.left + l.width / 2 - a.left,
52
- clientY: l.top - a.top
53
+ clientX: a.left + a.width / 2 - l.left,
54
+ clientY: a.top - l.top
53
55
  });
54
56
  },
55
57
  [m]
@@ -57,10 +59,10 @@ const F = 315, N = "M9.56148 9.69087C9.20834 10.3244 8.53986 10.7171 7.81452 10.
57
59
  return /* @__PURE__ */ w(
58
60
  "div",
59
61
  {
60
- ref: B,
62
+ ref: I,
61
63
  "data-component": "hex-tilemap-viewport",
62
64
  tabIndex: 0,
63
- className: k(L({ panning: o.isPanning }), v),
65
+ className: L($({ panning: o.isPanning }), v),
64
66
  style: { height: T },
65
67
  ...C,
66
68
  onPointerDown: o.handlePointerDown,
@@ -85,25 +87,25 @@ const F = 315, N = "M9.56148 9.69087C9.20834 10.3244 8.53986 10.7171 7.81452 10.
85
87
  /* @__PURE__ */ i(
86
88
  "path",
87
89
  {
88
- d: R,
90
+ d: B,
89
91
  className: "pointer-events-none fill-canvas-elevated stroke-content/15",
90
92
  strokeWidth: 0.35,
91
93
  filter: `url(#${f})`
92
94
  }
93
95
  ),
94
96
  P.map((e) => {
95
- const { pixelX: d, pixelY: a } = V(
97
+ const { pixelX: d, pixelY: l } = D(
96
98
  e.tile.x - t.originColumn,
97
99
  e.tile.y - t.originRow
98
- ), l = y.get(e.seriesId) ?? "var(--color-success)";
100
+ ), a = y.get(e.seriesId) ?? "var(--color-success)";
99
101
  return /* @__PURE__ */ i(
100
102
  "path",
101
103
  {
102
104
  "data-testid": "hex-tilemap-point",
103
105
  "data-point-id": e.id,
104
- d: N,
105
- transform: `translate(${d}, ${a})`,
106
- fill: l,
106
+ d: A,
107
+ transform: `translate(${d}, ${l})`,
108
+ fill: a,
107
109
  className: "cursor-pointer stroke-content/10 outline-none focus-visible:stroke-brand",
108
110
  strokeWidth: 0.3,
109
111
  tabIndex: 0,
@@ -124,9 +126,9 @@ const F = 315, N = "M9.56148 9.69087C9.20834 10.3244 8.53986 10.7171 7.81452 10.
124
126
  ]
125
127
  }
126
128
  ),
127
- /* @__PURE__ */ i(O, {}),
129
+ /* @__PURE__ */ i(_, {}),
128
130
  /* @__PURE__ */ i(
129
- _,
131
+ z,
130
132
  {
131
133
  onZoomIn: () => o.zoomBy(g),
132
134
  onZoomOut: () => o.zoomBy(-g),
@@ -143,5 +145,5 @@ const F = 315, N = "M9.56148 9.69087C9.20834 10.3244 8.53986 10.7171 7.81452 10.
143
145
  }
144
146
  );
145
147
  export {
146
- J as HexTilemapViewport
148
+ Q as HexTilemapViewport
147
149
  };
@@ -6,8 +6,9 @@ interface UseHexCameraOptions {
6
6
  onZoomChange: (zoom: number) => void;
7
7
  svgRef: React.RefObject<SVGSVGElement | null>;
8
8
  viewportRef: React.RefObject<HTMLDivElement | null>;
9
+ wheelZoomMode: "always" | "pinch-only";
9
10
  }
10
- export declare function useHexCamera({ extents, zoom, onZoomChange, svgRef, viewportRef, }: UseHexCameraOptions): {
11
+ export declare function useHexCamera({ extents, zoom, onZoomChange, svgRef, viewportRef, wheelZoomMode, }: UseHexCameraOptions): {
11
12
  isPanning: boolean;
12
13
  handlePointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;
13
14
  handlePointerMove: (event: React.PointerEvent<HTMLDivElement>) => void;