@dxos/react-ui-graph 0.8.4-main.cb12b3f963 → 0.8.4-main.d05539e30a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/index.mjs +903 -285
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +903 -285
  6. package/dist/lib/node-esm/index.mjs.map +4 -4
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/components/Graph/Graph.d.ts +6 -2
  9. package/dist/types/src/components/Graph/Graph.d.ts.map +1 -1
  10. package/dist/types/src/components/Graph/Graph.stories.d.ts +3 -3
  11. package/dist/types/src/components/Graph/Graph.stories.d.ts.map +1 -1
  12. package/dist/types/src/components/Mesh/Mesh.d.ts.map +1 -1
  13. package/dist/types/src/components/Mesh/Mesh.stories.d.ts.map +1 -1
  14. package/dist/types/src/components/SVG/Root.d.ts +4 -0
  15. package/dist/types/src/components/SVG/Root.d.ts.map +1 -1
  16. package/dist/types/src/graph/projector/graph-bundle-projector.d.ts +47 -0
  17. package/dist/types/src/graph/projector/graph-bundle-projector.d.ts.map +1 -0
  18. package/dist/types/src/graph/projector/graph-cluster-projector.d.ts +60 -0
  19. package/dist/types/src/graph/projector/graph-cluster-projector.d.ts.map +1 -0
  20. package/dist/types/src/graph/projector/graph-force-projector.d.ts.map +1 -1
  21. package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts.map +1 -1
  22. package/dist/types/src/graph/projector/graph-lattice-projector.d.ts +23 -0
  23. package/dist/types/src/graph/projector/graph-lattice-projector.d.ts.map +1 -0
  24. package/dist/types/src/graph/projector/graph-projector.d.ts.map +1 -1
  25. package/dist/types/src/graph/projector/graph-radial-projector.d.ts +6 -0
  26. package/dist/types/src/graph/projector/graph-radial-projector.d.ts.map +1 -1
  27. package/dist/types/src/graph/projector/graph-relational-projector.d.ts.map +1 -1
  28. package/dist/types/src/graph/projector/index.d.ts +3 -0
  29. package/dist/types/src/graph/projector/index.d.ts.map +1 -1
  30. package/dist/types/src/graph/projector/projector.d.ts +10 -1
  31. package/dist/types/src/graph/projector/projector.d.ts.map +1 -1
  32. package/dist/types/src/graph/renderer/graph-renderer.d.ts +21 -1
  33. package/dist/types/src/graph/renderer/graph-renderer.d.ts.map +1 -1
  34. package/dist/types/src/graph/renderer/renderer.d.ts +12 -1
  35. package/dist/types/src/graph/renderer/renderer.d.ts.map +1 -1
  36. package/dist/types/src/graph/types.d.ts +14 -0
  37. package/dist/types/src/graph/types.d.ts.map +1 -1
  38. package/dist/types/src/stories/hooks.stories.d.ts.map +1 -1
  39. package/dist/types/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +18 -18
  41. package/src/components/Graph/Graph.stories.tsx +5 -5
  42. package/src/components/Graph/Graph.tsx +48 -21
  43. package/src/components/Mesh/Mesh.stories.tsx +6 -4
  44. package/src/components/Mesh/Mesh.tsx +43 -35
  45. package/src/components/SVG/Root.tsx +28 -3
  46. package/src/graph/projector/graph-bundle-projector.ts +210 -0
  47. package/src/graph/projector/graph-cluster-projector.ts +325 -0
  48. package/src/graph/projector/graph-force-projector.ts +5 -1
  49. package/src/graph/projector/graph-hierarchical-projector.ts +1 -0
  50. package/src/graph/projector/graph-lattice-projector.ts +86 -0
  51. package/src/graph/projector/graph-projector.ts +7 -0
  52. package/src/graph/projector/graph-radial-projector.ts +30 -2
  53. package/src/graph/projector/graph-relational-projector.ts +1 -0
  54. package/src/graph/projector/index.ts +3 -0
  55. package/src/graph/projector/projector.ts +12 -3
  56. package/src/graph/renderer/graph-renderer.ts +172 -32
  57. package/src/graph/renderer/renderer.ts +15 -4
  58. package/src/graph/types.ts +14 -0
  59. package/src/stories/hooks.stories.tsx +6 -1
  60. package/styles/graph.css +51 -2
