@uvalib/web-components 1.7.0 → 1.8.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 (105) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +56 -12
  3. package/dist/base/states.d.ts +12 -0
  4. package/dist/base/states.js +33 -0
  5. package/dist/base/states.js.map +1 -0
  6. package/dist/base.css +15 -5
  7. package/dist/components/bento-box/BentoBox.js +1 -0
  8. package/dist/components/bento-box/BentoBox.js.map +1 -1
  9. package/dist/components/events-section/EventsSection.js +1 -0
  10. package/dist/components/events-section/EventsSection.js.map +1 -1
  11. package/dist/components/library-hours/hours-data.js +1 -1
  12. package/dist/components/library-hours/hours-data.js.map +1 -1
  13. package/dist/components/library-weekly-hours/LibraryWeeklyHours.js +1 -0
  14. package/dist/components/library-weekly-hours/LibraryWeeklyHours.js.map +1 -1
  15. package/dist/components/uvalib-card/UvalibCard.js +6 -0
  16. package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
  17. package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +27 -0
  18. package/dist/components/uvalib-combobox/UvalibCombobox.js +85 -1
  19. package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -1
  20. package/dist/components/uvalib-contents/UvalibContents.js +5 -0
  21. package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
  22. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +6 -0
  23. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +10 -0
  24. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -1
  25. package/dist/components/uvalib-image-regions/UvalibImageRegions.js +2 -0
  26. package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -1
  27. package/dist/components/uvalib-image-regions/regions.d.ts +6 -2
  28. package/dist/components/uvalib-image-regions/regions.js +6 -3
  29. package/dist/components/uvalib-image-regions/regions.js.map +1 -1
  30. package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +9 -2
  31. package/dist/components/uvalib-lightbox/UvalibLightbox.js +23 -3
  32. package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
  33. package/dist/components/uvalib-lightbox/compare.d.ts +30 -3
  34. package/dist/components/uvalib-lightbox/compare.js +98 -29
  35. package/dist/components/uvalib-lightbox/compare.js.map +1 -1
  36. package/dist/components/uvalib-map/UvalibMap.js +2 -2
  37. package/dist/components/uvalib-map/UvalibMap.js.map +1 -1
  38. package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -0
  39. package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
  40. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +3 -1
  41. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  42. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +3 -3
  43. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +16 -8
  44. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
  45. package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +4 -1
  46. package/dist/components/uvalib-tag-list/UvalibTagList.js +9 -2
  47. package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -1
  48. package/dist/custom-elements.json +1926 -1637
  49. package/dist/styles/message.js +4 -0
  50. package/dist/styles/message.js.map +1 -1
  51. package/dist/styles/result-list.js +25 -4
  52. package/dist/styles/result-list.js.map +1 -1
  53. package/dist/styles/results.js +17 -2
  54. package/dist/styles/results.js.map +1 -1
  55. package/dist-cdn/base.css +15 -5
  56. package/dist-cdn/bento-box.js +1 -0
  57. package/dist-cdn/bento-box.js.map +1 -1
  58. package/dist-cdn/chunks/{compare-DV6ltvsJ.js → compare-C0nhByn7.js} +66 -29
  59. package/dist-cdn/chunks/compare-C0nhByn7.js.map +1 -0
  60. package/dist-cdn/chunks/{hours-data-Bw6vkIw7.js → hours-data-gMu5uT7H.js} +2 -2
  61. package/dist-cdn/chunks/hours-data-gMu5uT7H.js.map +1 -0
  62. package/dist-cdn/chunks/{library-weekly-hours-CrV3TlP5.js → library-weekly-hours-BJgxAyah.js} +3 -2
  63. package/dist-cdn/chunks/library-weekly-hours-BJgxAyah.js.map +1 -0
  64. package/dist-cdn/chunks/{regions-B8ExwUGP.js → regions-B-rOwa-v.js} +15 -15
  65. package/dist-cdn/chunks/regions-B-rOwa-v.js.map +1 -0
  66. package/dist-cdn/chunks/states-DGXGzcte.js +17 -0
  67. package/dist-cdn/chunks/states-DGXGzcte.js.map +1 -0
  68. package/dist-cdn/custom-elements.json +1926 -1637
  69. package/dist-cdn/events-section.js +1 -0
  70. package/dist-cdn/events-section.js.map +1 -1
  71. package/dist-cdn/library-hours-setup.js +1 -1
  72. package/dist-cdn/library-weekly-hours.js +1 -1
  73. package/dist-cdn/manifest.json +1 -1
  74. package/dist-cdn/site-hours-section.js +1 -1
  75. package/dist-cdn/skills/uvalib-web-components/SKILL.md +5 -4
  76. package/dist-cdn/skills/uvalib-web-components/reference/components.md +33 -6
  77. package/dist-cdn/uvalib-card.js +6 -0
  78. package/dist-cdn/uvalib-card.js.map +1 -1
  79. package/dist-cdn/uvalib-combobox.js +107 -68
  80. package/dist-cdn/uvalib-combobox.js.map +1 -1
  81. package/dist-cdn/uvalib-contents.js +5 -0
  82. package/dist-cdn/uvalib-contents.js.map +1 -1
  83. package/dist-cdn/uvalib-filter-drawer.js +27 -25
  84. package/dist-cdn/uvalib-filter-drawer.js.map +1 -1
  85. package/dist-cdn/uvalib-image-regions.js +3 -1
  86. package/dist-cdn/uvalib-image-regions.js.map +1 -1
  87. package/dist-cdn/uvalib-lightbox.js +80 -69
  88. package/dist-cdn/uvalib-lightbox.js.map +1 -1
  89. package/dist-cdn/uvalib-map.js +2 -2
  90. package/dist-cdn/uvalib-map.js.map +1 -1
  91. package/dist-cdn/uvalib-metadata.js +3 -0
  92. package/dist-cdn/uvalib-metadata.js.map +1 -1
  93. package/dist-cdn/uvalib-pagefind-search.js +2 -1
  94. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  95. package/dist-cdn/uvalib-photo-grid.js +4 -5
  96. package/dist-cdn/uvalib-photo-grid.js.map +1 -1
  97. package/dist-cdn/uvalib-tag-list.js +21 -16
  98. package/dist-cdn/uvalib-tag-list.js.map +1 -1
  99. package/package.json +1 -1
  100. package/skills/uvalib-web-components/SKILL.md +5 -4
  101. package/skills/uvalib-web-components/reference/components.md +33 -6
  102. package/dist-cdn/chunks/compare-DV6ltvsJ.js.map +0 -1
  103. package/dist-cdn/chunks/hours-data-Bw6vkIw7.js.map +0 -1
  104. package/dist-cdn/chunks/library-weekly-hours-CrV3TlP5.js.map +0 -1
  105. package/dist-cdn/chunks/regions-B8ExwUGP.js.map +0 -1
