@uvalib/web-components 1.8.5 → 1.10.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 (98) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +719 -72
  3. package/bin/install-skill.mjs +174 -54
  4. package/dist/base/clipboard.d.ts +9 -0
  5. package/dist/base/clipboard.js +30 -0
  6. package/dist/base/clipboard.js.map +1 -0
  7. package/dist/base.css +301 -3
  8. package/dist/components/uvalib-citation/UvalibCitation.d.ts +124 -0
  9. package/dist/components/uvalib-citation/UvalibCitation.js +545 -0
  10. package/dist/components/uvalib-citation/UvalibCitation.js.map +1 -0
  11. package/dist/components/uvalib-citation/uvalib-citation.d.ts +1 -0
  12. package/dist/components/uvalib-citation/uvalib-citation.js +4 -0
  13. package/dist/components/uvalib-citation/uvalib-citation.js.map +1 -0
  14. package/dist/components/uvalib-dialog/UvalibDialog.d.ts +167 -0
  15. package/dist/components/uvalib-dialog/UvalibDialog.js +688 -0
  16. package/dist/components/uvalib-dialog/UvalibDialog.js.map +1 -0
  17. package/dist/components/uvalib-dialog/uvalib-dialog.d.ts +1 -0
  18. package/dist/components/uvalib-dialog/uvalib-dialog.js +4 -0
  19. package/dist/components/uvalib-dialog/uvalib-dialog.js.map +1 -0
  20. package/dist/components/uvalib-filter/UvalibFilter.d.ts +92 -9
  21. package/dist/components/uvalib-filter/UvalibFilter.js +748 -60
  22. package/dist/components/uvalib-filter/UvalibFilter.js.map +1 -1
  23. package/dist/components/uvalib-list-filter/UvalibListFilter.d.ts +162 -0
  24. package/dist/components/uvalib-list-filter/UvalibListFilter.js +685 -0
  25. package/dist/components/uvalib-list-filter/UvalibListFilter.js.map +1 -0
  26. package/dist/components/uvalib-list-filter/uvalib-list-filter.d.ts +1 -0
  27. package/dist/components/uvalib-list-filter/uvalib-list-filter.js +4 -0
  28. package/dist/components/uvalib-list-filter/uvalib-list-filter.js.map +1 -0
  29. package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -4
  30. package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
  31. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +28 -1
  32. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +139 -3
  33. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  34. package/dist/custom-elements.json +9503 -6086
  35. package/dist/edition.css +758 -0
  36. package/dist/index.d.ts +6 -0
  37. package/dist/index.js +3 -0
  38. package/dist/index.js.map +1 -1
  39. package/dist/styles/base.js +112 -1
  40. package/dist/styles/base.js.map +1 -1
  41. package/dist/styles/color-scheme.js +4 -0
  42. package/dist/styles/color-scheme.js.map +1 -1
  43. package/dist/styles/controls.js +6 -0
  44. package/dist/styles/controls.js.map +1 -1
  45. package/dist/styles/edition.d.ts +1 -0
  46. package/dist/styles/edition.js +747 -0
  47. package/dist/styles/edition.js.map +1 -0
  48. package/dist/styles/field-text.d.ts +1 -0
  49. package/dist/styles/field-text.js +21 -0
  50. package/dist/styles/field-text.js.map +1 -0
  51. package/dist/styles/hidden.js +15 -1
  52. package/dist/styles/hidden.js.map +1 -1
  53. package/dist/styles/layout.d.ts +1 -0
  54. package/dist/styles/layout.js +92 -0
  55. package/dist/styles/layout.js.map +1 -0
  56. package/dist/styles/table.d.ts +1 -0
  57. package/dist/styles/table.js +164 -0
  58. package/dist/styles/table.js.map +1 -0
  59. package/dist/tokens.css +4 -0
  60. package/dist-cdn/base.css +301 -3
  61. package/dist-cdn/chunks/{base-B3tNX103.js → base-DXkGlSgH.js} +113 -2
  62. package/dist-cdn/chunks/base-DXkGlSgH.js.map +1 -0
  63. package/dist-cdn/chunks/clipboard-CNG7Y_5X.js +18 -0
  64. package/dist-cdn/chunks/clipboard-CNG7Y_5X.js.map +1 -0
  65. package/dist-cdn/chunks/if-defined-COiQb-gl.js +6 -0
  66. package/dist-cdn/chunks/if-defined-COiQb-gl.js.map +1 -0
  67. package/dist-cdn/chunks/{site-header-CEmNtmk5.js → site-header-B78a_ldi.js} +27 -22
  68. package/dist-cdn/chunks/site-header-B78a_ldi.js.map +1 -0
  69. package/dist-cdn/chunks/{site-main-nav-CAwKq_x5.js → site-main-nav-CmMq2t8t.js} +52 -51
  70. package/dist-cdn/chunks/site-main-nav-CmMq2t8t.js.map +1 -0
  71. package/dist-cdn/custom-elements.json +9503 -6086
  72. package/dist-cdn/edition.css +758 -0
  73. package/dist-cdn/manifest.json +7 -3
  74. package/dist-cdn/site-header.js +1 -1
  75. package/dist-cdn/site-main-nav.js +1 -1
  76. package/dist-cdn/site-page.js +3 -3
  77. package/dist-cdn/site-style.js +1 -1
  78. package/dist-cdn/skills/uvalib-web-components/SKILL.md +34 -10
  79. package/dist-cdn/skills/uvalib-web-components/reference/components.md +188 -9
  80. package/dist-cdn/tokens.css +4 -0
  81. package/dist-cdn/uvalib-citation.js +382 -0
  82. package/dist-cdn/uvalib-citation.js.map +1 -0
  83. package/dist-cdn/uvalib-dialog.js +419 -0
  84. package/dist-cdn/uvalib-dialog.js.map +1 -0
  85. package/dist-cdn/uvalib-filter.js +603 -69
  86. package/dist-cdn/uvalib-filter.js.map +1 -1
  87. package/dist-cdn/uvalib-list-filter.js +451 -0
  88. package/dist-cdn/uvalib-list-filter.js.map +1 -0
  89. package/dist-cdn/uvalib-metadata.js +49 -49
  90. package/dist-cdn/uvalib-metadata.js.map +1 -1
  91. package/dist-cdn/uvalib-pagefind-search.js +118 -48
  92. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  93. package/package.json +14 -1
  94. package/skills/uvalib-web-components/SKILL.md +34 -10
  95. package/skills/uvalib-web-components/reference/components.md +188 -9
  96. package/dist-cdn/chunks/base-B3tNX103.js.map +0 -1
  97. package/dist-cdn/chunks/site-header-CEmNtmk5.js.map +0 -1
  98. package/dist-cdn/chunks/site-main-nav-CAwKq_x5.js.map +0 -1
package/README.md CHANGED
@@ -9,10 +9,11 @@ Reusable web components for UVA Library sites, built with Lit and TypeScript:
9
9
  - **Cards:** `<uvalib-card>`, `<uvalib-card-grid>` and `<uvalib-pager>`.
10
10
  - **Tabs:** `<uvalib-tabs>`.
11
11
  - **Long pages:** `<uvalib-back-to-top>` (a “Back to top” button that appears once the top has scrolled away).
12
- - **Records:** `<uvalib-metadata>` (a record's details, credit, rights and how to cite).
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) 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,7 +550,7 @@ 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.
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.
527
554
  - **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.
528
555
 
529
556
  `<uvalib-metadata>`, a record's description list:
@@ -558,6 +585,47 @@ Two components for Library sites with records and long texts, such as the Electr
558
585
 
559
586
  Both follow dark mode through the role tokens and reflow at 320px; `no-style` keeps only the structure, and light DOM styles are scoped to the tag in `@layer uvalib`.
560
587
 