@@ -12,8 +12,23 @@ import { type GraphLayout, type GraphLayoutEdge, type GraphLayoutNode } from '..
12
12
  import { createBullets } from './bullets';
13
13
  import { Renderer, type RendererOptions } from './renderer';
14
14
 
15
+ /**
16
+ * Replace the default `<circle>` with a custom node shape. Invoked once per
17
+ * entering node — append your own elements to the supplied `<g>`. Position and
18
+ * `attributes.node` callbacks are still applied by the renderer.
19
+ */
20
+ export type RenderNode<NodeData = any> = (group: D3Selection<SVGGElement>, node: GraphLayoutNode<NodeData>) => void;
21
+
15
22
  const createLine = line<Point>();
16
23
 
24
+ /** Duration for edge opacity transitions on enter / exit (ms). Matches node enter/exit timing. */
25
+ const EDGE_FADE_MS = 300;
26
+
27
+ /** Duration for node hide/show opacity transitions (ms). Matches the projector's tween
28
+ * duration so a cluster collapse/expand fades opacity over the same window the position
29
+ * is tweening toward / away from the parent group. */
30
+ const NODE_HIDE_MS = 500;
31
+
17
32
  export type LabelOptions<NodeData = any> = {
18
33
  text: (node: GraphLayoutNode<NodeData>, highlight?: boolean) => string | undefined;
19
34
  };
@@ -40,17 +55,19 @@ export type GraphRendererOptions<NodeData = any, EdgeData = any> = RendererOptio
40
55
  labels?: LabelOptions<NodeData>;
41
56
  subgraphs?: boolean;
42
57
  attributes?: AttributesOptions<NodeData>;
58
+ /**
59
+ * Override the default `<circle>` node shape. When set, the renderer appends
60
+ * whatever this callback creates instead. Use for lattice rects, custom icons, etc.
61
+ */
62
+ renderNode?: RenderNode<NodeData>;
43
63
  transition?: () => any;
44
64
  onNodeClick?: (node: GraphLayoutNode<NodeData>, event: MouseEvent) => void;
45
65
  onNodePointerEnter?: (node: GraphLayoutNode<NodeData>, event: MouseEvent) => void;
66
+ /** Fires on pointerleave from a node hit-target. Pair with `onNodePointerEnter` to clear hover state. */
67
+ onNodePointerLeave?: (node: GraphLayoutNode<NodeData>, event: MouseEvent) => void;
46
68
  onLinkClick?: (link: GraphLayoutEdge<NodeData, EdgeData>, event: MouseEvent) => void;
47
69
  }>;
48
70
 
49
- // TODO(burdon): Perf
50
- // - Leaking JS event listeners.
51
- // - Don't update unless data changes.
52
- // - Cache subgraph components in layout.
53
-
54
71
  /**
55
72
  * Renders the Graph layout.
56
73
  */
@@ -58,7 +75,26 @@ export class GraphRenderer<NodeData = any, EdgeData = any> extends Renderer<
58
75
  GraphLayout<NodeData, EdgeData>,
59
76
  GraphRendererOptions<NodeData, EdgeData>
