From 8e7a903fe49c551ad8c5354fdf3f02a2e39bcf83 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Thu, 2 Jul 2026 18:55:34 +0200 Subject: [PATCH] refactor(state-machine): derive legend from the machine's edges MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add navigate/changeScope transition kinds and build the legend from the transitions a machine actually has, so each blueprint shows only its own kinds — needed for Calendar, whose lifecycle has no loadMore(). --- src/components/StateMachine.vue | 27 ++++++++++++++++++--------- src/data/blueprint.ts | 4 +++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/components/StateMachine.vue b/src/components/StateMachine.vue index e3d05d4..ffae0fd 100644 --- a/src/components/StateMachine.vue +++ b/src/components/StateMachine.vue @@ -71,20 +71,29 @@ const edges = computed(() => }), ) -const legendItems = (() => { - const items: [string, SmKind][] = [ - ["succeed()", "succeed"], - ["fail()", "fail"], - ["refresh()", "refresh"], - ["loadMore()", "loadMore"], - ] +// Legend is derived from the transitions the machine actually has, so each +// blueprint shows exactly its own transition kinds — no phantom loadMore() on +// Calendar, no missing navigate()/changeScope(). +const KIND_LABELS: Record = { + succeed: "succeed()", + fail: "fail()", + refresh: "refresh()", + loadMore: "loadMore()", + navigate: "navigate(δ)", + changeScope: "changeScope(s)", +} +const KIND_ORDER: SmKind[] = ["succeed", "fail", "refresh", "loadMore", "navigate", "changeScope"] + +const legendItems = computed(() => { + const present = new Set(props.machine.edges.map((e) => e.kind)) let lxp = 70 - return items.map(([t, k]) => { + return KIND_ORDER.filter((k) => present.has(k)).map((k) => { + const t = KIND_LABELS[k] const item = { t, color: SM_COLORS[k], x1: lxp, x2: lxp + 18, tx: lxp + 24, y: 8, ty: 12 } lxp += 24 + t.length * 6.6 + 26 return item }) -})() +})