@stealthscale/component-graphs 0.1.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.
@@ -0,0 +1,1175 @@
1
+ import { ComponentProps, ReactElement, ReactNode } from "react";
2
+ import { ButtonProps } from "@stealthscale/component-actions";
3
+ import "@stealthscale/hooks";
4
+ import { Edge, EdgeProps, EdgeTypes, MiniMapProps, Node, NodeProps, NodeTypes, ReactFlowProps, XYPosition } from "@xyflow/react";
5
+ import { Palette } from "@stealthscale/theme/authoring";
6
+ import { RovingFocus } from "@stealthscale/component-a11y";
7
+ //#region src/graph/diffed.d.ts
8
+ /**
9
+ * Describes the words of the changes a canvas marks, each with an English default.
10
+ */
11
+ interface ChangeWords {
12
+ /**
13
+ * Word of an added node or edge. `Added` unless stated.
14
+ */
15
+ readonly addedLabel?: string | undefined;
16
+ /**
17
+ * Word of a changed node. `Changed` unless stated.
18
+ */
19
+ readonly changedLabel?: string | undefined;
20
+ /**
21
+ * Word of a removed node or edge. `Removed` unless stated.
22
+ */
23
+ readonly removedLabel?: string | undefined;
24
+ }
25
+ /**
26
+ * Describes the props a canvas marks changes by: a comparison and the words of its changes.
27
+ */
28
+ interface CanvasChanges extends ChangeWords {
29
+ /**
30
+ * Comparison whose changes the canvas marks, such as `diffGraphs(before, after)`.
31
+ */
32
+ readonly changes?: GraphDiff | undefined;
33
+ }
34
+ //#endregion
35
+ //#region src/graph/names.d.ts
36
+ /**
37
+ * Describes the ends of an edge by their names, which the canvas's words turn into the edge's name.
38
+ */
39
+ interface EdgeEnds {
40
+ /**
41
+ * Name of the node the edge leaves.
42
+ */
43
+ readonly source: string;
44
+ /**
45
+ * Name of the node the edge enters.
46
+ */
47
+ readonly target: string;
48
+ }
49
+ //#endregion
50
+ //#region src/diff/diff.d.ts
51
+ /**
52
+ * Describes what happened to a node or an edge between two versions.
53
+ */
54
+ type GraphChangeType = "added" | "changed" | "removed" | "unchanged";
55
+ /**
56
+ * Describes one node or edge of a comparison: what happened to it, and what it is called.
57
+ */
58
+ interface GraphChange {
59
+ /**
60
+ * Kind of change the node or the edge went through.
61
+ */
62
+ readonly change: GraphChangeType;
63
+ /**
64
+ * Fields of a changed node's data that differ, sorted. Empty for anything else.
65
+ */
66
+ readonly fields: readonly string[];
67
+ /**
68
+ * Id of the node or the edge in the version it is in, the later one where it is in both.
69
+ */
70
+ readonly id: string;
71
+ /**
72
+ * Name of the node, or the edge's name from the names of its ends.
73
+ */
74
+ readonly label: string;
75
+ }
76
+ /**
77
+ * Describes a comparison of two versions of a graph, node by node and edge by edge.
78
+ */
79
+ interface GraphDiff {
80
+ /**
81
+ * Every edge of either version.
82
+ */
83
+ readonly edges: readonly GraphChange[];
84
+ /**
85
+ * Every node of either version.
86
+ */
87
+ readonly nodes: readonly GraphChange[];
88
+ }
89
+ /**
90
+ * Describes one version of a graph: its nodes and its edges.
91
+ */
92
+ interface GraphVersion {
93
+ /**
94
+ * Edges of the version.
95
+ */
96
+ readonly edges: readonly Edge[];
97
+ /**
98
+ * Nodes of the version.
99
+ */
100
+ readonly nodes: readonly Node[];
101
+ }
102
+ /**
103
+ * Returns what the later version of a graph adds, changes and removes, node by node and edge by
104
+ * edge.
105
+ *
106
+ * @param before - The earlier version.
107
+ * @param after - The later version.
108
+ * @param edgeName - Writes an edge's name from the names of its ends. `Orders to Revenue` unless
109
+ * stated.
110
+ */
111
+ export declare function diffGraphs(before: GraphVersion, after: GraphVersion, edgeName?: (ends: EdgeEnds) => string): GraphDiff;
112
+ //#endregion
113
+ //#region src/graph/walk.d.ts
114
+ /**
115
+ * Walks a graph's links from one node, forward or backward, within a number of hops.
116
+ *
117
+ * @remarks
118
+ * The walk stops at a node it visited before, so a cycle never hangs it. It never counts the node
119
+ * it starts from, so a cycle that leads back to the start does not make the start its own
120
+ * neighbour.
121
+ */
122
+ /**
123
+ * Describes a link between two nodes by their ids.
124
+ */
125
+ interface Link {
126
+ /**
127
+ * Id of the node the link leaves.
128
+ */
129
+ readonly source: string;
130
+ /**
131
+ * Id of the node the link enters.
132
+ */
133
+ readonly target: string;
134
+ }
135
+ //#endregion
136
+ //#region src/directed-graph/branches.d.ts
137
+ /**
138
+ * Returns the ids of every node a node leads to, not counting the node itself.
139
+ */
140
+ export declare function descendantsOf(links: readonly Link[], id: string): ReadonlySet<string>;
141
+ /**
142
+ * Returns the ids of the nodes the collapsed nodes hide.
143
+ *
144
+ * @param ids - Every node of the graph.
145
+ * @param links - The graph's links.
146
+ * @param collapsed - The nodes whose branches are closed.
147
+ */
148
+ export declare function hiddenBy(ids: readonly string[], links: readonly Link[], collapsed: ReadonlySet<string>): ReadonlySet<string>;
149
+ //#endregion
150
+ //#region src/graph/editing.d.ts
151
+ /**
152
+ * Describes the kind of edit a step records.
153
+ */
154
+ type GraphStepType = "connect" | "move" | "remove";
155
+ /**
156
+ * Describes one edit to a graph: its kind and the nodes and edges it touched.
157
+ */
158
+ interface GraphStep {
159
+ /**
160
+ * Ids of the edges the edit connected or removed.
161
+ */
162
+ readonly edges: readonly string[];
163
+ /**
164
+ * Ids of the nodes the edit moved or removed.
165
+ */
166
+ readonly nodes: readonly string[];
167
+ /**
168
+ * Kind of the edit.
169
+ */
170
+ readonly type: GraphStepType;
171
+ }
172
+ /**
173
+ * Describes a graph after an edit.
174
+ *
175
+ * @typeParam N - One node of the graph.
176
+ * @typeParam E - One edge of the graph.
177
+ */
178
+ interface GraphEdit<N extends Node, E extends Edge> {
179
+ /**
180
+ * Edges of the graph after the edit.
181
+ */
182
+ readonly edges: E[];
183
+ /**
184
+ * Nodes of the graph after the edit.
185
+ */
186
+ readonly nodes: N[];
187
+ }
188
+ /**
189
+ * Describes the props a canvas reports edits and drops through.
190
+ *
191
+ * @typeParam N - One node of the graph.
192
+ * @typeParam E - One edge of the graph.
193
+ */
194
+ interface CanvasEdits<N extends Node, E extends Edge> {
195
+ /**
196
+ * Called with a palette item's id and the point in the graph a person dropped it at.
197
+ */
198
+ readonly onDropItem?: ((item: string, position: XYPosition) => void) | undefined;
199
+ /**
200
+ * Channel every edit on the canvas arrives through, as the graph after it and a step, while the
201
+ * canvas's `nodes` and `edges` are the caller's.
202
+ */
203
+ readonly onGraphChange?: ((graph: GraphEdit<N, E>, step: GraphStep) => void) | undefined;
204
+ }
205
+ //#endregion
206
+ //#region src/graph/words.d.ts
207
+ /**
208
+ * Describes the move React Flow announces after an arrow key moves the selected nodes.
209
+ */
210
+ interface Move {
211
+ /**
212
+ * Way the nodes moved: `up`, `down`, `left` or `right`.
213
+ */
214
+ readonly direction: string;
215
+ /**
216
+ * Position across the canvas the node was at before the move.
217
+ */
218
+ readonly x: number;
219
+ /**
220
+ * Position down the canvas the node was at before the move.
221
+ */
222
+ readonly y: number;
223
+ }
224
+ /**
225
+ * Describes the words a canvas gives a screen reader, each with an English default.
226
+ */
227
+ interface CanvasWords {
228
+ /**
229
+ * Instruction every edge of an editable canvas is described by.
230
+ */
231
+ readonly edgeDescription?: string | undefined;
232
+ /**
233
+ * Writes the name of an edge without a name of its own from the names of its ends.
234
+ * `Orders to Clean orders` unless stated.
235
+ */
236
+ readonly edgeName?: ((ends: EdgeEnds) => string) | undefined;
237
+ /**
238
+ * Writes the announcement of a move the arrow keys make.
239
+ */
240
+ readonly moveAnnouncement?: ((move: Move) => string) | undefined;
241
+ /**
242
+ * Instruction every node of an editable canvas is described by.
243
+ */
244
+ readonly nodeDescription?: string | undefined;
245
+ /**
246
+ * Writes the name of an edge's remove control from the names of its ends, for an edge whose data
247
+ * states no `removeLabel`. `Remove the connection from Orders to Clean orders` unless stated.
248
+ */
249
+ readonly removeName?: ((ends: EdgeEnds) => string) | undefined;
250
+ }
251
+ //#endregion
252
+ //#region src/graph/canvas.d.ts
253
+ /**
254
+ * Describes the props of the canvas: the graph, its name, its mode, its words, its edits, and
255
+ * React Flow's props.
256
+ *
257
+ * @typeParam N - One node of the graph.
258
+ * @typeParam E - One edge of the graph.
259
+ */
260
+ interface CanvasProps<N extends Node = Node, E extends Edge = Edge> extends CanvasChanges, CanvasEdits<N, E>, CanvasWords, Omit<ReactFlowProps<N, E>, "aria-label" | "ariaLabelConfig" | "children" | "className" | "colorMode" | "style"> {
261
+ /**
262
+ * Whether the canvas renders its dotted background. On unless stated.
263
+ */
264
+ readonly background?: boolean | undefined;
265
+ /**
266
+ * Elements React Flow renders over the canvas, such as a panel of the caller's. The kit's
267
+ * controls and overview map go beside the canvas, in `Graph.Root`.
268
+ */
269
+ readonly children?: ReactNode | undefined;
270
+ /**
271
+ * Accessible name of the canvas.
272
+ */
273
+ readonly label: string;
274
+ /**
275
+ * Whether the canvas is read and not edited.
276
+ */
277
+ readonly readOnly?: boolean | undefined;
278
+ /**
279
+ * Glyph of every edge's remove control, from the caller. No remove control renders without one.
280
+ */
281
+ readonly removeGlyph?: ReactNode | undefined;
282
+ }
283
+ /**
284
+ * Renders React Flow in the canvas's box with the kit's types, words, names, switches and edits.
285
+ *
286
+ * @typeParam N - One node of the graph.
287
+ * @typeParam E - One edge of the graph.
288
+ * @param props - The graph, its name, its mode, its words, its edits, and React Flow's props.
289
+ */
290
+ declare function Canvas<N extends Node = Node, E extends Edge = Edge>(props: CanvasProps<N, E>): ReactElement;
291
+ //#endregion
292
+ //#region src/graph/caption.d.ts
293
+ /**
294
+ * Renders the `figcaption` with the recipe's caption class.
295
+ */
296
+ declare const Shown$1: import("@stealthscale/theme").StyledComponent<"figcaption", {}>;
297
+ /**
298
+ * Describes the props of the caption: the props of a `figcaption`.
299
+ */
300
+ type CaptionProps = ComponentProps<typeof Shown$1>;
301
+ /**
302
+ * Renders the caption with the ID the root names the figure by.
303
+ *
304
+ * @param props - The props of the `figcaption`.
305
+ */
306
+ declare function Caption(props: CaptionProps): ReactElement;
307
+ //#endregion
308
+ //#region src/graph/control.d.ts
309
+ /**
310
+ * Describes what a control does to the view.
311
+ */
312
+ type ControlAction = "fit" | "zoomIn" | "zoomOut";
313
+ /**
314
+ * Describes the props of a control: what it does, its name, and a roving item's props.
315
+ */
316
+ interface ControlProps extends Omit<RovingFocus.ItemProps, "aria-label" | "as" | "onClick"> {
317
+ /**
318
+ * Action the control takes on the view: zoom in, zoom out, or fit the graph in view.
319
+ */
320
+ readonly action: ControlAction;
321
+ /**
322
+ * Accessible name of the control, such as `Zoom in`.
323
+ */
324
+ readonly label: string;
325
+ }
326
+ /**
327
+ * Renders the control as a toolbar item that zooms or fits the view when pressed.
328
+ *
329
+ * @param props - The action, the name and the item's props.
330
+ */
331
+ declare function Control({ action, label, ...props }: ControlProps): ReactElement;
332
+ //#endregion
333
+ //#region src/graph/controls.d.ts
334
+ /**
335
+ * Describes the props of the controls: their name and the roving focus group's props.
336
+ */
337
+ interface ControlsProps extends Omit<RovingFocus.RootProps, "aria-label" | "role"> {
338
+ /**
339
+ * Accessible name of the toolbar. `Canvas` unless stated.
340
+ */
341
+ readonly label?: string | undefined;
342
+ }
343
+ /**
344
+ * Renders the toolbar with small ghost buttons.
345
+ *
346
+ * @param props - The name and the group's props.
347
+ */
348
+ declare function Controls({ label, ...props }: ControlsProps): ReactElement;
349
+ //#endregion
350
+ //#region src/graph/edge.d.ts
351
+ /**
352
+ * Describes the data of the kit's edge.
353
+ */
354
+ interface GraphEdgeData extends Record<string, unknown> {
355
+ /**
356
+ * Name of the edge's remove control, such as `Remove Draft to Judge`, over the name the canvas's
357
+ * `removeName` writes.
358
+ */
359
+ readonly removeLabel?: string | undefined;
360
+ }
361
+ /**
362
+ * Describes an edge the kit renders.
363
+ */
364
+ type GraphEdgeType = Edge<GraphEdgeData>;
365
+ /**
366
+ * Renders the edge's path, and its remove control while the canvas takes edits.
367
+ *
368
+ * @param props - React Flow's edge props: its ends, its sides and its data among them.
369
+ */
370
+ declare function Edge$1(props: EdgeProps<GraphEdgeType>): ReactElement;
371
+ //#endregion
372
+ //#region src/graph/empty.d.ts
373
+ /**
374
+ * Renders the `div` with the recipe's empty class.
375
+ */
376
+ declare const Empty: import("@stealthscale/theme").StyledComponent<"div", {}>;
377
+ /**
378
+ * Describes the props of the empty state: the props of a `div`.
379
+ */
380
+ type EmptyProps = ComponentProps<typeof Empty>;
381
+ //#endregion
382
+ //#region src/layout/rank.d.ts
383
+ /**
384
+ * Describes the way a graph's edges run: down the canvas, or across it to the right.
385
+ */
386
+ type GraphDirection = "down" | "right";
387
+ /**
388
+ * Describes how `layoutGraph` places the ranks.
389
+ */
390
+ interface RankOptions {
391
+ /**
392
+ * Way the edges run. Down unless stated.
393
+ */
394
+ readonly direction?: GraphDirection | undefined;
395
+ /**
396
+ * Space between two nodes of one rank, in pixels. 48 unless stated.
397
+ */
398
+ readonly nodesep?: number | undefined;
399
+ /**
400
+ * Space between two ranks, in pixels. 128 unless stated.
401
+ */
402
+ readonly ranksep?: number | undefined;
403
+ }
404
+ /**
405
+ * Returns the nodes placed in ranks, each with the size it was placed by as its initial size and
406
+ * the sides its edges leave and enter.
407
+ *
408
+ * @typeParam N - One node of the graph.
409
+ * @param nodes - The graph's nodes, in any order.
410
+ * @param edges - The links between the nodes, of which one to a node outside `nodes` takes no part.
411
+ * @param options - The direction and the spacing.
412
+ */
413
+ export declare function layoutGraph<N extends Node>(nodes: readonly N[], edges: readonly Edge[], options?: RankOptions): N[];
414
+ //#endregion
415
+ //#region src/graph/ports.d.ts
416
+ /**
417
+ * Describes one port of a node: its identity, its name, and whether it takes new connections.
418
+ */
419
+ interface GraphPort {
420
+ /**
421
+ * Whether the port refuses new connections. It still renders.
422
+ */
423
+ readonly disabled?: boolean | undefined;
424
+ /**
425
+ * Identity an edge's `sourceHandle` or `targetHandle` names the port by.
426
+ */
427
+ readonly id: string;
428
+ /**
429
+ * Name of the port, such as `Pass` beside `Fail`.
430
+ */
431
+ readonly label: string;
432
+ /**
433
+ * Whether no edge meets the port. An unused port is still rendered and measured, and is
434
+ * invisible, so an edge that meets it later finds it.
435
+ */
436
+ readonly unused?: boolean | undefined;
437
+ }
438
+ //#endregion
439
+ //#region src/graph/node.d.ts
440
+ /**
441
+ * Describes a node's status: the palette of its dot and its word.
442
+ */
443
+ interface GraphStatus {
444
+ /**
445
+ * Word of the status, such as `Running`.
446
+ */
447
+ readonly label: string;
448
+ /**
449
+ * Palette of the status's dot.
450
+ */
451
+ readonly palette: Palette;
452
+ }
453
+ /**
454
+ * Describes the props of a node's card.
455
+ */
456
+ interface NodeProps$1 {
457
+ /**
458
+ * Controls in the header, such as a menu, outside the drag surface.
459
+ */
460
+ readonly actions?: ReactNode | undefined;
461
+ /**
462
+ * Control on the middle of the card's bottom edge, such as one that opens and closes the node's
463
+ * branch.
464
+ */
465
+ readonly branch?: ReactNode | undefined;
466
+ /**
467
+ * Body of the card, such as a configuration's summary.
468
+ */
469
+ readonly children?: ReactNode | undefined;
470
+ /**
471
+ * Whether the card recedes, as a node outside a traced path does.
472
+ */
473
+ readonly dimmed?: boolean | undefined;
474
+ /**
475
+ * Way this node's edges run, where it differs from the graph's.
476
+ */
477
+ readonly direction?: GraphDirection | undefined;
478
+ /**
479
+ * Glyph before the title, from the caller. Hidden from assistive technology.
480
+ */
481
+ readonly icon?: ReactNode | undefined;
482
+ /**
483
+ * Ports edges enter, in order along their side.
484
+ */
485
+ readonly inputs?: readonly GraphPort[] | undefined;
486
+ /**
487
+ * Whether the node is misconfigured, which edges the card in the error ink.
488
+ */
489
+ readonly invalid?: boolean | undefined;
490
+ /**
491
+ * Ports edges leave, in order along their side.
492
+ */
493
+ readonly outputs?: readonly GraphPort[] | undefined;
494
+ /**
495
+ * Fault of an invalid node in one line, shown under the body.
496
+ */
497
+ readonly problem?: ReactNode | undefined;
498
+ /**
499
+ * Status of the node, a dot in a palette beside a word.
500
+ */
501
+ readonly status?: GraphStatus | undefined;
502
+ /**
503
+ * Line under the title, such as the model or the condition.
504
+ */
505
+ readonly subtitle?: ReactNode | undefined;
506
+ /**
507
+ * Word above the card's top edge at its end, such as the node's relation to a traced node.
508
+ */
509
+ readonly tag?: ReactNode | undefined;
510
+ /**
511
+ * Title of the node.
512
+ */
513
+ readonly title: ReactNode;
514
+ }
515
+ /**
516
+ * Renders the card with its ports, header, body, problem line, tag and branch control.
517
+ *
518
+ * @remarks
519
+ * The branch control renders after the ports, so it covers the handle of the side it is on.
520
+ * @param props - The title, the details, the ports and the states.
521
+ */
522
+ declare function Node$1(props: NodeProps$1): ReactElement;
523
+ //#endregion
524
+ //#region src/graph/label-node.d.ts
525
+ /**
526
+ * Describes the data of a node of a built-in type: its words, its ports and its states.
527
+ */
528
+ interface LabelNodeData extends Record<string, unknown> {
529
+ /**
530
+ * Line in the card's body.
531
+ */
532
+ readonly detail?: string | undefined;
533
+ /**
534
+ * Glyph before the title, from the caller.
535
+ */
536
+ readonly icon?: ReactNode | undefined;
537
+ /**
538
+ * Ports edges enter. `In` unless stated, and none on an `input` node.
539
+ */
540
+ readonly inputs?: readonly GraphPort[] | undefined;
541
+ /**
542
+ * Whether the node is misconfigured.
543
+ */
544
+ readonly invalid?: boolean | undefined;
545
+ /**
546
+ * Title of the node.
547
+ */
548
+ readonly label: string;
549
+ /**
550
+ * Ports edges leave. `Out` unless stated, and none on an `output` node.
551
+ */
552
+ readonly outputs?: readonly GraphPort[] | undefined;
553
+ /**
554
+ * Fault of an invalid node in one line.
555
+ */
556
+ readonly problem?: string | undefined;
557
+ /**
558
+ * Status of the node.
559
+ */
560
+ readonly status?: GraphStatus | undefined;
561
+ /**
562
+ * Line under the title.
563
+ */
564
+ readonly subtitle?: string | undefined;
565
+ }
566
+ /**
567
+ * Describes a node of a built-in type.
568
+ */
569
+ type LabelNodeType = Node<LabelNodeData, "default" | "input" | "output">;
570
+ /**
571
+ * Renders the card of a built-in node from its data, with the ports its type has.
572
+ *
573
+ * @param props - React Flow's node props: its data and its type among them.
574
+ */
575
+ declare function LabelNode({ data, type }: NodeProps<LabelNodeType>): ReactElement;
576
+ //#endregion
577
+ //#region src/graph/minimap.d.ts
578
+ /**
579
+ * Describes the props of the overview map: its name and the props of React Flow's minimap.
580
+ */
581
+ interface MiniMapProps$1 extends Omit<MiniMapProps, "ariaLabel"> {
582
+ /**
583
+ * Accessible name of the map. `Overview` unless stated.
584
+ */
585
+ readonly label?: string | undefined;
586
+ }
587
+ /**
588
+ * Renders React Flow's minimap in the overview box, named, pannable and zoomable.
589
+ *
590
+ * @param props - The name and the props of React Flow's minimap.
591
+ */
592
+ declare function MiniMap$1({ label, ...props }: MiniMapProps$1): ReactElement;
593
+ //#endregion
594
+ //#region src/graph/palette-item.d.ts
595
+ /**
596
+ * Describes the props of a palette item: the kind of node it adds, what a press does, and the
597
+ * button's props.
598
+ */
599
+ interface PaletteItemProps extends Omit<ButtonProps, "draggable" | "onClick" | "onDragStart"> {
600
+ /**
601
+ * Id of the kind of node the item adds, which a drop and a press report.
602
+ */
603
+ readonly item: string;
604
+ /**
605
+ * Called with the item's id and the middle of the view when a person presses the item.
606
+ */
607
+ readonly onAdd: (item: string, position: XYPosition) => void;
608
+ }
609
+ /**
610
+ * Renders the item as a button a person drags onto the canvas or presses.
611
+ *
612
+ * @param props - The kind of node, what a press does, and the button's props.
613
+ */
614
+ declare function PaletteItem({ item, onAdd, ...props }: PaletteItemProps): ReactElement;
615
+ //#endregion
616
+ //#region src/graph/root.d.ts
617
+ /**
618
+ * Renders the `figure` that provides the recipe's variants.
619
+ */
620
+ declare const Figure: import("@stealthscale/theme").StyledComponent<"figure", {
621
+ readonly ratio?: import("@stealthscale/theme/authoring").Ratio;
622
+ }>;
623
+ /**
624
+ * Describes the props of the root: the graph's direction, the recipe's variants and the props of a
625
+ * `figure`.
626
+ *
627
+ * @remarks
628
+ * The figure's props leave out `direction`, the style prop, because the root takes `direction` as
629
+ * the way the graph's edges run.
630
+ */
631
+ interface RootProps extends Omit<ComponentProps<typeof Figure>, "direction"> {
632
+ /**
633
+ * Way the graph's edges run, which puts each node's inputs and outputs on the matching sides.
634
+ * Down unless stated.
635
+ */
636
+ readonly direction?: GraphDirection | undefined;
637
+ }
638
+ /**
639
+ * Renders the figure inside React Flow's provider, named by its caption while one renders.
640
+ *
641
+ * @param props - The direction, the recipe's variants and the props of a `figure`.
642
+ * @returns The `figure` element inside the providers.
643
+ */
644
+ declare function Root({ direction, ...props }: RootProps): ReactElement;
645
+ //#endregion
646
+ //#region src/graph/state.d.ts
647
+ /**
648
+ * Returns the way the graph's edges run.
649
+ */
650
+ declare function useGraphDirection(): GraphDirection;
651
+ //#endregion
652
+ //#region src/graph/summary.d.ts
653
+ /**
654
+ * Renders the `div` with the recipe's summary class.
655
+ */
656
+ declare const Summary: import("@stealthscale/theme").StyledComponent<"div", {}>;
657
+ /**
658
+ * Describes the props of the summary: the props of a `div`.
659
+ */
660
+ type SummaryProps = ComponentProps<typeof Summary>;
661
+ //#endregion
662
+ //#region src/graph/types.d.ts
663
+ /**
664
+ * Maps React Flow's `default`, `input` and `output` node types to the kit's node.
665
+ */
666
+ declare const NODE_TYPES: NodeTypes;
667
+ /**
668
+ * Maps React Flow's `default` edge type to the kit's edge.
669
+ */
670
+ declare const EDGE_TYPES: EdgeTypes;
671
+ //#endregion
672
+ //#region src/graph/zoom-level.d.ts
673
+ /**
674
+ * Renders the `output` with the recipe's level class.
675
+ */
676
+ declare const Shown: import("@stealthscale/theme").StyledComponent<"output", {}>;
677
+ /**
678
+ * Describes the props of the zoom level: its locale and the props of an `output`.
679
+ */
680
+ interface ZoomLevelProps extends Omit<ComponentProps<typeof Shown>, "children"> {
681
+ /**
682
+ * Locale the percentage is written in.
683
+ */
684
+ readonly locale?: string | undefined;
685
+ }
686
+ /**
687
+ * Renders the canvas's zoom as a percentage.
688
+ *
689
+ * @param props - The locale and the props of the `output`.
690
+ */
691
+ declare function ZoomLevel({ locale, ...props }: ZoomLevelProps): ReactElement;
692
+ declare namespace index_d_exports {
693
+ export { Canvas, CanvasChanges, CanvasEdits, CanvasProps, CanvasWords, Caption, CaptionProps, ChangeWords, Control, ControlAction, ControlProps, Controls, ControlsProps, Edge$1 as Edge, EdgeEnds, Empty, EmptyProps, GraphEdgeData, GraphEdgeType, GraphEdit, GraphPort, GraphStatus, GraphStep, GraphStepType, LabelNode, LabelNodeData, LabelNodeType, MiniMap$1 as MiniMap, MiniMapProps$1 as MiniMapProps, Move, Node$1 as Node, NodeProps$1 as NodeProps, PaletteItem, PaletteItemProps, Root, RootProps, Summary, SummaryProps, ZoomLevel, ZoomLevelProps, EDGE_TYPES as edgeTypes, NODE_TYPES as nodeTypes, useGraphDirection };
694
+ }
695
+ //#endregion
696
+ //#region src/directed-graph/types.d.ts
697
+ /**
698
+ * Describes one node of a directed graph: a table, a model, a person.
699
+ */
700
+ interface DirectedNode {
701
+ /**
702
+ * Line in the card's body.
703
+ */
704
+ readonly detail?: ReactNode | undefined;
705
+ /**
706
+ * Glyph before the name, from the caller. Hidden from assistive technology.
707
+ */
708
+ readonly icon?: ReactNode | undefined;
709
+ /**
710
+ * Identity the edges name the node by.
711
+ */
712
+ readonly id: string;
713
+ /**
714
+ * Kind of the node, such as `Table` or `Dashboard`, written under the name.
715
+ */
716
+ readonly kind?: string | undefined;
717
+ /**
718
+ * Name of the node, which is also its accessible name.
719
+ */
720
+ readonly label: string;
721
+ /**
722
+ * Freshness or health of the node, a dot in a palette beside a word.
723
+ */
724
+ readonly status?: GraphStatus | undefined;
725
+ }
726
+ /**
727
+ * Describes one edge of a directed graph: the node it leaves and the node it enters.
728
+ */
729
+ interface DirectedEdge {
730
+ /**
731
+ * Identity of the edge. The ids of its ends, joined by a hyphen, unless stated.
732
+ */
733
+ readonly id?: string | undefined;
734
+ /**
735
+ * Id of the node the edge leaves, such as the table a model reads.
736
+ */
737
+ readonly source: string;
738
+ /**
739
+ * Id of the node the edge enters, such as the model that reads the table.
740
+ */
741
+ readonly target: string;
742
+ }
743
+ /**
744
+ * Describes what a focus does to the other nodes: dims the nodes its trace leaves out, renders only
745
+ * the nodes its trace finds, or only selects.
746
+ */
747
+ type TraceMode = "highlight" | "isolate" | "off";
748
+ /**
749
+ * Describes a trace for the summary's words: the focused node's name and the number of nodes each
750
+ * way.
751
+ */
752
+ interface Counts {
753
+ /**
754
+ * Number of nodes the focused node feeds.
755
+ */
756
+ readonly downstream: number;
757
+ /**
758
+ * Name of the focused node.
759
+ */
760
+ readonly name: string;
761
+ /**
762
+ * Number of nodes that feed the focused node.
763
+ */
764
+ readonly upstream: number;
765
+ }
766
+ /**
767
+ * Describes the words a directed graph writes, each with an English default.
768
+ */
769
+ interface DirectedWords {
770
+ /**
771
+ * Words of the control that drops the focus. `Clear focus` unless stated.
772
+ */
773
+ readonly clearLabel?: string | undefined;
774
+ /**
775
+ * Writes the words of the control that closes a branch from the number of nodes it hides.
776
+ * `Hide 5` unless stated.
777
+ */
778
+ readonly collapseLabel?: ((count: number) => string) | undefined;
779
+ /**
780
+ * Word for a node the focused node feeds, which also names every port edges leave.
781
+ * `Downstream` unless stated.
782
+ */
783
+ readonly downstreamLabel?: string | undefined;
784
+ /**
785
+ * Writes the name of an edge from the names of its ends. `Orders to Revenue` unless stated.
786
+ */
787
+ readonly edgeName?: ((ends: EdgeEnds) => string) | undefined;
788
+ /**
789
+ * Message in the canvas's place while the graph has no node. `No nodes to show.` unless stated.
790
+ */
791
+ readonly emptyLabel?: ReactNode | undefined;
792
+ /**
793
+ * Writes the words of the control that opens a branch from the number of nodes it shows.
794
+ * `Show 5` unless stated.
795
+ */
796
+ readonly expandLabel?: ((count: number) => string) | undefined;
797
+ /**
798
+ * Word for the focused node. `Focus` unless stated.
799
+ */
800
+ readonly focusLabel?: string | undefined;
801
+ /**
802
+ * Instruction every node is described by for a screen reader, which offers Enter, Space and
803
+ * Escape unless stated.
804
+ */
805
+ readonly nodeDescription?: string | undefined;
806
+ /**
807
+ * Words of the summary while nothing is focused.
808
+ */
809
+ readonly promptLabel?: ReactNode | undefined;
810
+ /**
811
+ * Writes the summary of a trace. `Revenue: 3 upstream, 2 downstream` unless stated.
812
+ */
813
+ readonly summary?: ((counts: Counts) => ReactNode) | undefined;
814
+ /**
815
+ * Word for a node that feeds the focused node, which also names every port edges enter.
816
+ * `Upstream` unless stated.
817
+ */
818
+ readonly upstreamLabel?: string | undefined;
819
+ }
820
+ /**
821
+ * Describes the props of a directed graph: the graph, its focus and branches, its parts beside the
822
+ * canvas, its words, and the props of `Graph.Root`.
823
+ */
824
+ interface DirectedGraphProps extends DirectedWords, Omit<RootProps, "children"> {
825
+ /**
826
+ * The finding in words, which names the figure.
827
+ */
828
+ readonly caption?: ReactNode | undefined;
829
+ /**
830
+ * Ids of the nodes whose branches are closed, controlled.
831
+ */
832
+ readonly collapsed?: readonly string[] | undefined;
833
+ /**
834
+ * Whether a node that leads to other nodes renders a control that closes its branch.
835
+ */
836
+ readonly collapsible?: boolean | undefined;
837
+ /**
838
+ * Toolbar above the canvas, such as `Graph.Controls` with the caller's glyphs.
839
+ */
840
+ readonly controls?: ReactNode | undefined;
841
+ /**
842
+ * Ids of the nodes whose branches are closed on the first render.
843
+ */
844
+ readonly defaultCollapsed?: readonly string[] | undefined;
845
+ /**
846
+ * Node focused on the first render, or `null` for none.
847
+ */
848
+ readonly defaultFocus?: null | string | undefined;
849
+ /**
850
+ * Number of hops each way a trace follows. Every hop unless stated.
851
+ */
852
+ readonly depth?: number | undefined;
853
+ /**
854
+ * Edges of the graph.
855
+ */
856
+ readonly edges: readonly DirectedEdge[];
857
+ /**
858
+ * Focused node, controlled, or `null` for none.
859
+ */
860
+ readonly focus?: null | string | undefined;
861
+ /**
862
+ * Accessible name of the canvas.
863
+ */
864
+ readonly label: string;
865
+ /**
866
+ * Nodes of the graph, in any order.
867
+ */
868
+ readonly nodes: readonly DirectedNode[];
869
+ /**
870
+ * Called with the ids of the closed branches whenever a branch opens or closes.
871
+ */
872
+ readonly onCollapsedChange?: ((ids: string[]) => void) | undefined;
873
+ /**
874
+ * Called with the focused node's id, or `null` when the focus is dropped.
875
+ */
876
+ readonly onFocusChange?: ((id: null | string) => void) | undefined;
877
+ /**
878
+ * Overview map below the canvas, such as `Graph.MiniMap`.
879
+ */
880
+ readonly overview?: ReactNode | undefined;
881
+ /**
882
+ * Effect of a focus on the other nodes. `highlight` unless stated.
883
+ */
884
+ readonly trace?: TraceMode | undefined;
885
+ }
886
+ //#endregion
887
+ //#region src/directed-graph/directed-graph.d.ts
888
+ /**
889
+ * Renders the figure: the controls, the canvas, its readout with the overview, and the caption,
890
+ * or the empty state while the graph has no node.
891
+ *
892
+ * @param props - The graph, its focus and branches, its parts, its words and the figure's props.
893
+ */
894
+ export declare function DirectedGraph(props: DirectedGraphProps): ReactElement;
895
+ //#endregion
896
+ //#region src/directed-graph/trace.d.ts
897
+ /**
898
+ * Describes the nodes a trace found in each direction.
899
+ */
900
+ interface Trace {
901
+ /**
902
+ * Ids of the nodes the focused node feeds.
903
+ */
904
+ readonly downstream: ReadonlySet<string>;
905
+ /**
906
+ * Ids of the nodes that feed the focused node.
907
+ */
908
+ readonly upstream: ReadonlySet<string>;
909
+ }
910
+ /**
911
+ * Describes where a node is against the focused node.
912
+ */
913
+ type Relation = "downstream" | "focus" | "unrelated" | "upstream";
914
+ /**
915
+ * Returns the nodes that feed a node and the nodes it feeds, within `depth` hops.
916
+ *
917
+ * @param links - Every edge of the graph, by the ids of its ends.
918
+ * @param id - The node the trace starts from, which is in neither set.
919
+ * @param depth - How many hops each way count. Every hop unless stated.
920
+ */
921
+ export declare function traceGraph(links: readonly Link[], id: string, depth?: number): Trace;
922
+ /**
923
+ * Returns where a node is against the focused node of a trace.
924
+ */
925
+ export declare function relationOf(id: string, focus: string, trace: Trace): Relation;
926
+ //#endregion
927
+ //#region src/directed-graph/tree.d.ts
928
+ /**
929
+ * Turns a flat list whose items name their parent into the edges of a tree.
930
+ *
931
+ * @remarks
932
+ * An HR system, a file index or a category table stores a hierarchy as a parent field on each
933
+ * item, so a caller does not rebuild it into nested children. An item whose parent is not in the
934
+ * list becomes a root, so a list filtered to one department still renders. Each edge's id is the
935
+ * parent's id and the child's id, joined by a hyphen.
936
+ */
937
+ /**
938
+ * Describes an edge of a tree: its id and the ids of its parent and its child.
939
+ */
940
+ interface TreeEdge {
941
+ /**
942
+ * The parent's id and the child's id, joined by a hyphen.
943
+ */
944
+ readonly id: string;
945
+ /**
946
+ * Id of the parent.
947
+ */
948
+ readonly source: string;
949
+ /**
950
+ * Id of the child.
951
+ */
952
+ readonly target: string;
953
+ }
954
+ /**
955
+ * Describes an item of a flat list by its identity, which its children name as their parent.
956
+ */
957
+ interface TreeItem {
958
+ /**
959
+ * Identity of the item.
960
+ */
961
+ readonly id: string;
962
+ }
963
+ /**
964
+ * Returns an edge from each item's parent to the item, for every item whose parent is in the list.
965
+ *
966
+ * @typeParam T - One item of the list.
967
+ * @param items - The items, in any order.
968
+ * @param parentOf - Returns an item's parent's id, or undefined for an item without one.
969
+ */
970
+ export declare function treeEdges<T extends TreeItem>(items: readonly T[], parentOf: (item: T) => string | undefined): TreeEdge[];
971
+ //#endregion
972
+ //#region src/layout/force.d.ts
973
+ /**
974
+ * Describes a link a force layout pulls its ends together along.
975
+ */
976
+ interface ForceLink extends Link {
977
+ /**
978
+ * How strongly the link ties its ends, 1 unless stated. A tie of 2 or more pulls the ends twice
979
+ * as close as a tie of 1.
980
+ */
981
+ readonly strength?: number | undefined;
982
+ }
983
+ /**
984
+ * Describes how `layoutForce` runs its simulation.
985
+ */
986
+ interface ForceOptions {
987
+ /**
988
+ * Number of the simulation's steps. 300 unless stated.
989
+ */
990
+ readonly iterations?: number | undefined;
991
+ /**
992
+ * Number the start's order of neighbours comes from. The same seed and graph give the same
993
+ * positions. 1 unless stated.
994
+ */
995
+ readonly seed?: number | undefined;
996
+ }
997
+ /**
998
+ * Returns the nodes placed by the force simulation, each with the size it was placed by as its
999
+ * initial size.
1000
+ *
1001
+ * @typeParam N - One node of the graph.
1002
+ * @param nodes - The graph's nodes, in any order.
1003
+ * @param links - The links between the nodes, read as undirected.
1004
+ * @param options - The number of steps and the seed.
1005
+ */
1006
+ export declare function layoutForce<N extends Node>(nodes: readonly N[], links: readonly ForceLink[], options?: ForceOptions): N[];
1007
+ //#endregion
1008
+ //#region src/network-graph/types.d.ts
1009
+ /**
1010
+ * Describes one node of a network: a service, a bank, a person.
1011
+ */
1012
+ interface NetworkNode {
1013
+ /**
1014
+ * Glyph in the disc, from the caller. Hidden from assistive technology.
1015
+ */
1016
+ readonly icon?: ReactNode | undefined;
1017
+ /**
1018
+ * Identity the links name the node by.
1019
+ */
1020
+ readonly id: string;
1021
+ /**
1022
+ * Name under the disc, which is also the node's accessible name.
1023
+ */
1024
+ readonly label: string;
1025
+ /**
1026
+ * Importance of the node, which sizes its disc against the heaviest node's. The number of its
1027
+ * links unless stated.
1028
+ */
1029
+ readonly weight?: number | undefined;
1030
+ }
1031
+ /**
1032
+ * Describes one link of a network: two nodes it ties, read the same either way round.
1033
+ */
1034
+ interface NetworkLink extends ForceLink {
1035
+ /**
1036
+ * Identity of the link. The ids of its ends, joined by a hyphen, unless stated.
1037
+ */
1038
+ readonly id?: string | undefined;
1039
+ }
1040
+ /**
1041
+ * Describes a focused node for the summary's words: its name and the number of nodes it connects
1042
+ * to.
1043
+ */
1044
+ interface Connections {
1045
+ /**
1046
+ * Number of nodes within `depth` hops of the focused node.
1047
+ */
1048
+ readonly count: number;
1049
+ /**
1050
+ * Name of the focused node.
1051
+ */
1052
+ readonly name: string;
1053
+ }
1054
+ /**
1055
+ * Describes the words a network graph writes, each with an English default.
1056
+ */
1057
+ interface NetworkWords {
1058
+ /**
1059
+ * Words of the control that drops the focus. `Clear focus` unless stated.
1060
+ */
1061
+ readonly clearLabel?: string | undefined;
1062
+ /**
1063
+ * Writes the name of a link from the names of its ends. `Orders and Billing` unless stated.
1064
+ */
1065
+ readonly edgeName?: ((ends: EdgeEnds) => string) | undefined;
1066
+ /**
1067
+ * Message in the canvas's place while the graph has no node. `No nodes to show.` unless stated.
1068
+ */
1069
+ readonly emptyLabel?: ReactNode | undefined;
1070
+ /**
1071
+ * Word the focused node's accessible name ends with. `Focus` unless stated.
1072
+ */
1073
+ readonly focusLabel?: string | undefined;
1074
+ /**
1075
+ * Writes the announcement of a move the arrow keys make.
1076
+ */
1077
+ readonly moveAnnouncement?: ((move: Move) => string) | undefined;
1078
+ /**
1079
+ * Word the accessible name of a node the focused node connects to ends with. `Connected` unless
1080
+ * stated.
1081
+ */
1082
+ readonly neighborLabel?: string | undefined;
1083
+ /**
1084
+ * Instruction every node is described by for a screen reader, which offers Enter, Space, Escape
1085
+ * and, while nodes can be dragged, the arrow keys unless stated.
1086
+ */
1087
+ readonly nodeDescription?: string | undefined;
1088
+ /**
1089
+ * Words of the summary while nothing is focused.
1090
+ */
1091
+ readonly promptLabel?: ReactNode | undefined;
1092
+ /**
1093
+ * Writes the summary of a focus. `Orders: 3 connections` unless stated.
1094
+ */
1095
+ readonly summary?: ((connections: Connections) => ReactNode) | undefined;
1096
+ }
1097
+ /**
1098
+ * Describes the props of a network graph: the graph, its focus, its layout, its parts beside the
1099
+ * canvas, its words, and the props of `Graph.Root`.
1100
+ */
1101
+ interface NetworkGraphProps extends NetworkWords, Omit<RootProps, "children" | "direction"> {
1102
+ /**
1103
+ * The finding in words, which names the figure.
1104
+ */
1105
+ readonly caption?: ReactNode | undefined;
1106
+ /**
1107
+ * Toolbar above the canvas, such as `Graph.Controls` with the caller's glyphs.
1108
+ */
1109
+ readonly controls?: ReactNode | undefined;
1110
+ /**
1111
+ * Node focused on the first render, or `null` for none.
1112
+ */
1113
+ readonly defaultFocus?: null | string | undefined;
1114
+ /**
1115
+ * Number of hops from the focused node within which a node is lit. 1 unless stated.
1116
+ */
1117
+ readonly depth?: number | undefined;
1118
+ /**
1119
+ * Whether a person can move a node by dragging it or by the arrow keys. On unless stated.
1120
+ */
1121
+ readonly draggable?: boolean | undefined;
1122
+ /**
1123
+ * Focused node, controlled, or `null` for none.
1124
+ */
1125
+ readonly focus?: null | string | undefined;
1126
+ /**
1127
+ * Number of the layout's steps. 300 unless stated.
1128
+ */
1129
+ readonly iterations?: number | undefined;
1130
+ /**
1131
+ * Accessible name of the canvas.
1132
+ */
1133
+ readonly label: string;
1134
+ /**
1135
+ * Links of the graph, read the same either way round.
1136
+ */
1137
+ readonly links: readonly NetworkLink[];
1138
+ /**
1139
+ * Nodes of the graph, in any order.
1140
+ */
1141
+ readonly nodes: readonly NetworkNode[];
1142
+ /**
1143
+ * Called with the focused node's id, or `null` when the focus is dropped.
1144
+ */
1145
+ readonly onFocusChange?: ((id: null | string) => void) | undefined;
1146
+ /**
1147
+ * Overview map below the canvas, such as `Graph.MiniMap`.
1148
+ */
1149
+ readonly overview?: ReactNode | undefined;
1150
+ /**
1151
+ * Number the layout starts from. The same seed and graph give the same picture. 1 unless stated.
1152
+ */
1153
+ readonly seed?: number | undefined;
1154
+ }
1155
+ //#endregion
1156
+ //#region src/network-graph/network-graph.d.ts
1157
+ /**
1158
+ * Renders the figure: the controls, the canvas, its readout with the overview, and the caption,
1159
+ * or the empty state while the graph has no node.
1160
+ *
1161
+ * @param props - The graph, its focus, its layout, its parts, its words and the figure's props.
1162
+ */
1163
+ export declare function NetworkGraph(props: NetworkGraphProps): ReactElement;
1164
+ //#endregion
1165
+ //#region src/network-graph/network.d.ts
1166
+ /**
1167
+ * Returns the nodes within `depth` hops of a node, following each link either way round.
1168
+ *
1169
+ * @param links - The graph's links.
1170
+ * @param id - The node the walk starts from, which is never among the nodes it returns.
1171
+ * @param depth - How many hops count. 1 unless stated.
1172
+ */
1173
+ export declare function neighborsOf(links: readonly NetworkLink[], id: string, depth?: number): Set<string>;
1174
+ //#endregion
1175
+ export { type Connections, type Counts, type DirectedEdge, type DirectedGraphProps, type DirectedNode, type DirectedWords, type ForceLink, type ForceOptions, index_d_exports as Graph, type GraphChange, type GraphChangeType, type GraphDiff, type GraphDirection, type GraphVersion, type Link, type NetworkGraphProps, type NetworkLink, type NetworkNode, type NetworkWords, type RankOptions, type Relation, type Trace, type TraceMode, type TreeEdge };