@signalsafe/tree-spec-editor 0.2.3 → 0.3.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.
Files changed (65) hide show
  1. package/README.md +74 -25
  2. package/dist/index.d.ts +8 -10
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +7 -10
  5. package/dist/lib/PanelHeaderCollapseCarets.d.ts.map +1 -1
  6. package/dist/lib/PanelHeaderCollapseCarets.js +2 -1
  7. package/dist/lib/panelHelpers.d.ts +8 -1
  8. package/dist/lib/panelHelpers.d.ts.map +1 -1
  9. package/dist/lib/panelHelpers.js +14 -6
  10. package/dist/lib/panelNodeLink.d.ts.map +1 -1
  11. package/dist/lib/panelNodeLink.js +2 -1
  12. package/dist/lib/selectionStyles.d.ts +6 -6
  13. package/dist/lib/selectionStyles.d.ts.map +1 -1
  14. package/dist/lib/selectionStyles.js +6 -6
  15. package/dist/modals/AuditLogModal.d.ts +0 -6
  16. package/dist/modals/AuditLogModal.d.ts.map +1 -1
  17. package/dist/modals/AuditLogModal.js +6 -5
  18. package/dist/modals/DraftHistoryModal.d.ts +0 -10
  19. package/dist/modals/DraftHistoryModal.d.ts.map +1 -1
  20. package/dist/modals/DraftHistoryModal.js +6 -5
  21. package/dist/modals/PublishReviewModal.d.ts.map +1 -1
  22. package/dist/modals/PublishReviewModal.js +3 -2
  23. package/dist/panels/AdvancedJsonPanel.d.ts +1 -1
  24. package/dist/panels/AdvancedJsonPanel.d.ts.map +1 -1
  25. package/dist/panels/AdvancedJsonPanel.js +3 -3
  26. package/dist/panels/AppearancePanel.d.ts.map +1 -1
  27. package/dist/panels/AppearancePanel.js +6 -8
  28. package/dist/panels/ChoiceEdgeAppearanceFields.d.ts.map +1 -1
  29. package/dist/panels/ChoiceEdgeAppearanceFields.js +4 -3
  30. package/dist/panels/ChoiceTemplatesPanel.d.ts.map +1 -1
  31. package/dist/panels/ChoiceTemplatesPanel.js +3 -2
  32. package/dist/panels/GraphEditorInfoPanel.d.ts.map +1 -1
  33. package/dist/panels/GraphEditorInfoPanel.js +5 -4
  34. package/dist/panels/InspectorPanel.d.ts.map +1 -1
  35. package/dist/panels/InspectorPanel.js +1 -1
  36. package/dist/panels/IssuesPanel.d.ts.map +1 -1
  37. package/dist/panels/IssuesPanel.js +4 -5
  38. package/dist/panels/NodesPanel.d.ts.map +1 -1
  39. package/dist/panels/NodesPanel.js +7 -6
  40. package/dist/panels/SelectedEdgePanel.d.ts.map +1 -1
  41. package/dist/panels/SelectedEdgePanel.js +2 -1
  42. package/dist/panels/ToolbarPanel.d.ts +6 -18
  43. package/dist/panels/ToolbarPanel.d.ts.map +1 -1
  44. package/dist/panels/ToolbarPanel.js +10 -24
  45. package/dist/panels/inspector/ChoiceEditorCard.d.ts.map +1 -1
  46. package/dist/panels/inspector/ChoiceEditorCard.js +5 -4
  47. package/dist/panels/inspector/ChoiceEditorList.d.ts.map +1 -1
  48. package/dist/panels/inspector/ChoiceEditorList.js +3 -1
  49. package/dist/panels/inspector/NodeTypeField.d.ts.map +1 -1
  50. package/dist/panels/inspector/NodeTypeField.js +4 -3
  51. package/dist/panels/inspector/RequiredNodeCard.d.ts.map +1 -1
  52. package/dist/panels/inspector/RequiredNodeCard.js +3 -2
  53. package/dist/panels/inspector/choiceActionIconProps.d.ts +3 -2
  54. package/dist/panels/inspector/choiceActionIconProps.d.ts.map +1 -1
  55. package/dist/panels/inspector/choiceActionIconProps.js +4 -2
  56. package/dist/ui/editorClasses.d.ts +66 -0
  57. package/dist/ui/editorClasses.d.ts.map +1 -0
  58. package/dist/ui/editorClasses.js +89 -0
  59. package/dist/ui/primitives.d.ts +23 -0
  60. package/dist/ui/primitives.d.ts.map +1 -0
  61. package/dist/ui/primitives.js +32 -0
  62. package/docs/UI_KIT_AGNOSTIC_REFACTOR.md +186 -0
  63. package/docs/UI_KIT_AGNOSTIC_USAGE.md +129 -0
  64. package/package.json +8 -9
  65. package/README.standalone.md +0 -14
