shelving 1.319.1 → 1.321.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 (106) hide show
  1. package/docs/guides/building-with-shelving.md +26 -0
  2. package/docs/llms-full.txt +752 -265
  3. package/docs/ui/BackButton.md +75 -0
  4. package/docs/ui/BackButtonProps.md +21 -0
  5. package/docs/ui/ClickableProps.md +0 -2
  6. package/docs/ui/FADE_TRANSITION_CLASS.md +9 -0
  7. package/docs/ui/FadeTransition.md +13 -0
  8. package/docs/ui/Head.md +2 -2
  9. package/docs/ui/HorizontalTransition.md +21 -5
  10. package/docs/ui/LinkClickable.md +0 -1
  11. package/docs/ui/Meta.md +3 -1
  12. package/docs/ui/Navigation.md +93 -37
  13. package/docs/ui/NavigationEntryState.md +22 -0
  14. package/docs/ui/NavigationPosition.md +24 -0
  15. package/docs/ui/NavigationPositionContext.md +8 -0
  16. package/docs/ui/NavigationProps.md +12 -2
  17. package/docs/ui/NavigationStore/back.md +6 -4
  18. package/docs/ui/NavigationStore/forward.md +6 -2
  19. package/docs/ui/NavigationStore/history.md +15 -0
  20. package/docs/ui/NavigationStore/listen.md +14 -0
  21. package/docs/ui/NavigationStore/replace.md +15 -0
  22. package/docs/ui/NavigationStore.md +100 -19
  23. package/docs/ui/RouteCache.md +72 -36
  24. package/docs/ui/RouteCacheProps.md +3 -3
  25. package/docs/ui/Router.md +4 -2
  26. package/docs/ui/SLIDE_DOWN_TRANSITION_CLASS.md +9 -0
  27. package/docs/ui/SLIDE_LEFT_TRANSITION_CLASS.md +9 -0
  28. package/docs/ui/SLIDE_RIGHT_TRANSITION_CLASS.md +9 -0
  29. package/docs/ui/SLIDE_UP_TRANSITION_CLASS.md +9 -0
  30. package/docs/ui/StackButton.md +64 -0
  31. package/docs/ui/StackButtonProps.md +21 -0
  32. package/docs/ui/VerticalTransition.md +21 -5
  33. package/docs/ui/mergeMeta.md +2 -1
  34. package/docs/ui.md +18 -10
  35. package/package.json +1 -1
  36. package/ui/button/Clickable.d.ts +1 -3
  37. package/ui/button/Clickable.js +2 -2
  38. package/ui/button/Clickable.tsx +0 -4
  39. package/ui/dialog/Dialog.d.ts +0 -1
  40. package/ui/dialog/Dialog.js +2 -2
  41. package/ui/dialog/Dialog.tsx +2 -2
  42. package/ui/notice/NoticesTransition.module.css +1 -1
  43. package/ui/page/Head.d.ts +2 -2
  44. package/ui/page/Head.js +9 -8
  45. package/ui/page/Head.tsx +8 -6
  46. package/ui/router/BackButton.d.ts +22 -0
  47. package/ui/router/BackButton.js +19 -0
  48. package/ui/router/BackButton.md +47 -0
  49. package/ui/router/BackButton.tsx +34 -0
  50. package/ui/router/Navigation.d.ts +22 -12
  51. package/ui/router/Navigation.js +67 -51
  52. package/ui/router/Navigation.md +84 -27
  53. package/ui/router/Navigation.test.tsx +27 -7
  54. package/ui/router/Navigation.tsx +90 -53
  55. package/ui/router/NavigationContext.d.ts +9 -1
  56. package/ui/router/NavigationContext.js +9 -0
  57. package/ui/router/NavigationContext.tsx +11 -1
  58. package/ui/router/NavigationStore.d.ts +126 -19
  59. package/ui/router/NavigationStore.js +301 -30
  60. package/ui/router/NavigationStore.md +82 -9
  61. package/ui/router/NavigationStore.test.ts +384 -0
  62. package/ui/router/NavigationStore.tsx +347 -30
  63. package/ui/router/RouteCache.d.ts +15 -22
  64. package/ui/router/RouteCache.js +36 -47
  65. package/ui/router/RouteCache.md +59 -16
  66. package/ui/router/RouteCache.tsx +55 -62
  67. package/ui/router/Router.d.ts +2 -1
  68. package/ui/router/Router.js +9 -14
  69. package/ui/router/Router.md +2 -1
  70. package/ui/router/Router.tsx +9 -20
  71. package/ui/router/StackButton.d.ts +24 -0
  72. package/ui/router/StackButton.js +35 -0
  73. package/ui/router/StackButton.md +34 -0
  74. package/ui/router/StackButton.tsx +44 -0
  75. package/ui/router/index.d.ts +2 -2
  76. package/ui/router/index.js +2 -2
  77. package/ui/router/index.ts +2 -2
  78. package/ui/transition/FadeTransition.d.ts +9 -1
  79. package/ui/transition/FadeTransition.js +12 -2
  80. package/ui/transition/FadeTransition.md +13 -0
  81. package/ui/transition/{FadeTransition.css → FadeTransition.module.css} +9 -2
  82. package/ui/transition/FadeTransition.tsx +13 -2
  83. package/ui/transition/HorizontalTransition.d.ts +18 -1
  84. package/ui/transition/HorizontalTransition.js +21 -2
  85. package/ui/transition/HorizontalTransition.md +21 -5
  86. package/ui/transition/{HorizontalTransition.css → HorizontalTransition.module.css} +17 -5
  87. package/ui/transition/HorizontalTransition.tsx +30 -2
  88. package/ui/transition/VerticalTransition.d.ts +18 -1
  89. package/ui/transition/VerticalTransition.js +21 -2
  90. package/ui/transition/VerticalTransition.md +21 -5
  91. package/ui/transition/{VerticalTransition.css → VerticalTransition.module.css} +17 -5
  92. package/ui/transition/VerticalTransition.tsx +25 -2
  93. package/ui/util/meta.d.ts +4 -1
  94. package/ui/util/meta.ts +4 -1
  95. package/docs/ui/NavigationStore/redirect.md +0 -12
  96. package/docs/ui/RouteConfig.md +0 -75
  97. package/docs/ui/RouteConfigProps.md +0 -24
  98. package/docs/ui/RouteContext.md +0 -6
  99. package/docs/ui/RouteState.md +0 -30
  100. package/ui/router/RouteConfig.d.ts +0 -28
  101. package/ui/router/RouteConfig.js +0 -30
  102. package/ui/router/RouteConfig.md +0 -42
  103. package/ui/router/RouteConfig.tsx +0 -44
  104. package/ui/router/RouteContext.d.ts +0 -22
  105. package/ui/router/RouteContext.js +0 -8
  106. package/ui/router/RouteContext.tsx +0 -26
@@ -854,6 +854,32 @@ If every file in that list is in the right place, the client and server share on
854
854
 
855
855
  ## Upgrade notes
856
856
 
857
+ ### Tab stacks in `<Navigation>`
858
+
859
+ `<Navigation>` now keeps one stack of pages for each tab, like a phone app. It uses the browser [Navigation API](https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API). Some names and props changed. To upgrade an app:
860
+
861
+ 1. **Rename `redirect()` to `replace()`.** Change each `nav.redirect(url)` to `nav.replace(url)`. It does the same thing: it changes the URL of the current page with no new history entry and no slide.
862
+ 2. **Change the `back` prop to a class.** The `back` prop on `<Button>` and `<Link>` is removed, and so is the `data-back` attribute. Change `<Button href="/profile" back>` to `<Button href="/profile" className="back">`. For a page-header back button, use `<BackButton href="/profile"/>` (see step 6).
863
+ 3. **Remove `<RouteConfig>`.** `<RouteConfig>` and `RouteContext` are removed.
864
+ - `<RouteConfig path>` kept a page mounted for its tabs (for example `/dave/{tab}`). Instead, add `className="replace"` to each in-page tab link: `<Button href="/dave/posts" className="replace">Posts</Button>`. A replace keeps the same page mounted, with no slide and no new history entry.
865
+ - `<RouteConfig cache={false}>` unmounted a create form when you left it. Instead, clear the form after a successful submit: change the `key` of the `<Form>`, or call `form.reset()` on a plain HTML form. See `<RouteCache>` for an example.
866
+ 4. **Canonical URLs.** `<Head>` no longer writes browser history itself. When a page renders a `<Head>` with a `url` that is not the current URL, `<Head>` calls `NavigationStore.replace()`. You do not need to change anything, but do not also call `window.history.replaceState()` for it.
867
+ 5. **Add stacks (optional).** For an app with a tab bar, set `stacks` on `<Navigation>` to the root path of each tab, in tab order: `<Navigation stacks={["/home", "/discover", "/profile"]}>`. Each link then opens a new page in the current tab, wherever it points. Set `stack` on `<Navigation>` to the stack the app opens in. With no `stack`, the app opens in the `/` stack, which is unstacked: no tab is selected until the user taps a tab, or the app names a stack. Deep links and login pages are unstacked. A login page calls `nav.replace("/home", "/home")` to send the user into the Home tab.
868
+ 6. **Use the new buttons (optional).**
869
+ - `<StackButton stack="/home">` is a tab bar button. It goes to the page you left in that tab, goes back to the tab's root when you are already in it, and scrolls to the top at the root.
870
+ - `<BackButton href="/home"/>` goes back to the page before this one in the current tab, or to `href` when there is none.
871
+ 7. **Move the page transition outside `<RouteCache>`.** Put `<HorizontalTransition>` (or any page `<Transition>`) around the `<RouteCache>`, not inside it around each page. Safari (iOS 18) loses the exit animation when each page has its own `<ViewTransition>`.
872
+ 8. **Check pages that change URL for the same component.** `<RouteCache>` now keys each page by its stack and depth, not by its path. A replace from `/post/1` to `/post/2` keeps the same component mounted with its state. If the page must reset, wrap its content in an element with `key={id}`.
873
+ 9. **Know the fallback.** Without the Navigation API (older browsers), links still work with no page reload, but there are no stacks, no slides and no page cache. `<StackButton>` and `<BackButton>` become plain links.
874
+
875
+ What changes for users:
876
+
877
+ - Each tab remembers the page you left it on, and its back button goes back within that tab.
878
+ - The browser back button walks the history as before, across tabs. The page slides the right way.
879
+ - When you go back from a page, it leaves the cache. So the browser forward button then shows that page fresh, from the top.
880
+
881
+ See `<Navigation>`, `NavigationStore`, `<RouteCache>`, `<StackButton>` and `<BackButton>` for the full details.
882
+
857
883
  ### From `CacheDBProvider` to `HydratingAPIProvider`
858
884
 
859
885
  `CacheDBProvider` and the paging in `QueryStore` are removed. To upgrade an app:
@@ -20167,13 +20193,14 @@ The components below are listed in the index following this page; this is the sh
20167
20193
  - [Empty](ui/Empty.md): Message for a list with nothing in it: centred, grey content with space around it.
20168
20194
  - [Notice](ui/Notice.md): Block-level status callout with an icon and message, used to highlight feedback.
20169
20195
  - [Notices](ui/Notices.md): Render the global list of notices and subscribe to incoming "notice" events.
20170
- - [Head](ui/Head.md): Emit the current page's head metadata and sync browser history to its URL.
20196
+ - [Head](ui/Head.md): Emit the current page's head metadata, and replace the browser URL with the page's canonical URL.
20171
20197
  - [HTML](ui/HTML.md): Render the full <html> document shell wrapping <head> and <body>.
20172
20198
  - [Page](ui/Page.md): Wrap a single page (or screen) within an app, applying its meta and head tags.
20173
- - [Navigation](ui/Navigation.md): Top-level navigation provider.
20174
- - [RouteCache](ui/RouteCache.md): Keep-alive page cache keyed by the current URL — drop it into a layout around its scrolling content region.
20175
- - [RouteConfig](ui/RouteConfig.md): Configure the current page for the surrounding <Router> (and <RouteCache>).
20199
+ - [BackButton](ui/BackButton.md): Back button for the current stack.
20200
+ - [Navigation](ui/Navigation.md): Top-level navigation provider, with one stack of pages for each tab.
20201
+ - [RouteCache](ui/RouteCache.md): Keep-alive page cache for the pages in the navigation stacks. Drop it into a layout around its scrolling content region.
20176
20202
  - [Router](ui/Router.md): Match the current URL against routes and render the matched element.
20203
+ - [StackButton](ui/StackButton.md): Button for one stack in a tab bar.
20177
20204
  - [Scroll](ui/Scroll.md): Wrap children in a scrollable container with horizontal and/or vertical scrolling enabled.
