@uvalib/web-components 1.11.1 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +192 -54
- package/dist/base.css +56 -2
- package/dist/components/uvalib-audio/UvalibAudio.d.ts +186 -0
- package/dist/components/uvalib-audio/UvalibAudio.js +1154 -0
- package/dist/components/uvalib-audio/UvalibAudio.js.map +1 -0
- package/dist/components/uvalib-audio/uvalib-audio.d.ts +1 -0
- package/dist/components/uvalib-audio/uvalib-audio.js +4 -0
- package/dist/components/uvalib-audio/uvalib-audio.js.map +1 -0
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +25 -5
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +62 -9
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
- package/dist/custom-elements.json +8486 -7187
- package/dist/edition-epub.css +511 -0
- package/dist/edition-print.css +51 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/base.js +55 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/edition.d.ts +6 -0
- package/dist/styles/edition.js +20 -0
- package/dist/styles/edition.js.map +1 -1
- package/dist-cdn/base.css +56 -2
- package/dist-cdn/chunks/{base-DtkA4Pgg.js → base-D_oPO5cX.js} +56 -2
- package/dist-cdn/chunks/{base-DtkA4Pgg.js.map → base-D_oPO5cX.js.map} +1 -1
- package/dist-cdn/custom-elements.json +8486 -7187
- package/dist-cdn/edition-epub.css +511 -0
- package/dist-cdn/edition-print.css +51 -0
- package/dist-cdn/manifest.json +6 -3
- package/dist-cdn/site-page.js +1 -1
- package/dist-cdn/site-style.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +35 -4
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +53 -1
- package/dist-cdn/uvalib-audio.js +747 -0
- package/dist-cdn/uvalib-audio.js.map +1 -0
- package/dist-cdn/uvalib-pagefind-search.js +70 -44
- package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
- package/package.json +7 -1
- package/skills/uvalib-web-components/SKILL.md +35 -4
- package/skills/uvalib-web-components/reference/components.md +53 -1
|
@@ -1 +1 @@
|
|
|
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,CAAC,IAEbA;AACT;AAMA,SAASK,EAAS,GAAc,GAAkC;CAChE,IAAMC,KAAO,MAAc,qCAAqCd,EAAI,aAAae,EAAE,YAC7EC,IAAM,eAAehB,EAAI,kBAAkBc,EAAI,OAAO,IAAIA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AAG;EAC7C,QAAQ,CAER;CACF;AACF;;ACrqBK,eAAe,IAAI,wBAAwB,KAC9C,eAAe,OAAO,0BAA0BzD,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","FLAG_OFF","flagSet","values","v","scripts","loadPagefindUI","win","p","src","script","resolve","reject","skeleton","bar","c","sub","row","subResults","el","rows","VISUALLY_HIDDEN","instanceCounter","isPlain","json","text","fallback","check","withSlash","path","MANY_RESULTS_EN","escapeRe","t","countFromMessage","rest","template","re","query","message","at","digits","UvalibPagefindSearch","_args","promise","attr","b","name","params","flags","out","all","bundlePath","placeholder","label","PagefindUI","generation","fromUrl","num","mergeIndex","m","translations","extra","options","open","given","excerpt","lang","ui","input","q","drawn","r","timer","boxes","filters","one","have","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","want","wanted"],"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/** URL values that leave a `filter-flags` filter unset (any other value, or none, sets it). */\nconst FLAG_OFF = new Set(['0', 'false', 'no', 'off']);\n\n/** A `filter-flags` filter is set by its parameter with any value but one of `FLAG_OFF`. */\nexport const flagSet = (values: string[]): boolean =>\n values.some((v) => !FLAG_OFF.has(v.trim().toLowerCase()));\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 with `filter-flags`, one-value filters linked as `?audiobook=1`); 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 * @attr {string} filter-flags - Space-separated names of one-value Pagefind filters (\"has an audiobook\": its one value is `Available`), read from and written to the URL as on/off flags (issue #40). The parameter with any value, or none (`?audiobook`, `?audiobook=1`, `?audiobook=yes`), checks the filter's one value, whatever its spelling in the index; `0`, `false`, `no` and `off` leave it unchecked. Checking it writes `?audiobook=1`; unchecking removes it. Otherwise as `filter-params` (one search with the query, Back and Forward); a name need not be repeated there, and a name in both is a flag. If the index has more or fewer than one value for it, a console warning says so once and the filter is read as `filter-params` (exact values).\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 /** Space-separated names in an attribute. */\n private names(attr: string): string[] {\n return (this.getAttribute(attr) ?? '').split(/\\s+/).filter(Boolean);\n }\n\n /** The filter names read from and written to the URL: `filter-params` and `filter-flags`. */\n private get filterParams(): string[] {\n return [...new Set([...this.names('filter-params'), ...this.names('filter-flags')])];\n }\n\n /** The names in `filter-flags`. */\n private get flags(): string[] {\n return this.names('filter-flags');\n }\n\n /** Flag filters already warned about (a flag the index does not give exactly one value). */\n private readonly warned = new Set<string>();\n\n /**\n * A flag filter's one value in the index; undefined (warned once) when it has none or\n * several, and the filter is then read as `filter-params`.\n */\n private flagValue(name: string): string | undefined {\n const values = [...new Set(this.boxes.filter((b) => b.name === name).map((b) => b.value))];\n if (values.length === 1) return values[0];\n if (!this.warned.has(name)) {\n this.warned.add(name);\n console.warn(\n `${TAG}: filter-flags \"${name}\" has ${values.length} values in the index, not one; reading it as filter-params (exact values)`,\n );\n }\n return undefined;\n }\n\n private get boxes(): HTMLInputElement[] {\n return [...this.container.querySelectorAll<HTMLInputElement>('.pagefind-ui__filter-checkbox')];\n }\n\n /**\n * The `filter-params` filters in the page URL that have values (repeated params: several),\n * and the `filter-flags` filters it sets (their raw values, '' for a bare `?audiobook`).\n */\n private urlFilters(): Filters {\n const params = new URLSearchParams(location.search);\n const flags = this.flags;\n const out: Filters = {};\n for (const name of this.filterParams) {\n const all = params.getAll(name);\n const values = flags.includes(name) ? (flagSet(all) ? all : []) : all.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 // A flag (set, or it would not be here) checks its one value, however it is spelled.\n const one = this.flags.includes(name) ? this.flagValue(name) : undefined;\n if (one !== undefined) {\n out[name] = [one];\n continue;\n }\n const have = boxes.filter((b) => b.name === name).map((b) => b.value);\n const found = values\n .filter(Boolean)\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 /**\n * Write the `filter-params` filters to the URL, keeping every other parameter; a flag filter\n * whose one value is checked is written `=1`.\n */\n private writeFilters(filters: Filters): void {\n const url = new URL(location.href);\n const p = url.searchParams;\n const flags = this.flags;\n const want = (n: string): string[] => {\n const values = filters[n] ?? [];\n if (!flags.includes(n) || (!values.length && !p.has(n))) return values;\n const one = this.flagValue(n);\n return one === undefined ? values : values.includes(one) ? ['1'] : [];\n };\n const wanted = new Map(this.filterParams.map((n) => [n, want(n)]));\n const names = [...wanted.keys()].filter(\n (n) => JSON.stringify(p.getAll(n)) !== JSON.stringify(wanted.get(n)),\n );\n if (!names.length) return;\n for (const name of names) {\n p.delete(name);\n for (const v of wanted.get(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,oBAAW,IAAI,IAAI;CAAC;CAAK;CAAS;CAAM;AAAK,CAAC,GAGvCC,KAAW,MACtBC,EAAO,MAAM,MAAM,CAACF,EAAS,IAAIG,EAAE,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,GAGpDC,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,EA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AGkB,EAAKlB,CAAC,CAAC,CAAC,CAAC,GAC3DL,IAAQ,CAAC,GAAGwB,EAAO,KAAK,CAAC,CAAC,CAAC,QAC9B,MAAM,KAAK,UAAU/F,EAAE,OAAO4E,CAAC,CAAC,MAAM,KAAK,UAAUmB,EAAO,IAAInB,CAAC,CAAC,CACrE;EACA,IAAKL,EAAM,QACX;QAAK,IAAMjC,KAAQiC,GAAO;IACxB,EAAE,OAAOjC,CAAI;IACb,KAAK,IAAM1C,KAAKmG,EAAO,IAAIzD,CAAI,GAAI,EAAE,OAAOA,GAAM1C,CAAC;GACrD;GACA,KAAK,WAAWiG,CAAG;EADnB;CAEF;CAEA,WAAmB,GAAgB;EACjC,IAAI;GACF,QAAQ,aAAa,QAAQ,OAAO,IAAIA,CAAG;EAC7C,QAAQ,CAER;CACF;AACF;;ACjuBK,eAAe,IAAI,wBAAwB,KAC9C,eAAe,OAAO,0BAA0B5D,CAAoB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uvalib/web-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "UVA Library reusable web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -191,10 +191,16 @@
|
|
|
191
191
|
"types": "./dist/components/uvalib-list-filter/uvalib-list-filter.d.ts",
|
|
192
192
|
"default": "./dist/components/uvalib-list-filter/uvalib-list-filter.js"
|
|
193
193
|
},
|
|
194
|
+
"./uvalib-audio.js": {
|
|
195
|
+
"types": "./dist/components/uvalib-audio/uvalib-audio.d.ts",
|
|
196
|
+
"default": "./dist/components/uvalib-audio/uvalib-audio.js"
|
|
197
|
+
},
|
|
194
198
|
"./tokens.css": "./dist/tokens.css",
|
|
195
199
|
"./base.css": "./dist/base.css",
|
|
196
200
|
"./pagefind.css": "./dist/pagefind.css",
|
|
197
201
|
"./edition.css": "./dist/edition.css",
|
|
202
|
+
"./edition-epub.css": "./dist/edition-epub.css",
|
|
203
|
+
"./edition-print.css": "./dist/edition-print.css",
|
|
198
204
|
"./custom-elements.json": "./dist/custom-elements.json",
|
|
199
205
|
"./manifest.json": "./dist-cdn/manifest.json",
|
|
200
206
|
"./package.json": "./package.json",
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: uvalib-web-components
|
|
3
|
+
description: Use when building or editing UVA Library web pages or sites with @uvalib/web-components: page chrome (<site-page>, <site-header>, <site-main-nav>, <site-footer>, <site-alerts>, <site-analytics>/<uvalib-analytics>, <site-style>), and other uvalib-* components (breadcrumbs, cards, pager, tabs, contents, metadata, citation, chips, tags, results count, filter, filter drawer, dialog, date range, date histogram, combobox, list filter, map (Leaflet), lightbox, photo grid, image regions, back to top, audio by chapter, Pagefind search, edition.css for TEI texts and EPUB/PDF), the library hours, events and bento-box elements (e.g. <uvalib-card>, <library-weekly-hours>), base.css classes (incl. tables, sidebar layout), or script/link URLs on unpkg.internal.lib.virginia.edu (incl. old /web-components/latest/ or cdn-v URLs). Covers CDN vs npm, version pinning, shadow vs light DOM, theming with --uva-* tokens, WCAG 2.2 AA accessibility testing, requesting components via GitHub issues, and a verification checklist.
|
|
4
|
+
||||||| /private/tmp/claude-505/-Users-dhc4z-workspace-reusable-web-library/ac44f07e-107d-46b0-9a3a-fad028810779/scratchpad/r1
|
|
3
5
|
description: Use when building or editing UVA Library web pages or sites with @uvalib/web-components: page chrome (<site-page>, <site-header>, <site-main-nav>, <site-footer>, <site-alerts>, <site-analytics>/<uvalib-analytics>, <site-style>), and other uvalib-* components (breadcrumbs, cards, pager, tabs, contents, metadata, citation, chips, tags, results count, filter, filter drawer, dialog, date range, date histogram, combobox, list filter, map (Leaflet), lightbox, photo grid, image regions, back to top, Pagefind search, edition.css for TEI texts), the library hours, events and bento-box elements (e.g. <uvalib-card>, <uvalib-chip-group>, <library-weekly-hours>), base.css classes (incl. tables, sidebar layout), or script/link URLs on unpkg.internal.lib.virginia.edu (incl. old /web-components/latest/ or cdn-v URLs). Covers CDN vs npm, version pinning, shadow vs light DOM, theming with --uva-* tokens, WCAG 2.2 AA accessibility testing, requesting components via GitHub issues, and a verification checklist.
|
|
4
6
|
---
|
|
5
7
|
|
|
6
8
|
# UVA Library web components
|
|
7
9
|
|
|
8
|
-
`@uvalib/web-components` provides the UVA Library page chrome as custom elements: `<site-page>` (skip link, header with the library main navigation, one `<main>`, footer), `<site-header>`, `<site-main-nav>` (the main navigation, rendered by the header), `<site-footer>`, `<site-analytics>` (Matomo; also registered as `<uvalib-analytics>`) and `<site-style>` (legacy compatibility), plus `<uvalib-breadcrumbs>` (the breadcrumb trail), `<uvalib-contents>` (sub-navigation or a table of contents), `<uvalib-metadata>` (a record's details, credit, rights and how to cite) and `<uvalib-citation>` (a citation in several formats with Copy citation), all in section 2, `<uvalib-card>`, `<uvalib-card-grid>` and `<uvalib-pager>` (cards and paging, section 5), `<uvalib-tabs>` (tabbed panels), `<uvalib-back-to-top>` (a back-to-top button for long pages) and `<site-alerts>` (the live library alerts, which `<site-page>` shows itself). It also ships search-page components, `<uvalib-filter>`, `<uvalib-date-range>` and `<uvalib-date-histogram>`, `<uvalib-chip-group>` for segmented controls, filter chips and suggestion chips, `<uvalib-combobox>`, a text field that suggests values as you type, `<uvalib-list-filter>`, a field that filters a long list on the page as you type, and `<uvalib-filter-drawer>`, the filters as a sidebar or a modal panel on phones, and `<uvalib-dialog>`, a modal dialog for search tips, Cite and short forms (section 6), and three library-hours elements for library.virginia.edu, `<site-hours-section>`, `<library-weekly-hours>` and `<library-hours-setup>`, `<events-section>` for upcoming library events and `<bento-box>` for the library's search results page (section 7), and `pagefind.css` with `<uvalib-pagefind-search>` for a static site's Pagefind search, `edition.css` for reading TEI texts converted to HTML, and `<uvalib-tag-list>`, `<uvalib-results-count>` and `base.css`'s badge, toolbar, empty-state and skeleton classes for results lists (section 6), and `<uvalib-lightbox>`, `<uvalib-photo-grid>` and `<uvalib-image-regions>` for images and `<uvalib-map>` for a map of places over the page's own Leaflet, with a linked list (section 8). Tag names are stable.
|
|
10
|
+
`@uvalib/web-components` provides the UVA Library page chrome as custom elements: `<site-page>` (skip link, header with the library main navigation, one `<main>`, footer), `<site-header>`, `<site-main-nav>` (the main navigation, rendered by the header), `<site-footer>`, `<site-analytics>` (Matomo; also registered as `<uvalib-analytics>`) and `<site-style>` (legacy compatibility), plus `<uvalib-breadcrumbs>` (the breadcrumb trail), `<uvalib-contents>` (sub-navigation or a table of contents), `<uvalib-metadata>` (a record's details, credit, rights and how to cite) and `<uvalib-citation>` (a citation in several formats with Copy citation), all in section 2, `<uvalib-card>`, `<uvalib-card-grid>` and `<uvalib-pager>` (cards and paging, section 5), `<uvalib-tabs>` (tabbed panels), `<uvalib-back-to-top>` (a back-to-top button for long pages) and `<site-alerts>` (the live library alerts, which `<site-page>` shows itself). It also ships search-page components, `<uvalib-filter>`, `<uvalib-date-range>` and `<uvalib-date-histogram>`, `<uvalib-chip-group>` for segmented controls, filter chips and suggestion chips, `<uvalib-combobox>`, a text field that suggests values as you type, `<uvalib-list-filter>`, a field that filters a long list on the page as you type, and `<uvalib-filter-drawer>`, the filters as a sidebar or a modal panel on phones, and `<uvalib-dialog>`, a modal dialog for search tips, Cite and short forms (section 6), and three library-hours elements for library.virginia.edu, `<site-hours-section>`, `<library-weekly-hours>` and `<library-hours-setup>`, `<events-section>` for upcoming library events and `<bento-box>` for the library's search results page (section 7), and `pagefind.css` with `<uvalib-pagefind-search>` for a static site's Pagefind search, `edition.css` for reading TEI texts converted to HTML, `<uvalib-audio>` for a recording played by chapter (an audiobook), and `<uvalib-tag-list>`, `<uvalib-results-count>` and `base.css`'s badge, toolbar, empty-state and skeleton classes for results lists (section 6), and `<uvalib-lightbox>`, `<uvalib-photo-grid>` and `<uvalib-image-regions>` for images and `<uvalib-map>` for a map of places over the page's own Leaflet, with a linked list (section 8). Tag names are stable.
|
|
9
11
|
|
|
10
12
|
Authority rule: https://www.library.virginia.edu and the UVA Library design system are the source of truth for how the chrome looks and what it says. Do not re-create, copy or restyle the header, footer, logo or links by hand. Use the components, and change appearance only through the theming surface below.
|
|
11
13
|
|
|
@@ -31,7 +33,7 @@ Loading rules:
|
|
|
31
33
|
|
|
32
34
|
- One script is enough for the page chrome: `site-page.js` also loads the header (with its main navigation) and footer. For Matomo, give `<site-page>` a `matomo-id` (it loads the analytics code itself), or add `site-analytics.js` and a `<site-analytics>` (or `uvalib-analytics.js` and `<uvalib-analytics>`) element; never both, and never alongside a hand-written Matomo snippet.
|
|
33
35
|
- Also link `.../v1/base.css` in `<head>` (npm: `@uvalib/web-components/base.css`), unless the page sets `no-global-styles`. `<site-page>` installs the same base styles only after the first paint, so without the link the page shifts once (the default body margin goes away, and a heading's margin stops collapsing through the not-yet-defined `<site-page>`). The link also keeps `<site-page>` invisible until it is defined, with a two-second fallback.
|
|
34
|
-
- npm: the define entries (`@uvalib/web-components/site-page.js`, `site-header.js`, `site-main-nav.js`, `site-footer.js`, `site-analytics.js`, `uvalib-analytics.js`, `site-style.js`, `uvalib-breadcrumbs.js`, `uvalib-card.js`, `uvalib-card-grid.js`, `uvalib-pager.js`, `uvalib-contents.js`, `uvalib-metadata.js`, `site-alerts.js`, `uvalib-filter.js`, `uvalib-date-range.js`, `uvalib-date-histogram.js`, `site-hours-section.js`, `library-weekly-hours.js`, `library-hours-setup.js`, `events-section.js`, `bento-box.js`, `uvalib-pagefind-search.js`, `uvalib-lightbox.js`, `uvalib-photo-grid.js`, `uvalib-tabs.js`, `uvalib-chip-group.js`, `uvalib-tag-list.js`, `uvalib-results-count.js`, `uvalib-combobox.js`, `uvalib-image-regions.js`, `uvalib-map.js`, `uvalib-filter-drawer.js`, `uvalib-back-to-top.js`, `uvalib-dialog.js`, `uvalib-citation.js`, `uvalib-list-filter.js`) register the element (`bento-box.js` also registers its four sections, `<catalog-section>`, `<articles-section>`, `<libguides-section>` and `<website-section>`). Importing the package root (`@uvalib/web-components`) gives the classes only and registers nothing. If you use the `SitePage` class directly, also import the header and footer define entries.
|
|
36
|
+
- npm: the define entries (`@uvalib/web-components/site-page.js`, `site-header.js`, `site-main-nav.js`, `site-footer.js`, `site-analytics.js`, `uvalib-analytics.js`, `site-style.js`, `uvalib-breadcrumbs.js`, `uvalib-card.js`, `uvalib-card-grid.js`, `uvalib-pager.js`, `uvalib-contents.js`, `uvalib-metadata.js`, `site-alerts.js`, `uvalib-filter.js`, `uvalib-date-range.js`, `uvalib-date-histogram.js`, `site-hours-section.js`, `library-weekly-hours.js`, `library-hours-setup.js`, `events-section.js`, `bento-box.js`, `uvalib-pagefind-search.js`, `uvalib-lightbox.js`, `uvalib-photo-grid.js`, `uvalib-tabs.js`, `uvalib-chip-group.js`, `uvalib-tag-list.js`, `uvalib-results-count.js`, `uvalib-combobox.js`, `uvalib-image-regions.js`, `uvalib-map.js`, `uvalib-filter-drawer.js`, `uvalib-back-to-top.js`, `uvalib-dialog.js`, `uvalib-citation.js`, `uvalib-list-filter.js`, `uvalib-audio.js`) register the element (`bento-box.js` also registers its four sections, `<catalog-section>`, `<articles-section>`, `<libguides-section>` and `<website-section>`). Importing the package root (`@uvalib/web-components`) gives the classes only and registers nothing. If you use the `SitePage` class directly, also import the header and footer define entries.
|
|
35
37
|
- Do not load the same component from both the CDN and npm on one page.
|
|
36
38
|
|
|
37
39
|
## 2. Required page structure
|
|
@@ -228,7 +230,7 @@ import '@uvalib/web-components/tokens.css'; // optional: tokens for your own CSS
|
|
|
228
230
|
|
|
229
231
|
Analytics: only when the site needs Matomo, set `<site-page matomo-id="N">`, or add `site-analytics.js` and a `<site-analytics matomoid="N">` (add `downloads="event"`, or `matomo-downloads="event"` on `<site-page>`, when file URLs carry ids: downloads are then counted as `['download', '<extension>']` events without URLs); see the analytics page in [reference/snippets.md](reference/snippets.md). `<uvalib-analytics>` (`uvalib-analytics.js`) is the same element under its original name, for existing markup. It listens on `document` for `uvalib-analytics-*` and `site-analytics-*` events (`event`, `search`, `pageview`, `content`) and queues them for Matomo, so events fired before Matomo loads are kept, and a page never counts twice. A single-page app whose router uses `pushState` or hashes can set `spa="auto"` to have each route change counted (after the new title is set, never twice for one URL); bare `spa` means the app sends its own `uvalib-analytics-pageview` events.
|
|
230
232
|
|
|
231
|
-
The library's components already report what visitors do with them; do not add tracking for any of it: header utility and site links, logo, skip link, Menu and colour scheme; main-nav menu opens and links; footer links; breadcrumb and contents levels, the contents disclosure, Copy citation; card clicks (the card's place in its grid, or single); pager next, previous, page numbers and Load more; tab changes (the tab's label); alerts (impressions, dismiss, links, errors); event clicks; See all hours, week changes; filter facets, scopes and See more/less; date-range changes; histogram selections (`<from>–<to>` when both ends are ISO dates, otherwise `other`); bento searches, result and See all clicks, retries; lightbox opens, next, previous and full size (the name is `image N`, never the URL or the caption) and version comparisons (`compare`, the mode and the version's place, never its label); load errors; and tag-list clicks and Show all (`list N`, or the label with `track-label`, and the tag's place; never the tag text); and combobox choices and clears (the field's label and the suggestion's place; never the typed text or the suggestion); and list-filter queries and clears (how many items match; never the typed text); and image-region outline clicks (the list's label and the region's number; never a region's label); and map marker choices and zoom-button presses (the map's label and the place's position or the zoom level; never the place's name, coordinates or URL). `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing. The README's "Analytics" section has the full table.
|
|
233
|
+
The library's components already report what visitors do with them; do not add tracking for any of it: header utility and site links, logo, skip link, Menu and colour scheme; main-nav menu opens and links; footer links; breadcrumb and contents levels, the contents disclosure, Copy citation; card clicks (the card's place in its grid, or single); pager next, previous, page numbers and Load more; tab changes (the tab's label); alerts (impressions, dismiss, links, errors); event clicks; See all hours, week changes; filter facets, scopes and See more/less; date-range changes; histogram selections (`<from>–<to>` when both ends are ISO dates, otherwise `other`); bento searches, result and See all clicks, retries; lightbox opens, next, previous and full size (the name is `image N`, never the URL or the caption) and version comparisons (`compare`, the mode and the version's place, never its label); load errors; and tag-list clicks and Show all (`list N`, or the label with `track-label`, and the tag's place; never the tag text); and combobox choices and clears (the field's label and the suggestion's place; never the typed text or the suggestion); and list-filter queries and clears (how many items match; never the typed text); and audio plays, completes, speed, resume and downloads (`chapter N`, never a title or URL); and image-region outline clicks (the list's label and the region's number; never a region's label); and map marker choices and zoom-button presses (the map's label and the place's position or the zoom level; never the place's name, coordinates or URL). `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing. The README's "Analytics" section has the full table.
|
|
232
234
|
|
|
233
235
|
For the host page's own content, tag the clickable element (or a wrapper) with `data-uvalib-track="category,action[,name[,value]]"` instead of writing a listener, for example `<a href="/spaces" data-uvalib-track="home-page,banner-click,Study spaces">`: the category is your page or widget, the action a fixed kebab-case verb, the name a short fixed label, the value a number. It works inside shadow DOM too. Never put titles, URLs, search text, ids, email addresses, phone numbers or other personal data in events.
|
|
234
236
|
|
|
@@ -564,7 +566,7 @@ A static site (11ty, Jekyll, a generated collection) that searches with [Pagefin
|
|
|
564
566
|
|
|
565
567
|
- 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
568
|
- 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), `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.
|
|
569
|
+
- 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), `filter-flags` (one-value "has X" filters linked as `?audiobook=1`: the parameter with any value but `0`/`false`/`no`/`off` checks the filter's one value, whatever the index calls it, and checking writes `=1`; it need not be in `filter-params` too; do not rewrite such URLs with your own script), `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
570
|
|
|
569
571
|
```html
|
|
570
572
|
<!doctype html>
|
|
@@ -613,6 +615,35 @@ For a TEI text converted to class-annotated HTML (the class is the TEI element n
|
|
|
613
615
|
- Classes: `div`/`div-*`, `head`, `p`, `ab`, `seg-*`, `lb`, `pb` (`pb-n`, `a.pb-image`), `lg`, `l` (`data-n`), `sp`, `speaker`, `stage`, `opener`, `closer`, `dateline`, `salute`, `signed`, `postscript`, `epigraph`, `argument`, `trailer`, `byline`, `bibl`, `cit`, `figure`, `figDesc`, `add`, `del`, `sic`, `orig`, `reg`, `unclear`, `gap`, `noteref`, `footnotes`, `note`, `note-inline`, `ornament`, `textbreak`, `titlepage`/`titlePage`, `list`, `rend-*` (italic, smallcaps, center, right, indent, indent2, indent3, hang, underline…).
|
|
614
616
|
- Keep whitespace before each `<br class="lb">` (CSS cannot space a `<br>`), or write `<span class="lb"></span>`. Line breaks: a `<label class="uvalib-edition__lines"><input type="checkbox"> Show original line breaks</label>` before or inside the edition (or the class `uvalib-edition--lines`); readings in `title`: `.uvalib-edition__readings` (a title alone is hover-only).
|
|
615
617
|
- Additions and deletions are announced by generated text; do not add your own. Page images: `<uvalib-lightbox selector=".uvalib-edition a.pb-image">`. README: "Reading texts (edition.css)".
|
|
618
|
+
- EPUB and PDF downloads of the same text: link `edition-epub.css` in each EPUB content document (copy it into the EPUB; no `.uvalib-edition` wrapper needed), and `edition-epub.css` then `edition-print.css` (page margins and numbers, print rules) in the HTML a PDF is printed from. Generated from edition.css, same classes and look, in CSS reading systems handle; don't keep a hand-made download stylesheet. No toggles there (prose reflows).
|
|
619
|
+
|
|
620
|
+
### Audio by chapter
|
|
621
|
+
|
|
622
|
+
An audiobook's chapters or an oral history's sessions are one `<uvalib-audio>` (`uvalib-audio.js`) around a plain list of links to the files, never a native `<audio controls>` per chapter or your own player.
|
|
623
|
+
|
|
624
|
+
```html
|
|
625
|
+
<uvalib-audio
|
|
626
|
+
label="Alice’s Adventures in Wonderland"
|
|
627
|
+
download-href="alice.m4b"
|
|
628
|
+
download-label="Download the whole book"
|
|
629
|
+
download-size="161234567"
|
|
630
|
+
>
|
|
631
|
+
<ol>
|
|
632
|
+
<li>
|
|
633
|
+
<a href="ch01.mp3" data-duration="12:31">1. Down the Rabbit-Hole</a>
|
|
634
|
+
<a href="../text.html#ch1">Read the text</a>
|
|
635
|
+
</li>
|
|
636
|
+
<li data-download data-size="9800000">
|
|
637
|
+
<a href="ch02.mp3" data-duration="10:02">2. The Pool of Tears</a>
|
|
638
|
+
</li>
|
|
639
|
+
</ol>
|
|
640
|
+
</uvalib-audio>
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
- The first link in each item is the chapter (`data-duration` as `12:31`, `1:02:03` or seconds); other links stay links. `data-download` (+ `data-size`) on an item adds that chapter's download.
|
|
644
|
+
- It draws a Play button per chapter, `aria-current` and "Now playing", one player (Back 15 s, Play/Pause, Forward 30 s, a position slider, the time, a speed select 0.75–2×) and one polite status: do not add controls, live regions or keyboard shortcuts of your own. Nothing preloads or autoplays; `continuous` plays on to the next chapter.
|
|
645
|
+
- It remembers the chapter, position and speed per page in localStorage and offers "Resume … at 12:30" (`storage-key` when a page has two recordings; `no-resume` to turn it off).
|
|
646
|
+
- A cast or credits table goes after it as a `.uvalib-table`. With `base.css` the player's space is held. It reports its own analytics by chapter number. README: "Audio by chapter".
|
|
616
647
|
|
|
617
648
|
### Results toolbar, badges and tags
|
|
618
649
|
|
|
@@ -584,6 +584,57 @@ Compatibility element. Light mode (`no-shadow-dom`) installs the tokens and base
|
|
|
584
584
|
| `site-analytics-event` | Listened for on `document` too: the same as `uvalib-analytics-event`. |
|
|
585
585
|
| `site-analytics-content` | Listened for on `document` too: the same as `uvalib-analytics-content`. |
|
|
586
586
|
|
|
587
|
+
## `<uvalib-audio>`
|
|
588
|
+
|
|
589
|
+
A long recording played by chapter: an audiobook, an oral history's sessions. One player for the whole list, so starting a chapter stops the one playing. Give the chapters as a list of links to their files, so the page works before (and without) the script: `<ol><li><a href="ch1.mp3" data-duration="12:31">Chapter 1. Down the Rabbit-Hole</a></li>…</ol>`. The first link in each item is the chapter (its text is the title; inline markup such as `<i>` or `lang` is kept); `data-duration` (`12:31`, `1:02:03` or seconds) is shown beside it and gives the slider its length before the file loads. Other links in the item (the chapter's text, a transcript) are kept as links after it. `data-download` on the `<li>` adds a Download link for that chapter (its own file, or the URL given), with `data-size` (bytes or text) after it. Upgraded, each chapter is a real button (“Play Chapter 1. Down the Rabbit-Hole”, its visible text), with its duration; the current chapter gets `aria-current="true"` and says “Now playing” or “Paused” in text, beside an orange bar. Above the list, a player for the current chapter: what is playing (as text, not a live region), Back 15 s, Play/Pause, Forward 30 s, a position slider (a native range, read as “12 minutes 30 seconds of 41 minutes”), the elapsed and total time, and a native Speed select (0.75× to 2×). One `<audio preload="none">` plays everything: nothing loads until the visitor presses Play, and nothing ever plays without a press. `continuous` plays the next chapter when one ends. The position is remembered per page in localStorage (the page's path, plus `storage-key` when a page has more than one recording): on the next visit a “Resume “Chapter 4” at 12:30” button offers to carry on, never playing by itself. Saved on pause, every few seconds while playing, and when the page is left; cleared when the last chapter ends. `no-resume` turns it off. Without storage it simply forgets. Chapter changes, pauses, speed changes and skips are announced politely in one status (a burst of skips once, where it ends); the time is never announced as it runs. A chapter that fails to load says so in text, with a direct link to its file. `download-href` adds a link to the whole recording (an M4B audiobook), with `download-label` and `download-size` (bytes, shown as “312 MB”, or text). Where the browser has the Media Session API, the system's media keys and lock screen show the chapter and can play, pause, seek and change chapter. Before it upgrades, `base.css` holds the player's height above the list and gives each item the height of its upgraded row, so the list does not move.
|
|
590
|
+
|
|
591
|
+
### Attributes
|
|
592
|
+
|
|
593
|
+
| Attribute | Type | Default | Description |
|
|
594
|
+
|---|---|---|---|
|
|
595
|
+
| `label` | `string` | `''` | The player's accessible name, such as the book's title (default “Player”). |
|
|
596
|
+
| `continuous` | `boolean` | `false` | Play the next chapter when one ends. |
|
|
597
|
+
| `no-resume` | `boolean` | `false` | Don't remember the position (nothing is read from or written to localStorage). |
|
|
598
|
+
| `storage-key` | `string` | `''` | Added to the page's path to name what is remembered, for a page with several recordings. |
|
|
599
|
+
| `download-href` | `string` | `''` | The whole recording to download (an M4B audiobook with chapters, an MP3). |
|
|
600
|
+
| `download-label` | `string` | `'Download the whole recording'` | The download link's text. |
|
|
601
|
+
| `download-size` | `string` | `''` | The download's size: bytes (shown as “312 MB”) or text. |
|
|
602
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
603
|
+
| `no-style` | `boolean` | `false` | |
|
|
604
|
+
|
|
605
|
+
### CSS parts
|
|
606
|
+
|
|
607
|
+
| Part | Description |
|
|
608
|
+
|---|---|
|
|
609
|
+
| `player` | The player box above the list. |
|
|
610
|
+
| `now` | The line saying what is playing (or the Resume button). |
|
|
611
|
+
| `controls` | The player's buttons, slider, time and speed. |
|
|
612
|
+
| `download` | The whole recording's download line. |
|
|
613
|
+
| `list` | The list of chapters. |
|
|
614
|
+
| `chapter` | Each chapter's row. |
|
|
615
|
+
|
|
616
|
+
### Events
|
|
617
|
+
|
|
618
|
+
| Event | Description |
|
|
619
|
+
|---|---|
|
|
620
|
+
| `uvalib-analytics-event` | For `<site-analytics>`, on the visitor's actions only, never titles or URLs: `['uvalib-audio', 'play', 'chapter <N>', N]` the first time each chapter plays in a page view (N is its place in the list), `['uvalib-audio', 'complete', 'chapter <N>', N]` when it plays to its end, `['uvalib-audio', 'speed', '<speed>', speed]` once the visitor settles on a speed, `['uvalib-audio', 'resume', 'chapter <N>', N]`, and `['uvalib-audio', 'download', 'recording' \| 'chapter <N>']`. Bubbles and is composed. |
|
|
621
|
+
|
|
622
|
+
### CSS custom properties
|
|
623
|
+
|
|
624
|
+
| Property | Default | Description |
|
|
625
|
+
|---|---|---|
|
|
626
|
+
| `--uva-color-text` | | Dark-mode role token: text (else `--uva-grey-darkest`). |
|
|
627
|
+
| `--uva-color-text-muted` | | Dark-mode role token: durations (else #4b5563). |
|
|
628
|
+
| `--uva-color-link` | | Dark-mode role token: links and the outline buttons (else `--uva-brand-blue`). |
|
|
629
|
+
| `--uva-color-button-bg` | | Dark-mode role token: Play/Pause and the slider (else `--uva-blue-alt`). |
|
|
630
|
+
| `--uva-color-button-text` | | Dark-mode role token: Play/Pause text (else #fff). |
|
|
631
|
+
| `--uva-color-surface-raised` | | Dark-mode role token: the player's and the controls' background (else #fff). |
|
|
632
|
+
| `--uva-color-table-border` | | Dark-mode role token: the player's border and the rules between chapters (else #dadada). |
|
|
633
|
+
| `--uva-color-accent-bg` | | Dark-mode role token: the “Now playing” marker (else `--uva-brand-blue`). |
|
|
634
|
+
| `--uva-color-on-accent` | | Dark-mode role token: the marker's text (else #fff). |
|
|
635
|
+
| `--uva-color-current` | | Dark-mode role token: the current chapter's bar (else `--uva-brand-orange`). |
|
|
636
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
637
|
+
|
|
587
638
|
## `<uvalib-back-to-top>`
|
|
588
639
|
|
|
589
640
|
A “Back to top” button for long pages: minutes, finding aids, transcriptions, long result lists. It stays hidden (`visibility: hidden`, so it is neither a tab stop nor in the accessibility tree) until the top `offset` pixels of the page (default 400) have scrolled out of view, watched with an IntersectionObserver on a small sentinel at the top of the page, never a scroll listener. If it has focus as it hides, focus moves to the target. Activating it scrolls to the top (smoothly unless the visitor prefers reduced motion) and moves focus to the page's `<h1>` (the first in `<main>`, else the first anywhere, else `#top`), or to `target` (a selector), adding `tabindex="-1"` when it is not focusable, so keyboard and screen reader users land at the top too. The button is fixed in the bottom corner (end side), inside the safe-area insets. The element itself is an empty block 4.75rem tall: put it last in the page's main content and that is the space the button needs, so the last lines can always scroll clear of it. When that space comes into view the button sits in it instead of floating, so it never covers the footer either. It is hidden in print.
|
|
@@ -1509,7 +1560,7 @@ A record's details as a description list, as on the library's digital collection
|
|
|
1509
1560
|
|
|
1510
1561
|
## `<uvalib-pagefind-search>`
|
|
1511
1562
|
|
|
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.
|
|
1563
|
+
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 with `filter-flags`, one-value filters linked as `?audiobook=1`); 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.
|
|
1513
1564
|
|
|
1514
1565
|
### Attributes
|
|
1515
1566
|
|
|
@@ -1530,6 +1581,7 @@ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle)
|
|
|
1530
1581
|
| `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
1582
|
| `no-skeleton` | `boolean` | | Never hold space or show placeholder results (`searching` is ignored). |
|
|
1532
1583
|
| `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. |
|
|
1584
|
+
| `filter-flags` | `string` | | Space-separated names of one-value Pagefind filters ("has an audiobook": its one value is `Available`), read from and written to the URL as on/off flags (issue #40). The parameter with any value, or none (`?audiobook`, `?audiobook=1`, `?audiobook=yes`), checks the filter's one value, whatever its spelling in the index; `0`, `false`, `no` and `off` leave it unchecked. Checking it writes `?audiobook=1`; unchecking removes it. Otherwise as `filter-params` (one search with the query, Back and Forward); a name need not be repeated there, and a name in both is a flag. If the index has more or fewer than one value for it, a console warning says so once and the filter is read as `filter-params` (exact values). |
|
|
1533
1585
|
|
|
1534
1586
|
### Events
|
|
1535
1587
|
|