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