@zsherman/viz 0.0.0-stage → 0.1.1
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 +14 -0
- package/LICENSE +373 -0
- package/README.md +13 -2
- package/THIRD_PARTY_NOTICES.md +79 -0
- package/dist/dom/flow/flow.js +370 -0
- package/dist/dom/flow/flow.styles.js +158 -0
- package/dist/dom/flow/index.js +4 -0
- package/dist/dom/flow/layout.js +51 -0
- package/dist/dom/geo-map/geo-map.js +1037 -0
- package/dist/dom/geo-map/geo-map.styles.js +184 -0
- package/dist/dom/geo-map/geometry.js +231 -0
- package/dist/dom/geo-map/index.js +3 -0
- package/dist/dom/geo-map/types.js +0 -0
- package/dist/dom/geo-map/world.js +15 -0
- package/dist/dom/index.js +6 -0
- package/dist/solid/flow/flow.jsx +180 -0
- package/dist/solid/flow/flow.styles.jsx +158 -0
- package/dist/solid/flow/index.jsx +4 -0
- package/dist/solid/flow/layout.jsx +51 -0
- package/dist/solid/geo-map/geo-map.jsx +698 -0
- package/dist/solid/geo-map/geo-map.styles.jsx +184 -0
- package/dist/solid/geo-map/geometry.jsx +231 -0
- package/dist/solid/geo-map/index.jsx +3 -0
- package/dist/solid/geo-map/types.jsx +0 -0
- package/dist/solid/geo-map/world.jsx +15 -0
- package/dist/solid/index.jsx +6 -0
- package/dist/styles.css +1 -0
- package/dist/types/flow/flow.d.ts +92 -0
- package/dist/types/flow/flow.styles.d.ts +137 -0
- package/dist/types/flow/index.d.ts +6 -0
- package/dist/types/flow/layout.d.ts +47 -0
- package/dist/types/geo-map/geo-map.d.ts +70 -0
- package/dist/types/geo-map/geo-map.styles.d.ts +188 -0
- package/dist/types/geo-map/geometry.d.ts +116 -0
- package/dist/types/geo-map/index.d.ts +4 -0
- package/dist/types/geo-map/types.d.ts +103 -0
- package/dist/types/geo-map/world.d.ts +11 -0
- package/dist/types/index.d.ts +2 -0
- package/docs/api.json +297 -0
- package/docs/flow.md +255 -0
- package/docs/geo-map.md +320 -0
- package/docs/llms.txt +43 -0
- package/docs/search-index.json +64 -0
- package/package.json +66 -4
|
@@ -0,0 +1,1037 @@
|
|
|
1
|
+
import { boundsOf, clampFlat, facesViewer, fitFlat, fittedProjection, globeArc, globeFit, globeTransition, rotationFacing, screenArc } from "./geometry.js";
|
|
2
|
+
import { styles } from "./geo-map.styles.js";
|
|
3
|
+
import { loadWorld } from "./world.js";
|
|
4
|
+
import { className, createComponent, delegateEvents, effect, getNextElement, getNextMarker, insert, memo, readShallow, ref, runHydrationEvents, scope, setAttribute, setStyleProperty, spread, template } from "@solidjs/web";
|
|
5
|
+
import * as stylex from "@stylexjs/stylex";
|
|
6
|
+
import { Icon } from "@zsherman/kit/icon";
|
|
7
|
+
import { Minus, Plus, Scan } from "@zsherman/kit/icons";
|
|
8
|
+
import { useMessages } from "@zsherman/kit/locale-provider";
|
|
9
|
+
import { For, Show, createEffect, createMemo, createSignal, createUniqueId, omit, onSettled } from "solid-js";
|
|
10
|
+
import { IconButton } from "@zsherman/kit/button";
|
|
11
|
+
import { announce, createRovingFocus, createViewport, spatialMove } from "@ui-sdk/core";
|
|
12
|
+
import { geoGraticule10, geoPath } from "d3-geo";
|
|
13
|
+
// src/geo-map/geo-map.tsx
|
|
14
|
+
/**
|
|
15
|
+
* GeoMap: a world map of markers and the connections between them, flat or a globe. A Solid rewrite of
|
|
16
|
+
* hyper-ui's GeoMap and ConnectionMap (one component for both): Solid renders the SVG and the markers,
|
|
17
|
+
* d3-geo only projects (geometry.ts). Pan and zoom on a flat map are ui-sdk's `createViewport`; a globe
|
|
18
|
+
* turns with a drag (geometry.ts `globeTransition`, after hyper-ui's map-mode reducer). The markers are a
|
|
19
|
+
* listbox with one tab stop (ui-sdk `createRovingFocus`, arrows to the nearest marker on screen), and the
|
|
20
|
+
* kit's Tooltip names what the pointer or the focus is on: a chunk of its own (the popup core is most of a
|
|
21
|
+
* tooltip's weight), loaded when the browser is idle after the map mounts, or at the first hover or focus.
|
|
22
|
+
*/
|
|
23
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div><svg><g><path></path><!$><!/><!$><!/><g data-slot=geo-map-connections></g></g></svg><!$><!/><!$><!/><!$><!/>`);
|
|
24
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<svg><path></svg>`, 2);
|
|
25
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<svg><g data-slot=geo-map-connection><path></path><path></svg>`, 2);
|
|
26
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<div>`);
|
|
27
|
+
var _tmpl$5 = /* @__PURE__ */ template(`<div role=option data-slot=geo-map-marker>`);
|
|
28
|
+
var _tmpl$6 = /* @__PURE__ */ template(`<span hidden>`);
|
|
29
|
+
var _tmpl$7 = /* @__PURE__ */ template(`<div><!$><!/><!$><!/><!$><!/>`);
|
|
30
|
+
var _tmpl$8 = /* @__PURE__ */ template(`<span><!$><!/><!$><!/>`);
|
|
31
|
+
var _tmpl$9 = /* @__PURE__ */ template(`<span>`);
|
|
32
|
+
var _tmpl$10 = /* @__PURE__ */ template(`<span><!$><!/> → <!$><!/>`);
|
|
33
|
+
const DEFAULT_LABELS = {
|
|
34
|
+
map: "map",
|
|
35
|
+
markers: "Locations",
|
|
36
|
+
zoomIn: "Zoom in",
|
|
37
|
+
zoomOut: "Zoom out",
|
|
38
|
+
fit: "Show all",
|
|
39
|
+
zoom: (percent) => `Zoom ${percent}%`,
|
|
40
|
+
connections: (count) => count === 1 ? "1 connection" : `${count} connections`
|
|
41
|
+
};
|
|
42
|
+
const TONES = /* @__PURE__ */ new Set([
|
|
43
|
+
"accent",
|
|
44
|
+
"info",
|
|
45
|
+
"success",
|
|
46
|
+
"warning",
|
|
47
|
+
"danger"
|
|
48
|
+
]);
|
|
49
|
+
const CHART = /^chart-[1-8]$/;
|
|
50
|
+
/** A marker or connection color as CSS: token names become their custom properties. */
|
|
51
|
+
function geoMapColor(c) {
|
|
52
|
+
if (CHART.test(c)) return `var(--sui-${c})`;
|
|
53
|
+
if (TONES.has(c)) return `var(--sui-${c})`;
|
|
54
|
+
if (c === "neutral") return "var(--sui-text-muted)";
|
|
55
|
+
return c;
|
|
56
|
+
}
|
|
57
|
+
const DEFAULT_RADIUS = 5;
|
|
58
|
+
const DEFAULT_WEIGHT = 1.5;
|
|
59
|
+
/** The size the map lays out for before it's measured (on the server, the first render). */
|
|
60
|
+
const FALLBACK_WIDTH = 960;
|
|
61
|
+
const ZOOM_STEP = 1.5;
|
|
62
|
+
const MOTION_MS = 450;
|
|
63
|
+
const [tooltipKit, setTooltipKit] = createSignal(null);
|
|
64
|
+
let tooltipLoading;
|
|
65
|
+
/** Loads the kit's Tooltip once per page; every map shares it. */
|
|
66
|
+
function loadTooltip() {
|
|
67
|
+
tooltipLoading ??= import("@zsherman/kit/tooltip").then((kit) => void setTooltipKit(() => kit), () => {
|
|
68
|
+
tooltipLoading = void 0;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const reducedMotion = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
72
|
+
/** A store that ui-sdk's helpers read and write, backed by plain values and a signal for rendering. */
|
|
73
|
+
function createLocalStore(initial, onSet) {
|
|
74
|
+
const state = { ...initial };
|
|
75
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
76
|
+
return {
|
|
77
|
+
get: () => state,
|
|
78
|
+
set: (patch) => {
|
|
79
|
+
if (!Object.keys(patch).some((k) => !Object.is(state[k], patch[k]))) return;
|
|
80
|
+
Object.assign(state, patch);
|
|
81
|
+
onSet(state);
|
|
82
|
+
for (const listener of listeners) listener();
|
|
83
|
+
},
|
|
84
|
+
subscribe: (listener) => {
|
|
85
|
+
listeners.add(listener);
|
|
86
|
+
return () => void listeners.delete(listener);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A world map of markers and the connections between them: flat (pan and zoom) or a globe (turn and zoom).
|
|
92
|
+
* Markers are a listbox: Tab reaches the map's markers, arrows move to the nearest one on screen, Enter
|
|
93
|
+
* selects; + and − zoom. Land comes from Natural Earth (loaded on demand) unless `worldData` is given.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* <GeoMap
|
|
97
|
+
* label="Edge servers and the users on them"
|
|
98
|
+
* markers={[{ id: "fra", name: "Frankfurt", latitude: 50.1, longitude: 8.7, group: "server" }]}
|
|
99
|
+
* connections={[{ source: "u1", target: "fra" }]}
|
|
100
|
+
* />
|
|
101
|
+
*/
|
|
102
|
+
function GeoMap(props) {
|
|
103
|
+
const rest = omit(props, "label", "markers", "connections", "projection", "arcStyle", "graticule", "worldData", "center", "initialView", "interactive", "controls", "height", "selected", "defaultSelected", "onMarkerSelect", "onConnectionSelect", "highlighted", "animated", "tooltip", "labels", "controller", "class", "style");
|
|
104
|
+
const messages = useMessages("geoMap");
|
|
105
|
+
const label = (key) => props.labels?.[key] ?? messages()?.[key] ?? DEFAULT_LABELS[key];
|
|
106
|
+
const uid = createUniqueId();
|
|
107
|
+
let root;
|
|
108
|
+
const markerEls = /* @__PURE__ */ new Map();
|
|
109
|
+
const globe = () => props.projection === "orthographic";
|
|
110
|
+
const interactive = () => props.interactive !== false;
|
|
111
|
+
const markers = () => props.markers ?? [];
|
|
112
|
+
const [measured, setMeasured] = createSignal(null);
|
|
113
|
+
const box = createMemo(() => {
|
|
114
|
+
const m = measured();
|
|
115
|
+
if (m) return m;
|
|
116
|
+
const h = typeof props.height === "number" ? props.height : FALLBACK_WIDTH / 2;
|
|
117
|
+
return {
|
|
118
|
+
w: typeof props.height === "number" ? h * 2 : FALLBACK_WIDTH,
|
|
119
|
+
h
|
|
120
|
+
};
|
|
121
|
+
}, { equals: (a, b) => a.w === b.w && a.h === b.h });
|
|
122
|
+
const [loaded, setLoaded] = createSignal(null);
|
|
123
|
+
const world = () => props.worldData ?? loaded();
|
|
124
|
+
createEffect(() => props.worldData === void 0, (need) => {
|
|
125
|
+
if (need) loadWorld().then(setLoaded, () => void 0);
|
|
126
|
+
});
|
|
127
|
+
const lonLats = () => markers().map((m) => [m.longitude, m.latitude]);
|
|
128
|
+
const globeDefault = createMemo(() => {
|
|
129
|
+
const fitted = props.initialView === "markers" ? globeFit(lonLats()) : null;
|
|
130
|
+
const center = props.center ?? [10, 25];
|
|
131
|
+
return fitted ? {
|
|
132
|
+
...fitted,
|
|
133
|
+
drag: null
|
|
134
|
+
} : {
|
|
135
|
+
rotation: rotationFacing(center),
|
|
136
|
+
scale: 1,
|
|
137
|
+
drag: null
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
let globeNow = null;
|
|
141
|
+
const [globeMoved, setGlobeMoved] = createSignal(null, { ownedWrite: true });
|
|
142
|
+
const globeView = () => globeMoved() ?? globeDefault();
|
|
143
|
+
const setGlobe = (next) => {
|
|
144
|
+
globeNow = next;
|
|
145
|
+
setGlobeMoved(next);
|
|
146
|
+
};
|
|
147
|
+
const dispatchGlobe = (event) => {
|
|
148
|
+
const now = globeNow ?? globeDefault();
|
|
149
|
+
const next = globeTransition(now, event);
|
|
150
|
+
if (next !== now) setGlobe(next);
|
|
151
|
+
};
|
|
152
|
+
/** Projections for the flat map (fixed: pans and zooms are a transform) and for a globe (turns with it). */
|
|
153
|
+
const projection = createMemo(() => {
|
|
154
|
+
const { w, h } = box();
|
|
155
|
+
if (globe()) {
|
|
156
|
+
const v = globeView();
|
|
157
|
+
return fittedProjection("orthographic", w, h, v.rotation, v.scale);
|
|
158
|
+
}
|
|
159
|
+
return fittedProjection(props.projection ?? "naturalEarth", w, h);
|
|
160
|
+
});
|
|
161
|
+
const path = createMemo(() => geoPath(projection()));
|
|
162
|
+
const sphere = createMemo(() => path()({ type: "Sphere" }) ?? "");
|
|
163
|
+
const land = createMemo(() => {
|
|
164
|
+
const w = world();
|
|
165
|
+
return w ? path()(w) ?? "" : "";
|
|
166
|
+
});
|
|
167
|
+
const graticule = createMemo(() => props.graticule ? path()(geoGraticule10()) ?? "" : "");
|
|
168
|
+
const placed = createMemo(() => {
|
|
169
|
+
const p = projection();
|
|
170
|
+
const rotation = globe() ? p.rotate() : null;
|
|
171
|
+
const groups = /* @__PURE__ */ new Map();
|
|
172
|
+
return markers().map((marker) => {
|
|
173
|
+
const lonLat = [marker.longitude, marker.latitude];
|
|
174
|
+
const at = p(lonLat) ?? [NaN, NaN];
|
|
175
|
+
let tone = 1;
|
|
176
|
+
if (marker.group !== void 0) {
|
|
177
|
+
if (!groups.has(marker.group)) groups.set(marker.group, groups.size);
|
|
178
|
+
tone = groups.get(marker.group) % 8 + 1;
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
marker,
|
|
182
|
+
at,
|
|
183
|
+
shown: rotation ? facesViewer(lonLat, rotation) : Number.isFinite(at[0]),
|
|
184
|
+
color: geoMapColor(marker.color ?? `chart-${tone}`)
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
const byId = createMemo(() => new Map(placed().map((p) => [p.marker.id, p])));
|
|
189
|
+
/** The markers' ids, in order: the list renders one option per id and reads the rest through `byId`. */
|
|
190
|
+
const ids = createMemo(() => markers().map((m) => m.id), { equals: (a, b) => a.length === b.length && a.every((id, i) => id === b[i]) });
|
|
191
|
+
const links = createMemo(() => {
|
|
192
|
+
const out = /* @__PURE__ */ new Map();
|
|
193
|
+
const ids = new Set(markers().map((m) => m.id));
|
|
194
|
+
for (const c of props.connections ?? []) {
|
|
195
|
+
if (!ids.has(c.source) || !ids.has(c.target)) continue;
|
|
196
|
+
if (!out.has(c.source)) out.set(c.source, /* @__PURE__ */ new Set());
|
|
197
|
+
if (!out.has(c.target)) out.set(c.target, /* @__PURE__ */ new Set());
|
|
198
|
+
out.get(c.source).add(c.target);
|
|
199
|
+
out.get(c.target).add(c.source);
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
});
|
|
203
|
+
const hasConnections = () => (props.connections?.length ?? 0) > 0;
|
|
204
|
+
const drawn = createMemo(() => {
|
|
205
|
+
const p = projection();
|
|
206
|
+
const ids = byId();
|
|
207
|
+
const style = props.arcStyle ?? "greatCircle";
|
|
208
|
+
const out = [];
|
|
209
|
+
(props.connections ?? []).forEach((connection, index) => {
|
|
210
|
+
const a = ids.get(connection.source);
|
|
211
|
+
const b = ids.get(connection.target);
|
|
212
|
+
if (!a || !b) return;
|
|
213
|
+
let d;
|
|
214
|
+
if (globe()) {
|
|
215
|
+
if (style === "greatCircle") d = globeArc(p, [a.marker.longitude, a.marker.latitude], [b.marker.longitude, b.marker.latitude]);
|
|
216
|
+
else d = a.shown && b.shown ? screenArc(style, a.at, b.at) : "";
|
|
217
|
+
} else d = screenArc(style, a.at, b.at);
|
|
218
|
+
if (!d) return;
|
|
219
|
+
out.push({
|
|
220
|
+
connection,
|
|
221
|
+
index,
|
|
222
|
+
d,
|
|
223
|
+
color: connection.color ? geoMapColor(connection.color) : a.color
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
return out;
|
|
227
|
+
});
|
|
228
|
+
const flatDefault = createMemo(() => {
|
|
229
|
+
const { w, h } = box();
|
|
230
|
+
if (globe() || props.initialView !== "markers") return {
|
|
231
|
+
x: 0,
|
|
232
|
+
y: 0,
|
|
233
|
+
zoom: 1
|
|
234
|
+
};
|
|
235
|
+
const rect = boundsOf(placed().filter((m) => m.shown).map((m) => m.at));
|
|
236
|
+
return rect ? fitFlat(rect, w, h) : {
|
|
237
|
+
x: 0,
|
|
238
|
+
y: 0,
|
|
239
|
+
zoom: 1
|
|
240
|
+
};
|
|
241
|
+
}, { equals: (a, b) => a.x === b.x && a.y === b.y && a.zoom === b.zoom });
|
|
242
|
+
let flatNow = null;
|
|
243
|
+
const [flatMoved, setFlatMoved] = createSignal(null, { ownedWrite: true });
|
|
244
|
+
const flat = () => flatMoved() ?? flatDefault();
|
|
245
|
+
const setFlat = (next) => {
|
|
246
|
+
const { w, h } = box();
|
|
247
|
+
flatNow = clampFlat(next, w, h);
|
|
248
|
+
setFlatMoved(flatNow);
|
|
249
|
+
};
|
|
250
|
+
const viewport = createViewport({
|
|
251
|
+
store: {
|
|
252
|
+
get: () => ({ viewport: flatNow ?? flatDefault() }),
|
|
253
|
+
set: () => {}
|
|
254
|
+
},
|
|
255
|
+
onDestroy: (cleanup) => onSettled(() => cleanup)
|
|
256
|
+
}, {
|
|
257
|
+
key: "viewport",
|
|
258
|
+
surface: () => root,
|
|
259
|
+
minZoom: () => 1,
|
|
260
|
+
maxZoom: () => 12,
|
|
261
|
+
message: (zoom) => label("zoom")(Math.round(zoom * 100)),
|
|
262
|
+
set: (value) => {
|
|
263
|
+
setFlat(value);
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
let tween = 0;
|
|
268
|
+
const turnTo = (rotation, scale) => {
|
|
269
|
+
cancelAnimationFrame(tween);
|
|
270
|
+
const from = globeNow ?? globeDefault();
|
|
271
|
+
const to = {
|
|
272
|
+
rotation,
|
|
273
|
+
scale: scale ?? from.scale,
|
|
274
|
+
drag: null
|
|
275
|
+
};
|
|
276
|
+
if (reducedMotion() || typeof requestAnimationFrame !== "function") return setGlobe(to);
|
|
277
|
+
const dLon = ((to.rotation[0] - from.rotation[0]) % 360 + 540) % 360 - 180;
|
|
278
|
+
const start = performance.now();
|
|
279
|
+
const step = (now) => {
|
|
280
|
+
const t = Math.min(1, (now - start) / MOTION_MS);
|
|
281
|
+
const e = 1 - (1 - t) ** 3;
|
|
282
|
+
setGlobe({
|
|
283
|
+
rotation: [
|
|
284
|
+
from.rotation[0] + dLon * e,
|
|
285
|
+
from.rotation[1] + (to.rotation[1] - from.rotation[1]) * e,
|
|
286
|
+
from.rotation[2]
|
|
287
|
+
],
|
|
288
|
+
scale: from.scale + (to.scale - from.scale) * e,
|
|
289
|
+
drag: null
|
|
290
|
+
});
|
|
291
|
+
if (t < 1) tween = requestAnimationFrame(step);
|
|
292
|
+
};
|
|
293
|
+
tween = requestAnimationFrame(step);
|
|
294
|
+
};
|
|
295
|
+
const fit = (target = "markers") => {
|
|
296
|
+
const chosen = target === "world" ? [] : target === "markers" ? placed() : placed().filter((p) => target.includes(p.marker.id));
|
|
297
|
+
if (globe()) {
|
|
298
|
+
const fitted = globeFit(chosen.map((p) => [p.marker.longitude, p.marker.latitude]));
|
|
299
|
+
if (fitted) turnTo(fitted.rotation, fitted.scale);
|
|
300
|
+
else turnTo((globeNow ?? globeDefault()).rotation, 1);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const { w, h } = box();
|
|
304
|
+
const rect = boundsOf(chosen.filter((p) => p.shown).map((p) => p.at));
|
|
305
|
+
setFlat(rect ? fitFlat(rect, w, h) : {
|
|
306
|
+
x: 0,
|
|
307
|
+
y: 0,
|
|
308
|
+
zoom: 1
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
const zoomBy = (factor) => {
|
|
312
|
+
if (globe()) {
|
|
313
|
+
dispatchGlobe({
|
|
314
|
+
type: "scaleBy",
|
|
315
|
+
factor
|
|
316
|
+
});
|
|
317
|
+
announce(label("zoom")(Math.round((globeNow ?? globeDefault()).scale * 100)));
|
|
318
|
+
} else viewport.zoomBy(factor);
|
|
319
|
+
};
|
|
320
|
+
const centerOn = (target) => {
|
|
321
|
+
const lonLat = typeof target === "string" ? (() => {
|
|
322
|
+
const m = byId().get(target)?.marker;
|
|
323
|
+
return m ? [m.longitude, m.latitude] : void 0;
|
|
324
|
+
})() : [target[0], target[1]];
|
|
325
|
+
if (!lonLat) return;
|
|
326
|
+
if (globe()) return turnTo(rotationFacing(lonLat, (globeNow ?? globeDefault()).rotation[2]));
|
|
327
|
+
const at = projection()(lonLat);
|
|
328
|
+
if (!at) return;
|
|
329
|
+
const { w, h } = box();
|
|
330
|
+
const { zoom } = flat();
|
|
331
|
+
setFlat({
|
|
332
|
+
zoom,
|
|
333
|
+
x: w / 2 - at[0] * zoom,
|
|
334
|
+
y: h / 2 - at[1] * zoom
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
const view = () => {
|
|
338
|
+
if (globe()) {
|
|
339
|
+
const v = globeNow ?? globeDefault();
|
|
340
|
+
return {
|
|
341
|
+
zoom: v.scale,
|
|
342
|
+
center: [-v.rotation[0], -v.rotation[1]]
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
const { w, h } = box();
|
|
346
|
+
const v = flat();
|
|
347
|
+
const inverted = projection().invert?.([(w / 2 - v.x) / v.zoom, (h / 2 - v.y) / v.zoom]);
|
|
348
|
+
return {
|
|
349
|
+
zoom: v.zoom,
|
|
350
|
+
center: inverted ? [inverted[0], inverted[1]] : [0, 0]
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
const [ownSelected, setOwnSelected] = createSignal(null);
|
|
354
|
+
const [selectionTouched, setSelectionTouched] = createSignal(false);
|
|
355
|
+
const selected = () => props.selected !== void 0 ? props.selected : selectionTouched() ? ownSelected() : props.defaultSelected ?? null;
|
|
356
|
+
const select = (id) => {
|
|
357
|
+
const next = selected() === id ? null : id;
|
|
358
|
+
setOwnSelected(next);
|
|
359
|
+
setSelectionTouched(true);
|
|
360
|
+
props.onMarkerSelect?.(next === null ? null : byId().get(id)?.marker ?? null);
|
|
361
|
+
};
|
|
362
|
+
const [hovered, setHovered] = createSignal(null);
|
|
363
|
+
const [focused, setFocused] = createSignal(null);
|
|
364
|
+
const active = () => props.highlighted !== void 0 ? props.highlighted : (() => {
|
|
365
|
+
const h = hovered();
|
|
366
|
+
if (h?.kind === "marker") return h.id;
|
|
367
|
+
return focused()?.id ?? null;
|
|
368
|
+
})();
|
|
369
|
+
const dimmedMarker = (id) => {
|
|
370
|
+
const a = active();
|
|
371
|
+
return a !== null && a !== id && !links().get(a)?.has(id);
|
|
372
|
+
};
|
|
373
|
+
const connectionState = (c) => {
|
|
374
|
+
const a = active();
|
|
375
|
+
if (a === null) return "rest";
|
|
376
|
+
return c.source === a || c.target === a ? "active" : "dimmed";
|
|
377
|
+
};
|
|
378
|
+
const tip = () => {
|
|
379
|
+
const h = hovered();
|
|
380
|
+
if (h) return h;
|
|
381
|
+
const f = focused();
|
|
382
|
+
return f?.visible ? {
|
|
383
|
+
kind: "marker",
|
|
384
|
+
id: f.id,
|
|
385
|
+
el: f.el
|
|
386
|
+
} : null;
|
|
387
|
+
};
|
|
388
|
+
const tipMarker = () => {
|
|
389
|
+
const t = tip();
|
|
390
|
+
return t?.kind === "marker" ? byId().get(t.id) : void 0;
|
|
391
|
+
};
|
|
392
|
+
const tipConnection = () => {
|
|
393
|
+
const t = tip();
|
|
394
|
+
return t?.kind === "connection" ? props.connections?.[t.index] : void 0;
|
|
395
|
+
};
|
|
396
|
+
const tipAnchor = () => {
|
|
397
|
+
const t = tip();
|
|
398
|
+
if (!t) return null;
|
|
399
|
+
return t.kind === "marker" ? t.el : {
|
|
400
|
+
x: t.x,
|
|
401
|
+
y: t.y
|
|
402
|
+
};
|
|
403
|
+
};
|
|
404
|
+
const markerName = (m) => hasConnections() ? `${m.name}, ${label("connections")(links().get(m.id)?.size ?? 0)}` : m.name;
|
|
405
|
+
const [stop, setStop] = createSignal(null, { ownedWrite: true });
|
|
406
|
+
const rovingStore = createLocalStore({ focused: null }, (s) => setStop(s.focused));
|
|
407
|
+
const spatial = spatialMove({ rect: (_el, key) => {
|
|
408
|
+
const p = byId().get(key);
|
|
409
|
+
const [x, y] = p ? p.at : [0, 0];
|
|
410
|
+
return {
|
|
411
|
+
left: x,
|
|
412
|
+
right: x,
|
|
413
|
+
top: y,
|
|
414
|
+
bottom: y
|
|
415
|
+
};
|
|
416
|
+
} });
|
|
417
|
+
const listMove = (event, { from, items }) => {
|
|
418
|
+
const i = items.findIndex((item) => item.key === from.key);
|
|
419
|
+
switch (event.key) {
|
|
420
|
+
case "ArrowRight":
|
|
421
|
+
case "ArrowDown": return items[Math.min(items.length - 1, i + 1)]?.key;
|
|
422
|
+
case "ArrowLeft":
|
|
423
|
+
case "ArrowUp": return items[Math.max(0, i - 1)]?.key;
|
|
424
|
+
case "Home": return items[0]?.key;
|
|
425
|
+
case "End": return items.at(-1)?.key;
|
|
426
|
+
default: return;
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
const roving = createRovingFocus({
|
|
430
|
+
store: rovingStore,
|
|
431
|
+
onDestroy: (cleanup) => onSettled(() => cleanup)
|
|
432
|
+
}, {
|
|
433
|
+
slot: "marker",
|
|
434
|
+
key: "focused",
|
|
435
|
+
preferred: (item) => item.key === selected(),
|
|
436
|
+
move: (event, context) => globe() ? listMove(event, context) : spatial(event, context)
|
|
437
|
+
});
|
|
438
|
+
const onMarkerFocus = (id, el) => {
|
|
439
|
+
setFocused({
|
|
440
|
+
id,
|
|
441
|
+
el,
|
|
442
|
+
visible: el.matches(":focus-visible")
|
|
443
|
+
});
|
|
444
|
+
const p = byId().get(id);
|
|
445
|
+
if (!p) return;
|
|
446
|
+
if (globe()) {
|
|
447
|
+
if (!p.shown) turnTo(rotationFacing([p.marker.longitude, p.marker.latitude], globeView().rotation[2]));
|
|
448
|
+
} else {
|
|
449
|
+
const [x, y] = p.at;
|
|
450
|
+
viewport.reveal({
|
|
451
|
+
left: x,
|
|
452
|
+
right: x,
|
|
453
|
+
top: y,
|
|
454
|
+
bottom: y
|
|
455
|
+
}, { padding: 40 });
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
const onPart = (target) => target instanceof Element && !!target.closest("[data-slot=\"geo-map-marker\"], [data-slot=\"geo-map-controls\"], [data-hit]");
|
|
459
|
+
const onPointerDown = (event) => {
|
|
460
|
+
if (!interactive() || event.button !== 0 || onPart(event.target)) return;
|
|
461
|
+
if (!globe()) return viewport.pointerdown(event);
|
|
462
|
+
cancelAnimationFrame(tween);
|
|
463
|
+
root?.setPointerCapture(event.pointerId);
|
|
464
|
+
dispatchGlobe({
|
|
465
|
+
type: "dragStart",
|
|
466
|
+
x: event.clientX,
|
|
467
|
+
y: event.clientY
|
|
468
|
+
});
|
|
469
|
+
};
|
|
470
|
+
const onPointerMove = (event) => {
|
|
471
|
+
if (globe() && globeNow?.drag) dispatchGlobe({
|
|
472
|
+
type: "dragMove",
|
|
473
|
+
x: event.clientX,
|
|
474
|
+
y: event.clientY
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
const onPointerUp = () => {
|
|
478
|
+
if (globe()) dispatchGlobe({ type: "dragEnd" });
|
|
479
|
+
};
|
|
480
|
+
const onWheel = (event) => {
|
|
481
|
+
if (!interactive()) return;
|
|
482
|
+
const zoomIntent = event.ctrlKey || event.metaKey;
|
|
483
|
+
if (globe()) {
|
|
484
|
+
if (!zoomIntent) return;
|
|
485
|
+
event.preventDefault();
|
|
486
|
+
dispatchGlobe({
|
|
487
|
+
type: "scaleBy",
|
|
488
|
+
factor: Math.exp(-event.deltaY / 200)
|
|
489
|
+
});
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (zoomIntent || flat().zoom > 1) viewport.wheel(event);
|
|
493
|
+
};
|
|
494
|
+
const onKeyDown = (event) => {
|
|
495
|
+
if (!interactive() || event.defaultPrevented) return;
|
|
496
|
+
if (!globe()) {
|
|
497
|
+
viewport.keydown(event);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
501
|
+
if (event.key === "+" || event.key === "=") zoomBy(ZOOM_STEP);
|
|
502
|
+
else if (event.key === "-" || event.key === "_") zoomBy(1 / ZOOM_STEP);
|
|
503
|
+
else if (event.key === "0") dispatchGlobe({
|
|
504
|
+
type: "scaleTo",
|
|
505
|
+
scale: 1
|
|
506
|
+
});
|
|
507
|
+
else return;
|
|
508
|
+
event.preventDefault();
|
|
509
|
+
};
|
|
510
|
+
onSettled(() => {
|
|
511
|
+
const el = root;
|
|
512
|
+
const observer = new ResizeObserver(() => {
|
|
513
|
+
const w = el.clientWidth;
|
|
514
|
+
const h = el.clientHeight;
|
|
515
|
+
if (w <= 0 || h <= 0) return;
|
|
516
|
+
const was = measured();
|
|
517
|
+
setMeasured({
|
|
518
|
+
w,
|
|
519
|
+
h
|
|
520
|
+
});
|
|
521
|
+
if (was && flatNow) {
|
|
522
|
+
flatNow = clampFlat({
|
|
523
|
+
zoom: flatNow.zoom,
|
|
524
|
+
x: flatNow.x * w / was.w,
|
|
525
|
+
y: flatNow.y * h / was.h
|
|
526
|
+
}, w, h);
|
|
527
|
+
setFlatMoved(flatNow);
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
observer.observe(el);
|
|
531
|
+
const idle = typeof requestIdleCallback === "function" ? requestIdleCallback(loadTooltip) : setTimeout(loadTooltip, 200);
|
|
532
|
+
props.controller?.({
|
|
533
|
+
fit,
|
|
534
|
+
zoomBy,
|
|
535
|
+
centerOn,
|
|
536
|
+
focus: (id) => roving.focus(id),
|
|
537
|
+
view
|
|
538
|
+
});
|
|
539
|
+
return () => {
|
|
540
|
+
observer.disconnect();
|
|
541
|
+
cancelAnimationFrame(tween);
|
|
542
|
+
if (typeof cancelIdleCallback === "function") cancelIdleCallback(idle);
|
|
543
|
+
else clearTimeout(idle);
|
|
544
|
+
};
|
|
545
|
+
});
|
|
546
|
+
const pct = (value, of) => `${value / of * 100}%`;
|
|
547
|
+
const worldTransform = () => {
|
|
548
|
+
if (globe()) return void 0;
|
|
549
|
+
const v = flat();
|
|
550
|
+
return v.zoom === 1 && v.x === 0 && v.y === 0 ? void 0 : `translate(${v.x} ${v.y}) scale(${v.zoom})`;
|
|
551
|
+
};
|
|
552
|
+
const markerLeft = (at) => {
|
|
553
|
+
const { w } = box();
|
|
554
|
+
if (globe()) return pct(at[0], w);
|
|
555
|
+
const v = flat();
|
|
556
|
+
return pct(v.x + at[0] * v.zoom, w);
|
|
557
|
+
};
|
|
558
|
+
const markerTop = (at) => {
|
|
559
|
+
const { h } = box();
|
|
560
|
+
if (globe()) return pct(at[1], h);
|
|
561
|
+
const v = flat();
|
|
562
|
+
return pct(v.y + at[1] * v.zoom, h);
|
|
563
|
+
};
|
|
564
|
+
const descriptionId = (id) => `${uid}-d-${id.replace(/[^\w-]/g, "_")}`;
|
|
565
|
+
const rootStyle = () => {
|
|
566
|
+
const own = {};
|
|
567
|
+
if (props.height !== void 0) own.height = typeof props.height === "number" ? `${props.height}px` : props.height;
|
|
568
|
+
return typeof props.style === "object" && props.style ? {
|
|
569
|
+
...own,
|
|
570
|
+
...props.style
|
|
571
|
+
} : own;
|
|
572
|
+
};
|
|
573
|
+
var _el$ = getNextElement(_tmpl$);
|
|
574
|
+
var _el$2 = _el$.firstChild;
|
|
575
|
+
var _el$3 = _el$2.firstChild;
|
|
576
|
+
var _el$4 = _el$3.firstChild;
|
|
577
|
+
var _el$5 = _el$4.nextSibling;
|
|
578
|
+
var [_el$6, _el$7] = getNextMarker(_el$5.nextSibling);
|
|
579
|
+
var _el$8 = _el$6.nextSibling;
|
|
580
|
+
var [_el$9, _el$10] = getNextMarker(_el$8.nextSibling);
|
|
581
|
+
var _el$11 = _el$9.nextSibling;
|
|
582
|
+
var _el$12 = _el$2.nextSibling;
|
|
583
|
+
var [_el$13, _el$14] = getNextMarker(_el$12.nextSibling);
|
|
584
|
+
var _el$15 = _el$13.nextSibling;
|
|
585
|
+
var [_el$16, _el$17] = getNextMarker(_el$15.nextSibling);
|
|
586
|
+
var _el$18 = _el$16.nextSibling;
|
|
587
|
+
var [_el$19, _el$20] = getNextMarker(_el$18.nextSibling);
|
|
588
|
+
spread(_el$, [rest, {
|
|
589
|
+
role: "group",
|
|
590
|
+
get "aria-roledescription"() {
|
|
591
|
+
return label("map");
|
|
592
|
+
},
|
|
593
|
+
get "aria-label"() {
|
|
594
|
+
return props.label;
|
|
595
|
+
},
|
|
596
|
+
"data-slot": "geo-map",
|
|
597
|
+
get "data-projection"() {
|
|
598
|
+
return props.projection ?? "naturalEarth";
|
|
599
|
+
},
|
|
600
|
+
get "data-loading"() {
|
|
601
|
+
return world() ? void 0 : "";
|
|
602
|
+
},
|
|
603
|
+
get "class"() {
|
|
604
|
+
return [stylex.props(styles.root, props.height === void 0 && styles.aspect, props.interactive !== false && styles.interactive, props.projection === "orthographic" && styles.globe).className, props.class];
|
|
605
|
+
},
|
|
606
|
+
get style() {
|
|
607
|
+
return rootStyle();
|
|
608
|
+
},
|
|
609
|
+
onPointerEnter: loadTooltip,
|
|
610
|
+
onFocusIn: loadTooltip,
|
|
611
|
+
onPointerDown,
|
|
612
|
+
onPointerMove,
|
|
613
|
+
onPointerUp,
|
|
614
|
+
onPointerCancel: onPointerUp,
|
|
615
|
+
onWheel,
|
|
616
|
+
onKeyDown
|
|
617
|
+
}], true);
|
|
618
|
+
ref(() => {
|
|
619
|
+
return (el) => root = el;
|
|
620
|
+
}, _el$);
|
|
621
|
+
spread(_el$2, [{
|
|
622
|
+
"data-slot": "geo-map-base",
|
|
623
|
+
"aria-hidden": "true",
|
|
624
|
+
get viewBox() {
|
|
625
|
+
return `0 0 ${box().w} ${box().h}`;
|
|
626
|
+
},
|
|
627
|
+
preserveAspectRatio: "none"
|
|
628
|
+
}, () => {
|
|
629
|
+
return stylex.attrs(styles.svg);
|
|
630
|
+
}], true);
|
|
631
|
+
spread(_el$4, [{
|
|
632
|
+
"data-slot": "geo-map-water",
|
|
633
|
+
get d() {
|
|
634
|
+
return sphere();
|
|
635
|
+
}
|
|
636
|
+
}, () => {
|
|
637
|
+
return stylex.attrs(styles.water);
|
|
638
|
+
}], false);
|
|
639
|
+
insert(_el$3, scope((() => {
|
|
640
|
+
var _c$ = memo(() => {
|
|
641
|
+
return !!graticule();
|
|
642
|
+
});
|
|
643
|
+
return () => {
|
|
644
|
+
return _c$() ? (() => {
|
|
645
|
+
var _el$21 = getNextElement(_tmpl$2);
|
|
646
|
+
spread(_el$21, [{
|
|
647
|
+
"data-slot": "geo-map-graticule",
|
|
648
|
+
get d() {
|
|
649
|
+
return graticule();
|
|
650
|
+
}
|
|
651
|
+
}, () => {
|
|
652
|
+
return stylex.attrs(styles.graticule);
|
|
653
|
+
}], false);
|
|
654
|
+
runHydrationEvents();
|
|
655
|
+
return _el$21;
|
|
656
|
+
})() : void 0;
|
|
657
|
+
};
|
|
658
|
+
})()), _el$6, _el$7);
|
|
659
|
+
insert(_el$3, scope((() => {
|
|
660
|
+
var _c$2 = memo(() => {
|
|
661
|
+
return !!land();
|
|
662
|
+
});
|
|
663
|
+
return () => {
|
|
664
|
+
return _c$2() ? (() => {
|
|
665
|
+
var _el$22 = getNextElement(_tmpl$2);
|
|
666
|
+
spread(_el$22, [{
|
|
667
|
+
"data-slot": "geo-map-land",
|
|
668
|
+
get d() {
|
|
669
|
+
return land();
|
|
670
|
+
}
|
|
671
|
+
}, () => {
|
|
672
|
+
return stylex.attrs(styles.land);
|
|
673
|
+
}], false);
|
|
674
|
+
runHydrationEvents();
|
|
675
|
+
return _el$22;
|
|
676
|
+
})() : void 0;
|
|
677
|
+
};
|
|
678
|
+
})()), _el$9, _el$10);
|
|
679
|
+
insert(_el$11, createComponent(For, {
|
|
680
|
+
get each() {
|
|
681
|
+
return drawn();
|
|
682
|
+
},
|
|
683
|
+
keyed: (c) => `${c.index}:${c.connection.source}>${c.connection.target}`,
|
|
684
|
+
children: (c) => (() => {
|
|
685
|
+
var _el$23 = getNextElement(_tmpl$3);
|
|
686
|
+
var _el$24 = _el$23.firstChild;
|
|
687
|
+
var _el$25 = _el$24.nextSibling;
|
|
688
|
+
spread(_el$25, [
|
|
689
|
+
{
|
|
690
|
+
get d() {
|
|
691
|
+
return c().d;
|
|
692
|
+
},
|
|
693
|
+
"data-hit": ""
|
|
694
|
+
},
|
|
695
|
+
() => {
|
|
696
|
+
return stylex.attrs(styles.connectionHit);
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
onPointerEnter: (event) => setHovered({
|
|
700
|
+
kind: "connection",
|
|
701
|
+
index: c().index,
|
|
702
|
+
x: event.clientX,
|
|
703
|
+
y: event.clientY
|
|
704
|
+
}),
|
|
705
|
+
onPointerLeave: () => setHovered(null),
|
|
706
|
+
onClick: () => props.onConnectionSelect?.(c().connection)
|
|
707
|
+
}
|
|
708
|
+
], false);
|
|
709
|
+
effect(() => {
|
|
710
|
+
return {
|
|
711
|
+
e: connectionState(c().connection),
|
|
712
|
+
t: c().color,
|
|
713
|
+
a: String(c().connection.weight ?? DEFAULT_WEIGHT),
|
|
714
|
+
o: c().d,
|
|
715
|
+
i: readShallow(stylex.props(styles.connection, connectionState(c().connection) === "active" && styles.connectionActive, connectionState(c().connection) === "dimmed" && styles.connectionDimmed, props.animated === true && styles.flowing).className)
|
|
716
|
+
};
|
|
717
|
+
}, ({ e, t, a, o, i }, _p$) => {
|
|
718
|
+
e !== _p$?.e && setAttribute(_el$23, "data-state", e);
|
|
719
|
+
t !== _p$?.t && setStyleProperty(_el$23, "--geo-map-color", t);
|
|
720
|
+
a !== _p$?.a && setStyleProperty(_el$23, "--geo-map-weight", a);
|
|
721
|
+
o !== _p$?.o && setAttribute(_el$24, "d", o);
|
|
722
|
+
className(_el$24, i, _p$?.i);
|
|
723
|
+
});
|
|
724
|
+
runHydrationEvents();
|
|
725
|
+
return _el$23;
|
|
726
|
+
})()
|
|
727
|
+
}));
|
|
728
|
+
insert(_el$, scope((() => {
|
|
729
|
+
var _c$3 = memo(() => {
|
|
730
|
+
return markers().length > 0;
|
|
731
|
+
});
|
|
732
|
+
return () => {
|
|
733
|
+
return _c$3() ? (() => {
|
|
734
|
+
var _el$26 = getNextElement(_tmpl$4);
|
|
735
|
+
spread(_el$26, [{
|
|
736
|
+
role: "listbox",
|
|
737
|
+
get "aria-label"() {
|
|
738
|
+
return label("markers");
|
|
739
|
+
},
|
|
740
|
+
"data-slot": "geo-map-markers"
|
|
741
|
+
}, () => {
|
|
742
|
+
return stylex.attrs(styles.markers);
|
|
743
|
+
}], true);
|
|
744
|
+
insert(_el$26, createComponent(For, {
|
|
745
|
+
get each() {
|
|
746
|
+
return ids();
|
|
747
|
+
},
|
|
748
|
+
children: (id) => {
|
|
749
|
+
let last;
|
|
750
|
+
const p = createMemo(() => last = byId().get(id) ?? last);
|
|
751
|
+
const part = {
|
|
752
|
+
key: id,
|
|
753
|
+
props: { value: id }
|
|
754
|
+
};
|
|
755
|
+
let el;
|
|
756
|
+
onSettled(() => {
|
|
757
|
+
markerEls.set(part.key, el);
|
|
758
|
+
const leave = roving.bind(el, part);
|
|
759
|
+
return () => {
|
|
760
|
+
leave();
|
|
761
|
+
markerEls.delete(part.key);
|
|
762
|
+
};
|
|
763
|
+
});
|
|
764
|
+
var _el$27 = getNextElement(_tmpl$5);
|
|
765
|
+
_el$27._$$keydown = (event) => {
|
|
766
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
767
|
+
event.preventDefault();
|
|
768
|
+
select(part.key);
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
if (event.key === "Escape" && focused()?.visible) {
|
|
772
|
+
setFocused({
|
|
773
|
+
...focused(),
|
|
774
|
+
visible: false
|
|
775
|
+
});
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
roving.keydown(event, el);
|
|
779
|
+
};
|
|
780
|
+
_el$27._$$click = () => select(part.key);
|
|
781
|
+
_el$27.addEventListener("blur", () => setFocused(null));
|
|
782
|
+
_el$27.addEventListener("focus", () => onMarkerFocus(part.key, el));
|
|
783
|
+
_el$27.addEventListener("pointerleave", () => setHovered(null));
|
|
784
|
+
_el$27.addEventListener("pointerenter", () => setHovered({
|
|
785
|
+
kind: "marker",
|
|
786
|
+
id: part.key,
|
|
787
|
+
el
|
|
788
|
+
}));
|
|
789
|
+
ref(() => {
|
|
790
|
+
return (node) => el = node;
|
|
791
|
+
}, _el$27);
|
|
792
|
+
insert(_el$27, createComponent(Show, {
|
|
793
|
+
get when() {
|
|
794
|
+
return p().marker.description;
|
|
795
|
+
},
|
|
796
|
+
children: (description) => (() => {
|
|
797
|
+
var _el$28 = getNextElement(_tmpl$6);
|
|
798
|
+
insert(_el$28, scope(() => {
|
|
799
|
+
return description();
|
|
800
|
+
}));
|
|
801
|
+
effect(() => descriptionId(p().marker.id), (_v$) => {
|
|
802
|
+
setAttribute(_el$28, "id", _v$);
|
|
803
|
+
});
|
|
804
|
+
return _el$28;
|
|
805
|
+
})()
|
|
806
|
+
}));
|
|
807
|
+
effect(() => {
|
|
808
|
+
return {
|
|
809
|
+
e: markerName(p().marker),
|
|
810
|
+
t: selected() === p().marker.id ? "true" : "false",
|
|
811
|
+
a: p().marker.description ? descriptionId(p().marker.id) : void 0,
|
|
812
|
+
o: roving.tabIndex({ focused: stop() }, part),
|
|
813
|
+
i: p().marker.id,
|
|
814
|
+
n: p().marker.group,
|
|
815
|
+
s: active() === p().marker.id ? "" : void 0,
|
|
816
|
+
h: dimmedMarker(p().marker.id) ? "" : void 0,
|
|
817
|
+
r: p().shown ? void 0 : "",
|
|
818
|
+
d: readShallow(stylex.props(styles.marker, !p().shown && styles.farSide).className),
|
|
819
|
+
l: markerLeft(p().at),
|
|
820
|
+
u: markerTop(p().at),
|
|
821
|
+
c: p().color,
|
|
822
|
+
w: String(p().marker.radius ?? DEFAULT_RADIUS)
|
|
823
|
+
};
|
|
824
|
+
}, ({ e, t, a, o, i, n, s, h, r, d, l, u, c, w }, _p$) => {
|
|
825
|
+
e !== _p$?.e && setAttribute(_el$27, "aria-label", e);
|
|
826
|
+
t !== _p$?.t && setAttribute(_el$27, "aria-selected", t);
|
|
827
|
+
a !== _p$?.a && setAttribute(_el$27, "aria-describedby", a);
|
|
828
|
+
o !== _p$?.o && setAttribute(_el$27, "tabindex", o);
|
|
829
|
+
i !== _p$?.i && setAttribute(_el$27, "data-id", i);
|
|
830
|
+
n !== _p$?.n && setAttribute(_el$27, "data-group", n);
|
|
831
|
+
s !== _p$?.s && setAttribute(_el$27, "data-active", s);
|
|
832
|
+
h !== _p$?.h && setAttribute(_el$27, "data-dimmed", h);
|
|
833
|
+
r !== _p$?.r && setAttribute(_el$27, "data-hidden", r);
|
|
834
|
+
className(_el$27, d, _p$?.d);
|
|
835
|
+
l !== _p$?.l && setStyleProperty(_el$27, "left", l);
|
|
836
|
+
u !== _p$?.u && setStyleProperty(_el$27, "top", u);
|
|
837
|
+
c !== _p$?.c && setStyleProperty(_el$27, "--geo-map-color", c);
|
|
838
|
+
w !== _p$?.w && setStyleProperty(_el$27, "--geo-map-radius", w);
|
|
839
|
+
});
|
|
840
|
+
runHydrationEvents();
|
|
841
|
+
return _el$27;
|
|
842
|
+
}
|
|
843
|
+
}));
|
|
844
|
+
runHydrationEvents();
|
|
845
|
+
return _el$26;
|
|
846
|
+
})() : void 0;
|
|
847
|
+
};
|
|
848
|
+
})()), _el$13, _el$14);
|
|
849
|
+
insert(_el$, scope((() => {
|
|
850
|
+
var _c$4 = memo(() => {
|
|
851
|
+
return !!(interactive() && props.controls !== false);
|
|
852
|
+
});
|
|
853
|
+
return () => {
|
|
854
|
+
return _c$4() ? (() => {
|
|
855
|
+
var _el$29 = getNextElement(_tmpl$7);
|
|
856
|
+
var _el$30 = _el$29.firstChild;
|
|
857
|
+
var [_el$31, _el$32] = getNextMarker(_el$30.nextSibling);
|
|
858
|
+
var _el$33 = _el$31.nextSibling;
|
|
859
|
+
var [_el$34, _el$35] = getNextMarker(_el$33.nextSibling);
|
|
860
|
+
var _el$36 = _el$34.nextSibling;
|
|
861
|
+
var [_el$37, _el$38] = getNextMarker(_el$36.nextSibling);
|
|
862
|
+
spread(_el$29, [{ "data-slot": "geo-map-controls" }, () => {
|
|
863
|
+
return stylex.attrs(styles.controls);
|
|
864
|
+
}], true);
|
|
865
|
+
insert(_el$29, createComponent(IconButton, {
|
|
866
|
+
size: "sm",
|
|
867
|
+
variant: "secondary",
|
|
868
|
+
get label() {
|
|
869
|
+
return label("zoomIn");
|
|
870
|
+
},
|
|
871
|
+
onClick: () => zoomBy(ZOOM_STEP),
|
|
872
|
+
get children() {
|
|
873
|
+
return createComponent(Icon, { icon: Plus });
|
|
874
|
+
}
|
|
875
|
+
}), _el$31, _el$32);
|
|
876
|
+
insert(_el$29, createComponent(IconButton, {
|
|
877
|
+
size: "sm",
|
|
878
|
+
variant: "secondary",
|
|
879
|
+
get label() {
|
|
880
|
+
return label("zoomOut");
|
|
881
|
+
},
|
|
882
|
+
onClick: () => zoomBy(1 / ZOOM_STEP),
|
|
883
|
+
get children() {
|
|
884
|
+
return createComponent(Icon, { icon: Minus });
|
|
885
|
+
}
|
|
886
|
+
}), _el$34, _el$35);
|
|
887
|
+
insert(_el$29, createComponent(IconButton, {
|
|
888
|
+
size: "sm",
|
|
889
|
+
variant: "secondary",
|
|
890
|
+
get label() {
|
|
891
|
+
return label("fit");
|
|
892
|
+
},
|
|
893
|
+
onClick: () => fit(),
|
|
894
|
+
get children() {
|
|
895
|
+
return createComponent(Icon, { icon: Scan });
|
|
896
|
+
}
|
|
897
|
+
}), _el$37, _el$38);
|
|
898
|
+
runHydrationEvents();
|
|
899
|
+
return _el$29;
|
|
900
|
+
})() : void 0;
|
|
901
|
+
};
|
|
902
|
+
})()), _el$16, _el$17);
|
|
903
|
+
insert(_el$, createComponent(Show, {
|
|
904
|
+
get when() {
|
|
905
|
+
return tooltipKit();
|
|
906
|
+
},
|
|
907
|
+
keyed: true,
|
|
908
|
+
children: (kit) => createComponent(kit.Tooltip, {
|
|
909
|
+
get open() {
|
|
910
|
+
return tip() !== null;
|
|
911
|
+
},
|
|
912
|
+
onOpenChange: (open) => {
|
|
913
|
+
if (open) return;
|
|
914
|
+
setHovered(null);
|
|
915
|
+
const f = focused();
|
|
916
|
+
if (f) setFocused({
|
|
917
|
+
...f,
|
|
918
|
+
visible: false
|
|
919
|
+
});
|
|
920
|
+
},
|
|
921
|
+
get children() {
|
|
922
|
+
return createComponent(kit.TooltipContent, {
|
|
923
|
+
get anchor() {
|
|
924
|
+
return tipAnchor();
|
|
925
|
+
},
|
|
926
|
+
"data-slot": "geo-map-tooltip",
|
|
927
|
+
get children() {
|
|
928
|
+
var _el$39 = getNextElement(_tmpl$8);
|
|
929
|
+
var _el$40 = _el$39.firstChild;
|
|
930
|
+
var [_el$41, _el$42] = getNextMarker(_el$40.nextSibling);
|
|
931
|
+
var _el$43 = _el$41.nextSibling;
|
|
932
|
+
var [_el$44, _el$45] = getNextMarker(_el$43.nextSibling);
|
|
933
|
+
spread(_el$39, () => {
|
|
934
|
+
return stylex.attrs(styles.tooltipBody);
|
|
935
|
+
}, true);
|
|
936
|
+
insert(_el$39, createComponent(Show, {
|
|
937
|
+
get when() {
|
|
938
|
+
return tipMarker();
|
|
939
|
+
},
|
|
940
|
+
children: (p) => props.tooltip ? props.tooltip(p().marker) : [
|
|
941
|
+
(() => {
|
|
942
|
+
var _el$46 = getNextElement(_tmpl$9);
|
|
943
|
+
spread(_el$46, () => {
|
|
944
|
+
return stylex.attrs(styles.tooltipTitle);
|
|
945
|
+
}, true);
|
|
946
|
+
insert(_el$46, scope(() => {
|
|
947
|
+
return p().marker.name;
|
|
948
|
+
}));
|
|
949
|
+
runHydrationEvents();
|
|
950
|
+
return _el$46;
|
|
951
|
+
})(),
|
|
952
|
+
createComponent(Show, {
|
|
953
|
+
get when() {
|
|
954
|
+
return p().marker.description;
|
|
955
|
+
},
|
|
956
|
+
children: (description) => (() => {
|
|
957
|
+
var _el$47 = getNextElement(_tmpl$9);
|
|
958
|
+
spread(_el$47, () => {
|
|
959
|
+
return stylex.attrs(styles.tooltipLine);
|
|
960
|
+
}, true);
|
|
961
|
+
insert(_el$47, scope(() => {
|
|
962
|
+
return description();
|
|
963
|
+
}));
|
|
964
|
+
runHydrationEvents();
|
|
965
|
+
return _el$47;
|
|
966
|
+
})()
|
|
967
|
+
}),
|
|
968
|
+
memo(() => {
|
|
969
|
+
return memo(() => {
|
|
970
|
+
return !!hasConnections();
|
|
971
|
+
})() ? (() => {
|
|
972
|
+
var _el$48 = getNextElement(_tmpl$9);
|
|
973
|
+
spread(_el$48, () => {
|
|
974
|
+
return stylex.attrs(styles.tooltipLine);
|
|
975
|
+
}, true);
|
|
976
|
+
insert(_el$48, scope(() => {
|
|
977
|
+
return label("connections")(links().get(p().marker.id)?.size ?? 0);
|
|
978
|
+
}));
|
|
979
|
+
runHydrationEvents();
|
|
980
|
+
return _el$48;
|
|
981
|
+
})() : void 0;
|
|
982
|
+
})
|
|
983
|
+
]
|
|
984
|
+
}), _el$41, _el$42);
|
|
985
|
+
insert(_el$39, createComponent(Show, {
|
|
986
|
+
get when() {
|
|
987
|
+
return tipConnection();
|
|
988
|
+
},
|
|
989
|
+
children: (c) => [(() => {
|
|
990
|
+
var _el$49 = getNextElement(_tmpl$10);
|
|
991
|
+
var _el$50 = _el$49.firstChild;
|
|
992
|
+
var [_el$51, _el$52] = getNextMarker(_el$50.nextSibling);
|
|
993
|
+
var _el$54 = _el$51.nextSibling.nextSibling;
|
|
994
|
+
var [_el$55, _el$56] = getNextMarker(_el$54.nextSibling);
|
|
995
|
+
spread(_el$49, () => {
|
|
996
|
+
return stylex.attrs(styles.tooltipTitle);
|
|
997
|
+
}, true);
|
|
998
|
+
insert(_el$49, scope(() => {
|
|
999
|
+
return byId().get(c().source)?.marker.name ?? c().source;
|
|
1000
|
+
}), _el$51, _el$52);
|
|
1001
|
+
insert(_el$49, scope(() => {
|
|
1002
|
+
return byId().get(c().target)?.marker.name ?? c().target;
|
|
1003
|
+
}), _el$55, _el$56);
|
|
1004
|
+
runHydrationEvents();
|
|
1005
|
+
return _el$49;
|
|
1006
|
+
})(), createComponent(Show, {
|
|
1007
|
+
get when() {
|
|
1008
|
+
return c().label;
|
|
1009
|
+
},
|
|
1010
|
+
children: (text) => (() => {
|
|
1011
|
+
var _el$57 = getNextElement(_tmpl$9);
|
|
1012
|
+
spread(_el$57, () => {
|
|
1013
|
+
return stylex.attrs(styles.tooltipLine);
|
|
1014
|
+
}, true);
|
|
1015
|
+
insert(_el$57, scope(() => {
|
|
1016
|
+
return text();
|
|
1017
|
+
}));
|
|
1018
|
+
runHydrationEvents();
|
|
1019
|
+
return _el$57;
|
|
1020
|
+
})()
|
|
1021
|
+
})]
|
|
1022
|
+
}), _el$44, _el$45);
|
|
1023
|
+
runHydrationEvents();
|
|
1024
|
+
return _el$39;
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
})
|
|
1029
|
+
}), _el$19, _el$20);
|
|
1030
|
+
effect(() => worldTransform(), (_v$) => {
|
|
1031
|
+
setAttribute(_el$3, "transform", _v$);
|
|
1032
|
+
});
|
|
1033
|
+
runHydrationEvents();
|
|
1034
|
+
return _el$;
|
|
1035
|
+
}
|
|
1036
|
+
delegateEvents(["click", "keydown"]);
|
|
1037
|
+
export { GeoMap, geoMapColor };
|