gpui-bridge-react 0.2.0 → 0.3.0

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.
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode, Ref } from "react";
2
- import type { A11y, ButtonProps as WireButtonProps, DiffSelection, ImageProps as WireImageProps, Menu, MenuItem, NodeProps, NodeType, Option, RadioGroupProps as WireRadioGroupProps, TableCell, TableColumn, TableSort, TabsProps as WireTabsProps, UINode, WindowControl, WindowEventPayload } from "gpui-bridge";
2
+ import type { A11y, ButtonProps as WireButtonProps, DiffSelection, ImageProps as WireImageProps, Menu, MenuItem, NodeProps, NodeType, Option, QuestionnaireAnswer, RadioGroupProps as WireRadioGroupProps, SettingsChange, TableCell, TableColumn, TableSort, TabsProps as WireTabsProps, UINode, WindowControl, WindowEventPayload } from "gpui-bridge";
3
3
  /** A `ref` gets the node (`ref.current.focus()`). */
4
4
  type HostComponent<P> = (props: P & {
5
5
  ref?: Ref<UINode<NodeType>>;
@@ -287,6 +287,7 @@ export type CollapsibleProps = NodeProps["Collapsible"] & {
287
287
  export declare const Collapsible: HostComponent<CollapsibleProps>;
288
288
  export type AccordionProps = NodeProps["Accordion"] & {
289
289
  onChange?: (id: string) => void;
290
+ children?: ReactNode;
290
291
  };
291
292
  export declare const Accordion: HostComponent<AccordionProps>;
292
293
  export type AvatarProps = NodeProps["Avatar"];
@@ -318,7 +319,9 @@ export type GroupBoxProps = NodeProps["GroupBox"] & {
318
319
  export declare const GroupBox: HostComponent<GroupBoxProps>;
319
320
  export type DescriptionListProps = NodeProps["DescriptionList"];
320
321
  export declare const DescriptionList: HostComponent<DescriptionListProps>;
321
- export type StatusBarProps = NodeProps["StatusBar"];
322
+ export type StatusBarProps = NodeProps["StatusBar"] & {
323
+ children?: ReactNode;
324
+ };
322
325
  export declare const StatusBar: HostComponent<StatusBarProps>;
323
326
  export type ToolbarProps = NodeProps["Toolbar"] & {
324
327
  children?: ReactNode;
@@ -357,4 +360,192 @@ export declare const Sidebar: HostComponent<SidebarProps>;
357
360
  /** A line, bar or pie chart of the points in `data`; it has no events of its own. */
358
361
  export type ChartProps = NodeProps["Chart"];
359
362
  export declare const Chart: HostComponent<ChartProps>;
363
+ /** Paints the drawing commands in `commands`; `onPointerDown` gets the local point. */
364
+ export type CanvasProps = NodeProps["Canvas"] & {
365
+ onPointerDown?: (point: {
366
+ x: number;
367
+ y: number;
368
+ }) => void;
369
+ };
370
+ export declare const Canvas: HostComponent<CanvasProps>;
371
+ /** A command palette over the sections in `items`; `onConfirm` gets the chosen entry's `id`. */
372
+ export type CommandProps = NodeProps["Command"] & {
373
+ onConfirm?: (id: string) => void;
374
+ };
375
+ export declare const Command: HostComponent<CommandProps>;
376
+ /** Settings pages of typed fields; `onChange` gets `{key, value}` of the field the user set. */
377
+ export type SettingsProps = NodeProps["Settings"] & {
378
+ onChange?: (change: SettingsChange) => void;
379
+ };
380
+ export declare const Settings: HostComponent<SettingsProps>;
381
+ /** A button that stays pressed; `onChange` gets the new `checked`. */
382
+ export type ToggleProps = NodeProps["Toggle"] & {
383
+ onChange?: (checked: boolean) => void;
384
+ };
385
+ export declare const Toggle: HostComponent<ToggleProps>;
386
+ /** An action with a menu: `onClick` is the left half, `onMenu` gets the chosen item's id. */
387
+ export type DropdownButtonProps = NodeProps["DropdownButton"] & {
388
+ onClick?: () => void;
389
+ onMenu?: (item: string) => void;
390
+ };
391
+ export declare const DropdownButton: HostComponent<DropdownButtonProps>;
392
+ export type LabelProps = NodeProps["Label"];
393
+ export declare const Label: HostComponent<LabelProps>;
394
+ /** A centered empty state; its children are the action under the header. */
395
+ export type EmptyProps = NodeProps["Empty"] & {
396
+ children?: ReactNode;
397
+ };
398
+ export declare const Empty: HostComponent<EmptyProps>;
399
+ export type ShimmerProps = NodeProps["Shimmer"];
400
+ export declare const Shimmer: HostComponent<ShimmerProps>;
401
+ /** A framed text field; `onChange` and `onSubmit` work as in an `Input`. */
402
+ export type InputGroupProps = NodeProps["InputGroup"] & {
403
+ onChange?: (value: string) => void;
404
+ onSubmit?: (value: string) => void;
405
+ };
406
+ export declare const InputGroup: HostComponent<InputGroupProps>;
407
+ /** Copies `value` on click; `onCopied` gets the text that was copied. */
408
+ export type ClipboardProps = NodeProps["Clipboard"] & {
409
+ onCopied?: (value: string) => void;
410
+ };
411
+ export declare const Clipboard: HostComponent<ClipboardProps>;
412
+ /** A confirmation; `onOk` and `onCancel` close it, as in a `Dialog`. */
413
+ export type AlertDialogProps = NodeProps["AlertDialog"] & {
414
+ onOk?: () => void;
415
+ onCancel?: () => void;
416
+ children?: ReactNode;
417
+ };
418
+ export declare const AlertDialog: HostComponent<AlertDialogProps>;
419
+ /** A panel that slides in from `side`; `onClose` is its X, Escape or a click on the overlay. */
420
+ export type SheetProps = NodeProps["Sheet"] & {
421
+ onClose?: () => void;
422
+ children?: ReactNode;
423
+ };
424
+ export declare const Sheet: HostComponent<SheetProps>;
425
+ /**
426
+ * A panel anchored to its first child (the trigger); the rest are the panel. `onChange` gets the
427
+ * new `open`: the host keeps it, as it keeps a `Checkbox`'s `checked`.
428
+ */
429
+ export type PopoverProps = NodeProps["Popover"] & {
430
+ onChange?: (checked: boolean) => void;
431
+ children?: ReactNode;
432
+ };
433
+ export declare const Popover: HostComponent<PopoverProps>;
434
+ /** A card on hover, opened by the mouse alone; `onChange` gets the new `open`. */
435
+ export type HoverCardProps = NodeProps["HoverCard"] & {
436
+ onChange?: (checked: boolean) => void;
437
+ children?: ReactNode;
438
+ };
439
+ export declare const HoverCard: HostComponent<HoverCardProps>;
440
+ /** A day picker; `onChange` gets the chosen day, `null` when cleared. */
441
+ export type DatePickerProps = NodeProps["DatePicker"] & {
442
+ onChange?: (value: string | null) => void;
443
+ };
444
+ export declare const DatePicker: HostComponent<DatePickerProps>;
445
+ /** A time typed by segments; `onChange` gets the time (`HH:MM[:SS]`). */
446
+ export type TimeFieldProps = NodeProps["TimeField"] & {
447
+ onChange?: (value: string) => void;
448
+ };
449
+ export declare const TimeField: HostComponent<TimeFieldProps>;
450
+ /** A color swatch and hex box; `onChange` gets the color, `null` when cleared. */
451
+ export type ColorPickerProps = NodeProps["ColorPicker"] & {
452
+ onChange?: (value: string | null) => void;
453
+ };
454
+ export declare const ColorPicker: HostComponent<ColorPickerProps>;
455
+ /** A list that picks several options; `onChange` gets the whole selection. */
456
+ export type ComboboxProps = NodeProps["Combobox"] & {
457
+ onChange?: (value: string[]) => void;
458
+ };
459
+ export declare const Combobox: HostComponent<ComboboxProps>;
460
+ /** A chat bubble; its children are the content. */
461
+ export type BubbleProps = NodeProps["Bubble"] & {
462
+ children?: ReactNode;
463
+ };
464
+ export declare const Bubble: HostComponent<BubbleProps>;
465
+ /** A message row: a `MessageHeader` and a `MessageFooter` child, the rest is the content. */
466
+ export type MessageProps = NodeProps["Message"] & {
467
+ children?: ReactNode;
468
+ };
469
+ export declare const Message: HostComponent<MessageProps>;
470
+ export type MessageHeaderProps = NodeProps["MessageHeader"] & {
471
+ children?: ReactNode;
472
+ };
473
+ export declare const MessageHeader: HostComponent<MessageHeaderProps>;
474
+ export type MessageFooterProps = NodeProps["MessageFooter"] & {
475
+ children?: ReactNode;
476
+ };
477
+ export declare const MessageFooter: HostComponent<MessageFooterProps>;
478
+ /** A compact status row; children go after the text. */
479
+ export type MarkerProps = NodeProps["Marker"] & {
480
+ children?: ReactNode;
481
+ };
482
+ export declare const Marker: HostComponent<MarkerProps>;
483
+ /** A file or picture card; each handler shows its control (`onRetry` only while `failed`). */
484
+ export type AttachmentProps = NodeProps["Attachment"] & {
485
+ onClick?: () => void;
486
+ onRemove?: () => void;
487
+ onRetry?: () => void;
488
+ children?: ReactNode;
489
+ };
490
+ export declare const Attachment: HostComponent<AttachmentProps>;
491
+ /** A virtual list of messages anchored at the end; each child is a row. */
492
+ export type MessageScrollerProps = NodeProps["MessageScroller"] & {
493
+ children?: ReactNode;
494
+ };
495
+ export declare const MessageScroller: HostComponent<MessageScrollerProps>;
496
+ /** Questions one at a time; `onChange` gets one answer, `onSubmit` all of them. */
497
+ export type QuestionnaireProps = NodeProps["Questionnaire"] & {
498
+ onChange?: (answer: QuestionnaireAnswer) => void;
499
+ onSubmit?: (answers: QuestionnaireAnswer[]) => void;
500
+ };
501
+ export declare const Questionnaire: HostComponent<QuestionnaireProps>;
502
+ /**
503
+ * A selectable list over its `ListItem` children. Passing `value` makes the selection controlled.
504
+ * `onQuery` gets the search text (render the matching rows); `onLoadMore` asks for more rows.
505
+ */
506
+ export type ListProps = NodeProps["List"] & {
507
+ value?: string | null;
508
+ onChange?: (value: string | null) => void;
509
+ onConfirm?: (value: string) => void;
510
+ onQuery?: (query: string) => void;
511
+ onLoadMore?: () => void;
512
+ children?: ReactNode;
513
+ };
514
+ export declare const List: HostComponent<ListProps>;
515
+ /** A `List` row: `value` is what the list reports; its children are the content. */
516
+ export type ListItemProps = NodeProps["ListItem"] & {
517
+ children?: ReactNode;
518
+ };
519
+ export declare const ListItem: HostComponent<ListItemProps>;
520
+ /** Panels the user rearranges: its `DockPanel` children. The host owns the layout. */
521
+ export type DockProps = NodeProps["Dock"] & {
522
+ children?: ReactNode;
523
+ };
524
+ export declare const Dock: HostComponent<DockProps>;
525
+ /** A `Dock` panel; `onClose` means the user closed it: stop rendering it. */
526
+ export type DockPanelProps = NodeProps["DockPanel"] & {
527
+ onClose?: () => void;
528
+ children?: ReactNode;
529
+ };
530
+ export declare const DockPanel: HostComponent<DockPanelProps>;
531
+ /** An `Accordion` section: `id` is what `onChange` reports; its children are the content. */
532
+ export type AccordionItemProps = NodeProps["AccordionItem"] & {
533
+ children?: ReactNode;
534
+ };
535
+ export declare const AccordionItem: HostComponent<AccordionItemProps>;
536
+ /** A `Dialog`'s or `AlertDialog`'s footer: its children (buttons) replace OK/Cancel. */
537
+ export type DialogFooterProps = NodeProps["DialogFooter"] & {
538
+ children?: ReactNode;
539
+ };
540
+ export declare const DialogFooter: HostComponent<DialogFooterProps>;
541
+ /** A `StatusBar`'s left side: its children replace the `left` text. */
542
+ export type StatusBarLeftProps = NodeProps["StatusBarLeft"] & {
543
+ children?: ReactNode;
544
+ };
545
+ export declare const StatusBarLeft: HostComponent<StatusBarLeftProps>;
546
+ /** A `StatusBar`'s right side: its children replace the `right` text. */
547
+ export type StatusBarRightProps = NodeProps["StatusBarRight"] & {
548
+ children?: ReactNode;
549
+ };
550
+ export declare const StatusBarRight: HostComponent<StatusBarRightProps>;
360
551
  export {};
@@ -58,3 +58,37 @@ export const Diff = "Diff";
58
58
  export const Carousel = "Carousel";
59
59
  export const Sidebar = "Sidebar";
60
60
  export const Chart = "Chart";
61
+ export const Canvas = "Canvas";
62
+ export const Command = "Command";
63
+ export const Settings = "Settings";
64
+ export const Toggle = "Toggle";
65
+ export const DropdownButton = "DropdownButton";
66
+ export const Label = "Label";
67
+ export const Empty = "Empty";
68
+ export const Shimmer = "Shimmer";
69
+ export const InputGroup = "InputGroup";
70
+ export const Clipboard = "Clipboard";
71
+ export const AlertDialog = "AlertDialog";
72
+ export const Sheet = "Sheet";
73
+ export const Popover = "Popover";
74
+ export const HoverCard = "HoverCard";
75
+ export const DatePicker = "DatePicker";
76
+ export const TimeField = "TimeField";
77
+ export const ColorPicker = "ColorPicker";
78
+ export const Combobox = "Combobox";
79
+ export const Bubble = "Bubble";
80
+ export const Message = "Message";
81
+ export const MessageHeader = "MessageHeader";
82
+ export const MessageFooter = "MessageFooter";
83
+ export const Marker = "Marker";
84
+ export const Attachment = "Attachment";
85
+ export const MessageScroller = "MessageScroller";
86
+ export const Questionnaire = "Questionnaire";
87
+ export const List = "List";
88
+ export const ListItem = "ListItem";
89
+ export const Dock = "Dock";
90
+ export const DockPanel = "DockPanel";
91
+ export const AccordionItem = "AccordionItem";
92
+ export const DialogFooter = "DialogFooter";
93
+ export const StatusBarLeft = "StatusBarLeft";
94
+ export const StatusBarRight = "StatusBarRight";
@@ -120,6 +120,13 @@ const EVENT_PROPS = {
120
120
  onSort: "sort",
121
121
  onExpand: "expand",
122
122
  onCollapse: "collapse",
123
+ onPointerDown: "pointerDown",
124
+ onConfirm: "confirm",
125
+ onCopied: "copied",
126
+ onRemove: "remove",
127
+ onRetry: "retry",
128
+ onQuery: "query",
129
+ onLoadMore: "loadMore",
123
130
  };
124
131
  function isTextChildren(children) {
125
132
  const items = Array.isArray(children) ? children : [children];
@@ -156,14 +163,16 @@ function split(type, props) {
156
163
  wire.controlled = props.value !== undefined;
157
164
  if (type === "Pagination")
158
165
  wire.controlled = props.page !== undefined;
159
- if (type === "NumberInput" || type === "OtpInput")
166
+ if (type === "NumberInput" || type === "OtpInput" || type === "InputGroup")
160
167
  wire.controlled = props.value !== undefined;
161
168
  if (type === "Table")
162
169
  wire.controlled = props.selected !== undefined;
163
- if (type === "Tree" || type === "Carousel" || type === "Sidebar")
170
+ if (type === "Tree" || type === "Carousel" || type === "Sidebar" || type === "List")
164
171
  wire.controlled = props.value !== undefined;
165
- if (type === "Checkbox" || type === "Switch")
172
+ if (type === "Checkbox" || type === "Switch" || type === "Toggle")
166
173
  wire.controlled = props.checked !== undefined;
174
+ if (type === "DatePicker" || type === "TimeField" || type === "ColorPicker" || type === "Combobox")
175
+ wire.controlled = props.value !== undefined;
167
176
  return { wire, handlers };
168
177
  }
169
178
  /** Host event payloads become plain handler arguments. */
@@ -173,7 +182,7 @@ function subscribe(instance, event) {
173
182
  const handler = instance.handlers.get(event);
174
183
  if (!handler)
175
184
  return;
176
- if (event === "click" || event === "ok" || event === "cancel" || event === "close")
185
+ if (event === "click" || event === "ok" || event === "cancel" || event === "close" || event === "loadMore")
177
186
  handler();
178
187
  // A Table's double click carries the row.
179
188
  else if (event === "doubleClick")
@@ -186,7 +195,9 @@ function subscribe(instance, event) {
186
195
  handler(payload.key);
187
196
  else if (event === "drop")
188
197
  handler(payload.paths);
189
- else if (instance.type === "Checkbox" || instance.type === "Switch")
198
+ else if (instance.type === "Checkbox" || instance.type === "Switch" || instance.type === "Toggle")
199
+ handler(payload.checked);
200
+ else if (instance.type === "Popover" || instance.type === "HoverCard")
190
201
  handler(payload.checked);
191
202
  else
192
203
  handler(payload.value);
@@ -286,6 +297,74 @@ function createNode(app, type, wire) {
286
297
  return app.sidebar(wire);
287
298
  case "Chart":
288
299
  return app.chart(wire);
300
+ case "Canvas":
301
+ return app.canvas(wire);
302
+ case "Command":
303
+ return app.command(wire);
304
+ case "Settings":
305
+ return app.settings(wire);
306
+ case "Toggle":
307
+ return app.toggle(wire);
308
+ case "DropdownButton":
309
+ return app.dropdownButton(wire);
310
+ case "Label":
311
+ return app.label(wire);
312
+ case "Empty":
313
+ return app.empty(wire);
314
+ case "Shimmer":
315
+ return app.shimmer(wire);
316
+ case "InputGroup":
317
+ return app.inputGroup(wire);
318
+ case "Clipboard":
319
+ return app.clipboard(wire);
320
+ case "AlertDialog":
321
+ return app.alertDialog(wire);
322
+ case "Sheet":
323
+ return app.sheet(wire);
324
+ case "Popover":
325
+ return app.popover(wire);
326
+ case "HoverCard":
327
+ return app.hoverCard(wire);
328
+ case "DatePicker":
329
+ return app.datePicker(wire);
330
+ case "TimeField":
331
+ return app.timeField(wire);
332
+ case "ColorPicker":
333
+ return app.colorPicker(wire);
334
+ case "Combobox":
335
+ return app.combobox(wire);
336
+ case "Bubble":
337
+ return app.bubble(wire);
338
+ case "Message":
339
+ return app.message(wire);
340
+ case "MessageHeader":
341
+ return app.messageHeader(wire);
342
+ case "MessageFooter":
343
+ return app.messageFooter(wire);
344
+ case "Marker":
345
+ return app.marker(wire);
346
+ case "Attachment":
347
+ return app.attachment(wire);
348
+ case "MessageScroller":
349
+ return app.messageScroller(wire);
350
+ case "Questionnaire":
351
+ return app.questionnaire(wire);
352
+ case "List":
353
+ return app.list(wire);
354
+ case "ListItem":
355
+ return app.listItem(wire);
356
+ case "Dock":
357
+ return app.dock(wire);
358
+ case "DockPanel":
359
+ return app.dockPanel(wire);
360
+ case "AccordionItem":
361
+ return app.accordionItem(wire);
362
+ case "DialogFooter":
363
+ return app.dialogFooter(wire);
364
+ case "StatusBarLeft":
365
+ return app.statusBarLeft(wire);
366
+ case "StatusBarRight":
367
+ return app.statusBarRight(wire);
289
368
  default:
290
369
  throw new Error(`gpui-bridge-react: unknown element type '${type}'`);
291
370
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gpui-bridge-react",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "React renderer for gpui-bridge native UIs",
5
5
  "license": "MIT",
6
6
  "author": "gpui-bridge contributors",
@@ -29,14 +29,14 @@
29
29
  "node": ">=22.6"
30
30
  },
31
31
  "peerDependencies": {
32
- "gpui-bridge": "^0.2.0",
32
+ "gpui-bridge": "^0.3.0",
33
33
  "react": "^19.3.0"
34
34
  },
35
35
  "dependencies": {
36
36
  "react-reconciler": "0.34.0"
37
37
  },
38
38
  "devDependencies": {
39
- "gpui-bridge": "0.2.0",
39
+ "gpui-bridge": "0.3.0",
40
40
  "@types/node": "^26.6.5",
41
41
  "@types/react": "19.3.0",
42
42
  "@types/react-reconciler": "^0.34.0",