@esportsplus/ui 0.63.0 → 0.64.1

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 (538) 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/NOTICE +0 -232
  466. package/build/components/dock/index.d.ts +0 -47
  467. package/build/components/dock/index.js +0 -469
  468. package/build/components/dock/scss/index.scss +0 -2
  469. package/build/components/metric/flash.d.ts +0 -12
  470. package/build/components/metric/flash.js +0 -117
  471. package/build/components/metric/index.d.ts +0 -44
  472. package/build/components/metric/index.js +0 -275
  473. package/build/components/metric/scss/index.scss +0 -2
  474. package/build/components/pagination/dots.d.ts +0 -23
  475. package/build/components/pagination/dots.js +0 -115
  476. package/build/components/panels/dnd.d.ts +0 -47
  477. package/build/components/panels/dnd.js +0 -114
  478. package/build/components/panels/group.js +0 -322
  479. package/build/components/panels/index.d.ts +0 -17
  480. package/build/components/panels/index.js +0 -524
  481. package/build/components/panels/model.d.ts +0 -64
  482. package/build/components/panels/resize.d.ts +0 -9
  483. package/build/components/panels/scss/index.scss +0 -2
  484. package/build/components/preview/buttons.d.ts +0 -12
  485. package/build/components/preview/buttons.js +0 -26
  486. package/build/components/preview/code.d.ts +0 -8
  487. package/build/components/preview/code.js +0 -18
  488. package/build/components/preview/header.js +0 -21
  489. package/build/components/preview/index.d.ts +0 -37
  490. package/build/components/preview/index.js +0 -123
  491. package/build/components/preview/scss/index.scss +0 -2
  492. package/build/components/preview/source.d.ts +0 -12
  493. package/build/components/preview/source.js +0 -79
  494. package/build/components/preview/stage.d.ts +0 -8
  495. package/build/components/preview/stage.js +0 -28
  496. package/build/components/textarea/scss/index.scss +0 -2
  497. package/src/components/dock/index.ts +0 -567
  498. package/src/components/dock/scss/index.scss +0 -346
  499. package/src/components/dock/scss/variables.scss +0 -357
  500. package/src/components/input/scss/_field.scss +0 -39
  501. package/src/components/input/scss/_scrub.scss +0 -89
  502. package/src/components/input/scss/_tag.scss +0 -142
  503. package/src/components/metric/flash.ts +0 -129
  504. package/src/components/metric/index.ts +0 -307
  505. package/src/components/metric/scss/_flash.scss +0 -150
  506. package/src/components/metric/scss/index.scss +0 -155
  507. package/src/components/metric/scss/variables.scss +0 -233
  508. package/src/components/pagination/dots.ts +0 -132
  509. package/src/components/panels/dnd.ts +0 -190
  510. package/src/components/panels/index.ts +0 -676
  511. package/src/components/panels/resize.ts +0 -157
  512. package/src/components/panels/scss/index.scss +0 -379
  513. package/src/components/panels/scss/variables.scss +0 -197
  514. package/src/components/preview/buttons.ts +0 -48
  515. package/src/components/preview/code.ts +0 -28
  516. package/src/components/preview/header.ts +0 -23
  517. package/src/components/preview/index.ts +0 -149
  518. package/src/components/preview/scss/index.scss +0 -158
  519. package/src/components/preview/scss/variables.scss +0 -149
  520. package/src/components/preview/source.ts +0 -73
  521. package/src/components/preview/stage.ts +0 -33
  522. package/src/components/range/scss/_filter.scss +0 -360
  523. package/src/components/range/scss/_slider.scss +0 -65
  524. package/src/components/range/scss/_vertical.scss +0 -10
  525. package/src/components/textarea/scss/index.scss +0 -72
  526. package/src/components/textarea/scss/variables.scss +0 -22
  527. package/storage/svg/amex.svg +0 -1
  528. package/storage/svg/arrow-down.svg +0 -1
  529. package/storage/svg/arrow-left.svg +0 -1
  530. package/storage/svg/arrow-right.svg +0 -1
  531. package/storage/svg/arrow-up.svg +0 -1
  532. package/storage/svg/card.svg +0 -1
  533. package/storage/svg/chip.svg +0 -1
  534. package/storage/svg/discover.svg +0 -1
  535. package/storage/svg/mastercard.svg +0 -1
  536. package/storage/svg/visa.svg +0 -1
  537. /package/build/components/{panels → shell}/subtree.d.ts +0 -0
  538. /package/storage/svg/{chevron-right.svg → chevron.svg} +0 -0
