@workbench-kit/react 0.0.1-prototype.0 → 0.0.2-prototype.0.1.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.
Files changed (155) hide show
  1. package/package.json +33 -9
  2. package/src/index.ts +545 -43
  3. package/src/jdw/JdwPreview.tsx +38 -0
  4. package/src/jdw/JsonCodeEditorPane.tsx +274 -0
  5. package/src/jdw/builtins/renderBuiltinWidgetLeaf.tsx +29 -0
  6. package/src/jdw/builtins/renderBuiltinWidgetNode.tsx +126 -0
  7. package/src/jdw/createBuiltinJdwRegistry.ts +111 -0
  8. package/src/jdw/cssRenderBackend.tsx +134 -0
  9. package/src/jdw/document.ts +38 -0
  10. package/src/jdw/fixtures/jdw-fixtures.ts +52 -0
  11. package/src/jdw/fixtures/jdw-sample-screens.ts +522 -0
  12. package/src/jdw/index.ts +45 -0
  13. package/src/jdw/parse.ts +1 -0
  14. package/src/jdw/renderJdw.tsx +32 -0
  15. package/src/json-config/JsonConfigWorkbench.tsx +316 -0
  16. package/src/json-config/index.ts +6 -0
  17. package/src/json-config/json-config-editor-state.ts +42 -0
  18. package/src/layout/Panel.tsx +146 -1
  19. package/src/layout/SideBarViewFrame.tsx +367 -328
  20. package/src/layout/WorkbenchCanvas.tsx +849 -0
  21. package/src/layout/WorkbenchFullscreen.tsx +368 -0
  22. package/src/layout/WorkbenchLayout.tsx +5 -0
  23. package/src/layout/WorkbenchLayoutBase.tsx +294 -0
  24. package/src/layout/WorkbenchPropertyPanel.tsx +497 -0
  25. package/src/layout/WorkbenchSidebarActions.tsx +274 -0
  26. package/src/layout/WorkbenchTree.tsx +351 -0
  27. package/src/layout/layoutHelpers.ts +25 -0
  28. package/src/modal/ConfirmDialog.tsx +61 -53
  29. package/src/modal/Modal.tsx +295 -35
  30. package/src/overlay/ContextMenu.tsx +146 -145
  31. package/src/primitives/AbsoluteBox.tsx +46 -0
  32. package/src/primitives/Badge.tsx +12 -12
  33. package/src/primitives/Button.tsx +44 -14
  34. package/src/primitives/Checkbox.tsx +11 -5
  35. package/src/primitives/EmptyState.tsx +27 -26
  36. package/src/primitives/Field.tsx +38 -38
  37. package/src/primitives/IconButton.tsx +5 -2
  38. package/src/primitives/List.tsx +111 -0
  39. package/src/primitives/NumberInput.tsx +38 -0
  40. package/src/primitives/ScrollArea.tsx +42 -0
  41. package/src/primitives/Select.tsx +1 -12
  42. package/src/primitives/StatusBar.tsx +46 -0
  43. package/src/primitives/TextArea.tsx +36 -0
  44. package/src/primitives/TextInput.tsx +11 -2
  45. package/src/primitives/WorkbenchChrome.tsx +424 -0
  46. package/src/primitives/WorkbenchEditor.tsx +394 -0
  47. package/src/primitives/index.ts +105 -0
  48. package/src/primitives/select/Select.tsx +266 -0
  49. package/src/primitives/select/index.ts +2 -0
  50. package/src/primitives/select/options.ts +38 -0
  51. package/src/primitives/select/overlay.ts +63 -0
  52. package/src/primitives/select/select.app.css +9 -0
  53. package/src/primitives/select/select.css +140 -0
  54. package/src/primitives/select/types.ts +18 -0
  55. package/src/primitives/styles.css +955 -0
  56. package/src/scrollbars.css +69 -0
  57. package/src/styles.css +7738 -1762
  58. package/src/utils/codicon.ts +17 -0
  59. package/src/widget-asset/WidgetAssetEditor.tsx +140 -0
  60. package/src/widget-asset/WidgetAssetMetadataForm.tsx +82 -0
  61. package/src/widget-asset/WidgetAssetModeControls.tsx +42 -0
  62. package/src/widget-asset/WidgetAssetSourceEditor.tsx +50 -0
  63. package/src/widget-asset/WidgetAssetWorkbench.tsx +112 -0
  64. package/src/widget-asset/index.ts +17 -0
  65. package/src/widget-asset/widget-asset-document.ts +37 -0
  66. package/src/widget-asset/widget-asset-mode.ts +3 -0
  67. package/src/widget-studio/builtin-widget-asset-catalog.ts +12 -0
  68. package/src/widget-studio/create-widget-studio-workspace-editor.tsx +79 -0
  69. package/src/widget-studio/index.ts +7 -0
  70. package/src/widget-studio/resolve-widget-studio-asset-catalog.ts +26 -0
  71. package/src/widget-tree/WidgetAssetPalette.tsx +77 -0
  72. package/src/widget-tree/WidgetInspectorPanel.tsx +266 -0
  73. package/src/widget-tree/WidgetSourceEditor.tsx +56 -0
  74. package/src/widget-tree/WidgetTreeLab.tsx +272 -0
  75. package/src/widget-tree/WidgetTreeModeControls.tsx +44 -0
  76. package/src/widget-tree/WidgetTreeSidePanel.tsx +49 -0
  77. package/src/widget-tree/WidgetTreeView.tsx +97 -0
  78. package/src/widget-tree/WidgetTreeWorkbench.tsx +111 -0
  79. package/src/widget-tree/WidgetTreeWorkspaceShell.tsx +154 -0
  80. package/src/widget-tree/demo-registry.ts +32 -0
  81. package/src/widget-tree/demo-widget-assets.ts +4 -0
  82. package/src/widget-tree/index.ts +27 -0
  83. package/src/widget-tree/widget-tree-document.ts +20 -0
  84. package/src/widget-tree/widget-tree-layout.ts +31 -0
  85. package/src/widget-tree/widget-tree-mode.ts +7 -0
  86. package/src/widget-tree/widget-tree-play-helpers.ts +74 -0
  87. package/src/workbench/ActivityBar.tsx +52 -52
  88. package/src/workbench/ArtifactShell.tsx +397 -0
  89. package/src/workbench/CommandPalette.tsx +819 -0
  90. package/src/workbench/ConfirmationFlow.tsx +245 -0
  91. package/src/workbench/MarkdownPreview.tsx +151 -0
  92. package/src/workbench/ShortcutCommandBridge.tsx +368 -0
  93. package/src/workbench/SplitView.tsx +136 -136
  94. package/src/workbench/StatusBar.tsx +178 -123
  95. package/src/workbench/StructuredArtifactEditor.tsx +205 -0
  96. package/src/workbench/Timeline.tsx +302 -0
  97. package/src/workbench/WorkbenchCanvasShell.tsx +941 -0
  98. package/src/workbench/WorkbenchShell.tsx +74 -70
  99. package/src/workbench/WorkbenchStandaloneShell.tsx +318 -291
  100. package/src/workbench/auth/WorkbenchAuthGate.tsx +61 -0
  101. package/src/workbench/auth/WorkbenchLoginView.tsx +635 -0
  102. package/src/workbench/auth/index.ts +19 -0
  103. package/src/workbench/chat/ChatComposer.tsx +165 -148
  104. package/src/workbench/chat/ChatMessageItem.tsx +10 -1
  105. package/src/workbench/chat/index.ts +9 -0
  106. package/src/workbench/chat/slashCommand.ts +28 -0
  107. package/src/workbench/chat/useChatRuntimeState.ts +76 -0
  108. package/src/workbench/chat/useSlashCommandSuggest.ts +101 -0
  109. package/src/workbench/commands.ts +520 -490
  110. package/src/workbench/index.ts +443 -98
  111. package/src/workbench/keyboard.ts +53 -0
  112. package/src/workbench/schema/index.ts +48 -0
  113. package/src/workbench/schema/workbenchDocument.ts +31 -0
  114. package/src/workbench/schema/workbenchDocumentActions.ts +6 -0
  115. package/src/workbench/schema/workbenchDocumentAdapter.ts +9 -0
  116. package/src/workbench/schema/workbenchDocumentPatch.ts +13 -0
  117. package/src/workbench/schema/workbenchDocumentRenderer.tsx +702 -0
  118. package/src/workbench/settings/NavigationPanel.tsx +47 -0
  119. package/src/workbench/settings/SchemaForm.tsx +420 -0
  120. package/src/workbench/settings/SectionedPanel.tsx +415 -0
  121. package/src/workbench/settings/StructuredDataForm.tsx +539 -0
  122. package/src/workbench/settings/StructuredDataSchemaPanel.tsx +559 -0
  123. package/src/workbench/settings/StructuredDataSchemaPanelEmbed.tsx +21 -0
  124. package/src/workbench/settings/StructuredDataSchemaPanelFrame.tsx +76 -0
  125. package/src/workbench/settings/StructuredDataTableView.tsx +127 -0
  126. package/src/workbench/settings/WorkbenchPanelRegion.tsx +46 -0
  127. package/src/workbench/settings/WorkbenchSettingsModal.tsx +21 -12
  128. package/src/workbench/settings/WorkbenchSettingsNav.tsx +38 -22
  129. package/src/workbench/settings/index.ts +135 -0
  130. package/src/workbench/settings/panel-region.css +21 -0
  131. package/src/workbench/settings/sectionedPanelScrollSpy.ts +143 -0
  132. package/src/workbench/settings/structured-data-schema-panel.css +330 -0
  133. package/src/workbench/settings/structured-data-table-view.css +85 -0
  134. package/src/workbench/settings/structuredDataSchema.ts +886 -0
  135. package/src/workbench/shell.ts +15 -0
  136. package/src/workbench/shellState.ts +203 -203
  137. package/src/workbench/standalone.ts +101 -94
  138. package/src/workbench/status.ts +129 -0
  139. package/src/workbench/theme.ts +44 -0
  140. package/src/workbench/workspace/MultiProviderExplorer.tsx +625 -0
  141. package/src/workbench/workspace/WorkspaceDraftsContext.tsx +111 -0
  142. package/src/workbench/workspace/WorkspaceEditor.tsx +47 -12
  143. package/src/workbench/workspace/WorkspaceEditorPanel.tsx +334 -353
  144. package/src/workbench/workspace/WorkspaceExplorer.tsx +532 -524
  145. package/src/workbench/workspace/WorkspaceFileIcon.tsx +32 -2
  146. package/src/workbench/workspace/WorkspaceSearchPanel.tsx +113 -113
  147. package/src/workbench/workspace/WorkspaceSearchResults.tsx +47 -47
  148. package/src/workbench/workspace/index.ts +156 -98
  149. package/src/workbench/workspace/mimeType.ts +45 -0
  150. package/src/workbench/workspace/path.ts +10 -10
  151. package/src/workbench/workspace/search.ts +6 -6
  152. package/src/workbench/workspace/tree.ts +1 -1
  153. package/src/workbench/workspace/types.ts +10 -10
  154. package/src/workbench/workspace/useVirtualWorkspace.ts +111 -98
  155. package/src/workbench/workspace/workspaceJsonDiagnostics.ts +83 -0
