@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
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.bc2380dfbc",
|
|
4
4
|
"description": "Modular UI components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -8,10 +8,13 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/dxos/dxos"
|
|
10
10
|
},
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
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"
|
|
@@ -53,8 +52,9 @@
|
|
|
53
52
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "1.1.0",
|
|
54
53
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "3.2.10",
|
|
55
54
|
"@codemirror/state": "^6.5.2",
|
|
56
|
-
"@codemirror/view": "^6.38.
|
|
55
|
+
"@codemirror/view": "^6.38.5",
|
|
57
56
|
"@fluentui/react-tabster": "9.26.11",
|
|
57
|
+
"@playwright/test": "1.57.0",
|
|
58
58
|
"@radix-ui/react-compose-refs": "1.1.1",
|
|
59
59
|
"@radix-ui/react-context": "1.1.1",
|
|
60
60
|
"@radix-ui/react-primitive": "2.0.2",
|
|
@@ -62,17 +62,20 @@
|
|
|
62
62
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
63
63
|
"@tanstack/react-virtual": "^3.13.18",
|
|
64
64
|
"bind-event-listener": "^3.0.0",
|
|
65
|
-
"@dxos/async": "0.8.4-main.
|
|
66
|
-
"@dxos/echo": "0.8.4-main.
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/log": "0.8.4-main.
|
|
69
|
-
"@dxos/react-client": "0.8.4-main.
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/react-ui-
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/ui-
|
|
75
|
-
"@dxos/react-ui-
|
|
65
|
+
"@dxos/async": "0.8.4-main.bc2380dfbc",
|
|
66
|
+
"@dxos/echo": "0.8.4-main.bc2380dfbc",
|
|
67
|
+
"@dxos/keys": "0.8.4-main.bc2380dfbc",
|
|
68
|
+
"@dxos/log": "0.8.4-main.bc2380dfbc",
|
|
69
|
+
"@dxos/react-client": "0.8.4-main.bc2380dfbc",
|
|
70
|
+
"@dxos/invariant": "0.8.4-main.bc2380dfbc",
|
|
71
|
+
"@dxos/react-ui-attention": "0.8.4-main.bc2380dfbc",
|
|
72
|
+
"@dxos/react-ui-dnd": "0.8.4-main.bc2380dfbc",
|
|
73
|
+
"@dxos/react-ui-list": "0.8.4-main.bc2380dfbc",
|
|
74
|
+
"@dxos/react-ui-search": "0.8.4-main.bc2380dfbc",
|
|
75
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.bc2380dfbc",
|
|
76
|
+
"@dxos/ui-theme": "0.8.4-main.bc2380dfbc",
|
|
77
|
+
"@dxos/util": "0.8.4-main.bc2380dfbc",
|
|
78
|
+
"@dxos/react-ui-menu": "0.8.4-main.bc2380dfbc"
|
|
76
79
|
},
|
|
77
80
|
"devDependencies": {
|
|
78
81
|
"@effect-atom/atom-react": "^0.5.0",
|
|
@@ -81,25 +84,25 @@
|
|
|
81
84
|
"effect": "3.20.0",
|
|
82
85
|
"react": "~19.2.3",
|
|
83
86
|
"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/
|
|
90
|
-
"@dxos/
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/
|
|
87
|
+
"vite": "^8.0.13",
|
|
88
|
+
"@dxos/echo-atom": "0.8.4-main.bc2380dfbc",
|
|
89
|
+
"@dxos/random": "0.8.4-main.bc2380dfbc",
|
|
90
|
+
"@dxos/react-ui": "0.8.4-main.bc2380dfbc",
|
|
91
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.bc2380dfbc",
|
|
92
|
+
"@dxos/storybook-utils": "0.8.4-main.bc2380dfbc",
|
|
93
|
+
"@dxos/schema": "0.8.4-main.bc2380dfbc",
|
|
94
|
+
"@dxos/test-utils": "0.8.4-main.bc2380dfbc",
|
|
95
|
+
"@dxos/types": "0.8.4-main.bc2380dfbc",
|
|
96
|
+
"@dxos/ui-theme": "0.8.4-main.bc2380dfbc"
|
|
94
97
|
},
|
|
95
98
|
"peerDependencies": {
|
|
96
99
|
"@effect-atom/atom-react": "^0.5.0",
|
|
97
100
|
"effect": "3.20.0",
|
|
98
101
|
"react": "~19.2.3",
|
|
99
102
|
"react-dom": "~19.2.3",
|
|
100
|
-
"@dxos/random": "0.8.4-main.
|
|
101
|
-
"@dxos/
|
|
102
|
-
"@dxos/ui
|
|
103
|
+
"@dxos/random": "0.8.4-main.bc2380dfbc",
|
|
104
|
+
"@dxos/ui-theme": "0.8.4-main.bc2380dfbc",
|
|
105
|
+
"@dxos/react-ui": "0.8.4-main.bc2380dfbc"
|
|
103
106
|
},
|
|
104
107
|
"publishConfig": {
|
|
105
108
|
"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
|
}
|
|
@@ -172,7 +175,7 @@ const DefaultStory = ({ debug = false, columns: columnsProp = 0 }: DefaultStoryP
|
|
|
172
175
|
|
|
173
176
|
return (
|
|
174
177
|
<Mosaic.Root asChild debug={debug}>
|
|
175
|
-
<div
|
|
178
|
+
<div className={mx('grid md:p-2 overflow-hidden', debug && 'grid-cols-[1fr_20rem] gap-2')}>
|
|
176
179
|
<Board.Root model={model}>
|
|
177
180
|
<Board.Content id='board' debug={debug} eventHandler={eventHandler} Tile={DefaultBoardColumn} />
|
|
178
181
|
</Board.Root>
|
|
@@ -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}
|
|
@@ -8,10 +8,8 @@ import React, {
|
|
|
8
8
|
type PropsWithChildren,
|
|
9
9
|
type ReactElement,
|
|
10
10
|
type Ref as ReactRef,
|
|
11
|
-
type RefObject,
|
|
12
11
|
forwardRef,
|
|
13
12
|
useMemo,
|
|
14
|
-
useRef,
|
|
15
13
|
useState,
|
|
16
14
|
} from 'react';
|
|
17
15
|
|
|
@@ -21,8 +19,9 @@ import { IconButton, ScrollArea, type ThemedClassName, Toolbar, useTranslation }
|
|
|
21
19
|
import { Menu, createMenuAction } from '@dxos/react-ui-menu';
|
|
22
20
|
import { composable, composableProps, mx } from '@dxos/ui-theme';
|
|
23
21
|
|
|
22
|
+
import { translationKey } from '#translations';
|
|
23
|
+
|
|
24
24
|
import { useContainerDebug, useEventHandlerAdapter } from '../../hooks';
|
|
25
|
-
import { translationKey } from '../../translations';
|
|
26
25
|
import { Focus } from '../Focus';
|
|
27
26
|
import { Mosaic, type MosaicContainerProps, type MosaicStackProps, type MosaicTileProps } from '../Mosaic';
|
|
28
27
|
import { useBoard } from './Board';
|
|
@@ -49,7 +48,10 @@ export function useBoardColumn<TColumn = unknown>(): TColumn | undefined {
|
|
|
49
48
|
return value?.column as TColumn | undefined;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
type BoardColumnProps<TColumn = any> = Pick<
|
|
51
|
+
type BoardColumnProps<TColumn = any> = Pick<
|
|
52
|
+
MosaicTileProps<TColumn>,
|
|
53
|
+
'classNames' | 'location' | 'data' | 'debug' | 'draggable'
|
|
54
|
+
>;
|
|
53
55
|
|
|
54
56
|
//
|
|
55
57
|
// Column Root
|
|
@@ -58,17 +60,16 @@ type BoardColumnProps<TColumn = any> = Pick<MosaicTileProps<TColumn>, 'className
|
|
|
58
60
|
const BOARD_COLUMN_ROOT_NAME = 'Board.Column.Root';
|
|
59
61
|
|
|
60
62
|
type BoardColumnRootProps<TColumn = any> = PropsWithChildren<BoardColumnProps<TColumn>> & {
|
|
61
|
-
|
|
63
|
+
// Pass the actual button element (not a ref). Refs don't trigger re-renders, so reading
|
|
64
|
+
// `ref.current` at render time leaves Mosaic.Tile's `dragHandle` prop null forever.
|
|
65
|
+
// Consumers should track this with `useState` and a callback ref on `Board.Column.Header`.
|
|
66
|
+
dragHandle?: HTMLButtonElement | null;
|
|
62
67
|
};
|
|
63
68
|
|
|
64
69
|
const BoardColumnRootInner = composable<HTMLDivElement, BoardColumnRootProps>(
|
|
65
|
-
({ classNames, children, location, data, debug,
|
|
70
|
+
({ classNames, children, location, data, debug, draggable, dragHandle, ...rest }, forwardedRef) => {
|
|
66
71
|
const { model } = useBoard(BOARD_COLUMN_ROOT_NAME);
|
|
67
72
|
|
|
68
|
-
// TODO(burdon): Use merge ref hook (see react-hooks).
|
|
69
|
-
const internalRef = useRef<HTMLButtonElement>(null);
|
|
70
|
-
const dragHandleRef = dragHandleRefProp ?? internalRef;
|
|
71
|
-
|
|
72
73
|
return (
|
|
73
74
|
<Mosaic.Tile
|
|
74
75
|
asChild
|
|
@@ -76,7 +77,8 @@ const BoardColumnRootInner = composable<HTMLDivElement, BoardColumnRootProps>(
|
|
|
76
77
|
id={model.getColumnId(data)}
|
|
77
78
|
data={data}
|
|
78
79
|
debug={debug}
|
|
79
|
-
|
|
80
|
+
draggable={draggable}
|
|
81
|
+
dragHandle={dragHandle}
|
|
80
82
|
>
|
|
81
83
|
<Focus.Group
|
|
82
84
|
{...rest}
|
|
@@ -239,10 +241,10 @@ const BOARD_DEFAULT_COLUMN_NAME = 'Board.DefaultColumn';
|
|
|
239
241
|
type DefaultBoardColumnProps = BoardColumnProps & Pick<BoardColumnBodyProps, 'Tile'>;
|
|
240
242
|
|
|
241
243
|
const DefaultBoardColumn = forwardRef<HTMLDivElement, DefaultBoardColumnProps>(
|
|
242
|
-
({ classNames, location, data, debug, Tile = BoardItem }, forwardedRef) => {
|
|
244
|
+
({ classNames, location, data, debug, draggable, Tile = BoardItem }, forwardedRef) => {
|
|
243
245
|
const { model } = useBoard(BOARD_DEFAULT_COLUMN_NAME);
|
|
244
246
|
const [DebugInfo, debugHandler] = useContainerDebug(debug);
|
|
245
|
-
const
|
|
247
|
+
const [dragHandle, setDragHandle] = useState<HTMLButtonElement | null>(null);
|
|
246
248
|
const [column, updateColumn] = useObject(data);
|
|
247
249
|
|
|
248
250
|
const eventHandler = useEventHandlerAdapter<Ref.Unknown>({
|
|
@@ -269,12 +271,13 @@ const DefaultBoardColumn = forwardRef<HTMLDivElement, DefaultBoardColumnProps>(
|
|
|
269
271
|
)}
|
|
270
272
|
location={location}
|
|
271
273
|
data={data}
|
|
272
|
-
|
|
274
|
+
draggable={draggable}
|
|
275
|
+
dragHandle={dragHandle}
|
|
273
276
|
ref={forwardedRef}
|
|
274
277
|
>
|
|
275
|
-
<BoardColumnHeader label={Obj.getLabel(data) ?? data.id} dragHandleRef={
|
|
278
|
+
<BoardColumnHeader label={Obj.getLabel(data) ?? data.id} dragHandleRef={setDragHandle} />
|
|
276
279
|
<BoardColumnBody data={data} eventHandler={eventHandler} debug={debugHandler} Tile={Tile} />
|
|
277
|
-
<div
|
|
280
|
+
<div className='flex flex-col col-span-full'>
|
|
278
281
|
<BoardColumnFooter data={data} />
|
|
279
282
|
<DebugInfo />
|
|
280
283
|
</div>
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { useComposedRefs } from '@radix-ui/react-compose-refs';
|
|
6
|
-
import React, { type ReactElement, type Ref as ReactRef, forwardRef, useMemo, useRef } from 'react';
|
|
6
|
+
import React, { type ReactElement, type Ref as ReactRef, forwardRef, useMemo, useRef, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Obj } from '@dxos/echo';
|
|
9
9
|
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';
|
|
@@ -20,15 +21,17 @@ const BOARD_ITEM_NAME = 'Board.Item';
|
|
|
20
21
|
|
|
21
22
|
type BoardItemProps<TItem extends Obj.Unknown = any> = Pick<
|
|
22
23
|
MosaicTileProps<TItem>,
|
|
23
|
-
'classNames' | 'location' | 'data' | 'debug'
|
|
24
|
+
'classNames' | 'location' | 'data' | 'debug' | 'draggable'
|
|
24
25
|
>;
|
|
25
26
|
|
|
26
27
|
const BoardItemInner = forwardRef<HTMLDivElement, BoardItemProps>(
|
|
27
|
-
({ classNames, data, location, debug }, forwardedRef) => {
|
|
28
|
+
({ classNames, data, location, debug, draggable }, forwardedRef) => {
|
|
28
29
|
const { t } = useTranslation(translationKey);
|
|
29
30
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
30
31
|
const composedRef = useComposedRefs<HTMLDivElement>(rootRef, forwardedRef);
|
|
31
|
-
|
|
32
|
+
// Use state (callback ref) so the dragHandle prop updates when the button mounts.
|
|
33
|
+
// Refs don't trigger re-renders, so reading `.current` at render time leaves the prop null.
|
|
34
|
+
const [dragHandle, setDragHandle] = useState<HTMLButtonElement | null>(null);
|
|
32
35
|
|
|
33
36
|
const { model } = useBoard(BOARD_ITEM_NAME);
|
|
34
37
|
const column = useBoardColumn();
|
|
@@ -57,7 +60,8 @@ const BoardItemInner = forwardRef<HTMLDivElement, BoardItemProps>(
|
|
|
57
60
|
<Mosaic.Tile
|
|
58
61
|
ref={rootRef}
|
|
59
62
|
asChild
|
|
60
|
-
|
|
63
|
+
draggable={draggable}
|
|
64
|
+
dragHandle={dragHandle}
|
|
61
65
|
id={data.id}
|
|
62
66
|
data={data}
|
|
63
67
|
location={location}
|
|
@@ -71,7 +75,7 @@ const BoardItemInner = forwardRef<HTMLDivElement, BoardItemProps>(
|
|
|
71
75
|
onClick={(event) => event.currentTarget.focus()}
|
|
72
76
|
>
|
|
73
77
|
<Card.Toolbar>
|
|
74
|
-
<Card.DragHandle ref={
|
|
78
|
+
<Card.DragHandle ref={setDragHandle} testId='mosaicBoard.cardDragHandle' />
|
|
75
79
|
<Card.Title data-testid='mosaicBoard.cardTitle'>{label}</Card.Title>
|
|
76
80
|
{/* TODO(wittjosiah): Reconcile with Card.Menu. */}
|
|
77
81
|
<Menu.Trigger asChild disabled={!items?.length}>
|
|
@@ -90,7 +94,7 @@ const BoardItemInner = forwardRef<HTMLDivElement, BoardItemProps>(
|
|
|
90
94
|
</Card.Row>
|
|
91
95
|
<Card.Row icon='ph--tag--regular'>
|
|
92
96
|
{label && (
|
|
93
|
-
<div
|
|
97
|
+
<div className='shrink-0 flex gap-1 items-center text-xs'>
|
|
94
98
|
<Tag palette={getHashStyles(label).hue}>{label}</Tag>
|
|
95
99
|
</div>
|
|
96
100
|
)}
|
|
@@ -60,6 +60,11 @@ type MosaicContainerContextValue<TData = any, Location = LocationType> = {
|
|
|
60
60
|
/** Set the current item by ID. */
|
|
61
61
|
setCurrentId: (id: string | undefined) => void;
|
|
62
62
|
|
|
63
|
+
/** IDs of selected (aria-selected) items. */
|
|
64
|
+
selectedIds?: ReadonlySet<string>;
|
|
65
|
+
/** Request to set or unset selection on an item by ID. */
|
|
66
|
+
setSelected: (id: string, selected: boolean) => void;
|
|
67
|
+
|
|
63
68
|
/** Register a scroll-to-item callback (provided by Stack/VirtualStack). */
|
|
64
69
|
registerScrollTo: (fn: ((id: string) => void) | undefined) => void;
|
|
65
70
|
};
|
|
@@ -86,6 +91,10 @@ type MosaicContainerProps = PropsWithChildren<
|
|
|
86
91
|
currentId?: string;
|
|
87
92
|
/** Called when a tile requests to become current. */
|
|
88
93
|
onCurrentChange?: (id: string | undefined) => void;
|
|
94
|
+
/** Controlled set of selected item IDs. */
|
|
95
|
+
selectedIds?: ReadonlySet<string>;
|
|
96
|
+
/** Called when a tile requests to toggle selection. */
|
|
97
|
+
onSelectionChange?: (id: string, selected: boolean) => void;
|
|
89
98
|
debug?: () => ReactNode;
|
|
90
99
|
}
|
|
91
100
|
>;
|
|
@@ -102,6 +111,8 @@ const MosaicContainer = composable<HTMLDivElement, MosaicContainerProps>(
|
|
|
102
111
|
withFocus,
|
|
103
112
|
currentId,
|
|
104
113
|
onCurrentChange,
|
|
114
|
+
selectedIds,
|
|
115
|
+
onSelectionChange,
|
|
105
116
|
debug,
|
|
106
117
|
...props
|
|
107
118
|
},
|
|
@@ -126,6 +137,10 @@ const MosaicContainer = composable<HTMLDivElement, MosaicContainerProps>(
|
|
|
126
137
|
const [activeLocation, setActiveLocation] = useState<LocationType | undefined>();
|
|
127
138
|
const [scrolling, setScrolling] = useState(false);
|
|
128
139
|
const setCurrentId = useCallback((id: string | undefined) => onCurrentChange?.(id), [onCurrentChange]);
|
|
140
|
+
const setSelected = useCallback(
|
|
141
|
+
(id: string, selected: boolean) => onSelectionChange?.(id, selected),
|
|
142
|
+
[onSelectionChange],
|
|
143
|
+
);
|
|
129
144
|
|
|
130
145
|
// Scroll-to-item: Stack/VirtualStack registers its implementation.
|
|
131
146
|
const scrollToRef = useRef<((id: string) => void) | undefined>(undefined);
|
|
@@ -283,6 +298,8 @@ const MosaicContainer = composable<HTMLDivElement, MosaicContainerProps>(
|
|
|
283
298
|
setActiveLocation={setActiveLocation}
|
|
284
299
|
currentId={currentId}
|
|
285
300
|
setCurrentId={setCurrentId}
|
|
301
|
+
selectedIds={selectedIds}
|
|
302
|
+
setSelected={setSelected}
|
|
286
303
|
registerScrollTo={registerScrollTo}
|
|
287
304
|
>
|
|
288
305
|
<Comp
|
|
@@ -30,6 +30,11 @@ const MOSAIC_PLACEHOLDER_ORIENTATION_ATTR = 'mosaic-placeholder-orientation';
|
|
|
30
30
|
// State attribute: data-[mosaic-placeholder-state=active]
|
|
31
31
|
const MOSAIC_PLACEHOLDER_STATE_ATTR = 'mosaic-placeholder-state';
|
|
32
32
|
|
|
33
|
+
// Location attribute: data-[mosaic-placeholder-location=0.5]. Identifies the
|
|
34
|
+
// placeholder's slot in its container (0.5, 1.5, 2.5, …) so tests can target
|
|
35
|
+
// a specific gap unambiguously without relying on layout-dependent indices.
|
|
36
|
+
const MOSAIC_PLACEHOLDER_LOCATION_ATTR = 'mosaic-placeholder-location';
|
|
37
|
+
|
|
33
38
|
type MosaicPlaceholderProps<Location = LocationType> = ThemedClassName<
|
|
34
39
|
PropsWithChildren<{
|
|
35
40
|
asChild?: boolean;
|
|
@@ -94,6 +99,7 @@ const MosaicPlaceholder = <Location extends LocationType = LocationType>({
|
|
|
94
99
|
{...{
|
|
95
100
|
[`data-${MOSAIC_PLACEHOLDER_ORIENTATION_ATTR}`]: orientation,
|
|
96
101
|
[`data-${MOSAIC_PLACEHOLDER_STATE_ATTR}`]: data.location === activeLocation ? 'active' : 'idle',
|
|
102
|
+
[`data-${MOSAIC_PLACEHOLDER_LOCATION_ATTR}`]: String(location),
|
|
97
103
|
}}
|
|
98
104
|
role='none'
|
|
99
105
|
className={mx('relative', classNames)}
|
|
@@ -85,6 +85,7 @@ const MosaicStackInner = composable<HTMLDivElement, MosaicStackProps>(
|
|
|
85
85
|
orientation = orientationProp,
|
|
86
86
|
dragging,
|
|
87
87
|
currentId,
|
|
88
|
+
selectedIds,
|
|
88
89
|
registerScrollTo,
|
|
89
90
|
} = useMosaicContainerContext(MOSAIC_STACK_NAME);
|
|
90
91
|
const visibleItems = useVisibleItems({ id, items, dragging: dragging?.source.data, getId });
|
|
@@ -130,6 +131,7 @@ const MosaicStackInner = composable<HTMLDivElement, MosaicStackProps>(
|
|
|
130
131
|
location={index + 1}
|
|
131
132
|
draggable={draggable}
|
|
132
133
|
current={getId(item) === currentId}
|
|
134
|
+
selected={selectedIds?.has(getId(item))}
|
|
133
135
|
debug={debug}
|
|
134
136
|
/>
|
|
135
137
|
{draggable && <InternalPlaceholder orientation={orientation} location={index + 1.5} />}
|
|
@@ -178,7 +180,8 @@ const MosaicVirtualStackInner = forwardRef<HTMLDivElement, MosaicVirtualStackPro
|
|
|
178
180
|
forwardedRef,
|
|
179
181
|
) => {
|
|
180
182
|
invariant(Tile);
|
|
181
|
-
const { id, dragging, currentId, registerScrollTo } =
|
|
183
|
+
const { id, dragging, currentId, selectedIds, registerScrollTo } =
|
|
184
|
+
useMosaicContainerContext(MOSAIC_VIRTUAL_STACK_NAME);
|
|
182
185
|
const visibleItems = useVisibleItems({ id, items, dragging: dragging?.source.data, getId });
|
|
183
186
|
// In draggable mode virtual indices alternate: even=placeholder, odd=tile.
|
|
184
187
|
// Wrap estimateSize so placeholders get 0 (their actual negligible height) and
|
|
@@ -293,6 +296,7 @@ const MosaicVirtualStackInner = forwardRef<HTMLDivElement, MosaicVirtualStackPro
|
|
|
293
296
|
location={location}
|
|
294
297
|
draggable={draggable}
|
|
295
298
|
current={getId(data) === currentId}
|
|
299
|
+
selected={selectedIds?.has(getId(data))}
|
|
296
300
|
debug={debug}
|
|
297
301
|
/>
|
|
298
302
|
) : (
|
|
@@ -61,6 +61,8 @@ type MosaicTileProps<TData = any, TLocation = LocationType> = ThemedClassName<
|
|
|
61
61
|
draggable?: boolean;
|
|
62
62
|
/** Whether this tile is the current (aria-current) item. */
|
|
63
63
|
current?: boolean;
|
|
64
|
+
/** Whether this tile is selected (aria-selected). */
|
|
65
|
+
selected?: boolean;
|
|
64
66
|
debug?: boolean;
|
|
65
67
|
}>
|
|
66
68
|
>;
|
|
@@ -76,7 +78,8 @@ const MosaicTile = slottable<HTMLDivElement, MosaicTileProps>(
|
|
|
76
78
|
id,
|
|
77
79
|
data: dataProp,
|
|
78
80
|
draggable: draggableProp,
|
|
79
|
-
current
|
|
81
|
+
current,
|
|
82
|
+
selected,
|
|
80
83
|
debug: _,
|
|
81
84
|
...props
|
|
82
85
|
},
|
|
@@ -211,6 +214,12 @@ const MosaicTile = slottable<HTMLDivElement, MosaicTileProps>(
|
|
|
211
214
|
[`data-${MOSAIC_TILE_STATE_ATTR}`]: state.type,
|
|
212
215
|
}}
|
|
213
216
|
role='listitem'
|
|
217
|
+
// Pair `current` / `selected` props with `aria-current` / `aria-selected`
|
|
218
|
+
// so the `dx-current` / `dx-selected` / `dx-hover` utilities (which key
|
|
219
|
+
// off those attributes) actually fire. Without this the props are purely
|
|
220
|
+
// advisory and the corresponding styling silently no-ops.
|
|
221
|
+
aria-current={current ? 'true' : undefined}
|
|
222
|
+
aria-selected={selected ? 'true' : undefined}
|
|
214
223
|
className={className}
|
|
215
224
|
ref={composedRef}
|
|
216
225
|
>
|
|
@@ -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
|
+
};
|