@dxos/react-ui-mosaic 0.7.5-main.e9bb01b → 0.8.4-main.03d5cd7b56

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 (278) hide show
  1. package/README.md +2 -44
  2. package/dist/lib/browser/chunk-RUQB4JIG.mjs +964 -0
  3. package/dist/lib/browser/chunk-RUQB4JIG.mjs.map +7 -0
  4. package/dist/lib/browser/index.mjs +654 -661
  5. package/dist/lib/browser/index.mjs.map +4 -4
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/browser/playwright/index.mjs +231 -0
  8. package/dist/lib/browser/playwright/index.mjs.map +7 -0
  9. package/dist/lib/browser/testing/index.mjs +138 -0
  10. package/dist/lib/browser/testing/index.mjs.map +7 -0
  11. package/dist/lib/browser/translations.mjs +18 -0
  12. package/dist/lib/browser/translations.mjs.map +7 -0
  13. package/dist/lib/node-esm/chunk-MYDCPSNY.mjs +966 -0
  14. package/dist/lib/node-esm/chunk-MYDCPSNY.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +654 -662
  16. package/dist/lib/node-esm/index.mjs.map +4 -4
  17. package/dist/lib/node-esm/meta.json +1 -1
  18. package/dist/lib/node-esm/playwright/index.mjs +233 -0
  19. package/dist/lib/node-esm/playwright/index.mjs.map +7 -0
  20. package/dist/lib/node-esm/testing/index.mjs +139 -0
  21. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  22. package/dist/lib/node-esm/translations.mjs +20 -0
  23. package/dist/lib/node-esm/translations.mjs.map +7 -0
  24. package/dist/types/src/components/Board/Board.d.ts +88 -0
  25. package/dist/types/src/components/Board/Board.d.ts.map +1 -0
  26. package/dist/types/src/components/Board/Board.stories.d.ts +41 -0
  27. package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -0
  28. package/dist/types/src/components/Board/Column.d.ts +40 -0
  29. package/dist/types/src/components/Board/Column.d.ts.map +1 -0
  30. package/dist/types/src/components/Board/Item.d.ts +12 -0
  31. package/dist/types/src/components/Board/Item.d.ts.map +1 -0
  32. package/dist/types/src/components/Board/index.d.ts +2 -0
  33. package/dist/types/src/components/Board/index.d.ts.map +1 -0
  34. package/dist/types/src/components/Focus/Focus.d.ts +2 -0
  35. package/dist/types/src/components/Focus/Focus.d.ts.map +1 -0
  36. package/dist/types/src/components/Focus/index.d.ts +2 -0
  37. package/dist/types/src/components/Focus/index.d.ts.map +1 -0
  38. package/dist/types/src/components/Mosaic/Container.d.ts +45 -0
  39. package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -0
  40. package/dist/types/src/components/Mosaic/Mosaic.d.ts +50 -0
  41. package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -0
  42. package/dist/types/src/components/Mosaic/Placeholder.d.ts +21 -0
  43. package/dist/types/src/components/Mosaic/Placeholder.d.ts.map +1 -0
  44. package/dist/types/src/components/Mosaic/Root.d.ts +35 -0
  45. package/dist/types/src/components/Mosaic/Root.d.ts.map +1 -0
  46. package/dist/types/src/components/Mosaic/Stack.d.ts +29 -0
  47. package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -0
  48. package/dist/types/src/components/Mosaic/Stack.stories.d.ts +20 -0
  49. package/dist/types/src/components/Mosaic/Stack.stories.d.ts.map +1 -0
  50. package/dist/types/src/components/Mosaic/Tile.d.ts +53 -0
  51. package/dist/types/src/components/Mosaic/Tile.d.ts.map +1 -0
  52. package/dist/types/src/components/Mosaic/extension.d.ts +20 -0
  53. package/dist/types/src/components/Mosaic/extension.d.ts.map +1 -0
  54. package/dist/types/src/components/Mosaic/index.d.ts +5 -0
  55. package/dist/types/src/components/Mosaic/index.d.ts.map +1 -0
  56. package/dist/types/src/components/Mosaic/styles.d.ts +7 -0
  57. package/dist/types/src/components/Mosaic/styles.d.ts.map +1 -0
  58. package/dist/types/src/components/Mosaic/types.d.ts +86 -0
  59. package/dist/types/src/components/Mosaic/types.d.ts.map +1 -0
  60. package/dist/types/src/components/SearchStack/SearchStack.d.ts +20 -0
  61. package/dist/types/src/components/SearchStack/SearchStack.d.ts.map +1 -0
  62. package/dist/types/src/components/SearchStack/SearchStack.stories.d.ts +10 -0
  63. package/dist/types/src/components/SearchStack/SearchStack.stories.d.ts.map +1 -0
  64. package/dist/types/src/components/SearchStack/index.d.ts +2 -0
  65. package/dist/types/src/components/SearchStack/index.d.ts.map +1 -0
  66. package/dist/types/src/components/index.d.ts +5 -0
  67. package/dist/types/src/components/index.d.ts.map +1 -0
  68. package/dist/types/src/hooks/index.d.ts +5 -0
  69. package/dist/types/src/hooks/index.d.ts.map +1 -0
  70. package/dist/types/src/hooks/useContainerDebug.d.ts +9 -0
  71. package/dist/types/src/hooks/useContainerDebug.d.ts.map +1 -0
  72. package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts +15 -0
  73. package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts.map +1 -0
  74. package/dist/types/src/hooks/useEventHandlerAdapter.d.ts +32 -0
  75. package/dist/types/src/hooks/useEventHandlerAdapter.d.ts.map +1 -0
  76. package/dist/types/src/hooks/useVisibleItems.d.ts +16 -0
  77. package/dist/types/src/hooks/useVisibleItems.d.ts.map +1 -0
  78. package/dist/types/src/index.d.ts +2 -1
  79. package/dist/types/src/index.d.ts.map +1 -1
  80. package/dist/types/src/playwright/board-manager.d.ts +55 -0
  81. package/dist/types/src/playwright/board-manager.d.ts.map +1 -0
  82. package/dist/types/src/playwright/index.d.ts +9 -0
  83. package/dist/types/src/playwright/index.d.ts.map +1 -0
  84. package/dist/types/src/playwright/playwright.config.d.ts +3 -0
  85. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
  86. package/dist/types/src/playwright/smoke.spec.d.ts +2 -0
  87. package/dist/types/src/playwright/smoke.spec.d.ts.map +1 -0
  88. package/dist/types/src/testing/CardContainer.d.ts +18 -0
  89. package/dist/types/src/testing/CardContainer.d.ts.map +1 -0
  90. package/dist/types/src/testing/DefaultStackTile.d.ts +4 -0
  91. package/dist/types/src/testing/DefaultStackTile.d.ts.map +1 -0
  92. package/dist/types/src/testing/decorator.d.ts +3 -0
  93. package/dist/types/src/testing/decorator.d.ts.map +1 -0
  94. package/dist/types/src/testing/index.d.ts +4 -2
  95. package/dist/types/src/testing/index.d.ts.map +1 -1
  96. package/dist/types/src/testing/types.d.ts +21 -0
  97. package/dist/types/src/testing/types.d.ts.map +1 -0
  98. package/dist/types/src/translations.d.ts +11 -0
  99. package/dist/types/src/translations.d.ts.map +1 -0
  100. package/dist/types/tsconfig.tsbuildinfo +1 -1
  101. package/package.json +84 -43
  102. package/src/AUDIT.md +106 -0
  103. package/src/components/Board/Board.stories.tsx +274 -0
  104. package/src/components/Board/Board.tsx +190 -0
  105. package/src/components/Board/Column.tsx +304 -0
  106. package/src/components/Board/Item.tsx +119 -0
  107. package/src/components/Board/index.ts +5 -0
  108. package/src/components/Focus/Focus.tsx +6 -0
  109. package/src/components/Focus/index.ts +5 -0
  110. package/src/components/Mosaic/Container.tsx +315 -0
  111. package/src/components/Mosaic/Mosaic.tsx +51 -0
  112. package/src/components/Mosaic/Placeholder.tsx +139 -0
  113. package/src/components/Mosaic/Root.tsx +286 -0
  114. package/src/components/Mosaic/Stack.stories.tsx +175 -0
  115. package/src/components/Mosaic/Stack.tsx +341 -0
  116. package/src/components/Mosaic/Tile.tsx +252 -0
  117. package/src/components/Mosaic/extension.ts +141 -0
  118. package/src/components/Mosaic/index.ts +10 -0
  119. package/src/components/Mosaic/styles.ts +32 -0
  120. package/src/components/Mosaic/types.ts +94 -0
  121. package/src/components/SearchStack/SearchStack.stories.tsx +47 -0
  122. package/src/components/SearchStack/SearchStack.tsx +135 -0
  123. package/src/components/SearchStack/index.ts +5 -0
  124. package/src/components/index.ts +8 -0
  125. package/src/hooks/index.ts +8 -0
  126. package/src/hooks/useContainerDebug.tsx +48 -0
  127. package/src/hooks/useDefaultColumnEventHandler.ts +34 -0
  128. package/src/hooks/useEventHandlerAdapter.ts +108 -0
  129. package/src/hooks/useVisibleItems.ts +48 -0
  130. package/src/index.ts +3 -2
  131. package/src/playwright/board-manager.ts +287 -0
  132. package/src/playwright/index.ts +13 -0
  133. package/src/playwright/playwright.config.ts +17 -0
  134. package/src/playwright/smoke.spec.ts +143 -0
  135. package/src/testing/CardContainer.tsx +97 -0
  136. package/src/testing/DefaultStackTile.tsx +58 -0
  137. package/src/testing/decorator.tsx +16 -0
  138. package/src/testing/index.ts +5 -3
  139. package/src/testing/types.ts +38 -0
  140. package/src/translations.ts +19 -0
  141. package/dist/lib/node/index.cjs +0 -705
  142. package/dist/lib/node/index.cjs.map +0 -7
  143. package/dist/lib/node/meta.json +0 -1
  144. package/dist/types/src/mosaic/Container.d.ts +0 -94
  145. package/dist/types/src/mosaic/Container.d.ts.map +0 -1
  146. package/dist/types/src/mosaic/Debug.d.ts +0 -9
  147. package/dist/types/src/mosaic/Debug.d.ts.map +0 -1
  148. package/dist/types/src/mosaic/DefaultComponent.d.ts +0 -4
  149. package/dist/types/src/mosaic/DefaultComponent.d.ts.map +0 -1
  150. package/dist/types/src/mosaic/DragOverlay.d.ts +0 -11
  151. package/dist/types/src/mosaic/DragOverlay.d.ts.map +0 -1
  152. package/dist/types/src/mosaic/Mosaic.d.ts +0 -34
  153. package/dist/types/src/mosaic/Mosaic.d.ts.map +0 -1
  154. package/dist/types/src/mosaic/Root.d.ts +0 -28
  155. package/dist/types/src/mosaic/Root.d.ts.map +0 -1
  156. package/dist/types/src/mosaic/SortableContext.d.ts +0 -14
  157. package/dist/types/src/mosaic/SortableContext.d.ts.map +0 -1
  158. package/dist/types/src/mosaic/Tile.d.ts +0 -74
  159. package/dist/types/src/mosaic/Tile.d.ts.map +0 -1
  160. package/dist/types/src/mosaic/hooks/index.d.ts +0 -5
  161. package/dist/types/src/mosaic/hooks/index.d.ts.map +0 -1
  162. package/dist/types/src/mosaic/hooks/useContainer.d.ts +0 -4
  163. package/dist/types/src/mosaic/hooks/useContainer.d.ts.map +0 -1
  164. package/dist/types/src/mosaic/hooks/useItemsWithOrigin.d.ts +0 -3
  165. package/dist/types/src/mosaic/hooks/useItemsWithOrigin.d.ts.map +0 -1
  166. package/dist/types/src/mosaic/hooks/useItemsWithPreview.d.ts +0 -10
  167. package/dist/types/src/mosaic/hooks/useItemsWithPreview.d.ts.map +0 -1
  168. package/dist/types/src/mosaic/hooks/useMosaic.d.ts +0 -2
  169. package/dist/types/src/mosaic/hooks/useMosaic.d.ts.map +0 -1
  170. package/dist/types/src/mosaic/index.d.ts +0 -5
  171. package/dist/types/src/mosaic/index.d.ts.map +0 -1
  172. package/dist/types/src/mosaic/types.d.ts +0 -10
  173. package/dist/types/src/mosaic/types.d.ts.map +0 -1
  174. package/dist/types/src/mosaic/util/data.d.ts +0 -3
  175. package/dist/types/src/mosaic/util/data.d.ts.map +0 -1
  176. package/dist/types/src/mosaic/util/index.d.ts +0 -5
  177. package/dist/types/src/mosaic/util/index.d.ts.map +0 -1
  178. package/dist/types/src/mosaic/util/path.d.ts +0 -14
  179. package/dist/types/src/mosaic/util/path.d.ts.map +0 -1
  180. package/dist/types/src/mosaic/util/path.test.d.ts +0 -2
  181. package/dist/types/src/mosaic/util/path.test.d.ts.map +0 -1
  182. package/dist/types/src/mosaic/util/props.d.ts +0 -4
  183. package/dist/types/src/mosaic/util/props.d.ts.map +0 -1
  184. package/dist/types/src/mosaic/util/styles.d.ts +0 -3
  185. package/dist/types/src/mosaic/util/styles.d.ts.map +0 -1
  186. package/dist/types/src/testing/Cards.d.ts +0 -10
  187. package/dist/types/src/testing/Cards.d.ts.map +0 -1
  188. package/dist/types/src/testing/generator.d.ts +0 -35
  189. package/dist/types/src/testing/generator.d.ts.map +0 -1
  190. package/dist/types/src/views/Demo/Demo.stories.d.ts +0 -14
  191. package/dist/types/src/views/Demo/Demo.stories.d.ts.map +0 -1
  192. package/dist/types/src/views/Demo/Echo.stories.d.ts +0 -8
  193. package/dist/types/src/views/Demo/Echo.stories.d.ts.map +0 -1
  194. package/dist/types/src/views/Grid/Grid.d.ts +0 -31
  195. package/dist/types/src/views/Grid/Grid.d.ts.map +0 -1
  196. package/dist/types/src/views/Grid/Grid.stories.d.ts +0 -14
  197. package/dist/types/src/views/Grid/Grid.stories.d.ts.map +0 -1
  198. package/dist/types/src/views/Grid/index.d.ts +0 -3
  199. package/dist/types/src/views/Grid/index.d.ts.map +0 -1
  200. package/dist/types/src/views/Grid/layout.d.ts +0 -27
  201. package/dist/types/src/views/Grid/layout.d.ts.map +0 -1
  202. package/dist/types/src/views/Grid/testing.d.ts +0 -11
  203. package/dist/types/src/views/Grid/testing.d.ts.map +0 -1
  204. package/dist/types/src/views/Kanban/Kanban.d.ts +0 -12
  205. package/dist/types/src/views/Kanban/Kanban.d.ts.map +0 -1
  206. package/dist/types/src/views/Kanban/Kanban.stories.d.ts +0 -29
  207. package/dist/types/src/views/Kanban/Kanban.stories.d.ts.map +0 -1
  208. package/dist/types/src/views/Kanban/index.d.ts +0 -2
  209. package/dist/types/src/views/Kanban/index.d.ts.map +0 -1
  210. package/dist/types/src/views/Kanban/testing.d.ts +0 -12
  211. package/dist/types/src/views/Kanban/testing.d.ts.map +0 -1
  212. package/dist/types/src/views/Stack/Columns.stories.d.ts +0 -34
  213. package/dist/types/src/views/Stack/Columns.stories.d.ts.map +0 -1
  214. package/dist/types/src/views/Stack/Stack.d.ts +0 -10
  215. package/dist/types/src/views/Stack/Stack.d.ts.map +0 -1
  216. package/dist/types/src/views/Stack/Stack.stories.d.ts +0 -40
  217. package/dist/types/src/views/Stack/Stack.stories.d.ts.map +0 -1
  218. package/dist/types/src/views/Stack/index.d.ts +0 -2
  219. package/dist/types/src/views/Stack/index.d.ts.map +0 -1
  220. package/dist/types/src/views/Stack/testing.d.ts +0 -10
  221. package/dist/types/src/views/Stack/testing.d.ts.map +0 -1
  222. package/dist/types/src/views/Tree/Graph.stories.d.ts +0 -11
  223. package/dist/types/src/views/Tree/Graph.stories.d.ts.map +0 -1
  224. package/dist/types/src/views/Tree/Tree.d.ts +0 -13
  225. package/dist/types/src/views/Tree/Tree.d.ts.map +0 -1
  226. package/dist/types/src/views/Tree/Tree.stories.d.ts +0 -42
  227. package/dist/types/src/views/Tree/Tree.stories.d.ts.map +0 -1
  228. package/dist/types/src/views/Tree/index.d.ts +0 -2
  229. package/dist/types/src/views/Tree/index.d.ts.map +0 -1
  230. package/dist/types/src/views/Tree/testing.d.ts +0 -11
  231. package/dist/types/src/views/Tree/testing.d.ts.map +0 -1
  232. package/dist/types/src/views/index.d.ts +0 -5
  233. package/dist/types/src/views/index.d.ts.map +0 -1
  234. package/src/mosaic/Container.tsx +0 -190
  235. package/src/mosaic/Debug.tsx +0 -24
  236. package/src/mosaic/DefaultComponent.tsx +0 -26
  237. package/src/mosaic/DragOverlay.tsx +0 -150
  238. package/src/mosaic/Mosaic.ts +0 -100
  239. package/src/mosaic/Root.tsx +0 -320
  240. package/src/mosaic/SortableContext.tsx +0 -61
  241. package/src/mosaic/Tile.tsx +0 -207
  242. package/src/mosaic/hooks/index.ts +0 -8
  243. package/src/mosaic/hooks/useContainer.ts +0 -13
  244. package/src/mosaic/hooks/useItemsWithOrigin.ts +0 -33
  245. package/src/mosaic/hooks/useItemsWithPreview.ts +0 -69
  246. package/src/mosaic/hooks/useMosaic.ts +0 -11
  247. package/src/mosaic/index.ts +0 -9
  248. package/src/mosaic/types.ts +0 -15
  249. package/src/mosaic/util/data.ts +0 -19
  250. package/src/mosaic/util/index.ts +0 -8
  251. package/src/mosaic/util/path.test.ts +0 -24
  252. package/src/mosaic/util/path.ts +0 -21
  253. package/src/mosaic/util/props.ts +0 -14
  254. package/src/mosaic/util/styles.ts +0 -10
  255. package/src/testing/Cards.tsx +0 -88
  256. package/src/testing/generator.ts +0 -131
  257. package/src/views/Demo/Demo.stories.tsx +0 -81
  258. package/src/views/Demo/Echo.stories.tsx +0 -75
  259. package/src/views/Grid/Grid.stories.tsx +0 -51
  260. package/src/views/Grid/Grid.tsx +0 -265
  261. package/src/views/Grid/index.ts +0 -7
  262. package/src/views/Grid/layout.ts +0 -42
  263. package/src/views/Grid/testing.tsx +0 -92
  264. package/src/views/Kanban/Kanban.stories.tsx +0 -51
  265. package/src/views/Kanban/Kanban.tsx +0 -139
  266. package/src/views/Kanban/index.ts +0 -5
  267. package/src/views/Kanban/testing.tsx +0 -234
  268. package/src/views/Stack/Columns.stories.tsx +0 -63
  269. package/src/views/Stack/Stack.stories.tsx +0 -65
  270. package/src/views/Stack/Stack.tsx +0 -58
  271. package/src/views/Stack/index.ts +0 -5
  272. package/src/views/Stack/testing.tsx +0 -77
  273. package/src/views/Tree/Graph.stories.tsx +0 -37
  274. package/src/views/Tree/Tree.stories.tsx +0 -95
  275. package/src/views/Tree/Tree.tsx +0 -126
  276. package/src/views/Tree/index.ts +0 -5
  277. package/src/views/Tree/testing.tsx +0 -142
  278. package/src/views/index.ts +0 -8