60
77
  > {
78
+ // First render of this instance — used to clear DOM left behind by a previous
79
+ // renderer pointing at the same `<g>` (e.g. when the consumer swaps projectors
80
+ // and a new renderer is constructed for the same SVG root). Without this, the
81
+ // previous variant's node shapes (e.g. circles) would persist as d3.join sees
82
+ // them in the `update` set instead of `enter`.
83
+ #firstRender = true;
84
+
61
85
  override render(layout: GraphLayout<NodeData, EdgeData>) {
86
+ // The SVG group ref is unset between mount cycles and before the container has sized;
87
+ // skip the render rather than throw — the projector will emit again on the next tick.
88
+ if (!this.root) {
89
+ return;
90
+ }
91
+
92
+ if (this.#firstRender) {
93
+ this.#firstRender = false;
94
+ // Drop any DOM left by a prior renderer so this render's `renderNode` runs from scratch.
95
+ this.root.replaceChildren();
96
+ }
97
+
62
98
  log('render', layout);
63
99
 
64
100
  const root = select(this.root);
@@ -165,10 +201,13 @@ export class GraphRenderer<NodeData = any, EdgeData = any> extends Renderer<
165
201
  enter
166
202
  .append('g')
167
203
  .attr('data-id', (d) => d.id)
168
- .attr('opacity', 1)
204
+ // Initial opacity matches `hidden` so a node that enters already-collapsed is
205
+ // invisible from the first frame; updateNode's named 'hide' transition then
206
+ // handles any subsequent toggles.
207
+ .attr('opacity', (d) => (d.hidden ? 0 : 1))
169
208
  .classed('dx-node', true)
170
209
  .call(createNode, this.options),
171
- (update) => update.call(updateNode, this.options),
210
+ (update) => update,
172
211
  (exit) => {
173
212
  // Fade out.
174
213
  return exit
@@ -181,6 +220,9 @@ export class GraphRenderer<NodeData = any, EdgeData = any> extends Renderer<
181
220
  });
182
221
  },
183
222
  )
223
+ // Apply update (transform / attributes / labels) to enter+update so the first render
224
+ // also populates `data-*` attributes and transforms — not just subsequent ticks.
225
+ .call(updateNode, this.options)
184
226
  .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
185
227
 
186
228
  //
@@ -197,17 +239,69 @@ export class GraphRenderer<NodeData = any, EdgeData = any> extends Renderer<
197
239
  .attr('data-id', (d) => d.id)
198
240
  .classed('dx-edge', true)
199
241
  .call(createEdge, this.options),
200
- (update) => update.call(updateEdge, this.options, nodeGroup).each((d) => {}),
201
- (exit) => exit.remove(),
242
+ (update) => update,
243
+ // Exit fade: edges removed by a topology change (e.g. variant switch from cluster
244
+ // back to force replaces hierarchy edges with data edges) ease out rather than pop.
245
+ (exit) =>
246
+ exit
247
+ .transition()
248
+ .ease(easeCubicOut)
249
+ .duration(EDGE_FADE_MS)
250
+ .attr('opacity', 0)
251
+ .on('end', function () {
252
+ select(this).remove();
253
+ }),
202
254
  )
255
+ // Apply edge updates (paths / attributes) to enter+update — see note on nodes above.
256
+ .call(updateEdge, this.options, nodeGroup)
203
257
  .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
204
258
  }
205
259
 
260
+ /**
261
+ * Fast positions-only update. Skips enter/exit, attribute callbacks, label sizing,
262
+ * and the subgraph hull pass; just writes `transform` per node and `d` per edge.
263
+ * Called per simulation tick / animation frame.
264
+ */
265
+ override applyPositions(layout: GraphLayout<NodeData, EdgeData>) {
266
+ if (!this.root) {
267
+ return;
268
+ }
269
+
270
+ const root = select(this.root);
271
+
272
+ // Transforms only — no attribute callback, no label measurement.
273
+ root
274
+ .select('g.dx-nodes')
275
+ .selectAll<SVGGElement, GraphLayoutNode<NodeData>>('g.dx-node')
276
+ .attr('transform', (d) => (d.x != null && d.y != null ? `translate(${d.x},${d.y})` : null));
277
+
278
+ // Edge geometry — either precomputed (`edge.path`) or derived from endpoint positions.
279
+ root
280
+ .select('g.dx-edges')
281
+ .selectAll<SVGGElement, GraphLayoutEdge<NodeData, EdgeData>>('g.dx-edge')
282
+ .selectAll<SVGPathElement, GraphLayoutEdge<NodeData, EdgeData>>('path')
283
+ .attr('d', function () {
284
+ // NOTE: `d` is stale after layout is switched so get the datum from the parent element.
285
+ const edge = select(this.parentElement).datum() as GraphLayoutEdge<NodeData, EdgeData>;
286
+ if (edge.path) {
287
+ return edge.path;
288
+ }
289
+ const { source, target } = edge;
290
+ if (!source.initialized || !target.initialized) {
291
+ return null;
292
+ }
293
+ return createLine(getCircumferencePoints([source.x, source.y], [target.x, target.y], source.r, target.r));
294
+ });
295
+ }
296
+
206
297
  /**
207
298
  * Trigger path bullets.
208
299
  * @param node
209
300
  */
