@uvalib/web-components 1.8.5 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +719 -72
  3. package/bin/install-skill.mjs +174 -54
  4. package/dist/base/clipboard.d.ts +9 -0
  5. package/dist/base/clipboard.js +30 -0
  6. package/dist/base/clipboard.js.map +1 -0
  7. package/dist/base.css +301 -3
  8. package/dist/components/uvalib-citation/UvalibCitation.d.ts +124 -0
  9. package/dist/components/uvalib-citation/UvalibCitation.js +545 -0
  10. package/dist/components/uvalib-citation/UvalibCitation.js.map +1 -0
  11. package/dist/components/uvalib-citation/uvalib-citation.d.ts +1 -0
  12. package/dist/components/uvalib-citation/uvalib-citation.js +4 -0
  13. package/dist/components/uvalib-citation/uvalib-citation.js.map +1 -0
  14. package/dist/components/uvalib-dialog/UvalibDialog.d.ts +167 -0
  15. package/dist/components/uvalib-dialog/UvalibDialog.js +688 -0
  16. package/dist/components/uvalib-dialog/UvalibDialog.js.map +1 -0
  17. package/dist/components/uvalib-dialog/uvalib-dialog.d.ts +1 -0
  18. package/dist/components/uvalib-dialog/uvalib-dialog.js +4 -0
  19. package/dist/components/uvalib-dialog/uvalib-dialog.js.map +1 -0
  20. package/dist/components/uvalib-filter/UvalibFilter.d.ts +92 -9
  21. package/dist/components/uvalib-filter/UvalibFilter.js +748 -60
  22. package/dist/components/uvalib-filter/UvalibFilter.js.map +1 -1
  23. package/dist/components/uvalib-list-filter/UvalibListFilter.d.ts +162 -0
  24. package/dist/components/uvalib-list-filter/UvalibListFilter.js +685 -0
  25. package/dist/components/uvalib-list-filter/UvalibListFilter.js.map +1 -0
  26. package/dist/components/uvalib-list-filter/uvalib-list-filter.d.ts +1 -0
  27. package/dist/components/uvalib-list-filter/uvalib-list-filter.js +4 -0
  28. package/dist/components/uvalib-list-filter/uvalib-list-filter.js.map +1 -0
  29. package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -4
  30. package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
  31. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +28 -1
  32. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +139 -3
  33. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  34. package/dist/custom-elements.json +9503 -6086
  35. package/dist/edition.css +758 -0
  36. package/dist/index.d.ts +6 -0
  37. package/dist/index.js +3 -0
  38. package/dist/index.js.map +1 -1
  39. package/dist/styles/base.js +112 -1
  40. package/dist/styles/base.js.map +1 -1
  41. package/dist/styles/color-scheme.js +4 -0
  42. package/dist/styles/color-scheme.js.map +1 -1
  43. package/dist/styles/controls.js +6 -0
  44. package/dist/styles/controls.js.map +1 -1
  45. package/dist/styles/edition.d.ts +1 -0
  46. package/dist/styles/edition.js +747 -0
  47. package/dist/styles/edition.js.map +1 -0
  48. package/dist/styles/field-text.d.ts +1 -0
  49. package/dist/styles/field-text.js +21 -0
  50. package/dist/styles/field-text.js.map +1 -0
  51. package/dist/styles/hidden.js +15 -1
  52. package/dist/styles/hidden.js.map +1 -1
  53. package/dist/styles/layout.d.ts +1 -0
  54. package/dist/styles/layout.js +92 -0
  55. package/dist/styles/layout.js.map +1 -0
  56. package/dist/styles/table.d.ts +1 -0
  57. package/dist/styles/table.js +164 -0
  58. package/dist/styles/table.js.map +1 -0
  59. package/dist/tokens.css +4 -0
  60. package/dist-cdn/base.css +301 -3
  61. package/dist-cdn/chunks/{base-B3tNX103.js → base-DXkGlSgH.js} +113 -2
  62. package/dist-cdn/chunks/base-DXkGlSgH.js.map +1 -0
  63. package/dist-cdn/chunks/clipboard-CNG7Y_5X.js +18 -0
  64. package/dist-cdn/chunks/clipboard-CNG7Y_5X.js.map +1 -0
  65. package/dist-cdn/chunks/if-defined-COiQb-gl.js +6 -0
  66. package/dist-cdn/chunks/if-defined-COiQb-gl.js.map +1 -0
  67. package/dist-cdn/chunks/{site-header-CEmNtmk5.js → site-header-B78a_ldi.js} +27 -22
  68. package/dist-cdn/chunks/site-header-B78a_ldi.js.map +1 -0
  69. package/dist-cdn/chunks/{site-main-nav-CAwKq_x5.js → site-main-nav-CmMq2t8t.js} +52 -51
  70. package/dist-cdn/chunks/site-main-nav-CmMq2t8t.js.map +1 -0
  71. package/dist-cdn/custom-elements.json +9503 -6086
  72. package/dist-cdn/edition.css +758 -0
  73. package/dist-cdn/manifest.json +7 -3
  74. package/dist-cdn/site-header.js +1 -1
  75. package/dist-cdn/site-main-nav.js +1 -1
  76. package/dist-cdn/site-page.js +3 -3
  77. package/dist-cdn/site-style.js +1 -1
  78. package/dist-cdn/skills/uvalib-web-components/SKILL.md +34 -10
  79. package/dist-cdn/skills/uvalib-web-components/reference/components.md +188 -9
  80. package/dist-cdn/tokens.css +4 -0
  81. package/dist-cdn/uvalib-citation.js +382 -0
  82. package/dist-cdn/uvalib-citation.js.map +1 -0
  83. package/dist-cdn/uvalib-dialog.js +419 -0
  84. package/dist-cdn/uvalib-dialog.js.map +1 -0
  85. package/dist-cdn/uvalib-filter.js +603 -69
  86. package/dist-cdn/uvalib-filter.js.map +1 -1
  87. package/dist-cdn/uvalib-list-filter.js +451 -0
  88. package/dist-cdn/uvalib-list-filter.js.map +1 -0
  89. package/dist-cdn/uvalib-metadata.js +49 -49
  90. package/dist-cdn/uvalib-metadata.js.map +1 -1
  91. package/dist-cdn/uvalib-pagefind-search.js +118 -48
  92. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  93. package/package.json +14 -1
  94. package/skills/uvalib-web-components/SKILL.md +34 -10
  95. package/skills/uvalib-web-components/reference/components.md +188 -9
  96. package/dist-cdn/chunks/base-B3tNX103.js.map +0 -1
  97. package/dist-cdn/chunks/site-header-CEmNtmk5.js.map +0 -1
  98. package/dist-cdn/chunks/site-main-nav-CAwKq_x5.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"uvalib-filter.js","names":["nothing","repeat","_decorate","property","state","n","i","r","b","define","__decorate","UvalibElement","trackEvent","accessible","TAG","instanceCounter","UvalibFilter","_args","input","rest","v","e","key","pressed","label","s","active","kind","value","root","selector","el","part","focused","changed","total","name","title","shown","collapsible","listId","lower","scope","A","bucket","id","idx"],"sources":["../src/components/uvalib-filter/UvalibFilter.ts","../src/components/uvalib-filter/uvalib-filter.ts"],"sourcesContent":["import { html, css, nothing, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** One checkbox in a facet: a value, how many results it matches, and whether it is selected. */\nexport interface FilterBucket {\n key: string;\n doc_count: number;\n selected: boolean;\n}\n\n/** A facet: a machine name (used in events and input names), a title and its buckets. */\nexport interface FilterFacet {\n name: string;\n title: string;\n position: number;\n buckets: FilterBucket[];\n}\n\n/** One scope chip: the value reported in `scope-change` and the visible label. */\nexport interface FilterScopeOption {\n value: string;\n label: string;\n}\n\n/** The analytics category. */\nconst TAG = 'uvalib-filter';\n\n/** Element ids share the document id space in light DOM, so each instance gets its own prefix. */\nlet instanceCounter = 0;\n\n/**\n * A faceted-search filter: a fieldset of checkboxes (value plus result count), optional\n * toggle chips (\"scopes\") above them, and \"See more\" / \"See less\" buttons when `limit` is set.\n * It is controlled: set `filter`, `value` and `scopeValue` from your search state and listen\n * for the change events.\n *\n * @tagname uvalib-filter\n * @fires filter-change - A checkbox was toggled. `detail` is `{ name, value }`: the facet name and the new array of selected keys. Does not bubble.\n * @fires scope-change - A scope chip was toggled. `detail` is `{ value }`: the new array of pressed scope values. Does not bubble.\n * @fires uvalib-analytics-event - For `<site-analytics>`, on the visitor's changes only: `['uvalib-filter', 'facet-change', '<title>: <value>', 1 | 0]` (checked or unchecked), `['uvalib-filter', 'scope-change', <scope label>, 1 | 0]` (pressed or not), and `['uvalib-filter', 'see-more' | 'see-less', <title>]`. Bubbles and is composed.\n * @csspart see-more - The \"See more\" button (shadow mode).\n * @csspart see-less - The \"See less\" button (shadow mode).\n * @cssprop [--uva-brand-blue=#232d4b] - Scope chip text, hover border and pressed background.\n * @cssprop [--uva-brand-orange=#e57200] - Focus ring colour (focus-visible outline).\n * @cssprop --uva-color-border - Dark-mode role token: divider under the scope chips (else #e5e7eb).\n * @cssprop --uva-color-control-border - Dark-mode role token: scope chip border (else `--uva-grey`, #808080).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: scope chip background (else #fff).\n * @cssprop --uva-color-link - Dark-mode role token: scope chip text and hover border (else `--uva-brand-blue`).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: pressed chip background and border (else `--uva-brand-blue`).\n * @cssprop --uva-color-on-accent - Dark-mode role token: pressed chip text (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibFilter extends UvalibElement {\n static styles = [\n accessible,\n css`\n :host {\n display: block;\n }\n fieldset {\n border: none;\n padding: 0;\n margin: 0;\n }\n legend {\n font-weight: bold;\n margin-bottom: 0.5rem;\n }\n .scopes {\n display: flex;\n flex-wrap: wrap;\n gap: 0.4rem;\n margin: 0 0 0.85rem;\n padding: 0 0 0.75rem;\n border-bottom: 1px solid var(--uva-color-border, #e5e7eb);\n }\n .scope {\n appearance: none;\n margin: 0;\n border: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n border-radius: 999px;\n padding: 0.2rem 0.7rem;\n font: inherit;\n font-size: 0.8rem;\n font-weight: 600;\n line-height: 1.4;\n cursor: pointer;\n }\n .scope:hover {\n border-color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n .scope[aria-pressed='true'] {\n background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n border-color: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n color: var(--uva-color-on-accent, #fff);\n }\n .checkbox {\n margin: 0.5rem 0;\n }\n input[type='checkbox'] {\n margin-right: 0.5rem;\n }\n .scope:focus-visible,\n button[part]:focus-visible,\n input[type='checkbox']:focus-visible {\n outline: 2px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n `,\n ];\n\n /** The facet to show: `{ name, title, position, buckets: [{ key, doc_count, selected }] }`. */\n @property({ type: Object })\n filter: FilterFacet = { name: '', title: '', position: 0, buckets: [] };\n\n /** Selected bucket keys (matched case-insensitively). */\n @property({ type: Array })\n value: string[] = [];\n\n /** Optional toggle chips shown under the legend (for example attendee types): `[{ value, label }]`. */\n @property({ type: Array })\n scopes: FilterScopeOption[] = [];\n\n /** Pressed scope values (matched case-insensitively). */\n @property({ type: Array })\n scopeValue: string[] = [];\n\n /** Accessible name of the scope chip group. Empty (the default) means `Filter <title> by type`. */\n @property({ type: String, attribute: 'scopes-label' })\n scopesLabel = '';\n\n /** Maximum buckets to show at first; 0 shows all. \"See more\" doubles it, \"See less\" halves it back. */\n @property({ type: Number })\n limit = 0;\n\n @state()\n private currentLimit = 0;\n\n private readonly uid = `uvalib-filter-${++instanceCounter}`;\n\n private get buckets(): FilterBucket[] {\n return this.filter?.buckets ?? [];\n }\n\n private onChange(e: Event) {\n const input = e.target as HTMLInputElement;\n const rest = this.value.filter((v) => v.toLowerCase() !== input.value.toLowerCase());\n this.value = input.checked ? [...rest, input.value] : rest;\n trackEvent(this, [TAG, 'facet-change', `${this.filter.title}: ${input.value}`, +input.checked]);\n this.dispatchEvent(\n new CustomEvent('filter-change', { detail: { name: this.filter.name, value: this.value } }),\n );\n }\n\n private toggleScope(key: string, e: Event) {\n e.preventDefault();\n e.stopPropagation();\n const rest = this.scopeValue.filter((v) => v.toLowerCase() !== key.toLowerCase());\n const pressed = rest.length === this.scopeValue.length;\n this.scopeValue = pressed ? [...rest, key] : rest;\n const label = this.scopes.find((s) => s.value === key)?.label ?? key;\n trackEvent(this, [TAG, 'scope-change', label, +pressed]);\n this.dispatchEvent(new CustomEvent('scope-change', { detail: { value: this.scopeValue } }));\n }\n\n private facetName?: string;\n\n /** The focused control inside this component (checkbox, scope chip or see more/less button). */\n private get focused(): HTMLElement | null {\n const active =\n this.renderRoot instanceof ShadowRoot\n ? this.renderRoot.activeElement\n : this.contains(document.activeElement)\n ? document.activeElement\n : null;\n return active instanceof HTMLElement ? active : null;\n }\n\n /** Identifies the focused control by something that survives re-rendering: `kind:key`. */\n private focusKey?: string;\n\n private findByFocusKey(key: string): HTMLElement | undefined {\n const [kind, ...rest] = key.split(':');\n const value = rest.join(':');\n const root = this.renderRoot as ParentNode;\n if (kind === 'part')\n return root.querySelector<HTMLElement>(`button[part=\"${value}\"]`) ?? undefined;\n const selector = kind === 'box' ? 'input[type=checkbox]' : 'button.scope';\n return [...root.querySelectorAll<HTMLInputElement | HTMLButtonElement>(selector)].find(\n (n) => n.value === value,\n );\n }\n\n private keyOf(el: HTMLElement): string | undefined {\n if (el instanceof HTMLInputElement && el.type === 'checkbox') return `box:${el.value}`;\n if (el.classList.contains('scope')) return `scope:${(el as HTMLButtonElement).value}`;\n const part = el.getAttribute('part');\n return part ? `part:${part}` : undefined;\n }\n\n protected override willUpdate(changed: PropertyValues<this>) {\n // Moving a focused node (a reordered bucket) drops focus to <body>; remember it to restore.\n const focused = this.hasUpdated ? this.focused : null;\n this.focusKey = focused ? this.keyOf(focused) : undefined;\n if (!changed.has('limit') && !changed.has('filter')) return;\n const total = this.buckets.length;\n const name = this.filter?.name;\n if (this.limit <= 0) {\n this.currentLimit = total;\n } else if (changed.has('limit') || name !== this.facetName) {\n // A different facet or limit starts collapsed again.\n this.currentLimit = this.limit;\n } else {\n // The same facet with fresh data (BOV re-sets it after every search) stays expanded.\n this.currentLimit = Math.max(this.limit, Math.min(this.currentLimit, total));\n }\n this.facetName = name;\n }\n\n protected override updated() {\n const key = this.focusKey;\n this.focusKey = undefined;\n if (!key || this.focused) return; // focus is still inside, or was never ours\n this.findByFocusKey(key)?.focus({ preventScroll: true });\n }\n\n private showMore() {\n this.currentLimit = Math.min(this.currentLimit * 2, this.buckets.length);\n trackEvent(this, [TAG, 'see-more', this.filter.title]);\n }\n\n private showLess() {\n this.currentLimit = Math.max(Math.ceil(this.currentLimit / 2), this.limit);\n trackEvent(this, [TAG, 'see-less', this.filter.title]);\n }\n\n render() {\n const total = this.buckets.length;\n const title = this.filter?.title ?? '';\n const shown = Math.min(this.currentLimit || total, total);\n const collapsible = this.limit > 0;\n const listId = `${this.uid}-list`;\n const lower = (s: string) => s.toLowerCase();\n return html`\n <fieldset>\n <legend>${title}</legend>\n ${\n this.scopes.length\n ? html`<div\n class=\"scopes\"\n role=\"group\"\n aria-label=${this.scopesLabel || `Filter ${title} by type`}\n >\n ${this.scopes.map((scope) => {\n const pressed = this.scopeValue.some((v) => lower(v) === lower(scope.value));\n return html`<button\n type=\"button\"\n class=\"scope\"\n value=${scope.value}\n aria-pressed=${pressed ? 'true' : 'false'}\n @click=${(e: Event) => this.toggleScope(scope.value, e)}\n >\n ${scope.label}\n </button>`;\n })}\n </div>`\n : nothing\n }\n <div id=${listId}>\n ${repeat(\n this.buckets.slice(0, shown),\n (bucket) => bucket.key,\n (bucket, idx) => {\n const id = `${this.uid}-${idx}`;\n return html`<div class=\"checkbox\">\n <input\n type=\"checkbox\"\n id=${id}\n name=${this.filter.name}\n value=${bucket.key}\n @change=${this.onChange}\n .checked=${this.value.some((v) => lower(v) === lower(bucket.key))}\n />\n <label for=${id}>${bucket.key || '(empty)'} (${bucket.doc_count})</label>\n </div>`;\n },\n )}\n </div>\n ${\n collapsible && shown < total\n ? html`<button\n type=\"button\"\n part=\"see-more\"\n aria-controls=${listId}\n @click=${this.showMore}\n >\n See more<span class=\"visually-hidden\"> ${title}</span>\n </button>`\n : nothing\n }\n ${\n collapsible && shown > this.limit\n ? html`<button\n type=\"button\"\n part=\"see-less\"\n aria-controls=${listId}\n @click=${this.showLess}\n >\n See less<span class=\"visually-hidden\"> ${title}</span>\n </button>`\n : nothing\n }\n </fieldset>\n `;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibFilter } from './UvalibFilter.js';\n\ndefine('uvalib-filter', UvalibFilter);\n"],"mappings":";;;;;AA6BA,IAAMc,IAAM,iBAGRC,IAAkB,GAwBTC,IAAb,cAAkCL,EAAc;;EAwFvB,A,aAzBD,KAAA,SAAA;GAAE,MAAM;GAAI,OAAO;GAAI,UAAU;GAAG,SAAS,CAAC;EAAE,GAIpD,KAAA,QAAA,CAAC,GAIW,KAAA,SAAA,CAAC,GAIR,KAAA,aAAA,CAAC,GAIV,KAAA,cAAA,IAIN,KAAA,QAAA,GAGe,KAAA,eAAA,GAEA,KAAA,MAAA,iBAAiB,EAAEI;;;EAvF1B,KAAA,SAAA,CACdF,GACA,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwDL;;CA+BA,IAAY,UAA0B;EACpC,OAAO,KAAK,QAAQ,WAAW,CAAC;CAClC;CAEA,SAAiB,GAAU;EACzB,IAAMK,IAAQ,EAAE,QACVC,IAAO,KAAK,MAAM,QAAQ,MAAMC,EAAE,YAAY,MAAMF,EAAM,MAAM,YAAY,CAAC;EAGnF,AAFA,KAAK,QAAQA,EAAM,UAAU,CAAC,GAAGC,GAAMD,EAAM,KAAK,IAAIC,GACtDP,EAAW,MAAM;GAACE;GAAK;GAAgB,GAAG,KAAK,OAAO,MAAM,IAAII,EAAM;GAAS,CAACA,EAAM;EAAO,CAAC,GAC9F,KAAK,cACH,IAAI,YAAY,iBAAiB,EAAE,QAAQ;GAAE,MAAM,KAAK,OAAO;GAAM,OAAO,KAAK;EAAM,EAAE,CAAC,CAC5F;CACF;CAEA,YAAoB,GAAa,GAAU;EAEzC,AADAG,EAAE,eAAe,GACjBA,EAAE,gBAAgB;EAClB,IAAMF,IAAO,KAAK,WAAW,QAAQ,MAAMC,EAAE,YAAY,MAAME,EAAI,YAAY,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AAA,CAAA,GAIxBd,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAe,CAAC,CAAA,GAAAa,EAAA,WAAA,eAAA,KAAA,CAAA,GAIpDd,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAa,EAAA,WAAA,SAAA,KAAA,CAAA,GAGzBd,EAAA,CAAAE,EAAM,CAAA,GAAAY,EAAA,WAAA,gBAAA,KAAA,CAAA,GC1ITP,EAAO,iBAAiBO,CAAY"}