20178
20205
  - [Cell](ui/Cell.md): Table cell.
20179
20206
  - [Table](ui/Table.md): Table block — rendered as <table>.
@@ -20295,7 +20322,7 @@ The components below are listed in the index following this page; this is the sh
20295
20322
  - [FormStore](ui/FormStore.md): Reactive store holding the current (possibly partial and invalid) value of a form, plus its field messages.
20296
20323
  - [NoticesStore](ui/NoticesStore.md): Store holding the live list of NoticeStore notices currently shown.
20297
20324
  - [NoticeStore](ui/NoticeStore.md): Store holding a single notice's content and status, owned by a NoticesStore.
20298
- - [NavigationStore](ui/NavigationStore.md): Store holding the current navigation URL and driving browser history.
20325
+ - [NavigationStore](ui/NavigationStore.md): Store that holds the current navigation URL, drives browser history, and keeps a stack of pages for each tab.
20299
20326
 
20300
20327
  ## Interfaces
20301
20328
 
@@ -20429,11 +20456,13 @@ The components below are listed in the index following this page; this is the sh
20429
20456
  - [NoticesProps](ui/NoticesProps.md): Props for <Notices> — the place for the list, and flex styling variants for the notices container.
20430
20457
  - [HTMLProps](ui/HTMLProps.md): Props for <HTML> — initial Meta (language/root/app) plus the page children.
20431
20458
  - [PageProps](ui/PageProps.md): Props for <Page> — per-page Meta (title, description, etc.) plus the page children.
20432
- - [NavigationProps](ui/NavigationProps.md): Props for <Navigation> — initial Meta (url/base) plus optional children.
20433
- - [RouteCacheProps](ui/RouteCacheProps.md): Props for <RouteCache> — the maxCached size and the content children to keep alive per URL.
20434
- - [RouteConfigProps](ui/RouteConfigProps.md): Props for <RouteConfig> — the settings of a page for the surrounding <Router> and <RouteCache>, and the page content.
20435
- - [RouteState](ui/RouteState.md): The route state of one page, shared by <Router>, <RouteCache> and <RouteConfig>.
20459
+ - [BackButtonProps](ui/BackButtonProps.md): Props for <BackButton>: the href to go back to when the stack has no page before this one, plus the usual Button props except onClick.
20460
+ - [NavigationProps](ui/NavigationProps.md): Props for <Navigation>: the initial Meta (url, root and stack), the stacks, and optional children.
20461
+ - [NavigationEntryState](ui/NavigationEntryState.md): State that NavigationStore saves on each browser history entry.
20462
+ - [NavigationPosition](ui/NavigationPosition.md): Where the app is now in its stacks: the current stack and depth, the top depth of each stack, and the page before the current one.
20463
+ - [RouteCacheProps](ui/RouteCacheProps.md): Props for <RouteCache>: the maxCached size and the content children to keep alive for each page in the stacks.
20436
20464
  - [RouterProps](ui/RouterProps.md): Props for <Router> — the routes to match against plus an optional fallback.
20465
+ - [StackButtonProps](ui/StackButtonProps.md): Props for <StackButton>: the stack it opens, plus the usual Button props except href and onClick.
20437
20466
  - [BlockVariants](ui/BlockVariants.md): Variants for block level elements.
20438
20467
  - [ColorVariants](ui/ColorVariants.md): Variant props for colouring an element, e.g. color="purple".
20439
20468
  - [DurationVariants](ui/DurationVariants.md): Variant props for the transition duration of an element, e.g. duration="fast".
@@ -20534,9 +20563,14 @@ The components below are listed in the index following this page; this is the sh
20534
20563
  - [LOADING_NOTICE](ui/LOADING_NOTICE.md): Shared loading <Notice> element showing the loading spinner.
20535
20564
  - [NOTICES](ui/NOTICES.md): Global NoticesStore shown by <Notices>, accepting any of the default statuses.
20536
20565
  - [NavigationContext](ui/NavigationContext.md): React context holding the current NavigationStore, provided by <Navigation>.
20537
- - [RouteContext](ui/RouteContext.md): React context holding the RouteState of the current page, provided by <Router> and <RouteCache>.
20566
+ - [NavigationPositionContext](ui/NavigationPositionContext.md): React context holding where the app is in its stacks, published by <Navigation> with each URL change.
20538
20567
  - [STATUSES](ui/STATUSES.md): Tuple of the status names selectable via the status variant prop.
20539
20568
  - [TINT_CLASS](ui/TINT_CLASS.md): CSS class that (re)calculates the full ladder of tint shades from the current global tint colour.
20569
+ - [FADE_TRANSITION_CLASS](ui/FADE_TRANSITION_CLASS.md): View transition class that fades content in and out.
20570
+ - [SLIDE_RIGHT_TRANSITION_CLASS](ui/SLIDE_RIGHT_TRANSITION_CLASS.md): View transition class that slides content right: the new content comes in from the right and the old content leaves to the left.
20571
+ - [SLIDE_LEFT_TRANSITION_CLASS](ui/SLIDE_LEFT_TRANSITION_CLASS.md): View transition class that slides content left: the new content comes in from the left and the old content leaves to the right.
20572
+ - [SLIDE_DOWN_TRANSITION_CLASS](ui/SLIDE_DOWN_TRANSITION_CLASS.md): View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
20573
+ - [SLIDE_UP_TRANSITION_CLASS](ui/SLIDE_UP_TRANSITION_CLASS.md): View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
20540
20574
  - [TreeContext](ui/TreeContext.md): React context holding a flattened key → element map of the surrounding tree(s).
20541
20575
  - [TREE_CODE_RULE](ui/TREE_CODE_RULE.md): Markup rule that renders an inline code span as a tree-resolved <TreeLink> instead of a plain <code>.
20542
20576
  - [TREE_MARKUP_RULES](ui/TREE_MARKUP_RULES.md): Default markup rules with the inline-code rule swapped for TREE_CODE_RULE — every backtick span auto-links to its documented token.
@@ -23074,7 +23108,6 @@ Props for a thing that can be clicked — either has a string `href` link or an
23074
23108
  download?: string | undefined;
23075
23109
  title?: string | undefined;
23076
23110
  selected?: boolean | undefined;
23077
- back?: boolean | undefined;
23078
23111
  }
23079
23112
  ```
23080
23113
 
@@ -23089,7 +23122,6 @@ Props for a thing that can be clicked — either has a string `href` link or an
23089
23122
  | `download` | `string \| undefined` | If `href` is present then this is the suggested filename for downloading. Optional. |
23090
23123
  | `title` | `string \| undefined` | Title shown on hover. Optional. |
23091
23124
  | `selected` | `boolean \| undefined` | Whether this is the selected item in a group. Sets `aria-pressed` on a `<button>`, or `aria-current` on an `<a>`. Optional. |
23092
- | `back` | `boolean \| undefined` | If `href` is present, then `<Navigation>` opens the link with a back transition. Use it for a "back to" link. Sets `data-back` on the `<a>`. Optional. |
23093
23125
 
23094
23126
 
23095
23127
  ---
@@ -23170,7 +23202,6 @@ LinkClickable({
23170
23202
  download,
23171
23203
  title,
23172
23204
  selected,
23173
- back,
23174
23205
  children = "Go",
23175
23206
  className,
23176
23207
  }: StylableClickableProps): ReactElement
@@ -32425,10 +32456,10 @@ close(): void
32425
32456
  - Kind: component
32426
32457
  - Import: `import { Head } from "shelving/ui";`
32427
32458
 
32428
- Emit the current page's head metadata and sync browser history to its URL.
32459
+ Emit the current page's head metadata, and replace the browser URL with the page's canonical URL.
32429
32460
  - Emits hoistable head elements (title, meta, links, stylesheets, scripts) inline; React 19 hoists each one into the document `<head>`.
32430
32461
  - Does not render `<base>` (not hoistable — that lives in `<Head>` in the `<HTML>` shell component).
32431
- - Updates `window.history` to match the page URL.
32462
+ - When the meta `url` differs from the browser URL (a page that knows its canonical URL), calls `NavigationStore.replace()` with it. Outside `<Navigation>` it does not touch history.
32432
32463
 
32433
32464
  Low-level emitter of hoistable head metadata from the current `Meta` context. It outputs `<title>`, `<meta>`, `<link>`, stylesheet, module, and script elements inline, and React 19 hoists each one into the document `<head>`. It also syncs `window.history` to the page URL.
32434
32465
 
@@ -32622,6 +32653,110 @@ Page({ children, ...meta }: PageProps): ReactElement
32622
32653
  | `ReactElement` | |
32623
32654
 
32624
32655
 
32656
+ ---
32657
+
32658
+ # BackButtonProps
32659
+
32660
+ - Kind: interface
32661
+ - Import: `import { BackButtonProps } from "shelving/ui";`
32662
+ - Extends: `Omit<ButtonProps, "href" | "onClick">`
32663
+
32664
+ Props for `<BackButton>`: the `href` to go back to when the stack has no page before this one, plus the usual `Button` props except `onClick`.
32665
+
32666
+ ## Signatures
32667
+
32668
+ ```ts
32669
+ {
32670
+ readonly href: AbsolutePath;
32671
+ }
32672
+ ```
32673
+
32674
+ ## Properties
32675
+
32676
+ | Property | Type | Description |
32677
+ | --- | --- | --- |
32678
+ | `href` | `AbsolutePath` | Where to go back to when the current stack has no page before this one (for example, the app was opened at this page). Read only. |
32679
+
32680
+
32681
+ ---
32682
+
32683
+ # BackButton
32684
+
32685
+ - Kind: component
32686
+ - Import: `import { BackButton } from "shelving/ui";`
32687
+
32688
+ Back button for the current stack.
32689
+ - Goes back to the page before this one in the current stack, wherever you came from.
32690
+ - Goes to `href` when the stack has no page before this one: the app was opened at this page, or the browser has no Navigation API.
32691
+ - It is a plain link with `className="back"`, so it slides back, and it works in a server render and with a middle-click.
32692
+
32693
+ The back button for a page header. It goes back to the page before this one in the current stack, wherever you came from.
32694
+
32695
+ **Things to know:**
32696
+
32697
+ - It goes to the page before this one in the current stack. If you opened a post from a search, it goes back to the search.
32698
+ - It goes to `href` when the stack has no page before this one: for example, when the app was opened at this page. So a back button always has somewhere to go. Set `href` to the page's natural parent. On an unstacked page (for example a deep link), it goes to `href` and stays unstacked. To go into a stack, the user taps a `<StackButton>`.
32699
+ - It is a plain link with `className="back"`. `<Navigation>` turns a click into `NavigationStore.back()`, so the page slides back. A middle-click opens the link in a new browser tab.
32700
+ - Its default content is a `<LeftIcon>` and its default `title` is "Back". Pass `children` and `title` to change them.
32701
+ - It takes the usual `<Button>` props, except `onClick`.
32702
+ - Without the browser Navigation API, and in a server render, it links to `href`.
32703
+ - In a server-rendered app the server always renders `href`, and the browser may render the page before this one. React then warns about a hydration mismatch on the first render. A client-only app (with `<App>`) has no mismatch.
32704
+
32705
+ ## Usage
32706
+
32707
+ ```tsx
32708
+ import { BackButton } from "shelving/ui";
32709
+
32710
+ function PostPage({ id }: { id: string }) {
32711
+ return (
32712
+ <>
32713
+ <header>
32714
+ <BackButton href="/home"/>
32715
+ <h1>Post</h1>
32716
+ </header>
32717
+ {/* … */}
32718
+ </>
32719
+ );
32720
+ }
32721
+ ```
32722
+
32723
+ With a label:
32724
+
32725
+ ```tsx
32726
+ <BackButton href="/profile">Back to profile</BackButton>
32727
+ ```
32728
+
32729
+ To go back to one fixed page (not to the page before), use a link with `className="back"`:
32730
+
32731
+ ```tsx
32732
+ <Button href="/profile" className="back">Profile</Button>
32733
+ ```
32734
+
32735
+ ## Styling
32736
+
32737
+ `<BackButton>` renders a `<Button>`, so it has the same styling hooks. See `<Button>`.
32738
+
32739
+
32740
+ ## Signatures
32741
+
32742
+ ```ts
32743
+ BackButton({ href, className, title = "Back", children = <LeftIcon />, ...props }: BackButtonProps): ReactElement
32744
+ ```
32745
+
32746
+ ## Parameters
32747
+
32748
+ | Param | Type | Description |
32749
+ | --- | --- | --- |
32750
+ | `props` | `BackButtonProps` | |
32751
+ | `.href` | `AbsolutePath` | Where to go back to when the current stack has no page before this one (for example, the app was opened at this page). Read only. |
32752
+
32753
+ ## Returns
32754
+
32755
+ | Type | Description |
32756
+ | --- | --- |
32757
+ | `ReactElement` | |
32758
+
32759
+
32625
32760
  ---
32626
32761
 
32627
32762
  # NavigationProps
@@ -32630,14 +32765,24 @@ Page({ children, ...meta }: PageProps): ReactElement
32630
32765
  - Import: `import { NavigationProps } from "shelving/ui";`
32631
32766
  - Extends: `PossibleMeta`
32632
32767
 
32633
- Props for `<Navigation>` — initial `Meta` (url/base) plus optional `children`.
32768
+ Props for `<Navigation>`: the initial `Meta` (url, root and stack), the `stacks`, and optional `children`.
32634
32769
 
32635
32770
  ## Signatures
32636
32771
 
32637
32772
  ```ts
