@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.
Files changed (186) hide show
  1. package/dist/lib/browser/chunk-7S4PIFKU.mjs +953 -0
  2. package/dist/lib/browser/chunk-7S4PIFKU.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +596 -70
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/playwright/index.mjs +138 -0
  7. package/dist/lib/browser/playwright/index.mjs.map +7 -0
  8. package/dist/lib/browser/testing/index.mjs +61 -232
  9. package/dist/lib/browser/testing/index.mjs.map +4 -4
  10. package/dist/lib/node-esm/chunk-MK6KU66S.mjs +955 -0
  11. package/dist/lib/node-esm/chunk-MK6KU66S.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +596 -70
  13. package/dist/lib/node-esm/index.mjs.map +4 -4
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/playwright/index.mjs +140 -0
  16. package/dist/lib/node-esm/playwright/index.mjs.map +7 -0
  17. package/dist/lib/node-esm/testing/index.mjs +61 -232
  18. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  19. package/dist/types/src/components/Board/Board.d.ts +81 -0
  20. package/dist/types/src/components/Board/Board.d.ts.map +1 -0
  21. package/dist/types/src/components/{Mosaic/Mosaic.stories.d.ts → Board/Board.stories.d.ts} +15 -1
  22. package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -0
  23. package/dist/types/src/components/Board/Column.d.ts +40 -0
  24. package/dist/types/src/components/Board/Column.d.ts.map +1 -0
  25. package/dist/types/src/components/Board/Item.d.ts +9 -0
  26. package/dist/types/src/components/Board/Item.d.ts.map +1 -0
  27. package/dist/types/src/components/Board/index.d.ts +2 -0
  28. package/dist/types/src/components/Board/index.d.ts.map +1 -0
  29. package/dist/types/src/components/Focus/Focus.d.ts +5 -4
  30. package/dist/types/src/components/Focus/Focus.d.ts.map +1 -1
  31. package/dist/types/src/components/Focus/index.d.ts +0 -1
  32. package/dist/types/src/components/Focus/index.d.ts.map +1 -1
  33. package/dist/types/src/components/Mosaic/Container.d.ts +42 -0
  34. package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -0
  35. package/dist/types/src/components/Mosaic/Mosaic.d.ts +35 -118
  36. package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -1
  37. package/dist/types/src/components/Mosaic/Placeholder.d.ts +21 -0
  38. package/dist/types/src/components/Mosaic/Placeholder.d.ts.map +1 -0
  39. package/dist/types/src/components/Mosaic/Root.d.ts +36 -0
  40. package/dist/types/src/components/Mosaic/Root.d.ts.map +1 -0
  41. package/dist/types/src/components/Mosaic/Stack.d.ts +23 -0
  42. package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -0
  43. package/dist/types/src/components/{Stack → Mosaic}/Stack.stories.d.ts +2 -2
  44. package/dist/types/src/components/Mosaic/Stack.stories.d.ts.map +1 -0
  45. package/dist/types/src/components/Mosaic/Tile.d.ts +48 -0
  46. package/dist/types/src/components/Mosaic/Tile.d.ts.map +1 -0
  47. package/dist/types/src/components/Mosaic/styles.d.ts.map +1 -1
  48. package/dist/types/src/components/Mosaic/types.d.ts +9 -2
  49. package/dist/types/src/components/Mosaic/types.d.ts.map +1 -1
  50. package/dist/types/src/components/index.d.ts +1 -4
  51. package/dist/types/src/components/index.d.ts.map +1 -1
  52. package/dist/types/src/hooks/index.d.ts +1 -0
  53. package/dist/types/src/hooks/index.d.ts.map +1 -1
  54. package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts +15 -0
  55. package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts.map +1 -0
  56. package/dist/types/src/hooks/useEventHandlerAdapter.d.ts +1 -1
  57. package/dist/types/src/hooks/useEventHandlerAdapter.d.ts.map +1 -1
  58. package/dist/types/src/hooks/useVisibleItems.d.ts +2 -2
  59. package/dist/types/src/hooks/useVisibleItems.d.ts.map +1 -1
  60. package/dist/types/src/playwright/board-manager.d.ts +45 -0
  61. package/dist/types/src/playwright/board-manager.d.ts.map +1 -0
  62. package/dist/types/src/playwright/index.d.ts +9 -0
  63. package/dist/types/src/playwright/index.d.ts.map +1 -0
  64. package/dist/types/src/playwright/playwright.config.d.ts +3 -0
  65. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
  66. package/dist/types/src/playwright/smoke.spec.d.ts +2 -0
  67. package/dist/types/src/playwright/smoke.spec.d.ts.map +1 -0
  68. package/dist/types/src/testing/CardContainer.d.ts +5 -4
  69. package/dist/types/src/testing/CardContainer.d.ts.map +1 -1
  70. package/dist/types/src/testing/DefaultStackTile.d.ts +2 -2
  71. package/dist/types/src/testing/DefaultStackTile.d.ts.map +1 -1
  72. package/dist/types/src/testing/index.d.ts +1 -1
  73. package/dist/types/src/testing/index.d.ts.map +1 -1
  74. package/dist/types/src/testing/types.d.ts +21 -0
  75. package/dist/types/src/testing/types.d.ts.map +1 -0
  76. package/dist/types/src/translations.d.ts +5 -1
  77. package/dist/types/src/translations.d.ts.map +1 -1
  78. package/dist/types/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +43 -28
  80. package/src/components/Board/Board.stories.tsx +273 -0
  81. package/src/components/Board/Board.tsx +191 -0
  82. package/src/components/Board/Column.tsx +300 -0
  83. package/src/components/Board/Item.tsx +116 -0
  84. package/src/components/{Layout → Board}/index.ts +1 -1
  85. package/src/components/Focus/Focus.tsx +26 -17
  86. package/src/components/Focus/index.ts +0 -2
  87. package/src/components/Mosaic/Container.tsx +289 -0
  88. package/src/components/Mosaic/Mosaic.tsx +35 -913
  89. package/src/components/Mosaic/Placeholder.tsx +133 -0
  90. package/src/components/Mosaic/Root.tsx +292 -0
  91. package/src/components/{Stack → Mosaic}/Stack.stories.tsx +30 -26
  92. package/src/components/Mosaic/Stack.tsx +246 -0
  93. package/src/components/Mosaic/Tile.tsx +242 -0
  94. package/src/components/Mosaic/extension.ts +1 -1
  95. package/src/components/Mosaic/styles.ts +9 -8
  96. package/src/components/Mosaic/types.ts +15 -3
  97. package/src/components/index.ts +1 -4
  98. package/src/hooks/index.ts +1 -0
  99. package/src/hooks/useContainerDebug.tsx +4 -2
  100. package/src/hooks/useDefaultColumnEventHandler.ts +35 -0
  101. package/src/hooks/useEventHandlerAdapter.ts +15 -6
  102. package/src/hooks/useVisibleItems.ts +7 -2
  103. package/src/playwright/board-manager.ts +154 -0
  104. package/src/playwright/index.ts +13 -0
  105. package/src/playwright/playwright.config.ts +17 -0
  106. package/src/playwright/smoke.spec.ts +138 -0
  107. package/src/testing/CardContainer.tsx +30 -18
  108. package/src/testing/DefaultStackTile.tsx +27 -16
  109. package/src/testing/index.ts +1 -1
  110. package/src/testing/types.ts +38 -0
  111. package/src/translations.ts +5 -1
  112. package/dist/lib/browser/chunk-UMBPEG4F.mjs +0 -1637
  113. package/dist/lib/browser/chunk-UMBPEG4F.mjs.map +0 -7
  114. package/dist/lib/browser/index.css +0 -13
  115. package/dist/lib/browser/index.css.map +0 -7
  116. package/dist/lib/browser/testing/index.css +0 -13
  117. package/dist/lib/browser/testing/index.css.map +0 -7
  118. package/dist/lib/node-esm/chunk-X6GV7SMK.mjs +0 -1639
  119. package/dist/lib/node-esm/chunk-X6GV7SMK.mjs.map +0 -7
  120. package/dist/lib/node-esm/index.css +0 -13
  121. package/dist/lib/node-esm/index.css.map +0 -7
  122. package/dist/lib/node-esm/testing/index.css +0 -13
  123. package/dist/lib/node-esm/testing/index.css.map +0 -7
  124. package/dist/types/src/components/Card/Card.d.ts +0 -121
  125. package/dist/types/src/components/Card/Card.d.ts.map +0 -1
  126. package/dist/types/src/components/Card/Card.stories.d.ts +0 -21
  127. package/dist/types/src/components/Card/Card.stories.d.ts.map +0 -1
  128. package/dist/types/src/components/Card/CardDragPreview.d.ts +0 -6
  129. package/dist/types/src/components/Card/CardDragPreview.d.ts.map +0 -1
  130. package/dist/types/src/components/Card/index.d.ts +0 -4
  131. package/dist/types/src/components/Card/index.d.ts.map +0 -1
  132. package/dist/types/src/components/Card/styles.d.ts +0 -13
  133. package/dist/types/src/components/Card/styles.d.ts.map +0 -1
  134. package/dist/types/src/components/Focus/styles.d.ts +0 -6
  135. package/dist/types/src/components/Focus/styles.d.ts.map +0 -1
  136. package/dist/types/src/components/Image/Image.d.ts +0 -14
  137. package/dist/types/src/components/Image/Image.d.ts.map +0 -1
  138. package/dist/types/src/components/Image/Image.stories.d.ts +0 -33
  139. package/dist/types/src/components/Image/Image.stories.d.ts.map +0 -1
  140. package/dist/types/src/components/Image/index.d.ts +0 -2
  141. package/dist/types/src/components/Image/index.d.ts.map +0 -1
  142. package/dist/types/src/components/Layout/Layout.d.ts +0 -33
  143. package/dist/types/src/components/Layout/Layout.d.ts.map +0 -1
  144. package/dist/types/src/components/Layout/Layout.stories.d.ts +0 -10
  145. package/dist/types/src/components/Layout/Layout.stories.d.ts.map +0 -1
  146. package/dist/types/src/components/Layout/index.d.ts +0 -2
  147. package/dist/types/src/components/Layout/index.d.ts.map +0 -1
  148. package/dist/types/src/components/Mosaic/Mosaic.stories.d.ts.map +0 -1
  149. package/dist/types/src/components/Scrollable/Scrollable.d.ts +0 -24
  150. package/dist/types/src/components/Scrollable/Scrollable.d.ts.map +0 -1
  151. package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts +0 -10
  152. package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts.map +0 -1
  153. package/dist/types/src/components/Scrollable/index.d.ts +0 -2
  154. package/dist/types/src/components/Scrollable/index.d.ts.map +0 -1
  155. package/dist/types/src/components/Stack/Stack.d.ts +0 -22
  156. package/dist/types/src/components/Stack/Stack.d.ts.map +0 -1
  157. package/dist/types/src/components/Stack/Stack.stories.d.ts.map +0 -1
  158. package/dist/types/src/components/Stack/index.d.ts +0 -2
  159. package/dist/types/src/components/Stack/index.d.ts.map +0 -1
  160. package/dist/types/src/testing/Board.d.ts +0 -45
  161. package/dist/types/src/testing/Board.d.ts.map +0 -1
  162. package/dist/types/src/testing/Slot.stories.d.ts +0 -14
  163. package/dist/types/src/testing/Slot.stories.d.ts.map +0 -1
  164. package/dist/types/src/testing/Virtualizer.stories.d.ts +0 -12
  165. package/dist/types/src/testing/Virtualizer.stories.d.ts.map +0 -1
  166. package/src/components/Card/Card.stories.tsx +0 -148
  167. package/src/components/Card/Card.tsx +0 -458
  168. package/src/components/Card/CardDragPreview.tsx +0 -23
  169. package/src/components/Card/index.ts +0 -8
  170. package/src/components/Card/styles.ts +0 -23
  171. package/src/components/Focus/styles.ts +0 -24
  172. package/src/components/Image/Image.stories.tsx +0 -86
  173. package/src/components/Image/Image.tsx +0 -223
  174. package/src/components/Image/index.ts +0 -5
  175. package/src/components/Layout/Layout.stories.tsx +0 -59
  176. package/src/components/Layout/Layout.tsx +0 -108
  177. package/src/components/Mosaic/Mosaic.stories.tsx +0 -113
  178. package/src/components/Scrollable/Scrollable.stories.tsx +0 -59
  179. package/src/components/Scrollable/Scrollable.tsx +0 -88
  180. package/src/components/Scrollable/index.ts +0 -5
  181. package/src/components/Scrollable/scrollable.css +0 -20
  182. package/src/components/Stack/Stack.tsx +0 -210
  183. package/src/components/Stack/index.ts +0 -5
  184. package/src/testing/Board.tsx +0 -278
  185. package/src/testing/Slot.stories.tsx +0 -101
  186. package/src/testing/Virtualizer.stories.tsx +0 -133
