@uvalib/web-components 1.10.0 → 1.11.1

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 (33) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +44 -5
  3. package/dist/base.css +86 -1
  4. package/dist/components/uvalib-contents/UvalibContents.d.ts +66 -2
  5. package/dist/components/uvalib-contents/UvalibContents.js +277 -29
  6. package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
  7. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +27 -1
  8. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +92 -1
  9. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  10. package/dist/custom-elements.json +5915 -5521
  11. package/dist/pagefind.css +144 -0
  12. package/dist/styles/base.js +121 -1
  13. package/dist/styles/base.js.map +1 -1
  14. package/dist/styles/pagefind.js +150 -0
  15. package/dist/styles/pagefind.js.map +1 -1
  16. package/dist-cdn/base.css +86 -1
  17. package/dist-cdn/chunks/{base-DXkGlSgH.js → base-DtkA4Pgg.js} +99 -4
  18. package/dist-cdn/chunks/base-DtkA4Pgg.js.map +1 -0
  19. package/dist-cdn/custom-elements.json +5915 -5521
  20. package/dist-cdn/manifest.json +1 -1
  21. package/dist-cdn/pagefind.css +144 -0
  22. package/dist-cdn/site-page.js +1 -1
  23. package/dist-cdn/site-style.js +1 -1
  24. package/dist-cdn/skills/uvalib-web-components/SKILL.md +3 -3
  25. package/dist-cdn/skills/uvalib-web-components/reference/components.md +13 -4
  26. package/dist-cdn/uvalib-contents.js +185 -47
  27. package/dist-cdn/uvalib-contents.js.map +1 -1
  28. package/dist-cdn/uvalib-pagefind-search.js +64 -34
  29. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  30. package/package.json +1 -1
  31. package/skills/uvalib-web-components/SKILL.md +3 -3
  32. package/skills/uvalib-web-components/reference/components.md +13 -4
  33. package/dist-cdn/chunks/base-DXkGlSgH.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"uvalib-pagefind-search.js","names":["trackEvent","trackError","trackSearch","TAG","SETTLE_MS","FILTER_WAIT_MS","scripts","loadPagefindUI","win","p","src","script","resolve","reject","VISUALLY_HIDDEN","instanceCounter","isPlain","v","json","text","fallback","check","withSlash","path","MANY_RESULTS_EN","escapeRe","t","countFromMessage","rest","template","re","query","message","at","digits","UvalibPagefindSearch","_args","promise","params","out","name","values","bundlePath","placeholder","label","PagefindUI","generation","fromUrl","num","mergeIndex","m","translations","extra","options","open","given","excerpt","lang","ui","input","q","drawn","r","timer","boxes","filters","have","b","found","h","names","selected","known","key","f","n","vs","details","search","searchChanged","c","box","e","el","link","area","list","shown","count","s","param","url"],"sources":["../src/components/uvalib-pagefind-search/UvalibPagefindSearch.ts","../src/components/uvalib-pagefind-search/uvalib-pagefind-search.ts"],"sourcesContent":["import { trackError, trackEvent, trackSearch } from '../../base/analytics.js';\n\n/** The part of Pagefind's `PagefindUI` this element uses (pagefind-ui.js, 1.x). */\nexport interface PagefindUIInstance {\n triggerSearch(term: string): void;\n triggerFilters(filters: Record<string, string | string[]>): void;\n destroy(): void;\n}\ntype PagefindUIConstructor = new (options: Record<string, unknown>) => PagefindUIInstance;\ntype PagefindWindow = Window & { PagefindUI?: PagefindUIConstructor };\n\n/** The analytics category. */\nconst TAG = 'uvalib-pagefind-search';\n\n/** How long results must stay put before they are announced, reported and put in the URL. */\nexport const SETTLE_MS = 1000;\n\n/** How long to wait for Pagefind's filter list before searching without the URL's filters. */\nexport const FILTER_WAIT_MS = 10000;\n\n/** Filters as Pagefind takes them: each name with its values. */\ntype Filters = Record<string, string[]>;\n\n/** Each script URL is loaded once, however many elements ask for it. */\nconst scripts = new Map<string, Promise<PagefindUIConstructor>>();\nfunction loadPagefindUI(src: string): Promise<PagefindUIConstructor> {\n const win = window as PagefindWindow;\n if (win.PagefindUI) return Promise.resolve(win.PagefindUI);\n let p = scripts.get(src);\n if (!p) {\n p = new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = src;\n script.onload = () =>\n win.PagefindUI ? resolve(win.PagefindUI) : reject(new Error('no PagefindUI'));\n script.onerror = () => reject(new Error(`could not load ${src}`));\n document.head.append(script);\n });\n p.catch(() => scripts.delete(src));\n scripts.set(src, p);\n }\n return p;\n}\n\n/** Hidden from sight but read by screen readers; inline, so it holds without pagefind.css. */\nconst VISUALLY_HIDDEN: Partial<CSSStyleDeclaration> = {\n position: 'absolute',\n width: '1px',\n height: '1px',\n margin: '-1px',\n padding: '0',\n overflow: 'hidden',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n border: '0',\n};\n\nlet instanceCounter = 0;\n\ntype Plain = Record<string, unknown>;\nconst isPlain = (v: unknown): v is Plain =>\n typeof v === 'object' && v !== null && Object.getPrototypeOf(v) === Object.prototype;\n\n/** Parse a JSON attribute; `check` says whether the value has the right shape. */\nconst json = <T>(text: string | null, fallback: T, check: (v: unknown) => boolean): T => {\n if (!text) return fallback;\n try {\n const v: unknown = JSON.parse(text);\n if (check(v)) return v as T;\n } catch {\n // reported below\n }\n console.warn(`${TAG}: ignoring an attribute that is not the expected JSON`, text);\n return fallback;\n};\n\n/** A bundle path always ends in `/`: Pagefind appends file names to it. */\nexport const withSlash = (path: string): string => (path.endsWith('/') ? path : `${path}/`);\n\n/** Pagefind's English \"many results\" message, used to read the count back out of it. */\nconst MANY_RESULTS_EN = '[COUNT] results for [SEARCH_TERM]';\nconst escapeRe = (t: string) => t.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n/**\n * The total count in Pagefind's message, or undefined. With the message's template (`[COUNT]`\n * and `[SEARCH_TERM]`), the query is matched in its own place, so digits in the query never\n * leak into the count; without one, only the query's last occurrence is taken out.\n */\nexport function countFromMessage(\n message: string,\n query: string,\n template?: string,\n): number | undefined {\n let rest: string | undefined;\n if (template?.includes('[COUNT]')) {\n const re = new RegExp(\n `^${escapeRe(template)\n .replace(escapeRe('[COUNT]'), '(.+?)')\n .replace(escapeRe('[SEARCH_TERM]'), escapeRe(query))}$`,\n );\n rest = message.match(re)?.[1];\n }\n if (rest === undefined) {\n const at = message.lastIndexOf(query);\n rest = at < 0 ? message : message.slice(0, at) + ' ' + message.slice(at + query.length);\n }\n const digits = rest.match(/\\d[\\d.,\\s\\u00a0\\u202f]*/);\n return digits ? Number(digits[0].replace(/\\D/g, '')) : undefined;\n}\n\n/**\n * Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle) with the\n * library's defaults and the accessibility fixes that need script. Use it with pagefind.css,\n * in place of Pagefind's pagefind-ui.css. It renders in light DOM, so the page's styles reach\n * Pagefind's markup. It loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI`\n * already exists.\n *\n * What it adds to the stock UI: a visible `<label>` for the field (the stock field is named\n * only by its title); a polite status region that announces the result count (\"12 results\n * for virginia\") once results settle (the stock message is not a live region); focus kept in\n * the field after Clear or Escape (the stock UI blurs it, dropping focus to the page) and\n * moved to the first new result after \"Load more results\"; the loading placeholders' dots\n * hidden from screen readers; `?q=` read at start (and on Back and Forward) and the settled\n * query written back with `history.replaceState`, so a search can be shared; with\n * `filter-params`, the named Pagefind filters read from and written to the URL the same way;\n * and reports to `<site-analytics>`. The\n * `ui` property is the `PagefindUI` instance (for `triggerFilters`), and `ready` resolves\n * with it. Attributes are read once, when the element is first connected.\n *\n * @tagname uvalib-pagefind-search\n * @attr {string} [bundle-path=/pagefind/] - The Pagefind bundle's URL path, ending in `/`.\n * @attr {string} merge-index - JSON array of more indexes to search together: `[{\"bundlePath\": \"/pagefind/s1/\"}]`.\n * @attr {number} [page-size=10] - Results shown before \"Load more results\".\n * @attr {number} excerpt-length - Words per excerpt (Pagefind's default: 30, or 12 with sub-results).\n * @attr {boolean} show-sub-results - Also list the matching sections of each page.\n * @attr {boolean} show-images - Show each result's `image` metadata (off by default).\n * @attr {string} [placeholder=Search] - The field's placeholder.\n * @attr {string} label - The field's visible label. Empty (the default) uses the placeholder.\n * @attr {boolean} label-hidden - Keep the label for screen readers only.\n * @attr {string} translations - JSON of Pagefind UI strings to override (`{\"zero_results\": \"…\"}`).\n * @attr {string} options - JSON of any other `PagefindUI` options (`{\"openFilters\": [\"author\"]}`), applied last.\n * @attr {string} [query-param=q] - The URL parameter that holds the query; empty turns it off.\n * @attr {string} filter-params - 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.\n * @fires search-results - Results settled: `detail` is `{ query, count }`; `{ query: '', count: 0 }` when the field is emptied after a search. Does not bubble.\n * @fires uvalib-analytics-search - For `<site-analytics>`: the settled query, category `Pagefind` and its result count, once per query and filter set. Bubbles and is composed.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-pagefind-search', 'filter-change', '<filter>: <value>', 1 | 0]` (checked or unchecked), and `['uvalib-pagefind-search', 'error', 'load']` if Pagefind cannot be loaded. Bubbles and is composed.\n */\nexport class UvalibPagefindSearch extends HTMLElement {\n /** Bumped by each start and teardown, so a start still loading after removal stops. */\n private generation = 0;\n private started = false;\n private _ui?: PagefindUIInstance;\n private resolveReady!: (ui: PagefindUIInstance) => void;\n private _ready: Promise<PagefindUIInstance> = this.newReady();\n private readonly uid = `${TAG}-${++instanceCounter}`;\n private container = document.createElement('div');\n private readonly status = document.createElement('p');\n private observer?: MutationObserver;\n private settleTimer?: ReturnType<typeof setTimeout>;\n private lastAnnounced = '';\n private lastTracked = '';\n /** The \"many results\" template, to read the count back out of Pagefind's message. */\n private manyResults?: string;\n /** After \"Load more results\": the index of the first new result, to focus once it loads. */\n private focusIndex?: number;\n private readonly onPopState = () => this.followUrl();\n /** Resolves once Pagefind has drawn its filter checkboxes (set only while waiting for them). */\n private filtersDrawn?: () => void;\n\n private newReady(): Promise<PagefindUIInstance> {\n const { promise, resolve } = Promise.withResolvers<PagefindUIInstance>();\n this.resolveReady = resolve;\n return promise;\n }\n\n /**\n * Resolves with the `PagefindUI` instance once it is created (a new promise after the\n * element is removed and inserted again).\n */\n get ready(): Promise<PagefindUIInstance> {\n return this._ready;\n }\n\n /** The `PagefindUI` instance (for `triggerSearch` / `triggerFilters`), once created. */\n get ui(): PagefindUIInstance | undefined {\n return this._ui;\n }\n\n private get input(): HTMLInputElement | null {\n return this.container.querySelector('.pagefind-ui__search-input');\n }\n\n private get queryParam(): string {\n return this.getAttribute('query-param') ?? 'q';\n }\n\n /** The filter names in `filter-params`. */\n private get filterParams(): string[] {\n return (this.getAttribute('filter-params') ?? '').split(/\\s+/).filter(Boolean);\n }\n\n private get boxes(): HTMLInputElement[] {\n return [...this.container.querySelectorAll<HTMLInputElement>('.pagefind-ui__filter-checkbox')];\n }\n\n /** The `filter-params` filters in the page URL that have values (repeated params: several). */\n private urlFilters(): Filters {\n const params = new URLSearchParams(location.search);\n const out: Filters = {};\n for (const name of this.filterParams) {\n const values = params.getAll(name).filter(Boolean);\n if (values.length) out[name] = values;\n }\n return out;\n }\n\n connectedCallback(): void {\n if (this.started) return;\n this.started = true;\n void this.start(++this.generation);\n }\n\n disconnectedCallback(): void {\n // Moving the element (removed and inserted in one task) keeps its search; removing it\n // for good destroys the Pagefind UI, so inserting it again starts afresh.\n queueMicrotask(() => {\n if (!this.isConnected && this.started) this.teardown();\n });\n }\n\n private teardown(): void {\n this.generation++;\n this.started = false;\n clearTimeout(this.settleTimer);\n this.observer?.disconnect();\n this.observer = undefined;\n window.removeEventListener('popstate', this.onPopState);\n try {\n this._ui?.destroy();\n } catch {\n // Pagefind's own teardown failing must not stop ours.\n }\n if (this._ui) this._ready = this.newReady();\n this._ui = undefined;\n this.container.remove();\n this.container = document.createElement('div');\n this.querySelector(`:scope > .${TAG}__label`)?.remove();\n this.status.remove();\n this.status.textContent = '';\n this.lastAnnounced = this.lastTracked = '';\n this.focusIndex = undefined;\n }\n\n private async start(generation: number): Promise<void> {\n const bundlePath = withSlash(this.getAttribute('bundle-path') || '/pagefind/');\n const placeholder = this.getAttribute('placeholder') || 'Search';\n const label = document.createElement('label');\n label.className = `${TAG}__label`;\n label.htmlFor = `${this.uid}-input`;\n label.textContent = this.getAttribute('label') || placeholder;\n if (this.hasAttribute('label-hidden')) Object.assign(label.style, VISUALLY_HIDDEN);\n this.container.className = `${TAG}__ui`;\n this.status.className = `${TAG}__status`;\n this.status.setAttribute('role', 'status');\n Object.assign(this.status.style, VISUALLY_HIDDEN);\n this.append(label, this.container, this.status);\n\n let PagefindUI: PagefindUIConstructor;\n try {\n PagefindUI = await loadPagefindUI(`${bundlePath}pagefind-ui.js`);\n } catch {\n if (generation !== this.generation) return;\n trackError(this, TAG, 'load');\n label.remove();\n const p = document.createElement('p');\n p.className = `${TAG}__error`;\n p.textContent = 'Search is not available right now. Please try again later.';\n this.container.append(p);\n return;\n }\n if (generation !== this.generation) return; // removed while the script loaded\n const fromUrl = this.urlFilters();\n const num = (name: string, fallback?: number) => {\n const n = Number.parseInt(this.getAttribute(name) ?? '', 10);\n return Number.isFinite(n) && n > 0 ? n : fallback;\n };\n const mergeIndex = json<unknown[]>(this.getAttribute('merge-index'), [], Array.isArray)\n .filter((m): m is Plain => isPlain(m) && typeof m.bundlePath === 'string')\n .map((m) => ({ ...m, bundlePath: withSlash(m.bundlePath as string) }));\n const translations: Plain = {\n placeholder,\n ...json<Plain>(this.getAttribute('translations'), {}, isPlain),\n };\n const extra = json<Plain>(this.getAttribute('options'), {}, isPlain);\n const options: Plain = {\n bundlePath,\n mergeIndex,\n pageSize: num('page-size', 10),\n showSubResults: this.hasAttribute('show-sub-results'),\n showImages: this.hasAttribute('show-images'),\n ...extra,\n translations,\n // Always this element's own container: the label, status and focus fixes live there.\n element: this.container,\n };\n if (typeof options.bundlePath === 'string') options.bundlePath = withSlash(options.bundlePath);\n // The URL's filter groups start open, so the narrowed results explain themselves.\n const open = Object.keys(fromUrl);\n if (open.length) {\n const given = Array.isArray(options.openFilters) ? (options.openFilters as unknown[]) : [];\n options.openFilters = [...new Set([...given, ...open])];\n }\n const excerpt = num('excerpt-length');\n if (excerpt) options.excerptLength ??= excerpt;\n const lang = (document.documentElement.lang || 'en').toLowerCase();\n this.manyResults =\n typeof translations.many_results === 'string'\n ? translations.many_results\n : lang === 'en' || lang.startsWith('en-')\n ? MANY_RESULTS_EN\n : undefined;\n const ui = new PagefindUI(options);\n this._ui = ui;\n // Svelte renders synchronously, so the field exists now.\n const input = this.input;\n if (input) input.id = `${this.uid}-input`;\n this.listen();\n window.addEventListener('popstate', this.onPopState);\n const q = this.urlQuery();\n if (Object.keys(fromUrl).length) {\n this.resolveReady(ui);\n // Load the index (as focusing the field does) and wait for its filter list, so values\n // it lacks can be dropped before the one search.\n const drawn = new Promise<void>((r) => (this.filtersDrawn = r));\n input?.dispatchEvent(new Event('focus'));\n this.onMutation();\n let timer: ReturnType<typeof setTimeout> | undefined;\n await Promise.race([drawn, new Promise((r) => (timer = setTimeout(r, FILTER_WAIT_MS)))]);\n clearTimeout(timer);\n this.filtersDrawn = undefined;\n if (generation !== this.generation) return;\n this.applyUrl(fromUrl, q, !this.input?.value);\n return;\n }\n if (q) ui.triggerSearch(q);\n this.resolveReady(ui);\n }\n\n /**\n * The filter values Pagefind knows (matched without case, given in the index's own case),\n * from its filter checkboxes; values it does not have are dropped.\n */\n private known(filters: Filters): Filters {\n const boxes = this.boxes;\n const out: Filters = {};\n for (const [name, values] of Object.entries(filters)) {\n const have = boxes.filter((b) => b.name === name).map((b) => b.value);\n const found = values\n .map(\n (v) => have.find((h) => h === v) ?? have.find((h) => h.toLowerCase() === v.toLowerCase()),\n )\n .filter((v): v is string => v !== undefined);\n if (found.length) out[name] = [...new Set(found)];\n }\n return out;\n }\n\n /** The checked filters, by name. */\n private checked(): Filters {\n const out: Filters = {};\n for (const b of this.boxes) if (b.checked) (out[b.name] ??= []).push(b.value);\n return out;\n }\n\n /**\n * Apply the URL's filters (replacing those named in `filter-params`, keeping the others) and,\n * with `search`, its query, in one go: Pagefind runs one search for both.\n */\n private applyUrl(fromUrl: Filters, q: string, search: boolean): void {\n const ui = this._ui!;\n const names = this.filterParams;\n const selected = this.checked();\n for (const name of names) delete selected[name];\n const known = this.known(fromUrl);\n Object.assign(selected, known);\n const key = (f: Filters) =>\n JSON.stringify(\n Object.entries(f)\n .flatMap(([n, vs]) => vs.map((v) => `${n}:${v}`))\n .sort(),\n );\n if (key(selected) !== key(this.checked())) ui.triggerFilters(selected);\n for (const name of Object.keys(known)) {\n const box = this.boxes.find((b) => b.name === name);\n const details = box?.closest('details');\n if (details) details.open = true;\n }\n if (search) {\n const input = this.input;\n if (q) ui.triggerSearch(q);\n else if (input && input.value) {\n input.value = '';\n input.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n // Drop unknown values from the URL (and give known ones the index's case).\n this.writeFilters(selected);\n }\n\n /** The query in the page URL, or '' (always '' with `query-param=\"\"`). */\n private urlQuery(): string {\n return (this.queryParam && new URLSearchParams(location.search).get(this.queryParam)) || '';\n }\n\n /** Back and Forward: search for the URL's query, or clear the field when it has none. */\n private followUrl(): void {\n if (!this._ui) return;\n const q = this.urlQuery();\n const input = this.input;\n if (!input) return;\n const searchChanged = !!this.queryParam && input.value.trim() !== q;\n if (this.filterParams.length) {\n this.applyUrl(this.urlFilters(), q, searchChanged);\n return;\n }\n if (!searchChanged) return;\n if (q) {\n this._ui.triggerSearch(q);\n } else {\n input.value = '';\n input.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n\n private listen(): void {\n const c = this.container;\n // Pagefind blurs the field on Clear and Escape; bring focus back to it.\n c.addEventListener('click', (e) => {\n const t = e.target as Element;\n if (t.closest('.pagefind-ui__search-clear')) this.refocus();\n if (t.closest('.pagefind-ui__button')) {\n this.focusIndex = c.querySelectorAll('.pagefind-ui__results > li').length;\n }\n });\n // Capture, so the field's value is read before Pagefind empties it. Escape in an empty\n // field is left alone: it leaves the field (and can close a surrounding dialog).\n c.addEventListener(\n 'keydown',\n (e) => {\n const t = e.target as HTMLInputElement;\n if (e.key === 'Escape' && t.matches('.pagefind-ui__search-input') && t.value !== '')\n this.refocus();\n },\n true,\n );\n c.addEventListener('change', (e) => {\n const box = e.target as HTMLInputElement;\n if (!box.matches('.pagefind-ui__filter-checkbox')) return;\n trackEvent(this, [TAG, 'filter-change', `${box.name}: ${box.value}`, +box.checked]);\n if (this.filterParams.includes(box.name)) this.writeFilters(this.checked());\n });\n this.observer = new MutationObserver(() => this.onMutation());\n this.observer.observe(c, { childList: true, subtree: true, characterData: true });\n }\n\n private refocus(): void {\n setTimeout(() => this.input?.focus());\n }\n\n private onMutation(): void {\n const c = this.container;\n if (this.filtersDrawn && c.querySelector('.pagefind-ui__filter-checkbox')) this.filtersDrawn();\n for (const el of c.querySelectorAll('.pagefind-ui__loading:not([aria-hidden])'))\n el.setAttribute('aria-hidden', 'true');\n if (this.focusIndex !== undefined) {\n const item = c.querySelectorAll('.pagefind-ui__results > li')[this.focusIndex];\n const link = item?.querySelector<HTMLElement>('.pagefind-ui__result-link');\n if (link) {\n this.focusIndex = undefined;\n link.focus();\n }\n }\n clearTimeout(this.settleTimer);\n this.settleTimer = setTimeout(() => this.settle(), SETTLE_MS);\n }\n\n /**\n * The query in the field, its count and message, and a key for the query and checked\n * filters; undefined while results load (Pagefind's message is drawn before the results'\n * data, so a list with loading placeholders has not settled).\n */\n private settled(): { query: string; count: number; message: string; key: string } | undefined {\n const c = this.container;\n const query = (this.input?.value ?? '').trim();\n const area = c.querySelector('.pagefind-ui__results-area');\n const list = area?.querySelector('.pagefind-ui__results');\n if (!query || !list || list.querySelector('.pagefind-ui__loading')) return undefined;\n const message = area!.querySelector('.pagefind-ui__message')?.textContent?.trim() ?? '';\n const shown = list.children.length;\n // More results than shown: the count is the number in the message.\n const count = area!.querySelector('.pagefind-ui__button')\n ? (countFromMessage(message, query, this.manyResults) ?? shown)\n : shown;\n const filters = [...c.querySelectorAll<HTMLInputElement>('.pagefind-ui__filter-checkbox')]\n .filter((b) => b.checked)\n .map((b) => `${b.name}:${b.value}`)\n .sort();\n return { query, count, message, key: JSON.stringify([query, filters]) };\n }\n\n private settle(): void {\n if (this.filtersDrawn) return; // the URL's filters and query are not applied yet\n const s = this.settled();\n if (!s) {\n if (!(this.input?.value ?? '').trim()) this.cleared();\n return;\n }\n if (s.message && (s.message !== this.lastAnnounced || s.key !== this.lastTracked)) {\n this.announce(s.message);\n }\n if (s.key === this.lastTracked) return;\n this.lastTracked = s.key;\n this.writeQuery(s.query);\n trackSearch(this, s.query, 'Pagefind', s.count);\n this.dispatchEvent(\n new CustomEvent('search-results', { detail: { query: s.query, count: s.count } }),\n );\n }\n\n /** The field was emptied: clear the status and the URL, and say so once. */\n private cleared(): void {\n this.lastAnnounced = '';\n this.status.textContent = '';\n this.writeQuery('');\n if (!this.lastTracked) return;\n this.lastTracked = '';\n this.dispatchEvent(new CustomEvent('search-results', { detail: { query: '', count: 0 } }));\n }\n\n /** Put `message` in the status region; the same text again is emptied first, so it is read. */\n private announce(message: string): void {\n this.lastAnnounced = message;\n if (this.status.textContent !== message) {\n this.status.textContent = message;\n return;\n }\n this.status.textContent = '';\n setTimeout(() => (this.status.textContent = message), 100);\n }\n\n private writeQuery(query: string): void {\n const param = this.queryParam;\n if (!param) return;\n const url = new URL(location.href);\n if ((url.searchParams.get(param) ?? '') === query) return;\n if (query) url.searchParams.set(param, query);\n else url.searchParams.delete(param);\n this.replaceUrl(url);\n }\n\n /** Write the `filter-params` filters to the URL, keeping every other parameter. */\n private writeFilters(filters: Filters): void {\n const url = new URL(location.href);\n const p = url.searchParams;\n const names = this.filterParams.filter(\n (n) => JSON.stringify(p.getAll(n)) !== JSON.stringify(filters[n] ?? []),\n );\n if (!names.length) return;\n for (const name of names) {\n p.delete(name);\n for (const v of filters[name] ?? []) p.append(name, v);\n }\n this.replaceUrl(url);\n }\n\n private replaceUrl(url: URL): void {\n try {\n history.replaceState(history.state, '', url);\n } catch {\n // A document whose URL cannot change (about:srcdoc): keep the search, skip the URL.\n }\n }\n}\n","import { UvalibPagefindSearch } from './UvalibPagefindSearch.js';\n\n// Not base/define.js: every other entry shares it inside the Lit base chunk, and this entry\n// (which has no Lit) importing it alone would split it into a chunk of its own, adding a\n// request and bytes to every other element.\nif (!customElements.get('uvalib-pagefind-search'))\n customElements.define('uvalib-pagefind-search', UvalibPagefindSearch);\n"],"mappings":";;AAYA,IAAMG,IAAM,0BAGCC,IAAY,KAGZC,IAAiB,KAMxBC,oBAAU,IAAI,IAA4C;AAChE,SAASC,EAAe,GAA6C;CACnE,IAAMC,IAAM;CACZ,IAAIA,EAAI,YAAY,OAAO,QAAQ,QAAQA,EAAI,UAAU;CACzD,IAAIC,IAAIH,EAAQ,IAAII,CAAG;CAavB,OAZKD,MACH,IAAI,IAAI,SAAS,GAAS,MAAW;EACnC,IAAME,IAAS,SAAS,cAAc,QAAQ;EAK9C,AAJA,EAAO,MAAMD,GACb,EAAO,eACLF,EAAI,aAAaI,EAAQJ,EAAI,UAAU,IAAIK,EAAO,gBAAI,MAAM,eAAe,CAAC,GAC9E,EAAO,gBAAgBA,EAAO,gBAAI,MAAM,kBAAkBH,GAAK,CAAC,GAChE,SAAS,KAAK,OAAOC,CAAM;CAC7B,CAAC,GACDF,EAAE,YAAYH,EAAQ,OAAOI,CAAG,CAAC,GACjCJ,EAAQ,IAAII,GAAKD,CAAC,IAEbA;AACT;AAGA,IAAMK,IAAgD;CACpD,UAAU;CACV,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,UAAU;CACV,UAAU;CACV,YAAY;CACZ,QAAQ;AACV,GAEIC,IAAkB,GAGhBC,KAAW,MACf,OAAOC,KAAM,cAAYA,KAAc,OAAO,eAAeA,CAAC,MAAM,OAAO,WAGvEC,KAAW,GAAqB,GAAa,MAAsC;CACvF,IAAI,CAACC,GAAM,OAAOC;CAClB,IAAI;EACF,IAAMH,IAAa,KAAK,MAAME,CAAI;EAClC,IAAIE,EAAMJ,CAAC,GAAG,OAAOA;CACvB,QAAQ,CAER;CAEA,OADA,Q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AM9B,KAAQ8B,GAAO;IACxB,EAAE,OAAO9B,CAAI;IACb,KAAK,IAAMvB,KAAKgD,EAAQzB,MAAS,CAAC,GAAG,EAAE,OAAOA,GAAMvB,CAAC;GACvD;GACA,KAAK,WAAW0E,CAAG;EADnB;CAEF;CAEA,WAAmB,GAAgB;EACjC,IAAI;GACF,QAAQ,aAAa,QAAQ,OAAO,IAAIA,CAAG;EAC7C,QAAQ,CAER;CACF;AACF;;ACjkBK,eAAe,IAAI,wBAAwB,KAC9C,eAAe,OAAO,0BAA0BxD,CAAoB"}