32638
- {}
32773
+ {
32774
+ readonly stacks?: readonly AbsolutePath[] | undefined;
32775
+ readonly stack?: AbsolutePath | undefined;
32776
+ }
32639
32777
  ```
32640
32778
 
32779
+ ## Properties
32780
+
32781
+ | Property | Type | Description |
32782
+ | --- | --- | --- |
32783
+ | `stacks` | `readonly AbsolutePath[] \| undefined` | Root path of each stack, in tab order, for an app with a tab bar (for example `["/home", "/discover", "/profile"]`). - Each stack keeps its own pages, so each tab remembers where you left it, and a back button goes back within its tab. - With no stacks, the app has one stack at `"/"`, and `stack` in `Meta` is `"/"`. Read only. Optional. |
32784
+ | `stack` | `AbsolutePath \| undefined` | Stack of the page the app opens at (for example `"/home"`), like `url` and `root`. - Read from this prop, else from the surrounding `<Meta>`, else `"/"`. - Used only when the opening history entry has no saved stack. A reload keeps the stack it had. Read only. Optional. |
32785
+
32641
32786
 
32642
32787
  ---
32643
32788
 
@@ -32646,78 +32791,132 @@ Props for `<Navigation>` — initial `Meta` (url/base) plus optional `children`.
32646
32791
  - Kind: component
32647
32792
  - Import: `import { Navigation } from "shelving/ui";`
32648
32793
 
32649
- Top-level navigation provider.
32650
- - Owns a single `NavigationStore` initialised from the surrounding `<Meta>` url/base.
32651
- - Intercepts same-origin anchor clicks (excluding `download` anchors) and turns them into `forward()` calls, or `back()` calls for an anchor with a `data-back` attribute.
32652
- - Listens for `popstate` to sync the store with browser back/forward.
32653
- - Publishes the live URL into the `Meta` context via `mergeMeta()`, so descendant `<Router>`s re-render on navigation and merge invariants hold (e.g. `root` defaults to the live URL's origin when unset).
32654
- - Publishes each URL change inside `startTransition()` with a `"forward"` or `"back"` transition type, so a `<Transition>` around the routes runs a view transition.
32655
- - Skips the transition when the browser already animated the change (`PopStateEvent.hasUAVisualTransition`, e.g. a swipe-back gesture).
32794
+ Top-level navigation provider, with one stack of pages for each tab.
32795
+ - Owns a single `NavigationStore` made from the surrounding `<Meta>` url and root.
32796
+ - Turns clicks on same-origin links into `NavigationStore.forward()`, or `NavigationStore.back()` for a link with `className="back"`, or `NavigationStore.replace()` for a link with `className="replace"`. Clicks with a modifier key, or on links with `download` or a `target`, are left to the browser.
32797
+ - Publishes the URL and the current `stack` into `Meta`, and the position in the stacks into `NavigationPositionContext`, all in one render.
32798
+ - Publishes each change inside `startTransition()` with a `"forward"` or `"back"` transition type, so a `<Transition>` around the routes runs a view transition. A replace, or a change the browser already animated (for example a swipe-back), has no transition.
32799
+ - Uses the browser Navigation API. Without it (older browsers, server renders) there are no stacks and no transitions.
32656
32800
 
32657
- Exactly one `<Navigation>` per app — nested routers share this single store.
32801
+ Exactly one `<Navigation>` per app. Nested routers share its store.
32658
32802
 
32659
- TODO: switch click/popstate handling to the browser Navigation API when broadly supported.
32803
+ The top-level navigation provider for a client-side app. It owns one `NavigationStore`, turns link clicks into navigation, and publishes the live URL into `<Meta>`, so each `<Router>` re-renders when the URL changes. Use exactly one `<Navigation>` per app. Nested routers all share its store.
32660
32804
 
32661
- The top-level navigation provider for a client-side app. It owns a single `NavigationStore`, publishes the live URL into the `<Meta>` context so descendant `<Router>`s re-render on navigation, and wires up browser history. Use exactly one `<Navigation>` per app — nested routers all share its single store.
32805
+ Give it `stacks` for an app with a tab bar. Each stack is one tab with its own history of pages, like a phone app: each tab remembers where you left it, and a back button goes back within its tab.
32662
32806
 
32663
32807
  **Things to know:**
32664
32808
 
32665
- - Same-origin anchor clicks are intercepted automatically and turned into `forward()` calls. Add a `download` attribute to an anchor to opt out.
32666
- - An anchor with a `data-back` attribute calls `back()` instead, so the page slides back. Set it with the `back` prop on `<Button>` or `<Link>`, e.g. on a "Back to profile" button.
32667
- - It listens for `popstate` so the store stays in sync with browser back/forward.
32668
- - It publishes each page change inside `startTransition()`, so a `<Transition>` around the routes animates it. A link click, `NavigationStore.forward()` or `NavigationStore.redirect()` sets the `"forward"` transition type. A `data-back` link click, `NavigationStore.back()`, and the browser back or forward button set `"back"` (`popstate` does not say which way it went).
32669
- - When the browser already animated the change, for example a swipe-back gesture on a phone, there is no view transition, so the page does not slide twice. The browser says so with `hasUAVisualTransition` on the `popstate` event. Other browsers still slide.
32670
- - The `popstate` update waits for the next task (`setTimeout()`). React renders a transition that starts inside `popstate` as a sync update with no view transition.
32671
- - It initialises the store from the surrounding `<Meta>` url/base, so set those on an ancestor `<App>` / `<HTML>` / `<Page>`. In the browser the store falls back to `window.location.href` when no url is set.
32672
- - The meta it publishes always has a `root` — when none is set anywhere, `root` defaults to the live URL's origin. Setting `root` explicitly on `<App>` / `<HTML>` is still strongly recommended, especially for apps served under a sub-path.
32673
- - `<Router>` works with no `<Navigation>` at all (SSR, static rendering, tests) — `<Navigation>` is only what makes the URL *live* on the client.
32809
+ - Same-origin link clicks become `NavigationStore.forward()`, so the page slides forward.
32810
+ - A link with `className="back"` calls `NavigationStore.back()`, so the page slides back. `<BackButton>` sets this class for you.
32811
+ - A link with `className="replace"` calls `NavigationStore.replace()`. It changes the URL with no new history entry and no slide, and keeps the same page mounted. Use it for tabs inside a page.
32812
+ - Clicks with a modifier key (Cmd, Ctrl, Shift, Alt), a middle-click, and links with `download` or a `target` other than `_self` go to the browser as usual.
32813
+ - It publishes each page change inside `startTransition()` with a `"forward"` or `"back"` transition type, so a `<Transition>` such as `<HorizontalTransition>` slides the page. A replace has no transition.
32814
+ - The browser back and forward buttons slide too. Inside a stack the direction comes from the depth of the page. Across stacks it comes from tab order.
32815
+ - When the browser already animated the change (for example a swipe-back on a phone), there is no view transition, so the page does not slide twice.
32816
+ - It publishes `stack` (the root of the current stack) into `<Meta>` beside `url`, so any component can read the current tab with `requireMeta().stack`. With no `stacks`, the app has one stack, and `stack` is `"/"`.
32817
+ - It reads the start URL and root from the surrounding `<Meta>`, so set `url` and `root` on an ancestor `<App>` or `<HTML>`. In the browser the URL falls back to `window.location.href`.
32818
+ - `<Router>` works with no `<Navigation>` (server renders, static renders, tests). `<Navigation>` only makes the URL live on the client.
32819
+
32820
+ ### Browser support
32821
+
32822
+ Stacks and slides use the browser [Navigation API](https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API). Without it (older browsers, a server render, or a sandboxed frame), `<Navigation>` falls back to plain navigation:
32823
+
32824
+ - Links still go through the app with no page reload, and the browser back button works.
32825
+ - There are no stacks, no slides and no `<RouteCache>`. Each page mounts fresh.
32826
+ - `<StackButton>` is a plain link to its stack's root. `<BackButton>` is a plain link to its `href`.
32674
32827
 
32675
32828
  ## Usage
32676
32829
 
32830
+ ### Basic setup
32831
+
32677
32832
  ```tsx
32678
- import { HTML, Navigation, Router } from "shelving/ui";
32833
+ import { App, Navigation, Router } from "shelving/ui";
32679
32834
 
32680
- <HTML url={initialUrl} root="https://example.com/">
32835
+ <App root="https://example.com/">
32681
32836
  <Navigation>
32682
32837
  <Router routes={ROUTES}/>
32683
32838
  </Navigation>
32684
- </HTML>
32839
+ </App>
32685
32840
  ```
32686
32841
 
32687
- ### Page transitions
32842
+ ### App with a tab bar
32843
+
32844
+ List the root path of each stack in tab order. Put a `<StackButton>` for each stack in the tab bar.
32688
32845
 
32689
32846
  ```tsx
32690
- import { HorizontalTransition, Navigation, Router } from "shelving/ui";
32847
+ import { App, HorizontalTransition, Navigation, RouteCache, Router, StackButton } from "shelving/ui";
32691
32848
 
32692
- // Links slide right. Back links and the browser back button slide left.
32693
- <Navigation>
32694
- <HorizontalTransition>
32695
- <Router routes={ROUTES}/>
32696
- </HorizontalTransition>
32697
- </Navigation>
32849
+ const STACKS = ["/home", "/discover", "/profile"] as const;
32850
+
32851
+ <App root="https://example.com/">
32852
+ <Navigation stacks={STACKS}>
32853
+ <HorizontalTransition>
32854
+ <RouteCache>
32855
+ <Router routes={ROUTES}/>
32856
+ </RouteCache>
32857
+ </HorizontalTransition>
32858
+ <nav className="tab-bar">
32859
+ <StackButton stack="/home">Home</StackButton>
32860
+ <StackButton stack="/discover">Discover</StackButton>
32861
+ <StackButton stack="/profile">Profile</StackButton>
32862
+ </nav>
32863
+ </Navigation>
32864
+ </App>
32865
+ ```
32698
32866
 
32699
- // A "back to" link slides left too.
32700
- <Button href="/profile" back>Back to profile</Button>
32867
+ To select a tab when the app starts, pass the starting `stack`. The app decides which stack the opening URL belongs to, for example:
32868
+
32869
+ ```tsx
32870
+ const path = window.location.pathname;
32871
+ const stack = STACKS.find(s => path === s || path.startsWith(`${s}/`));
32872
+
32873
+ <Navigation stacks={STACKS} stack={stack}>
32874
+ ```
32875
+
32876
+ Put the transition **outside** `<RouteCache>`, around the whole cache. Safari (iOS 18) loses the exit animation when each page has its own `<ViewTransition>`.
32877
+
32878
+ The app opens in the `stack` you set on `<Navigation>` (or on the surrounding `<Meta>`, like `url` and `root`), else in the `/` stack. A page in the `/` stack, such as a deep link or a login page, is **unstacked**: no tab is selected, and links from it stay unstacked until you tap a tab or name a stack (for example `nav.replace("/home", "/home")` after a login). See `NavigationStore`.
32879
+
32880
+ Each link pushes a new page onto the current stack, wherever it points. So a link from `/home` to `/profile/settings` opens the settings page in the Home tab, and the Profile tab stays where it was. Tap a `<StackButton>` to change tab.
32881
+
32882
+ ### Links
32883
+
32884
+ ```tsx
32885
+ // Opens a new page in the current stack. Slides forward.
32886
+ <Button href="/home/post/1">Open post</Button>
32887
+
32888
+ // Goes back to a page. Slides back.
32889
+ // If the page is already in the stack, the stack goes back to it.
32890
+ <Button href="/home" className="back">Back to home</Button>
32891
+
32892
+ // The back button for a page header. Goes to the page before this one in the stack, or to `href`.
32893
+ <BackButton href="/home"/>
32894
+
32895
+ // Changes the URL but keeps the same page. No slide, no new history entry.
32896
+ <Button href="/profile/posts" className="replace">Posts</Button>
32897
+ <Button href="/profile/likes" className="replace">Likes</Button>
32701
32898
  ```
32702
32899
 
32703
32900
  ### Imperative navigation
32704
32901
 
32705
- Read the navigation store from anywhere in the tree with `requireNavigation()` for imperative URL changes:
32902
+ Read the store from anywhere in the tree with `requireNavigation()`:
32706
32903
 
32707
32904
  ```tsx
