@dxos/react-ui-mosaic 0.8.4-main.fcfe5033a5 → 0.9.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.
Files changed (91) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/{chunk-33NNDFD6.mjs → chunk-I3M5WM6C.mjs} +45 -73
  3. package/dist/lib/browser/chunk-I3M5WM6C.mjs.map +7 -0
  4. package/dist/lib/browser/index.mjs +125 -59
  5. package/dist/lib/browser/index.mjs.map +4 -4
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/browser/playwright/index.mjs +118 -10
  8. package/dist/lib/browser/playwright/index.mjs.map +3 -3
  9. package/dist/lib/browser/testing/index.mjs +10 -19
  10. package/dist/lib/browser/testing/index.mjs.map +3 -3
  11. package/dist/lib/browser/translations.mjs +18 -0
  12. package/dist/lib/browser/translations.mjs.map +7 -0
  13. package/dist/lib/node-esm/{chunk-Y4LG7O67.mjs → chunk-DVJLDZLE.mjs} +45 -73
  14. package/dist/lib/node-esm/chunk-DVJLDZLE.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +125 -59
  16. package/dist/lib/node-esm/index.mjs.map +4 -4
  17. package/dist/lib/node-esm/meta.json +1 -1
  18. package/dist/lib/node-esm/playwright/index.mjs +118 -10
  19. package/dist/lib/node-esm/playwright/index.mjs.map +3 -3
  20. package/dist/lib/node-esm/testing/index.mjs +10 -19
  21. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  22. package/dist/lib/node-esm/translations.mjs +20 -0
  23. package/dist/lib/node-esm/translations.mjs.map +7 -0
  24. package/dist/types/src/components/Board/Board.d.ts +12 -4
  25. package/dist/types/src/components/Board/Board.d.ts.map +1 -1
  26. package/dist/types/src/components/Board/Board.stories.d.ts +3 -3
  27. package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -1
  28. package/dist/types/src/components/Board/Column.d.ts +5 -5
  29. package/dist/types/src/components/Board/Column.d.ts.map +1 -1
  30. package/dist/types/src/components/Board/Item.d.ts +1 -1
  31. package/dist/types/src/components/Board/Item.d.ts.map +1 -1
  32. package/dist/types/src/components/Mosaic/Container.d.ts +9 -1
  33. package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -1
  34. package/dist/types/src/components/Mosaic/Mosaic.d.ts +3 -2
  35. package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -1
  36. package/dist/types/src/components/Mosaic/Placeholder.d.ts +8 -8
  37. package/dist/types/src/components/Mosaic/Placeholder.d.ts.map +1 -1
  38. package/dist/types/src/components/Mosaic/Stack.d.ts +6 -1
  39. package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -1
  40. package/dist/types/src/components/Mosaic/Stack.stories.d.ts.map +1 -1
  41. package/dist/types/src/components/Mosaic/Tile.d.ts +6 -2
  42. package/dist/types/src/components/Mosaic/Tile.d.ts.map +1 -1
  43. package/dist/types/src/components/Mosaic/extension.d.ts.map +1 -1
  44. package/dist/types/src/components/Mosaic/styles.d.ts.map +1 -1
  45. package/dist/types/src/components/Mosaic/types.d.ts.map +1 -1
  46. package/dist/types/src/components/SearchStack/SearchStack.d.ts +20 -0
  47. package/dist/types/src/components/SearchStack/SearchStack.d.ts.map +1 -0
  48. package/dist/types/src/components/SearchStack/SearchStack.stories.d.ts +10 -0
  49. package/dist/types/src/components/SearchStack/SearchStack.stories.d.ts.map +1 -0
  50. package/dist/types/src/components/SearchStack/index.d.ts +2 -0
  51. package/dist/types/src/components/SearchStack/index.d.ts.map +1 -0
  52. package/dist/types/src/components/index.d.ts +1 -0
  53. package/dist/types/src/components/index.d.ts.map +1 -1
  54. package/dist/types/src/hooks/useContainerDebug.d.ts.map +1 -1
  55. package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts.map +1 -1
  56. package/dist/types/src/hooks/useEventHandlerAdapter.d.ts +1 -1
  57. package/dist/types/src/hooks/useEventHandlerAdapter.d.ts.map +1 -1
  58. package/dist/types/src/hooks/useVisibleItems.d.ts.map +1 -1
  59. package/dist/types/src/playwright/board-manager.d.ts +20 -5
  60. package/dist/types/src/playwright/board-manager.d.ts.map +1 -1
  61. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
  62. package/dist/types/src/testing/CardContainer.d.ts.map +1 -1
  63. package/dist/types/src/testing/DefaultStackTile.d.ts.map +1 -1
  64. package/dist/types/src/testing/types.d.ts +7 -9
  65. package/dist/types/src/testing/types.d.ts.map +1 -1
  66. package/dist/types/src/translations.d.ts +3 -3
  67. package/dist/types/src/translations.d.ts.map +1 -1
  68. package/dist/types/tsconfig.tsbuildinfo +1 -1
  69. package/package.json +42 -40
  70. package/src/components/Board/Board.stories.tsx +11 -10
  71. package/src/components/Board/Board.tsx +4 -3
  72. package/src/components/Board/Column.tsx +22 -18
  73. package/src/components/Board/Item.tsx +14 -10
  74. package/src/components/Mosaic/Container.tsx +18 -2
  75. package/src/components/Mosaic/Placeholder.tsx +6 -0
  76. package/src/components/Mosaic/Stack.tsx +20 -5
  77. package/src/components/Mosaic/Tile.tsx +11 -2
  78. package/src/components/Mosaic/extension.ts +1 -1
  79. package/src/components/SearchStack/SearchStack.stories.tsx +47 -0
  80. package/src/components/SearchStack/SearchStack.tsx +135 -0
  81. package/src/components/SearchStack/index.ts +5 -0
  82. package/src/components/index.ts +1 -0
  83. package/src/hooks/useContainerDebug.tsx +3 -3
  84. package/src/hooks/useEventHandlerAdapter.ts +1 -1
  85. package/src/playwright/board-manager.ts +168 -13
  86. package/src/playwright/smoke.spec.ts +3 -3
  87. package/src/testing/CardContainer.tsx +2 -5
  88. package/src/testing/DefaultStackTile.tsx +11 -5
  89. package/src/testing/types.ts +7 -17
  90. package/dist/lib/browser/chunk-33NNDFD6.mjs.map +0 -7
  91. package/dist/lib/node-esm/chunk-Y4LG7O67.mjs.map +0 -7
