@workbench-kit/shell-react 0.0.2-prototype.0.2.6 → 0.0.2-prototype.0.2.8

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 (95) hide show
  1. package/README.md +41 -0
  2. package/package.json +9 -9
  3. package/src/{chat-ai-mock-proposals.ts → chat/ai-mock-proposals.ts} +39 -39
  4. package/src/{chat-command-input.ts → chat/command-input.ts} +52 -52
  5. package/src/{chat-command-policy.ts → chat/command-policy.ts} +54 -54
  6. package/src/{chat-command-surface.tsx → chat/command-surface.tsx} +155 -155
  7. package/src/{use-workbench-chat-command-proposals.ts → chat/use-chat-command-proposals.ts} +194 -194
  8. package/src/{chat-view-data.ts → chat/view-data.ts} +20 -20
  9. package/src/{chat-view.tsx → chat/view.tsx} +220 -220
  10. package/src/{command-inspector-surface.tsx → commands/inspector-surface.tsx} +46 -46
  11. package/src/{use-workbench-command-descriptors.ts → commands/use-command-descriptors.ts} +41 -41
  12. package/src/{use-context-key-revision.ts → commands/use-context-key-revision.ts} +18 -18
  13. package/src/{commands-view-data.ts → commands/view-data.ts} +17 -17
  14. package/src/{commands-view.tsx → commands/view.tsx} +43 -43
  15. package/src/devtools/WorkbenchDevtoolsPanel.tsx +124 -124
  16. package/src/devtools/WorkbenchDevtoolsShell.tsx +17 -17
  17. package/src/devtools/index.ts +11 -11
  18. package/src/devtools/use-workbench-devtools-snapshot.ts +84 -84
  19. package/src/devtools/workbench-devtools-snapshot.ts +140 -140
  20. package/src/devtools/workbench-devtools.css +82 -82
  21. package/src/{editor-area-dnd.ts → editor/area-dnd.ts} +69 -69
  22. package/src/{editor-area-model.ts → editor/area-model.ts} +71 -71
  23. package/src/{editor-area.css → editor/area.css} +454 -454
  24. package/src/{editor-area.tsx → editor/area.tsx} +676 -676
  25. package/src/{editor-host-surface.tsx → editor/host-surface.tsx} +631 -634
  26. package/src/{editor-pane-visibility.ts → editor/pane-visibility.ts} +130 -130
  27. package/src/{editor-resource.ts → editor/resource.ts} +36 -36
  28. package/src/{editor-state-storage.ts → editor/state-storage.ts} +182 -193
  29. package/src/{editor-tab-context-menu.ts → editor/tab-context-menu.ts} +118 -118
  30. package/src/{use-editor.ts → editor/use-editor.ts} +114 -107
  31. package/src/{editor-view-providers.tsx → editor/view-providers.tsx} +552 -552
  32. package/src/{editor-workspace-file-availability.ts → editor/workspace-file-availability.ts} +15 -15
  33. package/src/{editor-workspace-reconcile.tsx → editor/workspace-reconcile.tsx} +31 -28
  34. package/src/{explorer-context-menu.ts → explorer/context-menu.ts} +114 -114
  35. package/src/{createCommandWorkspaceExplorerPort.ts → explorer/create-command-workspace-explorer-port.ts} +86 -86
  36. package/src/{explorer-reveal.ts → explorer/reveal.ts} +112 -112
  37. package/src/{search-view-data.ts → explorer/search-view-data.ts} +15 -15
  38. package/src/{search-view.tsx → explorer/search-view.tsx} +65 -62
  39. package/src/{use-active-workspace-path.ts → explorer/use-active-workspace-path.ts} +15 -15
  40. package/src/{explorer-view-data.ts → explorer/view-data.ts} +58 -58
  41. package/src/{explorer-view.tsx → explorer/view.tsx} +227 -224
  42. package/src/{extension-context-menu.ts → extensions/context-menu.ts} +52 -52
  43. package/src/{extension-management-model.ts → extensions/management-model.ts} +313 -313
  44. package/src/{use-extension-management.ts → extensions/use-extension-management.ts} +241 -193
  45. package/src/{extensions-view-data.ts → extensions/view-data.ts} +19 -19
  46. package/src/{extensions-view.tsx → extensions/view.tsx} +63 -38
  47. package/src/{field-remap-demo.tsx → field-remap/demo.tsx} +18 -18
  48. package/src/{field-remap-editor-surface.tsx → field-remap/editor-surface.tsx} +36 -36
  49. package/src/{field-remap-flow-adapter.ts → field-remap/flow-adapter.ts} +240 -240
  50. package/src/{field-remap-flow.tsx → field-remap/flow.tsx} +369 -369
  51. package/src/{field-remap-graph.tsx → field-remap/graph.tsx} +559 -559
  52. package/src/field-remap/jsonata-transform.ts +166 -0
  53. package/src/{field-remap-panel.tsx → field-remap/panel.tsx} +193 -175
  54. package/src/{field-remap-samples.ts → field-remap/samples.ts} +352 -352
  55. package/src/{table-mapping-adapter.ts → field-remap/table-mapping-adapter.ts} +59 -59
  56. package/src/{field-remap-tree.tsx → field-remap/tree.tsx} +404 -404
  57. package/src/{field-remap-view-data.ts → field-remap/view-data.ts} +16 -16
  58. package/src/{field-remap-view.css → field-remap/view.css} +676 -676
  59. package/src/{field-remap-view.tsx → field-remap/view.tsx} +86 -86
  60. package/src/index.ts +212 -199
  61. package/src/{json-form-source-patch.ts → jdw/json-form-source-patch.ts} +323 -323
  62. package/src/{jdw-lab-view-data.ts → jdw/lab-view-data.ts} +25 -25
  63. package/src/{jdw-lab-view.css → jdw/lab-view.css} +21 -21
  64. package/src/{jdw-lab-view.tsx → jdw/lab-view.tsx} +79 -79
  65. package/src/{jdw-widget-form-view.tsx → jdw/widget-form-view.tsx} +68 -65
  66. package/src/{jdw-widget-preview-view.tsx → jdw/widget-preview-view.tsx} +54 -51
  67. package/src/{keybinding-overrides-storage.ts → management/keybinding-overrides-storage.ts} +49 -57
  68. package/src/{keybinding-management-settings.tsx → management/keybinding-settings.tsx} +16 -16
  69. package/src/{management-palette-commands.ts → management/palette-commands.ts} +38 -38
  70. package/src/{preference-settings-storage.ts → management/preference-settings-storage.ts} +50 -58
  71. package/src/{management-settings-ids.ts → management/settings-ids.ts} +12 -12
  72. package/src/{management-settings.tsx → management/settings.tsx} +96 -75
  73. package/src/{use-command-management.ts → management/use-command-management.ts} +191 -191
  74. package/src/{use-keybinding-management.ts → management/use-keybinding-management.ts} +130 -130
  75. package/src/{shell-model.tsx → shell/model.tsx} +149 -149
  76. package/src/{provider.tsx → shell/provider.tsx} +603 -573
  77. package/src/{shell-secondary-actions.tsx → shell/secondary-actions.tsx} +59 -59
  78. package/src/{shell-settings-constants.ts → shell/settings-constants.ts} +9 -9
  79. package/src/{shell-settings.tsx → shell/settings.tsx} +599 -599
  80. package/src/{shell.tsx → shell/shell.tsx} +680 -649
  81. package/src/{shell-titlebar-layout-controls.tsx → shell/titlebar-layout-controls.tsx} +4 -4
  82. package/src/{shell-view-host.tsx → shell/view-host.tsx} +212 -199
  83. package/src/{workbench-appearance-storage.ts → workbench/appearance-storage.ts} +107 -115
  84. package/src/{workbench-command-host.tsx → workbench/command-host.tsx} +243 -243
  85. package/src/{workbench-command-palette.ts → workbench/command-palette.ts} +208 -208
  86. package/src/{workbench-keybinding-bridge.ts → workbench/keybinding-bridge.ts} +54 -54
  87. package/src/{workbench-layout-storage.ts → workbench/layout-storage.ts} +134 -145
  88. package/src/{workbench-profile-modal.tsx → workbench/profile-modal.tsx} +118 -118
  89. package/src/{workbench-shell-command-registration.ts → workbench/shell-command-registration.ts} +58 -58
  90. package/src/{workbench-startup-gate.tsx → workbench/startup-gate.tsx} +136 -136
  91. package/src/{workbench-status-sections.ts → workbench/status-sections.ts} +43 -43
  92. package/src/{use-persisted-workbench-appearance.ts → workbench/use-persisted-appearance.ts} +33 -33
  93. package/src/{workbench-user-commands.ts → workbench/user-commands.ts} +46 -46
  94. package/src/{workspace-view-state.ts → workbench/workspace-view-state.ts} +35 -35
  95. package/src/jsonata-transform.ts +0 -36
