@re-cinq/floor-graph 0.6.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,7 +36,7 @@ Pass `run={{ visits }}` to overlay one assembly run. A `Visit` is `nodeId`, `ite
36
36
  - An edge the run did not take fades to 30% (`takenLinesOf`, lore's first-match rule).
37
37
  - An edge taken more than once shows ×N beside its label, and the layout reserves room for it.
38
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.
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's dashes march round it. `waiting={{ id: label }}` makes an open visit there read as that label, with a solid border.
40
40
 
41
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
42
 
package/dist/GraphNode.js CHANGED
@@ -45,11 +45,16 @@ function stationAttrsOf(props, family, shape) {
45
45
  }
46
46
  function runAttrsOf({ visited, outcome, status, }) {
47
47
  return {
48
- "data-open": status?.open || undefined,
48
+ ...openAttrsOf(status),
49
49
  "data-visited": visited === false ? "false" : undefined,
50
50
  "data-outcome": outcome,
51
51
  };
52
52
  }
53
+ function openAttrsOf(status) {
54
+ return status?.waiting
55
+ ? { "data-waiting": "true" }
56
+ : { "data-open": status?.open || undefined };
57
+ }
53
58
  function changeAttrOf({ added, moved, removed }) {
54
59
  if (removed)
55
60
  return { "data-change": "removed", "aria-hidden": true };
@@ -21,6 +21,8 @@ export interface RunGraphViewProps {
21
21
  on: string;
22
22
  };
23
23
  run?: RunOverlay;
24
+ /** Stations that wait on someone, by id, and what they wait on: an open visit there reads as waiting, not working. */
25
+ waiting?: Readonly<Record<string, string>>;
24
26
  /** Draws the whole line or only the part the run walked; defaults to the walked part when a run is given. */
25
27
  show?: "all" | "visited";
26
28
  }
@@ -88,7 +88,7 @@ function useGraphCanvasState(view, graph) {
88
88
  };
89
89
  }
90
90
  /** The stations no start leads to, the lines a run took, and the main line of the definition while `mainPathOnly` is set (else null). */
91
- function useLineMarkings({ definition, run, mainPathOnly: initialMainPathOnly, }) {
91
+ function useLineMarkings({ definition, run, waiting, mainPathOnly: initialMainPathOnly, }) {
92
92
  const [mainPathOnly, toggleMainPath] = useToggle({
93
93
  initiallyOn: initialMainPathOnly,
94
94
  });
@@ -100,7 +100,7 @@ function useLineMarkings({ definition, run, mainPathOnly: initialMainPathOnly, }
100
100
  mainPathOnly,
101
101
  toggleMainPath,
102
102
  taken: useTakenLines(definition, run),
103
- visits: useStationVisits(run),
103
+ visits: useStationVisits(run, waiting),
104
104
  };
105
105
  }
106
106
  /** The layout, asked to compact its stops when `compactStops` is set, and the stations drawn as stops: the pass-through ones. */
@@ -21,6 +21,7 @@ export interface DefinitionEdge {
21
21
  /** The outcome that takes this edge. */
22
22
  on: string;
23
23
  iterationMax?: number;
24
+ unattendedMax?: number;
24
25
  }
25
26
  export interface AssemblyLineDefinition {
26
27
  name: string;
@@ -0,0 +1,3 @@
1
+ import type { DefinitionEdge } from "./assembly-line-definition";
2
+ /** `max I` for iterationMax, then `max U unattended` for unattendedMax; each only when set. */
3
+ export declare function limitTextsOf({ iterationMax, unattendedMax }: DefinitionEdge): string[];
@@ -0,0 +1,7 @@
1
+ /** `max I` for iterationMax, then `max U unattended` for unattendedMax; each only when set. */
2
+ export function limitTextsOf({ iterationMax, unattendedMax }) {
3
+ const iterationText = iterationMax === undefined ? [] : [`max ${iterationMax}`];
4
+ const unattendedText = unattendedMax === undefined ? [] : [`max ${unattendedMax} unattended`];
5
+ return [...iterationText, ...unattendedText];
6
+ }
7
+ //# sourceMappingURL=edge-limit-texts.js.map
package/dist/elk-graph.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { limitTextsOf } from "./edge-limit-texts";
1
2
  import { declaredIdsOf } from "./metro/declared-ids";
2
3
  import { edgeKeyOf } from "./metro/edge-key";
3
4
  import { mainPathOf } from "./metro/main-path";
@@ -120,8 +121,8 @@ function portOf(edge, direction, side) {
120
121
  layoutOptions: { "elk.port.side": side },
121
122
  };
122
123
  }
123
- function edgeLabelOf({ on, iterationMax }, takenCount = 0) {
124
- const text = iterationMax === undefined ? on : `${on} · max ${iterationMax}`;
124
+ function edgeLabelOf(edge, takenCount = 0) {
125
+ const text = [edge.on, ...limitTextsOf(edge)].join(" · ");
125
126
  return {
126
127
  text,
127
128
  width: Math.ceil(text.length * LABEL_CHAR_WIDTH + LABEL_PADDING + countWidthOf(takenCount)),
@@ -1,4 +1,5 @@
1
1
  // Map a definition to drawable nodes and connectors.
2
+ import { limitTextsOf } from "./edge-limit-texts";
2
3
  /** The nodes and connectors to draw: one connector per outcome. */
3
4
  export function deriveVisibleGraph(definition) {
4
5
  if (!definition) {
@@ -39,8 +40,9 @@ function connectorsFor(from, outgoing) {
39
40
  branching,
40
41
  }));
41
42
  }
42
- function hopLabel({ on, iterationMax }) {
43
- return iterationMax === undefined ? on : `${on} (max ${iterationMax})`;
43
+ function hopLabel(edge) {
44
+ const limits = limitTextsOf(edge);
45
+ return limits.length === 0 ? edge.on : `${edge.on} (${limits.join(", ")})`;
44
46
  }
45
47
  /** Outcome (or edge condition) to a connector/badge tone. */
46
48
  export function outcomeTone(outcome) {
@@ -3,5 +3,7 @@ export interface StationVisits {
3
3
  count: number;
4
4
  outcome?: string;
5
5
  open: boolean;
6
+ waiting?: string;
6
7
  }
7
8
  export declare function stationVisitsOf(visits: readonly Visit[]): ReadonlyMap<string, StationVisits>;
9
+ export declare function withWaiting(stations: ReadonlyMap<string, StationVisits>, waiting?: Readonly<Record<string, string>>): ReadonlyMap<string, StationVisits>;
@@ -10,4 +10,12 @@ function afterVisit(before, visit) {
10
10
  open: visit.open,
11
11
  };
12
12
  }
13
+ export function withWaiting(stations, waiting = {}) {
14
+ return new Map([...stations].map(([nodeId, status]) => [
15
+ nodeId,
16
+ status.open && nodeId in waiting
17
+ ? { ...status, waiting: waiting[nodeId] }
18
+ : status,
19
+ ]));
20
+ }
13
21
  //# sourceMappingURL=station-visits.js.map
@@ -177,13 +177,18 @@
177
177
  stroke-width: 4;
178
178
  filter: brightness(0.8) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.12));
179
179
  }
180
+ /* An open visit: the dashes march round the border. One period of the 6 4 dash is 10, so the loop has no seam. */
180
181
  .node[data-open="true"] .box {
181
182
  stroke-dasharray: 6 4;
182
- animation: openPulse 1.6s ease-in-out infinite;
183
+ animation: openMarch 0.8s linear infinite;
183
184
  }
184
- @keyframes openPulse {
185
- 50% {
186
- opacity: 0.55;
185
+ /* A station waiting on someone: a solid border, no march. */
186
+ .node[data-waiting="true"] .box {
187
+ stroke: var(--wait);
188
+ }
189
+ @keyframes openMarch {
190
+ to {
191
+ stroke-dashoffset: -10;
187
192
  }
188
193
  }
189
194
  @media (prefers-reduced-motion: reduce) {
@@ -1,6 +1,6 @@
1
1
  export function subtitleOf(kind, status) {
2
2
  const visitCount = status && status.count > 1 ? ` · ${status.count} visits` : "";
3
- const openMark = status?.open ? " · open" : "";
3
+ const openMark = status?.open ? ` · ${status.waiting ?? "open"}` : "";
4
4
  return `${kind}${visitCount}${openMark}`;
5
5
  }
6
6
  //# sourceMappingURL=station-subtitle.js.map
@@ -4,4 +4,4 @@ export interface RunOverlay {
4
4
  visits: readonly Visit[];
5
5
  }
6
6
  export declare function useTakenLines(definition: AssemblyLineDefinition, run: RunOverlay | undefined): ReadonlyMap<string, number> | undefined;
7
- export declare function useStationVisits(run: RunOverlay | undefined): ReadonlyMap<string, import("./metro/station-visits").StationVisits> | undefined;
7
+ export declare function useStationVisits(run: RunOverlay | undefined, waiting?: Readonly<Record<string, string>>): ReadonlyMap<string, import("./metro/station-visits").StationVisits> | undefined;
@@ -1,11 +1,11 @@
1
1
  // The lines an assembly run took, for the graph to mark; undefined while no run is shown.
2
2
  import { useMemo } from "react";
3
- import { stationVisitsOf } from "./metro/station-visits";
3
+ import { stationVisitsOf, withWaiting } from "./metro/station-visits";
4
4
  import { takenLinesOf } from "./metro/taken-lines";
5
5
  export function useTakenLines(definition, run) {
6
6
  return useMemo(() => run && takenLinesOf(definition, run.visits), [definition, run]);
7
7
  }
8
- export function useStationVisits(run) {
9
- return useMemo(() => run && stationVisitsOf(run.visits), [run]);
8
+ export function useStationVisits(run, waiting) {
9
+ return useMemo(() => run && withWaiting(stationVisitsOf(run.visits), waiting), [run, waiting]);
10
10
  }
11
11
  //# sourceMappingURL=use-run-overlay.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@re-cinq/floor-graph",
3
- "version": "0.6.2",
3
+ "version": "0.8.0",
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.2",
48
+ "@re-cinq/floor-contracts": "0.8.0",
49
49
  "elkjs": "0.9.3"
50
50
  },
51
51
  "peerDependencies": {