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

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