feat(state-machine): let blueprints define init, caption, and kinds

RememberMe is the first blueprint whose lifecycle is not the composed
LoadState: it starts at NotPersisted (not `loading`), has its own panel
caption, and its own transition kinds. Make the init node, the panel
caption/field, and the SmKind palette data-driven, with defaults that
leave List/Grid/Calendar unchanged.
This commit is contained in:
Julien Calixte
2026-07-02 23:18:14 +02:00
parent 9c8ba9a752
commit f6b184406d
3 changed files with 53 additions and 6 deletions

View File

@@ -58,7 +58,20 @@ export interface SmNode {
label: string
}
export type SmKind = "succeed" | "fail" | "refresh" | "loadMore" | "navigate" | "changeScope"
export type SmKind =
| "succeed"
| "fail"
| "refresh"
| "loadMore"
| "navigate"
| "changeScope"
// RememberMe persistence lifecycle
| "persist"
| "store"
| "storeFail"
| "revoke"
| "expire"
| "clear"
export interface SmEdge {
from: string
@@ -71,6 +84,13 @@ export interface SmEdge {
export interface StateMachine {
nodes: SmNode[]
edges: SmEdge[]
// id of the initial state (the [*] arrow points here). Defaults to "loading"
// for the LoadState-based machines; RememberMe starts at "notpersisted".
initId?: string
// Panel caption + field label shown above the diagram. Default to the
// composed-LoadState wording; capabilities with their own lifecycle override.
caption?: string
field?: string
}
export const SM_COLORS: Record<SmKind | "init", string> = {
@@ -80,6 +100,13 @@ export const SM_COLORS: Record<SmKind | "init", string> = {
loadMore: "#8fd0ff",
navigate: "#b79cff",
changeScope: "#67d0c0",
// RememberMe: green mint / red store-fail / magenta revoke / amber expiry / purple reset
persist: "#8fd0ff",
store: "#7fdca0",
storeFail: "#ff8f8f",
revoke: "#ff5c8a",
expire: "#ffb84d",
clear: "#b79cff",
init: "#4f7099",
}