588
+ ## Citations
589
+
590
+ `<uvalib-citation>` shows one record's citation in several formats, as Virgo's Cite dialog does (MLA, APA, Chicago, Bluebook), with a Copy citation button and an optional Download RIS link. Entry: `uvalib-citation.js` on the CDN, `@uvalib/web-components/uvalib-citation.js` on npm. See the [Citation](https://uvalib.github.io/reusable-web-library/#citation) example. For a single citation in a record's details, `<uvalib-metadata citation="…">` (How to cite, with its own Copy citation button) is still the simpler choice.
591
+
592
+ ```html
593
+ <script
594
+ type="module"
595
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-citation.js"
596
+ ></script>
597
+
598
+ <uvalib-citation ris-href="/sources/uva_library/items/u2297137.ris">
599
+ <blockquote data-format="MLA">
600
+ Jefferson, Thomas. <i>Notes on the State of Virginia</i>. Edited by William Peden, U of North
601
+ Carolina P, 1955.
602
+ </blockquote>
603
+ <blockquote data-format="APA">
604
+ Jefferson, T. (1955). <i>Notes on the state of Virginia</i> (W. Peden, Ed.). University of North
605
+ Carolina Press. (Original work published 1785)
606
+ </blockquote>
607
+ <blockquote data-format="Chicago">
608
+ Jefferson, Thomas. <i>Notes on the State of Virginia</i>. Edited by William Peden. Chapel Hill:
609
+ University of North Carolina Press, 1955.
610
+ </blockquote>
611
+ <blockquote data-format="Bluebook">
612
+ Thomas Jefferson, <i>Notes on the State of Virginia</i> (William Peden ed., Univ. of N.C. Press
613
+ 1955).
614
+ </blockquote>
615
+ </uvalib-citation>
616
+ ```
617
+
618
+ - **Formats as children.** Any element with `data-format` (a `<blockquote>` reads well without the script). Inline markup is kept (`<i>`/`<em>` for a title, `<b>`, `<span lang>`…, copied element by element with only `lang` and `dir`); anything else (links, images, scripts) is reduced to its text, and nothing is parsed as HTML. A second citation with the same name is ignored with a console warning. It follows changes to the children. Apps set the `citations` property instead, `[{ format, text, html? }]`, winning over the children while set: `text` is shown as text, `html` is parsed in an inert template and only its inline elements are kept, as above. Do not fetch citations into the element from a URL template: give it what your page or app already has.
619
+ - **Choosing a format.** A segmented radio group, "Citation format" (native radios: one tab stop, the arrow keys move and select, Space selects), inside a group named by `label` (default "Cite this item", shown in bold above it; `hide-label` keeps it for screen readers only, for a dialog whose heading already says it). The selected format is filled and ticked, never told by colour alone, and in forced colors it is `Highlight`. `format` names the selected one (case-insensitive; default the first) and reflects the visitor's choice; the element fires `uvalib-citation-format` (`detail: { format }`) when the visitor changes it. Why radios and not tabs: choosing a format is a single choice that changes one value (like the header's Light / Dark / System), not a set of panels to browse, so a radio group is the right pattern; tabs would also add a second tab stop and panel semantics for one region of text.
620
+ - **Remembering.** `remember` keeps the visitor's last format in `localStorage` (`uvalib-citation-format`; storage is per origin, so per site) and uses it on the next record that has that format, over `format`. Off by default, so a page shows what its author chose; where storage is blocked it simply is not remembered.
621
+ - **The citation.** Selectable text in a bordered box, a region named "MLA citation" (the selected format's name).
622
+ - **Copy citation.** A 44px `.uvalib-button`. It copies the citation as `text/plain` and, when it has inline markup, also as `text/html` (one `ClipboardItem`), so the italic title stays italic when pasted into a word processor; where HTML is not supported or refused it copies plain text. It then says "MLA citation copied" in a polite `role="status"` next to the button, in the text colour (AAA in light and dark), for five seconds: not a floating toast. If the clipboard is unavailable (permission denied, an insecure page), it selects the citation and says "Could not copy: the MLA citation is selected, copy it with your keyboard".
623
+ - **Exports.** `ris-href` adds a "Download RIS" link (`ris-label` changes its text) with a `download` attribute, styled like the button. Other export links go in the `actions` slot after it: `<a slot="actions" class="uvalib-button" href="…/u2297137.enw" download>EndNote</a>` (give them `.uvalib-button` and keep them 44px tall).
624
+ - **In a dialog.** It assumes nothing about where it sits: put it inline on a record page, or inside a dialog (with `hide-label` when the dialog's heading is "Cite this item").
625
+ - **No jump on upgrade.** With `base.css`, only the first citation shows before the script runs, boxed as it will be, and the label, the format bar and the Copy citation row are held, so nothing moves when it upgrades. The `citations` property cannot be held that way.
626
+ - **Colours and modes.** Dark mode follows the role tokens; it reflows at 320px (the format bar scrolls sideways if the names do not fit); `no-style` keeps only the structure (the 44px radios, the hidden label); light DOM styles are scoped to the tag in `@layer uvalib`.
627
+ - **Analytics.** `['uvalib-citation', 'format', '<format>']` once the visitor settles on a format (a second after the last change, nothing when they end where they started), `['uvalib-citation', 'copy', '<format>']` and `['uvalib-citation', 'download', 'ris']`. Never the citation.
628
+
561
629
  ## Images
562
630
 
563
631
  `<uvalib-lightbox>` opens a set of plain image links in a dialog. `<uvalib-photo-grid>` lays the thumbnails out in justified rows. Entries: `uvalib-lightbox.js` and `uvalib-photo-grid.js` on the CDN, `@uvalib/web-components/uvalib-lightbox.js` and `…/uvalib-photo-grid.js` on npm. Without JavaScript the links still open the image.
@@ -971,6 +1039,216 @@ An inline message for the page's own content: a search error, a notice that resu
971
1039
  - **Live regions:** use `role="alert"` only for an error that appears in response to what the visitor did (it interrupts); use `role="status"` for a notice or confirmation (polite). For a status to be announced reliably, put the empty `role="status"` container in the page first and fill it later, rather than inserting the whole element. A message that is there when the page loads needs no role. Do not put an alert role on a message that is always shown.
972
1040
  - **Forced colors:** every message keeps a system-colour border, thicker at the start. In the flow of the page it is a block with the content's own width, its first and last child without outer margins.
973
1041
 
1042
+ ## Tables
1043
+
1044
+ Data tables in the page's own content (holdings, schedules, statistics) in the library look: library.virginia.edu's W3.CSS tables (left-aligned cells padded 8px, the first column 16px from the edge, top-aligned, a light rule between rows), the same rules `<library-weekly-hours>` draws. The classes are in `base.css`. See the [Tables](https://uvalib.github.io/reusable-web-library/#tables) example.
1045
+
1046
+ ```html
1047
+ <!-- Holdings grouped by library: a heading per library, then its table. -->
1048
+ <h3>Clemons Library</h3>
1049
+ <table class="uvalib-table">
1050
+ <caption>
1051
+ Clemons Library holdings
1052
+ </caption>
1053
+ <thead>
1054
+ <tr>
1055
+ <th scope="col">Location</th>
1056
+ <th scope="col">Call number</th>
1057
+ <th scope="col">Barcode</th>
1058
+ </tr>
1059
+ </thead>
1060
+ <tbody>
1061
+ <tr>
1062
+ <td>Stacks</td>
1063
+ <td>PS3545 .O337 Z5 2004</td>
1064
+ <td>X004812345</td>
1065
+ </tr>
1066
+ </tbody>
1067
+ </table>
1068
+ <h3>Law Library</h3>
1069
+ <table class="uvalib-table">
1070
+ <caption>
1071
+ Law Library holdings
1072
+ </caption>
1073
+ <thead>
1074
+ <tr>
1075
+ <th scope="col">Location</th>
1076
+ <th scope="col">Call number</th>
1077
+ <th scope="col">Barcode</th>
1078
+ </tr>
1079
+ </thead>
1080
+ <tbody>
1081
+ <tr>
1082
+ <td>Law Library Stacks, Lower Level</td>
1083
+ <td>KF4550 .A2 1787a vol. 1–4 suppl.</td>
1084
+ <td>35000101234567890123456789</td>
1085
+ </tr>
1086
+ </tbody>
1087
+ </table>
1088
+
1089
+ <!-- A striped, compact schedule with a number column. -->
1090
+ <table class="uvalib-table uvalib-table--striped uvalib-table--compact">
1091
+ <caption>
1092
+ Study rooms this week
1093
+ </caption>
1094
+ <thead>
1095
+ <tr>
1096
+ <th scope="col">Day</th>
1097
+ <th scope="col">Hours</th>
1098
+ <th scope="col" class="uvalib-table__num">Rooms free</th>
1099
+ </tr>
1100
+ </thead>
1101
+ <tbody>
1102
+ <tr>
1103
+ <th scope="row">Monday</th>
1104
+ <td>8 a.m. – midnight</td>
1105
+ <td class="uvalib-table__num">12</td>
1106
+ </tr>
1107
+ <tr>
1108
+ <th scope="row">Tuesday</th>
1109
+ <td>8 a.m. – midnight</td>
1110
+ <td class="uvalib-table__num">7</td>
1111
+ </tr>
1112
+ </tbody>
1113
+ </table>
1114
+
1115
+ <!-- A wide table scrolls inside its own region, named by the caption. -->
1116
+ <div class="uvalib-table-scroll" role="region" tabindex="0" aria-labelledby="circ-caption">
1117
+ <table class="uvalib-table">
1118
+ <caption id="circ-caption">
1119
+ Items borrowed per month, 2025
1120
+ </caption>
1121
+ <thead>
1122
+ <tr>
1123
+ <th scope="col">Library</th>
1124
+ <th scope="col" class="uvalib-table__num">Jan</th>
1125
+ <th scope="col" class="uvalib-table__num">Feb</th>
1126
+ <!-- … -->
1127
+ </tr>
1128
+ </thead>
1129
+ <tbody>
1130
+ <tr>
1131
+ <th scope="row">Clemons Library</th>
1132
+ <td class="uvalib-table__num">4,210</td>
1133
+ <td class="uvalib-table__num">3,987</td>
1134
+ </tr>
1135
+ </tbody>
1136
+ </table>
1137
+ </div>
1138
+
1139
+ <!-- Opt-in: rows stack below 30em of the wrapper's width. Explicit roles are required. -->
1140
+ <div class="uvalib-table-stack">
1141
+ <table class="uvalib-table uvalib-table--stack" role="table">
1142
+ <caption>
1143
+ Clemons Library holdings
1144
+ </caption>
1145
+ <thead role="rowgroup">
1146
+ <tr role="row">
1147
+ <th scope="col" role="columnheader">Location</th>
1148
+ <th scope="col" role="columnheader">Call number</th>
1149
+ </tr>
1150
+ </thead>
1151
+ <tbody role="rowgroup">
1152
+ <tr role="row">
1153
+ <td role="cell" data-label="Location">Stacks</td>
1154
+ <td role="cell" data-label="Call number">PS3545 .O337 Z5 2004</td>
1155
+ </tr>
1156
+ </tbody>
1157
+ </table>
1158
+ </div>
1159
+ ```
1160
+
1161
+ - **`.uvalib-table`** on a `<table>`: full width, collapsed borders, bold left-aligned header cells, a 2px rule under the header row and a 1px rule between rows (`--uva-color-table-border`). Cells wrap long values anywhere, so a long barcode, call number or URL never pushes the table past a phone's width.
1162
+ - **Every table needs an accessible name:** a `<caption>` (drawn as a bold line above the table; keep it visible) or `aria-labelledby` pointing at a visible heading. Header cells are `<th>` with `scope="col"` or `scope="row"` (a row's first cell is often its header: a day, a library); use `<td>` for data. Do not use a table for layout, and do not leave empty header cells: give them visually hidden text.
1163
+ - **Modifiers:** `--striped` (every even body row on `--uva-color-table-stripe`; body text is 12.5:1 on it in light and 12.6:1 in dark, AAA), `--compact` (4px by 8px cells), and **`.uvalib-table__num`** on a `<th>` or `<td>` for numbers: right-aligned with tabular digits, so columns line up. Put it on the column's header too.
1164
+ - **Wide tables:** wrap the table in `<div class="uvalib-table-scroll" role="region" tabindex="0" aria-labelledby="CAPTION-ID">` (give the caption that id). The wrapper scrolls sideways inside itself, never the page; `tabindex="0"` lets keyboard users focus and scroll it (it shows the library focus ring), and the region is named by the caption. Inside it, cells break only words that cannot fit. This is the default for any table wider than a phone.
1165
+ - **Stacked rows (opt-in):** in a `.uvalib-table-stack` wrapper (a size container), `.uvalib-table--stack` turns each row into a block when the wrapper is 30em wide or narrower (480px at 16px; in a sidebar too), each cell headed by its `data-label` (drawn by CSS and hidden from screen readers, which hear the column header). Changing a table's display removes its table semantics in some browsers (Safari/WebKit), so **a stacked table must carry explicit roles**: `role="table"` on the table, `rowgroup` on `<thead>`/`<tbody>`, `row`, `columnheader` (and `rowheader` for a `<th scope="row">`) and `cell`. Prefer the scroll wrapper; stack only short tables whose rows read well as cards.
1166
+ - **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.
1167
+ - **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.
1168
+
1169
+ ## Sidebar layout
1170
+
1171
+ 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.
1172
+
1173
+ ```html
1174
+ <!-- A reading page: the contents first in the source, so they also come first when stacked. -->
1175
+ <div
1176
+ class="uvalib-sidebar-layout uvalib-sidebar-layout--sticky uvalib-sidebar-layout--print-hide-sidebar"
1177
+ >
1178
+ <uvalib-contents class="uvalib-sidebar-layout__sidebar">
1179
+ <ol>
1180
+ <li><a href="#preface">Preface</a></li>
1181
+ <li><a href="#part-1">Part I. The Key</a></li>
1182
+ </ol>
1183
+ </uvalib-contents>
1184
+ <article class="uvalib-sidebar-layout__main">
1185
+ <h2 id="preface">Preface</h2>
1186
+ …
1187
+ <uvalib-pager prev-href="…" prev-label="…" next-href="…" next-label="…"></uvalib-pager>
1188
+ </article>
1189
+ </div>
1190
+
1191
+ <!-- Related links on the right: the sidebar after the main content in the source. -->
1192
+ <div class="uvalib-sidebar-layout">
1193
+ <div class="uvalib-sidebar-layout__main">…</div>
1194
+ <aside class="uvalib-sidebar-layout__sidebar" aria-labelledby="related-heading">
1195
+ <h2 id="related-heading">Related</h2>
1196
+ …
1197
+ </aside>
1198
+ </div>
1199
+ ```
1200
+
1201
+ - **`.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.
1202
+ - **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.
1203
+ - **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.
1204
+ - **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.
1205
+ - **`--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.
1206
+ - **`<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.
1207
+ - **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).
1208
+ - **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.
1209
+
1210
+ ## Reading texts (edition.css)
1211
+
1212
+ `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`.
1213
+
1214
+ ```html
1215
+ <link rel="stylesheet" href="https://unpkg.internal.lib.virginia.edu/web-components/v1/base.css" />
1216
+ <link
1217
+ rel="stylesheet"
1218
+ href="https://unpkg.internal.lib.virginia.edu/web-components/v1/edition.css"
1219
+ />
1220
+ <script
1221
+ type="module"
1222
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-lightbox.js"
1223
+ ></script>
1224
+
1225
+ <uvalib-lightbox selector=".uvalib-edition a.pb-image"></uvalib-lightbox>
1226
+ <label class="uvalib-edition__lines"><input type="checkbox" /> Show original line breaks</label>
1227
+ <label class="uvalib-edition__readings"><input type="checkbox" /> Show original readings</label>
1228
+ <div class="uvalib-edition" lang="en">
1229
+ <section class="div div-letter">
1230
+ <span class="pb" data-n="1"><a class="pb-image" href="…/default.jpg">p. 1</a></span>
1231
+ <div class="opener">
1232
+ <div class="dateline">May 3, 1859</div>
1233
+ <div class="salute">My dear Sister,</div>
1234
+ </div>
1235
+ <p class="p">
1236
+ The lawn is <ins class="add">all</ins> in bloom. I walked <del class="del">yesterday</del>
1237
+ <br class="lb" />
1238
+ this morning to the <span class="orig" title="Regularized: weather">wether</span>…
1239
+ </p>
1240
+ </section>
1241
+ </div>
1242
+ ```
1243
+
1244
+ - **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`.
1245
+ - **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`.
1246
+ - **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.
1247
+ - **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.
1248
+ - **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.
1249
+ - **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.
1250
+ - **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).
1251
+
974
1252
  ## Back to top
975
1253
 
976
1254
  `<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.
@@ -1135,6 +1413,59 @@ The filter and the date range are controlled: set `value` (and `scopeValue`) fro
1135
1413
  </script>
1136
1414
  ```
1137
1415
 
1416
+ ### Filter groups
1417
+
1418
+ A search page's facets (Availability, Subject, Format, Date, Author…) can each be a filter group: `<uvalib-filter>` has six opt-in attributes for that, and without them it is exactly as before (same markup, order and events).
1419
+
1420
+ - `collapsible` turns the legend into a disclosure button (`aria-expanded`, `aria-controls`) with the library's caret, as in `<uvalib-contents>` and the main navigation (it flips at once, with no motion). Enter and Space toggle it. `collapsed` starts it closed and is reflected as the visitor toggles; nothing is remembered, so the page decides each time. While closed, the button shows how many values are selected ("Subject, 2 selected"), so a closed group never hides an active filter. Each toggle fires `toggle` with `{ open }`. `heading-level="2"` to `"6"` puts the legend's text (or button) in that heading for the page outline; by default there is none, as before. base.css holds a `collapsible collapsed` group at its 44px button until the script loads, so the page does not move.
1421
+ - `searchable` adds a search field above the values (labelled "Search Subject", or `search-label`) that narrows them as the visitor types: case- and accent-insensitive ("eco" finds "Écologie"), the matched text bold and underlined in a `<mark>`. A line under it says "12 of 340 subjects" (`unit="subjects"`; the default is "values"), also said politely once typing pauses. Checked values always stay in the list, pinned at the top, so a selection never disappears while filtering. While searching, every match is shown (no See more), up to 100 ("type more to narrow them"); clearing the search brings `limit` and See more back. Escape clears the search (and, while there is text, does not close a surrounding filter drawer). The field has no `name`, so it is never submitted with a form.
1422
+ - `sortable` adds "Sort by: Count | Name (A–Z)": two native radios drawn as a segmented control (one tab stop, arrow keys choose), the current sort filled and ticked on every group, so it is never left to colour or to an icon on some groups only. `sort="count"` (the default) is most results first, ties in the data's order; `sort="name"` is A–Z. Without `sortable` the data's own order is kept, unless you set `sort="name"`. The visitor's choice updates `sort` and fires `sort` with `{ sort }`.
1423
+ - `clearable` adds a 44px "Clear" button (named "Clear Subject filters"), shown only while something in the group is selected. It fires one `filter-change` with `{ name, value: [] }` and moves focus to the group's first checkbox.
1424
+ - `apply-button` stages checkbox changes until the visitor presses Apply, for searches that are slow to run (one search per Apply instead of one per checkbox). Changed rows say "not applied" in words, a polite status says "3 changes not applied yet", and the button reads "Apply 3 changes". Apply fires `filter-change` once with the new value; Reset goes back to the applied `value`. Setting a different `value` from the page drops staged changes (the same value, re-set after another group's search, keeps them). Clear acts at once.
1425
+ - `match="any"` or `match="all"` says under the legend how the group's values combine ("Matches any selected value" / "Matches all selected values"), and describes the group to assistive technology. It changes only the text; your search decides the logic. No text by default.
1426
+
1427
+ Analytics: `toggle` (1 open, 0 closed), `sort` (`Subject: name`), `clear` and `apply` with the number of values, and `search` with the number of matches once a search pauses, never the typed text; with `apply-button`, each value's `facet-change` is sent when Apply is pressed.
1428
+
1429
+ ```html
1430
+ <uvalib-filter
1431
+ id="subjects"
1432
+ collapsible
1433
+ heading-level="2"
1434
+ searchable
1435
+ sortable
1436
+ clearable
1437
+ match="any"
1438
+ unit="subjects"
1439
+ limit="5"
1440
+ ></uvalib-filter>
1441
+ <uvalib-filter id="formats" collapsible collapsed heading-level="2" apply-button></uvalib-filter>
1442
+ <script type="module">
1443
+ await customElements.whenDefined('uvalib-filter');
1444
+ const facet = (name, title, keys) => ({
1445
+ name,
1446
+ title,
1447
+ position: 0,
1448
+ buckets: keys.map(([key, doc_count]) => ({ key, doc_count, selected: false })),
1449
+ });
1450
+ const groups = {
1451
+ subjects: facet('subject', 'Subject', [
1452
+ ['History', 40],
1453
+ ['Écologie', 12],
1454
+ ]),
1455
+ formats: facet('format', 'Format', [
1456
+ ['Book', 120],
1457
+ ['Map', 18],
1458
+ ]),
1459
+ };
1460
+ for (const [id, filter] of Object.entries(groups)) {
1461
+ const el = document.getElementById(id);
1462
+ el.filter = filter;
1463
+ // Controlled: run the search, then set value from your search state.
1464
+ el.addEventListener('filter-change', (e) => (el.value = e.detail.value));
1465
+ }
1466
+ </script>
1467
+ ```
1468
+
1138
1469
  ## Combobox
1139
1470
 
1140
1471
  `<uvalib-combobox>` is a text field that suggests values as you type, from a local list or a URL: a person, place or subject picker. It follows the WAI-ARIA APG [editable combobox with list autocomplete](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-autocomplete-list/) and looks like `.uvalib-input`. Entry: `uvalib-combobox.js` on the CDN, `@uvalib/web-components/uvalib-combobox.js` on npm.
@@ -1199,6 +1530,61 @@ The filter and the date range are controlled: set `value` (and `scopeValue`) fro
1199
1530
  - **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.
1200
1531
  - **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.
1201
1532
 
1533
+ ## List filter
1534
+
1535
+ `<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.
1536
+
1537
+ ```html
1538
+ <script
1539
+ type="module"
1540
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-list-filter.js"
1541
+ ></script>
1542
+
1543
+ <uvalib-list-filter
1544
+ for="doc-list"
1545
+ noun="texts"
1546
+ singular="text"
1547
+ placeholder="Title or author"
1548
+ query-param
1549
+ ></uvalib-list-filter>
1550
+ <ol id="doc-list">
1551
+ <li data-filter-text="amanda c. armentrout to william f. brand, 1866 armentrout, amanda c">
1552
+ <a href="/text/A2956/">Amanda C. Armentrout to William F. Brand, August 17, 1866</a>
1553
+ <span>Armentrout, Amanda C · 1866</span>
1554
+ </li>
1555
+ <!-- … -->
1556
+ </ol>
1557
+ ```
1558
+
1559
+ - **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).
1560
+ - **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.
1561
+ - **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()`.
1562
+ - **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.
1563
+ ```html
1564
+ <uvalib-list-filter selector="#by-letter li" noun="people"></uvalib-list-filter>
1565
+ <div id="by-letter">
1566
+ <section data-filter-group>
1567
+ <h2>A</h2>
1568
+ <ul>
1569
+ <li>Ada Lovelace</li>
1570
+ </ul>
1571
+ </section>
1572
+ <section data-filter-group>
1573
+ <h2>B</h2>
1574
+ <ul>
1575
+ <li>Bruno Taut</li>
1576
+ </ul>
1577
+ </section>
1578
+ </div>
1579
+ ```
1580
+ - **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.
1581
+ - **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.
1582
+ - **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.
1583
+ - **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.
1584
+ - **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.
1585
+ - **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.
1586
+ - **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.
1587
+
1202
1588
  ## Filter drawer
1203
1589
 
1204
1590
  `<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.
@@ -1251,6 +1637,82 @@ The filter and the date range are controlled: set `value` (and `scopeValue`) fro
1251
1637
 
1252
1638
  - **Analytics.** `open` and `close` with the drawer's `label`, only when the visitor does it (not a resize or a script).
1253
1639
 
1640
+ ## Dialog
1641
+
1642
+ `<uvalib-dialog>` is a modal dialog for content and short forms: search tips, Cite, a sign-in prompt, a request form. It looks and behaves like the library's other dialogs (`<uvalib-lightbox>`, `<uvalib-filter-drawer>`): a native `<dialog>` opened with `showModal()`, a visible heading that names it, a 44px Close button, the same tokens, backdrop, dark mode and forced colors. Use it instead of a hand-built modal, a `role="dialog"` div or a framework's dialog (such as PrimeVue's). Entry: `uvalib-dialog.js` on the CDN, `@uvalib/web-components/uvalib-dialog.js` on npm. See the [Dialog](https://uvalib.github.io/reusable-web-library/#dialog) example.
1643
+
1644
+ ```html
1645
+ <script
1646
+ type="module"
1647
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-dialog.js"
1648
+ ></script>
1649
+
1650
+ <!-- A content dialog opened by a button anywhere in the page. -->
1651
+ <button type="button" class="uvalib-button" data-uvalib-dialog="search-tips">Search tips</button>
1652
+
1653
+ <uvalib-dialog id="search-tips" label="Search tips">
1654
+ <ul>
1655
+ <li>Put a phrase in quotes: <code>"board of visitors"</code>.</li>
1656
+ <li>Use <code>OR</code> for either word: <code>Jefferson OR Madison</code>.</li>
1657
+ </ul>
1658
+ <p>
1659
+ <a href="https://guides.lib.virginia.edu/" target="_blank" rel="noopener"
1660
+ >Research guides (opens in a new tab)</a
1661
+ >
1662
+ </p>
1663
+ </uvalib-dialog>
1664
+
1665
+ <!-- A form dialog: method="dialog" closes it with the button's value. -->
1666
+ <button type="button" class="uvalib-button" data-uvalib-dialog="email-cite">Email citation</button>
1667
+
1668
+ <uvalib-dialog id="email-cite" label="Email this citation" size="small">
1669
+ <form method="dialog">
1670
+ <div class="uvalib-message uvalib-message--error" role="alert" id="cite-errors" hidden></div>
1671
+ <label for="cite-email">Email <span class="uvalib-required">(required)</span></label>
1672
+ <input
1673
+ class="uvalib-input"
1674
+ id="cite-email"
1675
+ name="email"
1676
+ type="email"
1677
+ required
1678
+ autofocus
1679
+ aria-describedby="cite-email-help"
1680
+ />
1681
+ <span class="uvalib-help" id="cite-email-help">We send the citation to this address only.</span>
1682
+ <button class="uvalib-button" value="send">Send</button>
1683
+ <button class="uvalib-button uvalib-button--secondary" value="cancel" formnovalidate>
1684
+ Cancel
1685
+ </button>
1686
+ </form>
1687
+ </uvalib-dialog>
1688
+
1689
+ <script type="module">
1690
+ const dialog = document.querySelector('#email-cite');
1691
+ dialog.addEventListener('uvalib-dialog-close', (e) => {
1692
+ if (e.detail.returnValue === 'send') {
1693
+ /* send it */
1694
+ }
1695
+ });
1696
+ // From script (after a sign-in check, say): focus returns to what had focus.
1697
+ // dialog.show(); dialog.close('cancel');
1698
+ </script>
1699
+ ```
1700
+
1701
+ - **Opening.** A `<button type="button" data-uvalib-dialog="<id>">` anywhere in the document opens the dialog with that id: one delegated listener, so buttons a framework renders later work too (also inside another component's shadow root). Where the browser has invoker commands, `<button commandfor="<id>" command="--show-modal">` works too; the built-in `show-modal` command only applies to a real `<dialog>`, so a custom element needs the `--show-modal` custom command (`--close` closes it). Keep `data-uvalib-dialog` for browsers without invokers; no polyfill is needed. From script: `show()`, `close(returnValue?)`, or set `open` (it reflects, so `<uvalib-dialog open>` and a framework's `:open` binding work).
1702
+ - **Focus.** On open, focus moves to the content's `[autofocus]` element if there is one (a form dialog: put `autofocus` on the first field), else to the heading (`tabindex="-1"`), so a screen reader starts at the top and long content opens at its start (the APG's advice for content dialogs). On every close, whichever way (Close, Escape, the backdrop, Cancel, a form submit, `close()`, the element being removed), focus returns to the element that opened it; if that element is gone, to `return-focus` (a selector, or an element set as the property). Virgo's dialogs sent focus to the top of the page instead.
1703
+ - **Modal.** `showModal()` makes the rest of the page inert, `<site-page>`'s shadow header, skip link and alerts included: Tab and a screen reader's virtual cursor stay in the dialog with no trap script, and nothing else needs `inert` or `aria-hidden`.
1704
+ - **Dismissal.** Escape always closes it (if a control inside uses Escape itself, such as a combobox, it must stop the key while it handles it). A click on the backdrop closes it (`closedby="any"`; in Safari, which lacks `closedby`, the same check in script), but a press that starts inside and ends on the backdrop (selecting text, a drag) does not. `persistent` keeps the backdrop from closing it, for a form that would lose typed text; Escape and Close still work.
1705
+ - **Forms.** A `<form method="dialog">` (or a submitter with `formmethod="dialog"`) closes it on submit with the submitter's `value` as `returnValue`, after the browser's own validation; give Cancel `formnovalidate`. A `<button data-uvalib-dialog-close="cancel">` closes it without submitting. Other forms submit as usual (call `close()` yourself when done). `uvalib-dialog-close` has `detail.returnValue` and `detail.reason` (`close-button`, `button`, `escape`, `backdrop`, `form`, `api` or `removed`); `uvalib-dialog-open` has `detail.reason` (`button` or `api`).
1706
+ - **Required and help text.** Say "required" in words (`<span class="uvalib-required">(required)</span>` in the label, plus `required` on the field), never with colour or an asterisk alone. Help text is `.uvalib-help`, tied to its field with `aria-describedby`. Both are in `base.css` in the muted text colour, 7:1 or more in light and dark (WCAG AAA): Virgo's grey failed contrast.
1707
+ - **Errors.** Never only red outlines. On a failed submit, fill an error summary at the top of the form, `<div class="uvalib-message uvalib-message--error" role="alert">`, that starts with “Error:” and lists each problem as a link to its field; set `aria-invalid="true"` on each bad field and put its own message next to it, tied with `aria-describedby`. Then move focus to the first bad field. Clear it all when the field is fixed.
1708
+ - **Status messages.** A "Copied" or "Sent" confirmation inside the dialog is a `<div class="uvalib-message uvalib-message--success" role="status">` that is in the dialog from the start and filled when it happens (text 7:1 or more in light and dark), not a toast: Virgo's copy toast failed contrast and disappeared before it could be read. Keep focus where it was.
1709
+ - **Links.** A link that opens a new tab or window says so in its text (“(opens in a new tab)”); better, open it in the same tab.
1710
+ - **Sizes.** `size="small"` (30rem), `medium` (the default, 40rem) or `large` (60rem) at most; `--uvalib-dialog-width` sets another width. On phones it is the viewport less 16px on each side, never taller than the viewport less 32px; the content scrolls inside it and the heading and Close stay in view (320px reflow).
1711
+ - **Content stays yours.** In shadow DOM the children are slotted, never moved: ids, `getElementById`, the page's CSS and listeners, and framework-rendered content keep working (use the default shadow mode with Vue, React and the like). With `no-shadow-dom` they are moved into the dialog element, in the same document. `description` (or a `slot="description"` child) is shown under the heading and set as `aria-describedby`; use it only for a short sentence.
1712
+ - **Look.** It fades in (no motion with reduced motion); in forced colors it keeps a 2px system-colour edge. Style it with `::part(dialog)`, `header`, `heading`, `close`, `description` and `body`, and `:state(open)`.
1713
+ - **Before the script loads.** `base.css` hides `uvalib-dialog:not(:defined)`, so the content never shows in the page; once defined, a closed dialog renders nothing.
1714
+ - **Analytics.** `['uvalib-dialog', 'open', '<label>']` when a visitor's button opens it and `['uvalib-dialog', 'close', '<label>']` when the visitor closes it; nothing for `show()`, `close()` or `open` from script, and never the content or what was typed.
1715
+
1254
1716
  ## Results, badges and tags
1255
1717
 
1256
1718
  For search pages, Virgo-like result lists and digital collections: badges and labels, a toolbar above the results, a results count that screen readers hear, keyword lists, an empty state and loading placeholders. The classes are in `base.css` (no script); `<uvalib-tag-list>` and `<uvalib-results-count>` are elements with their own entries (`uvalib-tag-list.js`, `uvalib-results-count.js`; npm `@uvalib/web-components/uvalib-tag-list.js`, `…/uvalib-results-count.js`). See the [Results toolbar & badges](https://uvalib.github.io/reusable-web-library/#results-toolbar) example.
@@ -1564,14 +2026,16 @@ Static sites that search with [Pagefind](https://pagefind.app) (such as Electron
1564
2026
  merge-index='[{"bundlePath": "/pagefind/s1/"}, {"bundlePath": "/pagefind/s2/"}]'
1565
2027
  placeholder="Search all texts"
1566
2028
  show-sub-results
2029
+ filter-params="collection author"
1567
2030
  ></uvalib-pagefind-search>
1568
2031
  ```
1569
2032
 
1570
2033
  - **`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.
1571
2034
  - **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`).
1572
2035
  - **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]`.
2036
+ - **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.
1573
2037
  - **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.
1574
- - 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.
2038
+ - 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.
1575
2039
 
1576
2040
  ## Analytics
1577
2041
 
@@ -1637,55 +2101,59 @@ Static sites that search with [Pagefind](https://pagefind.app) (such as Electron
1637
2101
  - **`<site-page matomo-id="N">`** (and optional `matomo-url` and `matomo-downloads`) adds one `<site-analytics>` for that site and loads its code only then. Off by default. While that code loads, what the components report is kept and handed over, so an early bento search is not lost. If the page already has a `<site-analytics>` or `<uvalib-analytics>` (including the old v0.0.12 one), site-page adds none and that element does the recording.
1638
2102
  - **What the library's components send.** They only fire `uvalib-analytics-*` events, so nothing happens without an analytics element (the old v0.0.12 element records them too). Every event is `[category, action, name?, value?]`: the category is the component's tag, the action a fixed verb, the name a short label from the library's own chrome or data (never a URL, never typed text), the value a number. Each one follows a visitor's action or a real failure: nothing is sent on render, re-render, the initial state or a restored one (a filter value set by the app, a remembered colour scheme). Errors are sent once per element and kind of failure.
1639
2103
 
1640
- | Component | Action | Name | Value |
1641
- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
1642
- | `site-header` | `link-click` (a utility or site link) | the link's label | |
1643
- | `site-header` | `menu-open` (the phone Menu popover) | | |
1644
- | `site-header` | `skip-link`, `logo-click` | | |
1645
- | `site-header` | `color-scheme` | `light`, `dark` or `system` | |
1646
- | `site-main-nav` | `menu-open` (a group opens, not closes) | the group's label | |
1647
- | `site-main-nav` | `link-click` | `Group > Link` (a top-level link: its label) | |
1648
- | `site-footer` | `link-click` (not the pre-footer's) | `Column: Link`, e.g. `About: Staff directory`; `Contact us: Phone`, `Contact us: Email`; `Social: Facebook`, `Social: Instagram` | |
1649
- | `uvalib-breadcrumbs` | `link-click` | `level N` (never the label) | N, from 1 |
1650
- | `uvalib-card` | `card-click` | `single`, or the card's place in its grid (`1`, `2`, …); never the title or URL | that place, from 1, in a grid |
1651
- | `uvalib-pager` | `page-change` | `next`, `previous` or `number` (never the label or URL) | the page, for `number` only |
1652
- | `uvalib-pager` | `load-more` | (empty) | the next page |
1653
- | `uvalib-tabs` | `change` | the tab's label (capped at 100 characters; not a URL) | |
1654
- | `uvalib-contents` | `link-click` | `level N` (never the label or URL) | N, from 1 (the top level) |
1655
- | `uvalib-contents` | `toggle` (the narrow-screen disclosure) | `open` or `close` | |
1656
- | `uvalib-metadata` | `copy-citation` (downloads are left to Matomo's, or to `downloads="event"`) | | |
1657
- | `uvalib-metadata` | `show-all`, `show-fewer` (a long list's toggle) | `row N` (the row's place in the list; never its label or values) | |
1658
- | `uvalib-lightbox` | `open`, `next`, `previous`, `full-size` | `image N` (never the URL or the caption) | N, from 1 |
1659
- | `uvalib-lightbox` (versions) | `compare` | `switch`, `wipe` or `fade` (never a version's label or URL) | the version's place, from 1 |
1660
- | `uvalib-image-regions` | `select` (an outline clicked; nothing on hover or focus) | the list's `label` (never a region's label) | the region's number, from 1 |
1661
- | `uvalib-tag-list` | `tag-click` | `list N` (the list's place on the page), or with `track-label` the list's own fixed `label`; never the tag's text or URL | the tag's place, from 1 |
1662
- | `uvalib-tag-list` | `show-all`, `show-fewer` | `list N`, or with `track-label` the `label` | |
1663
- | `site-alerts` | a content impression, once per alert per page view: `trackContentImpression('Library alert', '<severity>: <title>')` | | |
1664
- | `site-alerts` | `dismiss`, `link-click` (a link in an alert's text) | `<severity>: <title>` | |
1665
- | `site-alerts` | `error` (the alerts script failed to load) | `alerts-script` | |
1666
- | `events-section` | `event-click` | the `category` id, or `all` | the event's position, from 1 |
1667
- | `events-section` | `error` | `events-load` | |
1668
- | `site-hours-section` | `link-click` | `See all hours` | |
1669
- | `site-hours-section`, `library-weekly-hours` | `error` | `hours-load` | |
1670
- | `library-weekly-hours` | `week-change` | `next` or `previous` | |
1671
- | `uvalib-chip-group` | `change` (single: 1 s after the last change, and only if it differs from where it started; multi: each toggle) | `<group label>: <chip label>` | the chip's count, when it has one |
1672
- | `uvalib-chip-group` | `select` (links mode) | the group's label (never the chip or its URL) | |
1673
- | `uvalib-combobox` | `select` (a suggestion chosen) | the field's label (never the typed text or the suggestion) | the suggestion's position, from 1 |
1674
- | `uvalib-combobox` | `clear` (the clear button, or Escape on a closed list) | the field's label | |
1675
- | `uvalib-combobox` | `error` (`src` failed to load) | `load` | |
1676
- | `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` | |
1677
- | `uvalib-back-to-top` | `click` | | |
1678
- | `uvalib-map` | `select` (a marker chosen: click, Enter or Space) | the map's label (never the place's name, coordinates or URL) | the place's position, from 1 |
1679
- | `uvalib-map` | `zoom` (1 s after the last zoom-button press) | the map's label | the zoom level |
1680
- | `uvalib-map` | `expand` (a group of places chosen: it zooms in or opens its ring) | the map's label | the number of places in the group |
1681
- | `uvalib-filter` | `facet-change` | `<filter title>: <value>` (the facet value as the search service returns it, such as a format, library or subject; cut at 100 characters) | 1 checked, 0 unchecked |
1682
- | `uvalib-filter` | `scope-change` | the scope's label | 1 pressed, 0 not |
1683
- | `uvalib-filter` | `see-more`, `see-less` | the filter's title | |
1684
- | `uvalib-date-range` | `range-change` (1 s after the last change, and only if the years differ) | `<from year>–<to year>` | |
1685
- | `uvalib-date-histogram` | `select` (not when the selection is cleared, set in script, or restored from a date range) | `<from>–<to>` when both ends are ISO dates, otherwise `other` | |
1686
- | `bento-box` | `result-click` | the section (`Virgo catalog`, `Virgo articles`, `Subject guides`, `Library website`) | the result's position, from 1 |
1687
- | `bento-box` | `see-all-click`, `retry` | the section | |
1688
- | `bento-box` | `error` | `section-load: <section>` | |
2104
+ | Component | Action | Name | Value |
2105
+ | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
2106
+ | `site-header` | `link-click` (a utility or site link) | the link's label | |
2107
+ | `site-header` | `menu-open` (the phone Menu popover) | | |
2108
+ | `site-header` | `skip-link`, `logo-click` | | |
2109
+ | `site-header` | `color-scheme` | `light`, `dark` or `system` | |
2110
+ | `site-main-nav` | `menu-open` (a group opens, not closes) | the group's label | |
2111
+ | `site-main-nav` | `link-click` | `Group > Link` (a top-level link: its label) | |
2112
+ | `site-footer` | `link-click` (not the pre-footer's) | `Column: Link`, e.g. `About: Staff directory`; `Contact us: Phone`, `Contact us: Email`; `Social: Facebook`, `Social: Instagram` | |
2113
+ | `uvalib-breadcrumbs` | `link-click` | `level N` (never the label) | N, from 1 |
2114
+ | `uvalib-card` | `card-click` | `single`, or the card's place in its grid (`1`, `2`, …); never the title or URL | that place, from 1, in a grid |
2115
+ | `uvalib-pager` | `page-change` | `next`, `previous` or `number` (never the label or URL) | the page, for `number` only |
2116
+ | `uvalib-pager` | `load-more` | (empty) | the next page |
2117
+ | `uvalib-tabs` | `change` | the tab's label (capped at 100 characters; not a URL) | |
2118
+ | `uvalib-contents` | `link-click` | `level N` (never the label or URL) | N, from 1 (the top level) |
2119
+ | `uvalib-contents` | `toggle` (the narrow-screen disclosure) | `open` or `close` | |
2120
+ | `uvalib-metadata` | `copy-citation` (downloads are left to Matomo's, or to `downloads="event"`) | | |
2121
+ | `uvalib-metadata` | `show-all`, `show-fewer` (a long list's toggle) | `row N` (the row's place in the list; never its label or values) | |
2122
+ | `uvalib-citation` | `format` (once the visitor settles on one), `copy`, `download` (the RIS link) | the format's name (`MLA`, `APA`…), or `ris` for `download`; never the citation | |
2123
+ | `uvalib-lightbox` | `open`, `next`, `previous`, `full-size` | `image N` (never the URL or the caption) | N, from 1 |
2124
+ | `uvalib-lightbox` (versions) | `compare` | `switch`, `wipe` or `fade` (never a version's label or URL) | the version's place, from 1 |
2125
+ | `uvalib-image-regions` | `select` (an outline clicked; nothing on hover or focus) | the list's `label` (never a region's label) | the region's number, from 1 |
2126
+ | `uvalib-tag-list` | `tag-click` | `list N` (the list's place on the page), or with `track-label` the list's own fixed `label`; never the tag's text or URL | the tag's place, from 1 |
2127
+ | `uvalib-tag-list` | `show-all`, `show-fewer` | `list N`, or with `track-label` the `label` | |
2128
+ | `site-alerts` | a content impression, once per alert per page view: `trackContentImpression('Library alert', '<severity>: <title>')` | | |
2129
+ | `site-alerts` | `dismiss`, `link-click` (a link in an alert's text) | `<severity>: <title>` | |
2130
+ | `site-alerts` | `error` (the alerts script failed to load) | `alerts-script` | |
2131
+ | `events-section` | `event-click` | the `category` id, or `all` | the event's position, from 1 |
2132
+ | `events-section` | `error` | `events-load` | |
2133
+ | `site-hours-section` | `link-click` | `See all hours` | |
2134
+ | `site-hours-section`, `library-weekly-hours` | `error` | `hours-load` | |
2135
+ | `library-weekly-hours` | `week-change` | `next` or `previous` | |
2136
+ | `uvalib-chip-group` | `change` (single: 1 s after the last change, and only if it differs from where it started; multi: each toggle) | `<group label>: <chip label>` | the chip's count, when it has one |
2137
+ | `uvalib-chip-group` | `select` (links mode) | the group's label (never the chip or its URL) | |
2138
+ | `uvalib-combobox` | `select` (a suggestion chosen) | the field's label (never the typed text or the suggestion) | the suggestion's position, from 1 |
2139
+ | `uvalib-combobox` | `clear` (the clear button, or Escape on a closed list) | the field's label | |
2140
+ | `uvalib-combobox` | `error` (`src` failed to load) | `load` | |
2141
+ | `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 |
2142
+ | `uvalib-list-filter` | `clear` (the clear button, Escape, or the field emptied by typing) | | |
2143
+ | `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` | |
2144
+ | `uvalib-back-to-top` | `click` | | |
2145
+ | `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) |
2146
+ | `uvalib-map` | `select` (a marker chosen: click, Enter or Space) | the map's label (never the place's name, coordinates or URL) | the place's position, from 1 |
2147
+ | `uvalib-map` | `zoom` (1 s after the last zoom-button press) | the map's label | the zoom level |
2148
+ | `uvalib-map` | `expand` (a group of places chosen: it zooms in or opens its ring) | the map's label | the number of places in the group |
2149
+ | `uvalib-filter` | `facet-change` | `<filter title>: <value>` (the facet value as the search service returns it, such as a format, library or subject; cut at 100 characters) | 1 checked, 0 unchecked |
2150
+ | `uvalib-filter` | `scope-change` | the scope's label | 1 pressed, 0 not |
2151
+ | `uvalib-filter` | `see-more`, `see-less` | the filter's title | |
2152
+ | `uvalib-date-range` | `range-change` (1 s after the last change, and only if the years differ) | `<from year>–<to year>` | |
2153
+ | `uvalib-date-histogram` | `select` (not when the selection is cleared, set in script, or restored from a date range) | `<from>–<to>` when both ends are ISO dates, otherwise `other` | |
2154
+ | `bento-box` | `result-click` | the section (`Virgo catalog`, `Virgo articles`, `Subject guides`, `Library website`) | the result's position, from 1 |
2155
+ | `bento-box` | `see-all-click`, `retry` | the section | |
2156
+ | `bento-box` | `error` | `section-load: <section>` | |
1689
2157
 
1690
2158
  `<bento-box>` also sends a Matomo site search per section once its results are in (not on an error, not again on a re-render): the query, the section as category, and the section's total (0 when nothing was found). A new query, also by Back or Forward, is a new search. The `<library-weekly-hours>` elements `<library-hours-setup>` creates report as `library-weekly-hours`. Alert severities are `Critical`, `Warning`, `Information`, `Header` or `Regional warning` / `Regional information`. Names are capped at 100 characters. `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing.
1691
2159
 
@@ -2474,6 +2942,49 @@ A row of chips: a segmented control or single-select filter (`mode="single"`), f
2474
2942
  | `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
2475
2943
  | `--uva-color-surface` | | Dark-mode role token: the page background the scrolling row fades into at an edge with more chips (else #fff). |
2476
2944
 
2945
+ ### `<uvalib-citation>`
2946
+
2947
+ One record's citation in several formats (MLA, APA, Chicago, Bluebook…), a radio group to choose one, and a Copy citation button, as in Virgo's Cite dialog. Inline on a record page or inside a dialog: it assumes nothing about where it sits. Give each format as a child, `<blockquote data-format="MLA">…</blockquote>` (any element with `data-format`), so the page reads the same before the script loads (with `base.css`, only the first shows then, and the chooser's and button's space is held). Inline markup in a citation (`<i>` or `<em>` for a title) is kept; other elements are reduced to their text and nothing is parsed as HTML. Apps set the `citations` property instead (`[{ format, text, html? }]`, winning over the children while set); `html` keeps only inline elements, too. The formats are native radios drawn as one segmented bar (`role="radiogroup"`, "Citation format"): one tab stop, the arrow keys move and select, and the selected one is filled and ticked. `format` names the selected one (default the first). With `remember`, the visitor's last choice is kept in localStorage (per site) and wins over `format` on their next record. The selected citation is shown as selectable text in a region named "<format> citation". Copy citation copies it as plain text and as HTML where the browser allows (so an italic title stays italic when pasted into a word processor) and says "MLA citation copied" in a polite status next to the button, in the text colour (AAA), not in a toast. If the clipboard is unavailable, the citation is selected and the status says to copy it with the keyboard. `ris-href` adds a "Download RIS" link (`ris-label`) with a `download` attribute. Other export links go in the `actions` slot (`<a slot="actions" href="…" download>EndNote</a>`), after it.
2948
+
2949
+ #### Attributes
2950
+
2951
+ | Attribute | Type | Default | Description |
2952
+ |---|---|---|---|
2953
+ | `label` | `string` | `'Cite this item'` | The group's visible label and accessible name. |
2954
+ | `hide-label` | `boolean` | `false` | Hide the label visually (it still names the group), for a dialog whose heading says it. |
2955
+ | `format` | `string` | `''` | The selected format's name (default the first). Reflected when the visitor chooses one. |
2956
+ | `remember` | `boolean` | `false` | Keep the visitor's last format in localStorage (per site), winning over `format`. |
2957
+ | `ris-href` | `string` | `''` | A RIS file for the record: adds a download link. |
2958
+ | `ris-label` | `string` | `'Download RIS'` | The RIS link's text. |
2959
+ | `no-shadow-dom` | `boolean` | `false` | |
2960
+ | `no-style` | `boolean` | `false` | |
2961
+
2962
+ #### Slots
2963
+
2964
+ | Slot | Description |
2965
+ |---|---|
2966
+ | `actions` | More export links or buttons, after Copy citation and Download RIS. |
2967
+
2968
+ #### Events
2969
+
2970
+ | Event | Description |
2971
+ |---|---|
2972
+ | `uvalib-citation-format` | The visitor chose another format: `detail` is `{ format }`. Not fired when the app sets `format`. Bubbles and is composed. |
2973
+ | `uvalib-analytics-event` | For `<site-analytics>`, on the visitor's actions only: `['uvalib-citation', 'format', '<format>']` (once the visitor settles on one, a second after the last change), `['uvalib-citation', 'copy', '<format>']` and `['uvalib-citation', 'download', 'ris']`. Never the citation. Bubbles and is composed. |
2974
+
2975
+ #### CSS custom properties
2976
+
2977
+ | Property | Default | Description |
2978
+ |---|---|---|
2979
+ | `--uva-color-text` | | Dark-mode role token: label, citation and status colour (else `--uva-grey-darkest`). |
2980
+ | `--uva-color-border` | | Dark-mode role token: the citation's border (else #dadada). |
2981
+ | `--uva-color-surface-raised` | | Dark-mode role token: the citation's, segments' and buttons' background (else #fff). |
2982
+ | `--uva-color-control-border` | | Dark-mode role token: segment border (else `--uva-grey`, #808080). |
2983
+ | `--uva-color-link` | | Dark-mode role token: segment and button text, button border (else `--uva-brand-blue`). |
2984
+ | `--uva-color-accent-bg` | | Dark-mode role token: the selected segment (else `--uva-brand-blue`). |
2985
+ | `--uva-color-on-accent` | | Dark-mode role token: the selected segment's text (else #fff). |
2986
+ | `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
2987
+
2477
2988
  ### `<uvalib-combobox>`
2478
2989
 
2479
2990
  An editable text field that suggests values as you type, from a local list or a URL: a person, place or subject picker. It follows the WAI-ARIA APG “Editable Combobox With List Autocomplete”: a real `<input role="combobox">` and a `role="listbox"` popup under it. Suggestions come from the `items` property (`{ value, label?, description?, disabled? }` objects, or strings), from `<option>` children (directly or inside a `<datalist>`; the `label` attribute or text is the label, `data-description` the second line), or from `src`, a URL template with `{q}` (fetched 250 ms after the last keystroke once the text has `min-length` characters, default 1; a newer keystroke aborts the older request; the response is a JSON array of the same shape, or anything `transform(data, query)` turns into one). `items` wins over the children while set. Local suggestions match anywhere in the label, ignoring case and accents, those starting with the text first, then those with a word starting with it; at most `max-results` (default 50, 0 for all) are shown, which keeps a list of 16,000 people fast. The matched text is bold and underlined in a `<mark>`. Keys: Down opens the list on the first suggestion and moves (wrapping), Up opens on the last, Alt+Down opens without moving, Alt+Up closes, Enter chooses the active suggestion (and then does not submit the form; with none active, Enter submits as in any field), Escape closes the list and a second Escape clears the field, Home, End, Left and Right move the caret, and Tab leaves without choosing. A real clear button (“Clear <label>”, 44px, shown only with text) empties the field and returns focus to it. Free text is allowed: `value` is whatever is in the field, and `selected` the chosen suggestion (or null); typing after choosing clears it, and leaving the field with text that is exactly one suggestion's label chooses it. `must-choose` makes any other text invalid (“Choose one of the suggestions.”). The element is form-associated: with `name` it submits the chosen suggestion's value, or else the text, and a form reset restores the `value` attribute. `required` and `disabled` (also from a disabled fieldset) work as on an input. A polite status says “5 suggestions”, “50 of 1,234 suggestions”, “No suggestions”, “Loading suggestions” or “Couldn't load suggestions” half a second after the list settles (never on the first render); the popup shows the same notes visibly. A failed load never throws. Where the browser supports the Popover API and CSS anchor positioning, the popup is a manual popover in the top layer, anchored under the field and as wide as it (above it when there is no room below), so an ancestor with `overflow: hidden` or a scrolling panel never clips it. Elsewhere it is positioned under the field inside the element, as before. Pages can style the runtime state with `:state(open)`, `:state(invalid)` and `:state(loading)` (no attributes are added). Before it upgrades, `base.css` shows the label (from the attribute) and holds the field's height. A fallback `<input list>` child works as a plain field meanwhile; on upgrade its text, `name` and `placeholder` carry over, and it is disabled so it does not submit twice.
@@ -2683,9 +3194,73 @@ A date-range picker: a two-thumb year slider plus "From" and "To" date inputs. `
2683
3194
  | `--uva-color-control-border` | | Dark-mode role token: date input border (else `--uva-grey`, #808080). |
2684
3195
  | `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
2685
3196
 
3197
+ ### `<uvalib-dialog>`
3198
+
3199
+ A modal dialog for content and short forms: search tips, Cite, a sign-in prompt, a request form. Use it instead of a hand-built modal, a `role="dialog"` div or a framework's dialog. The children are the content. In shadow DOM they are slotted, never moved, so the page's CSS, ids, listeners and framework-rendered nodes keep working; with `no-shadow-dom` they are moved into the dialog (the same nodes, in the same document). It opens as a native `<dialog>` with `showModal()`: everything else on the page, `<site-page>`'s shadow header included, is inert while it is open, so focus stays inside without a trap script. The visible heading (`label`, an `<h2>` unless `heading-level` says otherwise) names it, and a 44px Close button is always shown; `description` (or a `slot="description"` child) is shown under the heading and is the dialog's description. Open it with a button anywhere in the page, `<button type="button" data-uvalib-dialog="<id>">` (one delegated listener, so buttons rendered later work too), with an invoker button (`commandfor="<id>" command="--show-modal"`) where the browser has invoker commands, with `show()`, or by setting `open`. On open, focus goes to the content's `[autofocus]` element when it has one (a form dialog: the first field), else to the heading, so a screen reader reads the dialog from the top and long content starts in view. On every close (Close, Escape, the backdrop, a `data-uvalib-dialog-close` button, a `<form method="dialog">` submitted, `close()`) focus returns to the element that opened it; if that is gone, to `return-focus` (a selector, or an element set as the property). Escape always closes it. A click on the backdrop closes it too (the native `closedby="any"`, or the same check in script where the browser lacks it), except with `persistent`, and never when a press starts inside the dialog and ends on the backdrop (a text selection or a drag). A `<form method="dialog">` in the content closes it on submit with the submitter's `value` as `returnValue`; other forms submit as usual. `size` is `small` (30rem), `medium` (the default, 40rem) or `large` (60rem) at most, and never wider or taller than the viewport less 16px on each side; the content scrolls inside it under a header that stays in view.
3200
+
3201
+ #### Attributes
3202
+
3203
+ | Attribute | Type | Default | Description |
3204
+ |---|---|---|---|
3205
+ | `label` | `string` | `''` | The visible heading and the dialog's accessible name. |
3206
+ | `heading-level` | `number` | `2` | The heading's level, 1 to 6 (default 2). |
3207
+ | `description` | `string` | `''` | A short description under the heading (or a `slot="description"` child), read as the dialog's description. |
3208
+ | `size` | `'small' \| 'medium' \| 'large'` | `'medium'` | The widest the dialog gets: `small` (30rem), `medium` (40rem) or `large` (60rem). |
3209
+ | `open` | `boolean` | `false` | Whether it is open. Reflected; setting it opens or closes the dialog (as `show()` and `close()`). |
3210
+ | `persistent` | `boolean` | `false` | A click on the backdrop does not close it (Escape and Close still do). For forms that would lose typed text. |
3211
+ | `return-focus` | `string \| HTMLElement \| null` | `null` | Where focus goes on close when the opener is gone: a selector (in the dialog's root, then the document) or an element. |
3212
+ | `close-label` | `string` | `'Close'` | The Close button's text. |
3213
+ | `no-shadow-dom` | `boolean` | `false` | |
3214
+ | `no-style` | `boolean` | `false` | |
3215
+
3216
+ #### Slots
3217
+
3218
+ | Slot | Description |
3219
+ |---|---|
3220
+ | (default) | The content: text, links, a form. |
3221
+ | `description` | A short description under the heading, read as the dialog's description (instead of the `description` attribute). |
3222
+
3223
+ #### CSS parts
3224
+
3225
+ | Part | Description |
3226
+ |---|---|
3227
+ | `dialog` | The `<dialog>`. |
3228
+ | `header` | The heading row (the heading and Close). |
3229
+ | `heading` | The heading. |
3230
+ | `close` | The Close button. |
3231
+ | `description` | The description under the heading. |
3232
+ | `body` | The scrolling wrapper of the content. |
3233
+
3234
+ #### CSS states
3235
+
3236
+ | State | Description |
3237
+ |---|---|
3238
+ | `:state(open)` | The dialog is open. |
3239
+
3240
+ #### Events
3241
+
3242
+ | Event | Description |
3243
+ |---|---|
3244
+ | `uvalib-dialog-open` | The dialog opened: `detail` is `{ reason }`, `button` (a visitor's opener) or `api` (`show()` or `open`). Bubbles and is composed. |
3245
+ | `uvalib-dialog-close` | The dialog closed: `detail` is `{ reason, returnValue }`, `reason` one of `close-button`, `button` (a `data-uvalib-dialog-close` or invoker close button), `escape`, `backdrop`, `form` (a `<form method="dialog">`), `api` (`close()` or `open = false`) or `removed` (taken out of the page while open). Bubbles and is composed. |
3246
+ | `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-dialog', 'open', '<label>']` when a visitor's button opens it, and `['uvalib-dialog', 'close', '<label>']` when the visitor closes it (Close, a close button, Escape, the backdrop or a dialog form); never on `show()`, `close()` or `open` from script, and never the content. Bubbles and is composed. |
3247
+
3248
+ #### CSS custom properties
3249
+
3250
+ | Property | Default | Description |
3251
+ |---|---|---|
3252
+ | `--uvalib-dialog-width` | | The dialog's widest inline size, instead of `size`'s (still never wider than the viewport less 16px on each side). |
3253
+ | `--uva-color-surface` | | Dark-mode role token: dialog background (else #fff). |
3254
+ | `--uva-color-text` | | Dark-mode role token: dialog text (else `--uva-grey-darkest`, #2b2b2b). |
3255
+ | `--uva-color-text-muted` | | Dark-mode role token: the description (else #4b5563, 7.5:1 on white). |
3256
+ | `--uva-color-border` | | Dark-mode role token: dialog edge and heading rule (else #dadada). |
3257
+ | `--uva-color-button-bg` | | Dark-mode role token: Close's border and text (else `--uva-blue-alt`, #007bac). |
3258
+ | `--uva-color-button-hover-bg` | | Dark-mode role token: hovered Close (else `--uva-blue-alt-A`, #005679). |
3259
+ | `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
3260
+
2686
3261
  ### `<uvalib-filter>`
2687
3262
 
2688
- A faceted-search filter: a fieldset of checkboxes (value plus result count), optional toggle chips ("scopes") above them, and "See more" / "See less" buttons when `limit` is set. It is controlled: set `filter`, `value` and `scopeValue` from your search state and listen for the change events.
3263
+ A faceted-search filter: a fieldset of checkboxes (value plus result count), optional toggle chips ("scopes") above them, and "See more" / "See less" buttons when `limit` is set. It is controlled: set `filter`, `value` and `scopeValue` from your search state and listen for the change events. Optional filter-group features, each off by default (without them the markup, events and order are as before): `collapsible` (a caret disclosure button in the legend, with the selected count while collapsed), `searchable` (search within the values), `sortable` (Count \| Name (A–Z)), `clearable` (a Clear button), `apply-button` (stage changes until Apply) and `match` (says how the values combine).
2689
3264
 
2690
3265
  #### Attributes
2691
3266
 
@@ -2697,6 +3272,17 @@ A faceted-search filter: a fieldset of checkboxes (value plus result count), opt
2697
3272
  | `scopevalue` | `string[]` | `[]` | Pressed scope values (matched case-insensitively). |
2698
3273
  | `scopes-label` | `string` | `''` | Accessible name of the scope chip group. Empty (the default) means `Filter <title> by type`. |
2699
3274
  | `limit` | `number` | `0` | Maximum buckets to show at first; 0 shows all. "See more" doubles it, "See less" halves it back. |
3275
+ | `collapsible` | `boolean` | `false` | The legend becomes a disclosure button (with the library's caret) that shows and hides the group. |
3276
+ | `collapsed` | `boolean` | `false` | With `collapsible`: the group is closed (its legend button and selected count only). The visitor's toggle updates it; nothing is remembered. |
3277
+ | `heading-level` | `number` | `0` | Wrap the legend's text (or disclosure button) in a heading of this level, 2 to 6. Unset (the default): no heading, as before. |
3278
+ | `searchable` | `boolean` | `false` | A search field above the values that narrows them as the visitor types. |
3279
+ | `search-label` | `string` | `''` | The search field's visible label. Empty (the default) means `Search <title>`. |
3280
+ | `unit` | `string` | `'values'` | What the values are, plural, for the search status ("12 of 340 subjects"). |
3281
+ | `sortable` | `boolean` | `false` | A "Sort by: Count \| Name (A–Z)" control. |
3282
+ | `sort` | `'count' \| 'name'` | `'count'` | The order: `count` (most results first; without `sortable`, the data's own order) or `name` (A–Z). The visitor's choice updates it. |
3283
+ | `clearable` | `boolean` | `false` | A Clear button, shown while something in the group is selected. |
3284
+ | `apply-button` | `boolean` | `false` | Stage checkbox changes until the visitor presses Apply (with Reset back to the applied state); `filter-change` fires on Apply only. |
3285
+ | `match` | `'any' \| 'all' \| undefined` | | Say how the selected values combine, under the legend: `any` ("Matches any selected value") or `all`. Unset: no text. |
2700
3286
  | `no-shadow-dom` | `boolean` | `false` | |
2701
3287
  | `no-style` | `boolean` | `false` | |
2702
3288
 
@@ -2706,14 +3292,21 @@ A faceted-search filter: a fieldset of checkboxes (value plus result count), opt
2706
3292
  |---|---|
2707
3293
  | `see-more` | The "See more" button (shadow mode). |
2708
3294
  | `see-less` | The "See less" button (shadow mode). |
3295
+ | `toggle` | The disclosure button in the legend (`collapsible`). |
3296
+ | `search` | The search-within field (`searchable`). |
3297
+ | `clear` | The Clear button (`clearable`). |
3298
+ | `apply` | The Apply button (`apply-button`). |
3299
+ | `reset` | The Reset button (`apply-button`). |
2709
3300
 
2710
3301
  #### Events
2711
3302
 
2712
3303
  | Event | Description |
2713
3304
  |---|---|
2714
- | `filter-change` | A checkbox was toggled. `detail` is `{ name, value }`: the facet name and the new array of selected keys. Does not bubble. |
3305
+ | `filter-change` | A checkbox was toggled, Clear was pressed, or (with `apply-button`) Apply was pressed. `detail` is `{ name, value }`: the facet name and the new array of selected keys (`[]` after Clear). Does not bubble. |
2715
3306
  | `scope-change` | A scope chip was toggled. `detail` is `{ value }`: the new array of pressed scope values. Does not bubble. |
2716
- | `uvalib-analytics-event` | For `<site-analytics>`, on the visitor's changes only: `['uvalib-filter', 'facet-change', '<title>: <value>', 1 \| 0]` (checked or unchecked), `['uvalib-filter', 'scope-change', <scope label>, 1 \| 0]` (pressed or not), and `['uvalib-filter', 'see-more' \| 'see-less', <title>]`. Bubbles and is composed. |
3307
+ | `toggle` | With `collapsible`: the visitor opened or closed the group. `detail` is `{ open }`. Does not bubble. |
3308
+ | `sort` | With `sortable`: the visitor chose a sort. `detail` is `{ sort }` (`count` or `name`). Does not bubble. |
3309
+ | `uvalib-analytics-event` | For `<site-analytics>`, on the visitor's changes only: `['uvalib-filter', 'facet-change', '<title>: <value>', 1 \| 0]` (checked or unchecked; with `apply-button`, one per value when Apply is pressed), `['uvalib-filter', 'scope-change', <scope label>, 1 \| 0]` (pressed or not), `['uvalib-filter', 'see-more' \| 'see-less', <title>]`, `['uvalib-filter', 'toggle', <title>, 1 \| 0]` (opened or closed), `['uvalib-filter', 'sort', '<title>: count' \| '<title>: name']`, `['uvalib-filter', 'clear', <title>, <number cleared>]`, `['uvalib-filter', 'apply', <title>, <number of changes>]` and `['uvalib-filter', 'search', <title>, <number of matches>]` once a search-within settles (never the typed text). Bubbles and is composed. |
2717
3310
 
2718
3311
  #### CSS custom properties
2719
3312
 
@@ -2722,11 +3315,13 @@ A faceted-search filter: a fieldset of checkboxes (value plus result count), opt
2722
3315
  | `--uva-brand-blue` | `#232d4b` | Scope chip text, hover border and pressed background. |
2723
3316
  | `--uva-brand-orange` | `#e57200` | Focus ring colour (focus-visible outline). |
2724
3317
  | `--uva-color-border` | | Dark-mode role token: divider under the scope chips (else #e5e7eb). |
2725
- | `--uva-color-control-border` | | Dark-mode role token: scope chip border (else `--uva-grey`, #808080). |
2726
- | `--uva-color-surface-raised` | | Dark-mode role token: scope chip background (else #fff). |
2727
- | `--uva-color-link` | | Dark-mode role token: scope chip text and hover border (else `--uva-brand-blue`). |
2728
- | `--uva-color-accent-bg` | | Dark-mode role token: pressed chip background and border (else `--uva-brand-blue`). |
2729
- | `--uva-color-on-accent` | | Dark-mode role token: pressed chip text (else #fff). |
3318
+ | `--uva-color-control-border` | | Dark-mode role token: scope chip, search field, sort and button borders (else `--uva-grey`, #808080). |
3319
+ | `--uva-color-surface-raised` | | Dark-mode role token: scope chip, search field, sort and button background (else #fff). |
3320
+ | `--uva-color-link` | | Dark-mode role token: scope chip and button text, the caret, hover border (else `--uva-brand-blue`). |
3321
+ | `--uva-color-accent-bg` | | Dark-mode role token: pressed chip, current sort and Apply background (else `--uva-brand-blue`). |
3322
+ | `--uva-color-on-accent` | | Dark-mode role token: pressed chip, current sort and Apply text (else #fff). |
3323
+ | `--uva-color-text-muted` | | Dark-mode role token: the match text, selected count, search status and staged note (else #4f4f4f). |
3324
+ | `--uva-color-input-text` | | Dark-mode role token: search field text (else #1f2937). |
2730
3325
  | `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
2731
3326
 
2732
3327
  ### `<uvalib-filter-drawer>`
@@ -2920,6 +3515,57 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
2920
3515
  | `--uva-grey-darkest` | `#2b2b2b` | Text when `--uva-color-text` is unset. |
2921
3516
  | `--uva-grey-100` | `#dadada` | Border when `--uva-color-border` is unset. |
2922
3517
 
3518
+ ### `<uvalib-list-filter>`
3519
+
3520
+ 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.
3521
+
3522
+ #### Attributes
3523
+
3524
+ | Attribute | Type | Default | Description |
3525
+ |---|---|---|---|
3526
+ | `for` | `string` | `''` | The id of the list whose children are the items (for a table, its body rows). |
3527
+ | `selector` | `string` | `''` | A CSS selector for the items, inside `for` when it is set, else in the page. |
3528
+ | `label` | `string` | `'Filter'` | The field's visible label and accessible name. |
3529
+ | `hide-label` | `boolean` | `false` | Hide the label visually (it still names the field), when a heading beside it says it. |
3530
+ | `placeholder` | `string` | `''` | Placeholder text in the empty field, such as “Title or author”. |
3531
+ | `noun` | `string` | `'items'` | What the items are, plural: “items” by default. |
3532
+ | `singular` | `string` | `''` | What one item is. Default: “item” when `noun` is unset, else `noun`. |
3533
+ | `results-count` | `string` | `''` | The id of a `<uvalib-results-count>` to drive instead of the element's own count. |
3534
+ | `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. |
3535
+ | `value` | `string` | `''` | The text in the field. Setting it filters the list (not reported to analytics). |
3536
+ | `no-shadow-dom` | `boolean` | `false` | |
3537
+ | `no-style` | `boolean` | `false` | |
3538
+
3539
+ #### CSS parts
3540
+
3541
+ | Part | Description |
3542
+ |---|---|
3543
+ | `label` | The visible label. |
3544
+ | `field` | The box around the field and its clear button. |
3545
+ | `input` | The text field. |
3546
+ | `clear` | The clear button. |
3547
+ | `count` | The visible count under the field. |
3548
+ | `empty` | The “No … match” message. |
3549
+
3550
+ #### Events
3551
+
3552
+ | Event | Description |
3553
+ |---|---|
3554
+ | `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. |
3555
+ | `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. |
3556
+
3557
+ #### CSS custom properties
3558
+
3559
+ | Property | Default | Description |
3560
+ |---|---|---|
3561
+ | `--uva-color-surface-raised` | | Dark-mode role token: field background (else #fff). |
3562
+ | `--uva-color-control-border` | | Dark-mode role token: field border (else `--uva-grey`, #808080). |
3563
+ | `--uva-color-input-text` | | Dark-mode role token: field text (else #2b2b2b). |
3564
+ | `--uva-color-text` | | Dark-mode role token: label text (else #2b2b2b). |
3565
+ | `--uva-color-text-muted` | | Dark-mode role token: placeholder, count and the clear icon (else #4f4f4f). |
3566
+ | `--uva-color-alert-info-bg` | | Dark-mode role token: the no-match message background. |
3567
+ | `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
3568
+
2923
3569
  ### `<uvalib-map>`
2924
3570
 
2925
3571
  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.
@@ -3025,7 +3671,7 @@ A record's details as a description list, as on the library's digital collection
3025
3671
 
3026
3672
  ### `<uvalib-pagefind-search>`
3027
3673
 
3028
- 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.
3674
+ 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>`. The `ui` property is the `PagefindUI` instance (for `triggerFilters`), and `ready` resolves with it. Attributes are read once, when the element is first connected.
3029
3675
 
3030
3676
  #### Attributes
3031
3677
 
@@ -3043,6 +3689,7 @@ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle)
3043
3689
  | `translations` | `string` | | JSON of Pagefind UI strings to override (`{"zero_results": "…"}`). |
3044
3690
  | `options` | `string` | | JSON of any other `PagefindUI` options (`{"openFilters": ["author"]}`), applied last. |
3045
3691
  | `query-param` | `string` | `q` | The URL parameter that holds the query; empty turns it off. |
3692
+ | `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. |
3046
3693
 
3047
3694
  #### Events
3048
3695