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