@slashsuite/ui-react 0.12.1 → 0.13.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 (367) hide show
  1. package/MIGRATING.md +386 -8
  2. package/README.md +89 -44
  3. package/agent-docs/components/app-shell.md +9 -6
  4. package/agent-docs/components/article-layout.md +140 -0
  5. package/agent-docs/components/audio.md +42 -0
  6. package/agent-docs/components/badge.md +2 -1
  7. package/agent-docs/components/body-text.md +26 -15
  8. package/agent-docs/components/bottom-sheet.md +27 -17
  9. package/agent-docs/components/breadcrumbs.md +10 -6
  10. package/agent-docs/components/button.md +2 -2
  11. package/agent-docs/components/call-to-action.md +59 -0
  12. package/agent-docs/components/callout.md +4 -3
  13. package/agent-docs/components/card-grid.md +15 -7
  14. package/agent-docs/components/card.md +33 -18
  15. package/agent-docs/components/cart-button.md +63 -0
  16. package/agent-docs/components/chat-composer.md +4 -3
  17. package/agent-docs/components/checkbox.md +11 -5
  18. package/agent-docs/components/cluster.md +10 -8
  19. package/agent-docs/components/code-example.md +2 -2
  20. package/agent-docs/components/code.md +7 -5
  21. package/agent-docs/components/colour-scheme-toggle.md +12 -6
  22. package/agent-docs/components/colour-swatch.md +41 -0
  23. package/agent-docs/components/combobox.md +88 -0
  24. package/agent-docs/components/confirm-dialog.md +98 -0
  25. package/agent-docs/components/container.md +2 -1
  26. package/agent-docs/components/copy-button.md +7 -5
  27. package/agent-docs/components/copy-line.md +6 -5
  28. package/agent-docs/components/date-field.md +14 -11
  29. package/agent-docs/components/date-range-picker.md +16 -9
  30. package/agent-docs/components/date-time-field.md +73 -0
  31. package/agent-docs/components/dialog.md +22 -68
  32. package/agent-docs/components/disclosure.md +4 -0
  33. package/agent-docs/components/docs-layout.md +10 -6
  34. package/agent-docs/components/drawer.md +13 -4
  35. package/agent-docs/components/embed-frame.md +48 -0
  36. package/agent-docs/components/empty-state.md +4 -1
  37. package/agent-docs/components/field-dialog.md +6 -5
  38. package/agent-docs/components/field.md +10 -7
  39. package/agent-docs/components/fieldset.md +4 -4
  40. package/agent-docs/components/flow-diagram.md +87 -0
  41. package/agent-docs/components/form-layout.md +4 -1
  42. package/agent-docs/components/form-row.md +7 -7
  43. package/agent-docs/components/full-bleed-layout.md +0 -2
  44. package/agent-docs/components/headings.md +13 -7
  45. package/agent-docs/components/hero.md +11 -2
  46. package/agent-docs/components/icon-button.md +1 -3
  47. package/agent-docs/components/icon.md +6 -13
  48. package/agent-docs/components/image.md +24 -14
  49. package/agent-docs/components/input.md +8 -7
  50. package/agent-docs/components/key-value-list.md +4 -1
  51. package/agent-docs/components/lightbox.md +1 -1
  52. package/agent-docs/components/list-layout.md +5 -7
  53. package/agent-docs/components/list-row.md +37 -34
  54. package/agent-docs/components/loading.md +2 -2
  55. package/agent-docs/components/markdown.md +13 -13
  56. package/agent-docs/components/media-tile.md +8 -4
  57. package/agent-docs/components/menu.md +19 -12
  58. package/agent-docs/components/meta-list.md +2 -2
  59. package/agent-docs/components/morph.md +11 -5
  60. package/agent-docs/components/navigation-progress.md +2 -2
  61. package/agent-docs/components/number-field.md +75 -0
  62. package/agent-docs/components/outline-region.md +19 -8
  63. package/agent-docs/components/page-fade.md +2 -1
  64. package/agent-docs/components/pill.md +7 -6
  65. package/agent-docs/components/popover.md +63 -0
  66. package/agent-docs/components/price.md +49 -0
  67. package/agent-docs/components/product-tile.md +78 -0
  68. package/agent-docs/components/promo-banner.md +46 -0
  69. package/agent-docs/components/prose-layout.md +1 -1
  70. package/agent-docs/components/radio-group.md +9 -6
  71. package/agent-docs/components/scroll-strip.md +3 -3
  72. package/agent-docs/components/segmented-control.md +4 -2
  73. package/agent-docs/components/select.md +8 -3
  74. package/agent-docs/components/show.md +2 -2
  75. package/agent-docs/components/side-column.md +13 -9
  76. package/agent-docs/components/sidebar-layout.md +1 -1
  77. package/agent-docs/components/site-footer.md +4 -4
  78. package/agent-docs/components/site-search.md +21 -9
  79. package/agent-docs/components/slider.md +59 -0
  80. package/agent-docs/components/sortable-list.md +15 -10
  81. package/agent-docs/components/stack.md +3 -3
  82. package/agent-docs/components/stacked-bar.md +7 -4
  83. package/agent-docs/components/state-machine.md +95 -0
  84. package/agent-docs/components/status-pages.md +13 -6
  85. package/agent-docs/components/stepper.md +54 -0
  86. package/agent-docs/components/switch.md +4 -4
  87. package/agent-docs/components/table-of-contents.md +78 -0
  88. package/agent-docs/components/table.md +35 -24
  89. package/agent-docs/components/tabs.md +24 -26
  90. package/agent-docs/components/text-link.md +12 -7
  91. package/agent-docs/components/textarea.md +4 -2
  92. package/agent-docs/components/toast.md +19 -14
  93. package/agent-docs/components/video.md +7 -2
  94. package/agent-docs/llms.txt +22 -3
  95. package/dist/AppShell.d.ts +25 -9
  96. package/dist/AppShell.js +67 -33
  97. package/dist/AppShellMenu.d.ts +31 -18
  98. package/dist/AppShellMenu.js +72 -45
  99. package/dist/ArticleLayout.d.ts +36 -0
  100. package/dist/ArticleLayout.js +27 -0
  101. package/dist/Audio.d.ts +16 -0
  102. package/dist/Audio.js +11 -0
  103. package/dist/Badge.d.ts +2 -1
  104. package/dist/Badge.js +3 -2
  105. package/dist/BottomSheet.d.ts +17 -6
  106. package/dist/BottomSheet.js +62 -11
  107. package/dist/Breadcrumbs.d.ts +8 -6
  108. package/dist/Breadcrumbs.js +17 -7
  109. package/dist/Button.d.ts +1 -0
  110. package/dist/Button.js +4 -3
  111. package/dist/CallToAction.d.ts +25 -0
  112. package/dist/CallToAction.js +17 -0
  113. package/dist/Callout.d.ts +2 -2
  114. package/dist/Callout.js +2 -2
  115. package/dist/Card.d.ts +88 -31
  116. package/dist/Card.js +55 -92
  117. package/dist/CardBody.d.ts +2 -0
  118. package/dist/CardBody.js +33 -3
  119. package/dist/CardGrid.d.ts +32 -4
  120. package/dist/CardGrid.js +42 -8
  121. package/dist/CardParts.d.ts +7 -1
  122. package/dist/CardParts.js +7 -2
  123. package/dist/CartButton.d.ts +33 -0
  124. package/dist/CartButton.js +18 -0
  125. package/dist/ChatComposer.d.ts +10 -4
  126. package/dist/ChatComposer.js +35 -13
  127. package/dist/Checkbox.d.ts +21 -3
  128. package/dist/Checkbox.js +66 -20
  129. package/dist/Chevron.js +1 -1
  130. package/dist/Cluster.d.ts +28 -15
  131. package/dist/Cluster.js +21 -4
  132. package/dist/Code.d.ts +15 -3
  133. package/dist/Code.js +23 -3
  134. package/dist/CodeBlock.d.ts +4 -4
  135. package/dist/CodeBlock.js +2 -2
  136. package/dist/CodeBody.d.ts +1 -1
  137. package/dist/CodeBody.js +4 -10
  138. package/dist/CodeExample.d.ts +1 -1
  139. package/dist/CodeExample.js +3 -2
  140. package/dist/ColourSchemeToggle.d.ts +21 -5
  141. package/dist/ColourSchemeToggle.js +15 -9
  142. package/dist/ColourSwatch.d.ts +15 -0
  143. package/dist/ColourSwatch.js +14 -0
  144. package/dist/Combobox.d.ts +42 -0
  145. package/dist/Combobox.js +43 -0
  146. package/dist/ConfirmDialog.d.ts +40 -0
  147. package/dist/ConfirmDialog.js +36 -0
  148. package/dist/Container.d.ts +3 -3
  149. package/dist/Container.js +1 -1
  150. package/dist/CopyButton.d.ts +8 -2
  151. package/dist/CopyButton.js +38 -28
  152. package/dist/CopyLine.d.ts +4 -2
  153. package/dist/CopyLine.js +4 -4
  154. package/dist/DateCalendar.d.ts +2 -0
  155. package/dist/DateCalendar.js +11 -9
  156. package/dist/DateField.d.ts +52 -21
  157. package/dist/DateField.js +73 -37
  158. package/dist/DateFieldCalendar.d.ts +12 -8
  159. package/dist/DateFieldCalendar.js +37 -18
  160. package/dist/DateRangePicker.d.ts +23 -3
  161. package/dist/DateRangePicker.js +10 -8
  162. package/dist/DateTimeField.d.ts +31 -0
  163. package/dist/DateTimeField.js +19 -0
  164. package/dist/Dialog.d.ts +42 -6
  165. package/dist/Dialog.js +50 -12
  166. package/dist/Disclosure.js +9 -1
  167. package/dist/DocsLayout.d.ts +13 -5
  168. package/dist/DocsLayout.js +11 -9
  169. package/dist/Drawer.d.ts +22 -7
  170. package/dist/Drawer.js +89 -8
  171. package/dist/EmbedFrame.d.ts +36 -0
  172. package/dist/EmbedFrame.js +18 -0
  173. package/dist/Field.d.ts +41 -4
  174. package/dist/Field.js +61 -25
  175. package/dist/FieldDialog.d.ts +8 -3
  176. package/dist/FieldDialog.js +19 -9
  177. package/dist/Fieldset.d.ts +3 -3
  178. package/dist/Fieldset.js +7 -9
  179. package/dist/FileDrop.js +2 -1
  180. package/dist/FlowDiagram.d.ts +92 -0
  181. package/dist/FlowDiagram.js +100 -0
  182. package/dist/FormRow.d.ts +6 -4
  183. package/dist/FormRow.js +11 -9
  184. package/dist/Hero.d.ts +30 -7
  185. package/dist/Hero.js +23 -9
  186. package/dist/Icon.d.ts +1 -1
  187. package/dist/Icon.js +1 -1
  188. package/dist/IconButton.js +1 -1
  189. package/dist/Image.d.ts +33 -9
  190. package/dist/Image.js +61 -16
  191. package/dist/Input.d.ts +1 -1
  192. package/dist/Input.js +4 -4
  193. package/dist/InputShell.d.ts +7 -0
  194. package/dist/InputShell.js +18 -3
  195. package/dist/KeyValueList.d.ts +2 -2
  196. package/dist/Lightbox.js +5 -3
  197. package/dist/ListRow.d.ts +4 -5
  198. package/dist/ListRow.js +36 -26
  199. package/dist/Mark.d.ts +10 -0
  200. package/dist/Mark.js +9 -0
  201. package/dist/Markdown.d.ts +18 -4
  202. package/dist/Markdown.js +176 -37
  203. package/dist/MediaTile.d.ts +9 -3
  204. package/dist/MediaTile.js +8 -4
  205. package/dist/Menu.d.ts +19 -8
  206. package/dist/Menu.js +13 -11
  207. package/dist/MetaList.d.ts +4 -3
  208. package/dist/MetaList.js +12 -4
  209. package/dist/Morph.d.ts +15 -1
  210. package/dist/Morph.js +70 -22
  211. package/dist/NavigationProgress.d.ts +2 -2
  212. package/dist/NavigationProgress.js +7 -5
  213. package/dist/NumberField.d.ts +66 -0
  214. package/dist/NumberField.js +68 -0
  215. package/dist/OutlineRegion.d.ts +41 -10
  216. package/dist/OutlineRegion.js +31 -6
  217. package/dist/PageFade.d.ts +9 -5
  218. package/dist/PageFade.js +39 -8
  219. package/dist/PageLayouts.d.ts +15 -5
  220. package/dist/PageLayouts.js +3 -3
  221. package/dist/Pill.d.ts +9 -4
  222. package/dist/Pill.js +15 -6
  223. package/dist/Popover.d.ts +31 -0
  224. package/dist/Popover.js +43 -0
  225. package/dist/Price.d.ts +21 -0
  226. package/dist/Price.js +34 -0
  227. package/dist/ProductTile.d.ts +36 -0
  228. package/dist/ProductTile.js +31 -0
  229. package/dist/ProgressBar.js +4 -2
  230. package/dist/PromoBanner.d.ts +25 -0
  231. package/dist/PromoBanner.js +16 -0
  232. package/dist/RadioGroup.d.ts +18 -8
  233. package/dist/RadioGroup.js +42 -18
  234. package/dist/ScrollStrip.d.ts +1 -1
  235. package/dist/ScrollStrip.js +1 -1
  236. package/dist/SearchInput.d.ts +17 -2
  237. package/dist/SearchInput.js +72 -13
  238. package/dist/SegmentedField.d.ts +15 -0
  239. package/dist/SegmentedField.js +15 -0
  240. package/dist/Select.js +5 -4
  241. package/dist/Show.d.ts +1 -1
  242. package/dist/Show.js +1 -1
  243. package/dist/SideColumn.d.ts +42 -15
  244. package/dist/SideColumn.js +45 -19
  245. package/dist/SiteFooter.d.ts +3 -3
  246. package/dist/SiteFooter.js +4 -3
  247. package/dist/SiteSearch.d.ts +57 -27
  248. package/dist/SiteSearch.js +13 -93
  249. package/dist/Slider.d.ts +27 -0
  250. package/dist/Slider.js +58 -0
  251. package/dist/SortableList.d.ts +19 -35
  252. package/dist/SortableList.js +36 -88
  253. package/dist/Stack.d.ts +4 -4
  254. package/dist/StackedBar.d.ts +13 -4
  255. package/dist/StackedBar.js +12 -7
  256. package/dist/StateMachine.d.ts +65 -0
  257. package/dist/StateMachine.js +113 -0
  258. package/dist/StatusPages.d.ts +28 -10
  259. package/dist/StatusPages.js +10 -10
  260. package/dist/Stepper.d.ts +21 -0
  261. package/dist/Stepper.js +33 -0
  262. package/dist/Steps.js +4 -3
  263. package/dist/Switch.d.ts +3 -3
  264. package/dist/Switch.js +18 -14
  265. package/dist/Table.d.ts +32 -9
  266. package/dist/Table.js +50 -20
  267. package/dist/TableCells.d.ts +24 -21
  268. package/dist/TableCells.js +68 -27
  269. package/dist/TableEditCell.d.ts +1 -1
  270. package/dist/TableOfContents.d.ts +34 -0
  271. package/dist/TableOfContents.js +23 -0
  272. package/dist/Tabs.d.ts +31 -16
  273. package/dist/Tabs.js +97 -22
  274. package/dist/TextLink.d.ts +18 -5
  275. package/dist/TextLink.js +19 -6
  276. package/dist/Textarea.d.ts +12 -1
  277. package/dist/Textarea.js +15 -2
  278. package/dist/ToastRegion.d.ts +17 -9
  279. package/dist/ToastRegion.js +70 -13
  280. package/dist/Tooltip.d.ts +10 -2
  281. package/dist/Tooltip.js +32 -11
  282. package/dist/Video.d.ts +19 -4
  283. package/dist/Video.js +15 -5
  284. package/dist/cardContext.d.ts +7 -0
  285. package/dist/cardContext.js +14 -0
  286. package/dist/cardControl.d.ts +15 -0
  287. package/dist/cardControl.js +32 -0
  288. package/dist/cardForm.d.ts +39 -0
  289. package/dist/cardForm.js +81 -0
  290. package/dist/cardWait.js +2 -1
  291. package/dist/colourScheme.d.ts +12 -2
  292. package/dist/colourScheme.js +32 -6
  293. package/dist/control.d.ts +30 -8
  294. package/dist/control.js +74 -7
  295. package/dist/copyScript.d.ts +7 -8
  296. package/dist/copyScript.js +8 -9
  297. package/dist/cx.d.ts +22 -3
  298. package/dist/cx.js +22 -3
  299. package/dist/dateLocale.d.ts +17 -0
  300. package/dist/dateLocale.js +30 -0
  301. package/dist/density.d.ts +15 -1
  302. package/dist/density.js +27 -8
  303. package/dist/emptySlot.d.ts +1 -0
  304. package/dist/fieldAnnounce.d.ts +11 -0
  305. package/dist/fieldAnnounce.js +36 -0
  306. package/dist/fieldControl.d.ts +7 -2
  307. package/dist/fieldControl.js +6 -2
  308. package/dist/fieldWait.d.ts +3 -3
  309. package/dist/fieldWait.js +3 -4
  310. package/dist/flowLayout.d.ts +68 -0
  311. package/dist/flowLayout.js +105 -0
  312. package/dist/fromXState.d.ts +73 -0
  313. package/dist/fromXState.js +110 -0
  314. package/dist/icons.d.ts +1 -1
  315. package/dist/icons.js +15 -0
  316. package/dist/index.d.ts +37 -11
  317. package/dist/index.js +24 -2
  318. package/dist/isoDate.d.ts +8 -1
  319. package/dist/isoDate.js +20 -1
  320. package/dist/labelWords.d.ts +16 -7
  321. package/dist/labelWords.js +14 -12
  322. package/dist/listRowProps.d.ts +17 -15
  323. package/dist/modal.d.ts +5 -0
  324. package/dist/modal.js +21 -1
  325. package/dist/navFold.js +6 -3
  326. package/dist/optionCard.d.ts +18 -0
  327. package/dist/optionCard.js +16 -0
  328. package/dist/scrollBody.d.ts +16 -0
  329. package/dist/scrollBody.js +15 -0
  330. package/dist/scrollEdges.d.ts +7 -0
  331. package/dist/scrollEdges.js +39 -5
  332. package/dist/scrollStop.d.ts +6 -2
  333. package/dist/scrollStop.js +24 -8
  334. package/dist/shownDate.d.ts +28 -10
  335. package/dist/shownDate.js +41 -22
  336. package/dist/siteSearchBody.d.ts +34 -0
  337. package/dist/siteSearchBody.js +117 -0
  338. package/dist/size.d.ts +7 -1
  339. package/dist/sortableDrop.d.ts +44 -0
  340. package/dist/sortableDrop.js +78 -0
  341. package/dist/sortableSlide.d.ts +9 -0
  342. package/dist/sortableSlide.js +70 -0
  343. package/dist/sortableTitle.d.ts +10 -0
  344. package/dist/sortableTitle.js +48 -0
  345. package/dist/stateMachineDots.d.ts +45 -0
  346. package/dist/stateMachineDots.js +162 -0
  347. package/dist/stickyColumn.d.ts +2 -2
  348. package/dist/stickyColumn.js +2 -2
  349. package/dist/switcher.d.ts +10 -5
  350. package/dist/switcher.js +7 -5
  351. package/dist/tableColumns.d.ts +17 -0
  352. package/dist/tableColumns.js +30 -2
  353. package/dist/tableEmpty.js +5 -5
  354. package/dist/tableRow.d.ts +26 -2
  355. package/dist/tableRow.js +23 -1
  356. package/dist/tableSort.d.ts +10 -5
  357. package/dist/tableSort.js +15 -4
  358. package/dist/target.d.ts +12 -0
  359. package/dist/target.js +12 -0
  360. package/dist/textBox.js +1 -1
  361. package/dist/truncated.d.ts +31 -0
  362. package/dist/truncated.js +51 -0
  363. package/dist/typography.d.ts +19 -11
  364. package/dist/typography.js +11 -13
  365. package/dist/useFlowLayout.d.ts +27 -0
  366. package/dist/useFlowLayout.js +119 -0
  367. package/package.json +3 -2