32708
32905
  import { requireNavigation } from "shelving/ui";
32709
32906
 
32710
32907
  const nav = requireNavigation();
32711
- nav.forward("/users/123"); // push a new history entry
32712
- nav.redirect("/login"); // replace the current history entry
32713
- nav.back("/users"); // push a new history entry that slides back
32908
+ nav.forward("/home/post/1"); // Open a page in the current stack.
32909
+ nav.back("/home"); // Go back to a page.
32910
+ nav.replace("/login"); // Change the URL of the current page.
32714
32911
  ```
32715
32912
 
32913
+ See `NavigationStore` for what each method does.
32914
+
32716
32915
 
32717
32916
  ## Signatures
32718
32917
 
32719
32918
  ```ts
32720
- Navigation({ children, ...meta }: NavigationProps): ReactElement
32919
+ Navigation({ children, stacks = [], ...meta }: NavigationProps): ReactElement
32721
32920
  ```
32722
32921
 
32723
32922
  ## Parameters
@@ -32725,6 +32924,8 @@ Navigation({ children, ...meta }: NavigationProps): ReactElement
32725
32924
  | Param | Type | Description |
32726
32925
  | --- | --- | --- |
32727
32926
  | `meta` | `NavigationProps` | |
32927
+ | `.stacks` | `readonly AbsolutePath[] \| undefined` | Root path of each stack, in tab order, for an app with a tab bar (for example `["/home", "/discover", "/profile"]`). - Each stack keeps its own pages, so each tab remembers where you left it, and a back button goes back within its tab. - With no stacks, the app has one stack at `"/"`, and `stack` in `Meta` is `"/"`. Read only. Optional. |
32928
+ | `.stack` | `AbsolutePath \| undefined` | Stack of the page the app opens at (for example `"/home"`), like `url` and `root`. - Read from this prop, else from the surrounding `<Meta>`, else `"/"`. - Used only when the opening history entry has no saved stack. A reload keeps the stack it had. Read only. Optional. |
32728
32929
 
32729
32930
  ## Returns
32730
32931
 
@@ -32777,6 +32978,72 @@ requireNavigation(): NavigationStore
32777
32978
  | `unknown` | RequiredError If no `<Navigation>` provider is present above. |
32778
32979
 
32779
32980
 
32981
+ ---
32982
+
32983
+ # NavigationPositionContext
32984
+
32985
+ - Kind: constant
32986
+ - Import: `import { NavigationPositionContext } from "shelving/ui";`
32987
+
32988
+ React context holding where the app is in its stacks, published by `<Navigation>` with each URL change.
32989
+ - `undefined` without the browser Navigation API, during a server render, or outside `<Navigation>`.
32990
+ - `<RouteCache>`, `<Router>` and `<BackButton>` read it, so they change in the same render as the URL.
32991
+
32992
+
32993
+ ---
32994
+
32995
+ # NavigationEntryState
32996
+
32997
+ - Kind: interface
32998
+ - Import: `import { NavigationEntryState } from "shelving/ui";`
32999
+
33000
+ State that `NavigationStore` saves on each browser history entry.
33001
+
33002
+ ## Signatures
33003
+
33004
+ ```ts
33005
+ {
33006
+ readonly stack: AbsolutePath;
33007
+ readonly depth: number;
33008
+ }
33009
+ ```
33010
+
33011
+ ## Properties
33012
+
33013
+ | Property | Type | Description |
33014
+ | --- | --- | --- |
33015
+ | `stack` | `AbsolutePath` | Root path of the stack this page is in. Read only. |
33016
+ | `depth` | `number` | Position of this page in its stack, where `0` is the root. Read only. |
33017
+
33018
+
33019
+ ---
33020
+
33021
+ # NavigationPosition
33022
+
33023
+ - Kind: interface
33024
+ - Import: `import { NavigationPosition } from "shelving/ui";`
33025
+ - Extends: `NavigationEntryState`
33026
+
33027
+ Where the app is now in its stacks: the current stack and depth, the top depth of each stack, and the page before the current one.
33028
+ - `undefined` when the browser has no Navigation API, or during a server render.
33029
+
33030
+ ## Signatures
33031
+
33032
+ ```ts
33033
+ {
33034
+ readonly tops: { readonly [stack: AbsolutePath]: number };
33035
+ readonly parent: AbsolutePath | undefined;
33036
+ }
33037
+ ```
33038
+
33039
+ ## Properties
33040
+
33041
+ | Property | Type | Description |
33042
+ | --- | --- | --- |
33043
+ | `tops` | `{ readonly [stack: AbsolutePath]: number }` | Depth of the top page of each stack that has pages. Read only. |
33044
+ | `parent` | `AbsolutePath \| undefined` | The page before the current one in its stack, or `undefined` at the bottom of the stack. Read only. |
33045
+
33046
+
32780
33047
  ---
32781
33048
 
32782
33049
  # NavigationStore
@@ -32785,46 +33052,120 @@ requireNavigation(): NavigationStore
32785
33052
  - Import: `import { NavigationStore } from "shelving/ui";`
32786
33053
  - Extends: `URLStore`
32787
33054
 
32788
- Store holding the current navigation URL and driving browser history.
33055
+ Store that holds the current navigation URL, drives browser history, and keeps a stack of pages for each tab.
32789
33056
 
32790
- - Extends `URLStore`; the current location is its `value`.
32791
- - `forward()` pushes a new history entry; `redirect()` replaces the current one.
32792
- - `back()` pushes a new history entry like `forward()`, but `<Navigation>` animates it as a back transition.
32793
- - TODO: switch to the browser Navigation API when broadly supported.
33057
+ - Extends `URLStore`, so its `value` is the current URL.
33058
+ - With the browser Navigation API, each history entry saves a `NavigationEntryState`, and each stack is read from `navigation.entries()` when it is needed. Nothing else is kept.
33059
+ - `stack` is a sub-store that holds the root of the current stack. It only changes when the stack changes.
33060
+ - Without the Navigation API (older browsers and server renders) there are no stacks: `stack` stays the starting stack, `history()` is empty, and `stack` arguments are ignored.
33061
+ - Owned by `<Navigation>`. Read it with `requireNavigation()`.
32794
33062
 
32795
- The store holding the current navigation URL and driving browser history. It extends `URLStore` — the current location is its `value` — and is owned by `<Navigation>`. Reach for it via `requireNavigation()` rather than constructing your own.
33063
+ The store that holds the current URL, drives browser history, and keeps one stack of pages for each tab. It extends `URLStore`, so its `value` is the current URL. `<Navigation>` owns it. Read it with `requireNavigation()`, and do not make your own.
32796
33064
 
32797
33065
  **Things to know:**
32798
33066
 
32799
- - `forward()` pushes a new browser history entry; `redirect()` replaces the current one. Both resolve the destination against the store's `base`.
32800
- - `back()` pushes a new browser history entry like `forward()`, but `<Navigation>` gives it the `"back"` transition type, so the page slides back. It does not go back in the browser history, so it works when the page was opened directly.
32801
- - It is a `shelving/store` `URLStore`, so components can subscribe to it for re-renders.
33067
+ - `NavigationStore.stacks` is the root path of each stack, in tab order, from the `stacks` prop on `<Navigation>`. With no stacks the app has one stack at `/`.
33068
+ - A page that is not in a listed stack is **unstacked**: it is in the `/` stack. See [Unstacked pages](#unstacked-pages).
33069
+ - `NavigationStore.stack` is a sub-store that holds the root of the current stack. It is always set: with no stacks it is `"/"`. It changes only when the stack changes, so `useStore(nav.stack)` re-renders only on a tab change.
33070
+ - `NavigationStore.history()` returns the pages in the current stack (or a given stack), root first.
33071
+ - `NavigationStore.position` is the current stack and depth, the depth of the top page of each stack, and the page before this one. `<RouteCache>` and `<BackButton>` use it.
33072
+ - All URLs resolve against the store's `base`. Each method also takes a full same-origin URL.
33073
+ - Without the browser Navigation API there is no stack history: `stack` stays the starting stack, `history()` returns `[]`, `position` is `undefined`, and every `stack` argument is ignored. `forward()` and `back()` push a history entry, and `replace()` replaces it.
33074
+
33075
+ ## Methods
33076
+
33077
+ | Method | What it does | Slide |
33078
+ |---|---|---|
33079
+ | `forward(href, stack?)` | Opens `href` as a new page on top of the stack. If `href` is the top page of another stack, it switches to that stack (a tab switch). If `href` is the current URL, it is a replace. | Forward. Across stacks, by tab order. |
33080
+ | `back(href, stack?)` | Goes back to `href`. If `href` is in the stack, the stack goes back to it, and the pages above it leave the stack. If `href` is the root of the stack, the stack goes to its root. Otherwise `href` takes the place of the top page of the stack. | Back |
33081
+ | `replace(href, stack?)` | Changes the URL of the current page. The stack, the depth and the mounted page stay the same. No new history entry. With another `stack`, the page moves into that stack: at its root if `href` is the root, else on top of its pages. | None |
33082
+ | `history(stack?)` | Returns the pages in `stack`, root first. | — |
33083
+
33084
+ `stack` defaults to the current stack.
33085
+
33086
+ ## Unstacked pages
33087
+
33088
+ A page changes stack only when you say so: with a `<StackButton>`, or with a `stack` argument to `forward()`, `back()` or `replace()`. Links never change stack. The page the app opens at starts in the `stack` set on `<Navigation>` (or the surrounding `<Meta>`), else in the `/` stack. A page in the `/` stack is **unstacked**. For example: a deep link into the app, a fresh open of `/post/9`, or a login page.
33089
+
33090
+ - On an unstacked page, no `<StackButton>` is selected.
33091
+ - Links from an unstacked page push deeper in the `/` stack, even a link to a stack root.
33092
+ - To leave the `/` stack, tap a `<StackButton>`, or name the stack.
33093
+ - To select a tab when the app starts, set `stack` on `<Navigation>`. The app decides which stack the opening URL belongs to. After a reload, each history entry keeps the stack it had.
33094
+ - If you list `/` as one of the `stacks`, it is a normal tab, and unstacked pages open in it.
33095
+
33096
+ For example, a login page sends the user home after they log in, and names the Home stack:
33097
+
33098
+ ```tsx
33099
+ const nav = requireNavigation();
33100
+ nav.replace("/home", "/home");
33101
+ ```
33102
+
33103
+ ## How stacks work
33104
+
33105
+ The store saves a small state on each browser history entry: the `stack` the page is in, and its `depth` in that stack (`0` is the root). See `NavigationEntryState`. To read a stack, the store walks back through the browser history from the current entry. It takes the newest entry in that stack, then the newest earlier entry with a lower depth, and so on down to depth `0`.
33106
+
33107
+ Why depth? A browser history entry cannot be changed or removed. So when you go back in one stack while another stack's pages are after it in the history, the store cannot go back in the browser. It pushes a new entry for the page you went back to, at that page's depth. The pages that were above it now have a higher depth than the newest entry, so they are no longer in the stack.
33108
+
33109
+ For example, with tabs `/home` and `/profile`:
33110
+
33111
+ | Step | New history entry | Home stack | Profile stack |
33112
+ |---|---|---|---|
33113
+ | Start at `/home` | `/home` (depth 0) | `/home` | — |
33114
+ | Open a post | `/home/post/1` (depth 1) | `/home`, `/home/post/1` | — |
33115
+ | Tap the Profile tab | `/profile` (depth 0) | `/home`, `/home/post/1` | `/profile` |
33116
+ | Tap the Home tab | `/home/post/1` (depth 1) | `/home`, `/home/post/1` | `/profile` |
33117
+ | Tap the back button | `/home` (depth 0) | `/home` | `/profile` |
33118
+
33119
+ When the page you go back to is the entry just before the current one, `back()` goes back in the browser history and pushes nothing.
33120
+
33121
+ The browser back and forward buttons walk the history entries one at a time, as usual. Each entry knows its stack and depth, so the stacks are always right and the slide goes the right way.
32802
33122
 
32803
33123
  ## Usage
32804
33124
 
32805
33125
  ```tsx
