@uvalib/web-components 1.7.0 → 1.8.3
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 +48 -0
- package/README.md +60 -15
- package/dist/base/states.d.ts +12 -0
- package/dist/base/states.js +33 -0
- package/dist/base/states.js.map +1 -0
- package/dist/base.css +69 -6
- package/dist/components/bento-box/BentoBox.js +1 -0
- package/dist/components/bento-box/BentoBox.js.map +1 -1
- package/dist/components/events-section/EventsSection.js +1 -0
- package/dist/components/events-section/EventsSection.js.map +1 -1
- package/dist/components/library-hours/hours-data.js +1 -1
- package/dist/components/library-hours/hours-data.js.map +1 -1
- package/dist/components/library-weekly-hours/LibraryWeeklyHours.js +1 -0
- package/dist/components/library-weekly-hours/LibraryWeeklyHours.js.map +1 -1
- package/dist/components/site-main-nav/SiteMainNav.d.ts +1 -1
- package/dist/components/site-main-nav/SiteMainNav.js +9 -2
- package/dist/components/site-main-nav/SiteMainNav.js.map +1 -1
- package/dist/components/site-page/SitePage.d.ts +1 -1
- package/dist/components/site-page/SitePage.js +3 -2
- package/dist/components/site-page/SitePage.js.map +1 -1
- package/dist/components/site-style/SiteStyle.d.ts +1 -1
- package/dist/components/site-style/SiteStyle.js +3 -2
- package/dist/components/site-style/SiteStyle.js.map +1 -1
- package/dist/components/uvalib-card/UvalibCard.js +6 -0
- package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
- package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +27 -0
- package/dist/components/uvalib-combobox/UvalibCombobox.js +85 -1
- package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -1
- package/dist/components/uvalib-contents/UvalibContents.js +5 -0
- package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +6 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +10 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -1
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js +2 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -1
- package/dist/components/uvalib-image-regions/regions.d.ts +6 -2
- package/dist/components/uvalib-image-regions/regions.js +6 -3
- package/dist/components/uvalib-image-regions/regions.js.map +1 -1
- package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +9 -2
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +23 -3
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-lightbox/compare.d.ts +30 -3
- package/dist/components/uvalib-lightbox/compare.js +98 -29
- package/dist/components/uvalib-lightbox/compare.js.map +1 -1
- package/dist/components/uvalib-map/UvalibMap.js +2 -2
- package/dist/components/uvalib-map/UvalibMap.js.map +1 -1
- package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -0
- package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +3 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +3 -3
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +16 -8
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
- package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +4 -1
- package/dist/components/uvalib-tag-list/UvalibTagList.js +9 -2
- package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -1
- package/dist/custom-elements.json +1992 -1681
- package/dist/pagefind.css +8 -1
- package/dist/styles/base.js +8 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/font-fallback.d.ts +17 -0
- package/dist/styles/font-fallback.js +64 -0
- package/dist/styles/font-fallback.js.map +1 -0
- package/dist/styles/message.js +4 -0
- package/dist/styles/message.js.map +1 -1
- package/dist/styles/pagefind.js +8 -1
- package/dist/styles/pagefind.js.map +1 -1
- package/dist/styles/result-list.js +25 -4
- package/dist/styles/result-list.js.map +1 -1
- package/dist/styles/results.js +17 -2
- package/dist/styles/results.js.map +1 -1
- package/dist/styles/tokens.js +1 -1
- package/dist/tokens.css +47 -1
- package/dist-cdn/base.css +69 -6
- package/dist-cdn/bento-box.js +1 -0
- package/dist-cdn/bento-box.js.map +1 -1
- package/dist-cdn/chunks/{base-BI8h0Gf3.js → base-CIX_-Rmo.js} +58 -6
- package/dist-cdn/chunks/base-CIX_-Rmo.js.map +1 -0
- package/dist-cdn/chunks/{compare-DV6ltvsJ.js → compare-C0nhByn7.js} +66 -29
- package/dist-cdn/chunks/compare-C0nhByn7.js.map +1 -0
- package/dist-cdn/chunks/{hours-data-Bw6vkIw7.js → hours-data-gMu5uT7H.js} +2 -2
- package/dist-cdn/chunks/hours-data-gMu5uT7H.js.map +1 -0
- package/dist-cdn/chunks/{library-weekly-hours-CrV3TlP5.js → library-weekly-hours-BJgxAyah.js} +3 -2
- package/dist-cdn/chunks/library-weekly-hours-BJgxAyah.js.map +1 -0
- package/dist-cdn/chunks/{regions-B8ExwUGP.js → regions-B-rOwa-v.js} +15 -15
- package/dist-cdn/chunks/regions-B-rOwa-v.js.map +1 -0
- package/dist-cdn/chunks/{site-header-DYRMpdBj.js → site-header-CEmNtmk5.js} +2 -2
- package/dist-cdn/chunks/{site-header-DYRMpdBj.js.map → site-header-CEmNtmk5.js.map} +1 -1
- package/dist-cdn/chunks/{site-main-nav-DURrQMal.js → site-main-nav-CAwKq_x5.js} +9 -2
- package/dist-cdn/chunks/site-main-nav-CAwKq_x5.js.map +1 -0
- package/dist-cdn/chunks/states-DGXGzcte.js +17 -0
- package/dist-cdn/chunks/states-DGXGzcte.js.map +1 -0
- package/dist-cdn/custom-elements.json +1992 -1681
- package/dist-cdn/events-section.js +1 -0
- package/dist-cdn/events-section.js.map +1 -1
- package/dist-cdn/library-hours-setup.js +1 -1
- package/dist-cdn/library-weekly-hours.js +1 -1
- package/dist-cdn/manifest.json +1 -1
- package/dist-cdn/pagefind.css +8 -1
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-hours-section.js +1 -1
- package/dist-cdn/site-main-nav.js +1 -1
- package/dist-cdn/site-page.js +50 -46
- package/dist-cdn/site-page.js.map +1 -1
- package/dist-cdn/site-style.js +6 -6
- package/dist-cdn/site-style.js.map +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +6 -5
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +36 -9
- package/dist-cdn/tokens.css +47 -1
- package/dist-cdn/uvalib-card.js +6 -0
- package/dist-cdn/uvalib-card.js.map +1 -1
- package/dist-cdn/uvalib-combobox.js +107 -68
- package/dist-cdn/uvalib-combobox.js.map +1 -1
- package/dist-cdn/uvalib-contents.js +5 -0
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-filter-drawer.js +27 -25
- package/dist-cdn/uvalib-filter-drawer.js.map +1 -1
- package/dist-cdn/uvalib-image-regions.js +3 -1
- package/dist-cdn/uvalib-image-regions.js.map +1 -1
- package/dist-cdn/uvalib-lightbox.js +80 -69
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-map.js +2 -2
- package/dist-cdn/uvalib-map.js.map +1 -1
- package/dist-cdn/uvalib-metadata.js +3 -0
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pagefind-search.js +2 -1
- package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +4 -5
- package/dist-cdn/uvalib-photo-grid.js.map +1 -1
- package/dist-cdn/uvalib-tag-list.js +21 -16
- package/dist-cdn/uvalib-tag-list.js.map +1 -1
- package/package.json +1 -1
- package/skills/uvalib-web-components/SKILL.md +6 -5
- package/skills/uvalib-web-components/reference/components.md +36 -9
- package/dist-cdn/chunks/base-BI8h0Gf3.js.map +0 -1
- package/dist-cdn/chunks/compare-DV6ltvsJ.js.map +0 -1
- package/dist-cdn/chunks/hours-data-Bw6vkIw7.js.map +0 -1
- package/dist-cdn/chunks/library-weekly-hours-CrV3TlP5.js.map +0 -1
- package/dist-cdn/chunks/regions-B8ExwUGP.js.map +0 -1
- package/dist-cdn/chunks/site-main-nav-DURrQMal.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uvalib-combobox.js","names":["unsafeCSS","nothing","_decorate","property","state","n","w","i","r$1","b","define","__decorate","A","r","installLightDomStyles","UvalibElement","trackEvent","trackError","normalize","SourceChildren","accessible","comboboxTiming","TAG","CLEAR_MS","CACHE_SIZE","uid","MARKS","fold","s","foldMap","text","map","ch","label","f","k","WORD","toEntry","raw","e","d","toEntries","list","count","structuralRules","host","shadowStructure","BORDER","ACCENT","MUTED","TEXT","RAISED","CLEAR_ICON","UvalibCombobox","nodes","root","sheet","node","disabled","state","input","options","v","kind","message","entries","o","item","key","m","all","max","q","buckets","total","cached","ctrl","url","res","data","err","value","type","hits","selected","at","from","dir","index","keep","button","form","el","li","now","changed","field","popup","opt","top","bottom","parts","last","end","id","off","expanded","note"],"sources":["../src/components/uvalib-combobox/UvalibCombobox.ts","../src/components/uvalib-combobox/uvalib-combobox.ts"],"sourcesContent":["import { css, html, nothing, svg, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackError, trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { normalize, SourceChildren } from '../../base/source-children.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/**\n * One suggestion: the value submitted with the form and reported in events, the text shown\n * (default: the value), an optional second line, and whether it can be chosen. Other fields\n * are kept: `select` and `change` hand back the object you gave.\n */\nexport interface ComboboxItem {\n value: string;\n label?: string;\n description?: string;\n disabled?: boolean;\n [key: string]: unknown;\n}\n\n/** Turns a `src` response into suggestions (default: the response is already an array). */\nexport type ComboboxTransform = (data: unknown, query: string) => (ComboboxItem | string)[];\n\n/**\n * `debounce`: milliseconds after the last keystroke before `src` is fetched. `announce`:\n * milliseconds the suggestion count must stay put before it is announced. Tests may shorten them.\n */\nexport const comboboxTiming = { debounce: 250, announce: 500 };\n\nconst TAG = 'uvalib-combobox';\n/** How long an announcement stays in the live region before it is cleared. */\nconst CLEAR_MS = 5000;\n/** Responses kept per `src`, so Backspace does not fetch again. */\nconst CACHE_SIZE = 30;\nlet uid = 0;\n\n/** A suggestion as shown: its display text, folded for matching, and what was given. */\ninterface Entry {\n value: string;\n label: string;\n description?: string;\n disabled: boolean;\n fold: string;\n /** What events and `selected` hand back: the given object, or `{ value, label }` for a string. */\n raw: ComboboxItem;\n}\n\nconst MARKS = /\\p{M}/gu;\n/** Case- and accent-insensitive form: “Ébène” and “ebene” match. */\nexport const fold = (s: string): string => s.normalize('NFD').replace(MARKS, '').toLowerCase();\n\n/** `label` folded, with the index in `label` that each folded character came from. */\nfunction foldMap(label: string): { text: string; map: number[] } {\n let text = '';\n const map: number[] = [];\n let i = 0;\n for (const ch of label) {\n const f = fold(ch);\n for (let k = 0; k < f.length; k++) map.push(i);\n text += f;\n i += ch.length;\n }\n map.push(i);\n return { text, map };\n}\n\nconst WORD = /[\\p{L}\\p{N}]/u;\n\nfunction toEntry(raw: unknown): Entry | null {\n if (typeof raw === 'string' || typeof raw === 'number') {\n const s = normalize(raw);\n return s\n ? { value: s, label: s, disabled: false, fold: fold(s), raw: { value: s, label: s } }\n : null;\n }\n if (!raw || typeof raw !== 'object') return null;\n const r = raw as ComboboxItem;\n const label = normalize(r.label ?? r.value);\n if (!label) return null;\n const e: Entry = {\n value: String(r.value ?? label),\n label,\n disabled: !!r.disabled,\n fold: fold(label),\n raw: r,\n };\n const d = normalize(r.description);\n if (d) e.description = d;\n return e;\n}\n\nconst toEntries = (list: unknown): Entry[] =>\n Array.isArray(list) ? list.map(toEntry).filter((e): e is Entry => e !== null) : [];\n\nconst count = (n: number) => n.toLocaleString('en-US');\n\n/**\n * Kept with `no-style`: the popup under the field, 44px options and clear button, and the\n * hidden live region. `host` is `:host` or the tag.\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; max-width: 100%; line-height: 1.5; }\n ${host} .label { display: block; margin-block-end: 0.25rem; }\n ${host} .field { position: relative; }\n ${host} .input {\n display: block;\n box-sizing: border-box;\n inline-size: 100%;\n min-block-size: 44px;\n margin: 0;\n padding-inline-end: 44px;\n font: inherit;\n line-height: 1.2;\n }\n ${host} .clear {\n position: absolute;\n inset-block-start: 0;\n inset-inline-end: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n inline-size: 44px;\n block-size: 44px;\n margin: 0;\n padding: 0;\n cursor: pointer;\n }\n ${host} .popup {\n position: absolute;\n inset-inline: 0;\n inset-block-start: calc(100% + 2px);\n z-index: 20;\n box-sizing: border-box;\n max-block-size: min(18rem, 60vh);\n margin: 0;\n overflow-y: auto;\n overscroll-behavior: contain;\n }\n ${host} .listbox { margin: 0; padding: 0; list-style: none; }\n ${host} .option {\n display: flex;\n flex-direction: column;\n justify-content: center;\n box-sizing: border-box;\n min-block-size: 44px;\n overflow-wrap: anywhere;\n cursor: pointer;\n }\n ${host} .option[aria-disabled='true'] { cursor: not-allowed; }\n ${host} .message { box-sizing: border-box; min-block-size: 44px; margin: 0; }\n ${host} .description { margin: 0.25rem 0 0; }\n ${host} .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\nconst BORDER = unsafeCSS('var(--uva-color-control-border, var(--uva-grey, #808080))');\nconst ACCENT = unsafeCSS('var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))');\nconst MUTED = unsafeCSS('var(--uva-color-text-muted, var(--uva-grey-A, #4f4f4f))');\nconst TEXT = unsafeCSS('var(--uva-color-input-text, var(--uva-grey-darkest, #2b2b2b))');\nconst RAISED = unsafeCSS('var(--uva-color-surface-raised, #ffffff)');\n\nconst CLEAR_ICON = svg`<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M4 4l8 8M12 4l-8 8\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>`;\n\n/**\n * An editable text field that suggests values as you type, from a local list or a URL: a\n * person, place or subject picker. It follows the WAI-ARIA APG “Editable Combobox With List\n * Autocomplete”: a real `<input role=\"combobox\">` and a `role=\"listbox\"` popup under it.\n *\n * Suggestions come from the `items` property (`{ value, label?, description?, disabled? }`\n * objects, or strings), from `<option>` children (directly or inside a `<datalist>`; the\n * `label` attribute or text is the label, `data-description` the second line), or from `src`,\n * a URL template with `{q}` (fetched 250 ms after the last keystroke once the text has\n * `min-length` characters, default 1; a newer keystroke aborts the older request; the\n * response is a JSON array of the same shape, or anything `transform(data, query)` turns\n * into one). `items` wins over the children while set. Local suggestions match anywhere in\n * the label, ignoring case and accents, those starting with the text first, then those with\n * a word starting with it; at most `max-results` (default 50, 0 for all) are shown, which\n * keeps a list of 16,000 people fast. The matched text is bold and underlined in a `<mark>`.\n *\n * Keys: Down opens the list on the first suggestion and moves (wrapping), Up opens on the\n * last, Alt+Down opens without moving, Alt+Up closes, Enter chooses the active suggestion\n * (and then does not submit the form; with none active, Enter submits as in any field),\n * Escape closes the list and a second Escape clears the field, Home, End, Left and Right move\n * the caret, and Tab leaves without choosing. A real clear button (“Clear <label>”, 44px,\n * shown only with text) empties the field and returns focus to it.\n *\n * Free text is allowed: `value` is whatever is in the field, and `selected` the chosen\n * suggestion (or null); typing after choosing clears it, and leaving the field with text that\n * is exactly one suggestion's label chooses it. `must-choose` makes any other text invalid\n * (“Choose one of the suggestions.”). The element is form-associated: with `name` it submits\n * the chosen suggestion's value, or else the text, and a form reset restores the `value`\n * attribute. `required` and `disabled` (also from a disabled fieldset) work as on an input.\n *\n * A polite status says “5 suggestions”, “50 of 1,234 suggestions”, “No suggestions”,\n * “Loading suggestions” or “Couldn't load suggestions” half a second after the list settles\n * (never on the first render); the popup shows the same notes visibly. A failed load never\n * throws.\n *\n * Before it upgrades, `base.css` shows the label (from the attribute) and holds the field's\n * height. A fallback `<input list>` child works as a plain field meanwhile; on upgrade its\n * text, `name` and `placeholder` carry over, and it is disabled so it does not submit twice.\n *\n * @tagname uvalib-combobox\n * @fires input - The text changed by typing (the native event of the field, composed). Not fired when an option is chosen.\n * @fires select - A suggestion was chosen (click or Enter). `detail` is `{ item }`, the object given. Bubbles and is composed.\n * @fires change - The value was committed: a suggestion chosen, the field cleared, or the field left with changed text. `detail` is `{ value, item }` (`item` is the chosen suggestion or null). Not fired when the app sets `value` or `selected`. Bubbles and is composed.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-combobox', 'select', '<label>', <position from 1>]` when a suggestion is chosen, `['uvalib-combobox', 'clear', '<label>']` when the clear button or Escape empties the field, and `['uvalib-combobox', 'error', 'load']` once when `src` fails. Never the typed text or a suggestion's text or value. Bubbles and is composed.\n * @csspart label - The visible label.\n * @csspart input - The text field.\n * @csspart clear - The clear button.\n * @csspart popup - The popup under the field.\n * @csspart option - Each suggestion.\n * @csspart description - The hint under the field.\n * @cssprop --uva-color-surface-raised - Dark-mode role token: field and popup background (else #fff).\n * @cssprop --uva-color-control-border - Dark-mode role token: field and popup border (else `--uva-grey`, #808080).\n * @cssprop --uva-color-input-text - Dark-mode role token: field and suggestion text (else #2b2b2b).\n * @cssprop --uva-color-text-muted - Dark-mode role token: descriptions, notes and the clear icon (else #4f4f4f).\n * @cssprop --uva-color-surface-hover - Dark-mode role token: active suggestion background (else #dadada).\n * @cssprop --uva-color-track - Dark-mode role token: hovered suggestion background (else #f1f1f1).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: the active suggestion's bar and outline (else `--uva-brand-blue`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-shadow - Dark-mode role token: popup shadow.\n */\nexport class UvalibCombobox extends UvalibElement {\n static formAssociated = true;\n static override shadowRootOptions: ShadowRootInit = {\n ...UvalibElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n static styles = [\n accessible,\n shadowStructure,\n css`\n .label {\n font-weight: 600;\n }\n .input {\n padding-block: 0.5rem;\n padding-inline-start: 0.75rem;\n border: 1px solid ${BORDER};\n border-radius: 5px;\n background: ${RAISED};\n color: ${TEXT};\n }\n .input::placeholder {\n color: ${MUTED};\n opacity: 1;\n }\n .input:disabled {\n background: var(--uva-color-track, var(--uva-grey-200, #f1f1f1));\n color: ${MUTED};\n cursor: not-allowed;\n }\n .input[aria-invalid='true'] {\n border-width: 2px;\n }\n .clear {\n border: 0;\n border-radius: 5px;\n background: none;\n color: ${MUTED};\n }\n .clear:hover {\n color: ${TEXT};\n }\n .clear:focus-visible {\n outline-offset: -4px;\n }\n .popup {\n padding-block: 0.25rem;\n border: 1px solid ${BORDER};\n border-radius: 5px;\n background: ${RAISED};\n color: ${TEXT};\n box-shadow: 0 4px 12px var(--uva-color-shadow, rgba(0, 0, 0, 0.2));\n }\n .option {\n padding: 0.375rem 0.75rem;\n border-inline-start: 4px solid transparent;\n }\n .option:hover {\n background: var(--uva-color-track, var(--uva-grey-200, #f1f1f1));\n }\n /* The active suggestion: a fill, a bar at the start and an outline, never colour alone. */\n .option[aria-selected='true'] {\n border-inline-start-color: ${ACCENT};\n background: var(--uva-color-surface-hover, var(--uva-grey-100, #dadada));\n outline: 2px solid ${ACCENT};\n outline-offset: -2px;\n }\n .option[aria-disabled='true'] {\n color: ${MUTED};\n font-style: italic;\n }\n .option-description {\n color: ${MUTED};\n font-size: 0.875em;\n }\n mark {\n background: none;\n color: inherit;\n font-weight: 700;\n text-decoration: underline;\n text-underline-offset: 0.15em;\n }\n .message {\n padding: 0.625rem 0.75rem;\n color: ${MUTED};\n }\n .description {\n color: ${MUTED};\n }\n @media (forced-colors: active) {\n .input,\n .popup {\n border-color: CanvasText;\n }\n .clear {\n color: ButtonText;\n }\n .option[aria-selected='true'] {\n forced-color-adjust: none;\n border-inline-start-color: HighlightText;\n background: Highlight;\n color: HighlightText;\n outline-color: HighlightText;\n }\n .option[aria-selected='true'] .option-description {\n color: HighlightText;\n }\n .option[aria-disabled='true'] {\n color: GrayText;\n }\n }\n `,\n ];\n\n /** The field's visible label (required); also the analytics name. */\n @property({ type: String }) label = '';\n\n /** A hint under the field, read with it (aria-describedby). */\n @property({ type: String }) description = '';\n\n @property({ type: String }) placeholder = '';\n\n /** The form field name. */\n @property({ type: String, reflect: true }) name = '';\n\n /**\n * The text in the field. The attribute is the starting text, and what a form reset\n * restores. Setting it does not fire `change`.\n */\n @property({ type: String }) value = '';\n\n /**\n * The chosen suggestion, or null. Set it (an item or a string) to show a choice: the field\n * shows its label. Setting it does not fire `change`.\n */\n @property({ attribute: false }) selected: ComboboxItem | null = null;\n\n /** Suggestions as data: `{ value, label?, description?, disabled? }` or strings. Wins over the children. */\n @property({ attribute: false }) items?: (ComboboxItem | string)[];\n\n /** A URL template with `{q}` (the trimmed text, URL-encoded) that returns suggestions as JSON. */\n @property({ type: String }) src = '';\n\n /** Maps a `src` response to suggestions, e.g. `(data) => data.results`. */\n @property({ attribute: false }) transform?: ComboboxTransform;\n\n /** Characters typed before suggestions appear (and `src` is fetched). */\n @property({ type: Number, attribute: 'min-length' }) minLength = 1;\n\n /** The most suggestions shown at once; 0 for all. */\n @property({ type: Number, attribute: 'max-results' }) maxResults = 50;\n\n /** Text that is not one of the suggestions is invalid. */\n @property({ type: Boolean, attribute: 'must-choose' }) mustChoose = false;\n\n @property({ type: Boolean, reflect: true }) required = false;\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n @state() private open = false;\n @state() private active = -1;\n @state() private shown: Entry[] = [];\n @state() private total = 0;\n @state() private loading: 'idle' | 'loading' | 'error' = 'idle';\n @state() private announcement = '';\n @state() private formDisabled = false;\n @state() private invalidShown = false;\n @state() private childEntries: Entry[] = [];\n\n private internals: ElementInternals;\n private readonly uid = `${TAG}-${++uid}`;\n private warned = new Set<string>();\n /** The last committed state: `change` fires when it differs. */\n private committed: { value: string; item: ComboboxItem | null } = { value: '', item: null };\n /** Values this element set itself (any other change is the app's). */\n private ownValue?: string;\n private ownSelected?: ComboboxItem | null;\n private itemEntries?: Entry[];\n private itemsSource?: unknown;\n private remote: Entry[] = [];\n private remoteQuery?: string;\n private cache = new Map<string, Entry[]>();\n private abort?: AbortController;\n private fetchTimer?: ReturnType<typeof setTimeout>;\n private announceTimer?: ReturnType<typeof setTimeout>;\n private clearTimer?: ReturnType<typeof setTimeout>;\n private lastAnnounced = '';\n private adopted = new WeakSet<HTMLInputElement>();\n private started = false;\n\n constructor() {\n super();\n this.internals = this.attachInternals();\n new SourceChildren(\n this,\n () => this.lightDom,\n (nodes) => this.read(nodes),\n );\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.cancelFetch();\n clearTimeout(this.announceTimer);\n clearTimeout(this.clearTimer);\n this.open = false;\n }\n\n /* ---------- form association ---------- */\n\n get form(): HTMLFormElement | null {\n return this.internals.form;\n }\n get validity(): ValidityState {\n return this.internals.validity;\n }\n get validationMessage(): string {\n return this.internals.validationMessage;\n }\n get willValidate(): boolean {\n return this.internals.willValidate;\n }\n checkValidity(): boolean {\n return this.internals.checkValidity();\n }\n reportValidity(): boolean {\n return this.internals.reportValidity();\n }\n\n formResetCallback(): void {\n this.cancelFetch();\n this.open = false;\n this.active = -1;\n this.invalidShown = false;\n this.setOwn(this.getAttribute('value') ?? '', null);\n this.committed = { value: this.value, item: null };\n }\n\n formDisabledCallback(disabled: boolean): void {\n this.formDisabled = disabled;\n }\n\n formStateRestoreCallback(state: string | File | FormData | null): void {\n if (typeof state === 'string') {\n this.setOwn(state, null);\n this.committed = { value: state, item: null };\n }\n }\n\n private get input(): HTMLInputElement | null {\n return this.renderRoot.querySelector<HTMLInputElement>(`#${this.uid}-input`);\n }\n\n override focus(options?: FocusOptions): void {\n const input = this.input;\n if (input) input.focus(options);\n else super.focus(options);\n }\n\n private updateForm(): void {\n const v = this.selected ? String(this.selected.value) : this.value;\n this.internals.setFormValue(v, this.value);\n const input = this.input ?? undefined;\n if (this.required && !this.value.trim())\n this.internals.setValidity({ valueMissing: true }, 'Fill in this field.', input);\n else if (this.mustChoose && this.value.trim() && !this.selected)\n this.internals.setValidity({ customError: true }, 'Choose one of the suggestions.', input);\n else this.internals.setValidity({});\n }\n\n /* ---------- data ---------- */\n\n private warnOnce(kind: string, message: string): void {\n if (this.warned.has(kind)) return;\n this.warned.add(kind);\n console.warn(`${this.localName}: ${message}`);\n }\n\n /** Read `<option>`s (direct or in a `<datalist>`) and adopt a fallback `<input>`. */\n private read(nodes: Node[]): void {\n const options: HTMLOptionElement[] = [];\n for (const n of nodes) {\n if (n instanceof HTMLOptionElement) options.push(n);\n else if (n instanceof HTMLDataListElement) options.push(...n.options);\n else if (n instanceof HTMLInputElement) {\n this.adopt(n);\n if (n.list && !nodes.includes(n.list)) options.push(...n.list.options);\n }\n }\n const entries = toEntries(\n options.map((o) => {\n const label = normalize(o.getAttribute('label') ?? o.textContent) || o.value;\n const item: ComboboxItem = { value: o.value || label, label };\n const d = o.getAttribute('data-description');\n if (d) item.description = d;\n if (o.disabled) item.disabled = true;\n return item;\n }),\n );\n const key = (list: Entry[]) =>\n list\n .map((e) => `${e.value}\\u0001${e.label}\\u0001${e.description ?? ''}\\u0001${+e.disabled}`)\n .join('\\u0000');\n if (key(entries) !== key(this.childEntries)) this.childEntries = entries;\n }\n\n /** The no-JavaScript field: its text, name and placeholder carry over, then it is disabled. */\n private adopt(input: HTMLInputElement): void {\n if (this.adopted.has(input)) return;\n this.adopted.add(input);\n if (!this.name && input.name) this.name = input.name;\n if (!this.placeholder && input.placeholder) this.placeholder = input.placeholder;\n if (!this.value && input.value) this.setOwn(input.value, null);\n input.disabled = true;\n }\n\n /** Local suggestions: `items` while set, else the children. */\n private get local(): Entry[] {\n if (this.items) {\n if (this.items !== this.itemsSource) {\n this.itemsSource = this.items;\n this.itemEntries = toEntries(this.items);\n }\n return this.itemEntries!;\n }\n return this.childEntries;\n }\n\n /** The trimmed text, and folded for matching. */\n private get query(): { text: string; folded: string } {\n const text = normalize(this.value);\n return { text, folded: fold(text) };\n }\n\n private get max(): number {\n const m = Math.trunc(Number(this.maxResults));\n return Number.isFinite(m) && m > 0 ? m : Infinity;\n }\n\n /** Prefix matches, then word-start matches, then the rest, each in the given order. */\n private filter(q: string): void {\n const all = this.local;\n const max = this.max;\n if (!q) {\n this.shown = all.slice(0, max);\n this.total = all.length;\n return;\n }\n const buckets: Entry[][] = [[], [], []];\n let total = 0;\n for (const e of all) {\n const i = e.fold.indexOf(q);\n if (i < 0) continue;\n total++;\n const b = i === 0 ? 0 : WORD.test(e.fold[i - 1]!) ? 2 : 1;\n if (buckets[b]!.length < max) buckets[b]!.push(e);\n }\n this.shown = buckets.flat().slice(0, max);\n this.total = total;\n }\n\n private cancelFetch(): void {\n clearTimeout(this.fetchTimer);\n this.fetchTimer = undefined;\n this.abort?.abort();\n this.abort = undefined;\n }\n\n private showRemote(q: string, entries: Entry[]): void {\n this.remote = entries;\n this.remoteQuery = q;\n this.loading = 'idle';\n this.shown = entries.slice(0, this.max);\n this.total = entries.length;\n }\n\n /** `src`: the cached response, or a fetch once typing pauses. */\n private request(q: string): void {\n this.cancelFetch();\n const cached = this.cache.get(q);\n if (cached) {\n this.showRemote(q, cached);\n return;\n }\n this.loading = 'loading';\n this.fetchTimer = setTimeout(() => void this.load(q), comboboxTiming.debounce);\n }\n\n private async load(q: string): Promise<void> {\n const ctrl = new AbortController();\n this.abort = ctrl;\n const url = this.src.replaceAll('{q}', encodeURIComponent(q));\n try {\n const res = await fetch(new URL(url, this.ownerDocument.baseURI), {\n signal: ctrl.signal,\n headers: { Accept: 'application/json' },\n });\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\n const data: unknown = await res.json();\n const list = this.transform ? this.transform(data, q) : data;\n if (!Array.isArray(list)) throw new Error('the response is not an array');\n if (ctrl.signal.aborted) return;\n const entries = toEntries(list);\n this.cache.set(q, entries);\n if (this.cache.size > CACHE_SIZE) this.cache.delete(this.cache.keys().next().value!);\n if (this.query.text !== q) return;\n this.showRemote(q, entries);\n this.active = -1;\n } catch (err) {\n if (ctrl.signal.aborted) return;\n this.loading = 'error';\n this.shown = [];\n this.total = 0;\n this.remoteQuery = undefined;\n this.warnOnce('load', `couldn't load suggestions (${(err as Error).message}).`);\n trackError(this, TAG, 'load');\n } finally {\n if (this.abort === ctrl) this.abort = undefined;\n }\n }\n\n /** Recompute the suggestions for the current text. */\n private refresh(): void {\n const q = this.query;\n if (this.src) {\n if (q.text.length < this.minLength) {\n this.cancelFetch();\n this.loading = 'idle';\n this.shown = [];\n this.total = 0;\n return;\n }\n if (q.text === this.remoteQuery && this.loading !== 'error') {\n this.shown = this.remote.slice(0, this.max);\n this.total = this.remote.length;\n return;\n }\n this.request(q.text);\n return;\n }\n this.filter(q.folded);\n }\n\n /* ---------- state changes ---------- */\n\n private setOwn(value: string, item: ComboboxItem | null): void {\n this.value = this.ownValue = value;\n this.selected = this.ownSelected = item;\n }\n\n private emit(type: string, detail: object): void {\n this.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true }));\n }\n\n /** The suggestion whose label is exactly the text (ignoring case and accents), if one. */\n private exact(): Entry | undefined {\n const q = this.query.folded;\n if (!q) return undefined;\n const pool = this.src ? this.remote : this.local;\n const hits = pool.filter((e) => !e.disabled && e.fold === q);\n return hits.length === 1 ? hits[0] : undefined;\n }\n\n private commit(): void {\n if (!this.selected) {\n const m = this.exact();\n if (m) this.setOwn(m.label, m.raw);\n }\n const { value, selected } = this;\n this.invalidShown = this.mustChoose && !!value.trim() && !selected;\n if (value === this.committed.value && selected === this.committed.item) return;\n this.committed = { value, item: selected };\n this.emit('change', { value, item: selected });\n }\n\n private close(): void {\n this.open = false;\n this.active = -1;\n }\n\n private openList(at: 'none' | 'first' | 'last'): void {\n if (this.src && this.query.text.length < this.minLength) return;\n this.refresh();\n this.open = true;\n this.active =\n at === 'none'\n ? -1\n : this.step(at === 'first' ? -1 : this.shown.length, at === 'first' ? 1 : -1);\n }\n\n /** The next choosable index from `from` in `dir`, wrapping; -1 when there is none. */\n private step(from: number, dir: 1 | -1): number {\n const n = this.shown.length;\n for (let k = 1; k <= n; k++) {\n const i = (((from + dir * k) % n) + n) % n;\n if (!this.shown[i]!.disabled) return i;\n }\n return -1;\n }\n\n private choose(index: number): void {\n const e = this.shown[index];\n if (!e || e.disabled) return;\n this.cancelFetch();\n this.setOwn(e.label, e.raw);\n this.close();\n this.invalidShown = false;\n this.emit('select', { item: e.raw });\n trackEvent(this, [TAG, 'select', this.label.trim(), index + 1]);\n this.commit();\n }\n\n private clear(): void {\n this.cancelFetch();\n this.loading = 'idle';\n this.setOwn('', null);\n this.close();\n trackEvent(this, [TAG, 'clear', this.label.trim()]);\n this.commit();\n this.focus();\n }\n\n /* ---------- handlers ---------- */\n\n private onInput(e: Event): void {\n const text = (e.target as HTMLInputElement).value;\n const keep = this.selected && text === normalize(this.selected.label ?? this.selected.value);\n this.setOwn(text, keep ? this.selected : null);\n this.invalidShown = false;\n this.active = -1;\n if (this.query.text.length < this.minLength) {\n this.cancelFetch();\n this.loading = 'idle';\n this.close();\n return;\n }\n this.refresh();\n this.open = true;\n }\n\n private onKeydown(e: KeyboardEvent): void {\n if (e.isComposing) return;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (e.altKey) {\n if (!this.open) this.openList('none');\n } else if (!this.open) this.openList('first');\n else this.active = this.step(this.active, 1);\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (e.altKey) this.close();\n else if (!this.open) this.openList('last');\n else this.active = this.step(this.active < 0 ? this.shown.length : this.active, -1);\n return;\n case 'Enter':\n if (this.open && this.active >= 0) {\n e.preventDefault();\n this.choose(this.active);\n return;\n }\n this.close();\n this.commit();\n this.updateForm();\n if (!this.lightDom && this.form) {\n // A shadow field is not the form's own: submit as a native field would.\n e.preventDefault();\n this.submit(this.form);\n }\n return;\n case 'Escape':\n if (this.open) {\n e.preventDefault();\n e.stopPropagation();\n this.cancelFetch();\n if (this.loading === 'loading') this.loading = 'idle';\n this.close();\n } else if (this.value) {\n e.preventDefault();\n e.stopPropagation();\n this.clear();\n }\n return;\n case 'Home':\n case 'End':\n case 'ArrowLeft':\n case 'ArrowRight':\n this.active = -1;\n return;\n }\n }\n\n /** Implicit submission: click the default button, or submit when there is none. */\n private submit(form: HTMLFormElement): void {\n const button = [...form.elements].find(\n (el): el is HTMLButtonElement | HTMLInputElement =>\n (el instanceof HTMLButtonElement || el instanceof HTMLInputElement) &&\n (el.type === 'submit' || el.type === 'image'),\n );\n if (button) {\n if (!button.disabled) button.click();\n return;\n }\n form.requestSubmit();\n }\n\n private onBlur(): void {\n this.cancelFetch();\n if (this.loading === 'loading') this.loading = 'idle';\n this.close();\n this.commit();\n }\n\n private onOptionClick(e: MouseEvent): void {\n const li = (e.target as Element).closest<HTMLElement>('[role=\"option\"]');\n if (!li) return;\n this.choose(Number(li.dataset.index));\n }\n\n /* ---------- status ---------- */\n\n /** The visible note in the popup, and what the live region says. */\n private get note(): { visible: string; spoken: string } {\n if (this.loading === 'loading' && !this.shown.length)\n return { visible: 'Loading suggestions…', spoken: 'Loading suggestions' };\n if (this.loading === 'error')\n return { visible: \"Couldn't load suggestions\", spoken: \"Couldn't load suggestions\" };\n const n = this.shown.length;\n if (!n) return { visible: 'No suggestions', spoken: 'No suggestions' };\n if (this.total > n)\n return {\n visible: `Showing ${count(n)} of ${count(this.total)}. Type more to narrow them.`,\n spoken: `${count(n)} of ${count(this.total)} suggestions`,\n };\n return { visible: '', spoken: `${count(n)} suggestion${n === 1 ? '' : 's'}` };\n }\n\n private scheduleAnnouncement(): void {\n clearTimeout(this.announceTimer);\n const text = this.open ? this.note.spoken : '';\n if (!text) {\n this.lastAnnounced = '';\n return;\n }\n if (text === this.lastAnnounced) return;\n this.announceTimer = setTimeout(() => {\n const now = this.open ? this.note.spoken : '';\n if (!now || now === this.lastAnnounced) return;\n this.lastAnnounced = now;\n this.announcement = now;\n clearTimeout(this.clearTimer);\n this.clearTimer = setTimeout(() => (this.announcement = ''), CLEAR_MS);\n }, comboboxTiming.announce);\n }\n\n /* ---------- lifecycle ---------- */\n\n protected override willUpdate(changed: PropertyValues): void {\n if (!this.label.trim()) this.warnOnce('label', 'set label: the field needs a visible label.');\n if (changed.has('selected') && this.selected !== this.ownSelected) {\n // Set by the app: show it.\n const s = this.selected as ComboboxItem | string | null;\n const e = s === null || s === undefined ? null : toEntry(s);\n this.selected = this.ownSelected = e ? e.raw : null;\n if (e) this.value = this.ownValue = e.label;\n this.committed = { value: this.value, item: this.selected };\n } else if (changed.has('value') && this.value !== this.ownValue) {\n this.value = this.ownValue = String(this.value ?? '');\n if (this.selected && this.value !== normalize(this.selected.label ?? this.selected.value))\n this.selected = this.ownSelected = null;\n this.committed = { value: this.value, item: this.selected };\n }\n if (changed.has('src') || changed.has('transform')) {\n this.cache.clear();\n this.remoteQuery = undefined;\n }\n if (\n this.open &&\n (changed.has('items') || changed.has('childEntries') || changed.has('maxResults'))\n )\n this.refresh();\n if (this.open && this.active >= this.shown.length) this.active = -1;\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n // The field may hold typed text the last render did not know about.\n const field = this.input;\n if (field && field.value !== this.value) field.value = this.value;\n if (!this.started) {\n this.started = true;\n this.updateForm();\n return;\n }\n if (\n changed.has('value') ||\n changed.has('selected') ||\n changed.has('required') ||\n changed.has('mustChoose')\n )\n this.updateForm();\n if (\n changed.has('open') ||\n changed.has('shown') ||\n changed.has('total') ||\n changed.has('loading')\n )\n this.scheduleAnnouncement();\n if (changed.has('active') && this.active >= 0) this.reveal();\n }\n\n /** Scroll the active suggestion into view inside the popup (not the page). */\n private reveal(): void {\n const popup = this.renderRoot.querySelector<HTMLElement>('.popup');\n const opt = this.renderRoot.querySelector<HTMLElement>(`#${this.uid}-opt-${this.active}`);\n if (!popup || !opt) return;\n const top = opt.offsetTop;\n const bottom = top + opt.offsetHeight;\n if (top < popup.scrollTop) popup.scrollTop = top;\n else if (bottom > popup.scrollTop + popup.clientHeight)\n popup.scrollTop = bottom - popup.clientHeight;\n }\n\n /* ---------- render ---------- */\n\n private marked(label: string, q: string) {\n if (!q) return label;\n const { text, map } = foldMap(label);\n const parts: unknown[] = [];\n let last = 0;\n let from = 0;\n for (let i = text.indexOf(q); i !== -1; i = text.indexOf(q, from)) {\n const s = map[i]!;\n const end = map[i + q.length]!;\n if (s > last) parts.push(label.slice(last, s));\n parts.push(html`<mark>${label.slice(s, end)}</mark>`);\n last = end;\n from = i + q.length;\n }\n parts.push(label.slice(last));\n return parts;\n }\n\n protected override render() {\n const id = this.uid;\n const label = this.label.trim();\n const off = this.disabled || this.formDisabled;\n const expanded = this.open && this.shown.length > 0;\n const note = this.open ? this.note.visible : '';\n const q = this.query.folded;\n return html`<label class=\"label\" part=\"label\" id=\"${id}-label\" for=\"${id}-input\"\n >${label}</label\n >\n <div class=\"field\">\n <input\n id=\"${id}-input\"\n class=\"input\"\n part=\"input\"\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded=${expanded ? 'true' : 'false'}\n aria-controls=\"${id}-listbox\"\n aria-activedescendant=${expanded && this.active >= 0 ? `${id}-opt-${this.active}` : nothing}\n aria-describedby=${this.description ? `${id}-description` : nothing}\n aria-required=${this.required ? 'true' : nothing}\n aria-invalid=${this.invalidShown ? 'true' : nothing}\n autocomplete=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n placeholder=${this.placeholder || nothing}\n .value=${this.value}\n ?disabled=${off}\n @input=${this.onInput}\n @keydown=${this.onKeydown}\n @blur=${this.onBlur}\n @change=${(e: Event) => e.stopPropagation()}\n @select=${(e: Event) => e.stopPropagation()}\n /><button\n type=\"button\"\n class=\"clear\"\n part=\"clear\"\n aria-label=\"Clear ${label}\"\n ?hidden=${!this.value || off}\n @mousedown=${(e: MouseEvent) => e.preventDefault()}\n @click=${this.clear}\n >\n ${CLEAR_ICON}\n </button>\n <div\n class=\"popup\"\n part=\"popup\"\n ?hidden=${!this.open || (!this.shown.length && !note)}\n @mousedown=${(e: MouseEvent) => e.preventDefault()}\n >\n <ul\n id=\"${id}-listbox\"\n class=\"listbox\"\n role=\"listbox\"\n aria-labelledby=\"${id}-label\"\n tabindex=\"-1\"\n ?hidden=${!expanded}\n @click=${this.onOptionClick}\n >\n ${\n expanded\n ? this.shown.map(\n (e, i) =>\n html`<li\n id=\"${id}-opt-${i}\"\n class=\"option\"\n part=\"option\"\n role=\"option\"\n data-index=${i}\n aria-selected=${i === this.active ? 'true' : 'false'}\n aria-disabled=${e.disabled ? 'true' : nothing}\n >\n <span class=\"option-label\">${this.marked(e.label, q)}</span>${\n e.description\n ? html`<span class=\"option-description\">${e.description}</span>`\n : nothing\n }\n </li>`,\n )\n : nothing\n }\n </ul>\n <p class=\"message\" ?hidden=${!note}>${note}</p>\n </div>\n </div>\n <p class=\"description\" part=\"description\" id=\"${id}-description\" ?hidden=${!this.description}>\n ${this.description}\n </p>\n <span class=\"visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n >${this.announcement}</span\n >`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibCombobox } from './UvalibCombobox.js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,SAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,SAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,WAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,gBAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,gBAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,gBAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,gBAAA,KAAA,CAAA,GChZT3C,EAAO,mBAAmB2C,CAAc"}
|
|
1
|
+
{"version":3,"file":"uvalib-combobox.js","names":["unsafeCSS","nothing","_decorate","property","state","n","w","i","r$1","b","define","__decorate","A","r","installLightDomStyles","UvalibElement","trackEvent","trackError","setState","normalize","SourceChildren","accessible","comboboxTiming","ANCHORING","detectTopLayer","comboboxSupport","TAG","CLEAR_MS","CACHE_SIZE","uid","MARKS","fold","s","foldMap","text","map","ch","label","f","k","WORD","toEntry","raw","e","d","toEntries","list","count","structuralRules","host","shadowStructure","BORDER","ACCENT","MUTED","TEXT","RAISED","CLEAR_ICON","UvalibCombobox","nodes","root","sheet","node","disabled","state","input","options","v","kind","message","entries","o","item","key","m","all","max","q","buckets","total","cached","ctrl","url","res","data","err","value","type","hits","selected","at","from","dir","index","keep","button","form","el","li","now","changed","field","popup","showing","name","isOpen","opt","top","bottom","parts","last","end","id","off","expanded","note"],"sources":["../src/components/uvalib-combobox/UvalibCombobox.ts","../src/components/uvalib-combobox/uvalib-combobox.ts"],"sourcesContent":["import { css, html, nothing, svg, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackError, trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { setState } from '../../base/states.js';\nimport { normalize, SourceChildren } from '../../base/source-children.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/**\n * One suggestion: the value submitted with the form and reported in events, the text shown\n * (default: the value), an optional second line, and whether it can be chosen. Other fields\n * are kept: `select` and `change` hand back the object you gave.\n */\nexport interface ComboboxItem {\n value: string;\n label?: string;\n description?: string;\n disabled?: boolean;\n [key: string]: unknown;\n}\n\n/** Turns a `src` response into suggestions (default: the response is already an array). */\nexport type ComboboxTransform = (data: unknown, query: string) => (ComboboxItem | string)[];\n\n/**\n * `debounce`: milliseconds after the last keystroke before `src` is fetched. `announce`:\n * milliseconds the suggestion count must stay put before it is announced. Tests may shorten them.\n */\nexport const comboboxTiming = { debounce: 250, announce: 500 };\n\n/** The CSS the top-layer popup needs, as one `@supports` condition (also what JS checks). */\nconst ANCHORING =\n '(anchor-name: --a) and (position-try-fallbacks: flip-block) and (inline-size: anchor-size(inline))';\n\n/** Popover API and CSS anchor positioning both supported (not in Firefox today). */\nfunction detectTopLayer(): boolean {\n try {\n return (\n typeof HTMLElement !== 'undefined' &&\n Object.hasOwn(HTMLElement.prototype, 'popover') &&\n typeof CSS !== 'undefined' &&\n CSS.supports(ANCHORING)\n );\n } catch {\n return false;\n }\n}\n\n/**\n * `topLayer`: whether a new element puts its popup in the top layer, anchored to the field\n * (where the browser supports the Popover API and CSS anchor positioning). Read when each\n * element is created; tests may turn it off to check the fallback.\n */\nexport const comboboxSupport = { topLayer: detectTopLayer() };\n\nconst TAG = 'uvalib-combobox';\n/** How long an announcement stays in the live region before it is cleared. */\nconst CLEAR_MS = 5000;\n/** Responses kept per `src`, so Backspace does not fetch again. */\nconst CACHE_SIZE = 30;\nlet uid = 0;\n\n/** A suggestion as shown: its display text, folded for matching, and what was given. */\ninterface Entry {\n value: string;\n label: string;\n description?: string;\n disabled: boolean;\n fold: string;\n /** What events and `selected` hand back: the given object, or `{ value, label }` for a string. */\n raw: ComboboxItem;\n}\n\nconst MARKS = /\\p{M}/gu;\n/** Case- and accent-insensitive form: “Ébène” and “ebene” match. */\nexport const fold = (s: string): string => s.normalize('NFD').replace(MARKS, '').toLowerCase();\n\n/** `label` folded, with the index in `label` that each folded character came from. */\nfunction foldMap(label: string): { text: string; map: number[] } {\n let text = '';\n const map: number[] = [];\n let i = 0;\n for (const ch of label) {\n const f = fold(ch);\n for (let k = 0; k < f.length; k++) map.push(i);\n text += f;\n i += ch.length;\n }\n map.push(i);\n return { text, map };\n}\n\nconst WORD = /[\\p{L}\\p{N}]/u;\n\nfunction toEntry(raw: unknown): Entry | null {\n if (typeof raw === 'string' || typeof raw === 'number') {\n const s = normalize(raw);\n return s\n ? { value: s, label: s, disabled: false, fold: fold(s), raw: { value: s, label: s } }\n : null;\n }\n if (!raw || typeof raw !== 'object') return null;\n const r = raw as ComboboxItem;\n const label = normalize(r.label ?? r.value);\n if (!label) return null;\n const e: Entry = {\n value: String(r.value ?? label),\n label,\n disabled: !!r.disabled,\n fold: fold(label),\n raw: r,\n };\n const d = normalize(r.description);\n if (d) e.description = d;\n return e;\n}\n\nconst toEntries = (list: unknown): Entry[] =>\n Array.isArray(list) ? list.map(toEntry).filter((e): e is Entry => e !== null) : [];\n\nconst count = (n: number) => n.toLocaleString('en-US');\n\n/**\n * Kept with `no-style`: the popup under the field, 44px options and clear button, and the\n * hidden live region. `host` is `:host` or the tag.\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; max-width: 100%; line-height: 1.5; }\n ${host} .label { display: block; margin-block-end: 0.25rem; }\n ${host} .field { position: relative; }\n ${host} .input {\n display: block;\n box-sizing: border-box;\n inline-size: 100%;\n min-block-size: 44px;\n margin: 0;\n padding-inline-end: 44px;\n font: inherit;\n line-height: 1.2;\n }\n ${host} .clear {\n position: absolute;\n inset-block-start: 0;\n inset-inline-end: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n inline-size: 44px;\n block-size: 44px;\n margin: 0;\n padding: 0;\n cursor: pointer;\n }\n ${host} .popup {\n position: absolute;\n inset-inline: 0;\n inset-block-start: calc(100% + 2px);\n z-index: 20;\n box-sizing: border-box;\n max-block-size: min(18rem, 60vh);\n margin: 0;\n overflow-y: auto;\n overscroll-behavior: contain;\n }\n /* Where supported, the popup is a manual popover in the top layer, so no ancestor's\n overflow clips it: anchored under the field, as wide as it, above it when there is no\n room below. Elsewhere it stays absolutely positioned (no popover attribute). */\n @supports ${ANCHORING} {\n ${host} .popup[popover] {\n position: fixed;\n inset: auto;\n inline-size: anchor-size(inline);\n max-inline-size: 100vw;\n margin: 0;\n margin-block-start: 2px;\n position-area: block-end span-inline-end;\n position-try-fallbacks: flip-block;\n }\n }\n ${host} .listbox { margin: 0; padding: 0; list-style: none; }\n ${host} .option {\n display: flex;\n flex-direction: column;\n justify-content: center;\n box-sizing: border-box;\n min-block-size: 44px;\n overflow-wrap: anywhere;\n cursor: pointer;\n }\n ${host} .option[aria-disabled='true'] { cursor: not-allowed; }\n ${host} .message { box-sizing: border-box; min-block-size: 44px; margin: 0; }\n ${host} .description { margin: 0.25rem 0 0; }\n ${host} .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\nconst BORDER = unsafeCSS('var(--uva-color-control-border, var(--uva-grey, #808080))');\nconst ACCENT = unsafeCSS('var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))');\nconst MUTED = unsafeCSS('var(--uva-color-text-muted, var(--uva-grey-A, #4f4f4f))');\nconst TEXT = unsafeCSS('var(--uva-color-input-text, var(--uva-grey-darkest, #2b2b2b))');\nconst RAISED = unsafeCSS('var(--uva-color-surface-raised, #ffffff)');\n\nconst CLEAR_ICON = svg`<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M4 4l8 8M12 4l-8 8\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>`;\n\n/**\n * An editable text field that suggests values as you type, from a local list or a URL: a\n * person, place or subject picker. It follows the WAI-ARIA APG “Editable Combobox With List\n * Autocomplete”: a real `<input role=\"combobox\">` and a `role=\"listbox\"` popup under it.\n *\n * Suggestions come from the `items` property (`{ value, label?, description?, disabled? }`\n * objects, or strings), from `<option>` children (directly or inside a `<datalist>`; the\n * `label` attribute or text is the label, `data-description` the second line), or from `src`,\n * a URL template with `{q}` (fetched 250 ms after the last keystroke once the text has\n * `min-length` characters, default 1; a newer keystroke aborts the older request; the\n * response is a JSON array of the same shape, or anything `transform(data, query)` turns\n * into one). `items` wins over the children while set. Local suggestions match anywhere in\n * the label, ignoring case and accents, those starting with the text first, then those with\n * a word starting with it; at most `max-results` (default 50, 0 for all) are shown, which\n * keeps a list of 16,000 people fast. The matched text is bold and underlined in a `<mark>`.\n *\n * Keys: Down opens the list on the first suggestion and moves (wrapping), Up opens on the\n * last, Alt+Down opens without moving, Alt+Up closes, Enter chooses the active suggestion\n * (and then does not submit the form; with none active, Enter submits as in any field),\n * Escape closes the list and a second Escape clears the field, Home, End, Left and Right move\n * the caret, and Tab leaves without choosing. A real clear button (“Clear <label>”, 44px,\n * shown only with text) empties the field and returns focus to it.\n *\n * Free text is allowed: `value` is whatever is in the field, and `selected` the chosen\n * suggestion (or null); typing after choosing clears it, and leaving the field with text that\n * is exactly one suggestion's label chooses it. `must-choose` makes any other text invalid\n * (“Choose one of the suggestions.”). The element is form-associated: with `name` it submits\n * the chosen suggestion's value, or else the text, and a form reset restores the `value`\n * attribute. `required` and `disabled` (also from a disabled fieldset) work as on an input.\n *\n * A polite status says “5 suggestions”, “50 of 1,234 suggestions”, “No suggestions”,\n * “Loading suggestions” or “Couldn't load suggestions” half a second after the list settles\n * (never on the first render); the popup shows the same notes visibly. A failed load never\n * throws.\n *\n * Where the browser supports the Popover API and CSS anchor positioning, the popup is a manual\n * popover in the top layer, anchored under the field and as wide as it (above it when there is\n * no room below), so an ancestor with `overflow: hidden` or a scrolling panel never clips it.\n * Elsewhere it is positioned under the field inside the element, as before.\n *\n * Pages can style the runtime state with `:state(open)`, `:state(invalid)` and\n * `:state(loading)` (no attributes are added).\n *\n * Before it upgrades, `base.css` shows the label (from the attribute) and holds the field's\n * height. A fallback `<input list>` child works as a plain field meanwhile; on upgrade its\n * text, `name` and `placeholder` carry over, and it is disabled so it does not submit twice.\n *\n * @tagname uvalib-combobox\n * @fires input - The text changed by typing (the native event of the field, composed). Not fired when an option is chosen.\n * @fires select - A suggestion was chosen (click or Enter). `detail` is `{ item }`, the object given. Bubbles and is composed.\n * @fires change - The value was committed: a suggestion chosen, the field cleared, or the field left with changed text. `detail` is `{ value, item }` (`item` is the chosen suggestion or null). Not fired when the app sets `value` or `selected`. Bubbles and is composed.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-combobox', 'select', '<label>', <position from 1>]` when a suggestion is chosen, `['uvalib-combobox', 'clear', '<label>']` when the clear button or Escape empties the field, and `['uvalib-combobox', 'error', 'load']` once when `src` fails. Never the typed text or a suggestion's text or value. Bubbles and is composed.\n * @csspart label - The visible label.\n * @csspart input - The text field.\n * @csspart clear - The clear button.\n * @csspart popup - The popup under the field.\n * @csspart option - Each suggestion.\n * @csspart description - The hint under the field.\n * @cssstate open - The popup is showing (suggestions or a note such as “No suggestions”).\n * @cssstate invalid - The text was shown as invalid (`aria-invalid=\"true\"`: `must-choose` text that is not a suggestion, after leaving the field or pressing Enter).\n * @cssstate loading - Suggestions from `src` are loading.\n * @cssprop --uva-color-surface-raised - Dark-mode role token: field and popup background (else #fff).\n * @cssprop --uva-color-control-border - Dark-mode role token: field and popup border (else `--uva-grey`, #808080).\n * @cssprop --uva-color-input-text - Dark-mode role token: field and suggestion text (else #2b2b2b).\n * @cssprop --uva-color-text-muted - Dark-mode role token: descriptions, notes and the clear icon (else #4f4f4f).\n * @cssprop --uva-color-surface-hover - Dark-mode role token: active suggestion background (else #dadada).\n * @cssprop --uva-color-track - Dark-mode role token: hovered suggestion background (else #f1f1f1).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: the active suggestion's bar and outline (else `--uva-brand-blue`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-shadow - Dark-mode role token: popup shadow.\n */\nexport class UvalibCombobox extends UvalibElement {\n static formAssociated = true;\n static override shadowRootOptions: ShadowRootInit = {\n ...UvalibElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n static styles = [\n accessible,\n shadowStructure,\n css`\n .label {\n font-weight: 600;\n }\n .input {\n padding-block: 0.5rem;\n padding-inline-start: 0.75rem;\n border: 1px solid ${BORDER};\n border-radius: 5px;\n background: ${RAISED};\n color: ${TEXT};\n }\n .input::placeholder {\n color: ${MUTED};\n opacity: 1;\n }\n .input:disabled {\n background: var(--uva-color-track, var(--uva-grey-200, #f1f1f1));\n color: ${MUTED};\n cursor: not-allowed;\n }\n .input[aria-invalid='true'] {\n border-width: 2px;\n }\n .clear {\n border: 0;\n border-radius: 5px;\n background: none;\n color: ${MUTED};\n }\n .clear:hover {\n color: ${TEXT};\n }\n .clear:focus-visible {\n outline-offset: -4px;\n }\n .popup {\n padding-block: 0.25rem;\n padding-inline: 0;\n border: 1px solid ${BORDER};\n border-radius: 5px;\n background: ${RAISED};\n color: ${TEXT};\n box-shadow: 0 4px 12px var(--uva-color-shadow, rgba(0, 0, 0, 0.2));\n }\n .option {\n padding: 0.375rem 0.75rem;\n border-inline-start: 4px solid transparent;\n }\n .option:hover {\n background: var(--uva-color-track, var(--uva-grey-200, #f1f1f1));\n }\n /* The active suggestion: a fill, a bar at the start and an outline, never colour alone. */\n .option[aria-selected='true'] {\n border-inline-start-color: ${ACCENT};\n background: var(--uva-color-surface-hover, var(--uva-grey-100, #dadada));\n outline: 2px solid ${ACCENT};\n outline-offset: -2px;\n }\n .option[aria-disabled='true'] {\n color: ${MUTED};\n font-style: italic;\n }\n .option-description {\n color: ${MUTED};\n font-size: 0.875em;\n }\n mark {\n background: none;\n color: inherit;\n font-weight: 700;\n text-decoration: underline;\n text-underline-offset: 0.15em;\n }\n .message {\n padding: 0.625rem 0.75rem;\n color: ${MUTED};\n }\n .description {\n color: ${MUTED};\n }\n @media (forced-colors: active) {\n .input,\n .popup {\n border-color: CanvasText;\n }\n .clear {\n color: ButtonText;\n }\n .option[aria-selected='true'] {\n forced-color-adjust: none;\n border-inline-start-color: HighlightText;\n background: Highlight;\n color: HighlightText;\n outline-color: HighlightText;\n }\n .option[aria-selected='true'] .option-description {\n color: HighlightText;\n }\n .option[aria-disabled='true'] {\n color: GrayText;\n }\n }\n `,\n ];\n\n /** The field's visible label (required); also the analytics name. */\n @property({ type: String }) label = '';\n\n /** A hint under the field, read with it (aria-describedby). */\n @property({ type: String }) description = '';\n\n @property({ type: String }) placeholder = '';\n\n /** The form field name. */\n @property({ type: String, reflect: true }) name = '';\n\n /**\n * The text in the field. The attribute is the starting text, and what a form reset\n * restores. Setting it does not fire `change`.\n */\n @property({ type: String }) value = '';\n\n /**\n * The chosen suggestion, or null. Set it (an item or a string) to show a choice: the field\n * shows its label. Setting it does not fire `change`.\n */\n @property({ attribute: false }) selected: ComboboxItem | null = null;\n\n /** Suggestions as data: `{ value, label?, description?, disabled? }` or strings. Wins over the children. */\n @property({ attribute: false }) items?: (ComboboxItem | string)[];\n\n /** A URL template with `{q}` (the trimmed text, URL-encoded) that returns suggestions as JSON. */\n @property({ type: String }) src = '';\n\n /** Maps a `src` response to suggestions, e.g. `(data) => data.results`. */\n @property({ attribute: false }) transform?: ComboboxTransform;\n\n /** Characters typed before suggestions appear (and `src` is fetched). */\n @property({ type: Number, attribute: 'min-length' }) minLength = 1;\n\n /** The most suggestions shown at once; 0 for all. */\n @property({ type: Number, attribute: 'max-results' }) maxResults = 50;\n\n /** Text that is not one of the suggestions is invalid. */\n @property({ type: Boolean, attribute: 'must-choose' }) mustChoose = false;\n\n @property({ type: Boolean, reflect: true }) required = false;\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n @state() private open = false;\n @state() private active = -1;\n @state() private shown: Entry[] = [];\n @state() private total = 0;\n @state() private loading: 'idle' | 'loading' | 'error' = 'idle';\n @state() private announcement = '';\n @state() private formDisabled = false;\n @state() private invalidShown = false;\n @state() private childEntries: Entry[] = [];\n\n private internals: ElementInternals;\n private readonly uid = `${TAG}-${++uid}`;\n private warned = new Set<string>();\n /** The last committed state: `change` fires when it differs. */\n private committed: { value: string; item: ComboboxItem | null } = { value: '', item: null };\n /** Values this element set itself (any other change is the app's). */\n private ownValue?: string;\n private ownSelected?: ComboboxItem | null;\n private itemEntries?: Entry[];\n private itemsSource?: unknown;\n private remote: Entry[] = [];\n private remoteQuery?: string;\n private cache = new Map<string, Entry[]>();\n private abort?: AbortController;\n private fetchTimer?: ReturnType<typeof setTimeout>;\n private announceTimer?: ReturnType<typeof setTimeout>;\n private clearTimer?: ReturnType<typeof setTimeout>;\n private lastAnnounced = '';\n private adopted = new WeakSet<HTMLInputElement>();\n private started = false;\n /** The popup is a popover in the top layer, anchored to the field (see `comboboxSupport`). */\n private readonly topLayer = comboboxSupport.topLayer;\n\n constructor() {\n super();\n this.internals = this.attachInternals();\n new SourceChildren(\n this,\n () => this.lightDom,\n (nodes) => this.read(nodes),\n );\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.cancelFetch();\n clearTimeout(this.announceTimer);\n clearTimeout(this.clearTimer);\n this.open = false;\n }\n\n /* ---------- form association ---------- */\n\n get form(): HTMLFormElement | null {\n return this.internals.form;\n }\n get validity(): ValidityState {\n return this.internals.validity;\n }\n get validationMessage(): string {\n return this.internals.validationMessage;\n }\n get willValidate(): boolean {\n return this.internals.willValidate;\n }\n checkValidity(): boolean {\n return this.internals.checkValidity();\n }\n reportValidity(): boolean {\n return this.internals.reportValidity();\n }\n\n formResetCallback(): void {\n this.cancelFetch();\n this.open = false;\n this.active = -1;\n this.invalidShown = false;\n this.setOwn(this.getAttribute('value') ?? '', null);\n this.committed = { value: this.value, item: null };\n }\n\n formDisabledCallback(disabled: boolean): void {\n this.formDisabled = disabled;\n }\n\n formStateRestoreCallback(state: string | File | FormData | null): void {\n if (typeof state === 'string') {\n this.setOwn(state, null);\n this.committed = { value: state, item: null };\n }\n }\n\n private get input(): HTMLInputElement | null {\n return this.renderRoot.querySelector<HTMLInputElement>(`#${this.uid}-input`);\n }\n\n override focus(options?: FocusOptions): void {\n const input = this.input;\n if (input) input.focus(options);\n else super.focus(options);\n }\n\n private updateForm(): void {\n const v = this.selected ? String(this.selected.value) : this.value;\n this.internals.setFormValue(v, this.value);\n const input = this.input ?? undefined;\n if (this.required && !this.value.trim())\n this.internals.setValidity({ valueMissing: true }, 'Fill in this field.', input);\n else if (this.mustChoose && this.value.trim() && !this.selected)\n this.internals.setValidity({ customError: true }, 'Choose one of the suggestions.', input);\n else this.internals.setValidity({});\n }\n\n /* ---------- data ---------- */\n\n private warnOnce(kind: string, message: string): void {\n if (this.warned.has(kind)) return;\n this.warned.add(kind);\n console.warn(`${this.localName}: ${message}`);\n }\n\n /** Read `<option>`s (direct or in a `<datalist>`) and adopt a fallback `<input>`. */\n private read(nodes: Node[]): void {\n const options: HTMLOptionElement[] = [];\n for (const n of nodes) {\n if (n instanceof HTMLOptionElement) options.push(n);\n else if (n instanceof HTMLDataListElement) options.push(...n.options);\n else if (n instanceof HTMLInputElement) {\n this.adopt(n);\n if (n.list && !nodes.includes(n.list)) options.push(...n.list.options);\n }\n }\n const entries = toEntries(\n options.map((o) => {\n const label = normalize(o.getAttribute('label') ?? o.textContent) || o.value;\n const item: ComboboxItem = { value: o.value || label, label };\n const d = o.getAttribute('data-description');\n if (d) item.description = d;\n if (o.disabled) item.disabled = true;\n return item;\n }),\n );\n const key = (list: Entry[]) =>\n list\n .map((e) => `${e.value}\\u0001${e.label}\\u0001${e.description ?? ''}\\u0001${+e.disabled}`)\n .join('\\u0000');\n if (key(entries) !== key(this.childEntries)) this.childEntries = entries;\n }\n\n /** The no-JavaScript field: its text, name and placeholder carry over, then it is disabled. */\n private adopt(input: HTMLInputElement): void {\n if (this.adopted.has(input)) return;\n this.adopted.add(input);\n if (!this.name && input.name) this.name = input.name;\n if (!this.placeholder && input.placeholder) this.placeholder = input.placeholder;\n if (!this.value && input.value) this.setOwn(input.value, null);\n input.disabled = true;\n }\n\n /** Local suggestions: `items` while set, else the children. */\n private get local(): Entry[] {\n if (this.items) {\n if (this.items !== this.itemsSource) {\n this.itemsSource = this.items;\n this.itemEntries = toEntries(this.items);\n }\n return this.itemEntries!;\n }\n return this.childEntries;\n }\n\n /** The trimmed text, and folded for matching. */\n private get query(): { text: string; folded: string } {\n const text = normalize(this.value);\n return { text, folded: fold(text) };\n }\n\n private get max(): number {\n const m = Math.trunc(Number(this.maxResults));\n return Number.isFinite(m) && m > 0 ? m : Infinity;\n }\n\n /** Prefix matches, then word-start matches, then the rest, each in the given order. */\n private filter(q: string): void {\n const all = this.local;\n const max = this.max;\n if (!q) {\n this.shown = all.slice(0, max);\n this.total = all.length;\n return;\n }\n const buckets: Entry[][] = [[], [], []];\n let total = 0;\n for (const e of all) {\n const i = e.fold.indexOf(q);\n if (i < 0) continue;\n total++;\n const b = i === 0 ? 0 : WORD.test(e.fold[i - 1]!) ? 2 : 1;\n if (buckets[b]!.length < max) buckets[b]!.push(e);\n }\n this.shown = buckets.flat().slice(0, max);\n this.total = total;\n }\n\n private cancelFetch(): void {\n clearTimeout(this.fetchTimer);\n this.fetchTimer = undefined;\n this.abort?.abort();\n this.abort = undefined;\n }\n\n private showRemote(q: string, entries: Entry[]): void {\n this.remote = entries;\n this.remoteQuery = q;\n this.loading = 'idle';\n this.shown = entries.slice(0, this.max);\n this.total = entries.length;\n }\n\n /** `src`: the cached response, or a fetch once typing pauses. */\n private request(q: string): void {\n this.cancelFetch();\n const cached = this.cache.get(q);\n if (cached) {\n this.showRemote(q, cached);\n return;\n }\n this.loading = 'loading';\n this.fetchTimer = setTimeout(() => void this.load(q), comboboxTiming.debounce);\n }\n\n private async load(q: string): Promise<void> {\n const ctrl = new AbortController();\n this.abort = ctrl;\n const url = this.src.replaceAll('{q}', encodeURIComponent(q));\n try {\n const res = await fetch(new URL(url, this.ownerDocument.baseURI), {\n signal: ctrl.signal,\n headers: { Accept: 'application/json' },\n });\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\n const data: unknown = await res.json();\n const list = this.transform ? this.transform(data, q) : data;\n if (!Array.isArray(list)) throw new Error('the response is not an array');\n if (ctrl.signal.aborted) return;\n const entries = toEntries(list);\n this.cache.set(q, entries);\n if (this.cache.size > CACHE_SIZE) this.cache.delete(this.cache.keys().next().value!);\n if (this.query.text !== q) return;\n this.showRemote(q, entries);\n this.active = -1;\n } catch (err) {\n if (ctrl.signal.aborted) return;\n this.loading = 'error';\n this.shown = [];\n this.total = 0;\n this.remoteQuery = undefined;\n this.warnOnce('load', `couldn't load suggestions (${(err as Error).message}).`);\n trackError(this, TAG, 'load');\n } finally {\n if (this.abort === ctrl) this.abort = undefined;\n }\n }\n\n /** Recompute the suggestions for the current text. */\n private refresh(): void {\n const q = this.query;\n if (this.src) {\n if (q.text.length < this.minLength) {\n this.cancelFetch();\n this.loading = 'idle';\n this.shown = [];\n this.total = 0;\n return;\n }\n if (q.text === this.remoteQuery && this.loading !== 'error') {\n this.shown = this.remote.slice(0, this.max);\n this.total = this.remote.length;\n return;\n }\n this.request(q.text);\n return;\n }\n this.filter(q.folded);\n }\n\n /* ---------- state changes ---------- */\n\n private setOwn(value: string, item: ComboboxItem | null): void {\n this.value = this.ownValue = value;\n this.selected = this.ownSelected = item;\n }\n\n private emit(type: string, detail: object): void {\n this.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true }));\n }\n\n /** The suggestion whose label is exactly the text (ignoring case and accents), if one. */\n private exact(): Entry | undefined {\n const q = this.query.folded;\n if (!q) return undefined;\n const pool = this.src ? this.remote : this.local;\n const hits = pool.filter((e) => !e.disabled && e.fold === q);\n return hits.length === 1 ? hits[0] : undefined;\n }\n\n private commit(): void {\n if (!this.selected) {\n const m = this.exact();\n if (m) this.setOwn(m.label, m.raw);\n }\n const { value, selected } = this;\n this.invalidShown = this.mustChoose && !!value.trim() && !selected;\n if (value === this.committed.value && selected === this.committed.item) return;\n this.committed = { value, item: selected };\n this.emit('change', { value, item: selected });\n }\n\n private close(): void {\n this.open = false;\n this.active = -1;\n }\n\n private openList(at: 'none' | 'first' | 'last'): void {\n if (this.src && this.query.text.length < this.minLength) return;\n this.refresh();\n this.open = true;\n this.active =\n at === 'none'\n ? -1\n : this.step(at === 'first' ? -1 : this.shown.length, at === 'first' ? 1 : -1);\n }\n\n /** The next choosable index from `from` in `dir`, wrapping; -1 when there is none. */\n private step(from: number, dir: 1 | -1): number {\n const n = this.shown.length;\n for (let k = 1; k <= n; k++) {\n const i = (((from + dir * k) % n) + n) % n;\n if (!this.shown[i]!.disabled) return i;\n }\n return -1;\n }\n\n private choose(index: number): void {\n const e = this.shown[index];\n if (!e || e.disabled) return;\n this.cancelFetch();\n this.setOwn(e.label, e.raw);\n this.close();\n this.invalidShown = false;\n this.emit('select', { item: e.raw });\n trackEvent(this, [TAG, 'select', this.label.trim(), index + 1]);\n this.commit();\n }\n\n private clear(): void {\n this.cancelFetch();\n this.loading = 'idle';\n this.setOwn('', null);\n this.close();\n trackEvent(this, [TAG, 'clear', this.label.trim()]);\n this.commit();\n this.focus();\n }\n\n /* ---------- handlers ---------- */\n\n private onInput(e: Event): void {\n const text = (e.target as HTMLInputElement).value;\n const keep = this.selected && text === normalize(this.selected.label ?? this.selected.value);\n this.setOwn(text, keep ? this.selected : null);\n this.invalidShown = false;\n this.active = -1;\n if (this.query.text.length < this.minLength) {\n this.cancelFetch();\n this.loading = 'idle';\n this.close();\n return;\n }\n this.refresh();\n this.open = true;\n }\n\n private onKeydown(e: KeyboardEvent): void {\n if (e.isComposing) return;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (e.altKey) {\n if (!this.open) this.openList('none');\n } else if (!this.open) this.openList('first');\n else this.active = this.step(this.active, 1);\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (e.altKey) this.close();\n else if (!this.open) this.openList('last');\n else this.active = this.step(this.active < 0 ? this.shown.length : this.active, -1);\n return;\n case 'Enter':\n if (this.open && this.active >= 0) {\n e.preventDefault();\n this.choose(this.active);\n return;\n }\n this.close();\n this.commit();\n this.updateForm();\n if (!this.lightDom && this.form) {\n // A shadow field is not the form's own: submit as a native field would.\n e.preventDefault();\n this.submit(this.form);\n }\n return;\n case 'Escape':\n if (this.open) {\n e.preventDefault();\n e.stopPropagation();\n this.cancelFetch();\n if (this.loading === 'loading') this.loading = 'idle';\n this.close();\n } else if (this.value) {\n e.preventDefault();\n e.stopPropagation();\n this.clear();\n }\n return;\n case 'Home':\n case 'End':\n case 'ArrowLeft':\n case 'ArrowRight':\n this.active = -1;\n return;\n }\n }\n\n /** Implicit submission: click the default button, or submit when there is none. */\n private submit(form: HTMLFormElement): void {\n const button = [...form.elements].find(\n (el): el is HTMLButtonElement | HTMLInputElement =>\n (el instanceof HTMLButtonElement || el instanceof HTMLInputElement) &&\n (el.type === 'submit' || el.type === 'image'),\n );\n if (button) {\n if (!button.disabled) button.click();\n return;\n }\n form.requestSubmit();\n }\n\n private onBlur(): void {\n this.cancelFetch();\n if (this.loading === 'loading') this.loading = 'idle';\n this.close();\n this.commit();\n }\n\n private onOptionClick(e: MouseEvent): void {\n const li = (e.target as Element).closest<HTMLElement>('[role=\"option\"]');\n if (!li) return;\n this.choose(Number(li.dataset.index));\n }\n\n /* ---------- status ---------- */\n\n /** The visible note in the popup, and what the live region says. */\n private get note(): { visible: string; spoken: string } {\n if (this.loading === 'loading' && !this.shown.length)\n return { visible: 'Loading suggestions…', spoken: 'Loading suggestions' };\n if (this.loading === 'error')\n return { visible: \"Couldn't load suggestions\", spoken: \"Couldn't load suggestions\" };\n const n = this.shown.length;\n if (!n) return { visible: 'No suggestions', spoken: 'No suggestions' };\n if (this.total > n)\n return {\n visible: `Showing ${count(n)} of ${count(this.total)}. Type more to narrow them.`,\n spoken: `${count(n)} of ${count(this.total)} suggestions`,\n };\n return { visible: '', spoken: `${count(n)} suggestion${n === 1 ? '' : 's'}` };\n }\n\n private scheduleAnnouncement(): void {\n clearTimeout(this.announceTimer);\n const text = this.open ? this.note.spoken : '';\n if (!text) {\n this.lastAnnounced = '';\n return;\n }\n if (text === this.lastAnnounced) return;\n this.announceTimer = setTimeout(() => {\n const now = this.open ? this.note.spoken : '';\n if (!now || now === this.lastAnnounced) return;\n this.lastAnnounced = now;\n this.announcement = now;\n clearTimeout(this.clearTimer);\n this.clearTimer = setTimeout(() => (this.announcement = ''), CLEAR_MS);\n }, comboboxTiming.announce);\n }\n\n /* ---------- lifecycle ---------- */\n\n protected override willUpdate(changed: PropertyValues): void {\n if (!this.label.trim()) this.warnOnce('label', 'set label: the field needs a visible label.');\n if (changed.has('selected') && this.selected !== this.ownSelected) {\n // Set by the app: show it.\n const s = this.selected as ComboboxItem | string | null;\n const e = s === null || s === undefined ? null : toEntry(s);\n this.selected = this.ownSelected = e ? e.raw : null;\n if (e) this.value = this.ownValue = e.label;\n this.committed = { value: this.value, item: this.selected };\n } else if (changed.has('value') && this.value !== this.ownValue) {\n this.value = this.ownValue = String(this.value ?? '');\n if (this.selected && this.value !== normalize(this.selected.label ?? this.selected.value))\n this.selected = this.ownSelected = null;\n this.committed = { value: this.value, item: this.selected };\n }\n if (changed.has('src') || changed.has('transform')) {\n this.cache.clear();\n this.remoteQuery = undefined;\n }\n if (\n this.open &&\n (changed.has('items') || changed.has('childEntries') || changed.has('maxResults'))\n )\n this.refresh();\n if (this.open && this.active >= this.shown.length) this.active = -1;\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n // The field may hold typed text the last render did not know about.\n const field = this.input;\n if (field && field.value !== this.value) field.value = this.value;\n if (!this.started) {\n this.started = true;\n this.updateForm();\n return;\n }\n if (\n changed.has('value') ||\n changed.has('selected') ||\n changed.has('required') ||\n changed.has('mustChoose')\n )\n this.updateForm();\n if (\n changed.has('open') ||\n changed.has('shown') ||\n changed.has('total') ||\n changed.has('loading')\n )\n this.scheduleAnnouncement();\n this.syncPopup();\n if (changed.has('active') && this.active >= 0) this.reveal();\n }\n\n private get popup(): HTMLElement | null {\n return this.renderRoot.querySelector<HTMLElement>('.popup');\n }\n\n /**\n * Custom states, and in the top layer: show or hide the popover with the popup, and name\n * the field as its anchor (an instance-unique name, so light-DOM comboboxes never share one).\n */\n private syncPopup(): void {\n const popup = this.popup;\n const showing = !!popup && !popup.hidden;\n setState(this.internals, 'open', showing);\n setState(this.internals, 'invalid', this.invalidShown);\n setState(this.internals, 'loading', this.loading === 'loading');\n if (!this.topLayer || !popup) return;\n const name = `--${this.uid}`;\n const field = this.input;\n if (field && field.style.getPropertyValue('anchor-name') !== name) {\n field.style.setProperty('anchor-name', name);\n popup.style.setProperty('position-anchor', name);\n }\n const isOpen = popup.matches(':popover-open');\n try {\n if (showing && !isOpen && this.isConnected) popup.showPopover();\n else if (!showing && isOpen) popup.hidePopover();\n } catch {\n // Not connected, or mid-transition: the next update tries again.\n }\n }\n\n /** Scroll the active suggestion into view inside the popup (not the page). */\n private reveal(): void {\n const popup = this.popup;\n const opt = this.renderRoot.querySelector<HTMLElement>(`#${this.uid}-opt-${this.active}`);\n if (!popup || !opt) return;\n const top = opt.offsetTop;\n const bottom = top + opt.offsetHeight;\n if (top < popup.scrollTop) popup.scrollTop = top;\n else if (bottom > popup.scrollTop + popup.clientHeight)\n popup.scrollTop = bottom - popup.clientHeight;\n }\n\n /* ---------- render ---------- */\n\n private marked(label: string, q: string) {\n if (!q) return label;\n const { text, map } = foldMap(label);\n const parts: unknown[] = [];\n let last = 0;\n let from = 0;\n for (let i = text.indexOf(q); i !== -1; i = text.indexOf(q, from)) {\n const s = map[i]!;\n const end = map[i + q.length]!;\n if (s > last) parts.push(label.slice(last, s));\n parts.push(html`<mark>${label.slice(s, end)}</mark>`);\n last = end;\n from = i + q.length;\n }\n parts.push(label.slice(last));\n return parts;\n }\n\n protected override render() {\n const id = this.uid;\n const label = this.label.trim();\n const off = this.disabled || this.formDisabled;\n const expanded = this.open && this.shown.length > 0;\n const note = this.open ? this.note.visible : '';\n const q = this.query.folded;\n return html`<label class=\"label\" part=\"label\" id=\"${id}-label\" for=\"${id}-input\"\n >${label}</label\n >\n <div class=\"field\">\n <input\n id=\"${id}-input\"\n class=\"input\"\n part=\"input\"\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded=${expanded ? 'true' : 'false'}\n aria-controls=\"${id}-listbox\"\n aria-activedescendant=${expanded && this.active >= 0 ? `${id}-opt-${this.active}` : nothing}\n aria-describedby=${this.description ? `${id}-description` : nothing}\n aria-required=${this.required ? 'true' : nothing}\n aria-invalid=${this.invalidShown ? 'true' : nothing}\n autocomplete=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n placeholder=${this.placeholder || nothing}\n .value=${this.value}\n ?disabled=${off}\n @input=${this.onInput}\n @keydown=${this.onKeydown}\n @blur=${this.onBlur}\n @change=${(e: Event) => e.stopPropagation()}\n @select=${(e: Event) => e.stopPropagation()}\n /><button\n type=\"button\"\n class=\"clear\"\n part=\"clear\"\n aria-label=\"Clear ${label}\"\n ?hidden=${!this.value || off}\n @mousedown=${(e: MouseEvent) => e.preventDefault()}\n @click=${this.clear}\n >\n ${CLEAR_ICON}\n </button>\n <div\n class=\"popup\"\n part=\"popup\"\n popover=${this.topLayer ? 'manual' : nothing}\n ?hidden=${!this.open || (!this.shown.length && !note)}\n @mousedown=${(e: MouseEvent) => e.preventDefault()}\n >\n <ul\n id=\"${id}-listbox\"\n class=\"listbox\"\n role=\"listbox\"\n aria-labelledby=\"${id}-label\"\n tabindex=\"-1\"\n ?hidden=${!expanded}\n @click=${this.onOptionClick}\n >\n ${\n expanded\n ? this.shown.map(\n (e, i) =>\n html`<li\n id=\"${id}-opt-${i}\"\n class=\"option\"\n part=\"option\"\n role=\"option\"\n data-index=${i}\n aria-selected=${i === this.active ? 'true' : 'false'}\n aria-disabled=${e.disabled ? 'true' : nothing}\n >\n <span class=\"option-label\">${this.marked(e.label, q)}</span>${\n e.description\n ? html`<span class=\"option-description\">${e.description}</span>`\n : nothing\n }\n </li>`,\n )\n : nothing\n }\n </ul>\n <p class=\"message\" ?hidden=${!note}>${note}</p>\n </div>\n </div>\n <p class=\"description\" part=\"description\" id=\"${id}-description\" ?hidden=${!this.description}>\n ${this.description}\n </p>\n <span class=\"visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n >${this.announcement}</span\n >`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibCombobox } from './UvalibCombobox.js';\n\ndefine('uvalib-combobox', UvalibCombobox);\n"],"mappings":";;;;;;AA6BA,IAAasB,IAAiB;CAAE,UAAU;CAAK,UAAU;AAAI,GAGvDC,IACJ;AAGF,SAASC,IAA0B;CACjC,IAAI;EACF,OACE,OAAO,cAAgB,OACvB,OAAO,OAAO,YAAY,WAAW,SAAS,KAC9C,OAAO,MAAQ,OACf,IAAI,SAASD,CAAS;CAE1B,QAAQ;EACN,OAAO;CACT;AACF;AAOA,IAAaE,IAAkB,EAAE,UAAUD,EAAe,EAAE,GAEtDE,IAAM,mBAENC,IAAW,KAEXC,I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|
|
51
|
+
/* Balanced, but not when narrow: the headline is then a bordered button, and balanced
|
|
52
|
+
lines would leave empty space inside its box. */
|
|
53
|
+
:host(:not([data-narrow])) .headline {
|
|
54
|
+
text-wrap: balance;
|
|
55
|
+
}
|
|
51
56
|
.panel {
|
|
52
57
|
max-height: var(--uvalib-contents-max-height, none);
|
|
53
58
|
overflow-y: auto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uvalib-contents.js","names":["unsafeCSS","nothing","unsafeStatic","_decorate","property","state","n","i","r$1","define","__decorate","A","r","installLightDomStyles","UvalibElement","u","s","trackEvent","langDir","inlineCopy","normalize","safeHref","SourceChildren","accessible","markOf","v","entriesKey","items","k","DEFAULT_LABEL","DEFAULT_COLLAPSE","DEFAULT_LEVEL","DEFAULT_LEVELS","DEFAULT_MIN","uid","HEADINGS","slugify","text","headingText","walk","h","structuralRules","host","shadowStructure","pageKey","queryKey","q","UvalibContents","nodes","root","sheet","node","win","on","nav","targets","type","below","kind","message","sel","scope","finder","m","a","b","lo","hi","selector","top","open","added","label","base","id","level","entry","min","hash","list","ordered","out","li","sub","c","x","children","mark","own","item","copy","clean","e","rest","flat","l","entries","found","marked","here","target","resolve","key","query","same","page","section","go","changed","panel","links","p","current","collapsed","headline"],"sources":["../src/components/uvalib-contents/UvalibContents.ts","../src/components/uvalib-contents/uvalib-contents.ts"],"sourcesContent":["import { css, nothing, unsafeCSS, type PropertyValues, type TemplateResult } from 'lit';\nimport { html, unsafeStatic } from 'lit/static-html.js';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { inlineCopy, langDir } from '../../base/inline-copy.js';\nimport { normalize, safeHref, SourceChildren } from '../../base/source-children.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** One entry of the contents: its text, a link (optional for a group label) and sub-entries. */\nexport interface ContentsItem {\n label: string;\n href?: string;\n children?: ContentsItem[];\n}\n\n/**\n * An entry as drawn: `mark` is a valid `aria-current` the author gave its source link;\n * `lang`/`dir` come from the link and `itemLang`/`itemDir` from the `<li>`. `nodes` is a safe inline copy of the label (`em`, `cite`, `code`, `abbr`…),\n * cloned for each render; `rich` describes it, so two reads can be compared.\n */\ninterface Entry {\n label: string;\n href?: string;\n children: Entry[];\n mark?: Current;\n lang?: string;\n dir?: string;\n itemLang?: string;\n itemDir?: string;\n rich?: string;\n nodes?: Node[];\n}\n\n/** An `aria-current` value an author may give: `page`, `location`, or `true` (a page). */\nconst markOf = (v: string | null | undefined): Current | undefined => {\n const t = v?.trim().toLowerCase();\n return t === 'page' || t === 'true' ? 'page' : t === 'location' ? 'location' : undefined;\n};\n\n/** Compare two reads, leaving out the copied nodes (their `rich` key stands for them). */\nconst entriesKey = (items: Entry[]) =>\n JSON.stringify(items, (k, v: unknown) => (k === 'nodes' ? undefined : v));\n\ntype Current = 'page' | 'location';\n\nconst DEFAULT_LABEL = 'Contents';\nconst DEFAULT_COLLAPSE = '64rem';\nconst DEFAULT_LEVEL = 2;\nconst DEFAULT_LEVELS = '2-3';\nconst DEFAULT_MIN = 2;\nlet uid = 0;\n\n/** What is watched in the `headings-from` element: headings added, removed or retitled. */\nconst HEADINGS: MutationObserverInit = { childList: true, characterData: true, subtree: true };\n\n/**\n * An id from a heading's text: lowercase ASCII (accents dropped), runs of anything else as\n * one `-`, none at either end; `section` when nothing is left.\n */\nconst slugify = (text: string): string =>\n text\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '') || 'section';\n\n/** A heading's text, leaving out what is hidden from assistive technology (a `#` permalink). */\nconst headingText = (h: Element): string => {\n let text = '';\n const walk = (n: Node) => {\n if (n instanceof Element && n.getAttribute('aria-hidden') === 'true') return;\n if (n.nodeType === Node.TEXT_NODE) text += n.textContent;\n else n.childNodes.forEach(walk);\n };\n walk(h);\n return normalize(text);\n};\n\n/**\n * The rules kept with `no-style`: unmarked lists, the disclosure's closed panel hidden, and\n * `[hidden]` hides. `host` is `:host` (shadow) or the tag name (light DOM, so they stay scoped).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} :is(ol, ul) { list-style: none; margin: 0; padding: 0; }\n ${host} li :is(ol, ul) { padding-inline-start: 1rem; }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/** A comparable form of a URL: origin and path, without a trailing slash or index.html. */\nconst pageKey = (u: URL) =>\n u.origin + (u.pathname.replace(/\\/index\\.html?$/i, '/').replace(/(.)\\/$/, '$1') || '/');\n\n/** The query string as a sorted, comparable form (`?b=2&a=1` is `?a=1&b=2`). */\nconst queryKey = (u: URL) => {\n const q = new URLSearchParams(u.search);\n q.sort();\n return q.toString();\n};\n\n/**\n * Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation: a\n * `<nav>` landmark (named by `label`, \"Contents\" by default) with the label as a visible\n * headline, and a nested list of links with dividers between the top-level entries and a bar\n * beside each nested level.\n *\n * Give the list as a child: an `<ol>` or `<ul>` of `<li>` elements, each with an `<a href>`\n * (or plain text for a group label) and, for sub-entries, a nested `<ol>`/`<ul>`, to any\n * depth. Other children (a heading) are ignored. The list follows changes to the children.\n * Apps set the `items` property instead (`{ label, href?, children? }`, winning over the\n * children while set).\n *\n * The current entry gets `aria-current`: `page` for the link to this page, `location` for the\n * link to the section of it in the URL's hash. It is found from the page URL (path, and hash\n * for in-page sections), followed through same-document navigations (`hashchange`,\n * `popstate` and the Navigation API), or from the `current` attribute (a URL, resolved like\n * the links). An entry whose href has a query string matches only that query (`?part=2`); one\n * without matches the page whatever its query. Hash-only hrefs are places on that page. With\n * `current` unset, a valid `aria-current` on a source link (`page`, `location` or `true`) is\n * used instead, the first of each kind. `lang` and `dir` on the source links and items, and\n * inline markup in their text (`em`, `cite`, `code`, `abbr`…, copied element by element,\n * never as HTML), are kept.\n *\n * On narrow screens the list collapses into a disclosure: the headline becomes a button with\n * `aria-expanded`, and the list starts closed (as the Electronic Text Collections' Contents\n * does on phones, so the text comes first) until the reader opens it, or while the `open`\n * attribute is set; opening it shows the current entry. Narrow means the viewport\n * (`collapse-below`, 64rem by default), not the element's own width: a contents sidebar is\n * always far narrower than 64rem, so a container query could not tell a phone from a\n * desktop. `sticky` keeps it in view in a sidebar on wide\n * screens; a list longer than the window then scrolls, and the current entry is scrolled\n * into view inside it (never the page).\n *\n * A table of contents for a long document: `headings-from=\"#article\"` builds the list from the\n * headings in that element (`levels`, `2-3` by default; nothing shown below `min` top-level\n * entries, 2 by default). Headings without text or hidden with `aria-hidden` are skipped;\n * one without an id gets one from its text (`budget-report`, then `budget-report-2`), and\n * existing ids are kept, so links to sections keep working. It follows headings added,\n * removed or retitled; `refresh()` reads them again after other changes. The children and\n * `items` win while they give a list. Without JavaScript there is no list: a list rendered\n * at build time, as children, works everywhere.\n *\n * Single-page apps: the list is drawn from copies of the children, so a router's own click\n * handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in\n * place; hash links need nothing.\n *\n * @tagname uvalib-contents\n * @fires uvalib-analytics-event - For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), and opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' | 'close']`; never the label or URL. Bubbles and is composed.\n * @fires uvalib-contents-navigate - A plain click on an entry: `detail` is `{ href, level }` (href as written). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed.\n * @cssprop [--uvalib-contents-sticky-top=1rem] - With `sticky`: the gap kept above it.\n * @cssprop [--uvalib-contents-max-height=none] - The list's maximum height on wide screens (it scrolls beyond it); with `sticky`, the window's height less twice the sticky gap.\n * @cssprop [--uva-blue-alt-dark=#005679] - Link colour.\n * @cssprop [--uva-brand-blue=#232d4b] - The current entry's bar.\n * @cssprop [--uva-brand-orange=#e57200] - The nested levels' bar.\n * @cssprop [--uva-grey-darkest=#2b2b2b] - Text and current entry colour.\n * @cssprop --uva-color-utility-link - Dark-mode role token: link colour (else `--uva-blue-alt-dark`).\n * @cssprop --uva-color-text - Dark-mode role token: text and current entry (else `--uva-grey-darkest`).\n * @cssprop --uva-color-link - Dark-mode role token: the current entry's bar and the button's text (else `--uva-brand-blue`).\n * @cssprop --uva-color-current - Dark-mode role token: the nested levels' bar (else `--uva-brand-orange`).\n * @cssprop --uva-color-border - Dark-mode role token: dividers (else #dadada).\n * @cssprop --uva-color-control-border - Dark-mode role token: the button's border (else #808080).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: the button's background (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibContents extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n font-size: 1rem;\n line-height: 1.5;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n overflow-wrap: anywhere;\n }\n :host([sticky]:not([data-narrow])) {\n position: sticky;\n top: var(--uvalib-contents-sticky-top, 1rem);\n align-self: start;\n }\n .headline {\n margin: 0 0 0.5rem;\n font-size: 1.125rem;\n font-weight: 700;\n line-height: 1.3;\n }\n .panel {\n max-height: var(--uvalib-contents-max-height, none);\n overflow-y: auto;\n overscroll-behavior: contain;\n }\n :host([sticky]:not([data-narrow])) .panel {\n max-height: var(\n --uvalib-contents-max-height,\n calc(100dvh - 2 * var(--uvalib-contents-sticky-top, 1rem) - 3rem)\n );\n }\n :host([data-narrow]) .panel {\n max-height: none;\n overflow: visible;\n }\n .panel > :is(ol, ul) {\n border-block: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n }\n .panel > :is(ol, ul) > li + li {\n border-top: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n }\n li :is(ol, ul) {\n margin: 0 0 0.5rem 0.75rem;\n padding: 0;\n border-inline-start: 2px solid var(--uva-color-current, var(--uva-brand-orange, #e57200));\n }\n a,\n .group {\n display: block;\n padding: 0.5rem 0.75rem 0.5rem calc(0.75rem + 4px);\n }\n li li > :is(a, .group) {\n padding-block: 0.25rem;\n }\n .group {\n font-weight: 700;\n }\n a {\n color: var(--uva-color-utility-link, var(--uva-blue-alt-dark, #005679));\n text-decoration: none;\n }\n a:hover {\n text-decoration: underline;\n }\n a[aria-current] {\n padding-inline-start: 0.75rem;\n border-inline-start: 4px solid var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n color: inherit;\n font-weight: 700;\n }\n .panel a:focus-visible {\n outline-offset: -3px;\n }\n .toggle {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.75rem;\n box-sizing: border-box;\n width: 100%;\n min-height: 44px;\n margin: 0;\n padding: 0.5rem 0.75rem;\n border: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));\n border-radius: 0.3rem;\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n font-weight: 700;\n text-align: start;\n cursor: pointer;\n }\n .toggle::after {\n content: '';\n flex: none;\n width: 0.5em;\n height: 0.5em;\n margin-block-end: 0.25em;\n border-inline-end: 2px solid currentColor;\n border-block-end: 2px solid currentColor;\n transform: rotate(45deg);\n }\n .toggle[aria-expanded='true']::after {\n margin-block: 0.25em 0;\n transform: rotate(225deg);\n }\n :host([data-narrow]) .headline {\n margin-bottom: 0;\n }\n :host([data-narrow]) .panel {\n margin-top: 0.5rem;\n }\n `,\n ];\n\n /** Accessible name of the navigation landmark, and its visible headline. */\n @property({ type: String }) label = DEFAULT_LABEL;\n\n /** The headline's level (2 to 6), for the page's outline. */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel = DEFAULT_LEVEL;\n\n /**\n * The URL of the current entry (resolved like the links), for apps whose route is not the\n * page URL. Unset: the page URL, followed through same-document navigations.\n */\n @property({ type: String }) current?: string;\n\n /**\n * The viewport width at and below which the list collapses into a disclosure: a CSS length\n * (`64rem`, `800px`). `0` or `none` never collapses.\n */\n @property({ type: String, attribute: 'collapse-below' }) collapseBelow = DEFAULT_COLLAPSE;\n\n /** Whether the collapsed disclosure is open (no effect on wide screens). Toggled by its button. */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** Keep it in view while the page scrolls (a sidebar), on wide screens. */\n @property({ type: Boolean, reflect: true }) sticky = false;\n\n /**\n * The entries as data, for apps that build them in JavaScript: `{ label, href?, children? }`.\n * Wins over the children while set; `undefined` goes back to them. Entries without a label\n * are skipped (with their children) with one console warning.\n */\n @property({ attribute: false }) items?: ContentsItem[];\n\n /**\n * Build the list from the headings in the element this selector names (`#article`): each\n * heading at `levels` gets an entry linking to it (an id is added when it has none), the\n * lower levels nested under the heading before them. The children and `items` win while\n * they give a list.\n */\n @property({ type: String, attribute: 'headings-from' }) headingsFrom?: string;\n\n /** With `headings-from`: the heading levels to list, `2-3` (the default) or one level, `2`. */\n @property({ type: String }) levels = DEFAULT_LEVELS;\n\n /**\n * With `headings-from`: the fewest top-level entries worth a list (default 2). With fewer,\n * nothing is shown.\n */\n @property({ type: Number }) min = DEFAULT_MIN;\n\n /** The entries built from the headings (`headings-from`). */\n @state() private headingItems: Entry[] = [];\n private headingsObserver?: MutationObserver;\n private headingsScope?: Element | null;\n private headingsQueued = false;\n private scrolledToHash = false;\n\n /** The entries read from the children. */\n @state() private childItems: Entry[] = [];\n /** The root list's element in the source (`ol` or `ul`). */\n @state() private ordered = false;\n @state() private narrow = false;\n /** The page URL, updated on same-document navigations. */\n @state() private here = '';\n\n private warned = new Set<string>();\n private readonly panelId = `uvalib-contents-${++uid}`;\n private mql?: MediaQueryList;\n /** What was last scrolled into view, so the list is not scrolled again on every update. */\n private scrolledTo?: string;\n\n constructor() {\n super();\n new SourceChildren(\n this,\n () => this.lightDom,\n (nodes) => this.read(nodes),\n );\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n this.here = this.ownerDocument.defaultView?.location.href ?? '';\n this.listenLocation(true);\n this.watchWidth();\n // Reconnected: the headings may have changed meanwhile (the first time, willUpdate reads).\n if (this.hasUpdated) this.refresh();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.headingsObserver?.disconnect();\n this.headingsScope = undefined;\n this.listenLocation(false);\n this.mql?.removeEventListener('change', this.onWidth);\n this.mql = undefined;\n }\n\n private onLocation = (): void => {\n this.here = this.ownerDocument.defaultView?.location.href ?? '';\n };\n\n private listening = false;\n private listenLocation(on: boolean): void {\n const win = this.ownerDocument.defaultView;\n if (!win || on === this.listening) return;\n this.listening = on;\n const nav = (win as Window & { navigation?: EventTarget }).navigation;\n const targets: [EventTarget, string][] = [\n [win, 'popstate'],\n [win, 'hashchange'],\n ...(nav ? [[nav, 'currententrychange'] as [EventTarget, string]] : []),\n ];\n for (const [t, type] of targets) {\n if (on) t.addEventListener(type, this.onLocation);\n else t.removeEventListener(type, this.onLocation);\n }\n }\n\n private onWidth = (): void => {\n this.narrow = !!this.mql?.matches;\n };\n\n /** Follow the viewport against `collapse-below`. */\n private watchWidth(): void {\n this.mql?.removeEventListener('change', this.onWidth);\n const win = this.ownerDocument.defaultView;\n const below = normalize(this.collapseBelow) || DEFAULT_COLLAPSE;\n this.mql =\n win && !/^(none|0+(\\.0*)?[a-z%]*)$/i.test(below)\n ? win.matchMedia(`(max-width: ${below})`)\n : undefined;\n if (this.mql?.media === 'not all') {\n this.warnOnce('collapse', `ignoring collapse-below=\"${below}\" (not a CSS length).`);\n this.mql = win?.matchMedia(`(max-width: ${DEFAULT_COLLAPSE})`);\n }\n this.mql?.addEventListener('change', this.onWidth);\n this.onWidth();\n }\n\n private warnOnce(kind: string, message: string): void {\n if (this.warned.has(kind)) return;\n this.warned.add(kind);\n console.warn(`${this.localName}: ${message}`);\n }\n\n /**\n * With `headings-from`: read the headings again, adding ids to new ones. Headings added,\n * removed or retitled are followed by themselves; call this after other changes (an\n * `aria-hidden` set or a heading's level changed).\n */\n refresh(): void {\n const sel = normalize(this.headingsFrom);\n let scope: Element | null = null;\n if (sel) {\n const root = this.getRootNode();\n const finder =\n root instanceof Document || root instanceof ShadowRoot ? root : this.ownerDocument;\n try {\n scope = finder.querySelector(sel);\n } catch {\n scope = null;\n }\n if (!scope && this.ownerDocument.readyState === 'loading') {\n // Still parsing: try again once the document is read.\n this.ownerDocument.addEventListener('DOMContentLoaded', () => this.refresh(), {\n once: true,\n });\n } else if (!scope) {\n this.warnOnce('headings-from', `no element matches headings-from=\"${sel}\".`);\n }\n }\n if (scope !== this.headingsScope) {\n this.headingsScope = scope;\n this.headingsObserver?.disconnect();\n if (scope) {\n this.headingsObserver ??= new MutationObserver(() => this.queueHeadings());\n this.headingsObserver.observe(scope, HEADINGS);\n }\n }\n const items = scope ? this.fromHeadings(scope) : [];\n if (entriesKey(items) !== entriesKey(this.headingItems)) this.headingItems = items;\n }\n\n /** Several changes at once read the headings once. */\n private queueHeadings(): void {\n if (this.headingsQueued) return;\n this.headingsQueued = true;\n queueMicrotask(() => {\n this.headingsQueued = false;\n if (this.isConnected) this.refresh();\n });\n }\n\n /** The heading levels to list, from `levels`. */\n private get headingRange(): [number, number] {\n const m = /^\\s*([1-6])\\s*(?:-\\s*([1-6]))?\\s*$/.exec(String(this.levels ?? ''));\n if (!m) {\n this.warnOnce(\n 'levels',\n `ignoring levels=\"${this.levels}\" (use a level, 2, or a range, 2-3).`,\n );\n return [2, 3];\n }\n const a = Number(m[1]);\n const b = m[2] ? Number(m[2]) : a;\n return [Math.min(a, b), Math.max(a, b)];\n }\n\n /**\n * The entries for the headings in `scope`, in document order: empty and `aria-hidden` ones\n * and those inside this element skipped; an id added to each without one (a slug of its\n * text, unique with `-2`, `-3`…); each nested under the previous higher-level heading.\n * Fewer than `min` top-level entries: none.\n */\n private fromHeadings(scope: Element): Entry[] {\n const [lo, hi] = this.headingRange;\n const selector = Array.from({ length: hi - lo + 1 }, (_, i) => `h${lo + i}`).join(', ');\n const root = scope.getRootNode() as Document | ShadowRoot;\n const top: Entry[] = [];\n const open: { level: number; entry: Entry }[] = [];\n const added: Element[] = [];\n for (const h of scope.querySelectorAll(selector)) {\n if (this.contains(h) || h.closest('[aria-hidden=\"true\"]')) continue;\n const label = headingText(h);\n if (!label) continue;\n if (!h.id) {\n const base = slugify(label);\n let id = base;\n for (let n = 2; root.getElementById(id); n++) id = `${base}-${n}`;\n h.id = id;\n added.push(h);\n }\n const level = Number(h.localName.slice(1));\n const entry: Entry = { label, href: `#${h.id}`, children: [] };\n while (open.length && open[open.length - 1]!.level >= level) open.pop();\n (open.length ? open[open.length - 1]!.entry.children : top).push(entry);\n open.push({ level, entry });\n }\n this.scrollToAdded(added);\n const min = Number.isFinite(Number(this.min)) ? Math.trunc(Number(this.min)) : DEFAULT_MIN;\n return top.length >= min ? top : [];\n }\n\n /**\n * The page was opened at a section whose heading had no id until now: go there, as the\n * browser would have (once).\n */\n private scrollToAdded(added: Element[]): void {\n if (this.scrolledToHash || !added.length) return;\n const hash = this.ownerDocument.defaultView?.location.hash.slice(1);\n if (!hash) return;\n let id = hash;\n try {\n id = decodeURIComponent(hash);\n } catch {\n /* keep it as written */\n }\n const h = added.find((a) => a.id === id);\n if (!h) return;\n this.scrolledToHash = true;\n requestAnimationFrame(() => h.scrollIntoView());\n }\n\n /** Read the entries from the first list among the children. */\n private read(nodes: Node[]): void {\n let list: Element | null = null;\n for (const n of nodes) {\n if (!(n instanceof Element)) continue;\n list = n.matches('ol, ul') ? n : n.querySelector('ol, ul');\n if (list) break;\n }\n const items = list ? this.parse(list) : [];\n const ordered = list?.localName === 'ol';\n if (ordered !== this.ordered) this.ordered = ordered;\n // Only a real change re-renders.\n if (entriesKey(items) !== entriesKey(this.childItems)) this.childItems = items;\n }\n\n private parse(list: Element): Entry[] {\n const out: Entry[] = [];\n for (const li of list.children) {\n if (li.localName !== 'li') continue;\n const sub = [...li.children].find((c) => c.matches('ol, ul'));\n const a = [...li.querySelectorAll('a[href]')].find((x) => x.closest('li') === li);\n // The entry's own text: the link's, or the item's without its sub-list.\n const label = normalize(\n a\n ? a.textContent\n : [...li.childNodes]\n .filter((c) => c !== sub)\n .map((c) => c.textContent)\n .join(' '),\n );\n const children = sub ? this.parse(sub) : [];\n if (!label) {\n this.warnOnce('label', 'ignoring entries with no text (each needs a label).');\n continue;\n }\n const entry: Entry = { label, children };\n if (a) entry.href = a.getAttribute('href')!;\n const mark = markOf(a?.getAttribute('aria-current'));\n if (mark) entry.mark = mark;\n const own = langDir(a);\n if (own.lang !== undefined) entry.lang = own.lang;\n if (own.dir) entry.dir = own.dir;\n const item = langDir(li);\n if (item.lang !== undefined) entry.itemLang = item.lang;\n if (item.dir) entry.itemDir = item.dir;\n const copy = inlineCopy(\n a ? a.childNodes : [...li.childNodes].filter((c) => c !== sub),\n this.ownerDocument,\n );\n if (copy.rich) {\n entry.rich = copy.key;\n entry.nodes = copy.nodes;\n }\n out.push(entry);\n }\n return out;\n }\n\n private fromItems(items: readonly ContentsItem[]): Entry[] {\n const out: Entry[] = [];\n for (const i of items) {\n const label = normalize(i?.label);\n if (!label) {\n this.warnOnce('label', 'ignoring entries with no text (each needs a label).');\n continue;\n }\n const entry: Entry = { label, children: this.fromItems(i.children ?? []) };\n if (i.href != null) entry.href = String(i.href);\n out.push(entry);\n }\n return out;\n }\n\n /** What is shown: `items` while set, else the children; unsafe hrefs made plain text. */\n private get entries(): Entry[] {\n const base = this.ownerDocument.baseURI;\n const clean = (list: Entry[]): Entry[] =>\n list.map((e) => {\n const children = clean(e.children);\n if (e.href === undefined || safeHref(e.href, base)) return { ...e, children };\n this.warnOnce(\n 'href',\n 'showing an entry as text: its href is not http(s), mailto, tel or relative.',\n );\n const rest: Entry = { ...e, children };\n delete rest.href;\n delete rest.mark;\n return rest;\n });\n return clean(\n this.items\n ? this.fromItems(this.items)\n : this.fromHeadingsNow\n ? this.headingItems\n : this.childItems,\n );\n }\n\n /** Whether the list shown is the one built from the headings (no items, no child list). */\n private get fromHeadingsNow(): boolean {\n return !this.items && !this.childItems.length && !!this.headingItems.length;\n }\n\n /** The current entries: the page's and its section's. */\n private currentOf(entries: Entry[]): Map<Entry, Current> {\n const flat: Entry[] = [];\n const walk = (l: Entry[]) => l.forEach((e) => (flat.push(e), walk(e.children)));\n walk(entries);\n const found = new Map<Entry, Current>();\n // The author's marks, on links only (a group or an unsafe link has none): the first\n // `page` and the first `location`.\n const marked = flat.filter((e) => e.mark && e.href !== undefined);\n if (!this.current && marked.length) {\n for (const kind of ['page', 'location'] as const) {\n const e = marked.find((m) => m.mark === kind);\n if (e) found.set(e, kind);\n }\n return found;\n }\n const base = this.ownerDocument.baseURI;\n const here = this.here || base;\n let target: URL;\n try {\n // A hash-only href is a place on this page, whatever the base URL (about:srcdoc frames).\n const c = this.current || here;\n target = new URL(c, c.startsWith('#') ? here : base);\n } catch {\n return found;\n }\n // Entries' hash-only hrefs are places on the target page (the current URL, or `current`).\n const resolve = (h: string) => new URL(h, h.startsWith('#') ? target.href : base);\n const key = pageKey(target);\n const query = queryKey(target);\n const same = flat.flatMap((e) => {\n if (e.href === undefined) return [];\n try {\n const u = resolve(e.href);\n // An entry with a query names that query (?part=2); one without matches the page\n // whatever its query (tracking parameters).\n if (pageKey(u) !== key || (u.search && queryKey(u) !== query)) return [];\n return [{ e, hash: u.hash }];\n } catch {\n return [];\n }\n });\n const page = same.find((s) => !s.hash);\n if (page) found.set(page.e, 'page');\n const section = target.hash && same.find((s) => s.hash === target.hash);\n if (section) found.set(section.e, 'location');\n return found;\n }\n\n private get level(): number {\n const n = Math.trunc(Number(this.headingLevel));\n return n >= 2 && n <= 6 ? n : DEFAULT_LEVEL;\n }\n\n private toggle(): void {\n this.open = !this.open;\n trackEvent(this, ['uvalib-contents', 'toggle', this.open ? 'open' : 'close']);\n }\n\n /**\n * A plain click on an entry fires a cancelable `uvalib-contents-navigate`; a router that\n * cancels it navigates itself (the click's default is prevented too).\n */\n private onClick(e: MouseEvent): void {\n const a = (e.target as Element | null)?.closest?.('a[href]');\n if (!a || !this.renderRoot.contains(a)) return;\n // Analytics: the entry's level (1 is the top), never its label or URL.\n const level = Number(a.getAttribute('data-level'));\n trackEvent(this, ['uvalib-contents', 'link-click', `level ${level}`, level]);\n if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)\n return;\n const go = new CustomEvent('uvalib-contents-navigate', {\n detail: { href: a.getAttribute('href'), level },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('collapseBelow') && this.isConnected) this.watchWidth();\n if (\n (changed.has('headingsFrom') || changed.has('levels') || changed.has('min')) &&\n this.isConnected\n )\n this.refresh();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.toggleAttribute('data-narrow', this.narrow);\n this.toggleAttribute('data-empty', !this.entries.length);\n this.reveal();\n }\n\n /** Scroll the list (never the page) so the current entry shows, once per entry and opening. */\n private reveal(): void {\n const panel = this.renderRoot.querySelector<HTMLElement>(`#${this.panelId}`);\n const links = panel ? [...panel.querySelectorAll<HTMLElement>('a[aria-current]')] : [];\n const a = links.find((l) => l.getAttribute('aria-current') === 'location') ?? links[0];\n if (!panel || !a || panel.hidden) return;\n const key = `${a.getAttribute('href')}|${this.narrow}|${this.open}`;\n if (key === this.scrolledTo) return;\n this.scrolledTo = key;\n if (panel.scrollHeight <= panel.clientHeight) return;\n const p = panel.getBoundingClientRect();\n const r = a.getBoundingClientRect();\n if (r.top >= p.top && r.bottom <= p.bottom) return;\n panel.scrollTop += r.top - p.top - (p.height - r.height) / 2;\n }\n\n private renderList(\n entries: Entry[],\n current: Map<Entry, Current>,\n level: number,\n ): TemplateResult {\n const items = entries.map((e) => {\n const mark = current.get(e);\n // Fresh copies of the label's inline markup each render (a node can be in one place).\n const text = e.nodes ? e.nodes.map((n) => n.cloneNode(true)) : e.label;\n const own =\n e.href !== undefined\n ? html`<a\n href=${e.href}\n data-level=${level}\n aria-current=${mark ?? nothing}\n lang=${e.lang ?? nothing}\n dir=${e.dir ?? nothing}\n >${text}</a\n >`\n : html`<span class=\"group\" lang=${e.lang ?? nothing} dir=${e.dir ?? nothing}\n >${text}</span\n >`;\n return html`<li role=\"listitem\" lang=${e.itemLang ?? nothing} dir=${e.itemDir ?? nothing}>\n ${own}${e.children.length ? this.renderList(e.children, current, level + 1) : nothing}\n </li>`;\n });\n // role=\"list\": Safari drops the list semantics of a list styled without markers. A list\n // built from headings is an <ol>: the document's order.\n return this.ordered || this.fromHeadingsNow\n ? html`<ol role=\"list\">\n ${items}\n </ol>`\n : html`<ul role=\"list\">\n ${items}\n </ul>`;\n }\n\n protected override render() {\n const entries = this.entries;\n const label = normalize(this.label) || DEFAULT_LABEL;\n const h = unsafeStatic(`h${this.level}`);\n const collapsed = this.narrow && !this.open;\n const headline = this.narrow\n ? html`<button\n type=\"button\"\n class=\"toggle\"\n aria-expanded=${this.open ? 'true' : 'false'}\n aria-controls=${this.panelId}\n @click=${this.toggle}\n >\n ${label}\n </button>`\n : label;\n // The heading's tag changes the inner template only: the <nav> (in light DOM, a child\n // of the element) is never replaced.\n return html`<nav aria-label=${label} ?hidden=${!entries.length} @click=${this.onClick}>\n ${html`<${h} class=\"headline\">${headline}</${h}>`}\n <div class=\"panel\" id=${this.panelId} ?hidden=${collapsed}>\n ${this.renderList(entries, this.currentOf(entries), 1)}\n </div>\n </nav>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibContents } from './UvalibContents.js';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,KAAA,CAAA,GAMzB5C,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA2C,EAAA,WAAA,OAAA,KAAA,CAAA,GAGzB5C,EAAA,CAAAE,EAAM,CAAA,GAAA0C,EAAA,WAAA,gBAAA,KAAA,CAAA,GAON5C,EAAA,CAAAE,EAAM,CAAA,GAAA0C,EAAA,WAAA,cAAA,KAAA,CAAA,GAEN5C,EAAA,CAAAE,EAAM,CAAA,GAAA0C,EAAA,WAAA,WAAA,KAAA,CAAA,GACN5C,EAAA,CAAAE,EAAM,CAAA,GAAA0C,EAAA,WAAA,UAAA,KAAA,CAAA,GAEN5C,EAAA,CAAAE,EAAM,CAAA,GAAA0C,EAAA,WAAA,QAAA,KAAA,CAAA,GCvVTtC,EAAO,mBAAmBsC,CAAc"}
|
|
1
|
+
{"version":3,"file":"uvalib-contents.js","names":["unsafeCSS","nothing","unsafeStatic","_decorate","property","state","n","i","r$1","define","__decorate","A","r","installLightDomStyles","UvalibElement","u","s","trackEvent","langDir","inlineCopy","normalize","safeHref","SourceChildren","accessible","markOf","v","entriesKey","items","k","DEFAULT_LABEL","DEFAULT_COLLAPSE","DEFAULT_LEVEL","DEFAULT_LEVELS","DEFAULT_MIN","uid","HEADINGS","slugify","text","headingText","walk","h","structuralRules","host","shadowStructure","pageKey","queryKey","q","UvalibContents","nodes","root","sheet","node","win","on","nav","targets","type","below","kind","message","sel","scope","finder","m","a","b","lo","hi","selector","top","open","added","label","base","id","level","entry","min","hash","list","ordered","out","li","sub","c","x","children","mark","own","item","copy","clean","e","rest","flat","l","entries","found","marked","here","target","resolve","key","query","same","page","section","go","changed","panel","links","p","current","collapsed","headline"],"sources":["../src/components/uvalib-contents/UvalibContents.ts","../src/components/uvalib-contents/uvalib-contents.ts"],"sourcesContent":["import { css, nothing, unsafeCSS, type PropertyValues, type TemplateResult } from 'lit';\nimport { html, unsafeStatic } from 'lit/static-html.js';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { inlineCopy, langDir } from '../../base/inline-copy.js';\nimport { normalize, safeHref, SourceChildren } from '../../base/source-children.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** One entry of the contents: its text, a link (optional for a group label) and sub-entries. */\nexport interface ContentsItem {\n label: string;\n href?: string;\n children?: ContentsItem[];\n}\n\n/**\n * An entry as drawn: `mark` is a valid `aria-current` the author gave its source link;\n * `lang`/`dir` come from the link and `itemLang`/`itemDir` from the `<li>`. `nodes` is a safe inline copy of the label (`em`, `cite`, `code`, `abbr`…),\n * cloned for each render; `rich` describes it, so two reads can be compared.\n */\ninterface Entry {\n label: string;\n href?: string;\n children: Entry[];\n mark?: Current;\n lang?: string;\n dir?: string;\n itemLang?: string;\n itemDir?: string;\n rich?: string;\n nodes?: Node[];\n}\n\n/** An `aria-current` value an author may give: `page`, `location`, or `true` (a page). */\nconst markOf = (v: string | null | undefined): Current | undefined => {\n const t = v?.trim().toLowerCase();\n return t === 'page' || t === 'true' ? 'page' : t === 'location' ? 'location' : undefined;\n};\n\n/** Compare two reads, leaving out the copied nodes (their `rich` key stands for them). */\nconst entriesKey = (items: Entry[]) =>\n JSON.stringify(items, (k, v: unknown) => (k === 'nodes' ? undefined : v));\n\ntype Current = 'page' | 'location';\n\nconst DEFAULT_LABEL = 'Contents';\nconst DEFAULT_COLLAPSE = '64rem';\nconst DEFAULT_LEVEL = 2;\nconst DEFAULT_LEVELS = '2-3';\nconst DEFAULT_MIN = 2;\nlet uid = 0;\n\n/** What is watched in the `headings-from` element: headings added, removed or retitled. */\nconst HEADINGS: MutationObserverInit = { childList: true, characterData: true, subtree: true };\n\n/**\n * An id from a heading's text: lowercase ASCII (accents dropped), runs of anything else as\n * one `-`, none at either end; `section` when nothing is left.\n */\nconst slugify = (text: string): string =>\n text\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '') || 'section';\n\n/** A heading's text, leaving out what is hidden from assistive technology (a `#` permalink). */\nconst headingText = (h: Element): string => {\n let text = '';\n const walk = (n: Node) => {\n if (n instanceof Element && n.getAttribute('aria-hidden') === 'true') return;\n if (n.nodeType === Node.TEXT_NODE) text += n.textContent;\n else n.childNodes.forEach(walk);\n };\n walk(h);\n return normalize(text);\n};\n\n/**\n * The rules kept with `no-style`: unmarked lists, the disclosure's closed panel hidden, and\n * `[hidden]` hides. `host` is `:host` (shadow) or the tag name (light DOM, so they stay scoped).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} :is(ol, ul) { list-style: none; margin: 0; padding: 0; }\n ${host} li :is(ol, ul) { padding-inline-start: 1rem; }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/** A comparable form of a URL: origin and path, without a trailing slash or index.html. */\nconst pageKey = (u: URL) =>\n u.origin + (u.pathname.replace(/\\/index\\.html?$/i, '/').replace(/(.)\\/$/, '$1') || '/');\n\n/** The query string as a sorted, comparable form (`?b=2&a=1` is `?a=1&b=2`). */\nconst queryKey = (u: URL) => {\n const q = new URLSearchParams(u.search);\n q.sort();\n return q.toString();\n};\n\n/**\n * Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation: a\n * `<nav>` landmark (named by `label`, \"Contents\" by default) with the label as a visible\n * headline, and a nested list of links with dividers between the top-level entries and a bar\n * beside each nested level.\n *\n * Give the list as a child: an `<ol>` or `<ul>` of `<li>` elements, each with an `<a href>`\n * (or plain text for a group label) and, for sub-entries, a nested `<ol>`/`<ul>`, to any\n * depth. Other children (a heading) are ignored. The list follows changes to the children.\n * Apps set the `items` property instead (`{ label, href?, children? }`, winning over the\n * children while set).\n *\n * The current entry gets `aria-current`: `page` for the link to this page, `location` for the\n * link to the section of it in the URL's hash. It is found from the page URL (path, and hash\n * for in-page sections), followed through same-document navigations (`hashchange`,\n * `popstate` and the Navigation API), or from the `current` attribute (a URL, resolved like\n * the links). An entry whose href has a query string matches only that query (`?part=2`); one\n * without matches the page whatever its query. Hash-only hrefs are places on that page. With\n * `current` unset, a valid `aria-current` on a source link (`page`, `location` or `true`) is\n * used instead, the first of each kind. `lang` and `dir` on the source links and items, and\n * inline markup in their text (`em`, `cite`, `code`, `abbr`…, copied element by element,\n * never as HTML), are kept.\n *\n * On narrow screens the list collapses into a disclosure: the headline becomes a button with\n * `aria-expanded`, and the list starts closed (as the Electronic Text Collections' Contents\n * does on phones, so the text comes first) until the reader opens it, or while the `open`\n * attribute is set; opening it shows the current entry. Narrow means the viewport\n * (`collapse-below`, 64rem by default), not the element's own width: a contents sidebar is\n * always far narrower than 64rem, so a container query could not tell a phone from a\n * desktop. `sticky` keeps it in view in a sidebar on wide\n * screens; a list longer than the window then scrolls, and the current entry is scrolled\n * into view inside it (never the page).\n *\n * A table of contents for a long document: `headings-from=\"#article\"` builds the list from the\n * headings in that element (`levels`, `2-3` by default; nothing shown below `min` top-level\n * entries, 2 by default). Headings without text or hidden with `aria-hidden` are skipped;\n * one without an id gets one from its text (`budget-report`, then `budget-report-2`), and\n * existing ids are kept, so links to sections keep working. It follows headings added,\n * removed or retitled; `refresh()` reads them again after other changes. The children and\n * `items` win while they give a list. Without JavaScript there is no list: a list rendered\n * at build time, as children, works everywhere.\n *\n * Single-page apps: the list is drawn from copies of the children, so a router's own click\n * handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in\n * place; hash links need nothing.\n *\n * @tagname uvalib-contents\n * @fires uvalib-analytics-event - For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), and opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' | 'close']`; never the label or URL. Bubbles and is composed.\n * @fires uvalib-contents-navigate - A plain click on an entry: `detail` is `{ href, level }` (href as written). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed.\n * @cssprop [--uvalib-contents-sticky-top=1rem] - With `sticky`: the gap kept above it.\n * @cssprop [--uvalib-contents-max-height=none] - The list's maximum height on wide screens (it scrolls beyond it); with `sticky`, the window's height less twice the sticky gap.\n * @cssprop [--uva-blue-alt-dark=#005679] - Link colour.\n * @cssprop [--uva-brand-blue=#232d4b] - The current entry's bar.\n * @cssprop [--uva-brand-orange=#e57200] - The nested levels' bar.\n * @cssprop [--uva-grey-darkest=#2b2b2b] - Text and current entry colour.\n * @cssprop --uva-color-utility-link - Dark-mode role token: link colour (else `--uva-blue-alt-dark`).\n * @cssprop --uva-color-text - Dark-mode role token: text and current entry (else `--uva-grey-darkest`).\n * @cssprop --uva-color-link - Dark-mode role token: the current entry's bar and the button's text (else `--uva-brand-blue`).\n * @cssprop --uva-color-current - Dark-mode role token: the nested levels' bar (else `--uva-brand-orange`).\n * @cssprop --uva-color-border - Dark-mode role token: dividers (else #dadada).\n * @cssprop --uva-color-control-border - Dark-mode role token: the button's border (else #808080).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: the button's background (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibContents extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n font-size: 1rem;\n line-height: 1.5;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n overflow-wrap: anywhere;\n }\n :host([sticky]:not([data-narrow])) {\n position: sticky;\n top: var(--uvalib-contents-sticky-top, 1rem);\n align-self: start;\n }\n .headline {\n margin: 0 0 0.5rem;\n font-size: 1.125rem;\n font-weight: 700;\n line-height: 1.3;\n }\n /* Balanced, but not when narrow: the headline is then a bordered button, and balanced\n lines would leave empty space inside its box. */\n :host(:not([data-narrow])) .headline {\n text-wrap: balance;\n }\n .panel {\n max-height: var(--uvalib-contents-max-height, none);\n overflow-y: auto;\n overscroll-behavior: contain;\n }\n :host([sticky]:not([data-narrow])) .panel {\n max-height: var(\n --uvalib-contents-max-height,\n calc(100dvh - 2 * var(--uvalib-contents-sticky-top, 1rem) - 3rem)\n );\n }\n :host([data-narrow]) .panel {\n max-height: none;\n overflow: visible;\n }\n .panel > :is(ol, ul) {\n border-block: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n }\n .panel > :is(ol, ul) > li + li {\n border-top: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n }\n li :is(ol, ul) {\n margin: 0 0 0.5rem 0.75rem;\n padding: 0;\n border-inline-start: 2px solid var(--uva-color-current, var(--uva-brand-orange, #e57200));\n }\n a,\n .group {\n display: block;\n padding: 0.5rem 0.75rem 0.5rem calc(0.75rem + 4px);\n }\n li li > :is(a, .group) {\n padding-block: 0.25rem;\n }\n .group {\n font-weight: 700;\n }\n a {\n color: var(--uva-color-utility-link, var(--uva-blue-alt-dark, #005679));\n text-decoration: none;\n }\n a:hover {\n text-decoration: underline;\n }\n a[aria-current] {\n padding-inline-start: 0.75rem;\n border-inline-start: 4px solid var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n color: inherit;\n font-weight: 700;\n }\n .panel a:focus-visible {\n outline-offset: -3px;\n }\n .toggle {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.75rem;\n box-sizing: border-box;\n width: 100%;\n min-height: 44px;\n margin: 0;\n padding: 0.5rem 0.75rem;\n border: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));\n border-radius: 0.3rem;\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n font-weight: 700;\n text-align: start;\n cursor: pointer;\n }\n .toggle::after {\n content: '';\n flex: none;\n width: 0.5em;\n height: 0.5em;\n margin-block-end: 0.25em;\n border-inline-end: 2px solid currentColor;\n border-block-end: 2px solid currentColor;\n transform: rotate(45deg);\n }\n .toggle[aria-expanded='true']::after {\n margin-block: 0.25em 0;\n transform: rotate(225deg);\n }\n :host([data-narrow]) .headline {\n margin-bottom: 0;\n }\n :host([data-narrow]) .panel {\n margin-top: 0.5rem;\n }\n `,\n ];\n\n /** Accessible name of the navigation landmark, and its visible headline. */\n @property({ type: String }) label = DEFAULT_LABEL;\n\n /** The headline's level (2 to 6), for the page's outline. */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel = DEFAULT_LEVEL;\n\n /**\n * The URL of the current entry (resolved like the links), for apps whose route is not the\n * page URL. Unset: the page URL, followed through same-document navigations.\n */\n @property({ type: String }) current?: string;\n\n /**\n * The viewport width at and below which the list collapses into a disclosure: a CSS length\n * (`64rem`, `800px`). `0` or `none` never collapses.\n */\n @property({ type: String, attribute: 'collapse-below' }) collapseBelow = DEFAULT_COLLAPSE;\n\n /** Whether the collapsed disclosure is open (no effect on wide screens). Toggled by its button. */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** Keep it in view while the page scrolls (a sidebar), on wide screens. */\n @property({ type: Boolean, reflect: true }) sticky = false;\n\n /**\n * The entries as data, for apps that build them in JavaScript: `{ label, href?, children? }`.\n * Wins over the children while set; `undefined` goes back to them. Entries without a label\n * are skipped (with their children) with one console warning.\n */\n @property({ attribute: false }) items?: ContentsItem[];\n\n /**\n * Build the list from the headings in the element this selector names (`#article`): each\n * heading at `levels` gets an entry linking to it (an id is added when it has none), the\n * lower levels nested under the heading before them. The children and `items` win while\n * they give a list.\n */\n @property({ type: String, attribute: 'headings-from' }) headingsFrom?: string;\n\n /** With `headings-from`: the heading levels to list, `2-3` (the default) or one level, `2`. */\n @property({ type: String }) levels = DEFAULT_LEVELS;\n\n /**\n * With `headings-from`: the fewest top-level entries worth a list (default 2). With fewer,\n * nothing is shown.\n */\n @property({ type: Number }) min = DEFAULT_MIN;\n\n /** The entries built from the headings (`headings-from`). */\n @state() private headingItems: Entry[] = [];\n private headingsObserver?: MutationObserver;\n private headingsScope?: Element | null;\n private headingsQueued = false;\n private scrolledToHash = false;\n\n /** The entries read from the children. */\n @state() private childItems: Entry[] = [];\n /** The root list's element in the source (`ol` or `ul`). */\n @state() private ordered = false;\n @state() private narrow = false;\n /** The page URL, updated on same-document navigations. */\n @state() private here = '';\n\n private warned = new Set<string>();\n private readonly panelId = `uvalib-contents-${++uid}`;\n private mql?: MediaQueryList;\n /** What was last scrolled into view, so the list is not scrolled again on every update. */\n private scrolledTo?: string;\n\n constructor() {\n super();\n new SourceChildren(\n this,\n () => this.lightDom,\n (nodes) => this.read(nodes),\n );\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n this.here = this.ownerDocument.defaultView?.location.href ?? '';\n this.listenLocation(true);\n this.watchWidth();\n // Reconnected: the headings may have changed meanwhile (the first time, willUpdate reads).\n if (this.hasUpdated) this.refresh();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.headingsObserver?.disconnect();\n this.headingsScope = undefined;\n this.listenLocation(false);\n this.mql?.removeEventListener('change', this.onWidth);\n this.mql = undefined;\n }\n\n private onLocation = (): void => {\n this.here = this.ownerDocument.defaultView?.location.href ?? '';\n };\n\n private listening = false;\n private listenLocation(on: boolean): void {\n const win = this.ownerDocument.defaultView;\n if (!win || on === this.listening) return;\n this.listening = on;\n const nav = (win as Window & { navigation?: EventTarget }).navigation;\n const targets: [EventTarget, string][] = [\n [win, 'popstate'],\n [win, 'hashchange'],\n ...(nav ? [[nav, 'currententrychange'] as [EventTarget, string]] : []),\n ];\n for (const [t, type] of targets) {\n if (on) t.addEventListener(type, this.onLocation);\n else t.removeEventListener(type, this.onLocation);\n }\n }\n\n private onWidth = (): void => {\n this.narrow = !!this.mql?.matches;\n };\n\n /** Follow the viewport against `collapse-below`. */\n private watchWidth(): void {\n this.mql?.removeEventListener('change', this.onWidth);\n const win = this.ownerDocument.defaultView;\n const below = normalize(this.collapseBelow) || DEFAULT_COLLAPSE;\n this.mql =\n win && !/^(none|0+(\\.0*)?[a-z%]*)$/i.test(below)\n ? win.matchMedia(`(max-width: ${below})`)\n : undefined;\n if (this.mql?.media === 'not all') {\n this.warnOnce('collapse', `ignoring collapse-below=\"${below}\" (not a CSS length).`);\n this.mql = win?.matchMedia(`(max-width: ${DEFAULT_COLLAPSE})`);\n }\n this.mql?.addEventListener('change', this.onWidth);\n this.onWidth();\n }\n\n private warnOnce(kind: string, message: string): void {\n if (this.warned.has(kind)) return;\n this.warned.add(kind);\n console.warn(`${this.localName}: ${message}`);\n }\n\n /**\n * With `headings-from`: read the headings again, adding ids to new ones. Headings added,\n * removed or retitled are followed by themselves; call this after other changes (an\n * `aria-hidden` set or a heading's level changed).\n */\n refresh(): void {\n const sel = normalize(this.headingsFrom);\n let scope: Element | null = null;\n if (sel) {\n const root = this.getRootNode();\n const finder =\n root instanceof Document || root instanceof ShadowRoot ? root : this.ownerDocument;\n try {\n scope = finder.querySelector(sel);\n } catch {\n scope = null;\n }\n if (!scope && this.ownerDocument.readyState === 'loading') {\n // Still parsing: try again once the document is read.\n this.ownerDocument.addEventListener('DOMContentLoaded', () => this.refresh(), {\n once: true,\n });\n } else if (!scope) {\n this.warnOnce('headings-from', `no element matches headings-from=\"${sel}\".`);\n }\n }\n if (scope !== this.headingsScope) {\n this.headingsScope = scope;\n this.headingsObserver?.disconnect();\n if (scope) {\n this.headingsObserver ??= new MutationObserver(() => this.queueHeadings());\n this.headingsObserver.observe(scope, HEADINGS);\n }\n }\n const items = scope ? this.fromHeadings(scope) : [];\n if (entriesKey(items) !== entriesKey(this.headingItems)) this.headingItems = items;\n }\n\n /** Several changes at once read the headings once. */\n private queueHeadings(): void {\n if (this.headingsQueued) return;\n this.headingsQueued = true;\n queueMicrotask(() => {\n this.headingsQueued = false;\n if (this.isConnected) this.refresh();\n });\n }\n\n /** The heading levels to list, from `levels`. */\n private get headingRange(): [number, number] {\n const m = /^\\s*([1-6])\\s*(?:-\\s*([1-6]))?\\s*$/.exec(String(this.levels ?? ''));\n if (!m) {\n this.warnOnce(\n 'levels',\n `ignoring levels=\"${this.levels}\" (use a level, 2, or a range, 2-3).`,\n );\n return [2, 3];\n }\n const a = Number(m[1]);\n const b = m[2] ? Number(m[2]) : a;\n return [Math.min(a, b), Math.max(a, b)];\n }\n\n /**\n * The entries for the headings in `scope`, in document order: empty and `aria-hidden` ones\n * and those inside this element skipped; an id added to each without one (a slug of its\n * text, unique with `-2`, `-3`…); each nested under the previous higher-level heading.\n * Fewer than `min` top-level entries: none.\n */\n private fromHeadings(scope: Element): Entry[] {\n const [lo, hi] = this.headingRange;\n const selector = Array.from({ length: hi - lo + 1 }, (_, i) => `h${lo + i}`).join(', ');\n const root = scope.getRootNode() as Document | ShadowRoot;\n const top: Entry[] = [];\n const open: { level: number; entry: Entry }[] = [];\n const added: Element[] = [];\n for (const h of scope.querySelectorAll(selector)) {\n if (this.contains(h) || h.closest('[aria-hidden=\"true\"]')) continue;\n const label = headingText(h);\n if (!label) continue;\n if (!h.id) {\n const base = slugify(label);\n let id = base;\n for (let n = 2; root.getElementById(id); n++) id = `${base}-${n}`;\n h.id = id;\n added.push(h);\n }\n const level = Number(h.localName.slice(1));\n const entry: Entry = { label, href: `#${h.id}`, children: [] };\n while (open.length && open[open.length - 1]!.level >= level) open.pop();\n (open.length ? open[open.length - 1]!.entry.children : top).push(entry);\n open.push({ level, entry });\n }\n this.scrollToAdded(added);\n const min = Number.isFinite(Number(this.min)) ? Math.trunc(Number(this.min)) : DEFAULT_MIN;\n return top.length >= min ? top : [];\n }\n\n /**\n * The page was opened at a section whose heading had no id until now: go there, as the\n * browser would have (once).\n */\n private scrollToAdded(added: Element[]): void {\n if (this.scrolledToHash || !added.length) return;\n const hash = this.ownerDocument.defaultView?.location.hash.slice(1);\n if (!hash) return;\n let id = hash;\n try {\n id = decodeURIComponent(hash);\n } catch {\n /* keep it as written */\n }\n const h = added.find((a) => a.id === id);\n if (!h) return;\n this.scrolledToHash = true;\n requestAnimationFrame(() => h.scrollIntoView());\n }\n\n /** Read the entries from the first list among the children. */\n private read(nodes: Node[]): void {\n let list: Element | null = null;\n for (const n of nodes) {\n if (!(n instanceof Element)) continue;\n list = n.matches('ol, ul') ? n : n.querySelector('ol, ul');\n if (list) break;\n }\n const items = list ? this.parse(list) : [];\n const ordered = list?.localName === 'ol';\n if (ordered !== this.ordered) this.ordered = ordered;\n // Only a real change re-renders.\n if (entriesKey(items) !== entriesKey(this.childItems)) this.childItems = items;\n }\n\n private parse(list: Element): Entry[] {\n const out: Entry[] = [];\n for (const li of list.children) {\n if (li.localName !== 'li') continue;\n const sub = [...li.children].find((c) => c.matches('ol, ul'));\n const a = [...li.querySelectorAll('a[href]')].find((x) => x.closest('li') === li);\n // The entry's own text: the link's, or the item's without its sub-list.\n const label = normalize(\n a\n ? a.textContent\n : [...li.childNodes]\n .filter((c) => c !== sub)\n .map((c) => c.textContent)\n .join(' '),\n );\n const children = sub ? this.parse(sub) : [];\n if (!label) {\n this.warnOnce('label', 'ignoring entries with no text (each needs a label).');\n continue;\n }\n const entry: Entry = { label, children };\n if (a) entry.href = a.getAttribute('href')!;\n const mark = markOf(a?.getAttribute('aria-current'));\n if (mark) entry.mark = mark;\n const own = langDir(a);\n if (own.lang !== undefined) entry.lang = own.lang;\n if (own.dir) entry.dir = own.dir;\n const item = langDir(li);\n if (item.lang !== undefined) entry.itemLang = item.lang;\n if (item.dir) entry.itemDir = item.dir;\n const copy = inlineCopy(\n a ? a.childNodes : [...li.childNodes].filter((c) => c !== sub),\n this.ownerDocument,\n );\n if (copy.rich) {\n entry.rich = copy.key;\n entry.nodes = copy.nodes;\n }\n out.push(entry);\n }\n return out;\n }\n\n private fromItems(items: readonly ContentsItem[]): Entry[] {\n const out: Entry[] = [];\n for (const i of items) {\n const label = normalize(i?.label);\n if (!label) {\n this.warnOnce('label', 'ignoring entries with no text (each needs a label).');\n continue;\n }\n const entry: Entry = { label, children: this.fromItems(i.children ?? []) };\n if (i.href != null) entry.href = String(i.href);\n out.push(entry);\n }\n return out;\n }\n\n /** What is shown: `items` while set, else the children; unsafe hrefs made plain text. */\n private get entries(): Entry[] {\n const base = this.ownerDocument.baseURI;\n const clean = (list: Entry[]): Entry[] =>\n list.map((e) => {\n const children = clean(e.children);\n if (e.href === undefined || safeHref(e.href, base)) return { ...e, children };\n this.warnOnce(\n 'href',\n 'showing an entry as text: its href is not http(s), mailto, tel or relative.',\n );\n const rest: Entry = { ...e, children };\n delete rest.href;\n delete rest.mark;\n return rest;\n });\n return clean(\n this.items\n ? this.fromItems(this.items)\n : this.fromHeadingsNow\n ? this.headingItems\n : this.childItems,\n );\n }\n\n /** Whether the list shown is the one built from the headings (no items, no child list). */\n private get fromHeadingsNow(): boolean {\n return !this.items && !this.childItems.length && !!this.headingItems.length;\n }\n\n /** The current entries: the page's and its section's. */\n private currentOf(entries: Entry[]): Map<Entry, Current> {\n const flat: Entry[] = [];\n const walk = (l: Entry[]) => l.forEach((e) => (flat.push(e), walk(e.children)));\n walk(entries);\n const found = new Map<Entry, Current>();\n // The author's marks, on links only (a group or an unsafe link has none): the first\n // `page` and the first `location`.\n const marked = flat.filter((e) => e.mark && e.href !== undefined);\n if (!this.current && marked.length) {\n for (const kind of ['page', 'location'] as const) {\n const e = marked.find((m) => m.mark === kind);\n if (e) found.set(e, kind);\n }\n return found;\n }\n const base = this.ownerDocument.baseURI;\n const here = this.here || base;\n let target: URL;\n try {\n // A hash-only href is a place on this page, whatever the base URL (about:srcdoc frames).\n const c = this.current || here;\n target = new URL(c, c.startsWith('#') ? here : base);\n } catch {\n return found;\n }\n // Entries' hash-only hrefs are places on the target page (the current URL, or `current`).\n const resolve = (h: string) => new URL(h, h.startsWith('#') ? target.href : base);\n const key = pageKey(target);\n const query = queryKey(target);\n const same = flat.flatMap((e) => {\n if (e.href === undefined) return [];\n try {\n const u = resolve(e.href);\n // An entry with a query names that query (?part=2); one without matches the page\n // whatever its query (tracking parameters).\n if (pageKey(u) !== key || (u.search && queryKey(u) !== query)) return [];\n return [{ e, hash: u.hash }];\n } catch {\n return [];\n }\n });\n const page = same.find((s) => !s.hash);\n if (page) found.set(page.e, 'page');\n const section = target.hash && same.find((s) => s.hash === target.hash);\n if (section) found.set(section.e, 'location');\n return found;\n }\n\n private get level(): number {\n const n = Math.trunc(Number(this.headingLevel));\n return n >= 2 && n <= 6 ? n : DEFAULT_LEVEL;\n }\n\n private toggle(): void {\n this.open = !this.open;\n trackEvent(this, ['uvalib-contents', 'toggle', this.open ? 'open' : 'close']);\n }\n\n /**\n * A plain click on an entry fires a cancelable `uvalib-contents-navigate`; a router that\n * cancels it navigates itself (the click's default is prevented too).\n */\n private onClick(e: MouseEvent): void {\n const a = (e.target as Element | null)?.closest?.('a[href]');\n if (!a || !this.renderRoot.contains(a)) return;\n // Analytics: the entry's level (1 is the top), never its label or URL.\n const level = Number(a.getAttribute('data-level'));\n trackEvent(this, ['uvalib-contents', 'link-click', `level ${level}`, level]);\n if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)\n return;\n const go = new CustomEvent('uvalib-contents-navigate', {\n detail: { href: a.getAttribute('href'), level },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('collapseBelow') && this.isConnected) this.watchWidth();\n if (\n (changed.has('headingsFrom') || changed.has('levels') || changed.has('min')) &&\n this.isConnected\n )\n this.refresh();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.toggleAttribute('data-narrow', this.narrow);\n this.toggleAttribute('data-empty', !this.entries.length);\n this.reveal();\n }\n\n /** Scroll the list (never the page) so the current entry shows, once per entry and opening. */\n private reveal(): void {\n const panel = this.renderRoot.querySelector<HTMLElement>(`#${this.panelId}`);\n const links = panel ? [...panel.querySelectorAll<HTMLElement>('a[aria-current]')] : [];\n const a = links.find((l) => l.getAttribute('aria-current') === 'location') ?? links[0];\n if (!panel || !a || panel.hidden) return;\n const key = `${a.getAttribute('href')}|${this.narrow}|${this.open}`;\n if (key === this.scrolledTo) return;\n this.scrolledTo = key;\n if (panel.scrollHeight <= panel.clientHeight) return;\n const p = panel.getBoundingClientRect();\n const r = a.getBoundingClientRect();\n if (r.top >= p.top && r.bottom <= p.bottom) return;\n panel.scrollTop += r.top - p.top - (p.height - r.height) / 2;\n }\n\n private renderList(\n entries: Entry[],\n current: Map<Entry, Current>,\n level: number,\n ): TemplateResult {\n const items = entries.map((e) => {\n const mark = current.get(e);\n // Fresh copies of the label's inline markup each render (a node can be in one place).\n const text = e.nodes ? e.nodes.map((n) => n.cloneNode(true)) : e.label;\n const own =\n e.href !== undefined\n ? html`<a\n href=${e.href}\n data-level=${level}\n aria-current=${mark ?? nothing}\n lang=${e.lang ?? nothing}\n dir=${e.dir ?? nothing}\n >${text}</a\n >`\n : html`<span class=\"group\" lang=${e.lang ?? nothing} dir=${e.dir ?? nothing}\n >${text}</span\n >`;\n return html`<li role=\"listitem\" lang=${e.itemLang ?? nothing} dir=${e.itemDir ?? nothing}>\n ${own}${e.children.length ? this.renderList(e.children, current, level + 1) : nothing}\n </li>`;\n });\n // role=\"list\": Safari drops the list semantics of a list styled without markers. A list\n // built from headings is an <ol>: the document's order.\n return this.ordered || this.fromHeadingsNow\n ? html`<ol role=\"list\">\n ${items}\n </ol>`\n : html`<ul role=\"list\">\n ${items}\n </ul>`;\n }\n\n protected override render() {\n const entries = this.entries;\n const label = normalize(this.label) || DEFAULT_LABEL;\n const h = unsafeStatic(`h${this.level}`);\n const collapsed = this.narrow && !this.open;\n const headline = this.narrow\n ? html`<button\n type=\"button\"\n class=\"toggle\"\n aria-expanded=${this.open ? 'true' : 'false'}\n aria-controls=${this.panelId}\n @click=${this.toggle}\n >\n ${label}\n </button>`\n : label;\n // The heading's tag changes the inner template only: the <nav> (in light DOM, a child\n // of the element) is never replaced.\n return html`<nav aria-label=${label} ?hidden=${!entries.length} @click=${this.onClick}>\n ${html`<${h} class=\"headline\">${headline}</${h}>`}\n <div class=\"panel\" id=${this.panelId} ?hidden=${collapsed}>\n ${this.renderList(entries, this.currentOf(entries), 1)}\n </div>\n </nav>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibContents } from './UvalibContents.js';\n\ndefine('uvalib-contents', UvalibContents);\n"],"mappings":";;;;;;;AAoCA,IAAMwB,KAAU,MAAsD;CACpE,IAAM,IAAIC,GAAG,KAAK,CAAC,CAAC,YAAY;CAChC,OAAO,MAAM,UAAU,MAAM,SAAS,SAAS,MAAM,aAAa,aAAa,KAAA;AACjF,GAGMC,KAAc,MAClB,KAAK,UAAUC,IAAQ,GAAG,MAAgBC,MAAM,UAAU,KAAA,IAAYH,CAAE,GAIpEI,IAAgB,YAChBC,IAAmB,SACnBC,IAAgB,GAChBC,IAAiB,OACjBC,IAAc,GAChBC,IAAM,GAGJC,IAAiC;CAAE,WAAW;CAAM,eAAe;CAAM,SAAS;AAAK,GAMvFC,KAAW,MACfC,EACG,UAAU,MAAM,CAAC,CACjB,QAAQ,oBAAoB,EAAE,CAAC,CAC/B,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,YAAY,EAAE,KAAK,WAG1BC,KAAe,MAAuB;CAC1C,IAAID,IAAO,IACLE,KAAQ,MAAY;EACxB,AAAIjC,aAAa,WAAWA,EAAE,aAAa,aAAa,MAAM,WAC1DA,EAAE,aAAa,KAAK,YAAW,KAAQA,EAAE,cACxCA,EAAE,WAAW,QAAQiC,CAAI;CAChC;CAEA,OADAA,EAAKC,CAAC,GACCpB,EAAUiB,CAAI;AACvB,GAMMI,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;I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