@workbench-kit/jdw-editor 0.0.1-prototype.0 → 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 +81 -181
- package/src/ScreenNodeInspector.tsx +369 -203
- package/src/ScreenSpecEditor.tsx +431 -196
- 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 +27 -14
- package/src/useScreenSpecPipeline.ts +82 -88
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workbench-kit/jdw-editor",
|
|
3
|
-
"version": "0.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.
|
|
18
|
-
"@workbench-kit/react": "0.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,181 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
>
|
|
83
|
-
<PanelHeader
|
|
84
|
-
actions={
|
|
85
|
-
<div className="jdw-sample-explorer__header-actions">
|
|
86
|
-
<SegmentedControl
|
|
87
|
-
ariaLabel="Source view"
|
|
88
|
-
options={SOURCE_VIEW_OPTIONS}
|
|
89
|
-
value={sourceView}
|
|
90
|
-
onChange={handleSourceViewChange}
|
|
91
|
-
/>
|
|
92
|
-
<Field label="Sample screen" htmlFor="jdw-sample-screen-select" inline>
|
|
93
|
-
<Select
|
|
94
|
-
id="jdw-sample-screen-select"
|
|
95
|
-
aria-label="Sample screen"
|
|
96
|
-
data-testid="jdw-sample-screen-select"
|
|
97
|
-
controlWidth="wide"
|
|
98
|
-
value={activeSample.id}
|
|
99
|
-
onValueChange={setSampleId}
|
|
100
|
-
>
|
|
101
|
-
{samples.map((sample) => (
|
|
102
|
-
<option key={sample.id} value={sample.id}>
|
|
103
|
-
{sample.title}
|
|
104
|
-
</option>
|
|
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>
|
|
180
|
-
);
|
|
181
|
-
}
|
|
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';
|
|
6
|
+
import {
|
|
7
|
+
JDW_SAMPLE_SCREENS,
|
|
8
|
+
formatJdwSampleScreenJson,
|
|
9
|
+
type JdwSampleScreenDefinition,
|
|
10
|
+
} from '@workbench-kit/react/jdw/samples';
|
|
11
|
+
|
|
12
|
+
export interface JdwSampleScreenExplorerProps {
|
|
13
|
+
readonly samples?: readonly JdwSampleScreenDefinition[] | undefined;
|
|
14
|
+
readonly initialSampleId?: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function resolveSample(
|
|
18
|
+
samples: readonly JdwSampleScreenDefinition[],
|
|
19
|
+
sampleId: string,
|
|
20
|
+
): JdwSampleScreenDefinition {
|
|
21
|
+
return samples.find((entry) => entry.id === sampleId) ?? samples[0]!;
|
|
22
|
+
}
|
|
23
|
+
|
|
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
|
+
*/
|
|
28
|
+
export function JdwSampleScreenExplorer({
|
|
29
|
+
samples = JDW_SAMPLE_SCREENS,
|
|
30
|
+
initialSampleId,
|
|
31
|
+
}: JdwSampleScreenExplorerProps) {
|
|
32
|
+
const [sampleId, setSampleId] = useState(initialSampleId ?? samples[0]?.id ?? '');
|
|
33
|
+
const activeSample = resolveSample(samples, sampleId);
|
|
34
|
+
const [documentValue, setDocumentValue] = useState(() => formatJdwSampleScreenJson(activeSample));
|
|
35
|
+
const assetCatalog = useMemo(() => createScreenSpecPaletteAssetCatalog(), []);
|
|
36
|
+
|
|
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
|
+
);
|
|
46
|
+
|
|
47
|
+
if (samples.length === 0) {
|
|
48
|
+
return <div data-testid="jdw-sample-explorer-empty">No sample screens configured.</div>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
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>
|
|
80
|
+
);
|
|
81
|
+
}
|