210
301
  fireBullet(node: GraphLayoutNode<NodeData>) {
302
+ if (!this.root) {
303
+ return;
304
+ }
211
305
  select(this.root).selectAll('g.dx-edges').selectAll('path').call(createBullets(this.root, node.id));
212
306
  }
213
307
  }
@@ -217,21 +311,45 @@ export class GraphRenderer<NodeData = any, EdgeData = any> extends Renderer<
217
311
  * @param group
218
312
  * @param options
219
313
  */
314
+ const SHAPE_CLASS = 'dx-shape';
315
+
316
+ const renderCustomShape = <Data>(group: D3Selection, options: GraphRendererOptions<Data>) => {
317
+ group.each(function (d) {
318
+ const g = select<SVGGElement, GraphLayoutNode<Data>>(this);
319
+ // Clear any previous custom shape so subsequent renders pick up updated
320
+ // node.r / node.data without leaving stale elements behind.
321
+ g.selectAll(`.${SHAPE_CLASS}`).remove();
322
+ // Wrap the consumer's drawing in a `<g class="dx-shape">` so we have a
323
+ // stable selector for the cleanup above.
324
+ const shapeGroup = g.append('g').classed(SHAPE_CLASS, true);
325
+ options.renderNode!(shapeGroup, d);
326
+ });
327
+ };
328
+
220
329
  const createNode: D3Callable = <Data>(group: D3Selection, options: GraphRendererOptions<Data>) => {
221
- // Circle.
222
- const circle = group.append('circle');
330
+ // Custom node shape: consumer appends its own elements (e.g. <rect>) and the
331
+ // renderer skips the default <circle>. Drag/hover handlers attach to the
332
+ // wrapping <g> so the custom shape acts as the hit target.
333
+ const useCustom = !!options.renderNode;
334
+ if (useCustom) {
335
+ renderCustomShape(group, options);
336
+ }
337
+ const hitTarget = useCustom ? group : group.append('circle');
223
338
 
224
339
  // Drag.
225
340
  // TODO(burdon): Update when layout changes.
226
341
  if (options.drag) {
227
- circle.call(options.drag);
342
+ hitTarget.call(options.drag);
228
343
  }
229
344
 
230
- // Click.
345
+ // Click. d3 invokes `on` listeners as `(event, datum)` where datum is the bound data on
346
+ // the listener's host element (the dx-node `<g>`). Use it directly — reading from
347
+ // `event.target` returned undefined for the inner circle / text (which don't inherit
348
+ // __data__), and `this` plus `select(this).datum()` was producing inconsistent results
349
+ // across HMR reloads.
231
350
  if (options.onNodeClick) {
232
- group.on('click', (event: MouseEvent) => {
233
- const node = select<SVGElement, GraphLayoutNode<Data>>(event.target as SVGGElement).datum();
234
- options.onNodeClick(node, event);
351
+ group.on('click', (event: MouseEvent, d: GraphLayoutNode<Data>) => {
352
+ options.onNodeClick(d, event);
235
353
  });
236
354
  }
237
355
 
@@ -244,21 +362,19 @@ const createNode: D3Callable = <Data>(group: D3Selection, options: GraphRenderer
244
362
  }
245
363
 
246
364
  // Hover.
247
- if (options.onNodePointerEnter) {
248
- circle.on('pointerenter', function (event: PointerEvent) {
249
- const node = select<any, GraphLayoutNode<Data>>(this.parentElement).datum();
250
- options.onNodePointerEnter(node, event);
365
+ if (options.onNodePointerEnter || options.onNodePointerLeave) {
366
+ hitTarget.on('pointerenter', function (event: PointerEvent) {
367
+ const node = select<any, GraphLayoutNode<Data>>(useCustom ? this : this.parentElement).datum();
368
+ options.onNodePointerEnter?.(node, event);
369
+ });
370
+ hitTarget.on('pointerleave', function (event: PointerEvent) {
371
+ const node = select<any, GraphLayoutNode<Data>>(useCustom ? this : this.parentElement).datum();
372
+ options.onNodePointerLeave?.(node, event);
251
373
  });
252
374
 
253
- group.attr('data-hover', 'handled'); // TODO(burdon): ???
254
- } else if (options.highlight !== false) {
255
- // `dx-node-active` is a graph-renderer-private state flag — used as a
256
- // mutable boolean on the DOM element across event handlers, not as a
257
- // Tailwind utility. Renamed from `dx-active` (which had no CSS rule
258
- // and collided with the global `dx-*` utility namespace; the canonical
259
- // selection utilities are `dx-selected` / `dx-current` — see
260
- // `ui-theme/src/css/components/selected.md`).
261
- circle.on('pointerenter', function () {
375
+ group.attr('data-hover', 'handled');
376
+ } else if (options.highlight !== false && !useCustom) {
377
+ hitTarget.on('pointerenter', function () {
262
378
  select(this.closest('g.dx-node')).raise();
263
379
  if (options.labels) {
264
380
  select(this.parentElement).classed('dx-node-active', true).classed('dx-highlight', true);
@@ -291,6 +407,24 @@ const updateNode: D3Callable = <NodeData = any, EdgeData = any>(
291
407
  return d.x != null && d.y != null ? `translate(${d.x},${d.y})` : undefined;
292
408
  });
293
409
 
410
+ // Hidden state: drive pointer-events + the hover opacity via the `dx-hidden` class;
411
+ // tween the actual opacity attribute on a named transition so it doesn't fight the
412
+ // CSS hover transition (different namespaces, different durations).
413
+ group.classed('dx-hidden', (d) => d.hidden ?? false);
414
+ group
415
+ .transition('hide')
416
+ .ease(easeCubicOut)
417
+ .duration(NODE_HIDE_MS)
418
+ .attr('opacity', (d) => (d.hidden ? 0 : 1));
419
+
420
+ // Re-run the custom shape on every full render so a topology / data update
421
+ // refreshes geometry (e.g. lattice node.r changes on resize, fill changes on
422
+ // typename change). The cheap fast path (`applyPositions`) doesn't touch
423
+ // shapes, so this only runs on the rarer topology-emit code path.
424
+ if (options.renderNode) {
425
+ renderCustomShape(group, options);
426
+ }
427
+
294
428
  // Custom attributes.
295
429
  if (options.attributes?.node) {
296
430
  try {
@@ -316,8 +450,10 @@ const updateNode: D3Callable = <NodeData = any, EdgeData = any>(
316
450
  ? (group.transition(options.transition()) as unknown as D3Selection)
317
451
  : group;
318
452
 
319
- // Update circles.
320
- groupOrTransition.select<SVGCircleElement>('circle').attr('r', (d) => d.r ?? 16);
453
+ // Update circles. Skipped when the consumer supplied a custom node shape.
454
+ if (!options.renderNode) {
455
+ groupOrTransition.select<SVGCircleElement>('circle').attr('r', (d) => d.r ?? 16);
456
+ }
321
457
 
322
458
  // Update labels.
323
459
  if (options.labels) {
@@ -429,7 +565,11 @@ const updateEdge: D3Callable = <NodeData = any, EdgeData = any>(
429
565
 
430
566
  groupOrTransition.selectAll<SVGPathElement, GraphLayoutEdge<NodeData, EdgeData>>('path').attr('d', function () {
431
567
  // NOTE: `d` is stale after layout is switched so get the datum from the parent element.
432
- const { source, target } = select(this.parentElement).datum() as GraphLayoutEdge<NodeData, EdgeData>;
568
+ const edge = select(this.parentElement).datum() as GraphLayoutEdge<NodeData, EdgeData>;
569
+ if (edge.path) {
570
+ return edge.path;
571
+ }
572
+ const { source, target } = edge;
433
573
  if (!source.initialized || !target.initialized) {
434
574
  return;
435
575
  }
@@ -4,8 +4,6 @@
4
4
 
5
5
  import { type RefObject } from 'react';
6
6
 
7
- import { invariant } from '@dxos/invariant';
8
-
9
7
  import { type SVGContext } from '../../hooks';
10
8
  import { type IdAccessor, defaultIdAccessor } from '../types';
11
9
 
@@ -36,8 +34,12 @@ export abstract class Renderer<LAYOUT, OPTIONS extends RendererOptions> {
36
34
  return this._context;
37
35
  }
38
36
 
39
- get root(): SVGGElement {
40
- invariant(this._root.current, 'SVG root is not initialized');
37
+ /**
38
+ * Returns the SVG group root if mounted.
39
+ * The ref may be null between mount/unmount cycles or before the SVG container has sized.
40
+ * Callers should treat null as "skip this render" rather than as an error.
41
+ */
42
+ get root(): SVGGElement | null {
41
43
  return this._root.current;
42
44
  }
43
45
 
@@ -46,4 +48,13 @@ export abstract class Renderer<LAYOUT, OPTIONS extends RendererOptions> {
46
48
  }
47
49
 
48
50
  abstract render(layout: LAYOUT): void;
51
+
52
+ /**
53
+ * Fast path invoked when only positions changed.
54
+ * Default falls back to a full `render`; subclasses can override to skip
55
+ * enter/exit joins and attribute callbacks for per-tick updates.
56
+ */
57
+ applyPositions(layout: LAYOUT): void {
58
+ this.render(layout);
59
+ }
49
60
  }
@@ -45,6 +45,14 @@ export type GraphLayoutNode<NodeData = any> = {
45
45
  type?: string;
46
46
  order?: number;
47
47
  data?: NodeData;
48
+ /** Human-readable label. Synthetic nodes (e.g. cluster root / group) carry this so
49
+ * consumer renderNode callbacks can label them without parsing internal id formats. */
50
+ label?: string;
51
+ /** When true the node remains in the layout but is rendered with opacity 0 and no
52
+ * pointer events — used by the cluster's collapse animation so hidden leaves can
53
+ * tween to their parent's position rather than popping out, and tween back when the
54
+ * parent is re-expanded. */
55
+ hidden?: boolean;
48
56
  x?: number;
49
57
  y?: number;
50
58
  r?: number;
@@ -65,6 +73,12 @@ export type GraphLayoutEdge<NodeData = any, EdgeData = any> = {
65
73
  target: GraphLayoutNode<NodeData>;
66
74
  data?: EdgeData;
67
75
  linkForce?: boolean;
76
+ /**
77
+ * Precomputed SVG `d` attribute. When set, the renderer uses this instead of
78
+ * deriving a straight-line path from `source/target` positions. Lets projectors
79
+ * own edge geometry (e.g. radial elbows, bundled curves) without renderer changes.
80
+ */
81
+ path?: string;
68
82
  classes?: {
69
83
  path?: string;
70
84
  };
@@ -109,9 +109,14 @@ const Component = ({
109
109
  }, [markersRef]);
110
110
 
111
111
  useEffect(() => {
112
+ // Prime the projector with the initial graph — `model.subscribe` only fires on changes by default,
113
+ // so without this the simulation starts empty and the renderer never sees any nodes.
114
+ // The subscribe callback receives `(model, graph)` from GraphModel; use the model reference
115
+ // we already have to fetch the current snapshot.
116
+ projector.updateData(model.graph);
112
117
  void projector.start();
113
118
  return combine(
114
- model.subscribe((graph) => projector.updateData(graph)),
119
+ model.subscribe(() => projector.updateData(model.graph)),
115
120
  projector.updated.on(({ layout }) => renderer.render(layout)),
116
121
  () => projector.stop(),
117
122
  );
package/styles/graph.css CHANGED
@@ -65,6 +65,20 @@ svg {
65
65
 
66
66
  g.dx-nodes {
67
67
  g.dx-node {
68
+ /* Hover feedback — every variant (force / lattice / cluster / bundle) wraps its
69
+ consumer-drawn shape in `g.dx-node`, so a single rule covers all four. Dim the
70
+ whole node group on hover; the `transition` smooths the in/out. */
71
+ cursor: pointer;
72
+ transition: opacity 150ms ease-out;
73
+ &:hover {
74
+ opacity: 0.65;
75
+ }
76
+ /* Cluster collapse: hidden leaves stay in the layout (so they tween to/from their
77
+ parent), but the d3 hide-transition fades their opacity attribute to 0 and we
78
+ drop pointer events so they don't catch clicks during the fade. */
79
+ &.dx-hidden {
80
+ pointer-events: none;
81
+ }
68
82
  circle {
69
83
  @apply fill-neutral-300 stroke-neutral-800;
70
84
 
@@ -72,6 +86,37 @@ svg {
72
86
  @apply fill-neutral-600 stroke-none;
73
87
  }
74
88
  }
89
+ /* Radial cluster labels — small, neutral, no fill swatch since these are SVG
90
+ text nodes (not HTML). Stroke + paint-order halos the text for legibility against
91
+ edges or color-coded nodes drawn beneath it. */
92
+ text.dx-cluster-label {
93
+ @apply fill-neutral-700 text-[10px];
94
+ paint-order: stroke;
95
+ stroke: var(--surface-bg, white);
96
+ stroke-width: 3px;
97
+ stroke-linejoin: round;
98
+
99
+ .dark & {
100
+ @apply fill-neutral-300;
101
+ }
102
+ }
103
+ /* Group label sits inward of the ring — slightly stronger so the typename labels
104
+ the cluster of leaves they introduce. */
105
+ text.dx-cluster-label-group {
106
+ @apply fill-neutral-500 text-[11px] font-medium;
107
+
108
+ .dark & {
109
+ @apply fill-neutral-400;
110
+ }
111
+ }
112
+ /* Root label is a centered caption — larger, slightly bolder. */
113
+ text.dx-cluster-label-root {
114
+ @apply fill-neutral-600 text-xs font-semibold;
115
+
116
+ .dark & {
117
+ @apply fill-neutral-300;
118
+ }
119
+ }
75
120
  &.dx-selected {
76
121
  circle {
77
122
  @apply !fill-red-500 stroke-2 stroke-neutral-950;
@@ -228,7 +273,7 @@ svg {
228
273
  @apply stroke-1 stroke-neutral-500 fill-inverse-surface;
229
274
  }
230
275
  text {
231
- @apply fill-inverse-surface-text;
276
+ @apply fill-inverse-foreground;
232
277
  }
233
278
  }
234
279
  }
@@ -238,7 +283,11 @@ svg {
238
283
  g.dx-edge {
239
284
  path {
240
285
  /** NOTE: Set text- so that current color is picked up by marker. */
241
- @apply stroke-1 stroke-neutral-700;
286
+ @apply stroke-1 stroke-neutral-700 fill-none;
287
+ /* Force higher-quality tessellation. Some browsers' default `auto` shape-rendering
288
+ produces visible gaps in stroked bezier curves at certain curvature / stroke-width
289
+ combinations — geometricPrecision avoids the heuristic and uses precise math. */
290
+ shape-rendering: geometricPrecision;
242
291
 
243
292
  .dark & {
244
293
  @apply stroke-neutral-700;