@uvalib/web-components 1.9.0 → 1.11.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 (57) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +277 -18
  3. package/bin/install-skill.mjs +174 -54
  4. package/dist/base.css +121 -2
  5. package/dist/components/uvalib-contents/UvalibContents.d.ts +66 -2
  6. package/dist/components/uvalib-contents/UvalibContents.js +277 -29
  7. package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
  8. package/dist/components/uvalib-list-filter/UvalibListFilter.d.ts +162 -0
  9. package/dist/components/uvalib-list-filter/UvalibListFilter.js +685 -0
  10. package/dist/components/uvalib-list-filter/UvalibListFilter.js.map +1 -0
  11. package/dist/components/uvalib-list-filter/uvalib-list-filter.d.ts +1 -0
  12. package/dist/components/uvalib-list-filter/uvalib-list-filter.js +4 -0
  13. package/dist/components/uvalib-list-filter/uvalib-list-filter.js.map +1 -0
  14. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +54 -1
  15. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +230 -3
  16. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  17. package/dist/custom-elements.json +7757 -6209
  18. package/dist/edition.css +758 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +1 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/pagefind.css +144 -0
  23. package/dist/styles/base.js +78 -1
  24. package/dist/styles/base.js.map +1 -1
  25. package/dist/styles/controls.js +2 -0
  26. package/dist/styles/controls.js.map +1 -1
  27. package/dist/styles/edition.d.ts +1 -0
  28. package/dist/styles/edition.js +747 -0
  29. package/dist/styles/edition.js.map +1 -0
  30. package/dist/styles/hidden.js +2 -0
  31. package/dist/styles/hidden.js.map +1 -1
  32. package/dist/styles/layout.d.ts +1 -0
  33. package/dist/styles/layout.js +92 -0
  34. package/dist/styles/layout.js.map +1 -0
  35. package/dist/styles/pagefind.js +150 -0
  36. package/dist/styles/pagefind.js.map +1 -1
  37. package/dist-cdn/base.css +121 -2
  38. package/dist-cdn/chunks/{base-CHMHBPeI.js → base-DmImIMld.js} +79 -2
  39. package/dist-cdn/chunks/base-DmImIMld.js.map +1 -0
  40. package/dist-cdn/custom-elements.json +7757 -6209
  41. package/dist-cdn/edition.css +758 -0
  42. package/dist-cdn/manifest.json +5 -3
  43. package/dist-cdn/pagefind.css +144 -0
  44. package/dist-cdn/site-page.js +1 -1
  45. package/dist-cdn/site-style.js +1 -1
  46. package/dist-cdn/skills/uvalib-web-components/SKILL.md +29 -8
  47. package/dist-cdn/skills/uvalib-web-components/reference/components.md +65 -4
  48. package/dist-cdn/uvalib-contents.js +185 -47
  49. package/dist-cdn/uvalib-contents.js.map +1 -1
  50. package/dist-cdn/uvalib-list-filter.js +451 -0
  51. package/dist-cdn/uvalib-list-filter.js.map +1 -0
  52. package/dist-cdn/uvalib-pagefind-search.js +149 -49
  53. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  54. package/package.json +6 -1
  55. package/skills/uvalib-web-components/SKILL.md +29 -8
  56. package/skills/uvalib-web-components/reference/components.md +65 -4
  57. package/dist-cdn/chunks/base-CHMHBPeI.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.11.0 — 2026-11-25
