@signalsafe/tree-spec-editor-react 0.1.1 → 0.1.3
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 +21 -0
- package/README.md +125 -28
- package/README.standalone.md +14 -0
- package/dist/GraphEditorCanvasContext.d.ts +26 -0
- package/dist/GraphEditorCanvasContext.d.ts.map +1 -0
- package/dist/GraphEditorCanvasContext.js +20 -0
- package/dist/TreeSpecGraphEditor.d.ts +22 -1
- package/dist/TreeSpecGraphEditor.d.ts.map +1 -1
- package/dist/TreeSpecGraphEditor.js +133 -260
- package/dist/canvas/constants.d.ts +41 -0
- package/dist/canvas/constants.d.ts.map +1 -0
- package/dist/canvas/constants.js +40 -0
- package/dist/canvas/edgeBuilders.d.ts +6 -0
- package/dist/canvas/edgeBuilders.d.ts.map +1 -0
- package/dist/canvas/edgeBuilders.js +57 -0
- package/dist/canvas/edgeStyle.d.ts +16 -0
- package/dist/canvas/edgeStyle.d.ts.map +1 -0
- package/dist/canvas/edgeStyle.js +44 -0
- package/dist/canvas/focusChoice.d.ts +3 -0
- package/dist/canvas/focusChoice.d.ts.map +1 -0
- package/dist/canvas/focusChoice.js +12 -0
- package/dist/canvas/typeGuards.d.ts +3 -0
- package/dist/canvas/typeGuards.d.ts.map +1 -0
- package/dist/canvas/typeGuards.js +16 -0
- package/dist/contextMenu/GraphCanvasContextMenu.d.ts +10 -0
- package/dist/contextMenu/GraphCanvasContextMenu.d.ts.map +1 -0
- package/dist/contextMenu/GraphCanvasContextMenu.js +39 -0
- package/dist/contextMenu/types.d.ts +11 -0
- package/dist/contextMenu/types.d.ts.map +1 -0
- package/dist/contextMenu/types.js +1 -0
- package/dist/hooks/keyboardShortcutDispatch.d.ts +30 -0
- package/dist/hooks/keyboardShortcutDispatch.d.ts.map +1 -0
- package/dist/hooks/keyboardShortcutDispatch.js +88 -0
- package/dist/hooks/types.d.ts +32 -2
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/hooks/useCanvasContextMenu.d.ts +15 -0
- package/dist/hooks/useCanvasContextMenu.d.ts.map +1 -0
- package/dist/hooks/useCanvasContextMenu.js +50 -0
- package/dist/hooks/useCanvasGraphState.d.ts +29 -0
- package/dist/hooks/useCanvasGraphState.d.ts.map +1 -0
- package/dist/hooks/useCanvasGraphState.js +150 -0
- package/dist/hooks/useCanvasIssueIndex.d.ts +12 -0
- package/dist/hooks/useCanvasIssueIndex.d.ts.map +1 -0
- package/dist/hooks/useCanvasIssueIndex.js +32 -0
- package/dist/hooks/useCanvasNodeResize.d.ts +17 -0
- package/dist/hooks/useCanvasNodeResize.d.ts.map +1 -0
- package/dist/hooks/useCanvasNodeResize.js +53 -0
- package/dist/hooks/useCanvasViewport.d.ts +12 -0
- package/dist/hooks/useCanvasViewport.d.ts.map +1 -0
- package/dist/hooks/useCanvasViewport.js +84 -0
- package/dist/hooks/useChoiceDragDrop.d.ts +25 -0
- package/dist/hooks/useChoiceDragDrop.d.ts.map +1 -0
- package/dist/hooks/useChoiceDragDrop.js +40 -0
- package/dist/hooks/useEditorAdapter.d.ts +46 -0
- package/dist/hooks/useEditorAdapter.d.ts.map +1 -0
- package/dist/hooks/useEditorAdapter.js +281 -0
- package/dist/hooks/useEditorAutosave.d.ts +18 -0
- package/dist/hooks/useEditorAutosave.d.ts.map +1 -0
- package/dist/hooks/useEditorAutosave.js +37 -0
- package/dist/hooks/useEditorHistory.d.ts +16 -0
- package/dist/hooks/useEditorHistory.d.ts.map +1 -0
- package/dist/hooks/useEditorHistory.js +103 -0
- package/dist/hooks/useEditorSelection.d.ts +22 -0
- package/dist/hooks/useEditorSelection.d.ts.map +1 -0
- package/dist/hooks/useEditorSelection.js +75 -0
- package/dist/hooks/useGraphConnect.d.ts +22 -0
- package/dist/hooks/useGraphConnect.d.ts.map +1 -0
- package/dist/hooks/useGraphConnect.js +75 -0
- package/dist/hooks/useTreeSpecEditor.d.ts +1 -9
- package/dist/hooks/useTreeSpecEditor.d.ts.map +1 -1
- package/dist/hooks/useTreeSpecEditor.js +231 -462
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/nodes/ChoiceCanvasRow.d.ts +10 -0
- package/dist/nodes/ChoiceCanvasRow.d.ts.map +1 -0
- package/dist/nodes/ChoiceCanvasRow.js +55 -0
- package/dist/nodes/EndNode.d.ts +3 -0
- package/dist/nodes/EndNode.d.ts.map +1 -0
- package/dist/nodes/EndNode.js +7 -0
- package/dist/nodes/PromptNode.d.ts +6 -0
- package/dist/nodes/PromptNode.d.ts.map +1 -0
- package/dist/nodes/PromptNode.js +51 -0
- package/dist/nodes/PromptNodeChoicesList.d.ts +14 -0
- package/dist/nodes/PromptNodeChoicesList.d.ts.map +1 -0
- package/dist/nodes/PromptNodeChoicesList.js +24 -0
- package/dist/nodes/PromptNodeHeader.d.ts +10 -0
- package/dist/nodes/PromptNodeHeader.d.ts.map +1 -0
- package/dist/nodes/PromptNodeHeader.js +6 -0
- package/dist/nodes/PromptNodeIssueBadges.d.ts +7 -0
- package/dist/nodes/PromptNodeIssueBadges.d.ts.map +1 -0
- package/dist/nodes/PromptNodeIssueBadges.js +6 -0
- package/dist/nodes/PromptNodeToolbar.d.ts +6 -0
- package/dist/nodes/PromptNodeToolbar.d.ts.map +1 -0
- package/dist/nodes/PromptNodeToolbar.js +5 -0
- package/dist/nodes/types.d.ts +13 -0
- package/dist/nodes/types.d.ts.map +1 -0
- package/dist/nodes/types.js +1 -0
- package/dist/utils/joinClasses.d.ts +2 -0
- package/dist/utils/joinClasses.d.ts.map +1 -0
- package/dist/utils/joinClasses.js +3 -0
- package/package.json +36 -13
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SignalSafe Software
|
|
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
CHANGED
|
@@ -1,43 +1,140 @@
|
|
|
1
1
|
# @signalsafe/tree-spec-editor-react
|
|
2
2
|
|
|
3
|
-
Headless React layer for the SignalSafe TreeSpec graph editor
|
|
4
|
-
React Flow canvas, owns React state plumbing, and exposes the editor as a
|
|
5
|
-
single React component — without depending on any specific UI library.
|
|
3
|
+
Headless **React + React Flow** layer for the SignalSafe TreeSpec graph editor: canvas component, orchestration hook, and wiring to `@signalsafe/tree-spec-editor-core`.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
| | |
|
|
6
|
+
|---|---|
|
|
7
|
+
| **npm** | `@signalsafe/tree-spec-editor-react` |
|
|
8
|
+
| **GitHub** | [SignalSafeSoftware/tree-spec-editor-react](https://github.com/SignalSafeSoftware/tree-spec-editor-react) |
|
|
9
|
+
| **Peer deps** | `react`, `react-dom`, `reactflow` (^18 / ^11) |
|
|
8
10
|
|
|
9
|
-
## What this package
|
|
11
|
+
## What this package does
|
|
10
12
|
|
|
11
|
-
- **`TreeSpecGraphEditor`**
|
|
12
|
-
- **`
|
|
13
|
-
-
|
|
14
|
-
`useGraphSelection`) that wrap the framework-agnostic helpers from
|
|
15
|
-
`tree-spec-editor-core`.
|
|
13
|
+
- Renders **`TreeSpecGraphEditor`** (React Flow canvas, custom nodes/edges, selection).
|
|
14
|
+
- Exposes **`useTreeSpecEditor`** for load/validate/autosave/publish orchestration (host injects adapter callbacks).
|
|
15
|
+
- Re-exports core editor types used by the hook.
|
|
16
16
|
|
|
17
|
-
## What
|
|
17
|
+
## What this package does not do
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
| Sidebar panels, inspector, modals, toolbar (Bootstrap-styled) | `@signalsafe/tree-spec-editor` |
|
|
23
|
-
| Material-styled UI shells (planned) | `@signalsafe/tree-spec-editor-react-mui` |
|
|
24
|
-
| Angular implementation (planned) | `@signalsafe/tree-spec-editor-angular` |
|
|
19
|
+
- Sidebar panels, modals, toolbars, or Bootstrap chrome — use `@signalsafe/tree-spec-editor` or your own UI shell.
|
|
20
|
+
- Routing, HTTP, authentication, or persistence — host app provides adapter implementations.
|
|
21
|
+
- Wire compile/publish to a backend without your adapter code.
|
|
25
22
|
|
|
26
23
|
## Install
|
|
27
24
|
|
|
28
25
|
```bash
|
|
29
|
-
npm install @signalsafe/tree-spec-editor-react react react-dom reactflow
|
|
26
|
+
npm install @signalsafe/tree-spec-editor-react @signalsafe/tree-spec-editor-core @signalsafe/tree-spec react react-dom reactflow
|
|
30
27
|
```
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
e.g. `import 'reactflow/dist/style.css';`) in the consuming app. The
|
|
34
|
-
package itself imports the CSS file from its source, so bundlers that
|
|
35
|
-
resolve module references will pick it up automatically.
|
|
29
|
+
### React Flow CSS (required)
|
|
36
30
|
|
|
37
|
-
|
|
31
|
+
This package imports `reactflow/dist/style.css` from source. Bundlers treat it as a side effect (`sideEffects: ["**/*.css"]` in `package.json`).
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
Ensure your app loads React Flow styles, for example:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import "reactflow/dist/style.css";
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
If you use `@signalsafe/tree-spec-editor` (Bootstrap shell), the canvas still comes from this package — consumers may need the CSS import in the app entry when tree-shaking.
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { useState } from "react";
|
|
45
|
+
import TreeSpecGraphEditor from "@signalsafe/tree-spec-editor-react";
|
|
46
|
+
import {
|
|
47
|
+
END_NODE_ID,
|
|
48
|
+
type EditorTree,
|
|
49
|
+
} from "@signalsafe/tree-spec-editor-core";
|
|
50
|
+
|
|
51
|
+
const initialTree: EditorTree = {
|
|
52
|
+
start_node: "start",
|
|
53
|
+
nodes: {
|
|
54
|
+
start: {
|
|
55
|
+
id: "start",
|
|
56
|
+
type: "prompt",
|
|
57
|
+
prompt: "Example prompt",
|
|
58
|
+
choices: [{ id: "done", label: "Finish" }],
|
|
59
|
+
position: { x: 40, y: 120 },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
transitions: [
|
|
63
|
+
{
|
|
64
|
+
id: "t1",
|
|
65
|
+
fromNodeId: "start",
|
|
66
|
+
fromChoiceId: "done",
|
|
67
|
+
toNodeId: END_NODE_ID,
|
|
68
|
+
outcome: "safe",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export function ExampleCanvas() {
|
|
74
|
+
const [tree, setTree] = useState(initialTree);
|
|
75
|
+
return (
|
|
76
|
+
<TreeSpecGraphEditor
|
|
77
|
+
tree={tree}
|
|
78
|
+
onChange={setTree}
|
|
79
|
+
className="h-[60vh] border rounded"
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
For full authoring flows (load/save/validate), compose **`useTreeSpecEditor`** with your adapter — see tests and `@signalsafe/tree-spec-editor` for a reference shell.
|
|
86
|
+
|
|
87
|
+
## Public exports
|
|
88
|
+
|
|
89
|
+
| Export | Purpose |
|
|
90
|
+
|---|---|
|
|
91
|
+
| `default` / `TreeSpecGraphEditor` | React Flow canvas |
|
|
92
|
+
| `TreeSpecGraphEditorProps` | Canvas props |
|
|
93
|
+
| `useTreeSpecEditor` | Stateful editor orchestration |
|
|
94
|
+
| `TreeSpecEditorAdapter`, `UseTreeSpecEditorResult`, … | Adapter and hook types |
|
|
95
|
+
|
|
96
|
+
Import from `@signalsafe/tree-spec-editor-react` only (no subpath exports).
|
|
97
|
+
|
|
98
|
+
## Package boundaries
|
|
99
|
+
|
|
100
|
+
| Layer | Package |
|
|
101
|
+
|---|---|
|
|
102
|
+
| Wire | `@signalsafe/tree-spec` |
|
|
103
|
+
| Editor model | `@signalsafe/tree-spec-editor-core` |
|
|
104
|
+
| **React canvas (this package)** | `@signalsafe/tree-spec-editor-react` |
|
|
105
|
+
| Bootstrap shell | `@signalsafe/tree-spec-editor` |
|
|
106
|
+
|
|
107
|
+
## Canvas selection behavior
|
|
108
|
+
|
|
109
|
+
| Selection | Inspector context | Contextual zoom (default on) |
|
|
110
|
+
|---|---|---|
|
|
111
|
+
| Node | selected node | fits node in viewport |
|
|
112
|
+
| Edge | source node + focused choice | viewport unchanged |
|
|
113
|
+
| Choice | `focusChoiceId` set | fits parent node when selected |
|
|
114
|
+
|
|
115
|
+
Pass `contextualZoom={false}` to disable automatic viewport fitting.
|
|
116
|
+
|
|
117
|
+
## Development
|
|
118
|
+
|
|
119
|
+
`yarn build` uses `tsconfig.build.json` and resolves `@signalsafe/*` from `node_modules`. Ecosystem sibling `paths` in `tsconfig.json` apply to local typecheck/tests only.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
yarn install
|
|
123
|
+
yarn build
|
|
124
|
+
yarn test
|
|
125
|
+
yarn typecheck
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Security
|
|
129
|
+
|
|
130
|
+
See [SECURITY.md](./SECURITY.md). Host applications must authenticate users, authorize edits, and validate TreeSpec JSON server-side before publish.
|
|
131
|
+
|
|
132
|
+
## Changelog and releases
|
|
133
|
+
|
|
134
|
+
- [CHANGELOG.md](./CHANGELOG.md)
|
|
135
|
+
- [RELEASING.md](./RELEASING.md)
|
|
136
|
+
|
|
137
|
+
## Related packages
|
|
138
|
+
|
|
139
|
+
- [`@signalsafe/tree-spec-editor-core`](https://github.com/SignalSafeSoftware/tree-spec-editor-core) — framework-agnostic editor helpers.
|
|
140
|
+
- [`@signalsafe/tree-spec-editor`](https://github.com/SignalSafeSoftware/tree-spec-editor) — full Bootstrap UI shell.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Standalone export
|
|
2
|
+
|
|
3
|
+
This tree was generated by `scripts/export-standalone-npm-package.sh tree-spec-editor-react` from the DeliveryPlus monorepo.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
git init
|
|
7
|
+
git branch -M main
|
|
8
|
+
git add .
|
|
9
|
+
git commit -m "Sync tree-spec-editor-react from DeliveryPlus"
|
|
10
|
+
git remote add origin git@github.com:SignalSafeSoftware/tree-spec-editor-react.git
|
|
11
|
+
git push -u origin main
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
See `RELEASING.md` for npm publish steps.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type ChoiceDropTarget = {
|
|
2
|
+
nodeId: string;
|
|
3
|
+
index: number;
|
|
4
|
+
};
|
|
5
|
+
export type ChoiceDragState = {
|
|
6
|
+
sourceNodeId: string;
|
|
7
|
+
choiceId: string;
|
|
8
|
+
};
|
|
9
|
+
export type GraphEditorCanvasContextValue = {
|
|
10
|
+
readOnly: boolean;
|
|
11
|
+
onDuplicateNode: (nodeId: string) => void;
|
|
12
|
+
onDeleteNode: (nodeId: string) => void;
|
|
13
|
+
onResizeNode: (nodeId: string, width: number, height: number) => void;
|
|
14
|
+
/** Lock the node box height when a resize drag begins (prevents wrap reflow jumps). */
|
|
15
|
+
onResizeNodeStart: (nodeId: string, width: number, height: number) => void;
|
|
16
|
+
onSelectChoice: (nodeId: string, choiceId: string) => void;
|
|
17
|
+
choiceDrag: ChoiceDragState | null;
|
|
18
|
+
choiceDropTarget: ChoiceDropTarget | null;
|
|
19
|
+
onChoiceDragStart: (nodeId: string, choiceId: string) => void;
|
|
20
|
+
onChoiceDragEnd: () => void;
|
|
21
|
+
onChoiceDragOver: (nodeId: string, index: number) => void;
|
|
22
|
+
onChoiceDrop: (nodeId: string, index: number) => void;
|
|
23
|
+
};
|
|
24
|
+
export declare const GraphEditorCanvasContext: import("react").Context<GraphEditorCanvasContextValue>;
|
|
25
|
+
export declare function useGraphEditorCanvas(): GraphEditorCanvasContextValue;
|
|
26
|
+
//# sourceMappingURL=GraphEditorCanvasContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphEditorCanvasContext.d.ts","sourceRoot":"","sources":["../src/GraphEditorCanvasContext.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,uFAAuF;IACvF,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3E,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;IACnC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC1C,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9D,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzD,CAAC;AAmBF,eAAO,MAAM,wBAAwB,wDAA8B,CAAC;AAEpE,wBAAgB,oBAAoB,IAAI,6BAA6B,CAEpE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
const noop = () => undefined;
|
|
3
|
+
const defaultValue = {
|
|
4
|
+
readOnly: true,
|
|
5
|
+
onDuplicateNode: noop,
|
|
6
|
+
onDeleteNode: noop,
|
|
7
|
+
onResizeNode: noop,
|
|
8
|
+
onResizeNodeStart: noop,
|
|
9
|
+
onSelectChoice: noop,
|
|
10
|
+
choiceDrag: null,
|
|
11
|
+
choiceDropTarget: null,
|
|
12
|
+
onChoiceDragStart: noop,
|
|
13
|
+
onChoiceDragEnd: noop,
|
|
14
|
+
onChoiceDragOver: noop,
|
|
15
|
+
onChoiceDrop: noop,
|
|
16
|
+
};
|
|
17
|
+
export const GraphEditorCanvasContext = createContext(defaultValue);
|
|
18
|
+
export function useGraphEditorCanvas() {
|
|
19
|
+
return useContext(GraphEditorCanvasContext);
|
|
20
|
+
}
|
|
@@ -7,10 +7,31 @@ export type TreeSpecGraphEditorProps = {
|
|
|
7
7
|
showMiniMap?: boolean;
|
|
8
8
|
selected?: GraphSelection;
|
|
9
9
|
onSelect?: (sel: GraphSelection) => void;
|
|
10
|
+
/** Called when a choice row is clicked on the canvas (after `onSelect` for the parent node). */
|
|
11
|
+
onChoiceSelect?: (nodeId: string, choiceId: string) => void;
|
|
12
|
+
/** Called when a choice is dropped after drag (reorder or move to another node). */
|
|
13
|
+
onRepositionChoice?: (fromNodeId: string, choiceId: string, toNodeId: string, toIndex: number) => void;
|
|
10
14
|
focusNodeId?: string | null;
|
|
15
|
+
/** Focused choice on the currently selected node (canvas + inspector sync). */
|
|
16
|
+
focusChoiceId?: string | null;
|
|
11
17
|
fitViewNonce?: number;
|
|
12
18
|
/** Optional class for the outer container (default includes h-70vh border rounded). */
|
|
13
19
|
className?: string;
|
|
20
|
+
/** When true, disables canvas editing affordances (toolbar, resize, context menu). */
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
/** Duplicate a prompt node from the canvas toolbar or context menu. */
|
|
23
|
+
onDuplicateNode?: (nodeId: string) => void;
|
|
24
|
+
/** Delete a prompt node from the canvas toolbar or context menu. */
|
|
25
|
+
onDeleteNode?: (nodeId: string) => void;
|
|
26
|
+
/** Run auto-layout from the pane context menu. */
|
|
27
|
+
onAutoLayout?: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* When true (default), zooms the viewport to fit the current node/edge selection.
|
|
30
|
+
* Skipped when `focusNodeId` already targets the same node.
|
|
31
|
+
*/
|
|
32
|
+
contextualZoom?: boolean;
|
|
33
|
+
/** Canvas chrome mode — host should pass Bootstrap `colorScheme` (`light` / `dark`). */
|
|
34
|
+
colorMode?: 'light' | 'dark';
|
|
14
35
|
};
|
|
15
|
-
export default function TreeSpecGraphEditor(props: Readonly<TreeSpecGraphEditorProps>): import("react
|
|
36
|
+
export default function TreeSpecGraphEditor(props: Readonly<TreeSpecGraphEditorProps>): import("react").JSX.Element;
|
|
16
37
|
//# sourceMappingURL=TreeSpecGraphEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeSpecGraphEditor.d.ts","sourceRoot":"","sources":["../src/TreeSpecGraphEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TreeSpecGraphEditor.d.ts","sourceRoot":"","sources":["../src/TreeSpecGraphEditor.tsx"],"names":[],"mappings":"AAYA,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAKH,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACxB,MAAM,mCAAmC,CAAC;AAsB3C,MAAM,MAAM,wBAAwB,GAAG;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACrC,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;IACzC,gGAAgG;IAChG,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5D,oFAAoF;IACpF,kBAAkB,CAAC,EAAE,CACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,KACd,IAAI,CAAC;IACV,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uEAAuE;IACvE,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,oEAAoE;IACpE,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wFAAwF;IACxF,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC,CAAC;AA4PF,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,wBAAwB,CAAC,+BAMpF"}
|