@@ -2,9 +2,10 @@ import { a as e, f as t, i as n, l as r, m as i, n as a, o, p as s, r as c, t as
2
2
  import { a as u } from "./chunks/analytics-DTTihuBD.js";
3
3
  import { n as d, t as f } from "./chunks/inline-copy-BANQSMIR.js";
4
4
  import { n as p, r as m, t as h } from "./chunks/source-children-BHsDwCvL.js";
5
- import { t as g } from "./chunks/accessible-DJv7YOtS.js";
5
+ import { n as g, t as _ } from "./chunks/states-DGXGzcte.js";
6
+ import { t as v } from "./chunks/accessible-DJv7YOtS.js";
6
7
  // src/components/uvalib-tag-list/UvalibTagList.ts
7
- var _ = (e) => JSON.stringify(e, (e, t) => e === "nodes" ? void 0 : t), v = (e) => e?.trim() || void 0, y = (e) => `
8
+ var y = (e) => JSON.stringify(e, (e, t) => e === "nodes" ? void 0 : t), b = (e) => e?.trim() || void 0, x = (e) => `
8
9
  ${e} { display: block; }
9
10
  ${e} ul {
10
11
  display: flex;
@@ -36,11 +37,11 @@ var _ = (e) => JSON.stringify(e, (e, t) => e === "nodes" ? void 0 : t), v = (e)
36
37
  border: 0;
37
38
  }
38
39
  ${e}[hidden], ${e} [hidden] { display: none !important; }
39
- `, b = s(y(":host")), x = 0, S = class extends l {
40
+ `, S = s(x(":host")), C = 0, w = class extends l {
40
41
  static {
41
42
  this.styles = [
42
- g,
43
- b,
43
+ v,
44
+ S,
44
45
  t`
45
46
  :host {
46
47
  color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));
@@ -106,12 +107,12 @@ var _ = (e) => JSON.stringify(e, (e, t) => e === "nodes" ? void 0 : t), v = (e)
106
107
  ];
107
108
  }
108
109
  constructor() {
109
- super(), this.label = "", this.hideLabel = !1, this.trackLabel = !1, this.hrefTemplate = "", this.expanded = !1, this.childTags = [], this.uid = `uvalib-tag-list-${++x}`, this.warned = /* @__PURE__ */ new Set(), new h(this, () => this.lightDom, (e) => this.read(e));
110
+ super(), this.label = "", this.hideLabel = !1, this.trackLabel = !1, this.hrefTemplate = "", this.expanded = !1, this.childTags = [], this.uid = `uvalib-tag-list-${++C}`, this.warned = /* @__PURE__ */ new Set(), this.internals = _(this), new h(this, () => this.lightDom, (e) => this.read(e));
110
111
  }
111
112
  createRenderRoot() {
112
113
  let e = super.createRenderRoot();
113
114
  if (e instanceof ShadowRoot && this.noStyle) {
114
- let t = b.styleSheet;
115
+ let t = S.styleSheet;
115
116
  t && (e.adoptedStyleSheets = [t]);
116
117
  }
117
118
  return e;
@@ -119,7 +120,7 @@ var _ = (e) => JSON.stringify(e, (e, t) => e === "nodes" ? void 0 : t), v = (e)
119
120
  connectedCallback() {
120
121
  if (super.connectedCallback(), this.lightDom && this.noStyle) {
121
122
  let e = this.getRootNode();
122
- c(`${this.localName}::structure`, s(y(this.localName)), {
123
+ c(`${this.localName}::structure`, s(x(this.localName)), {
123
124
  root: e instanceof ShadowRoot || e instanceof Document ? e : void 0,
124
125
  scope: !1
125
126
  });
@@ -150,12 +151,12 @@ var _ = (e) => JSON.stringify(e, (e, t) => e === "nodes" ? void 0 : t), v = (e)
150
151
  let i = {
151
152
  label: e,
152
153
  ...d(r)
153
- }, a = r instanceof HTMLAnchorElement ? v(r.getAttribute("href")) : void 0;
154
+ }, a = r instanceof HTMLAnchorElement ? b(r.getAttribute("href")) : void 0;
154
155
  a !== void 0 && (i.href = a);
155
156
  let o = f(r.childNodes, this.ownerDocument);
156
157
  o.rich && (i.rich = o.key, i.nodes = o.nodes), t.push(i);
157
158
  }
158
- n && this.warnOnce("text", "ignoring tags with no text."), _(t) !== _(this.childTags) && (this.childTags = t);
159
+ n && this.warnOnce("text", "ignoring tags with no text."), y(t) !== y(this.childTags) && (this.childTags = t);
159
160
  }
160
161
  safe(e) {
161
162
  let t = m(e, this.ownerDocument.baseURI);
@@ -163,7 +164,7 @@ var _ = (e) => JSON.stringify(e, (e, t) => e === "nodes" ? void 0 : t), v = (e)
163
164
  }
164
165
  get tags() {
165
166
  let e = this.items ? this.items.filter((e) => p(e?.label)).map((e) => {
166
- let t = { label: p(e.label) }, n = v(e.href);
167
+ let t = { label: p(e.label) }, n = b(e.href);
167
168
  return n !== void 0 && (t.href = n), e.lang !== void 0 && (t.lang = e.lang), e.dir && (t.dir = e.dir), t;
168
169
  }) : this.childTags, t = this.hrefTemplate.trim();
169
170
  return e.map((e) => {
@@ -211,7 +212,11 @@ var _ = (e) => JSON.stringify(e, (e, t) => e === "nodes" ? void 0 : t), v = (e)
211
212
  ]);
212
213
  }
213
214
  updated(e) {
214
- super.updated(e), this.toggleAttribute("data-empty", !this.tags.length);
215
+ super.updated(e);
216
+ let t = this.tags;
217
+ this.toggleAttribute("data-empty", !t.length);
218
+ let n = this.max;
219
+ g(this.internals, "expanded", this.expanded && n > 0 && t.length > n);
215
220
  }
216
221
  renderTag(e, t) {
217
222
  let n = e.nodes ? e.nodes.map((e) => e.cloneNode(!0)) : e.label;
@@ -253,15 +258,15 @@ var _ = (e) => JSON.stringify(e, (e, t) => e === "nodes" ? void 0 : t), v = (e)
253
258
  }
254
259
  };
255
260
  // src/components/uvalib-tag-list/uvalib-tag-list.ts
256
- a([e({ type: String })], S.prototype, "label", void 0), a([e({
261
+ a([e({ type: String })], w.prototype, "label", void 0), a([e({
257
262
  type: Boolean,
258
263
  attribute: "hide-label"
259
- })], S.prototype, "hideLabel", void 0), a([e({
264
+ })], w.prototype, "hideLabel", void 0), a([e({
260
265
  type: Boolean,
261
266
  attribute: "track-label"
262
- })], S.prototype, "trackLabel", void 0), a([e({ type: Number })], S.prototype, "limit", void 0), a([e({
267
+ })], w.prototype, "trackLabel", void 0), a([e({ type: Number })], w.prototype, "limit", void 0), a([e({
263
268
  type: String,
264
269
  attribute: "href-template"
265
- })], S.prototype, "hrefTemplate", void 0), a([e({ attribute: !1 })], S.prototype, "items", void 0), a([n()], S.prototype, "expanded", void 0), a([n()], S.prototype, "childTags", void 0), i("uvalib-tag-list", S);
270
+ })], w.prototype, "hrefTemplate", void 0), a([e({ attribute: !1 })], w.prototype, "items", void 0), a([n()], w.prototype, "expanded", void 0), a([n()], w.prototype, "childTags", void 0), i("uvalib-tag-list", w);
266
271
 
267
272
  //# sourceMappingURL=uvalib-tag-list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uvalib-tag-list.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","langDir","inlineCopy","normalize","safeHref","SourceChildren","accessible","keyOf","tags","k","v","hrefOf","h","structuralRules","host","shadowStructure","instances","UvalibTagList","nodes","root","sheet","node","changed","key","message","invalid","label","tag","href","copy","ok","source","template","t","out","a","index","go","text","A","max","collapsible","labelId","listId","toggleText"],"sources":["../src/components/uvalib-tag-list/UvalibTagList.ts","../src/components/uvalib-tag-list/uvalib-tag-list.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { inlineCopy, langDir } from '../../base/inline-copy.js';\nimport { normalize, safeHref, SourceChildren } from '../../base/source-children.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** One tag: its visible text and, when it is a link, where it goes; `lang`/`dir` if they differ. */\nexport interface TagItem {\n label: string;\n href?: string;\n lang?: string;\n dir?: string;\n}\n\n/** A tag as read and drawn: `nodes` is a safe inline copy of a child's content, `rich` its key. */\ninterface Tag extends TagItem {\n rich?: string;\n nodes?: Node[];\n}\n\n/** Compare two reads, leaving out the copied nodes (their `rich` key stands for them). */\nconst keyOf = (tags: Tag[]) =>\n JSON.stringify(tags, (k, v: unknown) => (k === 'nodes' ? undefined : v));\n\n/** A blank href is no href (it would reload the page and skip `href-template`). */\nconst hrefOf = (h: string | null | undefined): string | undefined => {\n const t = h?.trim();\n return t ? t : undefined;\n};\n\n/**\n * Kept with `no-style`: the tags wrap in a row with gaps, no bullets, every link and the\n * toggle at least 24px with space around (WCAG 2.5.8), the hidden label stays hidden and\n * `[hidden]` hides. `host` is `:host` or the tag name.\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} ul {\n display: flex;\n flex-wrap: wrap;\n gap: 0.5rem;\n list-style: none;\n margin: 0;\n padding: 0;\n }\n ${host} li { display: flex; max-width: 100%; min-width: 0; }\n ${host} :where(a.tag, .toggle) {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n min-height: 24px;\n min-width: 24px;\n }\n ${host} :where(.toggle) { margin-top: 0.5rem; }\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\nlet instances = 0;\n\n/**\n * A labelled list of keywords or subjects that wraps: each tag a link (for example a search\n * for that term) or plain text. Link tags are outlined pills in the link colour; plain tags\n * are filled chips (the card chip's colours), so a link never looks like a label. Every tag\n * and the toggle are at least 2rem (34px) tall and wide, 0.5rem apart.\n *\n * Give the tags as children: `<a href>` for a link, any other element (`<span>`) for plain\n * text. A child's `lang` and `dir` are kept, and so is inline markup inside it (`em`, `cite`,\n * `abbr`, `bdi`, a `span lang`…), copied element by element (never parsed as HTML). Or set\n * `href-template` (with `{tag}`, replaced by the URL-encoded text) to make every tag without\n * its own href a link; a blank href counts as none. Apps can set the `items` property\n * (`{ label, href?, lang?, dir? }`) instead; it wins over the children. Children with no text\n * are skipped with one warning.\n *\n * `label` names the list (shown above it, or visually hidden with `hide-label`); without one\n * a console warning is logged. `limit` shows that many tags and a “Show all N” button\n * (`aria-expanded`, `aria-controls`), which reveals the rest in place and keeps focus.\n *\n * Analytics never sends a tag's text (record tags can be user-submitted or machine-made), and\n * by default not the label either, which a template may fill from a record: the name is the\n * list's place among the tag lists on the page, `list N`. Add `track-label` when the label is\n * fixed text the page author wrote (“Subjects”), to send it instead.\n *\n * @tagname uvalib-tag-list\n * @fires uvalib-analytics-event - For `<site-analytics>`: a primary-button click on a tag link, `['uvalib-tag-list', 'tag-click', '<name>', <n>]` (n from 1, the tag's place in the list), and the toggle, `['uvalib-tag-list', 'show-all'|'show-fewer', '<name>']`. The name is `list N` (N from 1, the list's place among the tag lists in its document or shadow root), or with `track-label` the list's `label`; never the tag text or URL. Bubbles and is composed.\n * @fires uvalib-tag-list-navigate - A plain click on a tag link: `detail` is `{ href, tag, index }` (index from 0). Cancel it (`preventDefault()`) to route in the app; the click's default is then prevented. Bubbles and is composed.\n * @cssprop [--uva-blue-alt-300=#BFE7F7] - Plain tag background (the card chip's).\n * @cssprop [--uva-blue-alt-dark=#005679] - Plain tag text.\n * @cssprop --uva-color-link - Dark-mode role token: link tag text (else `--uva-brand-blue`).\n * @cssprop --uva-color-control-border - Dark-mode role token: link tag outline (else `--uva-grey`).\n * @cssprop --uva-color-text - Dark-mode role token: the label (else `--uva-grey-darkest`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibTagList extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .label {\n display: block;\n margin-block-end: 0.5rem;\n font-weight: 600;\n }\n .tag {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n max-width: 100%;\n min-height: 2rem;\n min-width: 2rem;\n padding: 0.15rem 0.7rem;\n border: 1px solid transparent;\n border-radius: 999px;\n font-size: 0.875rem;\n line-height: 1.4;\n overflow-wrap: anywhere;\n }\n span.tag {\n background: var(--uva-blue-alt-300, #bfe7f7);\n color: var(--uva-blue-alt-dark, #005679);\n }\n a.tag {\n border-color: var(--uva-color-control-border, var(--uva-grey, #808080));\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n text-decoration: none;\n }\n a.tag:hover {\n border-color: currentColor;\n text-decoration: underline;\n }\n .toggle {\n min-height: 2rem;\n min-width: 2rem;\n padding: 0.15rem 0.35rem;\n border: 0;\n background: none;\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n font-size: 0.875rem;\n text-decoration: underline;\n cursor: pointer;\n }\n @media (forced-colors: active) {\n span.tag {\n border-color: CanvasText;\n }\n a.tag {\n border-color: LinkText;\n color: LinkText;\n }\n .toggle {\n color: ButtonText;\n }\n }\n `,\n ];\n\n /** The list's name: shown above the tags (and, with `track-label`, the analytics name). */\n @property({ type: String }) label = '';\n\n /** Hide the label visually; it still names the list. */\n @property({ type: Boolean, attribute: 'hide-label' }) hideLabel = false;\n\n /**\n * Send the label as the analytics name. Only for fixed text the page author wrote, never a\n * label filled from a record. Without it the name is `list N`.\n */\n @property({ type: Boolean, attribute: 'track-label' }) trackLabel = false;\n\n /** Show this many tags and a “Show all N” button. Zero or empty shows every tag. */\n @property({ type: Number }) limit?: number;\n\n /**\n * Href for tags without their own, with `{tag}` where the URL-encoded text goes, for\n * example `/search?q={tag}`. Empty: such tags are plain text.\n */\n @property({ type: String, attribute: 'href-template' }) hrefTemplate = '';\n\n /** The tags as data (`{ label, href?, lang?, dir? }`), for apps. Wins over the children while set. */\n @property({ attribute: false }) items?: TagItem[];\n\n /** Whether every tag is shown (after Show all). */\n @state() private expanded = false;\n /** The tags read from the children. */\n @state() private childTags: Tag[] = [];\n\n private readonly uid = `uvalib-tag-list-${++instances}`;\n private warned = new Set<string>();\n\n constructor() {\n super();\n // Light DOM: the children move to a hidden holder before every render, also when the\n // element is connected, moved or reconnected before its first update.\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 protected override firstUpdated(): void {\n if (!normalize(this.label))\n this.warnOnce('label', 'set label to name the list (for example “Subjects”).');\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('items') && this.items?.some((i) => !normalize(i?.label)))\n this.warnOnce('text', 'ignoring tags with no text.');\n }\n\n private warnOnce(key: string, message: string): void {\n if (this.warned.has(key)) return;\n this.warned.add(key);\n console.warn(`${this.localName}: ${message}`);\n }\n\n /** Read the tags from the source children. */\n private read(nodes: Node[]): void {\n const tags: Tag[] = [];\n let invalid = false;\n for (const n of nodes) {\n if (n.nodeType === Node.TEXT_NODE) {\n if (normalize(n.textContent)) invalid = true;\n continue;\n }\n if (!(n instanceof Element)) continue;\n const label = normalize(n.textContent);\n if (!label) {\n invalid = true;\n continue;\n }\n const tag: Tag = { label, ...langDir(n) };\n const href = n instanceof HTMLAnchorElement ? hrefOf(n.getAttribute('href')) : undefined;\n if (href !== undefined) tag.href = href;\n const copy = inlineCopy(n.childNodes, this.ownerDocument);\n if (copy.rich) {\n tag.rich = copy.key;\n tag.nodes = copy.nodes;\n }\n tags.push(tag);\n }\n if (invalid) this.warnOnce('text', 'ignoring tags with no text.');\n if (keyOf(tags) !== keyOf(this.childTags)) this.childTags = tags;\n }\n\n private safe(href: string): boolean {\n const ok = safeHref(href, this.ownerDocument.baseURI);\n if (!ok)\n this.warnOnce(\n 'href',\n 'showing a tag as text: its href is not http(s), mailto, tel or relative.',\n );\n return ok;\n }\n\n /** What is shown: `items` while set, else the children; hrefs from the template; unsafe ones dropped. */\n private get tags(): Tag[] {\n const source: Tag[] = this.items\n ? this.items\n .filter((i) => normalize(i?.label))\n .map((i) => {\n const t: Tag = { label: normalize(i.label) };\n const href = hrefOf(i.href);\n if (href !== undefined) t.href = href;\n if (i.lang !== undefined) t.lang = i.lang;\n if (i.dir) t.dir = i.dir;\n return t;\n })\n : this.childTags;\n const template = this.hrefTemplate.trim();\n return source.map((t) => {\n const href =\n t.href ??\n (template.includes('{tag}')\n ? template.replaceAll('{tag}', encodeURIComponent(t.label))\n : undefined);\n const out: Tag = { ...t };\n if (href !== undefined && this.safe(href)) out.href = href;\n else delete out.href;\n return out;\n });\n }\n\n /** The `limit`, when it hides anything: a positive whole number. */\n private get max(): number {\n const n = Math.trunc(this.limit ?? 0);\n return Number.isFinite(n) && n > 0 ? n : 0;\n }\n\n /** The analytics name: the label with `track-label`, else `list N` (this list's place in its root). */\n private get name(): string {\n const label = normalize(this.label);\n if (this.trackLabel && label) return label;\n const root = this.getRootNode() as Document | ShadowRoot;\n const lists = root.querySelectorAll ? [...root.querySelectorAll(this.localName)] : [];\n const i = lists.indexOf(this);\n return `list ${i < 0 ? 1 : i + 1}`;\n }\n\n private onClick(e: MouseEvent): void {\n const node = e.target instanceof Node ? e.target : null;\n const el = node instanceof Element ? node : node?.parentElement;\n const a = el?.closest('a[href]');\n if (!(a instanceof HTMLAnchorElement) || !this.renderRoot.contains(a)) return;\n if (e.defaultPrevented || e.button !== 0) return;\n const index = Number(a.dataset.index);\n trackEvent(this, ['uvalib-tag-list', 'tag-click', this.name, index + 1]);\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n const go = new CustomEvent('uvalib-tag-list-navigate', {\n detail: { href: a.getAttribute('href'), tag: normalize(a.textContent), index },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n private toggle(): void {\n this.expanded = !this.expanded;\n trackEvent(this, ['uvalib-tag-list', this.expanded ? 'show-all' : 'show-fewer', this.name]);\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.toggleAttribute('data-empty', !this.tags.length);\n }\n\n private renderTag(t: Tag, i: number) {\n const text = t.nodes ? t.nodes.map((n) => n.cloneNode(true)) : t.label;\n return t.href !== undefined\n ? html`<a\n class=\"tag\"\n href=${t.href}\n data-index=${i}\n lang=${t.lang ?? nothing}\n dir=${t.dir ?? nothing}\n >${text}</a\n >`\n : html`<span class=\"tag\" lang=${t.lang ?? nothing} dir=${t.dir ?? nothing}>${text}</span>`;\n }\n\n protected override render() {\n const tags = this.tags;\n const max = this.max;\n const collapsible = max > 0 && tags.length > max;\n const label = normalize(this.label);\n const labelId = `${this.uid}-label`;\n const listId = `${this.uid}-list`;\n const toggleText = this.expanded ? 'Show fewer' : `Show all ${tags.length}`;\n // One wrapper, always rendered.\n return html`<div class=\"tag-list\" ?hidden=${!tags.length}>\n ${\n label\n ? html`<span id=${labelId} class=${this.hideLabel ? 'label visually-hidden' : 'label'}\n >${label}</span\n >`\n : nothing\n }\n <ul\n role=\"list\"\n id=${listId}\n aria-labelledby=${label ? labelId : nothing}\n @click=${this.onClick}\n >\n ${tags.map(\n (t, i) =>\n html`<li role=\"listitem\" ?hidden=${collapsible && !this.expanded && i >= max}>\n ${this.renderTag(t, i)}\n </li>`,\n )}\n </ul>\n ${\n collapsible\n ? html`<button\n type=\"button\"\n class=\"toggle\"\n aria-expanded=${this.expanded ? 'true' : 'false'}\n aria-controls=${listId}\n @click=${this.toggle}\n >\n ${toggleText}${label ? html`<span class=\"visually-hidden\"> ${label}</span>` : nothing}\n </button>`\n : nothing\n }\n </div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibTagList } from './UvalibTagList.js';\n\ndefine('uvalib-tag-list', UvalibTagList);\n"],"mappings":";;;;;;AAwBA,IAAMqB,KAAS,MACb,KAAK,UAAUC,IAAO,GAAG,MAAgBC,MAAM,UAAU,KAAA,IAAYC,CAAE,GAGnEC,KAAU,MACJC,GAAG,KAAK,KACH,KAAA,GAQXC,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;;;;;;;;;;;IAWLA,EAAK,YAAYA,EAAK;GAEpBC,IAAkB7B,EAAU2B,EAAgB,OAAO,CAAC,GAEtDG,IAAY,GAmCHC,IAAb,cAAmClB,EAAc;;EAC/B,KAAA,SAAA;GACdO;GACAS;GACA,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8DL;;CAkCA,cAAc;EAIZ,AAHA,MAAM,GAhC4B,KAAA,QAAA,IAG8B,KAAA,YAAA,IAME,KAAA,aAAA,IASG,KAAA,eAAA,IAM3C,KAAA,WAAA,IAEQ,KAAA,YAAA,CAAC,GAEd,KAAA,MAAA,mBAAmB,EAAEC,KAC3B,KAAA,yBAAA,IAAI,IAAY,GAM/B,IAAIX,EACF,YACM,KAAK,WACV,MAAU,KAAK,KAAKa,CAAK,CAC5B;CACF;CAEA,mBAAsE;EACpE,IAAMC,IAAO,MAAM,iBAAiB;EACpC,IAAIA,aAAgB,cAAc,KAAK,SAAS;GAC9C,IAAMC,IAAQL,EAAgB;GAC9B,AAAIK,MAAO,EAAK,qBAAqB,CAACA,CAAK;EAC7C;EACA,OAAOD;CACT;CAEA,oBAAmC;EAEjC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,GAMnD7B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAS,WAAW;AAAc,CAAC,CAAA,GAAA4B,EAAA,WAAA,cAAA,KAAA,CAAA,GAGpD7B,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA4B,EAAA,WAAA,SAAA,KAAA,CAAA,GAMzB7B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAgB,CAAC,CAAA,GAAA4B,EAAA,WAAA,gBAAA,KAAA,CAAA,GAGrD7B,EAAA,CAAAC,EAAS,EAAE,WAAW,GAAM,CAAC,CAAA,GAAA4B,EAAA,WAAA,SAAA,KAAA,CAAA,GAG7B7B,EAAA,CAAAE,EAAM,CAAA,GAAA2B,EAAA,WAAA,YAAA,KAAA,CAAA,GAEN7B,EAAA,CAAAE,EAAM,CAAA,GAAA2B,EAAA,WAAA,aAAA,KAAA,CAAA,GCxMTtB,EAAO,mBAAmBsB,CAAa"}
1
+ {"version":3,"file":"uvalib-tag-list.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","langDir","inlineCopy","normalize","safeHref","SourceChildren","setState","attachStateInternals","accessible","keyOf","tags","k","v","hrefOf","h","structuralRules","host","shadowStructure","instances","UvalibTagList","nodes","root","sheet","node","changed","key","message","invalid","label","tag","href","copy","ok","source","template","t","out","a","index","go","max","text","A","collapsible","labelId","listId","toggleText"],"sources":["../src/components/uvalib-tag-list/UvalibTagList.ts","../src/components/uvalib-tag-list/uvalib-tag-list.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { inlineCopy, langDir } from '../../base/inline-copy.js';\nimport { normalize, safeHref, SourceChildren } from '../../base/source-children.js';\nimport { attachStateInternals, setState } from '../../base/states.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** One tag: its visible text and, when it is a link, where it goes; `lang`/`dir` if they differ. */\nexport interface TagItem {\n label: string;\n href?: string;\n lang?: string;\n dir?: string;\n}\n\n/** A tag as read and drawn: `nodes` is a safe inline copy of a child's content, `rich` its key. */\ninterface Tag extends TagItem {\n rich?: string;\n nodes?: Node[];\n}\n\n/** Compare two reads, leaving out the copied nodes (their `rich` key stands for them). */\nconst keyOf = (tags: Tag[]) =>\n JSON.stringify(tags, (k, v: unknown) => (k === 'nodes' ? undefined : v));\n\n/** A blank href is no href (it would reload the page and skip `href-template`). */\nconst hrefOf = (h: string | null | undefined): string | undefined => {\n const t = h?.trim();\n return t ? t : undefined;\n};\n\n/**\n * Kept with `no-style`: the tags wrap in a row with gaps, no bullets, every link and the\n * toggle at least 24px with space around (WCAG 2.5.8), the hidden label stays hidden and\n * `[hidden]` hides. `host` is `:host` or the tag name.\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} ul {\n display: flex;\n flex-wrap: wrap;\n gap: 0.5rem;\n list-style: none;\n margin: 0;\n padding: 0;\n }\n ${host} li { display: flex; max-width: 100%; min-width: 0; }\n ${host} :where(a.tag, .toggle) {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n min-height: 24px;\n min-width: 24px;\n }\n ${host} :where(.toggle) { margin-top: 0.5rem; }\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\nlet instances = 0;\n\n/**\n * A labelled list of keywords or subjects that wraps: each tag a link (for example a search\n * for that term) or plain text. Link tags are outlined pills in the link colour; plain tags\n * are filled chips (the card chip's colours), so a link never looks like a label. Every tag\n * and the toggle are at least 2rem (34px) tall and wide, 0.5rem apart.\n *\n * Give the tags as children: `<a href>` for a link, any other element (`<span>`) for plain\n * text. A child's `lang` and `dir` are kept, and so is inline markup inside it (`em`, `cite`,\n * `abbr`, `bdi`, a `span lang`…), copied element by element (never parsed as HTML). Or set\n * `href-template` (with `{tag}`, replaced by the URL-encoded text) to make every tag without\n * its own href a link; a blank href counts as none. Apps can set the `items` property\n * (`{ label, href?, lang?, dir? }`) instead; it wins over the children. Children with no text\n * are skipped with one warning.\n *\n * `label` names the list (shown above it, or visually hidden with `hide-label`); without one\n * a console warning is logged. `limit` shows that many tags and a “Show all N” button\n * (`aria-expanded`, `aria-controls`), which reveals the rest in place and keeps focus. Pages\n * can style the list while every tag is shown with `:state(expanded)`.\n *\n * Analytics never sends a tag's text (record tags can be user-submitted or machine-made), and\n * by default not the label either, which a template may fill from a record: the name is the\n * list's place among the tag lists on the page, `list N`. Add `track-label` when the label is\n * fixed text the page author wrote (“Subjects”), to send it instead.\n *\n * @tagname uvalib-tag-list\n * @fires uvalib-analytics-event - For `<site-analytics>`: a primary-button click on a tag link, `['uvalib-tag-list', 'tag-click', '<name>', <n>]` (n from 1, the tag's place in the list), and the toggle, `['uvalib-tag-list', 'show-all'|'show-fewer', '<name>']`. The name is `list N` (N from 1, the list's place among the tag lists in its document or shadow root), or with `track-label` the list's `label`; never the tag text or URL. Bubbles and is composed.\n * @fires uvalib-tag-list-navigate - A plain click on a tag link: `detail` is `{ href, tag, index }` (index from 0). Cancel it (`preventDefault()`) to route in the app; the click's default is then prevented. Bubbles and is composed.\n * @cssstate expanded - Show all was pressed: every tag is shown (the toggle's `aria-expanded=\"true\"`).\n * @cssprop [--uva-blue-alt-300=#BFE7F7] - Plain tag background (the card chip's).\n * @cssprop [--uva-blue-alt-dark=#005679] - Plain tag text.\n * @cssprop --uva-color-link - Dark-mode role token: link tag text (else `--uva-brand-blue`).\n * @cssprop --uva-color-control-border - Dark-mode role token: link tag outline (else `--uva-grey`).\n * @cssprop --uva-color-text - Dark-mode role token: the label (else `--uva-grey-darkest`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibTagList extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .label {\n display: block;\n margin-block-end: 0.5rem;\n font-weight: 600;\n }\n .tag {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n max-width: 100%;\n min-height: 2rem;\n min-width: 2rem;\n padding: 0.15rem 0.7rem;\n border: 1px solid transparent;\n border-radius: 999px;\n font-size: 0.875rem;\n line-height: 1.4;\n overflow-wrap: anywhere;\n }\n span.tag {\n background: var(--uva-blue-alt-300, #bfe7f7);\n color: var(--uva-blue-alt-dark, #005679);\n }\n a.tag {\n border-color: var(--uva-color-control-border, var(--uva-grey, #808080));\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n text-decoration: none;\n }\n a.tag:hover {\n border-color: currentColor;\n text-decoration: underline;\n }\n .toggle {\n min-height: 2rem;\n min-width: 2rem;\n padding: 0.15rem 0.35rem;\n border: 0;\n background: none;\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n font-size: 0.875rem;\n text-decoration: underline;\n cursor: pointer;\n }\n @media (forced-colors: active) {\n span.tag {\n border-color: CanvasText;\n }\n a.tag {\n border-color: LinkText;\n color: LinkText;\n }\n .toggle {\n color: ButtonText;\n }\n }\n `,\n ];\n\n /** The list's name: shown above the tags (and, with `track-label`, the analytics name). */\n @property({ type: String }) label = '';\n\n /** Hide the label visually; it still names the list. */\n @property({ type: Boolean, attribute: 'hide-label' }) hideLabel = false;\n\n /**\n * Send the label as the analytics name. Only for fixed text the page author wrote, never a\n * label filled from a record. Without it the name is `list N`.\n */\n @property({ type: Boolean, attribute: 'track-label' }) trackLabel = false;\n\n /** Show this many tags and a “Show all N” button. Zero or empty shows every tag. */\n @property({ type: Number }) limit?: number;\n\n /**\n * Href for tags without their own, with `{tag}` where the URL-encoded text goes, for\n * example `/search?q={tag}`. Empty: such tags are plain text.\n */\n @property({ type: String, attribute: 'href-template' }) hrefTemplate = '';\n\n /** The tags as data (`{ label, href?, lang?, dir? }`), for apps. Wins over the children while set. */\n @property({ attribute: false }) items?: TagItem[];\n\n /** Whether every tag is shown (after Show all). */\n @state() private expanded = false;\n /** The tags read from the children. */\n @state() private childTags: Tag[] = [];\n\n private readonly uid = `uvalib-tag-list-${++instances}`;\n private warned = new Set<string>();\n private readonly internals = attachStateInternals(this);\n\n constructor() {\n super();\n // Light DOM: the children move to a hidden holder before every render, also when the\n // element is connected, moved or reconnected before its first update.\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 protected override firstUpdated(): void {\n if (!normalize(this.label))\n this.warnOnce('label', 'set label to name the list (for example “Subjects”).');\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('items') && this.items?.some((i) => !normalize(i?.label)))\n this.warnOnce('text', 'ignoring tags with no text.');\n }\n\n private warnOnce(key: string, message: string): void {\n if (this.warned.has(key)) return;\n this.warned.add(key);\n console.warn(`${this.localName}: ${message}`);\n }\n\n /** Read the tags from the source children. */\n private read(nodes: Node[]): void {\n const tags: Tag[] = [];\n let invalid = false;\n for (const n of nodes) {\n if (n.nodeType === Node.TEXT_NODE) {\n if (normalize(n.textContent)) invalid = true;\n continue;\n }\n if (!(n instanceof Element)) continue;\n const label = normalize(n.textContent);\n if (!label) {\n invalid = true;\n continue;\n }\n const tag: Tag = { label, ...langDir(n) };\n const href = n instanceof HTMLAnchorElement ? hrefOf(n.getAttribute('href')) : undefined;\n if (href !== undefined) tag.href = href;\n const copy = inlineCopy(n.childNodes, this.ownerDocument);\n if (copy.rich) {\n tag.rich = copy.key;\n tag.nodes = copy.nodes;\n }\n tags.push(tag);\n }\n if (invalid) this.warnOnce('text', 'ignoring tags with no text.');\n if (keyOf(tags) !== keyOf(this.childTags)) this.childTags = tags;\n }\n\n private safe(href: string): boolean {\n const ok = safeHref(href, this.ownerDocument.baseURI);\n if (!ok)\n this.warnOnce(\n 'href',\n 'showing a tag as text: its href is not http(s), mailto, tel or relative.',\n );\n return ok;\n }\n\n /** What is shown: `items` while set, else the children; hrefs from the template; unsafe ones dropped. */\n private get tags(): Tag[] {\n const source: Tag[] = this.items\n ? this.items\n .filter((i) => normalize(i?.label))\n .map((i) => {\n const t: Tag = { label: normalize(i.label) };\n const href = hrefOf(i.href);\n if (href !== undefined) t.href = href;\n if (i.lang !== undefined) t.lang = i.lang;\n if (i.dir) t.dir = i.dir;\n return t;\n })\n : this.childTags;\n const template = this.hrefTemplate.trim();\n return source.map((t) => {\n const href =\n t.href ??\n (template.includes('{tag}')\n ? template.replaceAll('{tag}', encodeURIComponent(t.label))\n : undefined);\n const out: Tag = { ...t };\n if (href !== undefined && this.safe(href)) out.href = href;\n else delete out.href;\n return out;\n });\n }\n\n /** The `limit`, when it hides anything: a positive whole number. */\n private get max(): number {\n const n = Math.trunc(this.limit ?? 0);\n return Number.isFinite(n) && n > 0 ? n : 0;\n }\n\n /** The analytics name: the label with `track-label`, else `list N` (this list's place in its root). */\n private get name(): string {\n const label = normalize(this.label);\n if (this.trackLabel && label) return label;\n const root = this.getRootNode() as Document | ShadowRoot;\n const lists = root.querySelectorAll ? [...root.querySelectorAll(this.localName)] : [];\n const i = lists.indexOf(this);\n return `list ${i < 0 ? 1 : i + 1}`;\n }\n\n private onClick(e: MouseEvent): void {\n const node = e.target instanceof Node ? e.target : null;\n const el = node instanceof Element ? node : node?.parentElement;\n const a = el?.closest('a[href]');\n if (!(a instanceof HTMLAnchorElement) || !this.renderRoot.contains(a)) return;\n if (e.defaultPrevented || e.button !== 0) return;\n const index = Number(a.dataset.index);\n trackEvent(this, ['uvalib-tag-list', 'tag-click', this.name, index + 1]);\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n const go = new CustomEvent('uvalib-tag-list-navigate', {\n detail: { href: a.getAttribute('href'), tag: normalize(a.textContent), index },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n private toggle(): void {\n this.expanded = !this.expanded;\n trackEvent(this, ['uvalib-tag-list', this.expanded ? 'show-all' : 'show-fewer', this.name]);\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n const tags = this.tags;\n this.toggleAttribute('data-empty', !tags.length);\n const max = this.max;\n setState(this.internals, 'expanded', this.expanded && max > 0 && tags.length > max);\n }\n\n private renderTag(t: Tag, i: number) {\n const text = t.nodes ? t.nodes.map((n) => n.cloneNode(true)) : t.label;\n return t.href !== undefined\n ? html`<a\n class=\"tag\"\n href=${t.href}\n data-index=${i}\n lang=${t.lang ?? nothing}\n dir=${t.dir ?? nothing}\n >${text}</a\n >`\n : html`<span class=\"tag\" lang=${t.lang ?? nothing} dir=${t.dir ?? nothing}>${text}</span>`;\n }\n\n protected override render() {\n const tags = this.tags;\n const max = this.max;\n const collapsible = max > 0 && tags.length > max;\n const label = normalize(this.label);\n const labelId = `${this.uid}-label`;\n const listId = `${this.uid}-list`;\n const toggleText = this.expanded ? 'Show fewer' : `Show all ${tags.length}`;\n // One wrapper, always rendered.\n return html`<div class=\"tag-list\" ?hidden=${!tags.length}>\n ${\n label\n ? html`<span id=${labelId} class=${this.hideLabel ? 'label visually-hidden' : 'label'}\n >${label}</span\n >`\n : nothing\n }\n <ul\n role=\"list\"\n id=${listId}\n aria-labelledby=${label ? labelId : nothing}\n @click=${this.onClick}\n >\n ${tags.map(\n (t, i) =>\n html`<li role=\"listitem\" ?hidden=${collapsible && !this.expanded && i >= max}>\n ${this.renderTag(t, i)}\n </li>`,\n )}\n </ul>\n ${\n collapsible\n ? html`<button\n type=\"button\"\n class=\"toggle\"\n aria-expanded=${this.expanded ? 'true' : 'false'}\n aria-controls=${listId}\n @click=${this.toggle}\n >\n ${toggleText}${label ? html`<span class=\"visually-hidden\"> ${label}</span>` : nothing}\n </button>`\n : nothing\n }\n </div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibTagList } from './UvalibTagList.js';\n\ndefine('uvalib-tag-list', UvalibTagList);\n"],"mappings":";;;;;;;AAyBA,IAAMuB,KAAS,MACb,KAAK,UAAUC,IAAO,GAAG,MAAgBC,MAAM,UAAU,KAAA,IAAYC,CAAE,GAGnEC,KAAU,MACJC,GAAG,KAAK,KACH,KAAA,GAQXC,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;;;;;;;;;;;IAWLA,EAAK,YAAYA,EAAK;GAEpBC,IAAkB/B,EAAU6B,EAAgB,OAAO,CAAC,GAEtDG,IAAY,GAqCHC,IAAb,cAAmCpB,EAAc;;EAC/B,KAAA,SAAA;GACdS;GACAS;GACA,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8DL;;CAmCA,cAAc;EAIZ,AAHA,MAAM,GAjC4B,KAAA,QAAA,IAG8B,KAAA,YAAA,IAME,KAAA,aAAA,IASG,KAAA,eAAA,IAM3C,KAAA,WAAA,IAEQ,KAAA,YAAA,CAAC,GAEd,KAAA,MAAA,mBAAmB,EAAEC,KAC3B,KAAA,yBAAA,IAAI,IAAY,GACJ,KAAA,YAAAX,EAAqB,I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C,EAAE;kBAE7B,EAAE;;QAGFQ,IACI,CAAI;;;8BAGc,KAAK,WAAW,SAAS,QAAQ;8BACjCE,EAAO;uBACd,KAAK,OAAO;;gBAEnBC,IAAalB,IAAQ,CAAI,kCAAkCA,EAAM,WAAWzC,EAAQ;yBAExFA,EACL;;CAEL;AACF;;AAhQGC,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA8B,EAAA,WAAA,SAAA,KAAA,CAAA,GAGzB/B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAS,WAAW;AAAa,CAAC,CAAA,GAAA8B,EAAA,WAAA,aAAA,KAAA,CAAA,GAMnD/B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAS,WAAW;AAAc,CAAC,CAAA,GAAA8B,EAAA,WAAA,cAAA,KAAA,CAAA,GAGpD/B,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA8B,EAAA,WAAA,SAAA,KAAA,CAAA,GAMzB/B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAgB,CAAC,CAAA,GAAA8B,EAAA,WAAA,gBAAA,KAAA,CAAA,GAGrD/B,EAAA,CAAAC,EAAS,EAAE,WAAW,GAAM,CAAC,CAAA,GAAA8B,EAAA,WAAA,SAAA,KAAA,CAAA,GAG7B/B,EAAA,CAAAE,EAAM,CAAA,GAAA6B,EAAA,WAAA,YAAA,KAAA,CAAA,GAEN/B,EAAA,CAAAE,EAAM,CAAA,GAAA6B,EAAA,WAAA,aAAA,KAAA,CAAA,GC3MTxB,EAAO,mBAAmBwB,CAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uvalib/web-components",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "UVA Library reusable web components",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -76,6 +76,7 @@ Theme only through the documented surface, never by reaching into internals:
76
76
 
77
77
  - Inherited `--uva-*` custom properties (colors such as `--uva-brand-blue`, `--uva-brand-orange`; `--uva-font-family`, `--uva-font-size-base`). Set them on `:root` or an ancestor of `<site-page>`. The full set is in `tokens.css`; per-component ones are in reference/components.md. Prefer the library's values; override only with a stated reason.
78
78
  - `::part()` in shadow mode. On a page, use `site-page::part(header)`, `site-page::part(footer)` and `site-page::part(main)` (`<site-page>` re-exports the header and footer parts; `site-header::part(header)` cannot reach through its shadow root). For a standalone `<site-header>` or `<site-footer>` use `site-header::part(header)` / `site-footer::part(footer)`. In light mode there are no shadow parts; style the elements with ordinary selectors.
79
+ - Custom states for runtime state, in shadow and light mode: `uvalib-combobox:state(open)`, `:state(invalid)`, `:state(loading)`; `uvalib-filter-drawer:state(modal)` (phone layout), `:state(open)`; `uvalib-lightbox:state(open)`; `uvalib-tag-list:state(expanded)`. Style them; never add or watch attributes for that state (there are none) or set it yourself (a page cannot). Browsers without custom states just never match.
79
80
  - Never pierce shadow roots with JS, depend on internal class names, or use `!important` to fight the chrome.
80
81
 
81
82
  ### Dark mode (opt-in)
@@ -594,10 +595,10 @@ A static site (11ty, Jekyll, a generated collection) that searches with [Pagefin
594
595
  For a results list of your own (a collection, a Virgo-like listing, a photo archive), use these instead of hand-made pills, counts and spinners. Classes are in `base.css`; the two elements load from `uvalib-tag-list.js` and `uvalib-results-count.js`.
595
596
 
596
597
  - Badges: `.uvalib-badge` (neutral) with `--category` (the card chip), `--count` (on media, inside `.uvalib-media`; several in `.uvalib-media__badges`), `--status` plus `--success` / `--warning` / `--danger` / `--info`, `--new`, and `--body` for body size. A status badge always says its state in words; an icon in it gets `aria-hidden="true"`. Inside `<uvalib-card>` use its `badge` and `chip` slots instead.
597
- - Toolbar: `.uvalib-toolbar` around `.uvalib-toolbar__field` (label over control; `--grow` takes the spare width), `.uvalib-toolbar__group` (`role="group"` with an `aria-label`, `.uvalib-button` toggles with `aria-pressed`) and `.uvalib-toolbar__summary`. It stacks on phones.
598
+ - Toolbar: `.uvalib-toolbar` around `.uvalib-toolbar__field` (label over control; `--grow` takes the spare width), `.uvalib-toolbar__group` (`role="group"` with an `aria-label`, `.uvalib-button` toggles with `aria-pressed`) and `.uvalib-toolbar__summary`. It stacks when it is itself 30em wide or less (a phone, a sidebar, a drawer): toolbar, result list and photo grid follow their own width (CSS size containers), so give one a width in a shrink-to-fit box.
598
599
  - `<uvalib-results-count shown total noun singular>`: the visible “Showing 48 of 3,694 shoots”, announced politely once it settles (1 s); never the first render, but the first count after an empty one (data loading) is. Leave `shown`/`total` unset while loading. Set `shown` and `total` after every filter change; do not add your own live region for the count. Not beside `<bento-box>` or `<uvalib-pagefind-search>`, which announce their own.
599
600
  - `<uvalib-tag-list label="Subjects" track-label limit="8" href-template="/search?q={tag}">` with `<a href>` or `<span>` children (or `items`): links are outlined pills, plain tags filled chips; a child's `lang`/`dir` and inline markup are kept; `limit` adds “Show all N”. Always set `label` (`hide-label` hides it visually). It reports tag clicks as `list N` and the tag's position, never the tag text; add `track-label` only when the label is fixed text you wrote, never one filled from a record.
600
- - Long result sets (hundreds or thousands of rows): `<ul class="uvalib-result-list">` of `<li class="uvalib-result">` rows holding `__meta` (badges, date), `__title` (the row's one link), `__snippet` (search terms in `<mark>`, drawn bold on `--uva-color-highlight`) and `__actions` (secondary buttons, each with a unique visually hidden name). Plain HTML, never a `<uvalib-card>` per row; rows skip rendering off screen (`content-visibility: auto`). A heading and a list per group for date order.
601
+ - Long result sets (hundreds or thousands of rows): `<ul class="uvalib-result-list">` of `<li class="uvalib-result">` rows holding `__meta` (badges, date), `__title` (the row's one link), `__snippet` (search terms in `<mark>`, drawn bold on `--uva-color-highlight`) and `__actions` (secondary buttons, each with a unique visually hidden name). Plain HTML, never a `<uvalib-card>` per row; rows skip rendering off screen (`content-visibility: auto`); the actions wrap below when the list itself is 40em or narrower. A heading and a list per group for date order.
601
602
  - No results: `.uvalib-empty-state` (decorative `__icon`, a heading, a sentence, one action). Loading: `.uvalib-skeleton` (give it a height, or `--media` for 3:2) and `.uvalib-skeleton-text` (one line), sized like what replaces them, inside an `aria-hidden="true"` container, with `aria-busy="true"` on the region while it loads.
602
603
 
603
604
  ```html snippet
@@ -723,8 +724,8 @@ Use these instead of a hand-built gallery or a carousel. There is no autoplay.
723
724
  - From the page: `open(idOrIndex)` (false if unknown) and `close({ focus })` (after deleting the open item; focus your heading); `uvalib-lightbox-open` (`{ id, index, restored }`) and `uvalib-lightbox-close` (`{ id, index, reason }`) report both. Never click the dialog's own Close.
724
725
  - `<uvalib-image-regions>` from `uvalib-image-regions.js`: numbered outlines on an image (people, objects, inscriptions) with a list of the same regions beside it. Write the page's own `<img width height alt>` and `<ol>` inside, each `<li data-xywh="percent:x,y,w,h">` (or pixels of the natural size, `160,120,320,240`; `image-width`/`image-height` for a IIIF derivative) holding the region's link and your own action buttons, which stay yours; or set `items` (`{ label, x, y, w, h, unit?, href?, description? }[]`). The list is the accessible route: the outlines are `aria-hidden`, not tab stops, and never the only place a name or action is; hovering or focusing an entry highlights its outline (thicker double outline and label) and back, and clicking an outline focuses its entry. `label` names the list. Listen for `uvalib-image-regions-activate` (an outline clicked, before its entry takes focus; `detail: { index, item, entry }`, `entry` the page's own `<li>`; cancelable, so the page can focus its own control in the entry, such as a "Who is this?" field) and `highlight`; never read the shadow DOM's outlines for it. Do not hand-build absolutely positioned outlines. It reports outline clicks itself (the list's label and the number, never a region's label).
725
726
  - Regions in the viewer: `data-regions` on a lightbox link (a JSON array, or `percent:10,20,30,40 Person 1; percent:55,15,20,30 Sign`), or the lightbox's `regions` callback (`({ element, id, href, index }) => regions`). The open image then shows the outlines, their list and a "Show regions" toggle; `regions-label` names the list. For your own buttons in each entry, `data-regions-list="<id>"` (or the `regionsList` callback) names a hidden `<ol>` of `<li data-xywh>` in the page: it is lent to the viewer (same nodes, your listeners and CSS keep working) and put back on close; give each action a unique name ("Confirm Tim Kaine"). In React, create that `<ol>` (and a details element) outside React and make it the `createPortal` target for the entries, never render it inside a portal (README "React and other frameworks").
726
- - Versions in the viewer: `data-versions='[{"label":"Original"},{"label":"AI colorization","href":"color.jpg","note":"The colours are an AI model’s guess."}]'` on a lightbox link (first entry = the link's image; or the `versions` callback) compares them over the photo, the comparison loaded on first use: Switch (default), Reveal (`compare="wipe"`, a divider: click the photo or the slider) or Fade; label AI versions as such and give them a `note`; a version with a different framing (AI-expanded frame, whole plate, crop) gives `"frame": "percent:x,y,w,h"` (the original's box in it; pixels need its `width`/`height`) and is drawn at the original's scale around it; `version-param` (with `url-param`) keeps `?version=wipe:40`; `uvalib-lightbox-version` reports changes.
727
- - `<uvalib-photo-grid>` from `uvalib-photo-grid.js`: justified rows. Each direct `<a href>` or `<button>` is one photo and stays a real control. The row is about 220px, and 140px at 767px and below, unless `row-height` is set (a bare number is pixels). Give each image `width` and `height` so the row does not jump when it loads. An image with no visible text gets a caption from its alt, and a repeated alt is cleared (the original is kept for a lightbox). A different alt is kept. Do not set an `aria-label` that differs from the visible text; the grid will not add a caption beside one. Generated "Photo N" captions renumber when the photos change order. A `<span slot="badge">` inside the item, or `data-badge` on it (“seq”, “3 photos”), is drawn over the thumbnail and stays in the accessible name; an existing `aria-label` gains the badge text. A grid inside a lightbox opens the viewer. The grid reports no analytics.
727
+ - Versions in the viewer: `data-versions='[{"label":"Original"},{"label":"AI colorization","href":"color.jpg","note":"The colours are an AI model’s guess."}]'` on a lightbox link (first entry = the link's image; or the `versions` callback) compares them over the photo, the comparison loaded on first use: Switch (default), Reveal (`compare="wipe"`, a divider: click the photo or the slider) or Fade; label AI versions as such and give them a `note`; a version with a different framing (AI-expanded frame, whole plate, crop) gives `"frame": "percent:x,y,w,h"` (the original's box in it; pixels need its `width`/`height`) and is drawn at the original's scale around it (a crop's frame goes past it: `percent:-25,-25,150,150`); `data-version="1"` (the `version-param` format) opens a link on that version, the original still first; `version-param` (with `url-param`) keeps `?version=wipe:40`; `uvalib-lightbox-version` reports changes.
728
+ - `<uvalib-photo-grid>` from `uvalib-photo-grid.js`: justified rows. Each direct `<a href>` or `<button>` is one photo and stays a real control. The row is about 220px, and 140px when the grid itself is under 48rem (also in a sidebar), unless `row-height` is set (a bare number is pixels). Give each image `width` and `height` so the row does not jump when it loads. An image with no visible text gets a caption from its alt, and a repeated alt is cleared (the original is kept for a lightbox). A different alt is kept. Do not set an `aria-label` that differs from the visible text; the grid will not add a caption beside one. Generated "Photo N" captions renumber when the photos change order. A `<span slot="badge">` inside the item, or `data-badge` on it (“seq”, “3 photos”), is drawn over the thumbnail and stays in the accessible name; an existing `aria-label` gains the badge text. A grid inside a lightbox opens the viewer. The grid reports no analytics.
728
729
 
729
730
  ```html snippet
730
731
  <!doctype html>
@@ -775,7 +775,7 @@ A row of chips: a segmented control or single-select filter (`mode="single"`), f
775
775
 
776
776
  ## `<uvalib-combobox>`
777
777
 
778
- An editable text field that suggests values as you type, from a local list or a URL: a person, place or subject picker. It follows the WAI-ARIA APG “Editable Combobox With List Autocomplete”: a real `<input role="combobox">` and a `role="listbox"` popup under it. Suggestions come from the `items` property (`{ value, label?, description?, disabled? }` objects, or strings), from `<option>` children (directly or inside a `<datalist>`; the `label` attribute or text is the label, `data-description` the second line), or from `src`, a URL template with `{q}` (fetched 250 ms after the last keystroke once the text has `min-length` characters, default 1; a newer keystroke aborts the older request; the response is a JSON array of the same shape, or anything `transform(data, query)` turns into one). `items` wins over the children while set. Local suggestions match anywhere in the label, ignoring case and accents, those starting with the text first, then those with a word starting with it; at most `max-results` (default 50, 0 for all) are shown, which keeps a list of 16,000 people fast. The matched text is bold and underlined in a `<mark>`. Keys: Down opens the list on the first suggestion and moves (wrapping), Up opens on the last, Alt+Down opens without moving, Alt+Up closes, Enter chooses the active suggestion (and then does not submit the form; with none active, Enter submits as in any field), Escape closes the list and a second Escape clears the field, Home, End, Left and Right move the caret, and Tab leaves without choosing. A real clear button (“Clear <label>”, 44px, shown only with text) empties the field and returns focus to it. Free text is allowed: `value` is whatever is in the field, and `selected` the chosen suggestion (or null); typing after choosing clears it, and leaving the field with text that is exactly one suggestion's label chooses it. `must-choose` makes any other text invalid (“Choose one of the suggestions.”). The element is form-associated: with `name` it submits the chosen suggestion's value, or else the text, and a form reset restores the `value` attribute. `required` and `disabled` (also from a disabled fieldset) work as on an input. A polite status says “5 suggestions”, “50 of 1,234 suggestions”, “No suggestions”, “Loading suggestions” or “Couldn't load suggestions” half a second after the list settles (never on the first render); the popup shows the same notes visibly. A failed load never throws. Before it upgrades, `base.css` shows the label (from the attribute) and holds the field's height. A fallback `<input list>` child works as a plain field meanwhile; on upgrade its text, `name` and `placeholder` carry over, and it is disabled so it does not submit twice.
778
+ An editable text field that suggests values as you type, from a local list or a URL: a person, place or subject picker. It follows the WAI-ARIA APG “Editable Combobox With List Autocomplete”: a real `<input role="combobox">` and a `role="listbox"` popup under it. Suggestions come from the `items` property (`{ value, label?, description?, disabled? }` objects, or strings), from `<option>` children (directly or inside a `<datalist>`; the `label` attribute or text is the label, `data-description` the second line), or from `src`, a URL template with `{q}` (fetched 250 ms after the last keystroke once the text has `min-length` characters, default 1; a newer keystroke aborts the older request; the response is a JSON array of the same shape, or anything `transform(data, query)` turns into one). `items` wins over the children while set. Local suggestions match anywhere in the label, ignoring case and accents, those starting with the text first, then those with a word starting with it; at most `max-results` (default 50, 0 for all) are shown, which keeps a list of 16,000 people fast. The matched text is bold and underlined in a `<mark>`. Keys: Down opens the list on the first suggestion and moves (wrapping), Up opens on the last, Alt+Down opens without moving, Alt+Up closes, Enter chooses the active suggestion (and then does not submit the form; with none active, Enter submits as in any field), Escape closes the list and a second Escape clears the field, Home, End, Left and Right move the caret, and Tab leaves without choosing. A real clear button (“Clear <label>”, 44px, shown only with text) empties the field and returns focus to it. Free text is allowed: `value` is whatever is in the field, and `selected` the chosen suggestion (or null); typing after choosing clears it, and leaving the field with text that is exactly one suggestion's label chooses it. `must-choose` makes any other text invalid (“Choose one of the suggestions.”). The element is form-associated: with `name` it submits the chosen suggestion's value, or else the text, and a form reset restores the `value` attribute. `required` and `disabled` (also from a disabled fieldset) work as on an input. A polite status says “5 suggestions”, “50 of 1,234 suggestions”, “No suggestions”, “Loading suggestions” or “Couldn't load suggestions” half a second after the list settles (never on the first render); the popup shows the same notes visibly. A failed load never throws. Where the browser supports the Popover API and CSS anchor positioning, the popup is a manual popover in the top layer, anchored under the field and as wide as it (above it when there is no room below), so an ancestor with `overflow: hidden` or a scrolling panel never clips it. Elsewhere it is positioned under the field inside the element, as before. Pages can style the runtime state with `:state(open)`, `:state(invalid)` and `:state(loading)` (no attributes are added). Before it upgrades, `base.css` shows the label (from the attribute) and holds the field's height. A fallback `<input list>` child works as a plain field meanwhile; on upgrade its text, `name` and `placeholder` carry over, and it is disabled so it does not submit twice.
779
779
 
780
780
  ### Attributes
781
781
 
@@ -806,6 +806,14 @@ An editable text field that suggests values as you type, from a local list or a
806
806
  | `option` | Each suggestion. |
807
807
  | `description` | The hint under the field. |
808
808
 
809
+ ### CSS states
810
+
811
+ | State | Description |
812
+ |---|---|
813
+ | `:state(open)` | The popup is showing (suggestions or a note such as “No suggestions”). |
814
+ | `:state(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). |
815
+ | `:state(loading)` | Suggestions from `src` are loading. |
816
+
809
817
  ### Events
810
818
 
811
819
  | Event | Description |
@@ -1022,7 +1030,7 @@ A faceted-search filter: a fieldset of checkboxes (value plus result count), opt
1022
1030
 
1023
1031
  ## `<uvalib-filter-drawer>`
1024
1032
 
1025
- A search page's form and filters: a plain sidebar on wide screens, and on narrow ones a “Search and filters” button that opens them in a modal panel from the side. Put the page's search form, `<uvalib-filter>`s and other facets inside. Above `breakpoint` (default `48rem`) they are shown as written: no button, no dialog role. At and below it only the button is shown; it opens a native `<dialog>` (`showModal()`) with a visible heading (the `label`) and a 44px Close button, which takes focus. Escape, Close and a click on the backdrop close it, and focus returns to the button; widening the window past the breakpoint closes it and keeps focus where it was. While it is open the rest of the page, including `<site-page>`'s header, skip link and alerts, is inert (the browser's modal dialog), so focus cannot leave it except to the browser itself, and nothing else is announced. The children are the same nodes in both layouts (moved, never re-created): typed text, checked boxes, listeners and each filter's state are kept. Inert content is not announced, so results counts and status notices outside the panel would go silent while the visitor filters: name them in `live` (space-separated ids) and the drawer repeats what they announce in its own polite live region while it is open. `count` (the page's number of active filters) is shown on the button when above 0. The drawer never counts by itself: only the page knows which inputs are filters.
1033
+ A search page's form and filters: a plain sidebar on wide screens, and on narrow ones a “Search and filters” button that opens them in a modal panel from the side. Put the page's search form, `<uvalib-filter>`s and other facets inside. Above `breakpoint` (default `48rem`) they are shown as written: no button, no dialog role. At and below it only the button is shown; it opens a native `<dialog>` (`showModal()`) with a visible heading (the `label`) and a 44px Close button, which takes focus. Escape, Close and a click on the backdrop close it, and focus returns to the button; widening the window past the breakpoint closes it and keeps focus where it was. While it is open the rest of the page, including `<site-page>`'s header, skip link and alerts, is inert (the browser's modal dialog), so focus cannot leave it except to the browser itself, and nothing else is announced. The children are the same nodes in both layouts (moved, never re-created): typed text, checked boxes, listeners and each filter's state are kept. Inert content is not announced, so results counts and status notices outside the panel would go silent while the visitor filters: name them in `live` (space-separated ids) and the drawer repeats what they announce in its own polite live region while it is open. `count` (the page's number of active filters) is shown on the button when above 0. The drawer never counts by itself: only the page knows which inputs are filters. Pages can style the runtime layout with `:state(modal)` (at or below the breakpoint: the button and panel) and `:state(open)` (the panel is open).
1026
1034
 
1027
1035
  ### Attributes
1028
1036
 
@@ -1054,6 +1062,13 @@ A search page's form and filters: a plain sidebar on wide screens, and on narrow
1054
1062
  | `close` | The Close button. |
1055
1063
  | `body` | The wrapper of the children, in the sidebar or the panel. |
1056
1064
 
1065
+ ### CSS states
1066
+
1067
+ | State | Description |
1068
+ |---|---|
1069
+ | `:state(modal)` | The viewport is at or below the breakpoint: the button and panel, not the sidebar. |
1070
+ | `:state(open)` | The panel is open. |
1071
+
1057
1072
  ### Events
1058
1073
 
1059
1074
  | Event | Description |
@@ -1136,7 +1151,7 @@ An image with numbered region outlines (people, objects, inscriptions) and a lis
1136
1151
 
1137
1152
  ## `<uvalib-lightbox>`
1138
1153
 
1139
- An accessible image viewer over a set of plain links. With JavaScript a primary click opens a modal dialog; without it (or with a modified click) the link opens the image as before. Wrap the links, or point at them with `selector` (for example `a.pb-image` on a reading page). There is no autoplay and no carousel. The dialog is labelled by the caption (`data-caption`, else the image alt, else the link text). Focus moves to Close on open and back to the trigger on close. Escape and a click on the backdrop close it. With more than one image, Previous and Next and the arrow keys move through the set (wrapping), and a polite “3 of 13” counter is shown. Full size opens the original image in a new tab. A IIIF Image API URL keeps its region; only the size becomes `!W,H` for the viewport. TIFF and JPEG2000 URLs are left as written. `url-param` (for example `photo`) keeps `?photo=<id>` in sync, including on a hash route (`#/text?photo=<id>`): opening pushes a history entry, stepping replaces it, and Back closes. Optional details: children with `slot="details"` (and `data-for` equal to the item's id or its position from 1; without `data-for` they show for every image), or `data-details-id` on a link pointing at an element elsewhere on the page. Either is shown inside the dialog and put back exactly (same place, `hidden` and `slot`) when the viewer moves on or closes. The `data-details-id` element stays in the page (in shadow mode it becomes a child of the lightbox slotted into the dialog), so `getElementById`, the page's CSS (except selectors through its old ancestors) and listeners keep working; nothing is cloned. Details that appear while their image is open (rendered after a fetch) are shown then. `open(idOrIndex)` and `close({ focus })` let the page open or close the viewer itself; `uvalib-lightbox-open` and `uvalib-lightbox-close` say when it did. Optional regions (people, objects, inscriptions): `data-regions` on a link, a JSON array of `{ label, x, y, w, h, unit? }` or `xywh` values each followed by its label, separated by `;` (`percent:10,20,30,40 Person 1; percent:55,15,20,30 Sign`), or the `regions` callback. The open image then shows numbered outlines (`<uvalib-image-regions>`, loaded on first use) and a list of the regions beside it, with a "Show regions" toggle (`aria-pressed`) that hides the outlines. Pixel regions are measured in `data-image-width` × `data-image-height` when set (the viewer shows a resized IIIF image), else in the image's natural size. Or the page's own list, with its own buttons: `data-regions-list="<id>"` on a link (or the `regionsList` callback) names an `<ol>` or `<ul>` of `<li data-xywh>` anywhere in the page, usually `hidden`. While that image is open the list (the same nodes, so the page's listeners keep working) is the region list: in shadow mode it becomes a child of the lightbox slotted into the viewer, not moved into the shadow root, so the page's CSS still applies to it. When the image changes or the viewer closes it goes back where it was, `hidden` as before. It wins over `data-regions`. Optional versions of an image (an original scan and an AI colorization, a restoration, an infrared capture): `data-versions` on a link, a JSON array of `{ label, href?, note? }` whose first entry is the link's own image, or the `versions` callback. The viewer then compares them over the photo (loaded on first use): Switch (a segmented control), Reveal (a divider: click or tap the photo, or use the slider) or Fade (a slider), `compare` choosing the first. A version's `note` shows under the photo while it is visible, and the image's accessible name ends with the label of the version shown. `version-param` (with `url-param`) keeps the comparison in the address: `?version=2` (Switch, the version from 0), `?version=wipe:40` or `?version=fade:60` (the percentage of the other version shown; `wipe:40:2` compares the original with version 2). A version with a different framing (an AI-expanded frame, a crop, the whole plate) gives `frame`, the original's box in it (`percent:x,y,w,h`, or pixels of its `width` × `height`): the viewer draws every version at the original's scale in one box, the original lined up, and regions stay on it.
1154
+ An accessible image viewer over a set of plain links. With JavaScript a primary click opens a modal dialog; without it (or with a modified click) the link opens the image as before. Wrap the links, or point at them with `selector` (for example `a.pb-image` on a reading page). There is no autoplay and no carousel. The dialog is labelled by the caption (`data-caption`, else the image alt, else the link text). Focus moves to Close on open and back to the trigger on close. Escape and a click on the backdrop close it. With more than one image, Previous and Next and the arrow keys move through the set (wrapping), and a polite “3 of 13” counter is shown. Full size opens the original image in a new tab. A IIIF Image API URL keeps its region; only the size becomes `!W,H` for the viewport. TIFF and JPEG2000 URLs are left as written. `url-param` (for example `photo`) keeps `?photo=<id>` in sync, including on a hash route (`#/text?photo=<id>`): opening pushes a history entry, stepping replaces it, and Back closes. Optional details: children with `slot="details"` (and `data-for` equal to the item's id or its position from 1; without `data-for` they show for every image), or `data-details-id` on a link pointing at an element elsewhere on the page. Either is shown inside the dialog and put back exactly (same place, `hidden` and `slot`) when the viewer moves on or closes. The `data-details-id` element stays in the page (in shadow mode it becomes a child of the lightbox slotted into the dialog), so `getElementById`, the page's CSS (except selectors through its old ancestors) and listeners keep working; nothing is cloned. Details that appear while their image is open (rendered after a fetch) are shown then. `open(idOrIndex)` and `close({ focus })` let the page open or close the viewer itself; `uvalib-lightbox-open` and `uvalib-lightbox-close` say when it did. Optional regions (people, objects, inscriptions): `data-regions` on a link, a JSON array of `{ label, x, y, w, h, unit? }` or `xywh` values each followed by its label, separated by `;` (`percent:10,20,30,40 Person 1; percent:55,15,20,30 Sign`), or the `regions` callback. The open image then shows numbered outlines (`<uvalib-image-regions>`, loaded on first use) and a list of the regions beside it, with a "Show regions" toggle (`aria-pressed`) that hides the outlines. Pixel regions are measured in `data-image-width` × `data-image-height` when set (the viewer shows a resized IIIF image), else in the image's natural size. Or the page's own list, with its own buttons: `data-regions-list="<id>"` on a link (or the `regionsList` callback) names an `<ol>` or `<ul>` of `<li data-xywh>` anywhere in the page, usually `hidden`. While that image is open the list (the same nodes, so the page's listeners keep working) is the region list: in shadow mode it becomes a child of the lightbox slotted into the viewer, not moved into the shadow root, so the page's CSS still applies to it. When the image changes or the viewer closes it goes back where it was, `hidden` as before. It wins over `data-regions`. Optional versions of an image (an original scan and an AI colorization, a restoration, an infrared capture): `data-versions` on a link, a JSON array of `{ label, href?, note? }` whose first entry is the link's own image, or the `versions` callback. The viewer then compares them over the photo (loaded on first use): Switch (a segmented control), Reveal (a divider: click or tap the photo, or use the slider) or Fade (a slider), `compare` choosing the first. A version's `note` shows under the photo while it is visible, and the image's accessible name ends with the label of the version shown. `version-param` (with `url-param`) keeps the comparison in the address: `?version=2` (Switch, the version from 0), `?version=wipe:40` or `?version=fade:60` (the percentage of the other version shown; `wipe:40:2` compares the original with version 2). `data-version` on a link (the same values) opens that image on that version, from a click, `open()` or Previous and Next; an address with `version-param` wins. A version with a different framing (an AI-expanded frame, a crop, the whole plate) gives `frame`, the original's box in it (`percent:x,y,w,h`, or pixels of its `width` × `height`): the viewer draws every version at the original's scale in one box, the original lined up, and regions stay on it. Pages can style the element while the viewer is open with `:state(open)`.
1140
1155
 
1141
1156
  ### Attributes
1142
1157
 
@@ -1170,6 +1185,12 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
1170
1185
  | `regions` | The `<uvalib-image-regions>` around an image with regions. |
1171
1186
  | `compare` | The version comparison controls and notes under the photo. |
1172
1187
 
1188
+ ### CSS states
1189
+
1190
+ | State | Description |
1191
+ |---|---|
1192
+ | `:state(open)` | The viewer is open. |
1193
+
1173
1194
  ### Events
1174
1195
 
1175
1196
  | Event | Description |
@@ -1378,13 +1399,13 @@ Previous/next section links, as on a reading page, or a numbered page list. Prev
1378
1399
 
1379
1400
  ## `<uvalib-photo-grid>`
1380
1401
 
1381
- Justified rows of thumbnails. Each direct child that is a link or a button is one photo; its image keeps its shape from the `width` and `height` attributes, or from the loaded image, so the row does not jump when the picture arrives. The row is about 220px tall and shorter on a phone; `row-height` sets that height. Every item stays a real link or button. An image with no visible text gets a visible caption from its alt (the caption is then the accessible name, and a repeated alt is cleared). The original alt is kept in `data-uvalib-alt` so a lightbox still describes the picture. An item with no name at all is captioned “Photo N” and warned about once; that caption is renumbered when the photos change order. An `aria-label` is left as the name: the grid does not add a caption that would disagree with it. Put the grid inside `<uvalib-lightbox>` and a plain click opens the viewer. A badge sits on the thumbnail: `<span slot="badge">` inside the link or button, or `data-badge` on that item (for example “seq” or “3 photos”). It is read after the caption (“The Lawn, 3 photos”). When the item already has an `aria-label`, the badge is appended to that label (the author’s words stay in `data-uvalib-label`) and an alt that repeats those words is cleared. A badge does not replace the alt caption.
1402
+ Justified rows of thumbnails. Each direct child that is a link or a button is one photo; its image keeps its shape from the `width` and `height` attributes, or from the loaded image, so the row does not jump when the picture arrives. The row is about 220px tall and shorter when the grid is narrow (a phone, a sidebar); `row-height` sets that height. Every item stays a real link or button. An image with no visible text gets a visible caption from its alt (the caption is then the accessible name, and a repeated alt is cleared). The original alt is kept in `data-uvalib-alt` so a lightbox still describes the picture. An item with no name at all is captioned “Photo N” and warned about once; that caption is renumbered when the photos change order. An `aria-label` is left as the name: the grid does not add a caption that would disagree with it. Put the grid inside `<uvalib-lightbox>` and a plain click opens the viewer. A badge sits on the thumbnail: `<span slot="badge">` inside the link or button, or `data-badge` on that item (for example “seq” or “3 photos”). It is read after the caption (“The Lawn, 3 photos”). When the item already has an `aria-label`, the badge is appended to that label (the author’s words stay in `data-uvalib-label`) and an alt that repeats those words is cleared. A badge does not replace the alt caption.
1382
1403
 
1383
1404
  ### Attributes
1384
1405
 
1385
1406
  | Attribute | Type | Default | Description |
1386
1407
  |---|---|---|---|
1387
- | `row-height` | `string` | `''` | Row height. A bare number is pixels (`220` is 220px); `px`, `rem`, `em`, `vh`, `vw`, `vmin`, `vmax`, `ch` and `%` are kept. Empty uses 220px, or 140px when the viewport is 767px or narrower. |
1408
+ | `row-height` | `string` | `''` | Row height. A bare number is pixels (`220` is 220px); `px`, `rem`, `em`, `vh`, `vw`, `vmin`, `vmax`, `ch` and `%` are kept. Empty uses 220px, or 140px when the grid itself is narrower than 48rem (a phone, a sidebar, a drawer). |
1388
1409
  | `no-shadow-dom` | `boolean` | `false` | |
1389
1410
  | `no-style` | `boolean` | `false` | |
1390
1411
 
@@ -1478,7 +1499,7 @@ Tabs, as on library.virginia.edu: a row of buttons over one visible panel. Each
1478
1499
 
1479
1500
  ## `<uvalib-tag-list>`
1480
1501
 
1481
- A labelled list of keywords or subjects that wraps: each tag a link (for example a search for that term) or plain text. Link tags are outlined pills in the link colour; plain tags are filled chips (the card chip's colours), so a link never looks like a label. Every tag and the toggle are at least 2rem (34px) tall and wide, 0.5rem apart. Give the tags as children: `<a href>` for a link, any other element (`<span>`) for plain text. A child's `lang` and `dir` are kept, and so is inline markup inside it (`em`, `cite`, `abbr`, `bdi`, a `span lang`…), copied element by element (never parsed as HTML). Or set `href-template` (with `{tag}`, replaced by the URL-encoded text) to make every tag without its own href a link; a blank href counts as none. Apps can set the `items` property (`{ label, href?, lang?, dir? }`) instead; it wins over the children. Children with no text are skipped with one warning. `label` names the list (shown above it, or visually hidden with `hide-label`); without one a console warning is logged. `limit` shows that many tags and a “Show all N” button (`aria-expanded`, `aria-controls`), which reveals the rest in place and keeps focus. Analytics never sends a tag's text (record tags can be user-submitted or machine-made), and by default not the label either, which a template may fill from a record: the name is the list's place among the tag lists on the page, `list N`. Add `track-label` when the label is fixed text the page author wrote (“Subjects”), to send it instead.
1502
+ A labelled list of keywords or subjects that wraps: each tag a link (for example a search for that term) or plain text. Link tags are outlined pills in the link colour; plain tags are filled chips (the card chip's colours), so a link never looks like a label. Every tag and the toggle are at least 2rem (34px) tall and wide, 0.5rem apart. Give the tags as children: `<a href>` for a link, any other element (`<span>`) for plain text. A child's `lang` and `dir` are kept, and so is inline markup inside it (`em`, `cite`, `abbr`, `bdi`, a `span lang`…), copied element by element (never parsed as HTML). Or set `href-template` (with `{tag}`, replaced by the URL-encoded text) to make every tag without its own href a link; a blank href counts as none. Apps can set the `items` property (`{ label, href?, lang?, dir? }`) instead; it wins over the children. Children with no text are skipped with one warning. `label` names the list (shown above it, or visually hidden with `hide-label`); without one a console warning is logged. `limit` shows that many tags and a “Show all N” button (`aria-expanded`, `aria-controls`), which reveals the rest in place and keeps focus. Pages can style the list while every tag is shown with `:state(expanded)`. Analytics never sends a tag's text (record tags can be user-submitted or machine-made), and by default not the label either, which a template may fill from a record: the name is the list's place among the tag lists on the page, `list N`. Add `track-label` when the label is fixed text the page author wrote (“Subjects”), to send it instead.
1482
1503
 
1483
1504
  ### Attributes
1484
1505
 
@@ -1492,6 +1513,12 @@ A labelled list of keywords or subjects that wraps: each tag a link (for example
1492
1513
  | `no-shadow-dom` | `boolean` | `false` | |
1493
1514
  | `no-style` | `boolean` | `false` | |
1494
1515
 
1516
+ ### CSS states
1517
+
1518
+ | State | Description |
1519
+ |---|---|
1520
+ | `:state(expanded)` | Show all was pressed: every tag is shown (the toggle's `aria-expanded="true"`). |
1521
+
1495
1522
  ### Events
1496
1523
 
1497
1524
  | Event | Description |
@@ -1 +0,0 @@
1
- {"version":3,"file":"compare-DV6ltvsJ.js","names":["unsafeCSS","nothing","b","A","r","trackEvent","parseXywh","MODES","MODE_NAMES","compareTiming","MAX_SIDE","framing","list","v","ext","f","x0","y0","uw","uh","r4","n","place","norm","s","clamp","structure","h","ACCENT","LINK","look","styled","install","root","host","opts","installLightDomStyles","text","sheet","nextId","Compare","rtl","k","d","key","index","slide","restore","raw","bad","out","o","label","href","box","i","size","w","img","m","param","mode","other","next","announce","fn","state","el","write","a","on","stack","l0","lk","base","geo","hide","top","sizer","layers","visible","notes","failed","seg","pressed","onClick","switching","panel","body","switchPanel","sliding","slot"],"sources":["../../src/components/uvalib-lightbox/compare.ts"],"sourcesContent":["/**\n * Versions of an image compared over the photo: Switch, Reveal (a wipe) and Fade. Loaded by\n * `<uvalib-lightbox>` the first time an open image has versions, so pages without them never\n * load it.\n */\nimport { html, nothing, unsafeCSS } from 'lit';\nimport { trackEvent } from '../../base/analytics.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { parseXywh } from '../uvalib-image-regions/regions.js';\n\nexport type CompareMode = 'switch' | 'wipe' | 'fade';\n\nconst MODES: CompareMode[] = ['switch', 'wipe', 'fade'];\nconst MODE_NAMES: Record<CompareMode, string> = {\n switch: 'Switch',\n wipe: 'Reveal',\n fade: 'Fade',\n};\n\n/** How long (ms) after the last slider or drag change it counts as settled. Tests shorten it. */\nexport const compareTiming = { settle: 400 };\n\n/** A box in percent: of a version (its `frame`), or of the box that holds every version. */\ninterface Box {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\ninterface Version {\n label: string;\n href: string;\n note: string;\n /** Where the original sits in this version, in percent of the version; null: the same framing. */\n frame: Box | null;\n}\n\n/**\n * Versions with a different framing: every version's box (and the original's, first) in\n * percent of the box that holds them all, at the original's scale; `uw` × `uh` is that box in\n * original widths and heights; `covers` says whether a version covers the whole original.\n */\ninterface Framing {\n boxes: Box[];\n uw: number;\n uh: number;\n covers: boolean[];\n}\n\n/** The largest side of the sizer (a canvas never drawn on, so nothing is allocated). */\nconst MAX_SIDE = 4096;\n\nfunction framing(list: Version[]): Framing | null {\n if (!list.some((v) => v.frame)) return null;\n // Each version's extent in original units: the original is 0..1 across and down.\n const ext = list.map(({ frame: f }) =>\n f ? { x: -f.x / f.w, y: -f.y / f.h, w: 100 / f.w, h: 100 / f.h } : { x: 0, y: 0, w: 1, h: 1 },\n );\n const x0 = Math.min(...ext.map((e) => e.x));\n const y0 = Math.min(...ext.map((e) => e.y));\n const uw = Math.max(...ext.map((e) => e.x + e.w)) - x0;\n const uh = Math.max(...ext.map((e) => e.y + e.h)) - y0;\n return {\n uw,\n uh,\n boxes: ext.map((e) => ({\n x: ((e.x - x0) / uw) * 100,\n y: ((e.y - y0) / uh) * 100,\n w: (e.w / uw) * 100,\n h: (e.h / uh) * 100,\n })),\n covers: list.map(({ frame: f }) => !f || (f.x + f.w <= 100.001 && f.y + f.h <= 100.001)),\n };\n}\n\nconst r4 = (n: number) => Math.round(n * 1e4) / 1e4;\n/** Custom properties placing a layer (numbers, percent of the stack). */\nconst place = (b: Box) =>\n `--uvalib-frame-x: ${r4(b.x)}; --uvalib-frame-y: ${r4(b.y)}; --uvalib-frame-w: ${r4(b.w)}; --uvalib-frame-h: ${r4(b.h)}`;\n\n/** What the lightbox lends the comparison. */\nexport interface CompareHost {\n el: HTMLElement;\n light: boolean;\n root: Node;\n noStyle: boolean;\n /** The `compare` attribute: the first mode. */\n mode(): string;\n /** The URL the viewer would load for `href` ('' when it may not be shown). */\n size(href: string): string;\n /** Write the comparison to `version-param` (replaceState). */\n write(value: string | null): void;\n update(): void;\n}\n\n/** The parts of a lightbox slide the comparison reads. */\nexport interface CompareSlide {\n id: string;\n href: string;\n versions: string | unknown[] | null;\n}\n\nconst norm = (s: unknown) => (typeof s === 'string' ? s.replace(/\\s+/g, ' ').trim() : '');\nconst clamp = (n: number) => Math.min(100, Math.max(0, Math.round(n)));\n\n/**\n * Kept with `no-style`: the stacked layers, the clip and fade, the divider and its handle\n * (white inside black, so it shows on any photo), the side labels and the control layout.\n * `h` is `:host` (shadow) or the tag (light DOM).\n */\nconst structure = (h: string) => `\n ${h} .stack { isolation: isolate; }\n ${h} .stack > img.top {\n position: absolute; inset: 0; width: 100%; height: 100%;\n max-width: none; max-height: none; margin: 0; opacity: 0; pointer-events: none;\n }\n ${h} .stack > img.top.on { opacity: 1; }\n ${h} .compare-fade > img.top.on { opacity: var(--uvalib-compare-opacity, 1); }\n ${h} .compare-wipe > img.top.on { clip-path: inset(0 calc(100% - var(--uvalib-compare, 50%)) 0 0); }\n ${h} .compare-wipe:dir(rtl) > img.top.on { clip-path: inset(0 0 0 calc(100% - var(--uvalib-compare, 50%))); }\n ${h} .compare-wipe { touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: col-resize; }\n ${h} .compare-wipe img { -webkit-user-drag: none; }\n ${h} .stack.framed > img {\n position: absolute; inset: auto;\n left: calc(var(--uvalib-frame-x) * 1%); top: calc(var(--uvalib-frame-y) * 1%);\n width: calc(var(--uvalib-frame-w) * 1%); height: calc(var(--uvalib-frame-h) * 1%);\n max-width: none; max-height: none; margin: 0;\n }\n ${h} .stack.framed > canvas.frame-box {\n display: block; width: auto; height: auto; max-width: 100%; max-height: 70dvh; margin: auto;\n }\n ${h} .stack.framed.hide-base > img:not(.top) { opacity: 0; }\n ${h} .stack.framed.compare-fade > img.top.on { opacity: 1; }\n ${h} .stack.framed.compare-fade.top-on > img:not(.top) {\n z-index: 1; opacity: calc(1 - var(--uvalib-compare-opacity, 1));\n }\n ${h} .stack.framed.compare-wipe > img.top.on {\n clip-path: inset(0 max(0%, calc((var(--uvalib-frame-x) + var(--uvalib-frame-w) - var(--uvalib-compare-n, 50)) / var(--uvalib-frame-w) * 100%)) 0 0);\n }\n ${h} .stack.framed.compare-wipe:dir(rtl) > img.top.on {\n clip-path: inset(0 0 0 max(0%, calc((100 - var(--uvalib-compare-n, 50) - var(--uvalib-frame-x)) / var(--uvalib-frame-w) * 100%)));\n }\n ${h} .divider {\n position: absolute; inset-block: 0; inset-inline-start: var(--uvalib-compare, 50%);\n width: 0; pointer-events: none; forced-color-adjust: none;\n }\n ${h} .divider::before {\n content: ''; position: absolute; inset-block: 0; inset-inline-start: -2px; width: 4px;\n background: #fff; outline: 1px solid #000;\n }\n ${h} .handle {\n position: absolute; top: 50%; inset-inline-start: -22px; box-sizing: border-box;\n width: 44px; height: 44px; margin-top: -22px; border: 3px solid #000; border-radius: 50%;\n background: #fff; outline: 2px solid #fff;\n }\n ${h} .handle::before, ${h} .handle::after {\n content: ''; position: absolute; top: 50%; margin-top: -6px;\n border-block: 6px solid transparent;\n }\n ${h} .handle::before { left: 7px; border-right: 8px solid #000; }\n ${h} .handle::after { right: 7px; border-left: 8px solid #000; }\n ${h} .side {\n position: absolute; inset-block-end: 0.5rem; max-width: 40%; overflow: hidden;\n padding: 0.125rem 0.5rem; background: #000; color: #fff; outline: 1px solid #fff;\n font-size: 0.875rem; font-weight: 700; line-height: 1.3; white-space: nowrap;\n text-overflow: ellipsis; pointer-events: none; forced-color-adjust: none;\n }\n ${h} .side-start { inset-inline-start: 0.5rem; }\n ${h} .side-end { inset-inline-end: 0.5rem; }\n ${h} .compare { display: flex; flex-direction: column; gap: 0.5rem; margin-block-start: 0.75rem; }\n ${h} .compare-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }\n ${h} .mode-panels { display: grid; flex: 1 1 auto; min-width: 0; }\n ${h} .mode-panel { grid-area: 1 / 1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }\n ${h} .mode-panel[data-off] { visibility: hidden; }\n ${h} .seg-group { display: flex; flex-wrap: wrap; }\n ${h} .slider { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; flex: 1 1 14rem; min-width: 0; }\n ${h} .slider input { flex: 1 1 8rem; min-width: 0; min-height: 44px; margin: 0; }\n ${h} .note { margin: 0; overflow-wrap: anywhere; }\n ${h} .note[data-off] { visibility: hidden; }\n ${h} .compare button.hold { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; touch-action: none; }\n @media (forced-colors: active) {\n ${h} .divider::before { background: CanvasText; outline-color: Canvas; }\n ${h} .handle { background: Canvas; border-color: Highlight; outline-color: Canvas; }\n ${h} .handle::before { border-right-color: CanvasText; }\n ${h} .handle::after { border-left-color: CanvasText; }\n ${h} .side { background: CanvasText; color: Canvas; outline-color: Canvas; }\n }\n`;\n\nconst ACCENT = 'var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))';\nconst LINK = 'var(--uva-color-link, var(--uva-brand-blue, #232d4b))';\n\n/** The look: segmented buttons like `<uvalib-chip-group segmented>`, the slider's accent. */\nconst look = (h: string) => `\n ${h} .compare button.seg, ${h} .compare button.jump, ${h} .compare button.hold {\n display: inline-flex; align-items: center; justify-content: center;\n border: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));\n background: var(--uva-color-surface-raised, var(--uva-color-surface, #fff));\n color: ${LINK}; font-size: 0.9375rem; font-weight: 600; line-height: 1.3;\n }\n ${h} .seg-group > button + button { margin-inline-start: -1px; }\n ${h} .seg-group > button:first-child { border-start-start-radius: 0.3rem; border-end-start-radius: 0.3rem; }\n ${h} .seg-group > button:last-child { border-start-end-radius: 0.3rem; border-end-end-radius: 0.3rem; }\n ${h} .compare button.seg[aria-pressed='true'] {\n position: relative; border-color: ${ACCENT}; background: ${ACCENT};\n color: var(--uva-color-on-accent, #fff);\n }\n ${h} .compare button.seg[aria-pressed='true']::before {\n content: ''; box-sizing: border-box; width: 0.375rem; height: 0.75rem;\n margin-inline-end: 0.5rem; border: solid currentColor; border-width: 0 2px 2px 0;\n transform: translateY(-0.0625rem) rotate(45deg);\n }\n ${h} .compare button:hover { border-color: ${LINK}; }\n ${h} .compare button.seg[aria-pressed='true']:hover { border-color: ${ACCENT}; }\n ${h} .compare button.hold[data-held] { background: var(--uva-color-surface-hover, #f1f1f1); }\n ${h} .slider label { font-weight: 600; }\n ${h} .slider input { accent-color: ${ACCENT}; }\n ${h} .slider input:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n ${h} .note { font-size: 0.9375rem; line-height: 1.5; }\n ${h} .stack.framed {\n background: repeating-linear-gradient(135deg, transparent 0 7px, rgb(128 128 128 / 0.2) 7px 9px);\n }\n @media (prefers-reduced-motion: no-preference) {\n ${h} .compare-switch > img.top, ${h} .compare-switch.framed > img { transition: opacity 0.2s ease; }\n }\n @media (forced-colors: active) {\n ${h} .compare button.seg, ${h} .compare button.jump, ${h} .compare button.hold { border-color: ButtonText; }\n ${h} .compare button.seg[aria-pressed='true'] { background: Highlight; color: HighlightText; border-color: Highlight; }\n }\n`;\n\n/** Shadow roots that already have the comparison's sheets. */\nconst styled = new WeakSet<Node>();\n\nfunction install(host: CompareHost): void {\n const root = host.root;\n if (host.light) {\n const opts = { root: root as Document | ShadowRoot, scope: false };\n installLightDomStyles(\n 'uvalib-lightbox::compare-structure',\n unsafeCSS(structure('uvalib-lightbox')),\n opts,\n );\n if (!host.noStyle)\n installLightDomStyles('uvalib-lightbox::compare', unsafeCSS(look('uvalib-lightbox')), opts);\n return;\n }\n if (!(root instanceof ShadowRoot) || styled.has(root)) return;\n styled.add(root);\n const text = structure(':host') + (host.noStyle ? '' : look(':host'));\n const sheet = unsafeCSS(text).styleSheet;\n if (sheet) root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];\n}\n\nlet nextId = 0;\n\n/**\n * The comparison for one lightbox. State: the mode, the version shown (Switch) or compared\n * with the original (Reveal, Fade), and the percentage of it shown. Another version's image\n * is requested the first time it is needed, and drawn (and announced) once it has loaded.\n */\nexport class Compare {\n private list: Version[] = [];\n private slideKey = '';\n private id = '';\n private warned = false;\n private warnedFrame = false;\n private geo: Framing | null = null;\n private baseHref = '';\n /** The mode the visitor (or the address) chose; else the lightbox's `compare`. */\n private chosen: CompareMode | null = null;\n mode: CompareMode = 'switch';\n /** The version compared with the original (Reveal, Fade), from 1. */\n private other = 1;\n /** The percentage of `other` shown (Reveal, Fade). */\n private value = 50;\n /** The version shown (Switch), from 0. */\n private shown = 0;\n private holding = false;\n private requested = new Set<number>();\n private ready = new Set<number>();\n private failed = new Set<number>();\n private message = '';\n private flip = false;\n private pendingAnnounce = false;\n private announceNext = false;\n private settleTimer = 0;\n private settled = '';\n private dragging = false;\n private dragEnd = 0;\n private readonly uid = `uvalib-compare-${++nextId}`;\n\n constructor(private readonly host: CompareHost) {\n install(host);\n }\n\n /** At least two usable versions. */\n get active(): boolean {\n return this.list.length > 1;\n }\n\n /** Follow the open image: a new one starts again (in the current mode); `restore` is the address's value. */\n sync(slide: CompareSlide, index: number, restore: string | null): void {\n const key = `${index}\\n${slide.href}\\n${JSON.stringify(slide.versions)}`;\n if (key !== this.slideKey) {\n this.reset();\n this.slideKey = key;\n this.id = slide.id;\n this.list = this.parse(slide);\n this.geo = framing(this.list);\n this.baseHref = slide.href;\n this.mode =\n this.chosen ??\n (MODES.includes(this.host.mode() as CompareMode)\n ? (this.host.mode() as CompareMode)\n : 'switch');\n this.value = this.mode === 'wipe' ? 50 : 0;\n this.need();\n this.settled = this.encode();\n }\n if (restore != null && this.active) this.restore(restore);\n }\n\n /** Forget the open image (the viewer closed): report a change still settling first. */\n reset(): void {\n // Its event and analytics, but not the address: that is the next image's now.\n if (this.settleTimer) this.settle(false);\n this.slideKey = '';\n this.list = [];\n this.geo = null;\n this.other = 1;\n this.shown = 0;\n this.holding = false;\n this.dragging = false;\n this.requested = new Set();\n this.ready = new Set();\n this.failed = new Set();\n this.message = '';\n this.pendingAnnounce = false;\n }\n\n private parse(slide: CompareSlide): Version[] {\n let raw: unknown = slide.versions;\n let bad = false;\n if (typeof raw === 'string') {\n try {\n raw = JSON.parse(raw);\n } catch {\n raw = null;\n bad = true;\n }\n }\n const out: Version[] = [];\n if (Array.isArray(raw)) {\n raw.forEach((v: unknown, i) => {\n const o = v && typeof v === 'object' ? (v as Record<string, unknown>) : {};\n const label = norm(o.label) || (i === 0 ? 'Original' : '');\n const href = i === 0 ? slide.href : norm(o.href);\n if (label && href && this.host.size(href))\n out.push({ label, href, note: norm(o.note), frame: this.frame(o, i) });\n else if (i === 0) out.length = 0;\n else bad = true;\n });\n } else bad = true;\n if (bad && !this.warned) {\n this.warned = true;\n console.warn(\n 'uvalib-lightbox: data-versions (or the versions callback) has entries without a label or a usable href; they are left out.',\n );\n }\n return out.length > 1 ? out : [];\n }\n\n /**\n * A version's `frame`: the original's box in it, `percent:x,y,w,h`, or pixels\n * (`x,y,w,h` / `pixel:`) of the version's `width` × `height`. Anything else is ignored\n * (the same framing), with one warning.\n */\n private frame(o: Record<string, unknown>, i: number): Box | null {\n if (o.frame == null || o.frame === '') return null;\n const box = i > 0 && typeof o.frame === 'string' ? parseXywh(o.frame) : null;\n const size = (v: unknown) => (typeof v === 'number' || typeof v === 'string' ? Number(v) : 0);\n const w = size(o.width);\n const h = size(o.height);\n if (box?.unit === 'percent') return { x: box.x, y: box.y, w: box.w, h: box.h };\n if (box && w > 0 && h > 0)\n return {\n x: (box.x / w) * 100,\n y: (box.y / h) * 100,\n w: (box.w / w) * 100,\n h: (box.h / h) * 100,\n };\n if (!this.warnedFrame) {\n this.warnedFrame = true;\n console.warn(\n \"uvalib-lightbox: a version has a frame that is not usable (on the first version, not percent:x,y,w,h, or pixels without the version's width and height); it is shown with the original's framing.\",\n );\n }\n return null;\n }\n\n /**\n * The original's natural size, once its image (the one rendered now) has loaded: the framed\n * layout needs it, and is used only from then on (before, the original sizes the stack).\n */\n private natural(): { w: number; h: number } | null {\n if (!this.geo) return null;\n const scope = (this.host.light ? this.host.el : this.host.root) as ParentNode;\n const img = scope.querySelector<HTMLImageElement>('dialog .stack > img:not(.top)');\n if (!img?.complete || !img.naturalWidth || !img.naturalHeight) return null;\n if (img.getAttribute('src') !== this.host.size(this.baseHref)) return null;\n return { w: img.naturalWidth, h: img.naturalHeight };\n }\n\n /** `2`, `switch:2`, `wipe:40`, `fade:60`, `wipe:40:2` (the version compared, from 1). */\n private restore(param: string): void {\n const m = /^(?:(switch|wipe|fade):)?(\\d{1,3})(?::(\\d{1,3}))?$/.exec(param.trim().toLowerCase());\n if (!m) return;\n const mode = (m[1] ?? 'switch') as CompareMode;\n const n = Number(m[2]);\n if (mode === 'switch') {\n if (n >= this.list.length) return;\n this.shown = n;\n } else {\n const other = m[3] ? Number(m[3]) : 1;\n this.other = other >= 1 && other < this.list.length ? other : 1;\n this.value = clamp(n);\n }\n this.mode = this.chosen = mode;\n this.need();\n this.settled = this.encode();\n }\n\n private encode(): string {\n if (this.mode === 'switch') return String(this.shown);\n return `${this.mode}:${this.value}${this.other !== 1 ? `:${this.other}` : ''}`;\n }\n\n /** The version over the original: shown (Switch) or compared (Reveal, Fade). */\n private get top(): number {\n return this.mode === 'switch' ? this.shown : this.other;\n }\n\n /** The percentage of the top version asked for. */\n private get amount(): number {\n if (this.holding) return 0;\n if (this.mode === 'switch') return this.shown > 0 ? 100 : 0;\n return this.value;\n }\n\n /** The percentage of it on screen: none until its image has loaded. */\n private get seen(): number {\n return this.top > 0 && this.ready.has(this.top) ? this.amount : 0;\n }\n\n private label(i: number): string {\n return this.list[i]?.label ?? '';\n }\n\n /** Request the top version's image the first time it is needed. */\n private need(): void {\n if (this.amount > 0 && this.top > 0) this.requested.add(this.top);\n }\n\n // ------------------------------------------------------------ changes\n\n private set(v: number, announce: boolean): void {\n const next = clamp(v);\n if (next === this.value) return;\n this.value = next;\n this.need();\n this.host.update();\n this.announceNext ||= announce;\n window.clearTimeout(this.settleTimer);\n this.settleTimer = window.setTimeout(() => this.settle(), compareTiming.settle);\n }\n\n private change(fn: () => void): void {\n fn();\n this.need();\n this.host.update();\n this.announceNext = true;\n this.settle();\n }\n\n /** A visitor's change has settled: the event, analytics, the address and the announcement. */\n private settle(write = true): void {\n window.clearTimeout(this.settleTimer);\n this.settleTimer = 0;\n const state = this.encode();\n const announce = this.announceNext;\n this.announceNext = false;\n if (state === this.settled || !this.active) return;\n this.settled = state;\n const index = this.top;\n const el = this.host.el;\n el.dispatchEvent(\n new CustomEvent('uvalib-lightbox-version', {\n detail: {\n id: this.id,\n mode: this.mode,\n index,\n value: this.mode === 'switch' ? null : this.value,\n },\n bubbles: true,\n composed: true,\n }),\n );\n trackEvent(el, ['uvalib-lightbox', 'compare', this.mode, index + 1]);\n if (!write) return;\n this.host.write(state);\n if (!announce) return;\n if (this.amount > 0 && !this.ready.has(this.top)) this.pendingAnnounce = true;\n else this.say(this.stateText());\n }\n\n private say(text: string): void {\n this.pendingAnnounce = false;\n // A repeated message is still a change, so it is read again.\n this.flip = !this.flip;\n this.message = text + (this.flip ? ' ' : '');\n this.host.update();\n }\n\n private stateText(): string {\n const a = this.amount;\n if (a <= 0) return `${this.label(0)} shown`;\n if (a >= 100) return `${this.label(this.top)} shown`;\n return `${a}% ${this.label(this.top)}`;\n }\n\n private setMode(mode: CompareMode): void {\n if (mode === this.mode) return;\n this.change(() => {\n if (mode === 'switch') this.shown = this.value >= 50 ? this.other : 0;\n else if (this.mode === 'switch') {\n if (this.shown > 0) this.other = this.shown;\n this.value = mode === 'wipe' ? 50 : this.shown > 0 ? 100 : 0;\n }\n this.mode = this.chosen = mode;\n });\n }\n\n private hold(on: boolean): void {\n if (on === this.holding) return;\n this.holding = on;\n this.host.update();\n }\n\n private loaded(i: number): void {\n this.ready.add(i);\n this.host.update();\n if (this.pendingAnnounce && i === this.top) this.say(this.stateText());\n }\n\n private errored(i: number): void {\n this.failed.add(i);\n this.pendingAnnounce = false;\n this.say(`${this.label(i)} could not be loaded.`);\n }\n\n // ------------------------------------------------------------ input\n\n /** The `o` key held anywhere in the dialog shows the original. True when handled. */\n key(e: KeyboardEvent): boolean {\n if (!this.active || (e.key !== 'o' && e.key !== 'O') || e.altKey || e.ctrlKey || e.metaKey)\n return false;\n this.hold(e.type === 'keydown');\n return true;\n }\n\n /** A press on the photo in Reveal moves the divider there; a drag keeps moving it. */\n pointer(e: PointerEvent): void {\n if (!this.active || this.mode !== 'wipe') return;\n const stack = e.currentTarget as HTMLElement;\n if (e.type === 'pointerdown') {\n if (e.button !== 0 || !e.isPrimary) return;\n this.dragging = true;\n try {\n stack.setPointerCapture(e.pointerId);\n } catch {\n // A synthetic pointer cannot be captured; the press still moves the divider.\n }\n e.preventDefault();\n } else if (e.type !== 'pointermove') {\n if (this.dragging) this.dragEnd = performance.now();\n this.dragging = false;\n return;\n }\n if (!this.dragging) return;\n const r = stack.getBoundingClientRect();\n if (!r.width) return;\n const rtl = getComputedStyle(stack).direction === 'rtl';\n this.set(((rtl ? r.right - e.clientX : e.clientX - r.left) / r.width) * 100, true);\n }\n\n /** A drag that ended outside the photo must not count as a click on the backdrop. */\n dragged(): boolean {\n return this.dragging || performance.now() - this.dragEnd < 100;\n }\n\n private readonly onInput = (e: Event): void => {\n this.set(Number((e.target as HTMLInputElement).value), false);\n };\n\n /** Shift with an arrow, and Page Up / Page Down, move 10%. */\n private readonly onSliderKey = (e: KeyboardEvent): void => {\n const rtl = getComputedStyle(e.target as Element).direction === 'rtl';\n const k = e.key;\n let d = 0;\n if (k === 'PageUp') d = 10;\n else if (k === 'PageDown') d = -10;\n else if (e.shiftKey && (k === 'ArrowUp' || k === 'ArrowDown')) d = k === 'ArrowUp' ? 10 : -10;\n else if (e.shiftKey && (k === 'ArrowLeft' || k === 'ArrowRight'))\n d = (k === 'ArrowRight') !== rtl ? 10 : -10;\n if (!d) return;\n e.preventDefault();\n this.set(this.value + d, false);\n };\n\n private readonly onHold = (e: Event): void => {\n const t = e.type;\n if (t === 'keydown' || t === 'keyup') {\n const k = (e as KeyboardEvent).key;\n if (k !== ' ' && k !== 'Enter') return;\n this.hold(t === 'keydown');\n } else this.hold(t === 'pointerdown');\n };\n\n // ------------------------------------------------------------ render\n\n /** The image's accessible name ends with what is on screen. */\n alt(base: string): string {\n const a = this.seen;\n const l0 = this.label(0);\n const lk = this.label(this.top);\n const what =\n a <= 0\n ? l0\n : a >= 100\n ? lk\n : `${l0} and ${lk}, ${this.mode === 'wipe' ? 'compared side by side' : 'blended'}`;\n return `${base} (${what})`;\n }\n\n get stackClass(): string {\n const geo = this.natural() ? this.geo : null;\n if (!geo) return `compare-${this.mode}`;\n const on = this.seen > 0;\n // Switch: a version that does not cover the whole original (a crop) hides it.\n const hide = this.mode === 'switch' && on && this.seen >= 100 && !geo.covers[this.top];\n return `compare-${this.mode} framed${on ? ' top-on' : ''}${hide ? ' hide-base' : ''}`;\n }\n\n get stackStyle(): string {\n const a = this.mode === 'switch' ? 100 : this.value;\n const base = `--uvalib-compare: ${a}%; --uvalib-compare-opacity: ${a / 100}`;\n const geo = this.natural() ? this.geo : null;\n return geo ? `${base}; --uvalib-compare-n: ${a}; ${place(geo.boxes[0]!)}` : base;\n }\n\n /**\n * With a different framing, where the outlines of regions go: the original's box in the\n * stack, as `<uvalib-image-regions>`'s overlay inset. Empty otherwise.\n */\n get regionsStyle(): string {\n const geo = this.natural() ? this.geo : null;\n if (!geo) return '';\n const b = geo.boxes[0]!;\n return `--uvalib-image-regions-inset: ${r4(b.y)}% ${r4(100 - b.x - b.w)}% ${r4(100 - b.y - b.h)}% ${r4(b.x)}%`;\n }\n\n /** The other versions' images (each requested on first use), the divider and the side labels. */\n layers() {\n const top = this.top;\n const on = this.seen > 0;\n const size = this.natural();\n const geo = size ? this.geo : null;\n // The stack's size, reserved from the frames and the original: a canvas of the whole box\n // at the original's scale (never drawn on), sized like the image it stands for.\n const sizer =\n geo && size\n ? (() => {\n const w = size.w * geo.uw;\n const h = size.h * geo.uh;\n const k = Math.min(1, MAX_SIDE / Math.max(w, h));\n return html`<canvas\n class=\"frame-box\"\n aria-hidden=\"true\"\n width=${Math.max(1, Math.round(w * k))}\n height=${Math.max(1, Math.round(h * k))}\n ></canvas>`;\n })()\n : nothing;\n const layers = this.list.map((v, i) =>\n i === 0\n ? nothing\n : html`<img\n class=\"top ${i === top && on ? 'on' : ''}\"\n style=${geo && v.frame ? place(geo.boxes[i]!) : nothing}\n data-version=${i}\n alt=\"\"\n decoding=\"async\"\n draggable=\"false\"\n src=${this.requested.has(i) ? this.host.size(v.href) : nothing}\n @load=${() => this.loaded(i)}\n @error=${() => this.errored(i)}\n />`,\n );\n if (this.mode !== 'wipe') return html`${sizer}${layers}`;\n const a = this.seen;\n return html`${sizer}${layers}\n <div class=\"divider\" aria-hidden=\"true\"><span class=\"handle\"></span></div>\n <span class=\"side side-start\" aria-hidden=\"true\" ?hidden=${a <= 0}>${this.label(top)}</span>\n <span class=\"side side-end\" aria-hidden=\"true\" ?hidden=${a >= 100}>${this.label(0)}</span>`;\n }\n\n /** Notes of the versions on screen, then the controls. `slot` puts them under regions' image. */\n controls(slot: string) {\n const a = this.seen;\n const top = this.top;\n // Every note keeps its line (hidden while its version is not on screen), so showing\n // another version never moves the photo or the controls.\n const visible = (i: number) => (i === 0 ? a < 100 : i === top && a > 0);\n const notes = this.list.map((v, i) =>\n v.note\n ? html`<p class=\"note\" ?data-off=${!visible(i)}><strong>${v.label}:</strong> ${v.note}</p>`\n : nothing,\n );\n const failed =\n this.failed.has(top) && this.amount > 0\n ? html`<p class=\"note\">${this.label(top)} could not be loaded.</p>`\n : nothing;\n const seg = (pressed: boolean, text: string, onClick: () => void) =>\n html`<button\n type=\"button\"\n class=\"seg\"\n aria-pressed=${pressed ? 'true' : 'false'}\n @click=${onClick}\n >\n ${text}\n </button>`;\n const l0 = this.label(0);\n const lk = this.label(this.other);\n // Both panels are always drawn, in one grid cell: the row is as tall as the taller one,\n // so changing mode never moves the photo (the dialog re-centres on any height change).\n // The other panel is inert and hidden, out of the tab order and the accessibility tree.\n const switching = this.mode === 'switch';\n const panel = (on: boolean, body: unknown) =>\n html`<div class=\"mode-panel\" ?inert=${!on} ?data-off=${!on}>${body}</div>`;\n const switchPanel = html`<div class=\"seg-group\" role=\"group\" aria-label=\"Version shown\">\n ${this.list.map((v, i) =>\n seg(this.shown === i, v.label, () => this.change(() => (this.shown = i))),\n )}\n </div>`;\n const sliding = html`${\n this.list.length > 2\n ? html`<div class=\"seg-group\" role=\"group\" aria-label=\"Compare ${l0} with\">\n ${this.list.map((v, i) =>\n i\n ? seg(this.other === i, v.label, () => this.change(() => (this.other = i)))\n : nothing,\n )}\n </div>`\n : nothing\n }\n <div class=\"slider\">\n <label for=${this.uid}>${this.mode === 'fade' ? 'Fade to' : 'Reveal'} ${lk}</label>\n <input\n id=${this.uid}\n type=\"range\"\n min=\"0\"\n max=\"100\"\n step=\"1\"\n .value=${String(this.value)}\n aria-valuetext=\"${this.value}% ${lk}\"\n @input=${this.onInput}\n @keydown=${this.onSliderKey}\n />\n </div>\n <div class=\"seg-group\" role=\"group\" aria-label=\"Jump to\">\n ${[\n [0, l0],\n [50, '50/50'],\n [100, lk],\n ].map(\n ([v, text]) =>\n html`<button\n type=\"button\"\n class=\"jump\"\n @click=${() => this.change(() => (this.value = v as number))}\n >\n ${text}\n </button>`,\n )}\n </div>\n <button\n type=\"button\"\n class=\"hold\"\n aria-keyshortcuts=\"O\"\n ?data-held=${this.holding}\n @pointerdown=${this.onHold}\n @pointerup=${this.onHold}\n @pointerleave=${this.onHold}\n @pointercancel=${this.onHold}\n @keydown=${this.onHold}\n @keyup=${this.onHold}\n @blur=${() => this.hold(false)}\n @contextmenu=${(e: Event) => e.preventDefault()}\n >\n Hold for ${l0}\n </button>`;\n return html`<div class=\"compare\" part=\"compare\" slot=${slot || nothing}>\n ${notes}${failed}\n <div class=\"compare-bar\">\n <div class=\"seg-group\" role=\"group\" aria-label=\"Compare versions\">\n ${MODES.map((m) => seg(this.mode === m, MODE_NAMES[m], () => this.setMode(m)))}\n </div>\n <div class=\"mode-panels\">${panel(switching, switchPanel)}${panel(!switching, sliding)}</div>\n </div>\n <p class=\"visually-hidden\" role=\"status\">${this.message}</p>\n </div>`;\n }\n\n /**\n * Full size, in every mode: the original and the version shown (Switch) or compared (Reveal,\n * Fade), each named. The same two links in every mode keep the toolbar's height, so changing\n * mode never moves the photo; and a visitor can always open the original at full size.\n */\n full(): { href: string; label: string }[] {\n const k = this.mode === 'switch' ? this.shown || this.other : this.other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