@sanity/workflow-diagram 0.0.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.
@@ -0,0 +1,123 @@
1
+ import type { HistoryEntry } from "@sanity/workflow-engine";
2
+ import { JSX } from "react";
3
+ import type { Stage } from "@sanity/workflow-engine";
4
+ import type { Transition } from "@sanity/workflow-engine";
5
+ import type { WorkflowDefinition } from "@sanity/workflow-engine";
6
+ import type { WorkflowEvaluation } from "@sanity/workflow-engine";
7
+
8
+ export declare function flattenTransitions(
9
+ stages: readonly Stage[],
10
+ ): FlatTransition[];
11
+
12
+ /**
13
+ * A transition flattened with its source stage name. Definitions nest
14
+ * transitions per stage; the diagram wants a flat edge list keyed by `from`.
15
+ */
16
+ export declare interface FlatTransition extends Transition {
17
+ from: string;
18
+ }
19
+
20
+ /**
21
+ * Context widget around the current stage — NOT a trimmed graph explorer.
22
+ * Only the current stage's own transitions render: `next` shows where the
23
+ * run can go (incoming collapses to short stubs), `previous` shows where it
24
+ * came from (outgoing collapses to stubs), `both` shows both sides with no
25
+ * stubs. Neighbor stages never show their own edges.
26
+ */
27
+ export declare interface LocalView {
28
+ /** Which of the current stage's neighbors to render (default 'next'). */
29
+ show?: LocalViewShow | undefined;
30
+ /** Ultra compression: each side of the current stage collapses into ONE
31
+ * synthetic edge and an "N stages" vertex (click it to expand to the
32
+ * regular local view). Constant footprint whatever the workflow shape. */
33
+ groupEdges?: boolean | undefined;
34
+ }
35
+
36
+ export declare type LocalViewShow = "next" | "previous" | "both";
37
+
38
+ /**
39
+ * Stage diagram for a workflow definition: stages + transitions laid out
40
+ * left-to-right, current stage highlighted, visited path toned by history.
41
+ * Hovering anywhere along a transition line opens its detail tooltip (title,
42
+ * description; machine name, GROQ filter and effects only in devMode); a
43
+ * gated transition additionally carries a lock marker on the line.
44
+ */
45
+ export declare function WorkflowDiagram({
46
+ definition,
47
+ currentStage,
48
+ selectedStage,
49
+ onSelectStage,
50
+ history,
51
+ guardCount,
52
+ gatedTransitions,
53
+ local,
54
+ static: isStatic,
55
+ devMode,
56
+ explain,
57
+ evaluation,
58
+ height,
59
+ }: WorkflowDiagramProps): JSX.Element;
60
+
61
+ export declare interface WorkflowDiagramProps {
62
+ /** The whole definition, not just its stages: definition-level vocabulary
63
+ * (field titles, author predicates) feeds features like human-language
64
+ * explanations, so the contract asks for it up front. */
65
+ definition: WorkflowDefinition;
66
+ /** Highlight this stage as where the instance is now. */
67
+ currentStage?: string | undefined;
68
+ /** Controlled selection — mark this stage as inspected. */
69
+ selectedStage?: string | undefined;
70
+ /** Stage click (name) / pane click (undefined). Enables selection UX. */
71
+ onSelectStage?: ((stage: string | undefined) => void) | undefined;
72
+ /** Instance history; tones visited stages and traversed transitions. */
73
+ history?: readonly HistoryEntry[] | undefined;
74
+ /** Active mutation-guard count, shown as a lock on the current node. */
75
+ guardCount?: number | undefined;
76
+ /** Names of current-stage transitions that cannot fire yet — their
77
+ * markers show a lock ("can't proceed, criteria unmet"). */
78
+ gatedTransitions?: readonly string[] | undefined;
79
+ /** Context snippet around the current stage instead of the whole workflow:
80
+ * only the current stage's own transitions render ({@link LocalView.show}
81
+ * picks next / previous / both). The hidden side collapses into short
82
+ * ghost-anchored stubs whose tooltips name the hidden stage. Requires
83
+ * currentStage. */
84
+ local?: LocalView | undefined;
85
+ /** Frozen canvas: no pan/zoom, no zoom controls — shows its initial fit.
86
+ * Tooltips, hover highlight and selection stay live. */
87
+ static?: boolean | undefined;
88
+ /** Tooling mode: tooltips additionally show machine names, GROQ filters
89
+ * and effects. Never on for end users. */
90
+ devMode?: boolean | undefined;
91
+ /** Explain the workflow in human language: tooltips gain each gate's
92
+ * phrased requirements ("«Review decision» must be 'approve'") — derived
93
+ * from the definition alone, so it works without an instance. */
94
+ explain?: boolean | undefined;
95
+ /** A live evaluation upgrades the explanations where it speaks — the
96
+ * current stage's transitions and gates get real ✓/✗ verdicts from the
97
+ * insight the engine already computed; the rest of the chart stays on
98
+ * the static tier. Only read when {@link WorkflowDiagramProps.explain}
99
+ * is on: `explain` is the feature gate, `evaluation` is its data. */
100
+ evaluation?: WorkflowEvaluation | undefined;
101
+ /** Height CEILING: the canvas hugs the laid-out content (and centers in
102
+ * its parent) when the graph is smaller than this. */
103
+ height?: number | string | undefined;
104
+ }
105
+
106
+ /**
107
+ * The base `--ws-*` design tokens, mapped onto Sanity UI's card vars so the
108
+ * workflow tools (diagram, inspector, simulator) follow the ambient theme.
109
+ * Consumers retheme by overriding `--ws-*` on a wrapping element.
110
+ */
111
+ export declare const WS_CARD_TOKENS: {
112
+ "--ws-accent": string;
113
+ "--ws-accent-bg": string;
114
+ "--ws-panel": string;
115
+ "--ws-ink": string;
116
+ "--ws-ink-2": string;
117
+ "--ws-border": string;
118
+ "--ws-red": string;
119
+ "--ws-positive": string;
120
+ "--ws-font": string;
121
+ };
122
+
123
+ export {};
@@ -0,0 +1,123 @@
1
+ import type { HistoryEntry } from "@sanity/workflow-engine";
2
+ import { JSX } from "react";
3
+ import type { Stage } from "@sanity/workflow-engine";
4
+ import type { Transition } from "@sanity/workflow-engine";
5
+ import type { WorkflowDefinition } from "@sanity/workflow-engine";
6
+ import type { WorkflowEvaluation } from "@sanity/workflow-engine";
7
+
8
+ export declare function flattenTransitions(
9
+ stages: readonly Stage[],
10
+ ): FlatTransition[];
11
+
12
+ /**
13
+ * A transition flattened with its source stage name. Definitions nest
14
+ * transitions per stage; the diagram wants a flat edge list keyed by `from`.
15
+ */
16
+ export declare interface FlatTransition extends Transition {
17
+ from: string;
18
+ }
19
+
20
+ /**
21
+ * Context widget around the current stage — NOT a trimmed graph explorer.
22
+ * Only the current stage's own transitions render: `next` shows where the
23
+ * run can go (incoming collapses to short stubs), `previous` shows where it
24
+ * came from (outgoing collapses to stubs), `both` shows both sides with no
25
+ * stubs. Neighbor stages never show their own edges.
26
+ */
27
+ export declare interface LocalView {
28
+ /** Which of the current stage's neighbors to render (default 'next'). */
29
+ show?: LocalViewShow | undefined;
30
+ /** Ultra compression: each side of the current stage collapses into ONE
31
+ * synthetic edge and an "N stages" vertex (click it to expand to the
32
+ * regular local view). Constant footprint whatever the workflow shape. */
33
+ groupEdges?: boolean | undefined;
34
+ }
35
+
36
+ export declare type LocalViewShow = "next" | "previous" | "both";
37
+
38
+ /**
39
+ * Stage diagram for a workflow definition: stages + transitions laid out
40
+ * left-to-right, current stage highlighted, visited path toned by history.
41
+ * Hovering anywhere along a transition line opens its detail tooltip (title,
42
+ * description; machine name, GROQ filter and effects only in devMode); a
43
+ * gated transition additionally carries a lock marker on the line.
44
+ */
45
+ export declare function WorkflowDiagram({
46
+ definition,
47
+ currentStage,
48
+ selectedStage,
49
+ onSelectStage,
50
+ history,
51
+ guardCount,
52
+ gatedTransitions,
53
+ local,
54
+ static: isStatic,
55
+ devMode,
56
+ explain,
57
+ evaluation,
58
+ height,
59
+ }: WorkflowDiagramProps): JSX.Element;
60
+
61
+ export declare interface WorkflowDiagramProps {
62
+ /** The whole definition, not just its stages: definition-level vocabulary
63
+ * (field titles, author predicates) feeds features like human-language
64
+ * explanations, so the contract asks for it up front. */
65
+ definition: WorkflowDefinition;
66
+ /** Highlight this stage as where the instance is now. */
67
+ currentStage?: string | undefined;
68
+ /** Controlled selection — mark this stage as inspected. */
69
+ selectedStage?: string | undefined;
70
+ /** Stage click (name) / pane click (undefined). Enables selection UX. */
71
+ onSelectStage?: ((stage: string | undefined) => void) | undefined;
72
+ /** Instance history; tones visited stages and traversed transitions. */
73
+ history?: readonly HistoryEntry[] | undefined;
74
+ /** Active mutation-guard count, shown as a lock on the current node. */
75
+ guardCount?: number | undefined;
76
+ /** Names of current-stage transitions that cannot fire yet — their
77
+ * markers show a lock ("can't proceed, criteria unmet"). */
78
+ gatedTransitions?: readonly string[] | undefined;
79
+ /** Context snippet around the current stage instead of the whole workflow:
80
+ * only the current stage's own transitions render ({@link LocalView.show}
81
+ * picks next / previous / both). The hidden side collapses into short
82
+ * ghost-anchored stubs whose tooltips name the hidden stage. Requires
83
+ * currentStage. */
84
+ local?: LocalView | undefined;
85
+ /** Frozen canvas: no pan/zoom, no zoom controls — shows its initial fit.
86
+ * Tooltips, hover highlight and selection stay live. */
87
+ static?: boolean | undefined;
88
+ /** Tooling mode: tooltips additionally show machine names, GROQ filters
89
+ * and effects. Never on for end users. */
90
+ devMode?: boolean | undefined;
91
+ /** Explain the workflow in human language: tooltips gain each gate's
92
+ * phrased requirements ("«Review decision» must be 'approve'") — derived
93
+ * from the definition alone, so it works without an instance. */
94
+ explain?: boolean | undefined;
95
+ /** A live evaluation upgrades the explanations where it speaks — the
96
+ * current stage's transitions and gates get real ✓/✗ verdicts from the
97
+ * insight the engine already computed; the rest of the chart stays on
98
+ * the static tier. Only read when {@link WorkflowDiagramProps.explain}
99
+ * is on: `explain` is the feature gate, `evaluation` is its data. */
100
+ evaluation?: WorkflowEvaluation | undefined;
101
+ /** Height CEILING: the canvas hugs the laid-out content (and centers in
102
+ * its parent) when the graph is smaller than this. */
103
+ height?: number | string | undefined;
104
+ }
105
+
106
+ /**
107
+ * The base `--ws-*` design tokens, mapped onto Sanity UI's card vars so the
108
+ * workflow tools (diagram, inspector, simulator) follow the ambient theme.
109
+ * Consumers retheme by overriding `--ws-*` on a wrapping element.
110
+ */
111
+ export declare const WS_CARD_TOKENS: {
112
+ "--ws-accent": string;
113
+ "--ws-accent-bg": string;
114
+ "--ws-panel": string;
115
+ "--ws-ink": string;
116
+ "--ws-ink-2": string;
117
+ "--ws-border": string;
118
+ "--ws-red": string;
119
+ "--ws-positive": string;
120
+ "--ws-font": string;
121
+ };
122
+
123
+ export {};