@re-cinq/floor-graph 0.0.0-stage → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +18 -2
  3. package/dist/ArrowMarkerDefs.d.ts +3 -0
  4. package/dist/ArrowMarkerDefs.js +16 -0
  5. package/dist/ControlIcon.d.ts +3 -0
  6. package/dist/ControlIcon.js +5 -0
  7. package/dist/DanglingStub.d.ts +7 -0
  8. package/dist/DanglingStub.js +10 -0
  9. package/dist/ExitDot.d.ts +8 -0
  10. package/dist/ExitDot.js +7 -0
  11. package/dist/GraphEdge.d.ts +27 -0
  12. package/dist/GraphEdge.js +32 -0
  13. package/dist/GraphNode.d.ts +43 -0
  14. package/dist/GraphNode.js +138 -0
  15. package/dist/GraphSvg.d.ts +50 -0
  16. package/dist/GraphSvg.js +77 -0
  17. package/dist/GraphViewport.d.ts +16 -0
  18. package/dist/GraphViewport.js +27 -0
  19. package/dist/NodeBadges.d.ts +8 -0
  20. package/dist/NodeBadges.js +19 -0
  21. package/dist/NodeBox.d.ts +8 -0
  22. package/dist/NodeBox.js +8 -0
  23. package/dist/NodeTitle.d.ts +8 -0
  24. package/dist/NodeTitle.js +7 -0
  25. package/dist/NodeTooltip.d.ts +9 -0
  26. package/dist/NodeTooltip.js +30 -0
  27. package/dist/RunGraphLegend.d.ts +4 -0
  28. package/dist/RunGraphLegend.js +20 -0
  29. package/dist/RunGraphView.d.ts +27 -0
  30. package/dist/RunGraphView.js +151 -0
  31. package/dist/ToggleButton.d.ts +8 -0
  32. package/dist/ToggleButton.js +6 -0
  33. package/dist/TypeGlyph.d.ts +9 -0
  34. package/dist/TypeGlyph.js +23 -0
  35. package/dist/ViewportControls.d.ts +13 -0
  36. package/dist/ViewportControls.js +11 -0
  37. package/dist/assembly-line-definition.d.ts +35 -0
  38. package/dist/assembly-line-definition.js +2 -0
  39. package/dist/elk-graph.d.ts +16 -0
  40. package/dist/elk-graph.js +131 -0
  41. package/dist/elk-layout.d.ts +46 -0
  42. package/dist/elk-layout.js +67 -0
  43. package/dist/graph-markers.d.ts +2 -0
  44. package/dist/graph-markers.js +10 -0
  45. package/dist/graph-view-model.d.ts +33 -0
  46. package/dist/graph-view-model.js +55 -0
  47. package/dist/index.d.ts +9 -0
  48. package/dist/index.js +6 -0
  49. package/dist/layout-geometry.d.ts +16 -0
  50. package/dist/layout-geometry.js +56 -0
  51. package/dist/metro/declared-ids.d.ts +3 -0
  52. package/dist/metro/declared-ids.js +5 -0
  53. package/dist/metro/edge-key.d.ts +3 -0
  54. package/dist/metro/edge-key.js +5 -0
  55. package/dist/metro/layout-diff.d.ts +12 -0
  56. package/dist/metro/layout-diff.js +32 -0
  57. package/dist/metro/main-path.d.ts +8 -0
  58. package/dist/metro/main-path.js +26 -0
  59. package/dist/metro/neighbourhood.d.ts +7 -0
  60. package/dist/metro/neighbourhood.js +28 -0
  61. package/dist/metro/node-edges.d.ts +5 -0
  62. package/dist/metro/node-edges.js +9 -0
  63. package/dist/metro/pass-through.d.ts +3 -0
  64. package/dist/metro/pass-through.js +16 -0
  65. package/dist/metro/reachability.d.ts +8 -0
  66. package/dist/metro/reachability.js +31 -0
  67. package/dist/metro/removed-stations.d.ts +13 -0
  68. package/dist/metro/removed-stations.js +11 -0
  69. package/dist/metro/station-visits.d.ts +7 -0
  70. package/dist/metro/station-visits.js +13 -0
  71. package/dist/metro/step-along.d.ts +8 -0
  72. package/dist/metro/step-along.js +28 -0
  73. package/dist/metro/taken-count.d.ts +6 -0
  74. package/dist/metro/taken-count.js +11 -0
  75. package/dist/metro/taken-lines.d.ts +12 -0
  76. package/dist/metro/taken-lines.js +20 -0
  77. package/dist/metro/visited-part.d.ts +4 -0
  78. package/dist/metro/visited-part.js +24 -0
  79. package/dist/node-aria-label.d.ts +9 -0
  80. package/dist/node-aria-label.js +11 -0
  81. package/dist/node-badges.d.ts +8 -0
  82. package/dist/node-badges.js +20 -0
  83. package/dist/node-tooltip.d.ts +12 -0
  84. package/dist/node-tooltip.js +34 -0
  85. package/dist/node-type-family.d.ts +6 -0
  86. package/dist/node-type-family.js +18 -0
  87. package/dist/run-graph-drawing.d.ts +14 -0
  88. package/dist/run-graph-drawing.js +22 -0
  89. package/dist/run-graph-geometry.d.ts +18 -0
  90. package/dist/run-graph-geometry.js +38 -0
  91. package/dist/run-graph-tone-classes.d.ts +5 -0
  92. package/dist/run-graph-tone-classes.js +34 -0
  93. package/dist/run-graph.module.css +470 -0
  94. package/dist/run-graph.test-helpers.d.ts +4 -0
  95. package/dist/run-graph.test-helpers.js +11 -0
  96. package/dist/station-subtitle.d.ts +2 -0
  97. package/dist/station-subtitle.js +6 -0
  98. package/dist/use-element-size.d.ts +6 -0
  99. package/dist/use-element-size.js +17 -0
  100. package/dist/use-elk-layout.d.ts +5 -0
  101. package/dist/use-elk-layout.js +19 -0
  102. package/dist/use-keyboard-cursor.d.ts +10 -0
  103. package/dist/use-keyboard-cursor.js +39 -0
  104. package/dist/use-layout-changes.d.ts +11 -0
  105. package/dist/use-layout-changes.js +45 -0
  106. package/dist/use-measured-box.d.ts +3 -0
  107. package/dist/use-measured-box.js +13 -0
  108. package/dist/use-node-size.d.ts +7 -0
  109. package/dist/use-node-size.js +17 -0
  110. package/dist/use-node-tooltip.d.ts +20 -0
  111. package/dist/use-node-tooltip.js +74 -0
  112. package/dist/use-pointer-drag.d.ts +7 -0
  113. package/dist/use-pointer-drag.js +23 -0
  114. package/dist/use-redrawn.d.ts +4 -0
  115. package/dist/use-redrawn.js +8 -0
  116. package/dist/use-revealed.d.ts +4 -0
  117. package/dist/use-revealed.js +11 -0
  118. package/dist/use-run-overlay.d.ts +7 -0
  119. package/dist/use-run-overlay.js +11 -0
  120. package/dist/use-toggle.d.ts +4 -0
  121. package/dist/use-toggle.js +7 -0
  122. package/dist/use-wheel-navigation.d.ts +3 -0
  123. package/dist/use-wheel-navigation.js +19 -0
  124. package/dist/viewport-input.d.ts +16 -0
  125. package/dist/viewport-input.js +19 -0
  126. package/dist/viewport-state.d.ts +46 -0
  127. package/dist/viewport-state.js +48 -0
  128. package/dist/viewport.d.ts +27 -0
  129. package/dist/viewport.js +66 -0
  130. package/dist/viewport.module.css +67 -0
  131. package/package.json +69 -4
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 re:cinq B.V.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,19 @@
1
- # Temporary Holding Version
1
+ # @re-cinq/floor-graph
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A React view of an assembly line as a graph: layout, pan and zoom, nodes and edges. [elkjs](https://github.com/kieler/elkjs) lays the line out: stations left to right, every line on its own ports, routed at right angles around stations and labels. It ships compiled JS and its CSS modules, so use it from a bundler such as Vite.
4
+
5
+ ```
6
+ npm install @re-cinq/floor-graph
7
+ ```
8
+
9
+ ```tsx
10
+ import { RunGraphView, type AssemblyLineDefinition } from "@re-cinq/floor-graph";
11
+
12
+ <RunGraphView definition={definition} />;
13
+ ```
14
+
15
+ The controls hold zoom, fit and two toggles. "Main path" fades every station and line off the path from the entry along `success` (or the first `always` when nothing succeeds). "Compact stops" draws a station with one line in and one `always` line out as a stop on the track, unless it is the entry or is started from outside. The `mainPathOnly` and `compactStops` props set where each toggle starts. `onSelectLine(key)` and `selectedLineKey` select a line by its `from|to|event` key (`edgeKeyOf`). On a focused station, Down and Up choose one of its out-lines (drawn bold), Right moves to the station that line leads to, Left goes back along an in-line, and Enter selects. When the definition changes, new stations and lines flash for 1.2 s (`diffLayouts` against the last layout; the first draw flashes nothing) and moved lines slide to their new route. A station that moves after an edit slides to its new place over 400 ms; motion is off under `prefers-reduced-motion`.
16
+
17
+ Pass `run={{ visits }}` (`Visit`: `nodeId`, `iteration`, `outcome?`, `open`) to overlay one assembly run. A line the run did not take fades to 30% (`takenLinesOf`, lore's first-match rule). A line taken more than once shows ×N beside its label, and the layout reserves room for it. An unvisited station fades to 40%; a visited card's own border takes the colour of its last closed outcome, its subtitle counts visits above one (`agent · 2 visits`), and while a visit is open it adds ` · open` and the border pulses. With a run, `show` defaults to `"visited"`: ELK lays out only the entry, the visited stations, the lines the run took and the stations they reach (`visitedPartOf`), so the graph stays small. A "Whole line" toggle brings in the rest, faded; `show="all"` starts there. A station removed by an edit, or hidden by turning "Whole line" off, fades out over 300 ms.
18
+
19
+ Started as a copy of re-cinq/lore-security `apps/web-ui/src` at commit 4598c19791154a2ae6afffa65e8b26c0825140b6, with everything about a run stripped. The layout is no longer lore's.
@@ -0,0 +1,3 @@
1
+ /** What a connector passes as its `markerEnd`. */
2
+ export declare const ARROW_MARKER_URL = "url(#rgv-arrow)";
3
+ export default function ArrowMarkerDefs(): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // The one arrowhead every connector points with; the marker id lives next to the marker so definition and reference cannot drift.
3
+ import styles from "./run-graph.module.css";
4
+ const ARROW_MARKER_ID = "rgv-arrow";
5
+ // Referenced from the stylesheet as url(#rgv-agent-border); keep the two in step.
6
+ const AGENT_BORDER_ID = "rgv-agent-border";
7
+ /** What a connector passes as its `markerEnd`. */
8
+ export const ARROW_MARKER_URL = `url(#${ARROW_MARKER_ID})`;
9
+ export default function ArrowMarkerDefs() {
10
+ return (_jsxs("defs", { children: [_jsx("marker", { id: ARROW_MARKER_ID, markerWidth: "9", markerHeight: "8", refX: "7", refY: "4", orient: "auto-start-reverse", markerUnits: "userSpaceOnUse", children: _jsx("path", { className: styles.arrowHead, d: "M1 1 L7 4 L1 7 L2.6 4 Z" }) }), _jsx(AgentBorderGradient, {})] }));
11
+ }
12
+ /** An AI step's border runs through the palette, so the work a model does reads apart from every other step (run-viz FR4.1h). */
13
+ function AgentBorderGradient() {
14
+ return (_jsxs("linearGradient", { id: AGENT_BORDER_ID, x1: "0", y1: "0", x2: "1", y2: "1", children: [_jsx("stop", { offset: "0", className: styles.agentStopStart }), _jsx("stop", { offset: "0.5", className: styles.agentStopMiddle }), _jsx("stop", { offset: "1", className: styles.agentStopEnd })] }));
15
+ }
16
+ //# sourceMappingURL=ArrowMarkerDefs.js.map
@@ -0,0 +1,3 @@
1
+ export default function ControlIcon({ icon }: {
2
+ icon: string;
3
+ }): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export default function ControlIcon({ icon }) {
3
+ return (_jsx("svg", { "aria-hidden": "true", viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: icon }) }));
4
+ }
5
+ //# sourceMappingURL=ControlIcon.js.map
@@ -0,0 +1,7 @@
1
+ import type { ElkLayout } from "./elk-layout";
2
+ interface DanglingStubProps {
3
+ node: ElkLayout["nodes"][number];
4
+ }
5
+ /** Where an outcome leads to a line nobody starts: a short end bar with a warning beside it. */
6
+ export default function DanglingStub({ node }: DanglingStubProps): import("react").JSX.Element;
7
+ export {};
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import styles from "./run-graph.module.css";
3
+ const BAR_HALF_LENGTH = 7;
4
+ const LABEL_GAP = 8;
5
+ const LABEL_DROP = 12;
6
+ /** Where an outcome leads to a line nobody starts: a short end bar with a warning beside it. */
7
+ export default function DanglingStub({ node }) {
8
+ return (_jsxs("g", { "data-stub": node.id.replace(/:stub$/, ""), children: [_jsx("line", { className: styles.stubBar, x1: node.x, x2: node.x, y1: node.y - BAR_HALF_LENGTH, y2: node.y + BAR_HALF_LENGTH }), _jsx("text", { className: styles.stubText, x: node.x + LABEL_GAP, y: node.y + LABEL_DROP, children: "\u26A0 nobody starts on it" })] }));
9
+ }
10
+ //# sourceMappingURL=DanglingStub.js.map
@@ -0,0 +1,8 @@
1
+ import type { ElkLayout } from "./elk-layout";
2
+ interface ExitDotProps {
3
+ node: ElkLayout["nodes"][number];
4
+ exit: string;
5
+ }
6
+ /** Where a line off the main path ends the run: a ring with a dot, like the exit terminal. */
7
+ export default function ExitDot({ node, exit }: ExitDotProps): import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import styles from "./run-graph.module.css";
3
+ /** Where a line off the main path ends the run: a ring with a dot, like the exit terminal. */
4
+ export default function ExitDot({ node, exit }) {
5
+ return (_jsxs("g", { "data-exit-dot": node.id.replace(/:exit$/, ""), children: [_jsx("title", { children: `ends the run at ${exit}` }), _jsx("circle", { className: styles.exitRing, cx: node.x, cy: node.y, r: 6 }), _jsx("circle", { className: styles.exitCore, cx: node.x, cy: node.y, r: 2.5 })] }));
6
+ }
7
+ //# sourceMappingURL=ExitDot.js.map
@@ -0,0 +1,27 @@
1
+ import type { LaidOutEdge } from "./elk-layout";
2
+ import type { VisibleEdge } from "./graph-view-model";
3
+ export type EdgeEmphasis = "outgoing" | "other" | undefined;
4
+ export interface GraphEdgeProps {
5
+ edge: LaidOutEdge;
6
+ model: VisibleEdge | undefined;
7
+ /** Outgoing: leaves the selected node. Other: something is selected and this hop is not from it. Undefined when nothing is selected. */
8
+ emphasis: EdgeEmphasis;
9
+ /** Outside the hovered node's neighbourhood. */
10
+ dimmed?: boolean;
11
+ /** Off the main line. */
12
+ offPath?: boolean;
13
+ /** Newly drawn by the latest layout. */
14
+ added?: boolean;
15
+ /** Whether the run took this line (or it is the `takenEdge`); undefined without either. */
16
+ taken?: boolean;
17
+ /** How many times the run took this line; shown from two. */
18
+ takenCount?: number;
19
+ /** The line the inspector shows. */
20
+ selected?: boolean;
21
+ /** The line the keyboard cursor is on. */
22
+ chosen?: boolean;
23
+ onSelectLine?: (key: string) => void;
24
+ }
25
+ export default function GraphEdge(props: GraphEdgeProps): import("react").JSX.Element;
26
+ /** Drawn after the nodes, so a label in the narrow air between two columns is not hidden behind them. */
27
+ export declare function EdgeLabel({ edge, model, emphasis, dimmed, offPath, selected, takenCount, onSelectLine }: GraphEdgeProps): import("react").JSX.Element | null;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { COUNT_GAP, countTextOf, countWidthOf } from "./metro/taken-count";
3
+ import { ARROW_MARKER_URL } from "./ArrowMarkerDefs";
4
+ import { edgeKeyOf } from "./metro/edge-key";
5
+ import { classes, edgeStrokeClass, textFillClass } from "./run-graph-tone-classes";
6
+ import styles from "./run-graph.module.css";
7
+ export default function GraphEdge(props) {
8
+ const { edge, model, emphasis, dimmed, offPath, selected, chosen, added, taken, takenCount = 0, onSelectLine } = props;
9
+ const tone = model?.tone ?? "neutral";
10
+ return (_jsxs("g", { "data-edge": edgeKeyOf(edge), "data-tone": tone, "data-emphasis": emphasis, ...stateAttrsOf({ dimmed, offPath, selected, chosen, added, taken }), onClick: () => onSelectLine?.(edgeKeyOf(edge)), children: [_jsx("path", { "data-hit": true, className: styles.edgeHit, d: edge.d }), _jsx("path", { className: pathClassOf(edge, { tone, emphasis, taken }), d: edge.d, markerEnd: ARROW_MARKER_URL }), takenCount > 1 && _jsx(TakenCount, { edge: edge, model: model, count: takenCount })] }));
11
+ }
12
+ /** Ends at the right edge of the box the layout reserved for the label, so it never lands under the line. */
13
+ function TakenCount({ edge, model, count }) {
14
+ const { y: midY, vertical } = edge.mid;
15
+ const countX = edge.labelBox.maxX - COUNT_GAP;
16
+ return (_jsx("text", { "data-taken-count": true, className: classes(styles.takenCount, textFillClass(model?.tone ?? "neutral")), x: countX, y: midY, textAnchor: "end", transform: vertical ? `rotate(-90 ${countX} ${midY})` : undefined, children: countTextOf(count) }));
17
+ }
18
+ function pathClassOf(edge, { tone, emphasis, taken }) {
19
+ return classes(styles.edge, styles[edge.kind], edgeStrokeClass(tone), emphasis === "outgoing" ? styles.outgoing : undefined, emphasis === "other" ? styles.dim : undefined, taken ? styles.taken : undefined);
20
+ }
21
+ /** Drawn after the nodes, so a label in the narrow air between two columns is not hidden behind them. */
22
+ export function EdgeLabel({ edge, model, emphasis, dimmed, offPath, selected, takenCount = 0, onSelectLine }) {
23
+ if (!model)
24
+ return null;
25
+ const labelX = edge.mid.x - countWidthOf(takenCount) / 2;
26
+ return (_jsx("text", { "data-edge-label": edgeKeyOf(edge), ...stateAttrsOf({ dimmed, offPath, selected }), onClick: () => onSelectLine?.(edgeKeyOf(edge)), className: classes(styles.edgeLabel, textFillClass(model.tone), emphasis === "other" ? styles.dim : undefined), x: labelX, y: edge.mid.y, textAnchor: "middle", transform: edge.mid.vertical ? `rotate(-90 ${labelX} ${edge.mid.y})` : undefined, children: model.label }));
27
+ }
28
+ /** The data attributes a line and its label share, each left off when false. */
29
+ function stateAttrsOf({ dimmed, offPath, selected, chosen, added, taken }) {
30
+ return { "data-dim": dimmed || undefined, "data-off-path": offPath || undefined, "data-selected": selected || undefined, "data-chosen": chosen || undefined, "data-change": added ? "added" : undefined, "data-taken": taken };
31
+ }
32
+ //# sourceMappingURL=GraphEdge.js.map
@@ -0,0 +1,43 @@
1
+ import type { KeyboardCursor } from "./use-keyboard-cursor";
2
+ import type { LaidOutNode } from "./elk-layout";
3
+ import type { ConnectorTone, VisibleNode } from "./graph-view-model";
4
+ import type { StationVisits } from "./metro/station-visits";
5
+ import type { NodeOffset } from "./metro/layout-diff";
6
+ export interface GraphNodeProps {
7
+ node: LaidOutNode;
8
+ model: VisibleNode;
9
+ height: number;
10
+ isTerminal: boolean;
11
+ /** No start leads to it. */
12
+ isUnreachable?: boolean;
13
+ /** Drawn as a small stop rather than a card. */
14
+ isStop?: boolean;
15
+ /** The node the inspector shows; drawn with a ring so the graph says which one. */
16
+ selected?: boolean;
17
+ onSelect?: (nodeId: string) => void;
18
+ /** Told which node the pointer or the keyboard focus is on, or null once it leaves. */
19
+ onHover?: (nodeId: string | null) => void;
20
+ /** Outside the hovered node's neighbourhood. */
21
+ dimmed?: boolean;
22
+ /** Off the main line. */
23
+ offPath?: boolean;
24
+ /** Newly drawn by the latest layout. */
25
+ added?: boolean;
26
+ moved?: boolean;
27
+ offset?: NodeOffset;
28
+ /** Dropped by the latest layout; fading out and out of reach. */
29
+ removed?: boolean;
30
+ /** The id of the tooltip shown for this node, while one is. */
31
+ describedBy?: string;
32
+ /** Whether the run came here (undefined without a run). */
33
+ visited?: boolean;
34
+ /** How the run's last closed visit here ended. */
35
+ outcome?: string;
36
+ /** What the run did here: how often it came, and whether a visit is open. */
37
+ status?: StationVisits;
38
+ /** The keyboard cursor: told when this node takes focus, and given its keys. */
39
+ keyboard?: Pick<KeyboardCursor, "onFocusNode" | "onKeyDown">;
40
+ /** The tone of each out-port's line, by edge key; a port with no line draws neutral. */
41
+ toneByEdge?: ReadonlyMap<string, ConnectorTone>;
42
+ }
43
+ export default function GraphNode(props: GraphNodeProps): import("react").JSX.Element;
@@ -0,0 +1,138 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import NodeBadges from "./NodeBadges";
3
+ import NodeBox from "./NodeBox";
4
+ import NodeTitle from "./NodeTitle";
5
+ import TypeGlyph, { FAMILY_CLASS } from "./TypeGlyph";
6
+ import { badgesOf } from "./node-badges";
7
+ import { nodeAriaLabel } from "./node-aria-label";
8
+ import { typeFamilyOf } from "./node-type-family";
9
+ import { nodeTitle } from "./node-tooltip";
10
+ import { subtitleOf } from "./station-subtitle";
11
+ import { classes, portFillClass } from "./run-graph-tone-classes";
12
+ import styles from "./run-graph.module.css";
13
+ // The type mark's centre from the box's top-left: inside the corner, clear of the text to its right.
14
+ const GLYPH_INSET = 11;
15
+ const NO_TONES = new Map();
16
+ export default function GraphNode(props) {
17
+ const { node, model, height, selected = false, isUnreachable } = props;
18
+ const family = typeFamilyOf(model.type);
19
+ const shape = shapeOf(family, props);
20
+ const BODY = BODY_BY_SHAPE[shape];
21
+ return (_jsxs("g", { className: classes(styles.node, FAMILY_CLASS[family], selected ? styles.selected : undefined), ...stationAttrsOf(props, family, shape), children: [_jsx(BODY, { node: node, family: family, subtitle: subtitleOf(family, props.status), height: height, isUnreachable: isUnreachable }), _jsx(NodeBadges, { badges: badgesOf(model), rightEdge: node.x + node.width / 2, top: node.y - height / 2 }), _jsx(NodePorts, { ports: node.ports, toneByEdge: props.toneByEdge })] }));
22
+ }
23
+ function stationAttrsOf(props, family, shape) {
24
+ const { node, model, isTerminal, selected = false, isUnreachable } = props;
25
+ return {
26
+ "data-node": node.id,
27
+ "data-family": family,
28
+ "data-shape": shape,
29
+ "data-selected": selected || undefined,
30
+ "data-unreachable": isUnreachable || undefined,
31
+ "data-off-path": props.offPath || undefined,
32
+ ...runAttrsOf(props),
33
+ ...changeAttrOf(props),
34
+ style: props.offset && { transform: `translate(${props.offset.dx}px, ${props.offset.dy}px)`, transition: "none" },
35
+ ...neighbourhoodAttrs(node.id, props),
36
+ "aria-label": nodeAriaLabel({ node: model, isTerminal, isUnreachable }),
37
+ "aria-describedby": props.describedBy,
38
+ ...interactionAttrs({
39
+ nodeId: node.id,
40
+ onSelect: props.onSelect,
41
+ selected,
42
+ keyboard: props.keyboard,
43
+ }),
44
+ };
45
+ }
46
+ function runAttrsOf({ visited, outcome, status, }) {
47
+ return {
48
+ "data-open": status?.open || undefined,
49
+ "data-visited": visited === false ? "false" : undefined,
50
+ "data-outcome": outcome,
51
+ };
52
+ }
53
+ function changeAttrOf({ added, moved, removed }) {
54
+ if (removed)
55
+ return { "data-change": "removed", "aria-hidden": true };
56
+ return { "data-change": (added && "added") || (moved && "moved") || undefined, "aria-hidden": undefined };
57
+ }
58
+ function shapeOf(family, { isStop }) {
59
+ if (family === "marker") {
60
+ return "terminal";
61
+ }
62
+ return isStop ? "stop" : "card";
63
+ }
64
+ function CardBody({ node, family, subtitle, height, isUnreachable, }) {
65
+ const box = boxOf(node, height);
66
+ const { top, leftEdge } = box;
67
+ return (_jsxs(_Fragment, { children: [_jsx(NodeBox, { ...box, height: height, isUnreachable: isUnreachable }), _jsx(TypeGlyph, { family: family, cx: leftEdge + GLYPH_INSET, cy: top + GLYPH_INSET }), _jsx(NodeTitle, { title: nodeTitle(node.id), subtitle: subtitle, isUnreachable: isUnreachable, centerX: node.x, centerY: node.y })] }));
68
+ }
69
+ function TerminalBody({ node }) {
70
+ return (_jsxs(_Fragment, { children: [_jsx("circle", { className: styles.terminalRing, cx: node.x, cy: node.y, r: 11 }), _jsx("circle", { className: styles.terminalCore, cx: node.x, cy: node.y, r: 5 }), _jsx("text", { className: styles.nodeId, x: node.x, y: node.y + 24, textAnchor: "middle", children: nodeTitle(node.id) })] }));
71
+ }
72
+ // The stop's circle centre from the box's top, and the title's drop below it.
73
+ const STOP_RADIUS = 12;
74
+ const STOP_CENTRE_DROP = 14;
75
+ const STOP_TITLE_DROP = 26;
76
+ function StopBody({ node, family, height }) {
77
+ const cy = node.y - height / 2 + STOP_CENTRE_DROP;
78
+ return (_jsxs(_Fragment, { children: [_jsx("circle", { className: styles.stopCircle, cx: node.x, cy: cy, r: STOP_RADIUS }), _jsx(TypeGlyph, { family: family, cx: node.x, cy: cy }), _jsx("text", { className: styles.stopTitle, x: node.x, y: cy + STOP_TITLE_DROP, textAnchor: "middle", children: nodeTitle(node.id) })] }));
79
+ }
80
+ const BODY_BY_SHAPE = {
81
+ card: CardBody,
82
+ terminal: TerminalBody,
83
+ stop: StopBody,
84
+ };
85
+ function NodePorts({ ports, toneByEdge = NO_TONES, }) {
86
+ return ports.map((port) => {
87
+ const tone = port.side === "in" ? "in" : (toneByEdge.get(port.edge) ?? "neutral");
88
+ return (_jsx("circle", { "data-port": `${port.edge}:${port.side}`, "data-tone": tone, className: portFillClass(tone), cx: port.x, cy: port.y, r: 4 }, `${port.edge}:${port.side}`));
89
+ });
90
+ }
91
+ /** The box's top-left, from the layout's CENTRE point. The layout places node centres so edges can aim at them; SVG rects are drawn from a corner. */
92
+ function boxOf(node, height) {
93
+ return {
94
+ top: node.y - height / 2,
95
+ leftEdge: node.x - node.width / 2,
96
+ width: node.width,
97
+ };
98
+ }
99
+ /** Marks the node dimmed, and reports pointer and focus entering and leaving it so the graph can light its neighbourhood. */
100
+ function neighbourhoodAttrs(nodeId, { dimmed, onHover, keyboard }) {
101
+ return {
102
+ "data-dim": dimmed || undefined,
103
+ onPointerEnter: () => onHover?.(nodeId),
104
+ onPointerLeave: () => onHover?.(null),
105
+ onFocus: () => {
106
+ onHover?.(nodeId);
107
+ keyboard?.onFocusNode(nodeId);
108
+ },
109
+ onBlur: () => onHover?.(null),
110
+ };
111
+ }
112
+ /** How the group answers a click or a key, and whether it is the pressed one; a node with no handler claims neither. */
113
+ function interactionAttrs({ nodeId, onSelect, selected, keyboard, }) {
114
+ if (!onSelect) {
115
+ return { role: "group" };
116
+ }
117
+ return {
118
+ role: "button",
119
+ "aria-pressed": selected,
120
+ tabIndex: 0,
121
+ onClick: () => onSelect(nodeId),
122
+ onKeyDown: (event) => {
123
+ keyboard?.onKeyDown(event);
124
+ selectOnActivationKey(nodeId, onSelect)(event);
125
+ },
126
+ };
127
+ }
128
+ // Enter and Space activate a node exactly as they activate a button; nothing else does.
129
+ function selectOnActivationKey(nodeId, onSelect) {
130
+ return (event) => {
131
+ if (event.key !== "Enter" && event.key !== " ") {
132
+ return;
133
+ }
134
+ event.preventDefault();
135
+ onSelect(nodeId);
136
+ };
137
+ }
138
+ //# sourceMappingURL=GraphNode.js.map
@@ -0,0 +1,50 @@
1
+ import type { Drawing } from "./run-graph-drawing";
2
+ import type { MainPath } from "./metro/main-path";
3
+ import type { StationVisits } from "./metro/station-visits";
4
+ import type { NodeOffset } from "./metro/layout-diff";
5
+ import type { Neighbourhood } from "./metro/neighbourhood";
6
+ import type { KeyboardCursor } from "./use-keyboard-cursor";
7
+ import type { RemovedStation } from "./metro/removed-stations";
8
+ export interface DescribedNode {
9
+ nodeId: string;
10
+ tooltipId: string;
11
+ }
12
+ /** What marks an element of the drawing apart from the rest. */
13
+ export interface LineMarks {
14
+ /** What the hovered node touches; everything else dims. Null while nothing is hovered. */
15
+ lit: Neighbourhood | null;
16
+ /** The main line, when only it is drawn in full. */
17
+ mainPath: MainPath | null;
18
+ /** Stations no start leads to. */
19
+ unreachable: ReadonlySet<string>;
20
+ keyboard: KeyboardCursor;
21
+ /** Keys the latest layout added. */
22
+ added: ReadonlySet<string>;
23
+ /** Keys the latest layout moved. */
24
+ moved: ReadonlySet<string>;
25
+ /** Where each node was, relative to where the latest layout put it. */
26
+ offsets: ReadonlyMap<string, NodeOffset>;
27
+ /** Stations the latest layout dropped, drawn fading out where they stood. */
28
+ removed: readonly RemovedStation[];
29
+ /** The lines the run took (undefined without a run). */
30
+ taken: ReadonlyMap<string, number> | undefined;
31
+ /** The one connector a station run took, marked when there is no run overlay. */
32
+ takenEdgeKey: string | undefined;
33
+ /** What the run did at each station (undefined without a run). */
34
+ visits: ReadonlyMap<string, StationVisits> | undefined;
35
+ }
36
+ export interface GraphSvgProps {
37
+ laid: Drawing;
38
+ name: string;
39
+ exit: string;
40
+ /** The node whose tooltip is up, which points at it through aria-describedby. */
41
+ describedNode: DescribedNode | null;
42
+ onSelectNode: ((nodeId: string) => void) | undefined;
43
+ onSelectLine: ((key: string) => void) | undefined;
44
+ selectedLineKey: string | null | undefined;
45
+ selectedNodeId: string | null | undefined;
46
+ onHover: (nodeId: string | null) => void;
47
+ marks: LineMarks;
48
+ }
49
+ /** The graph itself. A node nothing leaves is terminal, which the plain label renders differently. `role="img"` with a `<title>`: the drawing is one picture to a screen reader, the nodes inside it focusable buttons. */
50
+ export default function GraphSvg(props: GraphSvgProps): import("react").JSX.Element;