@dxos/react-ui-mosaic 0.8.4-main.bc674ce → 0.8.4-main.ef1bc66f44

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.
Files changed (109) hide show
  1. package/dist/lib/browser/{chunk-UMBPEG4F.mjs → chunk-Y6GU2CCU.mjs} +833 -992
  2. package/dist/lib/browser/chunk-Y6GU2CCU.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +407 -45
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +28 -218
  7. package/dist/lib/browser/testing/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/{chunk-X6GV7SMK.mjs → chunk-KTLFCRVA.mjs} +833 -992
  9. package/dist/lib/node-esm/chunk-KTLFCRVA.mjs.map +7 -0
  10. package/dist/lib/node-esm/index.mjs +407 -45
  11. package/dist/lib/node-esm/index.mjs.map +4 -4
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/testing/index.mjs +28 -218
  14. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  15. package/dist/types/src/components/Board/Board.d.ts +65 -0
  16. package/dist/types/src/components/Board/Board.d.ts.map +1 -0
  17. package/dist/types/src/components/{Mosaic/Mosaic.stories.d.ts → Board/Board.stories.d.ts} +9 -1
  18. package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -0
  19. package/dist/types/src/components/Board/Column.d.ts +29 -0
  20. package/dist/types/src/components/Board/Column.d.ts.map +1 -0
  21. package/dist/types/src/components/Board/Item.d.ts +9 -0
  22. package/dist/types/src/components/Board/Item.d.ts.map +1 -0
  23. package/dist/types/src/components/Board/index.d.ts +2 -0
  24. package/dist/types/src/components/Board/index.d.ts.map +1 -0
  25. package/dist/types/src/components/Card/Card.d.ts +5 -3
  26. package/dist/types/src/components/Card/Card.d.ts.map +1 -1
  27. package/dist/types/src/components/Focus/Focus.d.ts +5 -4
  28. package/dist/types/src/components/Focus/Focus.d.ts.map +1 -1
  29. package/dist/types/src/components/Focus/styles.d.ts.map +1 -1
  30. package/dist/types/src/components/Mosaic/Mosaic.d.ts +8 -17
  31. package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -1
  32. package/dist/types/src/components/Mosaic/styles.d.ts.map +1 -1
  33. package/dist/types/src/components/Mosaic/types.d.ts +0 -2
  34. package/dist/types/src/components/Mosaic/types.d.ts.map +1 -1
  35. package/dist/types/src/components/Stack/Stack.d.ts +3 -3
  36. package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
  37. package/dist/types/src/components/Stack/Stack.stories.d.ts.map +1 -1
  38. package/dist/types/src/{testing/Virtualizer.stories.d.ts → components/Stack/virtualizer.stories.d.ts} +2 -2
  39. package/dist/types/src/components/Stack/virtualizer.stories.d.ts.map +1 -0
  40. package/dist/types/src/components/index.d.ts +1 -1
  41. package/dist/types/src/components/index.d.ts.map +1 -1
  42. package/dist/types/src/testing/CardContainer.d.ts +1 -1
  43. package/dist/types/src/testing/CardContainer.d.ts.map +1 -1
  44. package/dist/types/src/testing/index.d.ts +1 -1
  45. package/dist/types/src/testing/index.d.ts.map +1 -1
  46. package/dist/types/src/testing/types.d.ts +21 -0
  47. package/dist/types/src/testing/types.d.ts.map +1 -0
  48. package/dist/types/src/translations.d.ts +4 -1
  49. package/dist/types/src/translations.d.ts.map +1 -1
  50. package/dist/types/tsconfig.tsbuildinfo +1 -1
  51. package/package.json +24 -26
  52. package/src/components/{Mosaic/Mosaic.stories.tsx → Board/Board.stories.tsx} +52 -8
  53. package/src/components/Board/Board.tsx +166 -0
  54. package/src/components/Board/Column.tsx +253 -0
  55. package/src/components/Board/Item.tsx +80 -0
  56. package/src/components/{Layout → Board}/index.ts +1 -1
  57. package/src/components/Card/Card.stories.tsx +1 -1
  58. package/src/components/Card/styles.ts +1 -1
  59. package/src/components/Focus/Focus.tsx +7 -9
  60. package/src/components/Focus/styles.ts +3 -6
  61. package/src/components/Image/Image.stories.tsx +1 -1
  62. package/src/components/Mosaic/Mosaic.tsx +40 -39
  63. package/src/components/Mosaic/styles.ts +9 -8
  64. package/src/components/Mosaic/types.ts +0 -4
  65. package/src/components/Stack/Stack.stories.tsx +23 -19
  66. package/src/components/Stack/Stack.tsx +34 -25
  67. package/src/{testing/Virtualizer.stories.tsx → components/Stack/virtualizer.stories.tsx} +47 -37
  68. package/src/components/index.ts +1 -1
  69. package/src/hooks/useContainerDebug.tsx +4 -2
  70. package/src/testing/CardContainer.tsx +12 -7
  71. package/src/testing/index.ts +1 -1
  72. package/src/testing/types.ts +38 -0
  73. package/src/translations.ts +4 -1
  74. package/dist/lib/browser/chunk-UMBPEG4F.mjs.map +0 -7
  75. package/dist/lib/browser/index.css +0 -13
  76. package/dist/lib/browser/index.css.map +0 -7
  77. package/dist/lib/browser/testing/index.css +0 -13
  78. package/dist/lib/browser/testing/index.css.map +0 -7
  79. package/dist/lib/node-esm/chunk-X6GV7SMK.mjs.map +0 -7
  80. package/dist/lib/node-esm/index.css +0 -13
  81. package/dist/lib/node-esm/index.css.map +0 -7
  82. package/dist/lib/node-esm/testing/index.css +0 -13
  83. package/dist/lib/node-esm/testing/index.css.map +0 -7
  84. package/dist/types/src/components/Layout/Layout.d.ts +0 -33
  85. package/dist/types/src/components/Layout/Layout.d.ts.map +0 -1
  86. package/dist/types/src/components/Layout/Layout.stories.d.ts +0 -10
  87. package/dist/types/src/components/Layout/Layout.stories.d.ts.map +0 -1
  88. package/dist/types/src/components/Layout/index.d.ts +0 -2
  89. package/dist/types/src/components/Layout/index.d.ts.map +0 -1
  90. package/dist/types/src/components/Mosaic/Mosaic.stories.d.ts.map +0 -1
  91. package/dist/types/src/components/Scrollable/Scrollable.d.ts +0 -24
  92. package/dist/types/src/components/Scrollable/Scrollable.d.ts.map +0 -1
  93. package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts +0 -10
  94. package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts.map +0 -1
  95. package/dist/types/src/components/Scrollable/index.d.ts +0 -2
  96. package/dist/types/src/components/Scrollable/index.d.ts.map +0 -1
  97. package/dist/types/src/testing/Board.d.ts +0 -45
  98. package/dist/types/src/testing/Board.d.ts.map +0 -1
  99. package/dist/types/src/testing/Slot.stories.d.ts +0 -14
  100. package/dist/types/src/testing/Slot.stories.d.ts.map +0 -1
  101. package/dist/types/src/testing/Virtualizer.stories.d.ts.map +0 -1
  102. package/src/components/Layout/Layout.stories.tsx +0 -59
  103. package/src/components/Layout/Layout.tsx +0 -108
  104. package/src/components/Scrollable/Scrollable.stories.tsx +0 -59
  105. package/src/components/Scrollable/Scrollable.tsx +0 -88
  106. package/src/components/Scrollable/index.ts +0 -5
  107. package/src/components/Scrollable/scrollable.css +0 -20
  108. package/src/testing/Board.tsx +0 -278
  109. package/src/testing/Slot.stories.tsx +0 -101