32806
- import { requireNavigation } from "shelving/ui";
33126
+ import { Button, requireNavigation } from "shelving/ui";
32807
33127
 
32808
33128
  function LogoutButton() {
32809
33129
  const nav = requireNavigation();
32810
- return <Button onClick={() => nav.redirect("/login")}>Log out</Button>;
33130
+ return <Button onClick={() => nav.replace("/login")}>Log out</Button>;
32811
33131
  }
32812
33132
  ```
32813
33133
 
32814
- Constructed directly only when wiring navigation by hand (e.g. tests):
33134
+ Read the current stack in a component:
33135
+
33136
+ ```tsx
33137
+ import { useStore } from "shelving/react";
33138
+ import { requireNavigation } from "shelving/ui";
33139
+
33140
+ function TabTitle() {
33141
+ const nav = requireNavigation();
33142
+ const stack = useStore(nav.stack).value;
33143
+ return <h1>{stack === "/profile" ? "Profile" : "Home"}</h1>;
33144
+ }
33145
+ ```
33146
+
33147
+ List the pages in a stack (for example, for breadcrumbs):
33148
+
33149
+ ```tsx
33150
+ const nav = requireNavigation();
33151
+ nav.history("/home"); // ["/home", "/home/post/1", "/home/post/1/comments"]
33152
+ ```
33153
+
33154
+ Make a store by hand only in tests:
32815
33155
 
32816
33156
  ```tsx
32817
33157
  import { NavigationStore } from "shelving/ui";
32818
33158
 
32819
- const nav = new NavigationStore("/");
32820
- nav.forward("/home");
33159
+ // URL, root, starting stack, then the stacks in tab order.
33160
+ const nav = new NavigationStore("https://example.com/home", "https://example.com/", "/home", "/home", "/profile");
33161
+ nav.forward("/home/post/1");
32821
33162
  ```
32822
33163
 
32823
33164
 
32824
33165
  ## Signatures
32825
33166
 
32826
33167
  ```ts
32827
- new NavigationStore(url: PossibleURL = typeof window === "undefined" ? "/" : window.location.href, base?: PossibleURL)
33168
+ new NavigationStore(url: PossibleURL = typeof window === "undefined" ? "/" : window.location.href, base?: PossibleURL, stack: AbsolutePath = "/", ...stacks: AbsolutePath[])
32828
33169
  ```
32829
33170
 
32830
33171
  ## Parameters
@@ -32833,6 +33174,8 @@ new NavigationStore(url: PossibleURL = typeof window === "undefined" ? "/" : win
32833
33174
  | --- | --- | --- |
32834
33175
  | `url` | `PossibleURL` | Defaults to `typeof window === "undefined" ? "/" : window.location.href`. |
32835
33176
  | `base` | `PossibleURL` | Optional. |
33177
+ | `stack` | `AbsolutePath` | Defaults to `"/"`. |
33178
+ | `stacks` | `AbsolutePath[]` | |
32836
33179
 
32837
33180
  ## Returns
32838
33181
 
@@ -32844,180 +33187,131 @@ new NavigationStore(url: PossibleURL = typeof window === "undefined" ? "/" : win
32844
33187
 
32845
33188
  | Property | Type | Description |
32846
33189
  | --- | --- | --- |
32847
- | `transition` | `TransitionType \| null` | Transition type of the next URL change. `null` means no transition. `<Navigation>` reads it, then sets it back to `"forward"`. Defaults to `"forward"`. |
33190
+ | `stacks` | `readonly AbsolutePath[]` | Root path of each stack, in tab order. A single-stack app has one root. Read only. |
33191
+ | `stack` | `Store<AbsolutePath>` | Root path of the current stack. - Always set. With no `stacks`, it is `"/"`. - It starts at the `stack` given to the constructor (default `"/"`). Without the Navigation API, it stays there. Read only. |
33192
+ | `transition` | `TransitionType \| null` | Transition type of the most recent change, read by `<Navigation>` when the value changes. - `null` means no transition: a replace, a change the browser already animated (for example a swipe-back), or no Navigation API. Defaults to `null`. |
33193
+ | `position` | `NavigationPosition \| undefined` | Where the app is now: the current stack and depth, and the top depth of each stack. Read only. |
32848
33194
 
32849
33195
  ## Methods
32850
33196
 
32851
- - [NavigationStore.forward()](ui/NavigationStore/forward.md): Navigate forward to a URL, pushing a new browser history entry.
32852
- - [NavigationStore.redirect()](ui/NavigationStore/redirect.md): Redirect to a URL, replacing the current browser history entry.
32853
- - [NavigationStore.back()](ui/NavigationStore/back.md): Navigate back to a URL, pushing a new browser history entry with the "back" transition type.
33197
+ - [NavigationStore.listen()](ui/NavigationStore/listen.md): Start listening to the browser (back, forward and swipe).
33198
+ - [NavigationStore.history()](ui/NavigationStore/history.md): Get the pages in a stack, root first, or every page in every stack.
33199
+ - [NavigationStore.forward()](ui/NavigationStore/forward.md): Go forward to a URL, as a link does.
33200
+ - [NavigationStore.back()](ui/NavigationStore/back.md): Go back to a URL, as a back button does.
33201
+ - [NavigationStore.replace()](ui/NavigationStore/replace.md): Replace the current URL, with no transition.
32854
33202
 
32855
33203
 
32856
33204
  ---
32857
33205
 
32858
- # NavigationStore.forward()
33206
+ # NavigationStore.listen()
32859
33207
 
32860
33208
  - Kind: method
32861
33209
  - Member of: `NavigationStore`
32862
33210
 
32863
- Navigate forward to a URL, pushing a new browser history entry.
33211
+ Start listening to the browser (back, forward and swipe).
33212
+ - Saves the current stack and depth on the current history entry, if it has none.
33213
+ - `<Navigation>` calls it once, when it mounts.
32864
33214
 
32865
33215
  ## Signatures
32866
33216
 
32867
33217
  ```ts
32868
- forward(possible: PossibleURL): void
33218
+ listen(): () => void
32869
33219
  ```
32870
33220
 
32871
33221
 
32872
33222
  ---
32873
33223
 
32874
- # NavigationStore.redirect()
33224
+ # NavigationStore.history()
32875
33225
 
32876
33226
  - Kind: method
32877
33227
  - Member of: `NavigationStore`
32878
33228
 
32879
- Redirect to a URL, replacing the current browser history entry.
33229
+ Get the pages in a stack, root first, or every page in every stack.
33230
+ - Read from the browser history entries up to the current one.
33231
+ - A stack whose root entry is gone (the browser keeps a limited history) still starts with its root.
33232
+ - Without the Navigation API this is always empty.
32880
33233
 
32881
33234
  ## Signatures
32882
33235
 
32883
33236
  ```ts
32884
- redirect(possible: PossibleURL): void
33237
+ history(stack: AbsolutePath = this.stack.value): AbsolutePath[]
32885
33238
  ```
32886
33239
 
32887
33240
 
32888
33241
  ---
32889
33242
 
32890
- # NavigationStore.back()
33243
+ # NavigationStore.forward()
32891
33244
 
32892
33245
  - Kind: method
32893
33246
  - Member of: `NavigationStore`
32894
33247
 
32895
- Navigate back to a URL, pushing a new browser history entry with the `"back"` transition type.
32896
- - Use it for a "back to" link, so the page slides back, not forward.
32897
- - It does not go back in the browser history, so it also works when the page was opened directly.
33248
+ Go forward to a URL, as a link does.
33249
+ - The URL is the top page of `stack`: switch to that stack, at the same depth. This is a tab switch.
33250
+ - Else push the URL onto `stack`, one level deeper than its top page.
33251
+ - The URL you are already on: replace it instead.
33252
+ - A change of stack slides by tab order. Else it slides forward.
32898
33253
 
32899
33254
  ## Signatures
32900
33255
 
32901
33256
  ```ts
32902
- back(possible: PossibleURL): void
33257
+ forward(possible: PossibleURL, stack: AbsolutePath = this.stack.value): void
32903
33258
  ```
32904
33259
 
32905
33260
 
32906
33261
  ---
32907
33262
 
32908
- # RouteCacheProps
33263
+ # NavigationStore.back()
32909
33264
 
32910
- - Kind: interface
32911
- - Import: `import { RouteCacheProps } from "shelving/ui";`
33265
+ - Kind: method
33266
+ - Member of: `NavigationStore`
32912
33267
 
32913
- Props for `<RouteCache>` — the `maxCached` size and the content `children` to keep alive per URL.
33268
+ Go back to a URL, as a back button does.
33269
+ - The URL is an earlier page in `stack`: go back to it. When it is the entry just before the current one, this goes back in the browser history. Else it pushes the URL again at that page's depth.
33270
+ - The URL is the root of `stack`: push it at depth 0.
33271
+ - Else push the URL in place of the top page of `stack`.
33272
+ - It works when the app was opened at the current page, so a back button always has somewhere to go.
32914
33273
 
32915
33274
  ## Signatures
32916
33275
 
32917
33276
  ```ts
32918
- {
32919
- readonly maxCached?: number | undefined;
32920
- readonly children: ReactNode;
32921
- }
33277
+ back(possible: PossibleURL, stack: AbsolutePath = this.stack.value): void
32922
33278
  ```
32923
33279
 
32924
- ## Properties
32925
-
32926
- | Property | Type | Description |
32927
- | --- | --- | --- |
32928
- | `maxCached` | `number \| undefined` | Number of recently-visited URLs to keep mounted (but hidden) so the entire state of their subtree — scroll position of every scroll container, open/closed toggles, in-progress searches, form inputs, focus — is restored intact when navigating back or forward to them. - Defaults to `10`. Once the limit is reached the least-recently-visited entry is unmounted. - Set to `0` (or less) to disable caching and unmount the subtree as you leave each URL. Read only. Optional. |
32929
- | `children` | `ReactNode` | The content to render for the current URL and keep alive (hidden) for recently-visited URLs. Read only. |
32930
-
32931
33280
 
32932
33281
  ---
32933
33282
 
32934
- # RouteCache
32935
-
32936
- - Kind: component
32937
- - Import: `import { RouteCache } from "shelving/ui";`
32938
-
32939
- Keep-alive page cache keyed by the current URL — drop it into a layout around its scrolling content region.
32940
-
32941
- - Reads the live URL from the surrounding `<Meta>` context and keeps up to `maxCached` recently-visited
32942
- pages mounted but hidden (via React's `<Activity>`), so navigating back/forward to a page restores its
32943
- entire DOM and component state — scroll position, toggles, searches, inputs, focus — untouched.
32944
- - Pages are kept in a least-recently-used map keyed by `path`; the oldest is unmounted past the limit.
32945
- - A page that owns other paths with `<RouteConfig path>` stays mounted when the URL changes to one of them.
32946
- - A page with `<RouteConfig cache={false}>` is dropped as soon as you leave it, so the next visit shows a new page.
32947
- - Each snapshot is frozen under its own `<MetaContext>`, so the same single `children` element resolves a
32948
- different page per path and a hidden page never re-renders for someone else's URL.
32949
- - `<Activity mode="hidden">` preserves a hidden page's state while unmounting its effects, so its
32950
- subscriptions/observers/timers pause and resume cleanly as it is hidden and shown.
32951
- - Because it wraps the scroll container itself (rather than sitting below it inside the router), the
32952
- scroll position of every cached page is preserved — surrounding chrome (sidebar, drawer state) stays
32953
- outside the cache, so it is neither duplicated nor remounted on navigation.
32954
- - When `maxCached <= 0` the page is rendered directly with no caching (it unmounts as you leave it).
32955
-
32956
- A keep-alive page cache. Drop it into a layout around its scrolling content region: it reads the current URL from the surrounding `<Meta>` context and keeps a handful of recently-visited pages mounted but *hidden* (using React's [`<Activity>`](https://react.dev/reference/react/Activity)), so navigating back or forward to a page restores its entire DOM and component state — scroll position of every scroll container, open/closed toggles, in-progress searches, form inputs, focus — instead of remounting it fresh at the top.
33283
+ # NavigationStore.replace()
32957
33284
 
32958
- Shelving's `<SidebarLayout>` and `<CenteredLayout>` already wrap their scrollable content column in one for you, so pages rendered inside them keep their state across navigation automatically. Reach for it by hand only when building a custom layout.
32959
-
32960
- **Things to know:**
32961
-
32962
- - Pages are kept in a least-recently-used map keyed by `path`. Once `maxCached` pages are retained the least-recently-visited one is unmounted (and loses its state). A never-seen or evicted page mounts fresh at the top.
32963
- - A page can own other paths with `<RouteConfig path>`, for example its tabs (`/dave/{tab}`). A navigation to one of those paths keeps the same page mounted: it keeps its scroll and state, and a `<ViewTransition>` around the page does not slide.
32964
- - A page with `<RouteConfig cache={false}>` is not kept: it unmounts as you leave it, so the next visit starts again. Use it for a form that makes or edits something, so it never shows old input.
32965
- - The cache key is the path only, not the `?query`. So `/new?from=a` and `/new?from=b` are one page.
32966
- - Pass `maxCached={0}` (or less) to disable caching entirely — the page renders directly and unmounts as soon as you leave it.
32967
- - `<Activity mode="hidden">` preserves a hidden page's *state* while unmounting its *effects*, so subscriptions, observers (e.g. infinite-scroll), and timers pause and resume cleanly as the page is hidden and shown.
32968
- - Each snapshot is frozen under its own `<Meta>` context, so the same single `children` element resolves a different page per path and a hidden page never re-renders for someone else's URL.
32969
- - For per-page **scroll** to be preserved the cache has to wrap the scroll container itself — which is why it lives in the layout (around the scrollable column) rather than below it inside the router. Surrounding chrome (sidebar, drawer state) stays outside the cache, so it is neither duplicated nor remounted on navigation.
32970
-
32971
- ## Usage
32972
-
32973
- ```tsx
32974
- import { RouteCache } from "shelving/ui";
32975
-
32976
- <SidebarLayout sidebar={<Menu/>}>
32977
- <RouteCache>
32978
- <Router routes={routes}/>
32979
- </RouteCache>
32980
- </SidebarLayout>
32981
- ```
33285
+ - Kind: method
33286
+ - Member of: `NavigationStore`
32982
33287
 
33288
+ Replace the current URL, with no transition.
33289
+ - The page stays in the same stack, at the same depth, so a cached page stays mounted.
33290
+ - Use it for a page that knows its canonical URL, or for in-page tabs.
33291
+ - Pass a `stack` to move the page into that stack: at its root if the URL is the root, else on top of its pages. For example, a login page calls `replace("/home", "/home")`.
32983
33292
 
32984
33293
  ## Signatures
32985
33294
 
32986
33295
  ```ts