4
+
5
+ ### Features
6
+
7
+ - hold the page still while a search from the URL loads (issue #37)
8
+ - full-contents link, partial-list line and window for long contents
9
+
10
+ ### Other
11
+
12
+ - Merge branch 'integrate/xtf': Pagefind searching hold (issue #37), contents window and full-contents link (issue #38)
13
+ - Merge branch 'feat/contents-window' into integrate/xtf
14
+ - Merge branch 'feat/pagefind-hold' into integrate/xtf
15
+
16
+ ## v1.10.0 — 2026-11-25
17
+
18
+ ### Features
19
+
20
+ - install per project or globally, for Claude Code and the shared Agent Skills folder
21
+ - edition.css, reading styles for converted TEI texts
22
+ - .uvalib-sidebar-layout, a sidebar beside the main content
23
+ - <uvalib-list-filter>, filter a long static list on the page as you type
24
+ - filter-params reads and writes Pagefind filters in the URL
25
+
26
+ ### Fixes
27
+
28
+ - the same words in any order are one query for analytics; literal event name for the manifest
29
+ - hold <uvalib-contents>'s upgraded layout before it is defined
30
+
31
+ ### Other
32
+
33
+ - Merge branch 'integrate/etc': edition.css, uvalib-list-filter, Pagefind filter-params, sidebar layout
34
+ - Merge branch 'feat/edition-css' into integrate/etc
35
+ - demo preset and tests for edition.css
36
+ - keep both the list-filter and sidebar-layout blocks after the merge
37
+ - Merge branch 'feat/sidebar-layout' into integrate/etc
38
+ - Merge branch 'feat/list-filter' into integrate/etc
39
+ - Merge branch 'feat/pagefind-filter-params' into integrate/etc
40
+ - register uvalib-list-filter (vite, manifest, exports, index, size budget, base.css pre-upgrade hold, catalogue tests)
41
+
3
42
  ## v1.9.0 — 2026-11-24
4
43
 
5
44
  ### Features
package/README.md CHANGED
@@ -12,7 +12,8 @@ Reusable web components for UVA Library sites, built with Lit and TypeScript:
12
12
  - **Records:** `<uvalib-metadata>` (a record's details, credit, rights and how to cite) and `<uvalib-citation>` (a citation in several formats, with Copy citation).
13
13
  - **Images:** `<uvalib-lightbox>` (an image viewer over plain links), `<uvalib-photo-grid>` (justified rows of thumbnails) and `<uvalib-image-regions>` (numbered region outlines on an image, with their list).
14
14
  - **Maps:** `<uvalib-map>` (places on the page's own Leaflet map, sized by a count, with a linked list).
15
- - **Search:** `<uvalib-filter>`, `<uvalib-date-range>`, `<uvalib-date-histogram>`, `<uvalib-combobox>` (a text field that suggests values as you type), `<uvalib-filter-drawer>` (the filters as a sidebar, or a modal panel on phones), `<uvalib-dialog>` (a modal dialog for search tips, Cite or a short form) and `<uvalib-pagefind-search>` (with `pagefind.css`, the library theme for Pagefind static-site search).
15
+ - **Search:** `<uvalib-filter>`, `<uvalib-date-range>`, `<uvalib-date-histogram>`, `<uvalib-combobox>` (a text field that suggests values as you type), `<uvalib-list-filter>` (a field that filters a long list on the page as you type), `<uvalib-filter-drawer>` (the filters as a sidebar, or a modal panel on phones), `<uvalib-dialog>` (a modal dialog for search tips, Cite or a short form) and `<uvalib-pagefind-search>` (with `pagefind.css`, the library theme for Pagefind static-site search).
16
+ - **Reading texts:** `edition.css` (reading styles for TEI texts converted to class-annotated HTML).
16
17
  - **Library hours:** `<site-hours-section>`, `<library-weekly-hours>` and `<library-hours-setup>`.
17
18
  - **Library events:** `<events-section>`.
18
19
  - **Search results:** `<bento-box>` (library.virginia.edu/search), with its `<catalog-section>`, `<articles-section>`, `<libguides-section>` and `<website-section>`.
@@ -21,12 +22,15 @@ Reusable web components for UVA Library sites, built with Lit and TypeScript:
21
22
 
22
23
  ## Quick start with a coding agent
23
24
 
24
- The fastest route: install the agent skill, then ask your coding agent (Claude Code and others) to do the work. The skill teaches it which entry to load, how to pin versions, shadow vs light DOM, theming, alerts and hours, and how to check the result.
25
+ The fastest route: install the agent skill, then ask your coding agent (Claude Code, Codex, Gemini CLI, GitHub Copilot, Cursor, Grok and others) to do the work. The skill teaches it which entry to load, how to pin versions, shadow vs light DOM, theming, alerts and hours, and how to check the result.
25
26
 
26
27
  ```sh
27
- npx @uvalib/web-components install-skill # copies the skill to .claude/skills/uvalib-web-components
28
+ npx @uvalib/web-components install-skill # this project, for every agent
29
+ npx @uvalib/web-components install-skill --global # your home folder, for every project
28
30
  ```
29
31
 
32
+ It is an [Agent Skills](https://agentskills.io) folder (`SKILL.md` and its references), the open format most coding agents read. By default it goes into `.claude/skills/` (Claude Code) and `.agents/skills/` (the shared folder that Codex, Gemini CLI, GitHub Copilot, Cursor, Grok and other tools read); `--global` uses `~/.claude/skills/` and `~/.agents/skills/` instead. See [Installing the skill](#installing-the-skill) for one agent's own folder.
33
+
30
34
  Then ask, for example:
31
35
 
32
36
  > Wrap this site's pages in the UVA Library `<site-page>` from the v1 CDN, with our own nav links in the header.
@@ -75,19 +79,42 @@ Name the skill so the agent loads it, say what to keep, and ask it to audit befo
75
79
 
76
80
  > Update the uvalib-web-components skill in this project to the latest release, then check whether anything we use changed and needs updating.
77
81
 
78
- - `npx` fetches the package on the fly, so this works in any repository, including sites that only use script tags (it needs Node, not an npm dependency).
79
- - Other agents or folders: `npx @uvalib/web-components install-skill --dir .agents/skills`. Add `--force` to update an existing copy.
80
- - Or copy `node_modules/@uvalib/web-components/skills/uvalib-web-components` into your skills folder. The skill is also on the CDN at `https://unpkg.internal.lib.virginia.edu/web-components/v1/skills/uvalib-web-components/SKILL.md`. More in [docs/usage.md](docs/usage.md#agent-skill).
82
+ ### Installing the skill
83
+
84
+ `npx` fetches the package on the fly, so this works in any repository, including sites that only use script tags (it needs Node, not an npm dependency).
85
+
86
+ | Command | Installs to |
87
+ | -------------------------------------- | ------------------------------------------------------------------------------- |
88
+ | `install-skill` | `.claude/skills/` and `.agents/skills/` in this project |
89
+ | `install-skill --global` | `~/.claude/skills/` and `~/.agents/skills/`, for every project on this computer |
90
+ | `install-skill --agent gemini,copilot` | each named agent's own folder (add `--global` for the home folder) |
91
+ | `install-skill --agent all` | every folder below |
92
+ | `install-skill --dir <folder>` | one folder of your choosing |
93
+ | `install-skill --list …` | prints the folders it would use, and changes nothing |
94
+
95
+ | `--agent` | Project folder | Global folder | Read by |
96
+ | --------- | ---------------- | ------------------- | ------------------------------------------------------------------------------------------ |
97
+ | `agents` | `.agents/skills` | `~/.agents/skills` | the shared Agent Skills folder: Codex, Gemini CLI, GitHub Copilot, Cursor, Grok and others |
98
+ | `claude` | `.claude/skills` | `~/.claude/skills` | Claude Code (also read by Copilot, Cursor and Grok) |
99
+ | `codex` | `.agents/skills` | `~/.agents/skills` | OpenAI Codex |
100
+ | `gemini` | `.gemini/skills` | `~/.gemini/skills` | Gemini CLI |
101
+ | `copilot` | `.github/skills` | `~/.copilot/skills` | GitHub Copilot (cloud agent, CLI, VS Code and other IDEs) |
102
+ | `cursor` | `.cursor/skills` | `~/.cursor/skills` | Cursor |
103
+ | `grok` | `.agents/skills` | `~/.grok/skills` | Grok |
104
+
105
+ The default (`claude` and `agents`) covers all of these. A tool that reads more than one of the folders (Copilot, Cursor and Grok read both `.claude/skills` and `.agents/skills`) may list the skill twice; the copies are identical, so it does no harm, or install for one folder with `--agent`. Agents check their folders when a session starts, so start a new session after installing. Add `--force` to replace an existing copy.
106
+
107
+ Without the installer: copy `node_modules/@uvalib/web-components/skills/uvalib-web-components` into a skills folder, or point a chat assistant without skills at `https://unpkg.internal.lib.virginia.edu/web-components/v1/skills/uvalib-web-components/SKILL.md`. More in [docs/usage.md](docs/usage.md#agent-skill).
81
108
 
82
109
  ### Keeping the skill current
83
110
 
84
- Each install is a copy stamped with its package version (`installed.json` next to `SKILL.md`), so it does not change as this library does. Update it after a release:
111
+ Each install is a copy stamped with its package version (`installed.json` next to `SKILL.md`), so it does not change as this library does. Update it after a release with the same options you installed with, plus `--force`:
85
112
 
86
113
  ```sh
87
- npx @uvalib/web-components@latest install-skill --dir .claude/skills --force
114
+ npx @uvalib/web-components@latest install-skill --force # or: --global --force
88
115
  ```
89
116
 
90
- `--check` compares an installed copy with the latest release on npm. It prints one line with that update command only when the copy is missing or out of date, is silent when it is current, and never fails offline (`--strict` exits 1 when it is out of date, for CI). To be told automatically, add it as a Claude Code SessionStart hook, in the project's `.claude/settings.json` (or `~/.claude/settings.json` with `--dir ~/.claude/skills` for a user-level copy):
117
+ `--check` compares the installed copies with the latest release on npm. It prints one line per copy, with that update command, only when a copy is missing or out of date, is silent when they are current, and never fails offline (`--strict` exits 1 when one is out of date, for CI). To be told automatically, run it when your agent starts a session; for Claude Code, a SessionStart hook in the project's `.claude/settings.json` (or `~/.claude/settings.json` with `--global` for the copies in your home folder):
91
118
 
92
119
  ```json
93
120
  {
@@ -97,7 +124,7 @@ npx @uvalib/web-components@latest install-skill --dir .claude/skills --force
97
124
  "hooks": [
98
125
  {
99
126
  "type": "command",
100
- "command": "npx --yes @uvalib/web-components@latest install-skill --check --dir .claude/skills"
127
+ "command": "npx --yes @uvalib/web-components@latest install-skill --check"
101
128
  }
102
129
  ]
103
130
  }
@@ -106,7 +133,7 @@ npx @uvalib/web-components@latest install-skill --dir .claude/skills --force
106
133
  }
107
134
  ```
108
135
 
109
- Projects that commit `.claude/skills/` get each update as an ordinary reviewed change.
136
+ Agents with their own session-start hooks can run the same command; otherwise run it with `--strict` in CI. Projects that commit `.claude/skills/` and `.agents/skills/` get each update as an ordinary reviewed change.
110
137
 
111
138
  To do it by hand, read on.
112
139
 
@@ -523,8 +550,25 @@ Two components for Library sites with records and long texts, such as the Electr
523
550
  - **From the page's headings.** For a long document (minutes, transcriptions, reports, finding aids), `headings-from="#article"` builds the list from the headings in that element: `levels` (`2-3` by default, or one level such as `2`) picks which, each lower level nested under the heading before it, and `min` (default 2) is the fewest top-level entries worth a list (fewer shows nothing). Headings with no text or hidden with `aria-hidden` (and text inside `aria-hidden`, such as a `#` permalink) are skipped. A heading without an id gets one from its text (lowercase ASCII, accents dropped, anything else as `-`: "Résumé of the budget" is `resume-of-the-budget`, a repeat `-2`, `-3`); existing ids are kept, so links to sections keep working, and opening the page at such a section goes to it. Headings added, removed or retitled are followed; call `refresh()` after other changes. A child list or `items` wins while given. Without JavaScript there is no list: where the list can be rendered at build time, give it as children instead.
524
551
  - **Current entry.** `aria-current="page"` on the link to this page and `aria-current="location"` on the link to the section in the URL's hash, drawn bold with a bar. It is found from the page URL (path, ignoring a trailing slash or `index.html`, and hash; an entry whose href has a query string, such as `?part=2`, matches only that query, one without matches whatever the query), followed through `hashchange`, `popstate` and the Navigation API, or from `current` (a URL, for apps whose route is not the page URL; hash-only entries are then places on that URL). With `current` unset, a valid `aria-current` the author put on a source link (`page`, `location`, or `true` for a page) is used, at most one of each.
525
552
  - **Narrow screens.** At and below `collapse-below` (a viewport width, default `64rem`; `0` never collapses) the headline becomes a full-width 44px button with `aria-expanded` and `aria-controls`, and the list starts closed until the reader opens it (as the Electronic Text Collections' Contents does on phones, so the text comes first; the `open` attribute starts it open), and opening it shows the current entry. It measures the viewport, not the element (no container query) on purpose: a contents sidebar is always much narrower than 64rem, so its own width cannot tell a phone from a desktop.
526
- - **Sidebars.** `sticky` keeps it in view on wide screens (`--uvalib-contents-sticky-top`, default 1rem); the list then scrolls within the window's height (`--uvalib-contents-max-height`) and the current entry is scrolled into view inside it, never the page.
527
- - **Single-page apps.** The list is drawn from copies of the children. A plain click on an entry fires `uvalib-contents-navigate` (`detail: { href, level }`, bubbling, cancelable): cancel it to route in place. Hash links need nothing.
553
+ - **Sidebars.** `sticky` keeps it in view on wide screens (`--uvalib-contents-sticky-top`, default 1rem); the list then scrolls within the window's height (`--uvalib-contents-max-height`) and the current entry is scrolled into view inside it, never the page. In a [`.uvalib-sidebar-layout`](#sidebar-layout), use the layout's `--sticky` or this, not both.
554
+ - **Very long contents (issue #38).** A text with hundreds of sections, each its own page, should not write the whole list into every page. Write only the entries near the current one (with their parents, so the nesting makes sense) and set `full-href` to the full contents: a "Full contents (243 sections)" link is drawn after the list, inside the landmark but not as an entry (bold and underlined with an arrow, as library.virginia.edu's "See all" links; 44px tall, the focus ring, `LinkText` in forced colors; outside the scrolling list, so it shows with `sticky`; inside the disclosure on narrow screens). `full-label` is its text ("Full contents"), `total` the number of entries in the full contents, shown as "(243 sections)" (`noun`, default "sections"; `singular` for one, as `<uvalib-results-count>`). A visually hidden line before the list tells screen readers it is partial ("Showing 25 of 243 sections."); the headline and the landmark's name stay the visible "Contents". `base.css` holds the link's line before the script runs. Where the whole list is in the page (or comes from `items` or `headings-from`), `window="12"` shows only the current entry and the 12 before and after it in document order (25 entries, shifted at either end), with their parents; the others are hidden, not removed, an ellipsis (hidden from assistive technology) marks each gap, and the window follows the current entry. With `full-href` the link follows it; without, a "Show all 243 sections" button (`aria-expanded`) shows the rest in place and "Show fewer" hides it again. The whole list shows until the script runs (base.css cannot hold a window), so prefer the build-time window for very long lists. Without JavaScript there is no link: the list shows alone. Analytics: `full-contents-click`, `show-all`, `show-fewer`, never the label or URL.
555
+
556
+ ```html
557
+ <uvalib-contents class="uvalib-sidebar-layout__sidebar" full-href="/text/eaf375v1/" total="243">
558
+ <ol>
559
+ <li>
560
+ <a href="/text/eaf375v1/d8/">The actress of Padua</a>
561
+ <ol>
562
+ <li><a href="/text/eaf375v1/d40/">Chapter XXXI</a></li>
563
+ <li><a href="/text/eaf375v1/d41/">Chapter XXXII</a></li>
564
+ <!-- … the entries near the current one … -->
565
+ </ol>
566
+ </li>
567
+ </ol>
568
+ </uvalib-contents>
569
+ ```
570
+
571
+ - **Single-page apps.** The list is drawn from copies of the children. A plain click on an entry fires `uvalib-contents-navigate` (`detail: { href, level }`, bubbling, cancelable; level 0 for the full-contents link): cancel it to route in place. Hash links need nothing.
528
572
 
529
573
  `<uvalib-metadata>`, a record's description list:
530
574
 
@@ -1139,6 +1183,89 @@ Data tables in the page's own content (holdings, schedules, statistics) in the l
1139
1183
  - **Grouped tables** (holdings by library, items by location): a heading per group followed by its table, each table with its own caption. The heading level follows the page's outline (Virgo's record design uses `<h5>` for locations because of where they sit; on your page it may be `<h2>` or `<h3>`), never a fixed level.
1140
1184
  - **Forced colors** draws the rules in the system text colour and drops the stripes; **print** draws the rules black, drops the stripes, and lets a scroll-wrapped table print in full. `hidden` hides a table, the wrappers and a stacked row.
1141
1185
 
1186
+ ## Sidebar layout
1187
+
1188
+ A sidebar beside the main content on wide screens, stacked on narrow ones: library.virginia.edu's sidebar pages (a quarter-width first sidebar, 3.5rem from the content) and the Electronic Text Collections' reading pages (a sticky Contents sidebar beside the text). The classes are in `base.css`; there is nothing to load. See the [Sidebar layout](https://uvalib.github.io/reusable-web-library/#sidebar-layout) example.
1189
+
1190
+ ```html
1191
+ <!-- A reading page: the contents first in the source, so they also come first when stacked. -->
1192
+ <div
1193
+ class="uvalib-sidebar-layout uvalib-sidebar-layout--sticky uvalib-sidebar-layout--print-hide-sidebar"
1194
+ >
1195
+ <uvalib-contents class="uvalib-sidebar-layout__sidebar">
1196
+ <ol>
1197
+ <li><a href="#preface">Preface</a></li>
1198
+ <li><a href="#part-1">Part I. The Key</a></li>
1199
+ </ol>
1200
+ </uvalib-contents>
1201
+ <article class="uvalib-sidebar-layout__main">
1202
+ <h2 id="preface">Preface</h2>
1203
+ …
1204
+ <uvalib-pager prev-href="…" prev-label="…" next-href="…" next-label="…"></uvalib-pager>
1205
+ </article>
1206
+ </div>
1207
+
1208
+ <!-- Related links on the right: the sidebar after the main content in the source. -->
1209
+ <div class="uvalib-sidebar-layout">
1210
+ <div class="uvalib-sidebar-layout__main">…</div>
1211
+ <aside class="uvalib-sidebar-layout__sidebar" aria-labelledby="related-heading">
1212
+ <h2 id="related-heading">Related</h2>
1213
+ …
1214
+ </aside>
1215
+ </div>
1216
+ ```
1217
+
1218
+ - **`.uvalib-sidebar-layout`** holds exactly two children: **`__sidebar`** and **`__main`**. Side by side, the sidebar is about a quarter of the layout, `clamp(14rem, 25%, 20rem)`, with 3.5rem between it and the content; the main content takes the rest and can shrink below its content's width, so a long word wraps and a wide table scrolls inside its `.uvalib-table-scroll` instead of pushing the page sideways. Stacked, the two are full width and 2rem apart.
1219
+ - **When:** from **913px of the layout's own width** (a container query), so it works in `<site-page>`'s main, a drawer or any column. 913px is library.virginia.edu's desktop breakpoint (993px of viewport) less `<site-page>`'s 40px gutters on each side, so on a `<site-page>` the layout changes where library.virginia.edu's does (a classic, non-overlay scrollbar moves it about 15px later). The layout fills its parent like any block; inside a shrink-wrapped flex or grid item, give it a width.
1220
+ - **Order is the source order,** side by side and stacked, so the reading and focus order always match what is seen (nothing is reordered with CSS). Sidebar first: a left-hand sidebar that stacks above the content, right for a reading page's contents. Sidebar after the main content: a right-hand sidebar that stacks below it (related links, a contact box). No modifier is needed for either.
1221
+ - **Landmarks are yours:** no role is added. For navigation, make the sidebar the `<nav>` itself: put the class on `<uvalib-contents>` (it is a `<nav>` landmark) or on a `<nav aria-label="…">`. For related content, an `<aside>` (complementary) named by its heading. Do not wrap a `<nav>` in another element with `role="navigation"`, and in a sidebar do not skip heading levels; if one category header is a link, make them all links.
1222
+ - **`--sticky`** keeps the sidebar in view while the page scrolls, **only when side by side** (never stacked): it sticks 1rem from the top (`--uvalib-sidebar-sticky-top`) and, when taller than the window, scrolls by itself. `<site-page>`'s header is not sticky, so nothing covers it; a site with a fixed header sets the offset to the header's height. Use the layout's `--sticky` **or** `<uvalib-contents sticky>` in a plain sidebar, not both; `--sticky` also covers a sidebar holding more than the contents. A sticky sidebar that can overflow needs something focusable in it (links), so keyboard users can scroll it.
1223
+ - **`<uvalib-contents>` in the sidebar:** keep its default `collapse-below` (64rem of viewport). Below that it is a closed Contents button, so on phones the text comes first; between the layout's breakpoint and 64rem it is that button at the top of the side-by-side sidebar. With `base.css` linked, the page does not move when it upgrades.
1224
+ - **Custom properties:** `--uvalib-sidebar-width` (default `clamp(14rem, 25%, 20rem)`), `--uvalib-sidebar-gap` (3.5rem), `--uvalib-sidebar-stack-gap` (2rem), `--uvalib-sidebar-sticky-top` (1rem).
1225
+ - **Print** always stacks it, never stuck or clipped. **`--print-hide-sidebar`** leaves the sidebar out of the printout (a reading page's contents are no use on paper); without it the sidebar prints above or below the content as in the source. `hidden` hides the layout. Forced colors changes nothing: the layout draws no colours of its own.
1226
+
1227
+ ## Reading texts (edition.css)
1228
+
1229
+ `edition.css` styles TEI texts converted to class-annotated HTML, where each element's class is its TEI element name (`<div class="lg">`, `<span class="pb">`, `<ins class="add">`), as Electronic Text Collections' converter, TEI Boilerplate and most TEI-to-HTML stylesheets write them. Put the converted text in an element with `class="uvalib-edition"`. Every rule is inside `:where()` (zero specificity), so any rule of the site's own wins; it carries the dark-mode role tokens it reads, like `pagefind.css`.
1230
+
1231
+ ```html
1232
+ <link rel="stylesheet" href="https://unpkg.internal.lib.virginia.edu/web-components/v1/base.css" />
1233
+ <link
1234
+ rel="stylesheet"
1235
+ href="https://unpkg.internal.lib.virginia.edu/web-components/v1/edition.css"
1236
+ />
1237
+ <script
1238
+ type="module"
1239
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-lightbox.js"
1240
+ ></script>
1241
+
1242
+ <uvalib-lightbox selector=".uvalib-edition a.pb-image"></uvalib-lightbox>
1243
+ <label class="uvalib-edition__lines"><input type="checkbox" /> Show original line breaks</label>
1244
+ <label class="uvalib-edition__readings"><input type="checkbox" /> Show original readings</label>
1245
+ <div class="uvalib-edition" lang="en">
1246
+ <section class="div div-letter">
1247
+ <span class="pb" data-n="1"><a class="pb-image" href="…/default.jpg">p. 1</a></span>
1248
+ <div class="opener">
1249
+ <div class="dateline">May 3, 1859</div>
1250
+ <div class="salute">My dear Sister,</div>
1251
+ </div>
1252
+ <p class="p">
1253
+ The lawn is <ins class="add">all</ins> in bloom. I walked <del class="del">yesterday</del>
1254
+ <br class="lb" />
1255
+ this morning to the <span class="orig" title="Regularized: weather">wether</span>…
1256
+ </p>
1257
+ </section>
1258
+ </div>
1259
+ ```
1260
+
1261
+ - **The look** is the library's, not a facsimile's: Franklin Gothic (`--uva-font-family`; serif body text is on the UX team's deprecated list), a 70ch measure at 1.125rem with a 1.7 line height, headings in the theme's colour and scale, epigraphs and quotations as the theme's blockquote (1px orange start border, italic), ornaments as a centred muted ⁂, footnotes after a rule in smaller text, and page breaks as small muted labels (a link to the page image is underlined in the link colour, at least 24px tall, with the library focus ring). Headings and title pages are left-aligned except where the text says `rend-center`.
1262
+ - **Class vocabulary.** Structure: `div` (and `div-*`, the TEI `@type`: `div-letter`, `div-poem`, `div-chapter`), `head` (`head-sub`), `p`, `ab`, `seg-*`, `list` (`list-simple`, `label`, `list-head`), `table-wrap`. Verse: `lg`, `l` (with `data-n`, shown as a line number). Drama: `sp`, `speaker`, `stage`. Letters: `opener`, `closer`, `dateline`, `salute`, `signed`, `postscript` (or `seg-postscript`). Front and back matter: `epigraph`, `argument`, `trailer`, `byline`, `dedication`, `bibl`, `cit`, `q`, `titlepage` (or ETC's `titlePage`), `titlePart`, `docTitle`, `docAuthor`, `docImprint`, `docDate`. Figures: `figure`, `figDesc` (or a `head` inside it). Editorial: `add`, `del`, `sic`, `orig`, `reg`, `corr`, `unclear`, `gap`. Notes: `noteref`, `footnotes`, `note` (`note-foot`, `note-end`, `note-n`, `note-body`), `note-inline` (a box as `aside`, bracketed as `span`). Breaks: `lb`, `pb` (`pb-n` for a label, `a.pb-image` for a link to the page image), `ornament`, `textbreak`. Renditions: `rend-italic`, `rend-bold`, `rend-roman`, `rend-smallcaps` (or `rend-small-caps`), `rend-underline`, `rend-sup`, `rend-sub`, `rend-center`, `rend-right`, `rend-left`, `rend-indent`, `rend-indent2`, `rend-indent3` (`rend-indent4` on verse lines), `rend-no-indent`, `rend-hang`.
1263
+ - **Editorial marks never rest on colour or strike-through alone.** An addition (raised, smaller) and a deletion (struck through) are announced by screen readers as "added: … (end added)" and "deleted: … (end deleted)" (generated text hidden from sight); an empty deletion shows "[deletion]". Unclear text is followed by a small "[?]" read as "(unclear)"; an empty `gap` shows "[…]" read as "gap in the text". A note reference is read as "Note 1". Line numbers and ornaments are hidden from screen readers.
1264
+ - **Readings** (`title` on `orig`, `reg`, `sic`, `corr` or `abbr`) get a dotted underline. A `title` shows only on mouse hover and most screen readers do not read it on plain text, so the readings toggle (a checkbox `.uvalib-edition__readings`, or the class `uvalib-edition--readings` on the edition) shows every reading inline in brackets, and print always does. Without the toggle, keyboard and touch users cannot reach them.
1265
+ - **Original line breaks.** Prose reflows: `br.lb` is hidden. CSS cannot give a `<br>` a space (browsers ignore `content` on it), so **the converter must keep whitespace before each `<br class="lb">`** or the words on either side run together (ETC's text does: all 12,061 in a sample of 70 pages; a contents label built from a heading's text, which drops the `<br>`, needs the same care); or write `<span class="lb"></span>`, which edition.css spaces itself. A line ending inside a word (`ca<lb/>pite`) needs the converter to drop the break. Lineation is shown by a checked `.uvalib-edition__lines` (a `<label>` round a checkbox, drawn like the library's outline toggle and filled while checked, or the checkbox itself) inside the edition or anywhere in an element before it, or by the class `uvalib-edition--lines` (for a script toggle such as a `.uvalib-button[aria-pressed]`). Verse lines (`l`) always break.
1266
+ - **Page images:** `<uvalib-lightbox selector=".uvalib-edition a.pb-image">` opens each `a.pb-image` in the viewer (Previous and Next through the pages); without JavaScript the link opens the image. A page break that starts a section sits on its own line at the end.
1267
+ - **Dark mode** via the role tokens; **forced colors** keeps the page labels, the note box and the checked toggle visible; **print** shows the text full width in black, keeps the page-break labels, shows every reading, and hides the toggles. Wide tables in `table-wrap` scroll sideways; give the wrapper `tabindex="0"` and a name in the converter if it can scroll. See the [edition example](https://uvalib.github.io/reusable-web-library/#edition).
1268
+
1142
1269
  ## Back to top
1143
1270
 
1144
1271
  `<uvalib-back-to-top>` is a “Back to top” button for long pages: minutes, finding aids, transcriptions, long result lists. Entry: `uvalib-back-to-top.js` on the CDN, `@uvalib/web-components/uvalib-back-to-top.js` on npm. See the [Back to top](https://uvalib.github.io/reusable-web-library/#back-to-top) example.
@@ -1420,6 +1547,61 @@ Analytics: `toggle` (1 open, 0 closed), `sort` (`Subject: name`), `clear` and `a
1420
1547
  - **Before the script loads.** `base.css` shows the label (from the attribute) and holds the field's height, plus one line for a `description`, so nothing below moves on upgrade. A fallback `<input>` child is a working field meanwhile (with `list`, the browser's own suggestions); once upgraded it is disabled so it does not submit twice. Other children stay hidden.
1421
1548
  - **Analytics.** `select` with the label and the suggestion's position (from 1), and `clear` with the label. Never the typed text or a suggestion's text or value: they can be people's names.
1422
1549
 
1550
+ ## List filter
1551
+
1552
+ `<uvalib-list-filter>` is a text field that filters a long list already on the page as you type: a collection's 473 texts, a staff directory, a table of databases. The list is your own markup and stays complete without the script; the field looks like `.uvalib-input`. Entry: `uvalib-list-filter.js` on the CDN, `@uvalib/web-components/uvalib-list-filter.js` on npm. See the [List filter](https://uvalib.github.io/reusable-web-library/#list-filter) example.
1553
+
1554
+ ```html
1555
+ <script
1556
+ type="module"
1557
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-list-filter.js"
1558
+ ></script>
1559
+
1560
+ <uvalib-list-filter
1561
+ for="doc-list"
1562
+ noun="texts"
1563
+ singular="text"
1564
+ placeholder="Title or author"
1565
+ query-param
1566
+ ></uvalib-list-filter>
1567
+ <ol id="doc-list">
1568
+ <li data-filter-text="amanda c. armentrout to william f. brand, 1866 armentrout, amanda c">
1569
+ <a href="/text/A2956/">Amanda C. Armentrout to William F. Brand, August 17, 1866</a>
1570
+ <span>Armentrout, Amanda C · 1866</span>
1571
+ </li>
1572
+ <!-- … -->
1573
+ </ol>
1574
+ ```
1575
+
1576
+ - **The list.** `for` is the id of an element whose children are the items: a `<ul>` or `<ol>`, a `<dl>` of `<div>` rows, a card grid, or a `<table>` (the rows of its `<tbody>` elements; the header stays). `selector` picks the items instead, inside `for` when both are set, else anywhere in the page (or the shadow root the element is in).
1577
+ - **Matching.** Every word typed must appear in the item, in any order (“kate armentrout” finds “Angus to Kate Armentrout”), ignoring case and accents (“eneide” finds “L’Énéide”). The item's `data-filter-text` is matched when present (put the title, author and dates there, as ETC does), otherwise its text. Items that do not match get the `hidden` attribute, and a small rule keeps them hidden even if your CSS gives them a `display`; clearing the field removes it from all of them.
1578
+ - **Fast with thousands of items.** The items' text is read and folded once, on the first keystroke; each keystroke then compares strings and touches only the items whose state changes. In the tests a 3,000-item list takes from under 1 ms to about 25 ms per keystroke, style and layout included (the slowest is showing all 3,000 again); the test fails above 150 ms. Items added or removed later, and `data-filter-text` changes, are picked up; after changing an item's text in script, call `refresh()`.
1579
+ - **Groups.** For a list in headed sections, put `data-filter-group` on each section's wrapper (its heading and its list) and point `selector` at the items: a group whose items are all hidden is hidden too, heading and all. Groups are wrappers, not heading-and-sibling pairs, to keep the rule simple and the markup explicit.
1580
+ ```html
1581
+ <uvalib-list-filter selector="#by-letter li" noun="people"></uvalib-list-filter>
1582
+ <div id="by-letter">
1583
+ <section data-filter-group>
1584
+ <h2>A</h2>
1585
+ <ul>
1586
+ <li>Ada Lovelace</li>
1587
+ </ul>
1588
+ </section>
1589
+ <section data-filter-group>
1590
+ <h2>B</h2>
1591
+ <ul>
1592
+ <li>Bruno Taut</li>
1593
+ </ul>
1594
+ </section>
1595
+ </div>
1596
+ ```
1597
+ - **The field.** A visible `label` (default “Filter”; `hide-label` keeps it for screen readers only, when a heading beside the field says it) and an optional `placeholder`. A Clear button (a real button named “Clear Filter”, 44px, shown only with text) or Escape empties the field, and focus stays in it. Enter does nothing: the list is already filtered.
1598
+ - **The count.** Under the field: “Showing all 473 texts”, “Showing 12 of 473 texts”, updated at once (`noun` is the plural, default “items”; `singular` the word for one). A polite status announces it once the typing settles (a second after the last keystroke), never on every key and never at load. When nothing matches, a `.uvalib-message` under the count says “No texts match “zzz”.”, and that is what is announced. To show the count somewhere else, point `results-count` at a `<uvalib-results-count>` with `total` and `noun` in its markup (so it shows the count before the script and does not announce it at load): the filter sets its `shown` and `total`, and leaves the visible count and the announcement to it.
1599
+ - **In the URL.** `query-param` (a bare attribute means `filter`; `query-param="q"` names it) reads the filter from the URL at start and writes it back with `history.replaceState` a moment after typing (and before the page is left), so a filtered list can be shared or bookmarked and Back returns to it. Hash routes keep it in the hash, as the lightbox does. Off by default.
1600
+ - **Events.** `uvalib-list-filter-change` (`detail: { query, shown, total }`, bubbling and composed) each time the filter is applied with a new query: typing, Clear, Escape, `value` set in script, the URL at start, Back and Forward. `value` (the field's text) can be read and set; `shown` and `total` are read-only.
1601
+ - **No jump on upgrade.** With `base.css`, the label, field and count's height are held before the script runs (less the label with `hide-label`, less the count with `results-count`), and the whole list is shown, so nothing moves when it upgrades. A filter restored from the URL does hide items at load.
1602
+ - **Accessibility.** The field is a labelled `<input type="search">` (the browser's own clear icon is hidden, as the 44px Clear button does its job); the focus ring is the library's 3px orange. The count, the status and the message use the muted and alert role tokens, which keep at least 4.5:1 in light and dark. `no-style` keeps the layout, the 44px targets and the hidden status. Removing the element shows the whole list again.
1603
+ - **Analytics.** `['uvalib-list-filter', 'filter', '', <how many match>]` once the typing settles on a new query (the same words in another case or order do not count again), and `['uvalib-list-filter', 'clear']` when the visitor empties the field. Never the typed text. A filter restored from the URL or set in script is not reported.
1604
+
1423
1605
  ## Filter drawer
1424
1606
 
1425
1607
  `<uvalib-filter-drawer>` holds a search page's form and filters: a plain sidebar on wide screens, and at and below `breakpoint` (default `48rem`) a “Search and filters” button that opens them in a modal panel from the side, as Virgo does on phones. Entry: `uvalib-filter-drawer.js` on the CDN, `@uvalib/web-components/uvalib-filter-drawer.js` on npm. See the [Filter drawer](https://uvalib.github.io/reusable-web-library/#filter-drawer) example.
@@ -1861,14 +2043,28 @@ Static sites that search with [Pagefind](https://pagefind.app) (such as Electron
1861
2043
  merge-index='[{"bundlePath": "/pagefind/s1/"}, {"bundlePath": "/pagefind/s2/"}]'
1862
2044
  placeholder="Search all texts"
1863
2045
  show-sub-results
2046
+ filter-params="collection author"
1864
2047
  ></uvalib-pagefind-search>
1865
2048
  ```
1866
2049
 
1867
2050
  - **`pagefind.css` replaces Pagefind's `pagefind-ui.css`**: link one or the other, never both (the stock rules carry Svelte hash classes that out-rank the theme's). It maps Pagefind's `--pagefind-ui-*` custom properties to the library tokens (set them yourself for small changes) and restyles its classes: the field and the Clear button like `.uvalib-input` and a small outline `.uvalib-button`, the filters like `<uvalib-filter>` (a fieldset of native checkbox rows, "value (count)", long facets scroll in their own box), result titles in the link colour, excerpts with library.virginia.edu's `<mark>` colour, metadata tags, and "Load more results" as a `.uvalib-button`. It carries the dark-mode role tokens it reads (like `base.css`) and keeps every control visible in forced colors.
1868
2051
  - **What it fixes in the stock UI:** text at 16px and up (the stock scale makes it 12.8px), a readable placeholder (stock: 20% opacity), the library focus ring on every control, a hidden Clear button that can no longer take focus (stock: invisible but focusable), native checkboxes (the stock ones vanish in forced colors), 44px targets for the filter headings, rows and buttons, no fixed heights that clip zoomed or spaced text, no arrow glyph read out before each sub-result, and a 320px reflow. Text is 7:1 or more (WCAG AAA) in light and dark, except the Load more button's white on blue-alt in light mode (4.7:1, as on every `.uvalib-button`).
1869
2052
  - **What needs script, done by `<uvalib-pagefind-search>`:** a visible `<label>` for the field (the stock field is named only by its `title` and has no id to point a label at), a polite status region that announces "7 results for virginia" once results settle (the stock message is not a live region), focus kept in the field after Clear and Escape (the stock UI blurs it) and moved to the first new result after "Load more results", and the loading placeholders' dots hidden from screen readers. It also reads `?q=` when it starts (and again on Back and Forward) and writes the settled query back with `history.replaceState` (`query-param`, default `q`; empty turns it off), and reports to `<site-analytics>`: the settled search (`trackSearch`, category `Pagefind`, with the result count, once per query and filter set) and `['uvalib-pagefind-search', 'filter-change', '<filter>: <value>', 1 | 0]`.
2053
+ - **Filters in the URL: `filter-params`.** List Pagefind filter names, space-separated (`filter-params="collection author"`), and each becomes a URL parameter of the same name, so a collection page can link to `/search/?collection=Manuscripts` ("Search this collection") or `/search/?q=virginia&collection=Manuscripts`. A repeated parameter (`?collection=A&collection=B`) checks several values; as with boxes checked by hand, Pagefind then wants pages with every one. At start (and on Back and Forward) the element loads the index, waits for Pagefind's filter list, checks the URL's values and applies them with the query, so there is one search; those filter groups start open (added to any `openFilters` in `options`), so the visitor sees why the results are narrowed. Values the index does not have are dropped without an error (matched without regard to case, then written back in the index's own case), so a stale link searches everything rather than showing no results; if the filter list never appears (an index with no filters), it searches without them after 10 s. Checking or unchecking a named filter writes it back with `history.replaceState`, keeping every other parameter; unchecking the last value removes the parameter. Filters not named stay out of the URL. A filter set from the URL is not a `filter-change` event; the settled search is still reported once, with the filters in its key. Without a query, the filters wait for the first search, as in Pagefind. Do not add your own `triggerFilters` script for this.
2054
+ - **A search from the URL holds the page still: `searching`.** Pagefind's results arrive after the page has painted, so a page opened with `?q=` used to push everything below the search (the footer) down as they loaded: Lighthouse measured CLS 0.274 on Electronic Text Collections. Mark the element `searching` when the URL has a query, in the page's HTML before any script runs, with one line after the element (or server-side):
2055
+
2056
+ ```html
2057
+ <uvalib-pagefind-search bundle-path="/pagefind/s0/" show-sub-results></uvalib-pagefind-search>
2058
+ <script>
2059
+ if (new URLSearchParams(location.search).get('q'))
2060
+ document.querySelector('uvalib-pagefind-search').setAttribute('searching', '');
2061
+ </script>
2062
+ ```
2063
+
2064
+ From first paint, `pagefind.css` then holds a window's height for the results and draws one screen of placeholder results (bars like base.css's `.uvalib-skeleton-text`, sized like Pagefind's result rows, with two sections each under `show-sub-results`); once the script runs, the element puts the same placeholders in the page (`page-size` rows, `aria-hidden`, with base.css's shimmer, which stops under reduced motion) and hides Pagefind's results area until the results, or "no results", have loaded. Then the element still reaches the bottom of the window until the visitor uses the search (types, clears or clicks in it), so a short list or "no results" does not pull the footer up into view; after that it is as tall as its content. The polite status region announces the count as before, and the analytics are unchanged. On Back and Forward to a new query the element does the same itself. Without `searching` it does not hold at start: its script runs after first paint, when holding would itself push the footer down. With the snippet, Electronic Text Collections' search measured CLS 0.000 (full page, 1 result and no results, phone and desktop; 0.13–0.44 without it), so a site's own `min-height` hold on the element can go. Add `no-skeleton` to turn all of this off. The snippet uses `q`: use your `query-param`.
2065
+
1870
2066
  - **Still open** (in Pagefind's markup, not fixable from outside without rewriting it): filter checkbox ids are built from the filter and value (`author-Jefferson, Thomas`), so they can contain spaces and repeat if a page has two search UIs.
1871
- - The element loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI` already exists; Pagefind itself stays the site's. `el.ready` resolves with the `PagefindUI` instance, for `triggerFilters` (filters from the URL, say). Attributes are read when it connects; removing the element destroys the Pagefind UI, and inserting it again starts a new one (`bundle-path` and each `merge-index` path get their trailing `/` if missing, and `options` cannot move the UI out of the element). Without the element, the theme still styles `new PagefindUI({ element })`, but then the field needs a label and the results a live region from your own script. See the [Pagefind example](https://uvalib.github.io/reusable-web-library/#pagefind-search) in the playground and the reference below.
2067
+ - The element loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI` already exists; Pagefind itself stays the site's. `el.ready` resolves with the `PagefindUI` instance, for `triggerFilters` (filters from your own script; for filters from the URL use `filter-params`). Attributes are read when it connects; removing the element destroys the Pagefind UI, and inserting it again starts a new one (`bundle-path` and each `merge-index` path get their trailing `/` if missing, and `options` cannot move the UI out of the element). Without the element, the theme still styles `new PagefindUI({ element })`, but then the field needs a label and the results a live region from your own script. See the [Pagefind example](https://uvalib.github.io/reusable-web-library/#pagefind-search) in the playground and the reference below.
1872
2068
 
1873
2069
  ## Analytics
1874
2070
 
@@ -1971,6 +2167,8 @@ Static sites that search with [Pagefind](https://pagefind.app) (such as Electron
1971
2167
  | `uvalib-combobox` | `select` (a suggestion chosen) | the field's label (never the typed text or the suggestion) | the suggestion's position, from 1 |
1972
2168
  | `uvalib-combobox` | `clear` (the clear button, or Escape on a closed list) | the field's label | |
1973
2169
  | `uvalib-combobox` | `error` (`src` failed to load) | `load` | |
2170
+ | `uvalib-list-filter` | `filter` (once the typing settles on a new query, 1 s after the last keystroke) | empty (never the typed text) | how many items match |
2171
+ | `uvalib-list-filter` | `clear` (the clear button, Escape, or the field emptied by typing) | | |
1974
2172
  | `uvalib-filter-drawer` | `open`, `close` (by the visitor: the button, Close, Escape or the backdrop; not a resize or a script) | the drawer's `label` | |
1975
2173
  | `uvalib-back-to-top` | `click` | | |
1976
2174
  | `uvalib-dialog` | `open` (a visitor's button), `close` (by the visitor: Close, a close button, Escape, the backdrop or a dialog form; not a script) | the dialog's `label` (never its content) |
@@ -2883,7 +3081,7 @@ An editable text field that suggests values as you type, from a local list or a
2883
3081
 
2884
3082
  ### `<uvalib-contents>`
2885
3083
 
2886
- Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation: a `<nav>` landmark (named by `label`, "Contents" by default) with the label as a visible headline, and a nested list of links with dividers between the top-level entries and a bar beside each nested level. Give the list as a child: an `<ol>` or `<ul>` of `<li>` elements, each with an `<a href>` (or plain text for a group label) and, for sub-entries, a nested `<ol>`/`<ul>`, to any depth. Other children (a heading) are ignored. The list follows changes to the children. Apps set the `items` property instead (`{ label, href?, children? }`, winning over the children while set). The current entry gets `aria-current`: `page` for the link to this page, `location` for the link to the section of it in the URL's hash. It is found from the page URL (path, and hash for in-page sections), followed through same-document navigations (`hashchange`, `popstate` and the Navigation API), or from the `current` attribute (a URL, resolved like the links). An entry whose href has a query string matches only that query (`?part=2`); one without matches the page whatever its query. Hash-only hrefs are places on that page. With `current` unset, a valid `aria-current` on a source link (`page`, `location` or `true`) is used instead, the first of each kind. `lang` and `dir` on the source links and items, and inline markup in their text (`em`, `cite`, `code`, `abbr`…, copied element by element, never as HTML), are kept. On narrow screens the list collapses into a disclosure: the headline becomes a button with `aria-expanded`, and the list starts closed (as the Electronic Text Collections' Contents does on phones, so the text comes first) until the reader opens it, or while the `open` attribute is set; opening it shows the current entry. Narrow means the viewport (`collapse-below`, 64rem by default), not the element's own width: a contents sidebar is always far narrower than 64rem, so a container query could not tell a phone from a desktop. `sticky` keeps it in view in a sidebar on wide screens; a list longer than the window then scrolls, and the current entry is scrolled into view inside it (never the page). A table of contents for a long document: `headings-from="#article"` builds the list from the headings in that element (`levels`, `2-3` by default; nothing shown below `min` top-level entries, 2 by default). Headings without text or hidden with `aria-hidden` are skipped; one without an id gets one from its text (`budget-report`, then `budget-report-2`), and existing ids are kept, so links to sections keep working. It follows headings added, removed or retitled; `refresh()` reads them again after other changes. The children and `items` win while they give a list. Without JavaScript there is no list: a list rendered at build time, as children, works everywhere. Single-page apps: the list is drawn from copies of the children, so a router's own click handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in place; hash links need nothing.
3084
+ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation: a `<nav>` landmark (named by `label`, "Contents" by default) with the label as a visible headline, and a nested list of links with dividers between the top-level entries and a bar beside each nested level. Give the list as a child: an `<ol>` or `<ul>` of `<li>` elements, each with an `<a href>` (or plain text for a group label) and, for sub-entries, a nested `<ol>`/`<ul>`, to any depth. Other children (a heading) are ignored. The list follows changes to the children. Apps set the `items` property instead (`{ label, href?, children? }`, winning over the children while set). The current entry gets `aria-current`: `page` for the link to this page, `location` for the link to the section of it in the URL's hash. It is found from the page URL (path, and hash for in-page sections), followed through same-document navigations (`hashchange`, `popstate` and the Navigation API), or from the `current` attribute (a URL, resolved like the links). An entry whose href has a query string matches only that query (`?part=2`); one without matches the page whatever its query. Hash-only hrefs are places on that page. With `current` unset, a valid `aria-current` on a source link (`page`, `location` or `true`) is used instead, the first of each kind. `lang` and `dir` on the source links and items, and inline markup in their text (`em`, `cite`, `code`, `abbr`…, copied element by element, never as HTML), are kept. On narrow screens the list collapses into a disclosure: the headline becomes a button with `aria-expanded`, and the list starts closed (as the Electronic Text Collections' Contents does on phones, so the text comes first) until the reader opens it, or while the `open` attribute is set; opening it shows the current entry. Narrow means the viewport (`collapse-below`, 64rem by default), not the element's own width: a contents sidebar is always far narrower than 64rem, so a container query could not tell a phone from a desktop. `sticky` keeps it in view in a sidebar on wide screens; a list longer than the window then scrolls, and the current entry is scrolled into view inside it (never the page). A table of contents for a long document: `headings-from="#article"` builds the list from the headings in that element (`levels`, `2-3` by default; nothing shown below `min` top-level entries, 2 by default). Headings without text or hidden with `aria-hidden` are skipped; one without an id gets one from its text (`budget-report`, then `budget-report-2`), and existing ids are kept, so links to sections keep working. It follows headings added, removed or retitled; `refresh()` reads them again after other changes. The children and `items` win while they give a list. Without JavaScript there is no list: a list rendered at build time, as children, works everywhere. A very long contents (a text with hundreds of sections, each its own page) can show only part of the list, with a link to the whole. `full-href` adds that link after the list: not an entry but a call to action (bold, underlined, with an arrow), its text `full-label` ("Full contents") followed by the count when `total` (the entries in the full contents) is set: "Full contents (243 sections)" (`noun`, "sections" by default; `singular` for one). A static site writes only the entries near the current one (with their parents) and sets these. `window="12"` does it in the browser when the whole list is given: only the current entry and the 12 before and after it in document order (25 entries, shifted at either end) are shown, with their parents so the nesting still makes sense; the others are hidden, not removed, and a gap between the entries shown is marked with an ellipsis (hidden from assistive technology). It follows the current entry, and applies to `items` and `headings-from` too. Without `full-href`, a "Show all 243 sections" button shows the rest in place ("Show fewer" goes back). While part of the list is shown, a visually hidden line before it says so ("Showing 25 of 243 sections."); the headline and the landmark keep the visible label as their name. On narrow screens the link and the button are inside the disclosure. Single-page apps: the list is drawn from copies of the children, so a router's own click handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in place; hash links need nothing.
2887
3085
 
2888
3086
  #### Attributes
2889
3087
 
@@ -2898,6 +3096,12 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
2898
3096
  | `headings-from` | `string \| undefined` | | Build the list from the headings in the element this selector names (`#article`): each heading at `levels` gets an entry linking to it (an id is added when it has none), the lower levels nested under the heading before them. The children and `items` win while they give a list. |
2899
3097
  | `levels` | | `DEFAULT_LEVELS` | With `headings-from`: the heading levels to list, `2-3` (the default) or one level, `2`. |
2900
3098
  | `min` | | `DEFAULT_MIN` | With `headings-from`: the fewest top-level entries worth a list (default 2). With fewer, nothing is shown. |
3099
+ | `full-href` | `string \| undefined` | | The URL of the full contents, when the list is only part of it: a "Full contents" link after the list (`full-label`, with the count from `total`). |
3100
+ | `full-label` | | `DEFAULT_FULL_LABEL` | The full-contents link's text, before the count: "Full contents" by default. |
3101
+ | `total` | `number \| undefined` | | How many entries the full contents has, for the link ("Full contents (243 sections)") and the screen-reader line ("Showing 25 of 243 sections."). With `window`, the whole list's count when unset. |
3102
+ | `noun` | | `DEFAULT_NOUN` | What the entries are, plural, in the counts: "sections" by default. |
3103
+ | `singular` | `string` | `''` | What an entry is, singular, for a count of one. Default: "section" for the default `noun`, else `noun`. |
3104
+ | `window` | `number \| undefined` | | Show only the current entry and this many before and after it in document order (and their parents); the others are hidden. Unset or blank: every entry. |
2901
3105
  | `no-shadow-dom` | `boolean` | `false` | |
2902
3106
  | `no-style` | `boolean` | `false` | |
2903
3107
 
@@ -2905,8 +3109,8 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
2905
3109
 
2906
3110
  | Event | Description |
2907
3111
  |---|---|
2908
- | `uvalib-analytics-event` | For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), and opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' \| 'close']`; never the label or URL. Bubbles and is composed. |
2909
- | `uvalib-contents-navigate` | A plain click on an entry: `detail` is `{ href, level }` (href as written). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed. |
3112
+ | `uvalib-analytics-event` | For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), on the full-contents link, `['uvalib-contents', 'full-contents-click']`, opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' \| 'close']`, and the window's button, `['uvalib-contents', 'show-all' \| 'show-fewer']`; never the label or URL. Bubbles and is composed. |
3113
+ | `uvalib-contents-navigate` | A plain click on an entry or the full-contents link: `detail` is `{ href, level }` (href as written; level 0 for the full-contents link). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed. |
2910
3114
 
2911
3115
  #### CSS custom properties
2912
3116
 
@@ -2922,6 +3126,7 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
2922
3126
  | `--uva-color-text` | | Dark-mode role token: text and current entry (else `--uva-grey-darkest`). |
2923
3127
  | `--uva-color-link` | | Dark-mode role token: the current entry's bar and the button's text (else `--uva-brand-blue`). |
2924
3128
  | `--uva-color-current` | | Dark-mode role token: the nested levels' bar (else `--uva-brand-orange`). |
3129
+ | `--uva-color-text-muted` | | Dark-mode role token: the ellipsis between the entries a window shows (else #4f4f4f). |
2925
3130
  | `--uva-color-border` | | Dark-mode role token: dividers (else #dadada). |
2926
3131
  | `--uva-color-control-border` | | Dark-mode role token: the button's border (else #808080). |
2927
3132
  | `--uva-color-surface-raised` | | Dark-mode role token: the button's background (else #fff). |
@@ -3346,6 +3551,57 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
3346
3551
  | `--uva-grey-darkest` | `#2b2b2b` | Text when `--uva-color-text` is unset. |
3347
3552
  | `--uva-grey-100` | `#dadada` | Border when `--uva-color-border` is unset. |
3348
3553
 
3554
+ ### `<uvalib-list-filter>`
3555
+
3556
+ A text field that filters a long list on the page as you type: a collection's 473 texts, a staff directory, a table of databases. The list is the page's own markup and stays fully visible without the script. `for` is the id of the list: any element whose children are the items (a `<ul>` or `<ol>`, a `<dl>` of `<div>` rows, a grid of cards; for a `<table>`, the rows of its bodies). `selector` picks the items instead (inside `for` when both are set, else in the page). An item matches when every word typed appears in its `data-filter-text`, or else its text, in any order, ignoring case and accents (“eneide” finds “Énéide”). Items that do not match get the `hidden` attribute (kept hidden whatever `display` the page gives them); clearing the field shows them all again. Thousands of items filter at once on every keystroke: the text is read once, and only items whose state changes are touched. Groups: give each group's wrapper `data-filter-group` (a `<section>` with its heading and its list) and point `selector` at the items; a group whose items are all hidden is hidden too, heading and all. The visible `label` (default “Filter”; `hide-label` hides it visually) names the field, and a Clear button (“Clear <label>”, 44px, shown only with text) or Escape empties it, keeping focus in the field. Under the field a count follows at once (“Showing 12 of 473 texts”; `noun`, plural, and `singular` name the items), and a polite status announces it once the typing settles (a second after the last keystroke), never on every key or at load. When nothing matches, a message says “No texts match “…”.” To put the count elsewhere, point `results-count` at a `<uvalib-results-count>` (give it `total` and `noun` in the markup): the element then sets its `shown` and `total` and leaves the count and announcement to it. With `query-param` (bare: `filter`) the filter is read from that URL parameter at start and written back with `history.replaceState` as you type, so a filtered list can be shared and Back returns to it. The list's content is read once; call `refresh()` after changing an item's text in script (added or removed items and `data-filter-text` changes are noticed). Before it upgrades, `base.css` holds the label, field and count's height, so nothing moves.
3557
+
3558
+ #### Attributes
3559
+
3560
+ | Attribute | Type | Default | Description |
3561
+ |---|---|---|---|
3562
+ | `for` | `string` | `''` | The id of the list whose children are the items (for a table, its body rows). |
3563
+ | `selector` | `string` | `''` | A CSS selector for the items, inside `for` when it is set, else in the page. |
3564
+ | `label` | `string` | `'Filter'` | The field's visible label and accessible name. |
3565
+ | `hide-label` | `boolean` | `false` | Hide the label visually (it still names the field), when a heading beside it says it. |
3566
+ | `placeholder` | `string` | `''` | Placeholder text in the empty field, such as “Title or author”. |
3567
+ | `noun` | `string` | `'items'` | What the items are, plural: “items” by default. |
3568
+ | `singular` | `string` | `''` | What one item is. Default: “item” when `noun` is unset, else `noun`. |
3569
+ | `results-count` | `string` | `''` | The id of a `<uvalib-results-count>` to drive instead of the element's own count. |
3570
+ | `query-param` | `string \| null` | `null` | The URL parameter to read the filter from and write it to; a bare attribute uses `filter`. Off by default. |
3571
+ | `value` | `string` | `''` | The text in the field. Setting it filters the list (not reported to analytics). |
3572
+ | `no-shadow-dom` | `boolean` | `false` | |
3573
+ | `no-style` | `boolean` | `false` | |
3574
+
3575
+ #### CSS parts
3576
+
3577
+ | Part | Description |
3578
+ |---|---|
3579
+ | `label` | The visible label. |
3580
+ | `field` | The box around the field and its clear button. |
3581
+ | `input` | The text field. |
3582
+ | `clear` | The clear button. |
3583
+ | `count` | The visible count under the field. |
3584
+ | `empty` | The “No … match” message. |
3585
+
3586
+ #### Events
3587
+
3588
+ | Event | Description |
3589
+ |---|---|
3590
+ | `uvalib-list-filter-change` | The filter was applied with a new query (typing, Clear, Escape, `value` set in script, the URL at start, Back and Forward). `detail` is `{ query, shown, total }`. Not fired at load without a query. Bubbles and is composed. |
3591
+ | `uvalib-analytics-event` | For `<site-analytics>`, on the visitor's actions only: `['uvalib-list-filter', 'filter', '', <shown>]` once the typing settles on a new query, and `['uvalib-list-filter', 'clear']` when the visitor empties the field. Never the typed text. Bubbles and is composed. |
3592
+
3593
+ #### CSS custom properties
3594
+
3595
+ | Property | Default | Description |
3596
+ |---|---|---|
3597
+ | `--uva-color-surface-raised` | | Dark-mode role token: field background (else #fff). |
3598
+ | `--uva-color-control-border` | | Dark-mode role token: field border (else `--uva-grey`, #808080). |
3599
+ | `--uva-color-input-text` | | Dark-mode role token: field text (else #2b2b2b). |
3600
+ | `--uva-color-text` | | Dark-mode role token: label text (else #2b2b2b). |
3601
+ | `--uva-color-text-muted` | | Dark-mode role token: placeholder, count and the clear icon (else #4f4f4f). |
3602
+ | `--uva-color-alert-info-bg` | | Dark-mode role token: the no-match message background. |
3603
+ | `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
3604
+
3349
3605
  ### `<uvalib-map>`
3350
3606
 
3351
3607
  A map of places with a linked list of the same places: buildings, rooms or outdoor spaces, each a marker sized by a count, with a link to the place's page. It wraps [Leaflet](https://leafletjs.com) 1.9, which the page provides (the library never bundles it): set the `leaflet` property to the Leaflet module (`import * as L from 'leaflet'`), or load leaflet.js so that `window.L` exists. Without Leaflet only the list is shown, with one console warning. Leaflet's leaflet.css is optional: the element carries the layout rules it needs, in shadow DOM and light DOM alike. Places come from `items` (`{ id?, name, lat, lng, count?, href?, description? }`) or from a child `<ul>`/`<ol>` of `<li><a href data-lat data-lng data-count>Name</a></li>`, which is the list before the script runs (and without it). The list always stays, under the map: it is the text equivalent. Each marker is a real link (a button when the place has no `href`) named like "The Rotunda, 2,702 photos" (`count-label` is the noun), sized by the square root of its count (a 24 to 56px dot in a hit area of at least 44px). Tab or the arrow keys move between markers, Enter follows the link (or chooses the place), and Escape hides the tooltip. Hovering or focusing a marker shows a tooltip with its name and count and highlights its list entry; hovering or focusing a list entry highlights its marker (a ring and a larger dot, not colour alone) and brings it into view. Markers whose 44px targets would overlap at the current zoom are drawn as one group marker (regrouped after every zoom and resize): a button showing how many places it holds, sized by their summed count and named like "The Rotunda and 2 more places, 3,610 photos" (the largest place's name; `place-label` is the noun). Choosing it zooms in until its places part; when they cannot (one point, or the maximum zoom) it spreads them in a ring around it instead, with focus on the first; Escape or a zoom closes the ring and focus returns to the group. The arrow keys move between the markers shown (a group is one); a place in the list that is in a group highlights the group, whose tooltip names the place. The map is a region named by `label`, after a "Skip map, go to the list" link and a line of key instructions. It opens on the bounds of the places, or on `center` and `zoom`. The zoom buttons are 44px with a visible focus ring; the attribution stays. Tiles come from `tile-url` (OpenStreetMap by default: low-traffic use only) with `attribution`. In the page's dark mode the tiles are inverted with a CSS filter (`--uvalib-map-dark-filter`) unless `dark-tile-url` gives dark tiles; markers and controls are never filtered. With `prefers-reduced-motion` nothing animates.
@@ -3451,7 +3707,7 @@ A record's details as a description list, as on the library's digital collection
3451
3707
 
3452
3708
  ### `<uvalib-pagefind-search>`
3453
3709
 
3454
- Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle) with the library's defaults and the accessibility fixes that need script. Use it with pagefind.css, in place of Pagefind's pagefind-ui.css. It renders in light DOM, so the page's styles reach Pagefind's markup. It loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI` already exists. What it adds to the stock UI: a visible `<label>` for the field (the stock field is named only by its title); a polite status region that announces the result count ("12 results for virginia") once results settle (the stock message is not a live region); focus kept in the field after Clear or Escape (the stock UI blurs it, dropping focus to the page) and moved to the first new result after "Load more results"; the loading placeholders' dots hidden from screen readers; `?q=` read at start (and on Back and Forward) and the settled query written back with `history.replaceState`, so a search can be shared; and reports to `<site-analytics>`. The `ui` property is the `PagefindUI` instance (for `triggerFilters`), and `ready` resolves with it. Attributes are read once, when the element is first connected.
3710
+ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle) with the library's defaults and the accessibility fixes that need script. Use it with pagefind.css, in place of Pagefind's pagefind-ui.css. It renders in light DOM, so the page's styles reach Pagefind's markup. It loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI` already exists. What it adds to the stock UI: a visible `<label>` for the field (the stock field is named only by its title); a polite status region that announces the result count ("12 results for virginia") once results settle (the stock message is not a live region); focus kept in the field after Clear or Escape (the stock UI blurs it, dropping focus to the page) and moved to the first new result after "Load more results"; the loading placeholders' dots hidden from screen readers; `?q=` read at start (and on Back and Forward) and the settled query written back with `history.replaceState`, so a search can be shared; with `filter-params`, the named Pagefind filters read from and written to the URL the same way; and reports to `<site-analytics>`. While a search from the URL loads, it can hold the page still (issue #37): with `searching` set in the page's HTML when the URL has a query, the element holds a screen's height from first paint, and placeholder results (aria-hidden) stand in for Pagefind's until they, or "no results", are drawn; the element then still reaches the bottom of the window until the visitor uses the search, so a short list does not pull the footer up. It does the same on Back and Forward to a new query. The `ui` property is the `PagefindUI` instance (for `triggerFilters`), and `ready` resolves with it. Attributes are read once, when the element is first connected.
3455
3711
 
3456
3712
  #### Attributes
3457
3713
 
@@ -3469,6 +3725,9 @@ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle)
3469
3725
  | `translations` | `string` | | JSON of Pagefind UI strings to override (`{"zero_results": "…"}`). |
3470
3726
  | `options` | `string` | | JSON of any other `PagefindUI` options (`{"openFilters": ["author"]}`), applied last. |
3471
3727
  | `query-param` | `string` | `q` | The URL parameter that holds the query; empty turns it off. |
3728
+ | `searching` | `boolean` | | Set it in the page's HTML when the URL has a query (server-side, or with a one-line inline script after the element): from first paint, before any script loads, it holds a screen's height for the results, and placeholder results show until they are drawn. The element removes it then (and at start without a query), and sets it itself on Back and Forward to a new query. |
3729
+ | `no-skeleton` | `boolean` | | Never hold space or show placeholder results (`searching` is ignored). |
3730
+ | `filter-params` | `string` | | Space-separated Pagefind filter names read from and written to URL parameters of the same name (`collection author`: `?collection=A&collection=B`). URL filters are applied with the query as one search, their filter groups open; values not in the index are ignored. Empty (the default) turns it off. |
3472
3731
 
3473
3732
  #### Events
3474
3733