1
+ {"version":3,"file":"uvalib-pagefind-search.js","names":["trackEvent","trackError","trackSearch","TAG","SETTLE_MS","FILTER_WAIT_MS","HOLD_MAX_MS","MAX_SKELETON_ROWS","scripts","loadPagefindUI","win","p","src","script","resolve","reject","skeleton","bar","c","sub","row","subResults","el","rows","VISUALLY_HIDDEN","instanceCounter","isPlain","v","json","text","fallback","check","withSlash","path","MANY_RESULTS_EN","escapeRe","t","countFromMessage","rest","template","re","query","message","at","digits","UvalibPagefindSearch","_args","promise","params","out","name","values","bundlePath","placeholder","label","PagefindUI","generation","fromUrl","num","mergeIndex","m","translations","extra","options","open","given","excerpt","lang","ui","input","q","drawn","r","timer","boxes","filters","have","b","found","h","names","selected","known","key","f","n","vs","details","search","searchChanged","keepFold","fold","type","box","e","list","link","area","shown","count","s","param","url"],"sources":["../src/components/uvalib-pagefind-search/UvalibPagefindSearch.ts","../src/components/uvalib-pagefind-search/uvalib-pagefind-search.ts"],"sourcesContent":["import { trackError, trackEvent, trackSearch } from '../../base/analytics.js';\n\n/** The part of Pagefind's `PagefindUI` this element uses (pagefind-ui.js, 1.x). */\nexport interface PagefindUIInstance {\n triggerSearch(term: string): void;\n triggerFilters(filters: Record<string, string | string[]>): void;\n destroy(): void;\n}\ntype PagefindUIConstructor = new (options: Record<string, unknown>) => PagefindUIInstance;\ntype PagefindWindow = Window & { PagefindUI?: PagefindUIConstructor };\n\n/** The analytics category. */\nconst TAG = 'uvalib-pagefind-search';\n\n/** How long results must stay put before they are announced, reported and put in the URL. */\nexport const SETTLE_MS = 1000;\n\n/** How long to wait for Pagefind's filter list before searching without the URL's filters. */\nexport const FILTER_WAIT_MS = 10000;\n\n/** The longest a skeleton holds the results' space before Pagefind's own state shows. */\nexport const HOLD_MAX_MS = FILTER_WAIT_MS + 5000;\n\n/** Skeleton rows at most, whatever `page-size` says (only the first screenful matters). */\nconst MAX_SKELETON_ROWS = 25;\n\n/** Filters as Pagefind takes them: each name with its values. */\ntype Filters = Record<string, string[]>;\n\n/** Each script URL is loaded once, however many elements ask for it. */\nconst scripts = new Map<string, Promise<PagefindUIConstructor>>();\nfunction loadPagefindUI(src: string): Promise<PagefindUIConstructor> {\n const win = window as PagefindWindow;\n if (win.PagefindUI) return Promise.resolve(win.PagefindUI);\n let p = scripts.get(src);\n if (!p) {\n p = new Promise((resolve, reject) => {\n const script = document.createElement('script');\n script.src = src;\n script.onload = () =>\n win.PagefindUI ? resolve(win.PagefindUI) : reject(new Error('no PagefindUI'));\n script.onerror = () => reject(new Error(`could not load ${src}`));\n document.head.append(script);\n });\n p.catch(() => scripts.delete(src));\n scripts.set(src, p);\n }\n return p;\n}\n\n/**\n * Placeholder results, sized like pagefind.css's result rows (a title and three excerpt lines,\n * and two sections with `show-sub-results`), drawn with base.css's `.uvalib-skeleton-text`.\n */\nfunction skeleton(rows: number, subResults: boolean): HTMLElement {\n const bar = (c: string) => `<span class=\"uvalib-skeleton-text ${TAG}__skeleton-${c}\"></span>`;\n const sub = `<div class=\"${TAG}__skeleton-sub\">${bar('title')}${bar('line')}${bar('short')}</div>`;\n const row = `<div class=\"${TAG}__skeleton-result\">${bar('title')}${bar('line')}${bar('line')}${bar('short')}${subResults ? sub + sub : ''}</div>`;\n const el = document.createElement('div');\n el.className = `${TAG}__skeleton`;\n el.setAttribute('aria-hidden', 'true');\n el.innerHTML = bar('message') + row.repeat(rows);\n return el;\n}\n\n/** Hidden from sight but read by screen readers; inline, so it holds without pagefind.css. */\nconst VISUALLY_HIDDEN: Partial<CSSStyleDeclaration> = {\n position: 'absolute',\n width: '1px',\n height: '1px',\n margin: '-1px',\n padding: '0',\n overflow: 'hidden',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n border: '0',\n};\n\nlet instanceCounter = 0;\n\ntype Plain = Record<string, unknown>;\nconst isPlain = (v: unknown): v is Plain =>\n typeof v === 'object' && v !== null && Object.getPrototypeOf(v) === Object.prototype;\n\n/** Parse a JSON attribute; `check` says whether the value has the right shape. */\nconst json = <T>(text: string | null, fallback: T, check: (v: unknown) => boolean): T => {\n if (!text) return fallback;\n try {\n const v: unknown = JSON.parse(text);\n if (check(v)) return v as T;\n } catch {\n // reported below\n }\n console.warn(`${TAG}: ignoring an attribute that is not the expected JSON`, text);\n return fallback;\n};\n\n/** A bundle path always ends in `/`: Pagefind appends file names to it. */\nexport const withSlash = (path: string): string => (path.endsWith('/') ? path : `${path}/`);\n\n/** Pagefind's English \"many results\" message, used to read the count back out of it. */\nconst MANY_RESULTS_EN = '[COUNT] results for [SEARCH_TERM]';\nconst escapeRe = (t: string) => t.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n/**\n * The total count in Pagefind's message, or undefined. With the message's template (`[COUNT]`\n * and `[SEARCH_TERM]`), the query is matched in its own place, so digits in the query never\n * leak into the count; without one, only the query's last occurrence is taken out.\n */\nexport function countFromMessage(\n message: string,\n query: string,\n template?: string,\n): number | undefined {\n let rest: string | undefined;\n if (template?.includes('[COUNT]')) {\n const re = new RegExp(\n `^${escapeRe(template)\n .replace(escapeRe('[COUNT]'), '(.+?)')\n .replace(escapeRe('[SEARCH_TERM]'), escapeRe(query))}$`,\n );\n rest = message.match(re)?.[1];\n }\n if (rest === undefined) {\n const at = message.lastIndexOf(query);\n rest = at < 0 ? message : message.slice(0, at) + ' ' + message.slice(at + query.length);\n }\n const digits = rest.match(/\\d[\\d.,\\s\\u00a0\\u202f]*/);\n return digits ? Number(digits[0].replace(/\\D/g, '')) : undefined;\n}\n\n/**\n * Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle) with the\n * library's defaults and the accessibility fixes that need script. Use it with pagefind.css,\n * in place of Pagefind's pagefind-ui.css. It renders in light DOM, so the page's styles reach\n * Pagefind's markup. It loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI`\n * already exists.\n *\n * What it adds to the stock UI: a visible `<label>` for the field (the stock field is named\n * only by its title); a polite status region that announces the result count (\"12 results\n * for virginia\") once results settle (the stock message is not a live region); focus kept in\n * the field after Clear or Escape (the stock UI blurs it, dropping focus to the page) and\n * moved to the first new result after \"Load more results\"; the loading placeholders' dots\n * hidden from screen readers; `?q=` read at start (and on Back and Forward) and the settled\n * query written back with `history.replaceState`, so a search can be shared; with\n * `filter-params`, the named Pagefind filters read from and written to the URL the same way;\n * and reports to `<site-analytics>`. While a search from the URL loads, it can hold the page\n * still (issue #37): with `searching` set in the page's HTML when the URL has a query, the\n * element holds a screen's height from first paint, and placeholder results (aria-hidden) stand\n * in for Pagefind's until they, or \"no results\", are drawn; the element then still reaches the\n * bottom of the window until the visitor uses the search, so a short list does not pull the\n * footer up. It does the same on Back and Forward to a new query. The\n * `ui` property is the `PagefindUI` instance (for `triggerFilters`), and `ready` resolves\n * with it. Attributes are read once, when the element is first connected.\n *\n * @tagname uvalib-pagefind-search\n * @attr {string} [bundle-path=/pagefind/] - The Pagefind bundle's URL path, ending in `/`.\n * @attr {string} merge-index - JSON array of more indexes to search together: `[{\"bundlePath\": \"/pagefind/s1/\"}]`.\n * @attr {number} [page-size=10] - Results shown before \"Load more results\".\n * @attr {number} excerpt-length - Words per excerpt (Pagefind's default: 30, or 12 with sub-results).\n * @attr {boolean} show-sub-results - Also list the matching sections of each page.\n * @attr {boolean} show-images - Show each result's `image` metadata (off by default).\n * @attr {string} [placeholder=Search] - The field's placeholder.\n * @attr {string} label - The field's visible label. Empty (the default) uses the placeholder.\n * @attr {boolean} label-hidden - Keep the label for screen readers only.\n * @attr {string} translations - JSON of Pagefind UI strings to override (`{\"zero_results\": \"…\"}`).\n * @attr {string} options - JSON of any other `PagefindUI` options (`{\"openFilters\": [\"author\"]}`), applied last.\n * @attr {string} [query-param=q] - The URL parameter that holds the query; empty turns it off.\n * @attr {boolean} searching - 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.\n * @attr {boolean} no-skeleton - Never hold space or show placeholder results (`searching` is ignored).\n * @attr {string} filter-params - 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.\n * @fires search-results - Results settled: `detail` is `{ query, count }`; `{ query: '', count: 0 }` when the field is emptied after a search. Does not bubble.\n * @fires uvalib-analytics-search - For `<site-analytics>`: the settled query, category `Pagefind` and its result count, once per query and filter set. Bubbles and is composed.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-pagefind-search', 'filter-change', '<filter>: <value>', 1 | 0]` (checked or unchecked), and `['uvalib-pagefind-search', 'error', 'load']` if Pagefind cannot be loaded. Bubbles and is composed.\n */\nexport class UvalibPagefindSearch extends HTMLElement {\n /** Bumped by each start and teardown, so a start still loading after removal stops. */\n private generation = 0;\n private started = false;\n private _ui?: PagefindUIInstance;\n private resolveReady!: (ui: PagefindUIInstance) => void;\n private _ready: Promise<PagefindUIInstance> = this.newReady();\n private readonly uid = `${TAG}-${++instanceCounter}`;\n private container = document.createElement('div');\n private readonly status = document.createElement('p');\n private observer?: MutationObserver;\n private settleTimer?: ReturnType<typeof setTimeout>;\n private lastAnnounced = '';\n private lastTracked = '';\n /** The \"many results\" template, to read the count back out of Pagefind's message. */\n private manyResults?: string;\n /** After \"Load more results\": the index of the first new result, to focus once it loads. */\n private focusIndex?: number;\n private readonly onPopState = () => this.followUrl();\n /** Resolves once Pagefind has drawn its filter checkboxes (set only while waiting for them). */\n private filtersDrawn?: () => void;\n /** The placeholder results, while a search from the URL loads. */\n private skeleton?: HTMLElement;\n /** The results list when the hold began (Pagefind draws a new one for the new results). */\n private heldList?: Element | null;\n private holdTimer?: ReturnType<typeof setTimeout>;\n /** The page's own inline min-block-size, while the element keeps the fold after a hold. */\n private ownMinSize?: string;\n\n private newReady(): Promise<PagefindUIInstance> {\n const { promise, resolve } = Promise.withResolvers<PagefindUIInstance>();\n this.resolveReady = resolve;\n return promise;\n }\n\n /**\n * Resolves with the `PagefindUI` instance once it is created (a new promise after the\n * element is removed and inserted again).\n */\n get ready(): Promise<PagefindUIInstance> {\n return this._ready;\n }\n\n /** The `PagefindUI` instance (for `triggerSearch` / `triggerFilters`), once created. */\n get ui(): PagefindUIInstance | undefined {\n return this._ui;\n }\n\n private get input(): HTMLInputElement | null {\n return this.container.querySelector('.pagefind-ui__search-input');\n }\n\n private get queryParam(): string {\n return this.getAttribute('query-param') ?? 'q';\n }\n\n /** The filter names in `filter-params`. */\n private get filterParams(): string[] {\n return (this.getAttribute('filter-params') ?? '').split(/\\s+/).filter(Boolean);\n }\n\n private get boxes(): HTMLInputElement[] {\n return [...this.container.querySelectorAll<HTMLInputElement>('.pagefind-ui__filter-checkbox')];\n }\n\n /** The `filter-params` filters in the page URL that have values (repeated params: several). */\n private urlFilters(): Filters {\n const params = new URLSearchParams(location.search);\n const out: Filters = {};\n for (const name of this.filterParams) {\n const values = params.getAll(name).filter(Boolean);\n if (values.length) out[name] = values;\n }\n return out;\n }\n\n connectedCallback(): void {\n if (this.started) return;\n this.started = true;\n void this.start(++this.generation);\n }\n\n disconnectedCallback(): void {\n // Moving the element (removed and inserted in one task) keeps its search; removing it\n // for good destroys the Pagefind UI, so inserting it again starts afresh.\n queueMicrotask(() => {\n if (!this.isConnected && this.started) this.teardown();\n });\n }\n\n private teardown(): void {\n this.generation++;\n this.started = false;\n clearTimeout(this.settleTimer);\n this.release();\n this.unkeep();\n this.observer?.disconnect();\n this.observer = undefined;\n window.removeEventListener('popstate', this.onPopState);\n try {\n this._ui?.destroy();\n } catch {\n // Pagefind's own teardown failing must not stop ours.\n }\n if (this._ui) this._ready = this.newReady();\n this._ui = undefined;\n this.container.remove();\n this.container = document.createElement('div');\n this.querySelector(`:scope > .${TAG}__label`)?.remove();\n this.status.remove();\n this.status.textContent = '';\n this.lastAnnounced = this.lastTracked = '';\n this.focusIndex = undefined;\n }\n\n private async start(generation: number): Promise<void> {\n const bundlePath = withSlash(this.getAttribute('bundle-path') || '/pagefind/');\n const placeholder = this.getAttribute('placeholder') || 'Search';\n const label = document.createElement('label');\n label.className = `${TAG}__label`;\n label.htmlFor = `${this.uid}-input`;\n label.textContent = this.getAttribute('label') || placeholder;\n if (this.hasAttribute('label-hidden')) Object.assign(label.style, VISUALLY_HIDDEN);\n this.container.className = `${TAG}__ui`;\n this.status.className = `${TAG}__status`;\n this.status.setAttribute('role', 'status');\n Object.assign(this.status.style, VISUALLY_HIDDEN);\n this.append(label, this.container, this.status);\n // Starting with a query and `searching` (set by the page, so the space is held from first\n // paint), show placeholders until the results are drawn. Without it the element does not\n // hold: this script runs after first paint, so holding now would push what is in view\n // (the footer) down as far as the results would, and further on a short list.\n if (this.urlQuery() && this.hasAttribute('searching')) this.hold();\n else this.removeAttribute('searching');\n\n let PagefindUI: PagefindUIConstructor;\n try {\n PagefindUI = await loadPagefindUI(`${bundlePath}pagefind-ui.js`);\n } catch {\n if (generation !== this.generation) return;\n this.release();\n trackError(this, TAG, 'load');\n label.remove();\n const p = document.createElement('p');\n p.className = `${TAG}__error`;\n p.textContent = 'Search is not available right now. Please try again later.';\n this.container.append(p);\n return;\n }\n if (generation !== this.generation) return; // removed while the script loaded\n const fromUrl = this.urlFilters();\n const num = (name: string, fallback?: number) => {\n const n = Number.parseInt(this.getAttribute(name) ?? '', 10);\n return Number.isFinite(n) && n > 0 ? n : fallback;\n };\n const mergeIndex = json<unknown[]>(this.getAttribute('merge-index'), [], Array.isArray)\n .filter((m): m is Plain => isPlain(m) && typeof m.bundlePath === 'string')\n .map((m) => ({ ...m, bundlePath: withSlash(m.bundlePath as string) }));\n const translations: Plain = {\n placeholder,\n ...json<Plain>(this.getAttribute('translations'), {}, isPlain),\n };\n const extra = json<Plain>(this.getAttribute('options'), {}, isPlain);\n const options: Plain = {\n bundlePath,\n mergeIndex,\n pageSize: num('page-size', 10),\n showSubResults: this.hasAttribute('show-sub-results'),\n showImages: this.hasAttribute('show-images'),\n ...extra,\n translations,\n // Always this element's own container: the label, status and focus fixes live there.\n element: this.container,\n };\n if (typeof options.bundlePath === 'string') options.bundlePath = withSlash(options.bundlePath);\n // The URL's filter groups start open, so the narrowed results explain themselves.\n const open = Object.keys(fromUrl);\n if (open.length) {\n const given = Array.isArray(options.openFilters) ? (options.openFilters as unknown[]) : [];\n options.openFilters = [...new Set([...given, ...open])];\n }\n const excerpt = num('excerpt-length');\n if (excerpt) options.excerptLength ??= excerpt;\n const lang = (document.documentElement.lang || 'en').toLowerCase();\n this.manyResults =\n typeof translations.many_results === 'string'\n ? translations.many_results\n : lang === 'en' || lang.startsWith('en-')\n ? MANY_RESULTS_EN\n : undefined;\n const ui = new PagefindUI(options);\n this._ui = ui;\n // Svelte renders synchronously, so the field exists now.\n const input = this.input;\n if (input) input.id = `${this.uid}-input`;\n this.listen();\n window.addEventListener('popstate', this.onPopState);\n const q = this.urlQuery();\n if (Object.keys(fromUrl).length) {\n this.resolveReady(ui);\n // Load the index (as focusing the field does) and wait for its filter list, so values\n // it lacks can be dropped before the one search.\n const drawn = new Promise<void>((r) => (this.filtersDrawn = r));\n input?.dispatchEvent(new Event('focus'));\n this.onMutation();\n let timer: ReturnType<typeof setTimeout> | undefined;\n await Promise.race([drawn, new Promise((r) => (timer = setTimeout(r, FILTER_WAIT_MS)))]);\n clearTimeout(timer);\n this.filtersDrawn = undefined;\n if (generation !== this.generation) return;\n this.applyUrl(fromUrl, q, !this.input?.value);\n return;\n }\n if (q) ui.triggerSearch(q);\n this.resolveReady(ui);\n }\n\n /**\n * The filter values Pagefind knows (matched without case, given in the index's own case),\n * from its filter checkboxes; values it does not have are dropped.\n */\n private known(filters: Filters): Filters {\n const boxes = this.boxes;\n const out: Filters = {};\n for (const [name, values] of Object.entries(filters)) {\n const have = boxes.filter((b) => b.name === name).map((b) => b.value);\n const found = values\n .map(\n (v) => have.find((h) => h === v) ?? have.find((h) => h.toLowerCase() === v.toLowerCase()),\n )\n .filter((v): v is string => v !== undefined);\n if (found.length) out[name] = [...new Set(found)];\n }\n return out;\n }\n\n /** The checked filters, by name. */\n private checked(): Filters {\n const out: Filters = {};\n for (const b of this.boxes) if (b.checked) (out[b.name] ??= []).push(b.value);\n return out;\n }\n\n /**\n * Apply the URL's filters (replacing those named in `filter-params`, keeping the others) and,\n * with `search`, its query, in one go: Pagefind runs one search for both.\n */\n private applyUrl(fromUrl: Filters, q: string, search: boolean): void {\n const ui = this._ui!;\n const names = this.filterParams;\n const selected = this.checked();\n for (const name of names) delete selected[name];\n const known = this.known(fromUrl);\n Object.assign(selected, known);\n const key = (f: Filters) =>\n JSON.stringify(\n Object.entries(f)\n .flatMap(([n, vs]) => vs.map((v) => `${n}:${v}`))\n .sort(),\n );\n if (key(selected) !== key(this.checked())) ui.triggerFilters(selected);\n for (const name of Object.keys(known)) {\n const box = this.boxes.find((b) => b.name === name);\n const details = box?.closest('details');\n if (details) details.open = true;\n }\n if (search) {\n const input = this.input;\n if (q) ui.triggerSearch(q);\n else if (input && input.value) {\n input.value = '';\n input.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n // Drop unknown values from the URL (and give known ones the index's case).\n this.writeFilters(selected);\n }\n\n /** The query in the page URL, or '' (always '' with `query-param=\"\"`). */\n private urlQuery(): string {\n return (this.queryParam && new URLSearchParams(location.search).get(this.queryParam)) || '';\n }\n\n /** Back and Forward: search for the URL's query, or clear the field when it has none. */\n private followUrl(): void {\n if (!this._ui) return;\n const q = this.urlQuery();\n const input = this.input;\n if (!input) return;\n const searchChanged = !!this.queryParam && input.value.trim() !== q;\n if (q && searchChanged) this.hold();\n if (this.filterParams.length) {\n this.applyUrl(this.urlFilters(), q, searchChanged);\n return;\n }\n if (!searchChanged) return;\n if (q) {\n this._ui.triggerSearch(q);\n } else {\n input.value = '';\n input.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n\n /** Show placeholder results in place of Pagefind's until the new results are drawn. */\n private hold(): void {\n if (this.hasAttribute('no-skeleton')) {\n this.removeAttribute('searching');\n return;\n }\n this.release();\n this.unkeep();\n const n = Number.parseInt(this.getAttribute('page-size') ?? '', 10);\n const rows = Math.min(Number.isFinite(n) && n > 0 ? n : 10, MAX_SKELETON_ROWS);\n this.skeleton = skeleton(rows, this.hasAttribute('show-sub-results'));\n this.heldList = this.container.querySelector('.pagefind-ui__results');\n this.container.after(this.skeleton);\n this.setAttribute('searching', '');\n this.holdTimer = setTimeout(() => this.release(), HOLD_MAX_MS);\n }\n\n /**\n * Drop the placeholders and show Pagefind's results area again. With `keepFold` (the results\n * are drawn), the element keeps reaching the bottom of the window until the visitor uses the\n * search, so a short list does not pull the footer up into view (a layout shift).\n */\n private release(keepFold = false): void {\n clearTimeout(this.holdTimer);\n if (keepFold && this.skeleton) {\n const fold = Math.ceil(window.innerHeight - this.getBoundingClientRect().top);\n if (fold > 0) {\n this.ownMinSize ??= this.style.minBlockSize;\n this.style.minBlockSize = `${fold}px`;\n }\n }\n this.skeleton?.remove();\n this.skeleton = undefined;\n this.removeAttribute('searching');\n }\n\n /** Let go of the fold kept after a hold (the page's own inline min-block-size, if any, back). */\n private unkeep(): void {\n if (this.ownMinSize === undefined) return;\n this.style.minBlockSize = this.ownMinSize;\n this.ownMinSize = undefined;\n }\n\n private listen(): void {\n const c = this.container;\n // The visitor typing, clearing or clicking takes over from a search from the URL.\n for (const type of ['input', 'click'])\n c.addEventListener(type, () => {\n this.release();\n this.unkeep();\n });\n // Pagefind blurs the field on Clear and Escape; bring focus back to it.\n c.addEventListener('click', (e) => {\n const t = e.target as Element;\n if (t.closest('.pagefind-ui__search-clear')) this.refocus();\n if (t.closest('.pagefind-ui__button')) {\n this.focusIndex = c.querySelectorAll('.pagefind-ui__results > li').length;\n }\n });\n // Capture, so the field's value is read before Pagefind empties it. Escape in an empty\n // field is left alone: it leaves the field (and can close a surrounding dialog).\n c.addEventListener(\n 'keydown',\n (e) => {\n const t = e.target as HTMLInputElement;\n if (e.key === 'Escape' && t.matches('.pagefind-ui__search-input') && t.value !== '')\n this.refocus();\n },\n true,\n );\n c.addEventListener('change', (e) => {\n const box = e.target as HTMLInputElement;\n if (!box.matches('.pagefind-ui__filter-checkbox')) return;\n trackEvent(this, [TAG, 'filter-change', `${box.name}: ${box.value}`, +box.checked]);\n if (this.filterParams.includes(box.name)) this.writeFilters(this.checked());\n });\n this.observer = new MutationObserver(() => this.onMutation());\n this.observer.observe(c, { childList: true, subtree: true, characterData: true });\n }\n\n private refocus(): void {\n setTimeout(() => this.input?.focus());\n }\n\n private onMutation(): void {\n const c = this.container;\n if (this.skeleton) {\n // Released once a new results list (or \"no results\", an empty one) has fully loaded.\n const list = c.querySelector('.pagefind-ui__results');\n if (list && list !== this.heldList && !list.querySelector('.pagefind-ui__loading'))\n this.release(true);\n }\n if (this.filtersDrawn && c.querySelector('.pagefind-ui__filter-checkbox')) this.filtersDrawn();\n for (const el of c.querySelectorAll('.pagefind-ui__loading:not([aria-hidden])'))\n el.setAttribute('aria-hidden', 'true');\n if (this.focusIndex !== undefined) {\n const item = c.querySelectorAll('.pagefind-ui__results > li')[this.focusIndex];\n const link = item?.querySelector<HTMLElement>('.pagefind-ui__result-link');\n if (link) {\n this.focusIndex = undefined;\n link.focus();\n }\n }\n clearTimeout(this.settleTimer);\n this.settleTimer = setTimeout(() => this.settle(), SETTLE_MS);\n }\n\n /**\n * The query in the field, its count and message, and a key for the query and checked\n * filters; undefined while results load (Pagefind's message is drawn before the results'\n * data, so a list with loading placeholders has not settled).\n */\n private settled(): { query: string; count: number; message: string; key: string } | undefined {\n const c = this.container;\n const query = (this.input?.value ?? '').trim();\n const area = c.querySelector('.pagefind-ui__results-area');\n const list = area?.querySelector('.pagefind-ui__results');\n if (!query || !list || list.querySelector('.pagefind-ui__loading')) return undefined;\n const message = area!.querySelector('.pagefind-ui__message')?.textContent?.trim() ?? '';\n const shown = list.children.length;\n // More results than shown: the count is the number in the message.\n const count = area!.querySelector('.pagefind-ui__button')\n ? (countFromMessage(message, query, this.manyResults) ?? shown)\n : shown;\n const filters = [...c.querySelectorAll<HTMLInputElement>('.pagefind-ui__filter-checkbox')]\n .filter((b) => b.checked)\n .map((b) => `${b.name}:${b.value}`)\n .sort();\n return { query, count, message, key: JSON.stringify([query, filters]) };\n }\n\n private settle(): void {\n if (this.filtersDrawn) return; // the URL's filters and query are not applied yet\n const s = this.settled();\n if (!s) {\n if (!(this.input?.value ?? '').trim()) this.cleared();\n return;\n }\n if (s.message && (s.message !== this.lastAnnounced || s.key !== this.lastTracked)) {\n this.announce(s.message);\n }\n if (s.key === this.lastTracked) return;\n this.lastTracked = s.key;\n this.writeQuery(s.query);\n trackSearch(this, s.query, 'Pagefind', s.count);\n this.dispatchEvent(\n new CustomEvent('search-results', { detail: { query: s.query, count: s.count } }),\n );\n }\n\n /** The field was emptied: clear the status and the URL, and say so once. */\n private cleared(): void {\n this.lastAnnounced = '';\n this.status.textContent = '';\n this.writeQuery('');\n if (!this.lastTracked) return;\n this.lastTracked = '';\n this.dispatchEvent(new CustomEvent('search-results', { detail: { query: '', count: 0 } }));\n }\n\n /** Put `message` in the status region; the same text again is emptied first, so it is read. */\n private announce(message: string): void {\n this.lastAnnounced = message;\n if (this.status.textContent !== message) {\n this.status.textContent = message;\n return;\n }\n this.status.textContent = '';\n setTimeout(() => (this.status.textContent = message), 100);\n }\n\n private writeQuery(query: string): void {\n const param = this.queryParam;\n if (!param) return;\n const url = new URL(location.href);\n if ((url.searchParams.get(param) ?? '') === query) return;\n if (query) url.searchParams.set(param, query);\n else url.searchParams.delete(param);\n this.replaceUrl(url);\n }\n\n /** Write the `filter-params` filters to the URL, keeping every other parameter. */\n private writeFilters(filters: Filters): void {\n const url = new URL(location.href);\n const p = url.searchParams;\n const names = this.filterParams.filter(\n (n) => JSON.stringify(p.getAll(n)) !== JSON.stringify(filters[n] ?? []),\n );\n if (!names.length) return;\n for (const name of names) {\n p.delete(name);\n for (const v of filters[name] ?? []) p.append(name, v);\n }\n this.replaceUrl(url);\n }\n\n private replaceUrl(url: URL): void {\n try {\n history.replaceState(history.state, '', url);\n } catch {\n // A document whose URL cannot change (about:srcdoc): keep the search, skip the URL.\n }\n }\n}\n","import { UvalibPagefindSearch } from './UvalibPagefindSearch.js';\n\n// Not base/define.js: every other entry shares it inside the Lit base chunk, and this entry\n// (which has no Lit) importing it alone would split it into a chunk of its own, adding a\n// request and bytes to every other element.\nif (!customElements.get('uvalib-pagefind-search'))\n customElements.define('uvalib-pagefind-search', UvalibPagefindSearch);\n"],"mappings":";;AAYA,IAAMG,IAAM,0BAGCC,IAAY,KAGZC,IAAiB,KAGjBC,IAAc,MAGrBC,IAAoB,IAMpBC,oBAAU,IAAI,IAA4C;AAChE,SAASC,EAAe,GAA6C;CACnE,IAAMC,IAAM;CACZ,IAAIA,EAAI,YAAY,OAAO,QAAQ,QAAQA,EAAI,UAAU;CACzD,IAAIC,IAAIH,EAAQ,IAAII,CAAG;CAavB,OAZKD,MACH,IAAI,IAAI,SAAS,GAAS,MAAW;EACnC,IAAME,IAAS,SAAS,cAAc,QAAQ;EAK9C,AAJA,EAAO,MAAMD,GACb,EAAO,eACLF,EAAI,aAAaI,EAAQJ,EAAI,UAAU,IAAIK,EAAO,gBAAI,MAAM,eAAe,CAAC,GAC9E,EAAO,gBAAgBA,EAAO,gBAAI,MAAM,kBAAkBH,GAAK,CAAC,GAChE,SAAS,KAAK,OAAOC,CAAM;CAC7B,CAAC,GACDF,EAAE,YAAYH,EAAQ,OAAOI,CAAG,CAAC,GACjCJ,EAAQ,IAAII,GAAKD,CA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CAAC,GAAG,EAAE,OAAOA,GAAMvB,CAAC;GACvD;GACA,KAAK,WAAW2E,CAAG;EADnB;CAEF;CAEA,WAAmB,GAAgB;EACjC,IAAI;GACF,QAAQ,aAAa,QAAQ,OAAO,IAAIA,CAAG;EAC7C,QAAQ,CAER;CACF;AACF;;ACrqBK,eAAe,IAAI,wBAAwB,KAC9C,eAAe,OAAO,0BAA0BzD,CAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uvalib/web-components",
3
- "version": "1.10.0",
3
+ "version": "1.11.1",
4
4
  "description": "UVA Library reusable web components",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,8 +40,8 @@ Loading rules:
40
40
  - `<site-page>` renders the one skip link, the header, one `<main id="main-content">` and the footer. Never add your own `<main>`, skip link, `<header>`/`<footer>` site chrome, or `role="main"`. If the page already has them, remove them and keep only the content that was inside `<main>`.
41
41
  - Sidebars and article content go inside `<site-page>` as ordinary elements (use `<nav aria-label="...">` for navigation, no ARIA menu roles).
42
42
  - Breadcrumbs: a `<uvalib-breadcrumbs slot="breadcrumbs">` (from `uvalib-breadcrumbs.js`) inside `<site-page>`, never a hand-built trail. Its children are `<a href>` links ending with the current page (`<span>Title</span>`, or `<a href aria-current="page">`); apps can set its `items` property (`[{ label, href? }]`) instead. `<site-page>` places it between the header and `<main>`, outside `<main>`. Outside `<site-page>` it goes first in the content, above the `<h1>`. To return to the search the visitor came from, give that crumb `data-return-from="<search path>"` (it links to the same-origin referrer when it is that path with a query), never an inline script. In a single-page app with history routing, listen for `uvalib-breadcrumbs-navigate` and call `preventDefault()` to route in place (hash links need nothing).
43
- - Cards and paging: a collection or photo is a `<uvalib-card>` (`uvalib-card.js`), inside `<uvalib-card-grid>` (`uvalib-card-grid.js`) when there are several. `href` makes the heading the one link for the whole card: never wrap the card in an `<a>`, and do not put another link, button or other control inside a clickable card. The heading needs an accessible name, or the link is hidden. A card with no `href` may contain its own links, including an `actions` slot row (“Read the story”, “Photos (132)”). Do not put that row in a clickable card: the card link covers it, and the component warns. `media-shape="circle"` draws a person or avatar as a circle and keeps the image alt; the count badge still sits on it. An image needs a real alt, or `alt=""` when the heading already names it. Previous/next sections, numbered pages, or `mode="load-more"` (a Load more button and “Showing N of M”, or “Showing N” with no `total`; with an unknown total add `has-more` and remove it, or set `hasMore = false`, after the last page) are one `<uvalib-pager>` (`uvalib-pager.js`); a second pager on the same page needs its own `label`. Load more fires `load-more` (`detail: { page }`, the next page). Call `loaded(firstNew)`, or set `for` to the list id and call `loaded()`, so focus moves to the new item. `<uvalib-tabs>` (`uvalib-tabs.js`) is a tab set: each child with `data-tab` is a panel, or pair `<button slot="tab">` with panels. Arrow keys move, Home and End jump, and `activation="manual"` waits for Enter or Space. `url-param` (or `url-param="hash"`) makes the selected tab linkable and Back restores it. In a single-page app, listen for `uvalib-card-navigate` and `uvalib-pager-navigate` and call `preventDefault()` to route in place.
44
- - Sub-navigation and tables of contents: a `<uvalib-contents>` (from `uvalib-contents.js`) holding one `<ol>`/`<ul>` of `<li><a href>` entries, nested lists for sub-entries (plain text in an `<li>` for a group label), never a hand-built `<nav>` list or `<details>` for it. It is the `<nav>` landmark (named and headed by `label`, default "Contents"; set `heading-level` to fit the outline) and marks the current page (`aria-current="page"`) and in-page section (`"location"`, from the hash) itself: do not add `aria-current` by hand unless the route is not the URL, and then prefer `current="<url>"`. It collapses into a disclosure button at 64rem and below (`collapse-below`), closed until opened. In a sidebar add `sticky` (or, in a `.uvalib-sidebar-layout`, the layout's `--sticky`; never both). For a long document's table of contents without a build-time list, `headings-from="#article"` (with `levels="2-3"`, `min`) builds it from the headings and adds ids; a build-time list (children) is better where possible, since it works without JavaScript. Apps can set `items` (`[{ label, href?, children? }]`); with history routing, cancel `uvalib-contents-navigate` to route in place.
43
+ - Cards and paging: a collection or photo is a `<uvalib-card>` (`uvalib-card.js`), inside `<uvalib-card-grid>` (`uvalib-card-grid.js`) when there are several. `href` makes the heading the one link for the whole card: never wrap the card in an `<a>`, and do not put another link, button or other control inside a clickable card. The heading needs an accessible name, or the link is hidden. A card with no `href` may contain its own links, including an `actions` slot row (“Read the story”, “Photos (132)”). Do not put that row in a clickable card: the card link covers it, and the component warns. `media-shape="circle"` draws a person or avatar as a circle and keeps the image alt; the count badge still sits on it. An image needs a real alt, or `alt=""` when the heading already names it. Previous/next sections, numbered pages, or `mode="load-more"` (a Load more button and “Showing N of M”, or “Showing N” with no `total`; with an unknown total add `has-more` and remove it, or set `hasMore = false`, after the last page) are one `<uvalib-pager>` (`uvalib-pager.js`); a second pager on the same page needs its own `label`. base.css holds the pager's space from its attributes before it upgrades: write the titles into `prev-label`/`next-label` in the HTML, and `has-more="false"` on a last Load more page. Load more fires `load-more` (`detail: { page }`, the next page). Call `loaded(firstNew)`, or set `for` to the list id and call `loaded()`, so focus moves to the new item. `<uvalib-tabs>` (`uvalib-tabs.js`) is a tab set: each child with `data-tab` is a panel, or pair `<button slot="tab">` with panels. Arrow keys move, Home and End jump, and `activation="manual"` waits for Enter or Space. `url-param` (or `url-param="hash"`) makes the selected tab linkable and Back restores it. In a single-page app, listen for `uvalib-card-navigate` and `uvalib-pager-navigate` and call `preventDefault()` to route in place.
44
+ - Sub-navigation and tables of contents: a `<uvalib-contents>` (from `uvalib-contents.js`) holding one `<ol>`/`<ul>` of `<li><a href>` entries, nested lists for sub-entries (plain text in an `<li>` for a group label), never a hand-built `<nav>` list or `<details>` for it. It is the `<nav>` landmark (named and headed by `label`, default "Contents"; set `heading-level` to fit the outline) and marks the current page (`aria-current="page"`) and in-page section (`"location"`, from the hash) itself: do not add `aria-current` by hand unless the route is not the URL, and then prefer `current="<url>"`. It collapses into a disclosure button at 64rem and below (`collapse-below`), closed until opened. In a sidebar add `sticky` (or, in a `.uvalib-sidebar-layout`, the layout's `--sticky`; never both). For a long document's table of contents without a build-time list, `headings-from="#article"` (with `levels="2-3"`, `min`) builds it from the headings and adds ids; a build-time list (children) is better where possible, since it works without JavaScript. Apps can set `items` (`[{ label, href?, children? }]`); with history routing, cancel `uvalib-contents-navigate` to route in place. For a very long contents (hundreds of sections, each a page), write only the entries near the current one (with their parents) and set `full-href` to the full contents and `total` (its entry count): the component draws "Full contents (243 sections)" after the list and tells screen readers the list is partial; never add that link as a last `<li>`. With the whole list in the page, `window="12"` shows the current entry and 12 either side (a Show all button without `full-href`).
45
45
  - Record details: a `<uvalib-metadata>` (from `uvalib-metadata.js`) around a plain `<dl>` (`<dt>` label, `<dd>` values; lists such as subjects as a `<ul>` in the `<dd>`). Downloads are `<a href download data-size="184 KB">EPUB</a>`. For credit and rights use its attributes, not your own rows: `creator`, `organization`, `rights` (a rightsstatements.org or Creative Commons URL; it shows the short name), `rights-info` (`https://www.library.virginia.edu/policies/use-of-materials`) and `citation` or `citation-title` (the Special Collections citation "<title>, Albert and Shirley Small Special Collections Library, University of Virginia"), which adds a Copy citation button. A long list (30 participants) gets `list-limit="8"` (or `data-limit` on its `<dd>`), not your own Show more script. Do not add icons from rightsstatements.org or creativecommons.org. With `base.css` linked the page does not move when it upgrades, including `list-limit` (or `data-limit`) from 1 to 12; for a larger limit add the page rule from the README ("No jump on upgrade").
46
46
  - Citations in several formats (a record's Cite dialog or a "Cite this item" block): a `<uvalib-citation>` (from `uvalib-citation.js`), never a hand-built tab set, select, copy script or toast. Give each format as `<blockquote data-format="MLA">…</blockquote>` (keep `<i>` for titles; nothing else is kept as markup), or set `citations` (`[{ format, text, html? }]`) in an app; never fetch HTML into it. It draws a "Citation format" radio group (not tabs), the selected citation as selectable text, a 44px Copy citation button (plain text plus HTML, so italics survive a paste) with a polite "MLA citation copied" status, and with `ris-href` a Download RIS link; more export links go in `slot="actions"`. `format` picks the default; `remember` keeps the visitor's last choice per site. In a dialog, add `hide-label` when the dialog's heading says "Cite this item". With `base.css` linked the page does not move when it upgrades. For one simple citation in a record's details, `<uvalib-metadata citation="…">` remains the right choice. It reports `format`, `copy` and `download` (the format name only) to analytics itself.
47
47
  - Long pages (minutes, finding aids, transcriptions, long result lists): a `<uvalib-back-to-top>` (from `uvalib-back-to-top.js`) last in the content inside `<site-page>`, never a hand-built button and scroll script. It stays hidden (`visibility: hidden`, not a tab stop) until the top 400px (`offset`) scroll away, then floats in the bottom corner; activating it scrolls to the top (smooth unless reduced motion) and moves focus to the page's `<h1>` (or `target`, a selector), adding `tabindex="-1"`. The element keeps 4.75rem of space at the end and the button rests there at the bottom, so it never covers the last lines or the footer: do not add your own padding for it. `label` changes its text. `<site-page>` has no attribute for it. It reports `click` to analytics itself.
@@ -564,7 +564,7 @@ A static site (11ty, Jekyll, a generated collection) that searches with [Pagefin
564
564
 
565
565
  - Link `pagefind.css` (npm: `@uvalib/web-components/pagefind.css`) **instead of** Pagefind's `pagefind-ui.css`; never both (the stock rules out-rank the theme's). It styles Pagefind's default UI (`.pagefind-ui__*`): the field and Clear like `.uvalib-input`, the filters like `<uvalib-filter>`, link-coloured result titles, the library `<mark>`, Load more as a `.uvalib-button`, with dark mode and forced colors. Pagefind's `--pagefind-ui-*` properties still work for small changes.
566
566
  - Use `<uvalib-pagefind-search>` (from `uvalib-pagefind-search.js`) rather than `new PagefindUI(...)`: it loads `<bundle-path>pagefind-ui.js` from the site's bundle and adds what CSS cannot: a visible label (the stock field has only a title), a polite result-count status (the stock message is not announced), focus that stays in the field after Clear and Escape and moves to the first new result after Load more, `?q=` read and written (`query-param`), Pagefind filters read from and written to the URL (`filter-params`), and analytics (`trackSearch(…, 'Pagefind', count)` once results settle, and `filter-change` events). Do not add your own `?q=` or `triggerFilters` URL script or live region.
567
- - Attributes: `bundle-path` (default `/pagefind/`), `merge-index` (JSON array, for sharded indexes), `page-size` (10), `show-sub-results`, `show-images`, `excerpt-length`, `placeholder`, `label`, `label-hidden`, `translations` and `options` (JSON), `query-param` (default `q`) and `filter-params` (space-separated filter names, such as `collection author`: `?collection=Manuscripts` lands with that filter checked and its group open, applied with `?q=` as one search; repeated parameters check several values; values the index lacks are ignored; checkbox changes are written back). For a "Search this collection" link, use `filter-params` and link to `/search/?collection=…`; `el.ready.then((ui) => ui.triggerFilters(…))` is for filters set from your own script.
567
+ - Attributes: `bundle-path` (default `/pagefind/`), `merge-index` (JSON array, for sharded indexes), `page-size` (10), `show-sub-results`, `show-images`, `excerpt-length`, `placeholder`, `label`, `label-hidden`, `translations` and `options` (JSON), `query-param` (default `q`) and `filter-params` (space-separated filter names, such as `collection author`: `?collection=Manuscripts` lands with that filter checked and its group open, applied with `?q=` as one search; repeated parameters check several values; values the index lacks are ignored; checkbox changes are written back), `searching` and `no-skeleton`. A search page opened with `?q=` must hold still while results load (CLS): add `searching` when the URL has a query, before any script runs, with one line after the element (`<script>if (new URLSearchParams(location.search).get('q')) document.querySelector('uvalib-pagefind-search').setAttribute('searching', '')</script>`, or server-side); `pagefind.css` then holds a window's height and draws placeholder results from first paint until the results load, and the element keeps the footer below the fold until the visitor uses the search. Do not add your own `min-height` hold. For a "Search this collection" link, use `filter-params` and link to `/search/?collection=…`; `el.ready.then((ui) => ui.triggerFilters(…))` is for filters set from your own script.
568
568
 
569
569
  ```html
570
570
  <!doctype html>
@@ -883,7 +883,7 @@ An editable text field that suggests values as you type, from a local list or a
883
883
 
884
884
  ## `<uvalib-contents>`
885
885
 
886
- 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.
886
+ 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.
887
887
 
888
888
  ### Attributes
889
889
 
@@ -898,6 +898,12 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
898
898
  | `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. |
899
899
  | `levels` | | `DEFAULT_LEVELS` | With `headings-from`: the heading levels to list, `2-3` (the default) or one level, `2`. |
900
900
  | `min` | | `DEFAULT_MIN` | With `headings-from`: the fewest top-level entries worth a list (default 2). With fewer, nothing is shown. |
901
+ | `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`). |
902
+ | `full-label` | | `DEFAULT_FULL_LABEL` | The full-contents link's text, before the count: "Full contents" by default. |
903
+ | `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. |
904
+ | `noun` | | `DEFAULT_NOUN` | What the entries are, plural, in the counts: "sections" by default. |
905
+ | `singular` | `string` | `''` | What an entry is, singular, for a count of one. Default: "section" for the default `noun`, else `noun`. |
906
+ | `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. |
901
907
  | `no-shadow-dom` | `boolean` | `false` | |
902
908
  | `no-style` | `boolean` | `false` | |
903
909
 
@@ -905,8 +911,8 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
905
911
 
906
912
  | Event | Description |
907
913
  |---|---|
908
- | `uvalib-analytics-event` | For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), and opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' \| 'close']`; never the label or URL. Bubbles and is composed. |
909
- | `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. |
914
+ | `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. |
915
+ | `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. |
910
916
 
911
917
  ### CSS custom properties
912
918
 
@@ -922,6 +928,7 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
922
928
  | `--uva-color-text` | | Dark-mode role token: text and current entry (else `--uva-grey-darkest`). |
923
929
  | `--uva-color-link` | | Dark-mode role token: the current entry's bar and the button's text (else `--uva-brand-blue`). |
924
930
  | `--uva-color-current` | | Dark-mode role token: the nested levels' bar (else `--uva-brand-orange`). |
931
+ | `--uva-color-text-muted` | | Dark-mode role token: the ellipsis between the entries a window shows (else #4f4f4f). |
925
932
  | `--uva-color-border` | | Dark-mode role token: dividers (else #dadada). |
926
933
  | `--uva-color-control-border` | | Dark-mode role token: the button's border (else #808080). |
927
934
  | `--uva-color-surface-raised` | | Dark-mode role token: the button's background (else #fff). |
@@ -1502,7 +1509,7 @@ A record's details as a description list, as on the library's digital collection
1502
1509
 
1503
1510
  ## `<uvalib-pagefind-search>`
1504
1511
 
1505
- 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.
1512
+ 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.
1506
1513
 
1507
1514
  ### Attributes
1508
1515
 
@@ -1520,6 +1527,8 @@ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle)
1520
1527
  | `translations` | `string` | | JSON of Pagefind UI strings to override (`{"zero_results": "…"}`). |
1521
1528
  | `options` | `string` | | JSON of any other `PagefindUI` options (`{"openFilters": ["author"]}`), applied last. |
1522
1529
  | `query-param` | `string` | `q` | The URL parameter that holds the query; empty turns it off. |
1530
+ | `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. |
1531
+ | `no-skeleton` | `boolean` | | Never hold space or show placeholder results (`searching` is ignored). |
1523
1532
  | `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. |
1524
1533
 
1525
1534
  ### Events
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-DXkGlSgH.js","names":["unsafeCSS","i","r","fontFallback","FACES","loadFontFallback","fonts","doc","face","tokens","METADATA_LIMITS","metadataLimits","lists","n","l","TYPEKIT_URL","base"],"sources":["../../src/styles/font-fallback.ts","../../src/styles/tokens.ts","../../src/styles/base.ts"],"sourcesContent":["import { css } from 'lit';\n\n/**\n * A metric-matched fallback for Franklin Gothic URW (issue #32). The Adobe Fonts kit uses\n * `font-display: auto`, so on a slow connection text is drawn in the next font of\n * `--uva-font-family` and redrawn when the kit's files arrive. Plain Arial is wider than\n * Franklin Gothic (by 6% regular, 9% bold), so paragraphs rewrapped and the page moved\n * (layout shift). \"UVA Franklin Fallback\" is the system's Arial scaled to Franklin Gothic's\n * average widths, with its ascent and descent, for each face the kit serves (400, 500, 700 and\n * 400 italic; a 600 rule gets the 700 face, as the kit's own matching does). Measured against\n * the kit in Chromium: the fallback wraps a paragraph like Franklin Gothic in about 99% of\n * widths from 260 to 700px at 16 to 20px, against 55 to 82% for plain Arial.\n *\n * `size-adjust` scales Arial's glyphs; the overrides are Franklin Gothic's ascent (0.95 em) and\n * descent (0.25 em) divided by that scale, with no line gap, so a line is as tall in both.\n * Liberation Sans (Linux) has Arial's metrics. Where neither is installed (Android has Roboto),\n * the face is skipped and the next font in the stack is used, as before.\n */\nexport const fontFallback = css`\n @font-face {\n font-family: 'UVA Franklin Fallback';\n src: local('Arial'), local('ArialMT'), local('Liberation Sans'), local('LiberationSans');\n font-weight: 100 450;\n font-style: normal;\n size-adjust: 94.52%;\n ascent-override: 100.93%;\n descent-override: 26.56%;\n line-gap-override: 0%;\n }\n @font-face {\n font-family: 'UVA Franklin Fallback';\n src: local('Arial'), local('ArialMT'), local('Liberation Sans'), local('LiberationSans');\n font-weight: 451 599;\n font-style: normal;\n size-adjust: 95.99%;\n ascent-override: 99.18%;\n descent-override: 26.04%;\n line-gap-override: 0%;\n }\n @font-face {\n font-family: 'UVA Franklin Fallback';\n src:\n local('Arial Bold'), local('Arial-BoldMT'), local('Liberation Sans Bold'),\n local('LiberationSans-Bold');\n font-weight: 600 1000;\n font-style: normal;\n size-adjust: 91.32%;\n ascent-override: 104.03%;\n descent-override: 27.38%;\n line-gap-override: 0%;\n }\n @font-face {\n font-family: 'UVA Franklin Fallback';\n src:\n local('Arial Italic'), local('Arial-ItalicMT'), local('Liberation Sans Italic'),\n local('LiberationSans-Italic');\n font-weight: 100 599;\n font-style: italic;\n size-adjust: 95.06%;\n ascent-override: 101.09%;\n descent-override: 26.4%;\n line-gap-override: 0%;\n }\n`;\n\n/** One font per fallback face, so each one is asked for. */\nconst FACES = ['400', '500', '700', 'italic 400'];\n\n/**\n * Load every fallback face now (issue #35). A face from a local() font loads only when text\n * first needs it, so the first italic (or medium) text could be drawn in unscaled Arial and\n * redrawn a moment later. Called once the faces are installed; failures (no Arial or\n * Liberation Sans on the system) are left to the next font in the stack, as before.\n */\nexport function loadFontFallback(doc: Document): void {\n const fonts = doc.fonts;\n if (!fonts?.load) return;\n for (const face of FACES) fonts.load(`${face} 1em \"UVA Franklin Fallback\"`).catch(() => {});\n}\n","// GENERATED by scripts/sync-tokens.mjs from ../monorepo/packages/drupal_library_theme/src/scss/base — do not edit\nimport { css } from 'lit';\n\nexport const tokens = css`\n :root {\n --uva-brand-blue-lightest: #87B9D9;\n --uva-brand-blue-lighter: #3395D4;\n --uva-brand-blue-light: #0370B7;\n --uva-brand-blue-base: #232D4B;\n --uva-brand-blue-300: #87B9D9;\n --uva-brand-blue-200: #3395D4;\n --uva-brand-blue-100: #0370B7;\n --uva-brand-blue: #232D4B;\n --uva-brand-orange-lightest: #FFEAD6;\n --uva-brand-orange-lighter: #FFC999;\n --uva-brand-orange-light: #FFB370;\n --uva-brand-orange-base: #E57200;\n --uva-brand-orange-dark: #B35900;\n --uva-brand-orange-darker: #854200;\n --uva-brand-orange-300: #FFEAD6;\n --uva-brand-orange-200: #FFC999;\n --uva-brand-orange-100: #FFB370;\n --uva-brand-orange: #E57200;\n --uva-brand-orange-A: #B35900;\n --uva-brand-orange-B: #854200;\n --uva-blue-alt-lightest: #BFE7F7;\n --uva-blue-alt-lighter: #91D8F2;\n --uva-blue-alt-light: #55C4EC;\n --uva-blue-alt-base: #007BAC;\n --uva-blue-alt-dark: #005679;\n --uva-blue-alt-darkest: #141E3C;\n --uva-blue-alt-400: #e6f2f7;\n --uva-blue-alt-300: #BFE7F7;\n --uva-blue-alt-200: #91D8F2;\n --uva-blue-alt-100: #55C4EC;\n --uva-blue-alt: #007BAC;\n --uva-blue-alt-A: #005679;\n --uva-blue-alt-B: #141E3C;\n --uva-teal-lightest: #C8F2F4;\n --uva-teal-light: #5BD7DE;\n --uva-teal-base: #25CAD3;\n --uva-teal-dark: #1DA1A8;\n --uva-teal-darker: #16777C;\n --uva-teal-200: #C8F2F4;\n --uva-teal-100: #5BD7DE;\n --uva-teal: #25CAD3;\n --uva-teal-A: #1DA1A8;\n --uva-teal-B: #16777C;\n --uva-green-lightest: #DDEFDC;\n --uva-green-lighter: #89CC74;\n --uva-green-base: #62BB46;\n --uva-green-dark: #4E9737;\n --uva-green-200: #DDEFDC;\n --uva-green-100: #89CC74;\n --uva-green: #62BB46;\n --uva-green-A: #4E9737;\n --uva-red-lightest: #FBCFDA;\n --uva-red-base: #EF3F6B;\n --uva-red-dark: #DF1E43;\n --uva-red-darker: #B30000;\n --uva-red-100: #FBCFDA;\n --uva-red: #EF3F6B;\n --uva-red-A: #DF1E43;\n --uva-red-B: #B30000;\n --uva-yellow-lightest: #FEF6C8;\n --uva-yellow-base: #ECC602;\n --uva-yellow-dark: #B99C02;\n --uva-yellow-100: #FEF6C8;\n --uva-yellow: #ECC602;\n --uva-yellow-A: #B99C02;\n --uva-grey-lightest: #F1F1F1;\n --uva-grey-light: #DADADA;\n --uva-grey-base: #808080;\n --uva-grey-dark: #4F4F4F;\n --uva-grey-darkest: #2B2B2B;\n --uva-grey-200: #F1F1F1;\n --uva-grey-100: #DADADA;\n --uva-grey-50: #ADADAD;\n --uva-grey: #808080;\n --uva-grey-A: #4F4F4F;\n --uva-grey-B: #2B2B2B;\n --uva-font-family: franklin-gothic-urw, \"UVA Franklin Fallback\", Arial, Helvetica, sans-serif;\n --uva-font-size-base: 17px;\n }\n`;\n","import { css, unsafeCSS } from 'lit';\n\n/**\n * `<uvalib-metadata>` long lists before it upgrades (issue #34): a list of more than N values\n * shows its first N and a line for its \"Show all\" button (4px above a 32px button), as the\n * upgraded element does. CSS cannot read N from the attribute into :nth-child(), so the rules\n * are written out for limits 1 to 12; a page with a larger limit adds its own (README). A row's\n * own data-limit on its <dd> wins over list-limit (data-limit=\"0\" shows them all); a data-limit\n * on the list itself works once upgraded but is not held before.\n */\nconst METADATA_LIMITS = Array.from({ length: 12 }, (_, i) => i + 1);\nconst metadataLimits = unsafeCSS(\n METADATA_LIMITS.map((n) => {\n const lists = [\n `uvalib-metadata[list-limit=\"${n}\"]:not(:defined) > dl > dd:not([data-limit]) > :is(ul, ol):not([data-limit])`,\n `uvalib-metadata:not(:defined) > dl > dd[data-limit=\"${n}\"] > :is(ul, ol)`,\n ];\n return (\n `${lists.map((l) => `${l} > li:nth-child(n + ${n + 1})`).join(',\\n')} { display: none; }\\n` +\n `${lists.map((l) => `${l}:has(> li:nth-child(${n + 1}))::after`).join(',\\n')} { content: ''; display: block; block-size: 2.25rem; }`\n );\n }).join('\\n'),\n);\n\nexport const TYPEKIT_URL = 'https://use.typekit.net/oym8nvz.css';\n\n// The body background has no fallback: without dark mode it stays transparent, as before.\n//\n// site-page:not(:defined) applies when base.css is linked in <head>, before the element\n// upgrades: its own formatting context (flow-root), so a heading's top margin cannot collapse\n// through to <body> and shift the page once the element upgrades, and invisible, so its\n// content does not paint above where the header will go. If the script never loads, the\n// content appears anyway after two seconds.\nexport const base = css`\n *,\n *::before,\n *::after {\n box-sizing: border-box;\n }\n html,\n body {\n font-family: var(\n --uva-font-family,\n franklin-gothic-urw,\n 'UVA Franklin Fallback',\n Arial,\n Helvetica,\n sans-serif\n );\n }\n html {\n font-size: var(--uva-font-size-base, 17px);\n }\n body {\n margin: 0;\n line-height: 1.5;\n min-height: 100vh;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n background-color: var(--uva-color-surface);\n }\n site-page:not(:defined) {\n display: flow-root;\n visibility: hidden;\n animation: uvalib-site-page-reveal 0s 2s forwards;\n }\n uvalib-breadcrumbs:not(:defined),\n uvalib-card:not(:defined),\n uvalib-card-grid:not(:defined),\n uvalib-pager:not(:defined),\n uvalib-contents:not(:defined),\n uvalib-metadata:not(:defined),\n uvalib-tag-list:not(:defined) {\n display: block;\n line-height: 1.5;\n visibility: hidden;\n animation: uvalib-site-page-reveal 0s 2s forwards;\n }\n /* A chip row: hidden, one 44px row tall (with the scrolling row's padding), the raw\n children kept on one line so they cannot make it taller. */\n uvalib-chip-group:not(:defined) {\n display: block;\n min-height: 44px;\n max-width: 100%;\n overflow: hidden;\n white-space: nowrap;\n visibility: hidden;\n animation: uvalib-site-page-reveal 0s 2s forwards;\n }\n uvalib-chip-group[scroll]:not(:defined) {\n min-height: calc(44px + 0.75rem);\n }\n /* A description: one line of it (0.875rem at 1.5, 0.25rem below the row). */\n uvalib-chip-group[description]:not(:defined) {\n padding-block-end: 1.5625rem;\n }\n /* Its text is drawn from attributes: hold one line until it upgrades. */\n uvalib-results-count:not(:defined) {\n display: block;\n min-block-size: 1.5em;\n }\n uvalib-tag-list:not(:defined)[hidden],\n uvalib-results-count:not(:defined)[hidden] {\n display: none;\n }\n /* The pre-upgrade rules here set display, which beats the hidden attribute's (issue #7).\n More specific than each of them (two pseudo-classes or attributes), so it needs no importance flag. */\n :where(\n site-page,\n uvalib-breadcrumbs,\n uvalib-card,\n uvalib-card-grid,\n uvalib-pager,\n uvalib-contents,\n uvalib-metadata,\n uvalib-chip-group,\n uvalib-tabs,\n uvalib-combobox,\n uvalib-image-regions,\n uvalib-map,\n uvalib-filter-drawer,\n uvalib-filter,\n uvalib-list-filter\n ):not(:defined)[hidden],\n :where(uvalib-combobox, uvalib-image-regions):not(:defined) > [hidden] {\n display: none;\n }\n /* A record's details before <uvalib-metadata> upgrades (issue #34): the rows already laid\n out as it lays them out (label beside value from 36rem of its own width, stacked below;\n 8px above and below each row, a 1px rule between rows; lists without bullets, 4px apart),\n so the page does not move when it upgrades. Rows the attributes add (creator, rights,\n citation) are not in the page's <dl> and cannot be held. */\n uvalib-metadata:not(:defined) {\n container-type: inline-size;\n font-size: 1rem;\n }\n uvalib-metadata:not(:defined) > dl {\n display: grid;\n grid-template-columns: minmax(7rem, 12rem) minmax(0, 1fr);\n column-gap: 1.5rem;\n margin: 0;\n }\n uvalib-metadata:not(:defined) > dl > dt {\n grid-column: 1;\n margin: 0;\n padding-block: 0.5rem;\n font-weight: 700;\n }\n uvalib-metadata:not(:defined) > dl > dd {\n grid-column: 2;\n margin: 0;\n padding-block: 0.5rem;\n }\n uvalib-metadata:not(:defined) > dl > dt:not(:first-child),\n uvalib-metadata:not(:defined) > dl > dt:not(:first-child) + dd {\n border-block-start: 1px solid transparent;\n }\n uvalib-metadata:not(:defined) > dl > dd > :is(ul, ol) {\n margin: 0;\n padding: 0;\n list-style: none;\n }\n uvalib-metadata:not(:defined) > dl > dd li + li {\n margin-block-start: 0.25rem;\n }\n @container (width < 36rem) {\n uvalib-metadata:not(:defined) > dl {\n grid-template-columns: minmax(0, 1fr);\n }\n uvalib-metadata:not(:defined) > dl > :is(dt, dd) {\n grid-column: 1;\n }\n uvalib-metadata:not(:defined) > dl > dt {\n padding-block-end: 0;\n }\n uvalib-metadata:not(:defined) > dl > dd {\n padding-block-start: 0;\n }\n uvalib-metadata:not(:defined) > dl > dt:not(:first-child) + dd {\n border-block-start: 0;\n }\n }\n ${metadataLimits}\n /* Tabs stay readable before the script runs: a block, one panel, and a gap the\n size of the tab row (44px) plus its 1rem margin, so the first panel does not\n jump when the element upgrades. Later data-tab panels stay hidden. */\n uvalib-tabs:not(:defined) {\n display: block;\n padding-block-start: calc(44px + 1rem);\n }\n uvalib-tabs:not(:defined) > [data-tab] ~ [data-tab] {\n display: none;\n }\n /* A combobox: its label (from the attribute) and one 44px field (plus a one-line\n description) held, so nothing moves when it upgrades. A fallback <input list> child\n works meanwhile; the other children (options, a datalist) stay out of sight. */\n uvalib-combobox:not(:defined) {\n display: block;\n min-block-size: calc(1.5em + 0.25rem + 44px);\n line-height: 1.5;\n }\n uvalib-combobox[description]:not(:defined) {\n min-block-size: calc(3em + 0.5rem + 44px);\n }\n uvalib-combobox:not(:defined)::before {\n content: attr(label);\n display: block;\n margin-block-end: 0.25rem;\n font-weight: 600;\n }\n uvalib-combobox:not(:defined) > :not(input) {\n display: none;\n }\n uvalib-combobox:not(:defined) > input {\n display: block;\n box-sizing: border-box;\n inline-size: 100%;\n min-block-size: 44px;\n font: inherit;\n line-height: 1.2;\n }\n /* A list filter draws its label, a 44px field and a one-line count from attributes: hold\n their height (less the label with hide-label, less the count with results-count), so the\n list below does not move when it upgrades. The list itself is the page's and stays\n fully shown until then. */\n uvalib-list-filter:not(:defined) {\n display: block;\n font-size: 1rem;\n line-height: 1.5;\n min-block-size: calc(1.5em + 0.25rem + 44px + 0.25rem + 1.5em);\n }\n uvalib-list-filter[hide-label]:not(:defined) {\n min-block-size: calc(44px + 0.25rem + 1.5em);\n }\n uvalib-list-filter[results-count]:not(:defined) {\n min-block-size: calc(1.5em + 0.25rem + 44px);\n }\n uvalib-list-filter[hide-label][results-count]:not(:defined) {\n min-block-size: 44px;\n }\n /* Image regions: the image at its own width and the list beside it (or under it), the\n layout the element keeps once it upgrades, so the image does not move. */\n uvalib-image-regions:not(:defined) {\n display: flex;\n flex-wrap: wrap;\n gap: 1rem;\n align-items: flex-start;\n }\n uvalib-image-regions:not(:defined) > :is(img, picture) {\n display: block;\n flex: 0 1 auto;\n min-width: 0;\n max-width: 100%;\n height: auto;\n }\n uvalib-image-regions:not(:defined) > :is(ol, ul) {\n flex: 1 1 14rem;\n min-width: 0;\n }\n /* A map: its key instructions (the same text it shows) and the map's height held above\n the child list, so the list does not move when the map is drawn over the page's\n Leaflet. Padding, not margin, so it cannot collapse with the list's own top margin. */\n uvalib-map:not(:defined) {\n display: block;\n }\n uvalib-map:not(:defined)::before {\n content: 'Tab or arrow keys move between places; Enter opens one. With the map focused, arrow keys pan and + and − zoom.';\n display: block;\n padding-block-end: calc(0.5rem + max(12rem, var(--uvalib-map-height, min(24rem, 75vw))));\n font-size: 0.875rem;\n line-height: 1.5;\n color: var(--uva-color-text-muted, #4b5563);\n }\n /* A collapsed filter group (<uvalib-filter collapsible collapsed>) draws only its 44px\n legend button once it upgrades: hold that height. Low specificity, so the [hidden] rule\n above still wins. */\n :where(uvalib-filter[collapsible][collapsed]):not(:defined) {\n display: block;\n min-block-size: 44px;\n }\n /* A filter drawer on a phone (the default 48rem breakpoint): once it upgrades only its 44px\n \"Search and filters\" button shows, so hold that height and keep the form and filters out\n of sight meanwhile; nothing moves when it upgrades. A page with its own breakpoint adds the\n same two rules in a media query of that width (see the README). Low specificity, so the\n [hidden] rule above still wins. */\n @media (max-width: 48rem) {\n :where(uvalib-filter-drawer:not([breakpoint])):not(:defined) {\n display: block;\n min-block-size: 44px;\n }\n :where(uvalib-filter-drawer:not([breakpoint])):not(:defined) > * {\n display: none;\n }\n }\n /* A contents list before <uvalib-contents> upgrades (a .uvalib-sidebar-layout sidebar): the\n headline's line held above, the links already padded as it pads them (the rules drawn\n transparent while hidden), so the list does not move. Narrow (the default 64rem\n collapse-below, closed): only its 44px button shows once it upgrades, so hold that and\n clip the list; the reveal releases it, so the list still shows if the script never loads.\n The [hidden] rule above still wins (it alone sets display). */\n uvalib-contents:not(:defined) {\n padding-block-start: calc(1.125rem * 1.3 + 0.5rem);\n animation-name: uvalib-contents-reveal;\n }\n :where(uvalib-contents):not(:defined) :is(ol, ul) {\n margin: 0;\n padding: 0;\n list-style: none;\n }\n :where(uvalib-contents):not(:defined) > :is(ol, ul) {\n border-block: 1px solid transparent;\n }\n :where(uvalib-contents):not(:defined) > :is(ol, ul) > li + li {\n border-block-start: 1px solid transparent;\n }\n :where(uvalib-contents):not(:defined) li > a {\n display: block;\n padding: 0.5rem 0.75rem 0.5rem calc(0.75rem + 4px);\n }\n :where(uvalib-contents):not(:defined) li li > a {\n padding-block: 0.25rem;\n }\n :where(uvalib-contents):not(:defined) li :is(ol, ul) {\n padding-inline-start: 1rem;\n border-inline-start: 2px solid transparent;\n }\n /* In light DOM (no-shadow-dom) a nested list is indented by a margin, with 0.5rem below. */\n :where(uvalib-contents[no-shadow-dom]):not(:defined) li :is(ol, ul) {\n margin: 0 0 0.5rem 0.75rem;\n padding-inline-start: 0;\n }\n @media (max-width: 64rem) {\n uvalib-contents:not([collapse-below], [open]):not(:defined) {\n max-block-size: 44px;\n padding-block-start: 0;\n overflow: hidden;\n }\n }\n @keyframes uvalib-contents-reveal {\n to {\n visibility: visible;\n max-block-size: none;\n overflow: visible;\n }\n }\n /* A dialog before <uvalib-dialog> upgrades: its children are the dialog's content, never\n shown in the page, so nothing flashes or moves. Once defined, a closed dialog renders\n nothing (its host is display: contents around a closed <dialog>). */\n uvalib-dialog:not(:defined) {\n display: none;\n }\n /* A citation before <uvalib-citation> upgrades: only the first format's citation, boxed\n as it will be, with the label and 44px format bar held above it (none for hide-label)\n and the 44px Copy citation row below, so nothing moves when it upgrades (an app's\n citations property cannot be held). */\n uvalib-citation:not(:defined) {\n display: block;\n font-size: 1rem;\n line-height: 1.5;\n }\n uvalib-citation:not(:defined):has(> [data-format]) {\n padding-block: calc(2rem + 44px + 0.75rem) calc(0.75rem + 44px);\n }\n uvalib-citation[hide-label]:not(:defined):has(> [data-format]) {\n padding-block-start: calc(44px + 0.75rem);\n }\n uvalib-citation:not(:defined) > [data-format] {\n margin: 0;\n padding: 0.75rem 1rem;\n border: 1px solid transparent;\n overflow-wrap: anywhere;\n text-wrap: pretty;\n }\n uvalib-citation:not(:defined) > [data-format] ~ [data-format],\n uvalib-citation:not(:defined) > [slot] {\n display: none;\n }\n /* Printing a <site-page> (issue #20; its own styles leave out the chrome): a dark scheme\n prints light (the role tokens resolve to their light values), and the content's links\n are black and underlined, so they are told apart without colour. Content is <main> in\n light DOM and the unslotted children in shadow DOM. print-chrome keeps the page as it is\n shown, apart from the light scheme. */\n @media print {\n :root[data-uva-color-scheme]:has(site-page) {\n color-scheme: light;\n --uva-color-scheme: light;\n }\n /* Light DOM's trail, here too, as the pre-upgrade rule above (unlayered) would win. */\n site-page:not([print-chrome]) > [slot='breadcrumbs'] {\n display: none;\n }\n site-page:not([print-chrome]) > :not([slot], site-header, site-footer, .alerts-list) :any-link,\n site-page:not([print-chrome]) > :any-link:not([slot], .skip-link) {\n color: #000;\n text-decoration: underline;\n }\n }\n @keyframes uvalib-site-page-reveal {\n to {\n visibility: visible;\n }\n }\n`;\n"],"mappings":";;AAkBA,IAAaG,IAAe,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDzBC,IAAQ;CAAC;CAAO;CAAO;CAAO;AAAY;AAQhD,SAAgBC,EAAiB,GAAqB;CACpD,IAAMC,IAAQC,EAAI;CAClB,IAAKD,GAAO,MACZ,KAAK,IAAME,KAAQJ,GAAO,EAAM,KAAK,GAAGI,EAAK,6BAA6B,CAAC,CAAC,YAAY,CAAC,CAAC;AAC5F;;AC3EA,IAAaC,IAAS,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GCOnBC,IAAkB,MAAM,KAAK,EAAE,QAAQ,GAAG,IAAI,GAAG,MAAMT,IAAI,CAAC,GAC5DU,IAAiBX,EACrBU,EAAgB,KAAK,MAAM;CACzB,IAAME,IAAQ,CACZ,+BAA+BC,EAAE,+EACjC,uDAAuDA,EAAE,iBAC3D;CACA,OACE,GAAGD,EAAM,KAAK,MAAM,GAAGE,EAAE,sBAAsBD,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE,uBAClED,EAAM,KAAK,MAAM,GAAGE,EAAE,sBAAsBD,IAAI,EAAE,UAAU,CAAC,CAAC,KAAK,KAAK,EAAE;AAEjF,CAAC,CAAC,CAAC,KAAK,IAAI,CACd,GAEaE,IAAc,uCASdC,IAAO,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoJnBL,EAAe"}