32987
- RouteCache({ maxCached = 10, children }: RouteCacheProps): ReactNode
33296
+ replace(possible: PossibleURL, stack: AbsolutePath = this.stack.value): void
32988
33297
  ```
32989
33298
 
32990
- ## Parameters
32991
-
32992
- | Param | Type | Description |
32993
- | --- | --- | --- |
32994
- | `props` | `RouteCacheProps` | |
32995
- | `.maxCached` | `number \| undefined` | Number of recently-visited URLs to keep mounted (but hidden) so the entire state of their subtree — scroll position of every scroll container, open/closed toggles, in-progress searches, form inputs, focus — is restored intact when navigating back or forward to them. - Defaults to `10`. Once the limit is reached the least-recently-visited entry is unmounted. - Set to `0` (or less) to disable caching and unmount the subtree as you leave each URL. Read only. Optional. |
32996
- | `.children` | `ReactNode` | The content to render for the current URL and keep alive (hidden) for recently-visited URLs. Read only. |
32997
-
32998
- ## Returns
32999
-
33000
- | Type | Description |
33001
- | --- | --- |
33002
- | `ReactNode` | |
33003
-
33004
33299
 
33005
33300
  ---
33006
33301
 
33007
- # RouteConfigProps
33302
+ # RouteCacheProps
33008
33303
 
33009
33304
  - Kind: interface
33010
- - Import: `import { RouteConfigProps } from "shelving/ui";`
33305
+ - Import: `import { RouteCacheProps } from "shelving/ui";`
33011
33306
 
33012
- Props for `<RouteConfig>` — the settings of a page for the surrounding `<Router>` and `<RouteCache>`, and the page content.
33307
+ Props for `<RouteCache>`: the `maxCached` size and the content `children` to keep alive for each page in the stacks.
33013
33308
 
33014
33309
  ## Signatures
33015
33310
 
33016
33311
  ```ts
33017
33312
  {
33018
- readonly path?: AbsolutePath | undefined;
33019
- readonly cache?: boolean | undefined;
33020
- readonly children?: ReactNode;
33313
+ readonly maxCached?: number | undefined;
33314
+ readonly children: ReactNode;
33021
33315
  }
33022
33316
  ```
33023
33317
 
@@ -33025,82 +33319,111 @@ Props for `<RouteConfig>` — the settings of a page for the surrounding `<Route
33025
33319
 
33026
33320
  | Property | Type | Description |
33027
33321
  | --- | --- | --- |
33028
- | `path` | `AbsolutePath \| undefined` | Path template the page owns, for example `/dave/{tab}`. Every path that matches it shows this same page. Read only. Optional. |
33029
- | `cache` | `boolean \| undefined` | Set to `false` so `<RouteCache>` drops the page when you leave it, and the next visit shows a new page. Defaults to `true`. Read only. Optional. |
33030
- | `children` | `ReactNode` | The page content. Read only. Optional. |
33322
+ | `maxCached` | `number \| undefined` | Number of pages to keep mounted (but hidden), so the whole state of each one (scroll position, toggles, searches, form input, focus) is still there when you come back to it. - The top page of each stack is never dropped, even past the limit, so a tab always shows the page you left. - Set to `0` (or less) to turn the cache off and unmount each page as you leave it. Read only. Defaults to `10`. |
33323
+ | `children` | `ReactNode` | The content to render for the current page and keep alive (hidden) for the other pages in the stacks. Read only. |
33031
33324
 
33032
33325
 
33033
33326
  ---
33034
33327
 
33035
- # RouteConfig
33328
+ # RouteCache
33036
33329
 
33037
33330
  - Kind: component
33038
- - Import: `import { RouteConfig } from "shelving/ui";`
33331
+ - Import: `import { RouteCache } from "shelving/ui";`
33332
+
33333
+ Keep-alive page cache for the pages in the navigation stacks. Drop it into a layout around its scrolling content region.
33039
33334
 