@@ -1,1639 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
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;
40
- }
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);
53
- }
54
- setImageLoaded(true);
55
- }, [
56
- sampleSize,
57
- contrast,
58
- src
59
- ]);
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;
144
- };
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++;
159
- }
160
- return edgeTransparentPixels / edgePixels > threshold;
161
- };
162
-
163
- // src/components/Card/Card.tsx
164
- 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]: {}
175
- }
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
186
- },
187
- ...props,
188
- role,
189
- className: mx2(styles.root, border && styles.border, fullWidth && "!max-is-none", className, classNames),
190
- ref: forwardedRef
191
- }, children);
192
- });
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"
488
- ],
489
- content: [
490
- "transition-all duration-0",
491
- // TODO(burdon): Don't animate open if placeholder is the source.
492
- // TODO(burdon): Flickers when start to drag since source is removed and then the placeholder shows up.
493
- // - Use absolute positioning?
494
- // '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)]"
499
- ]
500
- }
501
- };
502
-
503
- // src/components/Mosaic/extension.ts
504
- import { StateEffect, StateField } from "@codemirror/state";
505
- import { Decoration, EditorView, ViewPlugin, WidgetType } from "@codemirror/view";
506
- var dropHandler = ({ onDrop = handleDrop } = {}) => {
507
- const views = /* @__PURE__ */ new Set();
508
- let state = null;
509
- const reset = () => {
510
- views.forEach((view) => view.dispatch({
511
- effects: setDrop.of(null)
512
- }));
513
- state = null;
514
- };
515
- const extension = [
516
- dropField,
517
- ViewPlugin.fromClass(class {
518
- _view;
519
- constructor(_view) {
520
- this._view = _view;
521
- views.add(_view);
522
- }
523
- destroy() {
524
- views.delete(this._view);
525
- }
526
- })
527
- ];
528
- return {
529
- extension,
530
- update: (position) => {
531
- if (!position) {
532
- reset();
533
- return;
534
- }
535
- views.forEach((view) => {
536
- const rect = view.dom.getBoundingClientRect();
537
- if (position.x >= rect.left && position.x <= rect.right && position.y >= rect.top && position.y <= rect.bottom) {
538
- let pos = view.posAtCoords(position);
539
- if (pos !== null) {
540
- const word = view.state.wordAt(pos);
541
- if (word) {
542
- const startDist = Math.abs(pos - word.from);
543
- const endDist = Math.abs(pos - word.to);
544
- pos = startDist < endDist ? word.from : word.to;
545
- }
546
- view.dispatch({
547
- effects: setDrop.of(pos)
548
- });
549
- state = {
550
- view,
551
- pos
552
- };
553
- return;
554
- }
555
- }
556
- view.dispatch({
557
- effects: setDrop.of(null)
558
- });
559
- });
560
- },
561
- cancel: () => {
562
- reset();
563
- },
564
- drop: ({ text, url }) => {
565
- if (state) {
566
- onDrop(state.view, state.pos, {
567
- text,
568
- url
569
- });
570
- }
571
- reset();
572
- }
573
- };
574
- };
575
- var handleDrop = (view, pos, event) => {
576
- const line = view.state.doc.lineAt(pos);
577
- if (line.text.trim() === "") {
578
- view.dispatch({
579
- changes: {
580
- from: pos,
581
- insert: `
582
- ![${event.text}](${event.url})
583
- `
584
- },
585
- effects: setDrop.of(null)
586
- });
587
- } else {
588
- view.dispatch({
589
- changes: {
590
- from: pos,
591
- insert: ` [${event.text}](${event.url})`
592
- },
593
- effects: setDrop.of(null)
594
- });
595
- }
596
- };
597
- var setDrop = StateEffect.define();
598
- var dropField = StateField.define({
599
- create: () => Decoration.none,
600
- update: (decorations, tr) => {
601
- for (const effect of tr.effects) {
602
- if (effect.is(setDrop)) {
603
- if (effect.value === null) {
604
- return Decoration.none;
605
- }
606
- return Decoration.set([
607
- Decoration.widget({
608
- widget: new class extends WidgetType {
609
- toDOM() {
610
- const dom = document.createElement("span");
611
- dom.className = "cm-drop-cursor";
612
- dom.style.borderLeft = "2px solid var(--dx-accentSurface)";
613
- dom.style.display = "inline-block";
614
- dom.style.height = "1em";
615
- dom.style.verticalAlign = "middle";
616
- return dom;
617
- }
618
- }(),
619
- side: 0
620
- }).range(effect.value)
621
- ]);
622
- }
623
- }
624
- return decorations.map(tr.changes);
625
- },
626
- provide: (field) => EditorView.decorations.from(field)
627
- });
628
-
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";
634
-
635
- // src/components/Mosaic/Mosaic.tsx
636
- import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
637
- import { draggable, dropTargetForElements, monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
638
- import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
639
- import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
640
- import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
641
- import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
642
- import { DropIndicator as NativeDropIndicator } from "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box";
643
- import { composeRefs, useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
644
- import { createContext as createContext3 } from "@radix-ui/react-context";
645
- import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
646
- import { Slot as Slot3 } from "@radix-ui/react-slot";
647
- 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";
649
- import { createPortal } from "react-dom";
650
- import { log as log2 } from "@dxos/log";
651
- import { mx as mx6 } from "@dxos/ui-theme";
652
- 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
- }
665
- };
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
671
- };
672
- if (axis) {
673
- options2.overflow = {
674
- x: axis === "horizontal" ? "scroll" : "hidden",
675
- y: axis === "vertical" ? "scroll" : "hidden"
676
- };
677
- }
678
- return options2;
679
- }, [
680
- axis,
681
- optionsProp
682
- ]);
683
- useImperativeHandle(forwardedRef, () => osRef.current?.getElement(), [
684
- osRef
685
- ]);
686
- useEffect(() => {
687
- const instance = osRef.current?.osInstance();
688
- if (viewportRef) {
689
- viewportRef(instance?.elements().viewport ?? null);
690
- }
691
- }, [
692
- osRef,
693
- viewportRef
694
- ]);
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
- });
998
- };
999
- const handleCancel = () => {
1000
- setDragging((dragging2) => {
1001
- requestAnimationFrame(() => {
1002
- dragging2?.target?.handler?.onCancel?.();
1003
- dragging2?.source?.container?.dispatchEvent(new CustomEvent("dnd:cancel", {
1004
- bubbles: true
1005
- }));
1006
- });
1007
- return void 0;
1008
- });
1009
- };
1010
- let noTargetTimeout;
1011
- return combine(monitorForElements({
1012
- /**
1013
- * Dragging started within any container.
1014
- */
1015
- onDragStart: ({ source, location }) => {
1016
- log2("Root.onDragStart", {
1017
- source: source.data,
1018
- location: location.current.dropTargets.map((target) => target.data)
1019
- }, {
1020
- F: __dxlog_file3,
1021
- L: 215,
1022
- S: void 0,
1023
- C: (f, a) => f(...a)
1024
- });
1025
- handleChange({
1026
- source,
1027
- location
1028
- });
1029
- },
1030
- /**
1031
- * Dragging entered a new container.
1032
- */
1033
- onDropTargetChange: ({ source, location }) => {
1034
- clearTimeout(noTargetTimeout);
1035
- log2("Root.onDropTargetChange", {
1036
- source: source.data,
1037
- location: location.current.dropTargets.map((target) => target.data)
1038
- }, {
1039
- F: __dxlog_file3,
1040
- L: 228,
1041
- S: void 0,
1042
- C: (f, a) => f(...a)
1043
- });
1044
- if (location.current.dropTargets.length === 0) {
1045
- noTargetTimeout = setTimeout(() => setDragging(void 0), 1e3);
1046
- } else {
1047
- handleChange({
1048
- source,
1049
- location
1050
- });
1051
- }
1052
- },
1053
- /**
1054
- * Dragging within any container.
1055
- */
1056
- onDrag: ({ source, location }) => {
1057
- const { data } = getSourceHandler(source);
1058
- const { handler } = getTargetHandler(location);
1059
- if (handler) {
1060
- const { clientX: x, clientY: y } = location.current.input;
1061
- handler.onDrag?.({
1062
- source: data,
1063
- position: {
1064
- x,
1065
- y
1066
- }
1067
- });
1068
- }
1069
- },
1070
- /**
1071
- * Dragging ended.
1072
- */
1073
- onDrop: ({ source, location }) => {
1074
- log2.info("Root.onDrop", {
1075
- source: source.data,
1076
- location: location.current.dropTargets.map((target) => target.data)
1077
- }, {
1078
- F: __dxlog_file3,
1079
- L: 257,
1080
- S: void 0,
1081
- C: (f, a) => f(...a)
1082
- });
1083
- const { data: sourceData, handler: sourceHandler } = getSourceHandler(source);
1084
- if (!sourceHandler) {
1085
- log2.warn("invalid source", {
1086
- source: sourceData,
1087
- handlers: Object.keys(handlers)
1088
- }, {
1089
- F: __dxlog_file3,
1090
- L: 265,
1091
- S: void 0,
1092
- C: (f, a) => f(...a)
1093
- });
1094
- return;
1095
- }
1096
- try {
1097
- if (location.current.dropTargets.length === 0) {
1098
- log2.info("cancelled", void 0, {
1099
- F: __dxlog_file3,
1100
- L: 280,
1101
- S: void 0,
1102
- C: (f, a) => f(...a)
1103
- });
1104
- } else {
1105
- const { data: targetData, handler: targetHandler } = getTargetHandler(location);
1106
- if (!targetHandler) {
1107
- log2.warn("invalid target", {
1108
- source: sourceData,
1109
- location,
1110
- handlers: Object.keys(handlers)
1111
- }, {
1112
- F: __dxlog_file3,
1113
- L: 285,
1114
- S: void 0,
1115
- C: (f, a) => f(...a)
1116
- });
1117
- return;
1118
- }
1119
- if (sourceHandler === targetHandler) {
1120
- targetHandler.onDrop?.({
1121
- source: sourceData,
1122
- target: targetData
1123
- });
1124
- } else {
1125
- if (!sourceHandler.onTake) {
1126
- log2.warn("invalid source", {
1127
- source: sourceData
1128
- }, {
1129
- F: __dxlog_file3,
1130
- L: 301,
1131
- S: void 0,
1132
- C: (f, a) => f(...a)
1133
- });
1134
- return;
1135
- }
1136
- sourceHandler.onTake?.({
1137
- source: sourceData
1138
- }, async (object) => {
1139
- targetHandler.onDrop?.({
1140
- source: {
1141
- ...sourceData,
1142
- data: object
1143
- },
1144
- target: targetData
1145
- });
1146
- return true;
1147
- });
1148
- }
1149
- }
1150
- } finally {
1151
- handleCancel();
1152
- }
1153
- }
1154
- }));
1155
- }, [
1156
- handlers,
1157
- getSourceHandler,
1158
- getTargetHandler
1159
- ]);
1160
- return /* @__PURE__ */ React6.createElement(RootContextProvider, {
1161
- containers: handlers,
1162
- addContainer: (container) => setHandlers((containers) => ({
1163
- ...containers,
1164
- [container.id]: container
1165
- })),
1166
- removeContainer: (id) => setHandlers((containers) => {
1167
- delete containers[id];
1168
- return {
1169
- ...containers
1170
- };
1171
- }),
1172
- dragging
1173
- }, /* @__PURE__ */ React6.createElement(Root2, {
1174
- className: mx6("group overflow-hidden", classNames),
1175
- [`data-${ROOT_DEBUG_ATTR}`]: debug,
1176
- ref: composedRef
1177
- }, children));
1178
- });
1179
- var [ContainerContextProvider, useContainerContext] = createContext3("MosaicContainer");
1180
- var CONTAINER_STATE_ATTR = "mosaic-container-state";
1181
- var CONTAINER_PLACEHOLDER_WIDTH = "--mosaic-placeholder-width";
1182
- var CONTAINER_PLACEHOLDER_HEIGHT = "--mosaic-placeholder-height";
1183
- 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);
1186
- const composedRef = useComposedRefs2(rootRef, forwardedRef);
1187
- const Root2 = asChild ? Slot3 : Primitive2.div;
1188
- const eventHandler = useMemo4(() => eventHandlerProp ?? {
1189
- id: `mosaic-container-${counter++}`
1190
- }, [
1191
- eventHandlerProp
1192
- ]);
1193
- const { dragging } = useRootContext(Container.displayName);
1194
- const [state, setState] = useState3({
1195
- type: "idle"
1196
- });
1197
- const [activeLocation, setActiveLocation] = useState3();
1198
- const [scrolling, setScrolling] = useState3(false);
1199
- const { setFocus } = useFocus();
1200
- useEffect2(() => {
1201
- if (withFocus) {
1202
- setFocus?.(state.type === "active" ? "active" : void 0);
1203
- }
1204
- }, [
1205
- setFocus,
1206
- withFocus,
1207
- state
1208
- ]);
1209
- const { addContainer, removeContainer } = useRootContext(eventHandler.id);
1210
- useEffect2(() => {
1211
- addContainer(eventHandler);
1212
- return () => removeContainer(eventHandler.id);
1213
- }, [
1214
- eventHandler
1215
- ]);
1216
- const data = useMemo4(() => ({
1217
- type: "container",
1218
- id: eventHandler.id
1219
- }), [
1220
- eventHandler.id
1221
- ]);
1222
- useEffect2(() => {
1223
- if (!rootRef.current) {
1224
- return;
1225
- }
1226
- let timeout;
1227
- const handleScroll = () => {
1228
- setScrolling(true);
1229
- clearTimeout(timeout);
1230
- timeout = setTimeout(() => {
1231
- setScrolling(false);
1232
- }, 500);
1233
- };
1234
- return combine(...[
1235
- /**
1236
- * Custom event for dragging cancellation.
1237
- */
1238
- bind(rootRef.current, {
1239
- type: "dnd:cancel",
1240
- listener: () => {
1241
- setState({
1242
- type: "idle"
1243
- });
1244
- }
1245
- }),
1246
- // Target.
1247
- dropTargetForElements({
1248
- element: rootRef.current,
1249
- getData: () => data,
1250
- /**
1251
- * Test if permitted to drop here.
1252
- * NOTE: Contained Tile and Placeholder elements do the same.
1253
- */
1254
- canDrop: ({ source }) => {
1255
- const data2 = getSourceData(source);
1256
- return data2 && eventHandler.canDrop?.({
1257
- source: data2
1258
- }) || false;
1259
- },
1260
- // TODO(burdon): Provide semantic intent to onDrop.
1261
- // getDropEffect: () => {
1262
- // return 'move';
1263
- // },
1264
- /**
1265
- * Dragging started in this container.
1266
- */
1267
- onDragStart: ({ source }) => {
1268
- const sourceData = source.data;
1269
- setState({
1270
- type: "active",
1271
- bounds: sourceData.bounds
1272
- });
1273
- },
1274
- /**
1275
- * Dragging entered this container.
1276
- */
1277
- onDragEnter: ({ source }) => {
1278
- const sourceData = source.data;
1279
- setState({
1280
- type: "active",
1281
- bounds: sourceData.bounds
1282
- });
1283
- },
1284
- /**
1285
- * Dragging left this container.
1286
- * NOTE: If the container isn't full-height, then when the dragged item is temporarily removed the container will shrink,
1287
- * triggering `onDragLeave`, which then causes the item to be added and removed continually (flickering).
1288
- */
1289
- onDragLeave: ({ source }) => {
1290
- const sourceData = source.data;
1291
- if (sourceData.containerId !== eventHandler.id) {
1292
- setState({
1293
- type: "idle"
1294
- });
1295
- }
1296
- },
1297
- /**
1298
- * Dropped in this container.
1299
- */
1300
- onDrop: () => {
1301
- setState({
1302
- type: "idle"
1303
- });
1304
- }
1305
- }),
1306
- // Autoscroll.
1307
- // NOTE: When used with Scrollable we get a spurious warning (in dev mode).
1308
- // "Auto scrolling has been attached to an element that appears not to be scrollable."
1309
- autoscrollElement && [
1310
- autoScrollForElements({
1311
- element: autoscrollElement,
1312
- // canScroll: ({ element: _ }) => {
1313
- // return true;
1314
- // },
1315
- getAllowedAxis: () => axis,
1316
- getConfiguration: () => ({
1317
- maxScrollSpeed: "fast"
1318
- })
1319
- }),
1320
- bind(autoscrollElement, {
1321
- type: "scroll",
1322
- listener: handleScroll
1323
- }),
1324
- () => setScrolling(false)
1325
- ]
1326
- ].filter(isTruthy).flatMap((x) => x));
1327
- }, [
1328
- rootRef,
1329
- eventHandler,
1330
- data,
1331
- autoscrollElement
1332
- ]);
1333
- return /* @__PURE__ */ React6.createElement(ContainerContextProvider, {
1334
- id: eventHandler.id,
1335
- eventHandler,
1336
- axis,
1337
- state,
1338
- dragging: state.type === "active" ? dragging : void 0,
1339
- scrolling,
1340
- activeLocation,
1341
- setActiveLocation
1342
- }, /* @__PURE__ */ React6.createElement(Root2, {
1343
- className: mx6("bs-full", className, classNames),
1344
- style: {
1345
- [CONTAINER_PLACEHOLDER_WIDTH]: state.type === "active" && state.bounds ? `${state.bounds.width}px` : "0px",
1346
- [CONTAINER_PLACEHOLDER_HEIGHT]: state.type === "active" && state.bounds ? `${state.bounds.height}px` : "0px"
1347
- },
1348
- ...props,
1349
- [`data-${CONTAINER_STATE_ATTR}`]: state.type,
1350
- ref: composedRef
1351
- }, children), debug?.());
1352
- });
1353
- Container.displayName = "MosaicContainer";
1354
- var [TileContextProvider, useTileContext] = createContext3("MosaicTile");
1355
- 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);
1358
- 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({
1362
- type: "idle"
1363
- });
1364
- const allowedEdges = useMemo4(() => allowedEdgesProp || (axis === "vertical" ? [
1365
- "top",
1366
- "bottom"
1367
- ] : [
1368
- "left",
1369
- "right"
1370
- ]), [
1371
- allowedEdgesProp,
1372
- axis
1373
- ]);
1374
- const data = useMemo4(() => ({
1375
- type: "tile",
1376
- id,
1377
- containerId,
1378
- data: dataProp,
1379
- location
1380
- }), [
1381
- containerId,
1382
- location,
1383
- dataProp
1384
- ]);
1385
- useLayoutEffect(() => {
1386
- const root = rootRef.current;
1387
- if (!root || !containerId || scrolling) {
1388
- return;
1389
- }
1390
- const handleChange = ({ self, source }) => {
1391
- if (source.data.id !== dataProp.id) {
1392
- const closestEdge = extractClosestEdge(self.data);
1393
- const location2 = data.location + (closestEdge === "top" || closestEdge === "left" ? -0.5 : 0.5);
1394
- setActiveLocation(location2);
1395
- setState({
1396
- type: "target",
1397
- closestEdge
1398
- });
1399
- }
1400
- };
1401
- return combine(
1402
- // Source.
1403
- draggable({
1404
- element: root,
1405
- dragHandle: dragHandle && state.type !== "preview" ? dragHandle : void 0,
1406
- canDrag: () => true,
1407
- getInitialData: () => data,
1408
- onGenerateDragPreview: ({ location: location2, nativeSetDragImage }) => {
1409
- setCustomNativeDragPreview({
1410
- nativeSetDragImage,
1411
- getOffset: preserveOffsetOnSource({
1412
- element: root,
1413
- input: location2.current.input
1414
- }),
1415
- render: ({ container }) => {
1416
- data.bounds = root.getBoundingClientRect();
1417
- setState({
1418
- type: "preview",
1419
- container,
1420
- rect: root.getBoundingClientRect()
1421
- });
1422
- return () => setState({
1423
- type: "dragging"
1424
- });
1425
- }
1426
- });
1427
- },
1428
- onDragStart: () => {
1429
- setState({
1430
- type: "dragging"
1431
- });
1432
- },
1433
- onDrop: () => {
1434
- setState({
1435
- type: "idle"
1436
- });
1437
- }
1438
- }),
1439
- // Target.
1440
- dropTargetForElements({
1441
- element: root,
1442
- getData: ({ input, element }) => attachClosestEdge(data, {
1443
- input,
1444
- element,
1445
- allowedEdges
1446
- }),
1447
- canDrop: ({ source }) => {
1448
- const data2 = getSourceData(source);
1449
- return data2 && eventHandler.canDrop?.({
1450
- source: data2
1451
- }) || false;
1452
- },
1453
- onDragEnter: ({ self, source }) => {
1454
- handleChange({
1455
- self,
1456
- source
1457
- });
1458
- },
1459
- onDragLeave: () => {
1460
- setState({
1461
- type: "idle"
1462
- });
1463
- setActiveLocation(void 0);
1464
- },
1465
- onDrag: ({ self, source }) => {
1466
- handleChange({
1467
- self,
1468
- source
1469
- });
1470
- },
1471
- onDrop: () => {
1472
- setState({
1473
- type: "idle"
1474
- });
1475
- setActiveLocation(void 0);
1476
- }
1477
- })
1478
- );
1479
- }, [
1480
- rootRef,
1481
- dragHandle,
1482
- eventHandler,
1483
- data,
1484
- scrolling,
1485
- allowedEdges,
1486
- setActiveLocation
1487
- ]);
1488
- return /* @__PURE__ */ React6.createElement(TileContextProvider, {
1489
- state
1490
- }, /* @__PURE__ */ React6.createElement(Root2, {
1491
- [`data-${TILE_STATE_ATTR}`]: state.type,
1492
- role: "listitem",
1493
- className: mx6("relative", className, classNames),
1494
- ref: composedRef
1495
- }, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(Root2, {
1496
- // NOTE: Use to control appearance while dragging.
1497
- [`data-${TILE_STATE_ATTR}`]: state.type,
1498
- // TODO(burdon): Configure drop animation.
1499
- className: mx6("relative", className, classNames),
1500
- style: {
1501
- width: `${state.rect.width}px`,
1502
- height: `${state.rect.height}px`
1503
- }
1504
- }, children), state.container));
1505
- });
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;
1525
- }
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",
1554
- role: "none",
1555
- className: mx6("relative", classNames),
1556
- ref: rootRef
1557
- }, children);
1558
- };
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, {
1563
- ...props,
1564
- edge: state.closestEdge
1565
- }) : null;
1566
- };
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
1578
- };
1579
-
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),
1615
- ref: forwardedRef
1616
- });
1617
- });
1618
- ContainerInfo.displayName = "ContainerInfo";
1619
-
1620
- export {
1621
- styles,
1622
- Image,
1623
- Card,
1624
- styles2,
1625
- useFocus,
1626
- Focus,
1627
- styles3,
1628
- dropHandler,
1629
- useContainerDebug,
1630
- useEventHandlerAdapter,
1631
- useVisibleItems,
1632
- Stack,
1633
- VirtualStack,
1634
- useRootContext,
1635
- useContainerContext,
1636
- useTileContext,
1637
- Mosaic
1638
- };
1639
- //# sourceMappingURL=chunk-X6GV7SMK.mjs.map