@@ -1,705 +1,697 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ Focus,
4
+ Mosaic,
5
+ getSourceData,
6
+ styles,
7
+ useFocus,
8
+ useMosaicContainerContext,
9
+ useMosaicRootContext,
10
+ useMosaicTileContext,
11
+ useVisibleItems
12
+ } from "./chunk-MYDCPSNY.mjs";
2
13
 
3
- // packages/ui/react-ui-mosaic/src/mosaic/hooks/useContainer.ts
4
- import { useContext } from "react";
5
-
6
- // packages/ui/react-ui-mosaic/src/mosaic/Container.tsx
7
- import React, { createContext, useEffect, forwardRef } from "react";
8
- var DEFAULT_TRANSITION = 200;
9
- var DEFAULT_TYPE = "unknown";
10
- var DEFAULT_COMPONENT = /* @__PURE__ */ forwardRef(() => /* @__PURE__ */ React.createElement(React.Fragment, null, "missing component"));
11
- var MosaicOperations = [
12
- "transfer",
13
- "copy",
14
- "rearrange",
15
- "reject"
16
- ];
17
- var MosaicContainerContext = /* @__PURE__ */ createContext({
18
- id: "never",
19
- type: DEFAULT_TYPE,
20
- Component: DEFAULT_COMPONENT
21
- });
22
- var MosaicContainer = ({ children, id, debug, type = DEFAULT_TYPE, Component: Component2 = DEFAULT_COMPONENT, transitionDuration = DEFAULT_TRANSITION, modifier, getOverlayProps, getOverlayStyle, onOver, onDrop, onMove, onDragEnd }) => {
23
- const mosaic = useMosaic();
24
- const container = {
25
- id,
26
- debug,
27
- type,
28
- Component: Component2,
29
- transitionDuration,
30
- modifier,
31
- getOverlayProps,
32
- getOverlayStyle,
33
- onOver,
34
- onDrop,
35
- onMove,
36
- onDragEnd
37
- };
38
- useEffect(() => {
39
- mosaic.setContainer(container.id, container);
40
- return () => {
41
- };
42
- }, Object.values(container));
43
- return /* @__PURE__ */ React.createElement(MosaicContainerContext.Provider, {
44
- value: container
45
- }, children);
46
- };
47
-
48
- // packages/ui/react-ui-mosaic/src/mosaic/hooks/useContainer.ts
49
- var useContainer = () => useContext(MosaicContainerContext);
50
-
51
- // packages/ui/react-ui-mosaic/src/mosaic/hooks/useItemsWithPreview.ts
52
- import { useEffect as useEffect2, useState as useState2 } from "react";
53
-
54
- // packages/ui/react-ui-mosaic/src/mosaic/hooks/useMosaic.ts
55
- import { useContext as useContext2 } from "react";
56
- import { raise } from "@dxos/debug";
14
+ // src/components/Board/Board.tsx
15
+ import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
16
+ import { createContext as createContext2 } from "@radix-ui/react-context";
17
+ import React4, { forwardRef as forwardRef4, useRef as useRef3, useState as useState3 } from "react";
18
+ import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
19
+ import { JsonHighlighter as JsonHighlighter2 } from "@dxos/react-ui-syntax-highlighter";
20
+ import { composable as composable2, composableProps as composableProps2, mx as mx3 } from "@dxos/ui-theme";
57
21
 
