@uvalib/web-components 1.1.0 → 1.2.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 +64 -0
- package/README.md +563 -47
- package/dist/base/url-param.d.ts +23 -0
- package/dist/base/url-param.js +49 -0
- package/dist/base/url-param.js.map +1 -0
- package/dist/base.css +289 -1
- package/dist/components/uvalib-card/UvalibCard.d.ts +19 -5
- package/dist/components/uvalib-card/UvalibCard.js +112 -9
- package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
- package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +156 -0
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js +747 -0
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.d.ts +1 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.js +4 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.js.map +1 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.d.ts +148 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +1248 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.d.ts +1 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js +4 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js.map +1 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +8 -1
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-lightbox/media.d.ts +1 -18
- package/dist/components/uvalib-lightbox/media.js +1 -42
- package/dist/components/uvalib-lightbox/media.js.map +1 -1
- package/dist/components/uvalib-pager/UvalibPager.d.ts +58 -4
- package/dist/components/uvalib-pager/UvalibPager.js +232 -8
- package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +27 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +192 -26
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
- package/dist/components/uvalib-results-count/UvalibResultsCount.d.ts +62 -0
- package/dist/components/uvalib-results-count/UvalibResultsCount.js +208 -0
- package/dist/components/uvalib-results-count/UvalibResultsCount.js.map +1 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.d.ts +1 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.js +4 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.js.map +1 -0
- package/dist/components/uvalib-tabs/UvalibTabs.d.ts +127 -0
- package/dist/components/uvalib-tabs/UvalibTabs.js +821 -0
- package/dist/components/uvalib-tabs/UvalibTabs.js.map +1 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.d.ts +1 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.js +4 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.js.map +1 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +89 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.js +411 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.d.ts +1 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.js +4 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.js.map +1 -0
- package/dist/custom-elements.json +7140 -2630
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/base.js +35 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +4 -0
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.js +2 -0
- package/dist/styles/controls.js.map +1 -1
- package/dist/styles/results.d.ts +1 -0
- package/dist/styles/results.js +257 -0
- package/dist/styles/results.js.map +1 -0
- package/dist/tokens.css +4 -0
- package/dist-cdn/base.css +289 -1
- package/dist-cdn/chunks/{base-CAFQWnZG.js → base-p5pk0vb2.js} +36 -2
- package/dist-cdn/chunks/{base-CAFQWnZG.js.map → base-p5pk0vb2.js.map} +1 -1
- package/dist-cdn/chunks/inline-copy-BANQSMIR.js +69 -0
- package/dist-cdn/chunks/inline-copy-BANQSMIR.js.map +1 -0
- package/dist-cdn/chunks/{site-header-C9V7Wuw2.js → site-header-BlOYvQg1.js} +5 -1
- package/dist-cdn/chunks/site-header-BlOYvQg1.js.map +1 -0
- package/dist-cdn/chunks/source-children-BHsDwCvL.js +53 -0
- package/dist-cdn/chunks/source-children-BHsDwCvL.js.map +1 -0
- package/dist-cdn/chunks/url-param-C1sk_F1d.js +28 -0
- package/dist-cdn/chunks/url-param-C1sk_F1d.js.map +1 -0
- package/dist-cdn/custom-elements.json +7140 -2630
- package/dist-cdn/manifest.json +7 -2
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-page.js +2 -2
- package/dist-cdn/site-style.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +206 -19
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +220 -6
- package/dist-cdn/tokens.css +4 -0
- package/dist-cdn/uvalib-card.js +94 -20
- package/dist-cdn/uvalib-card.js.map +1 -1
- package/dist-cdn/uvalib-chip-group.js +496 -0
- package/dist-cdn/uvalib-chip-group.js.map +1 -0
- package/dist-cdn/uvalib-contents.js +2 -1
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-date-histogram.js +850 -0
- package/dist-cdn/uvalib-date-histogram.js.map +1 -0
- package/dist-cdn/uvalib-lightbox.js +26 -48
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-metadata.js +2 -1
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pager.js +141 -7
- package/dist-cdn/uvalib-pager.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +121 -19
- package/dist-cdn/uvalib-photo-grid.js.map +1 -1
- package/dist-cdn/uvalib-results-count.js +101 -0
- package/dist-cdn/uvalib-results-count.js.map +1 -0
- package/dist-cdn/uvalib-tabs.js +436 -0
- package/dist-cdn/uvalib-tabs.js.map +1 -0
- package/dist-cdn/uvalib-tag-list.js +267 -0
- package/dist-cdn/uvalib-tag-list.js.map +1 -0
- package/package.json +24 -3
- package/skills/uvalib-web-components/SKILL.md +206 -19
- package/skills/uvalib-web-components/reference/components.md +220 -6
- package/dist-cdn/chunks/site-header-C9V7Wuw2.js.map +0 -1
- package/dist-cdn/chunks/source-children-RuAec527.js +0 -119
- package/dist-cdn/chunks/source-children-RuAec527.js.map +0 -1
package/dist-cdn/uvalib-pager.js
CHANGED
|
@@ -54,6 +54,34 @@ var d = /* @__PURE__ */ new Set([
|
|
|
54
54
|
box-sizing: border-box;
|
|
55
55
|
text-decoration: none;
|
|
56
56
|
}
|
|
57
|
+
${e} .more {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-wrap: wrap;
|
|
60
|
+
align-items: center;
|
|
61
|
+
gap: 0.75rem 1rem;
|
|
62
|
+
min-width: 0;
|
|
63
|
+
max-width: 100%;
|
|
64
|
+
}
|
|
65
|
+
${e} .status { margin: 0; min-width: 0; overflow-wrap: anywhere; }
|
|
66
|
+
${e} .uvalib-button {
|
|
67
|
+
display: inline-flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
box-sizing: border-box;
|
|
71
|
+
min-width: 44px;
|
|
72
|
+
min-height: 44px;
|
|
73
|
+
margin: 0;
|
|
74
|
+
padding: 0.5rem 1.25rem;
|
|
75
|
+
font: inherit;
|
|
76
|
+
font-size: 1rem;
|
|
77
|
+
line-height: 1.2;
|
|
78
|
+
text-align: center;
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
}
|
|
81
|
+
${e} .uvalib-button:focus-visible {
|
|
82
|
+
outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));
|
|
83
|
+
outline-offset: 2px;
|
|
84
|
+
}
|
|
57
85
|
${e} .visually-hidden {
|
|
58
86
|
position: absolute;
|
|
59
87
|
width: 1px;
|
|
@@ -66,9 +94,13 @@ var d = /* @__PURE__ */ new Set([
|
|
|
66
94
|
border: 0;
|
|
67
95
|
}
|
|
68
96
|
${e}[hidden], ${e} [hidden] { display: none !important; }
|
|
97
|
+
@media (forced-colors: active) {
|
|
98
|
+
${e} .uvalib-button { border: 2px solid ButtonText; }
|
|
99
|
+
${e} .uvalib-button:focus-visible { outline: 3px solid Highlight; }
|
|
100
|
+
}
|
|
69
101
|
`, m = o(p(":host")), h = class extends c {
|
|
70
102
|
constructor(...e) {
|
|
71
|
-
super(...e), this.warnedHref = !1, this.warnedBoth = !1, this.warnedPages = !1, this.warnedTemplate = !1;
|
|
103
|
+
super(...e), this.warnedHref = !1, this.warnedBoth = !1, this.warnedPages = !1, this.warnedTemplate = !1, this.warnedLoad = !1, this.pendingCount = -1;
|
|
72
104
|
}
|
|
73
105
|
static {
|
|
74
106
|
this.styles = [
|
|
@@ -100,6 +132,23 @@ var d = /* @__PURE__ */ new Set([
|
|
|
100
132
|
min-height: 2.75rem;
|
|
101
133
|
padding-inline: 0.25rem;
|
|
102
134
|
}
|
|
135
|
+
.status {
|
|
136
|
+
color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));
|
|
137
|
+
}
|
|
138
|
+
.uvalib-button {
|
|
139
|
+
border: 2px solid var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));
|
|
140
|
+
border-radius: 5px;
|
|
141
|
+
background: var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));
|
|
142
|
+
color: var(--uva-color-button-text, #ffffff);
|
|
143
|
+
}
|
|
144
|
+
.uvalib-button:hover {
|
|
145
|
+
border-color: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));
|
|
146
|
+
background: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));
|
|
147
|
+
}
|
|
148
|
+
.uvalib-button:active {
|
|
149
|
+
border-color: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));
|
|
150
|
+
background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));
|
|
151
|
+
}
|
|
103
152
|
@media (forced-colors: active) {
|
|
104
153
|
.page[aria-current='page'] {
|
|
105
154
|
background: CanvasText;
|
|
@@ -109,6 +158,15 @@ var d = /* @__PURE__ */ new Set([
|
|
|
109
158
|
a {
|
|
110
159
|
color: LinkText;
|
|
111
160
|
}
|
|
161
|
+
.uvalib-button {
|
|
162
|
+
background: ButtonFace;
|
|
163
|
+
color: ButtonText;
|
|
164
|
+
border: 2px solid ButtonText;
|
|
165
|
+
forced-color-adjust: none;
|
|
166
|
+
}
|
|
167
|
+
.uvalib-button:focus-visible {
|
|
168
|
+
outline: 3px solid Highlight;
|
|
169
|
+
}
|
|
112
170
|
}
|
|
113
171
|
`
|
|
114
172
|
];
|
|
@@ -137,17 +195,29 @@ var d = /* @__PURE__ */ new Set([
|
|
|
137
195
|
get numbered() {
|
|
138
196
|
return this.pageCount > 0;
|
|
139
197
|
}
|
|
198
|
+
get loadMore() {
|
|
199
|
+
return (this.mode ?? "").trim().toLowerCase() === "load-more";
|
|
200
|
+
}
|
|
140
201
|
get currentPage() {
|
|
141
202
|
let e = this.pageCount, t = Math.trunc(this.page ?? 1);
|
|
142
203
|
return !Number.isFinite(t) || t < 1 ? 1 : Math.min(t, Math.max(e, 1));
|
|
143
204
|
}
|
|
144
205
|
get navLabel() {
|
|
145
|
-
return (this.label?.trim() ?? "") || (this.numbered ? "Pagination" : "Sections");
|
|
206
|
+
return (this.label?.trim() ?? "") || (this.loadMore ? "More results" : this.numbered ? "Pagination" : "Sections");
|
|
207
|
+
}
|
|
208
|
+
count(e) {
|
|
209
|
+
let t = Math.trunc(e ?? NaN);
|
|
210
|
+
return Number.isFinite(t) && t > 0 ? t : 0;
|
|
211
|
+
}
|
|
212
|
+
nextPage() {
|
|
213
|
+
let e = Math.trunc(this.page ?? NaN);
|
|
214
|
+
return (Number.isFinite(e) && e >= 1 ? e : 1) + 1;
|
|
215
|
+
}
|
|
216
|
+
hasPrevNext() {
|
|
217
|
+
return (this.prevHref ?? "").trim() !== "" || (this.nextHref ?? "").trim() !== "" || (this.prevLabel ?? "").trim() !== "" || (this.nextLabel ?? "").trim() !== "";
|
|
146
218
|
}
|
|
147
219
|
willUpdate() {
|
|
148
|
-
this.hasAttribute("pages") && !this.numbered && !this.warnedPages && (this.warnedPages = !0, console.warn(`${this.localName}: pages must be a positive number to show numbered pages.`));
|
|
149
|
-
let e = (this.prevHref ?? "").trim() !== "" || (this.nextHref ?? "").trim() !== "" || (this.prevLabel ?? "").trim() !== "" || (this.nextLabel ?? "").trim() !== "";
|
|
150
|
-
this.numbered && e && !this.warnedBoth && (this.warnedBoth = !0, console.warn(`${this.localName}: pages is set, so numbered pages are shown and previous/next are ignored.`)), this.numbered && !this.template().includes("{page}") && !this.warnedTemplate && (this.warnedTemplate = !0, console.warn(`${this.localName}: href-template must contain {page}.`));
|
|
220
|
+
this.loadMore ? (this.numbered || this.hasPrevNext()) && !this.warnedLoad && (this.warnedLoad = !0, console.warn(`${this.localName}: mode="load-more" is set, so previous/next and numbered pages are not shown.`)) : (this.hasAttribute("pages") && !this.numbered && !this.warnedPages && (this.warnedPages = !0, console.warn(`${this.localName}: pages must be a positive number to show numbered pages.`)), this.numbered && this.hasPrevNext() && !this.warnedBoth && (this.warnedBoth = !0, console.warn(`${this.localName}: pages is set, so numbered pages are shown and previous/next are ignored.`)), this.numbered && !this.template().includes("{page}") && !this.warnedTemplate && (this.warnedTemplate = !0, console.warn(`${this.localName}: href-template must contain {page}.`)));
|
|
151
221
|
}
|
|
152
222
|
template() {
|
|
153
223
|
return (this.hrefTemplate?.trim() ?? "") || f;
|
|
@@ -252,9 +322,70 @@ var d = /* @__PURE__ */ new Set([
|
|
|
252
322
|
${e ? this.renderSide("previous", e, this.prevLabel) : a}
|
|
253
323
|
${t ? this.renderSide("next", t, this.nextLabel) : a}
|
|
254
324
|
</nav>`;
|
|
325
|
+
}
|
|
326
|
+
listEl() {
|
|
327
|
+
let e = (this.listFor ?? "").trim();
|
|
328
|
+
if (!e) return null;
|
|
329
|
+
let t = this.getRootNode(), n = (t instanceof Document || t instanceof ShadowRoot ? t : null)?.getElementById(e) ?? this.ownerDocument.getElementById(e);
|
|
330
|
+
return n instanceof HTMLElement ? n : null;
|
|
331
|
+
}
|
|
332
|
+
entries(e) {
|
|
333
|
+
if (e.localName === "uvalib-card-grid") {
|
|
334
|
+
let t = (e.shadowRoot ?? e).querySelector("ul");
|
|
335
|
+
if (t) return [...t.children].filter((e) => e instanceof HTMLElement);
|
|
336
|
+
}
|
|
337
|
+
return [...e.children].filter((e) => e instanceof HTMLElement);
|
|
338
|
+
}
|
|
339
|
+
firstNew() {
|
|
340
|
+
let e = this.listEl();
|
|
341
|
+
return !e || this.pendingCount < 0 ? null : this.entries(e)[this.pendingCount] ?? null;
|
|
342
|
+
}
|
|
343
|
+
isDisabled(e) {
|
|
344
|
+
return (e instanceof HTMLButtonElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && e.disabled;
|
|
345
|
+
}
|
|
346
|
+
canFocus(e) {
|
|
347
|
+
return this.isDisabled(e) ? !1 : e.hasAttribute("tabindex") ? !0 : e instanceof HTMLAnchorElement ? e.hasAttribute("href") : e instanceof HTMLButtonElement || e.localName === "summary" || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
348
|
+
}
|
|
349
|
+
focusIn(e) {
|
|
350
|
+
let t = [], n = e.querySelector("slot");
|
|
351
|
+
n ? t.push(...n.assignedElements({ flatten: !0 })) : t.push(e);
|
|
352
|
+
for (let n of t) {
|
|
353
|
+
if (!(n instanceof HTMLElement)) continue;
|
|
354
|
+
if (n !== e && this.canFocus(n)) return n;
|
|
355
|
+
let t = n.querySelector("a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary");
|
|
356
|
+
if (t && this.canFocus(t)) return t;
|
|
357
|
+
}
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
loaded(e) {
|
|
361
|
+
let t = e instanceof HTMLElement && e.isConnected ? e : null, n = t ?? this.firstNew();
|
|
362
|
+
n instanceof HTMLElement && (t || (n = this.focusIn(n) ?? n), this.isDisabled(n) ? (n.tabIndex = -1, this.pendingCount = -1) : (this.canFocus(n) || (n.tabIndex = -1), n.focus({ focusVisible: !0 }), this.pendingCount = -1));
|
|
363
|
+
}
|
|
364
|
+
onLoadMore(e) {
|
|
365
|
+
if (e.defaultPrevented || e.button !== 0) return;
|
|
366
|
+
let t = this.nextPage(), n = this.listEl();
|
|
367
|
+
this.pendingCount = n ? this.entries(n).length : -1, l(this, [
|
|
368
|
+
"uvalib-pager",
|
|
369
|
+
"load-more",
|
|
370
|
+
"",
|
|
371
|
+
t
|
|
372
|
+
]), this.dispatchEvent(new CustomEvent("load-more", {
|
|
373
|
+
detail: { page: t },
|
|
374
|
+
bubbles: !0,
|
|
375
|
+
composed: !0
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
renderLoadMore() {
|
|
379
|
+
let e = this.count(this.shown), t = this.count(this.total), r = t > 0 && e >= t;
|
|
380
|
+
return n`<div class="more" role="group" aria-label=${this.navLabel}>
|
|
381
|
+
<div class="status" role="status">Showing ${e} of ${t}</div>
|
|
382
|
+
${r ? a : n`<button type="button" class="uvalib-button" @click=${this.onLoadMore}>
|
|
383
|
+
Load more
|
|
384
|
+
</button>`}
|
|
385
|
+
</div>`;
|
|
255
386
|
}
|
|
256
387
|
render() {
|
|
257
|
-
return this.numbered ? this.renderNumbered() : this.renderSections();
|
|
388
|
+
return this.loadMore ? this.renderLoadMore() : this.numbered ? this.renderNumbered() : this.renderSections();
|
|
258
389
|
}
|
|
259
390
|
};
|
|
260
391
|
// src/components/uvalib-pager/uvalib-pager.ts
|
|
@@ -270,7 +401,10 @@ i([e({
|
|
|
270
401
|
})], h.prototype, "nextHref", void 0), i([e({
|
|
271
402
|
type: String,
|
|
272
403
|
attribute: "next-label"
|
|
273
|
-
})], h.prototype, "nextLabel", void 0), i([e({ type: Number })], h.prototype, "
|
|
404
|
+
})], h.prototype, "nextLabel", void 0), i([e({ type: String })], h.prototype, "mode", void 0), i([e({ type: Number })], h.prototype, "shown", void 0), i([e({ type: Number })], h.prototype, "total", void 0), i([e({
|
|
405
|
+
type: String,
|
|
406
|
+
attribute: "for"
|
|
407
|
+
})], h.prototype, "listFor", void 0), i([e({ type: Number })], h.prototype, "page", void 0), i([e({ type: Number })], h.prototype, "pages", void 0), i([e({
|
|
274
408
|
type: String,
|
|
275
409
|
attribute: "href-template"
|
|
276
410
|
})], h.prototype, "hrefTemplate", void 0), i([e({ type: String })], h.prototype, "label", void 0), r("uvalib-pager", h);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uvalib-pager.js","names":["unsafeCSS","nothing","_decorate","property","n","i","b","define","__decorate","A","r","installLightDomStyles","UvalibElement","trackEvent","accessible","SAFE_SCHEMES","DEFAULT_TEMPLATE","structuralRules","host","shadowStructure","UvalibPager","_args","root","sheet","node","total","prevNext","ok","href","raw","template","current","set","nums","a","out","kind","page","detail","go","item","kicker","title","label","prev","next"],"sources":["../src/components/uvalib-pager/UvalibPager.ts","../src/components/uvalib-pager/uvalib-pager.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** Schemes a pager may link to; anything else is shown as text, not a link. */\nconst SAFE_SCHEMES = new Set(['http:', 'https:', 'mailto:', 'tel:']);\n\nconst DEFAULT_TEMPLATE = '?page={page}';\n\n/**\n * Kept with `no-style`: the previous/next row, the truncation of a long section title (the\n * full text stays in the accessible name), the page list, the “Page ” prefix hidden\n * visually, and a target at least 24px. `host` is `:host` or the tag.\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; min-width: 0; max-width: 100%; }\n ${host} nav.sections {\n display: flex;\n flex-wrap: wrap;\n justify-content: space-between;\n align-items: stretch;\n gap: 1rem;\n }\n ${host} a.pager-prev, ${host} a.pager-next {\n display: inline-flex;\n flex-direction: column;\n justify-content: center;\n gap: 0.15rem;\n max-width: 48%;\n min-width: 0;\n min-height: 2.75rem;\n overflow: hidden;\n text-decoration: none;\n }\n ${host} a.pager-next { margin-inline-start: auto; text-align: end; align-items: flex-end; }\n ${host} .pager-title {\n display: block;\n max-width: 100%;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n ${host} ol {\n display: flex;\n flex-wrap: wrap;\n gap: 0.25rem;\n list-style: none;\n margin: 0;\n padding: 0;\n }\n ${host} ol a, ${host} ol .page {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 2.75rem;\n min-height: 2.75rem;\n padding: 0.25rem;\n box-sizing: border-box;\n text-decoration: none;\n }\n ${host} .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\ntype Kind = 'next' | 'previous' | 'number';\ntype WindowItem = number | 'gap';\n\n/**\n * Previous/next section links, as on a reading page, or a numbered page list.\n *\n * Previous/next: set `prev-href` and `next-href` (either may be omitted). Each link shows\n * a “Previous” or “Next” kicker and, when `prev-label` or `next-label` is set, that title.\n * A visually hidden “: ” sits between them, so the accessible name is punctuated even\n * when CSS is off. A long title truncates visually; the full text stays in the accessible\n * name. The links use `rel=\"prev\"` and `rel=\"next\"`. With neither href, nothing is rendered.\n *\n * Numbered pages: set `pages` (a positive count). `page` is the current page, clamped to\n * `1…pages`. Each link’s href comes from `href-template`, which must contain `{page}`\n * (the default is `?page={page}`). The current page is text with `aria-current=\"page\"`,\n * not a link. Long ranges collapse to the first page, a window around the current page,\n * the last page, and an ellipsis where numbers are skipped. `pages` wins when previous/next\n * attributes are also set, with one console warning.\n *\n * The landmark’s accessible name is `label`, or “Sections” for previous/next and\n * “Pagination” for numbered pages. An empty `label` uses that default. Two pagers on one\n * page need different labels: a repeated landmark name fails the accessibility check.\n *\n * @tagname uvalib-pager\n * @fires uvalib-analytics-event - For `<site-analytics>`: a primary-button click that was not already canceled, including a modified click, on a page link `['uvalib-pager', 'page-change', 'number', <n>]`, or on a section link `['uvalib-pager', 'page-change', 'next'|'previous']` (no page number: that mode has none). Never the label or URL. Bubbles and is composed.\n * @fires uvalib-pager-navigate - A plain click on a pager link: `detail` is `{ href, kind, page? }` (`kind` is `'next'`, `'previous'` or `'number'`; `page` is set for `'number'`). Cancel it (`preventDefault()`) to route in the app; the click’s default is then prevented. Bubbles and is composed.\n * @cssprop --uva-color-link - Dark-mode role token: link colour (else `--uva-brand-blue`).\n * @cssprop --uva-color-text - Dark-mode role token: current page (else `--uva-grey-darkest`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: the Previous/Next kicker (else #4f4f4f).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: current page background (else `--uva-brand-blue`).\n * @cssprop --uva-color-on-accent - Text on the current page background (else #fff).\n */\nexport class UvalibPager extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n a {\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n a:hover .pager-title,\n a:hover {\n text-decoration: underline;\n }\n .pager-dir {\n color: var(--uva-color-text-muted, #4f4f4f);\n font-size: 0.75rem;\n letter-spacing: 0.04em;\n text-transform: uppercase;\n }\n .page[aria-current='page'] {\n background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n color: var(--uva-color-on-accent, #fff);\n border-radius: 0.25rem;\n font-weight: 600;\n }\n .ellipsis {\n display: inline-flex;\n align-items: center;\n min-height: 2.75rem;\n padding-inline: 0.25rem;\n }\n @media (forced-colors: active) {\n .page[aria-current='page'] {\n background: CanvasText;\n color: Canvas;\n forced-color-adjust: none;\n }\n a {\n color: LinkText;\n }\n }\n `,\n ];\n\n /** Href of the previous section. Omitted, that side is not shown. */\n @property({ type: String, attribute: 'prev-href' }) prevHref?: string;\n\n /** Title of the previous section, under the “Previous” kicker. */\n @property({ type: String, attribute: 'prev-label' }) prevLabel?: string;\n\n /** Href of the next section. Omitted, that side is not shown. */\n @property({ type: String, attribute: 'next-href' }) nextHref?: string;\n\n /** Title of the next section, under the “Next” kicker. */\n @property({ type: String, attribute: 'next-label' }) nextLabel?: string;\n\n /** Current page, from 1. Clamped to `pages`. Used when `pages` is set. */\n @property({ type: Number }) page?: number;\n\n /**\n * How many pages. A positive number selects numbered pages and ignores previous/next.\n * Zero, negative or non-numeric does not.\n */\n @property({ type: Number }) pages?: number;\n\n /**\n * Href of each numbered page, with `{page}` where the number goes.\n * Default `?page={page}` when omitted. Without `{page}`, numbered links are not made.\n */\n @property({ type: String, attribute: 'href-template' }) hrefTemplate?: string;\n\n /**\n * Accessible name of the navigation landmark. Default “Pagination” for numbered pages\n * and “Sections” for previous/next. Empty uses that default. A second pager on the\n * page needs its own name.\n */\n @property({ type: String }) label?: string;\n\n private warnedHref = false;\n private warnedBoth = false;\n private warnedPages = false;\n private warnedTemplate = false;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n }\n\n /** Positive finite `pages` selects numbered mode. `Number(\"foo\")` from the attribute is not. */\n private get pageCount(): number {\n const n = Math.trunc(this.pages ?? Number.NaN);\n return Number.isFinite(n) && n > 0 ? n : 0;\n }\n\n private get numbered(): boolean {\n return this.pageCount > 0;\n }\n\n private get currentPage(): number {\n const total = this.pageCount;\n const n = Math.trunc(this.page ?? 1);\n if (!Number.isFinite(n) || n < 1) return 1;\n return Math.min(n, Math.max(total, 1));\n }\n\n private get navLabel(): string {\n const text = this.label?.trim() ?? '';\n if (text) return text;\n return this.numbered ? 'Pagination' : 'Sections';\n }\n\n protected override willUpdate(): void {\n if (this.hasAttribute('pages') && !this.numbered && !this.warnedPages) {\n this.warnedPages = true;\n console.warn(`${this.localName}: pages must be a positive number to show numbered pages.`);\n }\n const prevNext =\n (this.prevHref ?? '').trim() !== '' ||\n (this.nextHref ?? '').trim() !== '' ||\n (this.prevLabel ?? '').trim() !== '' ||\n (this.nextLabel ?? '').trim() !== '';\n if (this.numbered && prevNext && !this.warnedBoth) {\n this.warnedBoth = true;\n console.warn(\n `${this.localName}: pages is set, so numbered pages are shown and previous/next are ignored.`,\n );\n }\n if (this.numbered && !this.template().includes('{page}') && !this.warnedTemplate) {\n this.warnedTemplate = true;\n console.warn(`${this.localName}: href-template must contain {page}.`);\n }\n }\n\n private template(): string {\n const raw = this.hrefTemplate?.trim() ?? '';\n return raw || DEFAULT_TEMPLATE;\n }\n\n private safe(href: string): boolean {\n let ok = false;\n try {\n ok = SAFE_SCHEMES.has(new URL(href, this.ownerDocument.baseURI).protocol);\n } catch {\n ok = false;\n }\n if (!ok && !this.warnedHref) {\n this.warnedHref = true;\n console.warn(\n `${this.localName}: not linking a page whose href is not http(s), mailto, tel or relative.`,\n );\n }\n return ok;\n }\n\n private sideHref(href: string | undefined): string | null {\n const raw = href?.trim() ?? '';\n if (!raw || !this.safe(raw)) return null;\n return raw;\n }\n\n private hrefFor(n: number): string | null {\n const template = this.template();\n if (!template.includes('{page}')) return null;\n const href = template.replaceAll('{page}', String(n));\n return this.safe(href) ? href : null;\n }\n\n /**\n * Pages to show. At most seven steps stay whole. Otherwise: the first, the last, and a\n * window around the current page (pages 1–4 when near the start, the last four when near\n * the end), with a gap wherever numbers are skipped.\n */\n private window(): WindowItem[] {\n const total = this.pageCount;\n const current = this.currentPage;\n if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1);\n const set = new Set<number>([1, total, current - 1, current, current + 1]);\n if (current <= 3) for (let i = 1; i <= 4; i++) set.add(i);\n if (current >= total - 2) for (let i = total - 3; i <= total; i++) set.add(i);\n const nums = [...set].filter((n) => n >= 1 && n <= total).sort((a, b) => a - b);\n const out: WindowItem[] = [];\n for (let i = 0; i < nums.length; i++) {\n const n = nums[i]!;\n if (i > 0 && n - nums[i - 1]! > 1) out.push('gap');\n out.push(n);\n }\n return out;\n }\n\n /**\n * A plain primary-button click fires a cancelable `uvalib-pager-navigate`. A click that\n * was already canceled, or that is not the primary button, is ignored. Modified clicks\n * are tracked and do not fire the navigate event.\n */\n private onClick(e: MouseEvent): void {\n const node = e.target instanceof Node ? e.target : null;\n const el = node instanceof Element ? node : node?.parentElement;\n const a = el?.closest('a[href]');\n if (!(a instanceof HTMLAnchorElement) || !this.renderRoot.contains(a)) return;\n const kind = a.dataset.kind as Kind | undefined;\n if (kind !== 'next' && kind !== 'previous' && kind !== 'number') return;\n if (e.defaultPrevented || e.button !== 0) return;\n const page = kind === 'number' ? Number(a.dataset.page) : undefined;\n if (kind === 'number' && page !== undefined && Number.isFinite(page))\n trackEvent(this, ['uvalib-pager', 'page-change', 'number', page]);\n else trackEvent(this, ['uvalib-pager', 'page-change', kind]);\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n const detail: { href: string | null; kind: Kind; page?: number } = {\n href: a.getAttribute('href'),\n kind,\n };\n if (page !== undefined && Number.isFinite(page)) detail.page = page;\n const go = new CustomEvent('uvalib-pager-navigate', {\n detail,\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n private pageBits(n: number) {\n return html`<span class=\"visually-hidden\">Page </span>${n}`;\n }\n\n private renderNumbered() {\n const current = this.currentPage;\n return html`<nav class=\"pages\" aria-label=${this.navLabel} @click=${this.onClick}>\n <ol role=\"list\">\n ${this.window().map((item) =>\n item === 'gap'\n ? html`<li aria-hidden=\"true\"><span class=\"ellipsis\">…</span></li>`\n : html`<li role=\"listitem\">\n ${\n item === current\n ? html`<span class=\"page\" aria-current=\"page\">${this.pageBits(item)}</span>`\n : this.hrefFor(item)\n ? html`<a href=${this.hrefFor(item)!} data-kind=\"number\" data-page=${item}\n >${this.pageBits(item)}</a\n >`\n : html`<span class=\"page\">${this.pageBits(item)}</span>`\n }\n </li>`,\n )}\n </ol>\n </nav>`;\n }\n\n private renderSide(kind: 'previous' | 'next', href: string, label: string | undefined) {\n const kicker = kind === 'previous' ? 'Previous' : 'Next';\n const title = label?.trim() ?? '';\n const className = kind === 'previous' ? 'pager-prev' : 'pager-next';\n return html`<a\n class=${className}\n rel=${kind === 'previous' ? 'prev' : 'next'}\n href=${href}\n data-kind=${kind}\n >\n <span class=\"pager-dir\">${kicker}</span>\n ${\n title\n ? html`<span class=\"visually-hidden\">: </span><span class=\"pager-title\">${title}</span>`\n : nothing\n }\n </a>`;\n }\n\n private renderSections() {\n const prev = this.sideHref(this.prevHref);\n const next = this.sideHref(this.nextHref);\n if (!prev && !next) return nothing;\n return html`<nav class=\"sections\" aria-label=${this.navLabel} @click=${this.onClick}>\n ${prev ? this.renderSide('previous', prev, this.prevLabel) : nothing}\n ${next ? this.renderSide('next', next, this.nextLabel) : nothing}\n </nav>`;\n }\n\n protected override render() {\n return this.numbered ? this.renderNumbered() : this.renderSections();\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibPager } from './UvalibPager.js';\n\ndefine('uvalib-pager', UvalibPager);\n"],"mappings":";;;;AAQA,IAAMe,oBA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AAO,CAAC,CAAA,GAAAiB,EAAA,WAAA,QAAA,KAAA,CAAA,GAMzBlB,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAiB,EAAA,WAAA,SAAA,KAAA,CAAA,GAMzBlB,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAQ,WAAW;AAAgB,CAAC,CAAA,GAAAiB,EAAA,WAAA,gBAAA,KAAA,CAAA,GAOrDlB,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAiB,EAAA,WAAA,SAAA,KAAA,CAAA,GCxL5Bb,EAAO,gBAAgBa,CAAW"}
|
|
1
|
+
{"version":3,"file":"uvalib-pager.js","names":["unsafeCSS","nothing","_decorate","property","n","i","b","define","__decorate","A","r","installLightDomStyles","UvalibElement","trackEvent","accessible","SAFE_SCHEMES","DEFAULT_TEMPLATE","structuralRules","host","shadowStructure","UvalibPager","_args","root","sheet","node","total","value","ok","href","raw","template","current","set","nums","a","out","kind","page","detail","go","item","kicker","title","label","prev","next","id","found","list","ul","el","roots","slot","inner","given","firstNew","target","shown","done"],"sources":["../src/components/uvalib-pager/UvalibPager.ts","../src/components/uvalib-pager/uvalib-pager.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** Schemes a pager may link to; anything else is shown as text, not a link. */\nconst SAFE_SCHEMES = new Set(['http:', 'https:', 'mailto:', 'tel:']);\n\nconst DEFAULT_TEMPLATE = '?page={page}';\n\n/**\n * Kept with `no-style`: the previous/next row, the truncation of a long section title (the\n * full text stays in the accessible name), the page list, the “Page ” prefix hidden\n * visually, and a target at least 24px. `host` is `:host` or the tag.\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; min-width: 0; max-width: 100%; }\n ${host} nav.sections {\n display: flex;\n flex-wrap: wrap;\n justify-content: space-between;\n align-items: stretch;\n gap: 1rem;\n }\n ${host} a.pager-prev, ${host} a.pager-next {\n display: inline-flex;\n flex-direction: column;\n justify-content: center;\n gap: 0.15rem;\n max-width: 48%;\n min-width: 0;\n min-height: 2.75rem;\n overflow: hidden;\n text-decoration: none;\n }\n ${host} a.pager-next { margin-inline-start: auto; text-align: end; align-items: flex-end; }\n ${host} .pager-title {\n display: block;\n max-width: 100%;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n ${host} ol {\n display: flex;\n flex-wrap: wrap;\n gap: 0.25rem;\n list-style: none;\n margin: 0;\n padding: 0;\n }\n ${host} ol a, ${host} ol .page {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 2.75rem;\n min-height: 2.75rem;\n padding: 0.25rem;\n box-sizing: border-box;\n text-decoration: none;\n }\n ${host} .more {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.75rem 1rem;\n min-width: 0;\n max-width: 100%;\n }\n ${host} .status { margin: 0; min-width: 0; overflow-wrap: anywhere; }\n ${host} .uvalib-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n min-width: 44px;\n min-height: 44px;\n margin: 0;\n padding: 0.5rem 1.25rem;\n font: inherit;\n font-size: 1rem;\n line-height: 1.2;\n text-align: center;\n cursor: pointer;\n }\n ${host} .uvalib-button:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n ${host} .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n @media (forced-colors: active) {\n ${host} .uvalib-button { border: 2px solid ButtonText; }\n ${host} .uvalib-button:focus-visible { outline: 3px solid Highlight; }\n }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\ntype Kind = 'next' | 'previous' | 'number';\ntype WindowItem = number | 'gap';\n\n/**\n * Previous/next section links, as on a reading page, or a numbered page list.\n *\n * Previous/next: set `prev-href` and `next-href` (either may be omitted). Each link shows\n * a “Previous” or “Next” kicker and, when `prev-label` or `next-label` is set, that title.\n * A visually hidden “: ” sits between them, so the accessible name is punctuated even\n * when CSS is off. A long title truncates visually; the full text stays in the accessible\n * name. The links use `rel=\"prev\"` and `rel=\"next\"`. With neither href, nothing is rendered.\n *\n * Numbered pages: set `pages` (a positive count). `page` is the current page, clamped to\n * `1…pages`. Each link’s href comes from `href-template`, which must contain `{page}`\n * (the default is `?page={page}`). The current page is text with `aria-current=\"page\"`,\n * not a link. Long ranges collapse to the first page, a window around the current page,\n * the last page, and an ellipsis where numbers are skipped. `pages` wins when previous/next\n * attributes are also set, with one console warning.\n *\n * Load more: `mode=\"load-more\"` shows a “Load more” button and “Showing N of M” (`shown`\n * of `total`). It wins over numbered pages and previous/next, with one warning when those\n * are also set. The button is not a link and the control is a group, not a navigation\n * landmark. The button hides once `shown` has reached a positive `total`. `page` is the\n * last loaded page (default 1). A click fires `load-more` with `{ page }` set to the next\n * page and reports `['uvalib-pager', 'load-more', '', page]`. Nothing is reported on\n * render. Call `loaded(firstNewElement)`, or set `for` to a list id and call `loaded()`,\n * and focus moves to that new item.\n *\n * The landmark’s accessible name is `label`, or “Sections” for previous/next and\n * “Pagination” for numbered pages. Load more uses `label` or “More results”. An empty\n * `label` uses that default. Two pagers on one page need different labels: a repeated\n * landmark name fails the accessibility check.\n *\n * @tagname uvalib-pager\n * @fires uvalib-analytics-event - For `<site-analytics>`: a primary-button click that was not already canceled, including a modified click, on a page link `['uvalib-pager', 'page-change', 'number', <n>]`, on a section link `['uvalib-pager', 'page-change', 'next'|'previous']`, or on Load more `['uvalib-pager', 'load-more', '', <next page>]`. Never the label or URL. Nothing on render. Bubbles and is composed.\n * @fires load-more - A primary click on Load more: `detail` is `{ page }` (the next page). Bubbles and is composed.\n * @fires uvalib-pager-navigate - A plain click on a pager link: `detail` is `{ href, kind, page? }` (`kind` is `'next'`, `'previous'` or `'number'`; `page` is set for `'number'`). Cancel it (`preventDefault()`) to route in the app; the click’s default is then prevented. Bubbles and is composed.\n * @cssprop --uva-color-link - Dark-mode role token: link colour (else `--uva-brand-blue`).\n * @cssprop --uva-color-text - Dark-mode role token: current page (else `--uva-grey-darkest`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: the Previous/Next kicker (else #4f4f4f).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: current page background (else `--uva-brand-blue`).\n * @cssprop --uva-color-on-accent - Text on the current page background (else #fff).\n * @cssprop --uva-color-button-bg - Load more background (else `--uva-blue-alt`).\n * @cssprop --uva-color-button-text - Load more text (else #fff). Dark mode’s own text is dark on the light button.\n * @cssprop --uva-color-button-hover-bg - Load more hover background (else `--uva-blue-alt-A`).\n */\nexport class UvalibPager extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n a {\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n a:hover .pager-title,\n a:hover {\n text-decoration: underline;\n }\n .pager-dir {\n color: var(--uva-color-text-muted, #4f4f4f);\n font-size: 0.75rem;\n letter-spacing: 0.04em;\n text-transform: uppercase;\n }\n .page[aria-current='page'] {\n background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n color: var(--uva-color-on-accent, #fff);\n border-radius: 0.25rem;\n font-weight: 600;\n }\n .ellipsis {\n display: inline-flex;\n align-items: center;\n min-height: 2.75rem;\n padding-inline: 0.25rem;\n }\n .status {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .uvalib-button {\n border: 2px solid var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));\n border-radius: 5px;\n background: var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));\n color: var(--uva-color-button-text, #ffffff);\n }\n .uvalib-button:hover {\n border-color: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));\n background: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));\n }\n .uvalib-button:active {\n border-color: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n }\n @media (forced-colors: active) {\n .page[aria-current='page'] {\n background: CanvasText;\n color: Canvas;\n forced-color-adjust: none;\n }\n a {\n color: LinkText;\n }\n .uvalib-button {\n background: ButtonFace;\n color: ButtonText;\n border: 2px solid ButtonText;\n forced-color-adjust: none;\n }\n .uvalib-button:focus-visible {\n outline: 3px solid Highlight;\n }\n }\n `,\n ];\n\n /** Href of the previous section. Omitted, that side is not shown. */\n @property({ type: String, attribute: 'prev-href' }) prevHref?: string;\n\n /** Title of the previous section, under the “Previous” kicker. */\n @property({ type: String, attribute: 'prev-label' }) prevLabel?: string;\n\n /** Href of the next section. Omitted, that side is not shown. */\n @property({ type: String, attribute: 'next-href' }) nextHref?: string;\n\n /** Title of the next section, under the “Next” kicker. */\n @property({ type: String, attribute: 'next-label' }) nextLabel?: string;\n\n /**\n * `load-more` shows a Load more button instead of previous/next or numbered pages.\n * Any other value, including empty, leaves the pager in its other modes.\n */\n @property({ type: String }) mode?: string;\n\n /** How many results are already shown. Used by `mode=\"load-more\"` as N in “Showing N of M”. */\n @property({ type: Number }) shown?: number;\n\n /** How many results there are. Used by `mode=\"load-more\"` as M in “Showing N of M”. */\n @property({ type: Number }) total?: number;\n\n /**\n * Id of the list Load more appends to. `loaded()` focuses the first child added after\n * the click. Ignored when `loaded` is passed an element.\n */\n @property({ type: String, attribute: 'for' }) listFor?: string;\n\n /** Current page, from 1. Clamped to `pages`. Used when `pages` is set. In load-more, the last loaded page (default 1); a click asks for the next one. */\n @property({ type: Number }) page?: number;\n\n /**\n * How many pages. A positive number selects numbered pages and ignores previous/next.\n * Zero, negative or non-numeric does not.\n */\n @property({ type: Number }) pages?: number;\n\n /**\n * Href of each numbered page, with `{page}` where the number goes.\n * Default `?page={page}` when omitted. Without `{page}`, numbered links are not made.\n */\n @property({ type: String, attribute: 'href-template' }) hrefTemplate?: string;\n\n /**\n * Accessible name of the navigation landmark. Default “Pagination” for numbered pages\n * and “Sections” for previous/next. Empty uses that default. A second pager on the\n * page needs its own name.\n */\n @property({ type: String }) label?: string;\n\n private warnedHref = false;\n private warnedBoth = false;\n private warnedPages = false;\n private warnedTemplate = false;\n private warnedLoad = false;\n /** Child count of the `for` list at the last Load more click, or -1 when there was no list. */\n private pendingCount = -1;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n }\n\n /** Positive finite `pages` selects numbered mode. `Number(\"foo\")` from the attribute is not. */\n private get pageCount(): number {\n const n = Math.trunc(this.pages ?? Number.NaN);\n return Number.isFinite(n) && n > 0 ? n : 0;\n }\n\n private get numbered(): boolean {\n return this.pageCount > 0;\n }\n\n private get loadMore(): boolean {\n return (this.mode ?? '').trim().toLowerCase() === 'load-more';\n }\n\n private get currentPage(): number {\n const total = this.pageCount;\n const n = Math.trunc(this.page ?? 1);\n if (!Number.isFinite(n) || n < 1) return 1;\n return Math.min(n, Math.max(total, 1));\n }\n\n private get navLabel(): string {\n const text = this.label?.trim() ?? '';\n if (text) return text;\n if (this.loadMore) return 'More results';\n return this.numbered ? 'Pagination' : 'Sections';\n }\n\n /** A non-negative integer, or 0 when the value is missing or not a positive count. */\n private count(value: number | undefined): number {\n const n = Math.trunc(value ?? Number.NaN);\n return Number.isFinite(n) && n > 0 ? n : 0;\n }\n\n /** The page a Load more click asks for. `page` is the last loaded page and defaults to 1. */\n private nextPage(): number {\n const n = Math.trunc(this.page ?? Number.NaN);\n const current = Number.isFinite(n) && n >= 1 ? n : 1;\n return current + 1;\n }\n\n private hasPrevNext(): boolean {\n return (\n (this.prevHref ?? '').trim() !== '' ||\n (this.nextHref ?? '').trim() !== '' ||\n (this.prevLabel ?? '').trim() !== '' ||\n (this.nextLabel ?? '').trim() !== ''\n );\n }\n\n protected override willUpdate(): void {\n if (this.loadMore) {\n if ((this.numbered || this.hasPrevNext()) && !this.warnedLoad) {\n this.warnedLoad = true;\n console.warn(\n `${this.localName}: mode=\"load-more\" is set, so previous/next and numbered pages are not shown.`,\n );\n }\n return;\n }\n if (this.hasAttribute('pages') && !this.numbered && !this.warnedPages) {\n this.warnedPages = true;\n console.warn(`${this.localName}: pages must be a positive number to show numbered pages.`);\n }\n if (this.numbered && this.hasPrevNext() && !this.warnedBoth) {\n this.warnedBoth = true;\n console.warn(\n `${this.localName}: pages is set, so numbered pages are shown and previous/next are ignored.`,\n );\n }\n if (this.numbered && !this.template().includes('{page}') && !this.warnedTemplate) {\n this.warnedTemplate = true;\n console.warn(`${this.localName}: href-template must contain {page}.`);\n }\n }\n\n private template(): string {\n const raw = this.hrefTemplate?.trim() ?? '';\n return raw || DEFAULT_TEMPLATE;\n }\n\n private safe(href: string): boolean {\n let ok = false;\n try {\n ok = SAFE_SCHEMES.has(new URL(href, this.ownerDocument.baseURI).protocol);\n } catch {\n ok = false;\n }\n if (!ok && !this.warnedHref) {\n this.warnedHref = true;\n console.warn(\n `${this.localName}: not linking a page whose href is not http(s), mailto, tel or relative.`,\n );\n }\n return ok;\n }\n\n private sideHref(href: string | undefined): string | null {\n const raw = href?.trim() ?? '';\n if (!raw || !this.safe(raw)) return null;\n return raw;\n }\n\n private hrefFor(n: number): string | null {\n const template = this.template();\n if (!template.includes('{page}')) return null;\n const href = template.replaceAll('{page}', String(n));\n return this.safe(href) ? href : null;\n }\n\n /**\n * Pages to show. At most seven steps stay whole. Otherwise: the first, the last, and a\n * window around the current page (pages 1–4 when near the start, the last four when near\n * the end), with a gap wherever numbers are skipped.\n */\n private window(): WindowItem[] {\n const total = this.pageCount;\n const current = this.currentPage;\n if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1);\n const set = new Set<number>([1, total, current - 1, current, current + 1]);\n if (current <= 3) for (let i = 1; i <= 4; i++) set.add(i);\n if (current >= total - 2) for (let i = total - 3; i <= total; i++) set.add(i);\n const nums = [...set].filter((n) => n >= 1 && n <= total).sort((a, b) => a - b);\n const out: WindowItem[] = [];\n for (let i = 0; i < nums.length; i++) {\n const n = nums[i]!;\n if (i > 0 && n - nums[i - 1]! > 1) out.push('gap');\n out.push(n);\n }\n return out;\n }\n\n /**\n * A plain primary-button click fires a cancelable `uvalib-pager-navigate`. A click that\n * was already canceled, or that is not the primary button, is ignored. Modified clicks\n * are tracked and do not fire the navigate event.\n */\n private onClick(e: MouseEvent): void {\n const node = e.target instanceof Node ? e.target : null;\n const el = node instanceof Element ? node : node?.parentElement;\n const a = el?.closest('a[href]');\n if (!(a instanceof HTMLAnchorElement) || !this.renderRoot.contains(a)) return;\n const kind = a.dataset.kind as Kind | undefined;\n if (kind !== 'next' && kind !== 'previous' && kind !== 'number') return;\n if (e.defaultPrevented || e.button !== 0) return;\n const page = kind === 'number' ? Number(a.dataset.page) : undefined;\n if (kind === 'number' && page !== undefined && Number.isFinite(page))\n trackEvent(this, ['uvalib-pager', 'page-change', 'number', page]);\n else trackEvent(this, ['uvalib-pager', 'page-change', kind]);\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n const detail: { href: string | null; kind: Kind; page?: number } = {\n href: a.getAttribute('href'),\n kind,\n };\n if (page !== undefined && Number.isFinite(page)) detail.page = page;\n const go = new CustomEvent('uvalib-pager-navigate', {\n detail,\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n private pageBits(n: number) {\n return html`<span class=\"visually-hidden\">Page </span>${n}`;\n }\n\n private renderNumbered() {\n const current = this.currentPage;\n return html`<nav class=\"pages\" aria-label=${this.navLabel} @click=${this.onClick}>\n <ol role=\"list\">\n ${this.window().map((item) =>\n item === 'gap'\n ? html`<li aria-hidden=\"true\"><span class=\"ellipsis\">…</span></li>`\n : html`<li role=\"listitem\">\n ${\n item === current\n ? html`<span class=\"page\" aria-current=\"page\">${this.pageBits(item)}</span>`\n : this.hrefFor(item)\n ? html`<a href=${this.hrefFor(item)!} data-kind=\"number\" data-page=${item}\n >${this.pageBits(item)}</a\n >`\n : html`<span class=\"page\">${this.pageBits(item)}</span>`\n }\n </li>`,\n )}\n </ol>\n </nav>`;\n }\n\n private renderSide(kind: 'previous' | 'next', href: string, label: string | undefined) {\n const kicker = kind === 'previous' ? 'Previous' : 'Next';\n const title = label?.trim() ?? '';\n const className = kind === 'previous' ? 'pager-prev' : 'pager-next';\n return html`<a\n class=${className}\n rel=${kind === 'previous' ? 'prev' : 'next'}\n href=${href}\n data-kind=${kind}\n >\n <span class=\"pager-dir\">${kicker}</span>\n ${\n title\n ? html`<span class=\"visually-hidden\">: </span><span class=\"pager-title\">${title}</span>`\n : nothing\n }\n </a>`;\n }\n\n private renderSections() {\n const prev = this.sideHref(this.prevHref);\n const next = this.sideHref(this.nextHref);\n if (!prev && !next) return nothing;\n return html`<nav class=\"sections\" aria-label=${this.navLabel} @click=${this.onClick}>\n ${prev ? this.renderSide('previous', prev, this.prevLabel) : nothing}\n ${next ? this.renderSide('next', next, this.nextLabel) : nothing}\n </nav>`;\n }\n\n private listEl(): HTMLElement | null {\n const id = (this.listFor ?? '').trim();\n if (!id) return null;\n const node = this.getRootNode();\n const root = node instanceof Document || node instanceof ShadowRoot ? node : null;\n const found = root?.getElementById(id) ?? this.ownerDocument.getElementById(id);\n return found instanceof HTMLElement ? found : null;\n }\n\n /** Cards in a grid live in its `<ul>`, not as host children once light DOM has placed them. */\n private entries(list: HTMLElement): HTMLElement[] {\n if (list.localName === 'uvalib-card-grid') {\n const ul = (list.shadowRoot ?? list).querySelector('ul');\n if (ul) return [...ul.children].filter((n): n is HTMLElement => n instanceof HTMLElement);\n }\n return [...list.children].filter((n): n is HTMLElement => n instanceof HTMLElement);\n }\n\n private firstNew(): HTMLElement | null {\n const list = this.listEl();\n if (!list || this.pendingCount < 0) return null;\n return this.entries(list)[this.pendingCount] ?? null;\n }\n\n private isDisabled(el: HTMLElement): boolean {\n return (\n (el instanceof HTMLButtonElement ||\n el instanceof HTMLInputElement ||\n el instanceof HTMLSelectElement ||\n el instanceof HTMLTextAreaElement) &&\n el.disabled\n );\n }\n\n private canFocus(el: HTMLElement): boolean {\n if (this.isDisabled(el)) return false;\n if (el.hasAttribute('tabindex')) return true;\n if (el instanceof HTMLAnchorElement) return el.hasAttribute('href');\n if (el instanceof HTMLButtonElement) return true;\n return (\n el.localName === 'summary' ||\n el instanceof HTMLInputElement ||\n el instanceof HTMLSelectElement ||\n el instanceof HTMLTextAreaElement\n );\n }\n\n /** A link or control inside a new list item, including one slotted into a card grid. */\n private focusIn(el: HTMLElement): HTMLElement | null {\n const roots: Element[] = [];\n const slot = el.querySelector('slot');\n if (slot) roots.push(...slot.assignedElements({ flatten: true }));\n else roots.push(el);\n for (const root of roots) {\n if (!(root instanceof HTMLElement)) continue;\n if (root !== el && this.canFocus(root)) return root;\n const inner = root.querySelector<HTMLElement>(\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary',\n );\n if (inner && this.canFocus(inner)) return inner;\n }\n return null;\n }\n\n /**\n * Move focus to `firstNew`, or to the first item added to the `for` list since the\n * click. A card grid counts the items in its list. An element that cannot take focus\n * gets `tabindex=\"-1\"`. A disabled field is not treated as focusable. The target is\n * focused so its ring shows.\n */\n loaded(firstNew?: HTMLElement): void {\n const given = firstNew instanceof HTMLElement && firstNew.isConnected ? firstNew : null;\n let target = given ?? this.firstNew();\n if (!(target instanceof HTMLElement)) return;\n if (!given) target = this.focusIn(target) ?? target;\n if (this.isDisabled(target)) {\n target.tabIndex = -1;\n this.pendingCount = -1;\n return;\n }\n if (!this.canFocus(target)) target.tabIndex = -1;\n // lib.dom in this project has no focusVisible; the option is what draws the ring.\n target.focus({ focusVisible: true } as FocusOptions);\n this.pendingCount = -1;\n }\n\n private onLoadMore(e: MouseEvent): void {\n if (e.defaultPrevented || e.button !== 0) return;\n const page = this.nextPage();\n const list = this.listEl();\n this.pendingCount = list ? this.entries(list).length : -1;\n trackEvent(this, ['uvalib-pager', 'load-more', '', page]);\n this.dispatchEvent(\n new CustomEvent('load-more', { detail: { page }, bubbles: true, composed: true }),\n );\n }\n\n private renderLoadMore() {\n const shown = this.count(this.shown);\n const total = this.count(this.total);\n const done = total > 0 && shown >= total;\n return html`<div class=\"more\" role=\"group\" aria-label=${this.navLabel}>\n <div class=\"status\" role=\"status\">Showing ${shown} of ${total}</div>\n ${\n done\n ? nothing\n : html`<button type=\"button\" class=\"uvalib-button\" @click=${this.onLoadMore}>\n Load more\n </button>`\n }\n </div>`;\n }\n\n protected override render() {\n if (this.loadMore) return this.renderLoadMore();\n return this.numbered ? this.renderNumbered() : this.renderSections();\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibPager } from './UvalibPager.js';\n\ndefine('uvalib-pager', UvalibPager);\n"],"mappings":";;;;AAQA,IAAMe,oBAAe,IAAI,IAAI;CAAC;CAAS;CAAU;CAAW;AAAM,CAAC,GAE7DC,IAAmB,gBAOnBC,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;;;;;;;IAOLA,EAAK,iBAAiBA,EAAK;;;;;;;;;;;IAW3BA,EAAK;IACLA,EAAK;;;;;;;;IAQLA,EAAK;;;;;;;;IAQLA,EAAK,SAASA,EAAK;;;;;;;;;;IAUnBA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;;;;;;;;;;;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e ?? "").replace(/\s+/g, " ").trim(), l = (e) => `
|
|
|
68
68
|
text-decoration: underline;
|
|
69
69
|
text-underline-offset: 0.15em;
|
|
70
70
|
}
|
|
71
|
+
${e} > a,
|
|
72
|
+
${e} > button {
|
|
73
|
+
position: relative;
|
|
74
|
+
}
|
|
75
|
+
${e} .visually-hidden {
|
|
76
|
+
position: absolute;
|
|
77
|
+
width: 1px;
|
|
78
|
+
height: 1px;
|
|
79
|
+
margin: -1px;
|
|
80
|
+
padding: 0;
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
clip: rect(0, 0, 0, 0);
|
|
83
|
+
white-space: nowrap;
|
|
84
|
+
border: 0;
|
|
85
|
+
}
|
|
86
|
+
${e} .badge,
|
|
87
|
+
${e} [slot='badge'] {
|
|
88
|
+
position: absolute;
|
|
89
|
+
z-index: 1;
|
|
90
|
+
inset-block-start: 0.5rem;
|
|
91
|
+
inset-inline-start: 0.5rem;
|
|
92
|
+
max-width: calc(100% - 1rem);
|
|
93
|
+
margin: 0;
|
|
94
|
+
padding: 0.15rem 0.5rem;
|
|
95
|
+
border-radius: 0.25rem;
|
|
96
|
+
background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));
|
|
97
|
+
color: var(--uva-color-on-accent, #fff);
|
|
98
|
+
font-size: 0.875rem;
|
|
99
|
+
line-height: 1.4;
|
|
100
|
+
overflow-wrap: anywhere;
|
|
101
|
+
pointer-events: none;
|
|
102
|
+
}
|
|
71
103
|
${e} > a:focus-visible, ${e} > button:focus-visible {
|
|
72
104
|
outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));
|
|
73
105
|
outline-offset: 2px;
|
|
@@ -77,6 +109,12 @@ var c = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), l = (e) => `
|
|
|
77
109
|
}
|
|
78
110
|
@media (forced-colors: active) {
|
|
79
111
|
${e} > a:focus-visible, ${e} > button:focus-visible { outline: 3px solid CanvasText; }
|
|
112
|
+
${e} .badge,
|
|
113
|
+
${e} [slot='badge'] {
|
|
114
|
+
background: Canvas;
|
|
115
|
+
color: CanvasText;
|
|
116
|
+
border: 1px solid CanvasText;
|
|
117
|
+
}
|
|
80
118
|
}
|
|
81
119
|
`, f = /^\d+(\.\d+)?(px|rem|em|vh|vw|vmin|vmax|ch|%)?$/, p = class extends o {
|
|
82
120
|
constructor(...e) {
|
|
@@ -104,17 +142,7 @@ var c = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), l = (e) => `
|
|
|
104
142
|
}
|
|
105
143
|
connectedCallback() {
|
|
106
144
|
let e = this.isLight;
|
|
107
|
-
super.connectedCallback(), this.install(e), this.applyRow(), this.layout(), this.
|
|
108
|
-
childList: !0,
|
|
109
|
-
subtree: !0,
|
|
110
|
-
attributes: !0,
|
|
111
|
-
attributeFilter: [
|
|
112
|
-
"width",
|
|
113
|
-
"height",
|
|
114
|
-
"alt",
|
|
115
|
-
"src"
|
|
116
|
-
]
|
|
117
|
-
}), this.addEventListener("load", this.onLoad, !0);
|
|
145
|
+
super.connectedCallback(), this.install(e), this.applyRow(), this.layout(), this.addEventListener("load", this.onLoad, !0);
|
|
118
146
|
}
|
|
119
147
|
disconnectedCallback() {
|
|
120
148
|
super.disconnectedCallback(), this.observer?.disconnect(), this.removeEventListener("load", this.onLoad, !0);
|
|
@@ -143,13 +171,33 @@ var c = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), l = (e) => `
|
|
|
143
171
|
items() {
|
|
144
172
|
return [...this.children].filter((e) => !(e instanceof HTMLElement) || e === this.mount ? !1 : m(e));
|
|
145
173
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
174
|
+
arm() {
|
|
175
|
+
this.observer ??= new MutationObserver(() => this.layout()), this.observer.observe(this, {
|
|
176
|
+
childList: !0,
|
|
177
|
+
subtree: !0,
|
|
178
|
+
attributes: !0,
|
|
179
|
+
attributeFilter: [
|
|
180
|
+
"width",
|
|
181
|
+
"height",
|
|
182
|
+
"alt",
|
|
183
|
+
"src",
|
|
184
|
+
"data-badge",
|
|
185
|
+
"slot"
|
|
186
|
+
]
|
|
151
187
|
});
|
|
152
188
|
}
|
|
189
|
+
layout() {
|
|
190
|
+
this.observer?.disconnect();
|
|
191
|
+
try {
|
|
192
|
+
let e = !1;
|
|
193
|
+
for (let t of this.children) t !== this.mount && t.nodeType === Node.ELEMENT_NODE && (m(t) || (e = !0));
|
|
194
|
+
e && this.warn(), this.items().forEach((e, t) => {
|
|
195
|
+
e.style.setProperty("--ar", this.ratio(e).toFixed(4)), this.ensureBadge(e), this.ensureCaption(e, t), this.orderBadge(e);
|
|
196
|
+
});
|
|
197
|
+
} finally {
|
|
198
|
+
this.isConnected && this.arm();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
153
201
|
warn() {
|
|
154
202
|
this.warned || (this.warned = !0, console.warn(`${this.localName}: an item was skipped because it is not a link or a button. Each photo is an <a href> or a <button>.`));
|
|
155
203
|
}
|
|
@@ -159,16 +207,70 @@ var c = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), l = (e) => `
|
|
|
159
207
|
let n = g(t.getAttribute("width")), r = g(t.getAttribute("height"));
|
|
160
208
|
return n && r ? n / r : t.naturalWidth > 0 && t.naturalHeight > 0 ? t.naturalWidth / t.naturalHeight : 1;
|
|
161
209
|
}
|
|
210
|
+
ensureBadge(e) {
|
|
211
|
+
let t = [...e.children].find((e) => e instanceof HTMLElement && e.getAttribute("slot") === "badge" && !e.hasAttribute("data-uvalib-generated-badge")), n = t ? c(t.textContent) : "", r = [...e.children].find((e) => e instanceof HTMLElement && e.hasAttribute("data-uvalib-generated-badge")), i = "";
|
|
212
|
+
if (t && n) r?.remove(), i = n;
|
|
213
|
+
else {
|
|
214
|
+
let t = c(e.getAttribute("data-badge"));
|
|
215
|
+
t ? (r || (r = this.ownerDocument.createElement("span"), r.className = "badge", r.setAttribute("data-uvalib-generated-badge", ""), e.append(r)), r.textContent !== t && (r.textContent = t), i = t) : r?.remove();
|
|
216
|
+
}
|
|
217
|
+
this.syncBadgeName(e, i);
|
|
218
|
+
}
|
|
219
|
+
syncBadgeName(e, t) {
|
|
220
|
+
let n = "data-uvalib-label", r = e.getAttribute(n), i = e.getAttribute("aria-label");
|
|
221
|
+
if (!t) {
|
|
222
|
+
r !== null && (r ? e.setAttribute("aria-label", r) : e.removeAttribute("aria-label"), e.removeAttribute(n));
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (i === null && r === null) return;
|
|
226
|
+
let a = r ?? i ?? "";
|
|
227
|
+
r === null && e.setAttribute(n, a);
|
|
228
|
+
let o = a ? `${a}, ${t}` : t;
|
|
229
|
+
i !== o && e.setAttribute("aria-label", o);
|
|
230
|
+
}
|
|
162
231
|
ensureCaption(e, t) {
|
|
163
232
|
let n = e.querySelector("img");
|
|
164
233
|
h(n);
|
|
165
234
|
let r = _(e), i = c(e.getAttribute("aria-label")), a = [...e.children].find((e) => e.classList.contains("caption")), o = r || i;
|
|
166
235
|
if (o) {
|
|
167
|
-
a?.remove(), n &&
|
|
236
|
+
a?.remove(), n && this.clearRepeatedAlt(e, n, o);
|
|
168
237
|
return;
|
|
169
238
|
}
|
|
170
239
|
let s = c(n?.getAttribute("data-uvalib-alt")), l = s || `Photo ${t + 1}`, u = a instanceof HTMLElement ? a : null;
|
|
171
|
-
|
|
240
|
+
if (!u) {
|
|
241
|
+
u = this.ownerDocument.createElement("span"), u.className = "caption";
|
|
242
|
+
let t = this.badgeEl(e);
|
|
243
|
+
t ? e.insertBefore(u, t) : e.append(u);
|
|
244
|
+
}
|
|
245
|
+
s ? u.removeAttribute("data-uvalib-generated") : u.setAttribute("data-uvalib-generated", ""), u.textContent !== l && (u.textContent = l), (n && c(n.getAttribute("alt")) === l || n && !n.hasAttribute("alt")) && n.setAttribute("alt", ""), s || this.warnNameless();
|
|
246
|
+
}
|
|
247
|
+
clearRepeatedAlt(e, t, n) {
|
|
248
|
+
let r = c(t.getAttribute("alt")), i = c(e.getAttribute("data-uvalib-label"));
|
|
249
|
+
r && (r === n || r === i) && t.setAttribute("alt", "");
|
|
250
|
+
}
|
|
251
|
+
orderBadge(e) {
|
|
252
|
+
let t = this.badgeEl(e), n = [...e.children].find((e) => e instanceof HTMLElement && e.hasAttribute("data-uvalib-badge-sep"));
|
|
253
|
+
if (!t) {
|
|
254
|
+
n?.remove();
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
let r = [...e.children].find((e) => e.classList.contains("caption"));
|
|
258
|
+
if (t.hasAttribute("data-uvalib-generated-badge") && r instanceof HTMLElement) {
|
|
259
|
+
let i = n && n.nextSibling === t ? n : t;
|
|
260
|
+
r.nextSibling !== i && e.insertBefore(i, r.nextSibling);
|
|
261
|
+
}
|
|
262
|
+
if (!(r instanceof HTMLElement)) {
|
|
263
|
+
n?.remove();
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
let i = n ?? (() => {
|
|
267
|
+
let e = this.ownerDocument.createElement("span");
|
|
268
|
+
return e.className = "visually-hidden", e.setAttribute("data-uvalib-badge-sep", ""), e.textContent = ", ", e;
|
|
269
|
+
})();
|
|
270
|
+
i.nextSibling !== t && t.before(i);
|
|
271
|
+
}
|
|
272
|
+
badgeEl(e) {
|
|
273
|
+
return [...e.children].find((e) => e instanceof HTMLElement && (e.hasAttribute("data-uvalib-generated-badge") || e.getAttribute("slot") === "badge"));
|
|
172
274
|
}
|
|
173
275
|
warnNameless() {
|
|
174
276
|
this.warnedName || (this.warnedName = !0, console.warn(`${this.localName}: a photo has no accessible name. Give its image an alt, or put visible text in the link.`));
|
|
@@ -192,7 +294,7 @@ function g(e) {
|
|
|
192
294
|
}
|
|
193
295
|
function _(e) {
|
|
194
296
|
let t = [], n = (e) => {
|
|
195
|
-
e instanceof HTMLImageElement || e instanceof HTMLElement && e.classList.contains("caption") || e instanceof HTMLElement && (e.hidden || e.getAttribute("aria-hidden") === "true" || e.classList.contains("visually-hidden")) || (e.nodeType === Node.TEXT_NODE ? t.push(e.textContent ?? "") : e.childNodes.forEach(n));
|
|
297
|
+
e instanceof HTMLImageElement || e instanceof HTMLElement && (e.classList.contains("caption") || e.classList.contains("badge") || e.getAttribute("slot") === "badge" || e.hasAttribute("data-uvalib-generated-badge")) || e instanceof HTMLElement && (e.hidden || e.getAttribute("aria-hidden") === "true" || e.classList.contains("visually-hidden")) || (e.nodeType === Node.TEXT_NODE ? t.push(e.textContent ?? "") : e.childNodes.forEach(n));
|
|
196
298
|
};
|
|
197
299
|
return e.childNodes.forEach(n), c(t.join(" "));
|
|
198
300
|
}
|