@@ -8,20 +8,21 @@ import {
8
8
  useMosaicRootContext,
9
9
  useMosaicTileContext,
10
10
  useVisibleItems
11
- } from "./chunk-33NNDFD6.mjs";
11
+ } from "./chunk-I3M5WM6C.mjs";
12
12
 
13
13
  // src/components/Board/Board.tsx
14
14
  import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
15
15
  import { createContext as createContext2 } from "@radix-ui/react-context";
16
- import React4, { forwardRef as forwardRef4, useRef as useRef4, useState as useState2 } from "react";
16
+ import React4, { forwardRef as forwardRef4, useRef as useRef3, useState as useState3 } from "react";
17
17
  import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
18
- import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
19
- import { composable as composable2, composableProps as composableProps2, mx as mx3 } from "@dxos/ui-theme";
18
+ import { composable as composable2, composableProps as composableProps2 } from "@dxos/react-ui";
19
+ import { JsonHighlighter as JsonHighlighter2 } from "@dxos/react-ui-syntax-highlighter";
20
+ import { mx as mx3 } from "@dxos/ui-theme";
20
21
 
21
22
  // src/hooks/useContainerDebug.tsx
22
23
  import React, { forwardRef, useMemo, useRef } from "react";
23
24
  import { createPortal } from "react-dom";
24
- import { Json } from "@dxos/react-ui-syntax-highlighter";
25
+ import { JsonHighlighter } from "@dxos/react-ui-syntax-highlighter";
25
26
  import { mx } from "@dxos/ui-theme";
