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 }) -})() +})