@workbench-kit/react 0.0.2-prototype.0.2.16 → 0.0.2-prototype.0.2.18

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.16",
3
+ "version": "0.0.2-prototype.0.2.18",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -63,15 +63,15 @@
63
63
  "@vscode/codicons": "^0.0.45",
64
64
  "remark-gfm": "^4.0.1",
65
65
  "rehype-sanitize": "^6.0.0",
66
- "@workbench-kit/adapters": "0.0.2-prototype.0.2.16",
67
- "@workbench-kit/contracts": "0.0.2-prototype.0.2.16",
68
- "@workbench-kit/monaco": "0.0.2-prototype.0.2.16",
69
- "@workbench-kit/platform": "0.0.2-prototype.0.2.16",
70
- "@workbench-kit/jdw": "0.0.2-prototype.0.2.16",
71
- "@workbench-kit/runtime": "0.0.2-prototype.0.2.16",
72
- "@workbench-kit/tokens": "0.0.2-prototype.0.2.16",
73
- "@workbench-kit/workspace": "0.0.2-prototype.0.2.16",
74
- "@workbench-kit/services": "0.0.2-prototype.0.2.16"
66
+ "@workbench-kit/adapters": "0.0.2-prototype.0.2.18",
67
+ "@workbench-kit/jdw": "0.0.2-prototype.0.2.18",
68
+ "@workbench-kit/contracts": "0.0.2-prototype.0.2.18",
69
+ "@workbench-kit/runtime": "0.0.2-prototype.0.2.18",
70
+ "@workbench-kit/services": "0.0.2-prototype.0.2.18",
71
+ "@workbench-kit/platform": "0.0.2-prototype.0.2.18",
72
+ "@workbench-kit/tokens": "0.0.2-prototype.0.2.18",
73
+ "@workbench-kit/workspace": "0.0.2-prototype.0.2.18",
74
+ "@workbench-kit/monaco": "0.0.2-prototype.0.2.18"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "react": "^19.0.0",
@@ -1,8 +1,18 @@
1
- import type { ComponentPropsWithRef, ReactNode } from 'react';
1
+ import type {
2
+ ComponentPropsWithRef,
3
+ KeyboardEvent as ReactKeyboardEvent,
4
+ MouseEvent as ReactMouseEvent,
5
+ ReactNode,
6
+ } from 'react';
2
7
  import { EmptyState } from '../../primitives/empty-state';
3
8
  import { cxCodicon } from '../../utils/codicon';
4
9
  import { cx } from '../../utils/cx';
5
- import { getWorkbenchStatusLabel, isWorkbenchStatusBusy, type WorkbenchStatus } from './status';
10
+ import {
11
+ getWorkbenchStatusLabel,
12
+ isWorkbenchStatusBusy,
13
+ isWorkbenchStatusDisabled,
14
+ type WorkbenchStatus,
15
+ } from './status';
6
16
 
7
17
  export type WorkbenchTimelineEventKind =
8
18
  'message' | 'operation-call' | 'operation-result' | 'file-write' | 'progress' | 'error';
@@ -178,6 +188,49 @@ export interface WorkbenchTimelineItemProps extends Omit<
178
188
  variant?: WorkbenchTimelineVariant;
179
189
  }
180
190
 
191
+ type WorkbenchTimelineActivationEvent =
192
+ ReactKeyboardEvent<HTMLElement> | ReactMouseEvent<HTMLElement>;
193
+
194
+ const timelineInteractiveDescendantSelector =
195
+ 'a[href],button,input,select,textarea,[contenteditable],[role="button"],[role="link"]';
196
+
197
+ function createTimelineActivationProps(
198
+ event: WorkbenchTimelineEvent,
199
+ onEventActivate: WorkbenchTimelineProps['onEventActivate'],
200
+ ): Pick<
201
+ WorkbenchTimelineItemProps,
202
+ 'aria-description' | 'aria-disabled' | 'aria-keyshortcuts' | 'onClick' | 'onKeyDown' | 'tabIndex'
203
+ > {
204
+ if (onEventActivate === undefined) return {};
205
+ if (isWorkbenchStatusDisabled(getWorkbenchTimelineEventStatus(event))) {
206
+ return { 'aria-disabled': true, tabIndex: -1 };
207
+ }
208
+
209
+ const activate = (activationEvent: WorkbenchTimelineActivationEvent) => {
210
+ const { currentTarget, target } = activationEvent;
211
+ const fromNestedControl =
212
+ target instanceof Element &&
213
+ target !== currentTarget &&
214
+ target.closest(timelineInteractiveDescendantSelector) !== null;
215
+ if (activationEvent.defaultPrevented || fromNestedControl) return;
216
+
217
+ if ('key' in activationEvent) {
218
+ if (activationEvent.key !== 'Enter' && activationEvent.key !== ' ') return;
219
+ activationEvent.preventDefault();
220
+ }
221
+
222
+ onEventActivate(event);
223
+ };
224
+
225
+ return {
226
+ 'aria-description': 'Press Enter or Space to activate.',
227
+ 'aria-keyshortcuts': 'Enter Space',
228
+ onClick: activate,
229
+ onKeyDown: activate,
230
+ tabIndex: 0,
231
+ };
232
+ }
233
+
181
234
  export function WorkbenchTimelineItem({
182
235
  className,
183
236
  event,
@@ -247,6 +300,8 @@ export function WorkbenchTimelineItem({
247
300
  export interface WorkbenchTimelineProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
248
301
  emptyLabel?: ReactNode;
249
302
  events: readonly WorkbenchTimelineEvent[];
303
+ /** Activates an enabled event from pointer or Enter/Space input. */
304
+ onEventActivate?: (event: WorkbenchTimelineEvent) => void;
250
305
  renderMetadata?: WorkbenchTimelineRenderMetadata;
251
306
  renderPayload?: WorkbenchTimelineRenderPayload;
252
307
  variant?: WorkbenchTimelineVariant;
@@ -256,6 +311,7 @@ export function WorkbenchTimeline({
256
311
  className,
257
312
  emptyLabel = 'No timeline events',
258
313
  events,
314
+ onEventActivate,
259
315
  renderMetadata,
260
316
  renderPayload,
261
317
  variant = 'expanded',
@@ -290,6 +346,7 @@ export function WorkbenchTimeline({
290
346
  renderMetadata={renderMetadata}
291
347
  renderPayload={renderPayload}
292
348
  variant={variant}
349
+ {...createTimelineActivationProps(event, onEventActivate)}
293
350
  />
294
351
  ))}
295
352
  </div>