58
- // packages/ui/react-ui-mosaic/src/mosaic/Root.tsx
59
- import { DndContext, KeyboardSensor, MouseSensor, pointerWithin, rectIntersection, TouchSensor, useSensor, useSensors } from "@dnd-kit/core";
60
- import { sortableKeyboardCoordinates } from "@dnd-kit/sortable";
61
- import React4, { createContext as createContext2, useState } from "react";
22
+ // src/hooks/useContainerDebug.tsx
23
+ import React, { forwardRef, useMemo, useRef } from "react";
62
24
  import { createPortal } from "react-dom";
63
- import { pick } from "@dxos/util";
64
-
65
- // packages/ui/react-ui-mosaic/src/mosaic/Debug.tsx
66
- import React2 from "react";
67
- import { mx } from "@dxos/react-ui-theme";
68
- var Debug = ({ data, position }) => /* @__PURE__ */ React2.createElement("pre", {
69
- className: mx("font-mono text-xs overflow-hidden m-2 p-1 z-[100]", "bg-neutral-50 dark:bg-neutral-700 border border-neutral-300 rounded", position === "bottom-left" && "fixed left-0 bottom-0", position === "bottom-right" && "fixed right-0 bottom-0")
70
- }, JSON.stringify(data, void 0, 1));
71
-
72
- // packages/ui/react-ui-mosaic/src/mosaic/DefaultComponent.tsx
73
- import React3, { forwardRef as forwardRef2 } from "react";
74
- import { Card } from "@dxos/react-ui-card";
75
-
76
- // packages/ui/react-ui-mosaic/src/mosaic/util/data.ts
77
- import { arrayMove } from "@dxos/util";
78
- var swapItems = (items, from, to) => {
79
- const fromIndex = items.findIndex((item) => item.id === from.id);
80
- const toIndex = items.findIndex((item) => item.id === to.id);
81
- return fromIndex !== -1 && toIndex !== -1 ? arrayMove(items, fromIndex, toIndex) : items;
82
- };
83
-
84
- // packages/ui/react-ui-mosaic/src/mosaic/util/path.ts
85
- var SEPARATOR = "~";
86
- var Path = {
87
- create: (...args) => args.join(SEPARATOR),
88
- parts: (path) => path.split(SEPARATOR),
89
- length: (path) => path.split(SEPARATOR).length,
90
- first: (path) => path.split(SEPARATOR)[0] ?? path,
91
- last: (path) => path.split(SEPARATOR).at(-1) ?? path,
92
- parent: (path) => path.split(SEPARATOR).slice(0, -1).join(SEPARATOR),
93
- hasRoot: (path, id) => Path.first(path) === id,
94
- hasChild: (path, compare) => Path.parent(compare) === path,
95
- hasDescendent: (path, compare) => compare !== path && compare.startsWith(path),
96
- siblings: (path, compare) => Path.parent(path) === Path.parent(compare),
97
- onPath: (path, id) => Path.parts(path).includes(id)
25
+ import { JsonHighlighter } from "@dxos/react-ui-syntax-highlighter";
26
+ import { mx } from "@dxos/ui-theme";
27
+ var useContainerDebug = (debug) => {
28
+ const debugRef = useRef(null);
29
+ return useMemo(() => {
30
+ if (!debug) {
31
+ return [
32
+ () => null,
33
+ void 0
34
+ ];
35
+ }
36
+ return [
37
+ ({ classNames }) => /* @__PURE__ */ React.createElement("div", {
38
+ className: mx("overflow-hidden", classNames),
39
+ ref: debugRef
40
+ }),
41
+ () => debugRef.current && /* @__PURE__ */ createPortal(/* @__PURE__ */ React.createElement(ContainerInfo, null), debugRef.current)
42
+ ];
43
+ }, [
44
+ debug,
45
+ debugRef
46
+ ]);
98
47
  };
99
-
100
- // packages/ui/react-ui-mosaic/src/mosaic/util/props.ts
101
- var isTileProps = (props) => typeof props.path === "string" && typeof props.item === "object" && props.item ? "id" in props.item && typeof props.item.id === "string" : false;
102
- var isTileComponentProps = (props) => isTileProps(props) && typeof props.operation === "string" && MosaicOperations.includes(props.operation);
103
-
104
- // packages/ui/react-ui-mosaic/src/mosaic/util/styles.ts
105
- import { CSS } from "@dnd-kit/utilities";
106
- var getTransformCSS = (transform) => transform ? CSS.Transform.toString(Object.assign(transform, {
107
- scaleX: 1,
108
- scaleY: 1
109
- })) : void 0;
110
-
111
- // packages/ui/react-ui-mosaic/src/mosaic/DefaultComponent.tsx
112
- var DefaultComponent = /* @__PURE__ */ forwardRef2(({ draggableStyle, draggableProps, item: { id }, path }, forwardRef4) => {
113
- return /* @__PURE__ */ React3.createElement(Card.Root, {
114
- ref: forwardRef4,
115
- style: draggableStyle
116
- }, /* @__PURE__ */ React3.createElement(Card.Header, null, /* @__PURE__ */ React3.createElement(Card.DragHandle, draggableProps), /* @__PURE__ */ React3.createElement(Card.Title, {
117
- title: Path.create(path, id),
118
- classNames: "truncate font-mono text-xs"
119
- })));
48
+ var CONTAINER_INFO_NAME = "ContainerInfo";
49
+ var ContainerInfo = /* @__PURE__ */ forwardRef(({ classNames }, forwardedRef) => {
50
+ const { id, state, activeLocation, scrolling } = useMosaicContainerContext(CONTAINER_INFO_NAME);
51
+ const counter = useRef(0);
52
+ return /* @__PURE__ */ React.createElement(JsonHighlighter, {
53
+ data: {
54
+ id,
55
+ activeLocation,
56
+ scrolling,
57
+ state,
58
+ count: counter.current++
59
+ },
60
+ classNames: mx("text-xs", classNames),
61
+ ref: forwardedRef
62
+ });
120
63
  });
121
- DefaultComponent.displayName = "DefaultComponent";
64
+ ContainerInfo.displayName = CONTAINER_INFO_NAME;
122
65
 
123
- // packages/ui/react-ui-mosaic/src/mosaic/Root.tsx
124
- var DEFAULT_COMPONENT_ID = "__default";
125
- var MosaicContext = /* @__PURE__ */ createContext2(void 0);
126
- var defaultDropAnimation = {
127
- duration: 0
128
- };
129
- var MosaicRoot = ({ Component: Component2 = DefaultComponent, debug, children }) => {
130
- const [containers, setContainers] = useState({
131
- [DEFAULT_COMPONENT_ID]: {
132
- id: DEFAULT_COMPONENT_ID,
133
- Component: Component2
134
- }
135
- });
136
- const handleSetContainer = (id, container) => {
137
- setContainers((containers2) => {
138
- if (container) {
139
- return {
140
- ...containers2,
141
- [id]: container
142
- };
66
+ // src/hooks/useEventHandlerAdapter.ts
67
+ import { useMemo as useMemo2 } from "react";
68
+ import { log } from "@dxos/log";
69
+ import { arrayMove } from "@dxos/util";
70
+ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/hooks/useEventHandlerAdapter.ts";
71
+ var useEventHandlerAdapter = ({ items, getId, get, make, onChange, ...props }) => {
72
+ return useMemo2(() => ({
73
+ ...props,
74
+ onTake: ({ source }, cb) => {
75
+ log.info("onTake", {
76
+ source
77
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 14, S: void 0 });
78
+ const mutate = (items2) => {
79
+ const from = items2.findIndex((item) => getId(item) === source.id);
80
+ if (from !== -1) {
81
+ items2.splice(from, 1);
82
+ }
83
+ };
84
+ if (onChange) {
85
+ onChange(mutate);
143
86
  } else {
144
- const { [id]: _, ...rest } = containers2;
145
- return rest;
87
+ mutate(items);
146
88
  }
147
- });
148
- };
149
- const [activeItem, setActiveItem] = useState();
150
- const [overItem, setOverItem] = useState();
151
- const [operation, setOperation] = useState("reject");
152
- const [moveDetails, setMoveDetails] = useState();
153
- const [dropAnimation, setDropAnimation] = useState(defaultDropAnimation);
154
- const collisionDetection = (args) => {
155
- const pointerCollisions = pointerWithin(args);
156
- if (pointerCollisions.length > 0) {
157
- return pointerCollisions;
158
- }
159
- return rectIntersection(args);
160
- };
161
- const modifiers = (props) => {
162
- const { transform } = props;
163
- if (activeItem) {
164
- const container = containers[Path.first(activeItem.path)];
165
- return container?.modifier?.(activeItem, props) ?? transform;
166
- } else {
167
- return transform;
168
- }
169
- };
170
- const sensors = useSensors(useSensor(MouseSensor, {
171
- activationConstraint: {
172
- distance: 10
173
- }
174
- }), useSensor(TouchSensor, {
175
- activationConstraint: {
176
- delay: 200,
177
- tolerance: 5
178
- }
179
- }), useSensor(KeyboardSensor, {
180
- coordinateGetter: sortableKeyboardCoordinates
181
- }));
182
- const handleDragStart = (event) => {
183
- setActiveItem(pick(event.active.data.current, [
184
- "path",
185
- "type",
186
- "item",
187
- "position"
188
- ]));
189
- };
190
- const handleDragMove = (event) => {
191
- const nextOverItem = pick(event.over?.data.current, [
192
- "path",
193
- "type",
194
- "item",
195
- "position"
196
- ]);
197
- const nextOverContainer = nextOverItem && nextOverItem?.path ? containers[Path.first(nextOverItem.path)] : void 0;
198
- if (!event.over || !nextOverItem || !nextOverContainer) {
199
- setOperation("reject");
200
- setOverItem(void 0);
201
- return;
202
- }
203
- if (overItem !== nextOverItem) {
204
- setOverItem(nextOverItem);
205
- }
206
- if (activeItem && nextOverItem && nextOverContainer?.onMove) {
207
- const { operation: nextOperation, details: nextDetails } = nextOverContainer.onMove({
208
- active: activeItem,
209
- over: nextOverItem,
210
- details: {
211
- delta: event.delta
89
+ void cb(source.data);
90
+ },
91
+ onDrop: ({ source, target }) => {
92
+ log.info("onDrop", {
93
+ source,
94
+ target
95
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 31, S: void 0 });
96
+ const mutate = (items2) => {
97
+ const to = target?.type === "tile" || target?.type === "placeholder" ? target.location : target?.type === "container" ? items2.length : -1;
98
+ const from = items2.findIndex((item) => getId(item) === source.id);
99
+ const insertIndex = typeof to === "number" && to >= 0 ? Math.floor(to) : -1;
100
+ if (insertIndex !== -1) {
101
+ if (from !== -1) {
102
+ arrayMove(items2, from, insertIndex);
103
+ } else {
104
+ items2.splice(insertIndex, 0, make(get(source.data)));
105
+ }
212
106
  }
213
- });
214
- setOperation(nextOperation);
215
- if (
216
- // always set falsy symbols
217
- !nextDetails || // always set if details become truthy
218
- !moveDetails && nextDetails || // only update if details change
219
- Object.entries(nextDetails).find(([key, value]) => !(key in moveDetails) || moveDetails[key] !== value)
220
- ) {
221
- setMoveDetails(nextDetails);
107
+ };
108
+ if (onChange) {
109
+ onChange(mutate);
110
+ } else {
111
+ mutate(items);
222
112
  }
223
113
  }
114
+ }), [
115
+ items,
116
+ onChange
117
+ ]);
118
+ };
119
+
120
+ // src/hooks/useDefaultColumnEventHandler.ts
121
+ var useDefaultColumnEventHandler = (id, model, items) => useEventHandlerAdapter({
122
+ id,
123
+ items,
124
+ getId: model.getColumnId,
125
+ get: (data) => data,
126
+ make: (object) => object,
127
+ canDrop: ({ source }) => model.isColumn(source.data)
128
+ });
129
+
130
+ // src/components/Mosaic/extension.ts
131
+ import { StateEffect, StateField } from "@codemirror/state";
132
+ import { Decoration, EditorView, ViewPlugin, WidgetType } from "@codemirror/view";
133
+ var dropHandler = ({ onDrop = handleDrop } = {}) => {
134
+ const views = /* @__PURE__ */ new Set();
135
+ let state = null;
136
+ const reset = () => {
137
+ views.forEach((view) => view.dispatch({
138
+ effects: setDrop.of(null)
139
+ }));
140
+ state = null;
224
141
  };
225
- const handleDragOver = (event) => {
226
- const overItem2 = pick(event.over?.data.current, [
227
- "path",
228
- "type",
229
- "item",
230
- "position"
231
- ]);
232
- const overContainer = overItem2 && overItem2?.path ? containers[Path.first(overItem2.path)] : void 0;
233
- if (overContainer?.onMove) {
234
- return;
235
- }
236
- const activeContainer = activeItem && containers[Path.first(activeItem.path)];
237
- if (!event.over || !overItem2 || !overContainer || !activeItem || !activeContainer) {
238
- setOperation("reject");
239
- setOverItem(void 0);
240
- return;
241
- }
242
- let operation2 = "reject";
243
- if (overContainer.onOver) {
244
- operation2 = overContainer.onOver({
245
- active: activeItem,
246
- over: overItem2,
247
- details: moveDetails
142
+ const extension = [
143
+ dropField,
144
+ ViewPlugin.fromClass(class {
145
+ _view;
146
+ constructor(_view) {
147
+ this._view = _view;
148
+ views.add(_view);
149
+ }
150
+ destroy() {
151
+ views.delete(this._view);
152
+ }
153
+ })
154
+ ];
155
+ return {
156
+ extension,
157
+ update: (position) => {
158
+ if (!position) {
159
+ reset();
160
+ return;
161
+ }
162
+ views.forEach((view) => {
163
+ const rect = view.dom.getBoundingClientRect();
164
+ if (position.x >= rect.left && position.x <= rect.right && position.y >= rect.top && position.y <= rect.bottom) {
165
+ let pos = view.posAtCoords(position);
166
+ if (pos !== null) {
167
+ const word = view.state.wordAt(pos);
168
+ if (word) {
169
+ const startDist = Math.abs(pos - word.from);
170
+ const endDist = Math.abs(pos - word.to);
171
+ pos = startDist < endDist ? word.from : word.to;
172
+ }
173
+ view.dispatch({
174
+ effects: setDrop.of(pos)
175
+ });
176
+ state = {
177
+ view,
178
+ pos
179
+ };
180
+ return;
181
+ }
182
+ }
183
+ view.dispatch({
184
+ effects: setDrop.of(null)
185
+ });
248
186
  });
249
- }
250
- setOperation(operation2);
251
- setOverItem(overItem2);
252
- };
253
- const handleDragCancel = (event) => {
254
- setOperation("reject");
255
- setActiveItem(void 0);
256
- setOverItem(void 0);
257
- };
258
- const handleDragEnd = (event) => {
259
- const overContainer = overItem && containers[Path.first(overItem.path)];
260
- if (operation !== "reject" && activeItem && overItem) {
261
- let nextDropAnimation = defaultDropAnimation;
262
- const activeContainer = containers[Path.first(activeItem.path)];
263
- if (activeContainer) {
264
- nextDropAnimation = activeContainer.onDrop?.({
265
- operation,
266
- active: activeItem,
267
- over: overItem,
268
- details: moveDetails
187
+ },
188
+ cancel: () => {
189
+ reset();
190
+ },
191
+ drop: ({ text, url }) => {
192
+ if (state) {
193
+ onDrop(state.view, state.pos, {
194
+ text,
195
+ url
269
196
  });
270
- if (overContainer && overContainer !== activeContainer) {
271
- nextDropAnimation = overContainer.onDrop?.({
272
- operation,
273
- active: activeItem,
274
- over: overItem,
275
- details: moveDetails
276
- });
277
- }
278
197
  }
279
- setDropAnimation(nextDropAnimation);
198
+ reset();
280
199
  }
281
- Object.values(containers).forEach((container) => container?.onDragEnd?.(event));
282
- setTimeout(() => {
283
- setOperation("reject");
284
- setOverItem(void 0);
285
- setActiveItem(void 0);
286
- }, overContainer?.transitionDuration ?? DEFAULT_TRANSITION);
287
200
  };
288
- return /* @__PURE__ */ React4.createElement(MosaicContext.Provider, {
289
- value: {
290
- containers,
291
- setContainer: handleSetContainer,
292
- activeItem,
293
- overItem,
294
- operation,
295
- moveDetails,
296
- dropAnimation
297
- }
298
- }, /* @__PURE__ */ React4.createElement(DndContext, {
299
- collisionDetection,
300
- modifiers: [
301
- modifiers
302
- ],
303
- sensors,
304
- // TODO(burdon): Allow container to veto drop.
305
- cancelDrop: (event) => false,
306
- onDragStart: handleDragStart,
307
- onDragMove: handleDragMove,
308
- onDragOver: handleDragOver,
309
- onDragCancel: handleDragCancel,
310
- onDragEnd: handleDragEnd
311
- }, children, debug && /* @__PURE__ */ createPortal(/* @__PURE__ */ React4.createElement(MosaicDebug, {
312
- containers,
313
- operation,
314
- activeItem,
315
- overItem
316
- }), document.body)));
317
201
  };
318
- var MosaicDebug = ({ containers, operation, activeItem, overItem }) => {
319
- return /* @__PURE__ */ React4.createElement(Debug, {
320
- position: "bottom-right",
321
- data: {
322
- containers: Object.keys(containers).map((id) => id),
323
- operation,
324
- active: {
325
- id: activeItem?.item?.id.slice(0, 16),
326
- path: activeItem?.path && Path.create(...Path.parts(activeItem.path).map((part) => part.slice(0, 16))),
327
- type: activeItem?.type,
328
- position: activeItem?.position
202
+ var handleDrop = (view, pos, event) => {
203
+ const line = view.state.doc.lineAt(pos);
204
+ if (line.text.trim() === "") {
205
+ view.dispatch({
206
+ changes: {
207
+ from: pos,
208
+ insert: `
209
+ ![${event.text}](${event.url})
210
+ `
329
211
  },
330
- over: {
331
- id: overItem?.item?.id.slice(0, 16),
332
- path: overItem?.path && Path.create(...Path.parts(overItem.path).map((part) => part.slice(0, 16))),
333
- type: overItem?.type,
334
- position: overItem?.position
335
- }
336
- }
337
- });
338
- };
339
-
340
- // packages/ui/react-ui-mosaic/src/mosaic/hooks/useMosaic.ts
341
- var useMosaic = () => useContext2(MosaicContext) ?? raise(new Error("Missing MosaicContext"));
342
-
343
- // packages/ui/react-ui-mosaic/src/mosaic/hooks/useItemsWithPreview.ts
344
- var useItemsWithPreview = ({ path, items }) => {
345
- const { operation, activeItem, overItem } = useMosaic();
346
- const [itemsWithPreview, setItemsWithPreview] = useState2(items);
347
- const overParent = (
348
- // If over the sortable context itself & active item is foreign, then treat self as the parent.
349
- // This allows items to be appended to the end of the sortable.
350
- overItem?.path === path && activeItem && Path.parent(activeItem.path) !== overItem.path ? path : overItem && !!overItem.path && Path.parent(overItem.path)
351
- );
352
- const [lastOverParent, setLastOverParent] = useState2(overParent);
353
- useEffect2(() => {
354
- if (!activeItem || !overItem) {
355
- setLastOverParent(void 0);
356
- setItemsWithPreview(items);
357
- return;
358
- }
359
- if (lastOverParent === overParent) {
360
- return;
361
- }
362
- const activeIsChild = Path.hasChild(path, activeItem.path);
363
- const overIsChild = Path.hasChild(path, overItem.path);
364
- const overSelf = overItem.path === path;
365
- if (operation === "reject" || operation === "rearrange") {
366
- setLastOverParent(void 0);
367
- setItemsWithPreview(items);
368
- return;
369
- } else {
370
- setLastOverParent(overParent);
371
- }
372
- if (!activeIsChild && overIsChild) {
373
- setItemsWithPreview((items2) => {
374
- const position = overItem.position;
375
- return [
376
- ...items2.slice(0, position),
377
- activeItem.item,
378
- ...items2.slice(position)
379
- ];
380
- });
381
- } else if (!activeIsChild && overSelf) {
382
- setItemsWithPreview((items2) => [
383
- ...items2,
384
- activeItem.item
385
- ]);
386
- } else if (activeIsChild && !overIsChild) {
387
- setItemsWithPreview((items2) => items2.filter((item) => item.id !== activeItem.item.id));
388
- } else {
389
- setItemsWithPreview(items);
390
- }
391
- }, [
392
- operation,
393
- activeItem,
394
- overItem,
395
- overParent,
396
- lastOverParent,
397
- path,
398
- items
399
- ]);
400
- return items.length === itemsWithPreview.length ? items : itemsWithPreview;
401
- };
402
-
403
- // packages/ui/react-ui-mosaic/src/mosaic/hooks/useItemsWithOrigin.ts
404
- var useItemsWithOrigin = (path, items) => {
405
- const { operation, activeItem, overItem } = useMosaic();
406
- if (!activeItem || !overItem) {
407
- return items;
408
- }
409
- const activeIsChild = Path.hasChild(path, activeItem.path);
410
- const overIsChild = Path.hasChild(path, overItem.path);
411
- if (activeIsChild && !overIsChild && operation !== "rearrange") {
412
- return items.map((item) => {
413
- if (item.id === activeItem.item.id) {
414
- return {
415
- ...item,
416
- id: `${item.id}--origin`
417
- };
418
- } else {
419
- return item;
420
- }
212
+ effects: setDrop.of(null)
421
213
  });
422
214
  } else {
423
- return items;
215
+ view.dispatch({
216
+ changes: {
217
+ from: pos,
218
+ insert: ` [${event.text}](${event.url})`
219
+ },
220
+ effects: setDrop.of(null)
221
+ });
424
222
  }
425
223
  };
426
-
427
- // packages/ui/react-ui-mosaic/src/mosaic/DragOverlay.tsx
428
- import { DragOverlay } from "@dnd-kit/core";
429
- import React5, { Component, useEffect as useEffect3, useRef, useState as useState3 } from "react";
430
- import { log } from "@dxos/log";
431
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-mosaic/src/mosaic/DragOverlay.tsx";
432
- var MosaicDragOverlay = ({ delay = 200, debug = false, ...overlayProps }) => {
433
- const { containers, operation, activeItem, overItem, dropAnimation } = useMosaic();
434
- const [state, setState] = useState3({});
435
- const timer = useRef();
436
- useEffect3(() => {
437
- if (activeItem && operation !== "reject") {
438
- let container2;
439
- let OverlayComponent2;
440
- if (overItem?.path) {
441
- container2 = containers[Path.first(overItem.path)];
442
- OverlayComponent2 = container2?.Component;
443
- }
444
- if (!OverlayComponent2) {
445
- container2 = containers[Path.first(activeItem.path)];
446
- OverlayComponent2 = container2?.Component ?? DefaultComponent;
224
+ var setDrop = StateEffect.define();
225
+ var dropField = StateField.define({
226
+ create: () => Decoration.none,
227
+ update: (decorations, tr) => {
228
+ for (const effect of tr.effects) {
229
+ if (effect.is(setDrop)) {
230
+ if (effect.value === null) {
231
+ return Decoration.none;
232
+ }
233
+ return Decoration.set([
234
+ Decoration.widget({
235
+ widget: new class extends WidgetType {
236
+ toDOM() {
237
+ const dom = document.createElement("span");
238
+ dom.className = "cm-drop-cursor";
239
+ dom.style.borderLeft = "2px solid var(--color-accent-surface)";
240
+ dom.style.display = "inline-block";
241
+ dom.style.height = "1em";
242
+ dom.style.verticalAlign = "middle";
243
+ return dom;
244
+ }
245
+ }(),
246
+ side: 0
247
+ }).range(effect.value)
248
+ ]);
447
249
  }
448
- clearTimeout(timer.current);
449
- timer.current = setTimeout(() => setState({
450
- container: container2,
451
- OverlayComponent: OverlayComponent2
452
- }), timer.current ? delay : 0);
453
- } else {
454
- setState({});
455
250
  }
456
- }, [
457
- activeItem,
458
- overItem
251
+ return decorations.map(tr.changes);
252
+ },
253
+ provide: (field) => EditorView.decorations.from(field)
254
+ });
255
+
256
+ // src/components/Board/Column.tsx
257
+ import { useAtomValue } from "@effect-atom/atom-react";
258
+ import { createContext } from "@radix-ui/react-context";
259
+ import React3, { forwardRef as forwardRef3, useMemo as useMemo4, useState as useState2 } from "react";
260
+ import { Obj as Obj2, Ref } from "@dxos/echo";
261
+ import { useObject } from "@dxos/react-client/echo";
262
+ import { IconButton, ScrollArea, Toolbar as Toolbar2, useTranslation as useTranslation2 } from "@dxos/react-ui";
263
+ import { Menu as Menu2, createMenuAction as createMenuAction2 } from "@dxos/react-ui-menu";
264
+ import { composable, composableProps, mx as mx2 } from "@dxos/ui-theme";
265
+ import { translationKey as translationKey2 } from "#translations";
266
+
267
+ // src/components/Board/Item.tsx
268
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
269
+ import React2, { forwardRef as forwardRef2, useMemo as useMemo3, useRef as useRef2, useState } from "react";
270
+ import { Obj } from "@dxos/echo";
271
+ import { Card, Tag, Toolbar, useTranslation } from "@dxos/react-ui";
272
+ import { Menu, createMenuAction } from "@dxos/react-ui-menu";
273
+ import { getHashStyles } from "@dxos/ui-theme";
274
+ import { translationKey } from "#translations";
275
+ var BOARD_ITEM_NAME = "Board.Item";
276
+ var BoardItemInner = /* @__PURE__ */ forwardRef2(({ classNames, data, location, debug, draggable }, forwardedRef) => {
277
+ const { t } = useTranslation(translationKey);
278
+ const rootRef = useRef2(null);
279
+ const composedRef = useComposedRefs(rootRef, forwardedRef);
280
+ const [dragHandle, setDragHandle] = useState(null);
281
+ const { model } = useBoard(BOARD_ITEM_NAME);
282
+ const column = useBoardColumn();
283
+ const items = useMemo3(() => column != null && model.onItemDelete ? [
284
+ createMenuAction("delete-item", () => model.onItemDelete?.(column, data), {
285
+ label: t("delete-menu.label"),
286
+ icon: "ph--trash--regular"
287
+ })
288
+ ] : [], [
289
+ column,
290
+ data,
291
+ model.onItemDelete,
292
+ t
459
293
  ]);
460
- const container = state.container ?? (activeItem && containers[Path.first(activeItem.path)]);
461
- const OverlayComponent = state.OverlayComponent ?? container?.Component;
462
- const FallbackComponent = (activeItem && containers[Path.first(activeItem.path)])?.Component ?? DefaultComponent;
463
- return (
464
- // TODO(burdon): Set custom animations (e.g., in/out/around).
465
- /* @__PURE__ */ React5.createElement(DragOverlay, {
466
- adjustScale: false,
467
- ...overlayProps,
468
- dropAnimation,
469
- style: {
470
- ...container?.getOverlayStyle?.()
471
- }
472
- }, activeItem?.path && container && OverlayComponent && /* @__PURE__ */ React5.createElement(OverlayErrorBoundary, {
473
- fallback: /* @__PURE__ */ React5.createElement(FallbackComponent, {
474
- ...container.getOverlayProps?.(),
475
- item: activeItem.item,
476
- path: activeItem.path,
477
- operation,
478
- active: "overlay"
479
- })
480
- }, /* @__PURE__ */ React5.createElement(OverlayComponent, {
481
- ...container.getOverlayProps?.(),
482
- item: activeItem.item,
483
- path: activeItem.path,
484
- type: activeItem.type,
485
- operation,
486
- active: "overlay"
487
- }), debug && /* @__PURE__ */ React5.createElement("div", {
488
- className: "flex flex-wrap mt-1 p-1 bg-neutral-50 dark:bg-neutral-700 text-xs border rounded overflow-hidden gap-1"
489
- }, /* @__PURE__ */ React5.createElement("span", {
490
- className: "truncate"
491
- }, /* @__PURE__ */ React5.createElement("span", {
492
- className: "text-neutral-400"
493
- }, "container "), container.id), /* @__PURE__ */ React5.createElement("span", {
494
- className: "truncate"
495
- }, /* @__PURE__ */ React5.createElement("span", {
496
- className: "text-neutral-400"
497
- }, "item "), activeItem.item.id.slice(0, 8)))))
498
- );
499
- };
500
- var OverlayErrorBoundary = class extends Component {
501
- constructor(props) {
502
- super(props);
503
- this.state = {
504
- error: null
505
- };
506
- this.fallback = props.fallback ?? /* @__PURE__ */ React5.createElement("p", null, "ERROR: $", String(this.state.error));
507
- }
508
- static getDerivedStateFromError(error) {
509
- return {
510
- error
511
- };
294
+ if (!data) {
295
+ return null;
512
296
  }
513
- componentDidCatch(error, info) {
514
- log.catch(error, {
515
- info
516
- }, {
517
- F: __dxlog_file,
518
- L: 140,
519
- S: this,
520
- C: (f, a) => f(...a)
521
- });
522
- }
523
- render() {
524
- if (this.state.error) {
525
- return this.fallback;
526
- }
527
- return this.props.children;
528
- }
529
- };
297
+ const label = Obj.getLabel(data);
298
+ const description = Obj.getDescription(data);
299
+ return /* @__PURE__ */ React2.createElement(Menu.Root, null, /* @__PURE__ */ React2.createElement(Mosaic.Tile, {
300
+ ref: rootRef,
301
+ asChild: true,
302
+ draggable,
303
+ dragHandle,
304
+ id: data.id,
305
+ data,
306
+ location,
307
+ debug
308
+ }, /* @__PURE__ */ React2.createElement(Focus.Item, {
309
+ asChild: true
310
+ }, /* @__PURE__ */ React2.createElement(Card.Root, {
311
+ classNames,
312
+ "data-testid": "board-item",
313
+ ref: composedRef,
314
+ onClick: (event) => event.currentTarget.focus()
315
+ }, /* @__PURE__ */ React2.createElement(Card.Toolbar, null, /* @__PURE__ */ React2.createElement(Card.DragHandle, {
316
+ ref: setDragHandle,
317
+ testId: "mosaicBoard.cardDragHandle"
318
+ }), /* @__PURE__ */ React2.createElement(Card.Title, {
319
+ "data-testid": "mosaicBoard.cardTitle"
320
+ }, label), /* @__PURE__ */ React2.createElement(Menu.Trigger, {
321
+ asChild: true,
322
+ disabled: !items?.length
323
+ }, /* @__PURE__ */ React2.createElement(Toolbar.IconButton, {
324
+ iconOnly: true,
325
+ variant: "ghost",
326
+ icon: "ph--dots-three-vertical--regular",
327
+ label: t("action-menu.label")
328
+ })), /* @__PURE__ */ React2.createElement(Menu.Content, {
329
+ items
330
+ })), /* @__PURE__ */ React2.createElement(Card.Row, {
331
+ icon: "ph--note--regular",
332
+ classNames: "text-description"
333
+ }, /* @__PURE__ */ React2.createElement(Card.Text, null, description)), /* @__PURE__ */ React2.createElement(Card.Row, {
334
+ icon: "ph--tag--regular"
335
+ }, label && /* @__PURE__ */ React2.createElement("div", {
336
+ className: "shrink-0 flex gap-1 items-center text-xs"
337
+ }, /* @__PURE__ */ React2.createElement(Tag, {
338
+ palette: getHashStyles(label).hue
339
+ }, label)))))));
340
+ });
341
+ BoardItemInner.displayName = BOARD_ITEM_NAME;
342
+ var BoardItem = BoardItemInner;
530
343
 
531
- // packages/ui/react-ui-mosaic/src/mosaic/SortableContext.tsx
532
- import { SortableContext, horizontalListSortingStrategy, verticalListSortingStrategy } from "@dnd-kit/sortable";
533
- import React6 from "react";
534
- var MosaicSortableContext = ({ id, items = [], direction = "vertical", children }) => {
535
- const { operation, activeItem, overItem } = useMosaic();
536
- const container = useContainer();
537
- const contextId = id ?? container.id;
538
- const Sortable = direction === "vertical" ? Column : Row;
539
- const ids = items.map((item) => {
540
- const path = Path.create(contextId, item.id);
541
- const isPreview = activeItem && activeItem.item.id === item.id && overItem && overItem.path && (Path.siblings(overItem.path, path) || Path.hasChild(overItem.path, path)) && operation !== "reject";
542
- return isPreview ? activeItem.path : path;
344
+ // src/components/Board/Column.tsx
345
+ var BOARD_COLUMN_CONTEXT_NAME = "Board.Column";
346
+ var [BoardColumnProvider, useBoardColumnContext] = createContext(BOARD_COLUMN_CONTEXT_NAME, null);
347
+ function useBoardColumn() {
348
+ const value = useBoardColumnContext(BOARD_COLUMN_CONTEXT_NAME);
349
+ return value?.column;
350
+ }
351
+ var BOARD_COLUMN_ROOT_NAME = "Board.Column.Root";
352
+ var BoardColumnRootInner = composable(({ classNames, children, location, data, debug, draggable, dragHandle, ...rest }, forwardedRef) => {
353
+ const { model } = useBoard(BOARD_COLUMN_ROOT_NAME);
354
+ return /* @__PURE__ */ React3.createElement(Mosaic.Tile, {
355
+ asChild: true,
356
+ location,
357
+ id: model.getColumnId(data),
358
+ data,
359
+ debug,
360
+ draggable,
361
+ dragHandle
362
+ }, /* @__PURE__ */ React3.createElement(Focus.Group, {
363
+ ...rest,
364
+ "data-testid": "board-column",
365
+ border: true,
366
+ classNames: mx2("group/column", "h-full w-full md:w-card-default-width snap-center bg-deck-surface", "overflow-hidden", classNames),
367
+ ref: forwardedRef
368
+ }, /* @__PURE__ */ React3.createElement(BoardColumnProvider, {
369
+ column: data
370
+ }, children)));
371
+ });
372
+ BoardColumnRootInner.displayName = BOARD_COLUMN_ROOT_NAME;
373
+ var BoardColumnRoot = BoardColumnRootInner;
374
+ var BOARD_COLUMN_HEADER_NAME = "Board.Column.Header";
375
+ var BoardColumnHeader = composable(({ label, dragHandleRef, ...props }, forwardedRef) => {
376
+ const { t } = useTranslation2(translationKey2);
377
+ const { model } = useBoard(BOARD_COLUMN_HEADER_NAME);
378
+ const column = useBoardColumn();
379
+ const columnMenuItems = useMemo4(() => column != null && model.onColumnDelete ? [
380
+ createMenuAction2("delete-column", () => model.onColumnDelete?.(column), {
381
+ label: t("delete-menu.label"),
382
+ icon: "ph--trash--regular"
383
+ })
384
+ ] : [], [
385
+ column,
386
+ model.onColumnDelete,
387
+ t
388
+ ]);
389
+ return /* @__PURE__ */ React3.createElement(Menu2.Root, null, /* @__PURE__ */ React3.createElement(Toolbar2.Root, {
390
+ ...composableProps(props),
391
+ "data-testid": "board-column-header",
392
+ ref: forwardedRef
393
+ }, /* @__PURE__ */ React3.createElement(Toolbar2.DragHandle, {
394
+ ref: dragHandleRef,
395
+ testId: "mosaicBoard.columnDragHandle"
396
+ }), /* @__PURE__ */ React3.createElement(Toolbar2.Text, {
397
+ "data-testid": "mosaicBoard.columnTitle"
398
+ }, label), /* @__PURE__ */ React3.createElement(Menu2.Trigger, {
399
+ asChild: true,
400
+ disabled: !columnMenuItems?.length
401
+ }, /* @__PURE__ */ React3.createElement(Toolbar2.IconButton, {
402
+ iconOnly: true,
403
+ variant: "ghost",
404
+ icon: "ph--dots-three-vertical--regular",
405
+ label: t("action-menu.label")
406
+ })), /* @__PURE__ */ React3.createElement(Menu2.Content, {
407
+ items: columnMenuItems
408
+ })));
409
+ });
410
+ BoardColumnHeader.displayName = BOARD_COLUMN_HEADER_NAME;
411
+ var BOARD_COLUMN_BODY_NAME = "Board.Column.Body";
412
+ var BoardColumnBody = composable(({ data, eventHandler, Tile = BoardItem, debug, ...props }, forwardedRef) => {
413
+ const { model } = useBoard(BOARD_COLUMN_BODY_NAME);
414
+ const [viewport, setViewport] = useState2(null);
415
+ const items = useAtomValue(model.items(data));
416
+ return /* @__PURE__ */ React3.createElement(Mosaic.Container, {
417
+ ...composableProps(props),
418
+ asChild: true,
419
+ withFocus: true,
420
+ orientation: "vertical",
421
+ autoScroll: viewport,
422
+ eventHandler,
423
+ debug,
424
+ ref: forwardedRef
425
+ }, /* @__PURE__ */ React3.createElement(ScrollArea.Root, {
426
+ orientation: "vertical",
427
+ thin: true,
428
+ centered: true,
429
+ padding: true
430
+ }, /* @__PURE__ */ React3.createElement(ScrollArea.Viewport, {
431
+ classNames: "snap-y md:snap-none",
432
+ ref: setViewport
433
+ }, /* @__PURE__ */ React3.createElement(Mosaic.Stack, {
434
+ items,
435
+ getId: model.getItemId,
436
+ Tile
437
+ }))));
438
+ });
439
+ BoardColumnBody.displayName = BOARD_COLUMN_BODY_NAME;
440
+ var BOARD_COLUMN_FOOTER_NAME = "Board.Column.Footer";
441
+ var BoardColumnFooter = /* @__PURE__ */ forwardRef3(({ classNames, data, onAdd }, forwardedRef) => {
442
+ const { t } = useTranslation2(translationKey2);
443
+ const { model } = useBoard(BOARD_COLUMN_FOOTER_NAME);
444
+ const handleAdd = onAdd ?? (model.onItemCreate && data ? () => void model.onItemCreate?.(data) : void 0);
445
+ return /* @__PURE__ */ React3.createElement(Toolbar2.Root, {
446
+ classNames: mx2("rounded-b-sm border-t border-separator", classNames),
447
+ ref: forwardedRef
448
+ }, handleAdd && /* @__PURE__ */ React3.createElement(IconButton, {
449
+ "data-testid": "board-column-add-item",
450
+ classNames: "group-hover/column:opacity-100 md:opacity-0 transition transition-opacity duration-500",
451
+ variant: "ghost",
452
+ icon: "ph--plus--regular",
453
+ iconOnly: true,
454
+ label: t("add-item.label"),
455
+ onClick: handleAdd
456
+ }));
457
+ });
458
+ BoardColumnFooter.displayName = BOARD_COLUMN_FOOTER_NAME;
459
+ var BOARD_DEFAULT_COLUMN_NAME = "Board.DefaultColumn";
460
+ var DefaultBoardColumn = /* @__PURE__ */ forwardRef3(({ classNames, location, data, debug, draggable, Tile = BoardItem }, forwardedRef) => {
461
+ const { model } = useBoard(BOARD_DEFAULT_COLUMN_NAME);
462
+ const [DebugInfo, debugHandler] = useContainerDebug(debug);
463
+ const [dragHandle, setDragHandle] = useState2(null);
464
+ const [column, updateColumn] = useObject(data);
465
+ const eventHandler = useEventHandlerAdapter({
466
+ id: model.getColumnId(data),
467
+ items: column?.items ?? [],
468
+ getId: (ref) => ref.target?.id ?? ref.dxn.toString(),
469
+ get: (refOrObj) => Ref.isRef(refOrObj) ? refOrObj.target : refOrObj,
470
+ make: (object) => Ref.make(object),
471
+ canDrop: ({ source }) => {
472
+ const item = Ref.isRef(source.data) ? source.data.target : source.data;
473
+ return item != null && Obj2.isObject(item) && model.isItem(item);
474
+ },
475
+ onChange: (mutator) => updateColumn((col) => mutator(col.items))
543
476
  });
544
- return /* @__PURE__ */ React6.createElement(Sortable, {
545
- id: contextId,
546
- items: ids
547
- }, children);
477
+ return /* @__PURE__ */ React3.createElement(BoardColumnRootInner, {
478
+ classNames: mx2("group/column grid", debug ? "grid-rows-[var(--dx-rail-action)_1fr_20rem]" : "grid-rows-[var(--dx-rail-action)_1fr_var(--dx-rail-action)]", classNames),
479
+ location,
480
+ data,
481
+ draggable,
482
+ dragHandle,
483
+ ref: forwardedRef
484
+ }, /* @__PURE__ */ React3.createElement(BoardColumnHeader, {
485
+ label: Obj2.getLabel(data) ?? data.id,
486
+ dragHandleRef: setDragHandle
487
+ }), /* @__PURE__ */ React3.createElement(BoardColumnBody, {
488
+ data,
489
+ eventHandler,
490
+ debug: debugHandler,
491
+ Tile
492
+ }), /* @__PURE__ */ React3.createElement("div", {
493
+ className: "flex flex-col col-span-full"
494
+ }, /* @__PURE__ */ React3.createElement(BoardColumnFooter, {
495
+ data
496
+ }), /* @__PURE__ */ React3.createElement(DebugInfo, null)));
497
+ });
498
+ DefaultBoardColumn.displayName = BOARD_DEFAULT_COLUMN_NAME;
499
+ var BoardColumn = {
500
+ Root: BoardColumnRoot,
501
+ Header: BoardColumnHeader,
502
+ Body: BoardColumnBody,
503
+ Footer: BoardColumnFooter
548
504
  };
549
- var Column = ({ children, id, items }) => /* @__PURE__ */ React6.createElement(SortableContext, {
550
- id,
551
- items,
552
- strategy: verticalListSortingStrategy
553
- }, children);
554
- var Row = ({ children, id, items }) => /* @__PURE__ */ React6.createElement(SortableContext, {
555
- id,
556
- items,
557
- strategy: horizontalListSortingStrategy
558
- }, children);
559
505
 
560
- // packages/ui/react-ui-mosaic/src/mosaic/Tile.tsx
561
- import { useDraggable, useDroppable } from "@dnd-kit/core";
562
- import { defaultAnimateLayoutChanges, useSortable } from "@dnd-kit/sortable";
563
- import { useComposedRefs } from "@radix-ui/react-compose-refs";
564
- import React7, { forwardRef as forwardRef3 } from "react";
565
- var DraggableTile = ({ path: parentPath, type = DEFAULT_TYPE, item, Component: Component2 = DefaultComponent, position, draggableStyle, ...props }) => {
566
- const { operation } = useMosaic();
567
- const path = Path.create(parentPath, item.id);
568
- const {
569
- setNodeRef,
570
- attributes,
571
- listeners,
572
- /* transform, */
573
- isDragging
574
- } = useDraggable({
575
- id: path,
576
- data: {
577
- path,
578
- type,
579
- item,
580
- position
581
- }
582
- });
583
- return /* @__PURE__ */ React7.createElement(Component2, {
584
- ref: setNodeRef,
585
- item,
586
- path,
587
- type,
588
- position,
589
- operation,
590
- isDragging,
591
- draggableStyle: {
592
- // TODO(burdon): Override by container?
593
- // transform: getTransformCSS(transform),
594
- ...draggableStyle
595
- },
596
- draggableProps: {
597
- ...attributes,
598
- ...listeners
599
- },
600
- ...props
601
- });
506
+ // src/components/Board/Board.tsx
507
+ var BOARD_NAME = "Board";
508
+ var [BoardContextProvider, useBoardContext] = createContext2(BOARD_NAME);
509
+ function useBoard(displayName) {
510
+ return useBoardContext(displayName ?? BOARD_NAME);
511
+ }
512
+ var BOARD_ROOT_NAME = "Board.Root";
513
+ var BoardRootInner = ({ model, children }) => {
514
+ return /* @__PURE__ */ React4.createElement(BoardContextProvider, {
515
+ model
516
+ }, children);
602
517
  };
603
- var DroppableTile = /* @__PURE__ */ forwardRef3(({ path: parentPath, type = DEFAULT_TYPE, item, Component: Component2 = DefaultComponent, position, ...props }, forwardedRef) => {
604
- const { operation } = useMosaic();
605
- const path = parentPath === item.id ? parentPath : Path.create(parentPath, item.id);
606
- const { setNodeRef, isOver } = useDroppable({
607
- id: path,
608
- data: {
609
- path,
610
- type,
611
- item,
612
- position
613
- }
614
- });
615
- const ref = useComposedRefs(setNodeRef, forwardedRef);
616
- return /* @__PURE__ */ React7.createElement(Component2, {
617
- item,
618
- path,
619
- type,
620
- position,
621
- operation,
622
- isOver,
623
- ...props,
624
- ref
625
- });
518
+ BoardRootInner.displayName = BOARD_ROOT_NAME;
519
+ var BoardRoot = BoardRootInner;
520
+ var BOARD_CONTENT_NAME = "Board.Content";
521
+ var BoardContentInner = composable2(({ id: _id, debug, eventHandler, Tile = DefaultBoardColumn, ...props }, forwardedRef) => {
522
+ const { model } = useBoardContext(BOARD_CONTENT_NAME);
523
+ const [DebugInfo, debugHandler] = useContainerDebug(debug);
524
+ const [viewport, setViewport] = useState3(null);
525
+ const items = useAtomValue2(model.columns);
526
+ return /* @__PURE__ */ React4.createElement("div", {
527
+ ...composableProps2(props, {
528
+ classNames: "dx-container"
529
+ }),
530
+ ref: forwardedRef
531
+ }, /* @__PURE__ */ React4.createElement(Focus.Group, {
532
+ asChild: true,
533
+ orientation: "horizontal"
534
+ }, /* @__PURE__ */ React4.createElement(Mosaic.Container, {
535
+ asChild: true,
536
+ withFocus: true,
537
+ orientation: "horizontal",
538
+ autoScroll: viewport,
539
+ eventHandler,
540
+ debug: debugHandler
541
+ }, /* @__PURE__ */ React4.createElement(ScrollArea2.Root, {
542
+ orientation: "horizontal",
543
+ centered: true,
544
+ padding: true
545
+ }, /* @__PURE__ */ React4.createElement(ScrollArea2.Viewport, {
546
+ classNames: "snap-mandatory snap-x md:snap-none",
547
+ ref: setViewport
548
+ }, /* @__PURE__ */ React4.createElement(Mosaic.Stack, {
549
+ items,
550
+ getId: model.getColumnId,
551
+ Tile,
552
+ debug
553
+ }))))), /* @__PURE__ */ React4.createElement(DebugInfo, null));
626
554
  });
627
- var SortableTile = ({ path: parentPath, type = DEFAULT_TYPE, item, Component: OverrideComponent, position, draggableStyle, ...props }) => {
628
- const { operation, activeItem, overItem } = useMosaic();
629
- const { transitionDuration, Component: ContainerComponent } = useContainer();
630
- const path = Path.create(parentPath, item.id);
631
- const isPreview = activeItem && activeItem.item.id === item.id && overItem && activeItem.path && overItem.path && !Path.siblings(activeItem.path, overItem.path) && (Path.siblings(overItem.path, path) || Path.hasChild(overItem.path, path)) && operation !== "reject";
632
- const { setNodeRef, attributes, listeners, transform, isDragging, isOver } = useSortable({
633
- id: isPreview ? activeItem.path : path,
555
+ BoardContentInner.displayName = BOARD_CONTENT_NAME;
556
+ var BoardContent = BoardContentInner;
557
+ var BOARD_PLACEHOLDER_NAME = "Board.Placeholder";
558
+ var BoardPlaceholder = (props) => {
559
+ return /* @__PURE__ */ React4.createElement(Mosaic.Placeholder, {
560
+ ...props,
561
+ classNames: styles.placeholder.root
562
+ }, /* @__PURE__ */ React4.createElement("div", {
563
+ className: mx3("flex h-full border border-dashed border-separator rounded-xs", styles.placeholder.content)
564
+ }));
565
+ };
566
+ BoardPlaceholder.displayName = BOARD_PLACEHOLDER_NAME;
567
+ var BOARD_DEBUG_NAME = "Board.Debug";
568
+ var BoardDebug = /* @__PURE__ */ forwardRef4(({ classNames }, forwardedRef) => {
569
+ const { containers, dragging } = useMosaicRootContext(BOARD_DEBUG_NAME);
570
+ const counter = useRef3(0);
571
+ return /* @__PURE__ */ React4.createElement(JsonHighlighter2, {
634
572
  data: {
635
- path,
636
- type,
637
- item,
638
- position
639
- },
640
- animateLayoutChanges: (args) => defaultAnimateLayoutChanges({
641
- ...args,
642
- wasDragging: item.id !== activeItem?.item.id
643
- })
644
- });
645
- let active;
646
- if (isDragging) {
647
- if (operation === "rearrange" || operation === "reject") {
648
- active = "rearrange";
649
- } else if (activeItem && activeItem.path && Path.parent(activeItem.path) !== parentPath) {
650
- active = "destination";
651
- } else {
652
- active = "origin";
653
- }
654
- }
655
- const Component2 = OverrideComponent ?? ContainerComponent ?? DefaultComponent;
656
- return /* @__PURE__ */ React7.createElement(Component2, {
657
- ref: setNodeRef,
658
- item,
659
- path,
660
- type,
661
- position,
662
- operation,
663
- active,
664
- isDragging,
665
- isOver,
666
- draggableStyle: {
667
- transform: getTransformCSS(transform),
668
- transition: transform ? `transform ${transitionDuration}ms ease` : "none",
669
- ...draggableStyle
670
- },
671
- draggableProps: {
672
- ...attributes,
673
- ...listeners
573
+ containers,
574
+ dragging,
575
+ count: counter.current++
674
576
  },
675
- ...props
577
+ classNames: mx3("text-xs", classNames),
578
+ ref: forwardedRef
676
579
  });
580
+ });
581
+ BoardDebug.displayName = BOARD_DEBUG_NAME;
582
+ var Board = {
583
+ Root: BoardRoot,
584
+ Content: BoardContent,
585
+ Column: BoardColumn,
586
+ Item: BoardItem,
587
+ Placeholder: BoardPlaceholder,
588
+ Debug: BoardDebug
677
589
  };
678
590
 
679
- // packages/ui/react-ui-mosaic/src/mosaic/Mosaic.ts
680
- var Mosaic = {
681
- Root: MosaicRoot,
682
- Container: MosaicContainer,
683
- DragOverlay: MosaicDragOverlay,
684
- SortableContext: MosaicSortableContext,
685
- DraggableTile,
686
- DroppableTile,
687
- SortableTile,
688
- // TODO(wittjosiah): Consider factoring out or using inline styles instead depending on DXOS UI theme/tailwind.
689
- DefaultComponent,
690
- // TODO(burdon): Don't export; move to util.
691
- Debug
692
- };
591
+ // src/components/SearchStack/SearchStack.tsx
592
+ import React5, { forwardRef as forwardRef5, useCallback, useMemo as useMemo5, useState as useState4 } from "react";
593
+ import { Card as Card2, ScrollArea as ScrollArea3 } from "@dxos/react-ui";
594
+ import { composable as composable3, composableProps as composableProps3 } from "@dxos/ui-theme";
595
+ var SearchStack = composable3(({ results = [], currentId, onAction, ...props }, forwardedRef) => {
596
+ const [viewport, setViewport] = useState4(null);
597
+ const items = useMemo5(() => results.map((result) => ({
598
+ result,
599
+ onAction
600
+ })), [
601
+ results,
602
+ onAction
603
+ ]);
604
+ const handleCurrentChange = useCallback((id) => {
605
+ if (id) {
606
+ onAction?.({
607
+ type: "select",
608
+ resultId: id
609
+ });
610
+ }
611
+ }, [
612
+ onAction
613
+ ]);
614
+ const handleKeyDown = useCallback((event) => {
615
+ if (event.key === "Enter") {
616
+ event.preventDefault();
617
+ document.activeElement?.click();
618
+ }
619
+ }, []);
620
+ return /* @__PURE__ */ React5.createElement(Focus.Group, {
621
+ asChild: true,
622
+ ...composableProps3(props),
623
+ onKeyDown: handleKeyDown,
624
+ ref: forwardedRef
625
+ }, /* @__PURE__ */ React5.createElement(Mosaic.Container, {
626
+ asChild: true,
627
+ withFocus: true,
628
+ currentId,
629
+ onCurrentChange: handleCurrentChange
630
+ }, /* @__PURE__ */ React5.createElement(ScrollArea3.Root, {
631
+ orientation: "vertical",
632
+ padding: true,
633
+ centered: true,
634
+ thin: true
635
+ }, /* @__PURE__ */ React5.createElement(ScrollArea3.Viewport, {
636
+ ref: setViewport
637
+ }, /* @__PURE__ */ React5.createElement(Mosaic.VirtualStack, {
638
+ Tile: SearchTile,
639
+ classNames: "my-2",
640
+ gap: 8,
641
+ items,
642
+ draggable: false,
643
+ getId: (item) => item.result.id,
644
+ getScrollElement: () => viewport,
645
+ estimateSize: () => 100
646
+ })))));
647
+ });
648
+ SearchStack.displayName = "SearchStack";
649
+ var SearchTile = /* @__PURE__ */ forwardRef5(({ data, location, current }, forwardedRef) => {
650
+ const { result } = data;
651
+ const { setCurrentId } = useMosaicContainerContext("SearchTile");
652
+ const handleCurrentChange = useCallback(() => {
653
+ setCurrentId(result.id);
654
+ }, [
655
+ result.id,
656
+ setCurrentId
657
+ ]);
658
+ return /* @__PURE__ */ React5.createElement(Mosaic.Tile, {
659
+ asChild: true,
660
+ classNames: "dx-hover dx-current",
661
+ id: result.id,
662
+ data,
663
+ location,
664
+ current
665
+ }, /* @__PURE__ */ React5.createElement(Focus.Item, {
666
+ asChild: true,
667
+ current,
668
+ onCurrentChange: handleCurrentChange
669
+ }, /* @__PURE__ */ React5.createElement(Card2.Root, {
670
+ fullWidth: true,
671
+ ref: forwardedRef
672
+ }, /* @__PURE__ */ React5.createElement(Card2.Toolbar, null, /* @__PURE__ */ React5.createElement(Card2.IconBlock, null), /* @__PURE__ */ React5.createElement(Card2.Title, null, result.label)), result.snippet && /* @__PURE__ */ React5.createElement(Card2.Content, null, /* @__PURE__ */ React5.createElement(Card2.Row, null, /* @__PURE__ */ React5.createElement(Card2.Text, {
673
+ variant: "description"
674
+ }, result.snippet))))));
675
+ });
676
+ SearchTile.displayName = "SearchTile";
693
677
  export {
678
+ Board,
679
+ BoardDebug,
680
+ Focus,
694
681
  Mosaic,
695
- Path,
696
- getTransformCSS,
697
- isTileComponentProps,
698
- isTileProps,
699
- swapItems,
700
- useContainer,
701
- useItemsWithOrigin,
702
- useItemsWithPreview,
703
- useMosaic
682
+ SearchStack,
683
+ dropHandler,
684
+ getSourceData,
685
+ styles as mosaicStyles,
686
+ useBoard,
687
+ useBoardColumn,
688
+ useContainerDebug,
689
+ useDefaultColumnEventHandler,
690
+ useEventHandlerAdapter,
691
+ useFocus,
692
+ useMosaicRootContext as useMosaic,
693
+ useMosaicContainerContext as useMosaicContainer,
694
+ useMosaicTileContext as useMosaicTile,
695
+ useVisibleItems
704
696
  };
705
697
  //# sourceMappingURL=index.mjs.map