26
27
  var useContainerDebug = (debug) => {
27
28
  const debugRef = useRef(null);
@@ -34,7 +35,6 @@ var useContainerDebug = (debug) => {
34
35
  }
35
36
  return [
36
37
  ({ classNames }) => /* @__PURE__ */ React.createElement("div", {
37
- role: "none",
38
38
  className: mx("overflow-hidden", classNames),
39
39
  ref: debugRef
40
40
  }),
@@ -49,7 +49,7 @@ var CONTAINER_INFO_NAME = "ContainerInfo";
49
49
  var ContainerInfo = /* @__PURE__ */ forwardRef(({ classNames }, forwardedRef) => {
50
50
  const { id, state, activeLocation, scrolling } = useMosaicContainerContext(CONTAINER_INFO_NAME);
51
51
  const counter = useRef(0);
52
- return /* @__PURE__ */ React.createElement(Json.Data, {
52
+ return /* @__PURE__ */ React.createElement(JsonHighlighter, {
53
53
  data: {
54
54
  id,
55
55
  activeLocation,
@@ -74,12 +74,7 @@ var useEventHandlerAdapter = ({ items, getId, get, make, onChange, ...props }) =
74
74
  onTake: ({ source }, cb) => {
75
75
  log.info("onTake", {
76
76
  source
77
- }, {
78
- F: __dxlog_file,
79
- L: 61,
80
- S: void 0,
81
- C: (f, a) => f(...a)
82
- });
77
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 14, S: void 0 });
83
78
  const mutate = (items2) => {
84
79
  const from = items2.findIndex((item) => getId(item) === source.id);
85
80
  if (from !== -1) {
@@ -97,12 +92,7 @@ var useEventHandlerAdapter = ({ items, getId, get, make, onChange, ...props }) =
97
92
  log.info("onDrop", {
98
93
  source,
99
94
  target
100
- }, {
101
- F: __dxlog_file,
102
- L: 78,
103
- S: void 0,
104
- C: (f, a) => f(...a)
105
- });
95
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 31, S: void 0 });
106
96
  const mutate = (items2) => {
107
97
  const to = target?.type === "tile" || target?.type === "placeholder" ? target.location : target?.type === "container" ? items2.length : -1;
108
98
  const from = items2.findIndex((item) => getId(item) === source.id);
@@ -246,7 +236,7 @@ var dropField = StateField.define({
246
236
  toDOM() {
247
237
  const dom = document.createElement("span");
248
238
  dom.className = "cm-drop-cursor";
249
- dom.style.borderLeft = "2px solid var(--color-accent-surface)";
239
+ dom.style.borderLeft = "2px solid var(--color-accent-bg)";
250
240
  dom.style.display = "inline-block";
251
241
  dom.style.height = "1em";
252
242
  dom.style.verticalAlign = "middle";
@@ -266,40 +256,29 @@ var dropField = StateField.define({
266
256
  // src/components/Board/Column.tsx
267
257
  import { useAtomValue } from "@effect-atom/atom-react";
268
258
  import { createContext } from "@radix-ui/react-context";
269
- import React3, { forwardRef as forwardRef3, useMemo as useMemo4, useRef as useRef3, useState } from "react";
259
+ import React3, { forwardRef as forwardRef3, useMemo as useMemo4, useState as useState2 } from "react";
270
260
  import { Obj as Obj2, Ref } from "@dxos/echo";
271
261
  import { useObject } from "@dxos/react-client/echo";
272
262
  import { IconButton, ScrollArea, Toolbar as Toolbar2, useTranslation as useTranslation2 } from "@dxos/react-ui";
263
+ import { composable, composableProps } from "@dxos/react-ui";
273
264
  import { Menu as Menu2, createMenuAction as createMenuAction2 } from "@dxos/react-ui-menu";
274
- import { composable, composableProps, mx as mx2 } from "@dxos/ui-theme";
275
-
276
- // src/translations.ts
277
- var translationKey = "@dxos/react-ui-mosaic";
278
- var translations = [
279
- {
280
- "en-US": {
281
- [translationKey]: {
282
- "action-menu.label": "Actions",
283
- "add-item.label": "Add item",
284
- "delete-menu.label": "Delete"
285
- }
286
- }
287
- }
288
- ];
265
+ import { mx as mx2 } from "@dxos/ui-theme";
266
+ import { translationKey as translationKey2 } from "#translations";
289
267
 
290
268
  // src/components/Board/Item.tsx
291
269
  import { useComposedRefs } from "@radix-ui/react-compose-refs";
292
- import React2, { forwardRef as forwardRef2, useMemo as useMemo3, useRef as useRef2 } from "react";
270
+ import React2, { forwardRef as forwardRef2, useMemo as useMemo3, useRef as useRef2, useState } from "react";
293
271
  import { Obj } from "@dxos/echo";
294
272
  import { Card, Tag, Toolbar, useTranslation } from "@dxos/react-ui";
295
273
  import { Menu, createMenuAction } from "@dxos/react-ui-menu";
296
274
  import { getHashStyles } from "@dxos/ui-theme";
275
+ import { translationKey } from "#translations";
297
276
  var BOARD_ITEM_NAME = "Board.Item";
298
- var BoardItemInner = /* @__PURE__ */ forwardRef2(({ classNames, data, location, debug }, forwardedRef) => {
277
+ var BoardItemInner = /* @__PURE__ */ forwardRef2(({ classNames, data, location, debug, draggable }, forwardedRef) => {
299
278
  const { t } = useTranslation(translationKey);
300
279
  const rootRef = useRef2(null);
301
280
  const composedRef = useComposedRefs(rootRef, forwardedRef);
302
- const dragHandleRef = useRef2(null);
281
+ const [dragHandle, setDragHandle] = useState(null);
303
282
  const { model } = useBoard(BOARD_ITEM_NAME);
304
283
  const column = useBoardColumn();
305
284
  const items = useMemo3(() => column != null && model.onItemDelete ? [
@@ -321,7 +300,8 @@ var BoardItemInner = /* @__PURE__ */ forwardRef2(({ classNames, data, location,
321
300
  return /* @__PURE__ */ React2.createElement(Menu.Root, null, /* @__PURE__ */ React2.createElement(Mosaic.Tile, {
322
301
  ref: rootRef,
323
302
  asChild: true,
324
- dragHandle: dragHandleRef.current,
303
+ draggable,
304
+ dragHandle,
325
305
  id: data.id,
326
306
  data,
327
307
  location,
@@ -333,8 +313,8 @@ var BoardItemInner = /* @__PURE__ */ forwardRef2(({ classNames, data, location,
333
313
  "data-testid": "board-item",
334
314
  ref: composedRef,
335
315
  onClick: (event) => event.currentTarget.focus()
336
- }, /* @__PURE__ */ React2.createElement(Card.Toolbar, null, /* @__PURE__ */ React2.createElement(Card.DragHandle, {
337
- ref: dragHandleRef,
316
+ }, /* @__PURE__ */ React2.createElement(Card.Header, null, /* @__PURE__ */ React2.createElement(Card.DragHandle, {
317
+ ref: setDragHandle,
338
318
  testId: "mosaicBoard.cardDragHandle"
339
319
  }), /* @__PURE__ */ React2.createElement(Card.Title, {
340
320
  "data-testid": "mosaicBoard.cardTitle"
@@ -354,7 +334,6 @@ var BoardItemInner = /* @__PURE__ */ forwardRef2(({ classNames, data, location,
354
334
  }, /* @__PURE__ */ React2.createElement(Card.Text, null, description)), /* @__PURE__ */ React2.createElement(Card.Row, {
355
335
  icon: "ph--tag--regular"
356
336
  }, label && /* @__PURE__ */ React2.createElement("div", {
357
- role: "none",
358
337
  className: "shrink-0 flex gap-1 items-center text-xs"
359
338
  }, /* @__PURE__ */ React2.createElement(Tag, {
360
339
  palette: getHashStyles(label).hue
@@ -371,17 +350,16 @@ function useBoardColumn() {
371
350
  return value?.column;
372
351
  }
373
352
  var BOARD_COLUMN_ROOT_NAME = "Board.Column.Root";
374
- var BoardColumnRootInner = composable(({ classNames, children, location, data, debug, dragHandleRef: dragHandleRefProp, ...rest }, forwardedRef) => {
353
+ var BoardColumnRootInner = composable(({ classNames, children, location, data, debug, draggable, dragHandle, ...rest }, forwardedRef) => {
375
354
  const { model } = useBoard(BOARD_COLUMN_ROOT_NAME);
376
- const internalRef = useRef3(null);
377
- const dragHandleRef = dragHandleRefProp ?? internalRef;
378
355
  return /* @__PURE__ */ React3.createElement(Mosaic.Tile, {
379
356
  asChild: true,
380
357
  location,
381
358
  id: model.getColumnId(data),
382
359
  data,
383
360
  debug,
384
- dragHandle: dragHandleRef.current
361
+ draggable,
362
+ dragHandle
385
363
  }, /* @__PURE__ */ React3.createElement(Focus.Group, {
386
364
  ...rest,
387
365
  "data-testid": "board-column",
@@ -396,7 +374,7 @@ BoardColumnRootInner.displayName = BOARD_COLUMN_ROOT_NAME;
396
374
  var BoardColumnRoot = BoardColumnRootInner;
397
375
  var BOARD_COLUMN_HEADER_NAME = "Board.Column.Header";
398
376
  var BoardColumnHeader = composable(({ label, dragHandleRef, ...props }, forwardedRef) => {
399
- const { t } = useTranslation2(translationKey);
377
+ const { t } = useTranslation2(translationKey2);
400
378
  const { model } = useBoard(BOARD_COLUMN_HEADER_NAME);
401
379
  const column = useBoardColumn();
402
380
  const columnMenuItems = useMemo4(() => column != null && model.onColumnDelete ? [
@@ -434,7 +412,7 @@ BoardColumnHeader.displayName = BOARD_COLUMN_HEADER_NAME;
434
412
  var BOARD_COLUMN_BODY_NAME = "Board.Column.Body";
435
413
  var BoardColumnBody = composable(({ data, eventHandler, Tile = BoardItem, debug, ...props }, forwardedRef) => {
436
414
  const { model } = useBoard(BOARD_COLUMN_BODY_NAME);
437
- const [viewport, setViewport] = useState(null);
415
+ const [viewport, setViewport] = useState2(null);
438
416
  const items = useAtomValue(model.items(data));
439
417
  return /* @__PURE__ */ React3.createElement(Mosaic.Container, {
440
418
  ...composableProps(props),
@@ -462,7 +440,7 @@ var BoardColumnBody = composable(({ data, eventHandler, Tile = BoardItem, debug,
462
440
  BoardColumnBody.displayName = BOARD_COLUMN_BODY_NAME;
463
441
  var BOARD_COLUMN_FOOTER_NAME = "Board.Column.Footer";
464
442
  var BoardColumnFooter = /* @__PURE__ */ forwardRef3(({ classNames, data, onAdd }, forwardedRef) => {
465
- const { t } = useTranslation2(translationKey);
443
+ const { t } = useTranslation2(translationKey2);
466
444
  const { model } = useBoard(BOARD_COLUMN_FOOTER_NAME);
467
445
  const handleAdd = onAdd ?? (model.onItemCreate && data ? () => void model.onItemCreate?.(data) : void 0);
468
446
  return /* @__PURE__ */ React3.createElement(Toolbar2.Root, {
@@ -480,15 +458,15 @@ var BoardColumnFooter = /* @__PURE__ */ forwardRef3(({ classNames, data, onAdd }
480
458
  });
481
459
  BoardColumnFooter.displayName = BOARD_COLUMN_FOOTER_NAME;
482
460
  var BOARD_DEFAULT_COLUMN_NAME = "Board.DefaultColumn";
483
- var DefaultBoardColumn = /* @__PURE__ */ forwardRef3(({ classNames, location, data, debug, Tile = BoardItem }, forwardedRef) => {
461
+ var DefaultBoardColumn = /* @__PURE__ */ forwardRef3(({ classNames, location, data, debug, draggable, Tile = BoardItem }, forwardedRef) => {
484
462
  const { model } = useBoard(BOARD_DEFAULT_COLUMN_NAME);
485
463
  const [DebugInfo, debugHandler] = useContainerDebug(debug);
486
- const dragHandleRef = useRef3(null);
464
+ const [dragHandle, setDragHandle] = useState2(null);
487
465
  const [column, updateColumn] = useObject(data);
488
466
  const eventHandler = useEventHandlerAdapter({
489
467
  id: model.getColumnId(data),
490
468
  items: column?.items ?? [],
491
- getId: (ref) => ref.target?.id ?? ref.dxn.toString(),
469
+ getId: (ref) => ref.target?.id ?? ref.uri,
492
470
  get: (refOrObj) => Ref.isRef(refOrObj) ? refOrObj.target : refOrObj,
493
471
  make: (object) => Ref.make(object),
494
472
  canDrop: ({ source }) => {
@@ -501,18 +479,18 @@ var DefaultBoardColumn = /* @__PURE__ */ forwardRef3(({ classNames, location, da
501
479
  classNames: mx2("group/column grid", debug ? "grid-rows-[var(--dx-rail-action)_1fr_20rem]" : "grid-rows-[var(--dx-rail-action)_1fr_var(--dx-rail-action)]", classNames),
502
480
  location,
503
481
  data,
504
- dragHandleRef,
482
+ draggable,
483
+ dragHandle,
505
484
  ref: forwardedRef
506
485
  }, /* @__PURE__ */ React3.createElement(BoardColumnHeader, {
507
486
  label: Obj2.getLabel(data) ?? data.id,
508
- dragHandleRef
487
+ dragHandleRef: setDragHandle
509
488
  }), /* @__PURE__ */ React3.createElement(BoardColumnBody, {
510
489
  data,
511
490
  eventHandler,
512
491
  debug: debugHandler,
513
492
  Tile
514
493
  }), /* @__PURE__ */ React3.createElement("div", {
515
- role: "none",
516
494
  className: "flex flex-col col-span-full"
517
495
  }, /* @__PURE__ */ React3.createElement(BoardColumnFooter, {
518
496
  data
@@ -544,7 +522,7 @@ var BOARD_CONTENT_NAME = "Board.Content";
544
522
  var BoardContentInner = composable2(({ id: _id, debug, eventHandler, Tile = DefaultBoardColumn, ...props }, forwardedRef) => {
545
523
  const { model } = useBoardContext(BOARD_CONTENT_NAME);
546
524
  const [DebugInfo, debugHandler] = useContainerDebug(debug);
547
- const [viewport, setViewport] = useState2(null);
525
+ const [viewport, setViewport] = useState3(null);
548
526
  const items = useAtomValue2(model.columns);
549
527
  return /* @__PURE__ */ React4.createElement("div", {
550
528
  ...composableProps2(props, {
@@ -590,8 +568,8 @@ BoardPlaceholder.displayName = BOARD_PLACEHOLDER_NAME;
590
568
  var BOARD_DEBUG_NAME = "Board.Debug";
591
569
  var BoardDebug = /* @__PURE__ */ forwardRef4(({ classNames }, forwardedRef) => {
592
570
  const { containers, dragging } = useMosaicRootContext(BOARD_DEBUG_NAME);
593
- const counter = useRef4(0);
594
- return /* @__PURE__ */ React4.createElement(Json2.Data, {
571
+ const counter = useRef3(0);
572
+ return /* @__PURE__ */ React4.createElement(JsonHighlighter2, {
595
573
  data: {
596
574
  containers,
597
575
  dragging,
@@ -610,11 +588,99 @@ var Board = {
610
588
  Placeholder: BoardPlaceholder,
611
589
  Debug: BoardDebug
612
590
  };
591
+
592
+ // src/components/SearchStack/SearchStack.tsx
593
+ import React5, { forwardRef as forwardRef5, useCallback, useMemo as useMemo5, useState as useState4 } from "react";
594
+ import { Card as Card2, ScrollArea as ScrollArea3 } from "@dxos/react-ui";
595
+ import { composable as composable3, composableProps as composableProps3 } from "@dxos/react-ui";
596
+ var SearchStack = composable3(({ results = [], currentId, onAction, ...props }, forwardedRef) => {
597
+ const [viewport, setViewport] = useState4(null);
598
+ const items = useMemo5(() => results.map((result) => ({
599
+ result,
600
+ onAction
601
+ })), [
602
+ results,
603
+ onAction
604
+ ]);
605
+ const handleCurrentChange = useCallback((id) => {
606
+ if (id) {
607
+ onAction?.({
608
+ type: "select",
609
+ resultId: id
610
+ });
611
+ }
612
+ }, [
613
+ onAction
614
+ ]);
615
+ const handleKeyDown = useCallback((event) => {
616
+ if (event.key === "Enter") {
617
+ event.preventDefault();
618
+ document.activeElement?.click();
619
+ }
620
+ }, []);
621
+ return /* @__PURE__ */ React5.createElement(Focus.Group, {
622
+ asChild: true,
623
+ ...composableProps3(props),
624
+ onKeyDown: handleKeyDown,
625
+ ref: forwardedRef
626
+ }, /* @__PURE__ */ React5.createElement(Mosaic.Container, {
627
+ asChild: true,
628
+ withFocus: true,
629
+ currentId,
630
+ onCurrentChange: handleCurrentChange
631
+ }, /* @__PURE__ */ React5.createElement(ScrollArea3.Root, {
632
+ orientation: "vertical",
633
+ padding: true,
634
+ centered: true,
635
+ thin: true
636
+ }, /* @__PURE__ */ React5.createElement(ScrollArea3.Viewport, {
637
+ ref: setViewport
638
+ }, /* @__PURE__ */ React5.createElement(Mosaic.VirtualStack, {
639
+ Tile: SearchTile,
640
+ classNames: "my-2",
641
+ gap: 8,
642
+ items,
643
+ draggable: false,
644
+ getId: (item) => item.result.id,
645
+ getScrollElement: () => viewport,
646
+ estimateSize: () => 100
647
+ })))));
648
+ });
649
+ SearchStack.displayName = "SearchStack";
650
+ var SearchTile = /* @__PURE__ */ forwardRef5(({ data, location, current }, forwardedRef) => {
651
+ const { result } = data;
652
+ const { setCurrentId } = useMosaicContainerContext("SearchTile");
653
+ const handleCurrentChange = useCallback(() => {
654
+ setCurrentId(result.id);
655
+ }, [
656
+ result.id,
657
+ setCurrentId
658
+ ]);
659
+ return /* @__PURE__ */ React5.createElement(Mosaic.Tile, {
660
+ asChild: true,
661
+ classNames: "dx-hover dx-current",
662
+ id: result.id,
663
+ data,
664
+ location,
665
+ current
666
+ }, /* @__PURE__ */ React5.createElement(Focus.Item, {
667
+ asChild: true,
668
+ current,
669
+ onCurrentChange: handleCurrentChange
670
+ }, /* @__PURE__ */ React5.createElement(Card2.Root, {
671
+ fullWidth: true,
672
+ ref: forwardedRef
673
+ }, /* @__PURE__ */ React5.createElement(Card2.Header, null, /* @__PURE__ */ React5.createElement(Card2.IconBlock, null), /* @__PURE__ */ React5.createElement(Card2.Title, null, result.label)), result.snippet && /* @__PURE__ */ React5.createElement(Card2.Body, null, /* @__PURE__ */ React5.createElement(Card2.Row, null, /* @__PURE__ */ React5.createElement(Card2.Text, {
674
+ variant: "description"
675
+ }, result.snippet))))));
676
+ });
677
+ SearchTile.displayName = "SearchTile";
613
678
  export {
614
679
  Board,
615
680
  BoardDebug,
616
681
  Focus,
617
682
  Mosaic,
683
+ SearchStack,
618
684
  dropHandler,
619
685
  getSourceData,
620
686
  styles as mosaicStyles,