@@ -0,0 +1,129 @@
1
+ # UI-kit agnostic editor — usage and migration
2
+
3
+ **Package:** `@signalsafe/tree-spec-editor`
4
+ **Status:** Implemented (0.3.0+)
5
+ **Related:** [UI_KIT_AGNOSTIC_REFACTOR.md](./UI_KIT_AGNOSTIC_REFACTOR.md) (design scan)
6
+
7
+ ---
8
+
9
+ ## Summary
10
+
11
+ `@signalsafe/tree-spec-editor` ships **composable React panels, modals, and toolbar** with semantic HTML and stable **`graph-editor-*` class hooks**. It does **not** require Bootstrap, Material UI, or any other UI library.
12
+
13
+ **The host application owns styling.** Map `graph-editor-*` classes to your design system, or load optional host CSS (Bootstrap, MUI, Tailwind, etc.).
14
+
15
+ Peer dependencies: `react`, `react-dom`, `reactflow` only.
16
+
17
+ ---
18
+
19
+ ## Architecture
20
+
21
+ | Layer | Package | UI library |
22
+ |-------|---------|------------|
23
+ | Wire | `@signalsafe/tree-spec` | None |
24
+ | Model | `@signalsafe/tree-spec-editor-core` | None |
25
+ | Canvas | `@signalsafe/tree-spec-editor-react` | None (React Flow only; canvas emits `graph-editor-*` hooks — see [`UI_KIT_AGNOSTIC_CANVAS.md`](../../tree-spec-editor-react/docs/UI_KIT_AGNOSTIC_CANVAS.md)) |
26
+ | Shell | `@signalsafe/tree-spec-editor` | **Host-owned** — semantic hooks only |
27
+
28
+ ---
29
+
30
+ ## Class hooks (`graph-editor-*`)
31
+
32
+ Panels, modals, and toolbar emit predictable class names from `src/ui/editorClasses.ts`:
33
+
34
+ | Token | Example classes | Used for |
35
+ |-------|-----------------|----------|
36
+ | Card chrome | `graph-editor-card`, `graph-editor-card__header`, `graph-editor-card__body` | Sidebar panels |
37
+ | Lists | `graph-editor-list`, `graph-editor-list__item`, `graph-editor-list__item--selected` | Nodes / Issues rows |
38
+ | Buttons | `graph-editor-btn`, `graph-editor-btn--neutral`, `graph-editor-btn--success` | Toolbar, modals, inspector |
39
+ | Badges | `graph-editor-badge`, `graph-editor-badge--error` | Severity, toolbar status |
40
+ | Modals | `graph-editor-modal`, `graph-editor-modal__dialog`, `graph-editor-alert--danger` | Publish / draft / audit dialogs |
41
+ | Forms | `graph-editor-input`, `graph-editor-select`, `graph-editor-field` | Inspector fields |
42
+ | Toolbar | `graph-editor-toolbar`, `graph-editor-dropdown__menu` | `ToolbarPanel` |
43
+
44
+ **Tone mapping:** `ToolbarPanel` and `EditorButton` accept legacy Bootstrap `variant` strings (`outline-secondary`, `success`, …). They are mapped to tone hooks (`neutral`, `success`, …) via `normalizeToolbarTone()` — you may pass either style during migration.
45
+
46
+ ---
47
+
48
+ ## Primitives (internal building blocks)
49
+
50
+ The package uses small presentational components in `src/ui/primitives.tsx`. They are **not** re-exported from the public barrel today; hosts typically style via `graph-editor-*` CSS. Maintainers and fork authors may import them from source when composing custom panels:
51
+
52
+ | Primitive | Role |
53
+ |-----------|------|
54
+ | `EditorButton` | `<button>` with `tone` → `graph-editor-btn--*` |
55
+ | `EditorIconButton` / `EditorCloseButton` | Icon and modal close controls |
56
+ | `EditorInput`, `EditorSelect`, `EditorTextarea` | Form controls |
57
+ | `EditorField`, `EditorLabel`, `EditorCheckbox`, `EditorSwitch` | Field layout |
58
+
59
+ ---
60
+
61
+ ## Render props and extension slots
62
+
63
+ Several panels accept host injection without replacing the whole component:
64
+
65
+ ### `InspectorPanel`
66
+
67
+ | Prop | Purpose |
68
+ |------|---------|
69
+ | `renderExtraNodeFields(ctx)` | Extra UI below the prompt textarea |
70
+ | `renderExtraChoiceFields(ctx)` | Extra UI per choice card |
71
+ | `outcomeOptions` | Override END-transition `<select>` options |
72
+ | `hideOutcomeField` | Hide outcome field when host manages outcomes elsewhere |
73
+ | `choiceTypes` / `onSetChoiceType` | Host-defined choice type catalog |
74
+
75
+ ### `AppearancePanel`
76
+
77
+ | Prop | Purpose |
78
+ |------|---------|
79
+ | `renderAppearanceFields(ctx)` | Replace default node/edge appearance fields |
80
+
81
+ ### `SelectedEdgePanel`
82
+
83
+ | Prop | Purpose |
84
+ |------|---------|
85
+ | `renderDetails(edge, ctx)` | Custom edge summary line |
86
+
87
+ ### `ToolbarPanel`
88
+
89
+ | Item kind | Purpose |
90
+ |-----------|---------|
91
+ | `kind: 'custom'` | `render: () => ReactNode` for router links, host widgets |
92
+
93
+ ### `buildDefaultToolbarSpec`
94
+
95
+ Returns a `ToolbarItem[]` for the standard authoring actions. Host closures own capability gates and labels; `ToolbarPanel` renders them with semantic classes.
96
+
97
+ ---
98
+
99
+ ## Helpers (public API)
100
+
101
+ | Export | Before (≤0.2.x) | After (0.3.0+) |
102
+ |--------|-----------------|----------------|
103
+ | `getIssueSeverityBadgeClass(severity)` | `text-bg-danger`, … | `graph-editor-badge graph-editor-badge--error`, … |
104
+ | `getIssueSeverityToken(severity)` | *(not exported)* | `'error' \| 'warning' \| 'info' \| 'neutral'` |
105
+ | `LIST_SELECTION_CLASS` | `list-group-item-primary` | `graph-editor-list__item--selected` |
106
+ | `CANVAS_SELECTION_CLASS` | Bootstrap canvas class | `graph-editor-canvas__selected` |
107
+
108
+ Prefer **`getIssueSeverityToken`** when mapping to MUI/Bootstrap/theme tokens in host code.
109
+
110
+ ---
111
+
112
+ ## DeliveryPlus migration (guidance only)
113
+
114
+ **Do not change DeliveryPlus in editor package work.** When DeliveryPlus upgrades to `@signalsafe/tree-spec-editor@0.3.0`:
115
+
116
+ 1. **Remove** `react-bootstrap` as a required peer for this package (keep it only if DeliveryPlus still uses Bootstrap elsewhere).
117
+ 2. **Add CSS** mapping `graph-editor-*` → DeliveryPlus/Bootstrap theme, **or** ship a small `graph-editor.css` in the host app.
118
+ 3. **Update tests** that assert `text-bg-*`, `list-group-item-primary`, or `btn-*` on panel output — assert `graph-editor-*` instead.
119
+ 4. **Toolbar variants** — existing `outline-secondary` / `success` strings still work via tone mapping.
120
+ 5. **Optional short-term pin** — stay on `0.2.x` until host CSS is ready; then bump to `0.3.0`.
121
+ 6. **Future (optional)** — `@signalsafe/tree-spec-editor-bootstrap` may provide a reference Bootstrap skin without coupling the core package.
122
+
123
+ **Canvas (`@signalsafe/tree-spec-editor-react@0.2.0`):** uses the same `graph-editor-*` prefix for node cards, lists, badges, and context menus. Map canvas hooks in host CSS alongside panel hooks.
124
+
125
+ ---
126
+
127
+ ## Semver
128
+
129
+ **0.3.0** — removes `react-bootstrap` peer dependency; changes styling class contract and adds `getIssueSeverityToken`. Component prop names and export surface are largely unchanged; visual parity requires host CSS updates.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@signalsafe/tree-spec-editor",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
- "description": "Reusable TreeSpec graph editor (React Flow) and authoring helpers (no API or routing).",
5
+ "description": "UI-kit agnostic TreeSpec graph editor shell (React Flow canvas, panels, modals, toolbar).",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -18,7 +18,6 @@
18
18
  "editor",
