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