@esportsplus/ui 0.63.0 → 0.64.0

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 (537) hide show
  1. package/.audit/audit.json +2 -2
  2. package/.audit/rules-audit.md +2 -2
  3. package/README.md +15 -18
  4. package/RULES.md +80 -9
  5. package/bin/agent-cli +300 -0
  6. package/build/components/accordion/index.d.ts +4 -0
  7. package/build/components/accordion/index.js +13 -10
  8. package/build/components/breadcrumb/index.d.ts +1 -0
  9. package/build/components/breadcrumb/index.js +43 -37
  10. package/build/components/breadcrumb/scss/index.scss +1 -1
  11. package/build/components/button/kbd.d.ts +1 -1
  12. package/build/components/button/kbd.js +17 -15
  13. package/build/components/button/scss/index.scss +1 -1
  14. package/build/components/button/split.js +14 -16
  15. package/build/components/capslock/scss/index.scss +1 -1
  16. package/build/components/card/scss/index.scss +1 -1
  17. package/build/components/chat/minimap/index.js +4 -5
  18. package/build/components/checkbox/group.d.ts +1 -0
  19. package/build/components/checkbox/group.js +21 -20
  20. package/build/components/checkbox/scss/index.scss +1 -1
  21. package/build/components/color-picker/index.js +6 -6
  22. package/build/components/color-picker/scss/index.scss +1 -1
  23. package/build/components/command/index.d.ts +1 -1
  24. package/build/components/command/palette.d.ts +13 -9
  25. package/build/components/command/palette.js +143 -152
  26. package/build/components/command/scss/index.scss +1 -1
  27. package/build/components/command/search.d.ts +5 -7
  28. package/build/components/command/search.js +6 -26
  29. package/build/components/counter/scss/index.scss +1 -1
  30. package/build/components/editor/code/commands.js +1 -1
  31. package/build/components/editor/code/document.d.ts +1 -3
  32. package/build/components/editor/code/document.js +1 -1
  33. package/build/components/editor/code/editor.d.ts +18 -6
  34. package/build/components/editor/code/editor.js +9 -7
  35. package/build/components/editor/code/features.js +27 -18
  36. package/build/components/editor/code/find.d.ts +1 -1
  37. package/build/components/editor/code/find.js +5 -6
  38. package/build/components/editor/code/folding.d.ts +3 -5
  39. package/build/components/editor/code/folding.js +2 -15
  40. package/build/components/editor/code/gutter.js +2 -2
  41. package/build/components/editor/code/index.d.ts +1 -0
  42. package/build/components/editor/code/index.js +1 -0
  43. package/build/components/editor/code/minimap.d.ts +3 -1
  44. package/build/components/editor/code/minimap.js +31 -5
  45. package/build/components/editor/code/services/model.js +2 -1
  46. package/build/components/editor/code/syntax.js +2 -1
  47. package/build/components/editor/code/view.d.ts +8 -2
  48. package/build/components/editor/code/view.js +37 -56
  49. package/build/components/editor/diffs/index.d.ts +1 -0
  50. package/build/components/editor/diffs/index.js +1 -0
  51. package/build/components/editor/diffs/merge.js +16 -17
  52. package/build/components/editor/diffs/view.js +10 -11
  53. package/build/components/editor/markdown/editing.d.ts +2 -1
  54. package/build/components/editor/markdown/editing.js +14 -5
  55. package/build/components/editor/markdown/format.d.ts +1 -1
  56. package/build/components/editor/markdown/format.js +116 -26
  57. package/build/components/editor/markdown/layout.js +2 -1
  58. package/build/components/editor/markdown/model.d.ts +1 -2
  59. package/build/components/editor/markdown/model.js +1 -29
  60. package/build/components/editor/markdown/render.js +1 -1
  61. package/build/components/editor/markdown/template.d.ts +3 -10
  62. package/build/components/editor/markdown/template.js +2 -29
  63. package/build/components/editor/markdown/toolbar.d.ts +2 -2
  64. package/build/components/editor/markdown/toolbar.js +90 -126
  65. package/build/components/editor/markdown/view.d.ts +1 -1
  66. package/build/components/editor/markdown/view.js +54 -87
  67. package/build/components/editor/tree/drag.js +1 -1
  68. package/build/components/editor/tree/find.js +70 -64
  69. package/build/components/editor/tree/template.js +8 -7
  70. package/build/components/editor/viewer/model.d.ts +1 -1
  71. package/build/components/editor/viewer/template.js +4 -26
  72. package/build/components/editor/workspace/keybindings.d.ts +1 -1
  73. package/build/components/editor/workspace/model.d.ts +12 -2
  74. package/build/components/editor/workspace/model.js +87 -31
  75. package/build/components/editor/workspace/session.d.ts +2 -6
  76. package/build/components/editor/workspace/session.js +99 -16
  77. package/build/components/editor/workspace/status.d.ts +1 -1
  78. package/build/components/editor/workspace/strip.d.ts +10 -9
  79. package/build/components/editor/workspace/strip.js +99 -141
  80. package/build/components/editor/workspace/tabs.d.ts +2 -4
  81. package/build/components/editor/workspace/tabs.js +1 -14
  82. package/build/components/editor/workspace/template.d.ts +1 -1
  83. package/build/components/editor/workspace/template.js +305 -435
  84. package/build/components/error/index.d.ts +4 -13
  85. package/build/components/error/index.js +53 -172
  86. package/build/components/error/scss/index.scss +1 -1
  87. package/build/components/form/action.d.ts +2 -2
  88. package/build/components/form/action.js +2 -2
  89. package/build/components/form/input.d.ts +3 -3
  90. package/build/components/form/input.js +32 -10
  91. package/build/components/frame/scss/index.scss +1 -1
  92. package/build/components/group/index.js +96 -9
  93. package/build/components/group/scss/index.scss +1 -1
  94. package/build/components/heatmap/scss/index.scss +1 -1
  95. package/build/components/highlight/index.js +55 -48
  96. package/build/components/highlight/scss/index.scss +1 -1
  97. package/build/components/icon/scss/index.scss +1 -1
  98. package/build/components/image/scss/index.scss +1 -1
  99. package/build/components/index.d.ts +3 -6
  100. package/build/components/index.js +3 -6
  101. package/build/components/inline-edit/index.d.ts +2 -2
  102. package/build/components/inline-edit/index.js +5 -5
  103. package/build/components/inline-edit/rich.js +4 -4
  104. package/build/components/inline-edit/scss/index.scss +1 -1
  105. package/build/components/inline-edit/status.js +1 -0
  106. package/build/components/input/index.d.ts +4 -0
  107. package/build/components/input/index.js +3 -1
  108. package/build/components/input/otp.d.ts +18 -0
  109. package/build/components/input/otp.js +112 -0
  110. package/build/components/input/password.d.ts +15 -0
  111. package/build/components/input/password.js +163 -0
  112. package/build/components/input/scrub.d.ts +1 -0
  113. package/build/components/input/scrub.js +103 -89
  114. package/build/components/input/scss/index.scss +1 -1
  115. package/build/components/input/tag.d.ts +5 -0
  116. package/build/components/input/tag.js +116 -69
  117. package/build/components/json/download.js +1 -1
  118. package/build/components/link/scss/index.scss +1 -1
  119. package/build/components/marquee/index.js +1 -1
  120. package/build/components/marquee/scss/index.scss +1 -1
  121. package/build/components/nav/scss/index.scss +1 -1
  122. package/build/components/nav/tree.d.ts +2 -1
  123. package/build/components/nav/tree.js +6 -5
  124. package/build/components/notification/index.js +3 -3
  125. package/build/components/notification/scss/index.scss +1 -1
  126. package/build/components/overlay/popup.d.ts +2 -2
  127. package/build/components/overlay/popup.js +1 -1
  128. package/build/components/overlay/scss/index.scss +1 -1
  129. package/build/components/pagination/arrows.js +2 -3
  130. package/build/components/pagination/cards.js +2 -3
  131. package/build/components/pagination/index.d.ts +2 -3
  132. package/build/components/pagination/index.js +18 -13
  133. package/build/components/pagination/scss/index.scss +1 -1
  134. package/build/components/progress/index.js +1 -1
  135. package/build/components/progress/scss/index.scss +1 -1
  136. package/build/components/progress/text.js +3 -3
  137. package/build/components/range/filter.d.ts +7 -1
  138. package/build/components/range/filter.js +188 -171
  139. package/build/components/range/index.d.ts +14 -9
  140. package/build/components/range/index.js +11 -8
  141. package/build/components/range/scss/index.scss +1 -1
  142. package/build/components/range/surface.d.ts +21 -0
  143. package/build/components/range/surface.js +144 -0
  144. package/build/components/relative-time/index.js +2 -2
  145. package/build/components/relative-time/scss/index.scss +1 -1
  146. package/build/components/root/scss/index.scss +1 -1
  147. package/build/components/{preview/header.d.ts → search/button.d.ts} +3 -3
  148. package/build/components/search/button.js +18 -0
  149. package/build/components/search/index.d.ts +8 -0
  150. package/build/components/search/index.js +5 -0
  151. package/build/components/search/input.d.ts +9 -0
  152. package/build/components/search/input.js +23 -0
  153. package/build/components/search/parts.d.ts +5 -0
  154. package/build/components/search/parts.js +17 -0
  155. package/build/components/search/scss/index.scss +2 -0
  156. package/build/components/select/expand.js +4 -5
  157. package/build/components/select/index.d.ts +7 -7
  158. package/build/components/select/index.js +127 -117
  159. package/build/components/select/placement.js +8 -1
  160. package/build/components/select/scss/index.scss +1 -1
  161. package/build/components/{panels → shell}/group.d.ts +21 -5
  162. package/build/components/shell/group.js +336 -0
  163. package/build/components/shell/index.d.ts +15 -17
  164. package/build/components/shell/index.js +583 -238
  165. package/build/components/shell/model.d.ts +94 -0
  166. package/build/components/{panels → shell}/model.js +199 -73
  167. package/build/components/shell/resize.d.ts +5 -0
  168. package/build/components/{panels → shell}/resize.js +54 -30
  169. package/build/components/shell/scss/index.scss +1 -1
  170. package/build/components/shell/sidebar.d.ts +34 -0
  171. package/build/components/shell/sidebar.js +362 -0
  172. package/build/components/{panels → shell}/subtree.js +7 -8
  173. package/build/components/shortcut-recorder/index.d.ts +5 -4
  174. package/build/components/shortcut-recorder/index.js +69 -44
  175. package/build/components/shortcut-recorder/scss/index.scss +1 -1
  176. package/build/components/sortable/index.d.ts +16 -2
  177. package/build/components/sortable/index.js +237 -134
  178. package/build/components/sortable/scss/index.scss +1 -1
  179. package/build/components/story/index.js +46 -34
  180. package/build/components/story/scss/index.scss +1 -1
  181. package/build/components/surface-field/engine.d.ts +2 -0
  182. package/build/components/surface-field/engine.js +86 -33
  183. package/build/components/surface-field/index.d.ts +26 -4
  184. package/build/components/surface-field/index.js +35 -4
  185. package/build/components/surface-field/scss/index.scss +1 -1
  186. package/build/components/surface-field/surface.d.ts +13 -1
  187. package/build/components/surface-field/surface.js +149 -58
  188. package/build/components/tasklist/index.d.ts +1 -4
  189. package/build/components/tasklist/index.js +36 -43
  190. package/build/components/tasklist/scss/index.scss +1 -1
  191. package/build/components/textarea/index.d.ts +1 -1
  192. package/build/components/textarea/index.js +14 -14
  193. package/build/components/theme/scss/index.scss +1 -1
  194. package/build/components/theme/shared.d.ts +1 -2
  195. package/build/components/theme/shared.js +2 -5
  196. package/build/components/toast/index.d.ts +3 -3
  197. package/build/components/toast/index.js +3 -3
  198. package/build/components/toast/scss/index.scss +1 -1
  199. package/build/components/toolbar/index.d.ts +91 -0
  200. package/build/components/toolbar/index.js +1281 -0
  201. package/build/components/toolbar/scss/index.scss +2 -0
  202. package/build/components/tooltip/menu.d.ts +9 -8
  203. package/build/components/tooltip/menu.js +397 -279
  204. package/build/components/tooltip/onclick.d.ts +2 -0
  205. package/build/components/tooltip/onclick.js +13 -4
  206. package/build/components/tooltip/onhover.d.ts +3 -1
  207. package/build/components/tooltip/onhover.js +10 -9
  208. package/build/components/tooltip/scss/index.scss +1 -1
  209. package/build/components/tooltip/shared.d.ts +4 -4
  210. package/build/components/tooltip/shared.js +27 -46
  211. package/build/components/tooltip/utilities.d.ts +5 -2
  212. package/build/components/tooltip/utilities.js +169 -9
  213. package/build/components/typewriter/rotate.js +6 -6
  214. package/build/components/typewriter/scss/index.scss +1 -1
  215. package/build/components/uptime/scss/index.scss +1 -1
  216. package/build/components/usage-meter/index.js +1 -1
  217. package/build/components/usage-meter/scss/index.scss +1 -1
  218. package/build/css-utilities/font/montserrat/OFL.txt +93 -0
  219. package/build/shared/drag.d.ts +15 -9
  220. package/build/shared/drag.js +41 -28
  221. package/build/shared/placement.d.ts +39 -0
  222. package/build/shared/placement.js +55 -0
  223. package/build/shared/transition.js +1 -1
  224. package/build/shared/viewport.d.ts +1 -2
  225. package/build/shared/viewport.js +1 -4
  226. package/package.json +2 -5
  227. package/src/components/accordion/index.ts +12 -5
  228. package/src/components/announcement/index.ts +1 -1
  229. package/src/components/breadcrumb/index.ts +13 -3
  230. package/src/components/breadcrumb/scss/index.scss +6 -6
  231. package/src/components/breadcrumb/scss/variables.scss +7 -0
  232. package/src/components/button/kbd.ts +22 -17
  233. package/src/components/button/scss/index.scss +69 -76
  234. package/src/components/button/scss/variables.scss +51 -18
  235. package/src/components/button/split.ts +12 -8
  236. package/src/components/capslock/index.ts +2 -0
  237. package/src/components/capslock/scss/index.scss +21 -21
  238. package/src/components/card/scss/index.scss +16 -0
  239. package/src/components/card/scss/variables.scss +25 -2
  240. package/src/components/chat/minimap/index.ts +5 -6
  241. package/src/components/chat/minimap/scss/index.scss +12 -11
  242. package/src/components/chat/minimap/scss/variables.scss +23 -17
  243. package/src/components/checkbox/group.ts +8 -7
  244. package/src/components/checkbox/scss/index.scss +59 -35
  245. package/src/components/checkbox/scss/variables.scss +24 -17
  246. package/src/components/color-picker/index.ts +6 -6
  247. package/src/components/color-picker/scss/index.scss +35 -22
  248. package/src/components/color-picker/scss/variables.scss +11 -3
  249. package/src/components/command/index.ts +1 -1
  250. package/src/components/command/palette.ts +174 -166
  251. package/src/components/command/scss/index.scss +18 -51
  252. package/src/components/command/scss/variables.scss +37 -71
  253. package/src/components/command/search.ts +9 -31
  254. package/src/components/counter/index.ts +22 -22
  255. package/src/components/counter/scss/variables.scss +10 -7
  256. package/src/components/editor/code/commands.ts +1 -1
  257. package/src/components/editor/code/document.ts +0 -2
  258. package/src/components/editor/code/editor.ts +31 -13
  259. package/src/components/editor/code/features.ts +39 -24
  260. package/src/components/editor/code/find.ts +5 -6
  261. package/src/components/editor/code/folding.ts +3 -21
  262. package/src/components/editor/code/gutter.ts +2 -2
  263. package/src/components/editor/code/index.ts +1 -0
  264. package/src/components/editor/code/minimap.ts +39 -5
  265. package/src/components/editor/code/scss/_editor.scss +28 -21
  266. package/src/components/editor/code/scss/_features.scss +19 -21
  267. package/src/components/editor/code/scss/_services.scss +14 -11
  268. package/src/components/editor/code/scss/variables.scss +31 -12
  269. package/src/components/editor/code/services/model.ts +2 -1
  270. package/src/components/editor/code/syntax.ts +2 -1
  271. package/src/components/editor/code/view.ts +22 -45
  272. package/src/components/editor/diffs/index.ts +1 -0
  273. package/src/components/editor/diffs/merge.ts +9 -10
  274. package/src/components/editor/diffs/scss/_diffs.scss +39 -63
  275. package/src/components/editor/diffs/scss/_merge.scss +10 -2
  276. package/src/components/editor/diffs/scss/index.scss +0 -1
  277. package/src/components/editor/diffs/scss/variables.scss +36 -17
  278. package/src/components/editor/diffs/view.ts +8 -9
  279. package/src/components/editor/markdown/editing.ts +18 -6
  280. package/src/components/editor/markdown/format.ts +180 -32
  281. package/src/components/editor/markdown/layout.ts +2 -1
  282. package/src/components/editor/markdown/model.ts +0 -38
  283. package/src/components/editor/markdown/render.ts +1 -1
  284. package/src/components/editor/markdown/scss/index.scss +38 -52
  285. package/src/components/editor/markdown/scss/variables.scss +24 -50
  286. package/src/components/editor/markdown/template.ts +3 -63
  287. package/src/components/editor/markdown/toolbar.ts +76 -127
  288. package/src/components/editor/markdown/view.ts +9 -32
  289. package/src/components/editor/tree/drag.ts +1 -1
  290. package/src/components/editor/tree/find.ts +61 -64
  291. package/src/components/editor/tree/scss/index.scss +29 -30
  292. package/src/components/editor/tree/scss/variables.scss +34 -15
  293. package/src/components/editor/tree/template.ts +9 -9
  294. package/src/components/editor/viewer/model.ts +1 -1
  295. package/src/components/editor/viewer/scss/_viewer.scss +4 -5
  296. package/src/components/editor/viewer/scss/variables.scss +3 -3
  297. package/src/components/editor/viewer/template.ts +4 -31
  298. package/src/components/editor/workspace/keybindings.ts +1 -1
  299. package/src/components/editor/workspace/model.ts +136 -37
  300. package/src/components/editor/workspace/scss/_keybindings.scss +3 -20
  301. package/src/components/editor/workspace/scss/_status.scss +0 -1
  302. package/src/components/editor/workspace/scss/_tabs.scss +2 -41
  303. package/src/components/editor/workspace/scss/index.scss +49 -71
  304. package/src/components/editor/workspace/scss/variables.scss +1 -135
  305. package/src/components/editor/workspace/session.ts +138 -18
  306. package/src/components/editor/workspace/status.ts +1 -1
  307. package/src/components/editor/workspace/strip.ts +96 -115
  308. package/src/components/editor/workspace/tabs.ts +2 -23
  309. package/src/components/editor/workspace/template.ts +323 -458
  310. package/src/components/error/index.ts +47 -183
  311. package/src/components/error/scss/index.scss +34 -35
  312. package/src/components/error/scss/variables.scss +14 -26
  313. package/src/components/filter/scss/index.scss +6 -5
  314. package/src/components/form/action.ts +7 -7
  315. package/src/components/form/input.ts +25 -12
  316. package/src/components/frame/scss/index.scss +5 -5
  317. package/src/components/group/index.ts +77 -2
  318. package/src/components/group/scss/index.scss +164 -0
  319. package/src/components/group/scss/variables.scss +110 -2
  320. package/src/components/heatmap/scss/variables.scss +13 -10
  321. package/src/components/highlight/index.ts +87 -79
  322. package/src/components/highlight/scss/index.scss +6 -16
  323. package/src/components/highlight/scss/variables.scss +33 -5
  324. package/src/components/icon/scss/index.scss +2 -2
  325. package/src/components/icon/scss/variables.scss +14 -1
  326. package/src/components/image/scss/index.scss +9 -9
  327. package/src/components/image/scss/variables.scss +1 -1
  328. package/src/components/index.ts +3 -6
  329. package/src/components/inline-edit/index.ts +8 -6
  330. package/src/components/inline-edit/rich.ts +8 -8
  331. package/src/components/inline-edit/scss/index.scss +50 -36
  332. package/src/components/inline-edit/scss/variables.scss +28 -18
  333. package/src/components/inline-edit/status.ts +2 -0
  334. package/src/components/input/index.ts +3 -1
  335. package/src/components/input/otp.ts +175 -0
  336. package/src/components/input/password.ts +178 -0
  337. package/src/components/input/scrub.ts +197 -178
  338. package/src/components/input/scss/index.scss +344 -4
  339. package/src/components/input/scss/variables.scss +234 -65
  340. package/src/components/input/tag.ts +98 -53
  341. package/src/components/json/download.ts +2 -5
  342. package/src/components/link/scss/index.scss +3 -5
  343. package/src/components/loading/scss/index.scss +1 -0
  344. package/src/components/loading/scss/variables.scss +1 -0
  345. package/src/components/marquee/index.ts +1 -1
  346. package/src/components/marquee/scss/index.scss +11 -4
  347. package/src/components/nav/scss/index.scss +10 -26
  348. package/src/components/nav/scss/variables.scss +13 -23
  349. package/src/components/nav/tree.ts +10 -8
  350. package/src/components/notification/index.ts +3 -3
  351. package/src/components/notification/scss/index.scss +7 -14
  352. package/src/components/notification/scss/variables.scss +10 -2
  353. package/src/components/number/index.ts +1 -1
  354. package/src/components/overlay/popup.ts +2 -2
  355. package/src/components/overlay/scss/index.scss +60 -51
  356. package/src/components/page/scss/variables.scss +1 -0
  357. package/src/components/pagination/arrows.ts +2 -3
  358. package/src/components/pagination/cards.ts +2 -3
  359. package/src/components/pagination/index.ts +11 -9
  360. package/src/components/pagination/scss/index.scss +38 -101
  361. package/src/components/pagination/scss/variables.scss +24 -75
  362. package/src/components/progress/index.ts +1 -1
  363. package/src/components/progress/scss/index.scss +22 -11
  364. package/src/components/progress/scss/variables.scss +13 -5
  365. package/src/components/progress/text.ts +3 -3
  366. package/src/components/range/filter.ts +249 -246
  367. package/src/components/range/index.ts +22 -7
  368. package/src/components/range/scss/index.scss +470 -15
  369. package/src/components/range/scss/variables.scss +402 -198
  370. package/src/components/range/surface.ts +135 -0
  371. package/src/components/relative-time/index.ts +2 -2
  372. package/src/components/relative-time/scss/index.scss +4 -2
  373. package/src/components/relative-time/scss/variables.scss +4 -5
  374. package/src/components/root/scss/index.scss +11 -11
  375. package/src/components/root/scss/variables.scss +4 -4
  376. package/src/components/search/button.ts +24 -0
  377. package/src/components/search/index.ts +12 -0
  378. package/src/components/search/input.ts +35 -0
  379. package/src/components/search/parts.ts +24 -0
  380. package/src/components/search/scss/index.scss +36 -0
  381. package/src/components/search/scss/variables.scss +67 -0
  382. package/src/components/section/scss/variables.scss +1 -0
  383. package/src/components/select/expand.ts +3 -4
  384. package/src/components/select/index.ts +55 -41
  385. package/src/components/select/placement.ts +17 -1
  386. package/src/components/select/scss/index.scss +57 -29
  387. package/src/components/select/scss/variables.scss +91 -53
  388. package/src/components/{panels → shell}/group.ts +151 -98
  389. package/src/components/shell/index.ts +805 -284
  390. package/src/components/{panels → shell}/model.ts +329 -102
  391. package/src/components/shell/resize.ts +176 -0
  392. package/src/components/shell/scss/index.scss +502 -89
  393. package/src/components/shell/scss/variables.scss +264 -39
  394. package/src/components/shell/sidebar.ts +325 -0
  395. package/src/components/{panels → shell}/subtree.ts +1 -2
  396. package/src/components/shortcut-recorder/index.ts +99 -61
  397. package/src/components/shortcut-recorder/scss/index.scss +76 -52
  398. package/src/components/shortcut-recorder/scss/variables.scss +25 -30
  399. package/src/components/sortable/index.ts +364 -63
  400. package/src/components/sortable/scss/index.scss +22 -2
  401. package/src/components/sortable/scss/variables.scss +16 -4
  402. package/src/components/story/index.ts +56 -33
  403. package/src/components/story/scss/index.scss +67 -16
  404. package/src/components/story/scss/variables.scss +59 -18
  405. package/src/components/surface-field/engine.ts +157 -61
  406. package/src/components/surface-field/index.ts +64 -9
  407. package/src/components/surface-field/scss/index.scss +88 -77
  408. package/src/components/surface-field/scss/variables.scss +84 -36
  409. package/src/components/surface-field/surface.ts +225 -76
  410. package/src/components/tasklist/index.ts +10 -14
  411. package/src/components/tasklist/scss/index.scss +25 -45
  412. package/src/components/tasklist/scss/variables.scss +12 -29
  413. package/src/components/textarea/index.ts +39 -42
  414. package/src/components/theme/reveal.ts +1 -0
  415. package/src/components/theme/scss/index.scss +20 -16
  416. package/src/components/theme/scss/variables.scss +11 -5
  417. package/src/components/theme/shared.ts +3 -7
  418. package/src/components/toast/index.ts +7 -8
  419. package/src/components/toast/scss/index.scss +44 -36
  420. package/src/components/toast/scss/variables.scss +36 -33
  421. package/src/components/toolbar/index.ts +1675 -0
  422. package/src/components/toolbar/scss/index.scss +759 -0
  423. package/src/components/toolbar/scss/variables.scss +555 -0
  424. package/src/components/tooltip/menu.ts +301 -220
  425. package/src/components/tooltip/onclick.ts +18 -3
  426. package/src/components/tooltip/onhover.ts +13 -9
  427. package/src/components/tooltip/scss/index.scss +155 -188
  428. package/src/components/tooltip/scss/variables.scss +151 -135
  429. package/src/components/tooltip/shared.ts +47 -74
  430. package/src/components/tooltip/utilities.ts +151 -10
  431. package/src/components/truncate/index.ts +1 -1
  432. package/src/components/typewriter/rotate.ts +6 -6
  433. package/src/components/typewriter/scss/index.scss +14 -5
  434. package/src/components/uptime/scss/index.scss +8 -15
  435. package/src/components/uptime/scss/variables.scss +12 -1
  436. package/src/components/usage-meter/index.ts +1 -1
  437. package/src/components/usage-meter/scss/index.scss +6 -4
  438. package/src/components/usage-meter/scss/variables.scss +11 -11
  439. package/src/css-utilities/box-shadow.scss +0 -1
  440. package/src/css-utilities/icon.scss +9 -9
  441. package/src/css-utilities/surface.scss +27 -17
  442. package/src/modifiers/glass/index.ts +2 -2
  443. package/src/modifiers/glass/scss/index.scss +2 -2
  444. package/src/normalize/scss/index.scss +1 -1
  445. package/src/shared/drag.ts +92 -53
  446. package/src/shared/placement.ts +145 -0
  447. package/src/shared/transition.ts +1 -1
  448. package/src/shared/viewport.ts +1 -7
  449. package/src/tokens/scss/color.scss +2 -2
  450. package/src/tokens/scss/scale.scss +5 -1
  451. package/src/tokens/scss/size.scss +0 -7
  452. package/storage/svg/angle.svg +1 -0
  453. package/storage/svg/{chevron-left.svg → arrow.svg} +1 -1
  454. package/storage/svg/calendar.svg +1 -0
  455. package/storage/svg/circle-filled.svg +1 -0
  456. package/storage/svg/cursor-arrow-left.svg +1 -0
  457. package/storage/svg/cursor-arrow-right.svg +1 -0
  458. package/storage/svg/fit.svg +1 -0
  459. package/storage/svg/grip.svg +1 -0
  460. package/storage/svg/mail.svg +1 -0
  461. package/storage/svg/{chevron-down.svg → minus.svg} +1 -1
  462. package/storage/svg/music.svg +1 -0
  463. package/storage/svg/{chevron-up.svg → rotate-ccw.svg} +1 -1
  464. package/vite.config.ts +9 -13
  465. package/build/components/dock/index.d.ts +0 -47
  466. package/build/components/dock/index.js +0 -469
  467. package/build/components/dock/scss/index.scss +0 -2
  468. package/build/components/metric/flash.d.ts +0 -12
  469. package/build/components/metric/flash.js +0 -117
  470. package/build/components/metric/index.d.ts +0 -44
  471. package/build/components/metric/index.js +0 -275
  472. package/build/components/metric/scss/index.scss +0 -2
  473. package/build/components/pagination/dots.d.ts +0 -23
  474. package/build/components/pagination/dots.js +0 -115
  475. package/build/components/panels/dnd.d.ts +0 -47
  476. package/build/components/panels/dnd.js +0 -114
  477. package/build/components/panels/group.js +0 -322
  478. package/build/components/panels/index.d.ts +0 -17
  479. package/build/components/panels/index.js +0 -524
  480. package/build/components/panels/model.d.ts +0 -64
  481. package/build/components/panels/resize.d.ts +0 -9
  482. package/build/components/panels/scss/index.scss +0 -2
  483. package/build/components/preview/buttons.d.ts +0 -12
  484. package/build/components/preview/buttons.js +0 -26
  485. package/build/components/preview/code.d.ts +0 -8
  486. package/build/components/preview/code.js +0 -18
  487. package/build/components/preview/header.js +0 -21
  488. package/build/components/preview/index.d.ts +0 -37
  489. package/build/components/preview/index.js +0 -123
  490. package/build/components/preview/scss/index.scss +0 -2
  491. package/build/components/preview/source.d.ts +0 -12
  492. package/build/components/preview/source.js +0 -79
  493. package/build/components/preview/stage.d.ts +0 -8
  494. package/build/components/preview/stage.js +0 -28
  495. package/build/components/textarea/scss/index.scss +0 -2
  496. package/src/components/dock/index.ts +0 -567
  497. package/src/components/dock/scss/index.scss +0 -346
  498. package/src/components/dock/scss/variables.scss +0 -357
  499. package/src/components/input/scss/_field.scss +0 -39
  500. package/src/components/input/scss/_scrub.scss +0 -89
  501. package/src/components/input/scss/_tag.scss +0 -142
  502. package/src/components/metric/flash.ts +0 -129
  503. package/src/components/metric/index.ts +0 -307
  504. package/src/components/metric/scss/_flash.scss +0 -150
  505. package/src/components/metric/scss/index.scss +0 -155
  506. package/src/components/metric/scss/variables.scss +0 -233
  507. package/src/components/pagination/dots.ts +0 -132
  508. package/src/components/panels/dnd.ts +0 -190
  509. package/src/components/panels/index.ts +0 -676
  510. package/src/components/panels/resize.ts +0 -157
  511. package/src/components/panels/scss/index.scss +0 -379
  512. package/src/components/panels/scss/variables.scss +0 -197
  513. package/src/components/preview/buttons.ts +0 -48
  514. package/src/components/preview/code.ts +0 -28
  515. package/src/components/preview/header.ts +0 -23
  516. package/src/components/preview/index.ts +0 -149
  517. package/src/components/preview/scss/index.scss +0 -158
  518. package/src/components/preview/scss/variables.scss +0 -149
  519. package/src/components/preview/source.ts +0 -73
  520. package/src/components/preview/stage.ts +0 -33
  521. package/src/components/range/scss/_filter.scss +0 -360
  522. package/src/components/range/scss/_slider.scss +0 -65
  523. package/src/components/range/scss/_vertical.scss +0 -10
  524. package/src/components/textarea/scss/index.scss +0 -72
  525. package/src/components/textarea/scss/variables.scss +0 -22
  526. package/storage/svg/amex.svg +0 -1
  527. package/storage/svg/arrow-down.svg +0 -1
  528. package/storage/svg/arrow-left.svg +0 -1
  529. package/storage/svg/arrow-right.svg +0 -1
  530. package/storage/svg/arrow-up.svg +0 -1
  531. package/storage/svg/card.svg +0 -1
  532. package/storage/svg/chip.svg +0 -1
  533. package/storage/svg/discover.svg +0 -1
  534. package/storage/svg/mastercard.svg +0 -1
  535. package/storage/svg/visa.svg +0 -1
  536. /package/build/components/{panels → shell}/subtree.d.ts +0 -0
  537. /package/storage/svg/{chevron-right.svg → chevron.svg} +0 -0
