@newtone-dev/ui-react-web 0.66.0 → 0.68.0
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/dialog/dialog.css +101 -0
- package/dist/dialog/dialog.d.ts +40 -0
- package/dist/dialog/dialog.d.ts.map +1 -0
- package/dist/dialog/dialog.js +49 -0
- package/dist/dialog/dialog.js.map +1 -0
- package/dist/dialog/index.d.ts +5 -0
- package/dist/dialog/index.d.ts.map +1 -0
- package/dist/dialog/index.js +3 -0
- package/dist/dialog/index.js.map +1 -0
- package/dist/dialog/use-scrolled-to-end.d.ts +17 -0
- package/dist/dialog/use-scrolled-to-end.d.ts.map +1 -0
- package/dist/dialog/use-scrolled-to-end.js +33 -0
- package/dist/dialog/use-scrolled-to-end.js.map +1 -0
- package/dist/icon/icon.css +8 -0
- package/dist/icon/icon.d.ts +7 -1
- package/dist/icon/icon.d.ts.map +1 -1
- package/dist/icon/icon.js +3 -2
- package/dist/icon/icon.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/nav-list/nav-list.css +18 -1
- package/dist/nav-list/nav-list.d.ts +23 -2
- package/dist/nav-list/nav-list.d.ts.map +1 -1
- package/dist/nav-list/nav-list.js +44 -6
- package/dist/nav-list/nav-list.js.map +1 -1
- package/dist/node-map/beads-gl.d.ts +38 -0
- package/dist/node-map/beads-gl.d.ts.map +1 -1
- package/dist/node-map/beads-gl.js +258 -28
- package/dist/node-map/beads-gl.js.map +1 -1
- package/dist/node-map/index.d.ts +1 -1
- package/dist/node-map/index.d.ts.map +1 -1
- package/dist/node-map/index.js +1 -1
- package/dist/node-map/index.js.map +1 -1
- package/dist/node-map/node-map-3d.d.ts +1 -1
- package/dist/node-map/node-map-3d.d.ts.map +1 -1
- package/dist/node-map/node-map-3d.js +447 -83
- package/dist/node-map/node-map-3d.js.map +1 -1
- package/dist/node-map/node-map.css +68 -3
- package/dist/node-map/node-map.d.ts +41 -0
- package/dist/node-map/node-map.d.ts.map +1 -1
- package/dist/node-map/node-map.js +9 -3
- package/dist/node-map/node-map.js.map +1 -1
- package/dist/node-map/space.d.ts +121 -0
- package/dist/node-map/space.d.ts.map +1 -1
- package/dist/node-map/space.js +551 -1
- package/dist/node-map/space.js.map +1 -1
- package/dist/pick/index.d.ts +29 -0
- package/dist/pick/index.d.ts.map +1 -0
- package/dist/pick/index.js +45 -0
- package/dist/pick/index.js.map +1 -0
- package/dist/pick/palettes.d.ts +2 -0
- package/dist/pick/palettes.d.ts.map +1 -0
- package/dist/pick/palettes.js +3 -0
- package/dist/pick/palettes.js.map +1 -0
- package/dist/pick/pick.css +634 -0
- package/dist/shade-picker/index.d.ts +5 -0
- package/dist/shade-picker/index.d.ts.map +1 -0
- package/dist/shade-picker/index.js +3 -0
- package/dist/shade-picker/index.js.map +1 -0
- package/dist/shade-picker/shade-picker.css +52 -0
- package/dist/shade-picker/shade-picker.d.ts +31 -0
- package/dist/shade-picker/shade-picker.d.ts.map +1 -0
- package/dist/shade-picker/shade-picker.js +61 -0
- package/dist/shade-picker/shade-picker.js.map +1 -0
- package/dist/split/split.css +1 -0
- package/dist/split/split.d.ts +9 -1
- package/dist/split/split.d.ts.map +1 -1
- package/dist/split/split.js +2 -2
- package/dist/split/split.js.map +1 -1
- package/dist/tag/tag.css +10 -0
- package/dist/tag/tag.d.ts +8 -1
- package/dist/tag/tag.d.ts.map +1 -1
- package/dist/tag/tag.js +3 -2
- package/dist/tag/tag.js.map +1 -1
- package/dist/toast/index.d.ts +3 -0
- package/dist/toast/index.d.ts.map +1 -0
- package/dist/toast/index.js +2 -0
- package/dist/toast/index.js.map +1 -0
- package/dist/toast/toast.css +61 -0
- package/dist/toast/toast.d.ts +23 -0
- package/dist/toast/toast.d.ts.map +1 -0
- package/dist/toast/toast.js +76 -0
- package/dist/toast/toast.js.map +1 -0
- package/package.json +23 -1
|
@@ -3,7 +3,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { useCallback, useEffect, useId, useMemo, useRef, useState, } from 'react';
|
|
4
4
|
import { MapOver, MapTools } from './over.js';
|
|
5
5
|
import { beadsOn, rgbOf } from './beads-gl.js';
|
|
6
|
-
import { boundsOf, FIT, fitted, focalOf, seen,
|
|
6
|
+
import { boundsOf, branchOf, layoutOf, placePills, FIT, fitted, focalOf, seen, turned, unturned, } from './space.js';
|
|
7
7
|
// A mark's radius, in pixels, at the target's depth.
|
|
8
8
|
const MARK = 4;
|
|
9
9
|
// How many names show at once when nothing is chosen, nearest first; and how many of the chosen one's ties.
|
|
@@ -96,6 +96,25 @@ export function floorOf(color, ground, want = TIE_CONTRAST) {
|
|
|
96
96
|
return hi;
|
|
97
97
|
}
|
|
98
98
|
const ALPHA = { dashed: 0.45 };
|
|
99
|
+
// A pill (s_map_pills): its name's size and weight at the target's depth, its height, the room either side of its name,
|
|
100
|
+
// how much depth may grow or shrink it, and the deepest fog it takes, so a far topic still reads.
|
|
101
|
+
const PILL_FONT = 12;
|
|
102
|
+
const PILL_H = 24;
|
|
103
|
+
const PILL_PAD = 10;
|
|
104
|
+
const PILL_SMALLEST = 0.75;
|
|
105
|
+
const PILL_BIGGEST = 1.3;
|
|
106
|
+
const PILL_FOG = 0.6;
|
|
107
|
+
const PILL_CHARS = 40;
|
|
108
|
+
// How see-through a pill is when it finds no room on the screen this frame (it then takes no presses).
|
|
109
|
+
const PILL_FADED = 0.25;
|
|
110
|
+
// A pill's tint of its look's colour at rest and pointed at; pressed or chosen it is filled with it.
|
|
111
|
+
const PILL_REST = 0.1;
|
|
112
|
+
const PILL_HOVER = 0.24;
|
|
113
|
+
// How far a press may wander, in CSS pixels, and still be a press rather than a turn: a mouse or pen, and a finger.
|
|
114
|
+
const PRESS_SLOP = 6;
|
|
115
|
+
const TOUCH_SLOP = 10;
|
|
116
|
+
// How long a branch takes to fade in or out, in ms (s_map_branch).
|
|
117
|
+
const BRANCH_FADE = 250;
|
|
99
118
|
const clip = (s, n) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
|
|
100
119
|
const lerp = (a, b, t) => a + (b - a) * t;
|
|
101
120
|
/**
|
|
@@ -105,7 +124,9 @@ const lerp = (a, b, t) => a + (b - a) * t;
|
|
|
105
124
|
* pointed node, its ties, and the nearest `named` nodes, never more than a few at once. Drawn in SVG with the same
|
|
106
125
|
* looks as the flat map; a hidden list of the nodes, in a steady order, is what Tab and assistive tech reach.
|
|
107
126
|
*/
|
|
108
|
-
export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labels, fresh, light = 'world', home, }) {
|
|
127
|
+
export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labels, fresh, light = 'world', home, layout = 'force', branch, hoverNames = 'many', blur = true, links = 'contrast', }) {
|
|
128
|
+
const one = hoverNames === 'one';
|
|
129
|
+
const plain = links === 'plain';
|
|
109
130
|
const svg = useRef(null);
|
|
110
131
|
const root = useRef(null);
|
|
111
132
|
const canvas = useRef(null);
|
|
@@ -128,6 +149,7 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
128
149
|
}, []);
|
|
129
150
|
// Each look's colour, read from the tokens, and read again when the mode or the style changes.
|
|
130
151
|
const [paints, setPaints] = useState(null);
|
|
152
|
+
const [font, setFont] = useState({ family: 'sans-serif', weight: '600' });
|
|
131
153
|
useEffect(() => {
|
|
132
154
|
const read = () => {
|
|
133
155
|
const el = probe.current;
|
|
@@ -137,6 +159,13 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
137
159
|
for (const [k, css] of Object.entries(PAINTS))
|
|
138
160
|
out[k] = rgbOf(css, el);
|
|
139
161
|
setPaints(out);
|
|
162
|
+
const cs = getComputedStyle(el);
|
|
163
|
+
const family = (svg.current ? getComputedStyle(svg.current).fontFamily : '') ||
|
|
164
|
+
cs.fontFamily ||
|
|
165
|
+
'sans-serif';
|
|
166
|
+
setFont((f) => f.family === family && f.weight === cs.fontWeight
|
|
167
|
+
? f
|
|
168
|
+
: { family, weight: cs.fontWeight || '600' });
|
|
140
169
|
};
|
|
141
170
|
read();
|
|
142
171
|
const watch = new MutationObserver(read);
|
|
@@ -152,7 +181,33 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
152
181
|
// The beads' shared paints (a satin body per look, the light inside, the shadow), named for this map alone.
|
|
153
182
|
const paint = `newtone-node-map-${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`;
|
|
154
183
|
const isFresh = useMemo(() => new Set(fresh ?? []), [fresh]);
|
|
155
|
-
const space = useMemo(() =>
|
|
184
|
+
const space = useMemo(() => layoutOf(nodes, edges, layout, home), [nodes, edges, layout, home]);
|
|
185
|
+
// The branch drawn alone, if any (s_map_branch); null draws everything.
|
|
186
|
+
const visible = useMemo(() => (branch ? branchOf(nodes, edges, home, branch) : null), [nodes, edges, home, branch]);
|
|
187
|
+
const drawn = (id) => !visible || visible.has(id);
|
|
188
|
+
// Each pill's name as drawn and its width at scale 1, measured in the pills' own font.
|
|
189
|
+
const pillText = useMemo(() => {
|
|
190
|
+
const m = new Map();
|
|
191
|
+
const pills = nodes.filter((n) => n.shape === 'pill');
|
|
192
|
+
if (!pills.length)
|
|
193
|
+
return m;
|
|
194
|
+
const c = typeof document !== 'undefined' ? document.createElement('canvas') : null;
|
|
195
|
+
let x = null;
|
|
196
|
+
try {
|
|
197
|
+
x = c?.getContext('2d') ?? null;
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
x = null;
|
|
201
|
+
}
|
|
202
|
+
if (x)
|
|
203
|
+
x.font = `${font.weight} ${PILL_FONT}px ${font.family}`;
|
|
204
|
+
for (const n of pills) {
|
|
205
|
+
const text = clip(n.label, PILL_CHARS);
|
|
206
|
+
const w = x?.measureText(text).width || text.length * PILL_FONT * 0.55;
|
|
207
|
+
m.set(n.id, { text, w });
|
|
208
|
+
}
|
|
209
|
+
return m;
|
|
210
|
+
}, [nodes, font]);
|
|
156
211
|
const bounds = useMemo(() => boundsOf(space.values()), [space]);
|
|
157
212
|
const [box, setBox] = useState({ w: 0, h: 0 });
|
|
158
213
|
// The node the map turns round while nothing is chosen (2026-12-05), if the consumer names one: every view that
|
|
@@ -160,10 +215,22 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
160
215
|
const homeAt = home ? space.get(home) : undefined;
|
|
161
216
|
const homeNow = useRef(homeAt);
|
|
162
217
|
homeNow.current = homeAt;
|
|
218
|
+
// A burst is a ball round its home (2026-12-05): its views fit that ball, as `firstView` says, so a lopsided map
|
|
219
|
+
// does not stand farther off than it needs to.
|
|
220
|
+
const homeReach = useMemo(() => {
|
|
221
|
+
if (layout !== 'burst' || !homeAt)
|
|
222
|
+
return 0;
|
|
223
|
+
let r = 0;
|
|
224
|
+
for (const p of space.values())
|
|
225
|
+
r = Math.max(r, Math.hypot(p.x - homeAt.x, p.y - homeAt.y, p.z - homeAt.z));
|
|
226
|
+
return r;
|
|
227
|
+
}, [layout, homeAt, space]);
|
|
163
228
|
const around = (c) => {
|
|
164
229
|
const h = homeNow.current;
|
|
165
230
|
if (!h)
|
|
166
231
|
return c;
|
|
232
|
+
if (homeReach > 0)
|
|
233
|
+
return { ...c, target: h, dist: homeReach * FIT };
|
|
167
234
|
const off = Math.hypot(h.x - c.target.x, h.y - c.target.y, h.z - c.target.z);
|
|
168
235
|
return { ...c, target: h, dist: c.dist + off };
|
|
169
236
|
};
|
|
@@ -221,7 +288,13 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
221
288
|
Math.abs(yaw - (g.yaw ?? yaw)) < 0.002 &&
|
|
222
289
|
Math.abs(pitch - (g.pitch ?? pitch)) < 0.002;
|
|
223
290
|
return done
|
|
224
|
-
? {
|
|
291
|
+
? {
|
|
292
|
+
...c,
|
|
293
|
+
target: g.target,
|
|
294
|
+
dist: g.dist,
|
|
295
|
+
yaw: g.yaw ?? c.yaw,
|
|
296
|
+
pitch: g.pitch ?? c.pitch,
|
|
297
|
+
}
|
|
225
298
|
: { ...c, target: t, dist, yaw, pitch };
|
|
226
299
|
});
|
|
227
300
|
if (done)
|
|
@@ -286,8 +359,11 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
286
359
|
// A drag orbits; two fingers pinch. As on the flat map, the pointer is taken only once it moves.
|
|
287
360
|
const down = useRef(new Map());
|
|
288
361
|
const moved = useRef(false);
|
|
362
|
+
// Where each pointer went down, to tell a press that wobbled from a drag.
|
|
363
|
+
const start = useRef(new Map());
|
|
289
364
|
const press = (e) => {
|
|
290
365
|
down.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
366
|
+
start.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
291
367
|
moved.current = false;
|
|
292
368
|
interacting.current = true;
|
|
293
369
|
};
|
|
@@ -299,7 +375,11 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
299
375
|
const others = [...down.current.entries()]
|
|
300
376
|
.filter(([id]) => id !== e.pointerId)
|
|
301
377
|
.map(([, p]) => p);
|
|
302
|
-
|
|
378
|
+
// A hand's press wobbles a few pixels (2026-12-05: a real click on a pill moved 2 to 3px and was taken for a
|
|
379
|
+
// turn, so nothing was chosen): only past PRESS_SLOP (TOUCH_SLOP for a finger) is it a drag.
|
|
380
|
+
const slop = e.pointerType === 'touch' ? TOUCH_SLOP : PRESS_SLOP;
|
|
381
|
+
const from = start.current.get(e.pointerId) ?? was;
|
|
382
|
+
if (!moved.current && Math.hypot(now.x - from.x, now.y - from.y) > slop) {
|
|
303
383
|
moved.current = true;
|
|
304
384
|
if (!e.currentTarget.hasPointerCapture(e.pointerId))
|
|
305
385
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
@@ -322,6 +402,7 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
322
402
|
};
|
|
323
403
|
const release = (e) => {
|
|
324
404
|
down.current.delete(e.pointerId);
|
|
405
|
+
start.current.delete(e.pointerId);
|
|
325
406
|
if (!down.current.size)
|
|
326
407
|
interacting.current = false;
|
|
327
408
|
};
|
|
@@ -338,11 +419,13 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
338
419
|
}, [nodes, space, cam, f, box.w, box.h]);
|
|
339
420
|
const near = bounds.reach * 0.05;
|
|
340
421
|
const inView = (id) => (at.get(id)?.depth ?? -1) > near;
|
|
341
|
-
|
|
422
|
+
// Every node in view, farthest first (what the spheres' painter may still be fading), and those of them drawn.
|
|
423
|
+
const allOrder = useMemo(() => nodes
|
|
342
424
|
.filter((n) => inView(n.id))
|
|
343
425
|
.sort((a, b) => at.get(b.id).depth - at.get(a.id).depth),
|
|
344
426
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
345
427
|
[nodes, at]);
|
|
428
|
+
const order = useMemo(() => (visible ? allOrder.filter((n) => visible.has(n.id)) : allOrder), [allOrder, visible]);
|
|
346
429
|
// How faint a node is by its depth: the nearest full, the farthest FAINTEST.
|
|
347
430
|
const [nearest, farthest] = order.length
|
|
348
431
|
? [at.get(order[order.length - 1].id).depth, at.get(order[0].id).depth]
|
|
@@ -351,6 +434,12 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
351
434
|
// A tie fades with depth only as far as it still stands TIE_CONTRAST off the ground (2026-12-05).
|
|
352
435
|
const tieFloor = useMemo(() => (paints ? floorOf(paints.tie, paints.ground) : FAINTEST), [paints]);
|
|
353
436
|
const tieFade = (depth) => Math.max(fade(depth), tieFloor);
|
|
437
|
+
// A plain tie (s_map_link_plain) fades at each end as a sphere there sinks into the fog; in the nearer half of the
|
|
438
|
+
// depth it keeps the 3 to 1 floor, which lets go evenly over the farther half.
|
|
439
|
+
const plainFade = (depth) => {
|
|
440
|
+
const t = depthT(depth);
|
|
441
|
+
return Math.max(1 - SPHERE_FOG * t, tieFloor * Math.min(1, 2 * (1 - t)));
|
|
442
|
+
};
|
|
354
443
|
const ties = useMemo(() => {
|
|
355
444
|
const m = new Map();
|
|
356
445
|
for (const e of edges) {
|
|
@@ -364,12 +453,142 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
364
453
|
return m;
|
|
365
454
|
}, [edges]);
|
|
366
455
|
const byId = useMemo(() => new Map(nodes.map((n) => [n.id, n])), [nodes]);
|
|
367
|
-
|
|
456
|
+
// What choosing keeps lit (2026-12-05): a chosen pill (or the branch shown) keeps all it holds and its way home, so a
|
|
457
|
+
// branch is never dimmed by its own pill; a chosen bead keeps its ties, among what is drawn.
|
|
458
|
+
const pillChosen = !!selected && (byId.get(selected)?.shape === 'pill' || selected === branch);
|
|
459
|
+
const litSet = useMemo(() => {
|
|
460
|
+
if (!selected)
|
|
461
|
+
return null;
|
|
462
|
+
if (pillChosen)
|
|
463
|
+
return branchOf(nodes, edges, home, selected);
|
|
464
|
+
return new Set([selected, ...(ties.get(selected) ?? [])]);
|
|
465
|
+
}, [selected, pillChosen, nodes, edges, home, ties]);
|
|
466
|
+
const lit = (id) => !litSet || litSet.has(id);
|
|
467
|
+
// Whether a tie stays bright while something is chosen: both ends lit, and touching the chosen bead (any tie of a
|
|
468
|
+
// chosen pill's branch).
|
|
469
|
+
const tieOn = (from, to) => lit(from) && lit(to) && (!selected || pillChosen || from === selected || to === selected);
|
|
368
470
|
const [pointed, setPointed] = useState(null);
|
|
471
|
+
const pointedNow = useRef(pointed);
|
|
472
|
+
pointedNow.current = pointed;
|
|
473
|
+
// The pill a pointer is held down on, drawn pressed until let go.
|
|
474
|
+
const [held, setHeld] = useState(null);
|
|
369
475
|
const focus = pointed ?? selected;
|
|
476
|
+
const isPill = (id) => byId.get(id)?.shape === 'pill';
|
|
370
477
|
// A big graph draws its marks smaller, so a crowd of them still reads as separate nodes.
|
|
371
478
|
const crowd = Math.min(1, Math.max(CROWDED, Math.sqrt(ROOMY / Math.max(1, nodes.length))));
|
|
372
479
|
const sizeOf = (s) => Math.min(BIGGEST, Math.max(SMALLEST, s)) * crowd;
|
|
480
|
+
// A pill's size where it falls: its scale, half width and half height in CSS pixels.
|
|
481
|
+
const pillOf = (id, s) => {
|
|
482
|
+
const scale = Math.min(PILL_BIGGEST, Math.max(PILL_SMALLEST, s));
|
|
483
|
+
const hh = (PILL_H / 2) * scale;
|
|
484
|
+
const hw = Math.max(hh, ((pillText.get(id)?.w ?? 0) / 2 + PILL_PAD) * scale);
|
|
485
|
+
return { scale, hw, hh };
|
|
486
|
+
};
|
|
487
|
+
// Where each pill stands on the screen this frame (s_map_pills, 2026-12-05): pills are drawn over everything, so two
|
|
488
|
+
// must never stand on each other. Topics take their places first, then the nearer pills; a pill that would stand on
|
|
489
|
+
// one already placed moves up or down by its own height until it is free, and one that finds no room is faded and
|
|
490
|
+
// takes no presses.
|
|
491
|
+
const pillPlaces = useMemo(() => {
|
|
492
|
+
const out = new Map();
|
|
493
|
+
const list = order.filter((n) => n.shape === 'pill');
|
|
494
|
+
if (!list.length)
|
|
495
|
+
return out;
|
|
496
|
+
const sizes = new Map(list.map((n) => [n.id, pillOf(n.id, at.get(n.id).s)]));
|
|
497
|
+
const placed = placePills(list.map((n) => {
|
|
498
|
+
const p = at.get(n.id);
|
|
499
|
+
const { hw, hh } = sizes.get(n.id);
|
|
500
|
+
return {
|
|
501
|
+
id: n.id,
|
|
502
|
+
x: p.x,
|
|
503
|
+
y: p.y,
|
|
504
|
+
hw,
|
|
505
|
+
hh,
|
|
506
|
+
depth: p.depth,
|
|
507
|
+
topic: !!home && !!ties.get(home)?.has(n.id),
|
|
508
|
+
};
|
|
509
|
+
}));
|
|
510
|
+
for (const [id, q] of placed) {
|
|
511
|
+
const z = sizes.get(id);
|
|
512
|
+
out.set(id, {
|
|
513
|
+
x: q.x,
|
|
514
|
+
y: q.y,
|
|
515
|
+
faded: q.faded,
|
|
516
|
+
hw: z.hw * q.shrink,
|
|
517
|
+
hh: z.hh * q.shrink,
|
|
518
|
+
scale: z.scale * q.shrink,
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
return out;
|
|
522
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
523
|
+
}, [order, at, pillText, home, ties]);
|
|
524
|
+
// Where a node is drawn: a pill where it stands this frame, anything else where it falls.
|
|
525
|
+
const drawnAt = (id) => {
|
|
526
|
+
const q = pillPlaces.get(id);
|
|
527
|
+
return q ? { x: q.x, y: q.y } : at.get(id);
|
|
528
|
+
};
|
|
529
|
+
// The node under a point: a pill first (it is drawn over everything; the nearest one when two are under it); else,
|
|
530
|
+
// with `hoverNames="one"` (s_map_hover_one), the bead whose middle is nearest the point.
|
|
531
|
+
const pillAt = (x, y) => {
|
|
532
|
+
let best = null;
|
|
533
|
+
let bestDepth = Infinity;
|
|
534
|
+
for (const [id, q] of pillPlaces) {
|
|
535
|
+
if (q.faded || Math.abs(x - q.x) > q.hw + 3 || Math.abs(y - q.y) > q.hh + 3)
|
|
536
|
+
continue;
|
|
537
|
+
const d = at.get(id).depth;
|
|
538
|
+
if (d < bestDepth) {
|
|
539
|
+
bestDepth = d;
|
|
540
|
+
best = id;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return best;
|
|
544
|
+
};
|
|
545
|
+
const nearestAt = (x, y) => {
|
|
546
|
+
const pill = pillAt(x, y);
|
|
547
|
+
if (pill)
|
|
548
|
+
return pill;
|
|
549
|
+
let best = null;
|
|
550
|
+
let bestD = Infinity;
|
|
551
|
+
for (const n of order) {
|
|
552
|
+
if (n.shape === 'pill')
|
|
553
|
+
continue;
|
|
554
|
+
const p = at.get(n.id);
|
|
555
|
+
const d = Math.hypot(x - p.x, y - p.y);
|
|
556
|
+
if (d <= n.r * sizeOf(p.s) + 8 && d < bestD) {
|
|
557
|
+
bestD = d;
|
|
558
|
+
best = n.id;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return best;
|
|
562
|
+
};
|
|
563
|
+
const pointAt = (e) => {
|
|
564
|
+
const el = svg.current;
|
|
565
|
+
if (!el)
|
|
566
|
+
return null;
|
|
567
|
+
const b = el.getBoundingClientRect();
|
|
568
|
+
return nearestAt(e.clientX - b.left, e.clientY - b.top);
|
|
569
|
+
};
|
|
570
|
+
// What a press lands on, decided where it went down (2026-12-05: a press on a pill's name must never fall to the
|
|
571
|
+
// ground, whatever is redrawn before it is let go): a pill under the point; else the bead nearest it (one name),
|
|
572
|
+
// or the node drawn under it; else the ground (null).
|
|
573
|
+
const pressAt = (e) => {
|
|
574
|
+
const el = svg.current;
|
|
575
|
+
if (!el)
|
|
576
|
+
return null;
|
|
577
|
+
const b = el.getBoundingClientRect();
|
|
578
|
+
const [x, y] = [e.clientX - b.left, e.clientY - b.top];
|
|
579
|
+
const pill = pillAt(x, y);
|
|
580
|
+
if (pill)
|
|
581
|
+
return pill;
|
|
582
|
+
if (one) {
|
|
583
|
+
const n = nearestAt(x, y);
|
|
584
|
+
if (n)
|
|
585
|
+
return n;
|
|
586
|
+
}
|
|
587
|
+
const hit = e.target?.closest?.('[data-node]');
|
|
588
|
+
const id = hit?.getAttribute('data-node');
|
|
589
|
+
return id && drawn(id) ? id : null;
|
|
590
|
+
};
|
|
591
|
+
const pressed = useRef(null);
|
|
373
592
|
// The names shown: the chosen and pointed nodes, then the focus's nearest ties, then the nearest named nodes still
|
|
374
593
|
// lit, never more than a few; in that order each takes its place, and a name that would cross one already placed
|
|
375
594
|
// is left out, so names never pile up.
|
|
@@ -382,21 +601,27 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
382
601
|
wanted.push(n);
|
|
383
602
|
}
|
|
384
603
|
};
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
604
|
+
// A pill carries its own name.
|
|
605
|
+
const byId = new Map(order.filter((n) => n.shape !== 'pill').map((n) => [n.id, n]));
|
|
606
|
+
if (one) {
|
|
607
|
+
want(byId.get(pointed ?? selected ?? ''));
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
if (selected)
|
|
611
|
+
want(byId.get(selected));
|
|
612
|
+
if (focus)
|
|
613
|
+
want(byId.get(focus));
|
|
614
|
+
const byNear = [...byId.values()].reverse();
|
|
615
|
+
if (focus)
|
|
616
|
+
byNear
|
|
617
|
+
.filter((n) => ties.get(focus)?.has(n.id))
|
|
618
|
+
.slice(0, BESIDE)
|
|
619
|
+
.forEach(want);
|
|
392
620
|
byNear
|
|
393
|
-
.filter((n) =>
|
|
394
|
-
.slice(0,
|
|
621
|
+
.filter((n) => (n.named || isFresh.has(n.id)) && lit(n.id))
|
|
622
|
+
.slice(0, NAMES)
|
|
395
623
|
.forEach(want);
|
|
396
|
-
|
|
397
|
-
.filter((n) => (n.named || isFresh.has(n.id)) && lit(n.id))
|
|
398
|
-
.slice(0, NAMES)
|
|
399
|
-
.forEach(want);
|
|
624
|
+
}
|
|
400
625
|
const placed = [];
|
|
401
626
|
const kept = new Set();
|
|
402
627
|
for (const n of wanted) {
|
|
@@ -414,11 +639,13 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
414
639
|
}
|
|
415
640
|
return order.filter((n) => kept.has(n.id));
|
|
416
641
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
417
|
-
}, [order, focus, selected, ties, at, isFresh]);
|
|
642
|
+
}, [order, focus, selected, ties, at, isFresh, one, pointed]);
|
|
418
643
|
// How deep a bead sits in the fog: none nearest, FOG farthest; deeper still when the chosen node does not touch it.
|
|
644
|
+
const depthT = (d) => farthest - nearest < 1e-6
|
|
645
|
+
? 0
|
|
646
|
+
: Math.min(1, Math.max(0, (d - nearest) / (farthest - nearest)));
|
|
419
647
|
const fogOf = (id) => {
|
|
420
|
-
const
|
|
421
|
-
const t = farthest - nearest < 1e-6 ? 0 : (d - nearest) / (farthest - nearest);
|
|
648
|
+
const t = depthT(at.get(id).depth);
|
|
422
649
|
return lit(id) ? FOG * t : Math.max(FOG * t, DIMMED_FOG);
|
|
423
650
|
};
|
|
424
651
|
const opacityOf = (id) => {
|
|
@@ -440,7 +667,12 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
440
667
|
if (!f)
|
|
441
668
|
return out;
|
|
442
669
|
const list = nodes
|
|
443
|
-
.
|
|
670
|
+
.filter((n) => n.shape !== 'pill')
|
|
671
|
+
.map((n) => ({
|
|
672
|
+
id: n.id,
|
|
673
|
+
p: space.get(n.id),
|
|
674
|
+
R: (n.r * crowd * bounds.reach * FIT) / f,
|
|
675
|
+
}))
|
|
444
676
|
.filter((x) => !!x.p);
|
|
445
677
|
const L = worldLight;
|
|
446
678
|
for (const a of list) {
|
|
@@ -470,7 +702,13 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
470
702
|
}, [nodes, space, worldLight, f, crowd, bounds.reach]);
|
|
471
703
|
// What fades: each sphere's share of the fresh colour, and how far the rest has stepped back. Kept between frames
|
|
472
704
|
// and eased toward what is wanted now, so a fresh sphere shows in accent at once and fades back over FADE.
|
|
473
|
-
const ease = useRef({
|
|
705
|
+
const ease = useRef({
|
|
706
|
+
fresh: new Map(),
|
|
707
|
+
shown: new Map(),
|
|
708
|
+
quiet: 0,
|
|
709
|
+
last: 0,
|
|
710
|
+
painted: 0,
|
|
711
|
+
});
|
|
474
712
|
const paintNow = useRef(() => false);
|
|
475
713
|
paintNow.current = () => {
|
|
476
714
|
const b = beads.current;
|
|
@@ -480,7 +718,8 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
480
718
|
const now = performance.now();
|
|
481
719
|
const dt = e.last ? Math.min(100, now - e.last) : 16;
|
|
482
720
|
e.last = now;
|
|
483
|
-
const still = typeof matchMedia === 'function' &&
|
|
721
|
+
const still = typeof matchMedia === 'function' &&
|
|
722
|
+
matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
484
723
|
const by = still ? 1 : dt / FADE;
|
|
485
724
|
let moving = false;
|
|
486
725
|
const toward = (v, to) => {
|
|
@@ -500,6 +739,19 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
500
739
|
e.fresh.set(edge.id, was === undefined ? want : toward(was, want));
|
|
501
740
|
}
|
|
502
741
|
e.quiet = toward(e.quiet, isFresh.size && !selected ? QUIET : 0);
|
|
742
|
+
// A branch fades in and out quicker than the fresh do.
|
|
743
|
+
const byBranch = still ? 1 : dt / BRANCH_FADE;
|
|
744
|
+
for (const n of nodes) {
|
|
745
|
+
const want = drawn(n.id) ? 1 : 0;
|
|
746
|
+
const was = e.shown.get(n.id);
|
|
747
|
+
if (was === undefined || Math.abs(was - want) <= byBranch)
|
|
748
|
+
e.shown.set(n.id, want);
|
|
749
|
+
else {
|
|
750
|
+
moving = true;
|
|
751
|
+
e.shown.set(n.id, was + Math.sign(want - was) * byBranch);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
const shownOf = (id) => e.shown.get(id) ?? 1;
|
|
503
755
|
const mixed = (a, c, t) => [lerp(a[0], c[0], t), lerp(a[1], c[1], t), lerp(a[2], c[2], t)];
|
|
504
756
|
const view = (id) => {
|
|
505
757
|
const p = at.get(id);
|
|
@@ -508,15 +760,59 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
508
760
|
return { p, r, R: (r * p.depth) / Math.max(f, 1) };
|
|
509
761
|
};
|
|
510
762
|
const beadsNow = [];
|
|
763
|
+
const pillsNow = [];
|
|
511
764
|
let maxR = 0;
|
|
512
|
-
for (const n of
|
|
513
|
-
const
|
|
514
|
-
|
|
765
|
+
for (const n of allOrder) {
|
|
766
|
+
const w = shownOf(n.id);
|
|
767
|
+
if (w <= 0)
|
|
768
|
+
continue;
|
|
515
769
|
const fr = e.fresh.get(n.id) ?? 0;
|
|
516
770
|
const lifted = n.id === selected || n.id === pointed;
|
|
771
|
+
if (n.shape === 'pill') {
|
|
772
|
+
const p = at.get(n.id);
|
|
773
|
+
// Where it stands this frame; a pill fading out of a branch, where it falls.
|
|
774
|
+
const q = pillPlaces.get(n.id) ?? {
|
|
775
|
+
...pillOf(n.id, p.s),
|
|
776
|
+
x: p.x,
|
|
777
|
+
y: p.y,
|
|
778
|
+
faded: false,
|
|
779
|
+
};
|
|
780
|
+
const { scale, hw, hh } = q;
|
|
781
|
+
const R = (hh * p.depth) / Math.max(f, 1);
|
|
782
|
+
maxR = Math.max(maxR, R);
|
|
783
|
+
const ink = mixed(n.look === 'plain' || n.look === 'dashed' ? paints.solid : paints[n.look], paints.fresh, fr);
|
|
784
|
+
const pressed = n.id === selected || n.id === held;
|
|
785
|
+
const fill = pressed
|
|
786
|
+
? ink
|
|
787
|
+
: mixed(paints.ground, ink, n.id === pointed ? PILL_HOVER : PILL_REST);
|
|
788
|
+
// Its name in the ink or the ground, whichever stands farther off its fill.
|
|
789
|
+
const text = contrastOf(paints.solid, fill) >= contrastOf(paints.ground, fill)
|
|
790
|
+
? paints.solid
|
|
791
|
+
: paints.ground;
|
|
792
|
+
const fog = lifted
|
|
793
|
+
? 0
|
|
794
|
+
: Math.min(PILL_FOG, Math.max(fogOf(n.id) * (SPHERE_FOG / FOG), e.quiet * (1 - fr)));
|
|
795
|
+
pillsNow.push({
|
|
796
|
+
x: q.x,
|
|
797
|
+
y: q.y,
|
|
798
|
+
depth: p.depth,
|
|
799
|
+
R,
|
|
800
|
+
hw,
|
|
801
|
+
hh,
|
|
802
|
+
scale,
|
|
803
|
+
text: pillText.get(n.id)?.text ?? '',
|
|
804
|
+
fill: mixed(fill, paints.ground, fog),
|
|
805
|
+
edge: mixed(ink, paints.ground, fog),
|
|
806
|
+
ink: mixed(text, paints.ground, fog),
|
|
807
|
+
alpha: w * (q.faded ? PILL_FADED : 1),
|
|
808
|
+
});
|
|
809
|
+
continue;
|
|
810
|
+
}
|
|
811
|
+
const { p, r, R } = view(n.id);
|
|
812
|
+
maxR = Math.max(maxR, R);
|
|
517
813
|
const fog = lifted ? 0 : Math.max(fogOf(n.id) * (SPHERE_FOG / FOG), e.quiet * (1 - fr));
|
|
518
814
|
const occId = occluders.get(n.id);
|
|
519
|
-
const occ = occId && at.has(occId) ? view(occId) : null;
|
|
815
|
+
const occ = occId && at.has(occId) && drawn(occId) ? view(occId) : null;
|
|
520
816
|
beadsNow.push({
|
|
521
817
|
x: p.x,
|
|
522
818
|
y: p.y,
|
|
@@ -527,9 +823,11 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
527
823
|
vz: p.v.z,
|
|
528
824
|
R,
|
|
529
825
|
color: mixed(paints[n.look], paints.fresh, fr),
|
|
530
|
-
alpha: lerp(ALPHA[n.look] ?? 1, 1, fr),
|
|
826
|
+
alpha: lerp(ALPHA[n.look] ?? 1, 1, fr) * w,
|
|
531
827
|
fog,
|
|
532
|
-
occluder: occ
|
|
828
|
+
occluder: occ
|
|
829
|
+
? { vx: occ.p.v.x, vy: occ.p.v.y, vz: occ.p.v.z, R: occ.R }
|
|
830
|
+
: undefined,
|
|
533
831
|
});
|
|
534
832
|
}
|
|
535
833
|
const tiesNow = [];
|
|
@@ -538,22 +836,42 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
538
836
|
const c = at.get(edge.to);
|
|
539
837
|
if (!a || !c || a.depth <= near || c.depth <= near)
|
|
540
838
|
continue;
|
|
839
|
+
const w = Math.min(shownOf(edge.from), shownOf(edge.to));
|
|
840
|
+
if (w <= 0)
|
|
841
|
+
continue;
|
|
541
842
|
const fr = e.fresh.get(edge.id) ?? 0;
|
|
542
|
-
const on =
|
|
543
|
-
|
|
544
|
-
|
|
843
|
+
const on = tieOn(edge.from, edge.to);
|
|
844
|
+
// A tie ends where its pill stands this frame.
|
|
845
|
+
const [ea, ec] = [drawnAt(edge.from), drawnAt(edge.to)];
|
|
846
|
+
const quietBy = (1 - e.quiet * (1 - fr)) * w;
|
|
847
|
+
const dimmed = (o) => (on ? o : Math.min(selected ? DIMMED_TIE : 0.18, o));
|
|
848
|
+
if (plain) {
|
|
849
|
+
tiesNow.push({
|
|
850
|
+
ax: ea.x,
|
|
851
|
+
ay: ea.y,
|
|
852
|
+
ad: a.depth,
|
|
853
|
+
bx: ec.x,
|
|
854
|
+
by: ec.y,
|
|
855
|
+
bd: c.depth,
|
|
856
|
+
width: lerp(TIE_WIDTH, FRESH_TIE_WIDTH, fr),
|
|
857
|
+
color: mixed(paints.tie, paints.fresh, fr),
|
|
858
|
+
alpha: dimmed(plainFade(a.depth)) * quietBy,
|
|
859
|
+
alphaB: dimmed(plainFade(c.depth)) * quietBy,
|
|
860
|
+
});
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
545
863
|
const o = tieFade((a.depth + c.depth) / 2);
|
|
546
|
-
const alpha =
|
|
864
|
+
const alpha = dimmed(o);
|
|
547
865
|
tiesNow.push({
|
|
548
|
-
ax:
|
|
549
|
-
ay:
|
|
866
|
+
ax: ea.x,
|
|
867
|
+
ay: ea.y,
|
|
550
868
|
ad: a.depth,
|
|
551
|
-
bx:
|
|
552
|
-
by:
|
|
869
|
+
bx: ec.x,
|
|
870
|
+
by: ec.y,
|
|
553
871
|
bd: c.depth,
|
|
554
872
|
width: lerp(TIE_WIDTH, FRESH_TIE_WIDTH, fr),
|
|
555
873
|
color: mixed(paints.tie, paints.fresh, fr),
|
|
556
|
-
alpha: alpha *
|
|
874
|
+
alpha: alpha * quietBy,
|
|
557
875
|
});
|
|
558
876
|
}
|
|
559
877
|
const lightNow = light === 'screen' ? LIGHT : turned(worldLight.x, worldLight.y, worldLight.z, cam);
|
|
@@ -569,6 +887,10 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
569
887
|
span: bounds.reach * 1.2,
|
|
570
888
|
near: nearest - maxR * 2,
|
|
571
889
|
far: farthest + maxR * 2,
|
|
890
|
+
blur,
|
|
891
|
+
plainTies: plain,
|
|
892
|
+
pills: pillsNow,
|
|
893
|
+
pillFont: { family: font.family, weight: font.weight, size: PILL_FONT },
|
|
572
894
|
});
|
|
573
895
|
// How long since the last frame while the person turns or flies it: a card that cannot keep up steps down.
|
|
574
896
|
if (interacting.current || goal.current) {
|
|
@@ -599,9 +921,40 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
599
921
|
'--newtone-node-map-sheen-warning': `url(#${paint}-warning)`,
|
|
600
922
|
'--newtone-node-map-sheen-error': `url(#${paint}-error)`,
|
|
601
923
|
'--newtone-node-map-sheen-support': `url(#${paint}-support)`,
|
|
602
|
-
}, onWheel: wheel, onPointerDown:
|
|
603
|
-
|
|
604
|
-
|
|
924
|
+
}, onWheel: wheel, onPointerDown: (e) => {
|
|
925
|
+
press(e);
|
|
926
|
+
// Decided now, where it went down: see pressAt.
|
|
927
|
+
const id = pressAt(e);
|
|
928
|
+
pressed.current = { pointer: e.pointerId, id };
|
|
929
|
+
if (id && isPill(id))
|
|
930
|
+
setHeld(id);
|
|
931
|
+
}, onPointerMove: (e) => {
|
|
932
|
+
drag(e);
|
|
933
|
+
// A press that turned into a turn of the map leaves the pill it began on.
|
|
934
|
+
if (moved.current && held)
|
|
935
|
+
setHeld(null);
|
|
936
|
+
// One name (s_map_hover_one): the node nearest the pointer, found by the map, not by what is on top.
|
|
937
|
+
if (one && !(down.current.size && moved.current)) {
|
|
938
|
+
const id = pointAt(e);
|
|
939
|
+
if (id !== pointedNow.current)
|
|
940
|
+
setPointed(id);
|
|
941
|
+
}
|
|
942
|
+
}, onPointerUp: (e) => {
|
|
943
|
+
release(e);
|
|
944
|
+
setHeld(null);
|
|
945
|
+
const p = pressed.current;
|
|
946
|
+
pressed.current = null;
|
|
947
|
+
// A press that did not move chooses what it went down on, or clears on the ground.
|
|
948
|
+
if (p && p.pointer === e.pointerId && !moved.current)
|
|
949
|
+
onSelect(p.id);
|
|
950
|
+
}, onPointerCancel: (e) => {
|
|
951
|
+
release(e);
|
|
952
|
+
setHeld(null);
|
|
953
|
+
pressed.current = null;
|
|
954
|
+
}, onPointerLeave: () => {
|
|
955
|
+
setHeld(null);
|
|
956
|
+
if (one)
|
|
957
|
+
setPointed(null);
|
|
605
958
|
}, onDoubleClick: (e) => {
|
|
606
959
|
// A double click on the ground fits the whole map (2026-12-04), as on Slides' plane.
|
|
607
960
|
if (!e.target.closest('.newtone-node-map-node, .newtone-node-map-label'))
|
|
@@ -612,43 +965,54 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
612
965
|
const t = at.get(edge.to);
|
|
613
966
|
if (!s || !t || s.depth <= near || t.depth <= near)
|
|
614
967
|
return null;
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
968
|
+
if (!drawn(edge.from) || !drawn(edge.to))
|
|
969
|
+
return null;
|
|
970
|
+
const o = plain
|
|
971
|
+
? (plainFade(s.depth) + plainFade(t.depth)) / 2
|
|
972
|
+
: tieFade((s.depth + t.depth) / 2);
|
|
973
|
+
const on = tieOn(edge.from, edge.to);
|
|
618
974
|
return (_jsx("line", { className: "newtone-node-map-edge", "data-fresh": isFresh.has(edge.id) ? '' : undefined, style: {
|
|
619
|
-
opacity: on
|
|
620
|
-
|
|
621
|
-
: Math.min(selected ? DIMMED_TIE : 0.18, tieFade((s.depth + t.depth) / 2)),
|
|
622
|
-
}, x1: s.x, y1: s.y, x2: t.x, y2: t.y }, edge.id));
|
|
975
|
+
opacity: on ? o : Math.min(selected ? DIMMED_TIE : 0.18, o),
|
|
976
|
+
}, x1: drawnAt(edge.from).x, y1: drawnAt(edge.from).y, x2: drawnAt(edge.to).x, y2: drawnAt(edge.to).y }, edge.id));
|
|
623
977
|
})
|
|
624
978
|
: null, box.w
|
|
625
|
-
?
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
979
|
+
? // Pills last: they are drawn over everything, and take presses over the beads under them.
|
|
980
|
+
[
|
|
981
|
+
...order.filter((n) => n.shape !== 'pill'),
|
|
982
|
+
...order.filter((n) => n.shape === 'pill' && pillPlaces.has(n.id)),
|
|
983
|
+
].map((n) => {
|
|
984
|
+
const p = at.get(n.id);
|
|
985
|
+
const r = n.r * sizeOf(p.s);
|
|
986
|
+
const fog = fogOf(n.id);
|
|
987
|
+
const detailed = r >= DETAIL;
|
|
988
|
+
const bright = n.look === 'accent' || isFresh.has(n.id);
|
|
989
|
+
const pill = n.shape === 'pill' ? pillPlaces.get(n.id) : null;
|
|
990
|
+
const where = pill ?? p;
|
|
991
|
+
return (_jsx("g", { "data-node": n.id, style: pill?.faded
|
|
992
|
+
? { pointerEvents: 'none', opacity: PILL_FADED }
|
|
993
|
+
: undefined, className: "newtone-node-map-node", "data-look": n.look, "data-shape": pill ? 'pill' : undefined, "data-fresh": isFresh.has(n.id) ? '' : undefined, "data-selected": n.id === selected ? '' : undefined, "data-pointed": n.id === pointed ? '' : undefined, "data-held": n.id === held ? '' : undefined, transform: `translate(${where.x},${where.y})`, onPointerEnter: one ? undefined : () => setPointed(n.id), onPointerLeave: one
|
|
994
|
+
? undefined
|
|
995
|
+
: () => setPointed((x) => (x === n.id ? null : x)), children: pill ? (_jsxs(_Fragment, { children: [_jsx("rect", { className: "newtone-node-map-hit", x: -pill.hw - 4, y: -pill.hh - 4, width: pill.hw * 2 + 8, height: pill.hh * 2 + 8, rx: pill.hh + 4 }), gl ? (n.id === selected ? (_jsx("rect", { className: "newtone-node-map-focus", x: -pill.hw - 3, y: -pill.hh - 3, width: pill.hw * 2 + 6, height: pill.hh * 2 + 6, rx: pill.hh + 3, style: { fill: 'none' } })) : null) : (_jsxs(_Fragment, { children: [_jsx("rect", { className: "newtone-node-map-pill", x: -pill.hw, y: -pill.hh, width: pill.hw * 2, height: pill.hh * 2, rx: pill.hh }), _jsx("text", { className: "newtone-node-map-pill-name", textAnchor: "middle", dominantBaseline: "central", style: { fontSize: PILL_FONT * pill.scale }, children: pillText.get(n.id)?.text }), _jsx("rect", { className: "newtone-node-map-veil", x: -pill.hw - 1, y: -pill.hh - 1, width: pill.hw * 2 + 2, height: pill.hh * 2 + 2, rx: pill.hh + 1, style: {
|
|
996
|
+
'--newtone-node-map-fog': Math.min(PILL_FOG, fog),
|
|
997
|
+
fill: 'var(--newtone-role-surface-primary)',
|
|
998
|
+
stroke: 'none',
|
|
999
|
+
} })] })), n.mark ? (_jsx("circle", { className: "newtone-node-map-mark", r: MARK, cx: pill.hw - pill.hh * 0.3, cy: -pill.hh * 0.75 })) : null] })) : (_jsxs(_Fragment, { children: [_jsx("circle", { r: r + 8, className: "newtone-node-map-hit" }), gl ? (
|
|
1000
|
+
// The sphere is drawn below, on the canvas; here only what is pressed, and the
|
|
1001
|
+
// ring of the one chosen or pointed at.
|
|
1002
|
+
n.id === selected || n.id === pointed ? (_jsx("circle", { r: r + 3, className: "newtone-node-map-focus", style: { fill: 'none' } })) : null) : (_jsxs(_Fragment, { children: [detailed ? (_jsx("circle", { className: "newtone-node-map-shadow", cx: r * 0.3, cy: r * 0.45, r: r * 1.25, style: {
|
|
1003
|
+
fill: `url(#${paint}-shadow)`,
|
|
1004
|
+
stroke: 'none',
|
|
1005
|
+
opacity: 1 - fog,
|
|
1006
|
+
} })) : null, _jsx("circle", { r: r, className: "newtone-node-map-body" }), detailed ? (_jsx("circle", { className: "newtone-node-map-bulb", r: r * 0.62, style: {
|
|
1007
|
+
fill: `url(#${paint}-bulb-${bright ? 'bright' : 'soft'})`,
|
|
1008
|
+
stroke: 'none',
|
|
1009
|
+
} })) : null, _jsx("circle", { className: "newtone-node-map-veil", r: r + 2.5, style: {
|
|
1010
|
+
'--newtone-node-map-fog': fog,
|
|
1011
|
+
fill: 'var(--newtone-role-surface-primary)',
|
|
1012
|
+
stroke: 'none',
|
|
1013
|
+
} })] })), n.mark ? (_jsx("circle", { className: "newtone-node-map-mark", r: MARK, cx: r * Math.SQRT1_2, cy: -r * Math.SQRT1_2 })) : null] })) }, n.id));
|
|
1014
|
+
})
|
|
1015
|
+
: null, _jsxs("g", { className: "newtone-node-map-labels", children: [focus && box.w && !one
|
|
652
1016
|
? edges
|
|
653
1017
|
.filter((e) => e.label && (e.from === focus || e.to === focus))
|
|
654
1018
|
.map((e) => {
|
|
@@ -656,16 +1020,16 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
|
|
|
656
1020
|
const t = at.get(e.to);
|
|
657
1021
|
if (!s || !t || s.depth <= near || t.depth <= near)
|
|
658
1022
|
return null;
|
|
1023
|
+
if (!drawn(e.from) || !drawn(e.to))
|
|
1024
|
+
return null;
|
|
659
1025
|
return (_jsx("text", { className: "newtone-node-map-edge-label", x: (s.x + t.x) / 2, y: (s.y + t.y) / 2 - 4, textAnchor: "middle", children: clip(e.label, 28) }, e.id));
|
|
660
1026
|
})
|
|
661
1027
|
: null, box.w
|
|
662
1028
|
? shown.map((n) => {
|
|
663
1029
|
const p = at.get(n.id);
|
|
664
|
-
return (_jsx("text", { className: "newtone-node-map-label", "data-style": n.labelStyle, "data-fresh": isFresh.has(n.id) ? '' : undefined, style: { opacity: opacityOf(n.id) }, x: p.x, y: p.y + n.r * sizeOf(p.s) + 15, textAnchor: "middle",
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
onSelect(n.id);
|
|
668
|
-
}, onPointerEnter: () => setPointed(n.id), onPointerLeave: () => setPointed((x) => (x === n.id ? null : x)), children: clip(n.label, n.id === focus ? 60 : 32) }, n.id));
|
|
1030
|
+
return (_jsx("text", { className: "newtone-node-map-label", "data-style": n.labelStyle, "data-fresh": isFresh.has(n.id) ? '' : undefined, style: { opacity: opacityOf(n.id) }, x: p.x, y: p.y + n.r * sizeOf(p.s) + 15, textAnchor: "middle", "data-node": n.id, onPointerEnter: one ? undefined : () => setPointed(n.id), onPointerLeave: one
|
|
1031
|
+
? undefined
|
|
1032
|
+
: () => setPointed((x) => (x === n.id ? null : x)), children: clip(n.label, n.id === focus ? 60 : 32) }, n.id));
|
|
669
1033
|
})
|
|
670
1034
|
: null] })] }), _jsx("ul", { className: "newtone-node-map-list", role: "group", "aria-label": labels.map, children: nodes.map((n) => (_jsx("li", { children: _jsx("button", { type: "button", "aria-pressed": n.id === selected, onClick: () => onSelect(n.id), onFocus: () => setPointed(n.id), onBlur: () => setPointed((x) => (x === n.id ? null : x)), children: n.name }) }, n.id))) }), _jsx(MapOver, { head: head, legend: legend, sphere: gl }), _jsx(MapTools, { labels: labels, zoomIn: () => flyBy(1.4), zoomOut: () => flyBy(1 / 1.4), fit: fit }), _jsx("span", { ref: probe, className: "newtone-node-map-probe", "aria-hidden": "true" })] }));
|
|
671
1035
|
}
|