@re-cinq/floor-graph 0.6.1 → 0.6.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @re-cinq/floor-graph
2
2
 
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.
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 it out with stations left to right, every edge on its own ports, routed at right angles around stations and labels. The package ships compiled JS and its CSS modules, so use it from a bundler such as Vite.
4
4
 
5
5
  ```
6
6
  npm install @re-cinq/floor-graph
@@ -12,8 +12,34 @@ import { RunGraphView, type AssemblyLineDefinition } from "@re-cinq/floor-graph"
12
12
  <RunGraphView definition={definition} />;
13
13
  ```
14
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`.
15
+ ## Controls
16
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.
17
+ The controls hold zoom, fit and two toggles. The `mainPathOnly` and `compactStops` props set where each toggle starts.
18
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.
19
+ - "Main path" fades every station and edge off the path from the entry along `success`, or along the first `always` when nothing succeeds.
20
+ - "Compact stops" draws a station with one edge in and one `always` edge out as a stop on the track, unless it is the entry or is started from outside.
21
+
22
+ ## Selection and keyboard
23
+
24
+ `onSelectLine(key)` and `selectedLineKey` select an edge by its `from|to|event` key (`edgeKeyOf`).
25
+
26
+ On a focused station, Down and Up choose one of its outgoing edges, which is drawn bold. Right moves to the station that edge leads to, Left goes back along an incoming edge, and Enter selects.
27
+
28
+ ## When the definition changes
29
+
30
+ New stations and edges flash for 1.2 s (`diffLayouts` against the last layout, and the first draw flashes nothing). Moved edges slide to their new route, and a station that moves slides to its new place over 400 ms. Motion is off under `prefers-reduced-motion`.
31
+
32
+ ## Overlaying an assembly run
33
+
34
+ Pass `run={{ visits }}` to overlay one assembly run. A `Visit` is `nodeId`, `iteration`, `outcome?` and `open`.
35
+
36
+ - An edge the run did not take fades to 30% (`takenLinesOf`, lore's first-match rule).
37
+ - An edge taken more than once shows ×N beside its label, and the layout reserves room for it.
38
+ - An unvisited station fades to 40%.
39
+ - A visited card's border takes the colour of its last closed outcome. Its subtitle counts visits above one (`agent · 2 visits`). While a visit is open the subtitle adds ` · open` and the border pulses.
40
+
41
+ With a run, `show` defaults to `"visited"`. ELK then lays out only the entry, the visited stations, the edges the run took and the stations they reach (`visitedPartOf`), so the graph stays small. A "Whole line" toggle brings in the rest, faded, and `show="all"` starts there. A station removed by an edit, or hidden by turning "Whole line" off, fades out over 300 ms.
42
+
43
+ ## Origin
44
+
45
+ The package 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.
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // Renders an assembly line — lays out the nodes/connectors from graph-view-model and hands drawing to its sibling files; every node also says its outcomes and badges as text, so meaning never rests on color alone.
3
- import { useMemo, useState } from "react";
3
+ import { useCallback, useMemo, useState } from "react";
4
4
  import { useToggle } from "./use-toggle";
5
5
  import { useElkLayout } from "./use-elk-layout";
6
6
  import { drawingOf } from "./run-graph-drawing";
@@ -34,11 +34,11 @@ export default function RunGraphView(givenProps) {
34
34
  }
35
35
  return (_jsxs("section", { className: styles.panel, "aria-label": `Graph of ${props.definition.name}`, children: [_jsx(GraphCanvas, { view: props, graph: graph }), _jsx(RunGraphLegend, { families: familiesOf(graph) })] }));
36
36
  }
37
- /** The whole definition or the part the run visited, and the toggle between them, offered only with a run. */
37
+ /** The whole definition or the part the run visited, and the toggle between them, offered only with a run. Until it is pressed, the default follows the props, so a run that arrives after the first draw still opens on its visited part. */
38
38
  function useWholeLine({ definition, run, show }) {
39
- const [wholeLineOn, toggleWholeLine] = useToggle({
40
- initiallyOn: (show ?? (run ? "visited" : "all")) === "all",
41
- });
39
+ const [pressedOn, setPressedOn] = useState(null);
40
+ const wholeLineOn = pressedOn ?? (show ?? (run ? "visited" : "all")) === "all";
41
+ const toggleWholeLine = useCallback(() => setPressedOn(!wholeLineOn), [wholeLineOn]);
42
42
  const shown = useMemo(() => run && !wholeLineOn ? visitedPartOf(definition, run.visits) : definition, [definition, run, wholeLineOn]);
43
43
  return useMemo(() => ({
44
44
  definition: shown,
@@ -1,5 +1,5 @@
1
1
  import type { AssemblyLineDefinition, DefinitionEdge } from "../assembly-line-definition";
2
- /** One station run, as `docs/entities/assembly-run.md` describes it. */
2
+ /** One station run, as `docs/assembly_run_storage.md`, "The rows", describes it. */
3
3
  export interface Visit {
4
4
  nodeId: string;
5
5
  iteration: number;
@@ -129,7 +129,7 @@
129
129
  [data-chosen="true"] .edge {
130
130
  stroke-width: 3.5;
131
131
  }
132
- text[data-selected="true"] {
132
+ .svg text[data-selected="true"] {
133
133
  font-weight: var(--fw-bold, 700);
134
134
  }
135
135
 
@@ -388,12 +388,12 @@ text[data-selected="true"] {
388
388
  fill: var(--text-muted);
389
389
  }
390
390
 
391
- [data-dim="true"] {
391
+ .svg [data-dim="true"] {
392
392
  opacity: 0.15;
393
393
  transition: opacity 150ms;
394
394
  }
395
395
 
396
- [data-off-path="true"] {
396
+ .svg [data-off-path="true"] {
397
397
  opacity: 0.25;
398
398
  transition: opacity 150ms;
399
399
  }
@@ -422,14 +422,14 @@ text[data-selected="true"] {
422
422
  opacity: 0;
423
423
  }
424
424
  }
425
- [data-change="added"] {
425
+ .svg [data-change="added"] {
426
426
  animation: changeFlash 1.2s ease-out;
427
427
  }
428
- [data-change="moved"] {
428
+ .svg [data-change="moved"] {
429
429
  transition: transform 400ms ease;
430
430
  }
431
431
 
432
- [data-change="removed"] {
432
+ .svg [data-change="removed"] {
433
433
  animation: changeFade 300ms ease-out forwards;
434
434
  pointer-events: none;
435
435
  }
@@ -437,11 +437,11 @@ text[data-selected="true"] {
437
437
  transition: d 400ms;
438
438
  }
439
439
  @media (prefers-reduced-motion: reduce) {
440
- [data-change="added"],
441
- [data-change="removed"] {
440
+ .svg [data-change="added"],
441
+ .svg [data-change="removed"] {
442
442
  animation: none;
443
443
  }
444
- [data-change="moved"] {
444
+ .svg [data-change="moved"] {
445
445
  transition: none;
446
446
  }
447
447
  .edge {
@@ -449,12 +449,12 @@ text[data-selected="true"] {
449
449
  }
450
450
  }
451
451
 
452
- [data-taken="false"] {
452
+ .svg [data-taken="false"] {
453
453
  opacity: 0.3;
454
454
  transition: opacity 150ms;
455
455
  }
456
456
 
457
- [data-visited="false"] {
457
+ .svg [data-visited="false"] {
458
458
  opacity: 0.4;
459
459
  transition: opacity 150ms;
460
460
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@re-cinq/floor-graph",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "A React view of an assembly line as a graph: the layout of its nodes and edges, the viewport that fits and pans it, and the node and edge drawing, with the stylesheets it needs.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -45,7 +45,7 @@
45
45
  "typecheck": "tsc --noEmit"
46
46
  },
47
47
  "dependencies": {
48
- "@re-cinq/floor-contracts": "0.6.1",
48
+ "@re-cinq/floor-contracts": "0.6.2",
49
49
  "elkjs": "0.9.3"
50
50
  },
51
51
  "peerDependencies": {