@dxos/react-ui-mosaic 0.8.4-main.4a85c3132b → 0.8.4-main.4f23b4e393
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-7S4PIFKU.mjs → chunk-3BMPGIWZ.mjs} +245 -226
- package/dist/lib/browser/chunk-3BMPGIWZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +157 -86
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/playwright/index.mjs +108 -15
- package/dist/lib/browser/playwright/index.mjs.map +3 -3
- package/dist/lib/browser/testing/index.mjs +16 -15
- 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-MK6KU66S.mjs → chunk-2UCLTU76.mjs} +245 -226
- package/dist/lib/node-esm/chunk-2UCLTU76.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +157 -86
- 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 +108 -15
- package/dist/lib/node-esm/playwright/index.mjs.map +3 -3
- package/dist/lib/node-esm/testing/index.mjs +16 -15
- 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 +15 -8
- package/dist/types/src/components/Board/Board.d.ts.map +1 -1
- package/dist/types/src/components/Board/Board.stories.d.ts +5 -5
- package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -1
- package/dist/types/src/components/Board/Column.d.ts +12 -12
- package/dist/types/src/components/Board/Column.d.ts.map +1 -1
- package/dist/types/src/components/Board/Item.d.ts +4 -1
- package/dist/types/src/components/Board/Item.d.ts.map +1 -1
- package/dist/types/src/components/Focus/Focus.d.ts +1 -25
- package/dist/types/src/components/Focus/Focus.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Container.d.ts +24 -13
- package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Mosaic.d.ts +13 -27
- 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/Root.d.ts +5 -6
- package/dist/types/src/components/Mosaic/Root.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Stack.d.ts +12 -6
- package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Stack.stories.d.ts +11 -0
- package/dist/types/src/components/Mosaic/Stack.stories.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Tile.d.ts +18 -9
- 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 +41 -38
- package/src/AUDIT.md +106 -0
- package/src/components/Board/Board.stories.tsx +24 -23
- package/src/components/Board/Board.tsx +7 -8
- package/src/components/Board/Column.tsx +60 -56
- package/src/components/Board/Item.tsx +33 -30
- package/src/components/Focus/Focus.tsx +2 -102
- package/src/components/Mosaic/Container.tsx +68 -25
- package/src/components/Mosaic/Placeholder.tsx +7 -1
- package/src/components/Mosaic/Root.tsx +199 -205
- package/src/components/Mosaic/Stack.stories.tsx +125 -69
- package/src/components/Mosaic/Stack.tsx +153 -54
- package/src/components/Mosaic/Tile.tsx +50 -36
- 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/useDefaultColumnEventHandler.ts +0 -1
- package/src/hooks/useEventHandlerAdapter.ts +1 -1
- package/src/playwright/board-manager.ts +156 -23
- package/src/playwright/smoke.spec.ts +10 -5
- package/src/testing/CardContainer.tsx +3 -6
- package/src/testing/DefaultStackTile.tsx +29 -20
- package/src/testing/types.ts +2 -2
- package/src/translations.ts +3 -3
- package/dist/lib/browser/chunk-7S4PIFKU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MK6KU66S.mjs.map +0 -7
|
@@ -22,55 +22,7 @@ var useVisibleItems = ({ id, items, dragging, getId }) => {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
// src/components/Focus/Focus.tsx
|
|
25
|
-
import {
|
|
26
|
-
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
27
|
-
import { Primitive } from "@radix-ui/react-primitive";
|
|
28
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
29
|
-
import React, { createContext, forwardRef, useContext, useRef, useState } from "react";
|
|
30
|
-
import { mx } from "@dxos/ui-theme";
|
|
31
|
-
var FOCUS_STATE_ATTR = "focus-state";
|
|
32
|
-
var FocusContext = /* @__PURE__ */ createContext({});
|
|
33
|
-
var useFocus = () => useContext(FocusContext);
|
|
34
|
-
var Group = /* @__PURE__ */ forwardRef(({ classNames, className, children, asChild, orientation = "vertical", ...props }, forwardedRef) => {
|
|
35
|
-
const rootRef = useRef(null);
|
|
36
|
-
const composedRef = useComposedRefs(rootRef, forwardedRef);
|
|
37
|
-
const Comp = asChild ? Slot : Primitive.div;
|
|
38
|
-
const focusableGroupAttrs = useFocusableGroup({
|
|
39
|
-
tabBehavior: "limited-trap-focus"
|
|
40
|
-
});
|
|
41
|
-
const arrowNavigationAttrs = useArrowNavigationGroup({
|
|
42
|
-
axis: orientation,
|
|
43
|
-
memorizeCurrent: true
|
|
44
|
-
});
|
|
45
|
-
const tabsterAttrs = useMergedTabsterAttributes_unstable(focusableGroupAttrs, arrowNavigationAttrs);
|
|
46
|
-
const [state, setState] = useState();
|
|
47
|
-
return /* @__PURE__ */ React.createElement(FocusContext.Provider, {
|
|
48
|
-
value: {
|
|
49
|
-
setFocus: setState
|
|
50
|
-
}
|
|
51
|
-
}, /* @__PURE__ */ React.createElement(Comp, {
|
|
52
|
-
...props,
|
|
53
|
-
...tabsterAttrs,
|
|
54
|
-
...state && {
|
|
55
|
-
[`data-${FOCUS_STATE_ATTR}`]: state
|
|
56
|
-
},
|
|
57
|
-
tabIndex: 0,
|
|
58
|
-
className: mx([
|
|
59
|
-
// TODO(burdon): Option for border/rounded; ring/outline vs border?
|
|
60
|
-
"outline-hidden border border-separator md:rounded-xs",
|
|
61
|
-
// Focus (e.g., via tabster).
|
|
62
|
-
"focus:!border-accent-surface",
|
|
63
|
-
// Active (e.g., drop target).
|
|
64
|
-
"data-[focus-state=active]:border-neutral-focus-indicator",
|
|
65
|
-
// Error
|
|
66
|
-
"data-[focus-state=error]:border-rose-500"
|
|
67
|
-
], className, classNames),
|
|
68
|
-
ref: composedRef
|
|
69
|
-
}, children));
|
|
70
|
-
});
|
|
71
|
-
var Focus = {
|
|
72
|
-
Group
|
|
73
|
-
};
|
|
25
|
+
import { Focus, useFocus } from "@dxos/react-ui";
|
|
74
26
|
|
|
75
27
|
// src/components/Mosaic/styles.ts
|
|
76
28
|
var styles = {
|
|
@@ -108,23 +60,22 @@ var getSourceData = (source) => {
|
|
|
108
60
|
// src/components/Mosaic/Root.tsx
|
|
109
61
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
110
62
|
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
111
|
-
import { useComposedRefs
|
|
112
|
-
import { createContext
|
|
113
|
-
import { Primitive
|
|
114
|
-
import { Slot
|
|
115
|
-
import
|
|
63
|
+
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
64
|
+
import { createContext } from "@radix-ui/react-context";
|
|
65
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
66
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
67
|
+
import React, { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
116
68
|
import { log } from "@dxos/log";
|
|
117
|
-
import { mx as mx2 } from "@dxos/ui-theme";
|
|
118
69
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Root.tsx";
|
|
119
|
-
var [MosaicRootContextProvider, useMosaicRootContext] =
|
|
70
|
+
var [MosaicRootContextProvider, useMosaicRootContext] = createContext("MosaicRoot");
|
|
120
71
|
var MOSAIC_ROOT_NAME = "Mosaic.Root";
|
|
121
72
|
var MOSAIC_ROOT_DEBUG_ATTR = "mosaic-debug";
|
|
122
|
-
var MosaicRoot = /* @__PURE__ */
|
|
123
|
-
const rootRef =
|
|
124
|
-
const composedRef =
|
|
125
|
-
const Comp = asChild ?
|
|
126
|
-
const [handlers, setHandlers] =
|
|
127
|
-
const [dragging, setDragging] =
|
|
73
|
+
var MosaicRoot = /* @__PURE__ */ forwardRef(({ children, asChild, debug }, forwardedRef) => {
|
|
74
|
+
const rootRef = useRef(null);
|
|
75
|
+
const composedRef = useComposedRefs(rootRef, forwardedRef);
|
|
76
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
77
|
+
const [handlers, setHandlers] = useState({});
|
|
78
|
+
const [dragging, setDragging] = useState();
|
|
128
79
|
const getSourceHandler = useCallback((source) => {
|
|
129
80
|
const data = source.data;
|
|
130
81
|
return {
|
|
@@ -169,7 +120,7 @@ var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, d
|
|
|
169
120
|
source: {
|
|
170
121
|
data: sourceData,
|
|
171
122
|
handler: handlers[sourceData.containerId],
|
|
172
|
-
//
|
|
123
|
+
// TODO(burdon): Check id matches.
|
|
173
124
|
container: location.initial.dropTargets.find((target) => target.data.type === "container")?.element
|
|
174
125
|
},
|
|
175
126
|
target: targetData && {
|
|
@@ -199,12 +150,7 @@ var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, d
|
|
|
199
150
|
log("Root.onDragStart", {
|
|
200
151
|
source: source.data,
|
|
201
152
|
location: location.current.dropTargets.map((target) => target.data)
|
|
202
|
-
}, {
|
|
203
|
-
F: __dxlog_file,
|
|
204
|
-
L: 149,
|
|
205
|
-
S: void 0,
|
|
206
|
-
C: (f, a) => f(...a)
|
|
207
|
-
});
|
|
153
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 96, S: void 0 });
|
|
208
154
|
handleChange({
|
|
209
155
|
source,
|
|
210
156
|
location
|
|
@@ -218,12 +164,7 @@ var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, d
|
|
|
218
164
|
log("Root.onDropTargetChange", {
|
|
219
165
|
source: source.data,
|
|
220
166
|
location: location.current.dropTargets.map((target) => target.data)
|
|
221
|
-
}, {
|
|
222
|
-
F: __dxlog_file,
|
|
223
|
-
L: 162,
|
|
224
|
-
S: void 0,
|
|
225
|
-
C: (f, a) => f(...a)
|
|
226
|
-
});
|
|
167
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 109, S: void 0 });
|
|
227
168
|
if (location.current.dropTargets.length === 0) {
|
|
228
169
|
noTargetTimeout = setTimeout(() => setDragging(void 0), 1e3);
|
|
229
170
|
} else {
|
|
@@ -257,33 +198,18 @@ var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, d
|
|
|
257
198
|
log.info("Root.onDrop", {
|
|
258
199
|
source: source.data,
|
|
259
200
|
location: location.current.dropTargets.map((target) => target.data)
|
|
260
|
-
}, {
|
|
261
|
-
F: __dxlog_file,
|
|
262
|
-
L: 191,
|
|
263
|
-
S: void 0,
|
|
264
|
-
C: (f, a) => f(...a)
|
|
265
|
-
});
|
|
201
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 142, S: void 0 });
|
|
266
202
|
const { data: sourceData, handler: sourceHandler } = getSourceHandler(source);
|
|
267
203
|
if (!sourceHandler) {
|
|
268
204
|
log.warn("invalid source", {
|
|
269
205
|
source: sourceData,
|
|
270
206
|
handlers: Object.keys(handlers)
|
|
271
|
-
}, {
|
|
272
|
-
F: __dxlog_file,
|
|
273
|
-
L: 199,
|
|
274
|
-
S: void 0,
|
|
275
|
-
C: (f, a) => f(...a)
|
|
276
|
-
});
|
|
207
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 149, S: void 0 });
|
|
277
208
|
return;
|
|
278
209
|
}
|
|
279
210
|
try {
|
|
280
211
|
if (location.current.dropTargets.length === 0) {
|
|
281
|
-
log.info("cancelled", void 0, {
|
|
282
|
-
F: __dxlog_file,
|
|
283
|
-
L: 214,
|
|
284
|
-
S: void 0,
|
|
285
|
-
C: (f, a) => f(...a)
|
|
286
|
-
});
|
|
212
|
+
log.info("cancelled", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 163, S: void 0 });
|
|
287
213
|
} else {
|
|
288
214
|
const { data: targetData, handler: targetHandler } = getTargetHandler(location);
|
|
289
215
|
if (!targetHandler) {
|
|
@@ -291,12 +217,7 @@ var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, d
|
|
|
291
217
|
source: sourceData,
|
|
292
218
|
location,
|
|
293
219
|
handlers: Object.keys(handlers)
|
|
294
|
-
}, {
|
|
295
|
-
F: __dxlog_file,
|
|
296
|
-
L: 219,
|
|
297
|
-
S: void 0,
|
|
298
|
-
C: (f, a) => f(...a)
|
|
299
|
-
});
|
|
220
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 168, S: void 0 });
|
|
300
221
|
return;
|
|
301
222
|
}
|
|
302
223
|
if (sourceHandler === targetHandler) {
|
|
@@ -308,12 +229,7 @@ var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, d
|
|
|
308
229
|
if (!sourceHandler.onTake) {
|
|
309
230
|
log.warn("invalid source", {
|
|
310
231
|
source: sourceData
|
|
311
|
-
}, {
|
|
312
|
-
F: __dxlog_file,
|
|
313
|
-
L: 235,
|
|
314
|
-
S: void 0,
|
|
315
|
-
C: (f, a) => f(...a)
|
|
316
|
-
});
|
|
232
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 183, S: void 0 });
|
|
317
233
|
return;
|
|
318
234
|
}
|
|
319
235
|
sourceHandler.onTake?.({
|
|
@@ -340,7 +256,7 @@ var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, d
|
|
|
340
256
|
getSourceHandler,
|
|
341
257
|
getTargetHandler
|
|
342
258
|
]);
|
|
343
|
-
return /* @__PURE__ */
|
|
259
|
+
return /* @__PURE__ */ React.createElement(MosaicRootContextProvider, {
|
|
344
260
|
containers: handlers,
|
|
345
261
|
addContainer: (container) => setHandlers((containers) => ({
|
|
346
262
|
...containers,
|
|
@@ -353,8 +269,8 @@ var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, d
|
|
|
353
269
|
};
|
|
354
270
|
}),
|
|
355
271
|
dragging
|
|
356
|
-
}, /* @__PURE__ */
|
|
357
|
-
className:
|
|
272
|
+
}, /* @__PURE__ */ React.createElement(Comp, {
|
|
273
|
+
className: "contents group",
|
|
358
274
|
[`data-${MOSAIC_ROOT_DEBUG_ATTR}`]: debug,
|
|
359
275
|
ref: composedRef
|
|
360
276
|
}, children));
|
|
@@ -362,38 +278,55 @@ var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, d
|
|
|
362
278
|
MosaicRoot.displayName = MOSAIC_ROOT_NAME;
|
|
363
279
|
|
|
364
280
|
// src/components/Mosaic/Container.tsx
|
|
281
|
+
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
|
365
282
|
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
366
283
|
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
367
|
-
import {
|
|
368
|
-
import {
|
|
369
|
-
import {
|
|
370
|
-
import {
|
|
371
|
-
import { Slot as Slot3 } from "@radix-ui/react-slot";
|
|
284
|
+
import { useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
|
|
285
|
+
import { createContext as createContext2 } from "@radix-ui/react-context";
|
|
286
|
+
import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
|
|
287
|
+
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
372
288
|
import { bind } from "bind-event-listener";
|
|
373
|
-
import
|
|
374
|
-
import {
|
|
289
|
+
import React2, { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
290
|
+
import { composable, composableProps } from "@dxos/ui-theme";
|
|
375
291
|
import { isTruthy } from "@dxos/util";
|
|
376
292
|
var MOSAIC_CONTAINER_NAME = "Mosaic.Container";
|
|
377
|
-
var [MosaicContainerContextProvider, useMosaicContainerContext] =
|
|
293
|
+
var [MosaicContainerContextProvider, useMosaicContainerContext] = createContext2("MosaicContainer");
|
|
378
294
|
var MOSAIC_CONTAINER_STATE_ATTR = "mosaic-container-state";
|
|
379
295
|
var MOSAIC_CONTAINER_PLACEHOLDER_WIDTH = "--mosaic-placeholder-width";
|
|
380
296
|
var MOSAIC_CONTAINER_PLACEHOLDER_HEIGHT = "--mosaic-placeholder-height";
|
|
381
297
|
var counter = 0;
|
|
382
|
-
var MosaicContainer =
|
|
383
|
-
const
|
|
384
|
-
const
|
|
385
|
-
const
|
|
298
|
+
var MosaicContainer = composable(({ children, eventHandler: eventHandlerProp, orientation = "vertical", asChild, autoScroll: autoscrollElement, withFocus, currentId, onCurrentChange, selectedIds, onSelectionChange, debug, ...props }, forwardedRef) => {
|
|
299
|
+
const Comp = asChild ? Slot2 : Primitive2.div;
|
|
300
|
+
const rootRef = useRef2(null);
|
|
301
|
+
const composedRef = useComposedRefs2(rootRef, forwardedRef);
|
|
386
302
|
const eventHandler = useMemo2(() => eventHandlerProp ?? {
|
|
387
303
|
id: `mosaic-container-${counter++}`
|
|
388
304
|
}, [
|
|
389
305
|
eventHandlerProp
|
|
390
306
|
]);
|
|
391
307
|
const { dragging } = useMosaicRootContext(MOSAIC_CONTAINER_NAME);
|
|
392
|
-
const [state, setState] =
|
|
308
|
+
const [state, setState] = useState2({
|
|
393
309
|
type: "idle"
|
|
394
310
|
});
|
|
395
|
-
const [activeLocation, setActiveLocation] =
|
|
396
|
-
const [scrolling, setScrolling] =
|
|
311
|
+
const [activeLocation, setActiveLocation] = useState2();
|
|
312
|
+
const [scrolling, setScrolling] = useState2(false);
|
|
313
|
+
const setCurrentId = useCallback2((id) => onCurrentChange?.(id), [
|
|
314
|
+
onCurrentChange
|
|
315
|
+
]);
|
|
316
|
+
const setSelected = useCallback2((id, selected) => onSelectionChange?.(id, selected), [
|
|
317
|
+
onSelectionChange
|
|
318
|
+
]);
|
|
319
|
+
const scrollToRef = useRef2(void 0);
|
|
320
|
+
const registerScrollTo = useCallback2((fn) => {
|
|
321
|
+
scrollToRef.current = fn;
|
|
322
|
+
}, []);
|
|
323
|
+
useEffect2(() => {
|
|
324
|
+
if (currentId) {
|
|
325
|
+
scrollToRef.current?.(currentId);
|
|
326
|
+
}
|
|
327
|
+
}, [
|
|
328
|
+
currentId
|
|
329
|
+
]);
|
|
397
330
|
const { setFocus } = useFocus();
|
|
398
331
|
useEffect2(() => {
|
|
399
332
|
if (withFocus) {
|
|
@@ -528,7 +461,7 @@ var MosaicContainer = /* @__PURE__ */ forwardRef3(({ classNames, className, chil
|
|
|
528
461
|
data,
|
|
529
462
|
autoscrollElement
|
|
530
463
|
]);
|
|
531
|
-
return /* @__PURE__ */
|
|
464
|
+
return /* @__PURE__ */ React2.createElement(MosaicContainerContextProvider, {
|
|
532
465
|
id: eventHandler.id,
|
|
533
466
|
eventHandler,
|
|
534
467
|
orientation,
|
|
@@ -536,14 +469,20 @@ var MosaicContainer = /* @__PURE__ */ forwardRef3(({ classNames, className, chil
|
|
|
536
469
|
dragging: state.type === "active" ? dragging : void 0,
|
|
537
470
|
scrolling,
|
|
538
471
|
activeLocation,
|
|
539
|
-
setActiveLocation
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
...props,
|
|
472
|
+
setActiveLocation,
|
|
473
|
+
currentId,
|
|
474
|
+
setCurrentId,
|
|
475
|
+
selectedIds,
|
|
476
|
+
setSelected,
|
|
477
|
+
registerScrollTo
|
|
478
|
+
}, /* @__PURE__ */ React2.createElement(Comp, {
|
|
479
|
+
...composableProps(props, {
|
|
480
|
+
classNames: "h-full",
|
|
481
|
+
style: {
|
|
482
|
+
[MOSAIC_CONTAINER_PLACEHOLDER_WIDTH]: state.type === "active" && state.bounds ? `${state.bounds.width}px` : "0px",
|
|
483
|
+
[MOSAIC_CONTAINER_PLACEHOLDER_HEIGHT]: state.type === "active" && state.bounds ? `${state.bounds.height}px` : "0px"
|
|
484
|
+
}
|
|
485
|
+
}),
|
|
547
486
|
[`data-${MOSAIC_CONTAINER_STATE_ATTR}`]: state.type,
|
|
548
487
|
ref: composedRef
|
|
549
488
|
}, children), debug?.());
|
|
@@ -551,27 +490,27 @@ var MosaicContainer = /* @__PURE__ */ forwardRef3(({ classNames, className, chil
|
|
|
551
490
|
MosaicContainer.displayName = MOSAIC_CONTAINER_NAME;
|
|
552
491
|
|
|
553
492
|
// src/components/Mosaic/Tile.tsx
|
|
493
|
+
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
554
494
|
import { combine as combine3 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
555
495
|
import { draggable, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
556
496
|
import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
|
|
557
497
|
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
558
|
-
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
559
498
|
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
560
|
-
import { createContext as
|
|
561
|
-
import { Primitive as
|
|
562
|
-
import { Slot as
|
|
563
|
-
import
|
|
499
|
+
import { createContext as createContext3 } from "@radix-ui/react-context";
|
|
500
|
+
import { Primitive as Primitive3 } from "@radix-ui/react-primitive";
|
|
501
|
+
import { Slot as Slot3 } from "@radix-ui/react-slot";
|
|
502
|
+
import React3, { useLayoutEffect, useMemo as useMemo3, useRef as useRef3, useState as useState3 } from "react";
|
|
564
503
|
import { createPortal } from "react-dom";
|
|
565
|
-
import {
|
|
504
|
+
import { composableProps as composableProps2, slottable } from "@dxos/ui-theme";
|
|
566
505
|
var MOSAIC_TILE_NAME = "Mosaic.Tile";
|
|
567
|
-
var [MosaicTileContextProvider, useMosaicTileContext] =
|
|
506
|
+
var [MosaicTileContextProvider, useMosaicTileContext] = createContext3("MosaicTile");
|
|
568
507
|
var MOSAIC_TILE_STATE_ATTR = "mosaic-tile-state";
|
|
569
|
-
var MosaicTile =
|
|
570
|
-
const
|
|
508
|
+
var MosaicTile = slottable(({ children, asChild, dragHandle, allowedEdges: allowedEdgesProp, location, id, data: dataProp, draggable: draggableProp, current, selected, debug: _, ...props }, forwardedRef) => {
|
|
509
|
+
const Comp = asChild ? Slot3 : Primitive3.div;
|
|
510
|
+
const rootRef = useRef3(null);
|
|
571
511
|
const composedRef = composeRefs(rootRef, forwardedRef);
|
|
572
|
-
const Comp = asChild ? Slot4 : Primitive4.div;
|
|
573
512
|
const { id: containerId, eventHandler, orientation, scrolling, setActiveLocation } = useMosaicContainerContext(MOSAIC_TILE_NAME);
|
|
574
|
-
const [state, setState] =
|
|
513
|
+
const [state, setState] = useState3({
|
|
575
514
|
type: "idle"
|
|
576
515
|
});
|
|
577
516
|
const allowedEdges = useMemo3(() => allowedEdgesProp || (orientation === "vertical" ? [
|
|
@@ -597,7 +536,7 @@ var MosaicTile = /* @__PURE__ */ forwardRef4(({ classNames, className, children,
|
|
|
597
536
|
]);
|
|
598
537
|
useLayoutEffect(() => {
|
|
599
538
|
const root = rootRef.current;
|
|
600
|
-
if (!root || !containerId || scrolling) {
|
|
539
|
+
if (!draggableProp || !root || !containerId || scrolling) {
|
|
601
540
|
return;
|
|
602
541
|
}
|
|
603
542
|
const handleChange = ({ self, source }) => {
|
|
@@ -691,6 +630,8 @@ var MosaicTile = /* @__PURE__ */ forwardRef4(({ classNames, className, children,
|
|
|
691
630
|
);
|
|
692
631
|
}, [
|
|
693
632
|
rootRef,
|
|
633
|
+
forwardedRef,
|
|
634
|
+
containerId,
|
|
694
635
|
dragHandle,
|
|
695
636
|
eventHandler,
|
|
696
637
|
data,
|
|
@@ -698,19 +639,28 @@ var MosaicTile = /* @__PURE__ */ forwardRef4(({ classNames, className, children,
|
|
|
698
639
|
allowedEdges,
|
|
699
640
|
setActiveLocation
|
|
700
641
|
]);
|
|
701
|
-
|
|
642
|
+
const { className, ...rest } = composableProps2(props, {
|
|
643
|
+
classNames: "relative outline-none"
|
|
644
|
+
});
|
|
645
|
+
return /* @__PURE__ */ React3.createElement(MosaicTileContextProvider, {
|
|
702
646
|
state
|
|
703
|
-
}, /* @__PURE__ */
|
|
704
|
-
...
|
|
647
|
+
}, /* @__PURE__ */ React3.createElement(Comp, {
|
|
648
|
+
...rest,
|
|
649
|
+
"data-object-id": id,
|
|
705
650
|
[`data-${MOSAIC_TILE_STATE_ATTR}`]: state.type,
|
|
706
651
|
role: "listitem",
|
|
707
|
-
|
|
652
|
+
// Pair `current` / `selected` props with `aria-current` / `aria-selected`
|
|
653
|
+
// so the `dx-current` / `dx-selected` / `dx-hover` utilities (which key
|
|
654
|
+
// off those attributes) actually fire. Without this the props are purely
|
|
655
|
+
// advisory and the corresponding styling silently no-ops.
|
|
656
|
+
"aria-current": current ? "true" : void 0,
|
|
657
|
+
"aria-selected": selected ? "true" : void 0,
|
|
658
|
+
className,
|
|
708
659
|
ref: composedRef
|
|
709
|
-
}, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
660
|
+
}, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */ React3.createElement(Comp, {
|
|
710
661
|
// NOTE: Use to control appearance while dragging.
|
|
711
662
|
[`data-${MOSAIC_TILE_STATE_ATTR}`]: state.type,
|
|
712
|
-
|
|
713
|
-
className: mx4("relative", className, classNames),
|
|
663
|
+
className,
|
|
714
664
|
style: {
|
|
715
665
|
width: `${state.rect.width}px`,
|
|
716
666
|
height: `${state.rect.height}px`
|
|
@@ -720,18 +670,19 @@ var MosaicTile = /* @__PURE__ */ forwardRef4(({ classNames, className, children,
|
|
|
720
670
|
MosaicTile.displayName = MOSAIC_TILE_NAME;
|
|
721
671
|
|
|
722
672
|
// src/components/Mosaic/Placeholder.tsx
|
|
723
|
-
import { dropTargetForElements as dropTargetForElements3 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
724
673
|
import { DropIndicator as NaturalDropIndicator } from "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box";
|
|
725
|
-
import {
|
|
726
|
-
import {
|
|
727
|
-
import
|
|
728
|
-
import {
|
|
674
|
+
import { dropTargetForElements as dropTargetForElements3 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
675
|
+
import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
|
|
676
|
+
import { Slot as Slot4 } from "@radix-ui/react-slot";
|
|
677
|
+
import React4, { useLayoutEffect as useLayoutEffect2, useMemo as useMemo4, useRef as useRef4 } from "react";
|
|
678
|
+
import { mx } from "@dxos/ui-theme";
|
|
729
679
|
var MOSAIC_PLACEHOLDER_NAME = "Mosaic.Placeholder";
|
|
730
680
|
var MOSAIC_PLACEHOLDER_ORIENTATION_ATTR = "mosaic-placeholder-orientation";
|
|
731
681
|
var MOSAIC_PLACEHOLDER_STATE_ATTR = "mosaic-placeholder-state";
|
|
682
|
+
var MOSAIC_PLACEHOLDER_LOCATION_ATTR = "mosaic-placeholder-location";
|
|
732
683
|
var MosaicPlaceholder = ({ classNames, children, asChild, orientation = "vertical", location }) => {
|
|
733
|
-
const rootRef =
|
|
734
|
-
const Comp = asChild ?
|
|
684
|
+
const rootRef = useRef4(null);
|
|
685
|
+
const Comp = asChild ? Slot4 : Primitive4.div;
|
|
735
686
|
const { id: containerId, eventHandler, scrolling, activeLocation, setActiveLocation } = useMosaicContainerContext(MOSAIC_PLACEHOLDER_NAME);
|
|
736
687
|
const data = useMemo4(() => ({
|
|
737
688
|
type: "placeholder",
|
|
@@ -771,11 +722,12 @@ var MosaicPlaceholder = ({ classNames, children, asChild, orientation = "vertica
|
|
|
771
722
|
scrolling,
|
|
772
723
|
setActiveLocation
|
|
773
724
|
]);
|
|
774
|
-
return /* @__PURE__ */
|
|
725
|
+
return /* @__PURE__ */ React4.createElement(Comp, {
|
|
775
726
|
[`data-${MOSAIC_PLACEHOLDER_ORIENTATION_ATTR}`]: orientation,
|
|
776
727
|
[`data-${MOSAIC_PLACEHOLDER_STATE_ATTR}`]: data.location === activeLocation ? "active" : "idle",
|
|
728
|
+
[`data-${MOSAIC_PLACEHOLDER_LOCATION_ATTR}`]: String(location),
|
|
777
729
|
role: "none",
|
|
778
|
-
className:
|
|
730
|
+
className: mx("relative", classNames),
|
|
779
731
|
ref: rootRef
|
|
780
732
|
}, children);
|
|
781
733
|
};
|
|
@@ -783,7 +735,7 @@ MosaicPlaceholder.displayName = MOSAIC_PLACEHOLDER_NAME;
|
|
|
783
735
|
var DROP_INDICATOR_NAME = "Mosaic.DropIndicator";
|
|
784
736
|
var MosaicDropIndicator = (props) => {
|
|
785
737
|
const { state } = useMosaicTileContext(DROP_INDICATOR_NAME);
|
|
786
|
-
return state.type === "target" && state.closestEdge ? /* @__PURE__ */
|
|
738
|
+
return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React4.createElement(NaturalDropIndicator, {
|
|
787
739
|
...props,
|
|
788
740
|
edge: state.closestEdge
|
|
789
741
|
}) : null;
|
|
@@ -791,55 +743,67 @@ var MosaicDropIndicator = (props) => {
|
|
|
791
743
|
MosaicDropIndicator.displayName = DROP_INDICATOR_NAME;
|
|
792
744
|
|
|
793
745
|
// src/components/Mosaic/Stack.tsx
|
|
746
|
+
import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
|
|
794
747
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
795
|
-
import
|
|
748
|
+
import React5, { forwardRef as forwardRef2, Fragment, useCallback as useCallback3, useEffect as useEffect3, useRef as useRef5 } from "react";
|
|
796
749
|
import { invariant } from "@dxos/invariant";
|
|
797
|
-
import { mx as
|
|
750
|
+
import { composable as composable2, composableProps as composableProps3, mx as mx2 } from "@dxos/ui-theme";
|
|
798
751
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Stack.tsx";
|
|
799
752
|
var MOSAIC_STACK_NAME = "MosaicStack";
|
|
800
|
-
var MosaicStackInner =
|
|
801
|
-
|
|
802
|
-
F: __dxlog_file2,
|
|
803
|
-
L: 75,
|
|
804
|
-
S: void 0,
|
|
805
|
-
A: [
|
|
806
|
-
"Tile",
|
|
807
|
-
""
|
|
808
|
-
]
|
|
809
|
-
});
|
|
810
|
-
const { id, orientation = orientationProp, dragging } = useMosaicContainerContext(MOSAIC_STACK_NAME);
|
|
753
|
+
var MosaicStackInner = composable2(({ orientation: orientationProp = "vertical", getId, items, scrollIntoView = true, Tile, draggable: draggable2 = true, debug, ...props }, forwardedRef) => {
|
|
754
|
+
const { id, orientation = orientationProp, dragging, currentId, selectedIds, registerScrollTo } = useMosaicContainerContext(MOSAIC_STACK_NAME);
|
|
811
755
|
const visibleItems = useVisibleItems({
|
|
812
756
|
id,
|
|
813
757
|
items,
|
|
814
758
|
dragging: dragging?.source.data,
|
|
815
759
|
getId
|
|
816
760
|
});
|
|
817
|
-
invariant(orientation === "vertical" || orientation === "horizontal", `Invalid orientation: ${orientation}`, {
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
761
|
+
invariant(orientation === "vertical" || orientation === "horizontal", `Invalid orientation: ${orientation}`, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 45, S: void 0, A: ["orientation === 'vertical' || orientation === 'horizontal'", "`Invalid orientation: ${orientation}`"] });
|
|
762
|
+
const rootRef = useRef5(null);
|
|
763
|
+
const scrollToId = useCallback3((targetId) => {
|
|
764
|
+
if (!scrollIntoView) {
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
const el = rootRef.current?.querySelector(`[data-object-id="${CSS.escape(targetId)}"]`);
|
|
768
|
+
el?.scrollIntoView({
|
|
769
|
+
block: "nearest",
|
|
770
|
+
behavior: "smooth"
|
|
771
|
+
});
|
|
772
|
+
}, [
|
|
773
|
+
scrollIntoView
|
|
774
|
+
]);
|
|
775
|
+
useEffect3(() => {
|
|
776
|
+
registerScrollTo(scrollToId);
|
|
777
|
+
return () => registerScrollTo(void 0);
|
|
778
|
+
}, [
|
|
779
|
+
registerScrollTo,
|
|
780
|
+
scrollToId
|
|
781
|
+
]);
|
|
782
|
+
const composedRef = useComposedRefs3(rootRef, forwardedRef);
|
|
783
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
784
|
+
...composableProps3(props, {
|
|
785
|
+
role: "list",
|
|
786
|
+
classNames: [
|
|
787
|
+
"flex",
|
|
788
|
+
orientation === "horizontal" && "h-full [&>*]:shrink-0",
|
|
789
|
+
orientation === "vertical" && "flex-col"
|
|
790
|
+
]
|
|
791
|
+
}),
|
|
792
|
+
ref: composedRef
|
|
793
|
+
}, draggable2 && /* @__PURE__ */ React5.createElement(InternalPlaceholder, {
|
|
832
794
|
orientation,
|
|
833
795
|
location: 0.5
|
|
834
|
-
}), visibleItems?.map((item, index) => /* @__PURE__ */
|
|
796
|
+
}), visibleItems?.map((item, index) => /* @__PURE__ */ React5.createElement(Fragment, {
|
|
835
797
|
key: getId(item)
|
|
836
|
-
}, /* @__PURE__ */
|
|
798
|
+
}, /* @__PURE__ */ React5.createElement(Tile, {
|
|
837
799
|
id: getId(item),
|
|
838
800
|
data: item,
|
|
839
801
|
location: index + 1,
|
|
840
802
|
draggable: draggable2,
|
|
803
|
+
current: getId(item) === currentId,
|
|
804
|
+
selected: selectedIds?.has(getId(item)),
|
|
841
805
|
debug
|
|
842
|
-
}), /* @__PURE__ */
|
|
806
|
+
}), draggable2 && /* @__PURE__ */ React5.createElement(InternalPlaceholder, {
|
|
843
807
|
orientation,
|
|
844
808
|
location: index + 1.5
|
|
845
809
|
}))));
|
|
@@ -847,35 +811,86 @@ var MosaicStackInner = /* @__PURE__ */ forwardRef5(({ classNames, className, rol
|
|
|
847
811
|
MosaicStackInner.displayName = MOSAIC_STACK_NAME;
|
|
848
812
|
var MosaicStack = MosaicStackInner;
|
|
849
813
|
var MOSAIC_VIRTUAL_STACK_NAME = "MosaicVirtualStack";
|
|
850
|
-
var MosaicVirtualStackInner = /* @__PURE__ */
|
|
851
|
-
invariant(Tile, void 0, {
|
|
852
|
-
|
|
853
|
-
L: 142,
|
|
854
|
-
S: void 0,
|
|
855
|
-
A: [
|
|
856
|
-
"Tile",
|
|
857
|
-
""
|
|
858
|
-
]
|
|
859
|
-
});
|
|
860
|
-
const { id, dragging } = useMosaicContainerContext(MOSAIC_VIRTUAL_STACK_NAME);
|
|
814
|
+
var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef2(({ orientation = "vertical", getId, items, scrollIntoView = true, Tile, estimateSize, getScrollElement, overscan = 8, gap, onChange, draggable: draggable2 = true, debug, ...props }, forwardedRef) => {
|
|
815
|
+
invariant(Tile, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 102, S: void 0, A: ["Tile", ""] });
|
|
816
|
+
const { id, dragging, currentId, selectedIds, registerScrollTo } = useMosaicContainerContext(MOSAIC_VIRTUAL_STACK_NAME);
|
|
861
817
|
const visibleItems = useVisibleItems({
|
|
862
818
|
id,
|
|
863
819
|
items,
|
|
864
820
|
dragging: dragging?.source.data,
|
|
865
821
|
getId
|
|
866
822
|
});
|
|
823
|
+
const wrappedEstimateSize = draggable2 ? (index) => index % 2 === 0 ? 0 : estimateSize(Math.floor(index / 2)) : estimateSize;
|
|
867
824
|
const virtualizer = useVirtualizer({
|
|
868
|
-
|
|
869
|
-
|
|
825
|
+
// NOTE: When draggable we double the number of items to allow for placeholders.
|
|
826
|
+
count: draggable2 ? visibleItems.length * 2 + 1 : visibleItems.length,
|
|
827
|
+
estimateSize: wrappedEstimateSize,
|
|
828
|
+
gap,
|
|
829
|
+
// Key measurements by stable item ID so the size cache survives scrolling;
|
|
830
|
+
// without this, measurements are indexed by position and are lost when items reorder.
|
|
831
|
+
getItemKey: draggable2 ? (index) => index % 2 === 0 ? `ph-${index}` : getId(visibleItems[Math.floor(index / 2)]) : (index) => getId(visibleItems[index]),
|
|
870
832
|
getScrollElement,
|
|
871
833
|
overscan,
|
|
872
834
|
onChange
|
|
873
835
|
});
|
|
836
|
+
const scrollToId = useCallback3((targetId) => {
|
|
837
|
+
const itemIndex = visibleItems.findIndex((item) => getId(item) === targetId);
|
|
838
|
+
if (itemIndex >= 0) {
|
|
839
|
+
if (!scrollIntoView) {
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
const virtualIndex = draggable2 ? itemIndex * 2 + 1 : itemIndex;
|
|
843
|
+
virtualizer.scrollToIndex(virtualIndex, {
|
|
844
|
+
align: "start",
|
|
845
|
+
behavior: "smooth"
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
}, [
|
|
849
|
+
visibleItems,
|
|
850
|
+
getId,
|
|
851
|
+
draggable2,
|
|
852
|
+
virtualizer,
|
|
853
|
+
scrollIntoView
|
|
854
|
+
]);
|
|
855
|
+
useEffect3(() => {
|
|
856
|
+
registerScrollTo(scrollToId);
|
|
857
|
+
return () => registerScrollTo(void 0);
|
|
858
|
+
}, [
|
|
859
|
+
registerScrollTo,
|
|
860
|
+
scrollToId
|
|
861
|
+
]);
|
|
874
862
|
const virtualItems = virtualizer.getVirtualItems();
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
863
|
+
const getData = (index) => {
|
|
864
|
+
if (draggable2) {
|
|
865
|
+
if (index % 2 === 0) {
|
|
866
|
+
return {
|
|
867
|
+
location: Math.floor(index / 2) + 0.5
|
|
868
|
+
};
|
|
869
|
+
} else {
|
|
870
|
+
return {
|
|
871
|
+
data: visibleItems[Math.floor(index / 2)],
|
|
872
|
+
location: Math.floor(index / 2) + 1
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
} else {
|
|
876
|
+
return {
|
|
877
|
+
data: visibleItems[index],
|
|
878
|
+
location: index + 1
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
883
|
+
...composableProps3(props, {
|
|
884
|
+
role: "list",
|
|
885
|
+
classNames: [
|
|
886
|
+
// shrink-0 is required: this div sets an explicit height via inline style (getTotalSize).
|
|
887
|
+
// Without it, a parent flex container (e.g. ScrollArea.Viewport) would shrink this div
|
|
888
|
+
// to the viewport height, collapsing the scroll content and causing scrollbar drift.
|
|
889
|
+
"flex shrink-0",
|
|
890
|
+
orientation === "horizontal" && "h-full [&>*]:shrink-0",
|
|
891
|
+
orientation === "vertical" && "flex-col"
|
|
892
|
+
]
|
|
893
|
+
}),
|
|
879
894
|
style: {
|
|
880
895
|
position: "relative",
|
|
881
896
|
...orientation === "vertical" ? {
|
|
@@ -887,43 +902,47 @@ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef5(({ classNames, classNa
|
|
|
887
902
|
}
|
|
888
903
|
},
|
|
889
904
|
ref: forwardedRef
|
|
890
|
-
}, virtualItems.map((
|
|
891
|
-
const data =
|
|
892
|
-
return /* @__PURE__ */
|
|
893
|
-
key
|
|
894
|
-
"data-index":
|
|
905
|
+
}, virtualItems.map(({ key, index, start }) => {
|
|
906
|
+
const { data, location } = getData(index);
|
|
907
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
908
|
+
key,
|
|
909
|
+
"data-index": index,
|
|
895
910
|
style: {
|
|
896
911
|
position: "absolute",
|
|
897
912
|
top: 0,
|
|
898
913
|
left: 0,
|
|
899
914
|
...orientation === "vertical" ? {
|
|
900
915
|
width: "100%",
|
|
901
|
-
transform: `translateY(${
|
|
916
|
+
transform: `translateY(${start}px)`
|
|
902
917
|
} : {
|
|
903
918
|
height: "100%",
|
|
904
|
-
transform: `translateX(${
|
|
919
|
+
transform: `translateX(${start}px)`
|
|
905
920
|
}
|
|
906
921
|
},
|
|
907
922
|
ref: virtualizer.measureElement
|
|
908
|
-
},
|
|
909
|
-
orientation,
|
|
910
|
-
location: Math.floor(virtualItem.index / 2) + 0.5
|
|
911
|
-
}) : /* @__PURE__ */ React6.createElement(Tile, {
|
|
923
|
+
}, data ? /* @__PURE__ */ React5.createElement(Tile, {
|
|
912
924
|
id: getId(data),
|
|
913
925
|
data,
|
|
914
|
-
location
|
|
926
|
+
location,
|
|
927
|
+
draggable: draggable2,
|
|
928
|
+
current: getId(data) === currentId,
|
|
929
|
+
selected: selectedIds?.has(getId(data)),
|
|
915
930
|
debug
|
|
931
|
+
}) : /* @__PURE__ */ React5.createElement(InternalPlaceholder, {
|
|
932
|
+
orientation,
|
|
933
|
+
location
|
|
916
934
|
}));
|
|
917
935
|
}));
|
|
918
936
|
});
|
|
919
937
|
MosaicVirtualStackInner.displayName = MOSAIC_VIRTUAL_STACK_NAME;
|
|
920
938
|
var MosaicVirtualStack = MosaicVirtualStackInner;
|
|
939
|
+
MosaicVirtualStack[/* @__PURE__ */ Symbol.for("dxos.composable")] = true;
|
|
921
940
|
var InternalPlaceholder = (props) => {
|
|
922
|
-
return /* @__PURE__ */
|
|
941
|
+
return /* @__PURE__ */ React5.createElement(MosaicPlaceholder, {
|
|
923
942
|
...props,
|
|
924
943
|
classNames: styles.placeholder.root
|
|
925
|
-
}, /* @__PURE__ */
|
|
926
|
-
className:
|
|
944
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
945
|
+
className: mx2("flex h-full bg-base-surface border border-dashed border-separator rounded-xs", styles.placeholder.content)
|
|
927
946
|
}));
|
|
928
947
|
};
|
|
929
948
|
InternalPlaceholder.displayName = "InternalPlaceholder";
|
|
@@ -941,8 +960,8 @@ var Mosaic = {
|
|
|
941
960
|
|
|
942
961
|
export {
|
|
943
962
|
useVisibleItems,
|
|
944
|
-
useFocus,
|
|
945
963
|
Focus,
|
|
964
|
+
useFocus,
|
|
946
965
|
styles,
|
|
947
966
|
getSourceData,
|
|
948
967
|
useMosaicRootContext,
|
|
@@ -950,4 +969,4 @@ export {
|
|
|
950
969
|
useMosaicTileContext,
|
|
951
970
|
Mosaic
|
|
952
971
|
};
|
|
953
|
-
//# sourceMappingURL=chunk-
|
|
972
|
+
//# sourceMappingURL=chunk-3BMPGIWZ.mjs.map
|