1
+ {"version":3,"file":"uvalib-filter.js","names":["unsafeCSS","nothing","repeat","ifDefined","_decorate","property","state","n","w","i","r$1","b","define","__decorate","A","r","UvalibElement","c","o","trackEvent","accessible","TAG","filterTiming","instanceCounter","MARKS","fold","s","foldMap","text","map","ch","label","f","k","marked","q","parts","last","end","collator","lower","plural","one","many","count","CHECK","heading","level","content","MUTED","BORDER","LINK","ACCENT","RAISED","FOCUS","UvalibFilter","_args","x","y","v","key","kept","added","input","staged","rest","e","pressed","open","sort","applied","root","changes","matches","active","kind","value","selector","el","part","focused","changed","before","now","total","name","title","bodyId","selected","id","idx","checked","bucket","note","listId","matchId","pending","pendingText","applyText","groupy","shownBuckets","shown","collapsible","capped","body","scope","legend","describedBy"],"sources":["../src/components/uvalib-filter/UvalibFilter.ts","../src/components/uvalib-filter/uvalib-filter.ts"],"sourcesContent":["import { html, css, svg, unsafeCSS, nothing, type PropertyValues, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** One checkbox in a facet: a value, how many results it matches, and whether it is selected. */\nexport interface FilterBucket {\n key: string;\n doc_count: number;\n selected: boolean;\n}\n\n/** A facet: a machine name (used in events and input names), a title and its buckets. */\nexport interface FilterFacet {\n name: string;\n title: string;\n position: number;\n buckets: FilterBucket[];\n}\n\n/** One scope chip: the value reported in `scope-change` and the visible label. */\nexport interface FilterScopeOption {\n value: string;\n label: string;\n}\n\n/** The analytics category. */\nconst TAG = 'uvalib-filter';\n\n/**\n * Timing of the search-within status, in milliseconds (exported for tests). `announce`: after\n * the last keystroke, the polite \"12 of 340 subjects\" is spoken. `track`: after the last\n * keystroke, one `search` analytics event (the number of matches, never the text) is sent.\n */\nexport const filterTiming = { announce: 500, track: 1500 };\n\n/** While searching, at most this many matching values are listed (\"Type more to narrow them\"). */\nexport const SEARCH_CAP = 100;\n\n/** Element ids share the document id space in light DOM, so each instance gets its own prefix. */\nlet instanceCounter = 0;\n\nconst MARKS = /\\p{M}/gu;\n/** Case- and accent-insensitive form: \"Ébène\" and \"ebene\" match. */\nconst 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\n/** `label` with each match of the folded query `q` in a `<mark>`. */\nfunction marked(label: string, q: string): unknown {\n if (!q) return label;\n const { text, map } = foldMap(label);\n const parts: unknown[] = [];\n let last = 0;\n for (let i = text.indexOf(q); i !== -1; i = text.indexOf(q, i + q.length)) {\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 }\n parts.push(label.slice(last));\n return parts;\n}\n\nconst collator = new Intl.Collator(undefined, { sensitivity: 'base', numeric: true });\nconst lower = (s: string) => s.toLowerCase();\nconst plural = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;\nconst count = (n: number) => n.toLocaleString('en-US');\n\n/** The tick on the current sort, so it never rests on colour alone. */\nconst CHECK = svg`<svg class=\"check\" viewBox=\"0 0 16 16\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M3 8.5l3.2 3.2L13 4.8\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n\n/** A heading of `level` (2 to 6) around `content`, or the content alone. */\nfunction heading(level: number, content: unknown): unknown {\n switch (level) {\n case 2:\n return html`<h2 class=\"heading\">${content}</h2>`;\n case 3:\n return html`<h3 class=\"heading\">${content}</h3>`;\n case 4:\n return html`<h4 class=\"heading\">${content}</h4>`;\n case 5:\n return html`<h5 class=\"heading\">${content}</h5>`;\n case 6:\n return html`<h6 class=\"heading\">${content}</h6>`;\n default:\n return content;\n }\n}\n\nconst MUTED = 'var(--uva-color-text-muted, #4f4f4f)';\nconst BORDER = 'var(--uva-color-control-border, var(--uva-grey, #808080))';\nconst LINK = 'var(--uva-color-link, var(--uva-brand-blue, #232d4b))';\nconst ACCENT = 'var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))';\nconst RAISED = 'var(--uva-color-surface-raised, #fff)';\nconst FOCUS = 'var(--uva-color-focus, var(--uva-brand-orange, #e57200))';\n\n/**\n * A faceted-search filter: a fieldset of checkboxes (value plus result count), optional\n * toggle chips (\"scopes\") above them, and \"See more\" / \"See less\" buttons when `limit` is set.\n * It is controlled: set `filter`, `value` and `scopeValue` from your search state and listen\n * for the change events.\n *\n * Optional filter-group features, each off by default (without them the markup, events and\n * order are as before): `collapsible` (a caret disclosure button in the legend, with the\n * selected count while collapsed), `searchable` (search within the values), `sortable`\n * (Count | Name (A–Z)), `clearable` (a Clear button), `apply-button` (stage changes until\n * Apply) and `match` (says how the values combine).\n *\n * @tagname uvalib-filter\n * @fires filter-change - A checkbox was toggled, Clear was pressed, or (with `apply-button`) Apply was pressed. `detail` is `{ name, value }`: the facet name and the new array of selected keys (`[]` after Clear). Does not bubble.\n * @fires scope-change - A scope chip was toggled. `detail` is `{ value }`: the new array of pressed scope values. Does not bubble.\n * @fires toggle - With `collapsible`: the visitor opened or closed the group. `detail` is `{ open }`. Does not bubble.\n * @fires sort - With `sortable`: the visitor chose a sort. `detail` is `{ sort }` (`count` or `name`). Does not bubble.\n * @fires uvalib-analytics-event - For `<site-analytics>`, on the visitor's changes only: `['uvalib-filter', 'facet-change', '<title>: <value>', 1 | 0]` (checked or unchecked; with `apply-button`, one per value when Apply is pressed), `['uvalib-filter', 'scope-change', <scope label>, 1 | 0]` (pressed or not), `['uvalib-filter', 'see-more' | 'see-less', <title>]`, `['uvalib-filter', 'toggle', <title>, 1 | 0]` (opened or closed), `['uvalib-filter', 'sort', '<title>: count' | '<title>: name']`, `['uvalib-filter', 'clear', <title>, <number cleared>]`, `['uvalib-filter', 'apply', <title>, <number of changes>]` and `['uvalib-filter', 'search', <title>, <number of matches>]` once a search-within settles (never the typed text). Bubbles and is composed.\n * @csspart see-more - The \"See more\" button (shadow mode).\n * @csspart see-less - The \"See less\" button (shadow mode).\n * @csspart toggle - The disclosure button in the legend (`collapsible`).\n * @csspart search - The search-within field (`searchable`).\n * @csspart clear - The Clear button (`clearable`).\n * @csspart apply - The Apply button (`apply-button`).\n * @csspart reset - The Reset button (`apply-button`).\n * @cssprop [--uva-brand-blue=#232d4b] - Scope chip text, hover border and pressed background.\n * @cssprop [--uva-brand-orange=#e57200] - Focus ring colour (focus-visible outline).\n * @cssprop --uva-color-border - Dark-mode role token: divider under the scope chips (else #e5e7eb).\n * @cssprop --uva-color-control-border - Dark-mode role token: scope chip, search field, sort and button borders (else `--uva-grey`, #808080).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: scope chip, search field, sort and button background (else #fff).\n * @cssprop --uva-color-link - Dark-mode role token: scope chip and button text, the caret, hover border (else `--uva-brand-blue`).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: pressed chip, current sort and Apply background (else `--uva-brand-blue`).\n * @cssprop --uva-color-on-accent - Dark-mode role token: pressed chip, current sort and Apply text (else #fff).\n * @cssprop --uva-color-text-muted - Dark-mode role token: the match text, selected count, search status and staged note (else #4f4f4f).\n * @cssprop --uva-color-input-text - Dark-mode role token: search field text (else #1f2937).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibFilter extends UvalibElement {\n static styles = [\n accessible,\n css`\n :host {\n display: block;\n }\n fieldset {\n border: none;\n padding: 0;\n margin: 0;\n min-inline-size: 0;\n }\n legend {\n font-weight: bold;\n margin-bottom: 0.5rem;\n }\n .scopes {\n display: flex;\n flex-wrap: wrap;\n gap: 0.4rem;\n margin: 0 0 0.85rem;\n padding: 0 0 0.75rem;\n border-bottom: 1px solid var(--uva-color-border, #e5e7eb);\n }\n .scope {\n appearance: none;\n margin: 0;\n border: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n border-radius: 999px;\n padding: 0.2rem 0.7rem;\n font: inherit;\n font-size: 0.8rem;\n font-weight: 600;\n line-height: 1.4;\n cursor: pointer;\n }\n .scope:hover {\n border-color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n .scope[aria-pressed='true'] {\n background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n border-color: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n color: var(--uva-color-on-accent, #fff);\n }\n .checkbox {\n margin: 0.5rem 0;\n }\n input[type='checkbox'] {\n margin-right: 0.5rem;\n }\n .scope:focus-visible,\n button[part]:focus-visible,\n input[type='checkbox']:focus-visible {\n outline: 2px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n\n /* ---- Filter-group features (each opt-in). ---- */\n legend.group {\n inline-size: 100%;\n margin: 0;\n padding: 0;\n }\n .heading {\n margin: 0;\n font: inherit;\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 inline-size: 100%;\n min-block-size: 44px;\n margin: 0;\n padding: 0.5rem 0.25rem 0.5rem 0;\n border: 0;\n background: none;\n color: inherit;\n font: inherit;\n font-weight: 700;\n line-height: 1.5;\n text-align: start;\n cursor: pointer;\n }\n /* The library's caret (as in uvalib-contents and site-main-nav): a rotated border box,\n turned over when open. It flips at once: no motion. */\n .toggle::after {\n content: '';\n flex: none;\n inline-size: 0.5em;\n block-size: 0.5em;\n margin-block-end: 0.25em;\n border-inline-end: 2px solid ${unsafeCSS(LINK)};\n border-block-end: 2px solid ${unsafeCSS(LINK)};\n transform: rotate(45deg);\n }\n .toggle[aria-expanded='true']::after {\n margin-block: 0.25em 0;\n transform: rotate(225deg);\n }\n .selected-count {\n margin-inline-start: 0.5rem;\n color: ${unsafeCSS(MUTED)};\n font-size: 0.875rem;\n font-weight: 400;\n }\n .body.collapsible {\n padding-block-start: 0.25rem;\n }\n .match,\n .search-status,\n .apply-status {\n margin: 0 0 0.5rem;\n color: ${unsafeCSS(MUTED)};\n font-size: 0.875rem;\n line-height: 1.5;\n }\n .search {\n margin: 0 0 0.5rem;\n }\n .search label {\n display: block;\n margin-block-end: 0.25rem;\n font-size: 0.875rem;\n font-weight: 600;\n }\n .search input {\n box-sizing: border-box;\n inline-size: 100%;\n min-block-size: 44px;\n margin: 0;\n padding: 0.5rem 0.75rem;\n border: 1px solid ${unsafeCSS(BORDER)};\n border-radius: 0.3rem;\n background: ${unsafeCSS(RAISED)};\n color: var(--uva-color-input-text, #1f2937);\n font: inherit;\n }\n .search-status {\n margin: 0.25rem 0 0;\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 .tools {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.25rem 0.75rem;\n margin: 0 0 0.25rem;\n }\n .sort {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n }\n .sort-label {\n margin-inline-end: 0.5rem;\n font-size: 0.875rem;\n }\n .seg {\n position: relative;\n display: inline-flex;\n align-items: center;\n min-block-size: 44px;\n min-inline-size: 44px;\n }\n .seg + .seg {\n margin-inline-start: -1px;\n }\n .seg input {\n position: absolute;\n inset: 0;\n inline-size: 100%;\n block-size: 100%;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n .face {\n display: inline-flex;\n align-items: center;\n gap: 0.3rem;\n box-sizing: border-box;\n min-block-size: 2.25rem;\n padding: 0.25rem 0.625rem;\n border: 1px solid ${unsafeCSS(BORDER)};\n background: ${unsafeCSS(RAISED)};\n color: ${unsafeCSS(LINK)};\n font-size: 0.875rem;\n font-weight: 600;\n line-height: 1.3;\n white-space: nowrap;\n }\n .seg:first-of-type .face {\n border-start-start-radius: 0.3rem;\n border-end-start-radius: 0.3rem;\n }\n .seg:last-of-type .face {\n border-start-end-radius: 0.3rem;\n border-end-end-radius: 0.3rem;\n }\n .seg input:checked + .face {\n position: relative;\n border-color: ${unsafeCSS(ACCENT)};\n background: ${unsafeCSS(ACCENT)};\n color: var(--uva-color-on-accent, #fff);\n }\n .seg input:focus-visible {\n outline: none;\n }\n .seg input:focus-visible + .face,\n .search input:focus-visible {\n position: relative;\n z-index: 1;\n outline: 3px solid ${unsafeCSS(FOCUS)};\n outline-offset: 2px;\n }\n .check {\n flex: none;\n inline-size: 1em;\n block-size: 1em;\n }\n .button {\n box-sizing: border-box;\n min-block-size: 44px;\n min-inline-size: 44px;\n margin: 0;\n padding: 0.25rem 0.875rem;\n border: 1px solid ${unsafeCSS(BORDER)};\n border-radius: 0.3rem;\n background: ${unsafeCSS(RAISED)};\n color: ${unsafeCSS(LINK)};\n font: inherit;\n font-size: 0.875rem;\n font-weight: 600;\n cursor: pointer;\n }\n .button:hover {\n border-color: ${unsafeCSS(LINK)};\n }\n .clear {\n margin-inline-start: auto;\n }\n .button.primary {\n border-color: ${unsafeCSS(ACCENT)};\n background: ${unsafeCSS(ACCENT)};\n color: var(--uva-color-on-accent, #fff);\n }\n .button[aria-disabled='true'] {\n border-style: dashed;\n border-color: ${unsafeCSS(BORDER)};\n background: ${unsafeCSS(RAISED)};\n color: ${unsafeCSS(MUTED)};\n cursor: not-allowed;\n }\n .apply-bar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.5rem;\n margin-block-start: 0.5rem;\n }\n .apply-status {\n flex: 1 1 100%;\n margin: 0;\n }\n .pending {\n margin-inline-start: 0.4rem;\n padding: 0 0.3rem;\n border: 1px dashed currentColor;\n border-radius: 0.25rem;\n color: ${unsafeCSS(MUTED)};\n font-size: 0.75rem;\n font-style: italic;\n }\n .staged {\n font-style: italic;\n }\n @media (forced-colors: active) {\n .seg input:checked + .face,\n .button.primary {\n forced-color-adjust: none;\n border-color: Highlight;\n background: Highlight;\n color: HighlightText;\n }\n .button[aria-disabled='true'] {\n forced-color-adjust: none;\n border-color: GrayText;\n background: Canvas;\n color: GrayText;\n }\n .toggle::after {\n border-color: ButtonText;\n }\n }\n `,\n ];\n\n /** The facet to show: `{ name, title, position, buckets: [{ key, doc_count, selected }] }`. */\n @property({ type: Object })\n filter: FilterFacet = { name: '', title: '', position: 0, buckets: [] };\n\n /** Selected bucket keys (matched case-insensitively). */\n @property({ type: Array })\n value: string[] = [];\n\n /** Optional toggle chips shown under the legend (for example attendee types): `[{ value, label }]`. */\n @property({ type: Array })\n scopes: FilterScopeOption[] = [];\n\n /** Pressed scope values (matched case-insensitively). */\n @property({ type: Array })\n scopeValue: string[] = [];\n\n /** Accessible name of the scope chip group. Empty (the default) means `Filter <title> by type`. */\n @property({ type: String, attribute: 'scopes-label' })\n scopesLabel = '';\n\n /** Maximum buckets to show at first; 0 shows all. \"See more\" doubles it, \"See less\" halves it back. */\n @property({ type: Number })\n limit = 0;\n\n /** The legend becomes a disclosure button (with the library's caret) that shows and hides the group. */\n @property({ type: Boolean, reflect: true })\n collapsible = false;\n\n /** With `collapsible`: the group is closed (its legend button and selected count only). The visitor's toggle updates it; nothing is remembered. */\n @property({ type: Boolean, reflect: true })\n collapsed = false;\n\n /** Wrap the legend's text (or disclosure button) in a heading of this level, 2 to 6. Unset (the default): no heading, as before. */\n @property({ type: Number, attribute: 'heading-level' })\n headingLevel = 0;\n\n /** A search field above the values that narrows them as the visitor types. */\n @property({ type: Boolean, reflect: true })\n searchable = false;\n\n /** The search field's visible label. Empty (the default) means `Search <title>`. */\n @property({ type: String, attribute: 'search-label' })\n searchLabel = '';\n\n /** What the values are, plural, for the search status (\"12 of 340 subjects\"). */\n @property({ type: String })\n unit = 'values';\n\n /** A \"Sort by: Count | Name (A–Z)\" control. */\n @property({ type: Boolean, reflect: true })\n sortable = false;\n\n /** The order: `count` (most results first; without `sortable`, the data's own order) or `name` (A–Z). The visitor's choice updates it. */\n @property({ type: String, reflect: true })\n sort: 'count' | 'name' = 'count';\n\n /** A Clear button, shown while something in the group is selected. */\n @property({ type: Boolean, reflect: true })\n clearable = false;\n\n /** Stage checkbox changes until the visitor presses Apply (with Reset back to the applied state); `filter-change` fires on Apply only. */\n @property({ type: Boolean, reflect: true, attribute: 'apply-button' })\n applyButton = false;\n\n /** Say how the selected values combine, under the legend: `any` (\"Matches any selected value\") or `all`. Unset: no text. */\n @property({ type: String, reflect: true })\n match?: 'any' | 'all';\n\n @state()\n private currentLimit = 0;\n\n /** The search-within text, as typed. */\n @state()\n private query = '';\n\n /** What the polite live region says (the settled search status). */\n @state()\n private announcement = '';\n\n /** With `apply-button`: keys (lower-cased) whose checkbox differs from `value`, and the state shown. */\n @state()\n private staged = new Map<string, { key: string; checked: boolean }>();\n\n private readonly uid = `uvalib-filter-${++instanceCounter}`;\n private announceTimer?: ReturnType<typeof setTimeout>;\n private trackTimer?: ReturnType<typeof setTimeout>;\n private lastTracked = '';\n\n private get buckets(): FilterBucket[] {\n return this.filter?.buckets ?? [];\n }\n\n private get facetTitle(): string {\n return this.filter?.title ?? '';\n }\n\n /** The buckets in display order: the data's order unless sorted (stable on ties). */\n private get ordered(): FilterBucket[] {\n const b = this.buckets;\n if (this.sort === 'name') return [...b].sort((x, y) => collator.compare(x.key, y.key));\n if (this.sortable) return [...b].sort((x, y) => y.doc_count - x.doc_count);\n return b;\n }\n\n /** Whether `key` is applied (in `value`). */\n private isApplied(key: string): boolean {\n return this.value.some((v) => lower(v) === lower(key));\n }\n\n /** Whether `key`'s checkbox is shown checked (applied, or staged with `apply-button`). */\n private isChecked(key: string): boolean {\n return this.staged.get(lower(key))?.checked ?? this.isApplied(key);\n }\n\n /** The selection as shown: `value` with the staged changes. */\n private get shownValue(): string[] {\n const kept = this.value.filter((v) => this.staged.get(lower(v))?.checked !== false);\n const added = [...this.staged.values()].filter((s) => s.checked).map((s) => s.key);\n return [...kept, ...added];\n }\n\n private onChange(e: Event) {\n const input = e.target as HTMLInputElement;\n if (this.applyButton) {\n const k = lower(input.value);\n const staged = new Map(this.staged);\n if (input.checked === this.isApplied(input.value)) staged.delete(k);\n else staged.set(k, { key: input.value, checked: input.checked });\n this.staged = staged;\n return;\n }\n const rest = this.value.filter((v) => v.toLowerCase() !== input.value.toLowerCase());\n this.value = input.checked ? [...rest, input.value] : rest;\n trackEvent(this, [TAG, 'facet-change', `${this.filter.title}: ${input.value}`, +input.checked]);\n this.emitChange();\n }\n\n private emitChange() {\n this.dispatchEvent(\n new CustomEvent('filter-change', { detail: { name: this.filter.name, value: this.value } }),\n );\n }\n\n private toggleScope(key: string, e: Event) {\n e.preventDefault();\n e.stopPropagation();\n const rest = this.scopeValue.filter((v) => v.toLowerCase() !== key.toLowerCase());\n const pressed = rest.length === this.scopeValue.length;\n this.scopeValue = pressed ? [...rest, key] : rest;\n const label = this.scopes.find((s) => s.value === key)?.label ?? key;\n trackEvent(this, [TAG, 'scope-change', label, +pressed]);\n this.dispatchEvent(new CustomEvent('scope-change', { detail: { value: this.scopeValue } }));\n }\n\n private toggleOpen() {\n this.collapsed = !this.collapsed;\n const open = !this.collapsed;\n trackEvent(this, [TAG, 'toggle', this.facetTitle, +open]);\n this.dispatchEvent(new CustomEvent('toggle', { detail: { open } }));\n }\n\n private onSort(e: Event) {\n const sort = (e.target as HTMLInputElement).value as 'count' | 'name';\n this.sort = sort;\n trackEvent(this, [TAG, 'sort', `${this.facetTitle}: ${sort}`]);\n this.dispatchEvent(new CustomEvent('sort', { detail: { sort } }));\n }\n\n private async clear() {\n const n = this.shownValue.length;\n const applied = this.value.length;\n this.staged = new Map();\n trackEvent(this, [TAG, 'clear', this.facetTitle, n]);\n if (applied) {\n this.value = [];\n this.emitChange();\n }\n await this.updateComplete;\n const root = this.renderRoot as ParentNode;\n (\n root.querySelector<HTMLElement>('input[type=checkbox]') ??\n root.querySelector<HTMLElement>('button[part=toggle]')\n )?.focus();\n }\n\n private apply() {\n const changes = [...this.staged.values()];\n if (!changes.length) return;\n this.value = this.shownValue;\n this.staged = new Map();\n for (const c of changes)\n trackEvent(this, [TAG, 'facet-change', `${this.facetTitle}: ${c.key}`, +c.checked]);\n trackEvent(this, [TAG, 'apply', this.facetTitle, changes.length]);\n this.emitChange();\n }\n\n private reset() {\n this.staged = new Map();\n }\n\n private onSearch(e: Event) {\n this.query = (e.target as HTMLInputElement).value;\n this.scheduleStatus();\n }\n\n private onSearchKey(e: KeyboardEvent) {\n if (e.key !== 'Escape' || !this.query) return;\n // Clear the search, and keep Escape from closing a surrounding dialog (the filter drawer).\n e.preventDefault();\n e.stopPropagation();\n (e.target as HTMLInputElement).value = '';\n this.query = '';\n this.scheduleStatus();\n }\n\n /** The search results: the folded query, the matching buckets, and the status line. */\n private get search(): { q: string; matches: FilterBucket[] } {\n const q = this.searchable ? fold(this.query.trim()) : '';\n return { q, matches: q ? this.ordered.filter((b) => fold(b.key).includes(q)) : [] };\n }\n\n private statusText(n: number): string {\n return `${count(n)} of ${count(this.buckets.length)} ${this.unit}`;\n }\n\n private scheduleStatus() {\n clearTimeout(this.announceTimer);\n clearTimeout(this.trackTimer);\n if (!this.search.q) {\n this.announcement = '';\n return;\n }\n this.announceTimer = setTimeout(() => {\n const { q, matches } = this.search;\n if (q) this.announcement = this.statusText(matches.length);\n }, filterTiming.announce);\n this.trackTimer = setTimeout(() => {\n const { q, matches } = this.search;\n if (!q || q === this.lastTracked) return;\n this.lastTracked = q;\n trackEvent(this, [TAG, 'search', this.facetTitle, matches.length]);\n }, filterTiming.track);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n clearTimeout(this.announceTimer);\n clearTimeout(this.trackTimer);\n }\n\n private facetName?: string;\n\n /** The focused control inside this component (checkbox, scope chip or see more/less button). */\n private get focused(): HTMLElement | null {\n const active =\n this.renderRoot instanceof ShadowRoot\n ? this.renderRoot.activeElement\n : this.contains(document.activeElement)\n ? document.activeElement\n : null;\n return active instanceof HTMLElement ? active : null;\n }\n\n /** Identifies the focused control by something that survives re-rendering: `kind:key`. */\n private focusKey?: string;\n\n private findByFocusKey(key: string): HTMLElement | undefined {\n const [kind, ...rest] = key.split(':');\n const value = rest.join(':');\n const root = this.renderRoot as ParentNode;\n if (kind === 'part')\n return root.querySelector<HTMLElement>(`button[part=\"${value}\"]`) ?? undefined;\n const selector = kind === 'box' ? 'input[type=checkbox]' : 'button.scope';\n return [...root.querySelectorAll<HTMLInputElement | HTMLButtonElement>(selector)].find(\n (n) => n.value === value,\n );\n }\n\n private keyOf(el: HTMLElement): string | undefined {\n if (el instanceof HTMLInputElement && el.type === 'checkbox') return `box:${el.value}`;\n if (el.classList.contains('scope')) return `scope:${(el as HTMLButtonElement).value}`;\n const part = el.getAttribute('part');\n return part ? `part:${part}` : undefined;\n }\n\n protected override willUpdate(changed: PropertyValues<this>) {\n // Moving a focused node (a reordered bucket) drops focus to <body>; remember it to restore.\n const focused = this.hasUpdated ? this.focused : null;\n this.focusKey = focused ? this.keyOf(focused) : undefined;\n // A new applied selection (from the page) replaces staged changes; the same one keeps them.\n if (changed.has('value') && this.staged.size) {\n const before = new Set(((changed.get('value') as string[] | undefined) ?? []).map(lower));\n const now = new Set(this.value.map(lower));\n if (before.size !== now.size || [...now].some((v) => !before.has(v))) this.staged = new Map();\n }\n if (changed.has('applyButton') && !this.applyButton) this.staged = new Map();\n if (!changed.has('limit') && !changed.has('filter')) return;\n const total = this.buckets.length;\n const name = this.filter?.name;\n if (this.limit <= 0) {\n this.currentLimit = total;\n } else if (changed.has('limit') || name !== this.facetName) {\n // A different facet or limit starts collapsed again.\n this.currentLimit = this.limit;\n } else {\n // The same facet with fresh data (BOV re-sets it after every search) stays expanded.\n this.currentLimit = Math.max(this.limit, Math.min(this.currentLimit, total));\n }\n this.facetName = name;\n }\n\n protected override updated() {\n const key = this.focusKey;\n this.focusKey = undefined;\n if (!key || this.focused) return; // focus is still inside, or was never ours\n this.findByFocusKey(key)?.focus({ preventScroll: true });\n }\n\n private showMore() {\n this.currentLimit = Math.min(this.currentLimit * 2, this.buckets.length);\n trackEvent(this, [TAG, 'see-more', this.filter.title]);\n }\n\n private showLess() {\n this.currentLimit = Math.max(Math.ceil(this.currentLimit / 2), this.limit);\n trackEvent(this, [TAG, 'see-less', this.filter.title]);\n }\n\n /** The legend's content: the title, or the disclosure button; in a heading if asked. */\n private renderLegend(title: string, bodyId: string, selected: number): unknown {\n const level = this.headingLevel >= 2 && this.headingLevel <= 6 ? this.headingLevel : 0;\n if (!this.collapsible) return heading(level, title);\n const open = !this.collapsed;\n return heading(\n level,\n html`<button\n type=\"button\"\n part=\"toggle\"\n class=\"toggle\"\n aria-expanded=${open ? 'true' : 'false'}\n aria-controls=${bodyId}\n @click=${this.toggleOpen}\n >\n <span\n >${title}${\n !open && selected\n ? html`<span class=\"selected-count\"\n ><span class=\"visually-hidden\">, </span>${selected} selected</span\n >`\n : nothing\n }</span\n >\n </button>`,\n );\n }\n\n private renderSort(): TemplateResult {\n const id = `${this.uid}-sort`;\n const options: ['count' | 'name', string][] = [\n ['count', 'Count'],\n ['name', 'Name (A–Z)'],\n ];\n // form= names no form: the radios group by name, and a surrounding form never submits them.\n return html`<div class=\"sort\" role=\"radiogroup\" aria-labelledby=\"${id}-label\">\n <span class=\"sort-label\" id=\"${id}-label\">Sort by</span>\n ${options.map(\n ([value, label]) =>\n html`<label class=\"seg\"\n ><input\n type=\"radio\"\n name=${id}\n form=\"${id}-none\"\n value=${value}\n .checked=${this.sort === value}\n @change=${this.onSort}\n /><span class=\"face\">${this.sort === value ? CHECK : nothing}${label}</span></label\n >`,\n )}\n </div>`;\n }\n\n private renderBucket(bucket: FilterBucket, idx: number, q: string): TemplateResult {\n const id = `${this.uid}-${idx}`;\n const checked = this.isChecked(bucket.key);\n const staged = this.staged.has(lower(bucket.key));\n const text = bucket.key ? marked(bucket.key, q) : '(empty)';\n const n = bucket.doc_count;\n const note = staged ? html`<span class=\"pending\">not applied</span>` : nothing;\n return html`<div class=\"checkbox\">\n <input\n type=\"checkbox\"\n id=${id}\n name=${this.filter.name}\n value=${bucket.key}\n @change=${this.onChange}\n .checked=${checked}\n />\n <label for=${id} class=${staged ? 'staged' : nothing}>${text} (${n})${note}</label>\n </div>`;\n }\n\n render() {\n const total = this.buckets.length;\n const title = this.facetTitle;\n const { q, matches } = this.search;\n const listId = `${this.uid}-list`;\n const bodyId = `${this.uid}-body`;\n const matchId = `${this.uid}-match`;\n const selected = this.shownValue.length;\n const pending = this.staged.size;\n const pendingText = pending ? `${plural(pending, 'change')} not applied yet` : '';\n const applyText = pending ? `Apply ${plural(pending, 'change')}` : 'Apply';\n const groupy = this.collapsible || this.headingLevel > 0;\n\n // While searching: every checked value first (so a selection never disappears), then the\n // unchecked matches, up to SEARCH_CAP. Otherwise: the first `currentLimit` values.\n let shownBuckets: FilterBucket[];\n let shown = 0;\n if (q) {\n const rest = matches.filter((b) => !this.isChecked(b.key));\n shownBuckets = [\n ...this.ordered.filter((b) => this.isChecked(b.key)),\n ...rest.slice(0, SEARCH_CAP),\n ];\n } else {\n shown = Math.min(this.currentLimit || total, total);\n shownBuckets = this.ordered.slice(0, shown);\n }\n const collapsible = this.limit > 0 && !q;\n const capped = q && matches.filter((b) => !this.isChecked(b.key)).length > SEARCH_CAP;\n\n const body = html`\n ${\n this.match === 'any' || this.match === 'all'\n ? html`<p class=\"match\" id=${matchId}>\n ${this.match === 'all' ? 'Matches all selected values' : 'Matches any selected value'}\n </p>`\n : nothing\n }\n ${\n this.scopes.length\n ? html`<div\n class=\"scopes\"\n role=\"group\"\n aria-label=${this.scopesLabel || `Filter ${title} by type`}\n >\n ${this.scopes.map((scope) => {\n const pressed = this.scopeValue.some((v) => lower(v) === lower(scope.value));\n return html`<button\n type=\"button\"\n class=\"scope\"\n value=${scope.value}\n aria-pressed=${pressed ? 'true' : 'false'}\n @click=${(e: Event) => this.toggleScope(scope.value, e)}\n >\n ${scope.label}\n </button>`;\n })}\n </div>`\n : nothing\n }\n ${\n this.searchable\n ? html`<div class=\"search\">\n <label for=\"${this.uid}-search\">${this.searchLabel || `Search ${title}`}</label>\n <input\n id=\"${this.uid}-search\"\n part=\"search\"\n type=\"search\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n .value=${this.query}\n @input=${this.onSearch}\n @keydown=${this.onSearchKey}\n />\n ${\n q\n ? html`<p class=\"search-status\">\n ${this.statusText(matches.length)}${\n capped ? `. Showing the first ${SEARCH_CAP}; type more to narrow them.` : ''\n }\n </p>`\n : nothing\n }\n <span class=\"visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n >${this.announcement}</span\n >\n </div>`\n : nothing\n }\n ${\n this.sortable || (this.clearable && selected)\n ? html`<div class=\"tools\">\n ${this.sortable ? this.renderSort() : nothing}\n ${\n this.clearable && selected\n ? html`<button\n type=\"button\"\n part=\"clear\"\n class=\"button clear\"\n @click=${this.clear}\n >\n Clear<span class=\"visually-hidden\"> ${title} filters</span>\n </button>`\n : nothing\n }\n </div>`\n : nothing\n }\n <div id=${listId}>\n ${repeat(\n shownBuckets,\n (bucket) => bucket.key,\n (bucket, idx) => this.renderBucket(bucket, idx, q),\n )}\n </div>\n ${\n collapsible && shown < total\n ? html`<button\n type=\"button\"\n part=\"see-more\"\n aria-controls=${listId}\n @click=${this.showMore}\n >\n See more<span class=\"visually-hidden\"> ${title}</span>\n </button>`\n : nothing\n }\n ${\n collapsible && shown > this.limit\n ? html`<button\n type=\"button\"\n part=\"see-less\"\n aria-controls=${listId}\n @click=${this.showLess}\n >\n See less<span class=\"visually-hidden\"> ${title}</span>\n </button>`\n : nothing\n }\n ${\n this.applyButton\n ? html`<div class=\"apply-bar\">\n <p class=\"apply-status\" role=\"status\" aria-live=\"polite\">${pendingText}</p>\n <button\n type=\"button\"\n part=\"apply\"\n class=\"button primary\"\n aria-disabled=${pending ? 'false' : 'true'}\n @click=${this.apply}\n >\n ${applyText}<span class=\"visually-hidden\"> to ${title}</span>\n </button>\n <button\n type=\"button\"\n part=\"reset\"\n class=\"button\"\n aria-disabled=${pending ? 'false' : 'true'}\n @click=${this.reset}\n >\n Reset<span class=\"visually-hidden\"> ${title}</span>\n </button>\n </div>`\n : nothing\n }\n `;\n\n const legend = this.renderLegend(title, bodyId, selected);\n const describedBy = this.match === 'any' || this.match === 'all' ? matchId : undefined;\n return html`\n <fieldset aria-describedby=${ifDefined(describedBy)}>\n <legend class=${groupy ? 'group' : nothing}>${legend}</legend>\n ${\n this.collapsible\n ? html`<div class=\"body collapsible\" id=${bodyId} ?hidden=${this.collapsed}>\n ${body}\n </div>`\n : body\n }\n </fieldset>\n `;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibFilter } from './UvalibFilter.js';\n\ndefine('uvalib-filter', UvalibFilter);\n"],"mappings":";;;;;;AA8BA,IAAMqB,IAAM,iBAOCC,IAAe;CAAE,UAAU;CAAK,OAAO;AAAK,GAMrDC,IAAkB,GAEhBC,IAAQ,WAERC,KAAQ,MAAsBC,EAAE,UAAU,KAAK,CAAC,CAAC,QAAQF,GAAO,EAAE,CAAC,CAAC,YAAY;AAGtF,SAASG,EAAQ,GAAgD;CAC/D,IAAIC,IAAO,IACLC,IAAgB,CAAC,GACnBpB,IAAI;CACR,KAAK,IAAMqB,KAAMC,GAAO;EACtB,IAAMC,IAAIP,EAAKK,CAAE;EACjB,KAAK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0 +1,451 @@
1
+ import { a as e, d as t, f as n, i as r, l as i, m as a, n as o, o as s, p as c, r as l, t as u } from "./chunks/UvalibElement-pGONDAwB.js";
2
+ import { a as d } from "./chunks/analytics-DTTihuBD.js";
3
+ import { n as f, t as p } from "./chunks/url-param-C1sk_F1d.js";
4
+ import { t as m } from "./chunks/accessible-DJv7YOtS.js";
5
+ // src/styles/message.ts
6
+ var h = n`
7
+ .uvalib-message {
8
+ display: block;
9
+ box-sizing: border-box;
10
+ max-inline-size: 100%;
11
+ margin-block: 1rem;
12
+ padding: 0.75rem 1rem;
13
+ border: 1px solid transparent;
14
+ border-inline-start: 6px solid var(--uva-color-alert-info-border, var(--uva-blue-alt, #007bac));
15
+ border-radius: 0.3rem;
16
+ background: var(--uva-color-alert-info-bg, var(--uva-blue-alt-300, #bfe7f7));
17
+ color: var(--uva-color-alert-text, var(--uva-grey-darkest, #2b2b2b));
18
+ line-height: 1.5;
19
+ overflow-wrap: anywhere;
20
+ text-wrap: pretty;
21
+ }
22
+ .uvalib-message > :first-child {
23
+ margin-block-start: 0;
24
+ }
25
+ .uvalib-message > :last-child {
26
+ margin-block-end: 0;
27
+ }
28
+ .uvalib-message a,
29
+ .uvalib-message a:visited {
30
+ color: var(--uva-color-alert-link, var(--uva-blue-alt-B, #141e3c));
31
+ text-decoration: underline;
32
+ }
33
+ /* The ring follows the text colour, chosen to read on the message's own background. */
34
+ .uvalib-message a:focus-visible {
35
+ outline: 2px solid currentColor;
36
+ outline-offset: 2px;
37
+ }
38
+ .uvalib-message__label {
39
+ font-weight: 700;
40
+ }
41
+ .uvalib-message__icon {
42
+ display: inline-block;
43
+ inline-size: 1.25em;
44
+ block-size: 1.25em;
45
+ margin-inline-end: 0.35em;
46
+ vertical-align: -0.25em;
47
+ }
48
+ .uvalib-message--error {
49
+ border-inline-start-color: var(--uva-color-alert-critical-border, var(--uva-red-B, #b30000));
50
+ background: var(--uva-color-alert-critical-bg, var(--uva-red-100, #fbcfda));
51
+ }
52
+ .uvalib-message--warning {
53
+ border-inline-start-color: var(--uva-color-alert-warning-border, var(--uva-yellow, #ecc602));
54
+ background: var(--uva-color-alert-warning-bg, var(--uva-yellow-100, #fef6c8));
55
+ }
56
+ .uvalib-message:is(.uvalib-message--info, .uvalib-message--notice) {
57
+ border-inline-start-color: var(--uva-color-alert-info-border, var(--uva-blue-alt, #007bac));
58
+ background: var(--uva-color-alert-info-bg, var(--uva-blue-alt-300, #bfe7f7));
59
+ }
60
+ .uvalib-message--success {
61
+ border-inline-start-color: var(--uva-color-status-success-border, var(--uva-green-A, #4e9737));
62
+ background: var(--uva-color-status-success-bg, var(--uva-green-200, #ddefdc));
63
+ }
64
+ @media (forced-colors: active) {
65
+ .uvalib-message {
66
+ border-color: CanvasText;
67
+ }
68
+ .uvalib-message a:focus-visible {
69
+ outline-color: Highlight;
70
+ }
71
+ }
72
+ `, g = "uvalib-list-filter", _ = {
73
+ settle: 1e3,
74
+ url: 250
75
+ }, v = 5e3, y = 0, b = /\p{M}/gu, x = (e) => e.normalize("NFD").replace(b, "").toLowerCase(), S = (e) => x(e).split(/\s+/).filter(Boolean), C = (e) => S(e).toSorted().join(" "), w = (e) => e.toLocaleString("en-US"), T = /* @__PURE__ */ new WeakMap(), E = "data-uvalib-list-filter";
76
+ function D(e) {
77
+ let t = T.get(e);
78
+ t || (t = new (((e.ownerDocument ?? e).defaultView?.CSSStyleSheet) ?? CSSStyleSheet)(), t.replaceSync(`:where([${E}]) > [hidden] { display: none !important; }`), T.set(e, t)), e.adoptedStyleSheets.includes(t) || (e.adoptedStyleSheets = [...e.adoptedStyleSheets, t]);
79
+ }
80
+ var O = t`<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>`, k = (e) => `
81
+ ${e} { display: block; max-width: 100%; font-size: 1rem; line-height: 1.5; }
82
+ ${e} .label { display: block; margin-block-end: 0.25rem; }
83
+ ${e} .field { position: relative; }
84
+ ${e} .input {
85
+ display: block;
86
+ box-sizing: border-box;
87
+ inline-size: 100%;
88
+ min-block-size: 44px;
89
+ margin: 0;
90
+ padding-inline-end: 44px;
91
+ font: inherit;
92
+ line-height: 1.2;
93
+ }
94
+ ${e} .input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
95
+ ${e} .clear {
96
+ position: absolute;
97
+ inset-block-start: 0;
98
+ inset-inline-end: 0;
99
+ display: inline-flex;
100
+ align-items: center;
101
+ justify-content: center;
102
+ box-sizing: border-box;
103
+ inline-size: 44px;
104
+ block-size: 44px;
105
+ margin: 0;
106
+ padding: 0;
107
+ cursor: pointer;
108
+ }
109
+ ${e} .count { margin: 0.25rem 0 0; }
110
+ ${e} .visually-hidden {
111
+ position: absolute;
112
+ width: 1px;
113
+ height: 1px;
114
+ margin: -1px;
115
+ padding: 0;
116
+ overflow: hidden;
117
+ clip: rect(0, 0, 0, 0);
118
+ white-space: nowrap;
119
+ border: 0;
120
+ }
121
+ ${e}[hidden], ${e} [hidden] { display: none !important; }
122
+ `, A = c(k(":host")), j = c("var(--uva-color-control-border, var(--uva-grey, #808080))"), M = c("var(--uva-color-text-muted, var(--uva-grey-A, #4f4f4f))"), N = c("var(--uva-color-input-text, var(--uva-grey-darkest, #2b2b2b))"), P = c("var(--uva-color-surface-raised, #ffffff)"), F = class extends u {
123
+ constructor(...e) {
124
+ super(...e), this.htmlFor = "", this.selector = "", this.label = "Filter", this.hideLabel = !1, this.placeholder = "", this.noun = "items", this.singular = "", this.resultsCount = "", this.queryParam = null, this.value = "", this.shownCount = 0, this.totalCount = 0, this.appliedQuery = "", this.announcement = "", this.uid = `${g}-${++y}`, this.started = !1, this.warned = !1, this.reported = "", this.onInput = (e) => {
125
+ e.stopPropagation(), this.value = e.target.value, this.apply(!0);
126
+ }, this.onKeydown = (e) => {
127
+ e.key === "Escape" && this.value && (e.preventDefault(), this.clear());
128
+ }, this.clear = () => {
129
+ let e = this.input;
130
+ e && (e.value = ""), this.value = "", this.apply(!0), e?.focus(), d(this, [g, "clear"]), this.reported = "";
131
+ }, this.flushUrl = () => {
132
+ if (this.urlTimer === void 0) return;
133
+ clearTimeout(this.urlTimer), this.urlTimer = void 0;
134
+ let e = this.param;
135
+ if (!e) return;
136
+ let t = this.value.trim();
137
+ if ((f(location, e) ?? "") !== t) try {
138
+ history.replaceState(history.state, "", p(location, e, t || null));
139
+ } catch {}
140
+ }, this.onPopState = () => {
141
+ if (!this.started || !this.param) return;
142
+ let e = this.urlQuery() ?? "";
143
+ e !== this.value && (this.value = e, this.reported = C(e), this.apply());
144
+ };
145
+ }
146
+ static {
147
+ this.styles = [
148
+ m,
149
+ A,
150
+ h,
151
+ n`
152
+ :host {
153
+ color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));
154
+ }
155
+ .label {
156
+ font-weight: 600;
157
+ }
158
+ .field {
159
+ max-inline-size: 36rem;
160
+ }
161
+ .input {
162
+ padding-block: 0.5rem;
163
+ padding-inline-start: 0.75rem;
164
+ border: 1px solid ${j};
165
+ border-radius: 5px;
166
+ background: ${P};
167
+ color: ${N};
168
+ }
169
+ .input::placeholder {
170
+ color: ${M};
171
+ opacity: 1;
172
+ }
173
+ .clear {
174
+ border: 0;
175
+ border-radius: 5px;
176
+ background: none;
177
+ color: ${M};
178
+ }
179
+ .clear:hover {
180
+ color: ${N};
181
+ }
182
+ .clear:focus-visible {
183
+ outline-offset: -4px;
184
+ }
185
+ .count {
186
+ color: ${M};
187
+ }
188
+ .uvalib-message {
189
+ margin-block: 0.75rem 0;
190
+ }
191
+ @media (forced-colors: active) {
192
+ .input {
193
+ border-color: CanvasText;
194
+ }
195
+ .clear {
196
+ color: ButtonText;
197
+ }
198
+ }
199
+ `
200
+ ];
201
+ }
202
+ get shown() {
203
+ return this.shownCount;
204
+ }
205
+ get total() {
206
+ return this.totalCount;
207
+ }
208
+ createRenderRoot() {
209
+ let e = super.createRenderRoot();
210
+ if (e instanceof ShadowRoot && this.noStyle) {
211
+ let t = A.styleSheet;
212
+ t && (e.adoptedStyleSheets = [t]);
213
+ }
214
+ return e;
215
+ }
216
+ connectedCallback() {
217
+ if (super.connectedCallback(), this.lightDom && this.noStyle) {
218
+ let e = this.getRootNode();
219
+ l(`${this.localName}::structure`, c(k(this.localName)), {
220
+ root: e instanceof ShadowRoot || e instanceof Document ? e : void 0,
221
+ scope: !1
222
+ });
223
+ }
224
+ window.addEventListener("popstate", this.onPopState), window.addEventListener("pagehide", this.flushUrl), this.started && this.reset();
225
+ }
226
+ disconnectedCallback() {
227
+ super.disconnectedCallback(), window.removeEventListener("popstate", this.onPopState), window.removeEventListener("pagehide", this.flushUrl), clearTimeout(this.settleTimer), clearTimeout(this.clearing), this.flushUrl(), this.observer?.disconnect(), this.observed = void 0, this.showAll();
228
+ }
229
+ begin() {
230
+ document.readyState === "loading" && !this.collect() ? document.addEventListener("DOMContentLoaded", () => this.start(), { once: !0 }) : this.start();
231
+ }
232
+ start() {
233
+ if (this.started || !this.isConnected) return;
234
+ this.started = !0;
235
+ let e = this.urlQuery();
236
+ e !== null && (this.value = e), this.reported = C(this.value), this.apply();
237
+ }
238
+ willUpdate(e) {
239
+ if (!this.hasUpdated) return this.begin();
240
+ this.started && (e.has("htmlFor") || e.has("selector") ? this.reset() : e.has("value") && this.value !== this.appliedQuery && this.apply());
241
+ }
242
+ refresh() {
243
+ this.started && this.reset();
244
+ }
245
+ reset() {
246
+ this.showAll(), this.index = void 0, this.apply();
247
+ }
248
+ lookupRoot() {
249
+ let e = this.getRootNode();
250
+ return e instanceof ShadowRoot || e instanceof Document ? e : document;
251
+ }
252
+ target() {
253
+ return this.htmlFor ? this.lookupRoot().getElementById(this.htmlFor) : null;
254
+ }
255
+ collect() {
256
+ let e = this.target();
257
+ if (this.htmlFor && !e) return null;
258
+ let t;
259
+ if (this.selector) try {
260
+ t = [...(e ?? this.lookupRoot()).querySelectorAll(this.selector)];
261
+ } catch {
262
+ return null;
263
+ }
264
+ else if (e) t = e instanceof HTMLTableElement ? [...e.tBodies].flatMap((e) => [...e.rows]) : [...e.children];
265
+ else return null;
266
+ return t.filter((e) => e instanceof HTMLElement);
267
+ }
268
+ build() {
269
+ let e = this.collect();
270
+ if (!e) {
271
+ this.warned || (this.warned = !0, console.warn(`<${g}>: no list found; set "for" to the id of the list, or "selector" to its items.`));
272
+ return;
273
+ }
274
+ let t = e.map((e) => e.parentElement?.closest("[data-filter-group]") ?? null), n = [...new Set(t.filter((e) => e !== null))], r = e[0]?.getRootNode();
275
+ (r instanceof Document || r instanceof ShadowRoot) && D(r);
276
+ for (let t of new Set([...e, ...n].map((e) => e.parentElement))) t?.setAttribute(E, "");
277
+ return this.observe(), {
278
+ items: e,
279
+ hidden: e.map((e) => e.hidden),
280
+ group: t,
281
+ groups: n
282
+ };
283
+ }
284
+ observe() {
285
+ let e = this.target();
286
+ e && e !== this.observed && (this.observer?.disconnect(), this.observer ??= new MutationObserver(() => {
287
+ this.index = void 0, this.apply();
288
+ }), this.observer.observe(e, {
289
+ childList: !0,
290
+ subtree: !0,
291
+ attributes: !0,
292
+ attributeFilter: ["data-filter-text"]
293
+ }), this.observed = e);
294
+ }
295
+ textOf(e) {
296
+ return e.text ??= e.items.map((e) => x(e.dataset.filterText ?? e.textContent ?? "")), e.text;
297
+ }
298
+ apply(e = !1) {
299
+ this.index ??= this.build();
300
+ let t = this.index, n = this.value, r = this.appliedQuery;
301
+ if (this.appliedQuery = n, !t) {
302
+ this.shownCount = this.totalCount = 0;
303
+ return;
304
+ }
305
+ let i = S(n), a = i.length ? this.textOf(t) : [], { items: o, hidden: s, group: c } = t, l = /* @__PURE__ */ new Map(), u = 0;
306
+ for (let e = 0; e < o.length; e++) {
307
+ let t = !1;
308
+ if (i.length) {
309
+ let n = a[e];
310
+ for (let e of i) if (!n.includes(e)) {
311
+ t = !0;
312
+ break;
313
+ }
314
+ }
315
+ if (s[e] !== t && (s[e] = t, o[e].hidden = t), !t) {
316
+ u++;
317
+ let t = c[e];
318
+ t && l.set(t, (l.get(t) ?? 0) + 1);
319
+ }
320
+ }
321
+ for (let e of t.groups) {
322
+ let t = !l.has(e);
323
+ e.hidden !== t && (e.hidden = t);
324
+ }
325
+ let d = n !== r || u !== this.shownCount || o.length !== this.totalCount;
326
+ this.shownCount = u, this.totalCount = o.length, this.driveResultsCount(), d && (n || r) && this.dispatchEvent(new CustomEvent("uvalib-list-filter-change", {
327
+ detail: {
328
+ query: n,
329
+ shown: u,
330
+ total: o.length
331
+ },
332
+ bubbles: !0,
333
+ composed: !0
334
+ })), e && (clearTimeout(this.settleTimer), this.settleTimer = setTimeout(() => this.settle(), _.settle), clearTimeout(this.urlTimer), this.urlTimer = setTimeout(this.flushUrl, _.url));
335
+ }
336
+ showAll() {
337
+ let e = this.index;
338
+ if (e) {
339
+ e.items.forEach((t, n) => {
340
+ e.hidden[n] && (t.hidden = e.hidden[n] = !1);
341
+ });
342
+ for (let t of e.groups) t.hidden = !1;
343
+ }
344
+ }
345
+ externalCount() {
346
+ return this.resultsCount ? this.lookupRoot().getElementById(this.resultsCount) : null;
347
+ }
348
+ driveResultsCount() {
349
+ let e = this.externalCount();
350
+ e && (e.total = this.totalCount, e.shown = this.shownCount);
351
+ }
352
+ word(e) {
353
+ let t = this.noun.trim() || "items";
354
+ return e === 1 ? this.singular.trim() || (t === "items" ? "item" : t) : t;
355
+ }
356
+ get countText() {
357
+ let e = this.totalCount, t = this.shownCount;
358
+ return e ? t < e ? `Showing ${w(t)} of ${w(e)} ${this.word(e)}` : e === 1 ? `Showing 1 ${this.word(1)}` : `Showing all ${w(e)} ${this.word(e)}` : this.started && this.index ? `No ${this.word(0)}` : "";
359
+ }
360
+ get emptyText() {
361
+ let e = this.appliedQuery.trim();
362
+ return this.totalCount && !this.shownCount && e ? `No ${this.word(0)} match “${e}”.` : "";
363
+ }
364
+ settle() {
365
+ this.externalCount() || this.announce(this.emptyText || this.countText);
366
+ let e = C(this.value);
367
+ e !== this.reported && (e ? d(this, [
368
+ g,
369
+ "filter",
370
+ "",
371
+ this.shownCount
372
+ ]) : d(this, [g, "clear"]), this.reported = e);
373
+ }
374
+ announce(e) {
375
+ if (!e) return;
376
+ clearTimeout(this.clearing);
377
+ let t = () => {
378
+ this.announcement = e, this.clearing = setTimeout(() => this.announcement = "", v);
379
+ };
380
+ this.announcement === e ? (this.announcement = "", this.updateComplete.then(() => requestAnimationFrame(t))) : t();
381
+ }
382
+ get input() {
383
+ return this.renderRoot.querySelector(`#${this.uid}-input`);
384
+ }
385
+ get param() {
386
+ let e = this.queryParam;
387
+ return e === null ? "" : e.trim() || "filter";
388
+ }
389
+ urlQuery() {
390
+ let e = this.param;
391
+ return e ? f(location, e) : null;
392
+ }
393
+ render() {
394
+ let e = this.uid, t = this.label.trim() || "Filter", n = !this.resultsCount, r = this.emptyText;
395
+ return i`<label
396
+ class="label ${this.hideLabel ? "visually-hidden" : ""}"
397
+ part="label"
398
+ for="${e}-input"
399
+ >${t}</label
400
+ >
401
+ <div class="field" part="field">
402
+ <input
403
+ id="${e}-input"
404
+ class="input"
405
+ part="input"
406
+ type="search"
407
+ autocomplete="off"
408
+ autocapitalize="off"
409
+ spellcheck="false"
410
+ enterkeyhint="search"
411
+ placeholder=${this.placeholder || s}
412
+ .value=${this.value}
413
+ @input=${this.onInput}
414
+ @keydown=${this.onKeydown}
415
+ @change=${(e) => e.stopPropagation()}
416
+ /><button
417
+ type="button"
418
+ class="clear"
419
+ part="clear"
420
+ aria-label="Clear ${t}"
421
+ ?hidden=${!this.value}
422
+ @mousedown=${(e) => e.preventDefault()}
423
+ @click=${this.clear}
424
+ >
425
+ ${O}
426
+ </button>
427
+ </div>
428
+ ${n ? i`<p class="count" part="count">${this.countText}</p>` : s}
429
+ <p class="uvalib-message" part="empty" ?hidden=${!r}>${r}</p>
430
+ ${n ? i`<span class="visually-hidden" role="status" aria-live="polite" aria-atomic="true"
431
+ >${this.announcement}</span
432
+ >` : s}`;
433
+ }
434
+ };
435
+ // src/components/uvalib-list-filter/uvalib-list-filter.ts
436
+ o([e({
437
+ type: String,
438
+ attribute: "for"
439
+ })], F.prototype, "htmlFor", void 0), o([e({ type: String })], F.prototype, "selector", void 0), o([e({ type: String })], F.prototype, "label", void 0), o([e({
440
+ type: Boolean,
441
+ reflect: !0,
442
+ attribute: "hide-label"
443
+ })], F.prototype, "hideLabel", void 0), o([e({ type: String })], F.prototype, "placeholder", void 0), o([e({ type: String })], F.prototype, "noun", void 0), o([e({ type: String })], F.prototype, "singular", void 0), o([e({
444
+ type: String,
445
+ attribute: "results-count"
446
+ })], F.prototype, "resultsCount", void 0), o([e({
447
+ type: String,
448
+ attribute: "query-param"
449
+ })], F.prototype, "queryParam", void 0), o([e({ type: String })], F.prototype, "value", void 0), o([r()], F.prototype, "shownCount", void 0), o([r()], F.prototype, "totalCount", void 0), o([r()], F.prototype, "appliedQuery", void 0), o([r()], F.prototype, "announcement", void 0), a("uvalib-list-filter", F);
450
+
451
+ //# sourceMappingURL=uvalib-list-filter.js.map