@workbench-kit/jdw-editor 0.0.2-prototype.0.1.4 → 0.0.2-prototype.0.2.2
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/package.json +4 -4
- package/src/JdwSampleScreenExplorer.tsx +49 -149
- package/src/ScreenNodeInspector.tsx +304 -138
- package/src/ScreenSpecEditor.tsx +373 -138
- package/src/ScreenSpecEditorStoryHost.tsx +103 -0
- package/src/ScreenSpecPalette.tsx +119 -0
- package/src/ScreenSpecWorkbench.tsx +177 -0
- package/src/filterScreenSpecOutline.ts +40 -0
- package/src/index.ts +18 -5
- package/src/useScreenSpecPipeline.ts +29 -35
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workbench-kit/jdw-editor",
|
|
3
|
-
"version": "0.0.2-prototype.0.
|
|
3
|
+
"version": "0.0.2-prototype.0.2.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"!src/**/*.stories.tsx"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@workbench-kit/jdw": "0.0.2-prototype.0.
|
|
18
|
-
"@workbench-kit/react": "0.0.2-prototype.0.
|
|
17
|
+
"@workbench-kit/jdw": "0.0.2-prototype.0.2.2",
|
|
18
|
+
"@workbench-kit/react": "0.0.2-prototype.0.2.2"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": "^19.0.0"
|
|
22
22
|
},
|
|
23
|
-
"description": "
|
|
23
|
+
"description": "JDW template-to-WidgetTreeLab sample flow with deprecated Screen Spec compatibility editors.",
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public",
|
|
26
26
|
"tag": "prototype",
|
|
@@ -1,32 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { createScreenSpecPaletteAssetCatalog } from '@workbench-kit/jdw';
|
|
3
|
+
import { BUILTIN_JDW_REGISTRY } from '@workbench-kit/react/jdw';
|
|
4
|
+
import { WidgetTreeLab } from '@workbench-kit/react/widget-tree';
|
|
5
|
+
import { Field, Select, WorkbenchAuthoringShell } from '@workbench-kit/react/primitives';
|
|
5
6
|
import {
|
|
6
7
|
JDW_SAMPLE_SCREENS,
|
|
7
|
-
|
|
8
|
+
formatJdwSampleScreenJson,
|
|
8
9
|
type JdwSampleScreenDefinition,
|
|
9
10
|
} from '@workbench-kit/react/jdw/samples';
|
|
10
|
-
import {
|
|
11
|
-
Field,
|
|
12
|
-
Panel,
|
|
13
|
-
PanelBody,
|
|
14
|
-
PanelHeader,
|
|
15
|
-
Select,
|
|
16
|
-
SegmentedControl,
|
|
17
|
-
WorkbenchParseError,
|
|
18
|
-
} from '@workbench-kit/react/primitives';
|
|
19
|
-
import { SplitView } from '@workbench-kit/react/workbench/shell';
|
|
20
|
-
|
|
21
|
-
import { ScreenSpecEditor } from './ScreenSpecEditor.js';
|
|
22
|
-
import { useScreenSpecPipeline } from './useScreenSpecPipeline.js';
|
|
23
|
-
|
|
24
|
-
export type JdwSampleSourceView = 'editor' | 'jdw';
|
|
25
11
|
|
|
26
12
|
export interface JdwSampleScreenExplorerProps {
|
|
27
13
|
readonly samples?: readonly JdwSampleScreenDefinition[] | undefined;
|
|
28
14
|
readonly initialSampleId?: string | undefined;
|
|
29
|
-
readonly initialSourceView?: JdwSampleSourceView | undefined;
|
|
30
15
|
}
|
|
31
16
|
|
|
32
17
|
function resolveSample(
|
|
@@ -36,146 +21,61 @@ function resolveSample(
|
|
|
36
21
|
return samples.find((entry) => entry.id === sampleId) ?? samples[0]!;
|
|
37
22
|
}
|
|
38
23
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Compiles a selected Screen Spec template once, then opens the resulting JDW
|
|
26
|
+
* document in the canonical WidgetTreeLab design/code authoring surface.
|
|
27
|
+
*/
|
|
44
28
|
export function JdwSampleScreenExplorer({
|
|
45
29
|
samples = JDW_SAMPLE_SCREENS,
|
|
46
30
|
initialSampleId,
|
|
47
|
-
initialSourceView = 'editor',
|
|
48
31
|
}: JdwSampleScreenExplorerProps) {
|
|
49
32
|
const [sampleId, setSampleId] = useState(initialSampleId ?? samples[0]?.id ?? '');
|
|
50
|
-
const [sourceView, setSourceView] = useState<JdwSampleSourceView>(initialSourceView);
|
|
51
33
|
const activeSample = resolveSample(samples, sampleId);
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const [editorError, setEditorError] = useState<string | null>(null);
|
|
34
|
+
const [documentValue, setDocumentValue] = useState(() => formatJdwSampleScreenJson(activeSample));
|
|
35
|
+
const assetCatalog = useMemo(() => createScreenSpecPaletteAssetCatalog(), []);
|
|
55
36
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
37
|
+
const sampleOptions = useMemo(
|
|
38
|
+
() =>
|
|
39
|
+
samples.map((sample) => (
|
|
40
|
+
<option key={sample.id} value={sample.id}>
|
|
41
|
+
{sample.title}
|
|
42
|
+
</option>
|
|
43
|
+
)),
|
|
44
|
+
[samples],
|
|
45
|
+
);
|
|
60
46
|
|
|
61
47
|
if (samples.length === 0) {
|
|
62
48
|
return <div data-testid="jdw-sample-explorer-empty">No sample screens configured.</div>;
|
|
63
49
|
}
|
|
64
50
|
|
|
65
|
-
const compileError = pipeline.compileError ?? editorError;
|
|
66
|
-
|
|
67
|
-
const handleSourceViewChange = (nextView: JdwSampleSourceView) => {
|
|
68
|
-
if (nextView === 'jdw') {
|
|
69
|
-
const compiled = compileScreenSpecText(formatJdwSampleScreenSpec(pipeline.spec));
|
|
70
|
-
if (compiled.json) {
|
|
71
|
-
pipeline.setJson(compiled.json);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
setSourceView(nextView);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
51
|
return (
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
</Select>
|
|
107
|
-
</Field>
|
|
108
|
-
</div>
|
|
109
|
-
}
|
|
110
|
-
>
|
|
111
|
-
JDW Sample Explorer
|
|
112
|
-
</PanelHeader>
|
|
113
|
-
<PanelBody
|
|
114
|
-
className="jdw-sample-explorer__body"
|
|
115
|
-
style={{
|
|
116
|
-
display: 'flex',
|
|
117
|
-
flexDirection: 'column',
|
|
118
|
-
gap: 8,
|
|
119
|
-
minHeight: 0,
|
|
120
|
-
flex: 1,
|
|
121
|
-
paddingTop: 0,
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
<p className="jdw-sample-explorer__description">{activeSample.description}</p>
|
|
125
|
-
{compileError ? (
|
|
126
|
-
<WorkbenchParseError role="alert" data-testid="jdw-sample-explorer-error">
|
|
127
|
-
{compileError}
|
|
128
|
-
</WorkbenchParseError>
|
|
129
|
-
) : null}
|
|
130
|
-
<SplitView
|
|
131
|
-
className="jdw-sample-explorer__split"
|
|
132
|
-
defaultPrimarySizePercent={46}
|
|
133
|
-
minPrimarySizePercent={24}
|
|
134
|
-
maxPrimarySizePercent={72}
|
|
135
|
-
primary={
|
|
136
|
-
<section
|
|
137
|
-
aria-label={sourceView === 'editor' ? 'Screen spec editor' : 'JDW JSON source'}
|
|
138
|
-
className="jdw-sample-explorer__pane"
|
|
139
|
-
data-testid="jdw-sample-explorer-source-pane"
|
|
140
|
-
>
|
|
141
|
-
<header className="jdw-sample-explorer__pane-header">
|
|
142
|
-
{sourceView === 'editor' ? 'Screen editor' : 'JDW JSON'}
|
|
143
|
-
</header>
|
|
144
|
-
<div className="jdw-sample-explorer__pane-body">
|
|
145
|
-
{sourceView === 'editor' ? (
|
|
146
|
-
<ScreenSpecEditor
|
|
147
|
-
value={pipeline.spec}
|
|
148
|
-
onChange={pipeline.setSpec}
|
|
149
|
-
onCompileError={setEditorError}
|
|
150
|
-
/>
|
|
151
|
-
) : (
|
|
152
|
-
<textarea
|
|
153
|
-
aria-label="JDW JSON source"
|
|
154
|
-
className="jdw-sample-explorer__json-source"
|
|
155
|
-
data-testid="jdw-sample-explorer-json"
|
|
156
|
-
value={pipeline.json}
|
|
157
|
-
onChange={(event) => pipeline.setJson(event.target.value)}
|
|
158
|
-
spellCheck={false}
|
|
159
|
-
/>
|
|
160
|
-
)}
|
|
161
|
-
</div>
|
|
162
|
-
</section>
|
|
163
|
-
}
|
|
164
|
-
secondary={
|
|
165
|
-
<section
|
|
166
|
-
aria-label="Rendered preview"
|
|
167
|
-
className="jdw-sample-explorer__pane"
|
|
168
|
-
data-testid="jdw-sample-explorer-preview-pane"
|
|
169
|
-
>
|
|
170
|
-
<header className="jdw-sample-explorer__pane-header">Preview</header>
|
|
171
|
-
<div className="jdw-sample-explorer__pane-body">
|
|
172
|
-
<JdwPreview json={pipeline.json} layoutConstraints={pipeline.layoutConstraints} />
|
|
173
|
-
</div>
|
|
174
|
-
</section>
|
|
175
|
-
}
|
|
176
|
-
/>
|
|
177
|
-
</PanelBody>
|
|
178
|
-
</Panel>
|
|
179
|
-
</div>
|
|
52
|
+
<WorkbenchAuthoringShell
|
|
53
|
+
data-testid="jdw-sample-explorer"
|
|
54
|
+
toolbar={
|
|
55
|
+
<Field label="Load sample" htmlFor="jdw-sample-screen-select" inline>
|
|
56
|
+
<Select
|
|
57
|
+
id="jdw-sample-screen-select"
|
|
58
|
+
aria-label="Load sample"
|
|
59
|
+
data-testid="jdw-sample-screen-select"
|
|
60
|
+
controlWidth="wide"
|
|
61
|
+
value={activeSample.id}
|
|
62
|
+
onValueChange={(nextId) => {
|
|
63
|
+
const next = resolveSample(samples, nextId);
|
|
64
|
+
setSampleId(next.id);
|
|
65
|
+
setDocumentValue(formatJdwSampleScreenJson(next));
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{sampleOptions}
|
|
69
|
+
</Select>
|
|
70
|
+
</Field>
|
|
71
|
+
}
|
|
72
|
+
>
|
|
73
|
+
<WidgetTreeLab
|
|
74
|
+
assetCatalog={assetCatalog}
|
|
75
|
+
registry={BUILTIN_JDW_REGISTRY}
|
|
76
|
+
value={documentValue}
|
|
77
|
+
onChange={setDocumentValue}
|
|
78
|
+
/>
|
|
79
|
+
</WorkbenchAuthoringShell>
|
|
180
80
|
);
|
|
181
81
|
}
|