19
19
  "graph-editor",
20
20
  "decision-tree",
21
- "react-bootstrap",
22
21
  "typescript",
23
22
  "signalsafe"
24
23
  ],
@@ -39,7 +38,7 @@
39
38
  "LICENSE"
40
39
  ],
41
40
  "engines": {
42
- "node": ">=18"
41
+ "node": ">=22.12.0"
43
42
  },
44
43
  "packageManager": "yarn@1.22.22",
45
44
  "publishConfig": {
@@ -47,6 +46,7 @@
47
46
  },
48
47
  "scripts": {
49
48
  "build": "tsc -p tsconfig.build.json",
49
+ "lint": "yarn typecheck",
50
50
  "typecheck": "tsc --noEmit",
51
51
  "pack:local": "npm pack --pack-destination ../../dist/reusable-npm",
52
52
  "release:check": "node ../../scripts/run-private-package-release-checks.mjs --mode prepublish",
@@ -61,16 +61,16 @@
61
61
  "prepublishOnly": "npm run build",
62
62
  "prepare": "npm run build",
63
63
  "test": "vitest run",
64
+ "test:coverage": "yarn test --coverage",
64
65
  "test:monorepo": "cd ../../frontend && yarn vitest run --config vitest.tree-spec-editor.config.ts"
65
66
  },