@@ -0,0 +1,134 @@
1
+ import { createElement, type CSSProperties, type ReactNode } from 'react';
2
+ import type { WidgetRegistryContract } from '@workbench-kit/contracts';
3
+ import {
4
+ DEFAULT_LAYOUT_CONSTRAINTS,
5
+ jdwNodeToGenericWidget,
6
+ layoutWidget,
7
+ type GenericWidget,
8
+ type JsonWidgetNode,
9
+ type LayoutConstraints,
10
+ type LayoutNodeResult,
11
+ } from '@workbench-kit/jdw';
12
+
13
+ import { renderBuiltinWidgetLeaf } from './builtins/renderBuiltinWidgetLeaf.js';
14
+ import { BUILTIN_JDW_REGISTRY } from './createBuiltinJdwRegistry.js';
15
+ export interface CssRenderBackendOptions {
16
+ readonly registry?: WidgetRegistryContract<unknown> | undefined;
17
+ readonly emptyLabel?: string | undefined;
18
+ readonly layoutConstraints?: LayoutConstraints | undefined;
19
+ }
20
+
21
+ const LAYOUT_CONTAINER_TYPES = new Set(['row', 'column', 'grid', 'stack']);
22
+
23
+ function readNumber(value: unknown): number | undefined {
24
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
25
+ }
26
+
27
+ function renderFromRegistry(
28
+ registry: WidgetRegistryContract<unknown>,
29
+ widget: GenericWidget,
30
+ emptyLabel: string,
31
+ ): ReactNode {
32
+ const build = registry.get(widget.type);
33
+ if (typeof build !== 'function') {
34
+ return emptyLabel;
35
+ }
36
+
37
+ const output = (build as (value: GenericWidget) => unknown)(widget);
38
+ if (output === null || output === undefined) {
39
+ return emptyLabel;
40
+ }
41
+
42
+ return output as ReactNode;
43
+ }
44
+
45
+ function containerBackgroundStyle(widget: GenericWidget): CSSProperties {
46
+ const background =
47
+ typeof widget.background === 'string' && widget.background.trim().length > 0
48
+ ? widget.background
49
+ : undefined;
50
+
51
+ return background ? { background } : {};
52
+ }
53
+
54
+ function layoutNodeStyle(
55
+ node: LayoutNodeResult,
56
+ parentOrigin: { readonly x: number; readonly y: number },
57
+ widget: GenericWidget,
58
+ ): CSSProperties {
59
+ return {
60
+ position: 'absolute',
61
+ left: node.rect.x - parentOrigin.x,
62
+ top: node.rect.y - parentOrigin.y,
63
+ width: node.rect.width,
64
+ height: node.rect.height,
65
+ boxSizing: 'border-box',
66
+ overflow: 'hidden',
67
+ ...containerBackgroundStyle(widget),
68
+ };
69
+ }
70
+
71
+ function renderLeafContent(widget: GenericWidget, options: CssRenderBackendOptions): ReactNode {
72
+ const { registry = BUILTIN_JDW_REGISTRY, emptyLabel = 'No render output.' } = options;
73
+
74
+ if (registry.has(widget.type)) {
75
+ return renderFromRegistry(registry, widget, emptyLabel);
76
+ }
77
+
78
+ return renderBuiltinWidgetLeaf(widget);
79
+ }
80
+
81
+ function renderLayoutNode(
82
+ node: LayoutNodeResult,
83
+ parentOrigin: { readonly x: number; readonly y: number },
84
+ options: CssRenderBackendOptions,
85
+ ): ReactNode {
86
+ const widget = node.widget;
87
+ const isLayoutContainer = LAYOUT_CONTAINER_TYPES.has(widget.type);
88
+ const leafContent = isLayoutContainer ? null : renderLeafContent(widget, options);
89
+
90
+ return createElement(
91
+ 'div',
92
+ {
93
+ 'data-layout-node': true,
94
+ 'data-widget-type': widget.type,
95
+ style: layoutNodeStyle(node, parentOrigin, widget),
96
+ },
97
+ leafContent,
98
+ ...node.children.map((child, index) =>
99
+ createElement(
100
+ 'div',
101
+ { key: index },
102
+ renderLayoutNode(child, { x: node.rect.x, y: node.rect.y }, options),
103
+ ),
104
+ ),
105
+ );
106
+ }
107
+
108
+ export function renderCssLayoutTree(
109
+ tree: LayoutNodeResult,
110
+ options: CssRenderBackendOptions = {},
111
+ ): ReactNode {
112
+ return createElement(
113
+ 'div',
114
+ {
115
+ 'data-css-render-root': true,
116
+ style: {
117
+ position: 'relative',
118
+ width: tree.rect.width,
119
+ height: tree.rect.height,
120
+ minHeight: readNumber(tree.widget.minHeight) ?? 24,
121
+ },
122
+ },
123
+ renderLayoutNode(tree, { x: tree.rect.x, y: tree.rect.y }, options),
124
+ );
125
+ }
126
+
127
+ export function renderJdwWithLayout(
128
+ node: JsonWidgetNode,
129
+ options: CssRenderBackendOptions = {},
130
+ ): ReactNode {
131
+ const widget = jdwNodeToGenericWidget(node);
132
+ const tree = layoutWidget(widget, options.layoutConstraints ?? DEFAULT_LAYOUT_CONSTRAINTS);
133
+ return renderCssLayoutTree(tree, options);
134
+ }
@@ -0,0 +1,38 @@
1
+ export const JDW_WIDGET_DOCUMENT_FILE_EXTENSION = '.jdw.json';
2
+ export const JDW_WIDGET_DOCUMENT_MIME = 'application/vnd.workbench-kit.jdw+json';
3
+ export const JDW_SCHEMA_DOCUMENT_FILE_EXTENSION = '.jdw.schema.json';
4
+ export const JDW_SCHEMA_DOCUMENT_MIME = 'application/vnd.workbench-kit.jdw-schema+json';
5
+
6
+ export const JDW_DOCUMENT_FILE_EXTENSION = JDW_WIDGET_DOCUMENT_FILE_EXTENSION;
7
+ export const JDW_DOCUMENT_MIME = JDW_WIDGET_DOCUMENT_MIME;
8
+
9
+ export interface JdwDocumentRef {
10
+ readonly mimeType?: string | undefined;
11
+ readonly path: string;
12
+ }
13
+
14
+ export type JdwSchemaDocumentRef = JdwDocumentRef;
15
+
16
+ export function isJdwDocumentPath(path: string): boolean {
17
+ return path.toLowerCase().endsWith(JDW_WIDGET_DOCUMENT_FILE_EXTENSION);
18
+ }
19
+
20
+ export function isJdwDocumentMimeType(mimeType: string | undefined): boolean {
21
+ return mimeType === JDW_WIDGET_DOCUMENT_MIME;
22
+ }
23
+
24
+ export function isJdwDocument(file: JdwDocumentRef): boolean {
25
+ return isJdwDocumentMimeType(file.mimeType) || isJdwDocumentPath(file.path);
26
+ }
27
+
28
+ export function isJdwSchemaDocumentPath(path: string): boolean {
29
+ return path.toLowerCase().endsWith(JDW_SCHEMA_DOCUMENT_FILE_EXTENSION);
30
+ }
31
+
32
+ export function isJdwSchemaDocumentMimeType(mimeType: string | undefined): boolean {
33
+ return mimeType === JDW_SCHEMA_DOCUMENT_MIME;
34
+ }
35
+
36
+ export function isJdwSchemaDocument(file: JdwSchemaDocumentRef): boolean {
37
+ return isJdwSchemaDocumentMimeType(file.mimeType) || isJdwSchemaDocumentPath(file.path);
38
+ }
@@ -0,0 +1,52 @@
1
+ export const JDW_FIXTURE_COLUMN_TEXT = `{
2
+ "type": "column",
3
+ "args": {
4
+ "gap": 12,
5
+ "padding": 16,
6
+ "children": [
7
+ { "type": "text", "args": { "text": "Hello JDW", "fontSize": 20 } },
8
+ { "type": "text", "args": { "text": "workbench-jdw-react-v1" } }
9
+ ]
10
+ }
11
+ }
12
+ `;
13
+
14
+ export const JDW_FIXTURE_ROW_FLEX = `{
15
+ "type": "row",
16
+ "args": {
17
+ "gap": 8,
18
+ "padding": 12,
19
+ "children": [
20
+ {
21
+ "type": "expanded",
22
+ "args": {
23
+ "flex": 1,
24
+ "child": { "type": "text", "args": { "text": "Left", "background": "#2b2f36" } }
25
+ }
26
+ },
27
+ {
28
+ "type": "expanded",
29
+ "args": {
30
+ "flex": 2,
31
+ "child": { "type": "text", "args": { "text": "Right (flex 2)", "background": "#353a42" } }
32
+ }
33
+ }
34
+ ]
35
+ }
36
+ }
37
+ `;
38
+
39
+ export const JDW_FIXTURE_GRID_CELLS = `{
40
+ "type": "grid",
41
+ "args": {
42
+ "columns": 2,
43
+ "gap": 8,
44
+ "padding": 12,
45
+ "children": [
46
+ { "type": "text", "args": { "text": "A", "col": 0, "row": 0 } },
47
+ { "type": "text", "args": { "text": "B", "col": 1, "row": 0 } },
48
+ { "type": "text", "args": { "text": "Wide", "col": 0, "row": 1, "colSpan": 2 } }
49
+ ]
50
+ }
51
+ }
52
+ `;