@dxos/react-ui-mosaic 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef
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/dist/lib/browser/{chunk-33NNDFD6.mjs → chunk-TY4RYZ3H.mjs} +16 -62
- package/dist/lib/browser/chunk-TY4RYZ3H.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +99 -33
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +3 -3
- 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-25RXZ2RH.mjs} +16 -62
- package/dist/lib/node-esm/chunk-25RXZ2RH.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +99 -33
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +3 -3
- 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 +11 -3
- 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 +2 -2
- package/dist/types/src/components/Board/Column.d.ts.map +1 -1
- package/dist/types/src/components/Board/Item.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Container.d.ts +1 -1
- package/dist/types/src/components/Mosaic/Mosaic.d.ts +2 -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 +2 -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.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 +37 -35
- package/src/components/Board/Board.stories.tsx +7 -4
- package/src/components/Board/Board.tsx +2 -2
- package/src/components/Board/Column.tsx +2 -1
- package/src/components/Board/Item.tsx +2 -1
- package/src/components/Mosaic/Tile.tsx +6 -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 +2 -2
- package/src/hooks/useEventHandlerAdapter.ts +1 -1
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-mosaic",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.abd8ff62ef",
|
|
4
4
|
"description": "Modular UI components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"author": "DXOS.org",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"type": "module",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#translations": "./src/translations.ts"
|
|
17
|
+
},
|
|
15
18
|
"exports": {
|
|
16
19
|
".": {
|
|
17
20
|
"source": "./src/index.ts",
|
|
@@ -30,19 +33,15 @@
|
|
|
30
33
|
"types": "./dist/types/src/testing/index.d.ts",
|
|
31
34
|
"browser": "./dist/lib/browser/testing/index.mjs",
|
|
32
35
|
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./translations": {
|
|
38
|
+
"source": "./src/translations.ts",
|
|
39
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
40
|
+
"browser": "./dist/lib/browser/translations.mjs",
|
|
41
|
+
"node": "./dist/lib/node-esm/translations.mjs"
|
|
33
42
|
}
|
|
34
43
|
},
|
|
35
44
|
"types": "dist/types/src/index.d.ts",
|
|
36
|
-
"typesVersions": {
|
|
37
|
-
"*": {
|
|
38
|
-
"playwright": [
|
|
39
|
-
"dist/types/src/playwright/index.d.ts"
|
|
40
|
-
],
|
|
41
|
-
"testing": [
|
|
42
|
-
"dist/types/src/testing/index.d.ts"
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
45
|
"files": [
|
|
47
46
|
"dist",
|
|
48
47
|
"src"
|
|
@@ -62,17 +61,20 @@
|
|
|
62
61
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
63
62
|
"@tanstack/react-virtual": "^3.13.18",
|
|
64
63
|
"bind-event-listener": "^3.0.0",
|
|
65
|
-
"@dxos/async": "0.8.4-main.
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/react-
|
|
71
|
-
"@dxos/react-ui-
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/ui-
|
|
75
|
-
"@dxos/react-ui-
|
|
64
|
+
"@dxos/async": "0.8.4-main.abd8ff62ef",
|
|
65
|
+
"@dxos/invariant": "0.8.4-main.abd8ff62ef",
|
|
66
|
+
"@dxos/log": "0.8.4-main.abd8ff62ef",
|
|
67
|
+
"@dxos/echo": "0.8.4-main.abd8ff62ef",
|
|
68
|
+
"@dxos/keys": "0.8.4-main.abd8ff62ef",
|
|
69
|
+
"@dxos/react-client": "0.8.4-main.abd8ff62ef",
|
|
70
|
+
"@dxos/react-ui-list": "0.8.4-main.abd8ff62ef",
|
|
71
|
+
"@dxos/react-ui-attention": "0.8.4-main.abd8ff62ef",
|
|
72
|
+
"@dxos/react-ui-dnd": "0.8.4-main.abd8ff62ef",
|
|
73
|
+
"@dxos/react-ui-menu": "0.8.4-main.abd8ff62ef",
|
|
74
|
+
"@dxos/react-ui-search": "0.8.4-main.abd8ff62ef",
|
|
75
|
+
"@dxos/ui-theme": "0.8.4-main.abd8ff62ef",
|
|
76
|
+
"@dxos/util": "0.8.4-main.abd8ff62ef",
|
|
77
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.abd8ff62ef"
|
|
76
78
|
},
|
|
77
79
|
"devDependencies": {
|
|
78
80
|
"@effect-atom/atom-react": "^0.5.0",
|
|
@@ -81,25 +83,25 @@
|
|
|
81
83
|
"effect": "3.20.0",
|
|
82
84
|
"react": "~19.2.3",
|
|
83
85
|
"react-dom": "~19.2.3",
|
|
84
|
-
"vite": "^
|
|
85
|
-
"@dxos/
|
|
86
|
-
"@dxos/
|
|
87
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
88
|
-
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.
|
|
89
|
-
"@dxos/schema": "0.8.4-main.
|
|
90
|
-
"@dxos/
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
93
|
-
"@dxos/
|
|
86
|
+
"vite": "^8.0.10",
|
|
87
|
+
"@dxos/echo-atom": "0.8.4-main.abd8ff62ef",
|
|
88
|
+
"@dxos/random": "0.8.4-main.abd8ff62ef",
|
|
89
|
+
"@dxos/react-ui": "0.8.4-main.abd8ff62ef",
|
|
90
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.abd8ff62ef",
|
|
91
|
+
"@dxos/schema": "0.8.4-main.abd8ff62ef",
|
|
92
|
+
"@dxos/test-utils": "0.8.4-main.abd8ff62ef",
|
|
93
|
+
"@dxos/storybook-utils": "0.8.4-main.abd8ff62ef",
|
|
94
|
+
"@dxos/ui-theme": "0.8.4-main.abd8ff62ef",
|
|
95
|
+
"@dxos/types": "0.8.4-main.abd8ff62ef"
|
|
94
96
|
},
|
|
95
97
|
"peerDependencies": {
|
|
96
98
|
"@effect-atom/atom-react": "^0.5.0",
|
|
97
99
|
"effect": "3.20.0",
|
|
98
100
|
"react": "~19.2.3",
|
|
99
101
|
"react-dom": "~19.2.3",
|
|
100
|
-
"@dxos/random": "0.8.4-main.
|
|
101
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
102
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
102
|
+
"@dxos/random": "0.8.4-main.abd8ff62ef",
|
|
103
|
+
"@dxos/react-ui": "0.8.4-main.abd8ff62ef",
|
|
104
|
+
"@dxos/ui-theme": "0.8.4-main.abd8ff62ef"
|
|
103
105
|
},
|
|
104
106
|
"publishConfig": {
|
|
105
107
|
"access": "public"
|
|
@@ -16,9 +16,10 @@ import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
|
16
16
|
import { withRegistry } from '@dxos/storybook-utils';
|
|
17
17
|
import { mx } from '@dxos/ui-theme';
|
|
18
18
|
|
|
19
|
+
import { translations } from '#translations';
|
|
20
|
+
|
|
19
21
|
import { useEventHandlerAdapter } from '../../hooks';
|
|
20
22
|
import { TestColumn, TestItem } from '../../testing';
|
|
21
|
-
import { translations } from '../../translations';
|
|
22
23
|
import { Focus } from '../Focus';
|
|
23
24
|
import { Mosaic, type MosaicEventHandler } from '../Mosaic';
|
|
24
25
|
import { Board, type BoardModel } from './Board';
|
|
@@ -79,7 +80,9 @@ const useTestBoardModel = (): TestBoardModelResult => {
|
|
|
79
80
|
const orderedColumnsAtom = Atom.make((get) => {
|
|
80
81
|
const cols = get(columnsAtom);
|
|
81
82
|
const order = get(orderAtom);
|
|
82
|
-
if (order.length === 0)
|
|
83
|
+
if (order.length === 0) {
|
|
84
|
+
return cols;
|
|
85
|
+
}
|
|
83
86
|
const byId = new Map(cols.map((column) => [getColumnId(column), column]));
|
|
84
87
|
const ordered = order.map((id) => byId.get(id)).filter((column): column is TestColumn => column != null);
|
|
85
88
|
const appended = cols.filter((column) => !order.includes(getColumnId(column)));
|
|
@@ -118,14 +121,14 @@ const useTestBoardModel = (): TestBoardModelResult => {
|
|
|
118
121
|
}),
|
|
119
122
|
);
|
|
120
123
|
|
|
121
|
-
Obj.
|
|
124
|
+
Obj.update(column, (column) => {
|
|
122
125
|
column.items.push(Ref.make(item));
|
|
123
126
|
});
|
|
124
127
|
|
|
125
128
|
return item;
|
|
126
129
|
},
|
|
127
130
|
onItemDelete: (column: TestColumn, current: TestItem) => {
|
|
128
|
-
Obj.
|
|
131
|
+
Obj.update(column, (column) => {
|
|
129
132
|
if (!column.items) {
|
|
130
133
|
return;
|
|
131
134
|
}
|
|
@@ -14,7 +14,7 @@ import React, {
|
|
|
14
14
|
} from 'react';
|
|
15
15
|
|
|
16
16
|
import { ScrollArea, type ThemedClassName } from '@dxos/react-ui';
|
|
17
|
-
import {
|
|
17
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
18
18
|
import { composable, composableProps, mx } from '@dxos/ui-theme';
|
|
19
19
|
|
|
20
20
|
import { useContainerDebug } from '../../hooks';
|
|
@@ -162,7 +162,7 @@ export const BoardDebug = forwardRef<HTMLDivElement, ThemedClassName>(({ classNa
|
|
|
162
162
|
const { containers, dragging } = useMosaic(BOARD_DEBUG_NAME);
|
|
163
163
|
const counter = useRef(0);
|
|
164
164
|
return (
|
|
165
|
-
<
|
|
165
|
+
<JsonHighlighter
|
|
166
166
|
data={{ containers, dragging, count: counter.current++ }}
|
|
167
167
|
classNames={mx('text-xs', classNames)}
|
|
168
168
|
ref={forwardedRef}
|
|
@@ -21,8 +21,9 @@ import { IconButton, ScrollArea, type ThemedClassName, Toolbar, useTranslation }
|
|
|
21
21
|
import { Menu, createMenuAction } from '@dxos/react-ui-menu';
|
|
22
22
|
import { composable, composableProps, mx } from '@dxos/ui-theme';
|
|
23
23
|
|
|
24
|
+
import { translationKey } from '#translations';
|
|
25
|
+
|
|
24
26
|
import { useContainerDebug, useEventHandlerAdapter } from '../../hooks';
|
|
25
|
-
import { translationKey } from '../../translations';
|
|
26
27
|
import { Focus } from '../Focus';
|
|
27
28
|
import { Mosaic, type MosaicContainerProps, type MosaicStackProps, type MosaicTileProps } from '../Mosaic';
|
|
28
29
|
import { useBoard } from './Board';
|
|
@@ -10,7 +10,8 @@ import { Card, Tag, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
|
10
10
|
import { Menu, createMenuAction } from '@dxos/react-ui-menu';
|
|
11
11
|
import { getHashStyles } from '@dxos/ui-theme';
|
|
12
12
|
|
|
13
|
-
import { translationKey } from '
|
|
13
|
+
import { translationKey } from '#translations';
|
|
14
|
+
|
|
14
15
|
import { Focus } from '../Focus';
|
|
15
16
|
import { Mosaic, type MosaicTileProps } from '../Mosaic';
|
|
16
17
|
import { useBoard } from './Board';
|
|
@@ -76,7 +76,7 @@ const MosaicTile = slottable<HTMLDivElement, MosaicTileProps>(
|
|
|
76
76
|
id,
|
|
77
77
|
data: dataProp,
|
|
78
78
|
draggable: draggableProp,
|
|
79
|
-
current
|
|
79
|
+
current,
|
|
80
80
|
debug: _,
|
|
81
81
|
...props
|
|
82
82
|
},
|
|
@@ -211,6 +211,11 @@ const MosaicTile = slottable<HTMLDivElement, MosaicTileProps>(
|
|
|
211
211
|
[`data-${MOSAIC_TILE_STATE_ATTR}`]: state.type,
|
|
212
212
|
}}
|
|
213
213
|
role='listitem'
|
|
214
|
+
// Pair `current` prop with `aria-current="true"` so the
|
|
215
|
+
// `dx-current` utility (which keys off `aria-[current=true]:`)
|
|
216
|
+
// actually fires. Without this the prop is purely advisory and
|
|
217
|
+
// any `dx-current` styling on the tile would silently no-op.
|
|
218
|
+
aria-current={current ? 'true' : undefined}
|
|
214
219
|
className={className}
|
|
215
220
|
ref={composedRef}
|
|
216
221
|
>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
9
|
+
import { withMosaic } from '@dxos/react-ui-mosaic/testing';
|
|
10
|
+
import { type SearchResult } from '@dxos/react-ui-search';
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
|
+
|
|
13
|
+
import { SearchStack, type SearchStackProps } from './SearchStack';
|
|
14
|
+
|
|
15
|
+
const createMockResults = (count: number): SearchResult[] => {
|
|
16
|
+
return Array.from({ length: count }, (_, index) => ({
|
|
17
|
+
id: `result-${index}`,
|
|
18
|
+
label: `Search Result ${index + 1}`,
|
|
19
|
+
snippet: index % 2 === 0 ? `This is a preview snippet for result ${index + 1}.` : undefined,
|
|
20
|
+
type: index % 3 === 0 ? 'document' : index % 3 === 1 ? 'contact' : 'project',
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const SearchStackStory = (props: Omit<SearchStackProps, 'id' | 'results'>) => {
|
|
25
|
+
const results = useMemo(() => createMockResults(50), []);
|
|
26
|
+
return <SearchStack id='story' results={results} {...props} />;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const meta: Meta<typeof SearchStackStory> = {
|
|
30
|
+
title: 'ui/react-ui-search/SearchStack',
|
|
31
|
+
component: SearchStackStory,
|
|
32
|
+
parameters: {
|
|
33
|
+
layout: 'fullscreen',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default meta;
|
|
38
|
+
|
|
39
|
+
type Story = StoryObj<typeof meta>;
|
|
40
|
+
|
|
41
|
+
export const Default: Story = {
|
|
42
|
+
decorators: [withTheme(), withLayout({ layout: 'column' }), withAttention(), withMosaic()],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const Responsive: Story = {
|
|
46
|
+
decorators: [withTheme(), withLayout({ layout: 'column', classNames: 'w-[30rem]' }), withAttention(), withMosaic()],
|
|
47
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type KeyboardEvent, forwardRef, useCallback, useMemo, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Card, ScrollArea } from '@dxos/react-ui';
|
|
8
|
+
import { type SearchResult } from '@dxos/react-ui-search';
|
|
9
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
10
|
+
|
|
11
|
+
import { Focus, Mosaic, type MosaicTileProps, useMosaicContainer } from '../..';
|
|
12
|
+
|
|
13
|
+
export type SearchStackAction = {
|
|
14
|
+
type: 'select';
|
|
15
|
+
resultId: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type SearchStackActionHandler = (action: SearchStackAction) => void;
|
|
19
|
+
|
|
20
|
+
//
|
|
21
|
+
// SearchStack
|
|
22
|
+
//
|
|
23
|
+
|
|
24
|
+
export type SearchStackProps = {
|
|
25
|
+
id: string;
|
|
26
|
+
results?: SearchResult[];
|
|
27
|
+
currentId?: string;
|
|
28
|
+
onAction?: SearchStackActionHandler;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Card-based search result stack component using mosaic layout.
|
|
33
|
+
*/
|
|
34
|
+
export const SearchStack = composable<HTMLDivElement, SearchStackProps>(
|
|
35
|
+
({ results = [], currentId, onAction, ...props }, forwardedRef) => {
|
|
36
|
+
const [viewport, setViewport] = useState<HTMLElement | null>(null);
|
|
37
|
+
const items = useMemo(() => results.map((result) => ({ result, onAction })), [results, onAction]);
|
|
38
|
+
|
|
39
|
+
const handleCurrentChange = useCallback(
|
|
40
|
+
(id: string | undefined) => {
|
|
41
|
+
if (id) {
|
|
42
|
+
onAction?.({ type: 'select', resultId: id });
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
[onAction],
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const handleKeyDown = useCallback((event: KeyboardEvent<HTMLDivElement>) => {
|
|
49
|
+
if (event.key === 'Enter') {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
(document.activeElement as HTMLElement | null)?.click();
|
|
52
|
+
}
|
|
53
|
+
}, []);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Focus.Group asChild {...composableProps(props)} onKeyDown={handleKeyDown} ref={forwardedRef}>
|
|
57
|
+
<Mosaic.Container asChild withFocus currentId={currentId} onCurrentChange={handleCurrentChange}>
|
|
58
|
+
<ScrollArea.Root orientation='vertical' padding centered thin>
|
|
59
|
+
<ScrollArea.Viewport ref={setViewport}>
|
|
60
|
+
<Mosaic.VirtualStack
|
|
61
|
+
Tile={SearchTile}
|
|
62
|
+
classNames='my-2'
|
|
63
|
+
gap={8}
|
|
64
|
+
items={items}
|
|
65
|
+
draggable={false}
|
|
66
|
+
getId={(item) => item.result.id}
|
|
67
|
+
getScrollElement={() => viewport}
|
|
68
|
+
estimateSize={() => 100}
|
|
69
|
+
/>
|
|
70
|
+
</ScrollArea.Viewport>
|
|
71
|
+
</ScrollArea.Root>
|
|
72
|
+
</Mosaic.Container>
|
|
73
|
+
</Focus.Group>
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
SearchStack.displayName = 'SearchStack';
|
|
79
|
+
|
|
80
|
+
//
|
|
81
|
+
// SearchTile
|
|
82
|
+
//
|
|
83
|
+
|
|
84
|
+
type SearchTileData = {
|
|
85
|
+
result: SearchResult;
|
|
86
|
+
onAction?: SearchStackActionHandler;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
type SearchTileProps = Pick<MosaicTileProps<SearchTileData>, 'location' | 'data' | 'current'>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Default search result tile with a simple Card header.
|
|
93
|
+
*/
|
|
94
|
+
const SearchTile = forwardRef<HTMLDivElement, SearchTileProps>(({ data, location, current }, forwardedRef) => {
|
|
95
|
+
const { result } = data;
|
|
96
|
+
const { setCurrentId } = useMosaicContainer('SearchTile');
|
|
97
|
+
|
|
98
|
+
const handleCurrentChange = useCallback(() => {
|
|
99
|
+
setCurrentId(result.id);
|
|
100
|
+
}, [result.id, setCurrentId]);
|
|
101
|
+
|
|
102
|
+
// Navigation / current pattern: clicking a result navigates to its
|
|
103
|
+
// detail. `dx-current` pairs with the `aria-current` attribute that
|
|
104
|
+
// `Mosaic.Tile` now sets from the `current` prop. `dx-selected`
|
|
105
|
+
// (master/detail option pattern) would be the wrong grammar here.
|
|
106
|
+
// See `ui-theme/src/css/components/selected.md`.
|
|
107
|
+
return (
|
|
108
|
+
<Mosaic.Tile
|
|
109
|
+
asChild
|
|
110
|
+
classNames='dx-hover dx-current'
|
|
111
|
+
id={result.id}
|
|
112
|
+
data={data}
|
|
113
|
+
location={location}
|
|
114
|
+
current={current}
|
|
115
|
+
>
|
|
116
|
+
<Focus.Item asChild current={current} onCurrentChange={handleCurrentChange}>
|
|
117
|
+
<Card.Root fullWidth ref={forwardedRef}>
|
|
118
|
+
<Card.Toolbar>
|
|
119
|
+
<Card.IconBlock />
|
|
120
|
+
<Card.Title>{result.label}</Card.Title>
|
|
121
|
+
</Card.Toolbar>
|
|
122
|
+
{result.snippet && (
|
|
123
|
+
<Card.Content>
|
|
124
|
+
<Card.Row>
|
|
125
|
+
<Card.Text variant='description'>{result.snippet}</Card.Text>
|
|
126
|
+
</Card.Row>
|
|
127
|
+
</Card.Content>
|
|
128
|
+
)}
|
|
129
|
+
</Card.Root>
|
|
130
|
+
</Focus.Item>
|
|
131
|
+
</Mosaic.Tile>
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
SearchTile.displayName = 'SearchTile';
|
package/src/components/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import React, { type FC, type ReactNode, forwardRef, useMemo, useRef } from 'rea
|
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
|
|
8
8
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
-
import {
|
|
9
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
10
10
|
import { mx } from '@dxos/ui-theme';
|
|
11
11
|
|
|
12
12
|
import { useMosaicContainer } from '../components';
|
|
@@ -37,7 +37,7 @@ const ContainerInfo = forwardRef<HTMLDivElement, ThemedClassName>(({ classNames
|
|
|
37
37
|
const { id, state, activeLocation, scrolling } = useMosaicContainer(CONTAINER_INFO_NAME);
|
|
38
38
|
const counter = useRef(0);
|
|
39
39
|
return (
|
|
40
|
-
<
|
|
40
|
+
<JsonHighlighter
|
|
41
41
|
data={{ id, activeLocation, scrolling, state, count: counter.current++ }}
|
|
42
42
|
classNames={mx('text-xs', classNames)}
|
|
43
43
|
ref={forwardedRef}
|
|
@@ -35,7 +35,7 @@ export type UseEventHandlerProps<TItem = any, TObject extends Obj.Unknown = Obj.
|
|
|
35
35
|
make: (object: TObject) => TItem;
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* Optional change callback for wrapping mutations in Obj.
|
|
38
|
+
* Optional change callback for wrapping mutations in Obj.update style.
|
|
39
39
|
* When provided, all array mutations will be wrapped in this callback.
|
|
40
40
|
* When not provided, mutations happen directly on the items array.
|
|
41
41
|
*/
|
|
@@ -7,7 +7,7 @@ import React, { useMemo, useRef, useState } from 'react';
|
|
|
7
7
|
import { Obj } from '@dxos/echo';
|
|
8
8
|
import { Card, Toolbar } from '@dxos/react-ui';
|
|
9
9
|
import { Menu, createMenuAction } from '@dxos/react-ui-menu';
|
|
10
|
-
import {
|
|
10
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
11
11
|
|
|
12
12
|
import { Focus, Mosaic, type MosaicStackTileComponent } from '../components';
|
|
13
13
|
|
|
@@ -26,6 +26,12 @@ export const DefaultStackTile: MosaicStackTileComponent<Obj.Any> = (props) => {
|
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
28
|
<Menu.Root>
|
|
29
|
+
{/*
|
|
30
|
+
* `Mosaic.Tile` sets `aria-current` from `props.current`, which the
|
|
31
|
+
* Slot composition propagates down to `Card.Root`'s div. That's what
|
|
32
|
+
* makes `dx-current` (an `aria-[current=true]:` utility) actually
|
|
33
|
+
* fire here. See `ui-theme/src/css/components/selected.md`.
|
|
34
|
+
*/}
|
|
29
35
|
<Mosaic.Tile {...props} asChild>
|
|
30
36
|
<Focus.Item asChild>
|
|
31
37
|
<Card.Root className='dx-current dx-hover'>
|
|
@@ -39,7 +45,7 @@ export const DefaultStackTile: MosaicStackTileComponent<Obj.Any> = (props) => {
|
|
|
39
45
|
</Card.Toolbar>
|
|
40
46
|
{open && (
|
|
41
47
|
<Card.Row>
|
|
42
|
-
<
|
|
48
|
+
<JsonHighlighter data={props.data} classNames='text-xs' />
|
|
43
49
|
</Card.Row>
|
|
44
50
|
)}
|
|
45
51
|
</Card.Root>
|