@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.
- package/CHANGELOG.md +23 -0
- package/README.md +56 -12
- package/dist/base/states.d.ts +12 -0
- package/dist/base/states.js +33 -0
- package/dist/base/states.js.map +1 -0
- package/dist/base.css +15 -5
- package/dist/components/bento-box/BentoBox.js +1 -0
- package/dist/components/bento-box/BentoBox.js.map +1 -1
- package/dist/components/events-section/EventsSection.js +1 -0
- package/dist/components/events-section/EventsSection.js.map +1 -1
- package/dist/components/library-hours/hours-data.js +1 -1
- package/dist/components/library-hours/hours-data.js.map +1 -1
- package/dist/components/library-weekly-hours/LibraryWeeklyHours.js +1 -0
- package/dist/components/library-weekly-hours/LibraryWeeklyHours.js.map +1 -1
- package/dist/components/uvalib-card/UvalibCard.js +6 -0
- package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
- package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +27 -0
- package/dist/components/uvalib-combobox/UvalibCombobox.js +85 -1
- package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -1
- package/dist/components/uvalib-contents/UvalibContents.js +5 -0
- package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +6 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +10 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -1
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js +2 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -1
- package/dist/components/uvalib-image-regions/regions.d.ts +6 -2
- package/dist/components/uvalib-image-regions/regions.js +6 -3
- package/dist/components/uvalib-image-regions/regions.js.map +1 -1
- package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +9 -2
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +23 -3
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-lightbox/compare.d.ts +30 -3
- package/dist/components/uvalib-lightbox/compare.js +98 -29
- package/dist/components/uvalib-lightbox/compare.js.map +1 -1
- package/dist/components/uvalib-map/UvalibMap.js +2 -2
- package/dist/components/uvalib-map/UvalibMap.js.map +1 -1
- package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -0
- package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +3 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +3 -3
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +16 -8
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
- package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +4 -1
- package/dist/components/uvalib-tag-list/UvalibTagList.js +9 -2
- package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -1
- package/dist/custom-elements.json +1926 -1637
- package/dist/styles/message.js +4 -0
- package/dist/styles/message.js.map +1 -1
- package/dist/styles/result-list.js +25 -4
- package/dist/styles/result-list.js.map +1 -1
- package/dist/styles/results.js +17 -2
- package/dist/styles/results.js.map +1 -1
- package/dist-cdn/base.css +15 -5
- package/dist-cdn/bento-box.js +1 -0
- package/dist-cdn/bento-box.js.map +1 -1
- package/dist-cdn/chunks/{compare-DV6ltvsJ.js → compare-C0nhByn7.js} +66 -29
- package/dist-cdn/chunks/compare-C0nhByn7.js.map +1 -0
- package/dist-cdn/chunks/{hours-data-Bw6vkIw7.js → hours-data-gMu5uT7H.js} +2 -2
- package/dist-cdn/chunks/hours-data-gMu5uT7H.js.map +1 -0
- package/dist-cdn/chunks/{library-weekly-hours-CrV3TlP5.js → library-weekly-hours-BJgxAyah.js} +3 -2
- package/dist-cdn/chunks/library-weekly-hours-BJgxAyah.js.map +1 -0
- package/dist-cdn/chunks/{regions-B8ExwUGP.js → regions-B-rOwa-v.js} +15 -15
- package/dist-cdn/chunks/regions-B-rOwa-v.js.map +1 -0
- package/dist-cdn/chunks/states-DGXGzcte.js +17 -0
- package/dist-cdn/chunks/states-DGXGzcte.js.map +1 -0
- package/dist-cdn/custom-elements.json +1926 -1637
- package/dist-cdn/events-section.js +1 -0
- package/dist-cdn/events-section.js.map +1 -1
- package/dist-cdn/library-hours-setup.js +1 -1
- package/dist-cdn/library-weekly-hours.js +1 -1
- package/dist-cdn/manifest.json +1 -1
- package/dist-cdn/site-hours-section.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +5 -4
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +33 -6
- package/dist-cdn/uvalib-card.js +6 -0
- package/dist-cdn/uvalib-card.js.map +1 -1
- package/dist-cdn/uvalib-combobox.js +107 -68
- package/dist-cdn/uvalib-combobox.js.map +1 -1
- package/dist-cdn/uvalib-contents.js +5 -0
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-filter-drawer.js +27 -25
- package/dist-cdn/uvalib-filter-drawer.js.map +1 -1
- package/dist-cdn/uvalib-image-regions.js +3 -1
- package/dist-cdn/uvalib-image-regions.js.map +1 -1
- package/dist-cdn/uvalib-lightbox.js +80 -69
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-map.js +2 -2
- package/dist-cdn/uvalib-map.js.map +1 -1
- package/dist-cdn/uvalib-metadata.js +3 -0
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pagefind-search.js +2 -1
- package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +4 -5
- package/dist-cdn/uvalib-photo-grid.js.map +1 -1
- package/dist-cdn/uvalib-tag-list.js +21 -16
- package/dist-cdn/uvalib-tag-list.js.map +1 -1
- package/package.json +1 -1
- package/skills/uvalib-web-components/SKILL.md +5 -4
- package/skills/uvalib-web-components/reference/components.md +33 -6
- package/dist-cdn/chunks/compare-DV6ltvsJ.js.map +0 -1
- package/dist-cdn/chunks/hours-data-Bw6vkIw7.js.map +0 -1
- package/dist-cdn/chunks/library-weekly-hours-CrV3TlP5.js.map +0 -1
- package/dist-cdn/chunks/regions-B8ExwUGP.js.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { a as e, f as t, i as n, l as r, m as i, n as a, o, t as s } from "./chunks/UvalibElement-pGONDAwB.js";
|
|
2
2
|
import { a as c } from "./chunks/analytics-DTTihuBD.js";
|
|
3
|
+
import { n as l, t as u } from "./chunks/states-DGXGzcte.js";
|
|
3
4
|
// src/components/uvalib-filter-drawer/UvalibFilterDrawer.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
if (e.matches(
|
|
7
|
-
let t = [...e.querySelectorAll(
|
|
8
|
-
return t.length ?
|
|
5
|
+
var d = "uvalib-filter-drawer", f = "Search and filters", p = "48rem", m = /^\d+(\.\d+)?(px|rem|em)$/, h = 5e3, g = "[aria-live]:not([aria-live=\"off\"]), [role=\"status\"], [role=\"alert\"], [role=\"log\"]", _ = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0", v = 0, y = (e) => (e ?? "").replace(/\s+/g, " ").trim();
|
|
6
|
+
function b(e) {
|
|
7
|
+
if (e.matches(g)) return y(e.textContent);
|
|
8
|
+
let t = [...e.querySelectorAll(g), ...e.shadowRoot ? e.shadowRoot.querySelectorAll(g) : []];
|
|
9
|
+
return t.length ? y(t.map((e) => e.textContent).join(" ")) : y(e.textContent);
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
+
function x(e, t, n = null) {
|
|
11
12
|
let r = e;
|
|
12
13
|
if (r.moveBefore && e.isConnected && t.isConnected) try {
|
|
13
14
|
r.moveBefore(t, n);
|
|
@@ -15,16 +16,16 @@ function y(e, t, n = null) {
|
|
|
15
16
|
} catch {}
|
|
16
17
|
e.insertBefore(t, n);
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function S() {
|
|
19
20
|
let e = document.activeElement;
|
|
20
21
|
for (; e?.shadowRoot?.activeElement;) e = e.shadowRoot.activeElement;
|
|
21
22
|
return e;
|
|
22
23
|
}
|
|
23
|
-
var
|
|
24
|
+
var C = class extends s {
|
|
24
25
|
constructor(...e) {
|
|
25
|
-
super(...e), this.label =
|
|
26
|
+
super(...e), this.label = f, this.breakpoint = p, this.count = 0, this.live = "", this.narrow = !1, this.isOpen = !1, this.uid = `${d}-${++v}`, this.internals = u(this), this.liveLast = /* @__PURE__ */ new Map(), this.warned = !1, this.onMedia = (e) => this.setNarrow(e.matches), this.onToggle = () => {
|
|
26
27
|
this.isOpen || (this.show(), this.isOpen && c(this, [
|
|
27
|
-
|
|
28
|
+
d,
|
|
28
29
|
"open",
|
|
29
30
|
this.label
|
|
30
31
|
]));
|
|
@@ -157,6 +158,7 @@ var x = class extends s {
|
|
|
157
158
|
font-size: 1.25rem;
|
|
158
159
|
line-height: 1.2;
|
|
159
160
|
overflow-wrap: anywhere;
|
|
161
|
+
text-wrap: balance;
|
|
160
162
|
}
|
|
161
163
|
.fd-panel > .fd-body {
|
|
162
164
|
padding: 1rem;
|
|
@@ -212,7 +214,7 @@ var x = class extends s {
|
|
|
212
214
|
let e = this.ownerDocument.createElement("div");
|
|
213
215
|
if (e.className = "fd-body", e.setAttribute("part", "body"), this.body = e, this.lightDom) {
|
|
214
216
|
this.prepend(e);
|
|
215
|
-
for (let t of [...this.childNodes]) t !== e &&
|
|
217
|
+
for (let t of [...this.childNodes]) t !== e && x(e, t);
|
|
216
218
|
} else e.append(this.ownerDocument.createElement("slot"));
|
|
217
219
|
}
|
|
218
220
|
this.lightDom && this.hasUpdated && this.watchChildren(), this.watchMedia();
|
|
@@ -225,17 +227,17 @@ var x = class extends s {
|
|
|
225
227
|
}
|
|
226
228
|
adopt() {
|
|
227
229
|
let e = this.body;
|
|
228
|
-
if (e && this.own) for (let t of [...this.childNodes]) this.own.has(t) || t === e || t.nodeType !== Node.COMMENT_NODE && (t.nodeType !== Node.TEXT_NODE ||
|
|
230
|
+
if (e && this.own) for (let t of [...this.childNodes]) this.own.has(t) || t === e || t.nodeType !== Node.COMMENT_NODE && (t.nodeType !== Node.TEXT_NODE || y(t.textContent)) && x(e, t);
|
|
229
231
|
}
|
|
230
232
|
get query() {
|
|
231
|
-
let e =
|
|
232
|
-
return
|
|
233
|
+
let e = y(this.breakpoint);
|
|
234
|
+
return m.test(e) ? `(max-width: ${e})` : (this.warned || (this.warned = !0, console.warn(`${d}: breakpoint "${this.breakpoint}" is not a length such as 48rem or 768px; using ${p}.`)), `(max-width: ${p})`);
|
|
233
235
|
}
|
|
234
236
|
watchMedia() {
|
|
235
237
|
this.media?.removeEventListener("change", this.onMedia), this.media = window.matchMedia(this.query), this.media.addEventListener("change", this.onMedia), this.setNarrow(this.media.matches);
|
|
236
238
|
}
|
|
237
239
|
setNarrow(e) {
|
|
238
|
-
e !== this.narrow && (!e && this.isOpen && (this.refocus =
|
|
240
|
+
e !== this.narrow && (!e && this.isOpen && (this.refocus = S(), this.closeReason = "resize", this.close()), this.narrow = e);
|
|
239
241
|
}
|
|
240
242
|
willUpdate(e) {
|
|
241
243
|
e.has("breakpoint") && this.hasUpdated && this.isConnected && (this.warned = !1, this.watchMedia());
|
|
@@ -244,13 +246,13 @@ var x = class extends s {
|
|
|
244
246
|
this.lightDom && (this.own = new Set(this.childNodes), this.watchChildren());
|
|
245
247
|
}
|
|
246
248
|
updated(e) {
|
|
247
|
-
super.updated(e), this.place(), e.has("live") && this.isOpen && this.startMirror();
|
|
249
|
+
super.updated(e), l(this.internals, "modal", this.narrow), l(this.internals, "open", this.isOpen), this.place(), e.has("live") && this.isOpen && this.startMirror();
|
|
248
250
|
}
|
|
249
251
|
place() {
|
|
250
252
|
let e = this.body;
|
|
251
253
|
if (!e) return;
|
|
252
254
|
let t = this.narrow ? this.root.querySelector(".fd-panel") : this.root.querySelector(".fd-sidebar");
|
|
253
|
-
t && e.parentNode !== t &&
|
|
255
|
+
t && e.parentNode !== t && x(t, e, this.narrow ? this.mirror : null);
|
|
254
256
|
}
|
|
255
257
|
show() {
|
|
256
258
|
let e = this.dialog;
|
|
@@ -263,7 +265,7 @@ var x = class extends s {
|
|
|
263
265
|
if (!this.isOpen) return;
|
|
264
266
|
let e = this.closeReason ?? "visitor";
|
|
265
267
|
if (this.closeReason = void 0, this.isOpen = !1, this.stopMirror(), e === "visitor" && c(this, [
|
|
266
|
-
|
|
268
|
+
d,
|
|
267
269
|
"close",
|
|
268
270
|
this.label
|
|
269
271
|
]), e === "resize") {
|
|
@@ -276,7 +278,7 @@ var x = class extends s {
|
|
|
276
278
|
}
|
|
277
279
|
startMirror() {
|
|
278
280
|
this.stopMirror();
|
|
279
|
-
let e = this.getRootNode(), t =
|
|
281
|
+
let e = this.getRootNode(), t = y(this.live).split(" ").filter(Boolean);
|
|
280
282
|
if (!t.length) return;
|
|
281
283
|
let n = new MutationObserver(() => this.checkLive()), r = {
|
|
282
284
|
childList: !0,
|
|
@@ -285,7 +287,7 @@ var x = class extends s {
|
|
|
285
287
|
};
|
|
286
288
|
for (let i of t) {
|
|
287
289
|
let t = e.getElementById?.(i) ?? document.getElementById(i);
|
|
288
|
-
t && !this.contains(t) && (this.liveLast.set(t,
|
|
290
|
+
t && !this.contains(t) && (this.liveLast.set(t, b(t)), n.observe(t, r), t.shadowRoot && n.observe(t.shadowRoot, r));
|
|
289
291
|
}
|
|
290
292
|
this.liveObserver = n;
|
|
291
293
|
}
|
|
@@ -296,18 +298,18 @@ var x = class extends s {
|
|
|
296
298
|
}
|
|
297
299
|
checkLive() {
|
|
298
300
|
for (let [e, t] of this.liveLast) {
|
|
299
|
-
let n =
|
|
301
|
+
let n = b(e);
|
|
300
302
|
n !== t && (this.liveLast.set(e, n), n && this.announce(n));
|
|
301
303
|
}
|
|
302
304
|
}
|
|
303
305
|
announce(e) {
|
|
304
306
|
let t = this.mirror;
|
|
305
307
|
t && (clearTimeout(this.clearTimer), t.textContent = "", requestAnimationFrame(() => {
|
|
306
|
-
this.isOpen && (t.textContent = e, this.clearTimer = setTimeout(() => t.textContent = "",
|
|
308
|
+
this.isOpen && (t.textContent = e, this.clearTimer = setTimeout(() => t.textContent = "", h));
|
|
307
309
|
}));
|
|
308
310
|
}
|
|
309
311
|
render() {
|
|
310
|
-
let e =
|
|
312
|
+
let e = y(this.label) || f, t = Number.isFinite(this.count) && this.count > 0 ? Math.trunc(this.count) : 0, n = `${this.uid}-dialog`, i = `${this.uid}-heading`;
|
|
311
313
|
return r`<button
|
|
312
314
|
type="button"
|
|
313
315
|
class="fd-toggle"
|
|
@@ -343,13 +345,13 @@ var x = class extends s {
|
|
|
343
345
|
role="status"
|
|
344
346
|
aria-live="polite"
|
|
345
347
|
aria-atomic="true"
|
|
346
|
-
style=${
|
|
348
|
+
style=${_}
|
|
347
349
|
></div>
|
|
348
350
|
</div>
|
|
349
351
|
</dialog>`;
|
|
350
352
|
}
|
|
351
353
|
};
|
|
352
354
|
// src/components/uvalib-filter-drawer/uvalib-filter-drawer.ts
|
|
353
|
-
a([e({ type: String })],
|
|
355
|
+
a([e({ type: String })], C.prototype, "label", void 0), a([e({ type: String })], C.prototype, "breakpoint", void 0), a([e({ type: Number })], C.prototype, "count", void 0), a([e({ type: String })], C.prototype, "live", void 0), a([n()], C.prototype, "narrow", void 0), a([n()], C.prototype, "isOpen", void 0), i("uvalib-filter-drawer", C);
|
|
354
356
|
|
|
355
357
|
//# sourceMappingURL=uvalib-filter-drawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uvalib-filter-drawer.js","names":["nothing","_decorate","property","state","n","i","r","b","define","__decorate","UvalibElement","trackEvent","TAG","DEFAULT_LABEL","DEFAULT_BREAKPOINT","LENGTH","CLEAR_MS","LIVE","HIDDEN_STYLE","instances","squash","s","liveText","el","regions","move","p","parent","node","before","deepActive","a","UvalibFilterDrawer","_args","dialog","body","bp","narrow","changed","target","reason","back","root","ids","observer","opts","id","mirror","last","text","label","count","dialogId","headingId","A"],"sources":["../src/components/uvalib-filter-drawer/UvalibFilterDrawer.ts","../src/components/uvalib-filter-drawer/uvalib-filter-drawer.ts"],"sourcesContent":["import { css, html, nothing, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\n\nconst TAG = 'uvalib-filter-drawer';\nconst DEFAULT_LABEL = 'Search and filters';\nconst DEFAULT_BREAKPOINT = '48rem';\n/** A breakpoint is a plain length: `48rem`, `768px`, `40em`. */\nconst LENGTH = /^\\d+(\\.\\d+)?(px|rem|em)$/;\n/** How long a mirrored announcement stays in the drawer's live region. */\nconst CLEAR_MS = 5000;\n/** What counts as a live region inside an element named in `live`. */\nconst LIVE = '[aria-live]:not([aria-live=\"off\"]), [role=\"status\"], [role=\"alert\"], [role=\"log\"]';\n/** Visually hidden, kept with `no-style` so the mirror never shows. */\nconst HIDDEN_STYLE =\n 'position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0';\n\nlet instances = 0;\n\nconst squash = (s: string | null | undefined) => (s ?? '').replace(/\\s+/g, ' ').trim();\n\n/** The text a live element would announce: its live regions' text (also in its open shadow root), else its own. */\nfunction liveText(el: Element): string {\n if (el.matches(LIVE)) return squash(el.textContent);\n const regions = [\n ...el.querySelectorAll(LIVE),\n ...(el.shadowRoot ? el.shadowRoot.querySelectorAll(LIVE) : []),\n ];\n return regions.length\n ? squash(regions.map((r) => r.textContent).join(' '))\n : squash(el.textContent);\n}\n\n/** Move `node` into `parent` before `before`, keeping its state (`moveBefore`) where the browser can. */\nfunction move(parent: Node, node: Node, before: Node | null = null): void {\n const p = parent as Node & { moveBefore?: (n: Node, c: Node | null) => void };\n if (p.moveBefore && parent.isConnected && node.isConnected) {\n try {\n p.moveBefore(node, before);\n return;\n } catch {\n // Not movable atomically (another document, say): insert instead.\n }\n }\n parent.insertBefore(node, before);\n}\n\n/** The focused element, through open shadow roots. */\nfunction deepActive(): Element | null {\n let a = document.activeElement;\n while (a?.shadowRoot?.activeElement) a = a.shadowRoot.activeElement;\n return a;\n}\n\n/**\n * A search page's form and filters: a plain sidebar on wide screens, and on narrow ones a\n * “Search and filters” button that opens them in a modal panel from the side.\n *\n * Put the page's search form, `<uvalib-filter>`s and other facets inside. Above `breakpoint`\n * (default `48rem`) they are shown as written: no button, no dialog role. At and below it only\n * the button is shown; it opens a native `<dialog>` (`showModal()`) with a visible heading (the\n * `label`) and a 44px Close button, which takes focus. Escape, Close and a click on the backdrop\n * close it, and focus returns to the button; widening the window past the breakpoint closes it\n * and keeps focus where it was. While it is open the rest of the page, including `<site-page>`'s\n * header, skip link and alerts, is inert (the browser's modal dialog), so focus cannot leave it\n * except to the browser itself, and nothing else is announced. The children are the same nodes\n * in both layouts (moved, never re-created): typed text, checked boxes, listeners and each\n * filter's state are kept.\n *\n * Inert content is not announced, so results counts and status notices outside the panel would\n * go silent while the visitor filters: name them in `live` (space-separated ids) and the drawer\n * repeats what they announce in its own polite live region while it is open.\n *\n * `count` (the page's number of active filters) is shown on the button when above 0. The\n * drawer never counts by itself: only the page knows which inputs are filters.\n *\n * @tagname uvalib-filter-drawer\n * @slot - The search form and filters. Shown as the sidebar on wide screens and inside the panel on narrow ones.\n * @fires open - The panel opened. Does not bubble.\n * @fires close - The panel closed (Close, Escape, the backdrop, `close()`, or the window widening past the breakpoint). Does not bubble.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-filter-drawer', 'open', '<label>']` when the visitor opens the panel, and `['uvalib-filter-drawer', 'close', '<label>']` when they close it (Close, Escape or the backdrop; not when the window widens or a script closes it). Bubbles and is composed.\n * @csspart toggle - The “Search and filters” button (narrow screens only).\n * @csspart count - The number of active filters on the button.\n * @csspart sidebar - The wrapper of the children on wide screens.\n * @csspart dialog - The `<dialog>` panel.\n * @csspart header - The panel's heading row.\n * @csspart heading - The panel's heading.\n * @csspart close - The Close button.\n * @csspart body - The wrapper of the children, in the sidebar or the panel.\n * @cssprop [--uvalib-filter-drawer-width=min(24rem, 100% - 3rem)] - The panel's width.\n * @cssprop --uva-color-surface - Dark-mode role token: panel background (else #fff).\n * @cssprop --uva-color-text - Dark-mode role token: panel text (else #2b2b2b).\n * @cssprop --uva-color-border - Dark-mode role token: panel edge and heading rule (else #dadada).\n * @cssprop --uva-color-button-bg - Dark-mode role token: button border and text, the count's background (else `--uva-blue-alt`, #007bac).\n * @cssprop --uva-color-button-hover-bg - Dark-mode role token: hovered button (else `--uva-blue-alt-A`, #005679).\n * @cssprop --uva-color-button-text - Dark-mode role token: the count's text (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibFilterDrawer extends UvalibElement {\n static styles = css`\n :host {\n display: block;\n }\n :host([hidden]) {\n display: none;\n }\n .fd-toggle,\n .fd-close {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\n box-sizing: border-box;\n min-block-size: 44px;\n min-inline-size: 44px;\n margin: 0;\n padding: 0.5rem 1.25rem;\n border: 2px solid var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));\n border-radius: 5px;\n background: transparent;\n color: var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));\n font: inherit;\n font-size: 1rem;\n line-height: 1.2;\n cursor: pointer;\n }\n /* Top-aligned, so the host's line is exactly the button's height whatever the page's font\n and line height (base.css holds that height before the element upgrades). */\n .fd-toggle {\n vertical-align: top;\n }\n .fd-close {\n padding-inline: 0.875rem;\n }\n .fd-toggle:hover,\n .fd-close:hover {\n border-color: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));\n color: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));\n }\n .fd-toggle[hidden] {\n display: none;\n }\n .fd-toggle:focus-visible,\n .fd-close:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n .fd-count {\n display: inline-flex;\n justify-content: center;\n min-inline-size: 1.5em;\n padding: 0.1em 0.4em;\n box-sizing: border-box;\n border-radius: 999px;\n background: var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));\n color: var(--uva-color-button-text, #fff);\n font-size: 0.875rem;\n font-weight: 700;\n line-height: 1.2;\n }\n .fd-vh {\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 .fd-dialog {\n box-sizing: border-box;\n position: fixed;\n inset: 0 auto 0 0;\n inline-size: var(--uvalib-filter-drawer-width, min(24rem, 100% - 3rem));\n max-inline-size: none;\n block-size: 100%;\n max-block-size: none;\n margin: 0;\n padding: 0;\n border: 0;\n border-inline-end: 1px solid var(--uva-color-border, #dadada);\n background: var(--uva-color-surface, #fff);\n color: var(--uva-color-text, #2b2b2b);\n overflow: auto;\n overscroll-behavior: contain;\n }\n .fd-dialog:dir(rtl) {\n inset: 0 0 0 auto;\n }\n .fd-dialog::backdrop {\n background: rgb(0 0 0 / 0.5);\n }\n .fd-panel {\n display: flex;\n flex-direction: column;\n min-block-size: 100%;\n }\n .fd-head {\n position: sticky;\n top: 0;\n z-index: 1;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 1rem;\n padding: 0.75rem 1rem;\n border-block-end: 1px solid var(--uva-color-border, #dadada);\n background: var(--uva-color-surface, #fff);\n }\n .fd-heading {\n margin: 0;\n font-size: 1.25rem;\n line-height: 1.2;\n overflow-wrap: anywhere;\n }\n .fd-panel > .fd-body {\n padding: 1rem;\n }\n @media (prefers-reduced-motion: no-preference) {\n .fd-dialog[open] {\n animation: uvalib-filter-drawer-in 0.2s ease-out;\n }\n .fd-dialog[open]:dir(rtl) {\n animation-name: uvalib-filter-drawer-in-rtl;\n }\n }\n @keyframes uvalib-filter-drawer-in {\n from {\n transform: translateX(-100%);\n }\n }\n @keyframes uvalib-filter-drawer-in-rtl {\n from {\n transform: translateX(100%);\n }\n }\n @media (forced-colors: active) {\n .fd-dialog {\n border-inline-end: 2px solid CanvasText;\n }\n .fd-count {\n border: 1px solid CanvasText;\n }\n }\n `;\n\n /** The button's text, the panel's heading and the dialog's name. */\n @property({ type: String }) label = DEFAULT_LABEL;\n\n /** The widest viewport that gets the button and panel (`48rem`, `768px`); wider gets the sidebar. */\n @property({ type: String }) breakpoint = DEFAULT_BREAKPOINT;\n\n /** Active filters, set by the page; shown on the button when above 0. */\n @property({ type: Number }) count = 0;\n\n /** Space-separated ids of live regions outside the drawer (a results count, a status notice) to keep announcing while the panel is open. */\n @property({ type: String }) live = '';\n\n /** Whether the viewport is at or below the breakpoint. */\n @state() private narrow = false;\n\n /** Whether the panel is open. */\n @state() private isOpen = false;\n\n private readonly uid = `${TAG}-${++instances}`;\n private media?: MediaQueryList;\n private body?: HTMLDivElement;\n /** Light mode: the nodes this element rendered (never adopted as content). */\n private own?: Set<Node>;\n private childObserver?: MutationObserver;\n private liveObserver?: MutationObserver;\n private liveLast = new Map<Element, string>();\n private clearTimer?: ReturnType<typeof setTimeout>;\n private warned = false;\n /** Why the panel is closing: the visitor (reported), a resize, or a script. */\n private closeReason?: 'visitor' | 'resize' | 'script';\n /** Focus to restore after a resize closes the panel. */\n private refocus?: Element | null;\n\n /** Whether the panel is open. */\n get open(): boolean {\n return this.isOpen;\n }\n\n private get root(): ParentNode {\n return this.renderRoot as ParentNode;\n }\n private get dialog(): HTMLDialogElement | null {\n return this.root.querySelector<HTMLDialogElement>('dialog.fd-dialog');\n }\n private get toggle(): HTMLButtonElement | null {\n return this.root.querySelector<HTMLButtonElement>('button.fd-toggle');\n }\n private get closeButton(): HTMLButtonElement | null {\n return this.root.querySelector<HTMLButtonElement>('button.fd-close');\n }\n private get mirror(): HTMLElement | null {\n return this.root.querySelector<HTMLElement>('.fd-mirror');\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.body) {\n const body = this.ownerDocument.createElement('div');\n body.className = 'fd-body';\n body.setAttribute('part', 'body');\n this.body = body;\n if (this.lightDom) {\n this.prepend(body);\n for (const n of [...this.childNodes]) if (n !== body) move(body, n);\n } else {\n body.append(this.ownerDocument.createElement('slot'));\n }\n }\n if (this.lightDom && this.hasUpdated) this.watchChildren();\n this.watchMedia();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.media?.removeEventListener('change', this.onMedia);\n this.media = undefined;\n this.childObserver?.disconnect();\n this.stopMirror();\n if (this.isOpen) {\n this.isOpen = false;\n this.closeReason = undefined;\n this.dialog?.close();\n this.dispatchEvent(new Event('close'));\n }\n }\n\n /** Light mode: children the page adds later go into the body too. */\n private watchChildren(): void {\n this.childObserver ??= new MutationObserver(() => this.adopt());\n this.childObserver.observe(this, { childList: true });\n this.adopt();\n }\n\n private adopt(): void {\n const body = this.body;\n if (!body || !this.own) return;\n for (const n of [...this.childNodes]) {\n if (this.own.has(n) || n === body) continue;\n if (n.nodeType === Node.COMMENT_NODE) continue;\n if (n.nodeType === Node.TEXT_NODE && !squash(n.textContent)) continue;\n move(body, n);\n }\n }\n\n private get query(): string {\n const bp = squash(this.breakpoint);\n if (LENGTH.test(bp)) return `(max-width: ${bp})`;\n if (!this.warned) {\n this.warned = true;\n console.warn(\n `${TAG}: breakpoint \"${this.breakpoint}\" is not a length such as 48rem or 768px; using ${DEFAULT_BREAKPOINT}.`,\n );\n }\n return `(max-width: ${DEFAULT_BREAKPOINT})`;\n }\n\n private watchMedia(): void {\n this.media?.removeEventListener('change', this.onMedia);\n this.media = window.matchMedia(this.query);\n this.media.addEventListener('change', this.onMedia);\n this.setNarrow(this.media.matches);\n }\n\n private readonly onMedia = (e: MediaQueryListEvent): void => this.setNarrow(e.matches);\n\n private setNarrow(narrow: boolean): void {\n if (narrow === this.narrow) return;\n if (!narrow && this.isOpen) {\n this.refocus = deepActive();\n this.closeReason = 'resize';\n this.close();\n }\n this.narrow = narrow;\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('breakpoint') && this.hasUpdated && this.isConnected) {\n this.warned = false;\n this.watchMedia();\n }\n }\n\n protected override firstUpdated(): void {\n if (this.lightDom) {\n this.own = new Set(this.childNodes);\n this.watchChildren();\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.place();\n if (changed.has('live') && this.isOpen) this.startMirror();\n }\n\n /** Put the body in the sidebar (wide) or the panel (narrow): the same nodes, moved. */\n private place(): void {\n const body = this.body;\n if (!body) return;\n const target = this.narrow\n ? this.root.querySelector('.fd-panel')\n : this.root.querySelector('.fd-sidebar');\n if (!target || body.parentNode === target) return;\n move(target, body, this.narrow ? this.mirror : null);\n }\n\n /** Open the panel (narrow screens only; wide screens always show the filters). */\n show(): void {\n const dialog = this.dialog;\n if (!this.narrow || this.isOpen || !dialog) return;\n this.place();\n dialog.showModal();\n this.isOpen = true;\n this.closeReason = undefined;\n this.closeButton?.focus();\n this.startMirror();\n this.dispatchEvent(new Event('open'));\n }\n\n /** Close the panel. */\n close(): void {\n if (!this.isOpen) return;\n this.closeReason ??= 'script';\n this.dialog?.close();\n this.closed();\n }\n\n private readonly onToggle = (): void => {\n if (this.isOpen) return;\n this.show();\n if (this.isOpen) trackEvent(this, [TAG, 'open', this.label]);\n };\n\n private readonly onCloseClick = (): void => {\n this.closeReason = 'visitor';\n this.close();\n };\n\n private readonly onCancel = (): void => {\n this.closeReason = 'visitor';\n };\n\n private readonly onDialogClick = (e: MouseEvent): void => {\n const dialog = this.dialog;\n if (!dialog || e.target !== dialog) return;\n const r = dialog.getBoundingClientRect();\n const inside =\n e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom;\n if (inside) return;\n this.closeReason = 'visitor';\n this.close();\n };\n\n /** The dialog's own close event: settles an Escape (or any close not made by `close()`). */\n private readonly onDialogClose = (): void => this.closed();\n\n /** The panel has closed, however it happened: report, restore focus, tell the page. */\n private closed(): void {\n if (!this.isOpen) return;\n // An Escape the browser closed without a cancel event is still the visitor's.\n const reason = this.closeReason ?? 'visitor';\n this.closeReason = undefined;\n this.isOpen = false;\n this.stopMirror();\n if (reason === 'visitor') trackEvent(this, [TAG, 'close', this.label]);\n if (reason === 'resize') {\n const back = this.refocus;\n this.refocus = undefined;\n void this.updateComplete.then(() => {\n if (back instanceof HTMLElement && back.isConnected) back.focus({ preventScroll: true });\n });\n } else if (this.narrow) {\n this.toggle?.focus();\n }\n this.dispatchEvent(new Event('close'));\n }\n\n // ---------------------------------------------------------------- live mirror\n\n private startMirror(): void {\n this.stopMirror();\n const root = this.getRootNode() as Document | ShadowRoot;\n const ids = squash(this.live).split(' ').filter(Boolean);\n if (!ids.length) return;\n const observer = new MutationObserver(() => this.checkLive());\n const opts: MutationObserverInit = { childList: true, subtree: true, characterData: true };\n for (const id of ids) {\n const el = root.getElementById?.(id) ?? document.getElementById(id);\n if (!el || this.contains(el)) continue; // inside the drawer it is not inert\n this.liveLast.set(el, liveText(el));\n observer.observe(el, opts);\n if (el.shadowRoot) observer.observe(el.shadowRoot, opts);\n }\n this.liveObserver = observer;\n }\n\n private stopMirror(): void {\n this.liveObserver?.disconnect();\n this.liveObserver = undefined;\n this.liveLast.clear();\n clearTimeout(this.clearTimer);\n const mirror = this.mirror;\n if (mirror) mirror.textContent = '';\n }\n\n private checkLive(): void {\n for (const [el, last] of this.liveLast) {\n const text = liveText(el);\n if (text === last) continue;\n this.liveLast.set(el, text);\n if (text) this.announce(text);\n }\n }\n\n private announce(text: string): void {\n const mirror = this.mirror;\n if (!mirror) return;\n clearTimeout(this.clearTimer);\n // The same words still in the region would not be read again: empty it first.\n mirror.textContent = '';\n requestAnimationFrame(() => {\n if (!this.isOpen) return;\n mirror.textContent = text;\n this.clearTimer = setTimeout(() => (mirror.textContent = ''), CLEAR_MS);\n });\n }\n\n protected override render() {\n const label = squash(this.label) || DEFAULT_LABEL;\n const count = Number.isFinite(this.count) && this.count > 0 ? Math.trunc(this.count) : 0;\n const dialogId = `${this.uid}-dialog`;\n const headingId = `${this.uid}-heading`;\n return html`<button\n type=\"button\"\n class=\"fd-toggle\"\n part=\"toggle\"\n aria-haspopup=\"dialog\"\n aria-expanded=${this.isOpen ? 'true' : 'false'}\n aria-controls=${dialogId}\n ?hidden=${!this.narrow}\n @click=${this.onToggle}\n >\n <span>${label}</span>${\n count\n ? html`<span class=\"fd-vh\">, </span><span class=\"fd-count\" part=\"count\">${count}</span\n ><span class=\"fd-vh\"> active</span>`\n : nothing\n }\n </button>\n <div class=\"fd-sidebar\" part=\"sidebar\"></div>\n <dialog\n id=${dialogId}\n class=\"fd-dialog\"\n part=\"dialog\"\n aria-labelledby=${headingId}\n @cancel=${this.onCancel}\n @close=${this.onDialogClose}\n @click=${this.onDialogClick}\n >\n <div class=\"fd-panel\">\n <div class=\"fd-head\" part=\"header\">\n <h2 class=\"fd-heading\" part=\"heading\" id=${headingId}>${label}</h2>\n <button type=\"button\" class=\"fd-close\" part=\"close\" @click=${this.onCloseClick}>\n Close\n </button>\n </div>\n <div\n class=\"fd-mirror\"\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n style=${HIDDEN_STYLE}\n ></div>\n </div>\n </dialog>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibFilterDrawer } from './UvalibFilterDrawer.js';\n\ndefine('uvalib-filter-drawer', UvalibFilterDrawer);\n"],"mappings":";;;AAKA,IAAMY,IAAM,wBACNC,IAAgB,sBAChBC,IAAqB,SAErBC,IAAS,4BAETC,IAAW,KAEXC,IAAO,6FAEPC,IACJ,+HAEEC,IAAY,GAEVC,KAAU,OAAkCC,KAAK,GAAA,CAAI,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK;AAGrF,SAASC,EAAS,GAAqB;CACrC,IAAIC,EAAG,QAAQN,CAAI,GAAG,OAAOG,EAAOG,EAAG,WAAW;CAClD,IAAMC,IAAU,CACd,GAAG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AE,EAAM,CAAA,GAAA6B,EAAA,WAAA,UAAA,KAAA,CAAA,GAGN/B,EAAA,CAAAE,EAAM,CAAA,GAAA6B,EAAA,WAAA,UAAA,KAAA,CAAA,GCtQTxB,EAAO,wBAAwBwB,CAAkB"}
|
|
1
|
+
{"version":3,"file":"uvalib-filter-drawer.js","names":["nothing","_decorate","property","state","n","i","r","b","define","__decorate","UvalibElement","trackEvent","setState","attachStateInternals","TAG","DEFAULT_LABEL","DEFAULT_BREAKPOINT","LENGTH","CLEAR_MS","LIVE","HIDDEN_STYLE","instances","squash","s","liveText","el","regions","move","p","parent","node","before","deepActive","a","UvalibFilterDrawer","_args","dialog","body","bp","narrow","changed","target","reason","back","root","ids","observer","opts","id","mirror","last","text","label","count","dialogId","headingId","A"],"sources":["../src/components/uvalib-filter-drawer/UvalibFilterDrawer.ts","../src/components/uvalib-filter-drawer/uvalib-filter-drawer.ts"],"sourcesContent":["import { css, html, nothing, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { attachStateInternals, setState } from '../../base/states.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\n\nconst TAG = 'uvalib-filter-drawer';\nconst DEFAULT_LABEL = 'Search and filters';\nconst DEFAULT_BREAKPOINT = '48rem';\n/** A breakpoint is a plain length: `48rem`, `768px`, `40em`. */\nconst LENGTH = /^\\d+(\\.\\d+)?(px|rem|em)$/;\n/** How long a mirrored announcement stays in the drawer's live region. */\nconst CLEAR_MS = 5000;\n/** What counts as a live region inside an element named in `live`. */\nconst LIVE = '[aria-live]:not([aria-live=\"off\"]), [role=\"status\"], [role=\"alert\"], [role=\"log\"]';\n/** Visually hidden, kept with `no-style` so the mirror never shows. */\nconst HIDDEN_STYLE =\n 'position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0';\n\nlet instances = 0;\n\nconst squash = (s: string | null | undefined) => (s ?? '').replace(/\\s+/g, ' ').trim();\n\n/** The text a live element would announce: its live regions' text (also in its open shadow root), else its own. */\nfunction liveText(el: Element): string {\n if (el.matches(LIVE)) return squash(el.textContent);\n const regions = [\n ...el.querySelectorAll(LIVE),\n ...(el.shadowRoot ? el.shadowRoot.querySelectorAll(LIVE) : []),\n ];\n return regions.length\n ? squash(regions.map((r) => r.textContent).join(' '))\n : squash(el.textContent);\n}\n\n/** Move `node` into `parent` before `before`, keeping its state (`moveBefore`) where the browser can. */\nfunction move(parent: Node, node: Node, before: Node | null = null): void {\n const p = parent as Node & { moveBefore?: (n: Node, c: Node | null) => void };\n if (p.moveBefore && parent.isConnected && node.isConnected) {\n try {\n p.moveBefore(node, before);\n return;\n } catch {\n // Not movable atomically (another document, say): insert instead.\n }\n }\n parent.insertBefore(node, before);\n}\n\n/** The focused element, through open shadow roots. */\nfunction deepActive(): Element | null {\n let a = document.activeElement;\n while (a?.shadowRoot?.activeElement) a = a.shadowRoot.activeElement;\n return a;\n}\n\n/**\n * A search page's form and filters: a plain sidebar on wide screens, and on narrow ones a\n * “Search and filters” button that opens them in a modal panel from the side.\n *\n * Put the page's search form, `<uvalib-filter>`s and other facets inside. Above `breakpoint`\n * (default `48rem`) they are shown as written: no button, no dialog role. At and below it only\n * the button is shown; it opens a native `<dialog>` (`showModal()`) with a visible heading (the\n * `label`) and a 44px Close button, which takes focus. Escape, Close and a click on the backdrop\n * close it, and focus returns to the button; widening the window past the breakpoint closes it\n * and keeps focus where it was. While it is open the rest of the page, including `<site-page>`'s\n * header, skip link and alerts, is inert (the browser's modal dialog), so focus cannot leave it\n * except to the browser itself, and nothing else is announced. The children are the same nodes\n * in both layouts (moved, never re-created): typed text, checked boxes, listeners and each\n * filter's state are kept.\n *\n * Inert content is not announced, so results counts and status notices outside the panel would\n * go silent while the visitor filters: name them in `live` (space-separated ids) and the drawer\n * repeats what they announce in its own polite live region while it is open.\n *\n * `count` (the page's number of active filters) is shown on the button when above 0. The\n * drawer never counts by itself: only the page knows which inputs are filters.\n *\n * Pages can style the runtime layout with `:state(modal)` (at or below the breakpoint: the\n * button and panel) and `:state(open)` (the panel is open).\n *\n * @tagname uvalib-filter-drawer\n * @slot - The search form and filters. Shown as the sidebar on wide screens and inside the panel on narrow ones.\n * @fires open - The panel opened. Does not bubble.\n * @fires close - The panel closed (Close, Escape, the backdrop, `close()`, or the window widening past the breakpoint). Does not bubble.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-filter-drawer', 'open', '<label>']` when the visitor opens the panel, and `['uvalib-filter-drawer', 'close', '<label>']` when they close it (Close, Escape or the backdrop; not when the window widens or a script closes it). Bubbles and is composed.\n * @cssstate modal - The viewport is at or below the breakpoint: the button and panel, not the sidebar.\n * @cssstate open - The panel is open.\n * @csspart toggle - The “Search and filters” button (narrow screens only).\n * @csspart count - The number of active filters on the button.\n * @csspart sidebar - The wrapper of the children on wide screens.\n * @csspart dialog - The `<dialog>` panel.\n * @csspart header - The panel's heading row.\n * @csspart heading - The panel's heading.\n * @csspart close - The Close button.\n * @csspart body - The wrapper of the children, in the sidebar or the panel.\n * @cssprop [--uvalib-filter-drawer-width=min(24rem, 100% - 3rem)] - The panel's width.\n * @cssprop --uva-color-surface - Dark-mode role token: panel background (else #fff).\n * @cssprop --uva-color-text - Dark-mode role token: panel text (else #2b2b2b).\n * @cssprop --uva-color-border - Dark-mode role token: panel edge and heading rule (else #dadada).\n * @cssprop --uva-color-button-bg - Dark-mode role token: button border and text, the count's background (else `--uva-blue-alt`, #007bac).\n * @cssprop --uva-color-button-hover-bg - Dark-mode role token: hovered button (else `--uva-blue-alt-A`, #005679).\n * @cssprop --uva-color-button-text - Dark-mode role token: the count's text (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibFilterDrawer extends UvalibElement {\n static styles = css`\n :host {\n display: block;\n }\n :host([hidden]) {\n display: none;\n }\n .fd-toggle,\n .fd-close {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\n box-sizing: border-box;\n min-block-size: 44px;\n min-inline-size: 44px;\n margin: 0;\n padding: 0.5rem 1.25rem;\n border: 2px solid var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));\n border-radius: 5px;\n background: transparent;\n color: var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));\n font: inherit;\n font-size: 1rem;\n line-height: 1.2;\n cursor: pointer;\n }\n /* Top-aligned, so the host's line is exactly the button's height whatever the page's font\n and line height (base.css holds that height before the element upgrades). */\n .fd-toggle {\n vertical-align: top;\n }\n .fd-close {\n padding-inline: 0.875rem;\n }\n .fd-toggle:hover,\n .fd-close:hover {\n border-color: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));\n color: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));\n }\n .fd-toggle[hidden] {\n display: none;\n }\n .fd-toggle:focus-visible,\n .fd-close:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n .fd-count {\n display: inline-flex;\n justify-content: center;\n min-inline-size: 1.5em;\n padding: 0.1em 0.4em;\n box-sizing: border-box;\n border-radius: 999px;\n background: var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));\n color: var(--uva-color-button-text, #fff);\n font-size: 0.875rem;\n font-weight: 700;\n line-height: 1.2;\n }\n .fd-vh {\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 .fd-dialog {\n box-sizing: border-box;\n position: fixed;\n inset: 0 auto 0 0;\n inline-size: var(--uvalib-filter-drawer-width, min(24rem, 100% - 3rem));\n max-inline-size: none;\n block-size: 100%;\n max-block-size: none;\n margin: 0;\n padding: 0;\n border: 0;\n border-inline-end: 1px solid var(--uva-color-border, #dadada);\n background: var(--uva-color-surface, #fff);\n color: var(--uva-color-text, #2b2b2b);\n overflow: auto;\n overscroll-behavior: contain;\n }\n .fd-dialog:dir(rtl) {\n inset: 0 0 0 auto;\n }\n .fd-dialog::backdrop {\n background: rgb(0 0 0 / 0.5);\n }\n .fd-panel {\n display: flex;\n flex-direction: column;\n min-block-size: 100%;\n }\n .fd-head {\n position: sticky;\n top: 0;\n z-index: 1;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 1rem;\n padding: 0.75rem 1rem;\n border-block-end: 1px solid var(--uva-color-border, #dadada);\n background: var(--uva-color-surface, #fff);\n }\n .fd-heading {\n margin: 0;\n font-size: 1.25rem;\n line-height: 1.2;\n overflow-wrap: anywhere;\n text-wrap: balance;\n }\n .fd-panel > .fd-body {\n padding: 1rem;\n }\n @media (prefers-reduced-motion: no-preference) {\n .fd-dialog[open] {\n animation: uvalib-filter-drawer-in 0.2s ease-out;\n }\n .fd-dialog[open]:dir(rtl) {\n animation-name: uvalib-filter-drawer-in-rtl;\n }\n }\n @keyframes uvalib-filter-drawer-in {\n from {\n transform: translateX(-100%);\n }\n }\n @keyframes uvalib-filter-drawer-in-rtl {\n from {\n transform: translateX(100%);\n }\n }\n @media (forced-colors: active) {\n .fd-dialog {\n border-inline-end: 2px solid CanvasText;\n }\n .fd-count {\n border: 1px solid CanvasText;\n }\n }\n `;\n\n /** The button's text, the panel's heading and the dialog's name. */\n @property({ type: String }) label = DEFAULT_LABEL;\n\n /** The widest viewport that gets the button and panel (`48rem`, `768px`); wider gets the sidebar. */\n @property({ type: String }) breakpoint = DEFAULT_BREAKPOINT;\n\n /** Active filters, set by the page; shown on the button when above 0. */\n @property({ type: Number }) count = 0;\n\n /** Space-separated ids of live regions outside the drawer (a results count, a status notice) to keep announcing while the panel is open. */\n @property({ type: String }) live = '';\n\n /** Whether the viewport is at or below the breakpoint. */\n @state() private narrow = false;\n\n /** Whether the panel is open. */\n @state() private isOpen = false;\n\n private readonly uid = `${TAG}-${++instances}`;\n private readonly internals = attachStateInternals(this);\n private media?: MediaQueryList;\n private body?: HTMLDivElement;\n /** Light mode: the nodes this element rendered (never adopted as content). */\n private own?: Set<Node>;\n private childObserver?: MutationObserver;\n private liveObserver?: MutationObserver;\n private liveLast = new Map<Element, string>();\n private clearTimer?: ReturnType<typeof setTimeout>;\n private warned = false;\n /** Why the panel is closing: the visitor (reported), a resize, or a script. */\n private closeReason?: 'visitor' | 'resize' | 'script';\n /** Focus to restore after a resize closes the panel. */\n private refocus?: Element | null;\n\n /** Whether the panel is open. */\n get open(): boolean {\n return this.isOpen;\n }\n\n private get root(): ParentNode {\n return this.renderRoot as ParentNode;\n }\n private get dialog(): HTMLDialogElement | null {\n return this.root.querySelector<HTMLDialogElement>('dialog.fd-dialog');\n }\n private get toggle(): HTMLButtonElement | null {\n return this.root.querySelector<HTMLButtonElement>('button.fd-toggle');\n }\n private get closeButton(): HTMLButtonElement | null {\n return this.root.querySelector<HTMLButtonElement>('button.fd-close');\n }\n private get mirror(): HTMLElement | null {\n return this.root.querySelector<HTMLElement>('.fd-mirror');\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.body) {\n const body = this.ownerDocument.createElement('div');\n body.className = 'fd-body';\n body.setAttribute('part', 'body');\n this.body = body;\n if (this.lightDom) {\n this.prepend(body);\n for (const n of [...this.childNodes]) if (n !== body) move(body, n);\n } else {\n body.append(this.ownerDocument.createElement('slot'));\n }\n }\n if (this.lightDom && this.hasUpdated) this.watchChildren();\n this.watchMedia();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.media?.removeEventListener('change', this.onMedia);\n this.media = undefined;\n this.childObserver?.disconnect();\n this.stopMirror();\n if (this.isOpen) {\n this.isOpen = false;\n this.closeReason = undefined;\n this.dialog?.close();\n this.dispatchEvent(new Event('close'));\n }\n }\n\n /** Light mode: children the page adds later go into the body too. */\n private watchChildren(): void {\n this.childObserver ??= new MutationObserver(() => this.adopt());\n this.childObserver.observe(this, { childList: true });\n this.adopt();\n }\n\n private adopt(): void {\n const body = this.body;\n if (!body || !this.own) return;\n for (const n of [...this.childNodes]) {\n if (this.own.has(n) || n === body) continue;\n if (n.nodeType === Node.COMMENT_NODE) continue;\n if (n.nodeType === Node.TEXT_NODE && !squash(n.textContent)) continue;\n move(body, n);\n }\n }\n\n private get query(): string {\n const bp = squash(this.breakpoint);\n if (LENGTH.test(bp)) return `(max-width: ${bp})`;\n if (!this.warned) {\n this.warned = true;\n console.warn(\n `${TAG}: breakpoint \"${this.breakpoint}\" is not a length such as 48rem or 768px; using ${DEFAULT_BREAKPOINT}.`,\n );\n }\n return `(max-width: ${DEFAULT_BREAKPOINT})`;\n }\n\n private watchMedia(): void {\n this.media?.removeEventListener('change', this.onMedia);\n this.media = window.matchMedia(this.query);\n this.media.addEventListener('change', this.onMedia);\n this.setNarrow(this.media.matches);\n }\n\n private readonly onMedia = (e: MediaQueryListEvent): void => this.setNarrow(e.matches);\n\n private setNarrow(narrow: boolean): void {\n if (narrow === this.narrow) return;\n if (!narrow && this.isOpen) {\n this.refocus = deepActive();\n this.closeReason = 'resize';\n this.close();\n }\n this.narrow = narrow;\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('breakpoint') && this.hasUpdated && this.isConnected) {\n this.warned = false;\n this.watchMedia();\n }\n }\n\n protected override firstUpdated(): void {\n if (this.lightDom) {\n this.own = new Set(this.childNodes);\n this.watchChildren();\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n setState(this.internals, 'modal', this.narrow);\n setState(this.internals, 'open', this.isOpen);\n this.place();\n if (changed.has('live') && this.isOpen) this.startMirror();\n }\n\n /** Put the body in the sidebar (wide) or the panel (narrow): the same nodes, moved. */\n private place(): void {\n const body = this.body;\n if (!body) return;\n const target = this.narrow\n ? this.root.querySelector('.fd-panel')\n : this.root.querySelector('.fd-sidebar');\n if (!target || body.parentNode === target) return;\n move(target, body, this.narrow ? this.mirror : null);\n }\n\n /** Open the panel (narrow screens only; wide screens always show the filters). */\n show(): void {\n const dialog = this.dialog;\n if (!this.narrow || this.isOpen || !dialog) return;\n this.place();\n dialog.showModal();\n this.isOpen = true;\n this.closeReason = undefined;\n this.closeButton?.focus();\n this.startMirror();\n this.dispatchEvent(new Event('open'));\n }\n\n /** Close the panel. */\n close(): void {\n if (!this.isOpen) return;\n this.closeReason ??= 'script';\n this.dialog?.close();\n this.closed();\n }\n\n private readonly onToggle = (): void => {\n if (this.isOpen) return;\n this.show();\n if (this.isOpen) trackEvent(this, [TAG, 'open', this.label]);\n };\n\n private readonly onCloseClick = (): void => {\n this.closeReason = 'visitor';\n this.close();\n };\n\n private readonly onCancel = (): void => {\n this.closeReason = 'visitor';\n };\n\n private readonly onDialogClick = (e: MouseEvent): void => {\n const dialog = this.dialog;\n if (!dialog || e.target !== dialog) return;\n const r = dialog.getBoundingClientRect();\n const inside =\n e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom;\n if (inside) return;\n this.closeReason = 'visitor';\n this.close();\n };\n\n /** The dialog's own close event: settles an Escape (or any close not made by `close()`). */\n private readonly onDialogClose = (): void => this.closed();\n\n /** The panel has closed, however it happened: report, restore focus, tell the page. */\n private closed(): void {\n if (!this.isOpen) return;\n // An Escape the browser closed without a cancel event is still the visitor's.\n const reason = this.closeReason ?? 'visitor';\n this.closeReason = undefined;\n this.isOpen = false;\n this.stopMirror();\n if (reason === 'visitor') trackEvent(this, [TAG, 'close', this.label]);\n if (reason === 'resize') {\n const back = this.refocus;\n this.refocus = undefined;\n void this.updateComplete.then(() => {\n if (back instanceof HTMLElement && back.isConnected) back.focus({ preventScroll: true });\n });\n } else if (this.narrow) {\n this.toggle?.focus();\n }\n this.dispatchEvent(new Event('close'));\n }\n\n // ---------------------------------------------------------------- live mirror\n\n private startMirror(): void {\n this.stopMirror();\n const root = this.getRootNode() as Document | ShadowRoot;\n const ids = squash(this.live).split(' ').filter(Boolean);\n if (!ids.length) return;\n const observer = new MutationObserver(() => this.checkLive());\n const opts: MutationObserverInit = { childList: true, subtree: true, characterData: true };\n for (const id of ids) {\n const el = root.getElementById?.(id) ?? document.getElementById(id);\n if (!el || this.contains(el)) continue; // inside the drawer it is not inert\n this.liveLast.set(el, liveText(el));\n observer.observe(el, opts);\n if (el.shadowRoot) observer.observe(el.shadowRoot, opts);\n }\n this.liveObserver = observer;\n }\n\n private stopMirror(): void {\n this.liveObserver?.disconnect();\n this.liveObserver = undefined;\n this.liveLast.clear();\n clearTimeout(this.clearTimer);\n const mirror = this.mirror;\n if (mirror) mirror.textContent = '';\n }\n\n private checkLive(): void {\n for (const [el, last] of this.liveLast) {\n const text = liveText(el);\n if (text === last) continue;\n this.liveLast.set(el, text);\n if (text) this.announce(text);\n }\n }\n\n private announce(text: string): void {\n const mirror = this.mirror;\n if (!mirror) return;\n clearTimeout(this.clearTimer);\n // The same words still in the region would not be read again: empty it first.\n mirror.textContent = '';\n requestAnimationFrame(() => {\n if (!this.isOpen) return;\n mirror.textContent = text;\n this.clearTimer = setTimeout(() => (mirror.textContent = ''), CLEAR_MS);\n });\n }\n\n protected override render() {\n const label = squash(this.label) || DEFAULT_LABEL;\n const count = Number.isFinite(this.count) && this.count > 0 ? Math.trunc(this.count) : 0;\n const dialogId = `${this.uid}-dialog`;\n const headingId = `${this.uid}-heading`;\n return html`<button\n type=\"button\"\n class=\"fd-toggle\"\n part=\"toggle\"\n aria-haspopup=\"dialog\"\n aria-expanded=${this.isOpen ? 'true' : 'false'}\n aria-controls=${dialogId}\n ?hidden=${!this.narrow}\n @click=${this.onToggle}\n >\n <span>${label}</span>${\n count\n ? html`<span class=\"fd-vh\">, </span><span class=\"fd-count\" part=\"count\">${count}</span\n ><span class=\"fd-vh\"> active</span>`\n : nothing\n }\n </button>\n <div class=\"fd-sidebar\" part=\"sidebar\"></div>\n <dialog\n id=${dialogId}\n class=\"fd-dialog\"\n part=\"dialog\"\n aria-labelledby=${headingId}\n @cancel=${this.onCancel}\n @close=${this.onDialogClose}\n @click=${this.onDialogClick}\n >\n <div class=\"fd-panel\">\n <div class=\"fd-head\" part=\"header\">\n <h2 class=\"fd-heading\" part=\"heading\" id=${headingId}>${label}</h2>\n <button type=\"button\" class=\"fd-close\" part=\"close\" @click=${this.onCloseClick}>\n Close\n </button>\n </div>\n <div\n class=\"fd-mirror\"\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n style=${HIDDEN_STYLE}\n ></div>\n </div>\n </dialog>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibFilterDrawer } from './UvalibFilterDrawer.js';\n\ndefine('uvalib-filter-drawer', UvalibFilterDrawer);\n"],"mappings":";;;;AAMA,IAAMc,IAAM,wBACNC,IAAgB,sBAChBC,IAAqB,SAErBC,IAAS,4BAETC,IAAW,KAEXC,IAAO,6FAEPC,IACJ,+HAEEC,IAAY,GAEVC,KAAU,OAAkCC,KAAK,GAAA,CAAI,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK;AAGrF,SAASC,EAAS,GAAqB;CACrC,IAAIC,EAAG,QAAQN,CAAI,GAAG,OAAOG,EAAOG,EAAG,WAAW;CAClD,IAAMC,IAAU,CACd,GAAGD,EAAG,iBAAiBN,CAAI,GAC3B,GAAIM,EAAG,aAAaA,EAAG,WAAW,iBAAiBN,CAAI,IAAI,CAAC,CAC9D;CACA,OAAOO,EAAQ,SACXJ,EAAOI,EAAQ,KAAK,MAAMpB,EAAE,WAAW,CAAC,CAAC,KAAK,GAAG,CAAC,IAClDgB,EAAOG,EAAG,WAAW;AAC3B;AAGA,SAASE,EAAK,GAAc,GAAY,IAAsB,MAAY;CACxE,IAAMC,IAAIC;CACV,IAAID,EAAE,cAAcC,EAAO,eAAeC,EAAK,aAC7C,IAAI;EACF,EAAE,WAAWA,GAAMC,CAAM;EACzB;CACF,QAAQ,CAER;CAEF,EAAO,aAAaD,GAAMC,CAAM;AAClC;AAGA,SAASC,IAA6B;CACpC,IAAIC,IAAI,SAAS;CACjB,OAAOA,GAAG,YAAY,gBAAe,IAAIA,EAAE,WAAW;CACtD,OAAOA;AACT;AAmDA,IAAaC,IAAb,c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K,IAAI;EAC9B,OAAO,CAAI;;;;;wBAKS,KAAK,SAAS,SAAS,QAAQ;wBAC/BD,EAAS;kBACf,CAAC,KAAK,OAAO;iBACd,KAAK,SAAS;;gBAEfF,EAAM,SACZC,IACI,CAAI,oEAAoEA,EAAM;uDAE9ErD,EACL;;;;aAIIsD,EAAS;;;0BAGIC,EAAU;kBAClB,KAAK,SAAS;iBACf,KAAK,cAAc;iBACnB,KAAK,cAAc;;;;uDAImBA,EAAU,GAAGH,EAAM;yEACD,KAAK,aAAa;;;;;;;;;oBASvEhC,EAAa;;;;CAI/B;AACF;;AAlVGnB,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAgC,EAAA,WAAA,SAAA,KAAA,CAAA,GAGzBjC,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAgC,EAAA,WAAA,cAAA,KAAA,CAAA,GAGzBjC,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAgC,EAAA,WAAA,SAAA,KAAA,CAAA,GAGzBjC,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAgC,EAAA,WAAA,QAAA,KAAA,CAAA,GAGzBjC,EAAA,CAAAE,EAAM,CAAA,GAAA+B,EAAA,WAAA,UAAA,KAAA,CAAA,GAGNjC,EAAA,CAAAE,EAAM,CAAA,GAAA+B,EAAA,WAAA,UAAA,KAAA,CAAA,GC7QT1B,EAAO,wBAAwB0B,CAAkB"}
|
|
@@ -3,7 +3,7 @@ import { a as u } from "./chunks/analytics-DTTihuBD.js";
|
|
|
3
3
|
import { t as d } from "./chunks/heading-level-DIuNS44-.js";
|
|
4
4
|
import { n as f, r as p } from "./chunks/source-children-BHsDwCvL.js";
|
|
5
5
|
import { t as m } from "./chunks/accessible-DJv7YOtS.js";
|
|
6
|
-
import { i as h, n as g, r as _ } from "./chunks/regions-
|
|
6
|
+
import { i as h, n as g, r as _ } from "./chunks/regions-B-rOwa-v.js";
|
|
7
7
|
// src/components/uvalib-image-regions/UvalibImageRegions.ts
|
|
8
8
|
var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden], [aria-hidden=\"true\"]", x = (e) => `
|
|
9
9
|
${e} { display: block; }
|
|
@@ -112,6 +112,7 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
|
|
|
112
112
|
font-size: 1.125rem;
|
|
113
113
|
font-weight: 700;
|
|
114
114
|
line-height: 1.3;
|
|
115
|
+
text-wrap: balance;
|
|
115
116
|
}
|
|
116
117
|
.items {
|
|
117
118
|
padding-inline-start: 1.75rem;
|
|
@@ -123,6 +124,7 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
|
|
|
123
124
|
display: block;
|
|
124
125
|
color: var(--uva-color-text-muted, #4b5563);
|
|
125
126
|
font-size: 0.9375rem;
|
|
127
|
+
text-wrap: pretty;
|
|
126
128
|
}
|
|
127
129
|
@media (prefers-reduced-motion: no-preference) {
|
|
128
130
|
.region {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uvalib-image-regions.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","precedingHeadingLevel","normalize","safeHref","accessible","toRegion","parseXywh","toPercent","DEFAULT_LABEL","nextId","NOT_LABEL","structuralRules","host","shadowStructure","entryRules","p","entryStyles","UvalibImageRegions","to","hit","root","node","above","options","changed","kids","el","k","img","next","key","sameEls","out","raw","items","item","list","outside","start","li","box","link","label","id","href","parts","walk","imgHost","listHost","controls","w","h","tall","entry","media","e","at","en","detail","name","base","A","light","numbers","image","hasActive"],"sources":["../src/components/uvalib-image-regions/UvalibImageRegions.ts","../src/components/uvalib-image-regions/uvalib-image-regions.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 { precedingHeadingLevel } from '../../base/heading-level.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { normalize, safeHref } from '../../base/source-children.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { accessible } from '../../styles/accessible.js';\nimport { parseXywh, toPercent, toRegion, type ImageRegion, type RegionBox } from './regions.js';\n\nexport type { ImageRegion } from './regions.js';\n\n/** One region as drawn: what events carry, its box, its number and its list entry. */\ninterface Entry {\n item: ImageRegion;\n box: RegionBox | null;\n number: number;\n /** The author's list item (children mode); own items are found by index. */\n el: HTMLElement | null;\n}\n\nconst DEFAULT_LABEL = 'Regions';\nlet nextId = 0;\n\n/** Controls inside a list item, which are actions and not part of the region's name. */\nconst NOT_LABEL = 'button, input, select, textarea, ol, ul, [hidden], [aria-hidden=\"true\"]';\n\n/**\n * Kept with `no-style`: the layout (the image at its own width, at most the element's, and\n * the list beside it when at least 14rem is left, else under it: the same wrapping flex row\n * base.css gives the children before the element upgrades, so nothing moves), the overlay\n * over the image, and the double outlines and number badges (without them the regions are\n * not visible). `host` is `:host` (shadow) or the tag (light DOM).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} .layout {\n display: flex;\n flex-wrap: wrap;\n gap: 1rem;\n align-items: flex-start;\n }\n ${host} .column { flex: 0 1 auto; min-width: 0; max-width: 100%; }\n ${host} .media {\n position: relative;\n width: fit-content;\n min-width: 0;\n max-width: 100%;\n margin: 0;\n }\n ${host} .list { flex: 1 1 14rem; min-width: 0; }\n ${host} .media img, ${host} .img-host > picture${\n host === ':host' ? ', ::slotted(img), ::slotted(picture)' : ''\n } { display: block; max-width: 100%; height: auto; }\n ${host} .overlay {\n position: absolute;\n inset: var(--uvalib-image-regions-inset, 0);\n overflow: clip;\n overflow-clip-margin: 0.5rem;\n pointer-events: none;\n forced-color-adjust: none;\n }\n ${host} .region {\n position: absolute;\n box-sizing: border-box;\n border: 2px solid #fff;\n outline: 2px solid #000;\n pointer-events: auto;\n cursor: pointer;\n }\n ${host} .region.active { z-index: 1; border-width: 4px; outline-width: 4px; }\n ${host} .overlay.has-active .region:not(.active) { opacity: 0.6; }\n ${host} .badge {\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n display: flex;\n gap: 0.375em;\n max-width: 16rem;\n padding: 0.0625rem 0.375rem;\n background: #000;\n color: #fff;\n font-size: 0.875rem;\n font-weight: 700;\n line-height: 1.25;\n white-space: nowrap;\n outline: 1px solid #fff;\n }\n ${host} .region:not([data-inside]) .badge {\n inset-block-start: auto;\n inset-block-end: calc(100% + 4px);\n inset-inline-start: -4px;\n }\n ${host} .region.active:not([data-inside]) .badge {\n inset-block-end: calc(100% + 8px);\n inset-inline-start: -8px;\n }\n ${host} .badge .name { overflow: hidden; text-overflow: ellipsis; }\n ${host} .region:not(.active) .badge .name, ${host} .badge:empty { display: none; }\n ${host} .region:not(.active) .badge.no-number { display: none; }\n ${host} .heading { margin: 0 0 0.5rem; }\n ${host} .items { margin: 0; }\n @media (forced-colors: active) {\n ${host} .region { border-color: Canvas; outline-color: CanvasText; }\n ${host} .region.active { outline-color: Highlight; }\n ${host} .badge { background: CanvasText; color: Canvas; outline-color: Canvas; }\n ${host} .region.active .badge { background: Highlight; color: HighlightText; }\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/**\n * A region's list entry: room for the highlight bar, and the bar (with a tint) while its\n * region is highlighted, so it is shown by more than colour. Shadow mode also installs\n * these in the page, scoped to the tag, for the author's own list items.\n */\nconst entryRules = (p: string) => `\n ${p}[data-uvalib-region] {\n box-sizing: border-box;\n padding-block: 0.5rem;\n padding-inline: calc(0.5rem + 0.375rem) 0.5rem;\n overflow-wrap: anywhere;\n }\n ${p}[data-uvalib-region][data-uvalib-active] {\n padding-inline-start: 0.5rem;\n border-inline-start: 0.375rem solid currentColor;\n background: var(--uva-color-surface-hover, #f1f1f1);\n }\n ${p}[data-uvalib-region]:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n ${p}[data-uvalib-region][tabindex='-1']:focus:not(:focus-visible) { outline: none; }\n @media (forced-colors: active) {\n ${p}[data-uvalib-region][data-uvalib-active] { border-inline-start-color: Highlight; }\n }\n`;\nconst entryStyles = unsafeCSS(entryRules(''));\n\n/**\n * An image with numbered region outlines (people, objects, inscriptions) and a list of the\n * same regions beside it (under it on a narrow screen). The list is the way in: the\n * outlines are a visual aid, hidden from assistive technology and not in the tab order, so\n * no region is a second tab stop. Hovering or focusing a list entry (or anything in it)\n * highlights its region with a thicker double outline and its label, and dims the others;\n * hovering a region highlights its entry. Clicking a region moves focus to its entry.\n *\n * The image: an `<img>` (or `<picture>`) child, which keeps its `alt`, or `src` and `alt`.\n * Give it `width` and `height` so its space is reserved before it loads.\n *\n * The regions: an `<ol>` child whose `<li>` items carry `data-xywh` (IIIF / Media Fragments:\n * `percent:10,20,30,40`, or pixels `160,120,320,240` of the image's natural size). The list\n * is shown as written, so it works before the component loads or without JavaScript, and\n * any links and buttons in it stay the page's own (their events are the page's). Or set\n * the `items` property, and the component draws the list. Region numbers are the list's\n * numbers, from 1 (or the `<ol>`'s `start`).\n *\n * @tagname uvalib-image-regions\n * @slot - The region list (`<ol>` with `<li data-xywh>`), shown as written. Not used with `items`.\n * @slot image - The image. A first `<img>` or `<picture>` child is put here by itself.\n * @slot controls - Controls for the image (a lightbox's version comparison), under the image and before the list in reading order. Not covered by the outlines.\n * @csspart layout - The grid holding the image and the list.\n * @csspart media - The image and its overlay.\n * @csspart overlay - The outlines over the image (`aria-hidden`).\n * @csspart region - One outline.\n * @csspart list - The heading and the list.\n * @fires highlight - The highlighted region changed by hover or focus: `detail` is `{ item, index }` (`item` null and `index` -1 when none is). Bubbles and is composed.\n * @fires uvalib-image-regions-activate - A region's outline was clicked, before its list entry takes focus: `detail` is `{ index, item, entry }` (`index` from 0; `item` the region's record; `entry` the page's own `<li>`, from its child list or a lightbox's lent list, or null when this element drew the list from `items`). Cancelable: `preventDefault()` keeps the entry from taking focus, so the page can focus its own control in it instead (a \"Who is this?\" field). Bubbles and is composed.\n * @fires select - A region's outline was clicked, after its entry took focus (or the page took the activate over): `detail` is `{ item, index, entry }`. Bubbles and is composed. Prefer `uvalib-image-regions-activate`: `select` is also the name of the native text-selection event.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-image-regions', 'select', '<label>', <number>]` when an outline is clicked (the list's `label`, and the region's number from 1). Never a region's label (it may be a person's name). Nothing on hover or focus. Bubbles and is composed.\n * @cssprop --uva-color-text - Dark-mode role token: text (else `--uva-grey-darkest`).\n * @cssprop --uva-color-surface-hover - Dark-mode role token: the highlighted entry's tint (else #f1f1f1).\n * @cssprop --uva-color-link - Dark-mode role token: entry links (else `--uva-brand-blue`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: descriptions (else #4b5563).\n * @cssprop --uvalib-image-regions-inset - Where the outlines sit inside the image slot (an `inset` value, default 0): set by `<uvalib-lightbox>` when the slot holds versions with a wider framing, so the outlines stay on the original.\n */\nexport class UvalibImageRegions extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n entryStyles,\n css`\n .list {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .heading {\n font-size: 1.125rem;\n font-weight: 700;\n line-height: 1.3;\n }\n .items {\n padding-inline-start: 1.75rem;\n }\n .items a {\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n .description {\n display: block;\n color: var(--uva-color-text-muted, #4b5563);\n font-size: 0.9375rem;\n }\n @media (prefers-reduced-motion: no-preference) {\n .region {\n transition: opacity 0.15s ease;\n }\n }\n `,\n ];\n\n /** The regions, when the component draws the list. Overrides the child list. */\n @property({ attribute: false }) items: ImageRegion[] | null = null;\n\n /** Image URL, when there is no `<img>` child. */\n @property({ type: String }) src = '';\n /** The image's alternative text (with `src`). */\n @property({ type: String }) alt = '';\n /** The image's width (with `src`), reserving its space. */\n @property({ type: Number }) width?: number;\n /** The image's height (with `src`). */\n @property({ type: Number }) height?: number;\n\n /**\n * The size pixel regions are measured in, when it is not the image's natural size (for\n * example a IIIF derivative of a larger original: the original's width and height).\n */\n @property({ type: Number, attribute: 'image-width' }) imageWidth?: number;\n /** The height pixel regions are measured in (with `image-width`). */\n @property({ type: Number, attribute: 'image-height' }) imageHeight?: number;\n\n /** The list's heading, and the analytics name. */\n @property({ type: String }) label = 'Regions';\n\n /** The heading's level (2 to 6). Default: one below the heading before the element. */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel?: number;\n\n /** `numbers` (default) shows each region's number on its outline; `none` hides them. */\n @property({ type: String }) numbering: 'numbers' | 'none' = 'numbers';\n\n /** Hide the outlines (the list stays). */\n @property({ type: Boolean, reflect: true, attribute: 'hide-outlines' }) hideOutlines = false;\n\n @state() private entries: Entry[] = [];\n @state() private natural: { w: number; h: number } | null = null;\n @state() private active = -1;\n @state() private inferredLevel = 2;\n\n private hover = -1;\n private focused = -1;\n private readonly headingId = `uvalib-image-regions-heading-${++nextId}`;\n private observer?: MutationObserver;\n private watchedImg: HTMLImageElement | null = null;\n /** A list slotted through a `<slot>` child (from a host element's light DOM), also observed. */\n private slottedList: Element | null = null;\n private key = '';\n /** The image's rendered size decides where badges fit. */\n private resizer?: ResizeObserver;\n private resized = 0;\n\n constructor() {\n super();\n this.addEventListener('pointerover', this.onPointerOver);\n this.addEventListener('pointerleave', this.onPointerLeave);\n this.addEventListener('focusin', this.onFocusIn);\n this.addEventListener('focusout', this.onFocusOut);\n this.addEventListener('click', this.onClick);\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (this.noStyle && root instanceof ShadowRoot && shadowStructure.styleSheet)\n root.adoptedStyleSheets = [shadowStructure.styleSheet];\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const node = this.getRootNode();\n const root = node instanceof Document || node instanceof ShadowRoot ? node : undefined;\n if (this.lightDom && this.noStyle) {\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n { root, scope: false },\n );\n } else if (!this.lightDom && !this.noStyle) {\n // The author's list items are page content: their highlight is styled in the page.\n installLightDomStyles(\n `${this.localName}::entries`,\n unsafeCSS(entryRules(`${this.localName} `)),\n { root, scope: false },\n );\n }\n const above = precedingHeadingLevel(this);\n this.inferredLevel = above === null ? 2 : Math.min(Math.max(above + 1, 2), 6);\n this.slottedList = null;\n this.sync();\n this.observe();\n }\n\n /** Watch the children, and a list slotted from outside them (it is not in this subtree). */\n private observe(): void {\n this.observer ??= new MutationObserver(() => this.sync());\n this.observer.disconnect();\n const options: MutationObserverInit = {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['data-xywh', 'data-label', 'data-id', 'href', 'start', 'src', 'srcset'],\n characterData: true,\n };\n this.observer.observe(this, options);\n if (this.slottedList) this.observer.observe(this.slottedList, options);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n this.resizer?.disconnect();\n this.resizer = undefined;\n this.watchImage(null);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('items') || changed.has('src')) this.sync();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.arrange();\n this.observeSize();\n this.place();\n this.mark();\n // Reading the image's size may set state: not from inside this update.\n queueMicrotask(() => {\n if (this.isConnected) this.watchImage(this.imageEl());\n });\n }\n\n // ---------------------------------------------------------------- sources\n\n /** The author's image element (`<img>` or `<picture>`), wherever it is now. */\n private sourceImage(): HTMLElement | null {\n if (this.src) return null;\n const kids = this.lightDom\n ? [...this.children, ...(this.imgHost?.children ?? [])]\n : [...this.children];\n const named = kids.find((k) => k.getAttribute('slot') === 'image');\n const el = named ?? kids.find((k) => k.localName === 'img' || k.localName === 'picture');\n return el instanceof HTMLElement ? el : null;\n }\n\n /**\n * The author's list (`<ol>` or `<ul>`), wherever it is now. A `<slot>` child (this element\n * inside another component's shadow root) passes on that host's list, which stays in the\n * page's light DOM (so the page's styles and listeners still apply to it).\n */\n private sourceList(): HTMLOListElement | HTMLUListElement | null {\n const kids = (\n this.lightDom ? [...this.children, ...(this.listHost?.children ?? [])] : [...this.children]\n ).flatMap((k) => (k instanceof HTMLSlotElement ? k.assignedElements({ flatten: true }) : [k]));\n const el = kids.find((k) => k.localName === 'ol' || k.localName === 'ul');\n return (el as HTMLOListElement | HTMLUListElement | undefined) ?? null;\n }\n\n private get imgHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .img-host') : null;\n }\n\n private get listHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .list-host') : null;\n }\n\n private get controlsHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .controls-host') : null;\n }\n\n /** The `<img>` whose natural size measures pixel regions. */\n private imageEl(): HTMLImageElement | null {\n if (this.src) return this.renderRoot.querySelector<HTMLImageElement>('.media > img');\n const el = this.sourceImage();\n if (!el) return null;\n return el instanceof HTMLImageElement ? el : el.querySelector('img');\n }\n\n /** Re-read the regions (and in shadow mode put the image in its slot). */\n private sync(): void {\n const img = this.sourceImage();\n if (img && !this.lightDom && !img.hasAttribute('slot')) img.setAttribute('slot', 'image');\n const next = this.items ? this.fromItems(this.items) : this.fromList();\n const key = JSON.stringify(next.map((e) => [e.item, e.box, e.number]));\n const sameEls =\n next.length === this.entries.length && next.every((e, i) => e.el === this.entries[i]?.el);\n if (key === this.key && sameEls) return;\n this.key = key;\n this.entries = next;\n if (this.active >= next.length) this.active = -1;\n }\n\n private fromItems(items: unknown[]): Entry[] {\n const out: Entry[] = [];\n for (const raw of Array.isArray(items) ? items : []) {\n const item = toRegion(raw);\n if (!item) continue;\n const { x, y, w, h, unit = 'px' } = item;\n out.push({ item, box: { x, y, w, h, unit }, number: out.length + 1, el: null });\n }\n return out;\n }\n\n private fromList(): Entry[] {\n const list = this.sourceList();\n const outside = list && !this.contains(list) ? list : null;\n if (outside !== this.slottedList) {\n this.slottedList = outside;\n if (this.isConnected) this.observe();\n if (outside && !this.noStyle) {\n // Its entries are styled where the list is (the page), not under this tag.\n const root = outside.getRootNode();\n if (root instanceof Document || root instanceof ShadowRoot)\n installLightDomStyles(`${this.localName}::slotted-entries`, entryStyles, {\n root,\n scope: false,\n });\n }\n }\n if (!list) return [];\n const start = list.localName === 'ol' ? Number(list.getAttribute('start') ?? 1) || 1 : 1;\n const out: Entry[] = [];\n [...list.children].forEach((li, i) => {\n if (li.localName !== 'li' || !(li instanceof HTMLElement)) return;\n const box = parseXywh(li.dataset.xywh);\n const link = li.querySelector('a[href]');\n const label = normalize(li.dataset.label) || normalize(link?.textContent) || this.text(li);\n const item: ImageRegion = box ? { label, ...box } : { label, x: 0, y: 0, w: 0, h: 0 };\n const id = normalize(li.dataset.id) || li.id;\n if (id) item.id = id;\n const href = link?.getAttribute('href');\n if (href) item.href = href;\n out.push({ item, box, number: start + i, el: li });\n });\n return out;\n }\n\n /** A list item's own text, without its actions (buttons, fields) or a nested list. */\n private text(li: Element): string {\n const parts: string[] = [];\n const walk = (n: Node) => {\n if (n.nodeType === Node.TEXT_NODE) parts.push(n.textContent ?? '');\n else if (n instanceof Element && !n.matches(NOT_LABEL)) n.childNodes.forEach(walk);\n };\n li.childNodes.forEach(walk);\n return normalize(parts.join(' '));\n }\n\n // ---------------------------------------------------------------- layout\n\n /** Light DOM: move the author's image and list into the layout (the same nodes). */\n private arrange(): void {\n if (!this.lightDom) return;\n const img = this.sourceImage();\n const imgHost = this.imgHost;\n if (img && imgHost && img.parentElement !== imgHost) imgHost.append(img);\n const list = this.items ? null : this.sourceList();\n const listHost = this.listHost;\n if (list && listHost && list.parentElement !== listHost) listHost.append(list);\n const controls = this.querySelector(':scope > [slot=\"controls\"]');\n if (controls) this.controlsHost?.append(controls);\n }\n\n private watchImage(img: HTMLImageElement | null): void {\n if (img === this.watchedImg) {\n if (img) this.measure();\n return;\n }\n this.watchedImg?.removeEventListener('load', this.onImageLoad);\n this.watchedImg = img;\n img?.addEventListener('load', this.onImageLoad);\n this.measure();\n }\n\n private readonly onImageLoad = (): void => this.measure();\n\n private measure(): void {\n const img = this.watchedImg;\n const w = img?.complete ? img.naturalWidth : 0;\n const h = img?.complete ? img.naturalHeight : 0;\n const next = w > 0 && h > 0 ? { w, h } : null;\n if (next?.w !== this.natural?.w || next?.h !== this.natural?.h) this.natural = next;\n }\n\n /** The size pixel regions are measured in. */\n private get space(): { w: number; h: number } {\n const w = Number(this.imageWidth);\n const h = Number(this.imageHeight);\n if (w > 0 && h > 0) return { w, h };\n return this.natural ?? { w: 0, h: 0 };\n }\n\n /**\n * Position the outlines in percent of the image, so they scale with it (CSSOM, not markup).\n * A number badge sits above its outline, or inside it when there is no room above.\n */\n private place(): void {\n const { w, h } = this.space;\n const overlay = this.renderRoot.querySelector<HTMLElement>('.overlay');\n const tall = overlay?.clientHeight ?? 0;\n for (const el of this.renderRoot.querySelectorAll<HTMLElement>('.overlay > .region')) {\n const entry = this.entries[Number(el.dataset.index)];\n const box = entry?.box ? toPercent(entry.box, w, h) : null;\n el.hidden = !box;\n if (!box) continue;\n el.style.left = `${box.x}%`;\n el.style.top = `${box.y}%`;\n el.style.width = `${box.w}%`;\n el.style.height = `${box.h}%`;\n el.toggleAttribute('data-inside', (box.y / 100) * tall < 28);\n }\n }\n\n private observeSize(): void {\n const media = this.renderRoot.querySelector<HTMLElement>('.media');\n if (!media || typeof ResizeObserver === 'undefined') return;\n if (!this.resizer) {\n this.resizer = new ResizeObserver(() => {\n // The outlines scale by themselves (percent); only the badges' side may change.\n const h = media.clientHeight;\n if (h === this.resized) return;\n this.resized = h;\n this.place();\n });\n this.resizer.observe(media);\n }\n }\n\n /** The list entry of region `i`. */\n private entryEl(i: number): HTMLElement | null {\n const entry = this.entries[i];\n if (!entry) return null;\n if (entry.el) return entry.el;\n return this.renderRoot.querySelector<HTMLElement>(`.items > li[data-index=\"${i}\"]`);\n }\n\n /** Mark the entries (their padding) and the highlighted one. */\n private mark(): void {\n const list = this.items ? null : this.sourceList();\n this.entries.forEach((e, i) => {\n const el = this.entryEl(i);\n // An author's item that has left the list (given back to the page) is not marked again.\n if (!el || (e.el && e.el.parentElement !== list)) return;\n if (el.getAttribute('data-uvalib-region') !== String(e.number))\n el.setAttribute('data-uvalib-region', String(e.number));\n el.toggleAttribute('data-uvalib-active', i === this.active);\n });\n }\n\n // ---------------------------------------------------------------- interaction\n\n /** The region an event is about: its outline or its list entry (or anything inside it). */\n private indexFrom(e: Event): { i: number; outline: boolean } | null {\n for (const n of e.composedPath()) {\n if (n === this) break;\n if (!(n instanceof HTMLElement)) continue;\n if (n.classList.contains('region') && n.parentElement?.classList.contains('overlay'))\n return { i: Number(n.dataset.index), outline: true };\n const at = this.entries.findIndex((en, i) => (en.el ?? this.entryEl(i)) === n);\n if (at >= 0) return { i: at, outline: false };\n }\n return null;\n }\n\n private setActive(): void {\n const next = this.hover >= 0 ? this.hover : this.focused;\n if (next === this.active) return;\n this.active = next;\n const item = this.entries[next]?.item ?? null;\n this.dispatchEvent(\n new CustomEvent('highlight', {\n detail: { item, index: item ? next : -1 },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private readonly onPointerOver = (e: PointerEvent): void => {\n this.hover = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onPointerLeave = (): void => {\n this.hover = -1;\n this.setActive();\n };\n\n private readonly onFocusIn = (e: FocusEvent): void => {\n this.focused = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onFocusOut = (e: FocusEvent): void => {\n const to = e.relatedTarget;\n if (\n to instanceof Node &&\n (this.contains(to) || this.renderRoot.contains(to) || this.slottedList?.contains(to))\n )\n return;\n this.focused = -1;\n this.setActive();\n };\n\n private readonly onClick = (e: MouseEvent): void => {\n const hit = this.indexFrom(e);\n if (!hit?.outline) return;\n this.choose(hit.i);\n };\n\n /**\n * An outline was clicked: say so first (`uvalib-image-regions-activate`, cancelable), then,\n * unless the page took it over, focus the entry; then `select`. `entry` is the page's own\n * `<li>` (its child list or a lightbox's lent list), never one this element drew from `items`.\n */\n private choose(i: number): void {\n const entry = this.entries[i];\n const el = this.entryEl(i);\n if (!entry || !el) return;\n const detail = { index: i, item: entry.item, entry: entry.el ?? null };\n const go = this.dispatchEvent(\n new CustomEvent('uvalib-image-regions-activate', {\n detail,\n bubbles: true,\n composed: true,\n cancelable: true,\n }),\n );\n if (go) {\n if (!el.hasAttribute('tabindex')) el.tabIndex = -1;\n el.focus();\n el.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n this.dispatchEvent(\n new CustomEvent('select', {\n detail: { item: entry.item, index: i, entry: detail.entry },\n bubbles: true,\n composed: true,\n }),\n );\n const name = normalize(this.label) || DEFAULT_LABEL;\n trackEvent(this, ['uvalib-image-regions', 'select', name, entry.number]);\n }\n\n // ---------------------------------------------------------------- render\n\n private get level(): number {\n const n = Math.trunc(Number(this.headingLevel));\n return n >= 2 && n <= 6 ? n : this.inferredLevel;\n }\n\n private renderOwnList() {\n const base = this.ownerDocument.baseURI;\n return html`<ol class=\"items\" aria-labelledby=${this.headingId}>\n ${this.entries.map(({ item }, i) => {\n const href = item.href && safeHref(item.href, base) ? item.href : '';\n return html`<li data-index=${i}>\n ${href ? html`<a href=${href}>${item.label}</a>` : html`<span>${item.label}</span>`}\n ${item.description ? html`<span class=\"description\">${item.description}</span>` : nothing}\n </li>`;\n })}\n </ol>`;\n }\n\n protected override render() {\n const light = this.lightDom;\n const numbers = this.numbering !== 'none';\n const image = this.src\n ? html`<img\n part=\"image\"\n src=${this.src}\n alt=${this.alt}\n width=${this.width ?? nothing}\n height=${this.height ?? nothing}\n @load=${this.onImageLoad}\n />`\n : light\n ? html`<div class=\"img-host\"></div>`\n : html`<slot name=\"image\" @slotchange=${() => this.requestUpdate()}></slot>`;\n const list = this.items\n ? this.renderOwnList()\n : light\n ? html`<div class=\"list-host\"></div>`\n : html`<slot @slotchange=${() => this.sync()}></slot>`;\n const hasActive = this.active >= 0 && !!this.entries[this.active]?.box;\n return html`<div class=\"layout\" part=\"layout\">\n <div class=\"column\">\n <div class=\"media\" part=\"media\">\n ${image}\n <div\n class=\"overlay ${hasActive ? 'has-active' : ''}\"\n part=\"overlay\"\n aria-hidden=\"true\"\n ?hidden=${this.hideOutlines}\n >\n ${this.entries.map((e, i) =>\n e.box\n ? html`<div\n class=\"region ${i === this.active ? 'active' : ''}\"\n part=\"region\"\n data-index=${i}\n >\n <span class=\"badge ${numbers ? '' : 'no-number'}\"\n >${numbers ? html`<span class=\"number\">${e.number}</span>` : nothing}${\n e.item.label ? html`<span class=\"name\">${e.item.label}</span>` : nothing\n }</span\n >\n </div>`\n : nothing,\n )}\n </div>\n </div>\n ${light ? html`<div class=\"controls-host\"></div>` : html`<slot name=\"controls\"></slot>`}\n </div>\n <div class=\"list\" part=\"list\">\n <div class=\"heading\" role=\"heading\" aria-level=${this.level} id=${this.headingId}>\n ${normalize(this.label) || DEFAULT_LABEL}\n </div>\n ${list}\n </div>\n </div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibImageRegions } from './UvalibImageRegions.js';\n\ndefine('uvalib-image-regions', UvalibImageRegions);\n"],"mappings":";;;;;;;AAqBA,IAAMsB,IAAgB,WAClBC,IAAS,GAGPC,IAAY,6EASZC,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;;;;;;IAMLA,EAAK;IACLA,EAAK;;;;;;;IAOLA,EAAK;IACLA,EAAK,eAAeA,EAAK,sBACzBA,MAAS,UAAU,yCAAyC,GAC7D;IACCA,EAAK;;;;;;;;IAQLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;IACLA,EAAK;;;;;;;;;;;;;;;;IAgBLA,EAAK;;;;;IAKLA,EAAK;;;;IAILA,EAAK;IACLA,EAAK,sCAAsCA,EAAK;IAChDA,EAAK;IACLA,EAAK;IACLA,EAAK;;MAE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A,WAAA,iBAAA,KAAA,CAAA,GCnPTtB,EAAO,wBAAwBsB,CAAkB"}
|
|
1
|
+
{"version":3,"file":"uvalib-image-regions.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","precedingHeadingLevel","normalize","safeHref","accessible","toRegion","parseXywh","toPercent","DEFAULT_LABEL","nextId","NOT_LABEL","structuralRules","host","shadowStructure","entryRules","p","entryStyles","UvalibImageRegions","to","hit","root","node","above","options","changed","kids","el","k","img","next","key","sameEls","out","raw","items","item","list","outside","start","li","box","link","label","id","href","parts","walk","imgHost","listHost","controls","w","h","tall","entry","media","e","at","en","detail","name","base","A","light","numbers","image","hasActive"],"sources":["../src/components/uvalib-image-regions/UvalibImageRegions.ts","../src/components/uvalib-image-regions/uvalib-image-regions.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 { precedingHeadingLevel } from '../../base/heading-level.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { normalize, safeHref } from '../../base/source-children.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { accessible } from '../../styles/accessible.js';\nimport { parseXywh, toPercent, toRegion, type ImageRegion, type RegionBox } from './regions.js';\n\nexport type { ImageRegion } from './regions.js';\n\n/** One region as drawn: what events carry, its box, its number and its list entry. */\ninterface Entry {\n item: ImageRegion;\n box: RegionBox | null;\n number: number;\n /** The author's list item (children mode); own items are found by index. */\n el: HTMLElement | null;\n}\n\nconst DEFAULT_LABEL = 'Regions';\nlet nextId = 0;\n\n/** Controls inside a list item, which are actions and not part of the region's name. */\nconst NOT_LABEL = 'button, input, select, textarea, ol, ul, [hidden], [aria-hidden=\"true\"]';\n\n/**\n * Kept with `no-style`: the layout (the image at its own width, at most the element's, and\n * the list beside it when at least 14rem is left, else under it: the same wrapping flex row\n * base.css gives the children before the element upgrades, so nothing moves), the overlay\n * over the image, and the double outlines and number badges (without them the regions are\n * not visible). `host` is `:host` (shadow) or the tag (light DOM).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} .layout {\n display: flex;\n flex-wrap: wrap;\n gap: 1rem;\n align-items: flex-start;\n }\n ${host} .column { flex: 0 1 auto; min-width: 0; max-width: 100%; }\n ${host} .media {\n position: relative;\n width: fit-content;\n min-width: 0;\n max-width: 100%;\n margin: 0;\n }\n ${host} .list { flex: 1 1 14rem; min-width: 0; }\n ${host} .media img, ${host} .img-host > picture${\n host === ':host' ? ', ::slotted(img), ::slotted(picture)' : ''\n } { display: block; max-width: 100%; height: auto; }\n ${host} .overlay {\n position: absolute;\n inset: var(--uvalib-image-regions-inset, 0);\n overflow: clip;\n overflow-clip-margin: 0.5rem;\n pointer-events: none;\n forced-color-adjust: none;\n }\n ${host} .region {\n position: absolute;\n box-sizing: border-box;\n border: 2px solid #fff;\n outline: 2px solid #000;\n pointer-events: auto;\n cursor: pointer;\n }\n ${host} .region.active { z-index: 1; border-width: 4px; outline-width: 4px; }\n ${host} .overlay.has-active .region:not(.active) { opacity: 0.6; }\n ${host} .badge {\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n display: flex;\n gap: 0.375em;\n max-width: 16rem;\n padding: 0.0625rem 0.375rem;\n background: #000;\n color: #fff;\n font-size: 0.875rem;\n font-weight: 700;\n line-height: 1.25;\n white-space: nowrap;\n outline: 1px solid #fff;\n }\n ${host} .region:not([data-inside]) .badge {\n inset-block-start: auto;\n inset-block-end: calc(100% + 4px);\n inset-inline-start: -4px;\n }\n ${host} .region.active:not([data-inside]) .badge {\n inset-block-end: calc(100% + 8px);\n inset-inline-start: -8px;\n }\n ${host} .badge .name { overflow: hidden; text-overflow: ellipsis; }\n ${host} .region:not(.active) .badge .name, ${host} .badge:empty { display: none; }\n ${host} .region:not(.active) .badge.no-number { display: none; }\n ${host} .heading { margin: 0 0 0.5rem; }\n ${host} .items { margin: 0; }\n @media (forced-colors: active) {\n ${host} .region { border-color: Canvas; outline-color: CanvasText; }\n ${host} .region.active { outline-color: Highlight; }\n ${host} .badge { background: CanvasText; color: Canvas; outline-color: Canvas; }\n ${host} .region.active .badge { background: Highlight; color: HighlightText; }\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/**\n * A region's list entry: room for the highlight bar, and the bar (with a tint) while its\n * region is highlighted, so it is shown by more than colour. Shadow mode also installs\n * these in the page, scoped to the tag, for the author's own list items.\n */\nconst entryRules = (p: string) => `\n ${p}[data-uvalib-region] {\n box-sizing: border-box;\n padding-block: 0.5rem;\n padding-inline: calc(0.5rem + 0.375rem) 0.5rem;\n overflow-wrap: anywhere;\n }\n ${p}[data-uvalib-region][data-uvalib-active] {\n padding-inline-start: 0.5rem;\n border-inline-start: 0.375rem solid currentColor;\n background: var(--uva-color-surface-hover, #f1f1f1);\n }\n ${p}[data-uvalib-region]:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n ${p}[data-uvalib-region][tabindex='-1']:focus:not(:focus-visible) { outline: none; }\n @media (forced-colors: active) {\n ${p}[data-uvalib-region][data-uvalib-active] { border-inline-start-color: Highlight; }\n }\n`;\nconst entryStyles = unsafeCSS(entryRules(''));\n\n/**\n * An image with numbered region outlines (people, objects, inscriptions) and a list of the\n * same regions beside it (under it on a narrow screen). The list is the way in: the\n * outlines are a visual aid, hidden from assistive technology and not in the tab order, so\n * no region is a second tab stop. Hovering or focusing a list entry (or anything in it)\n * highlights its region with a thicker double outline and its label, and dims the others;\n * hovering a region highlights its entry. Clicking a region moves focus to its entry.\n *\n * The image: an `<img>` (or `<picture>`) child, which keeps its `alt`, or `src` and `alt`.\n * Give it `width` and `height` so its space is reserved before it loads.\n *\n * The regions: an `<ol>` child whose `<li>` items carry `data-xywh` (IIIF / Media Fragments:\n * `percent:10,20,30,40`, or pixels `160,120,320,240` of the image's natural size). The list\n * is shown as written, so it works before the component loads or without JavaScript, and\n * any links and buttons in it stay the page's own (their events are the page's). Or set\n * the `items` property, and the component draws the list. Region numbers are the list's\n * numbers, from 1 (or the `<ol>`'s `start`).\n *\n * @tagname uvalib-image-regions\n * @slot - The region list (`<ol>` with `<li data-xywh>`), shown as written. Not used with `items`.\n * @slot image - The image. A first `<img>` or `<picture>` child is put here by itself.\n * @slot controls - Controls for the image (a lightbox's version comparison), under the image and before the list in reading order. Not covered by the outlines.\n * @csspart layout - The grid holding the image and the list.\n * @csspart media - The image and its overlay.\n * @csspart overlay - The outlines over the image (`aria-hidden`).\n * @csspart region - One outline.\n * @csspart list - The heading and the list.\n * @fires highlight - The highlighted region changed by hover or focus: `detail` is `{ item, index }` (`item` null and `index` -1 when none is). Bubbles and is composed.\n * @fires uvalib-image-regions-activate - A region's outline was clicked, before its list entry takes focus: `detail` is `{ index, item, entry }` (`index` from 0; `item` the region's record; `entry` the page's own `<li>`, from its child list or a lightbox's lent list, or null when this element drew the list from `items`). Cancelable: `preventDefault()` keeps the entry from taking focus, so the page can focus its own control in it instead (a \"Who is this?\" field). Bubbles and is composed.\n * @fires select - A region's outline was clicked, after its entry took focus (or the page took the activate over): `detail` is `{ item, index, entry }`. Bubbles and is composed. Prefer `uvalib-image-regions-activate`: `select` is also the name of the native text-selection event.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-image-regions', 'select', '<label>', <number>]` when an outline is clicked (the list's `label`, and the region's number from 1). Never a region's label (it may be a person's name). Nothing on hover or focus. Bubbles and is composed.\n * @cssprop --uva-color-text - Dark-mode role token: text (else `--uva-grey-darkest`).\n * @cssprop --uva-color-surface-hover - Dark-mode role token: the highlighted entry's tint (else #f1f1f1).\n * @cssprop --uva-color-link - Dark-mode role token: entry links (else `--uva-brand-blue`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: descriptions (else #4b5563).\n * @cssprop --uvalib-image-regions-inset - Where the outlines sit inside the image slot (an `inset` value, default 0): set by `<uvalib-lightbox>` when the slot holds versions with a wider framing, so the outlines stay on the original.\n */\nexport class UvalibImageRegions extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n entryStyles,\n css`\n .list {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .heading {\n font-size: 1.125rem;\n font-weight: 700;\n line-height: 1.3;\n text-wrap: balance;\n }\n .items {\n padding-inline-start: 1.75rem;\n }\n .items a {\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n .description {\n display: block;\n color: var(--uva-color-text-muted, #4b5563);\n font-size: 0.9375rem;\n text-wrap: pretty;\n }\n @media (prefers-reduced-motion: no-preference) {\n .region {\n transition: opacity 0.15s ease;\n }\n }\n `,\n ];\n\n /** The regions, when the component draws the list. Overrides the child list. */\n @property({ attribute: false }) items: ImageRegion[] | null = null;\n\n /** Image URL, when there is no `<img>` child. */\n @property({ type: String }) src = '';\n /** The image's alternative text (with `src`). */\n @property({ type: String }) alt = '';\n /** The image's width (with `src`), reserving its space. */\n @property({ type: Number }) width?: number;\n /** The image's height (with `src`). */\n @property({ type: Number }) height?: number;\n\n /**\n * The size pixel regions are measured in, when it is not the image's natural size (for\n * example a IIIF derivative of a larger original: the original's width and height).\n */\n @property({ type: Number, attribute: 'image-width' }) imageWidth?: number;\n /** The height pixel regions are measured in (with `image-width`). */\n @property({ type: Number, attribute: 'image-height' }) imageHeight?: number;\n\n /** The list's heading, and the analytics name. */\n @property({ type: String }) label = 'Regions';\n\n /** The heading's level (2 to 6). Default: one below the heading before the element. */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel?: number;\n\n /** `numbers` (default) shows each region's number on its outline; `none` hides them. */\n @property({ type: String }) numbering: 'numbers' | 'none' = 'numbers';\n\n /** Hide the outlines (the list stays). */\n @property({ type: Boolean, reflect: true, attribute: 'hide-outlines' }) hideOutlines = false;\n\n @state() private entries: Entry[] = [];\n @state() private natural: { w: number; h: number } | null = null;\n @state() private active = -1;\n @state() private inferredLevel = 2;\n\n private hover = -1;\n private focused = -1;\n private readonly headingId = `uvalib-image-regions-heading-${++nextId}`;\n private observer?: MutationObserver;\n private watchedImg: HTMLImageElement | null = null;\n /** A list slotted through a `<slot>` child (from a host element's light DOM), also observed. */\n private slottedList: Element | null = null;\n private key = '';\n /** The image's rendered size decides where badges fit. */\n private resizer?: ResizeObserver;\n private resized = 0;\n\n constructor() {\n super();\n this.addEventListener('pointerover', this.onPointerOver);\n this.addEventListener('pointerleave', this.onPointerLeave);\n this.addEventListener('focusin', this.onFocusIn);\n this.addEventListener('focusout', this.onFocusOut);\n this.addEventListener('click', this.onClick);\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (this.noStyle && root instanceof ShadowRoot && shadowStructure.styleSheet)\n root.adoptedStyleSheets = [shadowStructure.styleSheet];\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const node = this.getRootNode();\n const root = node instanceof Document || node instanceof ShadowRoot ? node : undefined;\n if (this.lightDom && this.noStyle) {\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n { root, scope: false },\n );\n } else if (!this.lightDom && !this.noStyle) {\n // The author's list items are page content: their highlight is styled in the page.\n installLightDomStyles(\n `${this.localName}::entries`,\n unsafeCSS(entryRules(`${this.localName} `)),\n { root, scope: false },\n );\n }\n const above = precedingHeadingLevel(this);\n this.inferredLevel = above === null ? 2 : Math.min(Math.max(above + 1, 2), 6);\n this.slottedList = null;\n this.sync();\n this.observe();\n }\n\n /** Watch the children, and a list slotted from outside them (it is not in this subtree). */\n private observe(): void {\n this.observer ??= new MutationObserver(() => this.sync());\n this.observer.disconnect();\n const options: MutationObserverInit = {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['data-xywh', 'data-label', 'data-id', 'href', 'start', 'src', 'srcset'],\n characterData: true,\n };\n this.observer.observe(this, options);\n if (this.slottedList) this.observer.observe(this.slottedList, options);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n this.resizer?.disconnect();\n this.resizer = undefined;\n this.watchImage(null);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('items') || changed.has('src')) this.sync();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.arrange();\n this.observeSize();\n this.place();\n this.mark();\n // Reading the image's size may set state: not from inside this update.\n queueMicrotask(() => {\n if (this.isConnected) this.watchImage(this.imageEl());\n });\n }\n\n // ---------------------------------------------------------------- sources\n\n /** The author's image element (`<img>` or `<picture>`), wherever it is now. */\n private sourceImage(): HTMLElement | null {\n if (this.src) return null;\n const kids = this.lightDom\n ? [...this.children, ...(this.imgHost?.children ?? [])]\n : [...this.children];\n const named = kids.find((k) => k.getAttribute('slot') === 'image');\n const el = named ?? kids.find((k) => k.localName === 'img' || k.localName === 'picture');\n return el instanceof HTMLElement ? el : null;\n }\n\n /**\n * The author's list (`<ol>` or `<ul>`), wherever it is now. A `<slot>` child (this element\n * inside another component's shadow root) passes on that host's list, which stays in the\n * page's light DOM (so the page's styles and listeners still apply to it).\n */\n private sourceList(): HTMLOListElement | HTMLUListElement | null {\n const kids = (\n this.lightDom ? [...this.children, ...(this.listHost?.children ?? [])] : [...this.children]\n ).flatMap((k) => (k instanceof HTMLSlotElement ? k.assignedElements({ flatten: true }) : [k]));\n const el = kids.find((k) => k.localName === 'ol' || k.localName === 'ul');\n return (el as HTMLOListElement | HTMLUListElement | undefined) ?? null;\n }\n\n private get imgHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .img-host') : null;\n }\n\n private get listHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .list-host') : null;\n }\n\n private get controlsHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .controls-host') : null;\n }\n\n /** The `<img>` whose natural size measures pixel regions. */\n private imageEl(): HTMLImageElement | null {\n if (this.src) return this.renderRoot.querySelector<HTMLImageElement>('.media > img');\n const el = this.sourceImage();\n if (!el) return null;\n return el instanceof HTMLImageElement ? el : el.querySelector('img');\n }\n\n /** Re-read the regions (and in shadow mode put the image in its slot). */\n private sync(): void {\n const img = this.sourceImage();\n if (img && !this.lightDom && !img.hasAttribute('slot')) img.setAttribute('slot', 'image');\n const next = this.items ? this.fromItems(this.items) : this.fromList();\n const key = JSON.stringify(next.map((e) => [e.item, e.box, e.number]));\n const sameEls =\n next.length === this.entries.length && next.every((e, i) => e.el === this.entries[i]?.el);\n if (key === this.key && sameEls) return;\n this.key = key;\n this.entries = next;\n if (this.active >= next.length) this.active = -1;\n }\n\n private fromItems(items: unknown[]): Entry[] {\n const out: Entry[] = [];\n for (const raw of Array.isArray(items) ? items : []) {\n const item = toRegion(raw);\n if (!item) continue;\n const { x, y, w, h, unit = 'px' } = item;\n out.push({ item, box: { x, y, w, h, unit }, number: out.length + 1, el: null });\n }\n return out;\n }\n\n private fromList(): Entry[] {\n const list = this.sourceList();\n const outside = list && !this.contains(list) ? list : null;\n if (outside !== this.slottedList) {\n this.slottedList = outside;\n if (this.isConnected) this.observe();\n if (outside && !this.noStyle) {\n // Its entries are styled where the list is (the page), not under this tag.\n const root = outside.getRootNode();\n if (root instanceof Document || root instanceof ShadowRoot)\n installLightDomStyles(`${this.localName}::slotted-entries`, entryStyles, {\n root,\n scope: false,\n });\n }\n }\n if (!list) return [];\n const start = list.localName === 'ol' ? Number(list.getAttribute('start') ?? 1) || 1 : 1;\n const out: Entry[] = [];\n [...list.children].forEach((li, i) => {\n if (li.localName !== 'li' || !(li instanceof HTMLElement)) return;\n const box = parseXywh(li.dataset.xywh);\n const link = li.querySelector('a[href]');\n const label = normalize(li.dataset.label) || normalize(link?.textContent) || this.text(li);\n const item: ImageRegion = box ? { label, ...box } : { label, x: 0, y: 0, w: 0, h: 0 };\n const id = normalize(li.dataset.id) || li.id;\n if (id) item.id = id;\n const href = link?.getAttribute('href');\n if (href) item.href = href;\n out.push({ item, box, number: start + i, el: li });\n });\n return out;\n }\n\n /** A list item's own text, without its actions (buttons, fields) or a nested list. */\n private text(li: Element): string {\n const parts: string[] = [];\n const walk = (n: Node) => {\n if (n.nodeType === Node.TEXT_NODE) parts.push(n.textContent ?? '');\n else if (n instanceof Element && !n.matches(NOT_LABEL)) n.childNodes.forEach(walk);\n };\n li.childNodes.forEach(walk);\n return normalize(parts.join(' '));\n }\n\n // ---------------------------------------------------------------- layout\n\n /** Light DOM: move the author's image and list into the layout (the same nodes). */\n private arrange(): void {\n if (!this.lightDom) return;\n const img = this.sourceImage();\n const imgHost = this.imgHost;\n if (img && imgHost && img.parentElement !== imgHost) imgHost.append(img);\n const list = this.items ? null : this.sourceList();\n const listHost = this.listHost;\n if (list && listHost && list.parentElement !== listHost) listHost.append(list);\n const controls = this.querySelector(':scope > [slot=\"controls\"]');\n if (controls) this.controlsHost?.append(controls);\n }\n\n private watchImage(img: HTMLImageElement | null): void {\n if (img === this.watchedImg) {\n if (img) this.measure();\n return;\n }\n this.watchedImg?.removeEventListener('load', this.onImageLoad);\n this.watchedImg = img;\n img?.addEventListener('load', this.onImageLoad);\n this.measure();\n }\n\n private readonly onImageLoad = (): void => this.measure();\n\n private measure(): void {\n const img = this.watchedImg;\n const w = img?.complete ? img.naturalWidth : 0;\n const h = img?.complete ? img.naturalHeight : 0;\n const next = w > 0 && h > 0 ? { w, h } : null;\n if (next?.w !== this.natural?.w || next?.h !== this.natural?.h) this.natural = next;\n }\n\n /** The size pixel regions are measured in. */\n private get space(): { w: number; h: number } {\n const w = Number(this.imageWidth);\n const h = Number(this.imageHeight);\n if (w > 0 && h > 0) return { w, h };\n return this.natural ?? { w: 0, h: 0 };\n }\n\n /**\n * Position the outlines in percent of the image, so they scale with it (CSSOM, not markup).\n * A number badge sits above its outline, or inside it when there is no room above.\n */\n private place(): void {\n const { w, h } = this.space;\n const overlay = this.renderRoot.querySelector<HTMLElement>('.overlay');\n const tall = overlay?.clientHeight ?? 0;\n for (const el of this.renderRoot.querySelectorAll<HTMLElement>('.overlay > .region')) {\n const entry = this.entries[Number(el.dataset.index)];\n const box = entry?.box ? toPercent(entry.box, w, h) : null;\n el.hidden = !box;\n if (!box) continue;\n el.style.left = `${box.x}%`;\n el.style.top = `${box.y}%`;\n el.style.width = `${box.w}%`;\n el.style.height = `${box.h}%`;\n el.toggleAttribute('data-inside', (box.y / 100) * tall < 28);\n }\n }\n\n private observeSize(): void {\n const media = this.renderRoot.querySelector<HTMLElement>('.media');\n if (!media || typeof ResizeObserver === 'undefined') return;\n if (!this.resizer) {\n this.resizer = new ResizeObserver(() => {\n // The outlines scale by themselves (percent); only the badges' side may change.\n const h = media.clientHeight;\n if (h === this.resized) return;\n this.resized = h;\n this.place();\n });\n this.resizer.observe(media);\n }\n }\n\n /** The list entry of region `i`. */\n private entryEl(i: number): HTMLElement | null {\n const entry = this.entries[i];\n if (!entry) return null;\n if (entry.el) return entry.el;\n return this.renderRoot.querySelector<HTMLElement>(`.items > li[data-index=\"${i}\"]`);\n }\n\n /** Mark the entries (their padding) and the highlighted one. */\n private mark(): void {\n const list = this.items ? null : this.sourceList();\n this.entries.forEach((e, i) => {\n const el = this.entryEl(i);\n // An author's item that has left the list (given back to the page) is not marked again.\n if (!el || (e.el && e.el.parentElement !== list)) return;\n if (el.getAttribute('data-uvalib-region') !== String(e.number))\n el.setAttribute('data-uvalib-region', String(e.number));\n el.toggleAttribute('data-uvalib-active', i === this.active);\n });\n }\n\n // ---------------------------------------------------------------- interaction\n\n /** The region an event is about: its outline or its list entry (or anything inside it). */\n private indexFrom(e: Event): { i: number; outline: boolean } | null {\n for (const n of e.composedPath()) {\n if (n === this) break;\n if (!(n instanceof HTMLElement)) continue;\n if (n.classList.contains('region') && n.parentElement?.classList.contains('overlay'))\n return { i: Number(n.dataset.index), outline: true };\n const at = this.entries.findIndex((en, i) => (en.el ?? this.entryEl(i)) === n);\n if (at >= 0) return { i: at, outline: false };\n }\n return null;\n }\n\n private setActive(): void {\n const next = this.hover >= 0 ? this.hover : this.focused;\n if (next === this.active) return;\n this.active = next;\n const item = this.entries[next]?.item ?? null;\n this.dispatchEvent(\n new CustomEvent('highlight', {\n detail: { item, index: item ? next : -1 },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private readonly onPointerOver = (e: PointerEvent): void => {\n this.hover = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onPointerLeave = (): void => {\n this.hover = -1;\n this.setActive();\n };\n\n private readonly onFocusIn = (e: FocusEvent): void => {\n this.focused = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onFocusOut = (e: FocusEvent): void => {\n const to = e.relatedTarget;\n if (\n to instanceof Node &&\n (this.contains(to) || this.renderRoot.contains(to) || this.slottedList?.contains(to))\n )\n return;\n this.focused = -1;\n this.setActive();\n };\n\n private readonly onClick = (e: MouseEvent): void => {\n const hit = this.indexFrom(e);\n if (!hit?.outline) return;\n this.choose(hit.i);\n };\n\n /**\n * An outline was clicked: say so first (`uvalib-image-regions-activate`, cancelable), then,\n * unless the page took it over, focus the entry; then `select`. `entry` is the page's own\n * `<li>` (its child list or a lightbox's lent list), never one this element drew from `items`.\n */\n private choose(i: number): void {\n const entry = this.entries[i];\n const el = this.entryEl(i);\n if (!entry || !el) return;\n const detail = { index: i, item: entry.item, entry: entry.el ?? null };\n const go = this.dispatchEvent(\n new CustomEvent('uvalib-image-regions-activate', {\n detail,\n bubbles: true,\n composed: true,\n cancelable: true,\n }),\n );\n if (go) {\n if (!el.hasAttribute('tabindex')) el.tabIndex = -1;\n el.focus();\n el.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n this.dispatchEvent(\n new CustomEvent('select', {\n detail: { item: entry.item, index: i, entry: detail.entry },\n bubbles: true,\n composed: true,\n }),\n );\n const name = normalize(this.label) || DEFAULT_LABEL;\n trackEvent(this, ['uvalib-image-regions', 'select', name, entry.number]);\n }\n\n // ---------------------------------------------------------------- render\n\n private get level(): number {\n const n = Math.trunc(Number(this.headingLevel));\n return n >= 2 && n <= 6 ? n : this.inferredLevel;\n }\n\n private renderOwnList() {\n const base = this.ownerDocument.baseURI;\n return html`<ol class=\"items\" aria-labelledby=${this.headingId}>\n ${this.entries.map(({ item }, i) => {\n const href = item.href && safeHref(item.href, base) ? item.href : '';\n return html`<li data-index=${i}>\n ${href ? html`<a href=${href}>${item.label}</a>` : html`<span>${item.label}</span>`}\n ${item.description ? html`<span class=\"description\">${item.description}</span>` : nothing}\n </li>`;\n })}\n </ol>`;\n }\n\n protected override render() {\n const light = this.lightDom;\n const numbers = this.numbering !== 'none';\n const image = this.src\n ? html`<img\n part=\"image\"\n src=${this.src}\n alt=${this.alt}\n width=${this.width ?? nothing}\n height=${this.height ?? nothing}\n @load=${this.onImageLoad}\n />`\n : light\n ? html`<div class=\"img-host\"></div>`\n : html`<slot name=\"image\" @slotchange=${() => this.requestUpdate()}></slot>`;\n const list = this.items\n ? this.renderOwnList()\n : light\n ? html`<div class=\"list-host\"></div>`\n : html`<slot @slotchange=${() => this.sync()}></slot>`;\n const hasActive = this.active >= 0 && !!this.entries[this.active]?.box;\n return html`<div class=\"layout\" part=\"layout\">\n <div class=\"column\">\n <div class=\"media\" part=\"media\">\n ${image}\n <div\n class=\"overlay ${hasActive ? 'has-active' : ''}\"\n part=\"overlay\"\n aria-hidden=\"true\"\n ?hidden=${this.hideOutlines}\n >\n ${this.entries.map((e, i) =>\n e.box\n ? html`<div\n class=\"region ${i === this.active ? 'active' : ''}\"\n part=\"region\"\n data-index=${i}\n >\n <span class=\"badge ${numbers ? '' : 'no-number'}\"\n >${numbers ? html`<span class=\"number\">${e.number}</span>` : nothing}${\n e.item.label ? html`<span class=\"name\">${e.item.label}</span>` : nothing\n }</span\n >\n </div>`\n : nothing,\n )}\n </div>\n </div>\n ${light ? html`<div class=\"controls-host\"></div>` : html`<slot name=\"controls\"></slot>`}\n </div>\n <div class=\"list\" part=\"list\">\n <div class=\"heading\" role=\"heading\" aria-level=${this.level} id=${this.headingId}>\n ${normalize(this.label) || DEFAULT_LABEL}\n </div>\n ${list}\n </div>\n </div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibImageRegions } from './UvalibImageRegions.js';\n\ndefine('uvalib-image-regions', UvalibImageRegions);\n"],"mappings":";;;;;;;AAqBA,IAAMsB,IAAgB,WAClBC,IAAS,GAGPC,IAAY,6EASZC,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;;;;;;IAMLA,EAAK;IACLA,EAAK;;;;;;;IAOLA,EAAK;IACLA,EAAK,eAAeA,EAAK,sBACzBA,MAAS,UAAU,yCAAyC,GAC7D;IACCA,EAAK;;;;;;;;IAQLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;IACLA,EAAK;;;;;;;;;;;;;;;;IAgBLA,EAAK;;;;;IAKLA,EAAK;;;;IAILA,EAAK;IACLA,EAAK,sCAAsCA,EAAK;IAChDA,EAAK;IACLA,EAAK;IACLA,EAAK;;MAEHA,EAAK;MACLA,EAAK;MACLA,EAAK;MACLA,EAAK;;IAEPA,EAAK,YAAYA,EAAK;GAEpBC,IAAkB3B,EAAUyB,EAAgB,OAAO,CAAC,GAOpDG,KAAc,MAAc;IAC9BC,EAAE;;;;;;IAMFA,EAAE;;;;;IAKFA,EAAE;;;;IAIFA,EAAE;;MAEAA,EAAE;;GAGFC,IAAc9B,EAAU4B,EAAW,EAAE,CAAC,GAwC/BG,IAAb,cAAwClB,EAAc;;EACpC,KAAA,SAAA;GACdK;GACAS;GACAG;GACA,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BL;;CAmDA,cAAc;EAMZ,AALA,MAAM,GAjDsD,KAAA,QAAA,MAG5B,KAAA,MAAA,IAEA,KAAA,MAAA,IAeE,KAAA,QAAA,WAMwB,KAAA,YAAA,WAG2B,KAAA,eAAA,IAEnD,KAAA,UAAA,CAAC,GACuB,KAAA,UAAA,MAClC,K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