@@ -1,224 +1,227 @@
1
- import {
2
- useCallback,
3
- useEffect,
4
- useMemo,
5
- useRef,
6
- useState,
7
- type MouseEvent as ReactMouseEvent,
8
- } from 'react';
9
- import { ContextMenu, type ContextMenuItem } from '@workbench-kit/react/overlay';
10
- import { ViewEmptyState } from '@workbench-kit/react/primitives';
11
- import {
12
- WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID,
13
- WORKBENCH_WORKSPACE_DELETE_COMMAND_ID,
14
- WORKBENCH_WORKSPACE_OPEN_COMMAND_ID,
15
- } from '@workbench-kit/react/workbench/commands';
16
- import {
17
- WorkspaceExplorerPanel,
18
- buildWorkspaceExplorerNodes,
19
- resolveWorkspaceExplorerSectionTitle,
20
- useWorkspaceExplorerController,
21
- } from '@workbench-kit/react/workbench/workspace';
22
- import { type WorkspaceExplorerItemContextMenuMeta } from '@workbench-kit/react/workbench/workspace/explorer';
23
- import { resolveWorkspaceCreateParentPath, type WorkspaceTreeNode } from '@workbench-kit/workspace';
24
- import { createCommandWorkspaceExplorerPort } from './createCommandWorkspaceExplorerPort.js';
25
- import { createExplorerItemContextMenuItems } from './explorer-context-menu.js';
26
- import { applyExplorerPathReveal, subscribeExplorerRevealRequest } from './explorer-reveal.js';
27
- import {
28
- BUILTIN_EXPLORER_REFRESH_COMMAND_ID,
29
- type BuiltinExplorerViewRenderData,
30
- } from './explorer-view-data.js';
31
- import { useWorkbench } from './provider.js';
32
- import { useActiveWorkspacePath } from './use-active-workspace-path.js';
33
- import { useActiveEditorTab } from './use-editor.js';
34
- import { isWorkspaceResourceService, useWorkspaceResourceState } from './workspace-view-state.js';
35
-
36
- export type { BuiltinExplorerViewRenderData };
37
- export {
38
- BUILTIN_EXPLORER_MOVE_COMMAND_ID,
39
- BUILTIN_EXPLORER_REFRESH_COMMAND_ID,
40
- BUILTIN_EXPLORER_VIEW_RENDER_KIND,
41
- isBuiltinExplorerViewRenderData,
42
- } from './explorer-view-data.js';
43
-
44
- interface ExplorerContextMenuState {
45
- readonly ariaLabel: string;
46
- readonly items: ContextMenuItem[];
47
- readonly x: number;
48
- readonly y: number;
49
- }
50
-
51
- export function BuiltinExplorerView() {
52
- const { executeCommand, extensionRegistry, workspaceHostPort } = useWorkbench();
53
- const activeTab = useActiveEditorTab();
54
- const workspaceService = isWorkspaceResourceService(workspaceHostPort?.service)
55
- ? workspaceHostPort.service
56
- : undefined;
57
- const workspaceState = useWorkspaceResourceState(workspaceService);
58
- const [contextMenu, setContextMenu] = useState<ExplorerContextMenuState | null>(null);
59
- const [seededExpandedPaths, setSeededExpandedPaths] = useState(false);
60
-
61
- const activePath = useActiveWorkspacePath(activeTab?.resourceUri);
62
-
63
- const port = useMemo(
64
- () =>
65
- createCommandWorkspaceExplorerPort({
66
- executeCommand,
67
- workspaceState,
68
- }),
69
- [executeCommand, workspaceState],
70
- );
71
-
72
- const explorer = useWorkspaceExplorerController({
73
- activePath,
74
- initialExpandedPaths: workspaceState?.expandedPaths,
75
- port,
76
- });
77
- const explorerRef = useRef(explorer);
78
- explorerRef.current = explorer;
79
-
80
- useEffect(() => {
81
- if (!workspaceState || seededExpandedPaths) {
82
- return;
83
- }
84
-
85
- workspaceState.expandedPaths.forEach((path) => {
86
- explorer.revealFolder(path);
87
- });
88
- setSeededExpandedPaths(true);
89
- }, [explorer, seededExpandedPaths, workspaceState]);
90
-
91
- useEffect(
92
- () =>
93
- subscribeExplorerRevealRequest((path) => {
94
- const currentExplorer = explorerRef.current;
95
- applyExplorerPathReveal(path, {
96
- revealFolder: currentExplorer.revealFolder,
97
- setSelection: (selection) => {
98
- currentExplorer.handleSelectionChange(selection, { mode: 'single', reason: 'click' });
99
- },
100
- });
101
- }),
102
- [],
103
- );
104
-
105
- const nodes = useMemo(
106
- () =>
107
- buildWorkspaceExplorerNodes({
108
- files: workspaceState?.files ?? [],
109
- folders: workspaceState?.folders ?? [],
110
- }),
111
- [workspaceState],
112
- );
113
-
114
- const sectionTitle = useMemo(
115
- () => resolveWorkspaceExplorerSectionTitle(workspaceState?.files ?? []),
116
- [workspaceState?.files],
117
- );
118
-
119
- const createParentPath = useMemo(
120
- () =>
121
- resolveWorkspaceCreateParentPath(
122
- explorer.selection.focusedPath,
123
- workspaceState?.folders ?? [],
124
- ),
125
- [explorer.selection.focusedPath, workspaceState?.folders],
126
- );
127
-
128
- const executeWorkspaceCommand = useCallback(
129
- async (commandId: string, payload?: unknown) => {
130
- await executeCommand(commandId, payload);
131
- },
132
- [executeCommand],
133
- );
134
-
135
- const handleItemContextMenu = useCallback(
136
- (
137
- event: ReactMouseEvent<HTMLButtonElement>,
138
- node: WorkspaceTreeNode,
139
- meta: WorkspaceExplorerItemContextMenuMeta,
140
- ) => {
141
- event.preventDefault();
142
- setContextMenu({
143
- ariaLabel: `${node.name} menu`,
144
- items: createExplorerItemContextMenuItems({
145
- actionPaths: meta.actionPaths,
146
- copyPaths: (paths) => {
147
- void executeWorkspaceCommand(WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID, { paths });
148
- },
149
- createFile: (parentPath) => explorer.startCreate('create-file', parentPath),
150
- createFolder: (parentPath) => explorer.startCreate('create-folder', parentPath),
151
- deleteTargets: (paths) => {
152
- void executeWorkspaceCommand(WORKBENCH_WORKSPACE_DELETE_COMMAND_ID, {
153
- kind: node.type,
154
- paths,
155
- });
156
- },
157
- executeExtensionCommand: (commandId) => executeCommand(commandId),
158
- extensionRegistry,
159
- files: workspaceState?.files ?? [],
160
- node,
161
- openFiles: (paths) => {
162
- void executeWorkspaceCommand(WORKBENCH_WORKSPACE_OPEN_COMMAND_ID, {
163
- kind: 'file',
164
- paths,
165
- });
166
- },
167
- revealFolder: explorer.revealFolder,
168
- renameTarget: () => explorer.startRename(node, meta.actionPaths),
169
- }),
170
- x: event.clientX,
171
- y: event.clientY,
172
- });
173
- },
174
- [executeWorkspaceCommand, explorer, workspaceState?.files],
175
- );
176
-
177
- if (!workspaceService || !workspaceState) {
178
- return (
179
- <ViewEmptyState className="workbench-explorer-view">
180
- No virtual workspace is registered.
181
- </ViewEmptyState>
182
- );
183
- }
184
-
185
- return (
186
- <>
187
- <WorkspaceExplorerPanel
188
- activePath={activePath}
189
- aria-label="Workspace Explorer"
190
- expandedPaths={explorer.expandedPaths}
191
- focusedPath={explorer.selection.focusedPath}
192
- inlineEdit={explorer.inlineEdit}
193
- nodes={nodes}
194
- onNewFile={() => explorer.startCreate('create-file', createParentPath)}
195
- onNewFolder={() => explorer.startCreate('create-folder', createParentPath)}
196
- onRefresh={() => {
197
- void executeWorkspaceCommand(BUILTIN_EXPLORER_REFRESH_COMMAND_ID);
198
- }}
199
- sectionTitle={sectionTitle}
200
- selectedPaths={explorer.selection.paths}
201
- selectionAnchorPath={explorer.selection.anchorPath}
202
- onActivateFile={explorer.handleActivateFile}
203
- onItemContextMenu={handleItemContextMenu}
204
- onInlineEditCancel={explorer.cancelInlineEdit}
205
- onInlineEditCommit={explorer.handleInlineEditCommit}
206
- onInlineEditValueChange={explorer.handleInlineEditValueChange}
207
- onRequestDelete={explorer.handleRequestDelete}
208
- onRequestMove={explorer.handleRequestMove}
209
- onRequestRename={explorer.handleRequestRename}
210
- onSelectionChange={explorer.handleSelectionChange}
211
- onToggleFolder={explorer.handleToggleFolder}
212
- />
213
- {contextMenu ? (
214
- <ContextMenu
215
- ariaLabel={contextMenu.ariaLabel}
216
- items={contextMenu.items}
217
- x={contextMenu.x}
218
- y={contextMenu.y}
219
- onClose={() => setContextMenu(null)}
220
- />
221
- ) : null}
222
- </>
223
- );
224
- }
1
+ import {
2
+ useCallback,
3
+ useEffect,
4
+ useMemo,
5
+ useRef,
6
+ useState,
7
+ type MouseEvent as ReactMouseEvent,
8
+ } from 'react';
9
+ import { ContextMenu, type ContextMenuItem } from '@workbench-kit/react/overlay';
10
+ import { ViewEmptyState } from '@workbench-kit/react/primitives';
11
+ import {
12
+ WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID,
13
+ WORKBENCH_WORKSPACE_DELETE_COMMAND_ID,
14
+ WORKBENCH_WORKSPACE_OPEN_COMMAND_ID,
15
+ } from '@workbench-kit/react/workbench/commands';
16
+ import {
17
+ WorkspaceExplorerPanel,
18
+ buildWorkspaceExplorerNodes,
19
+ resolveWorkspaceExplorerSectionTitle,
20
+ useWorkspaceExplorerController,
21
+ } from '@workbench-kit/react/workbench/workspace';
22
+ import { type WorkspaceExplorerItemContextMenuMeta } from '@workbench-kit/react/workbench/workspace/explorer';
23
+ import { resolveWorkspaceCreateParentPath, type WorkspaceTreeNode } from '@workbench-kit/workspace';
24
+ import { createCommandWorkspaceExplorerPort } from './create-command-workspace-explorer-port.js';
25
+ import { createExplorerItemContextMenuItems } from './context-menu.js';
26
+ import { applyExplorerPathReveal, subscribeExplorerRevealRequest } from './reveal.js';
27
+ import {
28
+ BUILTIN_EXPLORER_REFRESH_COMMAND_ID,
29
+ type BuiltinExplorerViewRenderData,
30
+ } from './view-data.js';
31
+ import { useWorkbench } from '../shell/provider.js';
32
+ import { useActiveWorkspacePath } from './use-active-workspace-path.js';
33
+ import { useActiveEditorTab } from '../editor/use-editor.js';
34
+ import {
35
+ isWorkspaceResourceService,
36
+ useWorkspaceResourceState,
37
+ } from '../workbench/workspace-view-state.js';
38
+
39
+ export type { BuiltinExplorerViewRenderData };
40
+ export {
41
+ BUILTIN_EXPLORER_MOVE_COMMAND_ID,
42
+ BUILTIN_EXPLORER_REFRESH_COMMAND_ID,
43
+ BUILTIN_EXPLORER_VIEW_RENDER_KIND,
44
+ isBuiltinExplorerViewRenderData,
45
+ } from './view-data.js';
46
+
47
+ interface ExplorerContextMenuState {
48
+ readonly ariaLabel: string;
49
+ readonly items: ContextMenuItem[];
50
+ readonly x: number;
51
+ readonly y: number;
52
+ }
53
+
54
+ export function BuiltinExplorerView() {
55
+ const { executeCommand, extensionRegistry, workspaceHostPort } = useWorkbench();
56
+ const activeTab = useActiveEditorTab();
57
+ const workspaceService = isWorkspaceResourceService(workspaceHostPort?.service)
58
+ ? workspaceHostPort.service
59
+ : undefined;
60
+ const workspaceState = useWorkspaceResourceState(workspaceService);
61
+ const [contextMenu, setContextMenu] = useState<ExplorerContextMenuState | null>(null);
62
+ const [seededExpandedPaths, setSeededExpandedPaths] = useState(false);
63
+
64
+ const activePath = useActiveWorkspacePath(activeTab?.resourceUri);
65
+
66
+ const port = useMemo(
67
+ () =>
68
+ createCommandWorkspaceExplorerPort({
69
+ executeCommand,
70
+ workspaceState,
71
+ }),
72
+ [executeCommand, workspaceState],
73
+ );
74
+
75
+ const explorer = useWorkspaceExplorerController({
76
+ activePath,
77
+ initialExpandedPaths: workspaceState?.expandedPaths,
78
+ port,
79
+ });
80
+ const explorerRef = useRef(explorer);
81
+ explorerRef.current = explorer;
82
+
83
+ useEffect(() => {
84
+ if (!workspaceState || seededExpandedPaths) {
85
+ return;
86
+ }
87
+
88
+ workspaceState.expandedPaths.forEach((path) => {
89
+ explorer.revealFolder(path);
90
+ });
91
+ setSeededExpandedPaths(true);
92
+ }, [explorer, seededExpandedPaths, workspaceState]);
93
+
94
+ useEffect(
95
+ () =>
96
+ subscribeExplorerRevealRequest((path) => {
97
+ const currentExplorer = explorerRef.current;
98
+ applyExplorerPathReveal(path, {
99
+ revealFolder: currentExplorer.revealFolder,
100
+ setSelection: (selection) => {
101
+ currentExplorer.handleSelectionChange(selection, { mode: 'single', reason: 'click' });
102
+ },
103
+ });
104
+ }),
105
+ [],
106
+ );
107
+
108
+ const nodes = useMemo(
109
+ () =>
110
+ buildWorkspaceExplorerNodes({
111
+ files: workspaceState?.files ?? [],
112
+ folders: workspaceState?.folders ?? [],
113
+ }),
114
+ [workspaceState],
115
+ );
116
+
117
+ const sectionTitle = useMemo(
118
+ () => resolveWorkspaceExplorerSectionTitle(workspaceState?.files ?? []),
119
+ [workspaceState?.files],
120
+ );
121
+
122
+ const createParentPath = useMemo(
123
+ () =>
124
+ resolveWorkspaceCreateParentPath(
125
+ explorer.selection.focusedPath,
126
+ workspaceState?.folders ?? [],
127
+ ),
128
+ [explorer.selection.focusedPath, workspaceState?.folders],
129
+ );
130
+
131
+ const executeWorkspaceCommand = useCallback(
132
+ async (commandId: string, payload?: unknown) => {
133
+ await executeCommand(commandId, payload);
134
+ },
135
+ [executeCommand],
136
+ );
137
+
138
+ const handleItemContextMenu = useCallback(
139
+ (
140
+ event: ReactMouseEvent<HTMLButtonElement>,
141
+ node: WorkspaceTreeNode,
142
+ meta: WorkspaceExplorerItemContextMenuMeta,
143
+ ) => {
144
+ event.preventDefault();
145
+ setContextMenu({
146
+ ariaLabel: `${node.name} menu`,
147
+ items: createExplorerItemContextMenuItems({
148
+ actionPaths: meta.actionPaths,
149
+ copyPaths: (paths) => {
150
+ void executeWorkspaceCommand(WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID, { paths });
151
+ },
152
+ createFile: (parentPath) => explorer.startCreate('create-file', parentPath),
153
+ createFolder: (parentPath) => explorer.startCreate('create-folder', parentPath),
154
+ deleteTargets: (paths) => {
155
+ void executeWorkspaceCommand(WORKBENCH_WORKSPACE_DELETE_COMMAND_ID, {
156
+ kind: node.type,
157
+ paths,
158
+ });
159
+ },
160
+ executeExtensionCommand: (commandId) => executeCommand(commandId),
161
+ extensionRegistry,
162
+ files: workspaceState?.files ?? [],
163
+ node,
164
+ openFiles: (paths) => {
165
+ void executeWorkspaceCommand(WORKBENCH_WORKSPACE_OPEN_COMMAND_ID, {
166
+ kind: 'file',
167
+ paths,
168
+ });
169
+ },
170
+ revealFolder: explorer.revealFolder,
171
+ renameTarget: () => explorer.startRename(node, meta.actionPaths),
172
+ }),
173
+ x: event.clientX,
174
+ y: event.clientY,
175
+ });
176
+ },
177
+ [executeWorkspaceCommand, explorer, workspaceState?.files],
178
+ );
179
+
180
+ if (!workspaceService || !workspaceState) {
181
+ return (
182
+ <ViewEmptyState className="workbench-explorer-view">
183
+ No virtual workspace is registered.
184
+ </ViewEmptyState>
185
+ );
186
+ }
187
+
188
+ return (
189
+ <>
190
+ <WorkspaceExplorerPanel
191
+ activePath={activePath}
192
+ aria-label="Workspace Explorer"
193
+ expandedPaths={explorer.expandedPaths}
194
+ focusedPath={explorer.selection.focusedPath}
195
+ inlineEdit={explorer.inlineEdit}
196
+ nodes={nodes}
197
+ onNewFile={() => explorer.startCreate('create-file', createParentPath)}
198
+ onNewFolder={() => explorer.startCreate('create-folder', createParentPath)}
199
+ onRefresh={() => {
200
+ void executeWorkspaceCommand(BUILTIN_EXPLORER_REFRESH_COMMAND_ID);
201
+ }}
202
+ sectionTitle={sectionTitle}
203
+ selectedPaths={explorer.selection.paths}
204
+ selectionAnchorPath={explorer.selection.anchorPath}
205
+ onActivateFile={explorer.handleActivateFile}
206
+ onItemContextMenu={handleItemContextMenu}
207
+ onInlineEditCancel={explorer.cancelInlineEdit}
208
+ onInlineEditCommit={explorer.handleInlineEditCommit}
209
+ onInlineEditValueChange={explorer.handleInlineEditValueChange}
210
+ onRequestDelete={explorer.handleRequestDelete}
211
+ onRequestMove={explorer.handleRequestMove}
212
+ onRequestRename={explorer.handleRequestRename}
213
+ onSelectionChange={explorer.handleSelectionChange}
214
+ onToggleFolder={explorer.handleToggleFolder}
215
+ />
216
+ {contextMenu ? (
217
+ <ContextMenu
218
+ ariaLabel={contextMenu.ariaLabel}
219
+ items={contextMenu.items}
220
+ x={contextMenu.x}
221
+ y={contextMenu.y}
222
+ onClose={() => setContextMenu(null)}
223
+ />
224
+ ) : null}
225
+ </>
226
+ );
227
+ }
@@ -1,52 +1,52 @@
1
- import type { ContextMenuItem } from '@workbench-kit/react/overlay';
2
- import { commandMenuItemsToContextMenuItems } from '@workbench-kit/react/workbench/commands';
3
- import {
4
- resolveWorkbenchMenuContributions,
5
- type ExtensionRegistry,
6
- } from '@workbench-kit/workbench-core';
7
-
8
- export interface ExtensionContextMenuInput {
9
- readonly contextKeys?: object | undefined;
10
- readonly executeCommand?: ((commandId: string) => unknown) | undefined;
11
- readonly extensionRegistry?: ExtensionRegistry | undefined;
12
- readonly menu: string;
13
- }
14
-
15
- export function createExtensionContextMenuItems({
16
- contextKeys,
17
- executeCommand,
18
- extensionRegistry,
19
- menu,
20
- }: ExtensionContextMenuInput): ContextMenuItem[] {
21
- if (!extensionRegistry || !executeCommand) {
22
- return [];
23
- }
24
-
25
- const menuItems = resolveWorkbenchMenuContributions({
26
- commandRegistry: extensionRegistry.commands,
27
- context: undefined,
28
- contextKeys,
29
- menu,
30
- menuItems: extensionRegistry.menus.getMenuItems(menu),
31
- });
32
-
33
- return commandMenuItemsToContextMenuItems([...menuItems], (commandId) => {
34
- void executeCommand(commandId);
35
- });
36
- }
37
-
38
- export function appendExtensionContextMenuItems(
39
- baseItems: readonly ContextMenuItem[],
40
- extensionItems: readonly ContextMenuItem[],
41
- separatorId: string,
42
- ): ContextMenuItem[] {
43
- if (extensionItems.length === 0) {
44
- return [...baseItems];
45
- }
46
-
47
- if (baseItems.length === 0) {
48
- return [...extensionItems];
49
- }
50
-
51
- return [...baseItems, { id: separatorId, type: 'separator' }, ...extensionItems];
52
- }
1
+ import type { ContextMenuItem } from '@workbench-kit/react/overlay';
2
+ import { commandMenuItemsToContextMenuItems } from '@workbench-kit/react/workbench/commands';
3
+ import {
4
+ resolveWorkbenchMenuContributions,
5
+ type ExtensionRegistry,
6
+ } from '@workbench-kit/workbench-core';
7
+
8
+ export interface ExtensionContextMenuInput {
9
+ readonly contextKeys?: object | undefined;
10
+ readonly executeCommand?: ((commandId: string) => unknown) | undefined;
11
+ readonly extensionRegistry?: ExtensionRegistry | undefined;
12
+ readonly menu: string;
13
+ }
14
+
15
+ export function createExtensionContextMenuItems({
16
+ contextKeys,
17
+ executeCommand,
18
+ extensionRegistry,
19
+ menu,
20
+ }: ExtensionContextMenuInput): ContextMenuItem[] {
21
+ if (!extensionRegistry || !executeCommand) {
22
+ return [];
23
+ }
24
+
25
+ const menuItems = resolveWorkbenchMenuContributions({
26
+ commandRegistry: extensionRegistry.commands,
27
+ context: undefined,
28
+ contextKeys,
29
+ menu,
30
+ menuItems: extensionRegistry.menus.getMenuItems(menu),
31
+ });
32
+
33
+ return commandMenuItemsToContextMenuItems([...menuItems], (commandId) => {
34
+ void executeCommand(commandId);
35
+ });
36
+ }
37
+
38
+ export function appendExtensionContextMenuItems(
39
+ baseItems: readonly ContextMenuItem[],
40
+ extensionItems: readonly ContextMenuItem[],
41
+ separatorId: string,
42
+ ): ContextMenuItem[] {
43
+ if (extensionItems.length === 0) {
44
+ return [...baseItems];
45
+ }
46
+
47
+ if (baseItems.length === 0) {
48
+ return [...extensionItems];
49
+ }
50
+
51
+ return [...baseItems, { id: separatorId, type: 'separator' }, ...extensionItems];
52
+ }