@dxos/plugin-deck 0.8.4-main.b97322e → 0.8.4-main.bc674ce

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 (277) hide show
  1. package/dist/lib/browser/app-graph-builder-DTVCULQ4.mjs +120 -0
  2. package/dist/lib/browser/app-graph-builder-DTVCULQ4.mjs.map +7 -0
  3. package/dist/lib/browser/{check-app-scheme-57U62A3A.mjs → check-app-scheme-JSRXXIYF.mjs} +9 -9
  4. package/dist/lib/browser/check-app-scheme-JSRXXIYF.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-F5BQOOEG.mjs → chunk-ATFPDN6J.mjs} +155 -23
  6. package/dist/lib/browser/chunk-ATFPDN6J.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-CNTGBCMK.mjs → chunk-NHABISX2.mjs} +40 -33
  8. package/dist/lib/browser/chunk-NHABISX2.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-S4A5UO4K.mjs +1448 -0
  10. package/dist/lib/browser/chunk-S4A5UO4K.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-UNG4CLLP.mjs +161 -0
  12. package/dist/lib/browser/chunk-UNG4CLLP.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +79 -67
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/operation-resolver-CDYBLZJ4.mjs +595 -0
  17. package/dist/lib/browser/operation-resolver-CDYBLZJ4.mjs.map +7 -0
  18. package/dist/lib/browser/react-root-XDCMNENQ.mjs +47 -0
  19. package/dist/lib/browser/react-root-XDCMNENQ.mjs.map +7 -0
  20. package/dist/lib/browser/react-surface-HODERLOL.mjs +42 -0
  21. package/dist/lib/browser/react-surface-HODERLOL.mjs.map +7 -0
  22. package/dist/lib/browser/settings-OMHVGZ6V.mjs +37 -0
  23. package/dist/lib/browser/settings-OMHVGZ6V.mjs.map +7 -0
  24. package/dist/lib/browser/state-OC3BSB6E.mjs +103 -0
  25. package/dist/lib/browser/state-OC3BSB6E.mjs.map +7 -0
  26. package/dist/lib/browser/toolkit-R53LD3EA.mjs +53 -0
  27. package/dist/lib/browser/toolkit-R53LD3EA.mjs.map +7 -0
  28. package/dist/lib/browser/types/index.mjs +11 -4
  29. package/dist/lib/browser/url-handler-53TE6JZO.mjs +93 -0
  30. package/dist/lib/browser/url-handler-53TE6JZO.mjs.map +7 -0
  31. package/dist/lib/node-esm/app-graph-builder-473BNZDJ.mjs +121 -0
  32. package/dist/lib/node-esm/app-graph-builder-473BNZDJ.mjs.map +7 -0
  33. package/dist/lib/node-esm/check-app-scheme-IVYRHKRH.mjs +33 -0
  34. package/dist/lib/node-esm/check-app-scheme-IVYRHKRH.mjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-ADPMWKLL.mjs +154 -0
  36. package/dist/lib/node-esm/chunk-ADPMWKLL.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-D34L3ECT.mjs +1449 -0
  38. package/dist/lib/node-esm/chunk-D34L3ECT.mjs.map +7 -0
  39. package/dist/lib/node-esm/chunk-SKEVPQ7E.mjs +162 -0
  40. package/dist/lib/node-esm/chunk-SKEVPQ7E.mjs.map +7 -0
  41. package/dist/lib/node-esm/chunk-XAKTY3EB.mjs +294 -0
  42. package/dist/lib/node-esm/chunk-XAKTY3EB.mjs.map +7 -0
  43. package/dist/lib/node-esm/index.mjs +181 -0
  44. package/dist/lib/node-esm/index.mjs.map +7 -0
  45. package/dist/lib/node-esm/meta.json +1 -0
  46. package/dist/lib/node-esm/operation-resolver-WUOE33ID.mjs +596 -0
  47. package/dist/lib/node-esm/operation-resolver-WUOE33ID.mjs.map +7 -0
  48. package/dist/lib/node-esm/react-root-O6GZO62Z.mjs +48 -0
  49. package/dist/lib/node-esm/react-root-O6GZO62Z.mjs.map +7 -0
  50. package/dist/lib/node-esm/react-surface-IHDJDGC5.mjs +43 -0
  51. package/dist/lib/node-esm/react-surface-IHDJDGC5.mjs.map +7 -0
  52. package/dist/lib/node-esm/settings-2HB6FKIK.mjs +38 -0
  53. package/dist/lib/node-esm/settings-2HB6FKIK.mjs.map +7 -0
  54. package/dist/lib/node-esm/state-JRQ45ACJ.mjs +104 -0
  55. package/dist/lib/node-esm/state-JRQ45ACJ.mjs.map +7 -0
  56. package/dist/lib/node-esm/toolkit-JLPZNNKB.mjs +54 -0
  57. package/dist/lib/node-esm/toolkit-JLPZNNKB.mjs.map +7 -0
  58. package/dist/lib/node-esm/types/index.mjs +40 -0
  59. package/dist/lib/node-esm/url-handler-QGF2R24T.mjs +94 -0
  60. package/dist/lib/node-esm/url-handler-QGF2R24T.mjs.map +7 -0
  61. package/dist/types/src/DeckPlugin.d.ts +2 -1
  62. package/dist/types/src/DeckPlugin.d.ts.map +1 -1
  63. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  64. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  65. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  66. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  67. package/dist/types/src/capabilities/check-app-scheme/check-app-scheme.d.ts +5 -0
  68. package/dist/types/src/capabilities/check-app-scheme/check-app-scheme.d.ts.map +1 -0
  69. package/dist/types/src/capabilities/check-app-scheme/index.d.ts +3 -0
  70. package/dist/types/src/capabilities/check-app-scheme/index.d.ts.map +1 -0
  71. package/dist/types/src/capabilities/index.d.ts +8 -13
  72. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  73. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  74. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  75. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  76. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  77. package/dist/types/src/capabilities/react-root/index.d.ts +6 -0
  78. package/dist/types/src/capabilities/react-root/index.d.ts.map +1 -0
  79. package/dist/types/src/capabilities/react-root/react-root.d.ts +9 -0
  80. package/dist/types/src/capabilities/react-root/react-root.d.ts.map +1 -0
  81. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  82. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  83. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  84. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  85. package/dist/types/src/capabilities/settings/index.d.ts +19 -0
  86. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  87. package/dist/types/src/capabilities/settings/settings.d.ts +21 -0
  88. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  89. package/dist/types/src/capabilities/state/index.d.ts +172 -0
  90. package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
  91. package/dist/types/src/capabilities/state/state.d.ts +175 -0
  92. package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
  93. package/dist/types/src/capabilities/toolkit/index.d.ts +3 -0
  94. package/dist/types/src/capabilities/toolkit/index.d.ts.map +1 -0
  95. package/dist/types/src/capabilities/toolkit/toolkit.d.ts +26 -0
  96. package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +1 -0
  97. package/dist/types/src/capabilities/tools/index.d.ts +3 -0
  98. package/dist/types/src/capabilities/tools/index.d.ts.map +1 -0
  99. package/dist/types/src/capabilities/tools/tools.d.ts +12 -0
  100. package/dist/types/src/capabilities/tools/tools.d.ts.map +1 -0
  101. package/dist/types/src/capabilities/url-handler/index.d.ts +3 -0
  102. package/dist/types/src/capabilities/url-handler/index.d.ts.map +1 -0
  103. package/dist/types/src/capabilities/url-handler/url-handler.d.ts +5 -0
  104. package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +1 -0
  105. package/dist/types/src/components/DeckLayout/Banner.d.ts.map +1 -1
  106. package/dist/types/src/components/DeckLayout/ContentEmpty.d.ts.map +1 -1
  107. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts +2 -3
  108. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
  109. package/dist/types/src/components/DeckLayout/DeckLayout.stories.d.ts +74 -0
  110. package/dist/types/src/components/DeckLayout/DeckLayout.stories.d.ts.map +1 -0
  111. package/dist/types/src/components/DeckLayout/DeckMain.d.ts +3 -0
  112. package/dist/types/src/components/DeckLayout/DeckMain.d.ts.map +1 -0
  113. package/dist/types/src/components/DeckLayout/Dialog.d.ts.map +1 -1
  114. package/dist/types/src/components/DeckLayout/Popover.d.ts.map +1 -1
  115. package/dist/types/src/components/DeckLayout/Toast.d.ts +7 -2
  116. package/dist/types/src/components/DeckLayout/Toast.d.ts.map +1 -1
  117. package/dist/types/src/components/DeckSettings/DeckSettings.d.ts +4 -2
  118. package/dist/types/src/components/DeckSettings/DeckSettings.d.ts.map +1 -1
  119. package/dist/types/src/components/Plank/Plank.d.ts +4 -4
  120. package/dist/types/src/components/Plank/Plank.d.ts.map +1 -1
  121. package/dist/types/src/components/Plank/Plank.stories.d.ts +104 -5
  122. package/dist/types/src/components/Plank/Plank.stories.d.ts.map +1 -1
  123. package/dist/types/src/components/Plank/PlankControls.d.ts +1 -1
  124. package/dist/types/src/components/Plank/PlankControls.d.ts.map +1 -1
  125. package/dist/types/src/components/Plank/PlankError.d.ts +1 -1
  126. package/dist/types/src/components/Plank/PlankError.d.ts.map +1 -1
  127. package/dist/types/src/components/Plank/PlankHeading.d.ts +3 -3
  128. package/dist/types/src/components/Plank/PlankHeading.d.ts.map +1 -1
  129. package/dist/types/src/components/Sidebar/ComplementarySidebar.d.ts.map +1 -1
  130. package/dist/types/src/components/Sidebar/Sidebar.d.ts.map +1 -1
  131. package/dist/types/src/components/Sidebar/SidebarButton.d.ts.map +1 -1
  132. package/dist/types/src/hooks/index.d.ts +1 -0
  133. package/dist/types/src/hooks/index.d.ts.map +1 -1
  134. package/dist/types/src/hooks/useDeckCompanions.d.ts +3 -3
  135. package/dist/types/src/hooks/useDeckCompanions.d.ts.map +1 -1
  136. package/dist/types/src/hooks/useDeckState.d.ts +17 -0
  137. package/dist/types/src/hooks/useDeckState.d.ts.map +1 -0
  138. package/dist/types/src/hooks/useHoistStatusbar.d.ts +1 -1
  139. package/dist/types/src/hooks/useHoistStatusbar.d.ts.map +1 -1
  140. package/dist/types/src/hooks/useNodeActionExpander.d.ts +1 -1
  141. package/dist/types/src/hooks/useNodeActionExpander.d.ts.map +1 -1
  142. package/dist/types/src/index.d.ts +1 -2
  143. package/dist/types/src/index.d.ts.map +1 -1
  144. package/dist/types/src/meta.d.ts +2 -3
  145. package/dist/types/src/meta.d.ts.map +1 -1
  146. package/dist/types/src/translations.d.ts +3 -1
  147. package/dist/types/src/translations.d.ts.map +1 -1
  148. package/dist/types/src/{capabilities → types}/capabilities.d.ts +96 -90
  149. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  150. package/dist/types/src/types/events.d.ts +7 -0
  151. package/dist/types/src/types/events.d.ts.map +1 -0
  152. package/dist/types/src/types/index.d.ts +2 -0
  153. package/dist/types/src/types/index.d.ts.map +1 -1
  154. package/dist/types/src/types/schema.d.ts +90 -30
  155. package/dist/types/src/types/schema.d.ts.map +1 -1
  156. package/dist/types/src/util/set-active.d.ts +18 -3
  157. package/dist/types/src/util/set-active.d.ts.map +1 -1
  158. package/dist/types/tsconfig.tsbuildinfo +1 -1
  159. package/package.json +56 -46
  160. package/src/DeckPlugin.ts +45 -61
  161. package/src/capabilities/app-graph-builder/app-graph-builder.ts +118 -0
  162. package/src/capabilities/app-graph-builder/index.ts +7 -0
  163. package/src/capabilities/{check-app-scheme.ts → check-app-scheme/check-app-scheme.ts} +12 -11
  164. package/src/capabilities/check-app-scheme/index.ts +7 -0
  165. package/src/capabilities/index.ts +9 -13
  166. package/src/capabilities/operation-resolver/index.ts +10 -0
  167. package/src/capabilities/operation-resolver/operation-resolver.ts +555 -0
  168. package/src/capabilities/react-root/index.ts +7 -0
  169. package/src/capabilities/react-root/react-root.tsx +47 -0
  170. package/src/capabilities/react-surface/index.ts +7 -0
  171. package/src/capabilities/react-surface/react-surface.tsx +37 -0
  172. package/src/capabilities/settings/index.ts +7 -0
  173. package/src/capabilities/settings/settings.ts +38 -0
  174. package/src/capabilities/state/index.ts +7 -0
  175. package/src/capabilities/state/state.ts +104 -0
  176. package/src/capabilities/toolkit/index.ts +7 -0
  177. package/src/capabilities/toolkit/toolkit.ts +63 -0
  178. package/src/capabilities/tools/index.ts +7 -0
  179. package/src/capabilities/tools/tools.ts +92 -0
  180. package/src/capabilities/url-handler/index.ts +7 -0
  181. package/src/capabilities/url-handler/url-handler.ts +95 -0
  182. package/src/components/DeckLayout/ActiveNode.tsx +1 -1
  183. package/src/components/DeckLayout/Banner.tsx +6 -6
  184. package/src/components/DeckLayout/ContentEmpty.tsx +4 -5
  185. package/src/components/DeckLayout/DeckLayout.stories.tsx +51 -0
  186. package/src/components/DeckLayout/DeckLayout.tsx +18 -285
  187. package/src/components/DeckLayout/DeckMain.tsx +286 -0
  188. package/src/components/DeckLayout/Dialog.tsx +13 -10
  189. package/src/components/DeckLayout/Fallback.tsx +4 -4
  190. package/src/components/DeckLayout/Popover.tsx +44 -32
  191. package/src/components/DeckLayout/StatusBar.tsx +1 -1
  192. package/src/components/DeckLayout/Toast.tsx +30 -5
  193. package/src/components/DeckSettings/DeckSettings.tsx +91 -66
  194. package/src/components/Plank/Plank.stories.tsx +23 -16
  195. package/src/components/Plank/Plank.tsx +89 -56
  196. package/src/components/Plank/PlankControls.tsx +9 -9
  197. package/src/components/Plank/PlankError.tsx +5 -4
  198. package/src/components/Plank/PlankHeading.tsx +38 -42
  199. package/src/components/Sidebar/ComplementarySidebar.tsx +61 -33
  200. package/src/components/Sidebar/Sidebar.tsx +6 -6
  201. package/src/components/Sidebar/SidebarButton.tsx +39 -32
  202. package/src/components/fragments.ts +1 -1
  203. package/src/hooks/index.ts +1 -0
  204. package/src/hooks/useCompanions.ts +1 -1
  205. package/src/hooks/useDeckCompanions.ts +7 -5
  206. package/src/hooks/useDeckState.ts +82 -0
  207. package/src/hooks/useHoistStatusbar.ts +4 -5
  208. package/src/hooks/useNodeActionExpander.ts +4 -4
  209. package/src/index.ts +1 -2
  210. package/src/meta.ts +8 -5
  211. package/src/translations.ts +3 -1
  212. package/src/types/capabilities.ts +33 -0
  213. package/src/types/events.ts +20 -0
  214. package/src/types/index.ts +2 -0
  215. package/src/types/schema.ts +86 -14
  216. package/src/util/layoutAppliesTopbar.ts +1 -1
  217. package/src/util/set-active.ts +49 -29
  218. package/dist/lib/browser/app-graph-builder-JTFSDT2I.mjs +0 -152
  219. package/dist/lib/browser/app-graph-builder-JTFSDT2I.mjs.map +0 -7
  220. package/dist/lib/browser/check-app-scheme-57U62A3A.mjs.map +0 -7
  221. package/dist/lib/browser/chunk-CNTGBCMK.mjs.map +0 -7
  222. package/dist/lib/browser/chunk-D7KTFCUV.mjs +0 -1494
  223. package/dist/lib/browser/chunk-D7KTFCUV.mjs.map +0 -7
  224. package/dist/lib/browser/chunk-F5BQOOEG.mjs.map +0 -7
  225. package/dist/lib/browser/chunk-JFTXENFN.mjs +0 -129
  226. package/dist/lib/browser/chunk-JFTXENFN.mjs.map +0 -7
  227. package/dist/lib/browser/chunk-M57WD3V6.mjs +0 -16
  228. package/dist/lib/browser/chunk-M57WD3V6.mjs.map +0 -7
  229. package/dist/lib/browser/chunk-QDZO4AJ4.mjs +0 -127
  230. package/dist/lib/browser/chunk-QDZO4AJ4.mjs.map +0 -7
  231. package/dist/lib/browser/chunk-Z5KITAZW.mjs +0 -13
  232. package/dist/lib/browser/chunk-Z5KITAZW.mjs.map +0 -7
  233. package/dist/lib/browser/intent-resolver-P2OBK5HK.mjs +0 -521
  234. package/dist/lib/browser/intent-resolver-P2OBK5HK.mjs.map +0 -7
  235. package/dist/lib/browser/react-root-PO64J7ML.mjs +0 -43
  236. package/dist/lib/browser/react-root-PO64J7ML.mjs.map +0 -7
  237. package/dist/lib/browser/react-surface-E45YOVF5.mjs +0 -40
  238. package/dist/lib/browser/react-surface-E45YOVF5.mjs.map +0 -7
  239. package/dist/lib/browser/settings-6AJZPZPM.mjs +0 -29
  240. package/dist/lib/browser/settings-6AJZPZPM.mjs.map +0 -7
  241. package/dist/lib/browser/state-MVDYX77Y.mjs +0 -12
  242. package/dist/lib/browser/tools-TKQDPCHJ.mjs +0 -88
  243. package/dist/lib/browser/tools-TKQDPCHJ.mjs.map +0 -7
  244. package/dist/lib/browser/url-handler-7L7M6IKH.mjs +0 -70
  245. package/dist/lib/browser/url-handler-7L7M6IKH.mjs.map +0 -7
  246. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  247. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  248. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  249. package/dist/types/src/capabilities/check-app-scheme.d.ts +0 -4
  250. package/dist/types/src/capabilities/check-app-scheme.d.ts.map +0 -1
  251. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  252. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  253. package/dist/types/src/capabilities/react-root.d.ts +0 -7
  254. package/dist/types/src/capabilities/react-root.d.ts.map +0 -1
  255. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  256. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  257. package/dist/types/src/capabilities/settings.d.ts +0 -4
  258. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  259. package/dist/types/src/capabilities/state.d.ts +0 -101
  260. package/dist/types/src/capabilities/state.d.ts.map +0 -1
  261. package/dist/types/src/capabilities/tools.d.ts +0 -11
  262. package/dist/types/src/capabilities/tools.d.ts.map +0 -1
  263. package/dist/types/src/capabilities/url-handler.d.ts +0 -4
  264. package/dist/types/src/capabilities/url-handler.d.ts.map +0 -1
  265. package/dist/types/src/events.d.ts +0 -4
  266. package/dist/types/src/events.d.ts.map +0 -1
  267. package/src/capabilities/app-graph-builder.ts +0 -141
  268. package/src/capabilities/capabilities.ts +0 -14
  269. package/src/capabilities/intent-resolver.ts +0 -468
  270. package/src/capabilities/react-root.tsx +0 -38
  271. package/src/capabilities/react-surface.tsx +0 -30
  272. package/src/capabilities/settings.ts +0 -26
  273. package/src/capabilities/state.ts +0 -104
  274. package/src/capabilities/tools.ts +0 -81
  275. package/src/capabilities/url-handler.ts +0 -59
  276. package/src/events.ts +0 -11
  277. /package/dist/lib/{browser/state-MVDYX77Y.mjs.map → node-esm/types/index.mjs.map} +0 -0