package/dist/AppShell.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback, useState } from "react";
3
- import { AppShellMenu } from "./AppShellMenu.js";
2
+ import { useCallback, useId, useState } from "react";
3
+ import { AppShellMenuButton, AppShellMenuPanel } from "./AppShellMenu.js";
4
4
  import { ContainerFrame } from "./Container.js";
5
5
  import { schemeClass } from "./colourScheme.js";
6
6
  import { cx, focusRing } from "./cx.js";
@@ -10,9 +10,15 @@ import { useNavFold } from "./navFold.js";
10
10
  import { useScrollEdges } from "./scrollEdges.js";
11
11
  /**
12
12
  * The class an app puts on its own `<html>`: it always reserves the scrollbar, so centred content
13
- * does not shift between a short page and a long one. AppShell never touches `<html>` itself.
13
+ * does not shift between a short page and a long one, and it paints the page canvas and sets the
14
+ * type face, ink and font smoothing, so a page outside AppShell (a `CenteredLayout` sign-in, a bare
15
+ * error page) looks like one inside it and an app writes no `<body>` or `<html>` styling of its own.
16
+ * A theme's scope class sits on the same element, where its `.<scope> .<utility>` rules do not reach,
17
+ * so the scope block itself sets the canvas, ink and face (unlayered, over these layered utilities).
18
+ * AppShell never touches `<html>` itself. Several classes: add them with `className`, or split them
19
+ * for `classList.add(...)`.
14
20
  */
