@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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sanity, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @sanity/workflow-diagram
2
+
3
+ React component rendering a `@sanity/workflow-engine` definition as a stage
4
+ diagram: stages laid out left-to-right by [ELK](https://eclipse.dev/elk/)'s
5
+ layered algorithm, rendered with [@xyflow/react](https://reactflow.dev).
6
+
7
+ - Every **stage** is the same label-sized capsule pill — run state lives in
8
+ the inline status icon, and position says what's first and last.
9
+ - **Transitions** are orthogonal rounded polylines; hovering anywhere along a
10
+ line opens a tooltip with the transition's title and description (plus
11
+ machine name, GROQ filter and effects when `devMode` is on — never for end
12
+ users). Only a gated transition carries a visible on-line marker (a lock
13
+ disc). No inline edge labels — the layout stays compressed.
14
+ - Pass `explain` to phrase the workflow in human language: transition
15
+ tooltips gain the filter's requirements as a checklist ("Transitions
16
+ when: • «Cancellation requested» must be true"), stage tooltips list the
17
+ stage's activity and editability gates. Derived from the definition
18
+ alone — no instance needed.
19
+ - Pass `currentStage` / `history` to tone the instance's position and the
20
+ visited path; `guardCount` shows a lock on the current stage.
21
+ - Pass `onSelectStage` (+ controlled `selectedStage`) to build inspection UX
22
+ around the diagram — clicking a stage reports its name, clicking the pane
23
+ reports `undefined`.
24
+
25
+ ```tsx
26
+ import {WorkflowDiagram} from '@sanity/workflow-diagram'
27
+ ;<WorkflowDiagram
28
+ definition={definition}
29
+ currentStage={instance?.currentStage}
30
+ history={instance?.history}
31
+ />
32
+ ```
33
+
34
+ The component follows the ambient Sanity UI theme (render inside a
35
+ `@sanity/ui` `ThemeProvider`); retheme by overriding the `--ws-*` CSS
36
+ variables on a wrapping element — `WS_CARD_TOKENS`, the exported base token
37
+ map (`--ws-*` → Sanity UI card vars), is the reference for what exists.
38
+ Key the component by instance id — layout fits the viewport once per mount
39
+ and preserves the user's zoom/pan afterwards.
40
+
41
+ The package entry imports `@xyflow/react`'s stylesheet as a side effect, so
42
+ it expects a CSS-capable bundler (Vite, Next.js, Studio, the App SDK all
43
+ qualify); importing it from plain Node without a CSS loader will fail on
44
+ that import.
45
+
46
+ `flattenTransitions` is also exported: the definition's nested per-stage
47
+ transitions as the flat `from`-keyed list the diagram renders — useful when
48
+ building transition UI beside the diagram.