@dxos/react-ui-mosaic 0.8.4-main.1068cf700f → 0.8.4-main.2244d791bb
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-Y6GU2CCU.mjs → chunk-XNANTBOP.mjs} +253 -350
- package/dist/lib/browser/chunk-XNANTBOP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +200 -57
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/{chunk-KTLFCRVA.mjs → chunk-LWXG4JVG.mjs} +253 -350
- package/dist/lib/node-esm/chunk-LWXG4JVG.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +200 -57
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/types/src/components/Board/Board.d.ts +35 -23
- package/dist/types/src/components/Board/Board.d.ts.map +1 -1
- package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -1
- package/dist/types/src/components/Board/Column.d.ts +13 -9
- package/dist/types/src/components/Board/Column.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Container.d.ts +42 -0
- package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Mosaic.d.ts +35 -109
- package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Placeholder.d.ts +21 -0
- package/dist/types/src/components/Mosaic/Placeholder.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Root.d.ts +36 -0
- package/dist/types/src/components/Mosaic/Root.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Stack.d.ts +23 -0
- package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -0
- package/dist/types/src/components/{Stack → Mosaic}/Stack.stories.d.ts +2 -2
- package/dist/types/src/components/Mosaic/Stack.stories.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Tile.d.ts +48 -0
- package/dist/types/src/components/Mosaic/Tile.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/types.d.ts +9 -0
- package/dist/types/src/components/Mosaic/types.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts +15 -0
- package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts.map +1 -0
- package/dist/types/src/hooks/useVisibleItems.d.ts +2 -2
- package/dist/types/src/hooks/useVisibleItems.d.ts.map +1 -1
- package/dist/types/src/testing/DefaultStackTile.d.ts +2 -2
- package/dist/types/src/testing/DefaultStackTile.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -23
- package/src/components/Board/Board.stories.tsx +86 -26
- package/src/components/Board/Board.tsx +87 -65
- package/src/components/Board/Column.tsx +46 -37
- package/src/components/Mosaic/Container.tsx +289 -0
- package/src/components/Mosaic/Mosaic.tsx +35 -914
- package/src/components/Mosaic/Placeholder.tsx +133 -0
- package/src/components/Mosaic/Root.tsx +292 -0
- package/src/components/{Stack → Mosaic}/Stack.stories.tsx +4 -4
- package/src/components/{Stack → Mosaic}/Stack.tsx +59 -32
- package/src/components/Mosaic/Tile.tsx +240 -0
- package/src/components/Mosaic/types.ts +16 -0
- package/src/components/index.ts +0 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useDefaultColumnEventHandler.ts +35 -0
- package/src/hooks/useVisibleItems.ts +7 -2
- package/src/testing/DefaultStackTile.tsx +2 -2
- package/dist/lib/browser/chunk-Y6GU2CCU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KTLFCRVA.mjs.map +0 -7
- package/dist/types/src/components/Stack/Stack.d.ts +0 -22
- package/dist/types/src/components/Stack/Stack.d.ts.map +0 -1
- package/dist/types/src/components/Stack/Stack.stories.d.ts.map +0 -1
- package/dist/types/src/components/Stack/index.d.ts +0 -2
- package/dist/types/src/components/Stack/index.d.ts.map +0 -1
- package/dist/types/src/components/Stack/virtualizer.stories.d.ts +0 -12
- package/dist/types/src/components/Stack/virtualizer.stories.d.ts.map +0 -1
- package/src/components/Stack/index.ts +0 -5
- package/src/components/Stack/virtualizer.stories.tsx +0 -143
|
@@ -50,7 +50,7 @@ var useFocus = () => useContext(FocusContext);
|
|
|
50
50
|
var Group = /* @__PURE__ */ forwardRef(({ classNames, className, children, asChild, orientation = "vertical", ...props }, forwardedRef) => {
|
|
51
51
|
const rootRef = useRef(null);
|
|
52
52
|
const composedRef = useComposedRefs(rootRef, forwardedRef);
|
|
53
|
-
const
|
|
53
|
+
const Root = asChild ? Slot : Primitive.div;
|
|
54
54
|
const focusableGroupAttrs = useFocusableGroup({
|
|
55
55
|
tabBehavior: "limited-trap-focus"
|
|
56
56
|
});
|
|
@@ -64,7 +64,7 @@ var Group = /* @__PURE__ */ forwardRef(({ classNames, className, children, asChi
|
|
|
64
64
|
value: {
|
|
65
65
|
setFocus: setState
|
|
66
66
|
}
|
|
67
|
-
}, /* @__PURE__ */ React.createElement(
|
|
67
|
+
}, /* @__PURE__ */ React.createElement(Root, {
|
|
68
68
|
tabIndex: 0,
|
|
69
69
|
className: mx(styles.container.root, className, classNames),
|
|
70
70
|
...tabsterAttrs,
|
|
@@ -107,167 +107,29 @@ var styles2 = {
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
// src/components/Mosaic/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var dropHandler = ({ onDrop = handleDrop } = {}) => {
|
|
114
|
-
const views = /* @__PURE__ */ new Set();
|
|
115
|
-
let state = null;
|
|
116
|
-
const reset = () => {
|
|
117
|
-
views.forEach((view) => view.dispatch({
|
|
118
|
-
effects: setDrop.of(null)
|
|
119
|
-
}));
|
|
120
|
-
state = null;
|
|
121
|
-
};
|
|
122
|
-
const extension = [
|
|
123
|
-
dropField,
|
|
124
|
-
ViewPlugin.fromClass(class {
|
|
125
|
-
_view;
|
|
126
|
-
constructor(_view) {
|
|
127
|
-
this._view = _view;
|
|
128
|
-
views.add(_view);
|
|
129
|
-
}
|
|
130
|
-
destroy() {
|
|
131
|
-
views.delete(this._view);
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
];
|
|
135
|
-
return {
|
|
136
|
-
extension,
|
|
137
|
-
update: (position) => {
|
|
138
|
-
if (!position) {
|
|
139
|
-
reset();
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
views.forEach((view) => {
|
|
143
|
-
const rect = view.dom.getBoundingClientRect();
|
|
144
|
-
if (position.x >= rect.left && position.x <= rect.right && position.y >= rect.top && position.y <= rect.bottom) {
|
|
145
|
-
let pos = view.posAtCoords(position);
|
|
146
|
-
if (pos !== null) {
|
|
147
|
-
const word = view.state.wordAt(pos);
|
|
148
|
-
if (word) {
|
|
149
|
-
const startDist = Math.abs(pos - word.from);
|
|
150
|
-
const endDist = Math.abs(pos - word.to);
|
|
151
|
-
pos = startDist < endDist ? word.from : word.to;
|
|
152
|
-
}
|
|
153
|
-
view.dispatch({
|
|
154
|
-
effects: setDrop.of(pos)
|
|
155
|
-
});
|
|
156
|
-
state = {
|
|
157
|
-
view,
|
|
158
|
-
pos
|
|
159
|
-
};
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
view.dispatch({
|
|
164
|
-
effects: setDrop.of(null)
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
},
|
|
168
|
-
cancel: () => {
|
|
169
|
-
reset();
|
|
170
|
-
},
|
|
171
|
-
drop: ({ text, url }) => {
|
|
172
|
-
if (state) {
|
|
173
|
-
onDrop(state.view, state.pos, {
|
|
174
|
-
text,
|
|
175
|
-
url
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
reset();
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
|
-
var handleDrop = (view, pos, event) => {
|
|
183
|
-
const line = view.state.doc.lineAt(pos);
|
|
184
|
-
if (line.text.trim() === "") {
|
|
185
|
-
view.dispatch({
|
|
186
|
-
changes: {
|
|
187
|
-
from: pos,
|
|
188
|
-
insert: `
|
|
189
|
-

|
|
190
|
-
`
|
|
191
|
-
},
|
|
192
|
-
effects: setDrop.of(null)
|
|
193
|
-
});
|
|
194
|
-
} else {
|
|
195
|
-
view.dispatch({
|
|
196
|
-
changes: {
|
|
197
|
-
from: pos,
|
|
198
|
-
insert: ` [${event.text}](${event.url})`
|
|
199
|
-
},
|
|
200
|
-
effects: setDrop.of(null)
|
|
201
|
-
});
|
|
202
|
-
}
|
|
110
|
+
// src/components/Mosaic/types.ts
|
|
111
|
+
var getSourceData = (source) => {
|
|
112
|
+
return source.data.type === "tile" ? source.data : null;
|
|
203
113
|
};
|
|
204
|
-
var setDrop = StateEffect.define();
|
|
205
|
-
var dropField = StateField.define({
|
|
206
|
-
create: () => Decoration.none,
|
|
207
|
-
update: (decorations, tr) => {
|
|
208
|
-
for (const effect of tr.effects) {
|
|
209
|
-
if (effect.is(setDrop)) {
|
|
210
|
-
if (effect.value === null) {
|
|
211
|
-
return Decoration.none;
|
|
212
|
-
}
|
|
213
|
-
return Decoration.set([
|
|
214
|
-
Decoration.widget({
|
|
215
|
-
widget: new class extends WidgetType {
|
|
216
|
-
toDOM() {
|
|
217
|
-
const dom = document.createElement("span");
|
|
218
|
-
dom.className = "cm-drop-cursor";
|
|
219
|
-
dom.style.borderLeft = "2px solid var(--dx-accentSurface)";
|
|
220
|
-
dom.style.display = "inline-block";
|
|
221
|
-
dom.style.height = "1em";
|
|
222
|
-
dom.style.verticalAlign = "middle";
|
|
223
|
-
return dom;
|
|
224
|
-
}
|
|
225
|
-
}(),
|
|
226
|
-
side: 0
|
|
227
|
-
}).range(effect.value)
|
|
228
|
-
]);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return decorations.map(tr.changes);
|
|
232
|
-
},
|
|
233
|
-
provide: (field) => EditorView.decorations.from(field)
|
|
234
|
-
});
|
|
235
114
|
|
|
236
|
-
// src/components/
|
|
237
|
-
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
238
|
-
import React5, { Fragment, forwardRef as forwardRef4 } from "react";
|
|
239
|
-
import { invariant } from "@dxos/invariant";
|
|
240
|
-
import { mx as mx5 } from "@dxos/ui-theme";
|
|
241
|
-
|
|
242
|
-
// src/components/Mosaic/Mosaic.tsx
|
|
115
|
+
// src/components/Mosaic/Root.tsx
|
|
243
116
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
244
|
-
import {
|
|
245
|
-
import {
|
|
246
|
-
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
247
|
-
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
|
248
|
-
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
249
|
-
import { DropIndicator as NativeDropIndicator } from "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box";
|
|
250
|
-
import { composeRefs, useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
|
|
117
|
+
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
118
|
+
import { useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
|
|
251
119
|
import { createContext as createContext2 } from "@radix-ui/react-context";
|
|
252
120
|
import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
|
|
253
121
|
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
254
|
-
import {
|
|
255
|
-
import React2, { forwardRef as forwardRef2, useCallback, useEffect, useLayoutEffect, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
256
|
-
import { createPortal } from "react-dom";
|
|
122
|
+
import React2, { forwardRef as forwardRef2, useCallback, useEffect, useRef as useRef2, useState as useState2 } from "react";
|
|
257
123
|
import { log } from "@dxos/log";
|
|
258
124
|
import { mx as mx2 } from "@dxos/ui-theme";
|
|
259
|
-
|
|
260
|
-
var
|
|
261
|
-
var
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
var [RootContextProvider, useRootContext] = createContext2("MosaicRoot");
|
|
265
|
-
var ROOT_NAME = "Mosaic.Root";
|
|
266
|
-
var ROOT_DEBUG_ATTR = "mosaic-debug";
|
|
267
|
-
var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }, forwardedRef) => {
|
|
125
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Root.tsx";
|
|
126
|
+
var [MosaicRootContextProvider, useMosaicRootContext] = createContext2("MosaicRoot");
|
|
127
|
+
var MOSAIC_ROOT_NAME = "Mosaic.Root";
|
|
128
|
+
var MOSAIC_ROOT_DEBUG_ATTR = "mosaic-debug";
|
|
129
|
+
var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }, forwardedRef) => {
|
|
268
130
|
const rootRef = useRef2(null);
|
|
269
131
|
const composedRef = useComposedRefs2(rootRef, forwardedRef);
|
|
270
|
-
const
|
|
132
|
+
const Root = asChild ? Slot2 : Primitive2.div;
|
|
271
133
|
const [handlers, setHandlers] = useState2({});
|
|
272
134
|
const [dragging, setDragging] = useState2();
|
|
273
135
|
const getSourceHandler = useCallback((source) => {
|
|
@@ -346,7 +208,7 @@ var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }
|
|
|
346
208
|
location: location.current.dropTargets.map((target) => target.data)
|
|
347
209
|
}, {
|
|
348
210
|
F: __dxlog_file,
|
|
349
|
-
L:
|
|
211
|
+
L: 149,
|
|
350
212
|
S: void 0,
|
|
351
213
|
C: (f, a) => f(...a)
|
|
352
214
|
});
|
|
@@ -365,7 +227,7 @@ var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }
|
|
|
365
227
|
location: location.current.dropTargets.map((target) => target.data)
|
|
366
228
|
}, {
|
|
367
229
|
F: __dxlog_file,
|
|
368
|
-
L:
|
|
230
|
+
L: 162,
|
|
369
231
|
S: void 0,
|
|
370
232
|
C: (f, a) => f(...a)
|
|
371
233
|
});
|
|
@@ -404,7 +266,7 @@ var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }
|
|
|
404
266
|
location: location.current.dropTargets.map((target) => target.data)
|
|
405
267
|
}, {
|
|
406
268
|
F: __dxlog_file,
|
|
407
|
-
L:
|
|
269
|
+
L: 191,
|
|
408
270
|
S: void 0,
|
|
409
271
|
C: (f, a) => f(...a)
|
|
410
272
|
});
|
|
@@ -415,7 +277,7 @@ var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }
|
|
|
415
277
|
handlers: Object.keys(handlers)
|
|
416
278
|
}, {
|
|
417
279
|
F: __dxlog_file,
|
|
418
|
-
L:
|
|
280
|
+
L: 199,
|
|
419
281
|
S: void 0,
|
|
420
282
|
C: (f, a) => f(...a)
|
|
421
283
|
});
|
|
@@ -425,7 +287,7 @@ var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }
|
|
|
425
287
|
if (location.current.dropTargets.length === 0) {
|
|
426
288
|
log.info("cancelled", void 0, {
|
|
427
289
|
F: __dxlog_file,
|
|
428
|
-
L:
|
|
290
|
+
L: 214,
|
|
429
291
|
S: void 0,
|
|
430
292
|
C: (f, a) => f(...a)
|
|
431
293
|
});
|
|
@@ -438,7 +300,7 @@ var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }
|
|
|
438
300
|
handlers: Object.keys(handlers)
|
|
439
301
|
}, {
|
|
440
302
|
F: __dxlog_file,
|
|
441
|
-
L:
|
|
303
|
+
L: 219,
|
|
442
304
|
S: void 0,
|
|
443
305
|
C: (f, a) => f(...a)
|
|
444
306
|
});
|
|
@@ -455,7 +317,7 @@ var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }
|
|
|
455
317
|
source: sourceData
|
|
456
318
|
}, {
|
|
457
319
|
F: __dxlog_file,
|
|
458
|
-
L:
|
|
320
|
+
L: 235,
|
|
459
321
|
S: void 0,
|
|
460
322
|
C: (f, a) => f(...a)
|
|
461
323
|
});
|
|
@@ -485,7 +347,7 @@ var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }
|
|
|
485
347
|
getSourceHandler,
|
|
486
348
|
getTargetHandler
|
|
487
349
|
]);
|
|
488
|
-
return /* @__PURE__ */ React2.createElement(
|
|
350
|
+
return /* @__PURE__ */ React2.createElement(MosaicRootContextProvider, {
|
|
489
351
|
containers: handlers,
|
|
490
352
|
addContainer: (container) => setHandlers((containers) => ({
|
|
491
353
|
...containers,
|
|
@@ -498,36 +360,49 @@ var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }
|
|
|
498
360
|
};
|
|
499
361
|
}),
|
|
500
362
|
dragging
|
|
501
|
-
}, /* @__PURE__ */ React2.createElement(
|
|
363
|
+
}, /* @__PURE__ */ React2.createElement(Root, {
|
|
502
364
|
className: mx2("group", classNames),
|
|
503
|
-
[`data-${
|
|
365
|
+
[`data-${MOSAIC_ROOT_DEBUG_ATTR}`]: debug,
|
|
504
366
|
ref: composedRef
|
|
505
367
|
}, children));
|
|
506
368
|
});
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
369
|
+
MosaicRoot.displayName = MOSAIC_ROOT_NAME;
|
|
370
|
+
|
|
371
|
+
// src/components/Mosaic/Container.tsx
|
|
372
|
+
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
373
|
+
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
374
|
+
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
|
375
|
+
import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
|
|
376
|
+
import { createContext as createContext3 } from "@radix-ui/react-context";
|
|
377
|
+
import { Primitive as Primitive3 } from "@radix-ui/react-primitive";
|
|
378
|
+
import { Slot as Slot3 } from "@radix-ui/react-slot";
|
|
379
|
+
import { bind } from "bind-event-listener";
|
|
380
|
+
import React3, { forwardRef as forwardRef3, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
|
|
381
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
382
|
+
import { isTruthy } from "@dxos/util";
|
|
383
|
+
var MOSAIC_CONTAINER_NAME = "Mosaic.Container";
|
|
384
|
+
var [MosaicContainerContextProvider, useMosaicContainerContext] = createContext3("MosaicContainer");
|
|
385
|
+
var MOSAIC_CONTAINER_STATE_ATTR = "mosaic-container-state";
|
|
386
|
+
var MOSAIC_CONTAINER_PLACEHOLDER_WIDTH = "--mosaic-placeholder-width";
|
|
387
|
+
var MOSAIC_CONTAINER_PLACEHOLDER_HEIGHT = "--mosaic-placeholder-height";
|
|
513
388
|
var counter = 0;
|
|
514
|
-
var
|
|
515
|
-
const rootRef =
|
|
516
|
-
const composedRef =
|
|
517
|
-
const
|
|
389
|
+
var MosaicContainer = /* @__PURE__ */ forwardRef3(({ classNames, className, children, eventHandler: eventHandlerProp, orientation = "vertical", asChild, autoScroll: autoscrollElement, withFocus, debug, ...props }, forwardedRef) => {
|
|
390
|
+
const rootRef = useRef3(null);
|
|
391
|
+
const composedRef = useComposedRefs3(rootRef, forwardedRef);
|
|
392
|
+
const Root = asChild ? Slot3 : Primitive3.div;
|
|
518
393
|
const eventHandler = useMemo2(() => eventHandlerProp ?? {
|
|
519
394
|
id: `mosaic-container-${counter++}`
|
|
520
395
|
}, [
|
|
521
396
|
eventHandlerProp
|
|
522
397
|
]);
|
|
523
|
-
const { dragging } =
|
|
524
|
-
const [state, setState] =
|
|
398
|
+
const { dragging } = useMosaicRootContext(MOSAIC_CONTAINER_NAME);
|
|
399
|
+
const [state, setState] = useState3({
|
|
525
400
|
type: "idle"
|
|
526
401
|
});
|
|
527
|
-
const [activeLocation, setActiveLocation] =
|
|
528
|
-
const [scrolling, setScrolling] =
|
|
402
|
+
const [activeLocation, setActiveLocation] = useState3();
|
|
403
|
+
const [scrolling, setScrolling] = useState3(false);
|
|
529
404
|
const { setFocus } = useFocus();
|
|
530
|
-
|
|
405
|
+
useEffect2(() => {
|
|
531
406
|
if (withFocus) {
|
|
532
407
|
setFocus?.(state.type === "active" ? "active" : void 0);
|
|
533
408
|
}
|
|
@@ -536,8 +411,8 @@ var Container = /* @__PURE__ */ forwardRef2(({ className, classNames, children,
|
|
|
536
411
|
withFocus,
|
|
537
412
|
state
|
|
538
413
|
]);
|
|
539
|
-
const { addContainer, removeContainer } =
|
|
540
|
-
|
|
414
|
+
const { addContainer, removeContainer } = useMosaicRootContext(eventHandler.id);
|
|
415
|
+
useEffect2(() => {
|
|
541
416
|
addContainer(eventHandler);
|
|
542
417
|
return () => removeContainer(eventHandler.id);
|
|
543
418
|
}, [
|
|
@@ -549,7 +424,7 @@ var Container = /* @__PURE__ */ forwardRef2(({ className, classNames, children,
|
|
|
549
424
|
}), [
|
|
550
425
|
eventHandler.id
|
|
551
426
|
]);
|
|
552
|
-
|
|
427
|
+
useEffect2(() => {
|
|
553
428
|
if (!rootRef.current) {
|
|
554
429
|
return;
|
|
555
430
|
}
|
|
@@ -561,7 +436,7 @@ var Container = /* @__PURE__ */ forwardRef2(({ className, classNames, children,
|
|
|
561
436
|
setScrolling(false);
|
|
562
437
|
}, 500);
|
|
563
438
|
};
|
|
564
|
-
return
|
|
439
|
+
return combine2(...[
|
|
565
440
|
/**
|
|
566
441
|
* Custom event for dragging cancellation.
|
|
567
442
|
*/
|
|
@@ -660,7 +535,7 @@ var Container = /* @__PURE__ */ forwardRef2(({ className, classNames, children,
|
|
|
660
535
|
data,
|
|
661
536
|
autoscrollElement
|
|
662
537
|
]);
|
|
663
|
-
return /* @__PURE__ */
|
|
538
|
+
return /* @__PURE__ */ React3.createElement(MosaicContainerContextProvider, {
|
|
664
539
|
id: eventHandler.id,
|
|
665
540
|
eventHandler,
|
|
666
541
|
orientation,
|
|
@@ -669,30 +544,44 @@ var Container = /* @__PURE__ */ forwardRef2(({ className, classNames, children,
|
|
|
669
544
|
scrolling,
|
|
670
545
|
activeLocation,
|
|
671
546
|
setActiveLocation
|
|
672
|
-
}, /* @__PURE__ */
|
|
673
|
-
className:
|
|
547
|
+
}, /* @__PURE__ */ React3.createElement(Root, {
|
|
548
|
+
className: mx3("bs-full", className, classNames),
|
|
674
549
|
style: {
|
|
675
|
-
[
|
|
676
|
-
[
|
|
550
|
+
[MOSAIC_CONTAINER_PLACEHOLDER_WIDTH]: state.type === "active" && state.bounds ? `${state.bounds.width}px` : "0px",
|
|
551
|
+
[MOSAIC_CONTAINER_PLACEHOLDER_HEIGHT]: state.type === "active" && state.bounds ? `${state.bounds.height}px` : "0px"
|
|
677
552
|
},
|
|
678
553
|
...props,
|
|
679
|
-
[`data-${
|
|
554
|
+
[`data-${MOSAIC_CONTAINER_STATE_ATTR}`]: state.type,
|
|
680
555
|
ref: composedRef
|
|
681
556
|
}, children), debug?.());
|
|
682
557
|
});
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
558
|
+
MosaicContainer.displayName = MOSAIC_CONTAINER_NAME;
|
|
559
|
+
|
|
560
|
+
// src/components/Mosaic/Tile.tsx
|
|
561
|
+
import { combine as combine3 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
562
|
+
import { draggable, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
563
|
+
import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
|
|
564
|
+
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
565
|
+
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
566
|
+
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
567
|
+
import { createContext as createContext4 } from "@radix-ui/react-context";
|
|
568
|
+
import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
|
|
569
|
+
import { Slot as Slot4 } from "@radix-ui/react-slot";
|
|
570
|
+
import React4, { forwardRef as forwardRef4, useLayoutEffect, useMemo as useMemo3, useRef as useRef4, useState as useState4 } from "react";
|
|
571
|
+
import { createPortal } from "react-dom";
|
|
572
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
573
|
+
var MOSAIC_TILE_NAME = "Mosaic.Tile";
|
|
574
|
+
var [MosaicTileContextProvider, useMosaicTileContext] = createContext4("MosaicTile");
|
|
575
|
+
var MOSAIC_TILE_STATE_ATTR = "mosaic-tile-state";
|
|
576
|
+
var MosaicTile = /* @__PURE__ */ forwardRef4(({ classNames, className, children, asChild, dragHandle, allowedEdges: allowedEdgesProp, location, id, data: dataProp, debug: _ }, forwardedRef) => {
|
|
577
|
+
const rootRef = useRef4(null);
|
|
689
578
|
const composedRef = composeRefs(rootRef, forwardedRef);
|
|
690
|
-
const
|
|
691
|
-
const { id: containerId, eventHandler, orientation, scrolling, setActiveLocation } =
|
|
692
|
-
const [state, setState] =
|
|
579
|
+
const Root = asChild ? Slot4 : Primitive4.div;
|
|
580
|
+
const { id: containerId, eventHandler, orientation, scrolling, setActiveLocation } = useMosaicContainerContext(MOSAIC_TILE_NAME);
|
|
581
|
+
const [state, setState] = useState4({
|
|
693
582
|
type: "idle"
|
|
694
583
|
});
|
|
695
|
-
const allowedEdges =
|
|
584
|
+
const allowedEdges = useMemo3(() => allowedEdgesProp || (orientation === "vertical" ? [
|
|
696
585
|
"top",
|
|
697
586
|
"bottom"
|
|
698
587
|
] : [
|
|
@@ -702,7 +591,7 @@ var Tile = /* @__PURE__ */ forwardRef2(({ className, classNames, children, asChi
|
|
|
702
591
|
allowedEdgesProp,
|
|
703
592
|
orientation
|
|
704
593
|
]);
|
|
705
|
-
const data =
|
|
594
|
+
const data = useMemo3(() => ({
|
|
706
595
|
type: "tile",
|
|
707
596
|
id,
|
|
708
597
|
containerId,
|
|
@@ -729,7 +618,7 @@ var Tile = /* @__PURE__ */ forwardRef2(({ className, classNames, children, asChi
|
|
|
729
618
|
});
|
|
730
619
|
}
|
|
731
620
|
};
|
|
732
|
-
return
|
|
621
|
+
return combine3(
|
|
733
622
|
// Source.
|
|
734
623
|
draggable({
|
|
735
624
|
element: root,
|
|
@@ -768,7 +657,7 @@ var Tile = /* @__PURE__ */ forwardRef2(({ className, classNames, children, asChi
|
|
|
768
657
|
}
|
|
769
658
|
}),
|
|
770
659
|
// Target.
|
|
771
|
-
|
|
660
|
+
dropTargetForElements2({
|
|
772
661
|
element: root,
|
|
773
662
|
getData: ({ input, element }) => attachClosestEdge(data, {
|
|
774
663
|
input,
|
|
@@ -816,33 +705,41 @@ var Tile = /* @__PURE__ */ forwardRef2(({ className, classNames, children, asChi
|
|
|
816
705
|
allowedEdges,
|
|
817
706
|
setActiveLocation
|
|
818
707
|
]);
|
|
819
|
-
return /* @__PURE__ */
|
|
708
|
+
return /* @__PURE__ */ React4.createElement(MosaicTileContextProvider, {
|
|
820
709
|
state
|
|
821
|
-
}, /* @__PURE__ */
|
|
822
|
-
[`data-${
|
|
710
|
+
}, /* @__PURE__ */ React4.createElement(Root, {
|
|
711
|
+
[`data-${MOSAIC_TILE_STATE_ATTR}`]: state.type,
|
|
823
712
|
role: "listitem",
|
|
824
|
-
className:
|
|
713
|
+
className: mx4("relative", className, classNames),
|
|
825
714
|
ref: composedRef
|
|
826
|
-
}, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */
|
|
715
|
+
}, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */ React4.createElement(Root, {
|
|
827
716
|
// NOTE: Use to control appearance while dragging.
|
|
828
|
-
[`data-${
|
|
717
|
+
[`data-${MOSAIC_TILE_STATE_ATTR}`]: state.type,
|
|
829
718
|
// TODO(burdon): Configure drop animation.
|
|
830
|
-
className:
|
|
719
|
+
className: mx4("relative", className, classNames),
|
|
831
720
|
style: {
|
|
832
721
|
width: `${state.rect.width}px`,
|
|
833
722
|
height: `${state.rect.height}px`
|
|
834
723
|
}
|
|
835
724
|
}, children), state.container));
|
|
836
725
|
});
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
726
|
+
MosaicTile.displayName = MOSAIC_TILE_NAME;
|
|
727
|
+
|
|
728
|
+
// src/components/Mosaic/Placeholder.tsx
|
|
729
|
+
import { dropTargetForElements as dropTargetForElements3 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
730
|
+
import { DropIndicator as NativeDropIndicator } from "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box";
|
|
731
|
+
import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
|
|
732
|
+
import { Slot as Slot5 } from "@radix-ui/react-slot";
|
|
733
|
+
import React5, { useLayoutEffect as useLayoutEffect2, useMemo as useMemo4, useRef as useRef5 } from "react";
|
|
734
|
+
import { mx as mx5 } from "@dxos/ui-theme";
|
|
735
|
+
var MOSAIC_PLACEHOLDER_NAME = "Mosaic.Placeholder";
|
|
736
|
+
var MOSAIC_PLACEHOLDER_ORIENTATION_ATTR = "mosaic-placeholder-orientation";
|
|
737
|
+
var MOSAIC_PLACEHOLDER_STATE_ATTR = "mosaic-placeholder-state";
|
|
738
|
+
var MosaicPlaceholder = ({ classNames, children, asChild, orientation = "vertical", location }) => {
|
|
739
|
+
const rootRef = useRef5(null);
|
|
740
|
+
const Root = asChild ? Slot5 : Primitive5.div;
|
|
741
|
+
const { id: containerId, eventHandler, scrolling, activeLocation, setActiveLocation } = useMosaicContainerContext(MOSAIC_PLACEHOLDER_NAME);
|
|
742
|
+
const data = useMemo4(() => ({
|
|
846
743
|
type: "placeholder",
|
|
847
744
|
containerId,
|
|
848
745
|
location
|
|
@@ -850,12 +747,12 @@ var Placeholder = ({ classNames, children, asChild, orientation = "vertical", lo
|
|
|
850
747
|
containerId,
|
|
851
748
|
location
|
|
852
749
|
]);
|
|
853
|
-
|
|
750
|
+
useLayoutEffect2(() => {
|
|
854
751
|
const root = rootRef.current;
|
|
855
752
|
if (!root || scrolling) {
|
|
856
753
|
return;
|
|
857
754
|
}
|
|
858
|
-
return
|
|
755
|
+
return dropTargetForElements3({
|
|
859
756
|
element: root,
|
|
860
757
|
getData: () => data,
|
|
861
758
|
canDrop: ({ source }) => {
|
|
@@ -880,33 +777,30 @@ var Placeholder = ({ classNames, children, asChild, orientation = "vertical", lo
|
|
|
880
777
|
scrolling,
|
|
881
778
|
setActiveLocation
|
|
882
779
|
]);
|
|
883
|
-
return /* @__PURE__ */
|
|
884
|
-
[`data-${
|
|
885
|
-
[`data-${
|
|
780
|
+
return /* @__PURE__ */ React5.createElement(Root, {
|
|
781
|
+
[`data-${MOSAIC_PLACEHOLDER_ORIENTATION_ATTR}`]: orientation,
|
|
782
|
+
[`data-${MOSAIC_PLACEHOLDER_STATE_ATTR}`]: data.location === activeLocation ? "active" : "idle",
|
|
886
783
|
role: "none",
|
|
887
|
-
className:
|
|
784
|
+
className: mx5("relative", classNames),
|
|
888
785
|
ref: rootRef
|
|
889
786
|
}, children);
|
|
890
787
|
};
|
|
891
|
-
|
|
788
|
+
MosaicPlaceholder.displayName = MOSAIC_PLACEHOLDER_NAME;
|
|
892
789
|
var DROP_INDICATOR_NAME = "Mosaic.DropIndicator";
|
|
893
|
-
var
|
|
894
|
-
const { state } =
|
|
895
|
-
return state.type === "target" && state.closestEdge ? /* @__PURE__ */
|
|
790
|
+
var MosaicDropIndicator = (props) => {
|
|
791
|
+
const { state } = useMosaicTileContext(DROP_INDICATOR_NAME);
|
|
792
|
+
return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React5.createElement(NativeDropIndicator, {
|
|
896
793
|
...props,
|
|
897
794
|
edge: state.closestEdge
|
|
898
795
|
}) : null;
|
|
899
796
|
};
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
Stack,
|
|
908
|
-
VirtualStack
|
|
909
|
-
};
|
|
797
|
+
MosaicDropIndicator.displayName = DROP_INDICATOR_NAME;
|
|
798
|
+
|
|
799
|
+
// src/components/Mosaic/Stack.tsx
|
|
800
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
801
|
+
import React8, { Fragment, forwardRef as forwardRef6 } from "react";
|
|
802
|
+
import { invariant } from "@dxos/invariant";
|
|
803
|
+
import { mx as mx8 } from "@dxos/ui-theme";
|
|
910
804
|
|
|
911
805
|
// src/translations.ts
|
|
912
806
|
var translationKey = "@dxos/react-ui-mosaic";
|
|
@@ -937,20 +831,20 @@ var styles3 = {
|
|
|
937
831
|
};
|
|
938
832
|
|
|
939
833
|
// src/components/Card/Card.tsx
|
|
940
|
-
import { Slot as
|
|
941
|
-
import
|
|
834
|
+
import { Slot as Slot6 } from "@radix-ui/react-slot";
|
|
835
|
+
import React7, { createContext as createContext5, forwardRef as forwardRef5, useContext as useContext2 } from "react";
|
|
942
836
|
import { Button, DropdownMenu, Icon, Toolbar, useTranslation } from "@dxos/react-ui";
|
|
943
|
-
import { mx as
|
|
837
|
+
import { mx as mx7 } from "@dxos/ui-theme";
|
|
944
838
|
|
|
945
839
|
// src/components/Image/Image.tsx
|
|
946
|
-
import
|
|
947
|
-
import { mx as
|
|
840
|
+
import React6, { useCallback as useCallback2, useRef as useRef6, useState as useState5 } from "react";
|
|
841
|
+
import { mx as mx6 } from "@dxos/ui-theme";
|
|
948
842
|
var cache = /* @__PURE__ */ new Map();
|
|
949
843
|
var Image = ({ classNames, src, alt = "", crossOrigin = "anonymous", sampleSize = 64, contrast = 0.9 }) => {
|
|
950
|
-
const [crossOriginState, setCrossOriginState] =
|
|
951
|
-
const [dominantColor, setDominantColor] =
|
|
952
|
-
const [imageLoaded, setImageLoaded] =
|
|
953
|
-
const canvasRef =
|
|
844
|
+
const [crossOriginState, setCrossOriginState] = useState5(crossOrigin);
|
|
845
|
+
const [dominantColor, setDominantColor] = useState5(void 0);
|
|
846
|
+
const [imageLoaded, setImageLoaded] = useState5(false);
|
|
847
|
+
const canvasRef = useRef6(null);
|
|
954
848
|
const handleImageError = () => {
|
|
955
849
|
setCrossOriginState(void 0);
|
|
956
850
|
};
|
|
@@ -984,31 +878,31 @@ var Image = ({ classNames, src, alt = "", crossOrigin = "anonymous", sampleSize
|
|
|
984
878
|
contrast,
|
|
985
879
|
src
|
|
986
880
|
]);
|
|
987
|
-
return /* @__PURE__ */
|
|
988
|
-
className:
|
|
881
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
882
|
+
className: mx6(`relative flex is-full justify-center overflow-hidden transition-all duration-700`, classNames),
|
|
989
883
|
style: {
|
|
990
884
|
backgroundColor: dominantColor
|
|
991
885
|
}
|
|
992
|
-
}, /* @__PURE__ */
|
|
886
|
+
}, /* @__PURE__ */ React6.createElement("canvas", {
|
|
993
887
|
ref: canvasRef,
|
|
994
888
|
style: {
|
|
995
889
|
display: "none"
|
|
996
890
|
},
|
|
997
891
|
"aria-hidden": "true"
|
|
998
|
-
}), /* @__PURE__ */
|
|
892
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
999
893
|
className: "absolute inset-0 pointer-events-none",
|
|
1000
894
|
style: {
|
|
1001
895
|
background: dominantColor ? `radial-gradient(circle at center, transparent 30%, ${dominantColor} 100%)` : void 0,
|
|
1002
896
|
transition: "opacity 0.7s ease-in-out",
|
|
1003
897
|
opacity: 0.5
|
|
1004
898
|
}
|
|
1005
|
-
}), /* @__PURE__ */
|
|
899
|
+
}), /* @__PURE__ */ React6.createElement("img", {
|
|
1006
900
|
src,
|
|
1007
901
|
alt,
|
|
1008
902
|
crossOrigin: crossOriginState,
|
|
1009
903
|
onError: handleImageError,
|
|
1010
904
|
onLoad: handleImageLoad,
|
|
1011
|
-
className:
|
|
905
|
+
className: mx6("z-10 object-contain transition-opacity duration-500", classNames),
|
|
1012
906
|
style: {
|
|
1013
907
|
opacity: imageLoaded ? 1 : 0
|
|
1014
908
|
}
|
|
@@ -1088,21 +982,21 @@ var isTransparent = (pixels, sampleSize, threshold = 0.5) => {
|
|
|
1088
982
|
};
|
|
1089
983
|
|
|
1090
984
|
// src/components/Card/Card.tsx
|
|
1091
|
-
var CardContext = /* @__PURE__ */
|
|
1092
|
-
var CardRoot = /* @__PURE__ */
|
|
1093
|
-
const
|
|
1094
|
-
return /* @__PURE__ */
|
|
985
|
+
var CardContext = /* @__PURE__ */ createContext5({});
|
|
986
|
+
var CardRoot = /* @__PURE__ */ forwardRef5(({ children, classNames, className, id, asChild, role = "group", border = true, fullWidth, ...props }, forwardedRef) => {
|
|
987
|
+
const Root = asChild ? Slot6 : "div";
|
|
988
|
+
return /* @__PURE__ */ React7.createElement(Root, {
|
|
1095
989
|
...id && {
|
|
1096
990
|
"data-object-id": id
|
|
1097
991
|
},
|
|
1098
992
|
...props,
|
|
1099
993
|
role,
|
|
1100
|
-
className:
|
|
994
|
+
className: mx7(styles3.root, border && styles3.border, fullWidth && "!max-is-none", className, classNames),
|
|
1101
995
|
ref: forwardedRef
|
|
1102
996
|
}, children);
|
|
1103
997
|
});
|
|
1104
|
-
var CardToolbar = /* @__PURE__ */
|
|
1105
|
-
return /* @__PURE__ */
|
|
998
|
+
var CardToolbar = /* @__PURE__ */ forwardRef5(({ children, classNames, density = "fine", ...props }, forwardedRef) => {
|
|
999
|
+
return /* @__PURE__ */ React7.createElement(Toolbar.Root, {
|
|
1106
1000
|
...props,
|
|
1107
1001
|
classNames: [
|
|
1108
1002
|
"density-fine bg-transparent",
|
|
@@ -1114,9 +1008,9 @@ var CardToolbar = /* @__PURE__ */ forwardRef3(({ children, classNames, density =
|
|
|
1114
1008
|
});
|
|
1115
1009
|
var CardToolbarIconButton = Toolbar.IconButton;
|
|
1116
1010
|
var CardToolbarSeparator = Toolbar.Separator;
|
|
1117
|
-
var CardDragHandle = /* @__PURE__ */
|
|
1011
|
+
var CardDragHandle = /* @__PURE__ */ forwardRef5((_, forwardedRef) => {
|
|
1118
1012
|
const { t } = useTranslation(translationKey);
|
|
1119
|
-
return /* @__PURE__ */
|
|
1013
|
+
return /* @__PURE__ */ React7.createElement(Toolbar.IconButton, {
|
|
1120
1014
|
"data-testid": "card-drag-handle",
|
|
1121
1015
|
noTooltip: true,
|
|
1122
1016
|
iconOnly: true,
|
|
@@ -1129,9 +1023,9 @@ var CardDragHandle = /* @__PURE__ */ forwardRef3((_, forwardedRef) => {
|
|
|
1129
1023
|
ref: forwardedRef
|
|
1130
1024
|
});
|
|
1131
1025
|
});
|
|
1132
|
-
var CardClose = /* @__PURE__ */
|
|
1026
|
+
var CardClose = /* @__PURE__ */ forwardRef5(({ onClick }, forwardedRef) => {
|
|
1133
1027
|
const { t } = useTranslation(translationKey);
|
|
1134
|
-
return /* @__PURE__ */
|
|
1028
|
+
return /* @__PURE__ */ React7.createElement(Toolbar.IconButton, {
|
|
1135
1029
|
iconOnly: true,
|
|
1136
1030
|
icon: "ph--x--regular",
|
|
1137
1031
|
variant: "ghost",
|
|
@@ -1149,62 +1043,62 @@ var CardMenu = ({ context, items }) => {
|
|
|
1149
1043
|
...items ?? [],
|
|
1150
1044
|
...menuItems ?? []
|
|
1151
1045
|
];
|
|
1152
|
-
return /* @__PURE__ */
|
|
1046
|
+
return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
|
|
1153
1047
|
disabled: !combinedItems.length,
|
|
1154
1048
|
asChild: true
|
|
1155
|
-
}, /* @__PURE__ */
|
|
1049
|
+
}, /* @__PURE__ */ React7.createElement(Card.ToolbarIconButton, {
|
|
1156
1050
|
iconOnly: true,
|
|
1157
1051
|
variant: "ghost",
|
|
1158
1052
|
icon: "ph--dots-three-vertical--regular",
|
|
1159
1053
|
label: t("action menu label")
|
|
1160
|
-
})), (combinedItems?.length ?? 0) > 0 && /* @__PURE__ */
|
|
1054
|
+
})), (combinedItems?.length ?? 0) > 0 && /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, combinedItems?.map(({ label, onClick: onSelect }, i) => /* @__PURE__ */ React7.createElement(DropdownMenu.Item, {
|
|
1161
1055
|
key: i,
|
|
1162
1056
|
onSelect: () => onSelect(context)
|
|
1163
|
-
}, label))), /* @__PURE__ */
|
|
1057
|
+
}, label))), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
|
|
1164
1058
|
};
|
|
1165
|
-
var CardTitle = /* @__PURE__ */
|
|
1166
|
-
const
|
|
1167
|
-
return /* @__PURE__ */
|
|
1059
|
+
var CardTitle = /* @__PURE__ */ forwardRef5(({ children, classNames, className, asChild, role = "heading", ...props }, forwardedRef) => {
|
|
1060
|
+
const Root = asChild ? Slot6 : "div";
|
|
1061
|
+
return /* @__PURE__ */ React7.createElement(Root, {
|
|
1168
1062
|
...props,
|
|
1169
1063
|
role,
|
|
1170
|
-
className:
|
|
1064
|
+
className: mx7("grow truncate", classNames, className),
|
|
1171
1065
|
ref: forwardedRef
|
|
1172
1066
|
}, children);
|
|
1173
1067
|
});
|
|
1174
|
-
var CardContent = /* @__PURE__ */
|
|
1175
|
-
return /* @__PURE__ */
|
|
1068
|
+
var CardContent = /* @__PURE__ */ forwardRef5(({ children, ...props }, forwardedRef) => {
|
|
1069
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1176
1070
|
role: "none",
|
|
1177
1071
|
className: "contents [&>:last-child]:pbe-1",
|
|
1178
1072
|
...props,
|
|
1179
1073
|
ref: forwardedRef
|
|
1180
1074
|
}, children);
|
|
1181
1075
|
});
|
|
1182
|
-
var CardRow = /* @__PURE__ */
|
|
1183
|
-
return /* @__PURE__ */
|
|
1076
|
+
var CardRow = /* @__PURE__ */ forwardRef5(({ children, classNames, className, role = "none", icon, ...props }, forwardedRef) => {
|
|
1077
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1184
1078
|
...props,
|
|
1185
1079
|
role,
|
|
1186
|
-
className:
|
|
1080
|
+
className: mx7(styles3.grid_2, "pli-1", classNames, className),
|
|
1187
1081
|
ref: forwardedRef
|
|
1188
|
-
}, icon && /* @__PURE__ */
|
|
1082
|
+
}, icon && /* @__PURE__ */ React7.createElement(CardIcon, {
|
|
1189
1083
|
classNames: "text-subdued",
|
|
1190
1084
|
icon
|
|
1191
|
-
}) || /* @__PURE__ */
|
|
1085
|
+
}) || /* @__PURE__ */ React7.createElement("div", null), children);
|
|
1192
1086
|
});
|
|
1193
|
-
var CardHeading = /* @__PURE__ */
|
|
1194
|
-
const
|
|
1087
|
+
var CardHeading = /* @__PURE__ */ forwardRef5(({ children, classNames, className, asChild, role = "heading", variant = "default", ...props }, forwardedRef) => {
|
|
1088
|
+
const Root = asChild ? Slot6 : "div";
|
|
1195
1089
|
const variantClassNames = {
|
|
1196
1090
|
default: "plb-1",
|
|
1197
1091
|
subtitle: "plb-2 text-xs text-description font-medium uppercase"
|
|
1198
1092
|
};
|
|
1199
|
-
return /* @__PURE__ */
|
|
1093
|
+
return /* @__PURE__ */ React7.createElement(Root, {
|
|
1200
1094
|
...props,
|
|
1201
1095
|
role,
|
|
1202
|
-
className:
|
|
1096
|
+
className: mx7(variantClassNames[variant], classNames, className),
|
|
1203
1097
|
ref: forwardedRef
|
|
1204
1098
|
}, children);
|
|
1205
1099
|
});
|
|
1206
|
-
var CardText = /* @__PURE__ */
|
|
1207
|
-
const
|
|
1100
|
+
var CardText = /* @__PURE__ */ forwardRef5(({ children, classNames, className, asChild, role = "none", truncate, variant = "default", ...props }, forwardedRef) => {
|
|
1101
|
+
const Root = asChild ? Slot6 : "div";
|
|
1208
1102
|
const variantClassNames = {
|
|
1209
1103
|
default: {
|
|
1210
1104
|
root: "plb-1"
|
|
@@ -1214,22 +1108,22 @@ var CardText = /* @__PURE__ */ forwardRef3(({ children, classNames, className, a
|
|
|
1214
1108
|
span: "text-sm text-description line-clamp-3"
|
|
1215
1109
|
}
|
|
1216
1110
|
};
|
|
1217
|
-
return /* @__PURE__ */
|
|
1111
|
+
return /* @__PURE__ */ React7.createElement(Root, {
|
|
1218
1112
|
...props,
|
|
1219
1113
|
role,
|
|
1220
|
-
className:
|
|
1114
|
+
className: mx7("flex overflow-hidden", variantClassNames[variant].root, classNames, className),
|
|
1221
1115
|
ref: forwardedRef
|
|
1222
|
-
}, /* @__PURE__ */
|
|
1223
|
-
className:
|
|
1116
|
+
}, /* @__PURE__ */ React7.createElement("span", {
|
|
1117
|
+
className: mx7(variantClassNames[variant].span, truncate && "truncate")
|
|
1224
1118
|
}, children));
|
|
1225
1119
|
});
|
|
1226
1120
|
var CardPoster = (props) => {
|
|
1227
1121
|
const aspect = props.aspect === "auto" ? "aspect-auto" : "aspect-video";
|
|
1228
1122
|
if (props.image) {
|
|
1229
|
-
return /* @__PURE__ */
|
|
1123
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1230
1124
|
role: "none",
|
|
1231
1125
|
className: "mbe-1"
|
|
1232
|
-
}, /* @__PURE__ */
|
|
1126
|
+
}, /* @__PURE__ */ React7.createElement(Image, {
|
|
1233
1127
|
classNames: [
|
|
1234
1128
|
styles3.poster,
|
|
1235
1129
|
aspect,
|
|
@@ -1240,62 +1134,62 @@ var CardPoster = (props) => {
|
|
|
1240
1134
|
}));
|
|
1241
1135
|
}
|
|
1242
1136
|
if (props.icon) {
|
|
1243
|
-
return /* @__PURE__ */
|
|
1137
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1244
1138
|
role: "image",
|
|
1245
|
-
className:
|
|
1139
|
+
className: mx7("grid place-items-center bg-inputSurface text-subdued", styles3.poster, aspect, props.classNames),
|
|
1246
1140
|
"aria-label": props.alt
|
|
1247
|
-
}, /* @__PURE__ */
|
|
1141
|
+
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
1248
1142
|
icon: props.icon,
|
|
1249
1143
|
size: 10
|
|
1250
1144
|
}));
|
|
1251
1145
|
}
|
|
1252
1146
|
};
|
|
1253
1147
|
var CardAction = ({ icon, actionIcon = "ph--arrow-right--regular", label, onClick }) => {
|
|
1254
|
-
return /* @__PURE__ */
|
|
1148
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1255
1149
|
role: "none",
|
|
1256
1150
|
className: "is-full pli-1"
|
|
1257
|
-
}, /* @__PURE__ */
|
|
1151
|
+
}, /* @__PURE__ */ React7.createElement(Button, {
|
|
1258
1152
|
variant: "ghost",
|
|
1259
|
-
classNames:
|
|
1153
|
+
classNames: mx7(styles3.grid_3, "!p-0 is-full text-start overflow-hidden"),
|
|
1260
1154
|
onClick
|
|
1261
|
-
}, icon ? /* @__PURE__ */
|
|
1155
|
+
}, icon ? /* @__PURE__ */ React7.createElement(CardIcon, {
|
|
1262
1156
|
classNames: "text-subdued",
|
|
1263
1157
|
icon
|
|
1264
|
-
}) : /* @__PURE__ */
|
|
1265
|
-
className:
|
|
1266
|
-
}, label), actionIcon && /* @__PURE__ */
|
|
1158
|
+
}) : /* @__PURE__ */ React7.createElement("div", null), /* @__PURE__ */ React7.createElement("span", {
|
|
1159
|
+
className: mx7("min-is-0 flex-1 truncate", !actionIcon && "col-span-2")
|
|
1160
|
+
}, label), actionIcon && /* @__PURE__ */ React7.createElement(CardIcon, {
|
|
1267
1161
|
icon: actionIcon
|
|
1268
1162
|
})));
|
|
1269
1163
|
};
|
|
1270
1164
|
var CardLink = ({ label, href }) => {
|
|
1271
|
-
return /* @__PURE__ */
|
|
1165
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1272
1166
|
role: "none",
|
|
1273
1167
|
className: "is-full pli-1"
|
|
1274
|
-
}, /* @__PURE__ */
|
|
1275
|
-
className:
|
|
1168
|
+
}, /* @__PURE__ */ React7.createElement("a", {
|
|
1169
|
+
className: mx7(styles3.grid_3, "group !p-0 dx-button dx-focus-ring !min-bs-1"),
|
|
1276
1170
|
"data-variant": "ghost",
|
|
1277
1171
|
href,
|
|
1278
1172
|
target: "_blank",
|
|
1279
1173
|
rel: "noreferrer"
|
|
1280
|
-
}, /* @__PURE__ */
|
|
1174
|
+
}, /* @__PURE__ */ React7.createElement(CardIcon, {
|
|
1281
1175
|
classNames: "text-subdued",
|
|
1282
1176
|
icon: "ph--link--regular"
|
|
1283
|
-
}), /* @__PURE__ */
|
|
1284
|
-
className:
|
|
1285
|
-
}, label), /* @__PURE__ */
|
|
1177
|
+
}), /* @__PURE__ */ React7.createElement("span", {
|
|
1178
|
+
className: mx7("min-is-0 flex-1 truncate")
|
|
1179
|
+
}, label), /* @__PURE__ */ React7.createElement(CardIcon, {
|
|
1286
1180
|
classNames: "invisible group-hover:visible",
|
|
1287
1181
|
icon: "ph--arrow-square-out--regular"
|
|
1288
1182
|
})));
|
|
1289
1183
|
};
|
|
1290
1184
|
var CardIconBlock = ({ classNames, children, role = "none", ...props }) => {
|
|
1291
|
-
return /* @__PURE__ */
|
|
1185
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
1292
1186
|
...props,
|
|
1293
1187
|
role,
|
|
1294
|
-
className:
|
|
1188
|
+
className: mx7("grid bs-[var(--rail-item)] is-[var(--rail-item)] place-items-center", classNames)
|
|
1295
1189
|
}, children);
|
|
1296
1190
|
};
|
|
1297
1191
|
var CardIcon = ({ toolbar, ...props }) => {
|
|
1298
|
-
return /* @__PURE__ */
|
|
1192
|
+
return /* @__PURE__ */ React7.createElement(CardIconBlock, null, /* @__PURE__ */ React7.createElement(Icon, {
|
|
1299
1193
|
...props,
|
|
1300
1194
|
size: toolbar ? 5 : 4
|
|
1301
1195
|
}));
|
|
@@ -1323,20 +1217,20 @@ var Card = {
|
|
|
1323
1217
|
Link: CardLink
|
|
1324
1218
|
};
|
|
1325
1219
|
|
|
1326
|
-
// src/components/
|
|
1327
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/
|
|
1328
|
-
var
|
|
1329
|
-
var
|
|
1330
|
-
invariant(
|
|
1220
|
+
// src/components/Mosaic/Stack.tsx
|
|
1221
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Stack.tsx";
|
|
1222
|
+
var MOSAIC_STACK_NAME = "MosaicStack";
|
|
1223
|
+
var MosaicStackInner = /* @__PURE__ */ forwardRef6(({ classNames, className, role = "list", orientation: orientationProp = "vertical", draggable: draggable2 = true, items, getId, Tile, debug, ...props }, forwardedRef) => {
|
|
1224
|
+
invariant(Tile, void 0, {
|
|
1331
1225
|
F: __dxlog_file2,
|
|
1332
|
-
L:
|
|
1226
|
+
L: 75,
|
|
1333
1227
|
S: void 0,
|
|
1334
1228
|
A: [
|
|
1335
1229
|
"Tile",
|
|
1336
1230
|
""
|
|
1337
1231
|
]
|
|
1338
1232
|
});
|
|
1339
|
-
const { id, orientation = orientationProp, dragging } =
|
|
1233
|
+
const { id, orientation = orientationProp, dragging } = useMosaicContainerContext(MOSAIC_STACK_NAME);
|
|
1340
1234
|
const visibleItems = useVisibleItems({
|
|
1341
1235
|
id,
|
|
1342
1236
|
items,
|
|
@@ -1345,48 +1239,48 @@ var StackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, role = "l
|
|
|
1345
1239
|
});
|
|
1346
1240
|
invariant(orientation === "vertical" || orientation === "horizontal", `Invalid orientation: ${orientation}`, {
|
|
1347
1241
|
F: __dxlog_file2,
|
|
1348
|
-
L:
|
|
1242
|
+
L: 78,
|
|
1349
1243
|
S: void 0,
|
|
1350
1244
|
A: [
|
|
1351
1245
|
"orientation === 'vertical' || orientation === 'horizontal'",
|
|
1352
1246
|
"`Invalid orientation: ${orientation}`"
|
|
1353
1247
|
]
|
|
1354
1248
|
});
|
|
1355
|
-
return /* @__PURE__ */
|
|
1249
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
1356
1250
|
...props,
|
|
1357
1251
|
role,
|
|
1358
|
-
className:
|
|
1252
|
+
className: mx8("flex", orientation === "horizontal" && "bs-full [&>*]:shrink-0", orientation === "vertical" && "flex-col", classNames, className),
|
|
1359
1253
|
ref: forwardedRef
|
|
1360
|
-
}, /* @__PURE__ */
|
|
1254
|
+
}, /* @__PURE__ */ React8.createElement(InternalPlaceholder, {
|
|
1361
1255
|
orientation,
|
|
1362
1256
|
location: 0.5
|
|
1363
|
-
}), visibleItems?.map((item, index) => /* @__PURE__ */
|
|
1257
|
+
}), visibleItems?.map((item, index) => /* @__PURE__ */ React8.createElement(Fragment, {
|
|
1364
1258
|
key: getId(item)
|
|
1365
|
-
}, /* @__PURE__ */
|
|
1259
|
+
}, /* @__PURE__ */ React8.createElement(Tile, {
|
|
1366
1260
|
id: getId(item),
|
|
1367
1261
|
data: item,
|
|
1368
1262
|
location: index + 1,
|
|
1369
1263
|
draggable: draggable2,
|
|
1370
1264
|
debug
|
|
1371
|
-
}), /* @__PURE__ */
|
|
1265
|
+
}), /* @__PURE__ */ React8.createElement(InternalPlaceholder, {
|
|
1372
1266
|
orientation,
|
|
1373
1267
|
location: index + 1.5
|
|
1374
1268
|
}))));
|
|
1375
1269
|
});
|
|
1376
|
-
|
|
1377
|
-
var
|
|
1378
|
-
var
|
|
1379
|
-
var
|
|
1380
|
-
invariant(
|
|
1270
|
+
MosaicStackInner.displayName = MOSAIC_STACK_NAME;
|
|
1271
|
+
var MosaicStack = MosaicStackInner;
|
|
1272
|
+
var MOSAIC_VIRTUAL_STACK_NAME = "MosaicVirtualStack";
|
|
1273
|
+
var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef6(({ classNames, className, role = "list", orientation = "vertical", items, getId, Tile, estimateSize, getScrollElement, overscan = 8, onChange, debug, ...props }, forwardedRef) => {
|
|
1274
|
+
invariant(Tile, void 0, {
|
|
1381
1275
|
F: __dxlog_file2,
|
|
1382
|
-
L:
|
|
1276
|
+
L: 142,
|
|
1383
1277
|
S: void 0,
|
|
1384
1278
|
A: [
|
|
1385
1279
|
"Tile",
|
|
1386
1280
|
""
|
|
1387
1281
|
]
|
|
1388
1282
|
});
|
|
1389
|
-
const { id, dragging } =
|
|
1283
|
+
const { id, dragging } = useMosaicContainerContext(MOSAIC_VIRTUAL_STACK_NAME);
|
|
1390
1284
|
const visibleItems = useVisibleItems({
|
|
1391
1285
|
id,
|
|
1392
1286
|
items,
|
|
@@ -1401,10 +1295,10 @@ var VirtualStackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, ro
|
|
|
1401
1295
|
onChange
|
|
1402
1296
|
});
|
|
1403
1297
|
const virtualItems = virtualizer.getVirtualItems();
|
|
1404
|
-
return /* @__PURE__ */
|
|
1298
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
1405
1299
|
...props,
|
|
1406
1300
|
role,
|
|
1407
|
-
className:
|
|
1301
|
+
className: mx8("flex", orientation === "horizontal" && "bs-full [&>*]:shrink-0", orientation === "vertical" && "flex-col", classNames, className),
|
|
1408
1302
|
style: {
|
|
1409
1303
|
position: "relative",
|
|
1410
1304
|
...orientation === "vertical" ? {
|
|
@@ -1418,7 +1312,7 @@ var VirtualStackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, ro
|
|
|
1418
1312
|
ref: forwardedRef
|
|
1419
1313
|
}, virtualItems.map((virtualItem) => {
|
|
1420
1314
|
const data = visibleItems[Math.floor(virtualItem.index / 2)];
|
|
1421
|
-
return /* @__PURE__ */
|
|
1315
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
1422
1316
|
key: virtualItem.key,
|
|
1423
1317
|
"data-index": virtualItem.index,
|
|
1424
1318
|
style: {
|
|
@@ -1434,10 +1328,10 @@ var VirtualStackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, ro
|
|
|
1434
1328
|
}
|
|
1435
1329
|
},
|
|
1436
1330
|
ref: virtualizer.measureElement
|
|
1437
|
-
}, virtualItem.index % 2 === 0 ? /* @__PURE__ */
|
|
1331
|
+
}, virtualItem.index % 2 === 0 ? /* @__PURE__ */ React8.createElement(InternalPlaceholder, {
|
|
1438
1332
|
orientation,
|
|
1439
1333
|
location: Math.floor(virtualItem.index / 2) + 0.5
|
|
1440
|
-
}) : /* @__PURE__ */
|
|
1334
|
+
}) : /* @__PURE__ */ React8.createElement(Tile, {
|
|
1441
1335
|
id: getId(data),
|
|
1442
1336
|
data,
|
|
1443
1337
|
location: Math.floor(virtualItem.index / 2) + 1,
|
|
@@ -1445,17 +1339,28 @@ var VirtualStackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, ro
|
|
|
1445
1339
|
}));
|
|
1446
1340
|
}));
|
|
1447
1341
|
});
|
|
1448
|
-
|
|
1449
|
-
var
|
|
1450
|
-
var
|
|
1451
|
-
return /* @__PURE__ */
|
|
1342
|
+
MosaicVirtualStackInner.displayName = MOSAIC_VIRTUAL_STACK_NAME;
|
|
1343
|
+
var MosaicVirtualStack = MosaicVirtualStackInner;
|
|
1344
|
+
var InternalPlaceholder = (props) => {
|
|
1345
|
+
return /* @__PURE__ */ React8.createElement(MosaicPlaceholder, {
|
|
1452
1346
|
...props,
|
|
1453
1347
|
classNames: styles2.placeholder.root
|
|
1454
|
-
}, /* @__PURE__ */
|
|
1455
|
-
className:
|
|
1348
|
+
}, /* @__PURE__ */ React8.createElement("div", {
|
|
1349
|
+
className: mx8("flex bs-full bg-baseSurface border border-dashed border-separator rounded-sm", styles2.placeholder.content)
|
|
1456
1350
|
}));
|
|
1457
1351
|
};
|
|
1458
|
-
|
|
1352
|
+
InternalPlaceholder.displayName = "InternalPlaceholder";
|
|
1353
|
+
|
|
1354
|
+
// src/components/Mosaic/Mosaic.tsx
|
|
1355
|
+
var Mosaic = {
|
|
1356
|
+
Root: MosaicRoot,
|
|
1357
|
+
Container: MosaicContainer,
|
|
1358
|
+
Tile: MosaicTile,
|
|
1359
|
+
Placeholder: MosaicPlaceholder,
|
|
1360
|
+
DropIndicator: MosaicDropIndicator,
|
|
1361
|
+
Stack: MosaicStack,
|
|
1362
|
+
VirtualStack: MosaicVirtualStack
|
|
1363
|
+
};
|
|
1459
1364
|
|
|
1460
1365
|
export {
|
|
1461
1366
|
useVisibleItems,
|
|
@@ -1463,16 +1368,14 @@ export {
|
|
|
1463
1368
|
useFocus,
|
|
1464
1369
|
Focus,
|
|
1465
1370
|
styles2,
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
useContainerContext,
|
|
1471
|
-
useTileContext,
|
|
1371
|
+
getSourceData,
|
|
1372
|
+
useMosaicRootContext,
|
|
1373
|
+
useMosaicContainerContext,
|
|
1374
|
+
useMosaicTileContext,
|
|
1472
1375
|
Mosaic,
|
|
1473
1376
|
translationKey,
|
|
1474
1377
|
styles3,
|
|
1475
1378
|
Image,
|
|
1476
1379
|
Card
|
|
1477
1380
|
};
|
|
1478
|
-
//# sourceMappingURL=chunk-
|
|
1381
|
+
//# sourceMappingURL=chunk-XNANTBOP.mjs.map
|