@k2b/ui 0.27.0 → 0.29.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 (323) hide show
  1. package/README.md +1 -1
  2. package/dist/base.css +147 -2
  3. package/dist/browser/actions/ContextMenu.js +35 -4
  4. package/dist/browser/actions/ContextMenu.js.map +1 -1
  5. package/dist/browser/actions/DragAndDrop.js +89 -0
  6. package/dist/browser/actions/DragAndDrop.js.map +1 -0
  7. package/dist/browser/actions/Dropdown.js +184 -158
  8. package/dist/browser/actions/Dropdown.js.map +1 -1
  9. package/dist/browser/actions/GestureMenu.js +95 -139
  10. package/dist/browser/actions/GestureMenu.js.map +1 -1
  11. package/dist/browser/actions/Toolbar.js +379 -48
  12. package/dist/browser/actions/Toolbar.js.map +1 -1
  13. package/dist/browser/actions/drag-and-drop-messages.js +75 -0
  14. package/dist/browser/actions/drag-and-drop-messages.js.map +1 -0
  15. package/dist/browser/actions/drag-and-drop.js +692 -0
  16. package/dist/browser/actions/drag-and-drop.js.map +1 -0
  17. package/dist/browser/actions/index.js +1 -0
  18. package/dist/browser/actions/index.js.map +1 -1
  19. package/dist/browser/actions/menu-rows.js +15 -0
  20. package/dist/browser/actions/menu-rows.js.map +1 -0
  21. package/dist/browser/actions/menu-sheet.js +154 -0
  22. package/dist/browser/actions/menu-sheet.js.map +1 -0
  23. package/dist/browser/actions/toolbar-messages.js +20 -0
  24. package/dist/browser/actions/toolbar-messages.js.map +1 -0
  25. package/dist/browser/chart-inspection.js +3 -0
  26. package/dist/browser/chart-inspection.js.map +1 -0
  27. package/dist/browser/chat/ChatComposer.js +714 -410
  28. package/dist/browser/chat/ChatComposer.js.map +1 -1
  29. package/dist/browser/chat/ChatDecision.js +778 -0
  30. package/dist/browser/chat/ChatDecision.js.map +1 -0
  31. package/dist/browser/chat/ChatPrimitives.js +34 -28
  32. package/dist/browser/chat/ChatPrimitives.js.map +1 -1
  33. package/dist/browser/chat/ChatTimeline.js.map +1 -1
  34. package/dist/browser/chat/chat-messages.js +25 -1
  35. package/dist/browser/chat/chat-messages.js.map +1 -1
  36. package/dist/browser/chat/command-search.js +13 -3
  37. package/dist/browser/chat/command-search.js.map +1 -1
  38. package/dist/browser/chat/index.js +8 -1
  39. package/dist/browser/chat/index.js.map +1 -1
  40. package/dist/browser/chat/reaction-people.js +15 -0
  41. package/dist/browser/chat/reaction-people.js.map +1 -0
  42. package/dist/browser/chat/types.js.map +1 -1
  43. package/dist/browser/content/Calendar.js +3 -3
  44. package/dist/browser/content/Calendar.js.map +1 -1
  45. package/dist/browser/content/Chart.js +60 -86
  46. package/dist/browser/content/Chart.js.map +1 -1
  47. package/dist/browser/content/ChartSnapshotView.js +7 -10
  48. package/dist/browser/content/ChartSnapshotView.js.map +1 -1
  49. package/dist/browser/content/FileBrowser.js +2 -2
  50. package/dist/browser/content/FileBrowser.js.map +1 -1
  51. package/dist/browser/content/FileTree.js +42 -36
  52. package/dist/browser/content/FileTree.js.map +1 -1
  53. package/dist/browser/content/FileTypeIcon.js +72 -0
  54. package/dist/browser/content/FileTypeIcon.js.map +1 -0
  55. package/dist/browser/content/FileView.js +2 -2
  56. package/dist/browser/content/FileView.js.map +1 -1
  57. package/dist/browser/content/MessageRow.js +330 -448
  58. package/dist/browser/content/MessageRow.js.map +1 -1
  59. package/dist/browser/content/ReactionBar.js +419 -0
  60. package/dist/browser/content/ReactionBar.js.map +1 -0
  61. package/dist/browser/content/ReferenceChip.js +162 -0
  62. package/dist/browser/content/ReferenceChip.js.map +1 -0
  63. package/dist/browser/content/calendar-pointer.js +9 -0
  64. package/dist/browser/content/calendar-pointer.js.map +1 -1
  65. package/dist/browser/content/calendar-time-view.js +6 -3
  66. package/dist/browser/content/calendar-time-view.js.map +1 -1
  67. package/dist/browser/content/chart-inspection-core.js +557 -0
  68. package/dist/browser/content/chart-inspection-core.js.map +1 -0
  69. package/dist/browser/content/chart-inspection.js +10 -445
  70. package/dist/browser/content/chart-inspection.js.map +1 -1
  71. package/dist/browser/content/chart-line-gaps.js +1 -1
  72. package/dist/browser/content/chart-line-gaps.js.map +1 -1
  73. package/dist/browser/content/chart-snapshot.js +1 -1
  74. package/dist/browser/content/chart-snapshot.js.map +1 -1
  75. package/dist/browser/content/index.js +3 -0
  76. package/dist/browser/content/index.js.map +1 -1
  77. package/dist/browser/feedback/dialog-core.js +135 -23
  78. package/dist/browser/feedback/dialog-core.js.map +1 -1
  79. package/dist/browser/index.js +1 -0
  80. package/dist/browser/index.js.map +1 -1
  81. package/dist/browser/input-mode.js +40 -0
  82. package/dist/browser/input-mode.js.map +1 -0
  83. package/dist/browser/inputs/FileDropTarget.js +24 -9
  84. package/dist/browser/inputs/FileDropTarget.js.map +1 -1
  85. package/dist/browser/inputs/FileInputs.js +2 -2
  86. package/dist/browser/inputs/FileInputs.js.map +1 -1
  87. package/dist/browser/inputs/SelectChip.js +9 -0
  88. package/dist/browser/inputs/SelectChip.js.map +1 -1
  89. package/dist/browser/inputs/emoji/EmojiPicker.js +13 -0
  90. package/dist/browser/inputs/emoji/EmojiPicker.js.map +1 -1
  91. package/dist/browser/inputs/file-drop.js.map +1 -1
  92. package/dist/browser/layout/AppOverview.js +1 -1
  93. package/dist/browser/layout/AppOverview.js.map +1 -1
  94. package/dist/browser/layout/AppWorkspace.js +644 -445
  95. package/dist/browser/layout/AppWorkspace.js.map +1 -1
  96. package/dist/browser/layout/DetailPanel.js +283 -197
  97. package/dist/browser/layout/DetailPanel.js.map +1 -1
  98. package/dist/browser/layout/Discussion.js +233 -185
  99. package/dist/browser/layout/Discussion.js.map +1 -1
  100. package/dist/browser/layout/PanelDialog.js +88 -86
  101. package/dist/browser/layout/PanelDialog.js.map +1 -1
  102. package/dist/browser/layout/ResizeSeparator.js +81 -0
  103. package/dist/browser/layout/ResizeSeparator.js.map +1 -0
  104. package/dist/browser/layout/SidebarSwitcher.js +9 -2
  105. package/dist/browser/layout/SidebarSwitcher.js.map +1 -1
  106. package/dist/browser/layout/TabBar.js +15 -12
  107. package/dist/browser/layout/TabBar.js.map +1 -1
  108. package/dist/browser/layout/TableOfContents.js +10 -2
  109. package/dist/browser/layout/TableOfContents.js.map +1 -1
  110. package/dist/browser/layout/app-workspace-controller.js +130 -17
  111. package/dist/browser/layout/app-workspace-controller.js.map +1 -1
  112. package/dist/browser/layout/detail-panel-messages.js +35 -0
  113. package/dist/browser/layout/detail-panel-messages.js.map +1 -0
  114. package/dist/browser/layout/index.js +3 -1
  115. package/dist/browser/layout/index.js.map +1 -1
  116. package/dist/browser/layout/resize-separator.js +90 -0
  117. package/dist/browser/layout/resize-separator.js.map +1 -0
  118. package/dist/browser/layout/workspace-messages.js +12 -2
  119. package/dist/browser/layout/workspace-messages.js.map +1 -1
  120. package/dist/browser/surfaces/Avatar.js +50 -20
  121. package/dist/browser/surfaces/Avatar.js.map +1 -1
  122. package/dist/browser/surfaces/AvatarStack.js +406 -0
  123. package/dist/browser/surfaces/AvatarStack.js.map +1 -0
  124. package/dist/browser/surfaces/LinkCard.js +1 -1
  125. package/dist/browser/surfaces/LinkCard.js.map +1 -1
  126. package/dist/browser/surfaces/Placeholder.js +14 -3
  127. package/dist/browser/surfaces/Placeholder.js.map +1 -1
  128. package/dist/browser/surfaces/StatCell.js +23 -0
  129. package/dist/browser/surfaces/StatCell.js.map +1 -1
  130. package/dist/browser/surfaces/avatar-messages.js +8 -2
  131. package/dist/browser/surfaces/avatar-messages.js.map +1 -1
  132. package/dist/browser/surfaces/index.js +1 -0
  133. package/dist/browser/surfaces/index.js.map +1 -1
  134. package/dist/browser/widgets/Widget.js +1 -1
  135. package/dist/browser/widgets/Widget.js.map +1 -1
  136. package/dist/ssr/actions/ContextMenu.js +26 -3
  137. package/dist/ssr/actions/ContextMenu.js.map +1 -1
  138. package/dist/ssr/actions/DragAndDrop.js +63 -0
  139. package/dist/ssr/actions/DragAndDrop.js.map +1 -0
  140. package/dist/ssr/actions/Dropdown.js +140 -72
  141. package/dist/ssr/actions/Dropdown.js.map +1 -1
  142. package/dist/ssr/actions/GestureMenu.js +76 -107
  143. package/dist/ssr/actions/GestureMenu.js.map +1 -1
  144. package/dist/ssr/actions/Toolbar.js +294 -14
  145. package/dist/ssr/actions/Toolbar.js.map +1 -1
  146. package/dist/ssr/actions/drag-and-drop-messages.js +75 -0
  147. package/dist/ssr/actions/drag-and-drop-messages.js.map +1 -0
  148. package/dist/ssr/actions/drag-and-drop.js +692 -0
  149. package/dist/ssr/actions/drag-and-drop.js.map +1 -0
  150. package/dist/ssr/actions/index.js +1 -0
  151. package/dist/ssr/actions/index.js.map +1 -1
  152. package/dist/ssr/actions/menu-rows.js +15 -0
  153. package/dist/ssr/actions/menu-rows.js.map +1 -0
  154. package/dist/ssr/actions/menu-sheet.js +138 -0
  155. package/dist/ssr/actions/menu-sheet.js.map +1 -0
  156. package/dist/ssr/actions/toolbar-messages.js +20 -0
  157. package/dist/ssr/actions/toolbar-messages.js.map +1 -0
  158. package/dist/ssr/chart-inspection.js +3 -0
  159. package/dist/ssr/chart-inspection.js.map +1 -0
  160. package/dist/ssr/chat/ChatComposer.js +393 -102
  161. package/dist/ssr/chat/ChatComposer.js.map +1 -1
  162. package/dist/ssr/chat/ChatDecision.js +465 -0
  163. package/dist/ssr/chat/ChatDecision.js.map +1 -0
  164. package/dist/ssr/chat/ChatPrimitives.js +2 -2
  165. package/dist/ssr/chat/ChatPrimitives.js.map +1 -1
  166. package/dist/ssr/chat/ChatTimeline.js.map +1 -1
  167. package/dist/ssr/chat/chat-messages.js +25 -1
  168. package/dist/ssr/chat/chat-messages.js.map +1 -1
  169. package/dist/ssr/chat/command-search.js +13 -3
  170. package/dist/ssr/chat/command-search.js.map +1 -1
  171. package/dist/ssr/chat/index.js +8 -1
  172. package/dist/ssr/chat/index.js.map +1 -1
  173. package/dist/ssr/chat/reaction-people.js +15 -0
  174. package/dist/ssr/chat/reaction-people.js.map +1 -0
  175. package/dist/ssr/chat/types.js.map +1 -1
  176. package/dist/ssr/content/Calendar.js +3 -3
  177. package/dist/ssr/content/Calendar.js.map +1 -1
  178. package/dist/ssr/content/Chart.js +25 -38
  179. package/dist/ssr/content/Chart.js.map +1 -1
  180. package/dist/ssr/content/ChartSnapshotView.js +7 -10
  181. package/dist/ssr/content/ChartSnapshotView.js.map +1 -1
  182. package/dist/ssr/content/FileBrowser.js +2 -2
  183. package/dist/ssr/content/FileBrowser.js.map +1 -1
  184. package/dist/ssr/content/FileTree.js +21 -14
  185. package/dist/ssr/content/FileTree.js.map +1 -1
  186. package/dist/ssr/content/FileTypeIcon.js +50 -0
  187. package/dist/ssr/content/FileTypeIcon.js.map +1 -0
  188. package/dist/ssr/content/FileView.js +2 -2
  189. package/dist/ssr/content/FileView.js.map +1 -1
  190. package/dist/ssr/content/MessageRow.js +98 -152
  191. package/dist/ssr/content/MessageRow.js.map +1 -1
  192. package/dist/ssr/content/ReactionBar.js +304 -0
  193. package/dist/ssr/content/ReactionBar.js.map +1 -0
  194. package/dist/ssr/content/ReferenceChip.js +121 -0
  195. package/dist/ssr/content/ReferenceChip.js.map +1 -0
  196. package/dist/ssr/content/calendar-pointer.js +9 -0
  197. package/dist/ssr/content/calendar-pointer.js.map +1 -1
  198. package/dist/ssr/content/calendar-time-view.js +6 -3
  199. package/dist/ssr/content/calendar-time-view.js.map +1 -1
  200. package/dist/ssr/content/chart-inspection-core.js +557 -0
  201. package/dist/ssr/content/chart-inspection-core.js.map +1 -0
  202. package/dist/ssr/content/chart-inspection.js +10 -445
  203. package/dist/ssr/content/chart-inspection.js.map +1 -1
  204. package/dist/ssr/content/chart-line-gaps.js +1 -1
  205. package/dist/ssr/content/chart-line-gaps.js.map +1 -1
  206. package/dist/ssr/content/chart-snapshot.js +1 -1
  207. package/dist/ssr/content/chart-snapshot.js.map +1 -1
  208. package/dist/ssr/content/index.js +3 -0
  209. package/dist/ssr/content/index.js.map +1 -1
  210. package/dist/ssr/feedback/dialog-core.js +135 -23
  211. package/dist/ssr/feedback/dialog-core.js.map +1 -1
  212. package/dist/ssr/index.js +1 -0
  213. package/dist/ssr/index.js.map +1 -1
  214. package/dist/ssr/input-mode.js +40 -0
  215. package/dist/ssr/input-mode.js.map +1 -0
  216. package/dist/ssr/inputs/FileDropTarget.js +17 -5
  217. package/dist/ssr/inputs/FileDropTarget.js.map +1 -1
  218. package/dist/ssr/inputs/FileInputs.js +2 -2
  219. package/dist/ssr/inputs/FileInputs.js.map +1 -1
  220. package/dist/ssr/inputs/SelectChip.js +9 -0
  221. package/dist/ssr/inputs/SelectChip.js.map +1 -1
  222. package/dist/ssr/inputs/emoji/EmojiPicker.js +12 -0
  223. package/dist/ssr/inputs/emoji/EmojiPicker.js.map +1 -1
  224. package/dist/ssr/inputs/file-drop.js.map +1 -1
  225. package/dist/ssr/layout/AppOverview.js +1 -1
  226. package/dist/ssr/layout/AppOverview.js.map +1 -1
  227. package/dist/ssr/layout/AppWorkspace.js +272 -95
  228. package/dist/ssr/layout/AppWorkspace.js.map +1 -1
  229. package/dist/ssr/layout/DetailPanel.js +112 -58
  230. package/dist/ssr/layout/DetailPanel.js.map +1 -1
  231. package/dist/ssr/layout/Discussion.js +63 -36
  232. package/dist/ssr/layout/Discussion.js.map +1 -1
  233. package/dist/ssr/layout/PanelDialog.js +7 -6
  234. package/dist/ssr/layout/PanelDialog.js.map +1 -1
  235. package/dist/ssr/layout/ResizeSeparator.js +45 -0
  236. package/dist/ssr/layout/ResizeSeparator.js.map +1 -0
  237. package/dist/ssr/layout/SidebarSwitcher.js +9 -2
  238. package/dist/ssr/layout/SidebarSwitcher.js.map +1 -1
  239. package/dist/ssr/layout/TabBar.js +1 -1
  240. package/dist/ssr/layout/TabBar.js.map +1 -1
  241. package/dist/ssr/layout/TableOfContents.js +10 -2
  242. package/dist/ssr/layout/TableOfContents.js.map +1 -1
  243. package/dist/ssr/layout/app-workspace-controller.js +130 -17
  244. package/dist/ssr/layout/app-workspace-controller.js.map +1 -1
  245. package/dist/ssr/layout/detail-panel-messages.js +35 -0
  246. package/dist/ssr/layout/detail-panel-messages.js.map +1 -0
  247. package/dist/ssr/layout/index.js +3 -1
  248. package/dist/ssr/layout/index.js.map +1 -1
  249. package/dist/ssr/layout/resize-separator.js +90 -0
  250. package/dist/ssr/layout/resize-separator.js.map +1 -0
  251. package/dist/ssr/layout/workspace-messages.js +12 -2
  252. package/dist/ssr/layout/workspace-messages.js.map +1 -1
  253. package/dist/ssr/surfaces/Avatar.js +20 -2
  254. package/dist/ssr/surfaces/Avatar.js.map +1 -1
  255. package/dist/ssr/surfaces/AvatarStack.js +286 -0
  256. package/dist/ssr/surfaces/AvatarStack.js.map +1 -0
  257. package/dist/ssr/surfaces/LinkCard.js +1 -1
  258. package/dist/ssr/surfaces/LinkCard.js.map +1 -1
  259. package/dist/ssr/surfaces/Placeholder.js +4 -2
  260. package/dist/ssr/surfaces/Placeholder.js.map +1 -1
  261. package/dist/ssr/surfaces/StatCell.js +23 -0
  262. package/dist/ssr/surfaces/StatCell.js.map +1 -1
  263. package/dist/ssr/surfaces/avatar-messages.js +8 -2
  264. package/dist/ssr/surfaces/avatar-messages.js.map +1 -1
  265. package/dist/ssr/surfaces/index.js +1 -0
  266. package/dist/ssr/surfaces/index.js.map +1 -1
  267. package/dist/ssr/widgets/Widget.js +1 -1
  268. package/dist/ssr/widgets/Widget.js.map +1 -1
  269. package/dist/styles.css +1 -1
  270. package/dist/types/actions/ContextMenu.d.ts +9 -0
  271. package/dist/types/actions/DragAndDrop.d.ts +29 -0
  272. package/dist/types/actions/Dropdown.d.ts +12 -5
  273. package/dist/types/actions/GestureMenu.d.ts +6 -4
  274. package/dist/types/actions/Toolbar.d.ts +20 -0
  275. package/dist/types/actions/drag-and-drop-messages.d.ts +35 -0
  276. package/dist/types/actions/drag-and-drop.d.ts +36 -0
  277. package/dist/types/actions/index.d.ts +3 -1
  278. package/dist/types/actions/menu-rows.d.ts +5 -0
  279. package/dist/types/actions/menu-sheet.d.ts +22 -0
  280. package/dist/types/actions/toolbar-messages.d.ts +8 -0
  281. package/dist/types/chart-inspection.d.ts +2 -0
  282. package/dist/types/chat/ChatComposer.d.ts +26 -1
  283. package/dist/types/chat/ChatDecision.d.ts +133 -0
  284. package/dist/types/chat/ChatPrimitives.d.ts +4 -1
  285. package/dist/types/chat/ChatTimeline.d.ts +2 -1
  286. package/dist/types/chat/chat-messages.d.ts +13 -2
  287. package/dist/types/chat/command-search.d.ts +5 -0
  288. package/dist/types/chat/index.d.ts +25 -1
  289. package/dist/types/chat/reaction-people.d.ts +9 -0
  290. package/dist/types/chat/types.d.ts +54 -1
  291. package/dist/types/content/Chart.d.ts +11 -5
  292. package/dist/types/content/FileTypeIcon.d.ts +27 -0
  293. package/dist/types/content/MessageRow.d.ts +3 -10
  294. package/dist/types/content/ReactionBar.d.ts +32 -0
  295. package/dist/types/content/ReferenceChip.d.ts +49 -0
  296. package/dist/types/content/calendar-pointer.d.ts +6 -0
  297. package/dist/types/content/chart-inspection-core.d.ts +61 -0
  298. package/dist/types/content/chart-inspection.d.ts +4 -20
  299. package/dist/types/content/chart-snapshot.d.ts +1 -1
  300. package/dist/types/content/index.d.ts +5 -1
  301. package/dist/types/feedback/dialog-core.d.ts +16 -1
  302. package/dist/types/index.d.ts +1 -0
  303. package/dist/types/input-mode.d.ts +7 -0
  304. package/dist/types/inputs/FileDropTarget.d.ts +6 -3
  305. package/dist/types/inputs/SelectChip.d.ts +2 -0
  306. package/dist/types/inputs/file-drop.d.ts +2 -0
  307. package/dist/types/layout/AppWorkspace.d.ts +5 -3
  308. package/dist/types/layout/DetailPanel.d.ts +11 -0
  309. package/dist/types/layout/Discussion.d.ts +8 -0
  310. package/dist/types/layout/ResizeSeparator.d.ts +9 -0
  311. package/dist/types/layout/TabBar.d.ts +7 -0
  312. package/dist/types/layout/TableOfContents.d.ts +2 -0
  313. package/dist/types/layout/app-workspace-controller.d.ts +2 -0
  314. package/dist/types/layout/detail-panel-messages.d.ts +15 -0
  315. package/dist/types/layout/index.d.ts +3 -1
  316. package/dist/types/layout/resize-separator.d.ts +18 -0
  317. package/dist/types/layout/workspace-messages.d.ts +5 -0
  318. package/dist/types/surfaces/Avatar.d.ts +12 -0
  319. package/dist/types/surfaces/AvatarStack.d.ts +41 -0
  320. package/dist/types/surfaces/StatCell.d.ts +6 -0
  321. package/dist/types/surfaces/avatar-messages.d.ts +3 -0
  322. package/dist/types/surfaces/index.d.ts +3 -1
  323. package/package.json +7 -2
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["layout/SidebarSwitcher.tsx"],"sourcesContent":["import { documentNavigate } from \"@k2b/ssr/nav\";\nimport { createMemo, createSignal, createUniqueId, For, type JSX, onCleanup, Show } from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nimport { dropdownPosition } from \"../actions/Dropdown\";\nimport { returnFocus, ringOnReturn } from \"../internal/focus-return\";\nimport { useUiMessages } from \"../intl/messages\";\n\n/** One container a person can switch to, such as a notebook, a space, or a mailbox. */\nexport type AppWorkspaceSwitcherOption = {\n id: string;\n label: string;\n /** One secondary fact, such as a mailbox's address. */\n description?: string;\n /** Tabler icon class; without it the row takes the switcher's icon. */\n icon?: string;\n /** Tints the icon; without it the app accent does. */\n color?: string;\n href: string;\n};\n\n/** A row below the containers, such as \"New notebook\" or \"All notebooks\". */\nexport type AppWorkspaceSwitcherAction = {\n id: string;\n label: string;\n icon: string;\n disabled?: boolean;\n} & ({ href: string; action?: never } | { action: () => void; href?: never });\n\nexport type AppWorkspaceSidebarSwitcherProps = {\n /** The current container's ID among `options`. */\n currentId: string;\n /** The current container's name. */\n label: string;\n /** One secondary fact under the name, such as a mailbox's address. */\n description?: string;\n icon: string;\n /** Tints the icon; without it the app accent does. */\n color?: string;\n /** Names the button's purpose and its panel, such as \"Switch notebook\". */\n switchLabel: string;\n /** Every container the person can switch to, the current one included; `undefined` until they are loaded. */\n options?: readonly AppWorkspaceSwitcherOption[];\n /** Shown in place of the options when loading them failed; the panel offers to try again through `onLoad`. */\n error?: string;\n /**\n * Asks for `options` while they are `undefined`: when a pointer or the focus first reaches the button, so the list\n * is usually there when the panel opens, on every opening, and from the panel's retry. Ignore repeated calls while a\n * request runs.\n */\n onLoad?: () => void;\n actions?: readonly AppWorkspaceSwitcherAction[];\n /**\n * A host menu around the switcher, such as the phone menu, finishes dismissing itself before a chosen container\n * opens or an action runs; `false` cancels the choice. Navigation passes its own.\n */\n beforeSelect?: () => boolean | void | Promise<boolean | void>;\n /** Sizes the switcher in its place, such as `flex-1` beside a button in one row. */\n class?: string;\n};\n\n/** From this many containers the panel scrolls, so it offers a search field. */\nexport const APP_WORKSPACE_SWITCHER_SEARCH_FROM = 8;\n\n/** The space between trigger and panel, and the panel's distance from the viewport edges, as for every dropdown. */\nconst SWITCHER_GAP = 4;\nconst SWITCHER_INSET = 8;\n\nconst iconClass = (icon: string) => (icon.split(/\\s+/).includes(\"ti\") ? icon : `ti ${icon}`);\nconst tint = (color: string | undefined) => (color ? { \"--k2b-sidebar-switcher-color\": color } : undefined);\nconst plainClick = (event: MouseEvent) => event.button === 0 && !(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey);\n\n/**\n * The current container at the top of a sidebar: its icon, name, and an optional fact, with a chevron that opens the\n * other containers, a search field when there are many, and actions such as \"New …\" and \"All …\". The rows are links,\n * so a container also opens in a new tab. In a collapsed rail it shows only the icon and opens beside the rail.\n */\nexport function AppWorkspaceSidebarSwitcher(props: AppWorkspaceSidebarSwitcherProps): JSX.Element {\n const messages = useUiMessages();\n const id = `k2b-sidebar-switcher-${createUniqueId().replace(/[^a-zA-Z0-9_-]/g, \"-\")}`;\n const [open, setOpen] = createSignal(false);\n const [query, setQuery] = createSignal(\"\");\n let trigger: HTMLButtonElement | undefined;\n let panel: HTMLDivElement | undefined;\n let search: HTMLInputElement | undefined;\n let keyboardOpened = true;\n /** Whether the panel was open when a press on the button began; the press itself light-dismisses it first. */\n let openAtPress: boolean | undefined;\n\n const searchable = () => (props.options?.length ?? 0) >= APP_WORKSPACE_SWITCHER_SEARCH_FROM;\n const visible = createMemo(() => {\n const needle = query().trim().toLocaleLowerCase();\n const options = props.options ?? [];\n if (!needle) return options;\n return options.filter((option) => [option.label, option.description].some((part) => part?.toLocaleLowerCase().includes(needle)));\n });\n const load = () => {\n if (props.options === undefined) props.onLoad?.();\n };\n\n // The collapsed rail is a narrow column from 64 rem, so the panel opens beside it instead of below.\n const inRail = () =>\n Boolean(\n trigger?.closest('[data-sidebar-collapsed=\"true\"] .k2b-app-workspace__sidebar[data-workspace-collapsible=\"true\"]') &&\n window.matchMedia(\"(min-width: 64rem)\").matches,\n );\n /** Whether the panel opens above its trigger; chosen on opening and on a viewport resize only. */\n let above = false;\n /**\n * Places the panel beside its trigger. `choose` picks its side again; otherwise it keeps the side, so arriving\n * options, an error, or a narrowed search never flip it to the other side while it is open.\n */\n const place = (choose = false) => {\n if (!trigger || !panel) return;\n const rect = trigger.getBoundingClientRect();\n const viewport = { width: window.innerWidth, height: window.innerHeight };\n const rail = inRail();\n // As wide as the sidebar row and never narrower than a menu, so long names keep their words; fixed while open,\n // so filtering never changes the panel's width.\n panel.style.setProperty(\"--k2b-sidebar-switcher-width\", `${rail ? 0 : Math.round(rect.width)}px`);\n if (rail) {\n panel.style.removeProperty(\"--k2b-sidebar-switcher-room\");\n panel.style.removeProperty(\"min-height\");\n panel.style.bottom = \"auto\";\n const position = dropdownPosition(rect, panel.getBoundingClientRect(), \"right-start\", viewport);\n panel.style.left = `${position.left}px`;\n panel.style.top = `${position.top}px`;\n return;\n }\n // Below the trigger, or above it when the panel at its tallest does not fit below and there is more room above,\n // as in the lower half of the phone menu. Its tallest is its CSS max-height, min(28rem, 80dvh), so the side does\n // not depend on what the panel shows at the moment. It never covers its trigger: it takes at most the room on its\n // side, and its list scrolls.\n const roomBelow = viewport.height - rect.bottom - SWITCHER_GAP - SWITCHER_INSET;\n const roomAbove = rect.top - SWITCHER_GAP - SWITCHER_INSET;\n if (choose) {\n const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;\n above = Math.min(28 * rem, 0.8 * viewport.height) > roomBelow && roomAbove > roomBelow;\n panel.style.removeProperty(\"min-height\");\n }\n const room = Math.max(0, above ? roomAbove : roomBelow);\n panel.style.setProperty(\"--k2b-sidebar-switcher-room\", `${room}px`);\n panel.style.left = `${dropdownPosition(rect, panel.getBoundingClientRect(), \"bottom-right\", viewport).left}px`;\n if (above) {\n // Its bottom edge stays beside the trigger, and it does not shrink while open, so a narrowed search keeps the\n // search field where the person is typing.\n const height = Math.min(room, Math.max(panel.getBoundingClientRect().height, Number.parseFloat(panel.style.minHeight) || 0));\n panel.style.minHeight = `${height}px`;\n panel.style.top = \"auto\";\n panel.style.bottom = `${document.documentElement.clientHeight - rect.top + SWITCHER_GAP}px`;\n } else {\n panel.style.top = `${rect.bottom + SWITCHER_GAP}px`;\n panel.style.bottom = \"auto\";\n }\n };\n const reposition = () => open() && place();\n const resize = () => open() && place(true);\n // Arriving options, an error, or the search field grow the panel after it opened, so its size places it too.\n let resizing: ResizeObserver | undefined;\n const listen = (on: boolean) => {\n const method = on ? \"addEventListener\" : \"removeEventListener\";\n window[method](\"resize\", resize);\n window[method](\"scroll\", reposition, true);\n if (on && panel) {\n resizing ??= new ResizeObserver(reposition);\n resizing.observe(panel);\n } else resizing?.disconnect();\n };\n // Server rendering cleans up too, where no window exists.\n onCleanup(() => isServer || listen(false));\n /** Lets the host dismiss its menu first, then opens the link or runs the action unless the host cancels. */\n const choose = (run: () => void) => {\n hide(false);\n if (!props.beforeSelect) return run();\n void Promise.resolve(props.beforeSelect()).then((allowed) => {\n if (allowed !== false) run();\n });\n };\n const follow = (event: MouseEvent & { currentTarget: HTMLAnchorElement }) => {\n if (!plainClick(event)) return;\n if (!props.beforeSelect) return hide(false);\n event.preventDefault();\n const href = event.currentTarget.href;\n choose(() => documentNavigate(href));\n };\n\n const rows = () => (panel ? Array.from(panel.querySelectorAll<HTMLElement>(\"[data-switcher-row]:not([aria-disabled='true'])\")) : []);\n const focusRow = (index: number) => {\n const all = rows();\n if (all.length) all[(index + all.length) % all.length]?.focus();\n };\n const show = (focus: \"start\" | \"end\" = \"start\") => {\n if (!panel || panel.matches(\":popover-open\")) return;\n load();\n keyboardOpened = ringOnReturn(trigger);\n setQuery(\"\");\n panel.showPopover();\n setOpen(true);\n listen(true);\n place(true);\n queueMicrotask(() => {\n // On touch the search field waits for a tap, so the keyboard does not cover the list on opening.\n if (searchable() && focus === \"start\" && !window.matchMedia(\"(pointer: coarse)\").matches) search?.focus();\n else if (focus === \"end\") focusRow(-1);\n // While the list loads, the panel holds focus, so arriving rows do not move it.\n else (panel?.querySelector<HTMLElement>('[aria-current=\"true\"]') ?? (props.options ? rows()[0] : panel))?.focus();\n });\n };\n const hide = (restoreFocus: boolean) => {\n if (restoreFocus) returnFocus(trigger, keyboardOpened);\n if (panel?.matches(\":popover-open\")) panel.hidePopover();\n };\n\n const onPanelKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const all = rows();\n const index = all.indexOf(target);\n if (event.key === \"Escape\") {\n // The panel closes alone; an overlay sidebar around it stays open.\n event.preventDefault();\n event.stopPropagation();\n hide(true);\n } else if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n focusRow(index + (event.key === \"ArrowDown\" ? 1 : -1));\n } else if ((event.key === \"Home\" || event.key === \"End\") && target !== search) {\n event.preventDefault();\n focusRow(event.key === \"Home\" ? 0 : -1);\n } else if (event.key === \"Enter\" && target === search) {\n event.preventDefault();\n panel?.querySelector<HTMLElement>(\"[data-switcher-option]\")?.click();\n } else if (\n search &&\n target !== search &&\n event.key.length === 1 &&\n event.key !== \" \" &&\n !(event.metaKey || event.ctrlKey || event.altKey)\n ) {\n // Typing anywhere in a long list searches it.\n event.preventDefault();\n setQuery(query() + event.key);\n search.focus();\n }\n };\n\n return (\n <div class={`k2b-sidebar-switcher ${props.class ?? \"\"}`} data-description={props.description ? \"\" : undefined}>\n <button\n ref={trigger}\n type=\"button\"\n class=\"k2b-sidebar-switcher__trigger\"\n aria-label={props.label}\n aria-describedby={`${id}-purpose`}\n aria-haspopup=\"dialog\"\n aria-expanded={open()}\n aria-controls={id}\n // The full name for a truncated title and for the icon in a collapsed rail.\n title={props.label}\n onPointerEnter={load}\n onFocus={load}\n onPointerDown={() => (openAtPress = panel?.matches(\":popover-open\"))}\n onClick={() => {\n const wasOpen = openAtPress ?? panel?.matches(\":popover-open\");\n openAtPress = undefined;\n if (wasOpen) hide(false);\n else show();\n }}\n onKeyDown={(event) => {\n if (event.key !== \"ArrowDown\" && event.key !== \"ArrowUp\") return;\n event.preventDefault();\n if (open()) focusRow(event.key === \"ArrowDown\" ? 0 : -1);\n else show(event.key === \"ArrowDown\" ? \"start\" : \"end\");\n }}\n >\n <span class=\"k2b-sidebar-switcher__icon\" style={tint(props.color)} aria-hidden=\"true\">\n <i class={iconClass(props.icon)} />\n </span>\n <span class=\"k2b-sidebar-switcher__copy\" aria-hidden=\"true\">\n <span>{props.label}</span>\n <Show when={props.description}>{(description) => <small>{description()}</small>}</Show>\n </span>\n <i class=\"ti ti-selector k2b-sidebar-switcher__chevron\" aria-hidden=\"true\" />\n <span id={`${id}-purpose`} class=\"k2b-sr-only\">\n {[props.description, props.switchLabel].filter(Boolean).join(\", \")}\n </span>\n </button>\n <div\n ref={panel}\n id={id}\n popover=\"auto\"\n tabIndex={-1}\n role=\"dialog\"\n aria-label={props.switchLabel}\n class=\"k2b-sidebar-switcher__panel\"\n onKeyDown={onPanelKeyDown}\n onFocusOut={(event) => {\n const next = event.relatedTarget as Node | null;\n // Tabbing out closes the panel; focus that leaves the window keeps it.\n if (next && !panel?.contains(next) && next !== trigger) hide(false);\n }}\n onToggle={(event) => {\n if ((event as ToggleEvent).newState === \"open\") return;\n setOpen(false);\n listen(false);\n }}\n >\n <Show when={searchable()}>\n <div class=\"k2b-choice-search k2b-sidebar-switcher__search\">\n <i class=\"ti ti-search\" aria-hidden=\"true\" />\n <input\n ref={search}\n type=\"search\"\n data-switcher-row\n value={query()}\n placeholder={messages().search}\n aria-label={messages().searchLabel}\n aria-controls={`${id}-options`}\n onInput={(event) => setQuery(event.currentTarget.value)}\n />\n </div>\n </Show>\n <ul id={`${id}-options`} class=\"k2b-sidebar-switcher__options\">\n <Show\n when={props.options}\n fallback={\n <li class=\"k2b-choice-status\" role=\"status\" data-tone={props.error ? \"danger\" : undefined}>\n <Show\n when={props.error}\n fallback={\n <>\n <i class=\"ti ti-loader-2 k2b-spin\" aria-hidden=\"true\" />\n <span>{messages().loading}</span>\n </>\n }\n >\n {(error) => (\n <>\n <span>{error()}</span>\n <button type=\"button\" data-switcher-row onClick={() => props.onLoad?.()}>\n {messages().retry}\n </button>\n </>\n )}\n </Show>\n </li>\n }\n >\n <For\n each={visible()}\n fallback={\n <li class=\"k2b-choice-status\" role=\"status\">\n {messages().noResults}\n </li>\n }\n >\n {(option) => {\n const current = () => option.id === props.currentId;\n return (\n <li>\n <a\n href={option.href}\n class=\"k2b-dropdown__item k2b-sidebar-switcher__option\"\n data-switcher-row\n data-switcher-option\n aria-current={current() ? \"true\" : undefined}\n onClick={(event) => {\n // The open container is already here: choosing it only closes the panel.\n if (current() && plainClick(event)) {\n event.preventDefault();\n hide(true);\n } else follow(event);\n }}\n >\n <span class=\"k2b-sidebar-switcher__option-icon\" style={tint(option.color ?? props.color)} aria-hidden=\"true\">\n <i class={iconClass(option.icon ?? props.icon)} />\n </span>\n <span class=\"k2b-dropdown__copy\">\n <span>{option.label}</span>\n <Show when={option.description}>{(description) => <small>{description()}</small>}</Show>\n </span>\n <i class=\"ti ti-check k2b-dropdown__check\" data-hidden={current() ? undefined : \"true\"} aria-hidden=\"true\" />\n </a>\n </li>\n );\n }}\n </For>\n </Show>\n </ul>\n <Show when={props.actions?.length}>\n <ul class=\"k2b-sidebar-switcher__actions\">\n <For each={props.actions}>\n {(item) => (\n <li>\n <Show\n when={item.href}\n fallback={\n <button\n type=\"button\"\n class=\"k2b-dropdown__item\"\n data-switcher-row\n disabled={item.disabled}\n aria-disabled={item.disabled ? \"true\" : undefined}\n onClick={() => choose(() => item.action?.())}\n >\n <i class={iconClass(item.icon)} aria-hidden=\"true\" />\n <span class=\"k2b-dropdown__copy\">\n <span>{item.label}</span>\n </span>\n </button>\n }\n >\n {(href) => (\n <a\n href={item.disabled ? undefined : href()}\n class=\"k2b-dropdown__item\"\n data-switcher-row\n aria-disabled={item.disabled ? \"true\" : undefined}\n onClick={(event) => item.disabled || follow(event)}\n >\n <i class={iconClass(item.icon)} aria-hidden=\"true\" />\n <span class=\"k2b-dropdown__copy\">\n <span>{item.label}</span>\n </span>\n </a>\n )}\n </Show>\n </li>\n )}\n </For>\n </ul>\n </Show>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB,QAAQ,cAAc;AAC/C,SAAS,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,EAAY,SAAS,EAAE,IAAI,QAAQ,UAAU;AACnG,SAAS,QAAQ,QAAQ,cAAc;AACvC,SAAS,gBAAgB,QAAQ,qBAAqB;AACtD,SAAS,WAAW,EAAE,YAAY,QAAQ,0BAA0B;AACpE,SAAS,aAAa,QAAQ,kBAAkB;;AAEhD;;AAaA;;AAwCA;AACA,OAAO,MAAM,kCAAkC,GAAG,CAAC;;AAEnD;AACA,MAAM,YAAY,GAAG,CAAC;AACtB,MAAM,cAAc,GAAG,CAAC;AAExB,MAAM,SAAS,GAAI,IAAY,IAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,MAAM,IAAI,EAAG;AAC5F,MAAM,IAAI,GAAI,KAAyB,IAAM,KAAK,GAAG;EAAE,8BAA8B,EAAE;AAAM,CAAC,GAAG,SAAU;AAC3G,MAAM,UAAU,GAAI,KAAiB,IAAK,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CA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O,EAAE,MAAM;IAAA;IAAA;MAAA,iDAE5B,GAAG;QAAA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,OAAO;QAAA;QAAA,UACpB,IAAI,8CAED,IAAI;UAAA,IACH,IAAI;YAAA,OAAE,IAAI,CAAC,IAAI;UAAA;UAAA,IACf,QAAQ;YAAA,kDAKM,IAAI,CAAC,QAAQ,0CACR,IAAI,CAAC,QAAQ,GAAG,MAAM,YAAG,SAAS,kDAGvC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,0BAErB,IAAI,CAAC,KAAK;UAAA;UAAA,UAKrB,IAAI,2CAEI,IAAI,CAAC,QAAQ,YAAG,SAAS,mBAAG,IAAI,CAAC,CAAC,iDAGzB,IAAI,CAAC,QAAQ,GAAG,MAAM,YAAG,SAAS,kDAGvC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,0BAErB,IAAI,CAAC,KAAK;QAGtB;MAGN;IAAA;EAAA;AAOf","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["layout/SidebarSwitcher.tsx"],"sourcesContent":["import { documentNavigate } from \"@k2b/ssr/nav\";\nimport { createMemo, createSignal, createUniqueId, For, type JSX, onCleanup, Show } from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nimport { dropdownPosition } from \"../actions/Dropdown\";\nimport { returnFocus, ringOnReturn } from \"../internal/focus-return\";\nimport { useUiMessages } from \"../intl/messages\";\n\n/** One container a person can switch to, such as a notebook, a space, or a mailbox. */\nexport type AppWorkspaceSwitcherOption = {\n id: string;\n label: string;\n /** One secondary fact, such as a mailbox's address. */\n description?: string;\n /** Tabler icon class; without it the row takes the switcher's icon. */\n icon?: string;\n /** Tints the icon; without it the app accent does. */\n color?: string;\n href: string;\n};\n\n/** A row below the containers, such as \"New notebook\" or \"All notebooks\". */\nexport type AppWorkspaceSwitcherAction = {\n id: string;\n label: string;\n icon: string;\n disabled?: boolean;\n} & ({ href: string; action?: never } | { action: () => void; href?: never });\n\nexport type AppWorkspaceSidebarSwitcherProps = {\n /** The current container's ID among `options`. */\n currentId: string;\n /** The current container's name. */\n label: string;\n /** One secondary fact under the name, such as a mailbox's address. */\n description?: string;\n icon: string;\n /** Tints the icon; without it the app accent does. */\n color?: string;\n /** Names the button's purpose and its panel, such as \"Switch notebook\". */\n switchLabel: string;\n /** Every container the person can switch to, the current one included; `undefined` until they are loaded. */\n options?: readonly AppWorkspaceSwitcherOption[];\n /** Shown in place of the options when loading them failed; the panel offers to try again through `onLoad`. */\n error?: string;\n /**\n * Asks for `options` while they are `undefined`: when a pointer or the focus first reaches the button, so the list\n * is usually there when the panel opens, on every opening, and from the panel's retry. Ignore repeated calls while a\n * request runs.\n */\n onLoad?: () => void;\n actions?: readonly AppWorkspaceSwitcherAction[];\n /**\n * A host menu around the switcher, such as the phone menu, finishes dismissing itself before a chosen container\n * opens or an action runs; `false` cancels the choice. Navigation passes its own.\n */\n beforeSelect?: () => boolean | void | Promise<boolean | void>;\n /** Sizes the switcher in its place, such as `flex-1` beside a button in one row. */\n class?: string;\n};\n\n/** From this many containers the panel scrolls, so it offers a search field. */\nexport const APP_WORKSPACE_SWITCHER_SEARCH_FROM = 8;\n\n/** The space between trigger and panel, and the panel's distance from the viewport edges, as for every dropdown. */\nconst SWITCHER_GAP = 4;\nconst SWITCHER_INSET = 8;\n\nconst iconClass = (icon: string) => (icon.split(/\\s+/).includes(\"ti\") ? icon : `ti ${icon}`);\nconst tint = (color: string | undefined) => (color ? { \"--k2b-sidebar-switcher-color\": color } : undefined);\nconst plainClick = (event: MouseEvent) => event.button === 0 && !(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey);\n\n/**\n * The current container at the top of a sidebar: its icon, name, and an optional fact, with a chevron that opens the\n * other containers, a search field when there are many, and actions such as \"New …\" and \"All …\". The rows are links,\n * so a container also opens in a new tab. In a collapsed rail it shows only the icon and opens beside the rail.\n */\nexport function AppWorkspaceSidebarSwitcher(props: AppWorkspaceSidebarSwitcherProps): JSX.Element {\n const messages = useUiMessages();\n const id = `k2b-sidebar-switcher-${createUniqueId().replace(/[^a-zA-Z0-9_-]/g, \"-\")}`;\n const [open, setOpen] = createSignal(false);\n const [query, setQuery] = createSignal(\"\");\n let trigger: HTMLButtonElement | undefined;\n let panel: HTMLDivElement | undefined;\n let search: HTMLInputElement | undefined;\n let keyboardOpened = true;\n /** Whether the panel was open when a press on the button began; the press itself light-dismisses it first. */\n let openAtPress: boolean | undefined;\n\n const searchable = () => (props.options?.length ?? 0) >= APP_WORKSPACE_SWITCHER_SEARCH_FROM;\n const visible = createMemo(() => {\n const needle = query().trim().toLocaleLowerCase();\n const options = props.options ?? [];\n if (!needle) return options;\n return options.filter((option) => [option.label, option.description].some((part) => part?.toLocaleLowerCase().includes(needle)));\n });\n const load = () => {\n if (props.options === undefined) props.onLoad?.();\n };\n\n // The collapsed rail is a narrow column from a 64 rem host, so the panel opens beside it instead of below.\n // The workspace's stylesheet states which form its sidebar has.\n const inRail = () => {\n const sidebar = trigger?.closest('[data-sidebar-collapsed=\"true\"] .k2b-app-workspace__sidebar[data-workspace-collapsible=\"true\"]');\n const root = sidebar?.closest<HTMLElement>(\"[data-k2b-app-workspace]\");\n return Boolean(root && getComputedStyle(root).getPropertyValue(\"--k2b-workspace-sidebar-form\").trim() === \"column\");\n };\n /** Whether the panel opens above its trigger; chosen on opening and on a viewport resize only. */\n let above = false;\n /**\n * Places the panel beside its trigger. `choose` picks its side again; otherwise it keeps the side, so arriving\n * options, an error, or a narrowed search never flip it to the other side while it is open.\n */\n const place = (choose = false) => {\n if (!trigger || !panel) return;\n const rect = trigger.getBoundingClientRect();\n const viewport = { width: window.innerWidth, height: window.innerHeight };\n const rail = inRail();\n // As wide as the sidebar row and never narrower than a menu, so long names keep their words; fixed while open,\n // so filtering never changes the panel's width.\n panel.style.setProperty(\"--k2b-sidebar-switcher-width\", `${rail ? 0 : Math.round(rect.width)}px`);\n if (rail) {\n panel.style.removeProperty(\"--k2b-sidebar-switcher-room\");\n panel.style.removeProperty(\"min-height\");\n panel.style.bottom = \"auto\";\n const position = dropdownPosition(rect, panel.getBoundingClientRect(), \"right-start\", viewport);\n panel.style.left = `${position.left}px`;\n panel.style.top = `${position.top}px`;\n return;\n }\n // Below the trigger, or above it when the panel at its tallest does not fit below and there is more room above,\n // as in the lower half of the phone menu. Its tallest is its CSS max-height, min(28rem, 80dvh), so the side does\n // not depend on what the panel shows at the moment. It never covers its trigger: it takes at most the room on its\n // side, and its list scrolls.\n const roomBelow = viewport.height - rect.bottom - SWITCHER_GAP - SWITCHER_INSET;\n const roomAbove = rect.top - SWITCHER_GAP - SWITCHER_INSET;\n if (choose) {\n const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;\n above = Math.min(28 * rem, 0.8 * viewport.height) > roomBelow && roomAbove > roomBelow;\n panel.style.removeProperty(\"min-height\");\n }\n const room = Math.max(0, above ? roomAbove : roomBelow);\n panel.style.setProperty(\"--k2b-sidebar-switcher-room\", `${room}px`);\n panel.style.left = `${dropdownPosition(rect, panel.getBoundingClientRect(), \"bottom-right\", viewport).left}px`;\n if (above) {\n // Its bottom edge stays beside the trigger, and it does not shrink while open, so a narrowed search keeps the\n // search field where the person is typing.\n const height = Math.min(room, Math.max(panel.getBoundingClientRect().height, Number.parseFloat(panel.style.minHeight) || 0));\n panel.style.minHeight = `${height}px`;\n panel.style.top = \"auto\";\n panel.style.bottom = `${document.documentElement.clientHeight - rect.top + SWITCHER_GAP}px`;\n } else {\n panel.style.top = `${rect.bottom + SWITCHER_GAP}px`;\n panel.style.bottom = \"auto\";\n }\n };\n const reposition = () => open() && place();\n const resize = () => open() && place(true);\n // Arriving options, an error, or the search field grow the panel after it opened, so its size places it too.\n // The trigger changes size when a host turns the rail into the expanded overlay, without a window resize.\n let resizing: ResizeObserver | undefined;\n const listen = (on: boolean) => {\n const method = on ? \"addEventListener\" : \"removeEventListener\";\n window[method](\"resize\", resize);\n window[method](\"scroll\", reposition, true);\n if (on && panel) {\n resizing ??= new ResizeObserver(reposition);\n resizing.observe(panel);\n if (trigger) resizing.observe(trigger);\n } else resizing?.disconnect();\n };\n // Server rendering cleans up too, where no window exists.\n onCleanup(() => isServer || listen(false));\n /** Lets the host dismiss its menu first, then opens the link or runs the action unless the host cancels. */\n const choose = (run: () => void) => {\n hide(false);\n if (!props.beforeSelect) return run();\n void Promise.resolve(props.beforeSelect()).then((allowed) => {\n if (allowed !== false) run();\n });\n };\n const follow = (event: MouseEvent & { currentTarget: HTMLAnchorElement }) => {\n if (!plainClick(event)) return;\n if (!props.beforeSelect) return hide(false);\n event.preventDefault();\n const href = event.currentTarget.href;\n choose(() => documentNavigate(href));\n };\n\n const rows = () => (panel ? Array.from(panel.querySelectorAll<HTMLElement>(\"[data-switcher-row]:not([aria-disabled='true'])\")) : []);\n const focusRow = (index: number) => {\n const all = rows();\n if (all.length) all[(index + all.length) % all.length]?.focus();\n };\n const show = (focus: \"start\" | \"end\" = \"start\") => {\n if (!panel || panel.matches(\":popover-open\")) return;\n load();\n keyboardOpened = ringOnReturn(trigger);\n setQuery(\"\");\n panel.showPopover();\n setOpen(true);\n listen(true);\n place(true);\n queueMicrotask(() => {\n // On touch the search field waits for a tap, so the keyboard does not cover the list on opening.\n if (searchable() && focus === \"start\" && !window.matchMedia(\"(pointer: coarse)\").matches) search?.focus();\n else if (focus === \"end\") focusRow(-1);\n // While the list loads, the panel holds focus, so arriving rows do not move it.\n else (panel?.querySelector<HTMLElement>('[aria-current=\"true\"]') ?? (props.options ? rows()[0] : panel))?.focus();\n });\n };\n const hide = (restoreFocus: boolean) => {\n if (restoreFocus) returnFocus(trigger, keyboardOpened);\n if (panel?.matches(\":popover-open\")) panel.hidePopover();\n };\n\n const onPanelKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const all = rows();\n const index = all.indexOf(target);\n if (event.key === \"Escape\") {\n // The panel closes alone; an overlay sidebar around it stays open.\n event.preventDefault();\n event.stopPropagation();\n hide(true);\n } else if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n focusRow(index + (event.key === \"ArrowDown\" ? 1 : -1));\n } else if ((event.key === \"Home\" || event.key === \"End\") && target !== search) {\n event.preventDefault();\n focusRow(event.key === \"Home\" ? 0 : -1);\n } else if (event.key === \"Enter\" && target === search) {\n event.preventDefault();\n panel?.querySelector<HTMLElement>(\"[data-switcher-option]\")?.click();\n } else if (\n search &&\n target !== search &&\n event.key.length === 1 &&\n event.key !== \" \" &&\n !(event.metaKey || event.ctrlKey || event.altKey)\n ) {\n // Typing anywhere in a long list searches it.\n event.preventDefault();\n setQuery(query() + event.key);\n search.focus();\n }\n };\n\n return (\n <div class={`k2b-sidebar-switcher ${props.class ?? \"\"}`} data-description={props.description ? \"\" : undefined}>\n <button\n ref={trigger}\n type=\"button\"\n class=\"k2b-sidebar-switcher__trigger\"\n aria-label={props.label}\n aria-describedby={`${id}-purpose`}\n aria-haspopup=\"dialog\"\n aria-expanded={open()}\n aria-controls={id}\n // The full name for a truncated title and for the icon in a collapsed rail.\n title={props.label}\n onPointerEnter={load}\n onFocus={load}\n onPointerDown={() => (openAtPress = panel?.matches(\":popover-open\"))}\n onClick={() => {\n const wasOpen = openAtPress ?? panel?.matches(\":popover-open\");\n openAtPress = undefined;\n if (wasOpen) hide(false);\n else show();\n }}\n onKeyDown={(event) => {\n if (event.key !== \"ArrowDown\" && event.key !== \"ArrowUp\") return;\n event.preventDefault();\n if (open()) focusRow(event.key === \"ArrowDown\" ? 0 : -1);\n else show(event.key === \"ArrowDown\" ? \"start\" : \"end\");\n }}\n >\n <span class=\"k2b-sidebar-switcher__icon\" style={tint(props.color)} aria-hidden=\"true\">\n <i class={iconClass(props.icon)} />\n </span>\n <span class=\"k2b-sidebar-switcher__copy\" aria-hidden=\"true\">\n <span>{props.label}</span>\n <Show when={props.description}>{(description) => <small>{description()}</small>}</Show>\n </span>\n <i class=\"ti ti-selector k2b-sidebar-switcher__chevron\" aria-hidden=\"true\" />\n <span id={`${id}-purpose`} class=\"k2b-sr-only\">\n {[props.description, props.switchLabel].filter(Boolean).join(\", \")}\n </span>\n </button>\n <div\n ref={panel}\n id={id}\n popover=\"auto\"\n tabIndex={-1}\n role=\"dialog\"\n aria-label={props.switchLabel}\n class=\"k2b-sidebar-switcher__panel\"\n onKeyDown={onPanelKeyDown}\n onFocusOut={(event) => {\n const next = event.relatedTarget as Node | null;\n // Tabbing out closes the panel; focus that leaves the window keeps it.\n if (next && !panel?.contains(next) && next !== trigger) hide(false);\n }}\n onToggle={(event) => {\n if ((event as ToggleEvent).newState === \"open\") return;\n setOpen(false);\n listen(false);\n }}\n >\n <Show when={searchable()}>\n <div class=\"k2b-choice-search k2b-sidebar-switcher__search\">\n <i class=\"ti ti-search\" aria-hidden=\"true\" />\n <input\n ref={search}\n type=\"search\"\n data-switcher-row\n value={query()}\n placeholder={messages().search}\n aria-label={messages().searchLabel}\n aria-controls={`${id}-options`}\n onInput={(event) => setQuery(event.currentTarget.value)}\n />\n </div>\n </Show>\n <ul id={`${id}-options`} class=\"k2b-sidebar-switcher__options\">\n <Show\n when={props.options}\n fallback={\n <li class=\"k2b-choice-status\" role=\"status\" data-tone={props.error ? \"danger\" : undefined}>\n <Show\n when={props.error}\n fallback={\n <>\n <i class=\"ti ti-loader-2 k2b-spin\" aria-hidden=\"true\" />\n <span>{messages().loading}</span>\n </>\n }\n >\n {(error) => (\n <>\n <span>{error()}</span>\n <button type=\"button\" data-switcher-row onClick={() => props.onLoad?.()}>\n {messages().retry}\n </button>\n </>\n )}\n </Show>\n </li>\n }\n >\n <For\n each={visible()}\n fallback={\n <li class=\"k2b-choice-status\" role=\"status\">\n {messages().noResults}\n </li>\n }\n >\n {(option) => {\n const current = () => option.id === props.currentId;\n return (\n <li>\n <a\n href={option.href}\n class=\"k2b-dropdown__item k2b-sidebar-switcher__option\"\n data-switcher-row\n data-switcher-option\n aria-current={current() ? \"true\" : undefined}\n onClick={(event) => {\n // The open container is already here: choosing it only closes the panel.\n if (current() && plainClick(event)) {\n event.preventDefault();\n hide(true);\n } else follow(event);\n }}\n >\n <span class=\"k2b-sidebar-switcher__option-icon\" style={tint(option.color ?? props.color)} aria-hidden=\"true\">\n <i class={iconClass(option.icon ?? props.icon)} />\n </span>\n <span class=\"k2b-dropdown__copy\">\n <span>{option.label}</span>\n <Show when={option.description}>{(description) => <small>{description()}</small>}</Show>\n </span>\n <i class=\"ti ti-check k2b-dropdown__check\" data-hidden={current() ? undefined : \"true\"} aria-hidden=\"true\" />\n </a>\n </li>\n );\n }}\n </For>\n </Show>\n </ul>\n <Show when={props.actions?.length}>\n <ul class=\"k2b-sidebar-switcher__actions\">\n <For each={props.actions}>\n {(item) => (\n <li>\n <Show\n when={item.href}\n fallback={\n <button\n type=\"button\"\n class=\"k2b-dropdown__item\"\n data-switcher-row\n disabled={item.disabled}\n aria-disabled={item.disabled ? \"true\" : undefined}\n onClick={() => choose(() => item.action?.())}\n >\n <i class={iconClass(item.icon)} aria-hidden=\"true\" />\n <span class=\"k2b-dropdown__copy\">\n <span>{item.label}</span>\n </span>\n </button>\n }\n >\n {(href) => (\n <a\n href={item.disabled ? undefined : href()}\n class=\"k2b-dropdown__item\"\n data-switcher-row\n aria-disabled={item.disabled ? \"true\" : undefined}\n onClick={(event) => item.disabled || follow(event)}\n >\n <i class={iconClass(item.icon)} aria-hidden=\"true\" />\n <span class=\"k2b-dropdown__copy\">\n <span>{item.label}</span>\n </span>\n </a>\n )}\n </Show>\n </li>\n )}\n </For>\n </ul>\n </Show>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB,QAAQ,cAAc;AAC/C,SAAS,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,EAAY,SAAS,EAAE,IAAI,QAAQ,UAAU;AACnG,SAAS,QAAQ,QAAQ,cAAc;AACvC,SAAS,gBAAgB,QAAQ,qBAAqB;AACtD,SAAS,WAAW,EAAE,YAAY,QAAQ,0BAA0B;AACpE,SAAS,aAAa,QAAQ,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C,QAAQ,GAAG,MAAM,YAAG,SAAS,kDAGvC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,0BAErB,IAAI,CAAC,KAAK;QAGtB;MAGN;IAAA;EAAA;AAOf","ignoreList":[]}
@@ -14,7 +14,7 @@ const TAB_BAR_MAX_ITEMS = 5;
14
14
  * tab switches at the first touch: the shell shows the item's `title` while its page loads.