33040
- Configure the current page for the surrounding `<Router>` (and `<RouteCache>`).
33041
- - `path` says the page owns every path that matches a template. A navigation to a path the page owns keeps the same
33042
- page mounted, so it keeps its scroll and state, and a `<ViewTransition>` around the page does not run an enter or
33043
- exit. The page updates for the new URL. Use it for a page whose tabs each have their own path: `path="/dave/{tab}"`.
33044
- - Put the real values in the template. `/{name}/{tab}` would make every person's profile one page.
33045
- - `cache={false}` makes `<RouteCache>` drop the page when you leave it, so the next visit starts again with no old
33046
- state. Use it for a form that makes or edits something, for example a "New challenge" page.
33335
+ - Keeps each page in the stacks mounted but hidden (with React's `<Activity>`), so going back to a page, or switching back to a tab, shows it exactly as you left it.
33336
+ - Each page is keyed by its stack and its depth in that stack, not by its URL. So `NavigationStore.replace()` (a canonical URL, an in-page tab) keeps the same page mounted, and the same URL open in two tabs is two separate pages.
33337
+ - A page leaves the cache as soon as it leaves its stack: when you go back from it, or when a stack is popped to its root. After a browser back, a browser forward shows that page fresh.
33338
+ - The top page of each stack is never dropped. Other pages can be dropped past `maxCached`, and show fresh (from the top) when you come back to them.
33339
+ - Each kept page is frozen under its own `<MetaContext>`, so the same `children` element renders a different page for each URL, and a hidden page never re-renders for another page's URL.
33340
+ - `<Activity mode="hidden">` keeps a hidden page's state but unmounts its effects, so its subscriptions and timers pause and resume as it is hidden and shown.
33341
+ - Without the browser Navigation API (older browsers, server renders), or with `maxCached` of `0`, it renders the current page directly with no cache.
33047
33342
 
33048
- Configure the current page for the surrounding `<Router>` (and `<RouteCache>`, if there is one). It has one prop for each setting, so a page wraps itself in one `<RouteConfig>` for all its settings.
33343
+ A keep-alive cache for the pages in the navigation stacks. Put it in a layout around the scrolling content region. It keeps each page in the stacks mounted but hidden (with React's [`<Activity>`](https://react.dev/reference/react/Activity)), so when you go back to a page, or switch back to a tab, the page is exactly as you left it: scroll position, toggles, searches, form input and focus.
33049
33344
 
33050
- - `path` says the page owns every path that matches a template. A navigation between paths the page owns keeps the same page mounted: it keeps its scroll and state, and a `<ViewTransition>` around the page does not slide. Use it for a page whose tabs each have their own path.
33051
- - `cache={false}` tells `<RouteCache>` to drop the page when you leave it. The next visit starts again, with no old state. Use it for a form that makes or edits something, so it never shows old input.
33345
+ `<SidebarLayout>` and `<CenteredLayout>` already wrap their content in a `<RouteCache>`. Use it by hand only in a custom layout.
33052
33346
 
33053
33347
  **Things to know:**
33054
33348
 
33055
- - Without `path`, each path is its own page, so `/challenge/123` and `/challenge/456` stay separate pages.
33056
- - Put the real values in the template (`/dave/{tab}`). A template such as `/{name}/{tab}` makes every profile the same page.
33057
- - The page still renders for the new URL, so it reads the tab from the URL as usual.
33058
- - The cache key is the path only, not the `?query`. A page that reads its `?query` once (for example `/new?from=123`) should use `cache={false}`, so a visit with another `?query` does not show the old page.
33059
- - It works with or without a `<RouteCache>`. In a nested router's page, it tells only that nested router.
33349
+ - Each page is keyed by its stack and its depth in that stack, not by its URL. See `NavigationStore` for how stacks work.
33350
+ - A page leaves the cache when it leaves its stack: when you go back from it, or when its stack goes back to the root. So a page you went back from mounts fresh the next time you open it.
33351
+ - After a browser back, the browser forward button shows the next page fresh (from the top), because that page left its stack when you went back.
33352
+ - The top page of each stack is never dropped, so each tab always shows the page you left. Other pages are dropped (least recently used first) past `maxCached`, and mount fresh when you come back to them.
33353
+ - `NavigationStore.replace()` and `className="replace"` links keep the same page mounted. A replace to another URL for the same component (for example from `/post/1` to `/post/2`) keeps its state. To reset the state, wrap the page content in an element with a `key`, for example `<Fragment key={id}>`.
33354
+ - The same URL open in two stacks is two separate pages.
33355
+ - A form that makes something stays in the cache with its input. Clear it after a successful submit, so it is empty the next time you see it (see the example below).
33356
+ - Each kept page is frozen under its own `<Meta>`, so a hidden page never re-renders for another page's URL.
33357
+ - `<Activity mode="hidden">` keeps a hidden page's state but unmounts its effects, so subscriptions, observers (for example infinite scroll) and timers pause and resume as the page is hidden and shown.
33358
+ - The cache must wrap the scroll container itself to keep each page's scroll. So it goes in the layout around the scrolling column, not inside the router. Chrome outside the cache (a sidebar, a tab bar) is not duplicated or remounted.
33359
+ - Put a page `<Transition>` around the `<RouteCache>`, not inside it. Safari (iOS 18) loses the exit animation when each page has its own `<ViewTransition>`.
33360
+ - Without the browser Navigation API, or with `maxCached={0}`, there is no cache: the current page renders directly and unmounts when you leave it.
33060
33361
 
33061
33362
  ## Usage
33062
33363
 
33063
33364
  ```tsx
33064
- import { Page, RouteConfig } from "shelving/ui";
33365
+ import { HorizontalTransition, RouteCache, Router } from "shelving/ui";
33065
33366
 
33066
- // Each tab has its own path, and all of them are the same page.
33067
- function ProfilePage({ name, tab }: { name: string; tab?: string }) {
33367
+ function MyLayout() {
33068
33368
  return (
33069
- <RouteConfig path={`/${name}/{tab}`}>
33070
- <Page title={name}>
33071
- <ProfileTabs tab={tab} />
33072
- </Page>
33073
- </RouteConfig>
33369
+ <HorizontalTransition>
33370
+ <RouteCache>
33371
+ <main className="scroll">
33372
+ <Router routes={ROUTES}/>
33373
+ </main>
33374
+ </RouteCache>
33375
+ </HorizontalTransition>
33074
33376
  );
33075
33377
  }
33378
+ ```
33379
+
33380
+ Keep fewer pages:
33076
33381
 
33077
- // A new form on each visit.
33078
- function NewChallengePage({ from }: { from?: string }) {
33382
+ ```tsx
33383
+ <RouteCache maxCached={5}>
33384
+ <Router routes={ROUTES}/>
33385
+ </RouteCache>
33386
+ ```
33387
+
33388
+ Clear a create form after it saves. Change the `key` of the `<Form>`, so it mounts again with no input:
33389
+
33390
+ ```tsx
33391
+ import { useState } from "react";
33392
+ import { Form, requireNavigation } from "shelving/ui";
33393
+
33394
+ function NewPostPage() {
33395
+ const nav = requireNavigation();
33396
+ const [formKey, setFormKey] = useState(0);
33079
33397
  return (
33080
- <RouteConfig cache={false}>
33081
- <Page title="New challenge">
33082
- <ChallengeForm from={from} />
33083
- </Page>
33084
- </RouteConfig>
33398
+ <Form
33399
+ key={formKey}
33400
+ schema={POST_SCHEMA}
33401
+ onSubmit={async data => {
33402
+ const id = await createPost(data);
33403
+ setFormKey(k => k + 1);
33404
+ nav.forward(`/post/${id}`);
33405
+ }}
33406
+ />
33085
33407
  );
33086
33408
  }
33087
33409
  ```
33088
33410
 
33411
+ For a plain HTML `<form>`, call `form.reset()` after the submit.
33412
+
33089
33413
 
33090
33414
  ## Signatures
33091
33415
 
33092
33416
  ```ts
33093
- RouteConfig({ path, cache, children }: RouteConfigProps): ReactNode
33417
+ RouteCache({ maxCached = 10, children }: RouteCacheProps): ReactNode
33094
33418
  ```
33095
33419
 
33096
33420
  ## Parameters
33097
33421
 
33098
33422
  | Param | Type | Description |
33099
33423
  | --- | --- | --- |
33100
- | `props` | `RouteConfigProps` | |
33101
- | `.path` | `AbsolutePath \| undefined` | Path template the page owns, for example `/dave/{tab}`. Every path that matches it shows this same page. Read only. Optional. |
33102
- | `.cache` | `boolean \| undefined` | Set to `false` so `<RouteCache>` drops the page when you leave it, and the next visit shows a new page. Defaults to `true`. Read only. Optional. |
33103
- | `.children` | `ReactNode` | The page content. Read only. Optional. |
33424
+ | `props` | `RouteCacheProps` | |
33425
+ | `.maxCached` | `number \| undefined` | Number of pages to keep mounted (but hidden), so the whole state of each one (scroll position, toggles, searches, form input, focus) is still there when you come back to it. - The top page of each stack is never dropped, even past the limit, so a tab always shows the page you left. - Set to `0` (or less) to turn the cache off and unmount each page as you leave it. Read only. Defaults to `10`. |
33426
+ | `.children` | `ReactNode` | The content to render for the current page and keep alive (hidden) for the other pages in the stacks. Read only. |
33104
33427
 
33105
33428
  ## Returns
33106
33429
 
@@ -33109,50 +33432,6 @@ RouteConfig({ path, cache, children }: RouteConfigProps): ReactNode
33109
33432
  | `ReactNode` | |
33110
33433
 
33111
33434
 
33112
- ---
33113
-
33114
- # RouteState
33115
-
33116
- - Kind: interface
33117
- - Import: `import { RouteState } from "shelving/ui";`
33118
-
33119
- The route state of one page, shared by `<Router>`, `<RouteCache>` and `<RouteConfig>`.
33120
- - `path` is the template of the paths the page owns, set by `<RouteConfig path>`.
33121
- - `cache` is `false` when `<RouteCache>` drops the page as you leave it, set by `<RouteConfig cache>`.
33122
- - `entry` is the page's `<RouteCache>` entry, so `<RouteConfig>` in a top-level page also tells the cache.
33123
- - `router` marks a state made by `<Router>`, so a nested router does not pass the cache entry on.
33124
-
33125
- ## Signatures
33126
-
33127
- ```ts
33128
- {
33129
- path?: AbsolutePath | undefined;
33130
- cache?: boolean | undefined;
33131
- readonly entry?: RouteState | undefined;
33132
- readonly router?: true | undefined;
33133
- }
33134
- ```
33135
-
33136
- ## Properties
33137
-
33138
- | Property | Type | Description |
33139
- | --- | --- | --- |
33140
- | `path` | `AbsolutePath \| undefined` | Optional. |
33141
- | `cache` | `boolean \| undefined` | Optional. |
33142
- | `entry` | `RouteState \| undefined` | Read only. Optional. |
33143
- | `router` | `true \| undefined` | Read only. Optional. |
33144
-
33145
-
33146
- ---
33147
-
33148
- # RouteContext
33149
-
33150
- - Kind: constant
33151
- - Import: `import { RouteContext } from "shelving/ui";`
33152
-
33153
- React context holding the `RouteState` of the current page, provided by `<Router>` and `<RouteCache>`.
33154
-
33155
-
33156
33435
  ---
33157
33436
 
33158
33437
  # RouterProps
@@ -33192,7 +33471,8 @@ Match the current URL against `routes` and render the matched element.
33192
33471
  - When `base` is set, the effective path is the URL after stripping the base prefix.
33193
33472
  - Nest by putting another `<Router>` inside a route's value; pass `base="/section"` (or wrap in `<Meta>`) to scope.
33194
33473
  - Route `{placeholders}` are passed as props to function/component route values along with merged URL `?query` params. They are not published into context — descendants of a `ReactElement`-valued route can't see them automatically.
33195
- - Each path is a new page, so a component route remounts when the path changes. A page that owns other paths with `<RouteConfig path>` stays mounted when the path changes to one of them.
33474
+ - Inside `<Navigation>` with the Navigation API, each page in a stack is a new page: a link mounts a new page, and `NavigationStore.replace()` keeps the same page mounted (it re-renders with the new URL). A replace that renders another component still mounts it fresh.
33475
+ - Elsewhere, each path is a new page, so a component route remounts when the path changes.
33196
33476
  - Returns `null` when there's no URL in context or the URL is outside the base.
33197
33477
 
33198
33478
  A pure URL matcher: it reads the current URL from the surrounding `<Meta>` context, matches it against a `routes` table, and renders the matched element. It has no client requirements, so it works for SSR, static rendering, and tests with no `<Navigation>` at all — wrap it in `<Navigation>` on the client to get live URL updates.
@@ -33203,6 +33483,7 @@ A pure URL matcher: it reads the current URL from the surrounding `<Meta>` conte
33203
33483
  - `<Router>` accepts `PossibleMeta` props (`url`, `base`, etc.) to override the surrounding context — this is how nested routers scope themselves.
33204
33484
  - With a `base` set, the path used for matching is the URL after `matchURLPrefix()` strips the base prefix; URLs outside the base render as `null`.
33205
33485
  - Pass `fallback` to control no-match behaviour. An explicit `null` renders nothing; leaving it `undefined` throws a `NotFoundError`.
33486
+ - Inside `<Navigation>` with stacks, each page in a stack is a new page: a link mounts a new page, and `NavigationStore.replace()` keeps the same page mounted (it re-renders with the new URL). Elsewhere each path is a new page.
33206
33487
  - `<Router>` itself does not cache pages — wrap it in a `<RouteCache>` (or use a layout that already does) to keep recently-visited pages mounted but hidden so back/forward navigation restores their state.
33207
33488
 
33208
33489
  ## Usage
@@ -33317,7 +33598,7 @@ const SIDEBARRED_ROUTES = {
33317
33598
 
33318
33599
  ### Keeping page state
33319
33600
 
33320
- By default a page is unmounted when you navigate away and mounted fresh when you return — so scroll position, open/closed toggles, in-progress searches, form inputs, and focus are all lost, and you land back at the top. Wrap the router (or its scrolling content region) in a `<RouteCache>` to keep recently-visited pages mounted but hidden so their state is restored on back/forward navigation. Shelving's `<SidebarLayout>` and `<CenteredLayout>` already do this for you.
33601
+ By default a page is unmounted when you navigate away and mounted fresh when you return — so scroll position, open/closed toggles, in-progress searches, form inputs, and focus are all lost, and you land back at the top. Wrap the router (or its scrolling content region) in a `<RouteCache>` to keep recently-visited pages mounted but hidden so their state is still there when you go back to them, or switch back to their tab. Shelving's `<SidebarLayout>` and `<CenteredLayout>` already do this for you.
33321
33602
 
33322
33603
  ### SSR / static rendering
33323
33604
 
@@ -33459,6 +33740,99 @@ Route table mapping `{ path: RouteComponent | redirectPath | ReactElement }` for
33459
33740
  - [Route](ui/Route.md): Valid route values:
33460
33741
 
33461
33742
 
33743
+ ---
33744
+
33745
+ # StackButtonProps
33746
+
33747
+ - Kind: interface
33748
+ - Import: `import { StackButtonProps } from "shelving/ui";`
33749
+ - Extends: `Omit<ButtonProps, "href" | "onClick" | "selected">`
33750
+
33751
+ Props for `<StackButton>`: the `stack` it opens, plus the usual `Button` props except `href` and `onClick`.
33752
+
33753
+ ## Signatures
33754
+
33755
+ ```ts
33756
+ {
33757
+ readonly stack: AbsolutePath;
33758
+ }
33759
+ ```
33760
+
33761
+ ## Properties
33762
+
33763
+ | Property | Type | Description |
33764
+ | --- | --- | --- |
33765
+ | `stack` | `AbsolutePath` | Root path of the stack this button opens. It must be one of the `stacks` on `<Navigation>`. Read only. |
33766
+
33767
+
33768
+ ---
33769
+
33770
+ # StackButton
33771
+
33772
+ - Kind: component
33773
+ - Import: `import { StackButton } from "shelving/ui";`
33774
+
33775
+ Button for one stack in a tab bar.
33776
+ - Tap another stack's button: go to the page you left in that stack. The page slides left or right by tab order.
33777
+ - Tap the current stack's button: go back to its root.
33778
+ - Tap it again at the root: scroll the page to the top.
33779
+ - It is selected while its stack is the current stack.
33780
+ - Without the browser Navigation API (and in a server render) it is a plain link to the stack's root.
33781
+
33782
+ A button for one stack in a tab bar. It acts like a tab button in a phone app.
33783
+
33784
+ **Things to know:**
33785
+
33786
+ - Tap another stack's button: go to the page you left in that stack. The page slides left or right, by tab order.
33787
+ - Tap the current stack's button: go back to the root of the stack. The page slides back.
33788
+ - Tap it again at the root: scroll the page to the top. It scrolls the window, and each visible `<main>` or `[data-scroll]` element.
33789
+ - It is selected (`aria-current`) while its stack is the current stack. On an unstacked page (for example a deep link or a login page), no stack button is selected.
33790
+ - `stack` must be one of the `stacks` on `<Navigation>`.
33791
+ - It takes the usual `<Button>` props, except `href`, `onClick` and `selected`.
33792
+ - Without the browser Navigation API, and in a server render, it is a plain link to the stack's root. It is selected while its stack is the starting stack.
33793
+ - In a server-rendered app, the server renders a link and the browser renders a button, so React warns about a hydration mismatch on the first render. A client-only app (with `<App>`) has no mismatch.
33794
+
33795
+ ## Usage
33796
+
33797
+ ```tsx
33798
+ import { Navigation, StackButton } from "shelving/ui";
33799
+ import { HomeIcon, SearchIcon, UserIcon } from "./icons.js";
33800
+
33801
+ <Navigation stacks={["/home", "/discover", "/profile"]}>
33802
+ {/* … */}
33803
+ <nav className="tab-bar">
33804
+ <StackButton stack="/home" title="Home"><HomeIcon/></StackButton>
33805
+ <StackButton stack="/discover" title="Discover"><SearchIcon/></StackButton>
33806
+ <StackButton stack="/profile" title="Profile"><UserIcon/></StackButton>
33807
+ </nav>
33808
+ </Navigation>
33809
+ ```
33810
+
33811
+ ## Styling
33812
+
33813
+ `<StackButton>` renders a `<Button>`, so it has the same styling hooks. See `<Button>`.
33814
+
33815
+
33816
+ ## Signatures
33817
+
33818
+ ```ts
33819
+ StackButton({ stack, ...props }: StackButtonProps): ReactElement
33820
+ ```
33821
+
33822
+ ## Parameters
33823
+
33824
+ | Param | Type | Description |
33825
+ | --- | --- | --- |
33826
+ | `props` | `StackButtonProps` | |
33827
+ | `.stack` | `AbsolutePath` | Root path of the stack this button opens. It must be one of the `stacks` on `<Navigation>`. Read only. |
33828
+
33829
+ ## Returns
33830
+
33831
+ | Type | Description |
33832
+ | --- | --- |
33833
+ | `ReactElement` | |
33834
+
33835
+
33462
33836
  ---
33463
33837
 
33464
33838
  # BlockVariants
@@ -35529,6 +35903,19 @@ CollapseTransition(props: CollapseTransitionProps): ReactElement
35529
35903
  | `ReactElement` | |
35530
35904
 
35531
35905
 
35906
+ ---
35907
+
35908
+ # FADE_TRANSITION_CLASS
35909
+
35910
+ - Kind: constant
35911
+ - Import: `import { FADE_TRANSITION_CLASS } from "shelving/ui";`
35912
+
35913
+ View transition class that fades content in and out.
35914
+
35915
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
35916
+ - Also adds the plain global `fade` class, so app CSS can target it with `::view-transition-group(.fade)`.
35917
+
35918
+
35532
35919
  ---
35533
35920
 
35534
35921
  # FadeTransitionProps
@@ -35577,6 +35964,19 @@ function Panel({ visible }: { visible: boolean }) {
35577
35964
  }
35578
35965
  ```
35579
35966
 
35967
+ ## Use the class without the component
35968
+
35969
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `FADE_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
35970
+
35971
+ ```tsx
35972
+ import { ViewTransition } from "react";
35973
+ import { FADE_TRANSITION_CLASS } from "shelving/ui";
35974
+
35975
+ <ViewTransition enter={FADE_TRANSITION_CLASS} exit={FADE_TRANSITION_CLASS}>
35976
+ <div className="panel">…</div>
35977
+ </ViewTransition>
35978
+ ```
35979
+
35580
35980
  ## Styling
35581
35981
 
35582
35982
  | Variable | Styles | Default |
@@ -35605,6 +36005,32 @@ FadeTransition(props: FadeTransitionProps): ReactElement
35605
36005
  | `ReactElement` | |
35606
36006
 
35607
36007
 
36008
+ ---
36009
+
36010
+ # SLIDE_RIGHT_TRANSITION_CLASS
36011
+
36012
+ - Kind: constant
36013
+ - Import: `import { SLIDE_RIGHT_TRANSITION_CLASS } from "shelving/ui";`
36014
+
36015
+ View transition class that slides content right: the new content comes in from the right and the old content leaves to the left.
36016
+
36017
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
36018
+ - Also adds the plain global `slide-right` class, so app CSS can target it with `::view-transition-group(.slide-right)`.
36019
+
36020
+
36021
+ ---
36022
+
36023
+ # SLIDE_LEFT_TRANSITION_CLASS
36024
+
36025
+ - Kind: constant
36026
+ - Import: `import { SLIDE_LEFT_TRANSITION_CLASS } from "shelving/ui";`
36027
+
36028
+ View transition class that slides content left: the new content comes in from the left and the old content leaves to the right.
36029
+
36030
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
36031
+ - Also adds the plain global `slide-left` class, so app CSS can target it with `::view-transition-group(.slide-left)`.
36032
+
36033
+
35608
36034
  ---
35609
36035
 
35610
36036
  # HorizontalTransitionProps
@@ -35636,16 +36062,19 @@ A direction-aware `<Transition>` preset that slides its children horizontally
35636
36062
  **Things to know:**
35637
36063
 
35638
36064
  - Slides right by default and when the type is `"forward"`; slides left when the type is `"back"`.
35639
- - Inside `<Navigation>` the direction is automatic: a link click, `NavigationStore.forward()` or `NavigationStore.redirect()` sets the `"forward"` type, and the browser back or forward button sets `"back"`. Outside `<Navigation>`, set the direction with `setTransitionType("forward" | "back")` inside a `startTransition()` callback — see `<Transition>`.
36065
+ - Inside `<Navigation>` the direction is automatic: a link click or `NavigationStore.forward()` sets the `"forward"` type, and a `className="back"` link or `NavigationStore.back()` sets `"back"`. The browser back and forward buttons set the type from the page's place in its stack. `NavigationStore.replace()` has no transition. Outside `<Navigation>`, set the direction with `setTransitionType("forward" | "back")` inside a `startTransition()` callback — see `<Transition>`.
35640
36066
  - Pass `overlay` to raise the transition group above surrounding content during the animation (`z-index: 100`).
35641
36067
  - The old and new content slide a full width apart, so they sit edge to edge and never overlap.
35642
36068
  - The slide is clipped to the element's own box (`overflow: clip` on the group), so it does not paint over the content around it.
35643
- - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and put the slide groups below it:
36069
+ - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and raise its group:
35644
36070
 
35645
36071
  ```css
35646
- ::view-transition-group(.slide-right),
35647
- ::view-transition-group(.slide-left) {
35648
- z-index: -1;
36072
+ .bottom-bar {
36073
+ view-transition-name: bottom-bar;
36074
+ }
36075
+
36076
+ ::view-transition-group(bottom-bar) {
36077
+ z-index: 1;
35649
36078
  }
35650
36079
  ```
35651
36080
 
@@ -35664,6 +36093,19 @@ import { HorizontalTransition, Navigation, Router } from "shelving/ui";
35664
36093
  </Navigation>
35665
36094
  ```
35666
36095
 
36096
+ ## Use the class without the component
36097
+
36098
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `SLIDE_RIGHT_TRANSITION_CLASS` and `SLIDE_LEFT_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
36099
+
36100
+ ```tsx
36101
+ import { ViewTransition } from "react";
36102
+ import { SLIDE_RIGHT_TRANSITION_CLASS } from "shelving/ui";
36103
+
36104
+ <ViewTransition enter={SLIDE_RIGHT_TRANSITION_CLASS} exit={SLIDE_RIGHT_TRANSITION_CLASS}>
36105
+ <div className="panel">…</div>
36106
+ </ViewTransition>
36107
+ ```
36108
+
35667
36109
  ## Styling
35668
36110
 
35669
36111
  | Variable | Styles | Default |
@@ -35973,6 +36415,32 @@ setTransitionType("forward")
35973
36415
  ```
35974
36416
 
35975
36417
 
36418
+ ---
36419
+
36420
+ # SLIDE_DOWN_TRANSITION_CLASS
36421
+
36422
+ - Kind: constant
36423
+ - Import: `import { SLIDE_DOWN_TRANSITION_CLASS } from "shelving/ui";`
36424
+
36425
+ View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
36426
+
36427
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
36428
+ - Also adds the plain global `slide-down` class, so app CSS can target it with `::view-transition-group(.slide-down)`.
36429
+
36430
+
36431
+ ---
36432
+
36433
+ # SLIDE_UP_TRANSITION_CLASS
36434
+
36435
+ - Kind: constant
36436
+ - Import: `import { SLIDE_UP_TRANSITION_CLASS } from "shelving/ui";`
36437
+
36438
+ View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
36439
+
36440
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
36441
+ - Also adds the plain global `slide-up` class, so app CSS can target it with `::view-transition-group(.slide-up)`.
36442
+
36443
+
35976
36444
  ---
35977
36445
 
35978
36446
  # VerticalTransitionProps
@@ -36004,16 +36472,19 @@ A direction-aware `<Transition>` preset that slides its children vertically —
36004
36472
  **Things to know:**
36005
36473
 
36006
36474
  - Slides down by default and when the type is `"forward"`; slides up when the type is `"back"`.
36007
- - Inside `<Navigation>` the direction is automatic: a link click, `NavigationStore.forward()` or `NavigationStore.redirect()` sets the `"forward"` type, and the browser back or forward button sets `"back"`. Outside `<Navigation>`, set the direction with `setTransitionType("forward" | "back")` inside a `startTransition()` callback — see `<Transition>`.
36475
+ - Inside `<Navigation>` the direction is automatic: a link click or `NavigationStore.forward()` sets the `"forward"` type, and a `className="back"` link or `NavigationStore.back()` sets `"back"`. The browser back and forward buttons set the type from the page's place in its stack. `NavigationStore.replace()` has no transition. Outside `<Navigation>`, set the direction with `setTransitionType("forward" | "back")` inside a `startTransition()` callback — see `<Transition>`.
36008
36476
  - Pass `overlay` to raise the transition group above surrounding content during the animation (`z-index: 100`).
36009
36477
  - The old and new content slide a full height apart, so they sit edge to edge and never overlap.
36010
36478
  - The slide is clipped to the element's own box (`overflow: clip` on the group), so it does not paint over the content around it.
36011
- - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and put the slide groups below it:
36479
+ - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and raise its group:
36012
36480
 
36013
36481
  ```css
36014
- ::view-transition-group(.slide-up),
36015
- ::view-transition-group(.slide-down) {
36016
- z-index: -1;
36482
+ .bottom-bar {
36483
+ view-transition-name: bottom-bar;
36484
+ }
36485
+
36486
+ ::view-transition-group(bottom-bar) {
36487
+ z-index: 1;
36017
36488
  }
36018
36489
  ```
36019
36490
 
@@ -36029,6 +36500,19 @@ import { VerticalTransition } from "shelving/ui";
36029
36500
  </VerticalTransition>
36030
36501
  ```
36031
36502
 
36503
+ ## Use the class without the component
36504
+
36505
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `SLIDE_DOWN_TRANSITION_CLASS` and `SLIDE_UP_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
36506
+
36507
+ ```tsx
36508
+ import { ViewTransition } from "react";
36509
+ import { SLIDE_DOWN_TRANSITION_CLASS } from "shelving/ui";
36510
+
36511
+ <ViewTransition enter={SLIDE_DOWN_TRANSITION_CLASS} exit={SLIDE_DOWN_TRANSITION_CLASS}>
36512
+ <div className="panel">…</div>
36513
+ </ViewTransition>
36514
+ ```
36515
+
36032
36516
  ## Styling
36033
36517
 
36034
36518
  | Variable | Styles | Default |
@@ -37538,6 +38022,7 @@ Combined meta data for a website page — title, URLs, description, CSP, tags, l
37538
38022
  {
37539
38023
  readonly root?: ImmutableURL | undefined;
37540
38024
  readonly url?: ImmutableURL | undefined;
38025
+ readonly stack?: AbsolutePath | undefined;
37541
38026
  readonly app?: string | undefined;
37542
38027
  readonly title?: string | undefined;
37543
38028
  readonly description?: string | undefined;
@@ -37557,7 +38042,8 @@ Combined meta data for a website page — title, URLs, description, CSP, tags, l
37557
38042
  | Property | Type | Description |
37558
38043
  | --- | --- | --- |
37559
38044
  | `root` | `ImmutableURL \| undefined` | Base URL for the app (used to resolve `url` and set as `<base>` tag in `<Head>`). Read only. Optional. |
37560
- | `url` | `ImmutableURL \| undefined` | URL of the current page (used to update history API and as the initial URL for routing). Read only. Optional. |
38045
+ | `url` | `ImmutableURL \| undefined` | URL of the current page (used as the initial URL for routing, and as the page's canonical URL in `<Head>`). Read only. Optional. |
38046
+ | `stack` | `AbsolutePath \| undefined` | Root path of the current stack (for example `"/home"`). Set it above `<Navigation>` to choose the stack the app opens in. `<Navigation>` publishes the live stack, which is `"/"` for an unstacked page. Read only. Optional. |
37561
38047
  | `app` | `string \| undefined` | Title of the entire application. Read only. Optional. |
37562
38048
  | `title` | `string \| undefined` | Title of the current page (set as `<title>` in `<Head>` Read only. Optional. |
37563
38049
  | `description` | `string \| undefined` | Description of the current page. Read only. Optional. |
@@ -37702,7 +38188,8 @@ mergeMeta(meta1: Meta, meta2: PossibleMeta, caller: AnyCaller = mergeMeta): Meta
37702
38188
  | --- | --- | --- |
37703
38189
  | `meta1` | `Meta` | The existing fully-resolved `Meta` to merge into. |
37704
38190
  | `.root` | `ImmutableURL \| undefined` | Base URL for the app (used to resolve `url` and set as `<base>` tag in `<Head>`). Read only. Optional. |
37705
- | `.url` | `ImmutableURL \| undefined` | URL of the current page (used to update history API and as the initial URL for routing). Read only. Optional. |
38191
+ | `.url` | `ImmutableURL \| undefined` | URL of the current page (used as the initial URL for routing, and as the page's canonical URL in `<Head>`). Read only. Optional. |
38192
+ | `.stack` | `AbsolutePath \| undefined` | Root path of the current stack (for example `"/home"`). Set it above `<Navigation>` to choose the stack the app opens in. `<Navigation>` publishes the live stack, which is `"/"` for an unstacked page. Read only. Optional. |
37706
38193
  | `.app` | `string \| undefined` | Title of the entire application. Read only. Optional. |
37707
38194
  | `.title` | `string \| undefined` | Title of the current page (set as `<title>` in `<Head>` Read only. Optional. |
37708
38195
  | `.description` | `string \| undefined` | Description of the current page. Read only. Optional. |