@@ -1,344 +1,865 @@
1
- import { flush, reactive } from '@esportsplus/reactivity';
2
- import { html, type Renderable } from '@esportsplus/template';
3
- import { drag } from '~/shared/drag';
4
- import button from '~/components/button';
5
- import scrollbar from '~/modifiers/scrollbar';
6
- import '~/components/card/scss/index.scss';
1
+ import { effect, flush, onCleanup, reactive, read, root, signal, untrack, write, type ReactiveArray } from '@esportsplus/reactivity';
2
+ import { component, html, render, type Attributes, type Renderable } from '@esportsplus/template';
3
+ import icon from '~/components/icon';
4
+ import tooltip from '~/components/tooltip';
5
+ import type { Controller, Item } from '~/components/tooltip/menu';
6
+ import { mac } from '~/shared/platform';
7
+ import { observe } from '~/shared/resize';
8
+ import { group, launcher, title, type Catalog, type Context, type Kind } from './group';
9
+ import state, { allGroups, bounded, contains, docked, findGroup, findSplit, findSurfaceGroup, MIN_FRACTION, stationary, type Group, type Layout, type Node, type Placement, type Saved, type Split, type Store, type Surface } from './model';
10
+ import { resized, separator } from './resize';
11
+ import { frame, grip, resizer, sidebar, toggle, type Edge, type Options, type Sidebars } from './sidebar';
12
+ import subtree from './subtree';
7
13
  import './scss/index.scss';