15
- export const appShellRootClass = "overflow-y-scroll";
21
+ export const appShellRootClass = "overflow-y-scroll bg-gray-50 font-sans text-slate-900 antialiased";
16
22
  /**
17
23
  * Everything an app puts on its own `<html>` from the scheme the server knows: that scheme's class
18
24
  * (`schemeClass`) and the shell's root class, joined: `<html className={appShellRootClassFor(scheme,
@@ -41,8 +47,10 @@ export function AppShellBrand({ logo, logoSize = "md", label, collapse = false,
41
47
  const ROW = "items-center gap-4 overflow-x-clip whitespace-nowrap md:overflow-x-auto *:shrink-0";
42
48
  // From `md`, while a row has more to scroll to on a side, that edge fades out (a mask, so it follows
43
49
  // any theme). `ScrollRow` sets `data-more-start` / `data-more-end` (and `data-more` for either); a
44
- // row that fits has none and is untouched. Below `md` there is no mask, which would clip the menu.
45
- const FADE = "md:data-more-start:[--fade-start:2rem] md:data-more-end:[--fade-end:2rem] md:data-more:[mask-image:linear-gradient(to_right,transparent,#000_var(--fade-start,0px),#000_calc(100%_-_var(--fade-end,0px)),transparent)]";
50
+ // row that fits has none and is untouched. The gradient runs from the inline start, so it flips
51
+ // right to left. While the keyboard's focus is in the row (`focus-visible`) the mask is off, so a
52
+ // focus ring at a faded edge stays whole. Below `md` there is no mask, which would clip the menu.
53
+ const FADE = "[--fade-dir:to_right] rtl:[--fade-dir:to_left] md:data-more-start:[--fade-start:2rem] md:data-more-end:[--fade-end:2rem] md:data-more:[mask-image:linear-gradient(var(--fade-dir),transparent,#000_var(--fade-start,0px),#000_calc(100%_-_var(--fade-end,0px)),transparent)] md:data-more:has-focus-visible:[mask-image:none]";
46
54
  /** A row in a Container, with the fade on whichever side still has content to scroll to. `onRow` is also handed the row. */