@@ -1,490 +1,99 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
- // src/components/Card/styles.ts
4
- var styles = {
5
- root: "group/card relative min-bs-[--rail-item] overflow-hidden is-full card-min-width __card-max-width",
6
- border: "bg-cardSurface border border-separator dark:border-subduedSeparator rounded-sm dx-focus-ring-group-y-indicator",
7
- /**
8
- * Row grid.
9
- * NOTE: Rows should provide their own line padding (since they may need to encapsulate buttons, etc.)
10
- */
11
- grid_3: "grid grid-cols-[var(--rail-item)_minmax(0,1fr)_var(--rail-item)] gap-x-1",
12
- grid_2: "grid grid-cols-[var(--rail-item)_minmax(0,1fr)] gap-x-1",
13
- // TODO(burdon): Address density.
14
- grid_3_coarse: "grid grid-cols-[var(--l0-avatar-size)_minmax(0,1fr)_var(--rail-item)] gap-x-1",
15
- poster: "max-bs-[200px]"
16
- };
17
-
18
- // src/components/Image/Image.tsx
19
- import React, { useCallback, useRef, useState } from "react";
20
- import { mx } from "@dxos/ui-theme";
21
- var cache = /* @__PURE__ */ new Map();
22
- var Image = ({ classNames, src, alt = "", crossOrigin = "anonymous", sampleSize = 64, contrast = 0.9 }) => {
23
- const [crossOriginState, setCrossOriginState] = useState(crossOrigin);
24
- const [dominantColor, setDominantColor] = useState(void 0);
25
- const [imageLoaded, setImageLoaded] = useState(false);
26
- const canvasRef = useRef(null);
27
- const handleImageError = () => {
28
- setCrossOriginState(void 0);
29
- };
30
- const handleImageLoad = useCallback(({ target }) => {
31
- const rgb = cache.get(src);
32
- if (rgb) {
33
- setDominantColor(rgb);
34
- setImageLoaded(true);
35
- return;
36
- }
37
- const img = target;
38
- if (!canvasRef.current) {
39
- return;
3
+ // src/hooks/useVisibleItems.ts
4
+ import { useMemo } from "react";
5
+ var useVisibleItems = ({ id, items, dragging, getId }) => {
6
+ const visibleItems = useMemo(() => {
7
+ if (!items || !dragging || id !== dragging.containerId) {
8
+ return items ?? [];
40
9
  }
41
- try {
42
- const color = extractDominantColor(canvasRef.current, img, {
43
- sampleSize,
44
- contrast
45
- });
46
- if (color) {
47
- const rgb2 = `rgb(${color[0]}, ${color[1]}, ${color[2]})`;
48
- cache.set(src, rgb2);
49
- setDominantColor(rgb2);
50
- }
51
- } catch {
52
- setCrossOriginState(void 0);
10
+ const idx = items.findIndex((item) => getId(item) === dragging.id);
11
+ if (idx === -1) {
12
+ return items;
53
13
  }
54
- setImageLoaded(true);
14
+ const visibleItems2 = items.slice();
15
+ visibleItems2.splice(idx, 1);
16
+ return visibleItems2;
55
17
  }, [
56
- sampleSize,
57
- contrast,
58
- src
18
+ id,
19
+ items,
20
+ dragging,
21
+ getId
59
22
  ]);
60
- return /* @__PURE__ */ React.createElement("div", {
61
- className: mx(`relative flex is-full justify-center overflow-hidden transition-all duration-700`, classNames),
62
- style: {
63
- backgroundColor: dominantColor
64
- }
65
- }, /* @__PURE__ */ React.createElement("canvas", {
66
- ref: canvasRef,
67
- style: {
68
- display: "none"
69
- },
70
- "aria-hidden": "true"
71
- }), /* @__PURE__ */ React.createElement("div", {
72
- className: "absolute inset-0 pointer-events-none",
73
- style: {
74
- background: dominantColor ? `radial-gradient(circle at center, transparent 30%, ${dominantColor} 100%)` : void 0,
75
- transition: "opacity 0.7s ease-in-out",
76
- opacity: 0.5
77
- }
78
- }), /* @__PURE__ */ React.createElement("img", {
79
- src,
80
- alt,
81
- crossOrigin: crossOriginState,
82
- onError: handleImageError,
83
- onLoad: handleImageLoad,
84
- className: mx("z-10 object-contain transition-opacity duration-500", classNames),
85
- style: {
86
- opacity: imageLoaded ? 1 : 0
87
- }
88
- }));
89
- };
90
- var extractDominantColor = (canvas, img, { sampleSize = 64, contrast = 0.95 }) => {
91
- const ctx = canvas.getContext("2d");
92
- if (!ctx) {
93
- return null;
94
- }
95
- canvas.width = sampleSize;
96
- canvas.height = sampleSize;
97
- ctx.drawImage(img, 0, 0, sampleSize, sampleSize);
98
- const imageData = ctx.getImageData(0, 0, sampleSize, sampleSize);
99
- const pixels = imageData.data;
100
- if (isTransparent(pixels, sampleSize)) {
101
- return null;
102
- }
103
- let r = 0;
104
- let g = 0;
105
- let b = 0;
106
- let totalWeight = 0;
107
- const cornerSize = Math.floor(sampleSize * 0.125);
108
- for (let y = 0; y < sampleSize; y++) {
109
- for (let x = 0; x < sampleSize; x++) {
110
- const isInTopLeft = x < cornerSize && y < cornerSize;
111
- const isInTopRight = x >= sampleSize - cornerSize && y < cornerSize;
112
- const isInBottomLeft = x < cornerSize && y >= sampleSize - cornerSize;
113
- const isInBottomRight = x >= sampleSize - cornerSize && y >= sampleSize - cornerSize;
114
- if (!isInTopLeft && !isInTopRight && !isInBottomLeft && !isInBottomRight) {
115
- continue;
116
- }
117
- const i = (y * sampleSize + x) * 4;
118
- const red = pixels[i];
119
- const green = pixels[i + 1];
120
- const blue = pixels[i + 2];
121
- const alpha = pixels[i + 3];
122
- if (alpha === 0) continue;
123
- const max = Math.max(red, green, blue);
124
- const min = Math.min(red, green, blue);
125
- const saturation = max === 0 ? 0 : (max - min) / max;
126
- const weight = 1 + saturation * 2;
127
- r += red * weight;
128
- g += green * weight;
129
- b += blue * weight;
130
- totalWeight += weight;
131
- }
132
- }
133
- if (totalWeight > 0) {
134
- r = Math.round(Math.round(r / totalWeight) * contrast);
135
- g = Math.round(Math.round(g / totalWeight) * contrast);
136
- b = Math.round(Math.round(b / totalWeight) * contrast);
137
- return [
138
- r,
139
- g,
140
- b
141
- ];
142
- }
143
- return null;
23
+ return visibleItems;
144
24
  };
145
- var isTransparent = (pixels, sampleSize, threshold = 0.5) => {
146
- let edgeTransparentPixels = 0;
147
- const edgePixels = sampleSize * 4 - 4;
148
- for (let x = 0; x < sampleSize; x++) {
149
- const topIndex = x * 4;
150
- if (pixels[topIndex + 3] === 0) edgeTransparentPixels++;
151
- const bottomIndex = ((sampleSize - 1) * sampleSize + x) * 4;
152
- if (pixels[bottomIndex + 3] === 0) edgeTransparentPixels++;
153
- }
154
- for (let y = 1; y < sampleSize - 1; y++) {
155
- const leftIndex = y * sampleSize * 4;
156
- if (pixels[leftIndex + 3] === 0) edgeTransparentPixels++;
157
- const rightIndex = (y * sampleSize + sampleSize - 1) * 4;
158
- if (pixels[rightIndex + 3] === 0) edgeTransparentPixels++;
25
+
26
+ // src/components/Focus/styles.ts
27
+ var styles = {
28
+ container: {
29
+ root: [
30
+ // TODO(burdon): Option for border/rounded; ring/outline vs border?
31
+ "outline-none border border-separator md:rounded-sm",
32
+ // Focus (e.g., via tabster).
33
+ "focus:!border-accentSurface",
34
+ // Active (e.g., drop target).
35
+ "data-[focus-state=active]:border-neutralFocusIndicator",
36
+ // Error
37
+ "data-[focus-state=error]:border-rose-500"
38
+ ]
159
39
  }
160
- return edgeTransparentPixels / edgePixels > threshold;
161
40
  };
162
41
 
163
- // src/components/Card/Card.tsx
42
+ // src/components/Focus/Focus.tsx
43
+ import { useArrowNavigationGroup, useFocusableGroup, useMergedTabsterAttributes_unstable } from "@fluentui/react-tabster";
44
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
45
+ import { Primitive } from "@radix-ui/react-primitive";
164
46
  import { Slot } from "@radix-ui/react-slot";
165
- import React2, { createContext, forwardRef, useContext } from "react";
166
- import { Button, DropdownMenu, Icon, Toolbar, useTranslation } from "@dxos/react-ui";
167
- import { mx as mx2 } from "@dxos/ui-theme";
168
-
169
- // src/translations.ts
170
- var translationKey = "@dxos/react-ui-mosaic";
171
- var translations = [
172
- {
173
- "en-US": {
174
- [translationKey]: {}
47
+ import React, { createContext, forwardRef, useContext, useRef, useState } from "react";
48
+ import { mx } from "@dxos/ui-theme";
49
+ var FOCUS_STATE_ATTR = "focus-state";
50
+ var FocusContext = /* @__PURE__ */ createContext({});
51
+ var useFocus = () => useContext(FocusContext);
52
+ var Group = /* @__PURE__ */ forwardRef(({ classNames, className, children, asChild, orientation = "vertical", ...props }, forwardedRef) => {
53
+ const rootRef = useRef(null);
54
+ const composedRef = useComposedRefs(rootRef, forwardedRef);
55
+ const Root2 = asChild ? Slot : Primitive.div;
56
+ const focusableGroupAttrs = useFocusableGroup({
57
+ tabBehavior: "limited-trap-focus"
58
+ });
59
+ const arrowNavigationAttrs = useArrowNavigationGroup({
60
+ axis: orientation,
61
+ memorizeCurrent: true
62
+ });
63
+ const tabsterAttrs = useMergedTabsterAttributes_unstable(focusableGroupAttrs, arrowNavigationAttrs);
64
+ const [state, setState] = useState();
65
+ return /* @__PURE__ */ React.createElement(FocusContext.Provider, {
66
+ value: {
67
+ setFocus: setState
175
68
  }
176
- }
177
- ];
178
-
179
- // src/components/Card/Card.tsx
180
- var CardContext = /* @__PURE__ */ createContext({});
181
- var CardRoot = /* @__PURE__ */ forwardRef(({ children, classNames, className, id, asChild, role = "group", border = true, fullWidth, ...props }, forwardedRef) => {
182
- const Root2 = asChild ? Slot : "div";
183
- return /* @__PURE__ */ React2.createElement(Root2, {
184
- ...id && {
185
- "data-object-id": id
69
+ }, /* @__PURE__ */ React.createElement(Root2, {
70
+ tabIndex: 0,
71
+ className: mx(styles.container.root, className, classNames),
72
+ ...tabsterAttrs,
73
+ ...state && {
74
+ [`data-${FOCUS_STATE_ATTR}`]: state
186
75
  },
187
76
  ...props,
188
- role,
189
- className: mx2(styles.root, border && styles.border, fullWidth && "!max-is-none", className, classNames),
190
- ref: forwardedRef
191
- }, children);
77
+ ref: composedRef
78
+ }, children));
192
79
  });
193
- var CardToolbar = /* @__PURE__ */ forwardRef(({ children, classNames, density = "fine", ...props }, forwardedRef) => {
194
- return /* @__PURE__ */ React2.createElement(Toolbar.Root, {
195
- ...props,
196
- classNames: [
197
- "density-fine bg-transparent",
198
- density === "fine" ? styles.grid_3 : styles.grid_3_coarse,
199
- classNames
200
- ],
201
- ref: forwardedRef
202
- }, children);
203
- });
204
- var CardToolbarIconButton = Toolbar.IconButton;
205
- var CardToolbarSeparator = Toolbar.Separator;
206
- var CardDragHandle = /* @__PURE__ */ forwardRef((_, forwardedRef) => {
207
- const { t } = useTranslation(translationKey);
208
- return /* @__PURE__ */ React2.createElement(Toolbar.IconButton, {
209
- "data-testid": "card-drag-handle",
210
- noTooltip: true,
211
- iconOnly: true,
212
- icon: "ph--dots-six-vertical--regular",
213
- variant: "ghost",
214
- label: t("drag handle label"),
215
- classNames: "cursor-pointer",
216
- size: 5,
217
- disabled: !forwardedRef,
218
- ref: forwardedRef
219
- });
220
- });
221
- var CardClose = /* @__PURE__ */ forwardRef(({ onClick }, forwardedRef) => {
222
- const { t } = useTranslation(translationKey);
223
- return /* @__PURE__ */ React2.createElement(Toolbar.IconButton, {
224
- iconOnly: true,
225
- icon: "ph--x--regular",
226
- variant: "ghost",
227
- label: t("card close label"),
228
- classNames: "cursor-pointer",
229
- size: 5,
230
- onClick,
231
- ref: forwardedRef
232
- });
233
- });
234
- var CardMenu = ({ context, items }) => {
235
- const { t } = useTranslation(translationKey);
236
- const { menuItems } = useContext(CardContext) ?? {};
237
- const combinedItems = [
238
- ...items ?? [],
239
- ...menuItems ?? []
240
- ];
241
- return /* @__PURE__ */ React2.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Trigger, {
242
- disabled: !combinedItems.length,
243
- asChild: true
244
- }, /* @__PURE__ */ React2.createElement(Card.ToolbarIconButton, {
245
- iconOnly: true,
246
- variant: "ghost",
247
- icon: "ph--dots-three-vertical--regular",
248
- label: t("action menu label")
249
- })), (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, {
250
- key: i,
251
- onSelect: () => onSelect(context)
252
- }, label))), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null))));
253
- };
254
- var CardTitle = /* @__PURE__ */ forwardRef(({ children, classNames, className, asChild, role = "heading", ...props }, forwardedRef) => {
255
- const Root2 = asChild ? Slot : "div";
256
- return /* @__PURE__ */ React2.createElement(Root2, {
257
- ...props,
258
- role,
259
- className: mx2("grow truncate", classNames, className),
260
- ref: forwardedRef
261
- }, children);
262
- });
263
- var CardContent = /* @__PURE__ */ forwardRef(({ children, ...props }, forwardedRef) => {
264
- return /* @__PURE__ */ React2.createElement("div", {
265
- role: "none",
266
- className: "contents [&>:last-child]:pbe-1",
267
- ...props,
268
- ref: forwardedRef
269
- }, children);
270
- });
271
- var CardRow = /* @__PURE__ */ forwardRef(({ children, classNames, className, role = "none", icon, ...props }, forwardedRef) => {
272
- return /* @__PURE__ */ React2.createElement("div", {
273
- ...props,
274
- role,
275
- className: mx2(styles.grid_2, "pli-1", classNames, className),
276
- ref: forwardedRef
277
- }, icon && /* @__PURE__ */ React2.createElement(CardIcon, {
278
- classNames: "text-subdued",
279
- icon
280
- }) || /* @__PURE__ */ React2.createElement("div", null), children);
281
- });
282
- var CardHeading = /* @__PURE__ */ forwardRef(({ children, classNames, className, asChild, role = "heading", variant = "default", ...props }, forwardedRef) => {
283
- const Root2 = asChild ? Slot : "div";
284
- const variantClassNames = {
285
- default: "plb-1",
286
- subtitle: "plb-2 text-xs text-description font-medium uppercase"
287
- };
288
- return /* @__PURE__ */ React2.createElement(Root2, {
289
- ...props,
290
- role,
291
- className: mx2(variantClassNames[variant], classNames, className),
292
- ref: forwardedRef
293
- }, children);
294
- });
295
- var CardText = /* @__PURE__ */ forwardRef(({ children, classNames, className, asChild, role = "none", truncate, variant = "default", ...props }, forwardedRef) => {
296
- const Root2 = asChild ? Slot : "div";
297
- const variantClassNames = {
298
- default: {
299
- root: "plb-1"
300
- },
301
- description: {
302
- root: "plb-1.5",
303
- span: "text-sm text-description line-clamp-3"
304
- }
305
- };
306
- return /* @__PURE__ */ React2.createElement(Root2, {
307
- ...props,
308
- role,
309
- className: mx2("flex overflow-hidden", variantClassNames[variant].root, classNames, className),
310
- ref: forwardedRef
311
- }, /* @__PURE__ */ React2.createElement("span", {
312
- className: mx2(variantClassNames[variant].span, truncate && "truncate")
313
- }, children));
314
- });
315
- var CardPoster = (props) => {
316
- const aspect = props.aspect === "auto" ? "aspect-auto" : "aspect-video";
317
- if (props.image) {
318
- return /* @__PURE__ */ React2.createElement("div", {
319
- role: "none",
320
- className: "mbe-1"
321
- }, /* @__PURE__ */ React2.createElement(Image, {
322
- classNames: [
323
- styles.poster,
324
- aspect,
325
- props.classNames
326
- ],
327
- src: props.image,
328
- alt: props.alt
329
- }));
330
- }
331
- if (props.icon) {
332
- return /* @__PURE__ */ React2.createElement("div", {
333
- role: "image",
334
- className: mx2("grid place-items-center bg-inputSurface text-subdued", styles.poster, aspect, props.classNames),
335
- "aria-label": props.alt
336
- }, /* @__PURE__ */ React2.createElement(Icon, {
337
- icon: props.icon,
338
- size: 10
339
- }));
340
- }
341
- };
342
- var CardAction = ({ icon, actionIcon = "ph--arrow-right--regular", label, onClick }) => {
343
- return /* @__PURE__ */ React2.createElement("div", {
344
- role: "none",
345
- className: "is-full pli-1"
346
- }, /* @__PURE__ */ React2.createElement(Button, {
347
- variant: "ghost",
348
- classNames: mx2(styles.grid_3, "!p-0 is-full text-start overflow-hidden"),
349
- onClick
350
- }, icon ? /* @__PURE__ */ React2.createElement(CardIcon, {
351
- classNames: "text-subdued",
352
- icon
353
- }) : /* @__PURE__ */ React2.createElement("div", null), /* @__PURE__ */ React2.createElement("span", {
354
- className: mx2("min-is-0 flex-1 truncate", !actionIcon && "col-span-2")
355
- }, label), actionIcon && /* @__PURE__ */ React2.createElement(CardIcon, {
356
- icon: actionIcon
357
- })));
358
- };
359
- var CardLink = ({ label, href }) => {
360
- return /* @__PURE__ */ React2.createElement("div", {
361
- role: "none",
362
- className: "is-full pli-1"
363
- }, /* @__PURE__ */ React2.createElement("a", {
364
- className: mx2(styles.grid_3, "group !p-0 dx-button dx-focus-ring !min-bs-1"),
365
- "data-variant": "ghost",
366
- href,
367
- target: "_blank",
368
- rel: "noreferrer"
369
- }, /* @__PURE__ */ React2.createElement(CardIcon, {
370
- classNames: "text-subdued",
371
- icon: "ph--link--regular"
372
- }), /* @__PURE__ */ React2.createElement("span", {
373
- className: mx2("min-is-0 flex-1 truncate")
374
- }, label), /* @__PURE__ */ React2.createElement(CardIcon, {
375
- classNames: "invisible group-hover:visible",
376
- icon: "ph--arrow-square-out--regular"
377
- })));
378
- };
379
- var CardIconBlock = ({ classNames, children, role = "none", ...props }) => {
380
- return /* @__PURE__ */ React2.createElement("div", {
381
- ...props,
382
- role,
383
- className: mx2("grid bs-[var(--rail-item)] is-[var(--rail-item)] place-items-center", classNames)
384
- }, children);
385
- };
386
- var CardIcon = ({ toolbar, ...props }) => {
387
- return /* @__PURE__ */ React2.createElement(CardIconBlock, null, /* @__PURE__ */ React2.createElement(Icon, {
388
- ...props,
389
- size: toolbar ? 5 : 4
390
- }));
391
- };
392
- var Card = {
393
- Context: CardContext,
394
- Root: CardRoot,
395
- // Toolbar
396
- Toolbar: CardToolbar,
397
- ToolbarIconButton: CardToolbarIconButton,
398
- ToolbarSeparator: CardToolbarSeparator,
399
- DragHandle: CardDragHandle,
400
- Title: CardTitle,
401
- Close: CardClose,
402
- Menu: CardMenu,
403
- Icon: CardIcon,
404
- IconBlock: CardIconBlock,
405
- // Content
406
- Content: CardContent,
407
- Row: CardRow,
408
- Heading: CardHeading,
409
- Text: CardText,
410
- Poster: CardPoster,
411
- Action: CardAction,
412
- Link: CardLink
413
- };
414
-
415
- // src/components/Focus/styles.ts
416
- var styles2 = {
417
- container: {
418
- // TODO(burdon): Handle selection (aria-current?)
419
- // TODO(burdon): Use ring instead of border?
420
- root: [
421
- "outline-none border border-separator rounded-sm",
422
- // Focus (e.g., via tabster).
423
- // TODO(burdon): Why is ! required?
424
- "focus:!border-accentSurface",
425
- // Active (e.g., drop target).
426
- "data-[focus-state=active]:border-neutralFocusIndicator",
427
- // Error
428
- // TODO(burdon): Error token.
429
- "data-[focus-state=error]:border-rose-500"
430
- ]
431
- }
432
- };
433
-
434
- // src/components/Focus/Focus.tsx
435
- import { useArrowNavigationGroup, useFocusableGroup, useMergedTabsterAttributes_unstable } from "@fluentui/react-tabster";
436
- import { useComposedRefs } from "@radix-ui/react-compose-refs";
437
- import { Primitive } from "@radix-ui/react-primitive";
438
- import { Slot as Slot2 } from "@radix-ui/react-slot";
439
- import React3, { createContext as createContext2, forwardRef as forwardRef2, useContext as useContext2, useRef as useRef2, useState as useState2 } from "react";
440
- import { mx as mx3 } from "@dxos/ui-theme";
441
- var FOCUS_STATE_ATTR = "focus-state";
442
- var FocusContext = /* @__PURE__ */ createContext2({});
443
- var useFocus = () => useContext2(FocusContext);
444
- var Group = /* @__PURE__ */ forwardRef2(({ classNames, className, children, asChild, axis = "vertical", ...props }, forwardedRef) => {
445
- const rootRef = useRef2(null);
446
- const composedRef = useComposedRefs(rootRef, forwardedRef);
447
- const Root2 = asChild ? Slot2 : Primitive.div;
448
- const focusableGroupAttrs = useFocusableGroup({
449
- tabBehavior: "limited-trap-focus"
450
- });
451
- const arrowNavigationAttrs = useArrowNavigationGroup({
452
- axis,
453
- memorizeCurrent: true
454
- });
455
- const tabsterAttrs = useMergedTabsterAttributes_unstable(focusableGroupAttrs, arrowNavigationAttrs);
456
- const [state, setState] = useState2();
457
- return /* @__PURE__ */ React3.createElement(FocusContext.Provider, {
458
- value: {
459
- setFocus: setState
460
- }
461
- }, /* @__PURE__ */ React3.createElement(Root2, {
462
- tabIndex: 0,
463
- className: mx3(styles2.container.root, className, classNames),
464
- ...tabsterAttrs,
465
- ...state && {
466
- [`data-${FOCUS_STATE_ATTR}`]: state
467
- },
468
- ...props,
469
- ref: composedRef
470
- }, children));
471
- });
472
- var Focus = {
473
- Group
474
- };
475
-
476
- // src/components/Mosaic/styles.ts
477
- var styles3 = {
478
- placeholder: {
479
- root: [
480
- "group opacity-0",
481
- 'group-data-[mosaic-debug="true"]:opacity-100',
482
- 'group-data-[mosaic-debug="true"]:bg-orange-500',
483
- "data-[mosaic-placeholder-state=active]:opacity-100",
484
- "data-[mosaic-placeholder-axis=vertical]:plb-1",
485
- "data-[mosaic-placeholder-axis=vertical]:data-[mosaic-placeholder-state=active]:plb-2.5",
486
- "data-[mosaic-placeholder-axis=horizontal]:pli-1",
487
- "data-[mosaic-placeholder-axis=horizontal]:data-[mosaic-placeholder-state=active]:pli-2.5"
80
+ var Focus = {
81
+ Group
82
+ };
83
+
84
+ // src/components/Mosaic/styles.ts
85
+ var styles2 = {
86
+ placeholder: {
87
+ root: [
88
+ "group opacity-0",
89
+ 'group-data-[mosaic-debug="true"]:opacity-100',
90
+ 'group-data-[mosaic-debug="true"]:bg-orange-500',
91
+ "data-[mosaic-placeholder-state=active]:opacity-100",
92
+ "data-[mosaic-placeholder-orientation=vertical]:snap-start",
93
+ "data-[mosaic-placeholder-orientation=vertical]:plb-1",
94
+ "data-[mosaic-placeholder-orientation=vertical]:data-[mosaic-placeholder-state=active]:plb-2.5",
95
+ "data-[mosaic-placeholder-orientation=horizontal]:pli-1",
96
+ "data-[mosaic-placeholder-orientation=horizontal]:data-[mosaic-placeholder-state=active]:pli-2.5"
488
97
  ],
489
98
  content: [
490
99
  "transition-all duration-0",
@@ -492,10 +101,10 @@ var styles3 = {
492
101
  // TODO(burdon): Flickers when start to drag since source is removed and then the placeholder shows up.
493
102
  // - Use absolute positioning?
494
103
  // 'group-data-[mosaic-placeholder-state=active]:duration-200',
495
- "group-data-[mosaic-placeholder-axis=vertical]:bs-0",
496
- "group-data-[mosaic-placeholder-axis=horizontal]:is-0",
497
- "group-data-[mosaic-placeholder-axis=vertical]:group-data-[mosaic-placeholder-state=active]:bs-[var(--mosaic-placeholder-height)]",
498
- "group-data-[mosaic-placeholder-axis=horizontal]:group-data-[mosaic-placeholder-state=active]:is-[var(--mosaic-placeholder-width)]"
104
+ "group-data-[mosaic-placeholder-orientation=vertical]:bs-0",
105
+ "group-data-[mosaic-placeholder-orientation=vertical]:group-data-[mosaic-placeholder-state=active]:bs-[var(--mosaic-placeholder-height)]",
106
+ "group-data-[mosaic-placeholder-orientation=horizontal]:is-0",
107
+ "group-data-[mosaic-placeholder-orientation=horizontal]:group-data-[mosaic-placeholder-state=active]:is-[var(--mosaic-placeholder-width)]"
499
108
  ]
500
109
  }
501
110
  };
@@ -626,11 +235,11 @@ var dropField = StateField.define({
626
235
  provide: (field) => EditorView.decorations.from(field)
627
236
  });
628
237
 
629
- // src/hooks/useContainerDebug.tsx
630
- import React7, { forwardRef as forwardRef6, useMemo as useMemo5, useRef as useRef5 } from "react";
631
- import { createPortal as createPortal2 } from "react-dom";
632
- import { Json } from "@dxos/react-ui-syntax-highlighter";
633
- import { mx as mx7 } from "@dxos/ui-theme";
238
+ // src/components/Stack/Stack.tsx
239
+ import { useVirtualizer } from "@tanstack/react-virtual";
240
+ import React5, { Fragment, forwardRef as forwardRef4 } from "react";
241
+ import { invariant } from "@dxos/invariant";
242
+ import { mx as mx5 } from "@dxos/ui-theme";
634
243
 
635
244
  // src/components/Mosaic/Mosaic.tsx
636
245
  import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
@@ -641,360 +250,81 @@ import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-sc
641
250
  import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
642
251
  import { DropIndicator as NativeDropIndicator } from "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box";
643
252
  import { composeRefs, useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
644
- import { createContext as createContext3 } from "@radix-ui/react-context";
253
+ import { createContext as createContext2 } from "@radix-ui/react-context";
645
254
  import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
646
- import { Slot as Slot3 } from "@radix-ui/react-slot";
255
+ import { Slot as Slot2 } from "@radix-ui/react-slot";
647
256
  import { bind } from "bind-event-listener";
648
- import React6, { forwardRef as forwardRef5, useCallback as useCallback2, useEffect as useEffect2, useLayoutEffect, useMemo as useMemo4, useRef as useRef4, useState as useState3 } from "react";
257
+ import React2, { forwardRef as forwardRef2, useCallback, useEffect, useLayoutEffect, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
649
258
  import { createPortal } from "react-dom";
650
- import { log as log2 } from "@dxos/log";
651
- import { mx as mx6 } from "@dxos/ui-theme";
259
+ import { log } from "@dxos/log";
260
+ import { mx as mx2 } from "@dxos/ui-theme";
652
261
  import { isTruthy } from "@dxos/util";
653
-
654
- // src/components/Scrollable/Scrollable.tsx
655
- import { OverlayScrollbarsComponent } from "overlayscrollbars-react";
656
- import React4, { forwardRef as forwardRef3, useEffect, useImperativeHandle, useMemo, useRef as useRef3 } from "react";
657
- import { mx as mx4 } from "@dxos/ui-theme";
658
- import "overlayscrollbars/styles/overlayscrollbars.css";
659
- var defaultOptions = {
660
- scrollbars: {
661
- autoHide: "leave",
662
- autoHideDelay: 1e3,
663
- autoHideSuspend: true
664
- }
262
+ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Mosaic.tsx";
263
+ var getSourceData = (source) => {
264
+ return source.data.type === "tile" ? source.data : null;
665
265
  };
666
- var Scrollable = /* @__PURE__ */ forwardRef3(({ classNames, axis = "vertical", padding, options: optionsProp = defaultOptions, onScroll, viewportRef, ...props }, forwardedRef) => {
667
- const osRef = useRef3(null);
668
- const options = useMemo(() => {
669
- const options2 = {
670
- ...optionsProp
266
+ var [RootContextProvider, useRootContext] = createContext2("MosaicRoot");
267
+ var ROOT_NAME = "Mosaic.Root";
268
+ var ROOT_DEBUG_ATTR = "mosaic-debug";
269
+ var Root = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }, forwardedRef) => {
270
+ const rootRef = useRef2(null);
271
+ const composedRef = useComposedRefs2(rootRef, forwardedRef);
272
+ const Root2 = asChild ? Slot2 : Primitive2.div;
273
+ const [handlers, setHandlers] = useState2({});
274
+ const [dragging, setDragging] = useState2();
275
+ const getSourceHandler = useCallback((source) => {
276
+ const data = source.data;
277
+ return {
278
+ data,
279
+ handler: handlers[data.containerId]
671
280
  };
672
- if (axis) {
673
- options2.overflow = {
674
- x: axis === "horizontal" ? "scroll" : "hidden",
675
- y: axis === "vertical" ? "scroll" : "hidden"
676
- };
677
- }
678
- return options2;
679
281
  }, [
680
- axis,
681
- optionsProp
682
- ]);
683
- useImperativeHandle(forwardedRef, () => osRef.current?.getElement(), [
684
- osRef
282
+ handlers
685
283
  ]);
686
- useEffect(() => {
687
- const instance = osRef.current?.osInstance();
688
- if (viewportRef) {
689
- viewportRef(instance?.elements().viewport ?? null);
284
+ const getTargetHandler = useCallback((location) => {
285
+ for (const target of location.current.dropTargets) {
286
+ const data = target.data;
287
+ let containerId;
288
+ switch (data.type) {
289
+ case "tile":
290
+ case "placeholder":
291
+ containerId = data.containerId;
292
+ break;
293
+ case "container":
294
+ containerId = data.id;
295
+ break;
296
+ }
297
+ const handler = handlers[containerId];
298
+ if (handler) {
299
+ return {
300
+ data,
301
+ handler
302
+ };
303
+ }
690
304
  }
305
+ return {};
691
306
  }, [
692
- osRef,
693
- viewportRef
307
+ handlers
694
308
  ]);
695
- const events = useMemo(() => {
696
- if (!onScroll) {
697
- return null;
698
- }
699
- return {
700
- scroll: (_, event) => {
701
- onScroll(event);
702
- }
703
- };
704
- }, [
705
- onScroll
706
- ]);
707
- return /* @__PURE__ */ React4.createElement(OverlayScrollbarsComponent, {
708
- ...props,
709
- className: mx4(padding && (axis === "vertical" ? "pli-3" : "pbe-3"), classNames),
710
- options,
711
- events,
712
- ref: osRef
713
- });
714
- });
715
-
716
- // src/components/Stack/Stack.tsx
717
- import { useVirtualizer } from "@tanstack/react-virtual";
718
- import React5, { Fragment, forwardRef as forwardRef4 } from "react";
719
- import { invariant } from "@dxos/invariant";
720
- import { mx as mx5 } from "@dxos/ui-theme";
721
-
722
- // src/hooks/useEventHandlerAdapter.ts
723
- import { useMemo as useMemo2 } from "react";
724
- import { log } from "@dxos/log";
725
- import { arrayMove } from "@dxos/util";
726
- var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/hooks/useEventHandlerAdapter.ts";
727
- var useEventHandlerAdapter = ({ items, getId, get, make, onChange, ...props }) => {
728
- return useMemo2(() => ({
729
- ...props,
730
- onTake: ({ source }, cb) => {
731
- log.info("onTake", {
732
- source
733
- }, {
734
- F: __dxlog_file,
735
- L: 58,
736
- S: void 0,
737
- C: (f, a) => f(...a)
738
- });
739
- const mutate = (items2) => {
740
- const from = items2.findIndex((item) => getId(item) === source.id);
741
- if (from !== -1) {
742
- items2.splice(from, 1);
743
- }
744
- };
745
- if (onChange) {
746
- onChange(mutate);
747
- } else {
748
- mutate(items);
749
- }
750
- void cb(source.data);
751
- },
752
- onDrop: ({ source, target }) => {
753
- const to = target?.type === "tile" || target?.type === "placeholder" ? target.location : -1;
754
- log.info("onDrop", {
755
- source,
756
- target,
757
- to
758
- }, {
759
- F: __dxlog_file,
760
- L: 76,
761
- S: void 0,
762
- C: (f, a) => f(...a)
763
- });
764
- const mutate = (items2) => {
765
- const from = items2.findIndex((item) => getId(item) === source.id);
766
- if (to !== -1) {
767
- if (from !== -1) {
768
- arrayMove(items2, from, to);
769
- } else {
770
- items2.splice(to, 0, make(get(source.data)));
771
- }
772
- }
773
- };
774
- if (onChange) {
775
- onChange(mutate);
776
- } else {
777
- mutate(items);
778
- }
779
- }
780
- }), [
781
- items,
782
- onChange
783
- ]);
784
- };
785
-
786
- // src/hooks/useVisibleItems.ts
787
- import { useMemo as useMemo3 } from "react";
788
- var useVisibleItems = ({ id, items, dragging, getId }) => {
789
- const visibleItems = useMemo3(() => {
790
- if (!items || !dragging || id !== dragging.containerId) {
791
- return items ?? [];
792
- }
793
- const idx = items.findIndex((item) => getId(item) === dragging.id);
794
- if (idx === -1) {
795
- return items;
796
- }
797
- const visibleItems2 = items.slice();
798
- visibleItems2.splice(idx, 1);
799
- return visibleItems2;
800
- }, [
801
- id,
802
- items,
803
- dragging,
804
- getId
805
- ]);
806
- return visibleItems;
807
- };
808
-
809
- // src/components/Stack/Stack.tsx
810
- var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Stack/Stack.tsx";
811
- var StackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, role = "list", axis = "vertical", draggable: draggable2 = true, items, getId, Tile: Tile2, debug, ...props }, forwardedRef) => {
812
- invariant(Tile2, void 0, {
813
- F: __dxlog_file2,
814
- L: 44,
815
- S: void 0,
816
- A: [
817
- "Tile",
818
- ""
819
- ]
820
- });
821
- const { id, dragging } = useContainerContext(StackInner.displayName);
822
- const visibleItems = useVisibleItems({
823
- id,
824
- items,
825
- dragging: dragging?.source.data,
826
- getId
827
- });
828
- return /* @__PURE__ */ React5.createElement("div", {
829
- ...props,
830
- role,
831
- className: mx5("flex", axis === "horizontal" && "bs-full [&>*]:shrink-0", axis === "vertical" && "flex-col", classNames, className),
832
- ref: forwardedRef
833
- }, /* @__PURE__ */ React5.createElement(Placeholder, {
834
- axis,
835
- location: 0.5
836
- }), visibleItems?.map((item, index) => /* @__PURE__ */ React5.createElement(Fragment, {
837
- key: getId(item)
838
- }, /* @__PURE__ */ React5.createElement(Tile2, {
839
- id: getId(item),
840
- data: item,
841
- location: index + 1,
842
- draggable: draggable2,
843
- debug
844
- }), /* @__PURE__ */ React5.createElement(Placeholder, {
845
- axis,
846
- location: index + 1.5
847
- }))));
848
- });
849
- StackInner.displayName = "Stack";
850
- var Stack = StackInner;
851
- var VirtualStackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, role = "list", axis = "vertical", items, getId, Tile: Tile2, estimateSize, getScrollElement, overscan = 8, onChange, debug, ...props }, forwardedRef) => {
852
- invariant(Tile2, void 0, {
853
- F: __dxlog_file2,
854
- L: 106,
855
- S: void 0,
856
- A: [
857
- "Tile",
858
- ""
859
- ]
860
- });
861
- const { id, dragging } = useContainerContext(VirtualStackInner.displayName);
862
- const visibleItems = useVisibleItems({
863
- id,
864
- items,
865
- dragging: dragging?.source.data,
866
- getId
867
- });
868
- const virtualizer = useVirtualizer({
869
- count: visibleItems.length * 2 + 1,
870
- estimateSize,
871
- getScrollElement,
872
- overscan,
873
- onChange
874
- });
875
- const virtualItems = virtualizer.getVirtualItems();
876
- return /* @__PURE__ */ React5.createElement("div", {
877
- ...props,
878
- role,
879
- className: mx5("flex", axis === "horizontal" && "bs-full [&>*]:shrink-0", axis === "vertical" && "flex-col", classNames, className),
880
- style: {
881
- position: "relative",
882
- ...axis === "vertical" ? {
883
- width: "100%",
884
- height: virtualizer.getTotalSize()
885
- } : {
886
- width: virtualizer.getTotalSize(),
887
- height: "100%"
888
- }
889
- },
890
- ref: forwardedRef
891
- }, virtualItems.map((virtualItem) => {
892
- const data = visibleItems[Math.floor(virtualItem.index / 2)];
893
- return /* @__PURE__ */ React5.createElement("div", {
894
- key: virtualItem.key,
895
- "data-index": virtualItem.index,
896
- style: {
897
- position: "absolute",
898
- top: 0,
899
- left: 0,
900
- ...axis === "vertical" ? {
901
- width: "100%",
902
- transform: `translateY(${virtualItem.start}px)`
903
- } : {
904
- height: "100%",
905
- transform: `translateX(${virtualItem.start}px)`
906
- }
907
- },
908
- ref: virtualizer.measureElement
909
- }, virtualItem.index % 2 === 0 ? /* @__PURE__ */ React5.createElement(Placeholder, {
910
- axis,
911
- location: Math.floor(virtualItem.index / 2) + 0.5
912
- }) : /* @__PURE__ */ React5.createElement(Tile2, {
913
- id: getId(data),
914
- data,
915
- location: Math.floor(virtualItem.index / 2) + 1,
916
- debug
917
- }));
918
- }));
919
- });
920
- VirtualStackInner.displayName = "VirtualStackInner";
921
- var VirtualStack = VirtualStackInner;
922
- var Placeholder = (props) => {
923
- return /* @__PURE__ */ React5.createElement(Mosaic.Placeholder, {
924
- ...props,
925
- classNames: styles3.placeholder.root
926
- }, /* @__PURE__ */ React5.createElement("div", {
927
- className: mx5("flex bs-full bg-baseSurface border border-dashed border-separator rounded-sm", styles3.placeholder.content)
928
- }));
929
- };
930
- Placeholder.displayName = "Placeholder";
931
-
932
- // src/components/Mosaic/Mosaic.tsx
933
- var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Mosaic.tsx";
934
- var getSourceData = (source) => {
935
- return source.data.type === "tile" ? source.data : null;
936
- };
937
- var [RootContextProvider, useRootContext] = createContext3("MosaicRoot");
938
- var ROOT_DEBUG_ATTR = "mosaic-debug";
939
- var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }, forwardedRef) => {
940
- const rootRef = useRef4(null);
941
- const composedRef = useComposedRefs2(rootRef, forwardedRef);
942
- const Root2 = asChild ? Slot3 : Primitive2.div;
943
- const [handlers, setHandlers] = useState3({});
944
- const [dragging, setDragging] = useState3();
945
- const getSourceHandler = useCallback2((source) => {
946
- const data = source.data;
947
- return {
948
- data,
949
- handler: handlers[data.containerId]
950
- };
951
- }, [
952
- handlers
953
- ]);
954
- const getTargetHandler = useCallback2((location) => {
955
- for (const target of location.current.dropTargets) {
956
- const data = target.data;
957
- let containerId;
958
- switch (data.type) {
959
- case "tile":
960
- case "placeholder":
961
- containerId = data.containerId;
962
- break;
963
- case "container":
964
- containerId = data.id;
965
- break;
966
- }
967
- const handler = handlers[containerId];
968
- if (handler) {
969
- return {
970
- data,
971
- handler
972
- };
973
- }
974
- }
975
- return {};
976
- }, [
977
- handlers
978
- ]);
979
- useEffect2(() => {
980
- const handleChange = ({ source, location }) => {
981
- const { data: sourceData } = getSourceHandler(source);
982
- const { data: targetData, handler } = getTargetHandler(location);
983
- setDragging((dragging2) => {
984
- dragging2?.target?.handler?.onCancel?.();
985
- return {
986
- source: {
987
- data: sourceData,
988
- handler: handlers[sourceData.containerId],
989
- // TOOD(burdon): Check id matches.
990
- container: location.initial.dropTargets.find((target) => target.data.type === "container")?.element
991
- },
992
- target: targetData && {
993
- data: targetData,
994
- handler
995
- }
996
- };
997
- });
309
+ useEffect(() => {
310
+ const handleChange = ({ source, location }) => {
311
+ const { data: sourceData } = getSourceHandler(source);
312
+ const { data: targetData, handler } = getTargetHandler(location);
313
+ setDragging((dragging2) => {
314
+ dragging2?.target?.handler?.onCancel?.();
315
+ return {
316
+ source: {
317
+ data: sourceData,
318
+ handler: handlers[sourceData.containerId],
319
+ // TOOD(burdon): Check id matches.
320
+ container: location.initial.dropTargets.find((target) => target.data.type === "container")?.element
321
+ },
322
+ target: targetData && {
323
+ data: targetData,
324
+ handler
325
+ }
326
+ };
327
+ });
998
328
  };
999
329
  const handleCancel = () => {
1000
330
  setDragging((dragging2) => {
@@ -1013,12 +343,12 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1013
343
  * Dragging started within any container.
1014
344
  */
1015
345
  onDragStart: ({ source, location }) => {
1016
- log2("Root.onDragStart", {
346
+ log("Root.onDragStart", {
1017
347
  source: source.data,
1018
348
  location: location.current.dropTargets.map((target) => target.data)
1019
349
  }, {
1020
- F: __dxlog_file3,
1021
- L: 215,
350
+ F: __dxlog_file,
351
+ L: 219,
1022
352
  S: void 0,
1023
353
  C: (f, a) => f(...a)
1024
354
  });
@@ -1032,12 +362,12 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1032
362
  */
1033
363
  onDropTargetChange: ({ source, location }) => {
1034
364
  clearTimeout(noTargetTimeout);
1035
- log2("Root.onDropTargetChange", {
365
+ log("Root.onDropTargetChange", {
1036
366
  source: source.data,
1037
367
  location: location.current.dropTargets.map((target) => target.data)
1038
368
  }, {
1039
- F: __dxlog_file3,
1040
- L: 228,
369
+ F: __dxlog_file,
370
+ L: 232,
1041
371
  S: void 0,
1042
372
  C: (f, a) => f(...a)
1043
373
  });
@@ -1071,23 +401,23 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1071
401
  * Dragging ended.
1072
402
  */
1073
403
  onDrop: ({ source, location }) => {
1074
- log2.info("Root.onDrop", {
404
+ log.info("Root.onDrop", {
1075
405
  source: source.data,
1076
406
  location: location.current.dropTargets.map((target) => target.data)
1077
407
  }, {
1078
- F: __dxlog_file3,
1079
- L: 257,
408
+ F: __dxlog_file,
409
+ L: 261,
1080
410
  S: void 0,
1081
411
  C: (f, a) => f(...a)
1082
412
  });
1083
413
  const { data: sourceData, handler: sourceHandler } = getSourceHandler(source);
1084
414
  if (!sourceHandler) {
1085
- log2.warn("invalid source", {
415
+ log.warn("invalid source", {
1086
416
  source: sourceData,
1087
417
  handlers: Object.keys(handlers)
1088
418
  }, {
1089
- F: __dxlog_file3,
1090
- L: 265,
419
+ F: __dxlog_file,
420
+ L: 269,
1091
421
  S: void 0,
1092
422
  C: (f, a) => f(...a)
1093
423
  });
@@ -1095,22 +425,22 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1095
425
  }
1096
426
  try {
1097
427
  if (location.current.dropTargets.length === 0) {
1098
- log2.info("cancelled", void 0, {
1099
- F: __dxlog_file3,
1100
- L: 280,
428
+ log.info("cancelled", void 0, {
429
+ F: __dxlog_file,
430
+ L: 284,
1101
431
  S: void 0,
1102
432
  C: (f, a) => f(...a)
1103
433
  });
1104
434
  } else {
1105
435
  const { data: targetData, handler: targetHandler } = getTargetHandler(location);
1106
436
  if (!targetHandler) {
1107
- log2.warn("invalid target", {
437
+ log.warn("invalid target", {
1108
438
  source: sourceData,
1109
439
  location,
1110
440
  handlers: Object.keys(handlers)
1111
441
  }, {
1112
- F: __dxlog_file3,
1113
- L: 285,
442
+ F: __dxlog_file,
443
+ L: 289,
1114
444
  S: void 0,
1115
445
  C: (f, a) => f(...a)
1116
446
  });
@@ -1123,11 +453,11 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1123
453
  });
1124
454
  } else {
1125
455
  if (!sourceHandler.onTake) {
1126
- log2.warn("invalid source", {
456
+ log.warn("invalid source", {
1127
457
  source: sourceData
1128
458
  }, {
1129
- F: __dxlog_file3,
1130
- L: 301,
459
+ F: __dxlog_file,
460
+ L: 305,
1131
461
  S: void 0,
1132
462
  C: (f, a) => f(...a)
1133
463
  });
@@ -1157,7 +487,7 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1157
487
  getSourceHandler,
1158
488
  getTargetHandler
1159
489
  ]);
1160
- return /* @__PURE__ */ React6.createElement(RootContextProvider, {
490
+ return /* @__PURE__ */ React2.createElement(RootContextProvider, {
1161
491
  containers: handlers,
1162
492
  addContainer: (container) => setHandlers((containers) => ({
1163
493
  ...containers,
@@ -1170,34 +500,36 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1170
500
  };
1171
501
  }),
1172
502
  dragging
1173
- }, /* @__PURE__ */ React6.createElement(Root2, {
1174
- className: mx6("group overflow-hidden", classNames),
503
+ }, /* @__PURE__ */ React2.createElement(Root2, {
504
+ className: mx2("group", classNames),
1175
505
  [`data-${ROOT_DEBUG_ATTR}`]: debug,
1176
506
  ref: composedRef
1177
507
  }, children));
1178
508
  });
1179
- var [ContainerContextProvider, useContainerContext] = createContext3("MosaicContainer");
509
+ Root.displayName = ROOT_NAME;
510
+ var CONTAINER_NAME = "Mosaic.Container";
511
+ var [ContainerContextProvider, useContainerContext] = createContext2("MosaicContainer");
1180
512
  var CONTAINER_STATE_ATTR = "mosaic-container-state";
1181
513
  var CONTAINER_PLACEHOLDER_WIDTH = "--mosaic-placeholder-width";
1182
514
  var CONTAINER_PLACEHOLDER_HEIGHT = "--mosaic-placeholder-height";
1183
515
  var counter = 0;
1184
- var Container = /* @__PURE__ */ forwardRef5(({ className, classNames, children, eventHandler: eventHandlerProp, axis = "vertical", asChild, autoScroll: autoscrollElement, withFocus, debug, ...props }, forwardedRef) => {
1185
- const rootRef = useRef4(null);
516
+ var Container = /* @__PURE__ */ forwardRef2(({ className, classNames, children, eventHandler: eventHandlerProp, orientation = "vertical", asChild, autoScroll: autoscrollElement, withFocus, debug, ...props }, forwardedRef) => {
517
+ const rootRef = useRef2(null);
1186
518
  const composedRef = useComposedRefs2(rootRef, forwardedRef);
1187
- const Root2 = asChild ? Slot3 : Primitive2.div;
1188
- const eventHandler = useMemo4(() => eventHandlerProp ?? {
519
+ const Root2 = asChild ? Slot2 : Primitive2.div;
520
+ const eventHandler = useMemo2(() => eventHandlerProp ?? {
1189
521
  id: `mosaic-container-${counter++}`
1190
522
  }, [
1191
523
  eventHandlerProp
1192
524
  ]);
1193
- const { dragging } = useRootContext(Container.displayName);
1194
- const [state, setState] = useState3({
525
+ const { dragging } = useRootContext(CONTAINER_NAME);
526
+ const [state, setState] = useState2({
1195
527
  type: "idle"
1196
528
  });
1197
- const [activeLocation, setActiveLocation] = useState3();
1198
- const [scrolling, setScrolling] = useState3(false);
529
+ const [activeLocation, setActiveLocation] = useState2();
530
+ const [scrolling, setScrolling] = useState2(false);
1199
531
  const { setFocus } = useFocus();
1200
- useEffect2(() => {
532
+ useEffect(() => {
1201
533
  if (withFocus) {
1202
534
  setFocus?.(state.type === "active" ? "active" : void 0);
1203
535
  }
@@ -1207,19 +539,19 @@ var Container = /* @__PURE__ */ forwardRef5(({ className, classNames, children,
1207
539
  state
1208
540
  ]);
1209
541
  const { addContainer, removeContainer } = useRootContext(eventHandler.id);
1210
- useEffect2(() => {
542
+ useEffect(() => {
1211
543
  addContainer(eventHandler);
1212
544
  return () => removeContainer(eventHandler.id);
1213
545
  }, [
1214
546
  eventHandler
1215
547
  ]);
1216
- const data = useMemo4(() => ({
548
+ const data = useMemo2(() => ({
1217
549
  type: "container",
1218
550
  id: eventHandler.id
1219
551
  }), [
1220
552
  eventHandler.id
1221
553
  ]);
1222
- useEffect2(() => {
554
+ useEffect(() => {
1223
555
  if (!rootRef.current) {
1224
556
  return;
1225
557
  }
@@ -1312,7 +644,7 @@ var Container = /* @__PURE__ */ forwardRef5(({ className, classNames, children,
1312
644
  // canScroll: ({ element: _ }) => {
1313
645
  // return true;
1314
646
  // },
1315
- getAllowedAxis: () => axis,
647
+ getAllowedAxis: () => orientation,
1316
648
  getConfiguration: () => ({
1317
649
  maxScrollSpeed: "fast"
1318
650
  })
@@ -1330,17 +662,17 @@ var Container = /* @__PURE__ */ forwardRef5(({ className, classNames, children,
1330
662
  data,
1331
663
  autoscrollElement
1332
664
  ]);
1333
- return /* @__PURE__ */ React6.createElement(ContainerContextProvider, {
665
+ return /* @__PURE__ */ React2.createElement(ContainerContextProvider, {
1334
666
  id: eventHandler.id,
1335
667
  eventHandler,
1336
- axis,
668
+ orientation,
1337
669
  state,
1338
670
  dragging: state.type === "active" ? dragging : void 0,
1339
671
  scrolling,
1340
672
  activeLocation,
1341
673
  setActiveLocation
1342
- }, /* @__PURE__ */ React6.createElement(Root2, {
1343
- className: mx6("bs-full", className, classNames),
674
+ }, /* @__PURE__ */ React2.createElement(Root2, {
675
+ className: mx2("bs-full", className, classNames),
1344
676
  style: {
1345
677
  [CONTAINER_PLACEHOLDER_WIDTH]: state.type === "active" && state.bounds ? `${state.bounds.width}px` : "0px",
1346
678
  [CONTAINER_PLACEHOLDER_HEIGHT]: state.type === "active" && state.bounds ? `${state.bounds.height}px` : "0px"
@@ -1350,18 +682,19 @@ var Container = /* @__PURE__ */ forwardRef5(({ className, classNames, children,
1350
682
  ref: composedRef
1351
683
  }, children), debug?.());
1352
684
  });
1353
- Container.displayName = "MosaicContainer";
1354
- var [TileContextProvider, useTileContext] = createContext3("MosaicTile");
685
+ Container.displayName = CONTAINER_NAME;
686
+ var TILE_NAME = "Mosaic.Tile";
687
+ var [TileContextProvider, useTileContext] = createContext2("MosaicTile");
1355
688
  var TILE_STATE_ATTR = "mosaic-tile-state";
1356
- var Tile = /* @__PURE__ */ forwardRef5(({ className, classNames, children, asChild, dragHandle, allowedEdges: allowedEdgesProp, location, id, data: dataProp, debug: _ }, forwardedRef) => {
1357
- const rootRef = useRef4(null);
689
+ var Tile = /* @__PURE__ */ forwardRef2(({ className, classNames, children, asChild, dragHandle, allowedEdges: allowedEdgesProp, location, id, data: dataProp, debug: _ }, forwardedRef) => {
690
+ const rootRef = useRef2(null);
1358
691
  const composedRef = composeRefs(rootRef, forwardedRef);
1359
- const Root2 = asChild ? Slot3 : Primitive2.div;
1360
- const { id: containerId, eventHandler, axis, scrolling, setActiveLocation } = useContainerContext(Tile.displayName);
1361
- const [state, setState] = useState3({
692
+ const Root2 = asChild ? Slot2 : Primitive2.div;
693
+ const { id: containerId, eventHandler, orientation, scrolling, setActiveLocation } = useContainerContext(TILE_NAME);
694
+ const [state, setState] = useState2({
1362
695
  type: "idle"
1363
696
  });
1364
- const allowedEdges = useMemo4(() => allowedEdgesProp || (axis === "vertical" ? [
697
+ const allowedEdges = useMemo2(() => allowedEdgesProp || (orientation === "vertical" ? [
1365
698
  "top",
1366
699
  "bottom"
1367
700
  ] : [
@@ -1369,9 +702,9 @@ var Tile = /* @__PURE__ */ forwardRef5(({ className, classNames, children, asChi
1369
702
  "right"
1370
703
  ]), [
1371
704
  allowedEdgesProp,
1372
- axis
705
+ orientation
1373
706
  ]);
1374
- const data = useMemo4(() => ({
707
+ const data = useMemo2(() => ({
1375
708
  type: "tile",
1376
709
  id,
1377
710
  containerId,
@@ -1485,155 +818,663 @@ var Tile = /* @__PURE__ */ forwardRef5(({ className, classNames, children, asChi
1485
818
  allowedEdges,
1486
819
  setActiveLocation
1487
820
  ]);
1488
- return /* @__PURE__ */ React6.createElement(TileContextProvider, {
821
+ return /* @__PURE__ */ React2.createElement(TileContextProvider, {
1489
822
  state
1490
- }, /* @__PURE__ */ React6.createElement(Root2, {
823
+ }, /* @__PURE__ */ React2.createElement(Root2, {
1491
824
  [`data-${TILE_STATE_ATTR}`]: state.type,
1492
825
  role: "listitem",
1493
- className: mx6("relative", className, classNames),
826
+ className: mx2("relative", className, classNames),
1494
827
  ref: composedRef
1495
- }, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(Root2, {
828
+ }, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */ React2.createElement(Root2, {
1496
829
  // NOTE: Use to control appearance while dragging.
1497
830
  [`data-${TILE_STATE_ATTR}`]: state.type,
1498
831
  // TODO(burdon): Configure drop animation.
1499
- className: mx6("relative", className, classNames),
832
+ className: mx2("relative", className, classNames),
1500
833
  style: {
1501
834
  width: `${state.rect.width}px`,
1502
835
  height: `${state.rect.height}px`
1503
836
  }
1504
837
  }, children), state.container));
1505
838
  });
1506
- Tile.displayName = "MosaicTile";
1507
- var PLACEHOLDER_AXIS_ATTR = "mosaic-placeholder-axis";
1508
- var PLACEHOLDER_STATE_ATTR = "mosaic-placeholder-state";
1509
- var Placeholder2 = ({ classNames, children, asChild, axis = "vertical", location }) => {
1510
- const rootRef = useRef4(null);
1511
- const Root2 = asChild ? Slot3 : Primitive2.div;
1512
- const { id: containerId, eventHandler, scrolling, activeLocation, setActiveLocation } = useContainerContext(Placeholder2.displayName);
1513
- const data = useMemo4(() => ({
1514
- type: "placeholder",
1515
- containerId,
1516
- location
1517
- }), [
1518
- containerId,
1519
- location
1520
- ]);
1521
- useLayoutEffect(() => {
1522
- const root = rootRef.current;
1523
- if (!root || scrolling) {
1524
- return;
839
+ Tile.displayName = TILE_NAME;
840
+ var PLACEHOLDER_NAME = "Mosaic.Placeholder";
841
+ var PLACEHOLDER_ORIENTATION_ATTR = "mosaic-placeholder-orientation";
842
+ var PLACEHOLDER_STATE_ATTR = "mosaic-placeholder-state";
843
+ var Placeholder = ({ classNames, children, asChild, orientation = "vertical", location }) => {
844
+ const rootRef = useRef2(null);
845
+ const Root2 = asChild ? Slot2 : Primitive2.div;
846
+ const { id: containerId, eventHandler, scrolling, activeLocation, setActiveLocation } = useContainerContext(PLACEHOLDER_NAME);
847
+ const data = useMemo2(() => ({
848
+ type: "placeholder",
849
+ containerId,
850
+ location
851
+ }), [
852
+ containerId,
853
+ location
854
+ ]);
855
+ useLayoutEffect(() => {
856
+ const root = rootRef.current;
857
+ if (!root || scrolling) {
858
+ return;
859
+ }
860
+ return dropTargetForElements({
861
+ element: root,
862
+ getData: () => data,
863
+ canDrop: ({ source }) => {
864
+ const data2 = getSourceData(source);
865
+ return data2 && eventHandler.canDrop?.({
866
+ source: data2
867
+ }) || false;
868
+ },
869
+ onDragEnter: () => {
870
+ setActiveLocation(data.location);
871
+ },
872
+ onDragLeave: () => {
873
+ setActiveLocation(void 0);
874
+ },
875
+ onDrop: () => {
876
+ setActiveLocation(void 0);
877
+ }
878
+ });
879
+ }, [
880
+ rootRef,
881
+ data,
882
+ scrolling,
883
+ setActiveLocation
884
+ ]);
885
+ return /* @__PURE__ */ React2.createElement(Root2, {
886
+ [`data-${PLACEHOLDER_ORIENTATION_ATTR}`]: orientation,
887
+ [`data-${PLACEHOLDER_STATE_ATTR}`]: data.location === activeLocation ? "active" : "idle",
888
+ role: "none",
889
+ className: mx2("relative", classNames),
890
+ ref: rootRef
891
+ }, children);
892
+ };
893
+ Placeholder.displayName = PLACEHOLDER_NAME;
894
+ var DROP_INDICATOR_NAME = "Mosaic.DropIndicator";
895
+ var DropIndicator = (props) => {
896
+ const { state } = useTileContext(DROP_INDICATOR_NAME);
897
+ return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React2.createElement(NativeDropIndicator, {
898
+ ...props,
899
+ edge: state.closestEdge
900
+ }) : null;
901
+ };
902
+ DropIndicator.displayName = DROP_INDICATOR_NAME;
903
+ var Mosaic = {
904
+ Root,
905
+ Container,
906
+ Tile,
907
+ Placeholder,
908
+ DropIndicator,
909
+ Stack,
910
+ VirtualStack
911
+ };
912
+
913
+ // src/translations.ts
914
+ var translationKey = "@dxos/react-ui-mosaic";
915
+ var translations = [
916
+ {
917
+ "en-US": {
918
+ [translationKey]: {
919
+ "add item label": "Add item",
920
+ "delete menu label": "Delete"
921
+ }
922
+ }
923
+ }
924
+ ];
925
+
926
+ // src/components/Card/styles.ts
927
+ var styles3 = {
928
+ root: "group/card relative min-bs-[--rail-item] is-full card-min-width overflow-hidden",
929
+ border: "bg-cardSurface border border-separator dark:border-subduedSeparator rounded-sm dx-focus-ring-group-y-indicator",
930
+ /**
931
+ * Row grid.
932
+ * NOTE: Rows should provide their own line padding (since they may need to encapsulate buttons, etc.)
933
+ */
934
+ grid_3: "grid grid-cols-[var(--rail-item)_minmax(0,1fr)_var(--rail-item)] gap-x-1",
935
+ grid_2: "grid grid-cols-[var(--rail-item)_minmax(0,1fr)] gap-x-1",
936
+ // TODO(burdon): Address density.
937
+ grid_3_coarse: "grid grid-cols-[var(--l0-avatar-size)_minmax(0,1fr)_var(--rail-item)] gap-x-1",
938
+ poster: "max-bs-[200px]"
939
+ };
940
+
941
+ // src/components/Card/Card.tsx
942
+ import { Slot as Slot3 } from "@radix-ui/react-slot";
943
+ import React4, { createContext as createContext3, forwardRef as forwardRef3, useContext as useContext2 } from "react";
944
+ import { Button, DropdownMenu, Icon, Toolbar, useTranslation } from "@dxos/react-ui";
945
+ import { mx as mx4 } from "@dxos/ui-theme";
946
+
947
+ // src/components/Image/Image.tsx
948
+ import React3, { useCallback as useCallback2, useRef as useRef3, useState as useState3 } from "react";
949
+ import { mx as mx3 } from "@dxos/ui-theme";
950
+ var cache = /* @__PURE__ */ new Map();
951
+ var Image = ({ classNames, src, alt = "", crossOrigin = "anonymous", sampleSize = 64, contrast = 0.9 }) => {
952
+ const [crossOriginState, setCrossOriginState] = useState3(crossOrigin);
953
+ const [dominantColor, setDominantColor] = useState3(void 0);
954
+ const [imageLoaded, setImageLoaded] = useState3(false);
955
+ const canvasRef = useRef3(null);
956
+ const handleImageError = () => {
957
+ setCrossOriginState(void 0);
958
+ };
959
+ const handleImageLoad = useCallback2(({ target }) => {
960
+ const rgb = cache.get(src);
961
+ if (rgb) {
962
+ setDominantColor(rgb);
963
+ setImageLoaded(true);
964
+ return;
965
+ }
966
+ const img = target;
967
+ if (!canvasRef.current) {
968
+ return;
969
+ }
970
+ try {
971
+ const color = extractDominantColor(canvasRef.current, img, {
972
+ sampleSize,
973
+ contrast
974
+ });
975
+ if (color) {
976
+ const rgb2 = `rgb(${color[0]}, ${color[1]}, ${color[2]})`;
977
+ cache.set(src, rgb2);
978
+ setDominantColor(rgb2);
979
+ }
980
+ } catch {
981
+ setCrossOriginState(void 0);
982
+ }
983
+ setImageLoaded(true);
984
+ }, [
985
+ sampleSize,
986
+ contrast,
987
+ src
988
+ ]);
989
+ return /* @__PURE__ */ React3.createElement("div", {
990
+ className: mx3(`relative flex is-full justify-center overflow-hidden transition-all duration-700`, classNames),
991
+ style: {
992
+ backgroundColor: dominantColor
993
+ }
994
+ }, /* @__PURE__ */ React3.createElement("canvas", {
995
+ ref: canvasRef,
996
+ style: {
997
+ display: "none"
998
+ },
999
+ "aria-hidden": "true"
1000
+ }), /* @__PURE__ */ React3.createElement("div", {
1001
+ className: "absolute inset-0 pointer-events-none",
1002
+ style: {
1003
+ background: dominantColor ? `radial-gradient(circle at center, transparent 30%, ${dominantColor} 100%)` : void 0,
1004
+ transition: "opacity 0.7s ease-in-out",
1005
+ opacity: 0.5
1006
+ }
1007
+ }), /* @__PURE__ */ React3.createElement("img", {
1008
+ src,
1009
+ alt,
1010
+ crossOrigin: crossOriginState,
1011
+ onError: handleImageError,
1012
+ onLoad: handleImageLoad,
1013
+ className: mx3("z-10 object-contain transition-opacity duration-500", classNames),
1014
+ style: {
1015
+ opacity: imageLoaded ? 1 : 0
1016
+ }
1017
+ }));
1018
+ };
1019
+ var extractDominantColor = (canvas, img, { sampleSize = 64, contrast = 0.95 }) => {
1020
+ const ctx = canvas.getContext("2d");
1021
+ if (!ctx) {
1022
+ return null;
1023
+ }
1024
+ canvas.width = sampleSize;
1025
+ canvas.height = sampleSize;
1026
+ ctx.drawImage(img, 0, 0, sampleSize, sampleSize);
1027
+ const imageData = ctx.getImageData(0, 0, sampleSize, sampleSize);
1028
+ const pixels = imageData.data;
1029
+ if (isTransparent(pixels, sampleSize)) {
1030
+ return null;
1031
+ }
1032
+ let r = 0;
1033
+ let g = 0;
1034
+ let b = 0;
1035
+ let totalWeight = 0;
1036
+ const cornerSize = Math.floor(sampleSize * 0.125);
1037
+ for (let y = 0; y < sampleSize; y++) {
1038
+ for (let x = 0; x < sampleSize; x++) {
1039
+ const isInTopLeft = x < cornerSize && y < cornerSize;
1040
+ const isInTopRight = x >= sampleSize - cornerSize && y < cornerSize;
1041
+ const isInBottomLeft = x < cornerSize && y >= sampleSize - cornerSize;
1042
+ const isInBottomRight = x >= sampleSize - cornerSize && y >= sampleSize - cornerSize;
1043
+ if (!isInTopLeft && !isInTopRight && !isInBottomLeft && !isInBottomRight) {
1044
+ continue;
1045
+ }
1046
+ const i = (y * sampleSize + x) * 4;
1047
+ const red = pixels[i];
1048
+ const green = pixels[i + 1];
1049
+ const blue = pixels[i + 2];
1050
+ const alpha = pixels[i + 3];
1051
+ if (alpha === 0) continue;
1052
+ const max = Math.max(red, green, blue);
1053
+ const min = Math.min(red, green, blue);
1054
+ const saturation = max === 0 ? 0 : (max - min) / max;
1055
+ const weight = 1 + saturation * 2;
1056
+ r += red * weight;
1057
+ g += green * weight;
1058
+ b += blue * weight;
1059
+ totalWeight += weight;
1060
+ }
1061
+ }
1062
+ if (totalWeight > 0) {
1063
+ r = Math.round(Math.round(r / totalWeight) * contrast);
1064
+ g = Math.round(Math.round(g / totalWeight) * contrast);
1065
+ b = Math.round(Math.round(b / totalWeight) * contrast);
1066
+ return [
1067
+ r,
1068
+ g,
1069
+ b
1070
+ ];
1071
+ }
1072
+ return null;
1073
+ };
1074
+ var isTransparent = (pixels, sampleSize, threshold = 0.5) => {
1075
+ let edgeTransparentPixels = 0;
1076
+ const edgePixels = sampleSize * 4 - 4;
1077
+ for (let x = 0; x < sampleSize; x++) {
1078
+ const topIndex = x * 4;
1079
+ if (pixels[topIndex + 3] === 0) edgeTransparentPixels++;
1080
+ const bottomIndex = ((sampleSize - 1) * sampleSize + x) * 4;
1081
+ if (pixels[bottomIndex + 3] === 0) edgeTransparentPixels++;
1082
+ }
1083
+ for (let y = 1; y < sampleSize - 1; y++) {
1084
+ const leftIndex = y * sampleSize * 4;
1085
+ if (pixels[leftIndex + 3] === 0) edgeTransparentPixels++;
1086
+ const rightIndex = (y * sampleSize + sampleSize - 1) * 4;
1087
+ if (pixels[rightIndex + 3] === 0) edgeTransparentPixels++;
1088
+ }
1089
+ return edgeTransparentPixels / edgePixels > threshold;
1090
+ };
1091
+
1092
+ // src/components/Card/Card.tsx
1093
+ var CardContext = /* @__PURE__ */ createContext3({});
1094
+ var CardRoot = /* @__PURE__ */ forwardRef3(({ children, classNames, className, id, asChild, role = "group", border = true, fullWidth, ...props }, forwardedRef) => {
1095
+ const Root2 = asChild ? Slot3 : "div";
1096
+ return /* @__PURE__ */ React4.createElement(Root2, {
1097
+ ...id && {
1098
+ "data-object-id": id
1099
+ },
1100
+ ...props,
1101
+ role,
1102
+ className: mx4(styles3.root, border && styles3.border, fullWidth && "!max-is-none", className, classNames),
1103
+ ref: forwardedRef
1104
+ }, children);
1105
+ });
1106
+ var CardToolbar = /* @__PURE__ */ forwardRef3(({ children, classNames, density = "fine", ...props }, forwardedRef) => {
1107
+ return /* @__PURE__ */ React4.createElement(Toolbar.Root, {
1108
+ ...props,
1109
+ classNames: [
1110
+ "density-fine bg-transparent",
1111
+ density === "fine" ? styles3.grid_3 : styles3.grid_3_coarse,
1112
+ classNames
1113
+ ],
1114
+ ref: forwardedRef
1115
+ }, children);
1116
+ });
1117
+ var CardToolbarIconButton = Toolbar.IconButton;
1118
+ var CardToolbarSeparator = Toolbar.Separator;
1119
+ var CardDragHandle = /* @__PURE__ */ forwardRef3((_, forwardedRef) => {
1120
+ const { t } = useTranslation(translationKey);
1121
+ return /* @__PURE__ */ React4.createElement(Toolbar.IconButton, {
1122
+ "data-testid": "card-drag-handle",
1123
+ noTooltip: true,
1124
+ iconOnly: true,
1125
+ icon: "ph--dots-six-vertical--regular",
1126
+ variant: "ghost",
1127
+ label: t("drag handle label"),
1128
+ classNames: "cursor-pointer",
1129
+ size: 5,
1130
+ disabled: !forwardedRef,
1131
+ ref: forwardedRef
1132
+ });
1133
+ });
1134
+ var CardClose = /* @__PURE__ */ forwardRef3(({ onClick }, forwardedRef) => {
1135
+ const { t } = useTranslation(translationKey);
1136
+ return /* @__PURE__ */ React4.createElement(Toolbar.IconButton, {
1137
+ iconOnly: true,
1138
+ icon: "ph--x--regular",
1139
+ variant: "ghost",
1140
+ label: t("card close label"),
1141
+ classNames: "cursor-pointer",
1142
+ size: 5,
1143
+ onClick,
1144
+ ref: forwardedRef
1145
+ });
1146
+ });
1147
+ var CardMenu = ({ context, items }) => {
1148
+ const { t } = useTranslation(translationKey);
1149
+ const { menuItems } = useContext2(CardContext) ?? {};
1150
+ const combinedItems = [
1151
+ ...items ?? [],
1152
+ ...menuItems ?? []
1153
+ ];
1154
+ return /* @__PURE__ */ React4.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Trigger, {
1155
+ disabled: !combinedItems.length,
1156
+ asChild: true
1157
+ }, /* @__PURE__ */ React4.createElement(Card.ToolbarIconButton, {
1158
+ iconOnly: true,
1159
+ variant: "ghost",
1160
+ icon: "ph--dots-three-vertical--regular",
1161
+ label: t("action menu label")
1162
+ })), (combinedItems?.length ?? 0) > 0 && /* @__PURE__ */ React4.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Viewport, null, combinedItems?.map(({ label, onClick: onSelect }, i) => /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
1163
+ key: i,
1164
+ onSelect: () => onSelect(context)
1165
+ }, label))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
1166
+ };
1167
+ var CardTitle = /* @__PURE__ */ forwardRef3(({ children, classNames, className, asChild, role = "heading", ...props }, forwardedRef) => {
1168
+ const Root2 = asChild ? Slot3 : "div";
1169
+ return /* @__PURE__ */ React4.createElement(Root2, {
1170
+ ...props,
1171
+ role,
1172
+ className: mx4("grow truncate", classNames, className),
1173
+ ref: forwardedRef
1174
+ }, children);
1175
+ });
1176
+ var CardContent = /* @__PURE__ */ forwardRef3(({ children, ...props }, forwardedRef) => {
1177
+ return /* @__PURE__ */ React4.createElement("div", {
1178
+ role: "none",
1179
+ className: "contents [&>:last-child]:pbe-1",
1180
+ ...props,
1181
+ ref: forwardedRef
1182
+ }, children);
1183
+ });
1184
+ var CardRow = /* @__PURE__ */ forwardRef3(({ children, classNames, className, role = "none", icon, ...props }, forwardedRef) => {
1185
+ return /* @__PURE__ */ React4.createElement("div", {
1186
+ ...props,
1187
+ role,
1188
+ className: mx4(styles3.grid_2, "pli-1", classNames, className),
1189
+ ref: forwardedRef
1190
+ }, icon && /* @__PURE__ */ React4.createElement(CardIcon, {
1191
+ classNames: "text-subdued",
1192
+ icon
1193
+ }) || /* @__PURE__ */ React4.createElement("div", null), children);
1194
+ });
1195
+ var CardHeading = /* @__PURE__ */ forwardRef3(({ children, classNames, className, asChild, role = "heading", variant = "default", ...props }, forwardedRef) => {
1196
+ const Root2 = asChild ? Slot3 : "div";
1197
+ const variantClassNames = {
1198
+ default: "plb-1",
1199
+ subtitle: "plb-2 text-xs text-description font-medium uppercase"
1200
+ };
1201
+ return /* @__PURE__ */ React4.createElement(Root2, {
1202
+ ...props,
1203
+ role,
1204
+ className: mx4(variantClassNames[variant], classNames, className),
1205
+ ref: forwardedRef
1206
+ }, children);
1207
+ });
1208
+ var CardText = /* @__PURE__ */ forwardRef3(({ children, classNames, className, asChild, role = "none", truncate, variant = "default", ...props }, forwardedRef) => {
1209
+ const Root2 = asChild ? Slot3 : "div";
1210
+ const variantClassNames = {
1211
+ default: {
1212
+ root: "plb-1"
1213
+ },
1214
+ description: {
1215
+ root: "plb-1.5",
1216
+ span: "text-sm text-description line-clamp-3"
1525
1217
  }
1526
- return dropTargetForElements({
1527
- element: root,
1528
- getData: () => data,
1529
- canDrop: ({ source }) => {
1530
- const data2 = getSourceData(source);
1531
- return data2 && eventHandler.canDrop?.({
1532
- source: data2
1533
- }) || false;
1534
- },
1535
- onDragEnter: () => {
1536
- setActiveLocation(data.location);
1537
- },
1538
- onDragLeave: () => {
1539
- setActiveLocation(void 0);
1540
- },
1541
- onDrop: () => {
1542
- setActiveLocation(void 0);
1543
- }
1544
- });
1545
- }, [
1546
- rootRef,
1547
- data,
1548
- scrolling,
1549
- setActiveLocation
1550
- ]);
1551
- return /* @__PURE__ */ React6.createElement(Root2, {
1552
- [`data-${PLACEHOLDER_AXIS_ATTR}`]: axis,
1553
- [`data-${PLACEHOLDER_STATE_ATTR}`]: data.location === activeLocation ? "active" : "idle",
1218
+ };
1219
+ return /* @__PURE__ */ React4.createElement(Root2, {
1220
+ ...props,
1221
+ role,
1222
+ className: mx4("flex overflow-hidden", variantClassNames[variant].root, classNames, className),
1223
+ ref: forwardedRef
1224
+ }, /* @__PURE__ */ React4.createElement("span", {
1225
+ className: mx4(variantClassNames[variant].span, truncate && "truncate")
1226
+ }, children));
1227
+ });
1228
+ var CardPoster = (props) => {
1229
+ const aspect = props.aspect === "auto" ? "aspect-auto" : "aspect-video";
1230
+ if (props.image) {
1231
+ return /* @__PURE__ */ React4.createElement("div", {
1232
+ role: "none",
1233
+ className: "mbe-1"
1234
+ }, /* @__PURE__ */ React4.createElement(Image, {
1235
+ classNames: [
1236
+ styles3.poster,
1237
+ aspect,
1238
+ props.classNames
1239
+ ],
1240
+ src: props.image,
1241
+ alt: props.alt
1242
+ }));
1243
+ }
1244
+ if (props.icon) {
1245
+ return /* @__PURE__ */ React4.createElement("div", {
1246
+ role: "image",
1247
+ className: mx4("grid place-items-center bg-inputSurface text-subdued", styles3.poster, aspect, props.classNames),
1248
+ "aria-label": props.alt
1249
+ }, /* @__PURE__ */ React4.createElement(Icon, {
1250
+ icon: props.icon,
1251
+ size: 10
1252
+ }));
1253
+ }
1254
+ };
1255
+ var CardAction = ({ icon, actionIcon = "ph--arrow-right--regular", label, onClick }) => {
1256
+ return /* @__PURE__ */ React4.createElement("div", {
1554
1257
  role: "none",
1555
- className: mx6("relative", classNames),
1556
- ref: rootRef
1258
+ className: "is-full pli-1"
1259
+ }, /* @__PURE__ */ React4.createElement(Button, {
1260
+ variant: "ghost",
1261
+ classNames: mx4(styles3.grid_3, "!p-0 is-full text-start overflow-hidden"),
1262
+ onClick
1263
+ }, icon ? /* @__PURE__ */ React4.createElement(CardIcon, {
1264
+ classNames: "text-subdued",
1265
+ icon
1266
+ }) : /* @__PURE__ */ React4.createElement("div", null), /* @__PURE__ */ React4.createElement("span", {
1267
+ className: mx4("min-is-0 flex-1 truncate", !actionIcon && "col-span-2")
1268
+ }, label), actionIcon && /* @__PURE__ */ React4.createElement(CardIcon, {
1269
+ icon: actionIcon
1270
+ })));
1271
+ };
1272
+ var CardLink = ({ label, href }) => {
1273
+ return /* @__PURE__ */ React4.createElement("div", {
1274
+ role: "none",
1275
+ className: "is-full pli-1"
1276
+ }, /* @__PURE__ */ React4.createElement("a", {
1277
+ className: mx4(styles3.grid_3, "group !p-0 dx-button dx-focus-ring !min-bs-1"),
1278
+ "data-variant": "ghost",
1279
+ href,
1280
+ target: "_blank",
1281
+ rel: "noreferrer"
1282
+ }, /* @__PURE__ */ React4.createElement(CardIcon, {
1283
+ classNames: "text-subdued",
1284
+ icon: "ph--link--regular"
1285
+ }), /* @__PURE__ */ React4.createElement("span", {
1286
+ className: mx4("min-is-0 flex-1 truncate")
1287
+ }, label), /* @__PURE__ */ React4.createElement(CardIcon, {
1288
+ classNames: "invisible group-hover:visible",
1289
+ icon: "ph--arrow-square-out--regular"
1290
+ })));
1291
+ };
1292
+ var CardIconBlock = ({ classNames, children, role = "none", ...props }) => {
1293
+ return /* @__PURE__ */ React4.createElement("div", {
1294
+ ...props,
1295
+ role,
1296
+ className: mx4("grid bs-[var(--rail-item)] is-[var(--rail-item)] place-items-center", classNames)
1557
1297
  }, children);
1558
1298
  };
1559
- Placeholder2.displayName = "MosaicPlaceholder";
1560
- var DropIndicator = (props) => {
1561
- const { state } = useTileContext(DropIndicator.displayName);
1562
- return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React6.createElement(NativeDropIndicator, {
1299
+ var CardIcon = ({ toolbar, ...props }) => {
1300
+ return /* @__PURE__ */ React4.createElement(CardIconBlock, null, /* @__PURE__ */ React4.createElement(Icon, {
1563
1301
  ...props,
1564
- edge: state.closestEdge
1565
- }) : null;
1302
+ size: toolbar ? 5 : 4
1303
+ }));
1566
1304
  };
1567
- DropIndicator.displayName = "MosaicDropIndicator";
1568
- var Mosaic = {
1569
- Root,
1570
- Container,
1571
- Tile,
1572
- Placeholder: Placeholder2,
1573
- DropIndicator,
1574
- // TODO(burdon): Move out of Mosaic namespace?
1575
- Viewport: Scrollable,
1576
- Stack,
1577
- VirtualStack
1305
+ var Card = {
1306
+ Context: CardContext,
1307
+ Root: CardRoot,
1308
+ // Toolbar
1309
+ Toolbar: CardToolbar,
1310
+ ToolbarIconButton: CardToolbarIconButton,
1311
+ ToolbarSeparator: CardToolbarSeparator,
1312
+ DragHandle: CardDragHandle,
1313
+ Title: CardTitle,
1314
+ Close: CardClose,
1315
+ Menu: CardMenu,
1316
+ Icon: CardIcon,
1317
+ IconBlock: CardIconBlock,
1318
+ // Content
1319
+ Content: CardContent,
1320
+ Row: CardRow,
1321
+ Heading: CardHeading,
1322
+ Text: CardText,
1323
+ Poster: CardPoster,
1324
+ Action: CardAction,
1325
+ Link: CardLink
1578
1326
  };
1579
1327
 
1580
- // src/hooks/useContainerDebug.tsx
1581
- var useContainerDebug = (debug) => {
1582
- const debugRef = useRef5(null);
1583
- return useMemo5(() => {
1584
- if (!debug) {
1585
- return [
1586
- () => null,
1587
- void 0
1588
- ];
1589
- }
1590
- return [
1591
- ({ classNames }) => /* @__PURE__ */ React7.createElement("div", {
1592
- role: "none",
1593
- className: mx7("overflow-hidden", classNames),
1594
- ref: debugRef
1595
- }),
1596
- () => debugRef.current && /* @__PURE__ */ createPortal2(/* @__PURE__ */ React7.createElement(ContainerInfo, null), debugRef.current)
1597
- ];
1598
- }, [
1599
- debug,
1600
- debugRef
1601
- ]);
1602
- };
1603
- var ContainerInfo = /* @__PURE__ */ forwardRef6(({ classNames }, forwardedRef) => {
1604
- const { id, state, activeLocation, scrolling } = useContainerContext(ContainerInfo.displayName);
1605
- const counter2 = useRef5(0);
1606
- return /* @__PURE__ */ React7.createElement(Json, {
1607
- data: {
1608
- id,
1609
- activeLocation,
1610
- scrolling,
1611
- state,
1612
- count: counter2.current++
1613
- },
1614
- classNames: mx7("text-xs", classNames),
1328
+ // src/components/Stack/Stack.tsx
1329
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Stack/Stack.tsx";
1330
+ var STACK_NAME = "Stack";
1331
+ var StackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, role = "list", orientation: orientationProp = "vertical", draggable: draggable2 = true, items, getId, Tile: Tile2, debug, ...props }, forwardedRef) => {
1332
+ invariant(Tile2, void 0, {
1333
+ F: __dxlog_file2,
1334
+ L: 50,
1335
+ S: void 0,
1336
+ A: [
1337
+ "Tile",
1338
+ ""
1339
+ ]
1340
+ });
1341
+ const { id, orientation = orientationProp, dragging } = useContainerContext(STACK_NAME);
1342
+ const visibleItems = useVisibleItems({
1343
+ id,
1344
+ items,
1345
+ dragging: dragging?.source.data,
1346
+ getId
1347
+ });
1348
+ invariant(orientation === "vertical" || orientation === "horizontal", `Invalid orientation: ${orientation}`, {
1349
+ F: __dxlog_file2,
1350
+ L: 53,
1351
+ S: void 0,
1352
+ A: [
1353
+ "orientation === 'vertical' || orientation === 'horizontal'",
1354
+ "`Invalid orientation: ${orientation}`"
1355
+ ]
1356
+ });
1357
+ return /* @__PURE__ */ React5.createElement("div", {
1358
+ ...props,
1359
+ role,
1360
+ className: mx5("flex", orientation === "horizontal" && "bs-full [&>*]:shrink-0", orientation === "vertical" && "flex-col", classNames, className),
1615
1361
  ref: forwardedRef
1362
+ }, /* @__PURE__ */ React5.createElement(Placeholder2, {
1363
+ orientation,
1364
+ location: 0.5
1365
+ }), visibleItems?.map((item, index) => /* @__PURE__ */ React5.createElement(Fragment, {
1366
+ key: getId(item)
1367
+ }, /* @__PURE__ */ React5.createElement(Tile2, {
1368
+ id: getId(item),
1369
+ data: item,
1370
+ location: index + 1,
1371
+ draggable: draggable2,
1372
+ debug
1373
+ }), /* @__PURE__ */ React5.createElement(Placeholder2, {
1374
+ orientation,
1375
+ location: index + 1.5
1376
+ }))));
1377
+ });
1378
+ StackInner.displayName = STACK_NAME;
1379
+ var Stack = StackInner;
1380
+ var VIRTUAL_STACK_NAME = "VirtualStackInner";
1381
+ var VirtualStackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, role = "list", orientation = "vertical", items, getId, Tile: Tile2, estimateSize, getScrollElement, overscan = 8, onChange, debug, ...props }, forwardedRef) => {
1382
+ invariant(Tile2, void 0, {
1383
+ F: __dxlog_file2,
1384
+ L: 115,
1385
+ S: void 0,
1386
+ A: [
1387
+ "Tile",
1388
+ ""
1389
+ ]
1390
+ });
1391
+ const { id, dragging } = useContainerContext(VIRTUAL_STACK_NAME);
1392
+ const visibleItems = useVisibleItems({
1393
+ id,
1394
+ items,
1395
+ dragging: dragging?.source.data,
1396
+ getId
1397
+ });
1398
+ const virtualizer = useVirtualizer({
1399
+ count: visibleItems.length * 2 + 1,
1400
+ estimateSize,
1401
+ getScrollElement,
1402
+ overscan,
1403
+ onChange
1616
1404
  });
1405
+ const virtualItems = virtualizer.getVirtualItems();
1406
+ return /* @__PURE__ */ React5.createElement("div", {
1407
+ ...props,
1408
+ role,
1409
+ className: mx5("flex", orientation === "horizontal" && "bs-full [&>*]:shrink-0", orientation === "vertical" && "flex-col", classNames, className),
1410
+ style: {
1411
+ position: "relative",
1412
+ ...orientation === "vertical" ? {
1413
+ width: "100%",
1414
+ height: virtualizer.getTotalSize()
1415
+ } : {
1416
+ width: virtualizer.getTotalSize(),
1417
+ height: "100%"
1418
+ }
1419
+ },
1420
+ ref: forwardedRef
1421
+ }, virtualItems.map((virtualItem) => {
1422
+ const data = visibleItems[Math.floor(virtualItem.index / 2)];
1423
+ return /* @__PURE__ */ React5.createElement("div", {
1424
+ key: virtualItem.key,
1425
+ "data-index": virtualItem.index,
1426
+ style: {
1427
+ position: "absolute",
1428
+ top: 0,
1429
+ left: 0,
1430
+ ...orientation === "vertical" ? {
1431
+ width: "100%",
1432
+ transform: `translateY(${virtualItem.start}px)`
1433
+ } : {
1434
+ height: "100%",
1435
+ transform: `translateX(${virtualItem.start}px)`
1436
+ }
1437
+ },
1438
+ ref: virtualizer.measureElement
1439
+ }, virtualItem.index % 2 === 0 ? /* @__PURE__ */ React5.createElement(Placeholder2, {
1440
+ orientation,
1441
+ location: Math.floor(virtualItem.index / 2) + 0.5
1442
+ }) : /* @__PURE__ */ React5.createElement(Tile2, {
1443
+ id: getId(data),
1444
+ data,
1445
+ location: Math.floor(virtualItem.index / 2) + 1,
1446
+ debug
1447
+ }));
1448
+ }));
1617
1449
  });
1618
- ContainerInfo.displayName = "ContainerInfo";
1450
+ VirtualStackInner.displayName = VIRTUAL_STACK_NAME;
1451
+ var VirtualStack = VirtualStackInner;
1452
+ var Placeholder2 = (props) => {
1453
+ return /* @__PURE__ */ React5.createElement(Mosaic.Placeholder, {
1454
+ ...props,
1455
+ classNames: styles2.placeholder.root
1456
+ }, /* @__PURE__ */ React5.createElement("div", {
1457
+ className: mx5("flex bs-full bg-baseSurface border border-dashed border-separator rounded-sm", styles2.placeholder.content)
1458
+ }));
1459
+ };
1460
+ Placeholder2.displayName = "Placeholder";
1619
1461
 
1620
1462
  export {
1463
+ useVisibleItems,
1621
1464
  styles,
1622
- Image,
1623
- Card,
1624
- styles2,
1625
1465
  useFocus,
1626
1466
  Focus,
1627
- styles3,
1467
+ styles2,
1628
1468
  dropHandler,
1629
- useContainerDebug,
1630
- useEventHandlerAdapter,
1631
- useVisibleItems,
1632
1469
  Stack,
1633
1470
  VirtualStack,
1634
1471
  useRootContext,
1635
1472
  useContainerContext,
1636
1473
  useTileContext,
1637
- Mosaic
1474
+ Mosaic,
1475
+ translationKey,
1476
+ styles3,
1477
+ Image,
1478
+ Card
1638
1479
  };
1639
- //# sourceMappingURL=chunk-X6GV7SMK.mjs.map
1480
+ //# sourceMappingURL=chunk-KTLFCRVA.mjs.map