8
14
 
9
15
 
10
- type Edge = 'left' | 'right';
11
-
12
- // Each edge's sidebar and strip as they connect, whether its sidebar is being dragged, and where the drag holds the
13
- // sidebar and the card's edge; undefined leaves each to the stylesheet.
14
- type Frame = Record<Edge, {
15
- dragging: boolean,
16
- edge?: HTMLElement,
17
- gap: string | undefined,
18
- offset: number,
19
- reach: string | undefined,
20
- sidebar?: HTMLElement,
21
- space: string | undefined,
22
- translate: string | undefined
23
- }>;
24
-
25
- // Which closed sidebars are showing for as long as the pointer stays over them.
26
- type Peeking = Record<Edge, boolean>;
27
-
28
- type Side = {
29
- class?: string;
30
- content?: Renderable<unknown>;
31
- // A closed sidebar opens while the pointer rests on its edge and closes the moment the pointer leaves it; its toggle
32
- // keeps it open.
33
- hover?: boolean;
34
- id: string;
35
- label: string;
36
- state: { active: boolean };
16
+ type A = Attributes & {
17
+ catalog: Catalog;
18
+ // What an empty group or main area shows in place of the launcher.
19
+ empty?: (group?: string) => Renderable<unknown>;
20
+ // Tabs show their kind's icon alone, closing from their menu.
21
+ icons?: boolean;
22
+ // At or below this width (px) of the layout, an open sidebar pushes the main area aside, one at a time, and the
23
+ // main area shows one group.
24
+ narrow?: number;
25
+ onconnect?: never;
26
+ // Each sidebar's label, whether it peeks while the pointer rests on its edge, and whether it resizes.
27
+ sidebars?: Partial<Record<Edge, Options>>;
28
+ state: ReturnType<typeof state>;
37
29
  };
38
30
 
39
- type Sides = Record<Edge, Side>;
31
+ type Host = { dispose: VoidFunction; element: HTMLElement };
40
32
 
33
+ type Region = Placement | 'main';
41
34
 
42
- // Presses in these keep their own text editing rather than dragging the sidebar.
43
- const FIELDS = 'input, select, textarea, [contenteditable]';
35
+ type Shown = Record<Region, Node | null>;
44
36
 
45
- // Below this width an open sidebar pushes the card aside rather than narrowing it, so only one opens at a time.
46
- const NARROW = '(max-width: 1024px)';
37
+ type Side = 'bottom' | 'left' | 'right' | 'top';
47
38
 
48
39
 
49
- // Found by id, since a page closes a side it only holds the config of.
50
- function close(side: Pick<Side, 'id' | 'state'>) {
51
- if (document.getElementById(side.id)?.contains(document.activeElement)) {
52
- document.getElementById(`${side.id}-toggle`)?.focus({ preventScroll: true });
40
+ // A collapsed sibling of a maximized group keeps this much (px) to click back into.
41
+ const COLLAPSED = 80;
42
+
43
+ const NARROW = 1024;
44
+
45
+ // Where a tab dropped on a group's edge goes: beside it along the axis, before or after it.
46
+ const EDGES = {
47
+ bottom: ['column', 'after'],
48
+ left: ['row', 'before'],
49
+ right: ['row', 'after'],
50
+ top: ['column', 'before']
51
+ } as const;
52
+
53
+
54
+ // The group at a tree's top corner on 'edge': the first child down each split, but a row's last toward the right.
55
+ function corner(node: Node | null, edge: Edge): Group | null {
56
+ if (node === null || node.kind === 'group') {
57
+ return node;
53
58
  }
54
59
 
55
- side.state.active = false;
60
+ return corner((edge === 'right' && node.direction === 'row' ? node.children.at(-1) : node.children[0]) ?? null, edge);
56
61
  }
57
62
 
58
- // The direction a drag toward the center takes from this edge.
59
- function direction(edge: Edge): -1 | 1 {
60
- return edge === 'left' ? 1 : -1;
61
- }
63
+ // The groups of one dock or the main area, as their own tree: every split keeps its children there, resized to share what
64
+ // the dropped ones leave.
65
+ function filter(node: Node | null, keep: (group: Group) => boolean): Node | null {
66
+ if (node === null) {
67
+ return null;
68
+ }
62
69
 
63
- // A strip along the window edge while the sidebar is closed: its handle follows the pointer up and down and stays where
64
- // the pointer left it. Clicking it opens the sidebar, and dragging from it pulls the sidebar out, with the overlay's drag:
65
- // past a quarter of the sidebar or flicked it opens, otherwise it slides back. Resting on it peeks a sidebar that opens
66
- // on hover.
67
- function grip(sides: Sides, peeking: Peeking, frame: Frame, edge: Edge) {
68
- let side = sides[edge],
69
- sign = direction(edge),
70
- gesture = drag({
71
- begin: (e) => e.button === 0 && !side.state.active ? [{ axis: 'x', sign }] : null,
72
- capture: () => hold(frame, edge),
73
- measure: (element) => frame[edge].sidebar ?? element,
74
- move: (_, { x }) => {
75
- let element = frame[edge].sidebar;
76
-
77
- if (element) {
78
- reveal(frame, edge, element.offsetWidth, x * sign);
79
- }
80
- },
81
- release: (_, __, dismiss) => {
82
- settle(frame, edge);
70
+ if (node.kind === 'group') {
71
+ return keep(node) ? node : null;
72
+ }
83
73
 
84
- if (dismiss) {
85
- open(sides, peeking, edge);
86
- }
87
- }
88
- });
74
+ let entries = node.children.flatMap((child, i) => {
75
+ let kept = filter(child, keep);
89
76
 
90
- return html`
91
- <div
92
- aria-hidden='true'
93
- class='shell-edge shell-edge--${edge}'
94
- id='${side.id}-edge'
95
- ${gesture}
96
- ${{
97
- // A drag swallows the click it ends with, so this is a tap or a click: either opens the sidebar.
98
- onclick: () => {
99
- if (!side.state.active) {
100
- open(sides, peeking, edge);
101
- }
102
- },
103
- onconnect: (element: HTMLElement) => {
104
- frame[edge].edge = element;
105
- },
106
- onpointerenter: () => {
107
- if (side.hover && !side.state.active) {
108
- peeking[edge] = true;
109
- }
110
- },
111
- onpointerleave: (e: PointerEvent) => leave(side, peeking, frame, edge, e),
112
- onpointermove: function(this: HTMLElement, e: PointerEvent) {
113
- let bounds = this.getBoundingClientRect();
77
+ return kept === null ? [] : [{ node: kept, size: node.sizes[i] ?? 0 }];
78
+ });
114
79
 
115
- frame[edge].offset = e.clientY - bounds.top - bounds.height / 2;
116
- gesture.onpointermove(e);
117
- },
118
- style: () => `--offset: ${frame[edge].offset}px;`
119
- }}
120
- >
121
- <span class='shell-handle'></span>
122
- </div>
123
- `;
80
+ if (entries.length === 0) {
81
+ return null;
82
+ }
83
+
84
+ if (entries.length === 1) {
85
+ return entries[0].node;
86
+ }
87
+
88
+ let total = entries.reduce((sum, entry) => sum + entry.size, 0);
89
+
90
+ return {
91
+ ...node,
92
+ children: entries.map((entry) => entry.node),
93
+ sizes: entries.map((entry) => total > 0 ? entry.size / total : 1 / entries.length)
94
+ };
124
95
  }
125
96
 
126
- // Marks the sidebar as following the pointer, flushed so its transitions stand down before the first move lands.
127
- function hold(frame: Frame, edge: Edge) {
128
- frame[edge].dragging = true;
129
- flush();
97
+ function findSurface(node: Node | null, id: string) {
98
+ return findSurfaceGroup(node, id)?.surfaces.find((surface) => surface.id === id) ?? null;
130
99
  }
131
100
 
132
- // A peeking sidebar closes once the pointer leaves it, unless it went on to the sidebar's own toggle or edge. The
133
- // toggle is found by id: it is the sidebar button's own, which keeps its connect to itself.
134
- function leave(side: Side, peeking: Peeking, frame: Frame, edge: Edge, e: PointerEvent) {
135
- let to = e.relatedTarget as Node | null;
101
+ // Every surface that should own a place on screen: the active surface of each group showing. A closed sidebar's
102
+ // groups stay mounted, so it slides out with its content in place.
103
+ function mounted(layout: Layout) {
104
+ let ids = new Set<string>();
136
105
 
137
- if (!peeking[edge] || (to && [frame[edge].sidebar, frame[edge].edge, document.getElementById(`${side.id}-toggle`)].some((element) => element?.contains(to)))) {
138
- return;
106
+ for (let group of Object.values(shown(layout)).flatMap(allGroups)) {
107
+ if (group.active !== null) {
108
+ ids.add(group.active);
109
+ }
139
110
  }
140
111
 
141
- peeking[edge] = false;
112
+ return ids;
142
113
  }
143
114
 
144
- function motion(): Frame[Edge] {
145
- return reactive({
146
- dragging: false,
147
- gap: undefined as string | undefined,
148
- offset: 0,
149
- reach: undefined as string | undefined,
150
- space: undefined as string | undefined,
151
- translate: undefined as string | undefined
152
- });
115
+ // What the layout shows: under a zoom, its groups fill the main area together, docked or not; otherwise the main
116
+ // groups, the bottom dock's below them while it is open, and each sidebar's on its edge, open or not.
117
+ function shown(layout: Layout): Shown {
118
+ let zoom = layout.zoom.at(-1);
119
+
120
+ if (zoom) {
121
+ let ids = new Set(zoom.groups);
122
+
123
+ return { bottom: null, left: null, main: filter(layout.root, (group) => ids.has(group.id)), right: null };
124
+ }
125
+
126
+ return {
127
+ bottom: layout.bottom.open ? filter(layout.root, (group) => docked(group, 'bottom')) : null,
128
+ left: filter(layout.root, (group) => docked(group, 'left')),
129
+ main: filter(layout.root, (group) => group.placement === undefined),
130
+ right: filter(layout.root, (group) => docked(group, 'right'))
131
+ };
132
+ }
133
+
134
+ // The parts of the tree a layout change rebuilds: kinds, ids and order, group membership and placement.
135
+ // Sizes, the active tab and group, maximizing and the dock's size bind in place instead.
136
+ function structure(node: Node | null): unknown {
137
+ if (node === null) {
138
+ return null;
139
+ }
140
+
141
+ if (node.kind === 'group') {
142
+ return [node.id, node.placement ?? '', node.surfaces.map((surface) => surface.id)];
143
+ }
144
+
145
+ return [node.id, node.direction, node.children.map(structure)];
153
146
  }
154
147
 
155
- function open(sides: Sides, peeking: Peeking, edge: Edge) {
156
- if (matchMedia(NARROW).matches) {
157
- close(sides[edge === 'left' ? 'right' : 'left']);
148
+ // Outside every tab strip, what a dragged tab drops onto: a dock's strip along the layout's edge, or the half of a
149
+ // group toward its nearest edge, which splits the group there. A group's header outside its strip takes nothing.
150
+ function target(workspace: HTMLElement, x: number, y: number) {
151
+ let elements = document.elementsFromPoint(x, y).filter((element) => element.closest('.shell') === workspace),
152
+ dock = elements.find((element) => element.matches('.shell-dock-target')) as HTMLElement | undefined,
153
+ section = elements.find((element) => element.matches('.shell-group')) as HTMLElement | undefined;
154
+
155
+ if (dock) {
156
+ return dock;
157
+ }
158
+
159
+ if (!section || y <= (section.querySelector(':scope > .shell-header')?.getBoundingClientRect().bottom ?? -Infinity)) {
160
+ return null;
158
161
  }
159
162
 
160
- peeking[edge] = false;
161
- sides[edge].state.active = true;
163
+ let { height, left, top, width } = section.getBoundingClientRect(),
164
+ across = width <= 0 ? 0.5 : (x - left) / width,
165
+ down = height <= 0 ? 0.5 : (y - top) / height,
166
+ side = ([['left', across], ['right', 1 - across], ['top', down], ['bottom', 1 - down]] as [Side, number][])
167
+ .reduce((nearest, candidate) => candidate[1] < nearest[1] ? candidate : nearest)[0];
168
+
169
+ return section.querySelector<HTMLElement>(`:scope > .shell-edge--${side}`);
162
170
  }
163
171
 
164
- // Dragged toward its edge with the overlay's drag, the sidebar follows the pointer; past a quarter of its width or
165
- // flicked it closes, otherwise it slides back.
166
- function panel(side: Side, peeking: Peeking, frame: Frame, edge: Edge) {
167
- let gesture = drag({
168
- begin: (e) => {
169
- let target = e.target as HTMLElement;
170
-
171
- // A press past the target's client box is on its scrollbar.
172
- if (
173
- e.button !== 0 ||
174
- !(side.state.active || peeking[edge]) ||
175
- target.closest(FIELDS) ||
176
- (target.clientWidth > 0 && (e.offsetX > target.clientWidth || e.offsetY > target.clientHeight))
177
- ) {
178
- return null;
172
+ // The id of this layout's innermost group under the point, skipping groups of layouts nested inside it.
173
+ function under(workspace: HTMLElement, x: number, y: number) {
174
+ let found = document.elementsFromPoint(x, y).find((element) => element.matches('.shell-group') && element.closest('.shell') === workspace);
175
+
176
+ return (found as HTMLElement | undefined)?.dataset.group;
177
+ }
178
+
179
+
180
+ // The app frame: tabbed groups of surfaces in resizable splits, in a main area between a sidebar on either edge, above
181
+ // a bottom dock. Tabs drag to reorder, into another group, onto a group's edge to split beside it, or onto a strip
182
+ // along the layout's left, right or bottom edge to dock there; groups clicked or swept across with ⌘ (Ctrl elsewhere)
183
+ // held fill the main area together once it, or the sweep, is let go. A double click on a header steps back a view at
184
+ // a time, out of a maximized group and then each zoom, and maximizes its group once there is nothing left to step out
185
+ // of. An empty group offers the catalog. A surface's content is rendered once and moved, never rebuilt, so it keeps
186
+ // its state across every layout change until its tab closes.
187
+ //
188
+ // A sidebar slides over the main area's edge and makes room as it opens; in a narrow layout it pushes the main area
189
+ // aside, one at a time, and the main area shows one group, switched from its header. Its toggle sits in its top
190
+ // corner, and a closed sidebar's edge holds a handle to drag it out by. A sidebar holding a single unsortable surface
191
+ // is static: it shows the surface without tabs, takes no drops, and swipes closed toward its edge.
192
+ const shell = component(
193
+ function({ catalog, empty, icons = false, narrow: breakpoint = NARROW, sidebars: options = {}, state, ...attributes }: A) {
194
+ let adding: Controller | undefined,
195
+ apple = mac(),
196
+ // A tab is being dragged, which lights the docks and group halves it can drop onto.
197
+ carrying = signal(false),
198
+ controller: Controller | undefined,
199
+ frames = { left: frame(), right: frame() },
200
+ hosts = new Map<string, Host>(),
201
+ // What a dragged tab does to the layout once its copy lands.
202
+ landing: VoidFunction | null = null,
203
+ // Where hosts wait while their surface isn't showing, inside the layout so they stay connected.
204
+ parking: HTMLElement | undefined,
205
+ picks = signal<string[]>([]),
206
+ // Each region's element, so rebuilding one parks only the hosts inside it.
207
+ regions: Partial<Record<Region, HTMLElement>> = {},
208
+ size = reactive({ height: 0, width: 0 }),
209
+ slots = new Map<string, HTMLElement>(),
210
+ // Each tab strip's group, so a tab sorted into a strip moves into its group.
211
+ strips = new WeakMap<ReactiveArray<Surface>, string>(),
212
+ subject = reactive({ group: '', surface: '' }),
213
+ switching: Controller | undefined,
214
+ unobserve: VoidFunction | undefined,
215
+ workspace: HTMLElement | undefined;
216
+
217
+ let narrow = () => size.width > 0 && size.width <= breakpoint;
218
+
219
+ let edges: Sidebars = {
220
+ frames,
221
+ id: `shell-${crypto.randomUUID().slice(0, 8)}`,
222
+ narrow,
223
+ options,
224
+ stationary: (edge) => stationary(state.layout.root, edge),
225
+ state
226
+ };
227
+
228
+ // A dragged tab changes the layout once its copy has landed, so the strips it moved through stay until then.
229
+ function drop(surface: Surface, element: HTMLElement) {
230
+ let placement = element.dataset.placement as Placement | undefined;
231
+
232
+ if (placement) {
233
+ state.dock(surface.id, placement);
234
+ return;
235
+ }
236
+
237
+ let group = element.closest<HTMLElement>('.shell-group')?.dataset.group,
238
+ [direction, side] = EDGES[element.dataset.side as Side];
239
+
240
+ if (group) {
241
+ state.split(surface.id, group, direction, side);
242
+ }
243
+ }
244
+
245
+ let context: Context = {
246
+ add(kind: string, group?: string) {
247
+ let entry = catalog[kind];
248
+
249
+ if (!entry) {
250
+ return;
251
+ }
252
+
253
+ let id = kind;
254
+
255
+ if (entry.multiple) {
256
+ let taken = new Set(allGroups(state.layout.root).flatMap((group) => group.surfaces.map((surface) => surface.id))),
257
+ n = 1;
258
+
259
+ while (taken.has(id = `${kind}-${n}`)) {
260
+ n++;
261
+ }
262
+ }
263
+
264
+ state.open({ id, kind }, group);
265
+ },
266
+ addable: Object.entries(catalog).filter(([, entry]) => entry.addable !== false),
267
+ catalog,
268
+ choose(e: MouseEvent, group: string) {
269
+ if (!adding) {
270
+ return;
179
271
  }
180
272
 
181
- return [{ axis: 'x', sign: direction(edge) === 1 ? -1 : 1 }];
273
+ let { bottom, left } = (e.currentTarget as HTMLElement).getBoundingClientRect();
274
+
275
+ subject.group = group;
276
+ flush();
277
+ adding.open({ x: left, y: bottom });
182
278
  },
183
- capture: () => hold(frame, edge),
184
- move: (element, { x }) => {
185
- reveal(frame, edge, element.offsetWidth, element.offsetWidth + x * direction(edge));
279
+ empty,
280
+ held: (e: MouseEvent) => apple ? e.metaKey : e.ctrlKey,
281
+ icons,
282
+ // The toggles cover the top corners: each sidebar's corner group clears its toggle, and the main area's
283
+ // while that sidebar is closed.
284
+ inset(group: string, edge: Edge) {
285
+ let layout = state.layout,
286
+ trees = shown(layout);
287
+
288
+ return trees[edge] !== null && (group === corner(trees[edge], edge)?.id || (group === corner(trees.main, edge)?.id && !layout[edge].open));
186
289
  },
187
- release: (_, __, dismiss) => {
188
- settle(frame, edge);
290
+ menu(e: MouseEvent, group: string, surface: string) {
291
+ if (!controller) {
292
+ return;
293
+ }
189
294
 
190
- if (dismiss) {
191
- hide();
295
+ e.preventDefault();
296
+ subject.group = group;
297
+ subject.surface = surface;
298
+ flush();
299
+ controller.open(e.button === 2 ? { x: e.clientX, y: e.clientY } : undefined);
300
+ },
301
+ pick(group: string) {
302
+ let current = read(picks);
303
+
304
+ write(picks, current.includes(group) ? current.filter((id) => id !== group) : [...current, group]);
305
+ },
306
+ picked: (group: string) => read(picks).includes(group),
307
+ slot: (surface: string) => html`
308
+ <div
309
+ class='shell-slot'
310
+ ${{
311
+ onconnect: (element: HTMLElement) => {
312
+ slots.set(surface, element);
313
+ attach(surface, element);
314
+ },
315
+ ondisconnect: () => {
316
+ if (slots.get(surface)?.isConnected === false) {
317
+ slots.delete(surface);
318
+ }
319
+ }
320
+ }}
321
+ ></div>
322
+ `,
323
+ sorting(strip: ReactiveArray<Surface>, group: string) {
324
+ strips.set(strip, group);
325
+
326
+ return {
327
+ disabled: (surface) => surface.sortable === false,
328
+ group: edges.id,
329
+ onland: () => {
330
+ let land = landing;
331
+
332
+ landing = null;
333
+ write(carrying, false);
334
+ land?.();
335
+ },
336
+ onlift: () => write(carrying, true),
337
+ onsort: (surface, _, to, __, target) => {
338
+ let group = strips.get(target);
339
+
340
+ landing = group ? () => state.move(surface.id, group, to) : null;
341
+ },
342
+ outside: {
343
+ ondrop: (surface, element) => {
344
+ landing = () => drop(surface, element);
345
+ },
346
+ over: (_, x, y) => workspace ? target(workspace, x, y) : null
347
+ }
348
+ };
349
+ },
350
+ state,
351
+ // Held down with the modifier, a press sweeps: every group the pointer crosses into is picked, and letting go
352
+ // after leaving the first zooms to every pick at once. A press that stays in its group is a click, which
353
+ // picks or unpicks it instead.
354
+ sweep(e: PointerEvent, group: string) {
355
+ let swept = [group];
356
+
357
+ function end(event: PointerEvent) {
358
+ document.documentElement.classList.remove('shell-sweeping');
359
+ window.removeEventListener('pointercancel', end);
360
+ window.removeEventListener('pointermove', move);
361
+ window.removeEventListener('pointerup', end);
362
+
363
+ if (swept.length < 2) {
364
+ return;
365
+ }
366
+
367
+ // The click the release ends with lands on whatever holds both groups; it picks nothing.
368
+ let swallow = (click: MouseEvent) => {
369
+ click.preventDefault();
370
+ click.stopPropagation();
371
+ };
372
+
373
+ window.addEventListener('click', swallow, { capture: true, once: true });
374
+ setTimeout(() => window.removeEventListener('click', swallow, { capture: true }));
375
+
376
+ if (event.type === 'pointerup') {
377
+ let chosen = read(picks);
378
+
379
+ write(picks, []);
380
+ state.zoom(chosen);
381
+ }
382
+ }
383
+
384
+ function move(event: PointerEvent) {
385
+ let id = workspace && under(workspace, event.clientX, event.clientY);
386
+
387
+ if (!id || swept.includes(id)) {
388
+ return;
389
+ }
390
+
391
+ swept.push(id);
392
+ write(picks, [...new Set([...read(picks), ...swept])]);
192
393
  }
394
+
395
+ if (e.button !== 0) {
396
+ return;
397
+ }
398
+
399
+ document.documentElement.classList.add('shell-sweeping');
400
+ window.addEventListener('pointercancel', end);
401
+ window.addEventListener('pointermove', move);
402
+ window.addEventListener('pointerup', end);
403
+ },
404
+ switcher(e: MouseEvent) {
405
+ let { bottom, left } = (e.currentTarget as HTMLElement).getBoundingClientRect();
406
+
407
+ switching?.open({ x: left, y: bottom });
408
+ },
409
+ switches: () => allGroups(shown(state.layout).main).length > 1
410
+ };
411
+
412
+ function attach(surface: string, slot: HTMLElement) {
413
+ let host = hosts.get(surface);
414
+
415
+ if (!host) {
416
+ return;
193
417
  }
194
- });
195
418
 
196
- function hide() {
197
- if (peeking[edge]) {
198
- peeking[edge] = false;
419
+ // A slot connects before the rebuilt tree is in the document; the host waits so it is moved, not removed.
420
+ if (!slot.isConnected) {
421
+ queueMicrotask(() => slot.isConnected && attach(surface, slot));
422
+ return;
423
+ }
424
+
425
+ move(host.element, slot);
199
426
  }
200
- else {
201
- close(side);
427
+
428
+ function ensure(surface: string) {
429
+ if (hosts.has(surface)) {
430
+ return;
431
+ }
432
+
433
+ let found = findSurface(state.layout.root, surface),
434
+ kind = found && catalog[found.kind];
435
+
436
+ if (!found || !kind) {
437
+ return;
438
+ }
439
+
440
+ let element = document.createElement('div'),
441
+ entry = found,
442
+ // Owned by no effect: the host outlives whichever layout pass created it.
443
+ release = untrack(() => root(() => render(element, { class: 'shell-host', 'data-surface': surface }, () => kind.render(entry))));
444
+
445
+ hosts.set(surface, { dispose: release, element });
202
446
  }
203
- }
204
447
 
205
- return html`
206
- <aside
207
- aria-label='${side.label}'
208
- class='shell-sidebar shell-sidebar--${edge} ${side.class ?? ''}'
209
- id='${side.id}'
210
- ${{
211
- class: [
212
- () => side.state.active ? '--active' : peeking[edge] && '--peek',
213
- () => frame[edge].dragging && 'shell-sidebar--dragging'
214
- ],
215
- inert: () => !side.state.active && !peeking[edge],
216
- // Delegated handlers stop at the nearest bound element, and the sidebar's content binds pointer events
217
- // of its own, so the drag listens on the sidebar directly.
218
- onconnect: (element: HTMLElement, on) => {
219
- frame[edge].sidebar = element;
220
-
221
- // Links would otherwise start a native drag-and-drop mid-swipe and cancel the pointer.
222
- on(element, 'dragstart', (e) => e.preventDefault(), { direct: true });
223
- on(element, 'pointercancel', gesture.onpointercancel, { direct: true });
224
- on(element, 'pointerdown', gesture.onpointerdown, { direct: true });
225
- on(element, 'pointerleave', (e) => leave(side, peeking, frame, edge, e), { direct: true });
226
- on(element, 'pointermove', gesture.onpointermove, { direct: true });
227
- on(element, 'pointerup', gesture.onpointerup, { direct: true });
448
+ // Moving a connected node keeps its focus, scroll and frames; appending would reload an iframe.
449
+ function move(element: HTMLElement, target: HTMLElement) {
450
+ if (element.parentElement === target) {
451
+ return;
452
+ }
453
+
454
+ if ('moveBefore' in target && element.isConnected && target.isConnected) {
455
+ (target as HTMLElement & { moveBefore: (node: ChildNode, child: null) => void }).moveBefore(element, null);
456
+ return;
457
+ }
458
+
459
+ let focused = document.activeElement;
460
+
461
+ target.append(element);
462
+
463
+ if (focused instanceof HTMLElement && element.contains(focused)) {
464
+ focused.focus({ preventScroll: true });
465
+ }
466
+ }
467
+
468
+ function node(current: Node): Renderable<unknown> {
469
+ if (current.kind === 'group') {
470
+ let id = current.id;
471
+
472
+ return group(context, () => {
473
+ let layout = state.layout;
474
+
475
+ return { group: findGroup(layout.root, id) ?? current, layout };
476
+ });
477
+ }
478
+
479
+ return split(current);
480
+ }
481
+
482
+ // A sidebar makes room while it is open and has groups to show, outside a zoom.
483
+ function open(edge: Edge) {
484
+ let layout = state.layout;
485
+
486
+ return layout.zoom.length === 0 && layout[edge].open && allGroups(layout.root).some((group) => docked(group, edge));
487
+ }
488
+
489
+ // Every host, or those inside 'within', waits in the parking while what held it is rebuilt.
490
+ function park(within?: HTMLElement) {
491
+ if (!parking) {
492
+ return;
493
+ }
494
+
495
+ for (let host of hosts.values()) {
496
+ if (!within || within.contains(host.element)) {
497
+ move(host.element, parking);
498
+ }
499
+ }
500
+ }
501
+
502
+ // One region's groups, rebuilt only when its own structure changes, so opening a tab in the main area leaves
503
+ // the sidebars' content where it is.
504
+ function region(name: Region) {
505
+ let last = '';
506
+
507
+ return subtree(
508
+ () => {
509
+ let key = JSON.stringify(structure(shown(state.layout)[name]));
510
+
511
+ if (key !== last && last !== '' && regions[name]) {
512
+ park(regions[name]);
513
+ }
514
+
515
+ last = key;
516
+
517
+ return key;
228
518
  },
229
- onkeydown: (e: KeyboardEvent) => {
230
- if (e.key === 'Escape' && !e.defaultPrevented) {
231
- e.preventDefault();
232
- hide();
519
+ () => {
520
+ let tree = shown(state.layout)[name];
521
+
522
+ if (name !== 'main') {
523
+ return tree ? node(tree) : '';
233
524
  }
525
+
526
+ return tree ? html`${node(tree)}${switcher(tree)}` : launcher(context);
234
527
  },
235
- style: () => ({ translate: frame[edge].translate })
236
- }}
237
- >
238
- ${side.content}
239
- </aside>
240
- `;
241
- }
528
+ {
529
+ onconnect: (element: HTMLElement) => {
530
+ regions[name] = element;
531
+ }
532
+ }
533
+ );
534
+ }
242
535
 
243
- // Shows 'shown' pixels of a sidebar 'width' wide and moves the card's edge to meet it, narrowing its gap to none as it
244
- // comes. The card's surface moves while its content keeps its layout, clipped where the sidebar covers it, until the
245
- // sidebar settles; on small screens the card keeps its width and slides, so it moves outright. The shell's transitions
246
- // stand down so both follow the pointer.
247
- function reveal(frame: Frame, edge: Edge, width: number, shown: number) {
248
- let clamped = Math.max(0, Math.min(width, shown)),
249
- rest = `calc(var(--gap-horizontal) * ${width ? 1 - clamped / width : 1})`,
250
- state = frame[edge];
251
-
252
- state.translate = `${(clamped - width) * direction(edge)}px 0`;
253
-
254
- if (matchMedia(NARROW).matches) {
255
- state.gap = rest;
256
- state.reach = undefined;
257
- state.space = `${clamped}px`;
258
- }
259
- else {
260
- state.gap = undefined;
261
- state.reach = `calc(${clamped}px + ${rest})`;
262
- state.space = undefined;
263
- }
264
- }
536
+ function split(current: Split) {
537
+ let axis = current.direction === 'row' ? 'x' as const : 'y' as const,
538
+ box = reactive({ length: 0 }),
539
+ unobserve: VoidFunction | undefined;
265
540
 
266
- // Hands the sidebar and the card back to their transitions, which carry both from where the drag left them to open or
267
- // closed; flushed, so the transitions are back before the drag's values go.
268
- function settle(frame: Frame, edge: Edge) {
269
- let state = frame[edge];
270
-
271
- state.dragging = false;
272
- flush();
273
- state.gap = undefined;
274
- state.reach = undefined;
275
- state.space = undefined;
276
- state.translate = undefined;
277
- }
541
+ // As shown: a zoom shows a split with only some of its children, sharing the space between them.
542
+ function sizes() {
543
+ for (let tree of Object.values(shown(state.layout))) {
544
+ let found = findSplit(tree, current.id);
278
545
 
279
- // Clicked while its sidebar peeks, the toggle keeps it open.
280
- function toggle(sides: Sides, peeking: Peeking, frame: Frame, edge: Edge) {
281
- let side = sides[edge];
546
+ if (found) {
547
+ return found.sizes;
548
+ }
549
+ }
282
550
 
283
- function label() {
284
- return `${side.state.active ? 'Close' : 'Open'} ${side.label.toLowerCase()}`;
285
- }
551
+ return current.sizes;
552
+ }
286
553
 
287
- return button.sidebar({
288
- 'aria-controls': side.id,
289
- 'aria-label': label,
290
- class: `shell-toggle shell-toggle--${edge}`,
291
- id: `${side.id}-toggle`,
292
- onclick: () => side.state.active ? close(side) : open(sides, peeking, edge),
293
- // The button keeps 'pointerleave' for itself; moves into its own glyph are ignored like any within the sidebar.
294
- onpointerout: (e: PointerEvent) => leave(side, peeking, frame, edge, e),
295
- open: () => side.state.active,
296
- side: edge,
297
- title: label
298
- });
299
- }
554
+ return html`
555
+ <div
556
+ class='shell-split shell-split--${current.direction}'
557
+ ${{
558
+ onconnect: (element: HTMLElement) => {
559
+ unobserve = observe(element, ([entry]) => {
560
+ box.length = axis === 'x' ? entry.contentRect.width : entry.contentRect.height;
561
+ });
562
+ },
563
+ ondisconnect: () => unobserve?.()
564
+ }}
565
+ >
566
+ ${current.children.map((child, index) => html`
567
+ <div
568
+ class='shell-pane'
569
+ ${{
570
+ // Holding the main group a narrow layout shows alone.
571
+ class: () => state.layout.main !== null && contains(child, state.layout.main) && 'shell-pane--current',
572
+ style: () => {
573
+ let maximized = state.layout.maximized;
574
+
575
+ if (maximized === null || !contains(current, maximized)) {
576
+ return `--flex: 0 0 ${(sizes()[index] ?? 0) * 100}%;`;
577
+ }
578
+
579
+ return contains(current.children[index], maximized)
580
+ ? `--flex: 0 0 calc(100% - ${(current.children.length - 1) * COLLAPSED}px);`
581
+ : `--flex: 0 0 ${COLLAPSED}px;`;
582
+ }
583
+ }}
584
+ >
585
+ ${node(child)}
586
+ </div>
587
+ ${index < current.children.length - 1 && separator(axis, () => {
588
+ let from = sizes(),
589
+ length = box.length;
590
+
591
+ return (delta) => state.resize(current.id, resized(from, index, delta, length, MIN_FRACTION), current.children.map((child) => child.id));
592
+ })}
593
+ `)}
594
+ </div>
595
+ `;
596
+ }
597
+
598
+ // The menu of main groups a narrow layout switches between.
599
+ function switcher(main: Node) {
600
+ let groups = allGroups(main);
601
+
602
+ return groups.length > 1 && tooltip.context(
603
+ {
604
+ class: 'shell-menu',
605
+ controller: (value: Controller) => {
606
+ switching = value;
607
+ },
608
+ items: groups.map((entry) => ({
609
+ label: () => {
610
+ let found = findGroup(state.layout.root, entry.id),
611
+ surface = found?.surfaces.find((item) => item.id === found.active);
612
+
613
+ return surface ? title(context, surface) : 'Empty group';
614
+ },
615
+ onselect: () => state.focus(entry.id)
616
+ })),
617
+ [tooltip.context.panel]: { 'aria-label': 'Switch group' }
618
+ },
619
+ ''
620
+ );
621
+ }
622
+
623
+ // Hiding a surface or picking another tab keeps its host parked; only closing it releases its content.
624
+ function sync(layout: Layout, attaching: boolean) {
625
+ let shown = mounted(layout);
626
+
627
+ for (let [surface, host] of hosts) {
628
+ if (findSurface(layout.root, surface)) {
629
+ if (!shown.has(surface) && parking) {
630
+ move(host.element, parking);
631
+ }
632
+
633
+ continue;
634
+ }
635
+
636
+ host.dispose();
637
+ host.element.remove();
638
+ hosts.delete(surface);
639
+ slots.delete(surface);
640
+ }
300
641
 
642
+ for (let surface of shown) {
643
+ ensure(surface);
301
644
 
302
- // The app frame: a sidebar on either edge, each with its toggle in its own top corner, around a card the page scrolls
303
- // in. The card insets from the window by a gap that closes on the side of an open sidebar, and a closed sidebar's gap
304
- // holds a handle to drag it open by, which slides in over the card while the pointer is on that edge.
305
- const shell = (sides: Sides, content: Renderable<unknown>) => {
306
- let frame: Frame = { left: motion(), right: motion() },
307
- peeking = reactive<Peeking>({ left: false, right: false });
308
-
309
- return html`
310
- <div
311
- class='shell ${() => sides.left.state.active && 'shell--left-open'} ${() => sides.right.state.active && 'shell--right-open'}'
312
- ${{
313
- class: () => (frame.left.dragging || frame.right.dragging) && 'shell--dragging',
314
- style: () => ({
315
- '--left-edge': frame.left.reach,
316
- '--left-gap-horizontal': frame.left.gap,
317
- '--left-space': frame.left.space,
318
- '--right-edge': frame.right.reach,
319
- '--right-gap-horizontal': frame.right.gap,
320
- '--right-space': frame.right.space
321
- })
322
- }}
323
- >
324
- <div aria-hidden='true' class='shell-backdrop'></div>
325
- <div aria-hidden='true' class='shell-surface'></div>
326
- ${panel(sides.left, peeking, frame, 'left')}
327
- ${panel(sides.right, peeking, frame, 'right')}
328
- ${grip(sides, peeking, frame, 'left')}
329
- ${grip(sides, peeking, frame, 'right')}
330
- ${toggle(sides, peeking, frame, 'left')}
331
- ${toggle(sides, peeking, frame, 'right')}
332
- <div class='card shell-main' ${scrollbar()}>
333
- ${content}
645
+ let slot = slots.get(surface);
646
+
647
+ if (attaching && slot) {
648
+ attach(surface, slot);
649
+ }
650
+ }
651
+ }
652
+
653
+ // Strips along the layout's edges a dragged tab docks onto; a static sidebar has none.
654
+ function targets() {
655
+ return (['bottom', 'left', 'right'] as const)
656
+ .filter((placement) => placement === 'bottom' || !stationary(state.layout.root, placement))
657
+ .map((placement) => html`
658
+ <div
659
+ aria-hidden='true'
660
+ class='shell-dock-target shell-dock-target--${placement}'
661
+ data-placement='${placement}'
662
+ ></div>
663
+ `);
664
+ }
665
+
666
+ // Rebuilt when a region appears or goes, the bottom dock opens or closes or the zoom changes; each region
667
+ // rebuilds its own groups. A sidebar named in 'sidebars' shows even without groups, so it can always be opened.
668
+ function tree(): Renderable<unknown> {
669
+ let trees = shown(state.layout);
670
+
671
+ return html`
672
+ <div class='shell-frame'>
673
+ ${(['left', 'right'] as const).map((edge) => (trees[edge] || options[edge]) && html`
674
+ ${sidebar(edges, edge, region(edge))}
675
+ ${grip(edges, edge)}
676
+ ${options[edge]?.resizable && resizer(edges, edge)}
677
+ ${toggle(edges, edge)}
678
+ `)}
679
+ <div class='shell-center'>
680
+ <div class='shell-main'>
681
+ ${region('main')}
682
+ </div>
683
+ ${trees.bottom && html`
684
+ ${separator(
685
+ 'y',
686
+ () => {
687
+ let share = bounded(state.layout.bottom.size),
688
+ length = size.height;
689
+
690
+ return (delta) => state.resizeDock('bottom', resized([1 - share, share], 0, delta, length, MIN_FRACTION)[1]);
691
+ },
692
+ { hidden: () => state.layout.bottom.maximized }
693
+ )}
694
+ <div
695
+ class='shell-dock'
696
+ ${{
697
+ class: () => state.layout.bottom.maximized && 'shell-dock--maximized',
698
+ style: () => `--flex: 0 0 ${bounded(state.layout.bottom.size) * 100}%;`
699
+ }}
700
+ >
701
+ ${region('bottom')}
702
+ </div>
703
+ `}
704
+ </div>
705
+ </div>
706
+ ${targets()}
707
+ `;
708
+ }
709
+
710
+ // The layout's own items, then each kind's: a kind with a menu of its own shows only that on its tabs.
711
+ let kind = () => findSurface(state.layout.root, subject.surface)?.kind ?? '',
712
+ own = () => !!catalog[kind()]?.menu,
713
+ items: Item[] = [
714
+ { hidden: own, label: 'Close', onselect: () => void state.close(subject.surface) },
715
+ {
716
+ hidden: () => own() || (findGroup(state.layout.root, subject.group)?.surfaces.length ?? 0) <= 1,
717
+ label: 'Close Others',
718
+ onselect: () => void state.closeOthers(subject.group, subject.surface)
719
+ },
720
+ {
721
+ hidden: () => {
722
+ let surfaces = findGroup(state.layout.root, subject.group)?.surfaces ?? [];
723
+
724
+ return own() || surfaces.findIndex((surface) => surface.id === subject.surface) >= surfaces.length - 1;
725
+ },
726
+ label: 'Close to the Right',
727
+ onselect: () => void state.closeRight(subject.group, subject.surface)
728
+ },
729
+ { hidden: own, label: 'Close All', onselect: () => void state.closeGroup(subject.group) },
730
+ ...Object.entries(catalog).flatMap(([name, entry]) => (entry.menu?.(() => subject.surface) ?? []).map((item) => ({
731
+ ...item,
732
+ hidden: () => kind() !== name || (typeof item.hidden === 'function' ? !!item.hidden() : !!item.hidden)
733
+ })))
734
+ ],
735
+ last = '';
736
+
737
+ onCleanup(() => {
738
+ for (let host of hosts.values()) {
739
+ host.dispose();
740
+ }
741
+
742
+ hosts.clear();
743
+ slots.clear();
744
+ });
745
+
746
+ // Narrow, opening a sidebar closes the other, so both open on turning narrow leaves the left.
747
+ effect(() => {
748
+ if (narrow() && state.layout.left.open && state.layout.right.open) {
749
+ untrack(() => state.toggle('right', false));
750
+ }
751
+ });
752
+
753
+ return html`
754
+ <div
755
+ class='shell'
756
+ ${attributes}
757
+ ${{
758
+ class: [
759
+ () => read(carrying) && 'shell--dragging',
760
+ () => narrow() && 'shell--narrow',
761
+ () => (frames.left.dragging || frames.right.dragging) && 'shell--sliding',
762
+ () => open('left') && 'shell--left-open',
763
+ () => open('right') && 'shell--right-open'
764
+ ],
765
+ onconnect: (element: HTMLElement) => {
766
+ workspace = element;
767
+ unobserve = observe(element, ([entry]) => {
768
+ size.height = entry.contentRect.height;
769
+ size.width = entry.contentRect.width;
770
+ });
771
+ },
772
+ ondisconnect: () => unobserve?.(),
773
+ onwindowblur: () => write(picks, []),
774
+ onwindowkeydown: (e: KeyboardEvent) => {
775
+ if (e.key === 'Escape' && read(picks).length) {
776
+ e.preventDefault();
777
+ write(picks, []);
778
+ }
779
+ },
780
+ onwindowkeyup: (e: KeyboardEvent) => {
781
+ let chosen = read(picks);
782
+
783
+ if (e.key !== (apple ? 'Meta' : 'Control') || chosen.length === 0) {
784
+ return;
785
+ }
786
+
787
+ write(picks, []);
788
+ state.zoom(chosen);
789
+ },
790
+ style: () => {
791
+ let { left, right } = state.layout;
792
+
793
+ return {
794
+ '--left': frames.left.space,
795
+ '--left-size': left.size === null ? undefined : `${left.size}px`,
796
+ '--right': frames.right.space,
797
+ '--right-size': right.size === null ? undefined : `${right.size}px`
798
+ };
799
+ }
800
+ }}
801
+ >
802
+ <div
803
+ class='shell-parking'
804
+ ${{
805
+ onconnect: (element: HTMLElement) => {
806
+ parking = element;
807
+ }
808
+ }}
809
+ ></div>
810
+ ${subtree(
811
+ () => {
812
+ let layout = state.layout,
813
+ trees = shown(layout),
814
+ key = JSON.stringify([layout.bottom.open, layout.zoom.at(-1)?.groups ?? null, ...Object.values(trees).map((tree) => tree !== null)]),
815
+ changed = key !== last;
816
+
817
+ if (changed) {
818
+ park();
819
+ }
820
+
821
+ sync(layout, !changed);
822
+ last = key;
823
+
824
+ return key;
825
+ },
826
+ tree,
827
+ { class: 'shell-tree' }
828
+ )}
829
+ ${tooltip.context(
830
+ {
831
+ class: 'shell-menu',
832
+ controller: (value: Controller) => {
833
+ adding = value;
834
+ },
835
+ items: context.addable.map(([kind, entry]) => ({
836
+ ...(entry.icon ? { icon: () => icon({ 'aria-hidden': 'true' }, entry.icon!) } : {}),
837
+ label: typeof entry.title === 'function' ? entry.title({ id: '', kind }) : entry.title,
838
+ onselect: () => context.add(kind, subject.group)
839
+ })),
840
+ [tooltip.context.panel]: { 'aria-label': 'Add panel' }
841
+ },
842
+ ''
843
+ )}
844
+ ${tooltip.context(
845
+ {
846
+ class: 'shell-menu',
847
+ controller: (value: Controller) => {
848
+ controller = value;
849
+ },
850
+ items,
851
+ [tooltip.context.panel]: { 'aria-label': 'Tab actions' }
852
+ },
853
+ ''
854
+ )}
334
855
  </div>
335
- </div>
336
- `;
337
- };
856
+ `;
857
+ }
858
+ );
338
859
 
339
860
 
340
- const layout: typeof shell & { close: typeof close } = Object.assign(shell, { close });
861
+ const layout: typeof shell & { state: typeof state } = Object.assign(shell, { state });
341
862
 
342
863
 
343
864
  export default layout;
344
- export type { Side };
865
+ export type { Catalog, Kind, Layout, Node, Placement, Saved, Store, Surface };