@dxos/react-ui-mosaic 0.8.4-main.bc674ce → 0.8.4-main.c85a9c8dae
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/chunk-7S4PIFKU.mjs +953 -0
- package/dist/lib/browser/chunk-7S4PIFKU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +596 -70
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/playwright/index.mjs +138 -0
- package/dist/lib/browser/playwright/index.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +61 -232
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-MK6KU66S.mjs +955 -0
- package/dist/lib/node-esm/chunk-MK6KU66S.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +596 -70
- 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 +140 -0
- package/dist/lib/node-esm/playwright/index.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +61 -232
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/components/Board/Board.d.ts +81 -0
- package/dist/types/src/components/Board/Board.d.ts.map +1 -0
- package/dist/types/src/components/{Mosaic/Mosaic.stories.d.ts → Board/Board.stories.d.ts} +15 -1
- package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -0
- package/dist/types/src/components/Board/Column.d.ts +40 -0
- package/dist/types/src/components/Board/Column.d.ts.map +1 -0
- package/dist/types/src/components/Board/Item.d.ts +9 -0
- package/dist/types/src/components/Board/Item.d.ts.map +1 -0
- package/dist/types/src/components/Board/index.d.ts +2 -0
- package/dist/types/src/components/Board/index.d.ts.map +1 -0
- package/dist/types/src/components/Focus/Focus.d.ts +5 -4
- package/dist/types/src/components/Focus/Focus.d.ts.map +1 -1
- package/dist/types/src/components/Focus/index.d.ts +0 -1
- package/dist/types/src/components/Focus/index.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 -118
- 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/styles.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/types.d.ts +9 -2
- package/dist/types/src/components/Mosaic/types.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -4
- 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/useEventHandlerAdapter.d.ts +1 -1
- package/dist/types/src/hooks/useEventHandlerAdapter.d.ts.map +1 -1
- 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/playwright/board-manager.d.ts +45 -0
- package/dist/types/src/playwright/board-manager.d.ts.map +1 -0
- package/dist/types/src/playwright/index.d.ts +9 -0
- package/dist/types/src/playwright/index.d.ts.map +1 -0
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/playwright/smoke.spec.d.ts +2 -0
- package/dist/types/src/playwright/smoke.spec.d.ts.map +1 -0
- package/dist/types/src/testing/CardContainer.d.ts +5 -4
- package/dist/types/src/testing/CardContainer.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/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/types.d.ts +21 -0
- package/dist/types/src/testing/types.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +5 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -28
- package/src/components/Board/Board.stories.tsx +273 -0
- package/src/components/Board/Board.tsx +191 -0
- package/src/components/Board/Column.tsx +300 -0
- package/src/components/Board/Item.tsx +116 -0
- package/src/components/{Layout → Board}/index.ts +1 -1
- package/src/components/Focus/Focus.tsx +26 -17
- package/src/components/Focus/index.ts +0 -2
- package/src/components/Mosaic/Container.tsx +289 -0
- package/src/components/Mosaic/Mosaic.tsx +35 -913
- package/src/components/Mosaic/Placeholder.tsx +133 -0
- package/src/components/Mosaic/Root.tsx +292 -0
- package/src/components/{Stack → Mosaic}/Stack.stories.tsx +30 -26
- package/src/components/Mosaic/Stack.tsx +246 -0
- package/src/components/Mosaic/Tile.tsx +242 -0
- package/src/components/Mosaic/extension.ts +1 -1
- package/src/components/Mosaic/styles.ts +9 -8
- package/src/components/Mosaic/types.ts +15 -3
- package/src/components/index.ts +1 -4
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useContainerDebug.tsx +4 -2
- package/src/hooks/useDefaultColumnEventHandler.ts +35 -0
- package/src/hooks/useEventHandlerAdapter.ts +15 -6
- package/src/hooks/useVisibleItems.ts +7 -2
- package/src/playwright/board-manager.ts +154 -0
- package/src/playwright/index.ts +13 -0
- package/src/playwright/playwright.config.ts +17 -0
- package/src/playwright/smoke.spec.ts +138 -0
- package/src/testing/CardContainer.tsx +30 -18
- package/src/testing/DefaultStackTile.tsx +27 -16
- package/src/testing/index.ts +1 -1
- package/src/testing/types.ts +38 -0
- package/src/translations.ts +5 -1
- package/dist/lib/browser/chunk-UMBPEG4F.mjs +0 -1637
- package/dist/lib/browser/chunk-UMBPEG4F.mjs.map +0 -7
- package/dist/lib/browser/index.css +0 -13
- package/dist/lib/browser/index.css.map +0 -7
- package/dist/lib/browser/testing/index.css +0 -13
- package/dist/lib/browser/testing/index.css.map +0 -7
- package/dist/lib/node-esm/chunk-X6GV7SMK.mjs +0 -1639
- package/dist/lib/node-esm/chunk-X6GV7SMK.mjs.map +0 -7
- package/dist/lib/node-esm/index.css +0 -13
- package/dist/lib/node-esm/index.css.map +0 -7
- package/dist/lib/node-esm/testing/index.css +0 -13
- package/dist/lib/node-esm/testing/index.css.map +0 -7
- package/dist/types/src/components/Card/Card.d.ts +0 -121
- package/dist/types/src/components/Card/Card.d.ts.map +0 -1
- package/dist/types/src/components/Card/Card.stories.d.ts +0 -21
- package/dist/types/src/components/Card/Card.stories.d.ts.map +0 -1
- package/dist/types/src/components/Card/CardDragPreview.d.ts +0 -6
- package/dist/types/src/components/Card/CardDragPreview.d.ts.map +0 -1
- package/dist/types/src/components/Card/index.d.ts +0 -4
- package/dist/types/src/components/Card/index.d.ts.map +0 -1
- package/dist/types/src/components/Card/styles.d.ts +0 -13
- package/dist/types/src/components/Card/styles.d.ts.map +0 -1
- package/dist/types/src/components/Focus/styles.d.ts +0 -6
- package/dist/types/src/components/Focus/styles.d.ts.map +0 -1
- package/dist/types/src/components/Image/Image.d.ts +0 -14
- package/dist/types/src/components/Image/Image.d.ts.map +0 -1
- package/dist/types/src/components/Image/Image.stories.d.ts +0 -33
- package/dist/types/src/components/Image/Image.stories.d.ts.map +0 -1
- package/dist/types/src/components/Image/index.d.ts +0 -2
- package/dist/types/src/components/Image/index.d.ts.map +0 -1
- package/dist/types/src/components/Layout/Layout.d.ts +0 -33
- package/dist/types/src/components/Layout/Layout.d.ts.map +0 -1
- package/dist/types/src/components/Layout/Layout.stories.d.ts +0 -10
- package/dist/types/src/components/Layout/Layout.stories.d.ts.map +0 -1
- package/dist/types/src/components/Layout/index.d.ts +0 -2
- package/dist/types/src/components/Layout/index.d.ts.map +0 -1
- package/dist/types/src/components/Mosaic/Mosaic.stories.d.ts.map +0 -1
- package/dist/types/src/components/Scrollable/Scrollable.d.ts +0 -24
- package/dist/types/src/components/Scrollable/Scrollable.d.ts.map +0 -1
- package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts +0 -10
- package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts.map +0 -1
- package/dist/types/src/components/Scrollable/index.d.ts +0 -2
- package/dist/types/src/components/Scrollable/index.d.ts.map +0 -1
- 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/testing/Board.d.ts +0 -45
- package/dist/types/src/testing/Board.d.ts.map +0 -1
- package/dist/types/src/testing/Slot.stories.d.ts +0 -14
- package/dist/types/src/testing/Slot.stories.d.ts.map +0 -1
- package/dist/types/src/testing/Virtualizer.stories.d.ts +0 -12
- package/dist/types/src/testing/Virtualizer.stories.d.ts.map +0 -1
- package/src/components/Card/Card.stories.tsx +0 -148
- package/src/components/Card/Card.tsx +0 -458
- package/src/components/Card/CardDragPreview.tsx +0 -23
- package/src/components/Card/index.ts +0 -8
- package/src/components/Card/styles.ts +0 -23
- package/src/components/Focus/styles.ts +0 -24
- package/src/components/Image/Image.stories.tsx +0 -86
- package/src/components/Image/Image.tsx +0 -223
- package/src/components/Image/index.ts +0 -5
- package/src/components/Layout/Layout.stories.tsx +0 -59
- package/src/components/Layout/Layout.tsx +0 -108
- package/src/components/Mosaic/Mosaic.stories.tsx +0 -113
- package/src/components/Scrollable/Scrollable.stories.tsx +0 -59
- package/src/components/Scrollable/Scrollable.tsx +0 -88
- package/src/components/Scrollable/index.ts +0 -5
- package/src/components/Scrollable/scrollable.css +0 -20
- package/src/components/Stack/Stack.tsx +0 -210
- package/src/components/Stack/index.ts +0 -5
- package/src/testing/Board.tsx +0 -278
- package/src/testing/Slot.stories.tsx +0 -101
- package/src/testing/Virtualizer.stories.tsx +0 -133
|
@@ -1,1637 +0,0 @@
|
|
|
1
|
-
// src/components/Card/styles.ts
|
|
2
|
-
var styles = {
|
|
3
|
-
root: "group/card relative min-bs-[--rail-item] overflow-hidden is-full card-min-width __card-max-width",
|
|
4
|
-
border: "bg-cardSurface border border-separator dark:border-subduedSeparator rounded-sm dx-focus-ring-group-y-indicator",
|
|
5
|
-
/**
|
|
6
|
-
* Row grid.
|
|
7
|
-
* NOTE: Rows should provide their own line padding (since they may need to encapsulate buttons, etc.)
|
|
8
|
-
*/
|
|
9
|
-
grid_3: "grid grid-cols-[var(--rail-item)_minmax(0,1fr)_var(--rail-item)] gap-x-1",
|
|
10
|
-
grid_2: "grid grid-cols-[var(--rail-item)_minmax(0,1fr)] gap-x-1",
|
|
11
|
-
// TODO(burdon): Address density.
|
|
12
|
-
grid_3_coarse: "grid grid-cols-[var(--l0-avatar-size)_minmax(0,1fr)_var(--rail-item)] gap-x-1",
|
|
13
|
-
poster: "max-bs-[200px]"
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// src/components/Image/Image.tsx
|
|
17
|
-
import React, { useCallback, useRef, useState } from "react";
|
|
18
|
-
import { mx } from "@dxos/ui-theme";
|
|
19
|
-
var cache = /* @__PURE__ */ new Map();
|
|
20
|
-
var Image = ({ classNames, src, alt = "", crossOrigin = "anonymous", sampleSize = 64, contrast = 0.9 }) => {
|
|
21
|
-
const [crossOriginState, setCrossOriginState] = useState(crossOrigin);
|
|
22
|
-
const [dominantColor, setDominantColor] = useState(void 0);
|
|
23
|
-
const [imageLoaded, setImageLoaded] = useState(false);
|
|
24
|
-
const canvasRef = useRef(null);
|
|
25
|
-
const handleImageError = () => {
|
|
26
|
-
setCrossOriginState(void 0);
|
|
27
|
-
};
|
|
28
|
-
const handleImageLoad = useCallback(({ target }) => {
|
|
29
|
-
const rgb = cache.get(src);
|
|
30
|
-
if (rgb) {
|
|
31
|
-
setDominantColor(rgb);
|
|
32
|
-
setImageLoaded(true);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const img = target;
|
|
36
|
-
if (!canvasRef.current) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
const color = extractDominantColor(canvasRef.current, img, {
|
|
41
|
-
sampleSize,
|
|
42
|
-
contrast
|
|
43
|
-
});
|
|
44
|
-
if (color) {
|
|
45
|
-
const rgb2 = `rgb(${color[0]}, ${color[1]}, ${color[2]})`;
|
|
46
|
-
cache.set(src, rgb2);
|
|
47
|
-
setDominantColor(rgb2);
|
|
48
|
-
}
|
|
49
|
-
} catch {
|
|
50
|
-
setCrossOriginState(void 0);
|
|
51
|
-
}
|
|
52
|
-
setImageLoaded(true);
|
|
53
|
-
}, [
|
|
54
|
-
sampleSize,
|
|
55
|
-
contrast,
|
|
56
|
-
src
|
|
57
|
-
]);
|
|
58
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
59
|
-
className: mx(`relative flex is-full justify-center overflow-hidden transition-all duration-700`, classNames),
|
|
60
|
-
style: {
|
|
61
|
-
backgroundColor: dominantColor
|
|
62
|
-
}
|
|
63
|
-
}, /* @__PURE__ */ React.createElement("canvas", {
|
|
64
|
-
ref: canvasRef,
|
|
65
|
-
style: {
|
|
66
|
-
display: "none"
|
|
67
|
-
},
|
|
68
|
-
"aria-hidden": "true"
|
|
69
|
-
}), /* @__PURE__ */ React.createElement("div", {
|
|
70
|
-
className: "absolute inset-0 pointer-events-none",
|
|
71
|
-
style: {
|
|
72
|
-
background: dominantColor ? `radial-gradient(circle at center, transparent 30%, ${dominantColor} 100%)` : void 0,
|
|
73
|
-
transition: "opacity 0.7s ease-in-out",
|
|
74
|
-
opacity: 0.5
|
|
75
|
-
}
|
|
76
|
-
}), /* @__PURE__ */ React.createElement("img", {
|
|
77
|
-
src,
|
|
78
|
-
alt,
|
|
79
|
-
crossOrigin: crossOriginState,
|
|
80
|
-
onError: handleImageError,
|
|
81
|
-
onLoad: handleImageLoad,
|
|
82
|
-
className: mx("z-10 object-contain transition-opacity duration-500", classNames),
|
|
83
|
-
style: {
|
|
84
|
-
opacity: imageLoaded ? 1 : 0
|
|
85
|
-
}
|
|
86
|
-
}));
|
|
87
|
-
};
|
|
88
|
-
var extractDominantColor = (canvas, img, { sampleSize = 64, contrast = 0.95 }) => {
|
|
89
|
-
const ctx = canvas.getContext("2d");
|
|
90
|
-
if (!ctx) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
canvas.width = sampleSize;
|
|
94
|
-
canvas.height = sampleSize;
|
|
95
|
-
ctx.drawImage(img, 0, 0, sampleSize, sampleSize);
|
|
96
|
-
const imageData = ctx.getImageData(0, 0, sampleSize, sampleSize);
|
|
97
|
-
const pixels = imageData.data;
|
|
98
|
-
if (isTransparent(pixels, sampleSize)) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
let r = 0;
|
|
102
|
-
let g = 0;
|
|
103
|
-
let b = 0;
|
|
104
|
-
let totalWeight = 0;
|
|
105
|
-
const cornerSize = Math.floor(sampleSize * 0.125);
|
|
106
|
-
for (let y = 0; y < sampleSize; y++) {
|
|
107
|
-
for (let x = 0; x < sampleSize; x++) {
|
|
108
|
-
const isInTopLeft = x < cornerSize && y < cornerSize;
|
|
109
|
-
const isInTopRight = x >= sampleSize - cornerSize && y < cornerSize;
|
|
110
|
-
const isInBottomLeft = x < cornerSize && y >= sampleSize - cornerSize;
|
|
111
|
-
const isInBottomRight = x >= sampleSize - cornerSize && y >= sampleSize - cornerSize;
|
|
112
|
-
if (!isInTopLeft && !isInTopRight && !isInBottomLeft && !isInBottomRight) {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
const i = (y * sampleSize + x) * 4;
|
|
116
|
-
const red = pixels[i];
|
|
117
|
-
const green = pixels[i + 1];
|
|
118
|
-
const blue = pixels[i + 2];
|
|
119
|
-
const alpha = pixels[i + 3];
|
|
120
|
-
if (alpha === 0) continue;
|
|
121
|
-
const max = Math.max(red, green, blue);
|
|
122
|
-
const min = Math.min(red, green, blue);
|
|
123
|
-
const saturation = max === 0 ? 0 : (max - min) / max;
|
|
124
|
-
const weight = 1 + saturation * 2;
|
|
125
|
-
r += red * weight;
|
|
126
|
-
g += green * weight;
|
|
127
|
-
b += blue * weight;
|
|
128
|
-
totalWeight += weight;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (totalWeight > 0) {
|
|
132
|
-
r = Math.round(Math.round(r / totalWeight) * contrast);
|
|
133
|
-
g = Math.round(Math.round(g / totalWeight) * contrast);
|
|
134
|
-
b = Math.round(Math.round(b / totalWeight) * contrast);
|
|
135
|
-
return [
|
|
136
|
-
r,
|
|
137
|
-
g,
|
|
138
|
-
b
|
|
139
|
-
];
|
|
140
|
-
}
|
|
141
|
-
return null;
|
|
142
|
-
};
|
|
143
|
-
var isTransparent = (pixels, sampleSize, threshold = 0.5) => {
|
|
144
|
-
let edgeTransparentPixels = 0;
|
|
145
|
-
const edgePixels = sampleSize * 4 - 4;
|
|
146
|
-
for (let x = 0; x < sampleSize; x++) {
|
|
147
|
-
const topIndex = x * 4;
|
|
148
|
-
if (pixels[topIndex + 3] === 0) edgeTransparentPixels++;
|
|
149
|
-
const bottomIndex = ((sampleSize - 1) * sampleSize + x) * 4;
|
|
150
|
-
if (pixels[bottomIndex + 3] === 0) edgeTransparentPixels++;
|
|
151
|
-
}
|
|
152
|
-
for (let y = 1; y < sampleSize - 1; y++) {
|
|
153
|
-
const leftIndex = y * sampleSize * 4;
|
|
154
|
-
if (pixels[leftIndex + 3] === 0) edgeTransparentPixels++;
|
|
155
|
-
const rightIndex = (y * sampleSize + sampleSize - 1) * 4;
|
|
156
|
-
if (pixels[rightIndex + 3] === 0) edgeTransparentPixels++;
|
|
157
|
-
}
|
|
158
|
-
return edgeTransparentPixels / edgePixels > threshold;
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
// src/components/Card/Card.tsx
|
|
162
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
163
|
-
import React2, { createContext, forwardRef, useContext } from "react";
|
|
164
|
-
import { Button, DropdownMenu, Icon, Toolbar, useTranslation } from "@dxos/react-ui";
|
|
165
|
-
import { mx as mx2 } from "@dxos/ui-theme";
|
|
166
|
-
|
|
167
|
-
// src/translations.ts
|
|
168
|
-
var translationKey = "@dxos/react-ui-mosaic";
|
|
169
|
-
var translations = [
|
|
170
|
-
{
|
|
171
|
-
"en-US": {
|
|
172
|
-
[translationKey]: {}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
];
|
|
176
|
-
|
|
177
|
-
// src/components/Card/Card.tsx
|
|
178
|
-
var CardContext = /* @__PURE__ */ createContext({});
|
|
179
|
-
var CardRoot = /* @__PURE__ */ forwardRef(({ children, classNames, className, id, asChild, role = "group", border = true, fullWidth, ...props }, forwardedRef) => {
|
|
180
|
-
const Root2 = asChild ? Slot : "div";
|
|
181
|
-
return /* @__PURE__ */ React2.createElement(Root2, {
|
|
182
|
-
...id && {
|
|
183
|
-
"data-object-id": id
|
|
184
|
-
},
|
|
185
|
-
...props,
|
|
186
|
-
role,
|
|
187
|
-
className: mx2(styles.root, border && styles.border, fullWidth && "!max-is-none", className, classNames),
|
|
188
|
-
ref: forwardedRef
|
|
189
|
-
}, children);
|
|
190
|
-
});
|
|
191
|
-
var CardToolbar = /* @__PURE__ */ forwardRef(({ children, classNames, density = "fine", ...props }, forwardedRef) => {
|
|
192
|
-
return /* @__PURE__ */ React2.createElement(Toolbar.Root, {
|
|
193
|
-
...props,
|
|
194
|
-
classNames: [
|
|
195
|
-
"density-fine bg-transparent",
|
|
196
|
-
density === "fine" ? styles.grid_3 : styles.grid_3_coarse,
|
|
197
|
-
classNames
|
|
198
|
-
],
|
|
199
|
-
ref: forwardedRef
|
|
200
|
-
}, children);
|
|
201
|
-
});
|
|
202
|
-
var CardToolbarIconButton = Toolbar.IconButton;
|
|
203
|
-
var CardToolbarSeparator = Toolbar.Separator;
|
|
204
|
-
var CardDragHandle = /* @__PURE__ */ forwardRef((_, forwardedRef) => {
|
|
205
|
-
const { t } = useTranslation(translationKey);
|
|
206
|
-
return /* @__PURE__ */ React2.createElement(Toolbar.IconButton, {
|
|
207
|
-
"data-testid": "card-drag-handle",
|
|
208
|
-
noTooltip: true,
|
|
209
|
-
iconOnly: true,
|
|
210
|
-
icon: "ph--dots-six-vertical--regular",
|
|
211
|
-
variant: "ghost",
|
|
212
|
-
label: t("drag handle label"),
|
|
213
|
-
classNames: "cursor-pointer",
|
|
214
|
-
size: 5,
|
|
215
|
-
disabled: !forwardedRef,
|
|
216
|
-
ref: forwardedRef
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
var CardClose = /* @__PURE__ */ forwardRef(({ onClick }, forwardedRef) => {
|
|
220
|
-
const { t } = useTranslation(translationKey);
|
|
221
|
-
return /* @__PURE__ */ React2.createElement(Toolbar.IconButton, {
|
|
222
|
-
iconOnly: true,
|
|
223
|
-
icon: "ph--x--regular",
|
|
224
|
-
variant: "ghost",
|
|
225
|
-
label: t("card close label"),
|
|
226
|
-
classNames: "cursor-pointer",
|
|
227
|
-
size: 5,
|
|
228
|
-
onClick,
|
|
229
|
-
ref: forwardedRef
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
var CardMenu = ({ context, items }) => {
|
|
233
|
-
const { t } = useTranslation(translationKey);
|
|
234
|
-
const { menuItems } = useContext(CardContext) ?? {};
|
|
235
|
-
const combinedItems = [
|
|
236
|
-
...items ?? [],
|
|
237
|
-
...menuItems ?? []
|
|
238
|
-
];
|
|
239
|
-
return /* @__PURE__ */ React2.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Trigger, {
|
|
240
|
-
disabled: !combinedItems.length,
|
|
241
|
-
asChild: true
|
|
242
|
-
}, /* @__PURE__ */ React2.createElement(Card.ToolbarIconButton, {
|
|
243
|
-
iconOnly: true,
|
|
244
|
-
variant: "ghost",
|
|
245
|
-
icon: "ph--dots-three-vertical--regular",
|
|
246
|
-
label: t("action menu label")
|
|
247
|
-
})), (combinedItems?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Viewport, null, combinedItems?.map(({ label, onClick: onSelect }, i) => /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
248
|
-
key: i,
|
|
249
|
-
onSelect: () => onSelect(context)
|
|
250
|
-
}, label))), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null))));
|
|
251
|
-
};
|
|
252
|
-
var CardTitle = /* @__PURE__ */ forwardRef(({ children, classNames, className, asChild, role = "heading", ...props }, forwardedRef) => {
|
|
253
|
-
const Root2 = asChild ? Slot : "div";
|
|
254
|
-
return /* @__PURE__ */ React2.createElement(Root2, {
|
|
255
|
-
...props,
|
|
256
|
-
role,
|
|
257
|
-
className: mx2("grow truncate", classNames, className),
|
|
258
|
-
ref: forwardedRef
|
|
259
|
-
}, children);
|
|
260
|
-
});
|
|
261
|
-
var CardContent = /* @__PURE__ */ forwardRef(({ children, ...props }, forwardedRef) => {
|
|
262
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
263
|
-
role: "none",
|
|
264
|
-
className: "contents [&>:last-child]:pbe-1",
|
|
265
|
-
...props,
|
|
266
|
-
ref: forwardedRef
|
|
267
|
-
}, children);
|
|
268
|
-
});
|
|
269
|
-
var CardRow = /* @__PURE__ */ forwardRef(({ children, classNames, className, role = "none", icon, ...props }, forwardedRef) => {
|
|
270
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
271
|
-
...props,
|
|
272
|
-
role,
|
|
273
|
-
className: mx2(styles.grid_2, "pli-1", classNames, className),
|
|
274
|
-
ref: forwardedRef
|
|
275
|
-
}, icon && /* @__PURE__ */ React2.createElement(CardIcon, {
|
|
276
|
-
classNames: "text-subdued",
|
|
277
|
-
icon
|
|
278
|
-
}) || /* @__PURE__ */ React2.createElement("div", null), children);
|
|
279
|
-
});
|
|
280
|
-
var CardHeading = /* @__PURE__ */ forwardRef(({ children, classNames, className, asChild, role = "heading", variant = "default", ...props }, forwardedRef) => {
|
|
281
|
-
const Root2 = asChild ? Slot : "div";
|
|
282
|
-
const variantClassNames = {
|
|
283
|
-
default: "plb-1",
|
|
284
|
-
subtitle: "plb-2 text-xs text-description font-medium uppercase"
|
|
285
|
-
};
|
|
286
|
-
return /* @__PURE__ */ React2.createElement(Root2, {
|
|
287
|
-
...props,
|
|
288
|
-
role,
|
|
289
|
-
className: mx2(variantClassNames[variant], classNames, className),
|
|
290
|
-
ref: forwardedRef
|
|
291
|
-
}, children);
|
|
292
|
-
});
|
|
293
|
-
var CardText = /* @__PURE__ */ forwardRef(({ children, classNames, className, asChild, role = "none", truncate, variant = "default", ...props }, forwardedRef) => {
|
|
294
|
-
const Root2 = asChild ? Slot : "div";
|
|
295
|
-
const variantClassNames = {
|
|
296
|
-
default: {
|
|
297
|
-
root: "plb-1"
|
|
298
|
-
},
|
|
299
|
-
description: {
|
|
300
|
-
root: "plb-1.5",
|
|
301
|
-
span: "text-sm text-description line-clamp-3"
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
return /* @__PURE__ */ React2.createElement(Root2, {
|
|
305
|
-
...props,
|
|
306
|
-
role,
|
|
307
|
-
className: mx2("flex overflow-hidden", variantClassNames[variant].root, classNames, className),
|
|
308
|
-
ref: forwardedRef
|
|
309
|
-
}, /* @__PURE__ */ React2.createElement("span", {
|
|
310
|
-
className: mx2(variantClassNames[variant].span, truncate && "truncate")
|
|
311
|
-
}, children));
|
|
312
|
-
});
|
|
313
|
-
var CardPoster = (props) => {
|
|
314
|
-
const aspect = props.aspect === "auto" ? "aspect-auto" : "aspect-video";
|
|
315
|
-
if (props.image) {
|
|
316
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
317
|
-
role: "none",
|
|
318
|
-
className: "mbe-1"
|
|
319
|
-
}, /* @__PURE__ */ React2.createElement(Image, {
|
|
320
|
-
classNames: [
|
|
321
|
-
styles.poster,
|
|
322
|
-
aspect,
|
|
323
|
-
props.classNames
|
|
324
|
-
],
|
|
325
|
-
src: props.image,
|
|
326
|
-
alt: props.alt
|
|
327
|
-
}));
|
|
328
|
-
}
|
|
329
|
-
if (props.icon) {
|
|
330
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
331
|
-
role: "image",
|
|
332
|
-
className: mx2("grid place-items-center bg-inputSurface text-subdued", styles.poster, aspect, props.classNames),
|
|
333
|
-
"aria-label": props.alt
|
|
334
|
-
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
335
|
-
icon: props.icon,
|
|
336
|
-
size: 10
|
|
337
|
-
}));
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
var CardAction = ({ icon, actionIcon = "ph--arrow-right--regular", label, onClick }) => {
|
|
341
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
342
|
-
role: "none",
|
|
343
|
-
className: "is-full pli-1"
|
|
344
|
-
}, /* @__PURE__ */ React2.createElement(Button, {
|
|
345
|
-
variant: "ghost",
|
|
346
|
-
classNames: mx2(styles.grid_3, "!p-0 is-full text-start overflow-hidden"),
|
|
347
|
-
onClick
|
|
348
|
-
}, icon ? /* @__PURE__ */ React2.createElement(CardIcon, {
|
|
349
|
-
classNames: "text-subdued",
|
|
350
|
-
icon
|
|
351
|
-
}) : /* @__PURE__ */ React2.createElement("div", null), /* @__PURE__ */ React2.createElement("span", {
|
|
352
|
-
className: mx2("min-is-0 flex-1 truncate", !actionIcon && "col-span-2")
|
|
353
|
-
}, label), actionIcon && /* @__PURE__ */ React2.createElement(CardIcon, {
|
|
354
|
-
icon: actionIcon
|
|
355
|
-
})));
|
|
356
|
-
};
|
|
357
|
-
var CardLink = ({ label, href }) => {
|
|
358
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
359
|
-
role: "none",
|
|
360
|
-
className: "is-full pli-1"
|
|
361
|
-
}, /* @__PURE__ */ React2.createElement("a", {
|
|
362
|
-
className: mx2(styles.grid_3, "group !p-0 dx-button dx-focus-ring !min-bs-1"),
|
|
363
|
-
"data-variant": "ghost",
|
|
364
|
-
href,
|
|
365
|
-
target: "_blank",
|
|
366
|
-
rel: "noreferrer"
|
|
367
|
-
}, /* @__PURE__ */ React2.createElement(CardIcon, {
|
|
368
|
-
classNames: "text-subdued",
|
|
369
|
-
icon: "ph--link--regular"
|
|
370
|
-
}), /* @__PURE__ */ React2.createElement("span", {
|
|
371
|
-
className: mx2("min-is-0 flex-1 truncate")
|
|
372
|
-
}, label), /* @__PURE__ */ React2.createElement(CardIcon, {
|
|
373
|
-
classNames: "invisible group-hover:visible",
|
|
374
|
-
icon: "ph--arrow-square-out--regular"
|
|
375
|
-
})));
|
|
376
|
-
};
|
|
377
|
-
var CardIconBlock = ({ classNames, children, role = "none", ...props }) => {
|
|
378
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
379
|
-
...props,
|
|
380
|
-
role,
|
|
381
|
-
className: mx2("grid bs-[var(--rail-item)] is-[var(--rail-item)] place-items-center", classNames)
|
|
382
|
-
}, children);
|
|
383
|
-
};
|
|
384
|
-
var CardIcon = ({ toolbar, ...props }) => {
|
|
385
|
-
return /* @__PURE__ */ React2.createElement(CardIconBlock, null, /* @__PURE__ */ React2.createElement(Icon, {
|
|
386
|
-
...props,
|
|
387
|
-
size: toolbar ? 5 : 4
|
|
388
|
-
}));
|
|
389
|
-
};
|
|
390
|
-
var Card = {
|
|
391
|
-
Context: CardContext,
|
|
392
|
-
Root: CardRoot,
|
|
393
|
-
// Toolbar
|
|
394
|
-
Toolbar: CardToolbar,
|
|
395
|
-
ToolbarIconButton: CardToolbarIconButton,
|
|
396
|
-
ToolbarSeparator: CardToolbarSeparator,
|
|
397
|
-
DragHandle: CardDragHandle,
|
|
398
|
-
Title: CardTitle,
|
|
399
|
-
Close: CardClose,
|
|
400
|
-
Menu: CardMenu,
|
|
401
|
-
Icon: CardIcon,
|
|
402
|
-
IconBlock: CardIconBlock,
|
|
403
|
-
// Content
|
|
404
|
-
Content: CardContent,
|
|
405
|
-
Row: CardRow,
|
|
406
|
-
Heading: CardHeading,
|
|
407
|
-
Text: CardText,
|
|
408
|
-
Poster: CardPoster,
|
|
409
|
-
Action: CardAction,
|
|
410
|
-
Link: CardLink
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
// src/components/Focus/styles.ts
|
|
414
|
-
var styles2 = {
|
|
415
|
-
container: {
|
|
416
|
-
// TODO(burdon): Handle selection (aria-current?)
|
|
417
|
-
// TODO(burdon): Use ring instead of border?
|
|
418
|
-
root: [
|
|
419
|
-
"outline-none border border-separator rounded-sm",
|
|
420
|
-
// Focus (e.g., via tabster).
|
|
421
|
-
// TODO(burdon): Why is ! required?
|
|
422
|
-
"focus:!border-accentSurface",
|
|
423
|
-
// Active (e.g., drop target).
|
|
424
|
-
"data-[focus-state=active]:border-neutralFocusIndicator",
|
|
425
|
-
// Error
|
|
426
|
-
// TODO(burdon): Error token.
|
|
427
|
-
"data-[focus-state=error]:border-rose-500"
|
|
428
|
-
]
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
// src/components/Focus/Focus.tsx
|
|
433
|
-
import { useArrowNavigationGroup, useFocusableGroup, useMergedTabsterAttributes_unstable } from "@fluentui/react-tabster";
|
|
434
|
-
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
435
|
-
import { Primitive } from "@radix-ui/react-primitive";
|
|
436
|
-
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
437
|
-
import React3, { createContext as createContext2, forwardRef as forwardRef2, useContext as useContext2, useRef as useRef2, useState as useState2 } from "react";
|
|
438
|
-
import { mx as mx3 } from "@dxos/ui-theme";
|
|
439
|
-
var FOCUS_STATE_ATTR = "focus-state";
|
|
440
|
-
var FocusContext = /* @__PURE__ */ createContext2({});
|
|
441
|
-
var useFocus = () => useContext2(FocusContext);
|
|
442
|
-
var Group = /* @__PURE__ */ forwardRef2(({ classNames, className, children, asChild, axis = "vertical", ...props }, forwardedRef) => {
|
|
443
|
-
const rootRef = useRef2(null);
|
|
444
|
-
const composedRef = useComposedRefs(rootRef, forwardedRef);
|
|
445
|
-
const Root2 = asChild ? Slot2 : Primitive.div;
|
|
446
|
-
const focusableGroupAttrs = useFocusableGroup({
|
|
447
|
-
tabBehavior: "limited-trap-focus"
|
|
448
|
-
});
|
|
449
|
-
const arrowNavigationAttrs = useArrowNavigationGroup({
|
|
450
|
-
axis,
|
|
451
|
-
memorizeCurrent: true
|
|
452
|
-
});
|
|
453
|
-
const tabsterAttrs = useMergedTabsterAttributes_unstable(focusableGroupAttrs, arrowNavigationAttrs);
|
|
454
|
-
const [state, setState] = useState2();
|
|
455
|
-
return /* @__PURE__ */ React3.createElement(FocusContext.Provider, {
|
|
456
|
-
value: {
|
|
457
|
-
setFocus: setState
|
|
458
|
-
}
|
|
459
|
-
}, /* @__PURE__ */ React3.createElement(Root2, {
|
|
460
|
-
tabIndex: 0,
|
|
461
|
-
className: mx3(styles2.container.root, className, classNames),
|
|
462
|
-
...tabsterAttrs,
|
|
463
|
-
...state && {
|
|
464
|
-
[`data-${FOCUS_STATE_ATTR}`]: state
|
|
465
|
-
},
|
|
466
|
-
...props,
|
|
467
|
-
ref: composedRef
|
|
468
|
-
}, children));
|
|
469
|
-
});
|
|
470
|
-
var Focus = {
|
|
471
|
-
Group
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
// src/components/Mosaic/styles.ts
|
|
475
|
-
var styles3 = {
|
|
476
|
-
placeholder: {
|
|
477
|
-
root: [
|
|
478
|
-
"group opacity-0",
|
|
479
|
-
'group-data-[mosaic-debug="true"]:opacity-100',
|
|
480
|
-
'group-data-[mosaic-debug="true"]:bg-orange-500',
|
|
481
|
-
"data-[mosaic-placeholder-state=active]:opacity-100",
|
|
482
|
-
"data-[mosaic-placeholder-axis=vertical]:plb-1",
|
|
483
|
-
"data-[mosaic-placeholder-axis=vertical]:data-[mosaic-placeholder-state=active]:plb-2.5",
|
|
484
|
-
"data-[mosaic-placeholder-axis=horizontal]:pli-1",
|
|
485
|
-
"data-[mosaic-placeholder-axis=horizontal]:data-[mosaic-placeholder-state=active]:pli-2.5"
|
|
486
|
-
],
|
|
487
|
-
content: [
|
|
488
|
-
"transition-all duration-0",
|
|
489
|
-
// TODO(burdon): Don't animate open if placeholder is the source.
|
|
490
|
-
// TODO(burdon): Flickers when start to drag since source is removed and then the placeholder shows up.
|
|
491
|
-
// - Use absolute positioning?
|
|
492
|
-
// 'group-data-[mosaic-placeholder-state=active]:duration-200',
|
|
493
|
-
"group-data-[mosaic-placeholder-axis=vertical]:bs-0",
|
|
494
|
-
"group-data-[mosaic-placeholder-axis=horizontal]:is-0",
|
|
495
|
-
"group-data-[mosaic-placeholder-axis=vertical]:group-data-[mosaic-placeholder-state=active]:bs-[var(--mosaic-placeholder-height)]",
|
|
496
|
-
"group-data-[mosaic-placeholder-axis=horizontal]:group-data-[mosaic-placeholder-state=active]:is-[var(--mosaic-placeholder-width)]"
|
|
497
|
-
]
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
// src/components/Mosaic/extension.ts
|
|
502
|
-
import { StateEffect, StateField } from "@codemirror/state";
|
|
503
|
-
import { Decoration, EditorView, ViewPlugin, WidgetType } from "@codemirror/view";
|
|
504
|
-
var dropHandler = ({ onDrop = handleDrop } = {}) => {
|
|
505
|
-
const views = /* @__PURE__ */ new Set();
|
|
506
|
-
let state = null;
|
|
507
|
-
const reset = () => {
|
|
508
|
-
views.forEach((view) => view.dispatch({
|
|
509
|
-
effects: setDrop.of(null)
|
|
510
|
-
}));
|
|
511
|
-
state = null;
|
|
512
|
-
};
|
|
513
|
-
const extension = [
|
|
514
|
-
dropField,
|
|
515
|
-
ViewPlugin.fromClass(class {
|
|
516
|
-
_view;
|
|
517
|
-
constructor(_view) {
|
|
518
|
-
this._view = _view;
|
|
519
|
-
views.add(_view);
|
|
520
|
-
}
|
|
521
|
-
destroy() {
|
|
522
|
-
views.delete(this._view);
|
|
523
|
-
}
|
|
524
|
-
})
|
|
525
|
-
];
|
|
526
|
-
return {
|
|
527
|
-
extension,
|
|
528
|
-
update: (position) => {
|
|
529
|
-
if (!position) {
|
|
530
|
-
reset();
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
views.forEach((view) => {
|
|
534
|
-
const rect = view.dom.getBoundingClientRect();
|
|
535
|
-
if (position.x >= rect.left && position.x <= rect.right && position.y >= rect.top && position.y <= rect.bottom) {
|
|
536
|
-
let pos = view.posAtCoords(position);
|
|
537
|
-
if (pos !== null) {
|
|
538
|
-
const word = view.state.wordAt(pos);
|
|
539
|
-
if (word) {
|
|
540
|
-
const startDist = Math.abs(pos - word.from);
|
|
541
|
-
const endDist = Math.abs(pos - word.to);
|
|
542
|
-
pos = startDist < endDist ? word.from : word.to;
|
|
543
|
-
}
|
|
544
|
-
view.dispatch({
|
|
545
|
-
effects: setDrop.of(pos)
|
|
546
|
-
});
|
|
547
|
-
state = {
|
|
548
|
-
view,
|
|
549
|
-
pos
|
|
550
|
-
};
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
view.dispatch({
|
|
555
|
-
effects: setDrop.of(null)
|
|
556
|
-
});
|
|
557
|
-
});
|
|
558
|
-
},
|
|
559
|
-
cancel: () => {
|
|
560
|
-
reset();
|
|
561
|
-
},
|
|
562
|
-
drop: ({ text, url }) => {
|
|
563
|
-
if (state) {
|
|
564
|
-
onDrop(state.view, state.pos, {
|
|
565
|
-
text,
|
|
566
|
-
url
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
reset();
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
};
|
|
573
|
-
var handleDrop = (view, pos, event) => {
|
|
574
|
-
const line = view.state.doc.lineAt(pos);
|
|
575
|
-
if (line.text.trim() === "") {
|
|
576
|
-
view.dispatch({
|
|
577
|
-
changes: {
|
|
578
|
-
from: pos,
|
|
579
|
-
insert: `
|
|
580
|
-

|
|
581
|
-
`
|
|
582
|
-
},
|
|
583
|
-
effects: setDrop.of(null)
|
|
584
|
-
});
|
|
585
|
-
} else {
|
|
586
|
-
view.dispatch({
|
|
587
|
-
changes: {
|
|
588
|
-
from: pos,
|
|
589
|
-
insert: ` [${event.text}](${event.url})`
|
|
590
|
-
},
|
|
591
|
-
effects: setDrop.of(null)
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
var setDrop = StateEffect.define();
|
|
596
|
-
var dropField = StateField.define({
|
|
597
|
-
create: () => Decoration.none,
|
|
598
|
-
update: (decorations, tr) => {
|
|
599
|
-
for (const effect of tr.effects) {
|
|
600
|
-
if (effect.is(setDrop)) {
|
|
601
|
-
if (effect.value === null) {
|
|
602
|
-
return Decoration.none;
|
|
603
|
-
}
|
|
604
|
-
return Decoration.set([
|
|
605
|
-
Decoration.widget({
|
|
606
|
-
widget: new class extends WidgetType {
|
|
607
|
-
toDOM() {
|
|
608
|
-
const dom = document.createElement("span");
|
|
609
|
-
dom.className = "cm-drop-cursor";
|
|
610
|
-
dom.style.borderLeft = "2px solid var(--dx-accentSurface)";
|
|
611
|
-
dom.style.display = "inline-block";
|
|
612
|
-
dom.style.height = "1em";
|
|
613
|
-
dom.style.verticalAlign = "middle";
|
|
614
|
-
return dom;
|
|
615
|
-
}
|
|
616
|
-
}(),
|
|
617
|
-
side: 0
|
|
618
|
-
}).range(effect.value)
|
|
619
|
-
]);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
return decorations.map(tr.changes);
|
|
623
|
-
},
|
|
624
|
-
provide: (field) => EditorView.decorations.from(field)
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
// src/hooks/useContainerDebug.tsx
|
|
628
|
-
import React7, { forwardRef as forwardRef6, useMemo as useMemo5, useRef as useRef5 } from "react";
|
|
629
|
-
import { createPortal as createPortal2 } from "react-dom";
|
|
630
|
-
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
631
|
-
import { mx as mx7 } from "@dxos/ui-theme";
|
|
632
|
-
|
|
633
|
-
// src/components/Mosaic/Mosaic.tsx
|
|
634
|
-
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
635
|
-
import { draggable, dropTargetForElements, monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
636
|
-
import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
|
|
637
|
-
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
638
|
-
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
|
639
|
-
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
640
|
-
import { DropIndicator as NativeDropIndicator } from "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box";
|
|
641
|
-
import { composeRefs, useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
|
|
642
|
-
import { createContext as createContext3 } from "@radix-ui/react-context";
|
|
643
|
-
import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
|
|
644
|
-
import { Slot as Slot3 } from "@radix-ui/react-slot";
|
|
645
|
-
import { bind } from "bind-event-listener";
|
|
646
|
-
import React6, { forwardRef as forwardRef5, useCallback as useCallback2, useEffect as useEffect2, useLayoutEffect, useMemo as useMemo4, useRef as useRef4, useState as useState3 } from "react";
|
|
647
|
-
import { createPortal } from "react-dom";
|
|
648
|
-
import { log as log2 } from "@dxos/log";
|
|
649
|
-
import { mx as mx6 } from "@dxos/ui-theme";
|
|
650
|
-
import { isTruthy } from "@dxos/util";
|
|
651
|
-
|
|
652
|
-
// src/components/Scrollable/Scrollable.tsx
|
|
653
|
-
import { OverlayScrollbarsComponent } from "overlayscrollbars-react";
|
|
654
|
-
import React4, { forwardRef as forwardRef3, useEffect, useImperativeHandle, useMemo, useRef as useRef3 } from "react";
|
|
655
|
-
import { mx as mx4 } from "@dxos/ui-theme";
|
|
656
|
-
import "overlayscrollbars/styles/overlayscrollbars.css";
|
|
657
|
-
var defaultOptions = {
|
|
658
|
-
scrollbars: {
|
|
659
|
-
autoHide: "leave",
|
|
660
|
-
autoHideDelay: 1e3,
|
|
661
|
-
autoHideSuspend: true
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
var Scrollable = /* @__PURE__ */ forwardRef3(({ classNames, axis = "vertical", padding, options: optionsProp = defaultOptions, onScroll, viewportRef, ...props }, forwardedRef) => {
|
|
665
|
-
const osRef = useRef3(null);
|
|
666
|
-
const options = useMemo(() => {
|
|
667
|
-
const options2 = {
|
|
668
|
-
...optionsProp
|
|
669
|
-
};
|
|
670
|
-
if (axis) {
|
|
671
|
-
options2.overflow = {
|
|
672
|
-
x: axis === "horizontal" ? "scroll" : "hidden",
|
|
673
|
-
y: axis === "vertical" ? "scroll" : "hidden"
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
return options2;
|
|
677
|
-
}, [
|
|
678
|
-
axis,
|
|
679
|
-
optionsProp
|
|
680
|
-
]);
|
|
681
|
-
useImperativeHandle(forwardedRef, () => osRef.current?.getElement(), [
|
|
682
|
-
osRef
|
|
683
|
-
]);
|
|
684
|
-
useEffect(() => {
|
|
685
|
-
const instance = osRef.current?.osInstance();
|
|
686
|
-
if (viewportRef) {
|
|
687
|
-
viewportRef(instance?.elements().viewport ?? null);
|
|
688
|
-
}
|
|
689
|
-
}, [
|
|
690
|
-
osRef,
|
|
691
|
-
viewportRef
|
|
692
|
-
]);
|
|
693
|
-
const events = useMemo(() => {
|
|
694
|
-
if (!onScroll) {
|
|
695
|
-
return null;
|
|
696
|
-
}
|
|
697
|
-
return {
|
|
698
|
-
scroll: (_, event) => {
|
|
699
|
-
onScroll(event);
|
|
700
|
-
}
|
|
701
|
-
};
|
|
702
|
-
}, [
|
|
703
|
-
onScroll
|
|
704
|
-
]);
|
|
705
|
-
return /* @__PURE__ */ React4.createElement(OverlayScrollbarsComponent, {
|
|
706
|
-
...props,
|
|
707
|
-
className: mx4(padding && (axis === "vertical" ? "pli-3" : "pbe-3"), classNames),
|
|
708
|
-
options,
|
|
709
|
-
events,
|
|
710
|
-
ref: osRef
|
|
711
|
-
});
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
// src/components/Stack/Stack.tsx
|
|
715
|
-
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
716
|
-
import React5, { Fragment, forwardRef as forwardRef4 } from "react";
|
|
717
|
-
import { invariant } from "@dxos/invariant";
|
|
718
|
-
import { mx as mx5 } from "@dxos/ui-theme";
|
|
719
|
-
|
|
720
|
-
// src/hooks/useEventHandlerAdapter.ts
|
|
721
|
-
import { useMemo as useMemo2 } from "react";
|
|
722
|
-
import { log } from "@dxos/log";
|
|
723
|
-
import { arrayMove } from "@dxos/util";
|
|
724
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/hooks/useEventHandlerAdapter.ts";
|
|
725
|
-
var useEventHandlerAdapter = ({ items, getId, get, make, onChange, ...props }) => {
|
|
726
|
-
return useMemo2(() => ({
|
|
727
|
-
...props,
|
|
728
|
-
onTake: ({ source }, cb) => {
|
|
729
|
-
log.info("onTake", {
|
|
730
|
-
source
|
|
731
|
-
}, {
|
|
732
|
-
F: __dxlog_file,
|
|
733
|
-
L: 58,
|
|
734
|
-
S: void 0,
|
|
735
|
-
C: (f, a) => f(...a)
|
|
736
|
-
});
|
|
737
|
-
const mutate = (items2) => {
|
|
738
|
-
const from = items2.findIndex((item) => getId(item) === source.id);
|
|
739
|
-
if (from !== -1) {
|
|
740
|
-
items2.splice(from, 1);
|
|
741
|
-
}
|
|
742
|
-
};
|
|
743
|
-
if (onChange) {
|
|
744
|
-
onChange(mutate);
|
|
745
|
-
} else {
|
|
746
|
-
mutate(items);
|
|
747
|
-
}
|
|
748
|
-
void cb(source.data);
|
|
749
|
-
},
|
|
750
|
-
onDrop: ({ source, target }) => {
|
|
751
|
-
const to = target?.type === "tile" || target?.type === "placeholder" ? target.location : -1;
|
|
752
|
-
log.info("onDrop", {
|
|
753
|
-
source,
|
|
754
|
-
target,
|
|
755
|
-
to
|
|
756
|
-
}, {
|
|
757
|
-
F: __dxlog_file,
|
|
758
|
-
L: 76,
|
|
759
|
-
S: void 0,
|
|
760
|
-
C: (f, a) => f(...a)
|
|
761
|
-
});
|
|
762
|
-
const mutate = (items2) => {
|
|
763
|
-
const from = items2.findIndex((item) => getId(item) === source.id);
|
|
764
|
-
if (to !== -1) {
|
|
765
|
-
if (from !== -1) {
|
|
766
|
-
arrayMove(items2, from, to);
|
|
767
|
-
} else {
|
|
768
|
-
items2.splice(to, 0, make(get(source.data)));
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
};
|
|
772
|
-
if (onChange) {
|
|
773
|
-
onChange(mutate);
|
|
774
|
-
} else {
|
|
775
|
-
mutate(items);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
}), [
|
|
779
|
-
items,
|
|
780
|
-
onChange
|
|
781
|
-
]);
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
// src/hooks/useVisibleItems.ts
|
|
785
|
-
import { useMemo as useMemo3 } from "react";
|
|
786
|
-
var useVisibleItems = ({ id, items, dragging, getId }) => {
|
|
787
|
-
const visibleItems = useMemo3(() => {
|
|
788
|
-
if (!items || !dragging || id !== dragging.containerId) {
|
|
789
|
-
return items ?? [];
|
|
790
|
-
}
|
|
791
|
-
const idx = items.findIndex((item) => getId(item) === dragging.id);
|
|
792
|
-
if (idx === -1) {
|
|
793
|
-
return items;
|
|
794
|
-
}
|
|
795
|
-
const visibleItems2 = items.slice();
|
|
796
|
-
visibleItems2.splice(idx, 1);
|
|
797
|
-
return visibleItems2;
|
|
798
|
-
}, [
|
|
799
|
-
id,
|
|
800
|
-
items,
|
|
801
|
-
dragging,
|
|
802
|
-
getId
|
|
803
|
-
]);
|
|
804
|
-
return visibleItems;
|
|
805
|
-
};
|
|
806
|
-
|
|
807
|
-
// src/components/Stack/Stack.tsx
|
|
808
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Stack/Stack.tsx";
|
|
809
|
-
var StackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, role = "list", axis = "vertical", draggable: draggable2 = true, items, getId, Tile: Tile2, debug, ...props }, forwardedRef) => {
|
|
810
|
-
invariant(Tile2, void 0, {
|
|
811
|
-
F: __dxlog_file2,
|
|
812
|
-
L: 44,
|
|
813
|
-
S: void 0,
|
|
814
|
-
A: [
|
|
815
|
-
"Tile",
|
|
816
|
-
""
|
|
817
|
-
]
|
|
818
|
-
});
|
|
819
|
-
const { id, dragging } = useContainerContext(StackInner.displayName);
|
|
820
|
-
const visibleItems = useVisibleItems({
|
|
821
|
-
id,
|
|
822
|
-
items,
|
|
823
|
-
dragging: dragging?.source.data,
|
|
824
|
-
getId
|
|
825
|
-
});
|
|
826
|
-
return /* @__PURE__ */ React5.createElement("div", {
|
|
827
|
-
...props,
|
|
828
|
-
role,
|
|
829
|
-
className: mx5("flex", axis === "horizontal" && "bs-full [&>*]:shrink-0", axis === "vertical" && "flex-col", classNames, className),
|
|
830
|
-
ref: forwardedRef
|
|
831
|
-
}, /* @__PURE__ */ React5.createElement(Placeholder, {
|
|
832
|
-
axis,
|
|
833
|
-
location: 0.5
|
|
834
|
-
}), visibleItems?.map((item, index) => /* @__PURE__ */ React5.createElement(Fragment, {
|
|
835
|
-
key: getId(item)
|
|
836
|
-
}, /* @__PURE__ */ React5.createElement(Tile2, {
|
|
837
|
-
id: getId(item),
|
|
838
|
-
data: item,
|
|
839
|
-
location: index + 1,
|
|
840
|
-
draggable: draggable2,
|
|
841
|
-
debug
|
|
842
|
-
}), /* @__PURE__ */ React5.createElement(Placeholder, {
|
|
843
|
-
axis,
|
|
844
|
-
location: index + 1.5
|
|
845
|
-
}))));
|
|
846
|
-
});
|
|
847
|
-
StackInner.displayName = "Stack";
|
|
848
|
-
var Stack = StackInner;
|
|
849
|
-
var VirtualStackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, role = "list", axis = "vertical", items, getId, Tile: Tile2, estimateSize, getScrollElement, overscan = 8, onChange, debug, ...props }, forwardedRef) => {
|
|
850
|
-
invariant(Tile2, void 0, {
|
|
851
|
-
F: __dxlog_file2,
|
|
852
|
-
L: 106,
|
|
853
|
-
S: void 0,
|
|
854
|
-
A: [
|
|
855
|
-
"Tile",
|
|
856
|
-
""
|
|
857
|
-
]
|
|
858
|
-
});
|
|
859
|
-
const { id, dragging } = useContainerContext(VirtualStackInner.displayName);
|
|
860
|
-
const visibleItems = useVisibleItems({
|
|
861
|
-
id,
|
|
862
|
-
items,
|
|
863
|
-
dragging: dragging?.source.data,
|
|
864
|
-
getId
|
|
865
|
-
});
|
|
866
|
-
const virtualizer = useVirtualizer({
|
|
867
|
-
count: visibleItems.length * 2 + 1,
|
|
868
|
-
estimateSize,
|
|
869
|
-
getScrollElement,
|
|
870
|
-
overscan,
|
|
871
|
-
onChange
|
|
872
|
-
});
|
|
873
|
-
const virtualItems = virtualizer.getVirtualItems();
|
|
874
|
-
return /* @__PURE__ */ React5.createElement("div", {
|
|
875
|
-
...props,
|
|
876
|
-
role,
|
|
877
|
-
className: mx5("flex", axis === "horizontal" && "bs-full [&>*]:shrink-0", axis === "vertical" && "flex-col", classNames, className),
|
|
878
|
-
style: {
|
|
879
|
-
position: "relative",
|
|
880
|
-
...axis === "vertical" ? {
|
|
881
|
-
width: "100%",
|
|
882
|
-
height: virtualizer.getTotalSize()
|
|
883
|
-
} : {
|
|
884
|
-
width: virtualizer.getTotalSize(),
|
|
885
|
-
height: "100%"
|
|
886
|
-
}
|
|
887
|
-
},
|
|
888
|
-
ref: forwardedRef
|
|
889
|
-
}, virtualItems.map((virtualItem) => {
|
|
890
|
-
const data = visibleItems[Math.floor(virtualItem.index / 2)];
|
|
891
|
-
return /* @__PURE__ */ React5.createElement("div", {
|
|
892
|
-
key: virtualItem.key,
|
|
893
|
-
"data-index": virtualItem.index,
|
|
894
|
-
style: {
|
|
895
|
-
position: "absolute",
|
|
896
|
-
top: 0,
|
|
897
|
-
left: 0,
|
|
898
|
-
...axis === "vertical" ? {
|
|
899
|
-
width: "100%",
|
|
900
|
-
transform: `translateY(${virtualItem.start}px)`
|
|
901
|
-
} : {
|
|
902
|
-
height: "100%",
|
|
903
|
-
transform: `translateX(${virtualItem.start}px)`
|
|
904
|
-
}
|
|
905
|
-
},
|
|
906
|
-
ref: virtualizer.measureElement
|
|
907
|
-
}, virtualItem.index % 2 === 0 ? /* @__PURE__ */ React5.createElement(Placeholder, {
|
|
908
|
-
axis,
|
|
909
|
-
location: Math.floor(virtualItem.index / 2) + 0.5
|
|
910
|
-
}) : /* @__PURE__ */ React5.createElement(Tile2, {
|
|
911
|
-
id: getId(data),
|
|
912
|
-
data,
|
|
913
|
-
location: Math.floor(virtualItem.index / 2) + 1,
|
|
914
|
-
debug
|
|
915
|
-
}));
|
|
916
|
-
}));
|
|
917
|
-
});
|
|
918
|
-
VirtualStackInner.displayName = "VirtualStackInner";
|
|
919
|
-
var VirtualStack = VirtualStackInner;
|
|
920
|
-
var Placeholder = (props) => {
|
|
921
|
-
return /* @__PURE__ */ React5.createElement(Mosaic.Placeholder, {
|
|
922
|
-
...props,
|
|
923
|
-
classNames: styles3.placeholder.root
|
|
924
|
-
}, /* @__PURE__ */ React5.createElement("div", {
|
|
925
|
-
className: mx5("flex bs-full bg-baseSurface border border-dashed border-separator rounded-sm", styles3.placeholder.content)
|
|
926
|
-
}));
|
|
927
|
-
};
|
|
928
|
-
Placeholder.displayName = "Placeholder";
|
|
929
|
-
|
|
930
|
-
// src/components/Mosaic/Mosaic.tsx
|
|
931
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Mosaic.tsx";
|
|
932
|
-
var getSourceData = (source) => {
|
|
933
|
-
return source.data.type === "tile" ? source.data : null;
|
|
934
|
-
};
|
|
935
|
-
var [RootContextProvider, useRootContext] = createContext3("MosaicRoot");
|
|
936
|
-
var ROOT_DEBUG_ATTR = "mosaic-debug";
|
|
937
|
-
var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }, forwardedRef) => {
|
|
938
|
-
const rootRef = useRef4(null);
|
|
939
|
-
const composedRef = useComposedRefs2(rootRef, forwardedRef);
|
|
940
|
-
const Root2 = asChild ? Slot3 : Primitive2.div;
|
|
941
|
-
const [handlers, setHandlers] = useState3({});
|
|
942
|
-
const [dragging, setDragging] = useState3();
|
|
943
|
-
const getSourceHandler = useCallback2((source) => {
|
|
944
|
-
const data = source.data;
|
|
945
|
-
return {
|
|
946
|
-
data,
|
|
947
|
-
handler: handlers[data.containerId]
|
|
948
|
-
};
|
|
949
|
-
}, [
|
|
950
|
-
handlers
|
|
951
|
-
]);
|
|
952
|
-
const getTargetHandler = useCallback2((location) => {
|
|
953
|
-
for (const target of location.current.dropTargets) {
|
|
954
|
-
const data = target.data;
|
|
955
|
-
let containerId;
|
|
956
|
-
switch (data.type) {
|
|
957
|
-
case "tile":
|
|
958
|
-
case "placeholder":
|
|
959
|
-
containerId = data.containerId;
|
|
960
|
-
break;
|
|
961
|
-
case "container":
|
|
962
|
-
containerId = data.id;
|
|
963
|
-
break;
|
|
964
|
-
}
|
|
965
|
-
const handler = handlers[containerId];
|
|
966
|
-
if (handler) {
|
|
967
|
-
return {
|
|
968
|
-
data,
|
|
969
|
-
handler
|
|
970
|
-
};
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
return {};
|
|
974
|
-
}, [
|
|
975
|
-
handlers
|
|
976
|
-
]);
|
|
977
|
-
useEffect2(() => {
|
|
978
|
-
const handleChange = ({ source, location }) => {
|
|
979
|
-
const { data: sourceData } = getSourceHandler(source);
|
|
980
|
-
const { data: targetData, handler } = getTargetHandler(location);
|
|
981
|
-
setDragging((dragging2) => {
|
|
982
|
-
dragging2?.target?.handler?.onCancel?.();
|
|
983
|
-
return {
|
|
984
|
-
source: {
|
|
985
|
-
data: sourceData,
|
|
986
|
-
handler: handlers[sourceData.containerId],
|
|
987
|
-
// TOOD(burdon): Check id matches.
|
|
988
|
-
container: location.initial.dropTargets.find((target) => target.data.type === "container")?.element
|
|
989
|
-
},
|
|
990
|
-
target: targetData && {
|
|
991
|
-
data: targetData,
|
|
992
|
-
handler
|
|
993
|
-
}
|
|
994
|
-
};
|
|
995
|
-
});
|
|
996
|
-
};
|
|
997
|
-
const handleCancel = () => {
|
|
998
|
-
setDragging((dragging2) => {
|
|
999
|
-
requestAnimationFrame(() => {
|
|
1000
|
-
dragging2?.target?.handler?.onCancel?.();
|
|
1001
|
-
dragging2?.source?.container?.dispatchEvent(new CustomEvent("dnd:cancel", {
|
|
1002
|
-
bubbles: true
|
|
1003
|
-
}));
|
|
1004
|
-
});
|
|
1005
|
-
return void 0;
|
|
1006
|
-
});
|
|
1007
|
-
};
|
|
1008
|
-
let noTargetTimeout;
|
|
1009
|
-
return combine(monitorForElements({
|
|
1010
|
-
/**
|
|
1011
|
-
* Dragging started within any container.
|
|
1012
|
-
*/
|
|
1013
|
-
onDragStart: ({ source, location }) => {
|
|
1014
|
-
log2("Root.onDragStart", {
|
|
1015
|
-
source: source.data,
|
|
1016
|
-
location: location.current.dropTargets.map((target) => target.data)
|
|
1017
|
-
}, {
|
|
1018
|
-
F: __dxlog_file3,
|
|
1019
|
-
L: 215,
|
|
1020
|
-
S: void 0,
|
|
1021
|
-
C: (f, a) => f(...a)
|
|
1022
|
-
});
|
|
1023
|
-
handleChange({
|
|
1024
|
-
source,
|
|
1025
|
-
location
|
|
1026
|
-
});
|
|
1027
|
-
},
|
|
1028
|
-
/**
|
|
1029
|
-
* Dragging entered a new container.
|
|
1030
|
-
*/
|
|
1031
|
-
onDropTargetChange: ({ source, location }) => {
|
|
1032
|
-
clearTimeout(noTargetTimeout);
|
|
1033
|
-
log2("Root.onDropTargetChange", {
|
|
1034
|
-
source: source.data,
|
|
1035
|
-
location: location.current.dropTargets.map((target) => target.data)
|
|
1036
|
-
}, {
|
|
1037
|
-
F: __dxlog_file3,
|
|
1038
|
-
L: 228,
|
|
1039
|
-
S: void 0,
|
|
1040
|
-
C: (f, a) => f(...a)
|
|
1041
|
-
});
|
|
1042
|
-
if (location.current.dropTargets.length === 0) {
|
|
1043
|
-
noTargetTimeout = setTimeout(() => setDragging(void 0), 1e3);
|
|
1044
|
-
} else {
|
|
1045
|
-
handleChange({
|
|
1046
|
-
source,
|
|
1047
|
-
location
|
|
1048
|
-
});
|
|
1049
|
-
}
|
|
1050
|
-
},
|
|
1051
|
-
/**
|
|
1052
|
-
* Dragging within any container.
|
|
1053
|
-
*/
|
|
1054
|
-
onDrag: ({ source, location }) => {
|
|
1055
|
-
const { data } = getSourceHandler(source);
|
|
1056
|
-
const { handler } = getTargetHandler(location);
|
|
1057
|
-
if (handler) {
|
|
1058
|
-
const { clientX: x, clientY: y } = location.current.input;
|
|
1059
|
-
handler.onDrag?.({
|
|
1060
|
-
source: data,
|
|
1061
|
-
position: {
|
|
1062
|
-
x,
|
|
1063
|
-
y
|
|
1064
|
-
}
|
|
1065
|
-
});
|
|
1066
|
-
}
|
|
1067
|
-
},
|
|
1068
|
-
/**
|
|
1069
|
-
* Dragging ended.
|
|
1070
|
-
*/
|
|
1071
|
-
onDrop: ({ source, location }) => {
|
|
1072
|
-
log2.info("Root.onDrop", {
|
|
1073
|
-
source: source.data,
|
|
1074
|
-
location: location.current.dropTargets.map((target) => target.data)
|
|
1075
|
-
}, {
|
|
1076
|
-
F: __dxlog_file3,
|
|
1077
|
-
L: 257,
|
|
1078
|
-
S: void 0,
|
|
1079
|
-
C: (f, a) => f(...a)
|
|
1080
|
-
});
|
|
1081
|
-
const { data: sourceData, handler: sourceHandler } = getSourceHandler(source);
|
|
1082
|
-
if (!sourceHandler) {
|
|
1083
|
-
log2.warn("invalid source", {
|
|
1084
|
-
source: sourceData,
|
|
1085
|
-
handlers: Object.keys(handlers)
|
|
1086
|
-
}, {
|
|
1087
|
-
F: __dxlog_file3,
|
|
1088
|
-
L: 265,
|
|
1089
|
-
S: void 0,
|
|
1090
|
-
C: (f, a) => f(...a)
|
|
1091
|
-
});
|
|
1092
|
-
return;
|
|
1093
|
-
}
|
|
1094
|
-
try {
|
|
1095
|
-
if (location.current.dropTargets.length === 0) {
|
|
1096
|
-
log2.info("cancelled", void 0, {
|
|
1097
|
-
F: __dxlog_file3,
|
|
1098
|
-
L: 280,
|
|
1099
|
-
S: void 0,
|
|
1100
|
-
C: (f, a) => f(...a)
|
|
1101
|
-
});
|
|
1102
|
-
} else {
|
|
1103
|
-
const { data: targetData, handler: targetHandler } = getTargetHandler(location);
|
|
1104
|
-
if (!targetHandler) {
|
|
1105
|
-
log2.warn("invalid target", {
|
|
1106
|
-
source: sourceData,
|
|
1107
|
-
location,
|
|
1108
|
-
handlers: Object.keys(handlers)
|
|
1109
|
-
}, {
|
|
1110
|
-
F: __dxlog_file3,
|
|
1111
|
-
L: 285,
|
|
1112
|
-
S: void 0,
|
|
1113
|
-
C: (f, a) => f(...a)
|
|
1114
|
-
});
|
|
1115
|
-
return;
|
|
1116
|
-
}
|
|
1117
|
-
if (sourceHandler === targetHandler) {
|
|
1118
|
-
targetHandler.onDrop?.({
|
|
1119
|
-
source: sourceData,
|
|
1120
|
-
target: targetData
|
|
1121
|
-
});
|
|
1122
|
-
} else {
|
|
1123
|
-
if (!sourceHandler.onTake) {
|
|
1124
|
-
log2.warn("invalid source", {
|
|
1125
|
-
source: sourceData
|
|
1126
|
-
}, {
|
|
1127
|
-
F: __dxlog_file3,
|
|
1128
|
-
L: 301,
|
|
1129
|
-
S: void 0,
|
|
1130
|
-
C: (f, a) => f(...a)
|
|
1131
|
-
});
|
|
1132
|
-
return;
|
|
1133
|
-
}
|
|
1134
|
-
sourceHandler.onTake?.({
|
|
1135
|
-
source: sourceData
|
|
1136
|
-
}, async (object) => {
|
|
1137
|
-
targetHandler.onDrop?.({
|
|
1138
|
-
source: {
|
|
1139
|
-
...sourceData,
|
|
1140
|
-
data: object
|
|
1141
|
-
},
|
|
1142
|
-
target: targetData
|
|
1143
|
-
});
|
|
1144
|
-
return true;
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
} finally {
|
|
1149
|
-
handleCancel();
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
}));
|
|
1153
|
-
}, [
|
|
1154
|
-
handlers,
|
|
1155
|
-
getSourceHandler,
|
|
1156
|
-
getTargetHandler
|
|
1157
|
-
]);
|
|
1158
|
-
return /* @__PURE__ */ React6.createElement(RootContextProvider, {
|
|
1159
|
-
containers: handlers,
|
|
1160
|
-
addContainer: (container) => setHandlers((containers) => ({
|
|
1161
|
-
...containers,
|
|
1162
|
-
[container.id]: container
|
|
1163
|
-
})),
|
|
1164
|
-
removeContainer: (id) => setHandlers((containers) => {
|
|
1165
|
-
delete containers[id];
|
|
1166
|
-
return {
|
|
1167
|
-
...containers
|
|
1168
|
-
};
|
|
1169
|
-
}),
|
|
1170
|
-
dragging
|
|
1171
|
-
}, /* @__PURE__ */ React6.createElement(Root2, {
|
|
1172
|
-
className: mx6("group overflow-hidden", classNames),
|
|
1173
|
-
[`data-${ROOT_DEBUG_ATTR}`]: debug,
|
|
1174
|
-
ref: composedRef
|
|
1175
|
-
}, children));
|
|
1176
|
-
});
|
|
1177
|
-
var [ContainerContextProvider, useContainerContext] = createContext3("MosaicContainer");
|
|
1178
|
-
var CONTAINER_STATE_ATTR = "mosaic-container-state";
|
|
1179
|
-
var CONTAINER_PLACEHOLDER_WIDTH = "--mosaic-placeholder-width";
|
|
1180
|
-
var CONTAINER_PLACEHOLDER_HEIGHT = "--mosaic-placeholder-height";
|
|
1181
|
-
var counter = 0;
|
|
1182
|
-
var Container = /* @__PURE__ */ forwardRef5(({ className, classNames, children, eventHandler: eventHandlerProp, axis = "vertical", asChild, autoScroll: autoscrollElement, withFocus, debug, ...props }, forwardedRef) => {
|
|
1183
|
-
const rootRef = useRef4(null);
|
|
1184
|
-
const composedRef = useComposedRefs2(rootRef, forwardedRef);
|
|
1185
|
-
const Root2 = asChild ? Slot3 : Primitive2.div;
|
|
1186
|
-
const eventHandler = useMemo4(() => eventHandlerProp ?? {
|
|
1187
|
-
id: `mosaic-container-${counter++}`
|
|
1188
|
-
}, [
|
|
1189
|
-
eventHandlerProp
|
|
1190
|
-
]);
|
|
1191
|
-
const { dragging } = useRootContext(Container.displayName);
|
|
1192
|
-
const [state, setState] = useState3({
|
|
1193
|
-
type: "idle"
|
|
1194
|
-
});
|
|
1195
|
-
const [activeLocation, setActiveLocation] = useState3();
|
|
1196
|
-
const [scrolling, setScrolling] = useState3(false);
|
|
1197
|
-
const { setFocus } = useFocus();
|
|
1198
|
-
useEffect2(() => {
|
|
1199
|
-
if (withFocus) {
|
|
1200
|
-
setFocus?.(state.type === "active" ? "active" : void 0);
|
|
1201
|
-
}
|
|
1202
|
-
}, [
|
|
1203
|
-
setFocus,
|
|
1204
|
-
withFocus,
|
|
1205
|
-
state
|
|
1206
|
-
]);
|
|
1207
|
-
const { addContainer, removeContainer } = useRootContext(eventHandler.id);
|
|
1208
|
-
useEffect2(() => {
|
|
1209
|
-
addContainer(eventHandler);
|
|
1210
|
-
return () => removeContainer(eventHandler.id);
|
|
1211
|
-
}, [
|
|
1212
|
-
eventHandler
|
|
1213
|
-
]);
|
|
1214
|
-
const data = useMemo4(() => ({
|
|
1215
|
-
type: "container",
|
|
1216
|
-
id: eventHandler.id
|
|
1217
|
-
}), [
|
|
1218
|
-
eventHandler.id
|
|
1219
|
-
]);
|
|
1220
|
-
useEffect2(() => {
|
|
1221
|
-
if (!rootRef.current) {
|
|
1222
|
-
return;
|
|
1223
|
-
}
|
|
1224
|
-
let timeout;
|
|
1225
|
-
const handleScroll = () => {
|
|
1226
|
-
setScrolling(true);
|
|
1227
|
-
clearTimeout(timeout);
|
|
1228
|
-
timeout = setTimeout(() => {
|
|
1229
|
-
setScrolling(false);
|
|
1230
|
-
}, 500);
|
|
1231
|
-
};
|
|
1232
|
-
return combine(...[
|
|
1233
|
-
/**
|
|
1234
|
-
* Custom event for dragging cancellation.
|
|
1235
|
-
*/
|
|
1236
|
-
bind(rootRef.current, {
|
|
1237
|
-
type: "dnd:cancel",
|
|
1238
|
-
listener: () => {
|
|
1239
|
-
setState({
|
|
1240
|
-
type: "idle"
|
|
1241
|
-
});
|
|
1242
|
-
}
|
|
1243
|
-
}),
|
|
1244
|
-
// Target.
|
|
1245
|
-
dropTargetForElements({
|
|
1246
|
-
element: rootRef.current,
|
|
1247
|
-
getData: () => data,
|
|
1248
|
-
/**
|
|
1249
|
-
* Test if permitted to drop here.
|
|
1250
|
-
* NOTE: Contained Tile and Placeholder elements do the same.
|
|
1251
|
-
*/
|
|
1252
|
-
canDrop: ({ source }) => {
|
|
1253
|
-
const data2 = getSourceData(source);
|
|
1254
|
-
return data2 && eventHandler.canDrop?.({
|
|
1255
|
-
source: data2
|
|
1256
|
-
}) || false;
|
|
1257
|
-
},
|
|
1258
|
-
// TODO(burdon): Provide semantic intent to onDrop.
|
|
1259
|
-
// getDropEffect: () => {
|
|
1260
|
-
// return 'move';
|
|
1261
|
-
// },
|
|
1262
|
-
/**
|
|
1263
|
-
* Dragging started in this container.
|
|
1264
|
-
*/
|
|
1265
|
-
onDragStart: ({ source }) => {
|
|
1266
|
-
const sourceData = source.data;
|
|
1267
|
-
setState({
|
|
1268
|
-
type: "active",
|
|
1269
|
-
bounds: sourceData.bounds
|
|
1270
|
-
});
|
|
1271
|
-
},
|
|
1272
|
-
/**
|
|
1273
|
-
* Dragging entered this container.
|
|
1274
|
-
*/
|
|
1275
|
-
onDragEnter: ({ source }) => {
|
|
1276
|
-
const sourceData = source.data;
|
|
1277
|
-
setState({
|
|
1278
|
-
type: "active",
|
|
1279
|
-
bounds: sourceData.bounds
|
|
1280
|
-
});
|
|
1281
|
-
},
|
|
1282
|
-
/**
|
|
1283
|
-
* Dragging left this container.
|
|
1284
|
-
* NOTE: If the container isn't full-height, then when the dragged item is temporarily removed the container will shrink,
|
|
1285
|
-
* triggering `onDragLeave`, which then causes the item to be added and removed continually (flickering).
|
|
1286
|
-
*/
|
|
1287
|
-
onDragLeave: ({ source }) => {
|
|
1288
|
-
const sourceData = source.data;
|
|
1289
|
-
if (sourceData.containerId !== eventHandler.id) {
|
|
1290
|
-
setState({
|
|
1291
|
-
type: "idle"
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
},
|
|
1295
|
-
/**
|
|
1296
|
-
* Dropped in this container.
|
|
1297
|
-
*/
|
|
1298
|
-
onDrop: () => {
|
|
1299
|
-
setState({
|
|
1300
|
-
type: "idle"
|
|
1301
|
-
});
|
|
1302
|
-
}
|
|
1303
|
-
}),
|
|
1304
|
-
// Autoscroll.
|
|
1305
|
-
// NOTE: When used with Scrollable we get a spurious warning (in dev mode).
|
|
1306
|
-
// "Auto scrolling has been attached to an element that appears not to be scrollable."
|
|
1307
|
-
autoscrollElement && [
|
|
1308
|
-
autoScrollForElements({
|
|
1309
|
-
element: autoscrollElement,
|
|
1310
|
-
// canScroll: ({ element: _ }) => {
|
|
1311
|
-
// return true;
|
|
1312
|
-
// },
|
|
1313
|
-
getAllowedAxis: () => axis,
|
|
1314
|
-
getConfiguration: () => ({
|
|
1315
|
-
maxScrollSpeed: "fast"
|
|
1316
|
-
})
|
|
1317
|
-
}),
|
|
1318
|
-
bind(autoscrollElement, {
|
|
1319
|
-
type: "scroll",
|
|
1320
|
-
listener: handleScroll
|
|
1321
|
-
}),
|
|
1322
|
-
() => setScrolling(false)
|
|
1323
|
-
]
|
|
1324
|
-
].filter(isTruthy).flatMap((x) => x));
|
|
1325
|
-
}, [
|
|
1326
|
-
rootRef,
|
|
1327
|
-
eventHandler,
|
|
1328
|
-
data,
|
|
1329
|
-
autoscrollElement
|
|
1330
|
-
]);
|
|
1331
|
-
return /* @__PURE__ */ React6.createElement(ContainerContextProvider, {
|
|
1332
|
-
id: eventHandler.id,
|
|
1333
|
-
eventHandler,
|
|
1334
|
-
axis,
|
|
1335
|
-
state,
|
|
1336
|
-
dragging: state.type === "active" ? dragging : void 0,
|
|
1337
|
-
scrolling,
|
|
1338
|
-
activeLocation,
|
|
1339
|
-
setActiveLocation
|
|
1340
|
-
}, /* @__PURE__ */ React6.createElement(Root2, {
|
|
1341
|
-
className: mx6("bs-full", className, classNames),
|
|
1342
|
-
style: {
|
|
1343
|
-
[CONTAINER_PLACEHOLDER_WIDTH]: state.type === "active" && state.bounds ? `${state.bounds.width}px` : "0px",
|
|
1344
|
-
[CONTAINER_PLACEHOLDER_HEIGHT]: state.type === "active" && state.bounds ? `${state.bounds.height}px` : "0px"
|
|
1345
|
-
},
|
|
1346
|
-
...props,
|
|
1347
|
-
[`data-${CONTAINER_STATE_ATTR}`]: state.type,
|
|
1348
|
-
ref: composedRef
|
|
1349
|
-
}, children), debug?.());
|
|
1350
|
-
});
|
|
1351
|
-
Container.displayName = "MosaicContainer";
|
|
1352
|
-
var [TileContextProvider, useTileContext] = createContext3("MosaicTile");
|
|
1353
|
-
var TILE_STATE_ATTR = "mosaic-tile-state";
|
|
1354
|
-
var Tile = /* @__PURE__ */ forwardRef5(({ className, classNames, children, asChild, dragHandle, allowedEdges: allowedEdgesProp, location, id, data: dataProp, debug: _ }, forwardedRef) => {
|
|
1355
|
-
const rootRef = useRef4(null);
|
|
1356
|
-
const composedRef = composeRefs(rootRef, forwardedRef);
|
|
1357
|
-
const Root2 = asChild ? Slot3 : Primitive2.div;
|
|
1358
|
-
const { id: containerId, eventHandler, axis, scrolling, setActiveLocation } = useContainerContext(Tile.displayName);
|
|
1359
|
-
const [state, setState] = useState3({
|
|
1360
|
-
type: "idle"
|
|
1361
|
-
});
|
|
1362
|
-
const allowedEdges = useMemo4(() => allowedEdgesProp || (axis === "vertical" ? [
|
|
1363
|
-
"top",
|
|
1364
|
-
"bottom"
|
|
1365
|
-
] : [
|
|
1366
|
-
"left",
|
|
1367
|
-
"right"
|
|
1368
|
-
]), [
|
|
1369
|
-
allowedEdgesProp,
|
|
1370
|
-
axis
|
|
1371
|
-
]);
|
|
1372
|
-
const data = useMemo4(() => ({
|
|
1373
|
-
type: "tile",
|
|
1374
|
-
id,
|
|
1375
|
-
containerId,
|
|
1376
|
-
data: dataProp,
|
|
1377
|
-
location
|
|
1378
|
-
}), [
|
|
1379
|
-
containerId,
|
|
1380
|
-
location,
|
|
1381
|
-
dataProp
|
|
1382
|
-
]);
|
|
1383
|
-
useLayoutEffect(() => {
|
|
1384
|
-
const root = rootRef.current;
|
|
1385
|
-
if (!root || !containerId || scrolling) {
|
|
1386
|
-
return;
|
|
1387
|
-
}
|
|
1388
|
-
const handleChange = ({ self, source }) => {
|
|
1389
|
-
if (source.data.id !== dataProp.id) {
|
|
1390
|
-
const closestEdge = extractClosestEdge(self.data);
|
|
1391
|
-
const location2 = data.location + (closestEdge === "top" || closestEdge === "left" ? -0.5 : 0.5);
|
|
1392
|
-
setActiveLocation(location2);
|
|
1393
|
-
setState({
|
|
1394
|
-
type: "target",
|
|
1395
|
-
closestEdge
|
|
1396
|
-
});
|
|
1397
|
-
}
|
|
1398
|
-
};
|
|
1399
|
-
return combine(
|
|
1400
|
-
// Source.
|
|
1401
|
-
draggable({
|
|
1402
|
-
element: root,
|
|
1403
|
-
dragHandle: dragHandle && state.type !== "preview" ? dragHandle : void 0,
|
|
1404
|
-
canDrag: () => true,
|
|
1405
|
-
getInitialData: () => data,
|
|
1406
|
-
onGenerateDragPreview: ({ location: location2, nativeSetDragImage }) => {
|
|
1407
|
-
setCustomNativeDragPreview({
|
|
1408
|
-
nativeSetDragImage,
|
|
1409
|
-
getOffset: preserveOffsetOnSource({
|
|
1410
|
-
element: root,
|
|
1411
|
-
input: location2.current.input
|
|
1412
|
-
}),
|
|
1413
|
-
render: ({ container }) => {
|
|
1414
|
-
data.bounds = root.getBoundingClientRect();
|
|
1415
|
-
setState({
|
|
1416
|
-
type: "preview",
|
|
1417
|
-
container,
|
|
1418
|
-
rect: root.getBoundingClientRect()
|
|
1419
|
-
});
|
|
1420
|
-
return () => setState({
|
|
1421
|
-
type: "dragging"
|
|
1422
|
-
});
|
|
1423
|
-
}
|
|
1424
|
-
});
|
|
1425
|
-
},
|
|
1426
|
-
onDragStart: () => {
|
|
1427
|
-
setState({
|
|
1428
|
-
type: "dragging"
|
|
1429
|
-
});
|
|
1430
|
-
},
|
|
1431
|
-
onDrop: () => {
|
|
1432
|
-
setState({
|
|
1433
|
-
type: "idle"
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
}),
|
|
1437
|
-
// Target.
|
|
1438
|
-
dropTargetForElements({
|
|
1439
|
-
element: root,
|
|
1440
|
-
getData: ({ input, element }) => attachClosestEdge(data, {
|
|
1441
|
-
input,
|
|
1442
|
-
element,
|
|
1443
|
-
allowedEdges
|
|
1444
|
-
}),
|
|
1445
|
-
canDrop: ({ source }) => {
|
|
1446
|
-
const data2 = getSourceData(source);
|
|
1447
|
-
return data2 && eventHandler.canDrop?.({
|
|
1448
|
-
source: data2
|
|
1449
|
-
}) || false;
|
|
1450
|
-
},
|
|
1451
|
-
onDragEnter: ({ self, source }) => {
|
|
1452
|
-
handleChange({
|
|
1453
|
-
self,
|
|
1454
|
-
source
|
|
1455
|
-
});
|
|
1456
|
-
},
|
|
1457
|
-
onDragLeave: () => {
|
|
1458
|
-
setState({
|
|
1459
|
-
type: "idle"
|
|
1460
|
-
});
|
|
1461
|
-
setActiveLocation(void 0);
|
|
1462
|
-
},
|
|
1463
|
-
onDrag: ({ self, source }) => {
|
|
1464
|
-
handleChange({
|
|
1465
|
-
self,
|
|
1466
|
-
source
|
|
1467
|
-
});
|
|
1468
|
-
},
|
|
1469
|
-
onDrop: () => {
|
|
1470
|
-
setState({
|
|
1471
|
-
type: "idle"
|
|
1472
|
-
});
|
|
1473
|
-
setActiveLocation(void 0);
|
|
1474
|
-
}
|
|
1475
|
-
})
|
|
1476
|
-
);
|
|
1477
|
-
}, [
|
|
1478
|
-
rootRef,
|
|
1479
|
-
dragHandle,
|
|
1480
|
-
eventHandler,
|
|
1481
|
-
data,
|
|
1482
|
-
scrolling,
|
|
1483
|
-
allowedEdges,
|
|
1484
|
-
setActiveLocation
|
|
1485
|
-
]);
|
|
1486
|
-
return /* @__PURE__ */ React6.createElement(TileContextProvider, {
|
|
1487
|
-
state
|
|
1488
|
-
}, /* @__PURE__ */ React6.createElement(Root2, {
|
|
1489
|
-
[`data-${TILE_STATE_ATTR}`]: state.type,
|
|
1490
|
-
role: "listitem",
|
|
1491
|
-
className: mx6("relative", className, classNames),
|
|
1492
|
-
ref: composedRef
|
|
1493
|
-
}, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(Root2, {
|
|
1494
|
-
// NOTE: Use to control appearance while dragging.
|
|
1495
|
-
[`data-${TILE_STATE_ATTR}`]: state.type,
|
|
1496
|
-
// TODO(burdon): Configure drop animation.
|
|
1497
|
-
className: mx6("relative", className, classNames),
|
|
1498
|
-
style: {
|
|
1499
|
-
width: `${state.rect.width}px`,
|
|
1500
|
-
height: `${state.rect.height}px`
|
|
1501
|
-
}
|
|
1502
|
-
}, children), state.container));
|
|
1503
|
-
});
|
|
1504
|
-
Tile.displayName = "MosaicTile";
|
|
1505
|
-
var PLACEHOLDER_AXIS_ATTR = "mosaic-placeholder-axis";
|
|
1506
|
-
var PLACEHOLDER_STATE_ATTR = "mosaic-placeholder-state";
|
|
1507
|
-
var Placeholder2 = ({ classNames, children, asChild, axis = "vertical", location }) => {
|
|
1508
|
-
const rootRef = useRef4(null);
|
|
1509
|
-
const Root2 = asChild ? Slot3 : Primitive2.div;
|
|
1510
|
-
const { id: containerId, eventHandler, scrolling, activeLocation, setActiveLocation } = useContainerContext(Placeholder2.displayName);
|
|
1511
|
-
const data = useMemo4(() => ({
|
|
1512
|
-
type: "placeholder",
|
|
1513
|
-
containerId,
|
|
1514
|
-
location
|
|
1515
|
-
}), [
|
|
1516
|
-
containerId,
|
|
1517
|
-
location
|
|
1518
|
-
]);
|
|
1519
|
-
useLayoutEffect(() => {
|
|
1520
|
-
const root = rootRef.current;
|
|
1521
|
-
if (!root || scrolling) {
|
|
1522
|
-
return;
|
|
1523
|
-
}
|
|
1524
|
-
return dropTargetForElements({
|
|
1525
|
-
element: root,
|
|
1526
|
-
getData: () => data,
|
|
1527
|
-
canDrop: ({ source }) => {
|
|
1528
|
-
const data2 = getSourceData(source);
|
|
1529
|
-
return data2 && eventHandler.canDrop?.({
|
|
1530
|
-
source: data2
|
|
1531
|
-
}) || false;
|
|
1532
|
-
},
|
|
1533
|
-
onDragEnter: () => {
|
|
1534
|
-
setActiveLocation(data.location);
|
|
1535
|
-
},
|
|
1536
|
-
onDragLeave: () => {
|
|
1537
|
-
setActiveLocation(void 0);
|
|
1538
|
-
},
|
|
1539
|
-
onDrop: () => {
|
|
1540
|
-
setActiveLocation(void 0);
|
|
1541
|
-
}
|
|
1542
|
-
});
|
|
1543
|
-
}, [
|
|
1544
|
-
rootRef,
|
|
1545
|
-
data,
|
|
1546
|
-
scrolling,
|
|
1547
|
-
setActiveLocation
|
|
1548
|
-
]);
|
|
1549
|
-
return /* @__PURE__ */ React6.createElement(Root2, {
|
|
1550
|
-
[`data-${PLACEHOLDER_AXIS_ATTR}`]: axis,
|
|
1551
|
-
[`data-${PLACEHOLDER_STATE_ATTR}`]: data.location === activeLocation ? "active" : "idle",
|
|
1552
|
-
role: "none",
|
|
1553
|
-
className: mx6("relative", classNames),
|
|
1554
|
-
ref: rootRef
|
|
1555
|
-
}, children);
|
|
1556
|
-
};
|
|
1557
|
-
Placeholder2.displayName = "MosaicPlaceholder";
|
|
1558
|
-
var DropIndicator = (props) => {
|
|
1559
|
-
const { state } = useTileContext(DropIndicator.displayName);
|
|
1560
|
-
return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React6.createElement(NativeDropIndicator, {
|
|
1561
|
-
...props,
|
|
1562
|
-
edge: state.closestEdge
|
|
1563
|
-
}) : null;
|
|
1564
|
-
};
|
|
1565
|
-
DropIndicator.displayName = "MosaicDropIndicator";
|
|
1566
|
-
var Mosaic = {
|
|
1567
|
-
Root,
|
|
1568
|
-
Container,
|
|
1569
|
-
Tile,
|
|
1570
|
-
Placeholder: Placeholder2,
|
|
1571
|
-
DropIndicator,
|
|
1572
|
-
// TODO(burdon): Move out of Mosaic namespace?
|
|
1573
|
-
Viewport: Scrollable,
|
|
1574
|
-
Stack,
|
|
1575
|
-
VirtualStack
|
|
1576
|
-
};
|
|
1577
|
-
|
|
1578
|
-
// src/hooks/useContainerDebug.tsx
|
|
1579
|
-
var useContainerDebug = (debug) => {
|
|
1580
|
-
const debugRef = useRef5(null);
|
|
1581
|
-
return useMemo5(() => {
|
|
1582
|
-
if (!debug) {
|
|
1583
|
-
return [
|
|
1584
|
-
() => null,
|
|
1585
|
-
void 0
|
|
1586
|
-
];
|
|
1587
|
-
}
|
|
1588
|
-
return [
|
|
1589
|
-
({ classNames }) => /* @__PURE__ */ React7.createElement("div", {
|
|
1590
|
-
role: "none",
|
|
1591
|
-
className: mx7("overflow-hidden", classNames),
|
|
1592
|
-
ref: debugRef
|
|
1593
|
-
}),
|
|
1594
|
-
() => debugRef.current && /* @__PURE__ */ createPortal2(/* @__PURE__ */ React7.createElement(ContainerInfo, null), debugRef.current)
|
|
1595
|
-
];
|
|
1596
|
-
}, [
|
|
1597
|
-
debug,
|
|
1598
|
-
debugRef
|
|
1599
|
-
]);
|
|
1600
|
-
};
|
|
1601
|
-
var ContainerInfo = /* @__PURE__ */ forwardRef6(({ classNames }, forwardedRef) => {
|
|
1602
|
-
const { id, state, activeLocation, scrolling } = useContainerContext(ContainerInfo.displayName);
|
|
1603
|
-
const counter2 = useRef5(0);
|
|
1604
|
-
return /* @__PURE__ */ React7.createElement(Json, {
|
|
1605
|
-
data: {
|
|
1606
|
-
id,
|
|
1607
|
-
activeLocation,
|
|
1608
|
-
scrolling,
|
|
1609
|
-
state,
|
|
1610
|
-
count: counter2.current++
|
|
1611
|
-
},
|
|
1612
|
-
classNames: mx7("text-xs", classNames),
|
|
1613
|
-
ref: forwardedRef
|
|
1614
|
-
});
|
|
1615
|
-
});
|
|
1616
|
-
ContainerInfo.displayName = "ContainerInfo";
|
|
1617
|
-
|
|
1618
|
-
export {
|
|
1619
|
-
styles,
|
|
1620
|
-
Image,
|
|
1621
|
-
Card,
|
|
1622
|
-
styles2,
|
|
1623
|
-
useFocus,
|
|
1624
|
-
Focus,
|
|
1625
|
-
styles3,
|
|
1626
|
-
dropHandler,
|
|
1627
|
-
useContainerDebug,
|
|
1628
|
-
useEventHandlerAdapter,
|
|
1629
|
-
useVisibleItems,
|
|
1630
|
-
Stack,
|
|
1631
|
-
VirtualStack,
|
|
1632
|
-
useRootContext,
|
|
1633
|
-
useContainerContext,
|
|
1634
|
-
useTileContext,
|
|
1635
|
-
Mosaic
|
|
1636
|
-
};
|
|
1637
|
-
//# sourceMappingURL=chunk-UMBPEG4F.mjs.map
|