@uvalib/web-components 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +43 -5
- package/dist/base.css +7 -1
- package/dist/components/uvalib-contents/UvalibContents.d.ts +66 -2
- package/dist/components/uvalib-contents/UvalibContents.js +277 -29
- package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +27 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +92 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
- package/dist/custom-elements.json +400 -6
- package/dist/pagefind.css +144 -0
- package/dist/styles/base.js +7 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/pagefind.js +150 -0
- package/dist/styles/pagefind.js.map +1 -1
- package/dist-cdn/base.css +7 -1
- package/dist-cdn/chunks/{base-DXkGlSgH.js → base-DmImIMld.js} +8 -2
- package/dist-cdn/chunks/{base-DXkGlSgH.js.map → base-DmImIMld.js.map} +1 -1
- package/dist-cdn/custom-elements.json +400 -6
- package/dist-cdn/manifest.json +1 -1
- package/dist-cdn/pagefind.css +144 -0
- package/dist-cdn/site-page.js +1 -1
- package/dist-cdn/site-style.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +2 -2
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +13 -4
- package/dist-cdn/uvalib-contents.js +185 -47
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-pagefind-search.js +64 -34
- package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
- package/package.json +1 -1
- package/skills/uvalib-web-components/SKILL.md +2 -2
- package/skills/uvalib-web-components/reference/components.md +13 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.11.0 — 2026-11-25
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- hold the page still while a search from the URL loads (issue #37)
|
|
8
|
+
- full-contents link, partial-list line and window for long contents
|
|
9
|
+
|
|
10
|
+
### Other
|
|
11
|
+
|
|
12
|
+
- Merge branch 'integrate/xtf': Pagefind searching hold (issue #37), contents window and full-contents link (issue #38)
|
|
13
|
+
- Merge branch 'feat/contents-window' into integrate/xtf
|
|
14
|
+
- Merge branch 'feat/pagefind-hold' into integrate/xtf
|
|
15
|
+
|
|
3
16
|
## v1.10.0 — 2026-11-25
|
|
4
17
|
|
|
5
18
|
### Features
|
package/README.md
CHANGED
|
@@ -551,7 +551,24 @@ Two components for Library sites with records and long texts, such as the Electr
|
|
|
551
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.
|
|
552
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.
|
|
553
553
|
- **Sidebars.** `sticky` keeps it in view on wide screens (`--uvalib-contents-sticky-top`, default 1rem); the list then scrolls within the window's height (`--uvalib-contents-max-height`) and the current entry is scrolled into view inside it, never the page. In a [`.uvalib-sidebar-layout`](#sidebar-layout), use the layout's `--sticky` or this, not both.
|
|
554
|
-
- **
|
|
554
|
+
- **Very long contents (issue #38).** A text with hundreds of sections, each its own page, should not write the whole list into every page. Write only the entries near the current one (with their parents, so the nesting makes sense) and set `full-href` to the full contents: a "Full contents (243 sections)" link is drawn after the list, inside the landmark but not as an entry (bold and underlined with an arrow, as library.virginia.edu's "See all" links; 44px tall, the focus ring, `LinkText` in forced colors; outside the scrolling list, so it shows with `sticky`; inside the disclosure on narrow screens). `full-label` is its text ("Full contents"), `total` the number of entries in the full contents, shown as "(243 sections)" (`noun`, default "sections"; `singular` for one, as `<uvalib-results-count>`). A visually hidden line before the list tells screen readers it is partial ("Showing 25 of 243 sections."); the headline and the landmark's name stay the visible "Contents". `base.css` holds the link's line before the script runs. Where the whole list is in the page (or comes from `items` or `headings-from`), `window="12"` shows only the current entry and the 12 before and after it in document order (25 entries, shifted at either end), with their parents; the others are hidden, not removed, an ellipsis (hidden from assistive technology) marks each gap, and the window follows the current entry. With `full-href` the link follows it; without, a "Show all 243 sections" button (`aria-expanded`) shows the rest in place and "Show fewer" hides it again. The whole list shows until the script runs (base.css cannot hold a window), so prefer the build-time window for very long lists. Without JavaScript there is no link: the list shows alone. Analytics: `full-contents-click`, `show-all`, `show-fewer`, never the label or URL.
|
|
555
|
+
|
|
556
|
+
```html
|
|
557
|
+
<uvalib-contents class="uvalib-sidebar-layout__sidebar" full-href="/text/eaf375v1/" total="243">
|
|
558
|
+
<ol>
|
|
559
|
+
<li>
|
|
560
|
+
<a href="/text/eaf375v1/d8/">The actress of Padua</a>
|
|
561
|
+
<ol>
|
|
562
|
+
<li><a href="/text/eaf375v1/d40/">Chapter XXXI</a></li>
|
|
563
|
+
<li><a href="/text/eaf375v1/d41/">Chapter XXXII</a></li>
|
|
564
|
+
<!-- … the entries near the current one … -->
|
|
565
|
+
</ol>
|
|
566
|
+
</li>
|
|
567
|
+
</ol>
|
|
568
|
+
</uvalib-contents>
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
- **Single-page apps.** The list is drawn from copies of the children. A plain click on an entry fires `uvalib-contents-navigate` (`detail: { href, level }`, bubbling, cancelable; level 0 for the full-contents link): cancel it to route in place. Hash links need nothing.
|
|
555
572
|
|
|
556
573
|
`<uvalib-metadata>`, a record's description list:
|
|
557
574
|
|
|
@@ -2034,6 +2051,18 @@ Static sites that search with [Pagefind](https://pagefind.app) (such as Electron
|
|
|
2034
2051
|
- **What it fixes in the stock UI:** text at 16px and up (the stock scale makes it 12.8px), a readable placeholder (stock: 20% opacity), the library focus ring on every control, a hidden Clear button that can no longer take focus (stock: invisible but focusable), native checkboxes (the stock ones vanish in forced colors), 44px targets for the filter headings, rows and buttons, no fixed heights that clip zoomed or spaced text, no arrow glyph read out before each sub-result, and a 320px reflow. Text is 7:1 or more (WCAG AAA) in light and dark, except the Load more button's white on blue-alt in light mode (4.7:1, as on every `.uvalib-button`).
|
|
2035
2052
|
- **What needs script, done by `<uvalib-pagefind-search>`:** a visible `<label>` for the field (the stock field is named only by its `title` and has no id to point a label at), a polite status region that announces "7 results for virginia" once results settle (the stock message is not a live region), focus kept in the field after Clear and Escape (the stock UI blurs it) and moved to the first new result after "Load more results", and the loading placeholders' dots hidden from screen readers. It also reads `?q=` when it starts (and again on Back and Forward) and writes the settled query back with `history.replaceState` (`query-param`, default `q`; empty turns it off), and reports to `<site-analytics>`: the settled search (`trackSearch`, category `Pagefind`, with the result count, once per query and filter set) and `['uvalib-pagefind-search', 'filter-change', '<filter>: <value>', 1 | 0]`.
|
|
2036
2053
|
- **Filters in the URL: `filter-params`.** List Pagefind filter names, space-separated (`filter-params="collection author"`), and each becomes a URL parameter of the same name, so a collection page can link to `/search/?collection=Manuscripts` ("Search this collection") or `/search/?q=virginia&collection=Manuscripts`. A repeated parameter (`?collection=A&collection=B`) checks several values; as with boxes checked by hand, Pagefind then wants pages with every one. At start (and on Back and Forward) the element loads the index, waits for Pagefind's filter list, checks the URL's values and applies them with the query, so there is one search; those filter groups start open (added to any `openFilters` in `options`), so the visitor sees why the results are narrowed. Values the index does not have are dropped without an error (matched without regard to case, then written back in the index's own case), so a stale link searches everything rather than showing no results; if the filter list never appears (an index with no filters), it searches without them after 10 s. Checking or unchecking a named filter writes it back with `history.replaceState`, keeping every other parameter; unchecking the last value removes the parameter. Filters not named stay out of the URL. A filter set from the URL is not a `filter-change` event; the settled search is still reported once, with the filters in its key. Without a query, the filters wait for the first search, as in Pagefind. Do not add your own `triggerFilters` script for this.
|
|
2054
|
+
- **A search from the URL holds the page still: `searching`.** Pagefind's results arrive after the page has painted, so a page opened with `?q=` used to push everything below the search (the footer) down as they loaded: Lighthouse measured CLS 0.274 on Electronic Text Collections. Mark the element `searching` when the URL has a query, in the page's HTML before any script runs, with one line after the element (or server-side):
|
|
2055
|
+
|
|
2056
|
+
```html
|
|
2057
|
+
<uvalib-pagefind-search bundle-path="/pagefind/s0/" show-sub-results></uvalib-pagefind-search>
|
|
2058
|
+
<script>
|
|
2059
|
+
if (new URLSearchParams(location.search).get('q'))
|
|
2060
|
+
document.querySelector('uvalib-pagefind-search').setAttribute('searching', '');
|
|
2061
|
+
</script>
|
|
2062
|
+
```
|
|
2063
|
+
|
|
2064
|
+
From first paint, `pagefind.css` then holds a window's height for the results and draws one screen of placeholder results (bars like base.css's `.uvalib-skeleton-text`, sized like Pagefind's result rows, with two sections each under `show-sub-results`); once the script runs, the element puts the same placeholders in the page (`page-size` rows, `aria-hidden`, with base.css's shimmer, which stops under reduced motion) and hides Pagefind's results area until the results, or "no results", have loaded. Then the element still reaches the bottom of the window until the visitor uses the search (types, clears or clicks in it), so a short list or "no results" does not pull the footer up into view; after that it is as tall as its content. The polite status region announces the count as before, and the analytics are unchanged. On Back and Forward to a new query the element does the same itself. Without `searching` it does not hold at start: its script runs after first paint, when holding would itself push the footer down. With the snippet, Electronic Text Collections' search measured CLS 0.000 (full page, 1 result and no results, phone and desktop; 0.13–0.44 without it), so a site's own `min-height` hold on the element can go. Add `no-skeleton` to turn all of this off. The snippet uses `q`: use your `query-param`.
|
|
2065
|
+
|
|
2037
2066
|
- **Still open** (in Pagefind's markup, not fixable from outside without rewriting it): filter checkbox ids are built from the filter and value (`author-Jefferson, Thomas`), so they can contain spaces and repeat if a page has two search UIs.
|
|
2038
2067
|
- The element loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI` already exists; Pagefind itself stays the site's. `el.ready` resolves with the `PagefindUI` instance, for `triggerFilters` (filters from your own script; for filters from the URL use `filter-params`). Attributes are read when it connects; removing the element destroys the Pagefind UI, and inserting it again starts a new one (`bundle-path` and each `merge-index` path get their trailing `/` if missing, and `options` cannot move the UI out of the element). Without the element, the theme still styles `new PagefindUI({ element })`, but then the field needs a label and the results a live region from your own script. See the [Pagefind example](https://uvalib.github.io/reusable-web-library/#pagefind-search) in the playground and the reference below.
|
|
2039
2068
|
|
|
@@ -3052,7 +3081,7 @@ An editable text field that suggests values as you type, from a local list or a
|
|
|
3052
3081
|
|
|
3053
3082
|
### `<uvalib-contents>`
|
|
3054
3083
|
|
|
3055
|
-
Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation: a `<nav>` landmark (named by `label`, "Contents" by default) with the label as a visible headline, and a nested list of links with dividers between the top-level entries and a bar beside each nested level. Give the list as a child: an `<ol>` or `<ul>` of `<li>` elements, each with an `<a href>` (or plain text for a group label) and, for sub-entries, a nested `<ol>`/`<ul>`, to any depth. Other children (a heading) are ignored. The list follows changes to the children. Apps set the `items` property instead (`{ label, href?, children? }`, winning over the children while set). The current entry gets `aria-current`: `page` for the link to this page, `location` for the link to the section of it in the URL's hash. It is found from the page URL (path, and hash for in-page sections), followed through same-document navigations (`hashchange`, `popstate` and the Navigation API), or from the `current` attribute (a URL, resolved like the links). An entry whose href has a query string matches only that query (`?part=2`); one without matches the page whatever its query. Hash-only hrefs are places on that page. With `current` unset, a valid `aria-current` on a source link (`page`, `location` or `true`) is used instead, the first of each kind. `lang` and `dir` on the source links and items, and inline markup in their text (`em`, `cite`, `code`, `abbr`…, copied element by element, never as HTML), are kept. On narrow screens the list collapses into a disclosure: the headline becomes a button with `aria-expanded`, and the list starts closed (as the Electronic Text Collections' Contents does on phones, so the text comes first) until the reader opens it, or while the `open` attribute is set; opening it shows the current entry. Narrow means the viewport (`collapse-below`, 64rem by default), not the element's own width: a contents sidebar is always far narrower than 64rem, so a container query could not tell a phone from a desktop. `sticky` keeps it in view in a sidebar on wide screens; a list longer than the window then scrolls, and the current entry is scrolled into view inside it (never the page). A table of contents for a long document: `headings-from="#article"` builds the list from the headings in that element (`levels`, `2-3` by default; nothing shown below `min` top-level entries, 2 by default). Headings without text or hidden with `aria-hidden` are skipped; one without an id gets one from its text (`budget-report`, then `budget-report-2`), and existing ids are kept, so links to sections keep working. It follows headings added, removed or retitled; `refresh()` reads them again after other changes. The children and `items` win while they give a list. Without JavaScript there is no list: a list rendered at build time, as children, works everywhere. Single-page apps: the list is drawn from copies of the children, so a router's own click handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in place; hash links need nothing.
|
|
3084
|
+
Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation: a `<nav>` landmark (named by `label`, "Contents" by default) with the label as a visible headline, and a nested list of links with dividers between the top-level entries and a bar beside each nested level. Give the list as a child: an `<ol>` or `<ul>` of `<li>` elements, each with an `<a href>` (or plain text for a group label) and, for sub-entries, a nested `<ol>`/`<ul>`, to any depth. Other children (a heading) are ignored. The list follows changes to the children. Apps set the `items` property instead (`{ label, href?, children? }`, winning over the children while set). The current entry gets `aria-current`: `page` for the link to this page, `location` for the link to the section of it in the URL's hash. It is found from the page URL (path, and hash for in-page sections), followed through same-document navigations (`hashchange`, `popstate` and the Navigation API), or from the `current` attribute (a URL, resolved like the links). An entry whose href has a query string matches only that query (`?part=2`); one without matches the page whatever its query. Hash-only hrefs are places on that page. With `current` unset, a valid `aria-current` on a source link (`page`, `location` or `true`) is used instead, the first of each kind. `lang` and `dir` on the source links and items, and inline markup in their text (`em`, `cite`, `code`, `abbr`…, copied element by element, never as HTML), are kept. On narrow screens the list collapses into a disclosure: the headline becomes a button with `aria-expanded`, and the list starts closed (as the Electronic Text Collections' Contents does on phones, so the text comes first) until the reader opens it, or while the `open` attribute is set; opening it shows the current entry. Narrow means the viewport (`collapse-below`, 64rem by default), not the element's own width: a contents sidebar is always far narrower than 64rem, so a container query could not tell a phone from a desktop. `sticky` keeps it in view in a sidebar on wide screens; a list longer than the window then scrolls, and the current entry is scrolled into view inside it (never the page). A table of contents for a long document: `headings-from="#article"` builds the list from the headings in that element (`levels`, `2-3` by default; nothing shown below `min` top-level entries, 2 by default). Headings without text or hidden with `aria-hidden` are skipped; one without an id gets one from its text (`budget-report`, then `budget-report-2`), and existing ids are kept, so links to sections keep working. It follows headings added, removed or retitled; `refresh()` reads them again after other changes. The children and `items` win while they give a list. Without JavaScript there is no list: a list rendered at build time, as children, works everywhere. A very long contents (a text with hundreds of sections, each its own page) can show only part of the list, with a link to the whole. `full-href` adds that link after the list: not an entry but a call to action (bold, underlined, with an arrow), its text `full-label` ("Full contents") followed by the count when `total` (the entries in the full contents) is set: "Full contents (243 sections)" (`noun`, "sections" by default; `singular` for one). A static site writes only the entries near the current one (with their parents) and sets these. `window="12"` does it in the browser when the whole list is given: only the current entry and the 12 before and after it in document order (25 entries, shifted at either end) are shown, with their parents so the nesting still makes sense; the others are hidden, not removed, and a gap between the entries shown is marked with an ellipsis (hidden from assistive technology). It follows the current entry, and applies to `items` and `headings-from` too. Without `full-href`, a "Show all 243 sections" button shows the rest in place ("Show fewer" goes back). While part of the list is shown, a visually hidden line before it says so ("Showing 25 of 243 sections."); the headline and the landmark keep the visible label as their name. On narrow screens the link and the button are inside the disclosure. Single-page apps: the list is drawn from copies of the children, so a router's own click handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in place; hash links need nothing.
|
|
3056
3085
|
|
|
3057
3086
|
#### Attributes
|
|
3058
3087
|
|
|
@@ -3067,6 +3096,12 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
|
|
|
3067
3096
|
| `headings-from` | `string \| undefined` | | Build the list from the headings in the element this selector names (`#article`): each heading at `levels` gets an entry linking to it (an id is added when it has none), the lower levels nested under the heading before them. The children and `items` win while they give a list. |
|
|
3068
3097
|
| `levels` | | `DEFAULT_LEVELS` | With `headings-from`: the heading levels to list, `2-3` (the default) or one level, `2`. |
|
|
3069
3098
|
| `min` | | `DEFAULT_MIN` | With `headings-from`: the fewest top-level entries worth a list (default 2). With fewer, nothing is shown. |
|
|
3099
|
+
| `full-href` | `string \| undefined` | | The URL of the full contents, when the list is only part of it: a "Full contents" link after the list (`full-label`, with the count from `total`). |
|
|
3100
|
+
| `full-label` | | `DEFAULT_FULL_LABEL` | The full-contents link's text, before the count: "Full contents" by default. |
|
|
3101
|
+
| `total` | `number \| undefined` | | How many entries the full contents has, for the link ("Full contents (243 sections)") and the screen-reader line ("Showing 25 of 243 sections."). With `window`, the whole list's count when unset. |
|
|
3102
|
+
| `noun` | | `DEFAULT_NOUN` | What the entries are, plural, in the counts: "sections" by default. |
|
|
3103
|
+
| `singular` | `string` | `''` | What an entry is, singular, for a count of one. Default: "section" for the default `noun`, else `noun`. |
|
|
3104
|
+
| `window` | `number \| undefined` | | Show only the current entry and this many before and after it in document order (and their parents); the others are hidden. Unset or blank: every entry. |
|
|
3070
3105
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
3071
3106
|
| `no-style` | `boolean` | `false` | |
|
|
3072
3107
|
|
|
@@ -3074,8 +3109,8 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
|
|
|
3074
3109
|
|
|
3075
3110
|
| Event | Description |
|
|
3076
3111
|
|---|---|
|
|
3077
|
-
| `uvalib-analytics-event` | For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level),
|
|
3078
|
-
| `uvalib-contents-navigate` | A plain click on an entry: `detail` is `{ href, level }` (href as written). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed. |
|
|
3112
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), on the full-contents link, `['uvalib-contents', 'full-contents-click']`, opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' \| 'close']`, and the window's button, `['uvalib-contents', 'show-all' \| 'show-fewer']`; never the label or URL. Bubbles and is composed. |
|
|
3113
|
+
| `uvalib-contents-navigate` | A plain click on an entry or the full-contents link: `detail` is `{ href, level }` (href as written; level 0 for the full-contents link). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed. |
|
|
3079
3114
|
|
|
3080
3115
|
#### CSS custom properties
|
|
3081
3116
|
|
|
@@ -3091,6 +3126,7 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
|
|
|
3091
3126
|
| `--uva-color-text` | | Dark-mode role token: text and current entry (else `--uva-grey-darkest`). |
|
|
3092
3127
|
| `--uva-color-link` | | Dark-mode role token: the current entry's bar and the button's text (else `--uva-brand-blue`). |
|
|
3093
3128
|
| `--uva-color-current` | | Dark-mode role token: the nested levels' bar (else `--uva-brand-orange`). |
|
|
3129
|
+
| `--uva-color-text-muted` | | Dark-mode role token: the ellipsis between the entries a window shows (else #4f4f4f). |
|
|
3094
3130
|
| `--uva-color-border` | | Dark-mode role token: dividers (else #dadada). |
|
|
3095
3131
|
| `--uva-color-control-border` | | Dark-mode role token: the button's border (else #808080). |
|
|
3096
3132
|
| `--uva-color-surface-raised` | | Dark-mode role token: the button's background (else #fff). |
|
|
@@ -3671,7 +3707,7 @@ A record's details as a description list, as on the library's digital collection
|
|
|
3671
3707
|
|
|
3672
3708
|
### `<uvalib-pagefind-search>`
|
|
3673
3709
|
|
|
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.
|
|
3710
|
+
Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle) with the library's defaults and the accessibility fixes that need script. Use it with pagefind.css, in place of Pagefind's pagefind-ui.css. It renders in light DOM, so the page's styles reach Pagefind's markup. It loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI` already exists. What it adds to the stock UI: a visible `<label>` for the field (the stock field is named only by its title); a polite status region that announces the result count ("12 results for virginia") once results settle (the stock message is not a live region); focus kept in the field after Clear or Escape (the stock UI blurs it, dropping focus to the page) and moved to the first new result after "Load more results"; the loading placeholders' dots hidden from screen readers; `?q=` read at start (and on Back and Forward) and the settled query written back with `history.replaceState`, so a search can be shared; with `filter-params`, the named Pagefind filters read from and written to the URL the same way; and reports to `<site-analytics>`. While a search from the URL loads, it can hold the page still (issue #37): with `searching` set in the page's HTML when the URL has a query, the element holds a screen's height from first paint, and placeholder results (aria-hidden) stand in for Pagefind's until they, or "no results", are drawn; the element then still reaches the bottom of the window until the visitor uses the search, so a short list does not pull the footer up. It does the same on Back and Forward to a new query. The `ui` property is the `PagefindUI` instance (for `triggerFilters`), and `ready` resolves with it. Attributes are read once, when the element is first connected.
|
|
3675
3711
|
|
|
3676
3712
|
#### Attributes
|
|
3677
3713
|
|
|
@@ -3689,6 +3725,8 @@ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle)
|
|
|
3689
3725
|
| `translations` | `string` | | JSON of Pagefind UI strings to override (`{"zero_results": "…"}`). |
|
|
3690
3726
|
| `options` | `string` | | JSON of any other `PagefindUI` options (`{"openFilters": ["author"]}`), applied last. |
|
|
3691
3727
|
| `query-param` | `string` | `q` | The URL parameter that holds the query; empty turns it off. |
|
|
3728
|
+
| `searching` | `boolean` | | Set it in the page's HTML when the URL has a query (server-side, or with a one-line inline script after the element): from first paint, before any script loads, it holds a screen's height for the results, and placeholder results show until they are drawn. The element removes it then (and at start without a query), and sets it itself on Back and Forward to a new query. |
|
|
3729
|
+
| `no-skeleton` | `boolean` | | Never hold space or show placeholder results (`searching` is ignored). |
|
|
3692
3730
|
| `filter-params` | `string` | | Space-separated Pagefind filter names read from and written to URL parameters of the same name (`collection author`: `?collection=A&collection=B`). URL filters are applied with the query as one search, their filter groups open; values not in the index are ignored. Empty (the default) turns it off. |
|
|
3693
3731
|
|
|
3694
3732
|
#### Events
|
package/dist/base.css
CHANGED
|
@@ -361,6 +361,12 @@ uvalib-metadata:not(:defined) > dl > dd[data-limit="12"] > :is(ul, ol):has(> li:
|
|
|
361
361
|
padding-block-start: calc(1.125rem * 1.3 + 0.5rem);
|
|
362
362
|
animation-name: uvalib-contents-reveal;
|
|
363
363
|
}
|
|
364
|
+
/* With full-href (issue #38): the full-contents link's line held below the list (0.5rem
|
|
365
|
+
above a 44px link). A window="N" list is not held: the whole list shows until it upgrades
|
|
366
|
+
(in a sidebar beside the content, nothing else moves). */
|
|
367
|
+
uvalib-contents[full-href]:not(:defined) {
|
|
368
|
+
padding-block-end: calc(44px + 0.5rem);
|
|
369
|
+
}
|
|
364
370
|
:where(uvalib-contents):not(:defined) :is(ol, ul) {
|
|
365
371
|
margin: 0;
|
|
366
372
|
padding: 0;
|
|
@@ -391,7 +397,7 @@ uvalib-metadata:not(:defined) > dl > dd[data-limit="12"] > :is(ul, ol):has(> li:
|
|
|
391
397
|
@media (max-width: 64rem) {
|
|
392
398
|
uvalib-contents:not([collapse-below], [open]):not(:defined) {
|
|
393
399
|
max-block-size: 44px;
|
|
394
|
-
padding-block
|
|
400
|
+
padding-block: 0;
|
|
395
401
|
overflow: hidden;
|
|
396
402
|
}
|
|
397
403
|
}
|
|
@@ -48,13 +48,30 @@ export interface ContentsItem {
|
|
|
48
48
|
* `items` win while they give a list. Without JavaScript there is no list: a list rendered
|
|
49
49
|
* at build time, as children, works everywhere.
|
|
50
50
|
*
|
|
51
|
+
* A very long contents (a text with hundreds of sections, each its own page) can show only
|
|
52
|
+
* part of the list, with a link to the whole. `full-href` adds that link after the list: not
|
|
53
|
+
* an entry but a call to action (bold, underlined, with an arrow), its text `full-label`
|
|
54
|
+
* ("Full contents") followed by the count when `total` (the entries in the full contents) is
|
|
55
|
+
* set: "Full contents (243 sections)" (`noun`, "sections" by default; `singular` for one). A
|
|
56
|
+
* static site writes only the entries near the current one (with their parents) and sets
|
|
57
|
+
* these. `window="12"` does it in the browser when the whole list is given: only the current
|
|
58
|
+
* entry and the 12 before and after it in document order (25 entries, shifted at either end)
|
|
59
|
+
* are shown, with their parents so the nesting still makes sense; the others are hidden, not
|
|
60
|
+
* removed, and a gap between the entries shown is marked with an ellipsis (hidden from
|
|
61
|
+
* assistive technology). It follows the current entry, and applies to `items` and
|
|
62
|
+
* `headings-from` too. Without `full-href`, a "Show all 243 sections" button shows the rest in
|
|
63
|
+
* place ("Show fewer" goes back). While part of the list is shown, a visually hidden line
|
|
64
|
+
* before it says so ("Showing 25 of 243 sections."); the headline and the landmark keep the
|
|
65
|
+
* visible label as their name. On narrow screens the link and the button are inside the
|
|
66
|
+
* disclosure.
|
|
67
|
+
*
|
|
51
68
|
* Single-page apps: the list is drawn from copies of the children, so a router's own click
|
|
52
69
|
* handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in
|
|
53
70
|
* place; hash links need nothing.
|
|
54
71
|
*
|
|
55
72
|
* @tagname uvalib-contents
|
|
56
|
-
* @fires uvalib-analytics-event - For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level),
|
|
57
|
-
* @fires uvalib-contents-navigate - A plain click on an entry: `detail` is `{ href, level }` (href as written). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed.
|
|
73
|
+
* @fires uvalib-analytics-event - For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), on the full-contents link, `['uvalib-contents', 'full-contents-click']`, opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' | 'close']`, and the window's button, `['uvalib-contents', 'show-all' | 'show-fewer']`; never the label or URL. Bubbles and is composed.
|
|
74
|
+
* @fires uvalib-contents-navigate - A plain click on an entry or the full-contents link: `detail` is `{ href, level }` (href as written; level 0 for the full-contents link). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed.
|
|
58
75
|
* @cssprop [--uvalib-contents-sticky-top=1rem] - With `sticky`: the gap kept above it.
|
|
59
76
|
* @cssprop [--uvalib-contents-max-height=none] - The list's maximum height on wide screens (it scrolls beyond it); with `sticky`, the window's height less twice the sticky gap.
|
|
60
77
|
* @cssprop [--uva-blue-alt-dark=#005679] - Link colour.
|
|
@@ -65,6 +82,7 @@ export interface ContentsItem {
|
|
|
65
82
|
* @cssprop --uva-color-text - Dark-mode role token: text and current entry (else `--uva-grey-darkest`).
|
|
66
83
|
* @cssprop --uva-color-link - Dark-mode role token: the current entry's bar and the button's text (else `--uva-brand-blue`).
|
|
67
84
|
* @cssprop --uva-color-current - Dark-mode role token: the nested levels' bar (else `--uva-brand-orange`).
|
|
85
|
+
* @cssprop --uva-color-text-muted - Dark-mode role token: the ellipsis between the entries a window shows (else #4f4f4f).
|
|
68
86
|
* @cssprop --uva-color-border - Dark-mode role token: dividers (else #dadada).
|
|
69
87
|
* @cssprop --uva-color-control-border - Dark-mode role token: the button's border (else #808080).
|
|
70
88
|
* @cssprop --uva-color-surface-raised - Dark-mode role token: the button's background (else #fff).
|
|
@@ -110,6 +128,30 @@ export declare class UvalibContents extends UvalibElement {
|
|
|
110
128
|
* nothing is shown.
|
|
111
129
|
*/
|
|
112
130
|
min: number;
|
|
131
|
+
/**
|
|
132
|
+
* The URL of the full contents, when the list is only part of it: a "Full contents" link
|
|
133
|
+
* after the list (`full-label`, with the count from `total`).
|
|
134
|
+
*/
|
|
135
|
+
fullHref?: string;
|
|
136
|
+
/** The full-contents link's text, before the count: "Full contents" by default. */
|
|
137
|
+
fullLabel: string;
|
|
138
|
+
/**
|
|
139
|
+
* How many entries the full contents has, for the link ("Full contents (243 sections)") and
|
|
140
|
+
* the screen-reader line ("Showing 25 of 243 sections."). With `window`, the whole list's
|
|
141
|
+
* count when unset.
|
|
142
|
+
*/
|
|
143
|
+
total?: number;
|
|
144
|
+
/** What the entries are, plural, in the counts: "sections" by default. */
|
|
145
|
+
noun: string;
|
|
146
|
+
/** What an entry is, singular, for a count of one. Default: "section" for the default `noun`, else `noun`. */
|
|
147
|
+
singular: string;
|
|
148
|
+
/**
|
|
149
|
+
* Show only the current entry and this many before and after it in document order (and
|
|
150
|
+
* their parents); the others are hidden. Unset or blank: every entry.
|
|
151
|
+
*/
|
|
152
|
+
windowSize?: number;
|
|
153
|
+
/** Whether "Show all" was pressed (a window without `full-href`). */
|
|
154
|
+
private expanded;
|
|
113
155
|
/** The entries built from the headings (`headings-from`). */
|
|
114
156
|
private headingItems;
|
|
115
157
|
private headingsObserver?;
|
|
@@ -126,6 +168,8 @@ export declare class UvalibContents extends UvalibElement {
|
|
|
126
168
|
private warned;
|
|
127
169
|
private readonly panelId;
|
|
128
170
|
private mql?;
|
|
171
|
+
/** Whether the last render drew the full-contents link or the window's button. */
|
|
172
|
+
private hasMore;
|
|
129
173
|
/** What was last scrolled into view, so the list is not scrolled again on every update. */
|
|
130
174
|
private scrolledTo?;
|
|
131
175
|
constructor();
|
|
@@ -172,6 +216,18 @@ export declare class UvalibContents extends UvalibElement {
|
|
|
172
216
|
/** The current entries: the page's and its section's. */
|
|
173
217
|
private currentOf;
|
|
174
218
|
private get level();
|
|
219
|
+
/** The noun for `n` entries. */
|
|
220
|
+
private word;
|
|
221
|
+
/** The safe `full-href`, or undefined (unset, blank, or not http(s), mailto, tel or relative). */
|
|
222
|
+
private get fullLink();
|
|
223
|
+
/**
|
|
224
|
+
* With `window`: the entries shown (the current one, `window` before and after it in
|
|
225
|
+
* document order, shifted at either end, and their parents), or undefined when every entry
|
|
226
|
+
* shows. The current entry is the section's (`location`), else the page's; with none, the
|
|
227
|
+
* window starts at the top.
|
|
228
|
+
*/
|
|
229
|
+
private windowOf;
|
|
230
|
+
private showAll;
|
|
175
231
|
private toggle;
|
|
176
232
|
/**
|
|
177
233
|
* A plain click on an entry fires a cancelable `uvalib-contents-navigate`; a router that
|
|
@@ -183,5 +239,13 @@ export declare class UvalibContents extends UvalibElement {
|
|
|
183
239
|
/** Scroll the list (never the page) so the current entry shows, once per entry and opening. */
|
|
184
240
|
private reveal;
|
|
185
241
|
private renderList;
|
|
242
|
+
private renderEntry;
|
|
243
|
+
/** The count of entries shown (all, or the window's). */
|
|
244
|
+
private static size;
|
|
245
|
+
/**
|
|
246
|
+
* After the list: the full-contents link, or a window's Show all / Show fewer button; and
|
|
247
|
+
* the visually hidden line before the list that says it is partial.
|
|
248
|
+
*/
|
|
249
|
+
private renderMore;
|
|
186
250
|
protected render(): TemplateResult;
|
|
187
251
|
}
|