@workbench-kit/react 0.0.2-prototype.0.2.29 → 0.0.2-prototype.0.2.31

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workbench-kit/react",
3
- "version": "0.0.2-prototype.0.2.29",
3
+ "version": "0.0.2-prototype.0.2.31",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -73,15 +73,15 @@
73
73
  "@vscode/codicons": "^0.0.45",
74
74
  "remark-gfm": "^4.0.1",
75
75
  "rehype-sanitize": "^6.0.0",
76
- "@workbench-kit/contracts": "0.0.2-prototype.0.2.29",
77
- "@workbench-kit/monaco": "0.0.2-prototype.0.2.29",
78
- "@workbench-kit/adapters": "0.0.2-prototype.0.2.29",
79
- "@workbench-kit/runtime": "0.0.2-prototype.0.2.29",
80
- "@workbench-kit/jdw": "0.0.2-prototype.0.2.29",
81
- "@workbench-kit/services": "0.0.2-prototype.0.2.29",
82
- "@workbench-kit/tokens": "0.0.2-prototype.0.2.29",
83
- "@workbench-kit/platform": "0.0.2-prototype.0.2.29",
84
- "@workbench-kit/workspace": "0.0.2-prototype.0.2.29"
76
+ "@workbench-kit/adapters": "0.0.2-prototype.0.2.31",
77
+ "@workbench-kit/contracts": "0.0.2-prototype.0.2.31",
78
+ "@workbench-kit/jdw": "0.0.2-prototype.0.2.31",
79
+ "@workbench-kit/monaco": "0.0.2-prototype.0.2.31",
80
+ "@workbench-kit/platform": "0.0.2-prototype.0.2.31",
81
+ "@workbench-kit/runtime": "0.0.2-prototype.0.2.31",
82
+ "@workbench-kit/services": "0.0.2-prototype.0.2.31",
83
+ "@workbench-kit/tokens": "0.0.2-prototype.0.2.31",
84
+ "@workbench-kit/workspace": "0.0.2-prototype.0.2.31"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "react": "^19.0.0",
@@ -138,6 +138,20 @@ export function CommandManagementSidebar({
138
138
  focusCommandEntry(getNextEntryId(currentEntryId ?? activeEntryId, event.key));
139
139
  };
140
140
 
141
+ const renderCommandEntry = (entry: CommandManagementEntry) => (
142
+ <CommandSidebarListItem
143
+ key={entry.id}
144
+ active={entry.id === activeEntryId}
145
+ disabled={entry.status !== 'available' || !onRunCommand || lastRun?.status === 'running'}
146
+ entry={entry}
147
+ onActivate={() => setActiveEntryId(entry.id)}
148
+ onInspect={onInspectCommand}
149
+ onRun={() => {
150
+ void onRunCommand?.(entry.id);
151
+ }}
152
+ />
153
+ );
154
+
141
155
  return (
142
156
  <SideBarViewFrame
143
157
  actions={
@@ -199,21 +213,7 @@ export function CommandManagementSidebar({
199
213
  className={commandManagementListClassName}
200
214
  onKeyDown={handleListKeyDown}
201
215
  >
202
- {filteredGroups[0]?.entries.map((entry) => (
203
- <CommandSidebarListItem
204
- key={entry.id}
205
- active={entry.id === activeEntryId}
206
- disabled={
207
- entry.status !== 'available' || !onRunCommand || lastRun?.status === 'running'
208
- }
209
- entry={entry}
210
- onActivate={() => setActiveEntryId(entry.id)}
211
- onInspect={onInspectCommand}
212
- onRun={() => {
213
- void onRunCommand?.(entry.id);
214
- }}
215
- />
216
- ))}
216
+ {filteredGroups[0]?.entries.map(renderCommandEntry)}
217
217
  </SideBarList>
218
218
  ) : (
219
219
  <WorkbenchSidebarSectionStack
@@ -224,21 +224,7 @@ export function CommandManagementSidebar({
224
224
  className={commandManagementListClassName}
225
225
  onKeyDown={handleListKeyDown}
226
226
  >
227
- {group.entries.map((entry) => (
228
- <CommandSidebarListItem
229
- key={entry.id}
230
- active={entry.id === activeEntryId}
231
- disabled={
232
- entry.status !== 'available' || !onRunCommand || lastRun?.status === 'running'
233
- }
234
- entry={entry}
235
- onActivate={() => setActiveEntryId(entry.id)}
236
- onInspect={onInspectCommand}
237
- onRun={() => {
238
- void onRunCommand?.(entry.id);
239
- }}
240
- />
241
- ))}
227
+ {group.entries.map(renderCommandEntry)}
242
228
  </SideBarList>
243
229
  ),
244
230
  id: `command-group-${group.id}`,
@@ -219,56 +219,16 @@ function renderResizeHandle(
219
219
  );
220
220
  }
221
221
 
222
- const nodeRendererRegistry: Record<string, (params: NodeRendererProps) => ReactNode> = {
223
- frame: ({
224
- node,
225
- style,
226
- children,
227
- onClick,
228
- onPointerDown,
229
- onResizeHandlePointerDown,
230
- resizeHandleLabel,
231
- }) => (
232
- <div
233
- key={node.id}
234
- data-node-id={node.id}
235
- style={style}
236
- onClick={onClick}
237
- onPointerDown={onPointerDown}
238
- >
239
- <div style={{ position: 'relative', width: '100%', height: '100%' }}>{children}</div>
240
- {renderResizeHandle(resizeHandleLabel, onResizeHandlePointerDown)}
241
- </div>
242
- ),
243
- group: ({
244
- node,
245
- style,
246
- children,
247
- onClick,
248
- onPointerDown,
249
- onResizeHandlePointerDown,
250
- resizeHandleLabel,
251
- }) => (
252
- <div
253
- key={node.id}
254
- data-node-id={node.id}
255
- style={style}
256
- onClick={onClick}
257
- onPointerDown={onPointerDown}
258
- >
259
- <div style={{ position: 'relative', width: '100%', height: '100%' }}>{children}</div>
260
- {renderResizeHandle(resizeHandleLabel, onResizeHandlePointerDown)}
261
- </div>
262
- ),
263
- component: ({
264
- node,
265
- style,
266
- children,
267
- onClick,
268
- onPointerDown,
269
- onResizeHandlePointerDown,
270
- resizeHandleLabel,
271
- }) => (
222
+ function renderContainerNode({
223
+ node,
224
+ style,
225
+ children,
226
+ onClick,
227
+ onPointerDown,
228
+ onResizeHandlePointerDown,
229
+ resizeHandleLabel,
230
+ }: NodeRendererProps) {
231
+ return (
272
232
  <div
273
233
  key={node.id}
274
234
  data-node-id={node.id}
@@ -279,35 +239,39 @@ const nodeRendererRegistry: Record<string, (params: NodeRendererProps) => ReactN
279
239
  <div style={{ position: 'relative', width: '100%', height: '100%' }}>{children}</div>
280
240
  {renderResizeHandle(resizeHandleLabel, onResizeHandlePointerDown)}
281
241
  </div>
282
- ),
283
- instance: ({
284
- node,
285
- style,
286
- children,
287
- onClick,
288
- onPointerDown,
289
- onResizeHandlePointerDown,
290
- resizeHandleLabel,
291
- }) => (
242
+ );
243
+ }
244
+
245
+ function renderEmptyNode({
246
+ node,
247
+ style,
248
+ onClick,
249
+ onPointerDown,
250
+ onResizeHandlePointerDown,
251
+ resizeHandleLabel,
252
+ }: NodeRendererProps) {
253
+ return (
292
254
  <div
293
255
  key={node.id}
294
256
  data-node-id={node.id}
295
257
  style={style}
296
- onClick={onClick}
258
+ onClick={wrapNodeClick(onClick)}
297
259
  onPointerDown={onPointerDown}
298
260
  >
299
- <div style={{ position: 'relative', width: '100%', height: '100%' }}>{children}</div>
300
261
  {renderResizeHandle(resizeHandleLabel, onResizeHandlePointerDown)}
301
262
  </div>
302
- ),
303
- rectangle: ({
304
- node,
305
- style,
306
- onClick,
307
- onPointerDown,
308
- onResizeHandlePointerDown,
309
- resizeHandleLabel,
310
- }) => (
263
+ );
264
+ }
265
+
266
+ function renderContentNode({
267
+ node,
268
+ style,
269
+ onClick,
270
+ onPointerDown,
271
+ onResizeHandlePointerDown,
272
+ resizeHandleLabel,
273
+ }: NodeRendererProps) {
274
+ return (
311
275
  <div
312
276
  key={node.id}
313
277
  data-node-id={node.id}
@@ -315,9 +279,18 @@ const nodeRendererRegistry: Record<string, (params: NodeRendererProps) => ReactN
315
279
  onClick={wrapNodeClick(onClick)}
316
280
  onPointerDown={onPointerDown}
317
281
  >
282
+ {(node as { content?: string }).content ?? ''}
318
283
  {renderResizeHandle(resizeHandleLabel, onResizeHandlePointerDown)}
319
284
  </div>
320
- ),
285
+ );
286
+ }
287
+
288
+ const nodeRendererRegistry: Record<string, (params: NodeRendererProps) => ReactNode> = {
289
+ frame: renderContainerNode,
290
+ group: renderContainerNode,
291
+ component: renderContainerNode,
292
+ instance: renderContainerNode,
293
+ rectangle: renderEmptyNode,
321
294
  circle: ({
322
295
  node,
323
296
  style,
@@ -336,18 +309,7 @@ const nodeRendererRegistry: Record<string, (params: NodeRendererProps) => ReactN
336
309
  {renderResizeHandle(resizeHandleLabel, onResizeHandlePointerDown)}
337
310
  </div>
338
311
  ),
339
- text: ({ node, style, onClick, onPointerDown, onResizeHandlePointerDown, resizeHandleLabel }) => (
340
- <div
341
- key={node.id}
342
- data-node-id={node.id}
343
- style={style}
344
- onClick={wrapNodeClick(onClick)}
345
- onPointerDown={onPointerDown}
346
- >
347
- {(node as { content?: string }).content ?? ''}
348
- {renderResizeHandle(resizeHandleLabel, onResizeHandlePointerDown)}
349
- </div>
350
- ),
312
+ text: renderContentNode,
351
313
  image: ({
352
314
  node,
353
315
  style,
@@ -394,43 +356,8 @@ const nodeRendererRegistry: Record<string, (params: NodeRendererProps) => ReactN
394
356
  </div>
395
357
  );
396
358
  },
397
- vector: ({
398
- node,
399
- style,
400
- onClick,
401
- onPointerDown,
402
- onResizeHandlePointerDown,
403
- resizeHandleLabel,
404
- }) => (
405
- <div
406
- key={node.id}
407
- data-node-id={node.id}
408
- style={style}
409
- onClick={wrapNodeClick(onClick)}
410
- onPointerDown={onPointerDown}
411
- >
412
- {(node as { content?: string }).content ?? ''}
413
- {renderResizeHandle(resizeHandleLabel, onResizeHandlePointerDown)}
414
- </div>
415
- ),
416
- unknown: ({
417
- node,
418
- style,
419
- onClick,
420
- onPointerDown,
421
- onResizeHandlePointerDown,
422
- resizeHandleLabel,
423
- }) => (
424
- <div
425
- key={node.id}
426
- data-node-id={node.id}
427
- style={style}
428
- onClick={wrapNodeClick(onClick)}
429
- onPointerDown={onPointerDown}
430
- >
431
- {renderResizeHandle(resizeHandleLabel, onResizeHandlePointerDown)}
432
- </div>
433
- ),
359
+ vector: renderContentNode,
360
+ unknown: renderEmptyNode,
434
361
  };
435
362
 
436
363
  function renderNode(
@@ -391,6 +391,15 @@ export function WorkbenchStandaloneShell<
391
391
  }),
392
392
  );
393
393
  };
394
+ const togglePrimarySidebar = () => {
395
+ const nextSidebarVisible = !isPrimarySidebarVisible;
396
+ setPrimarySidebarLifecycle(
397
+ activeActivityId,
398
+ nextSidebarVisible,
399
+ nextSidebarVisible ? 'sidebar-show' : 'sidebar-hide',
400
+ );
401
+ shell.togglePrimarySidebar();
402
+ };
394
403
  const createContext = ({
395
404
  activityId,
396
405
  shell,
@@ -403,15 +412,7 @@ export function WorkbenchStandaloneShell<
403
412
  isPrimarySidebarVisible,
404
413
  openSettings: shell.openSettings,
405
414
  showActivity,
406
- togglePrimarySidebar: () => {
407
- const nextSidebarVisible = !isPrimarySidebarVisible;
408
- setPrimarySidebarLifecycle(
409
- activeActivityId,
410
- nextSidebarVisible,
411
- nextSidebarVisible ? 'sidebar-show' : 'sidebar-hide',
412
- );
413
- shell.togglePrimarySidebar();
414
- },
415
+ togglePrimarySidebar,
415
416
  },
416
417
  isPrimarySidebarVisible,
417
418
  isSettingsOpen,
@@ -430,15 +431,7 @@ export function WorkbenchStandaloneShell<
430
431
  );
431
432
  shell.setPrimarySidebarVisible(isVisible);
432
433
  },
433
- togglePrimarySidebar: () => {
434
- const nextSidebarVisible = !isPrimarySidebarVisible;
435
- setPrimarySidebarLifecycle(
436
- activeActivityId,
437
- nextSidebarVisible,
438
- nextSidebarVisible ? 'sidebar-show' : 'sidebar-hide',
439
- );
440
- shell.togglePrimarySidebar();
441
- },
434
+ togglePrimarySidebar,
442
435
  openSettings: shell.openSettings,
443
436
  closeSettings: shell.closeSettings,
444
437
  setSettingsCategoryId: shell.setSettingsCategoryId,
@@ -1,57 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import { createElement } from 'react';
3
-
4
- export interface MockWorkbenchMonacoEditorProps {
5
- language?: string;
6
- onChange?: (value?: string) => void;
7
- path?: string;
8
- theme?: string;
9
- value?: string;
10
- }
11
-
12
- export interface MockWorkbenchMonacoDiffEditorProps {
13
- language?: string;
14
- modified?: string;
15
- onModifiedChange?: (value: string) => void;
16
- original?: string;
17
- readOnly?: boolean;
18
- theme?: string;
19
- }
20
-
21
- export function createWorkbenchMonacoMockModule(
22
- renderEditor?: (props: MockWorkbenchMonacoEditorProps) => ReactNode,
23
- ) {
24
- const defaultRender = ({ value }: MockWorkbenchMonacoEditorProps) =>
25
- createElement('div', { 'data-testid': 'monaco-editor' }, value ?? 'Mocked Monaco Editor');
26
-
27
- const defaultDiffRender = ({ modified, original }: MockWorkbenchMonacoDiffEditorProps) =>
28
- createElement(
29
- 'div',
30
- { 'data-testid': 'monaco-diff-editor' },
31
- original ?? '',
32
- '\n---\n',
33
- modified ?? '',
34
- );
35
-
36
- return {
37
- WorkbenchMonacoEditor: renderEditor ?? defaultRender,
38
- WorkbenchMonacoDiffEditor: defaultDiffRender,
39
- DiffEditor: defaultDiffRender,
40
- useMonacoWorkbenchThemeSync: () => undefined,
41
- prepareMonacoWorkbenchEditor: () => undefined,
42
- monacoThemeForWorkspaceTheme: (theme: string) =>
43
- theme === 'light' ? 'workbench-kit-light' : 'workbench-kit-dark',
44
- MONACO_DARK_THEME_ID: 'workbench-kit-dark',
45
- MONACO_LIGHT_THEME_ID: 'workbench-kit-light',
46
- monaco: {
47
- KeyMod: { CtrlCmd: 1 },
48
- KeyCode: { KeyS: 1 },
49
- editor: {
50
- defineTheme: () => undefined,
51
- setTheme: () => undefined,
52
- onDidChangeMarkers: () => ({ dispose: () => undefined }),
53
- getModelMarkers: () => [],
54
- },
55
- },
56
- };
57
- }