@@ -0,0 +1,1675 @@
1
+ import { computed, effect, flush, onCleanup, reactive, ReactiveArray, read, signal, write } from '@esportsplus/reactivity';
2
+ import { component, html, type Attributes, type Renderable } from '@esportsplus/template';
3
+ import icon from '~/components/icon';
4
+ import inlineEdit from '~/components/inline-edit';
5
+ import overlay from '~/components/overlay';
6
+ import searchbox from '~/components/search';
7
+ import sortable, { type SortableCombine, type SortableOptions } from '~/components/sortable';
8
+ import tooltip from '~/components/tooltip';
9
+ import { content as surface } from '~/components/tooltip/utilities';
10
+ import scrollbar from '~/modifiers/scrollbar';
11
+ import { observer } from '~/shared/resize';
12
+ import arrowSvg from '@esportsplus/ui/svg/arrow.svg';
13
+ import chevron from '@esportsplus/ui/svg/chevron.svg';
14
+ import enter from '@esportsplus/ui/svg/enter.svg';
15
+ import grid from '@esportsplus/ui/svg/grid.svg';
16
+ import '~/components/button/scss/index.scss';
17
+ import './scss/index.scss';
18
+
19
+
20
+ type A = Attributes & {
21
+ // Lays the drawer's buttons out by label, under '#' and A to Z headings, with a rail of those letters beside them:
22
+ // pointing along it scrolls to each letter's buttons, and leaving it leaves the drawer where it got to. Only the
23
+ // layout is sorted; 'apps' keeps its own order.
24
+ alphabetical?: boolean;
25
+ // The buttons kept out of the bar, in a drawer that opens from its own button; dragging moves them in and out of
26
+ // 'items', and throwing one off the bar puts it back.
27
+ apps?: Button[] | ReactiveArray<Button>;
28
+ // Arrows either end page through the buttons once they outgrow the bar, which otherwise grows to fit them.
29
+ arrows?: boolean;
30
+ // How long the pointer rests on a button before its label shows, ms.
31
+ delay?: number;
32
+ // The side the drawer and the labels open toward; east and west stand the bar upright, for a screen's side edge.
33
+ direction?: Direction;
34
+ // A drawer the bar morphs into, opened by the button 'toolbar.drawer()' places among 'items' (appended when
35
+ // missing, dropped without a drawer).
36
+ drawer?: boolean;
37
+ // A dragged button let go over the middle of another, on the bar or in a group's panel, groups the two, or over a
38
+ // group, joins it at its end; what it is over swells the moment the pointer reaches its middle. A group opens a
39
+ // panel of its own buttons, sorted by dragging, and
40
+ // gives way to its last button once the others have left. Groups nest; the drawer only ever holds buttons, and
41
+ // a group dropped in it, or thrown off the bar, spreads its buttons there.
42
+ groups?: boolean;
43
+ items: Entry[] | ReactiveArray<Entry>;
44
+ label?: string;
45
+ // Names each button on the bar under it, rather than as the pointer rests on it.
46
+ labels?: boolean;
47
+ // 'dock' treats the buttons as apps: a click launches one with a hop and lights its running dot.
48
+ mode?: Mode;
49
+ onlaunch?: (label: string) => void;
50
+ // A group renamed from its panel, its 'label' already the new name ('' unnamed).
51
+ onrename?: (group: Group, label: string) => void;
52
+ onsort?: SortableOptions<Entry>['onsort'];
53
+ // A search over the drawer's buttons.
54
+ search?: boolean;
55
+ // Whether buttons drag to reorder, and between the bar and the drawer; on in a dock, off otherwise.
56
+ sortable?: boolean;
57
+ // Whether the drawer is open.
58
+ state?: { active: boolean };
59
+ };
60
+
61
+ type Button = {
62
+ // Spread on the button: any state it shows ('aria-pressed', ...) and handlers other than its click.
63
+ attributes: Attributes;
64
+ // Shown as the pointer rests on it, the label when omitted: a shortcut, say, or a passing 'Copied'.
65
+ hint?: Hint;
66
+ label: Label;
67
+ // Run from the button's own click handler: an element keeps one handler per event, so a second would be lost.
68
+ onclick?: (e: MouseEvent) => void;
69
+ running?: boolean;
70
+ state?: { running: boolean };
71
+ } & Face;
72
+
73
+ // Any control the bar carries as is, a select or a field, rendered afresh wherever it shows. Never dragged.
74
+ type Custom = {
75
+ readonly [CUSTOM]: true;
76
+ hint?: Hint;
77
+ label?: Label;
78
+ render: () => Renderable<unknown>;
79
+ };
80
+
81
+ type Direction = 'e' | 'n' | 's' | 'w';
82
+
83
+ type Divider = { readonly [DIVIDER]: true };
84
+
85
+ type Entry = Button | Custom | Divider | Group | typeof TOOLBAR_DRAWER;
86
+
87
+ type Face =
88
+ // A sprite id, or a function rendering it: a button shows in the bar, the drawer and the copy being dragged at
89
+ // once, and rendered content can only stand in one place.
90
+ { icon: string | (() => Renderable<unknown>), thumbnail?: never } |
91
+ // An image url, covering the whole button.
92
+ { icon?: never, thumbnail: string };
93
+
94
+ // Buttons gathered under one button, which opens a panel of them; a group's members can be groups too.
95
+ type Group = {
96
+ readonly [GROUP]: true;
97
+ items: ReactiveArray<Member>;
98
+ // Unnamed by default; a name shows as its hover label, or under it with 'labels', and is edited at the top of its
99
+ // panel.
100
+ label?: Label;
101
+ };
102
+
103
+ type Hint = Renderable<unknown> | (() => Renderable<unknown>);
104
+
105
+ type Label = string | (() => string);
106
+
107
+ // What a group holds.
108
+ type Member = Button | Group;
109
+
110
+ type Mode = 'dock' | 'toolbar';
111
+
112
+ // 'MEMBER' is the button or group an element shows, which letting another go over it groups with.
113
+ type Slot = HTMLElement & { [LABEL]: Hint, [MEMBER]?: Member };
114
+
115
+
116
+ // Turns of the chevron, which points right.
117
+ const ARROWS: Record<'horizontal' | 'vertical', [previous: string, next: string]> = {
118
+ horizontal: ['icon--left', ''],
119
+ vertical: ['icon--up', 'icon--down']
120
+ };
121
+
122
+ const CUSTOM = Symbol();
123
+
124
+ const DIVIDER = Symbol();
125
+
126
+ // A custom item's control, the one the arrow keys reach.
127
+ const FOCUSABLE = 'button, input, select, textarea, [contenteditable], [tabindex]';
128
+
129
+ // How long pointing at a letter takes to scroll there, ms: short enough to keep up with a sweep down the rail, which
130
+ // retargets it on every letter.
131
+ const GLIDE = 150;
132
+
133
+ const GROUP = Symbol();
134
+
135
+ const LABEL = Symbol();
136
+
137
+ // An alphabetical drawer's headings and rail, '#' taking every label that starts with anything but a letter.
138
+ const LETTERS = ['#', ...'ABCDEFGHIJKLMNOPQRSTUVWXYZ'];
139
+
140
+ const MEMBER = Symbol();
141
+
142
+ // Keys that rove the bar's controls, by orientation; Home and End jump to its ends.
143
+ const ROVE: Record<'horizontal' | 'vertical', Record<string, -1 | 1>> = {
144
+ horizontal: { ArrowLeft: -1, ArrowRight: 1 },
145
+ vertical: { ArrowDown: 1, ArrowUp: -1 }
146
+ };
147
+
148
+ // How far the pointer may stray past a group's panel, carrying a button out of it, before the panel closes, px.
149
+ const SLACK = 8;
150
+
151
+ const TOOLBAR_DRAWER = Symbol.for('@esportsplus/ui/toolbar.drawer');
152
+
153
+ // The first label waits so a cursor passing through doesn't flash one; neighbours then open at once.
154
+ const TOOLTIP_DELAY = 240;
155
+
156
+
157
+ let uid = 0;
158
+
159
+
160
+ // Each button's letter and its place among them all, sorted by letter and then by label.
161
+ function alphabetize(items: ReactiveArray<Button>) {
162
+ let places = new Map<Button, { letter: number, rank: number }>(),
163
+ sorted: { item: Button, label: string, letter: number }[] = [];
164
+
165
+ items.$length;
166
+
167
+ for (let i = 0, n = items.length; i < n; i++) {
168
+ // A group passing through on its way to being spread out has no label to file.
169
+ let label = grouped(items[i]) ? '' : text(items[i].label);
170
+
171
+ sorted.push({ item: items[i], label, letter: initial(label) });
172
+ }
173
+
174
+ sorted.sort((a, b) => a.letter - b.letter || a.label.localeCompare(b.label));
175
+
176
+ for (let i = 0, n = sorted.length; i < n; i++) {
177
+ places.set(sorted[i].item, { letter: sorted[i].letter, rank: i });
178
+ }
179
+
180
+ return places;
181
+ }
182
+
183
+ // Every button a member holds, however deep.
184
+ function buttons(member: Member): Button[] {
185
+ if (!grouped(member)) {
186
+ return [member];
187
+ }
188
+
189
+ let list: Button[] = [];
190
+
191
+ for (let i = 0, n = member.items.length; i < n; i++) {
192
+ list.push(...buttons(member.items[i]));
193
+ }
194
+
195
+ return list;
196
+ }
197
+
198
+ // Whether 'member' sits anywhere inside 'group'.
199
+ function contains(group: Group, member: Member): boolean {
200
+ for (let i = 0, n = group.items.length; i < n; i++) {
201
+ let item = group.items[i];
202
+
203
+ if (item === member || (grouped(item) && contains(item, member))) {
204
+ return true;
205
+ }
206
+ }
207
+
208
+ return false;
209
+ }
210
+
211
+ // The copy following the pointer: the bar's slot with a stand-in for the button.
212
+ function copy(item: Member) {
213
+ return html`<div class='toolbar-item'>${stand(item)}</div>`;
214
+ }
215
+
216
+ function face(item: Button): Attributes {
217
+ return {
218
+ class: item.thumbnail !== undefined && 'toolbar-button--thumbnail',
219
+ style: item.thumbnail !== undefined ? `--thumbnail: url(${JSON.stringify(thumbnail(item.thumbnail))})` : ''
220
+ };
221
+ }
222
+
223
+ function glyph(item: Button) {
224
+ if (item.icon === undefined) {
225
+ return '';
226
+ }
227
+
228
+ return typeof item.icon === 'string' ? sprite(item.icon) : item.icon();
229
+ }
230
+
231
+ function grouped(value: unknown): value is Group {
232
+ return typeof value === 'object' && value !== null && GROUP in value;
233
+ }
234
+
235
+ function hint(keys: Renderable<unknown>[], label: string) {
236
+ return html`
237
+ <span class='toolbar-drawer-footer-hint'>
238
+ <span aria-hidden='true' class='toolbar-drawer-keys'>
239
+ ${keys.map((key) => html`<kbd class='button button--kbd'>${key}</kbd>`)}
240
+ </span>
241
+ ${label}
242
+ </span>
243
+ `;
244
+ }
245
+
246
+ // The letter a label files under, accents aside: 'Éclair' under E, '1Password' under '#'.
247
+ function initial(label: string) {
248
+ let letter = LETTERS.indexOf(label.normalize('NFD').charAt(0).toUpperCase());
249
+
250
+ return letter === -1 ? 0 : letter;
251
+ }
252
+
253
+ // Clicks anywhere in the drawer keep focus where the keys go, so typing and the arrow keys carry on after a stray click.
254
+ function keep(e: MouseEvent) {
255
+ if (!(e.target instanceof HTMLInputElement)) {
256
+ e.preventDefault();
257
+ }
258
+ }
259
+
260
+ // A member as one cell of a group's preview: a button's face, small, or a group's own preview, smaller.
261
+ function mini(member: Member): DocumentFragment | Element | Text {
262
+ if (grouped(member)) {
263
+ return html`<span class='toolbar-group-face toolbar-group-face--group'>${preview(member)}</span>`;
264
+ }
265
+
266
+ return html`
267
+ <span
268
+ class='toolbar-group-face'
269
+ style='${member.thumbnail !== undefined ? `--thumbnail: url(${JSON.stringify(thumbnail(member.thumbnail))})` : '--thumbnail: none'}'
270
+ >
271
+ ${glyph(member)}
272
+ </span>
273
+ `;
274
+ }
275
+
276
+ // A button or a group: what drags, and what groups.
277
+ function movable(entry: Entry): entry is Member {
278
+ return typeof entry === 'object' && !(CUSTOM in entry) && !(DIVIDER in entry);
279
+ }
280
+
281
+ function name(trigger: HTMLElement) {
282
+ return (trigger as Slot)[LABEL];
283
+ }
284
+
285
+ // A group's face: its members in a 2x2 grid, which shows the first four. Follows the group as it changes.
286
+ function preview(group: Group) {
287
+ return html`<span aria-hidden='true' class='toolbar-group-preview'>${html.reactive(group.items, mini)}</span>`;
288
+ }
289
+
290
+ // A click on a slot or tile around its button, its label or padding, presses the button. A drag's closing click never
291
+ // reaches here, since the drag swallows it.
292
+ function relay(e: MouseEvent) {
293
+ let target = e.target as Element;
294
+
295
+ if (target.closest('button, input, [contenteditable]')) {
296
+ return;
297
+ }
298
+
299
+ let button = (e.currentTarget as HTMLElement).querySelector<HTMLButtonElement>(':scope > button');
300
+
301
+ if (!button) {
302
+ return;
303
+ }
304
+
305
+ button.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, detail: e.detail, view: window }));
306
+ }
307
+
308
+ function sprite(href: string, name = '') {
309
+ return icon({ 'aria-hidden': 'true', class: name }, href);
310
+ }
311
+
312
+ // A dragged copy's button, which keeps no controls.
313
+ function stand(item: Member) {
314
+ if (grouped(item)) {
315
+ return html`<span class='button button--feedback toolbar-button toolbar-button--group'>${preview(item)}</span>`;
316
+ }
317
+
318
+ return html`<span class='button button--feedback toolbar-button' ${face(item)}>${glyph(item)}</span>`;
319
+ }
320
+
321
+ function text(label: Label) {
322
+ return typeof label === 'function' ? label() : label;
323
+ }
324
+
325
+ // Absolute, since a 'url()' substituted from a custom property resolves against the stylesheet that reads it.
326
+ function thumbnail(src: string) {
327
+ return new URL(src, document.baseURI).href;
328
+ }
329
+
330
+ // The copy dragged out of the drawer: its cell, with a stand-in for the button. CSS turns it into the bar's button as
331
+ // it lifts.
332
+ function tile(item: Member) {
333
+ return html`
334
+ <div class='toolbar-app'>
335
+ ${stand(item)}
336
+ <span class='toolbar-app-label'>${item.label}</span>
337
+ </div>
338
+ `;
339
+ }
340
+
341
+
342
+ const button = ({ hint, icon, label, onclick, running, state, thumbnail, ...attributes }: Attributes & Omit<Button, 'attributes'>): Button =>
343
+ ({ attributes, hint, icon, label, onclick, running, state, thumbnail }) as Button;
344
+
345
+ const divider = (): Divider => ({ [DIVIDER]: true });
346
+
347
+ const drawer = () => TOOLBAR_DRAWER;
348
+
349
+ const group = ({ items, label }: { items: Member[] | ReactiveArray<Member>, label?: Label }): Group =>
350
+ ({ [GROUP]: true, items: items instanceof ReactiveArray ? items : new ReactiveArray(items), label });
351
+
352
+ const item = (render: Custom['render'], { hint, label }: Pick<Custom, 'hint' | 'label'> = {}): Custom => ({ [CUSTOM]: true, hint, label, render });
353
+
354
+ const toolbar = ({
355
+ alphabetical = false,
356
+ apps,
357
+ arrows = false,
358
+ delay = TOOLTIP_DELAY,
359
+ direction = 'n',
360
+ drawer: drawn = false,
361
+ groups: gathering = false,
362
+ items,
363
+ labels = false,
364
+ mode = 'toolbar',
365
+ label = mode === 'dock' ? 'Dock' : 'Toolbar',
366
+ onlaunch,
367
+ onrename,
368
+ onsort,
369
+ search = true,
370
+ sortable: sorting = mode === 'dock' || gathering,
371
+ state = reactive({ active: false }),
372
+ ...attributes
373
+ }: A) => {
374
+ let cells: HTMLElement | undefined,
375
+ dock = mode === 'dock',
376
+ entries = items instanceof ReactiveArray ? items : new ReactiveArray(items),
377
+ // The bar has grown to the drawer: a frame behind 'state.active' while opening, so it starts from its own box,
378
+ // and with it while closing.
379
+ expanded = reactive({ active: false }),
380
+ field: HTMLInputElement | undefined,
381
+ // The bar's own box while it morphs to and from the drawer: lengths, since 'auto' doesn't transition, set only
382
+ // from opening until it has landed back. 'morphing' turns the transitions on a frame after 'sized' pins the
383
+ // bar's box, so the pin itself (a pill's '999px' rounding held to what it draws) is instant.
384
+ fit = reactive({ height: 0, morphing: false, radius: 0, sized: false, width: 0 }),
385
+ // A group's panel: whether it shows, and where on the bar it opens from, the middle of the group's slot.
386
+ folder = reactive({ active: false, x: 0, y: 0 }),
387
+ frame = 0,
388
+ // An alphabetical drawer's headings, by letter, which the rail scrolls to.
389
+ headings: HTMLElement[] = [],
390
+ // Also the name the bar, the drawer and the groups' panels trade buttons under.
391
+ id = `toolbar-${++uid}`,
392
+ // The drawer's search, and the button the keys rest on among those it shows: none (-1) until an arrow picks one.
393
+ launch = reactive({ index: -1, query: '' }),
394
+ // Kept per button rather than per render, since moving between lists renders it afresh.
395
+ launching = new WeakMap<Button, { launching: boolean }>(),
396
+ marker = entries.indexOf(TOOLBAR_DRAWER),
397
+ // Shows the buttons off the page for as long as 'measure()' reads them.
398
+ measuring = reactive({ active: false }),
399
+ more = mode === 'dock' ? 'All apps' : 'More',
400
+ // Each group's name as its panel edits it, which every place the name shows follows.
401
+ names = new WeakMap<Group, { editing: boolean, saved: boolean, value: string }>(),
402
+ // The bar's group button its panel opened from, which takes focus back as it closes.
403
+ opener: HTMLElement | undefined,
404
+ panel: HTMLElement | undefined,
405
+ // The rail's letter under the pointer, none (-1) once it leaves.
406
+ pointed = signal(-1),
407
+ popup = drawn && overlay.popup({ state, target: surface }),
408
+ // The bar's own box, which it grows from and lands back on.
409
+ resting = { height: 0, radius: 0, width: 0 },
410
+ running = new WeakMap<Button, { running: boolean }>(),
411
+ // The page of buttons the bar shows: the first, and how many fit (none while they all do). 'order' moves with
412
+ // every sort, which can reorder the bar without changing its length.
413
+ scroll = reactive({ count: 0, first: 0, order: 0 }),
414
+ // The frame of a glide to a letter.
415
+ scrolling = 0,
416
+ // A group's panel.
417
+ sheet: HTMLElement | undefined,
418
+ shelf: HTMLElement | undefined,
419
+ // The drawer's buttons.
420
+ stash = drawn ? (apps instanceof ReactiveArray ? apps : new ReactiveArray(apps ?? [])) : undefined,
421
+ // Each drawer button's element, for the keys to find the one above or below it.
422
+ tiles = new WeakMap<Button, HTMLElement>(),
423
+ track: HTMLElement | undefined,
424
+ // The groups a panel has opened into, from the bar's: it shows the last.
425
+ trail = signal<Group[]>([]),
426
+ vertical = direction === 'e' || direction === 'w',
427
+ viewport: HTMLElement | undefined,
428
+ // An alphabetical drawer's letter and place for each of its buttons.
429
+ alphabet = alphabetical && stash ? computed(() => alphabetize(stash)) : undefined,
430
+ // The letters an alphabetical drawer shows any button under, after its search.
431
+ filled = alphabet && computed(() => {
432
+ let letters = new Set<number>(),
433
+ list = shown(),
434
+ places = read(alphabet);
435
+
436
+ for (let i = 0, n = list.length; i < n; i++) {
437
+ letters.add(places.get(list[i])!.letter);
438
+ }
439
+
440
+ return letters;
441
+ });
442
+
443
+ // The button in the next row up or down whose middle is nearest across. Rows are read from the layout, since an
444
+ // alphabetical drawer's headings break them wherever the letter changes. Where there is none, the keys stay put.
445
+ function across(list: Button[], from: number, row: -1 | 1) {
446
+ let origin = tiles.get(list[from])?.getBoundingClientRect();
447
+
448
+ if (!origin) {
449
+ return from;
450
+ }
451
+
452
+ let best = from,
453
+ distance = Infinity,
454
+ middle = origin.left + origin.width / 2,
455
+ nearest = Infinity,
456
+ rects: (DOMRect | undefined)[] = [];
457
+
458
+ for (let i = 0, n = list.length; i < n; i++) {
459
+ let rect = rects[i] = tiles.get(list[i])?.getBoundingClientRect(),
460
+ offset = rect ? (rect.top - origin.top) * row : 0;
461
+
462
+ // A row away, not the same row drawn a pixel off.
463
+ if (offset > 1) {
464
+ nearest = Math.min(nearest, offset);
465
+ }
466
+ }
467
+
468
+ for (let i = 0, n = list.length; i < n; i++) {
469
+ let rect = rects[i];
470
+
471
+ if (!rect || Math.abs((rect.top - origin.top) * row - nearest) > 1) {
472
+ continue;
473
+ }
474
+
475
+ let gap = Math.abs(rect.left + rect.width / 2 - middle);
476
+
477
+ if (gap < distance) {
478
+ best = i;
479
+ distance = gap;
480
+ }
481
+ }
482
+
483
+ return best;
484
+ }
485
+
486
+ // Whether a dragged entry can group with the member an element shows: a button or a group, held over another,
487
+ // and never a group over something inside itself.
488
+ function admits(entry: Entry, element: HTMLElement) {
489
+ let target = (element as Slot)[MEMBER];
490
+
491
+ return movable(entry) && !!target && target !== entry && !(grouped(entry) && contains(entry, target));
492
+ }
493
+
494
+ // Lines an alphabetical drawer's headings and first column of buttons up with the search's magnifier, which the
495
+ // search places once it has measured itself. Skipped while the drawer is out of the layout.
496
+ function align() {
497
+ let glass = field?.parentElement?.querySelector('.group-item--overlay.icon');
498
+
499
+ if (!alphabet || !cells?.offsetWidth || !glass || !panel) {
500
+ return;
501
+ }
502
+
503
+ // Written synchronously, so 'grow()' measures the updated layout.
504
+ panel.style.setProperty('--toolbar-drawer-inset', `${glass.getBoundingClientRect().left - cells.getBoundingClientRect().left}px`);
505
+ }
506
+
507
+ function arrow(step: -1 | 1) {
508
+ return html`
509
+ <button
510
+ aria-label='${step < 0 ? 'Previous' : 'Next'}'
511
+ class='toolbar-arrow'
512
+ type='button'
513
+ ${{
514
+ disabled: () => step < 0 ? scroll.first <= 0 : scroll.first + scroll.count >= entries.$length,
515
+ onclick: () => page(step)
516
+ }}
517
+ >
518
+ ${sprite(chevron, ARROWS[vertical ? 'vertical' : 'horizontal'][step < 0 ? 0 : 1])}
519
+ </button>
520
+ `;
521
+ }
522
+
523
+ // A group's button. On the bar it opens the group's panel; in a panel, it opens the group in the panel's place.
524
+ function bunch(member: Group, nested: boolean) {
525
+ return html`
526
+ <button
527
+ aria-controls='${id}-group'
528
+ aria-haspopup='dialog'
529
+ class='button button--feedback toolbar-button toolbar-button--group'
530
+ type='button'
531
+ ${{
532
+ 'aria-expanded': () => !nested && folder.active && read(trail)[0] === member ? 'true' : 'false',
533
+ 'aria-label': () => `${naming(member).value || 'Group'}, ${member.items.$length} items`,
534
+ onclick: (e: MouseEvent) => {
535
+ reveal(member, e.currentTarget as HTMLElement, nested, e.detail === 0);
536
+ }
537
+ }}
538
+ >
539
+ ${preview(member)}
540
+ </button>
541
+ `;
542
+ }
543
+
544
+ // Back to the bar: the drawer's contents leave and the bar shrinks onto its buttons.
545
+ function collapse() {
546
+ cancelAnimationFrame(frame);
547
+ expanded.active = false;
548
+ land();
549
+ }
550
+
551
+ // Groups a dragged member with the one it was let go on: at a group's end, or with a button, as a new
552
+ // group in the button's place.
553
+ function combine(entry: Entry, element: HTMLElement, items: ReactiveArray<Entry>, from: number, source: ReactiveArray<Entry>) {
554
+ let target = (element as Slot)[MEMBER];
555
+
556
+ if (!target || !movable(entry)) {
557
+ return;
558
+ }
559
+
560
+ if (grouped(target)) {
561
+ target.items.push(entry);
562
+ sorted(entry, from, target.items.length - 1, source, target.items);
563
+ }
564
+ else {
565
+ let made = group({ items: [target, entry] });
566
+
567
+ items.splice(items.indexOf(target), 1, made);
568
+ sorted(entry, from, 1, source, made.items);
569
+ }
570
+
571
+ tidy();
572
+ }
573
+
574
+ // A group's card in its panel: its name, edited in place, over a grid of its members sorted by dragging.
575
+ function contents(current: Group) {
576
+ let list = sortable(current.items, (member, attributes) => html`
577
+ <div
578
+ class='toolbar-app'
579
+ ${attributes}
580
+ ${{
581
+ onclick: relay,
582
+ onconnect: (element: Slot) => {
583
+ element[MEMBER] = member;
584
+ }
585
+ }}
586
+ >
587
+ ${grouped(member) ? bunch(member, true) : control(member)}
588
+ <span class='toolbar-app-label'>${() => grouped(member) ? naming(member).value : text(member.label)}</span>
589
+ </div>
590
+ `, { combine: combining as SortableCombine<Member> | undefined, drag: tile, group: id, onland: landed, onlift: lifted, onsort: sorted, onthrow: stash ? thrown : undefined });
591
+
592
+ return html`
593
+ <div class='toolbar-group-header'>
594
+ ${inlineEdit({
595
+ class: 'toolbar-group-name',
596
+ label: 'Group name',
597
+ onsave: (value: string) => {
598
+ current.label = value;
599
+ onrename?.(current, value);
600
+ },
601
+ placeholder: 'Name',
602
+ state: naming(current)
603
+ })}
604
+ </div>
605
+ <div
606
+ class='toolbar-group-apps'
607
+ ${list.attributes}
608
+ ${{ style: () => `--columns: ${Math.min(Math.max(current.items.$length, 2), 4)};` }}
609
+ >
610
+ ${list.render()}
611
+ </div>
612
+ `;
613
+ }
614
+
615
+ // A button in the bar or the drawer: the consumer's attributes, and in a dock, its launch and running state.
616
+ function control(item: Button) {
617
+ let app = status(item),
618
+ local = motion(item);
619
+
620
+ return html`
621
+ <button
622
+ class='button button--feedback toolbar-button'
623
+ type='button'
624
+ ${face(item)}
625
+ ${item.attributes}
626
+ ${{
627
+ 'aria-label': () => dock && app.running ? `${text(item.label)}, running` : text(item.label),
628
+ class: () => local.launching && 'toolbar-button--launching',
629
+ onanimationend: () => {
630
+ local.launching = false;
631
+ },
632
+ onclick: (e: MouseEvent) => {
633
+ item.onclick?.(e);
634
+ open(item);
635
+ }
636
+ }}
637
+ >
638
+ ${glyph(item)}
639
+ </button>
640
+ `;
641
+ }
642
+
643
+ function custom(entry: Custom) {
644
+ let hint = entry.hint ?? entry.label;
645
+
646
+ return html`
647
+ <div
648
+ class='toolbar-custom ${hint !== undefined && 'toolbar-custom--hinted'}'
649
+ ${{
650
+ class: () => hidden(entry) && 'toolbar-custom--hidden',
651
+ onconnect: (element: Slot) => {
652
+ if (hint !== undefined) {
653
+ element[LABEL] = hint;
654
+ }
655
+ }
656
+ }}
657
+ >
658
+ ${entry.render()}
659
+ </div>
660
+ `;
661
+ }
662
+
663
+ function divide(entry: Divider) {
664
+ return html`<span aria-hidden='true' class='toolbar-divider ${() => hidden(entry) && 'toolbar-divider--hidden'}'></span>`;
665
+ }
666
+
667
+ // The drawer's slot: buttons sort around it, but it isn't dragged itself.
668
+ function door() {
669
+ return html`
670
+ <div
671
+ class='toolbar-item'
672
+ ${{
673
+ class: () => hidden(TOOLBAR_DRAWER) && 'toolbar-item--hidden',
674
+ onconnect: (element: Slot) => {
675
+ element[LABEL] = more;
676
+ }
677
+ }}
678
+ >
679
+ <button
680
+ aria-controls='${id}-drawer'
681
+ aria-haspopup='dialog'
682
+ aria-label='${more}'
683
+ class='button button--feedback toolbar-button'
684
+ type='button'
685
+ ${{
686
+ 'aria-expanded': () => state.active ? 'true' : 'false',
687
+ onclick: () => {
688
+ state.active = !state.active;
689
+ }
690
+ }}
691
+ >
692
+ ${sprite(grid)}
693
+ </button>
694
+ </div>
695
+ `;
696
+ }
697
+
698
+ // Beside the bar, centred on it, laid out as the command palette is: the search and the buttons in an inset card,
699
+ // and the keys that drive them on the frame around it. The buttons sort into the bar and back.
700
+ function drawer(apps: ReactiveArray<Button>) {
701
+ // The button the keys rest on, so a step only reaches the two buttons it moves between.
702
+ let current = signal<Button | undefined>(undefined),
703
+ // Without a search, the drawer itself takes focus and the keys. Kept out of the literal below, which
704
+ // compiles each handler to a listener even when unset.
705
+ keys: Attributes = search ? {} : { onkeydown: navigate, tabindex: '-1' },
706
+ library = sortable(apps, (item, attributes) => html`
707
+ <div
708
+ class='toolbar-app'
709
+ ${sorting ? attributes : {}}
710
+ ${{
711
+ class: [() => !matches(item) && 'toolbar-app--hidden', () => signal.selector(current, item) && '--active'],
712
+ onclick: relay,
713
+ onconnect: (element: HTMLElement) => {
714
+ tiles.set(item, element);
715
+ },
716
+ style: () => {
717
+ // Unset for the moment a button dragged out of the drawer still shows there.
718
+ let at = alphabet && read(alphabet).get(item);
719
+
720
+ return at && `--toolbar-order: ${place(at.letter, at.rank)};`;
721
+ }
722
+ }}
723
+ >
724
+ ${control(item)}
725
+ <span class='toolbar-app-label'>${item.label}</span>
726
+ </div>
727
+ `, {
728
+ drag: tile,
729
+ group: id,
730
+ onland: () => {
731
+ lift(false);
732
+ tidy();
733
+ },
734
+ onlift: () => lift(true),
735
+ onsort: sorted
736
+ });
737
+
738
+ effect(() => {
739
+ write(current, shown()[selected()]);
740
+ });
741
+
742
+ // Every opening starts afresh, on all the buttons, with the keys going to the drawer, and grows the bar into
743
+ // it; every close shrinks it back.
744
+ effect(() => state.active, (open) => {
745
+ if (!open) {
746
+ write(pointed, -1);
747
+ collapse();
748
+ return;
749
+ }
750
+
751
+ launch.index = -1;
752
+ launch.query = '';
753
+ shut();
754
+ expand();
755
+ });
756
+
757
+ return html`
758
+ <div
759
+ aria-label='${more}'
760
+ class='tooltip-content toolbar-drawer ${alphabet && 'toolbar-drawer--alphabetical'}'
761
+ id='${id}-drawer'
762
+ role='dialog'
763
+ ${keys}
764
+ ${{
765
+ // Followed while open, so a search that changes its rows resizes the bar around them.
766
+ onconnect: (element: HTMLElement) => {
767
+ let resize = observer(() => {
768
+ align();
769
+
770
+ if (expanded.active) {
771
+ grow();
772
+ }
773
+ });
774
+
775
+ panel = element;
776
+ resize.observe(element);
777
+ onCleanup(resize.disconnect);
778
+ },
779
+ onmousedown: keep
780
+ }}
781
+ >
782
+ <div class='toolbar-drawer-body'>
783
+ ${search && html`
784
+ <div class='toolbar-drawer-search'>
785
+ ${searchbox.input({
786
+ class: 'input--border toolbar-drawer-input',
787
+ oninput: (e: Event) => {
788
+ launch.index = -1;
789
+ launch.query = (e.target as HTMLInputElement).value;
790
+ },
791
+ onconnect: (element: HTMLInputElement) => {
792
+ field = element;
793
+ },
794
+ onkeydown: navigate,
795
+ spellcheck: false,
796
+ value: () => launch.query
797
+ })}
798
+ </div>
799
+ `}
800
+
801
+ <div class='toolbar-drawer-main'>
802
+ <div class='toolbar-drawer-view' ${scrollbar({ fade: true })}>
803
+ <div
804
+ class='toolbar-drawer-apps'
805
+ ${sorting && library.attributes}
806
+ ${{
807
+ onconnect: (element: HTMLElement) => {
808
+ cells = element;
809
+ },
810
+ // Taking the scroll back from a glide still under way.
811
+ onwheel: () => {
812
+ cancelAnimationFrame(scrolling);
813
+ }
814
+ }}
815
+ >
816
+ ${library.render()}
817
+ ${filled && LETTERS.map((letter, index) => html`
818
+ <div
819
+ aria-hidden='true'
820
+ class='toolbar-drawer-heading'
821
+ ${{
822
+ class: () => !read(filled).has(index) && 'toolbar-drawer-heading--hidden',
823
+ onconnect: (element: HTMLElement) => {
824
+ headings[index] = element;
825
+ },
826
+ style: () => `--toolbar-order: ${place(index)};`
827
+ }}
828
+ >
829
+ ${letter}
830
+ </div>
831
+ `)}
832
+ </div>
833
+ ${() => !shown().length && html`
834
+ <p class='toolbar-drawer-empty' role='status'>${launch.query.trim() ? 'No results' : 'Nothing here'}</p>
835
+ `}
836
+ </div>
837
+ ${filled && rail(filled)}
838
+ </div>
839
+ </div>
840
+
841
+ <div aria-hidden='true' class='toolbar-drawer-footer'>
842
+ ${hint(['esc'], 'Close')}
843
+ ${hint(['icon--left', '', 'icon--up', 'icon--down'].map((direction) => sprite(arrowSvg, `toolbar-drawer-kbd-icon ${direction}`)), 'Navigate')}
844
+ ${hint([sprite(enter, 'toolbar-drawer-kbd-icon')], 'Open')}
845
+ </div>
846
+ </div>
847
+ `;
848
+ }
849
+
850
+ // Grows the bar from its own box to the drawer's. Pinned at its own size first, which changes nothing on screen,
851
+ // so the growth has a length to start from; the popup has put focus back where it was by the time it grows.
852
+ function expand() {
853
+ cancelAnimationFrame(frame);
854
+
855
+ if (!fit.sized) {
856
+ hold();
857
+ Object.assign(fit, resting, { sized: true });
858
+ }
859
+
860
+ queueMicrotask(() => {
861
+ shelf?.getBoundingClientRect();
862
+
863
+ frame = requestAnimationFrame(() => {
864
+ expanded.active = true;
865
+ fit.morphing = true;
866
+ align();
867
+ grow();
868
+ (field ?? panel)?.focus({ preventScroll: true });
869
+ });
870
+ });
871
+ }
872
+
873
+ // Scrolls the drawer to a letter's heading, or with nothing under it, to the nearest letter after it that has
874
+ // anything (before it, past the last). Eased, and retargeted from wherever a glide already under way has got to.
875
+ function glide(letter: number, letters: Set<number>) {
876
+ let target = -1;
877
+
878
+ for (let i = letter, n = LETTERS.length; i < n && target === -1; i++) {
879
+ if (letters.has(i)) {
880
+ target = i;
881
+ }
882
+ }
883
+
884
+ for (let i = letter - 1; i >= 0 && target === -1; i--) {
885
+ if (letters.has(i)) {
886
+ target = i;
887
+ }
888
+ }
889
+
890
+ let heading = headings[target],
891
+ view = cells?.parentElement;
892
+
893
+ if (!cells || !heading || !view) {
894
+ return;
895
+ }
896
+
897
+ // The heading where the first one rests, at the top of the grid's padding.
898
+ let duration = matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : GLIDE,
899
+ from = view.scrollTop,
900
+ start = performance.now(),
901
+ to = Math.max(0, Math.min(
902
+ heading.getBoundingClientRect().top - view.getBoundingClientRect().top + from - (parseFloat(getComputedStyle(cells).paddingTop) || 0),
903
+ view.scrollHeight - view.clientHeight
904
+ ));
905
+
906
+ let tick = (now: number) => {
907
+ let progress = duration ? Math.min((now - start) / duration, 1) : 1;
908
+
909
+ view.scrollTop = from + (to - from) * (1 - (1 - progress) ** 3);
910
+
911
+ if (progress < 1) {
912
+ scrolling = requestAnimationFrame(tick);
913
+ }
914
+ };
915
+
916
+ cancelAnimationFrame(scrolling);
917
+ tick(start);
918
+ }
919
+
920
+ // The drawer's size, which the bar grows to; layout lengths, so a scaled ancestor doesn't skew them.
921
+ function grow() {
922
+ if (!panel) {
923
+ return;
924
+ }
925
+
926
+ fit.height = panel.offsetHeight;
927
+ fit.radius = parseFloat(getComputedStyle(panel).borderTopLeftRadius) || 0;
928
+ fit.width = panel.offsetWidth;
929
+ }
930
+
931
+ // Off the bar's current page; hidden outright, so the page's own buttons lay out as if they were all there is.
932
+ function hidden(entry: Entry) {
933
+ if (!scroll.count) {
934
+ return false;
935
+ }
936
+
937
+ entries.$length;
938
+ scroll.order;
939
+
940
+ let index = entries.indexOf(entry);
941
+
942
+ return index < scroll.first || index >= scroll.first + scroll.count;
943
+ }
944
+
945
+ // The bar's own box. Its rounding is held to half its height, so a pill's '999px' eases into the drawer's corners
946
+ // rather than holding the stadium shape until the end.
947
+ function hold() {
948
+ if (!shelf) {
949
+ return;
950
+ }
951
+
952
+ resting = {
953
+ height: shelf.offsetHeight,
954
+ radius: Math.min(parseFloat(getComputedStyle(shelf).borderTopLeftRadius) || 0, shelf.offsetHeight / 2, shelf.offsetWidth / 2),
955
+ width: shelf.offsetWidth
956
+ };
957
+ }
958
+
959
+ // Back to the bar's box, released once there so it sizes itself again. Closed before it grew, or with no morph to
960
+ // run (reduced motion), no transition ends to say so, so it lets go at once.
961
+ function land() {
962
+ if (!fit.sized) {
963
+ return;
964
+ }
965
+
966
+ if (
967
+ (fit.height === resting.height && fit.width === resting.width) ||
968
+ !shelf ||
969
+ !parseFloat(getComputedStyle(shelf).getPropertyValue('--morph-duration'))
970
+ ) {
971
+ release();
972
+ return;
973
+ }
974
+
975
+ Object.assign(fit, resting);
976
+ }
977
+
978
+ // A button carried out of a group's panel has landed. Let go off every list without a drawer to go back to, it
979
+ // landed back in the group, which opens again to show it.
980
+ function landed(member: Member) {
981
+ let path = read(trail);
982
+
983
+ removeEventListener('pointermove', stray);
984
+ tidy();
985
+
986
+ if (!folder.active && path.length && path[path.length - 1].items.includes(member)) {
987
+ folder.active = true;
988
+ }
989
+ }
990
+
991
+ // Dragging a button out of the drawer shows the bar to drop it in; once it has landed, wherever that is, the bar
992
+ // grows back into the drawer if it is still open.
993
+ function lift(active: boolean) {
994
+ if (active) {
995
+ collapse();
996
+ }
997
+ else if (state.active) {
998
+ expand();
999
+ }
1000
+ }
1001
+
1002
+ // Lifted out of a group's panel: the panel closes once the pointer carries it away. Listened for only while it is
1003
+ // carried, rather than bound for the bar's whole life, since it runs on every move.
1004
+ function lifted() {
1005
+ addEventListener('pointermove', stray);
1006
+ }
1007
+
1008
+ function matches(item: Button) {
1009
+ // A group dropped in the drawer is spread out as it lands.
1010
+ if (grouped(item)) {
1011
+ return true;
1012
+ }
1013
+
1014
+ let query = launch.query.trim().toLowerCase();
1015
+
1016
+ return !query || text(item.label).toLowerCase().includes(query);
1017
+ }
1018
+
1019
+ // Whether the buttons outgrow the bar, and if so how many whole ones a page holds. Read with every button shown,
1020
+ // at the length the bar gives them, which only the consumer's layout knows. Only the resize observer calls this,
1021
+ // outside any reactivity pass, so the flushes land the shown and hidden buttons around the reads, within one layout.
1022
+ function measure() {
1023
+ if (!arrows || !track || !viewport) {
1024
+ return;
1025
+ }
1026
+
1027
+ measuring.active = true;
1028
+ flush();
1029
+
1030
+ let gap = parseFloat(getComputedStyle(track)[vertical ? 'rowGap' : 'columnGap']) || 0,
1031
+ length: 'offsetHeight' | 'offsetWidth' = vertical ? 'offsetHeight' : 'offsetWidth',
1032
+ pitch = rest(length) + gap,
1033
+ room = vertical ? viewport.clientHeight : viewport.clientWidth,
1034
+ span = track[length];
1035
+
1036
+ measuring.active = false;
1037
+ flush();
1038
+
1039
+ if (span <= room) {
1040
+ scroll.count = 0;
1041
+ scroll.first = 0;
1042
+ return;
1043
+ }
1044
+
1045
+ // The last button on a page needs no gap after it.
1046
+ scroll.count = Math.max(1, Math.floor((room + gap) / pitch));
1047
+ scroll.first = Math.max(0, Math.min(scroll.first, entries.length - scroll.count));
1048
+ }
1049
+
1050
+ function motion(item: Button) {
1051
+ let current = launching.get(item);
1052
+
1053
+ if (!current) {
1054
+ current = reactive({ launching: false });
1055
+ launching.set(item, current);
1056
+ }
1057
+
1058
+ return current;
1059
+ }
1060
+
1061
+ // A group's name as its panel's inline edit holds it, kept per group: the edit's own state, so the bar, the trail
1062
+ // and the hover label follow it as it changes. Unnamed, it is ''.
1063
+ function naming(member: Group) {
1064
+ let current = names.get(member);
1065
+
1066
+ if (!current) {
1067
+ current = reactive({ editing: false, saved: false, value: member.label ? text(member.label) : '' });
1068
+ names.set(member, current);
1069
+ }
1070
+
1071
+ return current;
1072
+ }
1073
+
1074
+ // The first arrow picks the first button, later ones step through the shown buttons as the grid lays them out;
1075
+ // Enter presses the one they rest on, or the first shown before any is picked.
1076
+ function navigate(e: KeyboardEvent) {
1077
+ if (e.isComposing) {
1078
+ return;
1079
+ }
1080
+
1081
+ let list = shown(),
1082
+ row = ({ ArrowDown: 1, ArrowUp: -1 } as Record<string, -1 | 1>)[e.key],
1083
+ step = ({ ArrowLeft: -1, ArrowRight: 1 } as Record<string, number>)[e.key];
1084
+
1085
+ if (row || step) {
1086
+ e.preventDefault();
1087
+
1088
+ if (list.length) {
1089
+ launch.index = launch.index < 0
1090
+ ? 0
1091
+ : row ? across(list, selected(), row) : Math.min(Math.max(selected() + step, 0), list.length - 1);
1092
+
1093
+ // Scrolling needs the element, which the rendered '--active' marks once the step has landed.
1094
+ requestAnimationFrame(() => {
1095
+ cells?.querySelector('.toolbar-app.--active')?.scrollIntoView({ block: 'nearest' });
1096
+ });
1097
+ }
1098
+ }
1099
+ else if (e.key === 'Enter') {
1100
+ e.preventDefault();
1101
+
1102
+ // Clicked rather than opened, so the consumer's own handlers on the button run as a click's would.
1103
+ (cells?.querySelector('.toolbar-app.--active > .toolbar-button') ?? cells?.querySelector('.toolbar-app:not(.toolbar-app--hidden) > .toolbar-button'))
1104
+ ?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
1105
+ }
1106
+ }
1107
+
1108
+ // Pressing a button closes the drawer and any group's panel; in a dock, it also launches the app.
1109
+ function open(item: Button) {
1110
+ state.active = false;
1111
+ shut();
1112
+
1113
+ if (!dock) {
1114
+ return;
1115
+ }
1116
+
1117
+ let app = status(item);
1118
+
1119
+ // Already running: a click just brings it forward, no fanfare.
1120
+ if (app.running) {
1121
+ return;
1122
+ }
1123
+
1124
+ app.running = true;
1125
+ motion(item).launching = true;
1126
+ onlaunch?.(text(item.label));
1127
+ }
1128
+
1129
+ function page(step: -1 | 1) {
1130
+ scroll.first = Math.max(0, Math.min(scroll.first + step * scroll.count, entries.length - scroll.count));
1131
+ }
1132
+
1133
+ // A group's panel, beside the bar over the group's slot. Opened into a group inside, the groups on the way there
1134
+ // list above it as a menu panel under its sub-panel, the nearest last, each row going back to its group when
1135
+ // pressed. It stays in the page while closed, since a button carried out of it is still its to land, and closes on
1136
+ // a press anywhere off the bar, or Escape.
1137
+ function pane() {
1138
+ return html`
1139
+ <div
1140
+ class='toolbar-group'
1141
+ id='${id}-group'
1142
+ role='dialog'
1143
+ ${{
1144
+ 'aria-label': () => {
1145
+ let path = read(trail),
1146
+ current = path[path.length - 1];
1147
+
1148
+ return (current && naming(current).value) || 'Group';
1149
+ },
1150
+ class: () => folder.active && '--active',
1151
+ inert: () => !folder.active,
1152
+ onconnect: (element: HTMLElement) => {
1153
+ sheet = element;
1154
+ },
1155
+ ondocumentkeydown: (e: KeyboardEvent) => {
1156
+ if (e.key === 'Escape' && folder.active && !e.defaultPrevented) {
1157
+ e.preventDefault();
1158
+ shut(true);
1159
+ }
1160
+ },
1161
+ ondocumentpointerdown: (e: PointerEvent) => {
1162
+ if (folder.active && !shelf?.contains(e.target as Node | null)) {
1163
+ shut();
1164
+ }
1165
+ },
1166
+ style: () => `--group-x: ${folder.x}px; --group-y: ${folder.y}px;`
1167
+ }}
1168
+ >
1169
+ ${() => {
1170
+ let path = read(trail);
1171
+
1172
+ if (path.length < 2) {
1173
+ return '';
1174
+ }
1175
+
1176
+ return html`
1177
+ <div class='toolbar-group-trail'>
1178
+ ${path.slice(0, -1).map((member, index) => html`
1179
+ <button
1180
+ class='toolbar-group-trail-item'
1181
+ type='button'
1182
+ ${{
1183
+ 'aria-label': () => `Back to ${naming(member).value || 'Group'}`,
1184
+ onclick: () => {
1185
+ write(trail, path.slice(0, index + 1));
1186
+ }
1187
+ }}
1188
+ >
1189
+ <span class='toolbar-group-trail-name'>${() => naming(member).value || 'Group'}</span>
1190
+ </button>
1191
+ `)}
1192
+ </div>
1193
+ `;
1194
+ }}
1195
+ <div class='toolbar-group-card ${() => read(trail).length > 1 && 'toolbar-group-card--nested'}'>
1196
+ ${() => {
1197
+ let path = read(trail),
1198
+ current = path[path.length - 1];
1199
+
1200
+ return current && contents(current);
1201
+ }}
1202
+ </div>
1203
+ </div>
1204
+ `;
1205
+ }
1206
+
1207
+ // Where a heading, or a button under it, falls in an alphabetical drawer: each letter's heading, then its buttons
1208
+ // in order. Laid out by CSS 'order', so the drawer's own order stays the consumer's.
1209
+ function place(letter: number, rank = -1) {
1210
+ return letter * ((stash?.$length ?? 0) + 1) + rank + 1;
1211
+ }
1212
+
1213
+ // Groups down to one member give way to it, in their place, and empty ones go, deepest first.
1214
+ function prune<T>(items: ReactiveArray<T>) {
1215
+ for (let i = items.length - 1; i >= 0; i--) {
1216
+ let entry = items[i];
1217
+
1218
+ if (!grouped(entry)) {
1219
+ continue;
1220
+ }
1221
+
1222
+ prune(entry.items);
1223
+
1224
+ if (entry.items.length > 1) {
1225
+ continue;
1226
+ }
1227
+
1228
+ items.splice(i, 1);
1229
+
1230
+ if (entry.items.length) {
1231
+ let only = entry.items[0];
1232
+
1233
+ entry.items.splice(0, 1);
1234
+ items.splice(i, 0, only as T);
1235
+ sorted(only, 0, i, entry.items, items);
1236
+ }
1237
+ }
1238
+ }
1239
+
1240
+ // The letters beside an alphabetical drawer. The pointer's letter is read from where it falls along the rail, which
1241
+ // the letters share evenly, so a touch dragged along it scrubs as a mouse does, and their swell moves none of them.
1242
+ // Hidden from assistive tech, which has the search to find a button by name.
1243
+ function rail(letters: NonNullable<typeof filled>) {
1244
+ let element: HTMLElement | undefined;
1245
+
1246
+ function leave() {
1247
+ write(pointed, -1);
1248
+ }
1249
+
1250
+ function point(e: PointerEvent) {
1251
+ let first = element?.firstElementChild,
1252
+ last = element?.lastElementChild;
1253
+
1254
+ if (!first || !last) {
1255
+ return;
1256
+ }
1257
+
1258
+ // From the first letter's top to the last's bottom, inside the rail's padding.
1259
+ let top = first.getBoundingClientRect().top,
1260
+ height = last.getBoundingClientRect().bottom - top,
1261
+ letter = Math.max(0, Math.min(Math.floor((e.clientY - top) / height * LETTERS.length), LETTERS.length - 1));
1262
+
1263
+ if (letter === read(pointed)) {
1264
+ return;
1265
+ }
1266
+
1267
+ write(pointed, letter);
1268
+ glide(letter, read(letters));
1269
+ }
1270
+
1271
+ return html`
1272
+ <div
1273
+ aria-hidden='true'
1274
+ class='toolbar-rail'
1275
+ ${{
1276
+ onconnect: (connected: HTMLElement) => {
1277
+ element = connected;
1278
+ },
1279
+ onpointercancel: leave,
1280
+ onpointerdown: (e: PointerEvent) => {
1281
+ // Held by a touch, which would otherwise leave it at the first letter it crosses.
1282
+ if (e.pointerType !== 'mouse') {
1283
+ element?.setPointerCapture(e.pointerId);
1284
+ }
1285
+
1286
+ point(e);
1287
+ },
1288
+ onpointerleave: leave,
1289
+ onpointermove: point,
1290
+ onpointerup: (e: PointerEvent) => {
1291
+ if (e.pointerType !== 'mouse') {
1292
+ leave();
1293
+ }
1294
+ }
1295
+ }}
1296
+ >
1297
+ ${LETTERS.map((letter, index) => html`
1298
+ <span
1299
+ class='toolbar-rail-letter'
1300
+ ${{ class: [() => !read(letters).has(index) && 'toolbar-rail-letter--empty', () => signal.selector(pointed, index) && '--active'] }}
1301
+ >
1302
+ ${letter}
1303
+ </span>
1304
+ `)}
1305
+ </div>
1306
+ `;
1307
+ }
1308
+
1309
+ // The bar sizes itself again.
1310
+ function release() {
1311
+ fit.morphing = false;
1312
+ fit.sized = false;
1313
+ }
1314
+
1315
+ // A button's length along the bar: the shortest, so a page never holds more than fit. Dividers aren't buttons.
1316
+ function rest(length: 'offsetHeight' | 'offsetWidth') {
1317
+ let children = track?.children ?? [],
1318
+ min = Infinity;
1319
+
1320
+ for (let i = 0, n = children.length; i < n; i++) {
1321
+ if (children[i].classList.contains('toolbar-item')) {
1322
+ min = Math.min(min, (children[i] as HTMLElement)[length] || Infinity);
1323
+ }
1324
+ }
1325
+
1326
+ return min === Infinity ? 1 : min;
1327
+ }
1328
+
1329
+ // Opens a group's panel. From the bar it opens over the group's slot, and closes again on a second press; from a
1330
+ // panel, the group opens in the panel's place, with a way back. Opened by the keys, they move into it.
1331
+ function reveal(member: Group, button: HTMLElement, nested: boolean, keyed: boolean) {
1332
+ if (nested) {
1333
+ write(trail, [...read(trail), member]);
1334
+ }
1335
+ else if (folder.active && read(trail)[0] === member) {
1336
+ shut();
1337
+ return;
1338
+ }
1339
+ else if (shelf) {
1340
+ let bar = shelf.getBoundingClientRect(),
1341
+ slot = (button.closest('.toolbar-item') ?? button).getBoundingClientRect();
1342
+
1343
+ state.active = false;
1344
+ opener = button;
1345
+ folder.x = slot.left + slot.width / 2 - bar.left;
1346
+ folder.y = slot.top + slot.height / 2 - bar.top;
1347
+ write(trail, [member]);
1348
+ folder.active = true;
1349
+ }
1350
+
1351
+ if (keyed) {
1352
+ requestAnimationFrame(() => {
1353
+ sheet?.querySelector<HTMLElement>('.toolbar-app > .toolbar-button')?.focus();
1354
+ });
1355
+ }
1356
+ }
1357
+
1358
+ // The ARIA toolbar's one tab stop, on 'current' or else the first control, every other control out of the tab
1359
+ // order. Kept on the elements themselves, since a custom item's control is the consumer's to render.
1360
+ function rove(current?: Element | null) {
1361
+ let list = roving();
1362
+
1363
+ for (let i = 0, n = list.length; i < n; i++) {
1364
+ list[i].tabIndex = list[i] === (current && list.includes(current as HTMLElement) ? current : list[0]) ? 0 : -1;
1365
+ }
1366
+ }
1367
+
1368
+ // The controls the arrow keys reach, in the bar's order: each button, and each custom item's own control; none
1369
+ // hidden, off the page or disabled. Read from the bar's own state rather than layout, so a bar not yet shown (in a
1370
+ // closed popover, say) already has its tab stop.
1371
+ function roving() {
1372
+ let children = track?.children ?? [],
1373
+ list: HTMLElement[] = [];
1374
+
1375
+ for (let i = 0, n = children.length; i < n; i++) {
1376
+ let child = children[i],
1377
+ control = child.classList.contains('toolbar-item')
1378
+ ? child.querySelector<HTMLElement>(':scope > .toolbar-button')
1379
+ : child.classList.contains('toolbar-custom') ? child.querySelector<HTMLElement>(FOCUSABLE) : null;
1380
+
1381
+ if (control && !control.closest('[hidden], .toolbar-custom--hidden, .toolbar-item--hidden') && !control.matches(':disabled')) {
1382
+ list.push(control);
1383
+ }
1384
+ }
1385
+
1386
+ return list;
1387
+ }
1388
+
1389
+ function selected() {
1390
+ return launch.index < 0 ? -1 : Math.min(launch.index, shown().length - 1);
1391
+ }
1392
+
1393
+ function shown() {
1394
+ if (!stash) {
1395
+ return [];
1396
+ }
1397
+
1398
+ stash.$length;
1399
+
1400
+ let list = stash.filter(matches);
1401
+
1402
+ if (alphabet) {
1403
+ let places = read(alphabet);
1404
+
1405
+ list.sort((a, b) => places.get(a)!.rank - places.get(b)!.rank);
1406
+ }
1407
+
1408
+ return list;
1409
+ }
1410
+
1411
+ // Closes a group's panel; closed by the keys, focus goes back to the group's button on the bar.
1412
+ function shut(restore = false) {
1413
+ if (!folder.active) {
1414
+ return;
1415
+ }
1416
+
1417
+ folder.active = false;
1418
+
1419
+ if (restore && sheet?.contains(document.activeElement)) {
1420
+ opener?.focus();
1421
+ }
1422
+ }
1423
+
1424
+ // Dividers, custom items and the drawer's button sort with the rest, but only buttons and groups are dragged.
1425
+ function slot(entry: Entry, attributes: Attributes) {
1426
+ if (entry === TOOLBAR_DRAWER) {
1427
+ return door();
1428
+ }
1429
+
1430
+ if (DIVIDER in entry) {
1431
+ return divide(entry);
1432
+ }
1433
+
1434
+ if (CUSTOM in entry) {
1435
+ return custom(entry);
1436
+ }
1437
+
1438
+ // A group is named by its panel, as it is edited; unnamed, it has no hover label.
1439
+ let named = grouped(entry) ? () => naming(entry).value : undefined;
1440
+
1441
+ return html`
1442
+ <div
1443
+ class='toolbar-item'
1444
+ ${sorting ? attributes : {}}
1445
+ ${{
1446
+ class: [() => hidden(entry) && 'toolbar-item--hidden', () => named && !named() && 'toolbar-item--quiet'],
1447
+ onclick: relay,
1448
+ onconnect: (element: Slot) => {
1449
+ element[LABEL] = named ?? (grouped(entry) ? '' : entry.hint ?? entry.label);
1450
+ element[MEMBER] = entry;
1451
+ }
1452
+ }}
1453
+ >
1454
+ ${grouped(entry) ? bunch(entry, false) : control(entry)}
1455
+ ${labels && html`<span class='toolbar-item-label'>${named ?? entry.label}</span>`}
1456
+ ${dock && !grouped(entry) && html`<span aria-hidden='true' class='toolbar-light ${() => status(entry).running && '--active'}'></span>`}
1457
+ </div>
1458
+ `;
1459
+ }
1460
+
1461
+ // Shared by the bar's list, the drawer's and the groups', whose arrays trade entries; either end of a move can be
1462
+ // any of them.
1463
+ function sorted<S, T>(item: Entry, from: number, to: number, source: ReactiveArray<S>, target: ReactiveArray<T>) {
1464
+ scroll.order++;
1465
+ onsort?.(item, from, to, source as unknown as ReactiveArray<Entry>, target as unknown as ReactiveArray<Entry>);
1466
+ }
1467
+
1468
+ function status(item: Button) {
1469
+ let current = running.get(item);
1470
+
1471
+ if (!current) {
1472
+ current = item.state ?? reactive({ running: item.running ?? false });
1473
+ running.set(item, current);
1474
+ }
1475
+
1476
+ return current;
1477
+ }
1478
+
1479
+ // Steps between controls, leaving the keys alone in a field, where they move the caret.
1480
+ function step(e: KeyboardEvent) {
1481
+ let target = e.target as HTMLElement;
1482
+
1483
+ if (e.defaultPrevented || target.matches('input, textarea, [contenteditable]')) {
1484
+ return;
1485
+ }
1486
+
1487
+ let list = roving(),
1488
+ at = list.indexOf(target),
1489
+ move = ROVE[vertical ? 'vertical' : 'horizontal'][e.key],
1490
+ next = e.key === 'Home' ? list[0] : e.key === 'End' ? list[list.length - 1] : move && at !== -1 ? list[(at + move + list.length) % list.length] : null;
1491
+
1492
+ if (!next) {
1493
+ return;
1494
+ }
1495
+
1496
+ e.preventDefault();
1497
+ rove(next);
1498
+ next.focus();
1499
+ }
1500
+
1501
+ // Carrying a button out of a group's panel closes the panel once the pointer is clear of it, leaving the bar free
1502
+ // to drop on.
1503
+ function stray(e: PointerEvent) {
1504
+ let box = sheet?.getBoundingClientRect();
1505
+
1506
+ if (box && (e.clientX < box.left - SLACK || e.clientX > box.right + SLACK || e.clientY < box.top - SLACK || e.clientY > box.bottom + SLACK)) {
1507
+ removeEventListener('pointermove', stray);
1508
+ shut();
1509
+ }
1510
+ }
1511
+
1512
+ // Thrown off the bar or out of a group's panel, a button goes back to the drawer, at its end; a group spreads its
1513
+ // buttons there.
1514
+ function thrown<T>(item: Entry, from: number, list: ReactiveArray<T>) {
1515
+ if (!stash || !movable(item)) {
1516
+ return;
1517
+ }
1518
+
1519
+ let spread = buttons(item);
1520
+
1521
+ for (let i = 0, n = spread.length; i < n; i++) {
1522
+ stash.push(spread[i]);
1523
+ }
1524
+
1525
+ sorted(item, from, stash.length - 1, list, stash);
1526
+ tidy();
1527
+ }
1528
+
1529
+ // After every move: a group down to one member gives way to it, the drawer spreads out any group dropped in it,
1530
+ // since it only holds buttons, and a panel whose group has gone falls back to what remains of its way in.
1531
+ function tidy() {
1532
+ prune(entries);
1533
+
1534
+ if (stash) {
1535
+ for (let i = stash.length - 1; i >= 0; i--) {
1536
+ let item: Member = stash[i];
1537
+
1538
+ if (grouped(item)) {
1539
+ stash.splice(i, 1, ...buttons(item));
1540
+ }
1541
+ }
1542
+ }
1543
+
1544
+ let kept = 0,
1545
+ path = read(trail);
1546
+
1547
+ while (kept < path.length && (kept === 0 ? entries : path[kept - 1].items).includes(path[kept])) {
1548
+ kept++;
1549
+ }
1550
+
1551
+ if (kept === path.length) {
1552
+ return;
1553
+ }
1554
+
1555
+ write(trail, path.slice(0, kept));
1556
+
1557
+ if (!kept) {
1558
+ shut();
1559
+ }
1560
+ }
1561
+
1562
+ if (!stash && marker !== -1) {
1563
+ entries.splice(marker, 1);
1564
+ }
1565
+ else if (stash && marker === -1) {
1566
+ entries.push(TOOLBAR_DRAWER);
1567
+ }
1568
+
1569
+ // One label glides between the buttons; hidden from assistive tech, since each button is already named by it. Only
1570
+ // buttons and groups are dragged, so 'copy' only ever gets one, and only those are ever thrown back to the drawer.
1571
+ // Dragging a group whose panel shows closes the panel, which could otherwise take the group into itself.
1572
+ let combining: SortableCombine<Entry> | undefined = gathering ? { accepts: admits, oncombine: combine } : undefined,
1573
+ list = sortable(entries, slot, {
1574
+ combine: combining,
1575
+ drag: copy as (item: Entry) => Renderable<unknown>,
1576
+ group: id,
1577
+ onland: tidy,
1578
+ onlift: (entry) => {
1579
+ if (grouped(entry) && read(trail).includes(entry)) {
1580
+ shut();
1581
+ }
1582
+ },
1583
+ onsort: sorted,
1584
+ onthrow: sorting && stash ? thrown : undefined
1585
+ }),
1586
+ tip = tooltip.shared({ 'aria-hidden': 'true', axis: vertical ? 'x' : 'y', class: 'toolbar-label', delay: { open: delay }, swap: false });
1587
+
1588
+ // A toolbar takes one tab stop, kept on a control the bar still shows as its items change.
1589
+ if (!dock) {
1590
+ effect(() => {
1591
+ entries.$length;
1592
+ scroll.order;
1593
+ requestAnimationFrame(() => rove(roving().find((control) => control.tabIndex === 0)));
1594
+ });
1595
+ }
1596
+
1597
+ return html`
1598
+ <div
1599
+ class='toolbar toolbar--${direction} ${labels && 'toolbar--labels'} ${stash && 'tooltip'}'
1600
+ ${attributes}
1601
+ ${!labels && tip.delegate({ content: name, edge: true, selector: '.toolbar-item:not(.toolbar-item--quiet), .toolbar-custom--hinted' })}
1602
+ ${popup}
1603
+ ${{
1604
+ 'aria-label': label,
1605
+ 'aria-orientation': vertical ? 'vertical' : 'horizontal',
1606
+ class: [
1607
+ () => expanded.active && 'toolbar--expanded',
1608
+ () => fit.morphing && 'toolbar--morphing',
1609
+ () => fit.sized && 'toolbar--sized',
1610
+ () => measuring.active && 'toolbar--measuring',
1611
+ () => state.active && 'toolbar--open',
1612
+ () => scroll.count > 0 && 'toolbar--overflowing'
1613
+ ],
1614
+ // The buttons are measured against the bar whenever it, they, or the room around it change; the bar's
1615
+ // parent can grow without the bar growing with it.
1616
+ onconnect: (element: HTMLElement, on) => {
1617
+ shelf = element;
1618
+
1619
+ // Direct: delegation only runs the nearest bound handler, which for a select is its own.
1620
+ if (!dock) {
1621
+ on(element, 'focusin', (e: FocusEvent) => rove(e.target as Element), { direct: true });
1622
+ on(element, 'keydown', step, { direct: true });
1623
+ rove();
1624
+ }
1625
+
1626
+ if (!arrows) {
1627
+ return;
1628
+ }
1629
+
1630
+ let resize = observer(measure);
1631
+
1632
+ for (let node of [element, element.parentElement, track, viewport]) {
1633
+ if (node) {
1634
+ resize.observe(node);
1635
+ }
1636
+ }
1637
+
1638
+ onCleanup(resize.disconnect);
1639
+ },
1640
+ // Landed back on its own box: the bar sizes itself again.
1641
+ ontransitionend: (e: TransitionEvent) => {
1642
+ if (e.target === e.currentTarget && e.propertyName === 'height' && !expanded.active) {
1643
+ release();
1644
+ }
1645
+ },
1646
+ role: dock ? 'navigation' : 'toolbar',
1647
+ // '--fit-depth' is the bar's resting depth from the screen edge, which its contents keep throughout.
1648
+ style: () => fit.sized && `--fit-depth: ${vertical ? resting.width : resting.height}px; --fit-height: ${fit.height}px; --fit-radius: ${fit.radius}px; --fit-width: ${fit.width}px;`
1649
+ }}
1650
+ >
1651
+ ${arrows && arrow(-1)}
1652
+ <div
1653
+ class='toolbar-viewport'
1654
+ ${{
1655
+ // The track spreads the sortable's attributes, so it is reached from here; children connect
1656
+ // before the bar, which measures them.
1657
+ onconnect: (element: HTMLElement) => {
1658
+ track = element.firstElementChild as HTMLElement;
1659
+ viewport = element;
1660
+ }
1661
+ }}
1662
+ >
1663
+ <div class='toolbar-items' ${sorting && list.attributes}>${list.render()}</div>
1664
+ </div>
1665
+ ${arrows && arrow(1)}
1666
+ ${tip.render()}
1667
+ ${stash && drawer(stash)}
1668
+ ${pane()}
1669
+ </div>
1670
+ `;
1671
+ };
1672
+
1673
+
1674
+ export default component(toolbar, { button, divider, drawer, group, item });
1675
+ export type { Button, Custom, Direction, Divider, Entry, Group, Member, Mode };