66
67
  "dependencies": {
67
- "@signalsafe/tree-spec": "^0.3.2",
68
- "@signalsafe/tree-spec-editor-core": "^0.1.3",
69
- "@signalsafe/tree-spec-editor-react": "^0.1.3"
68
+ "@signalsafe/tree-spec": "^0.3.3",
69
+ "@signalsafe/tree-spec-editor-core": "^0.1.4",
70
+ "@signalsafe/tree-spec-editor-react": "^0.2.0"
70
71
  },
71
72
  "peerDependencies": {
72
73
  "react": "^18.0.0",
73
- "react-bootstrap": "^2.10.0",
74
74
  "react-dom": "^18.0.0",
75
75
  "reactflow": "^11.0.0"
76
76
  },
@@ -79,7 +79,6 @@
79
79
  "@types/react-dom": "^18.2.22",
80
80
  "@types/react-test-renderer": "^18.3.0",
81
81
  "react": "^18.3.1",
82
- "react-bootstrap": "^2.10.2",
83
82
  "react-dom": "^18.3.1",
84
83
  "react-test-renderer": "^18.3.1",
85
84
  "reactflow": "^11.11.4",
@@ -1,14 +0,0 @@
1
- # Standalone export
2
-
3
- This tree was generated by `scripts/export-standalone-npm-package.sh tree-spec-editor` 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 from DeliveryPlus"
10
- git remote add origin git@github.com:SignalSafeSoftware/tree-spec-editor.git
11
- git push -u origin main
12
- ```
13
-
14
- See `RELEASING.md` for npm publish steps.