@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 +1 -1
- package/dist/GraphNode.js +6 -1
- package/dist/RunGraphView.d.ts +2 -0
- package/dist/RunGraphView.js +2 -2
- package/dist/assembly-line-definition.d.ts +1 -0
- package/dist/edge-limit-texts.d.ts +3 -0
- package/dist/edge-limit-texts.js +7 -0
- package/dist/elk-graph.js +3 -2
- package/dist/graph-view-model.js +4 -2
- package/dist/metro/station-visits.d.ts +2 -0
- package/dist/metro/station-visits.js +8 -0
- package/dist/run-graph.module.css +9 -4
- package/dist/station-subtitle.js +1 -1
- package/dist/use-run-overlay.d.ts +1 -1
- package/dist/use-run-overlay.js +3 -3
- package/package.json +2 -2
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
|
|
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
|
-
|
|
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 };
|
package/dist/RunGraphView.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/RunGraphView.js
CHANGED
|
@@ -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. */
|
|
@@ -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(
|
|
124
|
-
const text =
|
|
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)),
|
package/dist/graph-view-model.js
CHANGED
|
@@ -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(
|
|
43
|
-
|
|
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:
|
|
183
|
+
animation: openMarch 0.8s linear infinite;
|
|
183
184
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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) {
|
package/dist/station-subtitle.js
CHANGED
|
@@ -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 ?
|
|
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;
|
package/dist/use-run-overlay.js
CHANGED
|
@@ -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.
|
|
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.
|
|
48
|
+
"@re-cinq/floor-contracts": "0.8.0",
|
|
49
49
|
"elkjs": "0.9.3"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|