15
15
  */
16
16
  export function TabBar(props) {
17
- return _$ssr(_tmpl$, _$ssrAttribute("class", props.class ? `k2b-tab-bar ${_$escape(props.class, true)}` : "k2b-tab-bar", false) + _$ssrAttribute("aria-label", _$escape(props.label, true), false), _$escape(_$createComponent(For, {
17
+ return _$ssr(_tmpl$, _$ssrAttribute("class", props.class ? `k2b-tab-bar ${_$escape(props.class, true)}` : "k2b-tab-bar", false) + _$ssrAttribute("aria-label", _$escape(props.label, true), false) + _$ssrAttribute("data-variant", props.variant === "floating" ? "floating" : _$escape(undefined, true), false), _$escape(_$createComponent(For, {
18
18
  get each() {
19
19
  return props.items.slice(0, TAB_BAR_MAX_ITEMS);
20
20
  },
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["layout/TabBar.tsx"],"sourcesContent":["import { For, type JSX } from \"solid-js\";\n\nexport type TabBarItem = {\n id: string;\n label: string;\n /** Icon class, for example `ti ti-home`. */\n icon: string;\n href: string;\n /** The header title of the page this item opens, shown while that page loads. Defaults to `label`. */\n title?: string;\n /** The page this item leads to is open. */\n current?: boolean;\n};\n\nexport type TabBarProps = {\n /** Accessible name of the navigation landmark. */\n label: string;\n /** Up to five destinations; further items are not rendered. Put the rest behind a \"More\" destination. */\n items: readonly TabBarItem[];\n class?: string;\n};\n\n/** A phone app's bottom navigation holds at most five destinations. */\nconst TAB_BAR_MAX_ITEMS = 5;\n\n/**\n * Bottom navigation between a phone app's top-level pages: native links with equal widths, an icon above each label,\n * and `aria-current=\"page\"` on the open page. Place it in `MobileShell`'s footer; it pads the bottom safe area. There a\n * tab switches at the first touch: the shell shows the item's `title` while its page loads.\n */\nexport function TabBar(props: TabBarProps): JSX.Element {\n return (\n <nav class={props.class ? `k2b-tab-bar ${props.class}` : \"k2b-tab-bar\"} aria-label={props.label}>\n <ul>\n <For each={props.items.slice(0, TAB_BAR_MAX_ITEMS)}>\n {(item) => (\n <li>\n <a\n href={item.href}\n aria-current={item.current ? \"page\" : undefined}\n data-tab={item.id}\n data-k2b-title={item.title ?? item.label}\n >\n <i class={item.icon} aria-hidden=\"true\" />\n <span>{item.label}</span>\n </a>\n </li>\n )}\n </For>\n </ul>\n </nav>\n );\n}\n\nexport default TabBar;\n"],"mappings":";;;;;;AAAA,SAAS,GAAG,QAAkB,UAAU;AAsBxC;AACA,MAAM,iBAAiB,GAAG,CAAC;;AAE3B;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,MAAM,CAAC,KAAkB,EAAe;EACtD,6CACc,KAAK,CAAC,KAAK,GAAG,wBAAe,KAAK,CAAC,KAAK,SAAE,GAAG,aAAa,iDAAc,KAAK,CAAC,KAAK,4CAE1F,GAAG;IAAA,IAAC,IAAI;MAAA,OAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC;IAAA;IAAA,UAC9C,IAAI,mDAGM,IAAI,CAAC,IAAI,iDACD,IAAI,CAAC,OAAO,GAAG,MAAM,YAAG,SAAS,sDACrC,IAAI,CAAC,EAAE,4DACD,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,kDAE9B,IAAI,CAAC,IAAI,0BACZ,IAAI,CAAC,KAAK;EAGtB;AAKX;AAEA,eAAe,MAAM","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["layout/TabBar.tsx"],"sourcesContent":["import { For, type JSX } from \"solid-js\";\n\nexport type TabBarItem = {\n id: string;\n label: string;\n /** Icon class, for example `ti ti-home`. */\n icon: string;\n href: string;\n /** The header title of the page this item opens, shown while that page loads. Defaults to `label`. */\n title?: string;\n /** The page this item leads to is open. */\n current?: boolean;\n};\n\nexport type TabBarProps = {\n /** Accessible name of the navigation landmark. */\n label: string;\n /** Up to five destinations; further items are not rendered. Put the rest behind a \"More\" destination. */\n items: readonly TabBarItem[];\n /**\n * `bar` (the default) is flat on the page canvas and pads the bottom safe area. `floating` is a rounded bar that the\n * host places above the content, away from the safe areas; its open item is a raised chip. The host may paint it\n * with `--k2b-tab-bar-background`, color its items with `--k2b-tab-bar-color`, and color the open item with\n * `--k2b-tab-bar-selected-background` and `--k2b-tab-bar-selected-color`.\n */\n variant?: \"bar\" | \"floating\";\n class?: string;\n};\n\n/** A phone app's bottom navigation holds at most five destinations. */\nconst TAB_BAR_MAX_ITEMS = 5;\n\n/**\n * Bottom navigation between a phone app's top-level pages: native links with equal widths, an icon above each label,\n * and `aria-current=\"page\"` on the open page. Place it in `MobileShell`'s footer; it pads the bottom safe area. There a\n * tab switches at the first touch: the shell shows the item's `title` while its page loads.\n */\nexport function TabBar(props: TabBarProps): JSX.Element {\n return (\n <nav\n class={props.class ? `k2b-tab-bar ${props.class}` : \"k2b-tab-bar\"}\n aria-label={props.label}\n data-variant={props.variant === \"floating\" ? \"floating\" : undefined}\n >\n <ul>\n <For each={props.items.slice(0, TAB_BAR_MAX_ITEMS)}>\n {(item) => (\n <li>\n <a\n href={item.href}\n aria-current={item.current ? \"page\" : undefined}\n data-tab={item.id}\n data-k2b-title={item.title ?? item.label}\n >\n <i class={item.icon} aria-hidden=\"true\" />\n <span>{item.label}</span>\n </a>\n </li>\n )}\n </For>\n </ul>\n </nav>\n );\n}\n\nexport default TabBar;\n"],"mappings":";;;;;;AAAA,SAAS,GAAG,QAAkB,UAAU;AA6BxC;AACA,MAAM,iBAAiB,GAAG,CAAC;;AAE3B;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,MAAM,CAAC,KAAkB,EAAe;EACtD,6CAEW,KAAK,CAAC,KAAK,GAAG,wBAAe,KAAK,CAAC,KAAK,SAAE,GAAG,aAAa,iDACrD,KAAK,CAAC,KAAK,iDACT,KAAK,CAAC,OAAO,KAAK,UAAU,GAAG,UAAU,YAAG,SAAS,4CAGhE,GAAG;IAAA,IAAC,IAAI;MAAA,OAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC;IAAA;IAAA,UAC9C,IAAI,mDAGM,IAAI,CAAC,IAAI,iDACD,IAAI,CAAC,OAAO,GAAG,MAAM,YAAG,SAAS,sDACrC,IAAI,CAAC,EAAE,4DACD,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,kDAE9B,IAAI,CAAC,IAAI,0BACZ,IAAI,CAAC,KAAK;EAGtB;AAKX;AAEA,eAAe,MAAM","ignoreList":[]}
@@ -20,6 +20,14 @@ export function TableOfContents(props) {
20
20
  // Reading every id here makes a changed id or a store update recompute the active section.
21
21
  const ids = props.items.map(item => item.id);
22
22
  const root = resolveMaybeAccessor(props.scrollRoot);
23
+ const content = resolveMaybeAccessor(props.contentRoot);
24
+ const heading = id => {
25
+ const element = document.getElementById(id);
26
+ if (!content || element && content.contains(element)) return element;
27
+ // The same id elsewhere on the page, or a root outside the document tree, needs a lookup within the root.
28
+ for (const candidate of content.querySelectorAll("[id]")) if (candidate.id === id) return candidate;
29
+ return null;
30
+ };
23
31
  const target = root ?? window;
24
32
  let frame;
25
33
  const update = () => {
@@ -30,7 +38,7 @@ export function TableOfContents(props) {
30
38
  const line = top + height / 4;
31
39
  const headings = ids.map(id => ({
32
40
  id,
33
- box: document.getElementById(id)?.getBoundingClientRect()
41
+ box: heading(id)?.getBoundingClientRect()
34
42
  }));
35
43
  let next = ids[0];
36
44
  for (const heading of headings) if (heading.box && heading.box.top <= line) next = heading.id;
@@ -51,7 +59,7 @@ export function TableOfContents(props) {
51
59
  window.addEventListener("resize", schedule);
52
60
  const observer = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(schedule);
53
61
  // No scroll or window resize happens when the root, a block above a heading, or a heading's own section changes size.
54
- const observed = new Set([root ?? document.documentElement, ...(root?.children ?? [document.body]), ...ids.map(id => document.getElementById(id)?.parentElement)]);
62
+ const observed = new Set([root ?? document.documentElement, ...(root?.children ?? [document.body]), ...ids.map(id => heading(id)?.parentElement)]);
55
63
  for (const element of observed) if (element) observer?.observe(element);
56
64
  untrack(update);
57
65
  onCleanup(() => {
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["layout/TableOfContents.tsx"],"sourcesContent":["import { createEffect, createSignal, createUniqueId, For, type JSX, onCleanup, Show, untrack } from \"solid-js\";\nimport type { MaybeAccessor } from \"../inputs/field-contract\";\nimport { resolveMaybeAccessor } from \"../inputs/field-contract\";\nimport { assertStableUiId } from \"./stable-id\";\nimport { useTableOfContentsMessages } from \"./table-of-contents-messages\";\n\nexport type TableOfContentsItem = { id: string; label: string };\nexport type TableOfContentsProps = {\n items: readonly TableOfContentsItem[];\n /** Visible heading and navigation name. Defaults to the localized \"On this page\". */\n title?: string;\n /** Element whose scrolling decides the active section. Defaults to the window. */\n scrollRoot?: MaybeAccessor<HTMLElement | undefined>;\n /** Stay in view inside the caller's layout. */\n sticky?: boolean;\n /** Called when another section becomes active. */\n onActiveChange?: (id: string | undefined) => void;\n class?: string;\n};\n\n/**\n * Native section links with a scroll spy on the window or a content container.\n * @example <TableOfContents items={[{ id: \"sharing\", label: \"Sharing\" }]} sticky />\n */\nexport function TableOfContents(props: TableOfContentsProps): JSX.Element {\n const t = useTableOfContentsMessages();\n const headingId = assertStableUiId(`k2b-toc-${createUniqueId().replace(/[^a-zA-Z0-9_-]/g, \"-\")}`, \"TableOfContents heading id\");\n const [active, setActive] = createSignal(props.items[0]?.id);\n createEffect(() => {\n // Reading every id here makes a changed id or a store update recompute the active section.\n const ids = props.items.map((item) => item.id);\n const root = resolveMaybeAccessor(props.scrollRoot);\n const target = root ?? window;\n let frame: number | undefined;\n const update = () => {\n frame = undefined;\n const box = root?.getBoundingClientRect();\n const top = box ? box.top + (root?.clientTop ?? 0) : 0;\n const height = root?.clientHeight ?? window.innerHeight;\n const line = top + height / 4;\n const headings = ids.map((id) => ({ id, box: document.getElementById(id)?.getBoundingClientRect() }));\n let next = ids[0];\n for (const heading of headings) if (heading.box && heading.box.top <= line) next = heading.id;\n const last = headings.at(-1);\n const atEnd = root\n ? root.scrollHeight - root.clientHeight - root.scrollTop <= 4\n : document.documentElement.scrollHeight - window.innerHeight - window.scrollY <= 4;\n if (atEnd && last?.box && last.box.top < top + height && last.box.bottom > top) next = last.id;\n if (next !== active()) {\n setActive(next);\n props.onActiveChange?.(next);\n }\n };\n const schedule = () => {\n if (frame === undefined) frame = requestAnimationFrame(update);\n };\n target.addEventListener(\"scroll\", schedule, { passive: true });\n window.addEventListener(\"resize\", schedule);\n const observer = typeof ResizeObserver === \"undefined\" ? undefined : new ResizeObserver(schedule);\n // No scroll or window resize happens when the root, a block above a heading, or a heading's own section changes size.\n const observed = new Set<Element | null | undefined>([\n root ?? document.documentElement,\n ...(root?.children ?? [document.body]),\n ...ids.map((id) => document.getElementById(id)?.parentElement),\n ]);\n for (const element of observed) if (element) observer?.observe(element);\n untrack(update);\n onCleanup(() => {\n target.removeEventListener(\"scroll\", schedule);\n window.removeEventListener(\"resize\", schedule);\n observer?.disconnect();\n if (frame !== undefined) cancelAnimationFrame(frame);\n });\n });\n return (\n <Show when={props.items.length > 0}>\n <nav\n class={`k2b-toc${props.class ? ` ${props.class}` : \"\"}`}\n data-sticky={props.sticky ? \"true\" : undefined}\n aria-labelledby={headingId}\n >\n <p class=\"k2b-toc__title\" id={headingId}>\n {props.title ?? t().title}\n </p>\n <ol class=\"k2b-toc__list\">\n <For each={props.items}>\n {(item) => (\n <li>\n <a class=\"k2b-toc__link\" href={`#${item.id}`} aria-current={active() === item.id ? \"location\" : undefined}>\n {item.label}\n </a>\n </li>\n )}\n </For>\n </ol>\n </nav>\n </Show>\n );\n}\nexport default TableOfContents;\n"],"mappings":";;;;;;AAAA,SAAS,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,EAAY,SAAS,EAAE,IAAI,EAAE,OAAO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A,eAAe,eAAe","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["layout/TableOfContents.tsx"],"sourcesContent":["import { createEffect, createSignal, createUniqueId, For, type JSX, onCleanup, Show, untrack } from \"solid-js\";\nimport type { MaybeAccessor } from \"../inputs/field-contract\";\nimport { resolveMaybeAccessor } from \"../inputs/field-contract\";\nimport { assertStableUiId } from \"./stable-id\";\nimport { useTableOfContentsMessages } from \"./table-of-contents-messages\";\n\nexport type TableOfContentsItem = { id: string; label: string };\nexport type TableOfContentsProps = {\n items: readonly TableOfContentsItem[];\n /** Visible heading and navigation name. Defaults to the localized \"On this page\". */\n title?: string;\n /** Element whose scrolling decides the active section. Defaults to the window. */\n scrollRoot?: MaybeAccessor<HTMLElement | undefined>;\n /** Element that contains the section headings. Defaults to the document. */\n contentRoot?: MaybeAccessor<HTMLElement | undefined>;\n /** Stay in view inside the caller's layout. */\n sticky?: boolean;\n /** Called when another section becomes active. */\n onActiveChange?: (id: string | undefined) => void;\n class?: string;\n};\n\n/**\n * Native section links with a scroll spy on the window or a content container.\n * @example <TableOfContents items={[{ id: \"sharing\", label: \"Sharing\" }]} sticky />\n */\nexport function TableOfContents(props: TableOfContentsProps): JSX.Element {\n const t = useTableOfContentsMessages();\n const headingId = assertStableUiId(`k2b-toc-${createUniqueId().replace(/[^a-zA-Z0-9_-]/g, \"-\")}`, \"TableOfContents heading id\");\n const [active, setActive] = createSignal(props.items[0]?.id);\n createEffect(() => {\n // Reading every id here makes a changed id or a store update recompute the active section.\n const ids = props.items.map((item) => item.id);\n const root = resolveMaybeAccessor(props.scrollRoot);\n const content = resolveMaybeAccessor(props.contentRoot);\n const heading = (id: string): Element | null => {\n const element = document.getElementById(id);\n if (!content || (element && content.contains(element))) return element;\n // The same id elsewhere on the page, or a root outside the document tree, needs a lookup within the root.\n for (const candidate of content.querySelectorAll(\"[id]\")) if (candidate.id === id) return candidate;\n return null;\n };\n const target = root ?? window;\n let frame: number | undefined;\n const update = () => {\n frame = undefined;\n const box = root?.getBoundingClientRect();\n const top = box ? box.top + (root?.clientTop ?? 0) : 0;\n const height = root?.clientHeight ?? window.innerHeight;\n const line = top + height / 4;\n const headings = ids.map((id) => ({ id, box: heading(id)?.getBoundingClientRect() }));\n let next = ids[0];\n for (const heading of headings) if (heading.box && heading.box.top <= line) next = heading.id;\n const last = headings.at(-1);\n const atEnd = root\n ? root.scrollHeight - root.clientHeight - root.scrollTop <= 4\n : document.documentElement.scrollHeight - window.innerHeight - window.scrollY <= 4;\n if (atEnd && last?.box && last.box.top < top + height && last.box.bottom > top) next = last.id;\n if (next !== active()) {\n setActive(next);\n props.onActiveChange?.(next);\n }\n };\n const schedule = () => {\n if (frame === undefined) frame = requestAnimationFrame(update);\n };\n target.addEventListener(\"scroll\", schedule, { passive: true });\n window.addEventListener(\"resize\", schedule);\n const observer = typeof ResizeObserver === \"undefined\" ? undefined : new ResizeObserver(schedule);\n // No scroll or window resize happens when the root, a block above a heading, or a heading's own section changes size.\n const observed = new Set<Element | null | undefined>([\n root ?? document.documentElement,\n ...(root?.children ?? [document.body]),\n ...ids.map((id) => heading(id)?.parentElement),\n ]);\n for (const element of observed) if (element) observer?.observe(element);\n untrack(update);\n onCleanup(() => {\n target.removeEventListener(\"scroll\", schedule);\n window.removeEventListener(\"resize\", schedule);\n observer?.disconnect();\n if (frame !== undefined) cancelAnimationFrame(frame);\n });\n });\n return (\n <Show when={props.items.length > 0}>\n <nav\n class={`k2b-toc${props.class ? ` ${props.class}` : \"\"}`}\n data-sticky={props.sticky ? \"true\" : undefined}\n aria-labelledby={headingId}\n >\n <p class=\"k2b-toc__title\" id={headingId}>\n {props.title ?? t().title}\n </p>\n <ol class=\"k2b-toc__list\">\n <For each={props.items}>\n {(item) => (\n <li>\n <a class=\"k2b-toc__link\" href={`#${item.id}`} aria-current={active() === item.id ? \"location\" : undefined}>\n {item.label}\n </a>\n </li>\n )}\n </For>\n </ol>\n </nav>\n </Show>\n );\n}\nexport default TableOfContents;\n"],"mappings":";;;;;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;MAAA,qBAEvB,UAAU,KAAK,CAAC,KAAK,GAAG,aAAI,KAAK,CAAC,KAAK,SAAE,GAAG,EAAE,EAAE,gCAC1C,KAAK,CAAC,MAAM,GAAG,MAAM,YAAG,SAAS,6DAC7B,SAAS,+CAEI,SAAS,0BACpC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,8BAGxB,GAAG;QAAA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,KAAK;QAAA;QAAA,UAClB,IAAI,mBAE6B,aAAI,IAAI,CAAC,EAAE,SAAE,iCAAgB,MAAM,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,GAAG,UAAU,YAAG,SAAS,0BACtG,IAAI,CAAC,KAAK;MAGhB;IAAA;EAAA;AAMb;AACA,eAAe,eAAe","ignoreList":[]}
@@ -6,8 +6,36 @@ const HANDLE_SELECTOR = "[data-app-workspace-resize]";
6
6
  const ROOT_SELECTOR = "[data-k2b-app-workspace]";
7
7
  const LAYOUT_REGION_SELECTOR = [ROOT_SELECTOR, ".k2b-app-workspace__sidebar", ".k2b-app-workspace__main-pane", ".k2b-app-workspace__detail", ".k2b-app-workspace__drawer", HANDLE_SELECTOR].join(",");
8
8
  const TOGGLE_SELECTOR = "[data-app-workspace-sidebar-toggle]";
9
- /** The width range in which the sidebar is an overlay; it matches the compact media query in the stylesheet. */
10
- const COMPACT_QUERY = "(min-width: 48rem) and (max-width: 63.999rem)";
9
+ /** Touch-tablet gestures remain viewport decisions. */
10
+ const TOUCH_DRAWER_QUERY = "(min-width: 48rem) and (max-width: 63.999rem) and (pointer: coarse)";
11
+ const DETAIL_TOGGLE_SELECTOR = "[data-app-workspace-detail-toggle]";
12
+ const DETAIL_DRAWER_SELECTOR = '.k2b-app-workspace__detail[data-workspace-detail-drawer="open"]';
13
+ const cssState = (element, name) => getComputedStyle(element).getPropertyValue(name).trim();
14
+ const detailWaiting = aside => cssState(aside, "--k2b-workspace-detail-waiting") === "1";
15
+ const detailDrawer = aside => aside.dataset.workspaceDetailDrawer === "open";
16
+ const detailToggle = aside => {
17
+ const root = workspaceRoot(aside);
18
+ return rootElements(root ?? aside, DETAIL_TOGGLE_SELECTOR).find(toggle => toggle.getAttribute("aria-controls") === aside.id);
19
+ };
20
+ // The trail's registered property accepts a length, not the drawer's percentage
21
+ // cap. Only a user-opened drawer needs this measurement; the first frame stays CSS-owned.
22
+ const detailDrawerContent = aside => aside.closest(".k2b-app-workspace__content");
23
+ const syncDetailDrawerSpace = aside => detailDrawerContent(aside)?.style.setProperty("--k2b-detail-space", `${aside.getBoundingClientRect().width}px`);
24
+ const parkDetailDrawer = (aside, focus = false) => {
25
+ if (!detailDrawer(aside)) return;
26
+ delete aside.dataset.workspaceDetailDrawer;
27
+ detailDrawerContent(aside)?.style.removeProperty("--k2b-detail-space");
28
+ const toggle = detailToggle(aside);
29
+ toggle?.setAttribute("aria-expanded", "false");
30
+ if (focus) toggle?.focus({
31
+ preventScroll: true
32
+ });
33
+ };
34
+
35
+ /** Parks open waiting-detail drawers; focus follows only when it was inside one. */
36
+ export const parkWorkspaceDetailDrawers = (root = document) => {
37
+ for (const aside of root.querySelectorAll(DETAIL_DRAWER_SELECTOR)) parkDetailDrawer(aside, aside.contains(aside.ownerDocument.activeElement));
38
+ };
11
39
  const FOCUSABLE_SELECTOR = ["a[href]", "button:not([disabled])", "input:not([disabled]):not([type='hidden'])", "select:not([disabled])", "textarea:not([disabled])", "[tabindex]:not([tabindex='-1'])"].join(",");
12
40
  /** Text entry, menus, dialogs, and open popups keep their own keys. */
13
41
  const KEY_OWNER_SELECTOR = "input, textarea, select, [contenteditable]:not([contenteditable='false']), [role='textbox'], [role='combobox'], [role='searchbox'], [role='spinbutton'], [role='menu'], [role='listbox'], [role='dialog'], dialog, [aria-haspopup]:not([aria-haspopup='false'])[aria-expanded='true']";
@@ -59,8 +87,9 @@ const controlledPanel = (root, handle) => {
59
87
  };
60
88
  const flexibleLevel = pane => {
61
89
  if (!pane.hasAttribute("data-workspace-level")) return false;
62
- const widthClass = window.matchMedia("(min-width: 80rem)").matches ? "3" : window.matchMedia("(min-width: 48rem)").matches ? "2" : "1";
63
- return pane.dataset.workspaceLevelLast?.split(" ").includes(widthClass) ?? false;
90
+ const root = workspaceRoot(pane);
91
+ const widthClass = root ? cssState(root, "--k2b-workspace-level-class") : "";
92
+ return Boolean(widthClass && pane.dataset.workspaceLevelLast?.split(" ").includes(widthClass));
64
93
  };
65
94
  const levelsMain = handle => handle.closest(".k2b-app-workspace__main")?.hasAttribute("data-workspace-levels") ?? false;
66
95
  const controlsResizableRegion = (root, handle, kind) => {
@@ -228,7 +257,6 @@ export const installAppWorkspaceController = (options = {}) => {
228
257
  const ownerDocument = eventRoot.ownerDocument ?? document;
229
258
  const ownerWindow = ownerDocument.defaultView ?? window;
230
259
  let overlay = null;
231
- const compact = typeof window.matchMedia === "function" ? window.matchMedia(COMPACT_QUERY) : null;
232
260
  // A server-rendered head names the sidebar before the sidebar renders; the button learns its real id now.
233
261
  for (const toggle of eventRoot.querySelectorAll(TOGGLE_SELECTOR)) overlayTarget(toggle);
234
262
  const openOverlay = target => {
@@ -269,12 +297,28 @@ export const installAppWorkspaceController = (options = {}) => {
269
297
  };
270
298
  const onClick = event => {
271
299
  const target = eventElement(event);
300
+ const detailButton = target?.closest(DETAIL_TOGGLE_SELECTOR);
301
+ if (detailButton) {
302
+ const root = workspaceRoot(detailButton);
303
+ const aside = root ? controlledPanel(root, detailButton) : null;
304
+ if (!aside || aside.hidden || !detailWaiting(aside) || claimedToggleClicks.has(event)) return;
305
+ claimedToggleClicks.add(event);
306
+ if (detailDrawer(aside)) parkDetailDrawer(aside);else {
307
+ aside.dataset.workspaceDetailDrawer = "open";
308
+ detailButton.setAttribute("aria-expanded", "true");
309
+ syncDetailDrawerSpace(aside);
310
+ if (event.detail === 0) requestTitle(aside);else detailButton.focus({
311
+ preventScroll: true
312
+ });
313
+ }
314
+ return;
315
+ }
272
316
  const toggle = target?.closest(TOGGLE_SELECTOR);
273
317
  if (toggle) {
274
318
  const next = overlayTarget(toggle);
275
319
  if (!next || claimedToggleClicks.has(event)) return;
276
320
  claimedToggleClicks.add(event);
277
- if (overlay?.sidebar === next.sidebar) closeOverlay("button");else if (compact?.matches) openOverlay(next);
321
+ if (overlay?.sidebar === next.sidebar) closeOverlay("button");else if (cssState(next.root, "--k2b-workspace-sidebar-form") === "overlay") openOverlay(next);
278
322
  return;
279
323
  }
280
324
  if (!overlay || !target) return;
@@ -310,6 +354,11 @@ export const installAppWorkspaceController = (options = {}) => {
310
354
  // Dialogs and popovers keep their own Tab order.
311
355
  const page = phone?.matches ? allRoots().flatMap(openDetails).find(phonePage) : undefined;
312
356
  if (!page || ownerDocument.querySelector("dialog[open], [aria-modal='true']") || target.closest("[popover]")) return;
357
+ if (target !== ownerDocument.body) {
358
+ const rect = target.getBoundingClientRect();
359
+ const hit = ownerDocument.elementFromPoint(rect.left + rect.width / 2, rect.top + rect.height / 2);
360
+ if (hit && target.contains(hit)) return;
361
+ }
313
362
  const stops = tabStopsIn(page);
314
363
  event.preventDefault();
315
364
  (event.shiftKey ? stops.at(-1) : stops[0])?.focus();
@@ -334,12 +383,37 @@ export const installAppWorkspaceController = (options = {}) => {
334
383
  first.focus();
335
384
  }
336
385
  };
337
- const onCompactChange = () => {
338
- if (!compact?.matches) closeOverlay("none");
386
+ // Whether each open detail waited at the last check, so a column that starts
387
+ // waiting under focus hands that focus to its Details button.
388
+ const detailWasWaiting = new WeakMap();
389
+ const syncHostState = () => {
390
+ if (overlay && cssState(overlay.root, "--k2b-workspace-sidebar-form") !== "overlay") closeOverlay("none");
391
+ for (const root of allRoots()) {
392
+ // A drawer removed with its panel leaves no space behind in Content.
393
+ for (const content of rootElements(root, ".k2b-app-workspace__content")) if (content.style.getPropertyValue("--k2b-detail-space") && !content.querySelector(DETAIL_DRAWER_SELECTOR)) content.style.removeProperty("--k2b-detail-space");
394
+ for (const aside of rootElements(root, detailSelector)) {
395
+ if (aside.hidden) {
396
+ detailWasWaiting.delete(aside);
397
+ parkDetailDrawer(aside);
398
+ continue;
399
+ }
400
+ const waiting = detailWaiting(aside);
401
+ const before = detailWasWaiting.get(aside);
402
+ detailWasWaiting.set(aside, waiting);
403
+ if (!waiting) {
404
+ // The Details button hides with the waiting; its focus moves to the returning column's title.
405
+ const toggleFocused = detailToggle(aside)?.contains(ownerDocument.activeElement) ?? false;
406
+ parkDetailDrawer(aside);
407
+ if (toggleFocused) focusTitle(aside);
408
+ } else if (detailDrawer(aside)) syncDetailDrawerSpace(aside);else if (before !== true && aside.contains(ownerDocument.activeElement)) detailToggle(aside)?.focus({
409
+ preventScroll: true
410
+ });
411
+ }
412
+ }
339
413
  };
340
414
  const phone = typeof window.matchMedia === "function" ? window.matchMedia("(max-width: 47.999rem)") : null;
341
415
  const wide = typeof window.matchMedia === "function" ? window.matchMedia("(min-width: 48rem)") : null;
342
- const touchDrawer = typeof window.matchMedia === "function" ? window.matchMedia(`${COMPACT_QUERY} and (pointer: coarse)`) : null;
416
+ const touchDrawer = typeof window.matchMedia === "function" ? window.matchMedia(TOUCH_DRAWER_QUERY) : null;
343
417
  const detailSelector = ".k2b-app-workspace__detail";
344
418
  const grabberSelector = ".k2b-app-workspace__detail-grabber";
345
419
  const detailHidden = new WeakMap();
@@ -499,7 +573,7 @@ export const installAppWorkspaceController = (options = {}) => {
499
573
  delete aside.dataset.workspaceDetailDragging;
500
574
  };
501
575
  const anchorItem = (root, aside, snapshot) => {
502
- if (!wide?.matches || touchDrawer?.matches && closable(aside) || !snapshot?.item.isConnected) return;
576
+ if (!wide?.matches || touchDrawer?.matches && closable(aside) || detailDrawer(aside) || !snapshot?.item.isConnected) return;
503
577
  if (!mainElement(root)?.contains(snapshot.item) || snapshot.item.closest(ROOT_SELECTOR) !== root) return;
504
578
  const scroller = snapshot.scroller;
505
579
  if (scroller?.isConnected && scroller.scrollTop === snapshot.scrollTop) scroller.scrollTop += snapshot.item.getBoundingClientRect().top - snapshot.top;
@@ -605,6 +679,7 @@ export const installAppWorkspaceController = (options = {}) => {
605
679
  const followedInteraction = snapshot?.fresh ?? false;
606
680
  if (snapshot) snapshot.fresh = false;
607
681
  if (aside.hidden) {
682
+ parkDetailDrawer(aside);
608
683
  if (pendingTitle?.aside === aside) cancelTitle();
609
684
  if (panelStep === aside) panelStep = null;
610
685
  if (root.hasAttribute("data-workspace-motion") && !prefersReducedMotion() && wide?.matches) {
@@ -633,6 +708,7 @@ export const installAppWorkspaceController = (options = {}) => {
633
708
  if (detailDrag?.aside === aside) finishDetailDrag(true);
634
709
  return;
635
710
  }
711
+ if (detailWaiting(aside) && !detailDrawer(aside)) return;
636
712
  anchorItem(root, aside, snapshot);
637
713
  if (phone?.matches) setDetent(aside, false);
638
714
  if (followedInteraction && snapshot) {
@@ -653,13 +729,18 @@ export const installAppWorkspaceController = (options = {}) => {
653
729
  const root = target.closest(ROOT_SELECTOR);
654
730
  let aside = target.closest(detailSelector);
655
731
  if (aside?.hidden || aside && (!eventRoot.contains(aside) || aside.closest(ROOT_SELECTOR) !== root)) aside = null;
656
- if (!aside && root && observedRoots.has(root) && mainElement(root)?.contains(target)) aside = openDetails(root)[0] ?? null;
732
+ if (!aside && root && observedRoots.has(root) && (mainElement(root)?.contains(target) || target.closest(DETAIL_TOGGLE_SELECTOR))) aside = openDetails(root).find(isVisible) ?? null;
657
733
  if (!aside && target === ownerDocument.body) {
658
- const open = allRoots().flatMap(openDetails);
734
+ const open = allRoots().flatMap(openDetails).filter(isVisible);
659
735
  if (open.length === 1) aside = open[0];
660
736
  }
661
737
  const owningRoot = aside?.closest(ROOT_SELECTOR);
662
- if (!aside || !owningRoot) return;
738
+ if (!aside || !owningRoot || !isVisible(aside)) return;
739
+ if (event.key === "Escape" && detailDrawer(aside)) {
740
+ parkDetailDrawer(aside, true);
741
+ event.preventDefault();
742
+ return;
743
+ }
663
744
  if (event.key === "Escape" && closable(aside)) requestClose(aside);else if ((event.key.toLowerCase() === "j" || event.key.toLowerCase() === "k") && aside.hasAttribute("data-workspace-detail-steppable")) {
664
745
  const main = mainElement(owningRoot);
665
746
  const inMain = remembered.get(owningRoot)?.item.contains(target) || main?.contains(target);
@@ -1196,14 +1277,43 @@ export const installAppWorkspaceController = (options = {}) => {
1196
1277
  reconcileFrame = requestAnimationFrame(() => {
1197
1278
  reconcileFrame = null;
1198
1279
  reconcile();
1280
+ // Reconciling can restore a drawer's persisted width; its trail space follows.
1281
+ for (const root of allRoots()) for (const aside of rootElements(root, DETAIL_DRAWER_SELECTOR)) syncDetailDrawerSpace(aside);
1199
1282
  });
1200
1283
  };
1201
- const onResize = () => scheduleReconcile();
1284
+ const onResize = () => {
1285
+ syncHostState();
1286
+ scheduleReconcile();
1287
+ };
1202
1288
  const observedRoots = new Set();
1203
1289
  const resizeObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => {
1290
+ syncHostState();
1204
1291
  scheduleReconcile();
1205
1292
  });
1293
+ // A host can change its width while a workspace with a fixed width keeps
1294
+ // its own, so the controller also watches each root's nearest named host.
1295
+ const observedHosts = new Set();
1296
+ // Found once per root: reading styles on every mutation would cost a style pass.
1297
+ const rootHosts = new WeakMap();
1298
+ const hostOf = root => {
1299
+ if (rootHosts.has(root)) return rootHosts.get(root);
1300
+ let host = null;
1301
+ for (let element = root.parentElement; element && !host; element = element.parentElement) if (getComputedStyle(element).containerName.split(/\s+/).includes("k2b-app-area")) host = element;
1302
+ rootHosts.set(root, host);
1303
+ return host;
1304
+ };
1206
1305
  const syncObservedRoots = () => {
1306
+ const hosts = new Set(allRoots().map(hostOf).filter(host => host !== null));
1307
+ observedHosts.forEach(host => {
1308
+ if (hosts.has(host)) return;
1309
+ resizeObserver?.unobserve(host);
1310
+ observedHosts.delete(host);
1311
+ });
1312
+ hosts.forEach(host => {
1313
+ if (observedHosts.has(host)) return;
1314
+ observedHosts.add(host);
1315
+ resizeObserver?.observe(host);
1316
+ });
1207
1317
  for (const elements of [touchedDetails, titleTabIndices, motionRoots]) {
1208
1318
  elements.forEach(element => {
1209
1319
  if (!element.isConnected) elements.delete(element);
@@ -1265,6 +1375,8 @@ export const installAppWorkspaceController = (options = {}) => {
1265
1375
  const changed = records.some(record => record.type === "attributes" ? record.target instanceof Element && record.target.matches(LAYOUT_REGION_SELECTOR) : [...Array.from(record.addedNodes), ...Array.from(record.removedNodes)].some(layoutNode));
1266
1376
  if (!changed) return;
1267
1377
  syncObservedRoots();
1378
+ // A new width token or a removed panel can end waiting without any box resizing.
1379
+ if (records.some(record => record.type === "childList" || record.attributeName === "data-width")) syncHostState();
1268
1380
  scheduleReconcile();
1269
1381
  });
1270
1382
  eventRoot.addEventListener("pointerdown", onPointerDown);
@@ -1289,7 +1401,7 @@ export const installAppWorkspaceController = (options = {}) => {
1289
1401
  });
1290
1402
  eventRoot.addEventListener("touchend", onDetailTouchEnd);
1291
1403
  eventRoot.addEventListener("touchcancel", onDetailTouchEnd);
1292
- compact?.addEventListener("change", onCompactChange);
1404
+ phone?.addEventListener("change", syncHostState);
1293
1405
  phone?.addEventListener("change", syncPhonePages);
1294
1406
  eventRoot.addEventListener("keydown", onKeyDown);
1295
1407
  eventRoot.addEventListener("focusin", onFocusIn);
@@ -1299,7 +1411,7 @@ export const installAppWorkspaceController = (options = {}) => {
1299
1411
  mutationObserver?.observe(eventRoot, {
1300
1412
  attributes: true,
1301
1413
  attributeOldValue: true,
1302
- attributeFilter: ["hidden", "data-workspace-level-shown"],
1414
+ attributeFilter: ["hidden", "data-workspace-level-shown", "data-width"],
1303
1415
  childList: true,
1304
1416
  subtree: true
1305
1417
  });
@@ -1348,11 +1460,12 @@ export const installAppWorkspaceController = (options = {}) => {
1348
1460
  mutationObserver?.disconnect();
1349
1461
  resizeObserver?.disconnect();
1350
1462
  observedRoots.clear();
1463
+ observedHosts.clear();
1351
1464
  closeOverlay("none");
1352
1465
  eventRoot.removeEventListener("pointerdown", onPointerDown);
1353
1466
  eventRoot.removeEventListener("click", onClick);
1354
1467
  ownerDocument.removeEventListener("keydown", onOverlayKeyDown);
1355
- compact?.removeEventListener("change", onCompactChange);
1468
+ phone?.removeEventListener("change", syncHostState);
1356
1469
  eventRoot.removeEventListener("keydown", onKeyDown);
1357
1470
  eventRoot.removeEventListener("focusin", onFocusIn);
1358
1471
  window.removeEventListener("resize", onResize);