@@ -0,0 +1,1448 @@
1
+ import {
2
+ getCompanionId,
3
+ useBreakpoints,
4
+ useCompanions,
5
+ useDeckCompanions,
6
+ useDeckState,
7
+ useHoistStatusbar,
8
+ useMainSize,
9
+ useNodeActionExpander
10
+ } from "./chunk-UNG4CLLP.mjs";
11
+ import {
12
+ calculateOverscroll,
13
+ layoutAppliesTopbar,
14
+ parseEntryId
15
+ } from "./chunk-NHABISX2.mjs";
16
+ import {
17
+ DeckCapabilities,
18
+ DeckOperation,
19
+ NewPlankPositions,
20
+ OverscrollOptions,
21
+ PLANK_COMPANION_TYPE,
22
+ getMode,
23
+ meta
24
+ } from "./chunk-ATFPDN6J.mjs";
25
+
26
+ // src/components/DeckLayout/Banner.tsx
27
+ import React9 from "react";
28
+ import { Surface as Surface5 } from "@dxos/app-framework/react";
29
+ import { useTranslation as useTranslation6 } from "@dxos/react-ui";
30
+ import { mx as mx5, osTranslations } from "@dxos/ui-theme";
31
+
32
+ // src/components/Sidebar/ComplementarySidebar.tsx
33
+ import React7, { Fragment as Fragment2, useCallback as useCallback5, useEffect as useEffect3, useMemo as useMemo3, useState as useState2 } from "react";
34
+ import { Common as Common4 } from "@dxos/app-framework";
35
+ import { Surface as Surface3, useOperationInvoker as useOperationInvoker5 } from "@dxos/app-framework/react";
36
+ import { IconButton as IconButton4, Main, toLocalizedString as toLocalizedString2, useTranslation as useTranslation5 } from "@dxos/react-ui";
37
+ import { Tabs } from "@dxos/react-ui-tabs";
38
+ import { mx as mx4 } from "@dxos/ui-theme";
39
+
40
+ // src/components/Plank/Plank.tsx
41
+ import { useFocusFinders } from "@fluentui/react-tabster";
42
+ import React5, { memo as memo2, useCallback as useCallback3, useLayoutEffect, useMemo as useMemo2, useRef } from "react";
43
+ import { Common as Common2 } from "@dxos/app-framework";
44
+ import { Surface as Surface2, useAppGraph as useAppGraph2, useOperationInvoker as useOperationInvoker3 } from "@dxos/app-framework/react";
45
+ import { debounce } from "@dxos/async";
46
+ import { useNode } from "@dxos/plugin-graph";
47
+ import { ATTENDABLE_PATH_SEPARATOR, useAttentionAttributes } from "@dxos/react-ui-attention";
48
+ import { StackItem as StackItem2, railGridHorizontal } from "@dxos/react-ui-stack";
49
+ import { mainIntrinsicSize, mx as mx3 } from "@dxos/ui-theme";
50
+
51
+ // src/components/Plank/PlankError.tsx
52
+ import React4, { useEffect as useEffect2, useState } from "react";
53
+ import { useTranslation as useTranslation3 } from "@dxos/react-ui";
54
+ import { descriptionMessage, mx as mx2 } from "@dxos/ui-theme";
55
+
56
+ // src/components/Plank/PlankHeading.tsx
57
+ import React2, { Fragment, memo, useCallback as useCallback2, useEffect, useMemo } from "react";
58
+ import { Common } from "@dxos/app-framework";
59
+ import { Surface, useAppGraph, useOperationInvoker as useOperationInvoker2 } from "@dxos/app-framework/react";
60
+ import { Graph, useActionRunner } from "@dxos/plugin-graph";
61
+ import { Icon, IconButton as IconButton2, Popover, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
62
+ import { StackItem } from "@dxos/react-ui-stack";
63
+ import { TextTooltip } from "@dxos/react-ui-text-tooltip";
64
+ import { hoverableControls, hoverableFocusedWithinControls } from "@dxos/ui-theme";
65
+
66
+ // src/components/fragments.ts
67
+ import { mx } from "@dxos/ui-theme";
68
+ var soloInlinePadding = "pis-[calc(env(safe-area-inset-left)+.25rem)] pie-[calc(env(safe-area-inset-left)+.25rem)]";
69
+ var sidebarToggleStyles = "bs-[--rail-item] is-[--rail-item] absolute block-end-2 z-[1] !bg-deckSurface lg:hidden";
70
+ var fixedSidebarToggleStyles = mx(sidebarToggleStyles, "inline-start-2");
71
+ var fixedComplementarySidebarToggleStyles = mx(sidebarToggleStyles, "inline-end-2");
72
+
73
+ // src/components/Plank/PlankControls.tsx
74
+ import React, { forwardRef, useCallback } from "react";
75
+ import { useOperationInvoker } from "@dxos/app-framework/react";
76
+ import { invariant } from "@dxos/invariant";
77
+ import { ButtonGroup, IconButton, useTranslation } from "@dxos/react-ui";
78
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-deck/src/components/Plank/PlankControls.tsx";
79
+ var PlankControl = ({ icon, label: label3, ...props }) => {
80
+ return /* @__PURE__ */ React.createElement(IconButton, {
81
+ label: label3,
82
+ icon,
83
+ iconOnly: true,
84
+ variant: "ghost",
85
+ tooltipSide: "bottom",
86
+ ...props
87
+ });
88
+ };
89
+ var plankControlSpacing = "pli-2";
90
+ var PlankCompanionControls = /* @__PURE__ */ forwardRef(({ primary }, forwardedRef) => {
91
+ const { t } = useTranslation(meta.id);
92
+ const { invokePromise } = useOperationInvoker();
93
+ const handleCloseCompanion = useCallback(() => {
94
+ invariant(primary, void 0, {
95
+ F: __dxlog_file,
96
+ L: 49,
97
+ S: void 0,
98
+ A: [
99
+ "primary",
100
+ ""
101
+ ]
102
+ });
103
+ return invokePromise(DeckOperation.ChangeCompanion, {
104
+ primary,
105
+ companion: null
106
+ });
107
+ }, [
108
+ invokePromise,
109
+ primary
110
+ ]);
111
+ return /* @__PURE__ */ React.createElement("div", {
112
+ ref: forwardedRef,
113
+ className: "contents app-no-drag"
114
+ }, /* @__PURE__ */ React.createElement(PlankControl, {
115
+ label: t("close companion label"),
116
+ variant: "ghost",
117
+ icon: "ph--x--regular",
118
+ onClick: handleCloseCompanion,
119
+ classNames: plankControlSpacing
120
+ }));
121
+ });
122
+ var PlankControls = /* @__PURE__ */ forwardRef(({ children, classNames, variant = "default", capabilities, layoutMode, pin, close = false, onClick, ...props }, forwardedRef) => {
123
+ const { t } = useTranslation(meta.id);
124
+ const buttonClassNames = variant === "hide-disabled" ? `disabled:hidden ${plankControlSpacing}` : plankControlSpacing;
125
+ const layoutIsAnySolo = !!layoutMode?.startsWith("solo");
126
+ return /* @__PURE__ */ React.createElement(ButtonGroup, {
127
+ ...props,
128
+ classNames: [
129
+ "app-no-drag !opacity-100",
130
+ classNames
131
+ ],
132
+ ref: forwardedRef
133
+ }, capabilities.deck ? /* @__PURE__ */ React.createElement(React.Fragment, null, capabilities.solo && /* @__PURE__ */ React.createElement(React.Fragment, null, layoutMode === "solo" && /* @__PURE__ */ React.createElement(PlankControl, {
134
+ label: t("show fullscreen plank label"),
135
+ classNames: buttonClassNames,
136
+ icon: "ph--corners-out--regular",
137
+ onClick: () => onClick?.("solo--fullscreen")
138
+ }), /* @__PURE__ */ React.createElement(PlankControl, {
139
+ label: t(layoutMode === "solo--fullscreen" ? "exit fullscreen label" : layoutIsAnySolo ? "show deck plank label" : "show solo plank label"),
140
+ classNames: buttonClassNames,
141
+ icon: layoutMode === "solo--fullscreen" ? "ph--corners-in--regular" : layoutIsAnySolo ? "ph--arrows-in-line-horizontal--regular" : "ph--arrows-out-line-horizontal--regular",
142
+ onClick: () => onClick?.(layoutMode === "solo--fullscreen" ? "solo--fullscreen" : "solo")
143
+ })), !layoutIsAnySolo && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PlankControl, {
144
+ label: t("increment start label"),
145
+ disabled: !capabilities.incrementStart,
146
+ classNames: buttonClassNames,
147
+ icon: "ph--caret-left--regular",
148
+ onClick: () => onClick?.("increment-start")
149
+ }), /* @__PURE__ */ React.createElement(PlankControl, {
150
+ label: t("increment end label"),
151
+ disabled: !capabilities.incrementEnd,
152
+ classNames: buttonClassNames,
153
+ icon: "ph--caret-right--regular",
154
+ onClick: () => onClick?.("increment-end")
155
+ }))) : capabilities.fullscreen && /* @__PURE__ */ React.createElement(PlankControl, {
156
+ label: t(layoutMode === "solo--fullscreen" ? "exit fullscreen label" : "show fullscreen plank label"),
157
+ classNames: buttonClassNames,
158
+ icon: layoutMode === "solo--fullscreen" ? "ph--corners-in--regular" : "ph--corners-out--regular",
159
+ onClick: () => onClick?.("solo--fullscreen")
160
+ }), close && !layoutIsAnySolo && /* @__PURE__ */ React.createElement(PlankControl, {
161
+ label: t(`${typeof close === "string" ? "minify" : "close"} label`),
162
+ classNames: buttonClassNames,
163
+ "data-testid": "plankHeading.close",
164
+ icon: close === "minify-start" ? "ph--caret-line-left--regular" : close === "minify-end" ? "ph--caret-line-right--regular" : "ph--x--regular",
165
+ onClick: () => onClick?.("close")
166
+ }), capabilities.companion && /* @__PURE__ */ React.createElement(PlankControl, {
167
+ label: t("open companion label"),
168
+ classNames: buttonClassNames,
169
+ "data-testid": "plankHeading.companion",
170
+ icon: "ph--square-split-horizontal--regular",
171
+ onClick: () => onClick?.("companion")
172
+ }), children);
173
+ });
174
+
175
+ // src/components/Plank/PlankHeading.tsx
176
+ var MAX_COMPANIONS = 5;
177
+ var PlankHeading = /* @__PURE__ */ memo(({ id, part, node, deckEnabled, canIncrementStart, canIncrementEnd, popoverAnchorId, primaryId, pending, companioned, companions, layoutMode, actions = [] }) => {
178
+ const { t } = useTranslation2(meta.id);
179
+ const { invokePromise, invokeSync } = useOperationInvoker2();
180
+ const runAction = useActionRunner();
181
+ const { graph } = useAppGraph();
182
+ const breakpoint = useBreakpoints();
183
+ const icon = node?.properties?.icon ?? "ph--placeholder--regular";
184
+ const label3 = pending ? t("pending heading") : toLocalizedString(node?.properties?.label ?? [
185
+ "plank heading fallback label",
186
+ {
187
+ ns: meta.id
188
+ }
189
+ ], t);
190
+ const isCompanionNode = node?.type === PLANK_COMPANION_TYPE;
191
+ useEffect(() => {
192
+ const frame = requestAnimationFrame(() => {
193
+ if (node) {
194
+ void Graph.expand(graph, node.id);
195
+ }
196
+ });
197
+ return () => cancelAnimationFrame(frame);
198
+ }, [
199
+ node
200
+ ]);
201
+ const attendableId = primaryId ?? id;
202
+ const capabilities = useMemo(() => ({
203
+ deck: deckEnabled ?? true,
204
+ solo: breakpoint !== "mobile" && (part === "solo" || part === "deck"),
205
+ incrementStart: canIncrementStart,
206
+ incrementEnd: canIncrementEnd,
207
+ fullscreen: !isCompanionNode,
208
+ companion: !isCompanionNode && companions && companions.length > 0
209
+ }), [
210
+ breakpoint,
211
+ part,
212
+ companions,
213
+ canIncrementStart,
214
+ canIncrementEnd,
215
+ isCompanionNode,
216
+ deckEnabled
217
+ ]);
218
+ const { variant } = parseEntryId(id);
219
+ const sigilActions = useMemo(() => {
220
+ if (!node) {
221
+ return void 0;
222
+ } else if (variant) {
223
+ return [];
224
+ } else {
225
+ return [
226
+ actions,
227
+ Graph.getActions(graph, node.id).filter((a) => [
228
+ "list-item",
229
+ "list-item-primary",
230
+ "heading-list-item"
231
+ ].includes(a.properties.disposition))
232
+ ].filter((a) => a.length > 0);
233
+ }
234
+ }, [
235
+ actions,
236
+ node,
237
+ variant,
238
+ graph
239
+ ]);
240
+ const handleAction = useCallback2((action) => {
241
+ if (typeof action.data === "function") {
242
+ void runAction(action, {
243
+ parent: node,
244
+ caller: meta.id
245
+ });
246
+ }
247
+ }, [
248
+ node,
249
+ runAction
250
+ ]);
251
+ const handlePlankAction = useCallback2((eventType) => {
252
+ if (eventType.startsWith("solo")) {
253
+ return invokePromise(DeckOperation.Adjust, {
254
+ type: eventType,
255
+ id
256
+ });
257
+ } else if (eventType === "close") {
258
+ if (part === "complementary") {
259
+ return invokeSync(Common.LayoutOperation.UpdateComplementary, {
260
+ state: "collapsed"
261
+ });
262
+ } else {
263
+ return invokeSync(Common.LayoutOperation.Close, {
264
+ subject: [
265
+ id
266
+ ]
267
+ });
268
+ }
269
+ } else {
270
+ return invokePromise(DeckOperation.Adjust, {
271
+ type: eventType,
272
+ id
273
+ });
274
+ }
275
+ }, [
276
+ invokePromise,
277
+ invokeSync,
278
+ id,
279
+ part
280
+ ]);
281
+ const ActionRoot = node && popoverAnchorId === `dxos.org/ui/${meta.id}/${node.id}` ? Popover.Anchor : Fragment;
282
+ const handleTabClick = useCallback2((event) => {
283
+ const target = event.target.closest("[data-id]");
284
+ const tabId = target?.dataset?.id;
285
+ if (primaryId && tabId) {
286
+ void invokePromise(DeckOperation.ChangeCompanion, {
287
+ primary: primaryId,
288
+ companion: tabId
289
+ });
290
+ }
291
+ }, [
292
+ primaryId,
293
+ invokePromise
294
+ ]);
295
+ return /* @__PURE__ */ React2.createElement(StackItem.Heading, {
296
+ classNames: [
297
+ "plb-1 items-stretch gap-1 sticky inline-start-12 app-drag min-is-0 contain-layout density-coarse",
298
+ part === "solo" ? soloInlinePadding : "pli-1",
299
+ ...layoutMode === "solo--fullscreen" ? [
300
+ hoverableControls,
301
+ hoverableFocusedWithinControls,
302
+ "*:transition-opacity *:opacity-[--controls-opacity] bg-transparent border-transparent transition-[background-color,border-color]",
303
+ "hover-hover:hover:bg-headerSurface focus-within:bg-headerSurface hover-hover:hover:border-subduedSeparator focus-within:border-subduedSeparator"
304
+ ] : []
305
+ ],
306
+ "data-plank-heading": true
307
+ }, companions && isCompanionNode ? (
308
+ /* TODO(thure): IMPORTANT: This is a tablist; it should be implemented as such. */
309
+ /* @__PURE__ */ React2.createElement("div", {
310
+ role: "none",
311
+ className: "flex-1 min-is-0 overflow-x-auto scrollbar-none flex gap-1"
312
+ }, companions.map(({ id: id2, properties: { icon: icon2, label: label4 } }) => /* @__PURE__ */ React2.createElement(IconButton2, {
313
+ key: id2,
314
+ "data-id": id2,
315
+ icon: icon2,
316
+ iconOnly: companions.length > MAX_COMPANIONS && node?.id !== id2,
317
+ label: toLocalizedString(label4, t),
318
+ variant: node?.id === id2 ? "primary" : "ghost",
319
+ onClick: handleTabClick
320
+ })))
321
+ ) : /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(ActionRoot, null, node && sigilActions ? /* @__PURE__ */ React2.createElement(StackItem.Sigil, {
322
+ icon,
323
+ related: part === "complementary",
324
+ attendableId,
325
+ triggerLabel: t("actions menu label"),
326
+ actions: sigilActions,
327
+ onAction: handleAction
328
+ }, /* @__PURE__ */ React2.createElement(Surface, {
329
+ role: "menu-footer",
330
+ data: {
331
+ subject: node.data
332
+ }
333
+ })) : /* @__PURE__ */ React2.createElement(StackItem.SigilButton, null, /* @__PURE__ */ React2.createElement("span", {
334
+ className: "sr-only"
335
+ }, label3), /* @__PURE__ */ React2.createElement(Icon, {
336
+ icon
337
+ }))), /* @__PURE__ */ React2.createElement(TextTooltip, {
338
+ text: label3,
339
+ onlyWhenTruncating: true
340
+ }, /* @__PURE__ */ React2.createElement(StackItem.HeadingLabel, {
341
+ attendableId,
342
+ related: part === "complementary",
343
+ ...pending && {
344
+ classNames: "text-description"
345
+ }
346
+ }, label3))), node && part !== "complementary" && /* @__PURE__ */ React2.createElement(Surface, {
347
+ role: "navbar-end",
348
+ data: {
349
+ subject: node.data
350
+ }
351
+ }), companioned === "companion" ? /* @__PURE__ */ React2.createElement(PlankCompanionControls, {
352
+ primary: primaryId
353
+ }) : /* @__PURE__ */ React2.createElement(PlankControls, {
354
+ capabilities,
355
+ layoutMode,
356
+ close: part === "complementary" ? "minify-end" : true,
357
+ onClick: handlePlankAction
358
+ }));
359
+ });
360
+
361
+ // src/components/Plank/PlankLoading.tsx
362
+ import React3 from "react";
363
+ var PlankLoading = () => {
364
+ return /* @__PURE__ */ React3.createElement("div", {
365
+ role: "none",
366
+ className: "grid place-items-center attention-surface"
367
+ });
368
+ };
369
+
370
+ // src/components/Plank/PlankError.tsx
371
+ var PlankContentError = ({ error }) => {
372
+ const { t } = useTranslation3(meta.id);
373
+ const errorString = error?.toString() ?? "";
374
+ return /* @__PURE__ */ React4.createElement("div", {
375
+ role: "none",
376
+ className: "overflow-y-auto p-8 attention-surface grid place-items-center"
377
+ }, /* @__PURE__ */ React4.createElement("p", {
378
+ role: "alert",
379
+ className: mx2(descriptionMessage, "break-all rounded-md p-4")
380
+ }, error ? errorString : t("error fallback message")));
381
+ };
382
+ var PlankError = ({ id, part, node, error }) => {
383
+ const [timedOut, setTimedOut] = useState(false);
384
+ useEffect2(() => {
385
+ setTimeout(() => setTimedOut(true), 5e3);
386
+ }, []);
387
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(PlankHeading, {
388
+ id,
389
+ part,
390
+ node,
391
+ pending: !timedOut
392
+ }), timedOut ? /* @__PURE__ */ React4.createElement(PlankContentError, {
393
+ error
394
+ }) : /* @__PURE__ */ React4.createElement(PlankLoading, null));
395
+ };
396
+
397
+ // src/components/Plank/Plank.tsx
398
+ var UNKNOWN_ID = "unknown_id";
399
+ var Plank = /* @__PURE__ */ memo2(({ id = UNKNOWN_ID, companionId, ...props }) => {
400
+ const { graph } = useAppGraph2();
401
+ const node = useNode(graph, id);
402
+ const companions = useCompanions(id);
403
+ const currentCompanion = companions.find(({ id: id2 }) => id2 === companionId);
404
+ const hasCompanion = !!(companionId && currentCompanion);
405
+ return /* @__PURE__ */ React5.createElement(PlankContainer, {
406
+ solo: props.part === "solo",
407
+ companion: hasCompanion,
408
+ encapsulate: !!props.settings?.encapsulatedPlanks
409
+ }, /* @__PURE__ */ React5.createElement(PlankComponent, {
410
+ id,
411
+ node,
412
+ companioned: hasCompanion ? "primary" : void 0,
413
+ companions: hasCompanion ? [] : companions,
414
+ ...props,
415
+ ...props.part === "solo" ? {
416
+ part: "solo-primary"
417
+ } : {}
418
+ }), hasCompanion && /* @__PURE__ */ React5.createElement(PlankComponent, {
419
+ id: companionId,
420
+ node: currentCompanion,
421
+ primary: node,
422
+ companions,
423
+ companioned: "companion",
424
+ ...props,
425
+ ...props.part === "solo" ? {
426
+ part: "solo-companion"
427
+ } : {
428
+ order: (props.order ?? 0) + 1
429
+ }
430
+ }));
431
+ });
432
+ var PlankContainer = ({ children, solo, companion, encapsulate }) => {
433
+ const sizeAttrs = useMainSize();
434
+ if (!solo) {
435
+ return children;
436
+ }
437
+ return /* @__PURE__ */ React5.createElement("div", {
438
+ role: "none",
439
+ "data-popover-collision-boundary": true,
440
+ className: mx3("absolute inset-[--main-spacing] grid", encapsulate && "border border-separator rounded overflow-hidden", companion && "grid-cols-[6fr_4fr]", railGridHorizontal, mainIntrinsicSize),
441
+ ...sizeAttrs
442
+ }, children);
443
+ };
444
+ var PlankComponent = /* @__PURE__ */ memo2(({ layoutMode, id, part, path, order, active, companioned, node, primary, companions, settings }) => {
445
+ const { invokePromise } = useOperationInvoker3();
446
+ const { state, deck } = useDeckState();
447
+ const { popoverAnchorId, scrollIntoView } = state;
448
+ const { findFirstFocusable } = useFocusFinders();
449
+ const canResize = layoutMode === "deck";
450
+ const attentionAttrs = useAttentionAttributes(primary?.id ?? id);
451
+ const index = active ? active.findIndex((entryId) => entryId === id) : 0;
452
+ const length = active?.length ?? 1;
453
+ const canIncrementStart = active && index !== void 0 && index > 0 && length !== void 0 && length > 1;
454
+ const canIncrementEnd = active && index !== void 0 && index < length - 1 && length !== void 0;
455
+ const rootElement = useRef(null);
456
+ const { variant } = parseEntryId(id);
457
+ const sizeKey = `${id.split("+")[0]}${variant ? `${ATTENDABLE_PATH_SEPARATOR}${variant}` : ""}`;
458
+ const size = deck.plankSizing[sizeKey];
459
+ const handleSizeChange = useCallback3(debounce((nextSize) => {
460
+ return invokePromise(DeckOperation.UpdatePlankSize, {
461
+ id: sizeKey,
462
+ size: nextSize
463
+ });
464
+ }, 200), [
465
+ invokePromise,
466
+ sizeKey
467
+ ]);
468
+ const handleKeyDown = useCallback3((event) => {
469
+ if (event.target === event.currentTarget) {
470
+ switch (event.key) {
471
+ case "Escape":
472
+ rootElement.current?.closest("main")?.focus();
473
+ break;
474
+ case "Enter":
475
+ rootElement.current && findFirstFocusable(rootElement.current)?.focus();
476
+ break;
477
+ }
478
+ }
479
+ }, []);
480
+ useLayoutEffect(() => {
481
+ if (scrollIntoView === id) {
482
+ layoutMode === "deck" && rootElement.current?.scrollIntoView({
483
+ behavior: "smooth",
484
+ inline: "center"
485
+ });
486
+ void invokePromise(Common2.LayoutOperation.ScrollIntoView, {
487
+ subject: void 0
488
+ });
489
+ }
490
+ }, [
491
+ id,
492
+ scrollIntoView,
493
+ layoutMode,
494
+ invokePromise
495
+ ]);
496
+ const isSolo = layoutMode.startsWith("solo") && part === "solo";
497
+ const isAttendable = layoutMode.startsWith("solo") && part.startsWith("solo") || layoutMode === "deck" && part === "deck";
498
+ const sizeAttrs = useMainSize();
499
+ const data = useMemo2(() => node && {
500
+ attendableId: id,
501
+ subject: node.data,
502
+ companionTo: primary?.data,
503
+ properties: node.properties,
504
+ variant,
505
+ path,
506
+ popoverAnchorId
507
+ }, [
508
+ node,
509
+ node?.data,
510
+ node?.properties,
511
+ path,
512
+ popoverAnchorId,
513
+ primary?.data,
514
+ variant
515
+ ]);
516
+ const placeholder = useMemo2(() => /* @__PURE__ */ React5.createElement(PlankLoading, null), []);
517
+ const Root = part.startsWith("solo") ? "article" : StackItem2.Root;
518
+ const fullscreen = layoutMode === "solo--fullscreen";
519
+ const className = mx3("attention-surface relative dx-focus-ring-inset-over-all density-coarse", isSolo && "absolute inset-0", isSolo && mainIntrinsicSize, railGridHorizontal, part.startsWith("solo") && "grid", part.startsWith("solo-") && "grid-rows-subgrid row-span-2 min-is-0", fullscreen && "grid-rows-1", part === "deck" && (companioned === "companion" ? "!border-separator border-ie" : "!border-separator border-li"), part === "solo-companion" && "!border-separator border-is", settings?.encapsulatedPlanks && !part.startsWith("solo") && "mli-[--main-spacing] !border-separator border rounded overflow-hidden");
520
+ return /* @__PURE__ */ React5.createElement(Root, {
521
+ ref: rootElement,
522
+ "data-testid": "deck.plank",
523
+ "data-popover-collision-boundary": true,
524
+ tabIndex: 0,
525
+ ...part.startsWith("solo") ? {
526
+ ...sizeAttrs,
527
+ className
528
+ } : {
529
+ item: {
530
+ id
531
+ },
532
+ size,
533
+ onSizeChange: handleSizeChange,
534
+ classNames: className,
535
+ order,
536
+ role: "article"
537
+ },
538
+ ...isAttendable ? attentionAttrs : {},
539
+ onKeyDown: handleKeyDown
540
+ }, node ? /* @__PURE__ */ React5.createElement(React5.Fragment, null, !fullscreen && /* @__PURE__ */ React5.createElement(PlankHeading, {
541
+ id,
542
+ part: part.startsWith("solo-") ? "solo" : part,
543
+ node,
544
+ layoutMode,
545
+ deckEnabled: settings?.enableDeck,
546
+ canIncrementStart,
547
+ canIncrementEnd,
548
+ popoverAnchorId,
549
+ primaryId: primary?.id,
550
+ companioned,
551
+ companions
552
+ }), /* @__PURE__ */ React5.createElement(Surface2, {
553
+ key: node.id,
554
+ role: "article",
555
+ data,
556
+ limit: 1,
557
+ fallback: PlankContentError,
558
+ placeholder
559
+ })) : /* @__PURE__ */ React5.createElement(PlankError, {
560
+ id,
561
+ part
562
+ }), canResize && /* @__PURE__ */ React5.createElement(StackItem2.ResizeHandle, null));
563
+ });
564
+
565
+ // src/components/Sidebar/SidebarButton.tsx
566
+ import React6, { useCallback as useCallback4 } from "react";
567
+ import { Common as Common3 } from "@dxos/app-framework";
568
+ import { useOperationInvoker as useOperationInvoker4 } from "@dxos/app-framework/react";
569
+ import { IconButton as IconButton3, useTranslation as useTranslation4 } from "@dxos/react-ui";
570
+ var ToggleSidebarButton = ({ classNames, variant = "ghost" }) => {
571
+ const { state, updateState } = useDeckState();
572
+ const { t } = useTranslation4(meta.id);
573
+ const handleClick = useCallback4(() => {
574
+ updateState((s) => ({
575
+ ...s,
576
+ sidebarState: s.sidebarState === "expanded" ? "collapsed" : "expanded"
577
+ }));
578
+ }, [
579
+ updateState
580
+ ]);
581
+ return /* @__PURE__ */ React6.createElement(IconButton3, {
582
+ variant,
583
+ icon: "ph--sidebar--regular",
584
+ iconOnly: true,
585
+ size: 4,
586
+ label: t("open navigation sidebar label"),
587
+ onClick: handleClick,
588
+ classNames
589
+ });
590
+ };
591
+ var CloseSidebarButton = () => {
592
+ const { updateState } = useDeckState();
593
+ const { t } = useTranslation4(meta.id);
594
+ const handleClick = useCallback4(() => {
595
+ updateState((s) => ({
596
+ ...s,
597
+ sidebarState: "collapsed"
598
+ }));
599
+ }, [
600
+ updateState
601
+ ]);
602
+ return /* @__PURE__ */ React6.createElement(IconButton3, {
603
+ variant: "ghost",
604
+ icon: "ph--caret-line-left--regular",
605
+ iconOnly: true,
606
+ size: 4,
607
+ label: t("close navigation sidebar label"),
608
+ onClick: handleClick,
609
+ classNames: "rounded-none pli-1 dx-focus-ring-inset pie-[max(.5rem,env(safe-area-inset-left))]"
610
+ });
611
+ };
612
+ var ToggleComplementarySidebarButton = ({ inR0, classNames, current }) => {
613
+ const { invokeSync } = useOperationInvoker4();
614
+ const { state, updateState } = useDeckState();
615
+ const { t } = useTranslation4(meta.id);
616
+ const companions = useDeckCompanions();
617
+ const handleClick = useCallback4(() => {
618
+ const nextState = state.complementarySidebarState === "expanded" ? "collapsed" : "expanded";
619
+ updateState((s) => ({
620
+ ...s,
621
+ complementarySidebarState: nextState
622
+ }));
623
+ const subject = state.complementarySidebarPanel ?? (companions[0] && getCompanionId(companions[0].id));
624
+ if (nextState === "expanded" && !current && subject) {
625
+ invokeSync(Common3.LayoutOperation.UpdateComplementary, {
626
+ subject
627
+ });
628
+ }
629
+ }, [
630
+ state,
631
+ updateState,
632
+ current,
633
+ companions,
634
+ invokeSync
635
+ ]);
636
+ return /* @__PURE__ */ React6.createElement(IconButton3, {
637
+ variant: "ghost",
638
+ classNames: [
639
+ "[&>svg]:-scale-x-100",
640
+ classNames
641
+ ],
642
+ icon: "ph--sidebar-simple--regular",
643
+ iconOnly: true,
644
+ label: t("open complementary sidebar label"),
645
+ size: inR0 ? 5 : 4,
646
+ tooltipSide: inR0 ? "left" : void 0,
647
+ onClick: handleClick
648
+ });
649
+ };
650
+
651
+ // src/components/Sidebar/ComplementarySidebar.tsx
652
+ var label = [
653
+ "complementary sidebar title",
654
+ {
655
+ ns: meta.id
656
+ }
657
+ ];
658
+ var ComplementarySidebar = ({ current }) => {
659
+ const { t } = useTranslation5(meta.id);
660
+ const { invokeSync } = useOperationInvoker5();
661
+ const { state, deck, updateState } = useDeckState();
662
+ const layoutMode = getMode(deck);
663
+ const breakpoint = useBreakpoints();
664
+ const topbar = layoutAppliesTopbar(breakpoint, layoutMode);
665
+ const hoistStatusbar = useHoistStatusbar(breakpoint, layoutMode);
666
+ const companions = useDeckCompanions();
667
+ const activeCompanion = companions.find((companion) => getCompanionId(companion.id) === current);
668
+ const activeId = activeCompanion && getCompanionId(activeCompanion.id);
669
+ const [internalValue, setInternalValue] = useState2(activeId);
670
+ useEffect3(() => {
671
+ setInternalValue(activeId);
672
+ }, [
673
+ activeId
674
+ ]);
675
+ const handleTabClick = useCallback5((event) => {
676
+ const nextValue = event.currentTarget.getAttribute("data-value");
677
+ if (nextValue === activeId) {
678
+ updateState((s) => ({
679
+ ...s,
680
+ complementarySidebarState: s.complementarySidebarState === "expanded" ? "collapsed" : "expanded"
681
+ }));
682
+ } else {
683
+ setInternalValue(nextValue);
684
+ updateState((s) => ({
685
+ ...s,
686
+ complementarySidebarState: "expanded"
687
+ }));
688
+ invokeSync(Common4.LayoutOperation.UpdateComplementary, {
689
+ subject: nextValue
690
+ });
691
+ }
692
+ }, [
693
+ state.complementarySidebarState,
694
+ activeId,
695
+ invokeSync,
696
+ updateState
697
+ ]);
698
+ const data = useMemo3(() => activeCompanion && {
699
+ id: activeCompanion.id,
700
+ subject: activeCompanion.data
701
+ }, [
702
+ activeCompanion?.id,
703
+ activeCompanion?.data
704
+ ]);
705
+ useEffect3(() => {
706
+ if (!activeId) {
707
+ invokeSync(Common4.LayoutOperation.UpdateComplementary, {
708
+ state: "collapsed"
709
+ });
710
+ }
711
+ }, [
712
+ activeId,
713
+ invokeSync
714
+ ]);
715
+ return /* @__PURE__ */ React7.createElement(Main.ComplementarySidebar, {
716
+ label,
717
+ classNames: [
718
+ topbar && "block-start-[calc(env(safe-area-inset-top)+var(--rail-size))]",
719
+ hoistStatusbar && "block-end-[--statusbar-size]"
720
+ ]
721
+ }, /* @__PURE__ */ React7.createElement(Tabs.Root, {
722
+ orientation: "vertical",
723
+ verticalVariant: "stateless",
724
+ value: internalValue,
725
+ classNames: "contents"
726
+ }, /* @__PURE__ */ React7.createElement("div", {
727
+ role: "none",
728
+ className: mx4("absolute z-[1] inset-block-0 inline-end-0 !is-[--r0-size]", "pbs-[env(safe-area-inset-top)] pbe-[env(safe-area-inset-bottom)] border-is border-subduedSeparator", "grid grid-cols-1 grid-rows-[1fr_min-content] bg-baseSurface contain-layout app-drag")
729
+ }, /* @__PURE__ */ React7.createElement(Tabs.Tablist, {
730
+ classNames: "grid grid-cols-1 auto-rows-[--rail-action] p-1 gap-1 !overflow-y-auto"
731
+ }, companions.map((companion) => /* @__PURE__ */ React7.createElement(Tabs.Tab, {
732
+ key: getCompanionId(companion.id),
733
+ value: getCompanionId(companion.id),
734
+ asChild: true
735
+ }, /* @__PURE__ */ React7.createElement(IconButton4, {
736
+ label: toLocalizedString2(companion.properties.label, t),
737
+ icon: companion.properties.icon,
738
+ iconOnly: true,
739
+ tooltipSide: "left",
740
+ "data-value": getCompanionId(companion.id),
741
+ variant: activeId === getCompanionId(companion.id) ? state.complementarySidebarState === "expanded" ? "primary" : "default" : "ghost",
742
+ onClick: handleTabClick
743
+ })))), !hoistStatusbar && /* @__PURE__ */ React7.createElement("div", {
744
+ role: "none",
745
+ className: "grid grid-cols-1 auto-rows-[--rail-item] p-1 overflow-y-auto"
746
+ }, /* @__PURE__ */ React7.createElement(Surface3, {
747
+ role: "status-bar--r0-footer",
748
+ limit: 1
749
+ })), /* @__PURE__ */ React7.createElement("div", {
750
+ role: "none",
751
+ className: "hidden lg:grid grid-cols-1 auto-rows-[--rail-action] p-1"
752
+ }, /* @__PURE__ */ React7.createElement(ToggleComplementarySidebarButton, null))), activeId && companions.map((companion) => /* @__PURE__ */ React7.createElement(Tabs.Tabpanel, {
753
+ key: getCompanionId(companion.id),
754
+ value: getCompanionId(companion.id),
755
+ classNames: [
756
+ 'absolute data-[state="inactive"]:-z-[1] overflow-hidden',
757
+ "inset-block-0 inline-start-0 is-[calc(100%-var(--r0-size))] lg:is-[--r1-size]",
758
+ "grid grid-cols-1 grid-rows-[var(--rail-size)_1fr_min-content] pbs-[env(safe-area-inset-top)]"
759
+ ],
760
+ ...state.complementarySidebarState !== "expanded" && {
761
+ inert: true
762
+ }
763
+ }, /* @__PURE__ */ React7.createElement(ComplementarySidebarPanel, {
764
+ companion,
765
+ activeId,
766
+ data,
767
+ hoistStatusbar
768
+ })))));
769
+ };
770
+ var ComplementarySidebarPanel = ({ companion, activeId, data, hoistStatusbar }) => {
771
+ const { t } = useTranslation5(meta.id);
772
+ if (getCompanionId(companion.id) !== activeId && !data) {
773
+ return null;
774
+ }
775
+ const Wrapper = companion.properties.fixed ? Fragment2 : ScrollArea;
776
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("div", {
777
+ role: "none",
778
+ className: "flex items-center p-1 gap-1 border-be border-subduedSeparator"
779
+ }, /* @__PURE__ */ React7.createElement(IconButton4, {
780
+ label: toLocalizedString2(companion.properties.label, t),
781
+ icon: companion.properties.icon,
782
+ iconOnly: true,
783
+ tooltipSide: "left",
784
+ "data-value": getCompanionId(companion.id),
785
+ classNames: "bs-10 is-10",
786
+ variant: "default"
787
+ }), /* @__PURE__ */ React7.createElement("div", {
788
+ role: "none",
789
+ className: "pli-1"
790
+ }, toLocalizedString2(companion.properties.label, t))), /* @__PURE__ */ React7.createElement(Wrapper, null, /* @__PURE__ */ React7.createElement(Surface3, {
791
+ role: `deck-companion--${getCompanionId(companion.id)}`,
792
+ data,
793
+ fallback: PlankContentError,
794
+ placeholder: /* @__PURE__ */ React7.createElement(PlankLoading, null)
795
+ })), !hoistStatusbar && /* @__PURE__ */ React7.createElement("div", {
796
+ role: "contentinfo",
797
+ className: "flex flex-wrap justify-center items-center border-bs border-subduedSeparator pbs-1 pbe-[max(env(safe-area-inset-bottom),0.25rem)]"
798
+ }, /* @__PURE__ */ React7.createElement(Surface3, {
799
+ role: "status-bar--r1-footer",
800
+ limit: 1
801
+ })));
802
+ };
803
+ var ScrollArea = ({ children }) => {
804
+ return /* @__PURE__ */ React7.createElement("div", {
805
+ className: "flex flex-col grow overflow-x-hidden overflow-y-auto scrollbar-thin"
806
+ }, children);
807
+ };
808
+
809
+ // src/components/Sidebar/Sidebar.tsx
810
+ import React8, { useMemo as useMemo4 } from "react";
811
+ import { Surface as Surface4 } from "@dxos/app-framework/react";
812
+ import { Main as Main2 } from "@dxos/react-ui";
813
+ var label2 = [
814
+ "sidebar title",
815
+ {
816
+ ns: meta.id
817
+ }
818
+ ];
819
+ var Sidebar = () => {
820
+ const { state, deck } = useDeckState();
821
+ const { popoverAnchorId, activeDeck: current } = state;
822
+ const breakpoint = useBreakpoints();
823
+ const layoutMode = getMode(deck);
824
+ const topbar = layoutAppliesTopbar(breakpoint, layoutMode);
825
+ const hoistStatusbar = useHoistStatusbar(breakpoint, layoutMode);
826
+ const navigationData = useMemo4(() => ({
827
+ popoverAnchorId,
828
+ topbar,
829
+ hoistStatusbar,
830
+ current
831
+ }), [
832
+ popoverAnchorId,
833
+ topbar,
834
+ hoistStatusbar,
835
+ current
836
+ ]);
837
+ return /* @__PURE__ */ React8.createElement(Main2.NavigationSidebar, {
838
+ label: label2,
839
+ classNames: [
840
+ "grid",
841
+ topbar && "block-start-[calc(env(safe-area-inset-top)+var(--rail-size))]",
842
+ hoistStatusbar && "block-end-[--statusbar-size]"
843
+ ]
844
+ }, /* @__PURE__ */ React8.createElement(Surface4, {
845
+ role: "navigation",
846
+ data: navigationData,
847
+ limit: 1
848
+ }));
849
+ };
850
+
851
+ // src/components/DeckLayout/Banner.tsx
852
+ var Banner = ({ variant, classNames }) => {
853
+ const { t } = useTranslation6(meta.id);
854
+ return /* @__PURE__ */ React9.createElement("header", {
855
+ className: mx5("flex items-stretch relative plb-1 pis-1 pie-2", variant === "topbar" && "fixed inset-inline-0 block-start-[env(safe-area-inset-top)] bs-[--rail-size] border-be border-separator", classNames)
856
+ }, variant === "sidebar" ? /* @__PURE__ */ React9.createElement(CloseSidebarButton, null) : /* @__PURE__ */ React9.createElement(ToggleSidebarButton, null), /* @__PURE__ */ React9.createElement("span", {
857
+ className: "self-center grow mis-1"
858
+ }, t("current app name", {
859
+ ns: osTranslations
860
+ })), variant === "topbar" && /* @__PURE__ */ React9.createElement("div", {
861
+ role: "none",
862
+ className: "absolute inset-0 pointer-events-none"
863
+ }, /* @__PURE__ */ React9.createElement("div", {
864
+ role: "none",
865
+ className: "grid bs-full pointer-fine:p-1 max-is-md mli-auto pointer-events-auto"
866
+ }, /* @__PURE__ */ React9.createElement(Surface5, {
867
+ role: "search-input",
868
+ limit: 1
869
+ }))), /* @__PURE__ */ React9.createElement("span", {
870
+ role: "none",
871
+ className: "grow"
872
+ }), /* @__PURE__ */ React9.createElement(Surface5, {
873
+ role: "header-end",
874
+ limit: 1
875
+ }), /* @__PURE__ */ React9.createElement(Surface5, {
876
+ role: "notch-start",
877
+ limit: 1
878
+ }));
879
+ };
880
+
881
+ // src/components/DeckLayout/DeckLayout.tsx
882
+ import React18 from "react";
883
+ import { Mosaic } from "@dxos/react-ui-mosaic";
884
+
885
+ // src/components/DeckLayout/ActiveNode.tsx
886
+ import React10 from "react";
887
+ import { Surface as Surface6, useAppGraph as useAppGraph3 } from "@dxos/app-framework/react";
888
+ import { useNode as useNode2 } from "@dxos/plugin-graph";
889
+ import { useAttended } from "@dxos/react-ui-attention";
890
+ var ActiveNode = () => {
891
+ const [id] = useAttended();
892
+ const { graph } = useAppGraph3();
893
+ const activeNode = useNode2(graph, id);
894
+ useNodeActionExpander(activeNode);
895
+ return /* @__PURE__ */ React10.createElement("div", {
896
+ role: "none",
897
+ className: "sr-only"
898
+ }, /* @__PURE__ */ React10.createElement(Surface6, {
899
+ role: "document-title",
900
+ data: {
901
+ subject: activeNode
902
+ },
903
+ limit: 1
904
+ }));
905
+ };
906
+
907
+ // src/components/DeckLayout/DeckMain.tsx
908
+ import React14, { Fragment as Fragment3, useCallback as useCallback6, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef2 } from "react";
909
+ import { Common as Common5 } from "@dxos/app-framework";
910
+ import { useAtomCapability, useOperationInvoker as useOperationInvoker6, usePluginManager } from "@dxos/app-framework/react";
911
+ import { AttentionCapabilities } from "@dxos/plugin-attention";
912
+ import { Main as Main3, useMediaQuery, useOnTransition } from "@dxos/react-ui";
913
+ import { DEFAULT_HORIZONTAL_SIZE, Stack, StackContext } from "@dxos/react-ui-stack";
914
+ import { mainPaddingTransitions, mx as mx6 } from "@dxos/ui-theme";
915
+
916
+ // src/components/DeckLayout/ContentEmpty.tsx
917
+ import React11 from "react";
918
+ import { Surface as Surface7 } from "@dxos/app-framework/react";
919
+ var ContentEmpty = () => {
920
+ const breakpoint = useBreakpoints();
921
+ const { deck } = useDeckState();
922
+ const layoutMode = getMode(deck);
923
+ const topbar = layoutAppliesTopbar(breakpoint, layoutMode);
924
+ return /* @__PURE__ */ React11.createElement("div", {
925
+ role: "none",
926
+ className: "grid place-items-center p-8 relative bg-deckSurface",
927
+ "data-testid": "layoutPlugin.firstRunMessage"
928
+ }, /* @__PURE__ */ React11.createElement(Surface7, {
929
+ role: "keyshortcuts"
930
+ }), !topbar && /* @__PURE__ */ React11.createElement(ToggleSidebarButton, {
931
+ variant: "default",
932
+ classNames: fixedSidebarToggleStyles
933
+ }));
934
+ };
935
+
936
+ // src/components/DeckLayout/StatusBar.tsx
937
+ import React12 from "react";
938
+ import { Surface as Surface8 } from "@dxos/app-framework/react";
939
+ import { useLandmarkMover } from "@dxos/react-ui";
940
+ var StatusBar = ({ showHints }) => {
941
+ const mover = useLandmarkMover(void 0, "3");
942
+ return /* @__PURE__ */ React12.createElement("div", {
943
+ role: "contentinfo",
944
+ className: "fixed block-end-0 inset-inline-0 bs-[--statusbar-size] border-bs border-separator z-[2] flex text-description",
945
+ ...mover
946
+ }, showHints && /* @__PURE__ */ React12.createElement(Surface8, {
947
+ role: "hints",
948
+ limit: 1
949
+ }), /* @__PURE__ */ React12.createElement(Surface8, {
950
+ role: "status-bar",
951
+ limit: 1
952
+ }));
953
+ };
954
+
955
+ // src/components/DeckLayout/Topbar.tsx
956
+ import React13 from "react";
957
+ var Topbar = () => {
958
+ return /* @__PURE__ */ React13.createElement(Banner, {
959
+ variant: "topbar"
960
+ });
961
+ };
962
+
963
+ // src/components/DeckLayout/DeckMain.tsx
964
+ var DeckMain = () => {
965
+ const { invokeSync } = useOperationInvoker6();
966
+ const settings = useAtomCapability(DeckCapabilities.Settings);
967
+ const { state, deck, updateState } = useDeckState();
968
+ const { sidebarState, complementarySidebarState, complementarySidebarPanel } = state;
969
+ const { active, activeCompanions, fullscreen, solo, plankSizing } = deck;
970
+ const layoutMode = getMode(deck);
971
+ const breakpoint = useBreakpoints();
972
+ const topbar = layoutAppliesTopbar(breakpoint, layoutMode);
973
+ const hoistStatusbar = useHoistStatusbar(breakpoint, layoutMode);
974
+ const pluginManager = usePluginManager();
975
+ const scrollLeftRef = useRef2(null);
976
+ const deckRef = useRef2(null);
977
+ useEffect4(() => {
978
+ const attention = pluginManager.capabilities.get(AttentionCapabilities.Attention);
979
+ const attended = attention.getCurrent();
980
+ const firstId = solo ?? active[0];
981
+ if (attended.length === 0 && firstId) {
982
+ document.querySelector(`article[data-attendable-id="${firstId}"] button`)?.focus();
983
+ }
984
+ }, []);
985
+ const [isNotMobile] = useMediaQuery("md");
986
+ const shouldRevert = useRef2(false);
987
+ useEffect4(() => {
988
+ if (!isNotMobile && layoutMode === "deck") {
989
+ const attention = pluginManager.capabilities.get(AttentionCapabilities.Attention);
990
+ const attended = attention.getCurrent();
991
+ shouldRevert.current = true;
992
+ invokeSync(Common5.LayoutOperation.SetLayoutMode, {
993
+ subject: attended[0],
994
+ mode: "solo"
995
+ });
996
+ } else if (isNotMobile && layoutMode === "solo" && shouldRevert.current) {
997
+ invokeSync(Common5.LayoutOperation.SetLayoutMode, {
998
+ revert: true
999
+ });
1000
+ }
1001
+ }, [
1002
+ isNotMobile,
1003
+ layoutMode,
1004
+ invokeSync
1005
+ ]);
1006
+ useEffect4(() => {
1007
+ if (!settings?.enableDeck && layoutMode === "deck") {
1008
+ invokeSync(Common5.LayoutOperation.SetLayoutMode, {
1009
+ subject: active[0],
1010
+ mode: "solo"
1011
+ });
1012
+ }
1013
+ }, [
1014
+ settings?.enableDeck,
1015
+ invokeSync,
1016
+ active,
1017
+ layoutMode
1018
+ ]);
1019
+ const handleResize = useCallback6(() => {
1020
+ scrollLeftRef.current = null;
1021
+ }, []);
1022
+ useEffect4(() => {
1023
+ window.addEventListener("resize", handleResize);
1024
+ return () => window.removeEventListener("resize", handleResize);
1025
+ }, [
1026
+ handleResize
1027
+ ]);
1028
+ const restoreScroll = useCallback6(() => {
1029
+ if (deckRef.current && scrollLeftRef.current != null) {
1030
+ deckRef.current.scrollLeft = scrollLeftRef.current;
1031
+ }
1032
+ }, []);
1033
+ useOnTransition(layoutMode, (mode) => mode !== "deck", "deck", restoreScroll);
1034
+ const handleScroll = useCallback6((event) => {
1035
+ if (!solo && event.currentTarget === event.target) {
1036
+ scrollLeftRef.current = event.target.scrollLeft;
1037
+ }
1038
+ }, [
1039
+ solo
1040
+ ]);
1041
+ const isEmpty = !solo && active.length === 0;
1042
+ const padding = useMemo5(() => {
1043
+ if (!solo && settings?.overscroll === "centering") {
1044
+ return calculateOverscroll(active.length);
1045
+ }
1046
+ return {};
1047
+ }, [
1048
+ solo,
1049
+ settings?.overscroll,
1050
+ deck
1051
+ ]);
1052
+ const mainPosition = useMemo5(() => [
1053
+ "grid !block-start-[env(safe-area-inset-top)]",
1054
+ topbar && "!block-start-[calc(env(safe-area-inset-top)+var(--rail-size))]",
1055
+ hoistStatusbar && "lg:block-end-[--statusbar-size]"
1056
+ ], [
1057
+ topbar,
1058
+ hoistStatusbar
1059
+ ]);
1060
+ const { order, itemsCount } = useMemo5(() => {
1061
+ return active.reduce((acc, entryId) => {
1062
+ acc.order[entryId] = acc.itemsCount + 1;
1063
+ acc.itemsCount += activeCompanions?.[entryId] ? 3 : 2;
1064
+ return acc;
1065
+ }, {
1066
+ order: {},
1067
+ itemsCount: 0
1068
+ });
1069
+ }, [
1070
+ active,
1071
+ activeCompanions
1072
+ ]);
1073
+ const handleNavigationSidebarStateChange = useCallback6((next) => {
1074
+ updateState((s) => ({
1075
+ ...s,
1076
+ sidebarState: next
1077
+ }));
1078
+ }, [
1079
+ updateState
1080
+ ]);
1081
+ const handleComplementarySidebarStateChange = useCallback6((next) => {
1082
+ updateState((s) => ({
1083
+ ...s,
1084
+ complementarySidebarState: next
1085
+ }));
1086
+ }, [
1087
+ updateState
1088
+ ]);
1089
+ return /* @__PURE__ */ React14.createElement(Main3.Root, {
1090
+ navigationSidebarState: fullscreen ? "closed" : sidebarState,
1091
+ complementarySidebarState: fullscreen ? "closed" : complementarySidebarState,
1092
+ onNavigationSidebarStateChange: handleNavigationSidebarStateChange,
1093
+ onComplementarySidebarStateChange: handleComplementarySidebarStateChange
1094
+ }, /* @__PURE__ */ React14.createElement(Sidebar, null), /* @__PURE__ */ React14.createElement(ComplementarySidebar, {
1095
+ current: complementarySidebarPanel
1096
+ }), /* @__PURE__ */ React14.createElement(Main3.Overlay, null), isEmpty && /* @__PURE__ */ React14.createElement(Main3.Content, {
1097
+ bounce: true,
1098
+ handlesFocus: true,
1099
+ classNames: mainPosition
1100
+ }, /* @__PURE__ */ React14.createElement(ContentEmpty, null)), !isEmpty && /* @__PURE__ */ React14.createElement(Main3.Content, {
1101
+ bounce: true,
1102
+ handlesFocus: true,
1103
+ classNames: mainPosition,
1104
+ style: {
1105
+ "--main-spacing": settings?.encapsulatedPlanks ? "0.75rem" : "0",
1106
+ "--dx-main-sidebarWidth": sidebarState === "expanded" ? "var(--nav-sidebar-size)" : sidebarState === "collapsed" ? "var(--l0-size)" : "0",
1107
+ "--dx-main-complementaryWidth": complementarySidebarState === "expanded" ? "var(--complementary-sidebar-size)" : complementarySidebarState === "collapsed" ? "var(--rail-size)" : "0",
1108
+ "--dx-main-contentFirstWidth": `${plankSizing[active[0] ?? "never"] ?? DEFAULT_HORIZONTAL_SIZE}rem`,
1109
+ "--dx-main-contentLastWidth": `${plankSizing[active[(active.length ?? 1) - 1] ?? "never"] ?? DEFAULT_HORIZONTAL_SIZE}rem`
1110
+ }
1111
+ }, /* @__PURE__ */ React14.createElement("div", {
1112
+ role: "none",
1113
+ className: !solo ? "relative bg-deckSurface overflow-hidden" : "sr-only",
1114
+ ...solo && {
1115
+ inert: true
1116
+ }
1117
+ }, !topbar && !fullscreen && /* @__PURE__ */ React14.createElement(ToggleSidebarButton, {
1118
+ classNames: fixedSidebarToggleStyles
1119
+ }), !topbar && !fullscreen && /* @__PURE__ */ React14.createElement(ToggleComplementarySidebarButton, {
1120
+ classNames: fixedComplementarySidebarToggleStyles
1121
+ }), /* @__PURE__ */ React14.createElement(Stack, {
1122
+ ref: deckRef,
1123
+ orientation: "horizontal",
1124
+ size: "contain",
1125
+ itemsCount: itemsCount - 1,
1126
+ classNames: [
1127
+ "absolute inset-block-[--main-spacing] -inset-inline-px bs-[calc(100%-2*var(--main-spacing))]",
1128
+ mainPaddingTransitions
1129
+ ],
1130
+ style: padding,
1131
+ onScroll: handleScroll
1132
+ }, active.map((entryId) => /* @__PURE__ */ React14.createElement(Fragment3, {
1133
+ key: entryId
1134
+ }, /* @__PURE__ */ React14.createElement(PlankSeparator, {
1135
+ order: order[entryId] - 1,
1136
+ encapsulate: !!settings?.enableDeck
1137
+ }), /* @__PURE__ */ React14.createElement(Plank, {
1138
+ id: entryId,
1139
+ companionId: activeCompanions?.[entryId],
1140
+ part: "deck",
1141
+ order: order[entryId],
1142
+ active,
1143
+ layoutMode,
1144
+ settings
1145
+ }))))), /* @__PURE__ */ React14.createElement("div", {
1146
+ role: "none",
1147
+ className: solo ? "relative overflow-hidden bg-deckSurface" : "sr-only",
1148
+ ...!solo && {
1149
+ inert: true
1150
+ }
1151
+ }, !topbar && !fullscreen && /* @__PURE__ */ React14.createElement(ToggleSidebarButton, {
1152
+ classNames: fixedSidebarToggleStyles
1153
+ }), !topbar && !fullscreen && /* @__PURE__ */ React14.createElement(ToggleComplementarySidebarButton, {
1154
+ classNames: fixedComplementarySidebarToggleStyles
1155
+ }), /* @__PURE__ */ React14.createElement(StackContext.Provider, {
1156
+ value: {
1157
+ orientation: "horizontal",
1158
+ size: "contain",
1159
+ rail: true
1160
+ }
1161
+ }, /* @__PURE__ */ React14.createElement(Plank, {
1162
+ id: solo,
1163
+ companionId: solo ? activeCompanions?.[solo] : void 0,
1164
+ part: "solo",
1165
+ layoutMode,
1166
+ settings
1167
+ })))), topbar && /* @__PURE__ */ React14.createElement(Topbar, null), hoistStatusbar && /* @__PURE__ */ React14.createElement(StatusBar, {
1168
+ showHints: settings?.showHints
1169
+ }));
1170
+ };
1171
+ var PlankSeparator = ({ order, encapsulate }) => order > 0 ? /* @__PURE__ */ React14.createElement("span", {
1172
+ role: "separator",
1173
+ className: mx6("row-span-2 bg-deckSurface", encapsulate ? "is-0" : "is-4"),
1174
+ style: {
1175
+ gridColumn: order
1176
+ }
1177
+ }) : null;
1178
+
1179
+ // src/components/DeckLayout/Dialog.tsx
1180
+ import React15, { useCallback as useCallback7 } from "react";
1181
+ import { Surface as Surface9 } from "@dxos/app-framework/react";
1182
+ import { AlertDialog, Dialog as NaturalDialog } from "@dxos/react-ui";
1183
+ var Dialog = () => {
1184
+ const { state, updateEphemeral } = useDeckState();
1185
+ const { dialogOpen, dialogType, dialogBlockAlign, dialogOverlayClasses, dialogOverlayStyle, dialogContent } = state;
1186
+ const Root = dialogType === "alert" ? AlertDialog.Root : NaturalDialog.Root;
1187
+ const Overlay = dialogType === "alert" ? AlertDialog.Overlay : NaturalDialog.Overlay;
1188
+ const handleOpenChange = useCallback7((nextOpen) => {
1189
+ updateEphemeral((s) => ({
1190
+ ...s,
1191
+ dialogOpen: nextOpen
1192
+ }));
1193
+ }, [
1194
+ updateEphemeral
1195
+ ]);
1196
+ return /* @__PURE__ */ React15.createElement(Root, {
1197
+ modal: dialogBlockAlign !== "end",
1198
+ open: dialogOpen,
1199
+ onOpenChange: handleOpenChange
1200
+ }, dialogBlockAlign === "end" ? (
1201
+ // TODO(burdon): Placeholder creates a suspense boundary; replace with defaults.
1202
+ /* @__PURE__ */ React15.createElement(Surface9, {
1203
+ role: "dialog",
1204
+ data: dialogContent,
1205
+ limit: 1,
1206
+ fallback: PlankContentError,
1207
+ placeholder: /* @__PURE__ */ React15.createElement("div", null)
1208
+ })
1209
+ ) : /* @__PURE__ */ React15.createElement(Overlay, {
1210
+ blockAlign: dialogBlockAlign,
1211
+ classNames: dialogOverlayClasses,
1212
+ style: dialogOverlayStyle
1213
+ }, /* @__PURE__ */ React15.createElement(Surface9, {
1214
+ role: "dialog",
1215
+ data: dialogContent,
1216
+ limit: 1,
1217
+ fallback: PlankContentError
1218
+ })));
1219
+ };
1220
+
1221
+ // src/components/DeckLayout/Popover.tsx
1222
+ import { createContext } from "@radix-ui/react-context";
1223
+ import React16, { useCallback as useCallback8, useEffect as useEffect5, useRef as useRef3, useState as useState3 } from "react";
1224
+ import { Surface as Surface10 } from "@dxos/app-framework/react";
1225
+ import { Popover as Popover2, toLocalizedString as toLocalizedString3, useTranslation as useTranslation7 } from "@dxos/react-ui";
1226
+ import { Card } from "@dxos/react-ui-mosaic";
1227
+ var DEBOUNCE_DELAY = 40;
1228
+ var [DeckPopoverProvider, useDeckPopoverContext] = createContext("DeckPopover");
1229
+ var PopoverRoot = ({ children }) => {
1230
+ const { state } = useDeckState();
1231
+ const virtualRef = useRef3(null);
1232
+ const [virtualIter, setVirtualIter] = useState3(0);
1233
+ const [open, setOpen] = useState3(false);
1234
+ const debounceRef = useRef3(null);
1235
+ useEffect5(() => {
1236
+ setOpen(false);
1237
+ if (state.popoverOpen) {
1238
+ if (debounceRef.current) {
1239
+ clearTimeout(debounceRef.current);
1240
+ }
1241
+ if (state.popoverAnchor && virtualRef.current !== state.popoverAnchor) {
1242
+ virtualRef.current = state.popoverAnchor ?? null;
1243
+ setVirtualIter((iter) => iter + 1);
1244
+ }
1245
+ debounceRef.current = setTimeout(() => setOpen(true), DEBOUNCE_DELAY);
1246
+ }
1247
+ }, [
1248
+ state.popoverOpen,
1249
+ state.popoverAnchorId,
1250
+ state.popoverAnchor,
1251
+ state.popoverContent
1252
+ ]);
1253
+ return /* @__PURE__ */ React16.createElement(DeckPopoverProvider, {
1254
+ setOpen
1255
+ }, /* @__PURE__ */ React16.createElement(Popover2.Root, {
1256
+ modal: false,
1257
+ open
1258
+ }, state.popoverAnchor && /* @__PURE__ */ React16.createElement(Popover2.VirtualTrigger, {
1259
+ key: virtualIter,
1260
+ virtualRef
1261
+ }), children));
1262
+ };
1263
+ var PopoverContent = () => {
1264
+ const { t } = useTranslation7(meta.id);
1265
+ const { state, updateEphemeral } = useDeckState();
1266
+ const { setOpen } = useDeckPopoverContext("PopoverContent");
1267
+ const handleClose = useCallback8(() => {
1268
+ setOpen(false);
1269
+ updateEphemeral((state2) => ({
1270
+ ...state2,
1271
+ popoverOpen: false,
1272
+ popoverAnchor: void 0,
1273
+ popoverAnchorId: void 0,
1274
+ popoverSide: void 0
1275
+ }));
1276
+ }, [
1277
+ updateEphemeral
1278
+ ]);
1279
+ const handleInteractOutside = useCallback8((event) => {
1280
+ if (
1281
+ // TODO(thure): CodeMirror should not focus itself when it updates.
1282
+ event.type === "dismissableLayer.focusOutside" && event.currentTarget?.classList.contains("cm-content")
1283
+ ) {
1284
+ event.preventDefault();
1285
+ } else {
1286
+ handleClose();
1287
+ }
1288
+ }, [
1289
+ handleClose
1290
+ ]);
1291
+ return /* @__PURE__ */ React16.createElement(Popover2.Portal, null, /* @__PURE__ */ React16.createElement(Popover2.Content, {
1292
+ side: state.popoverSide,
1293
+ sticky: "always",
1294
+ hideWhenDetached: true,
1295
+ onInteractOutside: handleInteractOutside,
1296
+ onEscapeKeyDown: handleInteractOutside
1297
+ }, /* @__PURE__ */ React16.createElement(Popover2.Viewport, null, state.popoverKind === "card" && /* @__PURE__ */ React16.createElement(Card.Root, null, /* @__PURE__ */ React16.createElement(Card.Toolbar, null, /* @__PURE__ */ React16.createElement("span", null), state.popoverTitle ? /* @__PURE__ */ React16.createElement(Card.Title, null, toLocalizedString3(state.popoverTitle, t)) : /* @__PURE__ */ React16.createElement("span", null), /* @__PURE__ */ React16.createElement(Card.Close, {
1298
+ onClick: handleClose
1299
+ })), /* @__PURE__ */ React16.createElement(Surface10, {
1300
+ role: "card--content",
1301
+ data: state.popoverContent,
1302
+ limit: 1
1303
+ })), state.popoverKind === "base" && /* @__PURE__ */ React16.createElement(Surface10, {
1304
+ role: "popover",
1305
+ data: state.popoverContent,
1306
+ limit: 1
1307
+ })), /* @__PURE__ */ React16.createElement(Popover2.Arrow, null)));
1308
+ };
1309
+
1310
+ // src/components/DeckLayout/Toast.tsx
1311
+ import React17 from "react";
1312
+ import { Button, Icon as Icon2, Toast as NaturalToast, toLocalizedString as toLocalizedString4, useTranslation as useTranslation8 } from "@dxos/react-ui";
1313
+ var Toast = ({ id, title, description, icon, duration, actionLabel, actionAlt, closeLabel, onAction, onOpenChange }) => {
1314
+ const { t } = useTranslation8(meta.id);
1315
+ return /* @__PURE__ */ React17.createElement(NaturalToast.Root, {
1316
+ "data-testid": id,
1317
+ defaultOpen: true,
1318
+ duration,
1319
+ onOpenChange
1320
+ }, /* @__PURE__ */ React17.createElement(NaturalToast.Body, null, /* @__PURE__ */ React17.createElement(NaturalToast.Title, {
1321
+ classNames: "items-center"
1322
+ }, icon && /* @__PURE__ */ React17.createElement(Icon2, {
1323
+ icon,
1324
+ classNames: "inline mr-1"
1325
+ }), title && /* @__PURE__ */ React17.createElement("span", null, toLocalizedString4(title, t))), description && /* @__PURE__ */ React17.createElement(NaturalToast.Description, null, description && toLocalizedString4(description, t))), /* @__PURE__ */ React17.createElement(NaturalToast.Actions, null, onAction && actionAlt && actionLabel && /* @__PURE__ */ React17.createElement(NaturalToast.Action, {
1326
+ altText: toLocalizedString4(actionAlt, t),
1327
+ asChild: true
1328
+ }, /* @__PURE__ */ React17.createElement(Button, {
1329
+ "data-testid": "toast.action",
1330
+ variant: "primary",
1331
+ onClick: () => onAction?.()
1332
+ }, toLocalizedString4(actionLabel, t))), closeLabel && /* @__PURE__ */ React17.createElement(NaturalToast.Close, {
1333
+ asChild: true
1334
+ }, /* @__PURE__ */ React17.createElement(Button, {
1335
+ "data-testid": "toast.close"
1336
+ }, toLocalizedString4(closeLabel, t)))));
1337
+ };
1338
+ var Toaster = ({ toasts, onDismissToast }) => {
1339
+ return /* @__PURE__ */ React17.createElement(React17.Fragment, null, toasts?.map((toast) => /* @__PURE__ */ React17.createElement(Toast, {
1340
+ ...toast,
1341
+ key: toast.id,
1342
+ onOpenChange: (open) => {
1343
+ if (!open) {
1344
+ onDismissToast?.(toast.id);
1345
+ }
1346
+ return open;
1347
+ }
1348
+ })));
1349
+ };
1350
+
1351
+ // src/components/DeckLayout/DeckLayout.tsx
1352
+ var DeckLayout = ({ onDismissToast }) => {
1353
+ const { state } = useDeckState();
1354
+ const { toasts } = state;
1355
+ return /* @__PURE__ */ React18.createElement(Mosaic.Root, null, /* @__PURE__ */ React18.createElement(PopoverRoot, null, /* @__PURE__ */ React18.createElement(ActiveNode, null), /* @__PURE__ */ React18.createElement(DeckMain, null), /* @__PURE__ */ React18.createElement(PopoverContent, null), /* @__PURE__ */ React18.createElement(Dialog, null), /* @__PURE__ */ React18.createElement(Toaster, {
1356
+ toasts,
1357
+ onDismissToast
1358
+ })));
1359
+ };
1360
+
1361
+ // src/components/DeckSettings/DeckSettings.tsx
1362
+ import React19 from "react";
1363
+ import { Input, Select, useTranslation as useTranslation9 } from "@dxos/react-ui";
1364
+ import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from "@dxos/react-ui-form";
1365
+ var isSocket = !!globalThis.__args;
1366
+ var DeckSettings = ({ settings, onSettingsChange }) => {
1367
+ const { t } = useTranslation9(meta.id);
1368
+ return /* @__PURE__ */ React19.createElement(ControlPage, null, /* @__PURE__ */ React19.createElement(ControlSection, {
1369
+ title: t("settings title", {
1370
+ ns: meta.id
1371
+ })
1372
+ }, /* @__PURE__ */ React19.createElement(ControlGroup, null, /* @__PURE__ */ React19.createElement(ControlItemInput, {
1373
+ title: t("settings enable deck label")
1374
+ }, /* @__PURE__ */ React19.createElement(Input.Switch, {
1375
+ checked: settings.enableDeck,
1376
+ onCheckedChange: (checked) => onSettingsChange((s) => ({
1377
+ ...s,
1378
+ enableDeck: checked
1379
+ }))
1380
+ })), /* @__PURE__ */ React19.createElement(ControlItemInput, {
1381
+ title: t("settings encapsulated planks label")
1382
+ }, /* @__PURE__ */ React19.createElement(Input.Switch, {
1383
+ checked: settings.encapsulatedPlanks ?? false,
1384
+ onCheckedChange: (checked) => onSettingsChange((s) => ({
1385
+ ...s,
1386
+ encapsulatedPlanks: checked
1387
+ }))
1388
+ })), /* @__PURE__ */ React19.createElement(ControlItemInput, {
1389
+ title: t("select new plank positioning label")
1390
+ }, /* @__PURE__ */ React19.createElement(Select.Root, {
1391
+ disabled: !settings.enableDeck,
1392
+ value: settings.newPlankPositioning ?? "start",
1393
+ onValueChange: (value) => onSettingsChange((s) => ({
1394
+ ...s,
1395
+ newPlankPositioning: value
1396
+ }))
1397
+ }, /* @__PURE__ */ React19.createElement(Select.TriggerButton, {
1398
+ placeholder: t("select new plank positioning placeholder")
1399
+ }), /* @__PURE__ */ React19.createElement(Select.Portal, null, /* @__PURE__ */ React19.createElement(Select.Content, null, /* @__PURE__ */ React19.createElement(Select.Viewport, null, NewPlankPositions.map((position) => /* @__PURE__ */ React19.createElement(Select.Option, {
1400
+ key: position,
1401
+ value: position
1402
+ }, t(`settings new plank position ${position} label`)))), /* @__PURE__ */ React19.createElement(Select.Arrow, null))))), /* @__PURE__ */ React19.createElement(ControlItemInput, {
1403
+ title: t("settings overscroll label")
1404
+ }, /* @__PURE__ */ React19.createElement(Select.Root, {
1405
+ disabled: !settings.enableDeck,
1406
+ value: settings.overscroll ?? "none",
1407
+ onValueChange: (value) => onSettingsChange((s) => ({
1408
+ ...s,
1409
+ overscroll: value
1410
+ }))
1411
+ }, /* @__PURE__ */ React19.createElement(Select.TriggerButton, {
1412
+ placeholder: t("select overscroll placeholder")
1413
+ }), /* @__PURE__ */ React19.createElement(Select.Portal, null, /* @__PURE__ */ React19.createElement(Select.Content, null, /* @__PURE__ */ React19.createElement(Select.Viewport, null, OverscrollOptions.map((option) => /* @__PURE__ */ React19.createElement(Select.Option, {
1414
+ key: option,
1415
+ value: option
1416
+ }, t(`settings overscroll ${option} label`)))), /* @__PURE__ */ React19.createElement(Select.Arrow, null))))), /* @__PURE__ */ React19.createElement(ControlItemInput, {
1417
+ title: t("settings enable statusbar label")
1418
+ }, /* @__PURE__ */ React19.createElement(Input.Switch, {
1419
+ checked: settings.enableStatusbar,
1420
+ onCheckedChange: (checked) => onSettingsChange((s) => ({
1421
+ ...s,
1422
+ enableStatusbar: checked
1423
+ }))
1424
+ })), /* @__PURE__ */ React19.createElement(ControlItemInput, {
1425
+ title: t("settings show hints label")
1426
+ }, /* @__PURE__ */ React19.createElement(Input.Switch, {
1427
+ checked: settings.showHints,
1428
+ onCheckedChange: (checked) => onSettingsChange((s) => ({
1429
+ ...s,
1430
+ showHints: checked
1431
+ }))
1432
+ })), !isSocket && /* @__PURE__ */ React19.createElement(ControlItemInput, {
1433
+ title: t("settings native redirect label")
1434
+ }, /* @__PURE__ */ React19.createElement(Input.Switch, {
1435
+ checked: settings.enableNativeRedirect,
1436
+ onCheckedChange: (checked) => onSettingsChange((s) => ({
1437
+ ...s,
1438
+ enableNativeRedirect: checked
1439
+ }))
1440
+ })))));
1441
+ };
1442
+
1443
+ export {
1444
+ Banner,
1445
+ DeckLayout,
1446
+ DeckSettings
1447
+ };
1448
+ //# sourceMappingURL=chunk-S4A5UO4K.mjs.map