@republicroad/seal-editor 1.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 +13 -0
- package/README.md +127 -0
- package/dist/index.d.ts +2515 -0
- package/dist/index.js +15779 -0
- package/dist/index.js.map +1 -0
- package/dist/schema-BmbNWz7t.js +596 -0
- package/dist/schema-BmbNWz7t.js.map +1 -0
- package/dist/schema.d.ts +868 -0
- package/dist/schema.js +2 -0
- package/dist/style.css +3 -0
- package/package.json +144 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2024 GoRules.io
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
|
4
|
+
files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
|
5
|
+
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
|
|
6
|
+
is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
11
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
12
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
13
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# `@republicroad/jdm-editor`
|
|
2
|
+
|
|
3
|
+
React components for authoring [JDM](https://gorules.io/docs) (JSON Decision
|
|
4
|
+
Model) documents: a decision graph canvas, decision tables, expression and
|
|
5
|
+
function editors, a simulator, and a custom-function spreadsheet — themed
|
|
6
|
+
end-to-end with shadcn/ReUI + Tailwind.
|
|
7
|
+
|
|
8
|
+
> Fork of [`@gorules/jdm-editor`](https://github.com/gorules/jdm-editor) with
|
|
9
|
+
> significant divergence (ReactFlow 12, shadcn/ReUI stack, seed-derived
|
|
10
|
+
> theming, i18n, pooled editors). Will not track upstream merges.
|
|
11
|
+
>
|
|
12
|
+
> **Live storybook:** https://republicroad.github.io/jdm-editor/
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm i @republicroad/jdm-editor
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Heads-up (0.3.0+):** `monaco-editor` is a peer dependency — install it
|
|
21
|
+
explicitly: `npm i monaco-editor`.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { DecisionGraph, JdmConfigProvider } from '@republicroad/jdm-editor';
|
|
27
|
+
import '@republicroad/jdm-editor/dist/style.css';
|
|
28
|
+
|
|
29
|
+
<JdmConfigProvider
|
|
30
|
+
seeds={{ primary: '#6366f1' }} // one seed → full light + dark palettes
|
|
31
|
+
locale='zh-CN' // or supply messages={...} for any locale
|
|
32
|
+
darkMode={{ enabled: true }}
|
|
33
|
+
>
|
|
34
|
+
<DecisionGraph value={graph} onChange={setGraph} />
|
|
35
|
+
</JdmConfigProvider>;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Wrap any subtree in `.grl-root` to scope the theme island; multiple islands
|
|
39
|
+
can coexist with independent themes.
|
|
40
|
+
|
|
41
|
+
## What's inside
|
|
42
|
+
|
|
43
|
+
| Surface | Highlights |
|
|
44
|
+
| ------------------------- | ----------------------------------------------------------------------------------------- |
|
|
45
|
+
| **Decision Graph** | xyflow canvas, tabs, diff support, simulator panel |
|
|
46
|
+
| **Request node** | Definitions / Data / Schema tab with example sources, inlay hints, JSON→Schema conversion |
|
|
47
|
+
| **Decision Table** | virtualized rows, hit-policy, Excel import/export, simulation row highlights |
|
|
48
|
+
| **Simulator** | request binding to example sources, bidirectional auto-sync, per-node trace |
|
|
49
|
+
| **Custom function table** | spreadsheet-style expressions: function/code modes, drag reorder, `;;` legacy migration |
|
|
50
|
+
| **SafeBoundary** | error-isolation boundary for editor subtrees |
|
|
51
|
+
|
|
52
|
+
## Theming
|
|
53
|
+
|
|
54
|
+
All chrome resolves through shadcn semantic tokens injected onto the theme
|
|
55
|
+
island — no global CSS leaks. Derive full palettes from a single seed, flip
|
|
56
|
+
dark mode per island, or drive everything with explicit tokens. See
|
|
57
|
+
[`docs/shadcn-theming-roadmap.md`](../../docs/shadcn-theming-roadmap.md).
|
|
58
|
+
|
|
59
|
+
## i18n
|
|
60
|
+
|
|
61
|
+
Locale-neutral components with bundled `en` + `zh-CN` catalogs and a typed
|
|
62
|
+
fallback chain (host overrides → locale → en → key). See
|
|
63
|
+
[`docs/i18n.md`](../../docs/i18n.md).
|
|
64
|
+
|
|
65
|
+
## Simulator
|
|
66
|
+
|
|
67
|
+
Wire your engine via `onRun`; the request panel binds to the input node's
|
|
68
|
+
example sources and keeps the editor, definitions and schema examples in sync
|
|
69
|
+
(`useSimulatorAutoSync`).
|
|
70
|
+
|
|
71
|
+
## Custom nodes
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
createJdmNode({
|
|
75
|
+
kind: 'myKind',
|
|
76
|
+
displayName: 'My Node',
|
|
77
|
+
renderTab: ({ id, user, customFunctions }) => <MyTab id={id} />,
|
|
78
|
+
renderNode: (props) => <GraphCard {...props} />,
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The bundled `CustomFunctionTable` gives custom nodes a full expression
|
|
83
|
+
spreadsheet out of the box. `DecisionGraph` accepts `userResolver` and
|
|
84
|
+
`customFunctions` props.
|
|
85
|
+
|
|
86
|
+
## Self-hosting Monaco Editor
|
|
87
|
+
|
|
88
|
+
Monaco is a peer dependency — hosts install it explicitly and register its
|
|
89
|
+
workers once at startup (Vite example):
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import type { Monaco } from '@monaco-editor/react';
|
|
93
|
+
import { loader } from '@monaco-editor/react';
|
|
94
|
+
import * as monaco from 'monaco-editor';
|
|
95
|
+
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
|
96
|
+
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
|
|
97
|
+
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
|
|
98
|
+
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
|
99
|
+
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
|
100
|
+
|
|
101
|
+
self.monaco = monaco;
|
|
102
|
+
|
|
103
|
+
self.MonacoEnvironment = {
|
|
104
|
+
getWorker(_workerId: string, label: string) {
|
|
105
|
+
if (label === 'json') return new jsonWorker();
|
|
106
|
+
if (label === 'css' || label === 'scss' || label === 'less') return new cssWorker();
|
|
107
|
+
if (label === 'html' || label === 'handlebars' || label === 'razor') return new htmlWorker();
|
|
108
|
+
if (label === 'typescript' || label === 'javascript') return new tsWorker();
|
|
109
|
+
return new editorWorker();
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
loader.config({ monaco });
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
For webpack and other setups you may need
|
|
117
|
+
[monaco-editor-webpack-plugin](https://www.npmjs.com/package/monaco-editor-webpack-plugin).
|
|
118
|
+
|
|
119
|
+
## Documentation
|
|
120
|
+
|
|
121
|
+
The full documentation map lives in [`docs/README.md`](../../docs/README.md):
|
|
122
|
+
architecture, theming roadmap, CodeMirror migration, i18n, storybook guide,
|
|
123
|
+
host migration guide, 0.3.0 roadmap, and a troubleshooting case log.
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
MIT — see [LICENSE](./LICENSE) (fork lineage: [GoRules](https://github.com/gorules/jdm-editor)).
|