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