47
55
  function ScrollRow({ className, onRow, children, }) {
48
56
  const [row, setRow] = useState(null);
@@ -54,27 +62,52 @@ function ScrollRow({ className, onRow, children, }) {
54
62
  return (_jsx(ContainerFrame, { ref: attach, className: cx(ROW, FADE, className), children: children }));
55
63
  }
56
64
  /**
57
- * The header row's slots in order: brand, nav (from `md`), the free `children`, then `controls` and
58
- * the menu at the end. `controls` have a wrapper of their own that shrinks and clips, and the menu
65
+ * The row's end: `controls`, then the Menu button (`children`). Below `md` this wrapper may shrink
66
+ * (the row's `*:shrink-0` is overridden), so a crowded `controls` clips inside its own box and the
67
+ * button stays on screen; from `md` it keeps its width and the row scrolls.
68
+ */
69
+ function HeaderEnd({ controls, folded, afterMenuControls, children, }) {
70
+ return (_jsxs("div", { className: cx("ml-auto flex min-w-0 items-center gap-2 max-md:shrink!", afterMenuControls && !folded && "md:ml-0", !controls && !folded && "md:hidden"), children: [controls && (_jsx("div", { className: "flex min-w-0 items-center gap-2 *:shrink-0 max-md:-mx-1 max-md:overflow-x-clip max-md:px-1 [&>.w-full]:w-auto", children: controls })), children] }));
71
+ }
72
+ /** The sticky header's box. */
73
+ function headerClass(hideChromeInPrint) {
74
+ return cx("group/shell sticky top-0 z-10 border-b border-slate-200 bg-white/95 pt-[env(safe-area-inset-top)]", hideChromeInPrint && "print:hidden");
75
+ }
76
+ /**
77
+ * The sticky header: one row of slots in order, brand, the menu panel (`nav` and `menuControls`,
78
+ * each rendered once, and the phone's `subnav`), the free `children`, then `controls` and the Menu
79
+ * button at the end. `controls` have a wrapper of their own that shrinks and clips, and the button
59
80
  * sits beside it, so a crowded `controls` never pushes the Menu off a phone screen. From `md` the
60
- * menu is the inline row of `menuControls` after `controls`. `folded` hides the nav from `md` too:
61
- * it is in the menu.
81
+ * panel's parts are the row's (`AppShellMenuPanel`), the subnav is a second row under it, outside
82
+ * the first row's fade, and a nav that does not fit folds the panel back into menu mode (`folded`).
83
+ * The markup is in the order the eye reads, so the focus follows it. It pads by the top safe-area
84
+ * inset.
62
85
  */
63
- function HeaderSlots({ brand, nav, controls, menu, menuInline, folded, children, }) {
64
- return (_jsxs(_Fragment, { children: [brand && (_jsx("div", { className: "flex items-center gap-2 text-base font-bold tracking-tight text-slate-900", children: brand })), nav && (_jsx("div", { className: cx("hidden items-center gap-4 *:shrink-0", !folded && "md:flex"), children: nav })), children, (controls || menu) && (_jsxs("div", { className: cx(
65
- // Below `md` this wrapper may shrink (the row's `*:shrink-0` is overridden), so a crowded
66
- // `controls` clips inside its own box; from `md` it keeps its width and the row scrolls.
67
- "ml-auto flex min-w-0 items-center gap-2 max-md:shrink!", !controls && !menuInline && !folded && "md:hidden"), children: [controls && (_jsx("div", { className: "flex min-w-0 items-center gap-2 *:shrink-0 max-md:-mx-1 max-md:overflow-x-clip max-md:px-1 [&>.w-full]:w-auto", children: controls })), menu] }))] }));
86
+ function AppShellHeader({ brand, nav, controls, menuControls, subnav, menuLabel, folded, onRow, hideChromeInPrint, children, }) {
87
+ const panelId = `${useId()}-menu`;
88
+ const menu = !!(nav || subnav || menuControls);
89
+ return (_jsxs("header", { className: headerClass(hideChromeInPrint), children: [_jsxs(ScrollRow, { className: "flex h-14", onRow: onRow, children: [brand && (_jsx("div", { className: "flex items-center gap-2 text-base font-bold tracking-tight text-slate-900", children: brand })), menu && (_jsx(AppShellMenuPanel, { id: panelId, controls: menuControls, nav: nav, subnav: subnav, folded: folded })), children, (controls || menu) && (_jsx(HeaderEnd, { controls: controls, folded: folded, afterMenuControls: !!menuControls, children: menu && _jsx(AppShellMenuButton, { label: menuLabel, panelId: panelId, folded: folded }) }))] }), subnav && _jsx(ScrollRow, { className: "hidden h-12 md:flex", children: subnav })] }));
90
+ }
91
+ /** The shell's own box: the canvas, ink and face, the bottom inset, and the header's height. */
92
+ function shellClass(subnavRow) {
93
+ return cx("flex min-h-dvh flex-col bg-gray-50 pb-[env(safe-area-inset-bottom)] font-sans text-slate-900 antialiased",
94
+ // The sticky header's height (its rows, the top inset and the bottom border), for a bar
95
+ // that sticks under it. Below `md` it is one row whatever the slots are: the subnav is in the
96
+ // menu. A subnav never folds, so from `md` it is two rows with one.
97
+ "[--app-header:calc(3.5rem+1px+env(safe-area-inset-top))]", subnavRow && "md:[--app-header:calc(6.5rem+1px+env(safe-area-inset-top))]",
98
+ // A link or focus that scrolls to any element with an id stops below the sticky header.
99
+ "[&_[id]]:scroll-mt-[calc(var(--app-header,0px)+1rem)]");
100
+ }
101
+ /** The page's first tab stop, shown only while it has the focus: it moves the focus to `target`. */
102
+ function SkipLink({ target, label }) {
103
+ return (_jsx("a", { href: `#${target}`, className: cx("sr-only z-20 rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm font-medium text-slate-900 focus:not-sr-only focus:fixed focus:top-[calc(env(safe-area-inset-top)+0.5rem)] focus:left-[calc(env(safe-area-inset-left)+0.5rem)]", focusRing), children: label }));
68
104
  }
69
105
  /**
70
- * The sticky header: the one-row slots, and from `md` the `subnav` row under them. It pads by the
71
- * top safe-area inset. From `md` it measures its row: a nav that does not fit folds into the Menu
72
- * (`data-nav-folded`) and comes back when the row is wide enough again (`useNavFold`).
106
+ * The main area, the skip link's target: focusable from script only, so it takes the focus with no
107
+ * ring of its own. In a Container unless `bleed`.
73
108
  */
74
- function AppShellHeader({ brand, nav, controls, menuControls, subnav, menuLabel, hideChromeInPrint, children, }) {
75
- const [row, setRow] = useState(null);
76
- const folded = useNavFold(row, !!nav);
77
- return (_jsxs("header", { "data-nav-folded": folded ? "" : undefined, className: cx("sticky top-0 z-10 border-b border-slate-200 bg-white pt-[env(safe-area-inset-top)]", hideChromeInPrint && "print:hidden"), children: [_jsx(ScrollRow, { className: "flex h-14", onRow: setRow, children: _jsx(HeaderSlots, { brand: brand, nav: nav, controls: controls, menuInline: !!menuControls, folded: folded, menu: (nav || subnav || menuControls) && (_jsx(AppShellMenu, { label: menuLabel, controls: menuControls, nav: nav, subnav: subnav, folded: folded })), children: children }) }), subnav && _jsx(ScrollRow, { className: "hidden h-12 md:flex", children: subnav })] }));
109
+ function ShellMain({ id, bleed, hideChromeInPrint, children, }) {
110
+ return (_jsx("main", { id: id, tabIndex: -1, className: "flex flex-1 flex-col outline-none", children: bleed ? (children) : (_jsx(ContainerFrame, { className: cx("py-8", hideChromeInPrint && "print:p-0"), children: children })) }));
78
111
  }
79
112
  /**
80
113
  * The page frame: it paints the page canvas and sets the type face, ink and font smoothing
@@ -92,8 +125,9 @@ function AppShellHeader({ brand, nav, controls, menuControls, subnav, menuLabel,
92
125
  *
93
126
  * On a phone (below `md`) the header is one 56px row at every page: `brand`, `header`, `controls`
94
127
  * and a "Menu" button (`menuLabel`), and `nav` and `subnav` move into that menu, so every link is
95
- * reachable and nothing scrolls sideways. The menu is a native `<details>`, so it works with the
96
- * keyboard, with a screen reader and on a page that never hydrates. From `md` the header is the
128
+ * reachable and nothing scrolls sideways. The menu is the browser's popover (`popovertarget`), so
129
+ * it works with the keyboard, closes on Escape and a click outside, hands focus back to the button,
130
+ * and opens on a page that never hydrates. From `md` the header is the
97
131
  * row, and the `subnav` row, as they are, except that a `nav` too wide for the row folds into the
98
132
  * Menu and comes back when the screen is wide enough (measured, with script; a `subnav` never
99
133
  * folds, it scrolls sideways with a fade).
@@ -105,15 +139,15 @@ function AppShellHeader({ brand, nav, controls, menuControls, subnav, menuLabel,
105
139
  *
106
140
  * `controls` stay in the row at every width, so keep them few (a theme toggle, the viewer's avatar);
107
141
  * on a phone a crowded `controls` clips, and the Menu button is never the part cut off. Pickers and
108
- * actions that do not fit a phone row go in `menuControls`: rendered once, they sit in the row after
109
- * `controls` from `md`, and below `md` at the top of the Menu, above `nav` and `subnav`.
142
+ * actions that do not fit a phone row go in `menuControls`: rendered once, from `md` they sit at the
143
+ * row's end, before `header` and `controls`, and fold into the Menu with a `nav` that does not fit;
144
+ * below `md` they are at the foot of the Menu, after `nav` and `subnav`. The markup is in the order
145
+ * the row shows, so the focus moves as the eye does.
110
146
  */
111
- export function AppShell({ brand, nav, controls, menuControls, header, subnav, menuLabel = "Menu", footer, bleed = false, printChrome = true, density, children, ...rest }) {
147
+ export function AppShell({ brand, nav, controls, menuControls, header, subnav, menuLabel = "Menu", footer, bleed = false, printChrome = true, density, skipLabel = "Skip to content", children, ...rest }) {
112
148
  const hideChromeInPrint = !printChrome;
113
- return (_jsx(DensityProvider, { type: density, children: _jsxs("div", { ...rest, className: cx("flex min-h-dvh flex-col bg-gray-50 pb-[env(safe-area-inset-bottom)] font-sans text-slate-900 antialiased",
114
- // The sticky header's height (its rows, the top inset and the bottom border), for a bar
115
- // that sticks under it. Below `md` it is one row whatever the slots are: the subnav is in the menu.
116
- "[--app-header:calc(3.5rem+1px+env(safe-area-inset-top))]", subnav ? "md:[--app-header:calc(6.5rem+1px+env(safe-area-inset-top))]" : undefined,
117
- // A link or focus that scrolls to any element with an id stops below the sticky header.
118
- "[&_[id]]:scroll-mt-[calc(var(--app-header,0px)+1rem)]"), children: [_jsx(AppShellHeader, { brand: brand, nav: nav, controls: controls, menuControls: menuControls, subnav: subnav, menuLabel: menuLabel, hideChromeInPrint: hideChromeInPrint, children: header }), _jsx("main", { className: "flex flex-1 flex-col", children: bleed ? (children) : (_jsx(ContainerFrame, { className: cx("py-8", hideChromeInPrint && "print:p-0"), children: children })) }), footer && (_jsx("footer", { className: cx("border-t border-slate-200", hideChromeInPrint && "print:hidden"), children: _jsx(ContainerFrame, { className: "py-6 text-sm text-slate-500", children: footer }) }))] }) }));
149
+ const mainId = `${useId()}-main`;
150
+ const [row, setRow] = useState(null);
151
+ const folded = useNavFold(row, !!nav);
152
+ return (_jsx(DensityProvider, { type: density, children: _jsxs("div", { ...rest, className: shellClass(!!subnav), children: [_jsx(SkipLink, { target: mainId, label: skipLabel }), _jsx(AppShellHeader, { brand: brand, nav: nav, controls: controls, menuControls: menuControls, subnav: subnav, menuLabel: menuLabel, folded: folded, onRow: setRow, hideChromeInPrint: hideChromeInPrint, children: header }), _jsx(ShellMain, { id: mainId, bleed: bleed, hideChromeInPrint: hideChromeInPrint, children: children }), footer && (_jsx("footer", { className: cx("border-t border-slate-200", hideChromeInPrint && "print:hidden"), children: _jsx(ContainerFrame, { className: "py-6 text-sm text-slate-500", children: footer }) }))] }) }));
119
153
  }
@@ -1,26 +1,39 @@
1
1
  import { type ReactElement, type ReactNode } from "react";
2
2
  /**
3
- * The header's phone menu (below `md`): a native `<details>` whose `<summary>` is the button, so it
4
- * opens and closes by pointer, Enter and Space, and is announced as a disclosure with its expanded
5
- * state, all with no script. That is why it also works on a page that is never hydrated. The panel
6
- * is out of flow (it hangs under the header, `top-full`), so the header keeps its one height open
7
- * or closed. With script it also closes on Escape (focus returns to the button) and when a link in
8
- * it is followed, for a router that changes the page without a reload.
9
- *
10
- * `controls` (AppShell's `menuControls`) sit at the top of the panel, above the links. From `md`
11
- * the `<details>` drops its own box and shows only them, inline at the row's end, whether it is
12
- * open or not: the summary and the link copies are hidden (the links render in their own rows from
13
- * `md`) and the panel is a plain row. They are rendered once, so a field keeps its state.
14
- *
15
- * `folded` (the nav did not fit the row from `md`) keeps the summary from `md` too, and its nav copy
16
- * then hangs under the header as the panel does on a phone. The `subnav` copy stays phone only.
3
+ * The header's Menu button: a native `popovertarget` for the panel, so it opens and closes by
4
+ * pointer, Enter and Space and is announced with its expanded state, with no script (a page that
5
+ * never hydrates still has its menu). Shown below `md`, and from `md` while the nav is `folded`.
6
+ * Its icon follows the panel (`:popover-open`, its own and no other popover's) through the header's
7
+ * `group/shell`.
17
8
  */
18
- export declare function AppShellMenu({ label, controls, nav, subnav, folded, }: {
9
+ export declare function AppShellMenuButton({ label, panelId, folded, }: {
19
10
  label: string;
20
- /** Rendered once: at the top of the panel below `md`, inline in the row from `md`. */
21
- controls?: ReactNode;
11
+ panelId: string;
12
+ folded: boolean;
13
+ }): ReactElement;
14
+ /**
15
+ * The one home of AppShell's `nav` and `menuControls`, and the phone's copy of the `subnav`: the nav
16
+ * and `menuControls` are rendered once, here, so a field keeps its state, ids stay unique and a
17
+ * screen reader meets the nav once. It is a `popover="auto"` panel the Menu button targets, so it
18
+ * light-dismisses on a click outside and on Escape, and hands the focus back to the button, all the
19
+ * browser's.
20
+ *
21
+ * In row mode (from `md`, nav not `folded`) the panel draws no box of its own (`display: contents`,
22
+ * over the UA's `display: none`): its parts are the header row's items, the nav after the brand and
23
+ * `menuControls` pushed to the row's end, before `controls`, in the order they are in the markup, so
24
+ * the focus moves as the eye does. The subnav copy is `display: none` there (the header draws the
25
+ * subnav's own row, `display: none` below `md`), so a screen reader meets one subnav at any width.
26
+ * In menu mode (below `md`, or `folded`) it is the dropdown: the nav, the subnav below `md`, then
27
+ * `menuControls`. Script closes it when a link in it is followed (for a router that does not reload)
28
+ * and when the header leaves menu mode while it is open.
29
+ */
30
+ export declare function AppShellMenuPanel({ id, controls, nav, subnav, folded, }: {
31
+ id: string;
32
+ /** AppShell's `menuControls`: last in the panel in menu mode, at the row's end otherwise. */
33
+ controls: ReactNode;
22
34
  nav: ReactNode;
35
+ /** The subnav's phone copy; from `md` the header draws its own row. */
23
36
  subnav: ReactNode;
24
- /** From `md` the nav is in the menu too: it did not fit the row. */
37
+ /** From `md` the header is in menu mode too: the nav did not fit the row. */
25
38
  folded: boolean;
26
39
  }): ReactElement;
@@ -1,7 +1,9 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useRef } from "react";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from "react";
3
3
  import { ContainerFrame } from "./Container.js";
4
4
  import { cx, focusRing } from "./cx.js";
5
+ // AppShell's `md` step: below it the header is always in menu mode.
6
+ const WIDE = "(width >= 48rem)";
5
7
  const ICON = {
6
8
  viewBox: "0 0 20 20",
7
9
  width: 16,
@@ -14,53 +16,78 @@ const ICON = {
14
16
  "aria-hidden": true,
15
17
  className: "shrink-0 text-slate-500",
16
18
  };
17
- // A folded nav from `md`: the phone panel's dropdown, shown while the menu is open. The surface
18
- // colours are unprefixed (below `md` the panel already draws them), so no palette utility takes a variant.
19
- const FOLDED_NAV = "border-slate-200 bg-white md:absolute md:inset-x-0 md:top-full md:hidden md:max-h-[calc(100dvh-var(--app-header))] md:overflow-y-auto md:overscroll-contain md:border-y md:shadow-lg md:group-open:block";
20
19
  /**
21
- * The menu's copies of the links. From `md` the links render in their own rows, so these copies are
22
- * hidden there, except a folded nav's, which hangs under the header while the menu is open.
20
+ * The header's Menu button: a native `popovertarget` for the panel, so it opens and closes by
21
+ * pointer, Enter and Space and is announced with its expanded state, with no script (a page that
22
+ * never hydrates still has its menu). Shown below `md`, and from `md` while the nav is `folded`.
23
+ * Its icon follows the panel (`:popover-open`, its own and no other popover's) through the header's
24
+ * `group/shell`.
23
25
  */
24
- function MenuLinks({ nav, subnav, folded, }) {
25
- return (_jsxs(_Fragment, { children: [nav && (_jsx("div", { className: folded ? FOLDED_NAV : "md:hidden", children: _jsx(ContainerFrame, { className: "flex flex-col gap-3 max-md:contents md:py-3", children: nav }) })), subnav && _jsx("div", { className: "flex flex-col gap-3 md:hidden", children: subnav })] }));
26
+ export function AppShellMenuButton({ label, panelId, folded, }) {
27
+ return (_jsxs("button", { type: "button", popoverTarget: panelId, className: cx("flex shrink-0 cursor-pointer items-center gap-2 rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm font-medium text-slate-900 select-none hover:bg-slate-50", focusRing, !folded && "md:hidden"), children: [_jsx("svg", { ...ICON, className: cx(ICON.className, "group-has-[[data-shell-menu]:popover-open]/shell:hidden"), children: _jsx("path", { d: "M3 5.5h14M3 10h14M3 14.5h14" }) }), _jsx("svg", { ...ICON, className: cx(ICON.className, "hidden group-has-[[data-shell-menu]:popover-open]/shell:block"), children: _jsx("path", { d: "M5 5l10 10M15 5L5 15" }) }), label] }));
28
+ }
29
+ // Menu mode: the browser's popover, in the top layer, hung under the sticky header across the
30
+ // screen. The UA box (inset 0, auto margins, fit-content, its border and padding, Canvas colours)
31
+ // is replaced; the ink is the shell's.
32
+ const PANEL_MENU = "fixed inset-x-0 top-(--app-header) bottom-auto m-0 h-auto max-h-[calc(100dvh-var(--app-header))] w-auto max-w-none overflow-y-auto overscroll-contain border-x-0 border-y border-slate-200 bg-white p-0 text-inherit shadow-lg";
33
+ // In the Menu a tab row (`Tabs` of links is a `nav`, of buttons a `tablist`) wraps rather than
34
+ // scrolling sideways, so every link shows in the panel.
35
+ const WRAP = "[&_nav]:flex-wrap [&_nav]:gap-y-1 [&_[role=tablist]]:flex-wrap [&_[role=tablist]]:gap-y-1";
36
+ /** Close the panel if it is open; one that is not shown, or a browser with no popover API, does nothing. */
37
+ function hide(panel) {
38
+ if (panel && "hidePopover" in panel)
39
+ panel.hidePopover();
26
40
  }
27
41
  /**
28
- * The header's phone menu (below `md`): a native `<details>` whose `<summary>` is the button, so it
29
- * opens and closes by pointer, Enter and Space, and is announced as a disclosure with its expanded
30
- * state, all with no script. That is why it also works on a page that is never hydrated. The panel
31
- * is out of flow (it hangs under the header, `top-full`), so the header keeps its one height open
32
- * or closed. With script it also closes on Escape (focus returns to the button) and when a link in
33
- * it is followed, for a router that changes the page without a reload.
34
- *
35
- * `controls` (AppShell's `menuControls`) sit at the top of the panel, above the links. From `md`
36
- * the `<details>` drops its own box and shows only them, inline at the row's end, whether it is
37
- * open or not: the summary and the link copies are hidden (the links render in their own rows from
38
- * `md`) and the panel is a plain row. They are rendered once, so a field keeps its state.
42
+ * Unfolding puts the panel back in the row, so it must not stay open in the top layer: close it when
43
+ * the header is in row mode and the screen is from `md`. Hiding a popover that is not shown does
44
+ * nothing.
45
+ */
46
+ function useCloseInRowMode(panel, rowMode) {
47
+ useEffect(() => {
48
+ const el = panel.current;
49
+ // jsdom (a consumer's own tests) has neither the popover API nor matchMedia.
50
+ if (!rowMode || !el || !("hidePopover" in el) || typeof window.matchMedia !== "function") {
51
+ return undefined;
52
+ }
53
+ const wide = window.matchMedia(WIDE);
54
+ const close = () => {
55
+ if (wide.matches)
56
+ hide(el);
57
+ };
58
+ close();
59
+ wide.addEventListener("change", close);
60
+ return () => wide.removeEventListener("change", close);
61
+ }, [panel, rowMode]);
62
+ }
63
+ /**
64
+ * The one home of AppShell's `nav` and `menuControls`, and the phone's copy of the `subnav`: the nav
65
+ * and `menuControls` are rendered once, here, so a field keeps its state, ids stay unique and a
66
+ * screen reader meets the nav once. It is a `popover="auto"` panel the Menu button targets, so it
67
+ * light-dismisses on a click outside and on Escape, and hands the focus back to the button, all the
68
+ * browser's.
39
69
  *
40
- * `folded` (the nav did not fit the row from `md`) keeps the summary from `md` too, and its nav copy
41
- * then hangs under the header as the panel does on a phone. The `subnav` copy stays phone only.
70
+ * In row mode (from `md`, nav not `folded`) the panel draws no box of its own (`display: contents`,
71
+ * over the UA's `display: none`): its parts are the header row's items, the nav after the brand and
72
+ * `menuControls` pushed to the row's end, before `controls`, in the order they are in the markup, so
73
+ * the focus moves as the eye does. The subnav copy is `display: none` there (the header draws the
74
+ * subnav's own row, `display: none` below `md`), so a screen reader meets one subnav at any width.
75
+ * In menu mode (below `md`, or `folded`) it is the dropdown: the nav, the subnav below `md`, then
76
+ * `menuControls`. Script closes it when a link in it is followed (for a router that does not reload)
77
+ * and when the header leaves menu mode while it is open.
42
78
  */
43
- export function AppShellMenu({ label, controls, nav, subnav, folded, }) {
44
- const details = useRef(null);
45
- const close = (focusButton) => {
46
- const el = details.current;
47
- if (!el?.open)
48
- return;
49
- el.open = false;
50
- if (focusButton)
51
- el.querySelector("summary")?.focus();
52
- };
53
- return (_jsxs("details", { ref: details, className: cx("group shrink-0", controls || folded
54
- ? "md:contents md:[&::details-content]:contents md:[&::details-content]:[content-visibility:visible]"
55
- : "md:hidden"), onKeyDown: (event) => {
56
- // A dialog opened from a control in the menu takes its own Escape; the menu stays open.
57
- if (event.key === "Escape" &&
58
- !(event.target instanceof Element && event.target.closest("dialog")))
59
- close(true);
60
- }, children: [_jsxs("summary", { className: cx("flex cursor-pointer list-none items-center gap-2 rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm font-medium text-slate-900 select-none hover:bg-slate-50 [&::-webkit-details-marker]:hidden", focusRing, !folded && "md:hidden"), children: [_jsx("svg", { ...ICON, className: cx(ICON.className, "group-open:hidden"), children: _jsx("path", { d: "M3 5.5h14M3 10h14M3 14.5h14" }) }), _jsx("svg", { ...ICON, className: cx(ICON.className, "hidden group-open:block"), children: _jsx("path", { d: "M5 5l10 10M15 5L5 15" }) }), label] }), _jsx("div", {
61
- // From `md` the panel draws no box (`contents`), so its dropdown look applies below `md` only.
62
- className: "absolute inset-x-0 top-full max-h-[calc(100dvh-var(--app-header))] overflow-y-auto overscroll-contain border-y border-slate-200 bg-white shadow-lg md:contents", onClick: (event) => {
63
- if (event.target instanceof Element && event.target.closest("a[href]"))
64
- close(false);
65
- }, children: _jsxs(ContainerFrame, { className: "flex flex-col gap-3 py-3 md:contents", children: [controls && (_jsx("div", { className: "flex flex-wrap items-center gap-2 md:flex-nowrap md:*:shrink-0 md:[&>.w-full]:w-auto", children: controls })), _jsx(MenuLinks, { nav: nav, subnav: subnav, folded: folded })] }) })] }));
79
+ export function AppShellMenuPanel({ id, controls, nav, subnav, folded, }) {
80
+ const panel = useRef(null);
81
+ const rowMode = !folded;
82
+ useCloseInRowMode(panel, rowMode);
83
+ return (_jsx("div", { ref: panel, id: id, popover: "auto", "data-shell-menu": "", className: cx(PANEL_MENU, rowMode && "md:contents"), onClick: (event) => {
84
+ if (event.target instanceof Element && event.target.closest("a[href]"))
85
+ hide(panel.current);
86
+ }, children: _jsxs(ContainerFrame, { className: cx("flex flex-col gap-3 py-3", rowMode && "md:contents"), children: [nav && (_jsx("div", {
87
+ // From `md` the nav is a row item of its own (the row's `*:shrink-0` does not reach through
88
+ // `contents`): it keeps its full width, so a nav too wide overflows the row and folds.
89
+ // In the Menu its tab rows wrap, so no link is left past the panel's edge.
90
+ className: cx("flex flex-col gap-3", WRAP, rowMode &&
91
+ "md:shrink-0 md:flex-row md:items-center md:gap-4 md:*:shrink-0 md:[&_nav]:flex-nowrap md:[&_[role=tablist]]:flex-nowrap"), children: nav })), subnav && _jsx("div", { className: cx("flex flex-col gap-3 md:hidden", WRAP), children: subnav }), controls && (_jsx("div", { className: cx("flex flex-wrap items-center gap-2", rowMode &&
92
+ "md:ml-auto md:shrink-0 md:flex-nowrap md:*:shrink-0 md:[&>.w-full]:w-auto"), children: controls }))] }) }));
66
93
  }
@@ -0,0 +1,36 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ import { type PageHeaderProps } from "./PageHeader.js";
3
+ import type { Passthrough } from "./props.js";
4
+ export type ArticleLayoutProps = Pick<PageHeaderProps, "breadcrumbs" | "title" | "description" | "loading" | "loadingLabel"> & {
5
+ /** Who wrote it: a name, or a `TextLink` to their page. */
6
+ author?: ReactNode;
7
+ /** When it was published, as the reader reads it: "12 November 2026". */
8
+ date?: string | undefined;
9
+ /** The same day as an ISO date (`2026-11-12`), for the `<time>` a machine reads. */
10
+ dateTime?: string | undefined;
11
+ /** How long it takes to read, worked out by the app: "6 min read". */
12
+ readingTime?: string | undefined;
13
+ /** The lead picture under the byline: an `Image` at `width="full"`. */
14
+ image?: ReactNode;
15
+ /** The article itself: `Prose`, or `SectionHeading`s and `Text` paragraphs, spaced `md` apart. */
16
+ children?: ReactNode;
17
+ /**
18
+ * The cards at the foot under "More like this", three to a row from `lg`: a `.map` of `Card`s or
19
+ * `ProductTile`s. Left out, there is no foot.
20
+ */
21
+ related?: ReactNode;
22
+ /**
23
+ * The heading over `related`, for an app in another language or another word ("Recipes for this kit").
24
+ * @default More like this
25
+ */
26
+ relatedTitle?: string | undefined;
27
+ } & Passthrough;
28
+ /**
29
+ * A blog article: the title (the page's `h1`) and its lede, a byline of the author, the date and the
30
+ * reading time in muted text, the lead picture, the body, and a "More like this" row of cards at the
31
+ * foot. The article sits in the reading column (`max-w-3xl`) at the Container's start edge, and the
32
+ * related cards take the Container's whole width under it. The date is a `<time>` when `dateTime`
33
+ * says which day it is. Every part but the title is optional. While `loading` it owns the wait and
34
+ * passes it to everything inside, the header too.
35
+ */
36
+ export declare function ArticleLayout({ breadcrumbs, title, description, author, date, dateTime, readingTime, image, children, related, relatedTitle, loading, loadingLabel, ...rest }: ArticleLayoutProps): ReactElement;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CardGrid } from "./CardGrid.js";
3
+ import { useWait } from "./layoutWait.js";
4
+ import { MetaList } from "./MetaList.js";
5
+ import { PageHeaderContent } from "./PageHeader.js";
6
+ import { Section } from "./Section.js";
7
+ import { LoadingScope } from "./skeleton.js";
8
+ import { Stack } from "./Stack.js";
9
+ /**
10
+ * A blog article: the title (the page's `h1`) and its lede, a byline of the author, the date and the
11
+ * reading time in muted text, the lead picture, the body, and a "More like this" row of cards at the
12
+ * foot. The article sits in the reading column (`max-w-3xl`) at the Container's start edge, and the
13
+ * related cards take the Container's whole width under it. The date is a `<time>` when `dateTime`
14
+ * says which day it is. Every part but the title is optional. While `loading` it owns the wait and
15
+ * passes it to everything inside, the header too.
16
+ */
17
+ export function ArticleLayout({ breadcrumbs, title, description, author, date, dateTime, readingTime, image, children, related, relatedTitle = "More like this", loading, loadingLabel, ...rest }) {
18
+ const wait = useWait(loading, loadingLabel);
19
+ return (_jsx(LoadingScope, { loading: wait.loading, children: _jsxs("div", { ...rest, ...wait.attrs, className: "flex flex-col gap-16", children: [_jsxs("article", { className: "max-w-3xl", children: [_jsxs("header", { className: "mb-8 flex flex-col gap-3", children: [_jsx(PageHeaderContent, { breadcrumbs: breadcrumbs, title: title, description: description }), _jsx(Byline, { author: author, date: date, dateTime: dateTime, readingTime: readingTime })] }), image != null && image !== false && _jsx("div", { className: "mb-8", children: image }), _jsx(Stack, { children: children })] }), related != null && related !== false && (_jsx(Section, { title: relatedTitle, children: _jsx(CardGrid, { as: "ul", columns: 3, children: related }) })), wait.label] }) }));
20
+ }
21
+ /** The author, the date and the reading time on one muted row; nothing when none is given. */
22
+ function Byline({ author, date, dateTime, readingTime, }) {
23
+ const hasAuthor = author != null && author !== false;
24
+ if (!hasAuthor && date === undefined && readingTime === undefined)
25
+ return null;
26
+ return (_jsxs(MetaList, { children: [hasAuthor && _jsx("span", { children: author }), date !== undefined && _jsx("time", { dateTime: dateTime, children: date }), readingTime !== undefined && _jsx("span", { children: readingTime })] }));
27
+ }
@@ -0,0 +1,16 @@
1
+ import type { AudioHTMLAttributes, ReactElement, ReactNode } from "react";
2
+ import type { Unstyled } from "./props.js";
3
+ /**
4
+ * An `<audio>` with the browser's own controls, at one fixed size: 20rem wide, narrower only when its column is. It loads
5
+ * metadata only, and lazily where the browser can, so the page does not pull the file until it is
6
+ * played. A voice note or a clip has no visible title, so `label` names the player. `src` is the
7
+ * app's own file; `children` is the fallback for a browser that cannot play it.
8
+ */
9
+ export declare function Audio({ src, label, children, ...rest }: {
10
+ /** The audio file, the app's own. */
11
+ src: string;
12
+ /** Names the player for a screen reader, as "Voice note from Anna": audio has no visible title. */
13
+ label: string;
14
+ /** The text for a browser that cannot play it. */
15
+ children?: ReactNode;
16
+ } & Unstyled<Omit<AudioHTMLAttributes<HTMLAudioElement>, "src" | "controls" | "children">>): ReactElement;
package/dist/Audio.js ADDED
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { LAZY_MEDIA } from "./Video.js";
3
+ /**
4
+ * An `<audio>` with the browser's own controls, at one fixed size: 20rem wide, narrower only when its column is. It loads
5
+ * metadata only, and lazily where the browser can, so the page does not pull the file until it is
6
+ * played. A voice note or a clip has no visible title, so `label` names the player. `src` is the
7
+ * app's own file; `children` is the fallback for a browser that cannot play it.
8
+ */
9
+ export function Audio({ src, label, children, ...rest }) {
10
+ return (_jsx("audio", { controls: true, preload: "metadata", ...LAZY_MEDIA, src: src, ...rest, "aria-label": label, className: "block h-10 w-xs max-w-full", children: children }));
11
+ }
package/dist/Badge.d.ts CHANGED
@@ -2,7 +2,8 @@ import type { ReactElement } from "react";
2
2
  import type { Passthrough } from "./props.js";
3
3
  import { type LoadingProps } from "./skeleton.js";
4
4
  /**
5
- * A small red count, 10px, for sitting on an icon. An icon with a count is an `IconButton` with
5
+ * A small red count, 10px, for sitting on an icon. Its size is in rem and its height grows with
6
+ * its line, so it scales with the reader's text size instead of clipping. An icon with a count is an `IconButton` with
6
7
  * its `count`, which pins the Badge to its corner and puts the count in the button's name. A
7
8
  * count above 99 reads `99+`. While `loading` it is
8
9
  * a bone of its size: a count is a number, so 0 is a value and not a gap.
package/dist/Badge.js CHANGED
@@ -2,7 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cx } from "./cx.js";
3
3
  import { useLoading, WaitingBone } from "./skeleton.js";
4
4
  /**
5
- * A small red count, 10px, for sitting on an icon. An icon with a count is an `IconButton` with
5
+ * A small red count, 10px, for sitting on an icon. Its size is in rem and its height grows with
6
+ * its line, so it scales with the reader's text size instead of clipping. An icon with a count is an `IconButton` with
6
7
  * its `count`, which pins the Badge to its corner and puts the count in the button's name. A
7
8
  * count above 99 reads `99+`. While `loading` it is
8
9
  * a bone of its size: a count is a number, so 0 is a value and not a gap.
@@ -11,5 +12,5 @@ export function Badge({ count, corner = false, loading: ownLoading, loadingLabel
11
12
  if (useLoading(ownLoading).loading) {
12
13
  return (_jsx(WaitingBone, { own: ownLoading, label: loadingLabel, attrs: rest, root: cx("inline-flex", corner && "absolute -end-1.5 -top-1.5"), shape: "inline-block h-4 w-5 rounded-full" }));
13
14
  }
14
- return (_jsx("span", { ...rest, className: cx("inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-red-600 px-1 text-[10px] font-semibold leading-none text-red-50", corner && "absolute -end-1.5 -top-1.5"), children: count > 99 ? "99+" : count }));
15
+ return (_jsx("span", { ...rest, className: cx("inline-flex min-h-4 min-w-4 items-center justify-center rounded-full bg-red-600 px-1 text-[0.625rem]/[1.6] font-semibold text-red-50", corner && "absolute -end-1.5 -top-1.5"), children: count > 99 ? "99+" : count }));
15
16
  }
@@ -2,6 +2,8 @@ import { type ReactElement, type ReactNode } from "react";
2
2
  import type { Passthrough } from "./props.js";
3
3
  import { type BottomSheetSnap } from "./sheetSnap.js";
4
4
  export type { BottomSheetSnap } from "./sheetSnap.js";
5
+ /** The widths from which a sheet is plain content in the page: Tailwind's `md` (768px) and `lg` (1024px). */
6
+ export type InlineFrom = "md" | "lg";
5
7
  export type BottomSheetProps = {
6
8
  /** The sheet's accessible name, as a region, and its handle button's. */
7
9
  label: string;
@@ -21,16 +23,25 @@ export type BottomSheetProps = {
21
23
  /** The scrolling body. */
22
24
  children?: ReactNode;
23
25
  /**
24
- * Called with the height (px) the sheet rests at: on mount, on every change of `snap` and when the
25
- * parent resizes. Pad a map camera by it.
26
+ * Called with the sheet's height (px): on mount, on every change of `snap`, when the parent
27
+ * resizes, and on every move of a drag, so a map camera padded by it follows the finger.
26
28
  */
27
29
  onHeightChange?: (px: number) => void;
30
+ /**
31
+ * From this width up the sheet is no sheet: its header, body and footer sit in the page's flow
32
+ * with no handle, no snaps and no height of its own, so the parent's grid places it (a list
33
+ * column beside a map). Below it, it is the sheet. One tree, switched by CSS: nothing renders
34
+ * twice, so `onHeightChange` still reports the snap's height: there the view has nothing under
35
+ * the list to pad. Without it the sheet is a panel at the start edge from `md` up.
36
+ */
37
+ inlineFrom?: InlineFrom | undefined;
28
38
  } & Passthrough;
29
39
  /**
30
40
  * A non-modal panel docked to the bottom edge of its positioned parent, over a full-screen view (a
31
41
  * map, a canvas) that stays usable behind it. It rests at one of its `snaps`; the handle steps
32
- * through them (Enter and Space), a drag of the handle moves it and releases to the nearest snap
33
- * (a fling steps on), and Escape inside it returns it to the first. Nothing is made inert and focus
34
- * never moves. Full width below `md`, a panel at the start edge from `md` up.
42
+ * through them (Enter and Space; ArrowUp and ArrowDown one up or down), a drag of the handle moves
43
+ * it and releases to the nearest snap (a fling steps on), and Escape inside it returns it to the
44
+ * first. Nothing is made inert and focus never moves. Full width below `md`, a panel at the start
45
+ * edge from `md` up, or, with `inlineFrom`, plain content in the page from that width.
35
46
  */
36
- export declare function BottomSheet({ label, snaps, snap, onSnapChange, header, footer, children, onHeightChange, ...rest }: BottomSheetProps): ReactElement;
47
+ export declare function BottomSheet({ label, snaps, snap, onSnapChange, header, footer, children, onHeightChange, inlineFrom, ...rest }: BottomSheetProps): ReactElement;