@ruckc/truss-graph 1.8.0 → 1.10.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/Graph.svelte +6 -1
- package/dist/Graph.svelte.d.ts +3 -0
- package/package.json +1 -1
package/dist/Graph.svelte
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount, tick, type Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
4
|
import { Button } from '@ruckc/truss-ui';
|
|
4
5
|
import { autoLayout, forceLayout, radialLayout } from './layout.js';
|
|
5
6
|
import { defaultPorts, opposite, portAnchor, routeEdge, type Anchor, type Rect } from './routing.js';
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
direction = 'LR',
|
|
18
19
|
layout: layoutMode = 'layered',
|
|
19
20
|
legend,
|
|
21
|
+
legendAttrs,
|
|
20
22
|
categories,
|
|
21
23
|
connectable = true,
|
|
22
24
|
editable = true,
|
|
@@ -53,6 +55,8 @@
|
|
|
53
55
|
layout?: GraphLayout;
|
|
54
56
|
/** Key for node and edge kinds. `true` derives it from the kinds in use; or pass labels per kind. Edge entries toggle `hiddenEdgeKinds`. */
|
|
55
57
|
legend?: boolean | GraphLegend;
|
|
58
|
+
/** Attributes for the legend's `<div role="group">` (`data-*`, `aria-*`, `id`, `class`, ...), e.g. a `data-testid`. Only used when `legend` is set. */
|
|
59
|
+
legendAttrs?: Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
56
60
|
/** Names for `node.category` (index = category), used by the legend. Missing names read "Category N". */
|
|
57
61
|
categories?: string[];
|
|
58
62
|
/** Drag from an output port to an input port to create edges. */
|
|
@@ -423,6 +427,7 @@
|
|
|
423
427
|
}
|
|
424
428
|
|
|
425
429
|
// ---- legend
|
|
430
|
+
const { class: legendCls, ...legendRest } = $derived(legendAttrs ?? {});
|
|
426
431
|
const cap = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
427
432
|
// Graph-local copy of the chart palette: `--trc-s1..8` when the charts stylesheet is loaded, built-in values otherwise
|
|
428
433
|
const SLOTS = 8;
|
|
@@ -602,7 +607,7 @@
|
|
|
602
607
|
{/if}
|
|
603
608
|
|
|
604
609
|
{#if legendData}
|
|
605
|
-
<div class=
|
|
610
|
+
<div class={['legend', legendCls]} role="group" aria-label="Legend" {...legendRest}>
|
|
606
611
|
{#each legendData.nodeRows as [kind, label] (kind)}
|
|
607
612
|
<span class="lg-item"><span class="lg-node" data-kind={kind}></span>{label}</span>
|
|
608
613
|
{/each}
|
package/dist/Graph.svelte.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
3
|
import { type EdgeType, type GraphEdge, type GraphLayout, type GraphLayoutOptions, type GraphLegend, type GraphNode, type HighlightDirection, type NodeRenderer } from './types.js';
|
|
3
4
|
type $$ComponentProps = {
|
|
4
5
|
nodes?: GraphNode[];
|
|
@@ -19,6 +20,8 @@ type $$ComponentProps = {
|
|
|
19
20
|
layout?: GraphLayout;
|
|
20
21
|
/** Key for node and edge kinds. `true` derives it from the kinds in use; or pass labels per kind. Edge entries toggle `hiddenEdgeKinds`. */
|
|
21
22
|
legend?: boolean | GraphLegend;
|
|
23
|
+
/** Attributes for the legend's `<div role="group">` (`data-*`, `aria-*`, `id`, `class`, ...), e.g. a `data-testid`. Only used when `legend` is set. */
|
|
24
|
+
legendAttrs?: Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
22
25
|
/** Names for `node.category` (index = category), used by the legend. Missing names read "Category N". */
|
|
23
26
|
categories?: string[];
|
|
24
27
|
/** Drag from an output port to an input port to create edges. */
|