@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
@@ -0,0 +1,955 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
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 ?? [];
9
+ }
10
+ const idx = items.findIndex((item) => getId(item) === dragging.id);
11
+ if (idx === -1) {
12
+ return items;
13
+ }
14
+ const visibleItems2 = items.slice();
15
+ visibleItems2.splice(idx, 1);
16
+ return visibleItems2;
17
+ }, [
18
+ id,
19
+ items,
20
+ dragging,
21
+ getId
22
+ ]);
23
+ return visibleItems;
24
+ };
25
+
26
+ // src/components/Focus/Focus.tsx
27
+ import { useArrowNavigationGroup, useFocusableGroup, useMergedTabsterAttributes_unstable } from "@fluentui/react-tabster";
28
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
29
+ import { Primitive } from "@radix-ui/react-primitive";
30
+ import { Slot } from "@radix-ui/react-slot";
31
+ import React, { createContext, forwardRef, useContext, useRef, useState } from "react";
32
+ import { mx } from "@dxos/ui-theme";
33
+ var FOCUS_STATE_ATTR = "focus-state";
34
+ var FocusContext = /* @__PURE__ */ createContext({});
35
+ var useFocus = () => useContext(FocusContext);
36
+ var Group = /* @__PURE__ */ forwardRef(({ classNames, className, children, asChild, orientation = "vertical", ...props }, forwardedRef) => {
37
+ const rootRef = useRef(null);
38
+ const composedRef = useComposedRefs(rootRef, forwardedRef);
39
+ const Comp = asChild ? Slot : Primitive.div;
40
+ const focusableGroupAttrs = useFocusableGroup({
41
+ tabBehavior: "limited-trap-focus"
42
+ });
43
+ const arrowNavigationAttrs = useArrowNavigationGroup({
44
+ axis: orientation,
45
+ memorizeCurrent: true
46
+ });
47
+ const tabsterAttrs = useMergedTabsterAttributes_unstable(focusableGroupAttrs, arrowNavigationAttrs);
48
+ const [state, setState] = useState();
49
+ return /* @__PURE__ */ React.createElement(FocusContext.Provider, {
50
+ value: {
51
+ setFocus: setState
52
+ }
53
+ }, /* @__PURE__ */ React.createElement(Comp, {
54
+ ...props,
55
+ ...tabsterAttrs,
56
+ ...state && {
57
+ [`data-${FOCUS_STATE_ATTR}`]: state
58
+ },
59
+ tabIndex: 0,
60
+ className: mx([
61
+ // TODO(burdon): Option for border/rounded; ring/outline vs border?
62
+ "outline-hidden border border-separator md:rounded-xs",
63
+ // Focus (e.g., via tabster).
64
+ "focus:!border-accent-surface",
65
+ // Active (e.g., drop target).
66
+ "data-[focus-state=active]:border-neutral-focus-indicator",
67
+ // Error
68
+ "data-[focus-state=error]:border-rose-500"
69
+ ], className, classNames),
70
+ ref: composedRef
71
+ }, children));
72
+ });
73
+ var Focus = {
74
+ Group
75
+ };
76
+
77
+ // src/components/Mosaic/styles.ts
78
+ var styles = {
79
+ placeholder: {
80
+ root: [
81
+ "group opacity-0",
82
+ 'group-data-[mosaic-debug="true"]:opacity-100',
83
+ 'group-data-[mosaic-debug="true"]:bg-orange-500',
84
+ "data-[mosaic-placeholder-state=active]:opacity-100",
85
+ "data-[mosaic-placeholder-orientation=vertical]:snap-start",
86
+ "data-[mosaic-placeholder-orientation=vertical]:py-1",
87
+ "data-[mosaic-placeholder-orientation=vertical]:data-[mosaic-placeholder-state=active]:py-2.5",
88
+ "data-[mosaic-placeholder-orientation=horizontal]:px-1",
89
+ "data-[mosaic-placeholder-orientation=horizontal]:data-[mosaic-placeholder-state=active]:px-2.5"
90
+ ],
91
+ content: [
92
+ "transition-all duration-0",
93
+ // TODO(burdon): Don't animate open if placeholder is the source.
94
+ // TODO(burdon): Flickers when start to drag since source is removed and then the placeholder shows up.
95
+ // - Use absolute positioning?
96
+ // 'group-data-[mosaic-placeholder-state=active]:duration-200',
97
+ "group-data-[mosaic-placeholder-orientation=vertical]:h-0",
98
+ "group-data-[mosaic-placeholder-orientation=vertical]:group-data-[mosaic-placeholder-state=active]:h-[var(--mosaic-placeholder-height)]",
99
+ "group-data-[mosaic-placeholder-orientation=horizontal]:w-0",
100
+ "group-data-[mosaic-placeholder-orientation=horizontal]:group-data-[mosaic-placeholder-state=active]:w-[var(--mosaic-placeholder-width)]"
101
+ ]
102
+ }
103
+ };
104
+
105
+ // src/components/Mosaic/types.ts
106
+ var getSourceData = (source) => {
107
+ return source.data.type === "tile" ? source.data : null;
108
+ };
109
+
110
+ // src/components/Mosaic/Root.tsx
111
+ import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
112
+ import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
113
+ import { useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
114
+ import { createContext as createContext2 } from "@radix-ui/react-context";
115
+ import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
116
+ import { Slot as Slot2 } from "@radix-ui/react-slot";
117
+ import React2, { forwardRef as forwardRef2, useCallback, useEffect, useRef as useRef2, useState as useState2 } from "react";
118
+ import { log } from "@dxos/log";
119
+ import { mx as mx2 } from "@dxos/ui-theme";
120
+ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Root.tsx";
121
+ var [MosaicRootContextProvider, useMosaicRootContext] = createContext2("MosaicRoot");
122
+ var MOSAIC_ROOT_NAME = "Mosaic.Root";
123
+ var MOSAIC_ROOT_DEBUG_ATTR = "mosaic-debug";
124
+ var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }, forwardedRef) => {
125
+ const rootRef = useRef2(null);
126
+ const composedRef = useComposedRefs2(rootRef, forwardedRef);
127
+ const Comp = asChild ? Slot2 : Primitive2.div;
128
+ const [handlers, setHandlers] = useState2({});
129
+ const [dragging, setDragging] = useState2();
130
+ const getSourceHandler = useCallback((source) => {
131
+ const data = source.data;
132
+ return {
133
+ data,
134
+ handler: handlers[data.containerId]
135
+ };
136
+ }, [
137
+ handlers
138
+ ]);
139
+ const getTargetHandler = useCallback((location) => {
140
+ for (const target of location.current.dropTargets) {
141
+ const data = target.data;
142
+ let containerId;
143
+ switch (data.type) {
144
+ case "tile":
145
+ case "placeholder":
146
+ containerId = data.containerId;
147
+ break;
148
+ case "container":
149
+ containerId = data.id;
150
+ break;
151
+ }
152
+ const handler = handlers[containerId];
153
+ if (handler) {
154
+ return {
155
+ data,
156
+ handler
157
+ };
158
+ }
159
+ }
160
+ return {};
161
+ }, [
162
+ handlers
163
+ ]);
164
+ useEffect(() => {
165
+ const handleChange = ({ source, location }) => {
166
+ const { data: sourceData } = getSourceHandler(source);
167
+ const { data: targetData, handler } = getTargetHandler(location);
168
+ setDragging((dragging2) => {
169
+ dragging2?.target?.handler?.onCancel?.();
170
+ return {
171
+ source: {
172
+ data: sourceData,
173
+ handler: handlers[sourceData.containerId],
174
+ // TOOD(burdon): Check id matches.
175
+ container: location.initial.dropTargets.find((target) => target.data.type === "container")?.element
176
+ },
177
+ target: targetData && {
178
+ data: targetData,
179
+ handler
180
+ }
181
+ };
182
+ });
183
+ };
184
+ const handleCancel = () => {
185
+ setDragging((dragging2) => {
186
+ requestAnimationFrame(() => {
187
+ dragging2?.target?.handler?.onCancel?.();
188
+ dragging2?.source?.container?.dispatchEvent(new CustomEvent("dnd:cancel", {
189
+ bubbles: true
190
+ }));
191
+ });
192
+ return void 0;
193
+ });
194
+ };
195
+ let noTargetTimeout;
196
+ return combine(monitorForElements({
197
+ /**
198
+ * Dragging started within any container.
199
+ */
200
+ onDragStart: ({ source, location }) => {
201
+ log("Root.onDragStart", {
202
+ source: source.data,
203
+ location: location.current.dropTargets.map((target) => target.data)
204
+ }, {
205
+ F: __dxlog_file,
206
+ L: 149,
207
+ S: void 0,
208
+ C: (f, a) => f(...a)
209
+ });
210
+ handleChange({
211
+ source,
212
+ location
213
+ });
214
+ },
215
+ /**
216
+ * Dragging entered a new container.
217
+ */
218
+ onDropTargetChange: ({ source, location }) => {
219
+ clearTimeout(noTargetTimeout);
220
+ log("Root.onDropTargetChange", {
221
+ source: source.data,
222
+ location: location.current.dropTargets.map((target) => target.data)
223
+ }, {
224
+ F: __dxlog_file,
225
+ L: 162,
226
+ S: void 0,
227
+ C: (f, a) => f(...a)
228
+ });
229
+ if (location.current.dropTargets.length === 0) {
230
+ noTargetTimeout = setTimeout(() => setDragging(void 0), 1e3);
231
+ } else {
232
+ handleChange({
233
+ source,
234
+ location
235
+ });
236
+ }
237
+ },
238
+ /**
239
+ * Dragging within any container.
240
+ */
241
+ onDrag: ({ source, location }) => {
242
+ const { data } = getSourceHandler(source);
243
+ const { handler } = getTargetHandler(location);
244
+ if (handler) {
245
+ const { clientX: x, clientY: y } = location.current.input;
246
+ handler.onDrag?.({
247
+ source: data,
248
+ position: {
249
+ x,
250
+ y
251
+ }
252
+ });
253
+ }
254
+ },
255
+ /**
256
+ * Dragging ended.
257
+ */
258
+ onDrop: ({ source, location }) => {
259
+ log.info("Root.onDrop", {
260
+ source: source.data,
261
+ location: location.current.dropTargets.map((target) => target.data)
262
+ }, {
263
+ F: __dxlog_file,
264
+ L: 191,
265
+ S: void 0,
266
+ C: (f, a) => f(...a)
267
+ });
268
+ const { data: sourceData, handler: sourceHandler } = getSourceHandler(source);
269
+ if (!sourceHandler) {
270
+ log.warn("invalid source", {
271
+ source: sourceData,
272
+ handlers: Object.keys(handlers)
273
+ }, {
274
+ F: __dxlog_file,
275
+ L: 199,
276
+ S: void 0,
277
+ C: (f, a) => f(...a)
278
+ });
279
+ return;
280
+ }
281
+ try {
282
+ if (location.current.dropTargets.length === 0) {
283
+ log.info("cancelled", void 0, {
284
+ F: __dxlog_file,
285
+ L: 214,
286
+ S: void 0,
287
+ C: (f, a) => f(...a)
288
+ });
289
+ } else {
290
+ const { data: targetData, handler: targetHandler } = getTargetHandler(location);
291
+ if (!targetHandler) {
292
+ log.warn("invalid target", {
293
+ source: sourceData,
294
+ location,
295
+ handlers: Object.keys(handlers)
296
+ }, {
297
+ F: __dxlog_file,
298
+ L: 219,
299
+ S: void 0,
300
+ C: (f, a) => f(...a)
301
+ });
302
+ return;
303
+ }
304
+ if (sourceHandler === targetHandler) {
305
+ targetHandler.onDrop?.({
306
+ source: sourceData,
307
+ target: targetData
308
+ });
309
+ } else {
310
+ if (!sourceHandler.onTake) {
311
+ log.warn("invalid source", {
312
+ source: sourceData
313
+ }, {
314
+ F: __dxlog_file,
315
+ L: 235,
316
+ S: void 0,
317
+ C: (f, a) => f(...a)
318
+ });
319
+ return;
320
+ }
321
+ sourceHandler.onTake?.({
322
+ source: sourceData
323
+ }, async (object) => {
324
+ targetHandler.onDrop?.({
325
+ source: {
326
+ ...sourceData,
327
+ data: object
328
+ },
329
+ target: targetData
330
+ });
331
+ return true;
332
+ });
333
+ }
334
+ }
335
+ } finally {
336
+ handleCancel();
337
+ }
338
+ }
339
+ }));
340
+ }, [
341
+ handlers,
342
+ getSourceHandler,
343
+ getTargetHandler
344
+ ]);
345
+ return /* @__PURE__ */ React2.createElement(MosaicRootContextProvider, {
346
+ containers: handlers,
347
+ addContainer: (container) => setHandlers((containers) => ({
348
+ ...containers,
349
+ [container.id]: container
350
+ })),
351
+ removeContainer: (id) => setHandlers((containers) => {
352
+ delete containers[id];
353
+ return {
354
+ ...containers
355
+ };
356
+ }),
357
+ dragging
358
+ }, /* @__PURE__ */ React2.createElement(Comp, {
359
+ className: mx2("group", classNames),
360
+ [`data-${MOSAIC_ROOT_DEBUG_ATTR}`]: debug,
361
+ ref: composedRef
362
+ }, children));
363
+ });
364
+ MosaicRoot.displayName = MOSAIC_ROOT_NAME;
365
+
366
+ // src/components/Mosaic/Container.tsx
367
+ import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
368
+ import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
369
+ import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
370
+ import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
371
+ import { createContext as createContext3 } from "@radix-ui/react-context";
372
+ import { Primitive as Primitive3 } from "@radix-ui/react-primitive";
373
+ import { Slot as Slot3 } from "@radix-ui/react-slot";
374
+ import { bind } from "bind-event-listener";
375
+ import React3, { forwardRef as forwardRef3, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
376
+ import { mx as mx3 } from "@dxos/ui-theme";
377
+ import { isTruthy } from "@dxos/util";
378
+ var MOSAIC_CONTAINER_NAME = "Mosaic.Container";
379
+ var [MosaicContainerContextProvider, useMosaicContainerContext] = createContext3("MosaicContainer");
380
+ var MOSAIC_CONTAINER_STATE_ATTR = "mosaic-container-state";
381
+ var MOSAIC_CONTAINER_PLACEHOLDER_WIDTH = "--mosaic-placeholder-width";
382
+ var MOSAIC_CONTAINER_PLACEHOLDER_HEIGHT = "--mosaic-placeholder-height";
383
+ var counter = 0;
384
+ var MosaicContainer = /* @__PURE__ */ forwardRef3(({ classNames, className, children, eventHandler: eventHandlerProp, orientation = "vertical", asChild, autoScroll: autoscrollElement, withFocus, debug, ...props }, forwardedRef) => {
385
+ const rootRef = useRef3(null);
386
+ const composedRef = useComposedRefs3(rootRef, forwardedRef);
387
+ const Comp = asChild ? Slot3 : Primitive3.div;
388
+ const eventHandler = useMemo2(() => eventHandlerProp ?? {
389
+ id: `mosaic-container-${counter++}`
390
+ }, [
391
+ eventHandlerProp
392
+ ]);
393
+ const { dragging } = useMosaicRootContext(MOSAIC_CONTAINER_NAME);
394
+ const [state, setState] = useState3({
395
+ type: "idle"
396
+ });
397
+ const [activeLocation, setActiveLocation] = useState3();
398
+ const [scrolling, setScrolling] = useState3(false);
399
+ const { setFocus } = useFocus();
400
+ useEffect2(() => {
401
+ if (withFocus) {
402
+ setFocus?.(state.type === "active" ? "active" : void 0);
403
+ }
404
+ }, [
405
+ setFocus,
406
+ withFocus,
407
+ state
408
+ ]);
409
+ const { addContainer, removeContainer } = useMosaicRootContext(eventHandler.id);
410
+ useEffect2(() => {
411
+ addContainer(eventHandler);
412
+ return () => removeContainer(eventHandler.id);
413
+ }, [
414
+ eventHandler
415
+ ]);
416
+ const data = useMemo2(() => ({
417
+ type: "container",
418
+ id: eventHandler.id
419
+ }), [
420
+ eventHandler.id
421
+ ]);
422
+ useEffect2(() => {
423
+ if (!rootRef.current) {
424
+ return;
425
+ }
426
+ let timeout;
427
+ const handleScroll = () => {
428
+ setScrolling(true);
429
+ clearTimeout(timeout);
430
+ timeout = setTimeout(() => {
431
+ setScrolling(false);
432
+ }, 500);
433
+ };
434
+ return combine2(...[
435
+ /**
436
+ * Custom event for dragging cancellation.
437
+ */
438
+ bind(rootRef.current, {
439
+ type: "dnd:cancel",
440
+ listener: () => {
441
+ setState({
442
+ type: "idle"
443
+ });
444
+ }
445
+ }),
446
+ // Target.
447
+ dropTargetForElements({
448
+ element: rootRef.current,
449
+ getData: () => data,
450
+ /**
451
+ * Test if permitted to drop here.
452
+ * NOTE: Contained Tile and Placeholder elements do the same.
453
+ */
454
+ canDrop: ({ source }) => {
455
+ const data2 = getSourceData(source);
456
+ return data2 && eventHandler.canDrop?.({
457
+ source: data2
458
+ }) || false;
459
+ },
460
+ // TODO(burdon): Provide semantic intent to onDrop.
461
+ // getDropEffect: () => {
462
+ // return 'move';
463
+ // },
464
+ /**
465
+ * Dragging started in this container.
466
+ */
467
+ onDragStart: ({ source }) => {
468
+ const sourceData = source.data;
469
+ setState({
470
+ type: "active",
471
+ bounds: sourceData.bounds
472
+ });
473
+ },
474
+ /**
475
+ * Dragging entered this container.
476
+ */
477
+ onDragEnter: ({ source }) => {
478
+ const sourceData = source.data;
479
+ setState({
480
+ type: "active",
481
+ bounds: sourceData.bounds
482
+ });
483
+ },
484
+ /**
485
+ * Dragging left this container.
486
+ * NOTE: If the container isn't full-height, then when the dragged item is temporarily removed the container will shrink,
487
+ * triggering `onDragLeave`, which then causes the item to be added and removed continually (flickering).
488
+ */
489
+ onDragLeave: ({ source }) => {
490
+ const sourceData = source.data;
491
+ if (sourceData.containerId !== eventHandler.id) {
492
+ setState({
493
+ type: "idle"
494
+ });
495
+ }
496
+ },
497
+ /**
498
+ * Dropped in this container.
499
+ */
500
+ onDrop: () => {
501
+ setState({
502
+ type: "idle"
503
+ });
504
+ }
505
+ }),
506
+ // Autoscroll.
507
+ // NOTE: When used with Scrollable we get a spurious warning (in dev mode).
508
+ // "Auto scrolling has been attached to an element that appears not to be scrollable."
509
+ autoscrollElement && [
510
+ autoScrollForElements({
511
+ element: autoscrollElement,
512
+ // canScroll: ({ element: _ }) => {
513
+ // return true;
514
+ // },
515
+ getAllowedAxis: () => orientation,
516
+ getConfiguration: () => ({
517
+ maxScrollSpeed: "fast"
518
+ })
519
+ }),
520
+ bind(autoscrollElement, {
521
+ type: "scroll",
522
+ listener: handleScroll
523
+ }),
524
+ () => setScrolling(false)
525
+ ]
526
+ ].filter(isTruthy).flatMap((x) => x));
527
+ }, [
528
+ rootRef,
529
+ eventHandler,
530
+ data,
531
+ autoscrollElement
532
+ ]);
533
+ return /* @__PURE__ */ React3.createElement(MosaicContainerContextProvider, {
534
+ id: eventHandler.id,
535
+ eventHandler,
536
+ orientation,
537
+ state,
538
+ dragging: state.type === "active" ? dragging : void 0,
539
+ scrolling,
540
+ activeLocation,
541
+ setActiveLocation
542
+ }, /* @__PURE__ */ React3.createElement(Comp, {
543
+ className: mx3("h-full", className, classNames),
544
+ style: {
545
+ [MOSAIC_CONTAINER_PLACEHOLDER_WIDTH]: state.type === "active" && state.bounds ? `${state.bounds.width}px` : "0px",
546
+ [MOSAIC_CONTAINER_PLACEHOLDER_HEIGHT]: state.type === "active" && state.bounds ? `${state.bounds.height}px` : "0px"
547
+ },
548
+ ...props,
549
+ [`data-${MOSAIC_CONTAINER_STATE_ATTR}`]: state.type,
550
+ ref: composedRef
551
+ }, children), debug?.());
552
+ });
553
+ MosaicContainer.displayName = MOSAIC_CONTAINER_NAME;
554
+
555
+ // src/components/Mosaic/Tile.tsx
556
+ import { combine as combine3 } from "@atlaskit/pragmatic-drag-and-drop/combine";
557
+ import { draggable, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
558
+ import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
559
+ import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
560
+ import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
561
+ import { composeRefs } from "@radix-ui/react-compose-refs";
562
+ import { createContext as createContext4 } from "@radix-ui/react-context";
563
+ import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
564
+ import { Slot as Slot4 } from "@radix-ui/react-slot";
565
+ import React4, { forwardRef as forwardRef4, useLayoutEffect, useMemo as useMemo3, useRef as useRef4, useState as useState4 } from "react";
566
+ import { createPortal } from "react-dom";
567
+ import { mx as mx4 } from "@dxos/ui-theme";
568
+ var MOSAIC_TILE_NAME = "Mosaic.Tile";
569
+ var [MosaicTileContextProvider, useMosaicTileContext] = createContext4("MosaicTile");
570
+ var MOSAIC_TILE_STATE_ATTR = "mosaic-tile-state";
571
+ var MosaicTile = /* @__PURE__ */ forwardRef4(({ classNames, className, children, asChild, dragHandle, allowedEdges: allowedEdgesProp, location, id, data: dataProp, debug: _, ...props }, forwardedRef) => {
572
+ const rootRef = useRef4(null);
573
+ const composedRef = composeRefs(rootRef, forwardedRef);
574
+ const Comp = asChild ? Slot4 : Primitive4.div;
575
+ const { id: containerId, eventHandler, orientation, scrolling, setActiveLocation } = useMosaicContainerContext(MOSAIC_TILE_NAME);
576
+ const [state, setState] = useState4({
577
+ type: "idle"
578
+ });
579
+ const allowedEdges = useMemo3(() => allowedEdgesProp || (orientation === "vertical" ? [
580
+ "top",
581
+ "bottom"
582
+ ] : [
583
+ "left",
584
+ "right"
585
+ ]), [
586
+ allowedEdgesProp,
587
+ orientation
588
+ ]);
589
+ const data = useMemo3(() => ({
590
+ type: "tile",
591
+ id,
592
+ containerId,
593
+ data: dataProp,
594
+ location
595
+ }), [
596
+ containerId,
597
+ location,
598
+ dataProp
599
+ ]);
600
+ useLayoutEffect(() => {
601
+ const root = rootRef.current;
602
+ if (!root || !containerId || scrolling) {
603
+ return;
604
+ }
605
+ const handleChange = ({ self, source }) => {
606
+ if (source.data.id !== dataProp.id) {
607
+ const closestEdge = extractClosestEdge(self.data);
608
+ const location2 = data.location + (closestEdge === "top" || closestEdge === "left" ? -0.5 : 0.5);
609
+ setActiveLocation(location2);
610
+ setState({
611
+ type: "target",
612
+ closestEdge
613
+ });
614
+ }
615
+ };
616
+ return combine3(
617
+ // Source.
618
+ draggable({
619
+ element: root,
620
+ dragHandle: dragHandle && state.type !== "preview" ? dragHandle : void 0,
621
+ canDrag: () => true,
622
+ getInitialData: () => data,
623
+ onGenerateDragPreview: ({ location: location2, nativeSetDragImage }) => {
624
+ setCustomNativeDragPreview({
625
+ nativeSetDragImage,
626
+ getOffset: preserveOffsetOnSource({
627
+ element: root,
628
+ input: location2.current.input
629
+ }),
630
+ render: ({ container }) => {
631
+ data.bounds = root.getBoundingClientRect();
632
+ setState({
633
+ type: "preview",
634
+ container,
635
+ rect: root.getBoundingClientRect()
636
+ });
637
+ return () => setState({
638
+ type: "dragging"
639
+ });
640
+ }
641
+ });
642
+ },
643
+ onDragStart: () => {
644
+ setState({
645
+ type: "dragging"
646
+ });
647
+ },
648
+ onDrop: () => {
649
+ setState({
650
+ type: "idle"
651
+ });
652
+ }
653
+ }),
654
+ // Target.
655
+ dropTargetForElements2({
656
+ element: root,
657
+ getData: ({ input, element }) => attachClosestEdge(data, {
658
+ input,
659
+ element,
660
+ allowedEdges
661
+ }),
662
+ canDrop: ({ source }) => {
663
+ const data2 = getSourceData(source);
664
+ return data2 && eventHandler.canDrop?.({
665
+ source: data2
666
+ }) || false;
667
+ },
668
+ onDragEnter: ({ self, source }) => {
669
+ handleChange({
670
+ self,
671
+ source
672
+ });
673
+ },
674
+ onDragLeave: () => {
675
+ setState({
676
+ type: "idle"
677
+ });
678
+ setActiveLocation(void 0);
679
+ },
680
+ onDrag: ({ self, source }) => {
681
+ handleChange({
682
+ self,
683
+ source
684
+ });
685
+ },
686
+ onDrop: () => {
687
+ setState({
688
+ type: "idle"
689
+ });
690
+ setActiveLocation(void 0);
691
+ }
692
+ })
693
+ );
694
+ }, [
695
+ rootRef,
696
+ dragHandle,
697
+ eventHandler,
698
+ data,
699
+ scrolling,
700
+ allowedEdges,
701
+ setActiveLocation
702
+ ]);
703
+ return /* @__PURE__ */ React4.createElement(MosaicTileContextProvider, {
704
+ state
705
+ }, /* @__PURE__ */ React4.createElement(Comp, {
706
+ ...props,
707
+ [`data-${MOSAIC_TILE_STATE_ATTR}`]: state.type,
708
+ role: "listitem",
709
+ className: mx4("relative", className, classNames),
710
+ ref: composedRef
711
+ }, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */ React4.createElement(Comp, {
712
+ // NOTE: Use to control appearance while dragging.
713
+ [`data-${MOSAIC_TILE_STATE_ATTR}`]: state.type,
714
+ // TODO(burdon): Configure drop animation.
715
+ className: mx4("relative", className, classNames),
716
+ style: {
717
+ width: `${state.rect.width}px`,
718
+ height: `${state.rect.height}px`
719
+ }
720
+ }, children), state.container));
721
+ });
722
+ MosaicTile.displayName = MOSAIC_TILE_NAME;
723
+
724
+ // src/components/Mosaic/Placeholder.tsx
725
+ import { dropTargetForElements as dropTargetForElements3 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
726
+ import { DropIndicator as NaturalDropIndicator } from "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box";
727
+ import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
728
+ import { Slot as Slot5 } from "@radix-ui/react-slot";
729
+ import React5, { useLayoutEffect as useLayoutEffect2, useMemo as useMemo4, useRef as useRef5 } from "react";
730
+ import { mx as mx5 } from "@dxos/ui-theme";
731
+ var MOSAIC_PLACEHOLDER_NAME = "Mosaic.Placeholder";
732
+ var MOSAIC_PLACEHOLDER_ORIENTATION_ATTR = "mosaic-placeholder-orientation";
733
+ var MOSAIC_PLACEHOLDER_STATE_ATTR = "mosaic-placeholder-state";
734
+ var MosaicPlaceholder = ({ classNames, children, asChild, orientation = "vertical", location }) => {
735
+ const rootRef = useRef5(null);
736
+ const Comp = asChild ? Slot5 : Primitive5.div;
737
+ const { id: containerId, eventHandler, scrolling, activeLocation, setActiveLocation } = useMosaicContainerContext(MOSAIC_PLACEHOLDER_NAME);
738
+ const data = useMemo4(() => ({
739
+ type: "placeholder",
740
+ containerId,
741
+ location
742
+ }), [
743
+ containerId,
744
+ location
745
+ ]);
746
+ useLayoutEffect2(() => {
747
+ const root = rootRef.current;
748
+ if (!root || scrolling) {
749
+ return;
750
+ }
751
+ return dropTargetForElements3({
752
+ element: root,
753
+ getData: () => data,
754
+ canDrop: ({ source }) => {
755
+ const data2 = getSourceData(source);
756
+ return data2 && eventHandler.canDrop?.({
757
+ source: data2
758
+ }) || false;
759
+ },
760
+ onDragEnter: () => {
761
+ setActiveLocation(data.location);
762
+ },
763
+ onDragLeave: () => {
764
+ setActiveLocation(void 0);
765
+ },
766
+ onDrop: () => {
767
+ setActiveLocation(void 0);
768
+ }
769
+ });
770
+ }, [
771
+ rootRef,
772
+ data,
773
+ scrolling,
774
+ setActiveLocation
775
+ ]);
776
+ return /* @__PURE__ */ React5.createElement(Comp, {
777
+ [`data-${MOSAIC_PLACEHOLDER_ORIENTATION_ATTR}`]: orientation,
778
+ [`data-${MOSAIC_PLACEHOLDER_STATE_ATTR}`]: data.location === activeLocation ? "active" : "idle",
779
+ role: "none",
780
+ className: mx5("relative", classNames),
781
+ ref: rootRef
782
+ }, children);
783
+ };
784
+ MosaicPlaceholder.displayName = MOSAIC_PLACEHOLDER_NAME;
785
+ var DROP_INDICATOR_NAME = "Mosaic.DropIndicator";
786
+ var MosaicDropIndicator = (props) => {
787
+ const { state } = useMosaicTileContext(DROP_INDICATOR_NAME);
788
+ return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React5.createElement(NaturalDropIndicator, {
789
+ ...props,
790
+ edge: state.closestEdge
791
+ }) : null;
792
+ };
793
+ MosaicDropIndicator.displayName = DROP_INDICATOR_NAME;
794
+
795
+ // src/components/Mosaic/Stack.tsx
796
+ import { useVirtualizer } from "@tanstack/react-virtual";
797
+ import React6, { Fragment, forwardRef as forwardRef5 } from "react";
798
+ import { invariant } from "@dxos/invariant";
799
+ import { mx as mx6 } from "@dxos/ui-theme";
800
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Stack.tsx";
801
+ var MOSAIC_STACK_NAME = "MosaicStack";
802
+ var MosaicStackInner = /* @__PURE__ */ forwardRef5(({ classNames, className, role = "list", orientation: orientationProp = "vertical", draggable: draggable2 = true, items, getId, Tile, debug, ...props }, forwardedRef) => {
803
+ invariant(Tile, void 0, {
804
+ F: __dxlog_file2,
805
+ L: 75,
806
+ S: void 0,
807
+ A: [
808
+ "Tile",
809
+ ""
810
+ ]
811
+ });
812
+ const { id, orientation = orientationProp, dragging } = useMosaicContainerContext(MOSAIC_STACK_NAME);
813
+ const visibleItems = useVisibleItems({
814
+ id,
815
+ items,
816
+ dragging: dragging?.source.data,
817
+ getId
818
+ });
819
+ invariant(orientation === "vertical" || orientation === "horizontal", `Invalid orientation: ${orientation}`, {
820
+ F: __dxlog_file2,
821
+ L: 78,
822
+ S: void 0,
823
+ A: [
824
+ "orientation === 'vertical' || orientation === 'horizontal'",
825
+ "`Invalid orientation: ${orientation}`"
826
+ ]
827
+ });
828
+ return /* @__PURE__ */ React6.createElement("div", {
829
+ ...props,
830
+ role,
831
+ className: mx6("flex", orientation === "horizontal" && "h-full [&>*]:shrink-0", orientation === "vertical" && "flex-col", classNames, className),
832
+ ref: forwardedRef
833
+ }, /* @__PURE__ */ React6.createElement(InternalPlaceholder, {
834
+ orientation,
835
+ location: 0.5
836
+ }), visibleItems?.map((item, index) => /* @__PURE__ */ React6.createElement(Fragment, {
837
+ key: getId(item)
838
+ }, /* @__PURE__ */ React6.createElement(Tile, {
839
+ id: getId(item),
840
+ data: item,
841
+ location: index + 1,
842
+ draggable: draggable2,
843
+ debug
844
+ }), /* @__PURE__ */ React6.createElement(InternalPlaceholder, {
845
+ orientation,
846
+ location: index + 1.5
847
+ }))));
848
+ });
849
+ MosaicStackInner.displayName = MOSAIC_STACK_NAME;
850
+ var MosaicStack = MosaicStackInner;
851
+ var MOSAIC_VIRTUAL_STACK_NAME = "MosaicVirtualStack";
852
+ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef5(({ classNames, className, role = "list", orientation = "vertical", items, getId, Tile, estimateSize, getScrollElement, overscan = 8, onChange, debug, ...props }, forwardedRef) => {
853
+ invariant(Tile, void 0, {
854
+ F: __dxlog_file2,
855
+ L: 142,
856
+ S: void 0,
857
+ A: [
858
+ "Tile",
859
+ ""
860
+ ]
861
+ });
862
+ const { id, dragging } = useMosaicContainerContext(MOSAIC_VIRTUAL_STACK_NAME);
863
+ const visibleItems = useVisibleItems({
864
+ id,
865
+ items,
866
+ dragging: dragging?.source.data,
867
+ getId
868
+ });
869
+ const virtualizer = useVirtualizer({
870
+ count: visibleItems.length * 2 + 1,
871
+ estimateSize,
872
+ getScrollElement,
873
+ overscan,
874
+ onChange
875
+ });
876
+ const virtualItems = virtualizer.getVirtualItems();
877
+ return /* @__PURE__ */ React6.createElement("div", {
878
+ ...props,
879
+ role,
880
+ className: mx6("flex", orientation === "horizontal" && "h-full [&>*]:shrink-0", orientation === "vertical" && "flex-col", classNames, className),
881
+ style: {
882
+ position: "relative",
883
+ ...orientation === "vertical" ? {
884
+ width: "100%",
885
+ height: virtualizer.getTotalSize()
886
+ } : {
887
+ width: virtualizer.getTotalSize(),
888
+ height: "100%"
889
+ }
890
+ },
891
+ ref: forwardedRef
892
+ }, virtualItems.map((virtualItem) => {
893
+ const data = visibleItems[Math.floor(virtualItem.index / 2)];
894
+ return /* @__PURE__ */ React6.createElement("div", {
895
+ key: virtualItem.key,
896
+ "data-index": virtualItem.index,
897
+ style: {
898
+ position: "absolute",
899
+ top: 0,
900
+ left: 0,
901
+ ...orientation === "vertical" ? {
902
+ width: "100%",
903
+ transform: `translateY(${virtualItem.start}px)`
904
+ } : {
905
+ height: "100%",
906
+ transform: `translateX(${virtualItem.start}px)`
907
+ }
908
+ },
909
+ ref: virtualizer.measureElement
910
+ }, virtualItem.index % 2 === 0 ? /* @__PURE__ */ React6.createElement(InternalPlaceholder, {
911
+ orientation,
912
+ location: Math.floor(virtualItem.index / 2) + 0.5
913
+ }) : /* @__PURE__ */ React6.createElement(Tile, {
914
+ id: getId(data),
915
+ data,
916
+ location: Math.floor(virtualItem.index / 2) + 1,
917
+ debug
918
+ }));
919
+ }));
920
+ });
921
+ MosaicVirtualStackInner.displayName = MOSAIC_VIRTUAL_STACK_NAME;
922
+ var MosaicVirtualStack = MosaicVirtualStackInner;
923
+ var InternalPlaceholder = (props) => {
924
+ return /* @__PURE__ */ React6.createElement(MosaicPlaceholder, {
925
+ ...props,
926
+ classNames: styles.placeholder.root
927
+ }, /* @__PURE__ */ React6.createElement("div", {
928
+ className: mx6("flex h-full bg-base-surface border border-dashed border-separator rounded-xs", styles.placeholder.content)
929
+ }));
930
+ };
931
+ InternalPlaceholder.displayName = "InternalPlaceholder";
932
+
933
+ // src/components/Mosaic/Mosaic.tsx
934
+ var Mosaic = {
935
+ Root: MosaicRoot,
936
+ Container: MosaicContainer,
937
+ Tile: MosaicTile,
938
+ Placeholder: MosaicPlaceholder,
939
+ DropIndicator: MosaicDropIndicator,
940
+ Stack: MosaicStack,
941
+ VirtualStack: MosaicVirtualStack
942
+ };
943
+
944
+ export {
945
+ useVisibleItems,
946
+ useFocus,
947
+ Focus,
948
+ styles,
949
+ getSourceData,
950
+ useMosaicRootContext,
951
+ useMosaicContainerContext,
952
+ useMosaicTileContext,
953
+ Mosaic
954
+ };
955
+ //# sourceMappingURL=chunk-MK6KU66S.mjs.map