@uvalib/web-components 1.0.0 → 1.1.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 +82 -0
- package/README.md +724 -33
- package/dist/base/analytics-state.d.ts +36 -0
- package/dist/base/analytics-state.js +44 -0
- package/dist/base/analytics-state.js.map +1 -0
- package/dist/base/analytics.d.ts +31 -27
- package/dist/base/analytics.js +48 -37
- package/dist/base/analytics.js.map +1 -1
- package/dist/base/inline-copy.d.ts +16 -0
- package/dist/base/inline-copy.js +92 -0
- package/dist/base/inline-copy.js.map +1 -0
- package/dist/base/source-children.d.ts +46 -0
- package/dist/base/source-children.js +116 -0
- package/dist/base/source-children.js.map +1 -0
- package/dist/base.css +199 -0
- package/dist/base.d.ts +2 -2
- package/dist/base.js +1 -1
- package/dist/base.js.map +1 -1
- package/dist/components/bento-box/BentoSection.d.ts +1 -1
- package/dist/components/bento-box/BentoSection.js +29 -6
- package/dist/components/bento-box/BentoSection.js.map +1 -1
- package/dist/components/events-section/EventsSection.d.ts +3 -0
- package/dist/components/events-section/EventsSection.js +12 -1
- package/dist/components/events-section/EventsSection.js.map +1 -1
- package/dist/components/library-weekly-hours/LibraryWeeklyHours.d.ts +1 -0
- package/dist/components/library-weekly-hours/LibraryWeeklyHours.js +5 -0
- package/dist/components/library-weekly-hours/LibraryWeeklyHours.js.map +1 -1
- package/dist/components/site-alerts/SiteAlerts.d.ts +109 -0
- package/dist/components/site-alerts/SiteAlerts.js +542 -0
- package/dist/components/site-alerts/SiteAlerts.js.map +1 -0
- package/dist/components/site-alerts/alerts-source.d.ts +36 -0
- package/dist/components/site-alerts/alerts-source.js +115 -0
- package/dist/components/site-alerts/alerts-source.js.map +1 -0
- package/dist/components/{site-page → site-alerts}/alerts.js +8 -3
- package/dist/components/site-alerts/alerts.js.map +1 -0
- package/dist/components/site-alerts/body.d.ts +10 -0
- package/dist/components/site-alerts/body.js +48 -0
- package/dist/components/site-alerts/body.js.map +1 -0
- package/dist/components/site-alerts/dismissed.d.ts +12 -0
- package/dist/components/site-alerts/dismissed.js +72 -0
- package/dist/components/site-alerts/dismissed.js.map +1 -0
- package/dist/components/site-alerts/icons.d.ts +8 -0
- package/dist/components/site-alerts/icons.js +15 -0
- package/dist/components/site-alerts/icons.js.map +1 -0
- package/dist/components/site-alerts/site-alerts.d.ts +1 -0
- package/dist/components/site-alerts/site-alerts.js +4 -0
- package/dist/components/site-alerts/site-alerts.js.map +1 -0
- package/dist/components/site-analytics/SiteAnalytics.d.ts +26 -2
- package/dist/components/site-analytics/SiteAnalytics.js +140 -4
- package/dist/components/site-analytics/SiteAnalytics.js.map +1 -1
- package/dist/components/site-footer/SiteFooter.d.ts +4 -0
- package/dist/components/site-footer/SiteFooter.js +28 -4
- package/dist/components/site-footer/SiteFooter.js.map +1 -1
- package/dist/components/site-header/SiteHeader.d.ts +47 -3
- package/dist/components/site-header/SiteHeader.js +198 -21
- package/dist/components/site-header/SiteHeader.js.map +1 -1
- package/dist/components/site-hours-section/SiteHoursSection.d.ts +4 -1
- package/dist/components/site-hours-section/SiteHoursSection.js +18 -3
- package/dist/components/site-hours-section/SiteHoursSection.js.map +1 -1
- package/dist/components/site-main-nav/SiteMainNav.d.ts +1 -1
- package/dist/components/site-main-nav/SiteMainNav.js +11 -1
- package/dist/components/site-main-nav/SiteMainNav.js.map +1 -1
- package/dist/components/site-page/SitePage.d.ts +43 -15
- package/dist/components/site-page/SitePage.js +161 -34
- package/dist/components/site-page/SitePage.js.map +1 -1
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.d.ts +91 -0
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js +310 -0
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js.map +1 -0
- package/dist/components/uvalib-breadcrumbs/uvalib-breadcrumbs.d.ts +1 -0
- package/dist/components/uvalib-breadcrumbs/uvalib-breadcrumbs.js +4 -0
- package/dist/components/uvalib-breadcrumbs/uvalib-breadcrumbs.js.map +1 -0
- package/dist/components/uvalib-card/UvalibCard.d.ts +113 -0
- package/dist/components/uvalib-card/UvalibCard.js +643 -0
- package/dist/components/uvalib-card/UvalibCard.js.map +1 -0
- package/dist/components/uvalib-card/uvalib-card.d.ts +1 -0
- package/dist/components/uvalib-card/uvalib-card.js +4 -0
- package/dist/components/uvalib-card/uvalib-card.js.map +1 -0
- package/dist/components/uvalib-card-grid/UvalibCardGrid.d.ts +60 -0
- package/dist/components/uvalib-card-grid/UvalibCardGrid.js +305 -0
- package/dist/components/uvalib-card-grid/UvalibCardGrid.js.map +1 -0
- package/dist/components/uvalib-card-grid/uvalib-card-grid.d.ts +1 -0
- package/dist/components/uvalib-card-grid/uvalib-card-grid.js +4 -0
- package/dist/components/uvalib-card-grid/uvalib-card-grid.js.map +1 -0
- package/dist/components/uvalib-contents/UvalibContents.d.ts +134 -0
- package/dist/components/uvalib-contents/UvalibContents.js +613 -0
- package/dist/components/uvalib-contents/UvalibContents.js.map +1 -0
- package/dist/components/uvalib-contents/uvalib-contents.d.ts +1 -0
- package/dist/components/uvalib-contents/uvalib-contents.js +4 -0
- package/dist/components/uvalib-contents/uvalib-contents.js.map +1 -0
- package/dist/components/uvalib-date-range/UvalibDateRange.d.ts +10 -0
- package/dist/components/uvalib-date-range/UvalibDateRange.js +21 -0
- package/dist/components/uvalib-date-range/UvalibDateRange.js.map +1 -1
- package/dist/components/uvalib-filter/UvalibFilter.d.ts +1 -0
- package/dist/components/uvalib-filter/UvalibFilter.js +11 -1
- package/dist/components/uvalib-filter/UvalibFilter.js.map +1 -1
- package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +204 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +1115 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -0
- package/dist/components/uvalib-lightbox/media.d.ts +51 -0
- package/dist/components/uvalib-lightbox/media.js +127 -0
- package/dist/components/uvalib-lightbox/media.js.map +1 -0
- package/dist/components/uvalib-lightbox/uvalib-lightbox.d.ts +1 -0
- package/dist/components/uvalib-lightbox/uvalib-lightbox.js +4 -0
- package/dist/components/uvalib-lightbox/uvalib-lightbox.js.map +1 -0
- package/dist/components/uvalib-metadata/UvalibMetadata.d.ts +124 -0
- package/dist/components/uvalib-metadata/UvalibMetadata.js +443 -0
- package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -0
- package/dist/components/uvalib-metadata/rights.d.ts +8 -0
- package/dist/components/uvalib-metadata/rights.js +47 -0
- package/dist/components/uvalib-metadata/rights.js.map +1 -0
- package/dist/components/uvalib-metadata/uvalib-metadata.d.ts +1 -0
- package/dist/components/uvalib-metadata/uvalib-metadata.js +4 -0
- package/dist/components/uvalib-metadata/uvalib-metadata.js.map +1 -0
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +103 -0
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +410 -0
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -0
- package/dist/components/uvalib-pagefind-search/uvalib-pagefind-search.d.ts +1 -0
- package/dist/components/uvalib-pagefind-search/uvalib-pagefind-search.js +7 -0
- package/dist/components/uvalib-pagefind-search/uvalib-pagefind-search.js.map +1 -0
- package/dist/components/uvalib-pager/UvalibPager.d.ts +94 -0
- package/dist/components/uvalib-pager/UvalibPager.js +390 -0
- package/dist/components/uvalib-pager/UvalibPager.js.map +1 -0
- package/dist/components/uvalib-pager/uvalib-pager.d.ts +1 -0
- package/dist/components/uvalib-pager/uvalib-pager.js +4 -0
- package/dist/components/uvalib-pager/uvalib-pager.js.map +1 -0
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +59 -0
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +350 -0
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -0
- package/dist/components/uvalib-photo-grid/uvalib-photo-grid.d.ts +1 -0
- package/dist/components/uvalib-photo-grid/uvalib-photo-grid.js +4 -0
- package/dist/components/uvalib-photo-grid/uvalib-photo-grid.js.map +1 -0
- package/dist/custom-elements.json +12291 -4424
- package/dist/index.d.ts +16 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/pagefind.css +388 -0
- package/dist/styles/base.js +11 -0
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +24 -11
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.d.ts +2 -0
- package/dist/styles/controls.js +200 -0
- package/dist/styles/controls.js.map +1 -0
- package/dist/styles/pagefind.d.ts +1 -0
- package/dist/styles/pagefind.js +395 -0
- package/dist/styles/pagefind.js.map +1 -0
- package/dist/tokens.css +23 -20
- package/dist-cdn/base.css +199 -0
- package/dist-cdn/bento-box.js +117 -97
- package/dist-cdn/bento-box.js.map +1 -1
- package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js +243 -0
- package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js.map +1 -0
- package/dist-cdn/chunks/alerts-C5vkeb-f.js +39 -0
- package/dist-cdn/chunks/alerts-C5vkeb-f.js.map +1 -0
- package/dist-cdn/chunks/analytics-DTTihuBD.js +43 -0
- package/dist-cdn/chunks/analytics-DTTihuBD.js.map +1 -0
- package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js +39 -0
- package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js.map +1 -0
- package/dist-cdn/chunks/{base-DCGd2Oii.js → base-CAFQWnZG.js} +12 -1
- package/dist-cdn/chunks/{base-DCGd2Oii.js.map → base-CAFQWnZG.js.map} +1 -1
- package/dist-cdn/chunks/{library-weekly-hours-ByQ8ugxh.js → library-weekly-hours-COE7Vv6V.js} +47 -38
- package/dist-cdn/chunks/library-weekly-hours-COE7Vv6V.js.map +1 -0
- package/dist-cdn/chunks/{site-header-BwDkZ2LL.js → site-header-C9V7Wuw2.js} +169 -49
- package/dist-cdn/chunks/site-header-C9V7Wuw2.js.map +1 -0
- package/dist-cdn/chunks/{site-main-nav-BLAAunnr.js → site-main-nav-AaxZ9rQf.js} +11 -2
- package/dist-cdn/chunks/site-main-nav-AaxZ9rQf.js.map +1 -0
- package/dist-cdn/chunks/source-children-RuAec527.js +119 -0
- package/dist-cdn/chunks/source-children-RuAec527.js.map +1 -0
- package/dist-cdn/custom-elements.json +12291 -4424
- package/dist-cdn/events-section.js +78 -66
- 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 +13 -2
- package/dist-cdn/pagefind.css +388 -0
- package/dist-cdn/site-alerts.js +516 -0
- package/dist-cdn/site-alerts.js.map +1 -0
- package/dist-cdn/site-analytics.js +1 -1
- package/dist-cdn/site-footer.js +33 -18
- package/dist-cdn/site-footer.js.map +1 -1
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-hours-section.js +33 -21
- package/dist-cdn/site-hours-section.js.map +1 -1
- package/dist-cdn/site-main-nav.js +1 -1
- package/dist-cdn/site-page.js +116 -81
- package/dist-cdn/site-page.js.map +1 -1
- package/dist-cdn/site-style.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +367 -11
- package/dist-cdn/skills/uvalib-web-components/reference/accessibility-testing.md +170 -0
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +414 -12
- package/dist-cdn/skills/uvalib-web-components/reference/migration.md +37 -0
- package/dist-cdn/tokens.css +23 -20
- package/dist-cdn/uvalib-analytics.js +1 -1
- package/dist-cdn/uvalib-breadcrumbs.js +176 -0
- package/dist-cdn/uvalib-breadcrumbs.js.map +1 -0
- package/dist-cdn/uvalib-card-grid.js +163 -0
- package/dist-cdn/uvalib-card-grid.js.map +1 -0
- package/dist-cdn/uvalib-card.js +424 -0
- package/dist-cdn/uvalib-card.js.map +1 -0
- package/dist-cdn/uvalib-contents.js +381 -0
- package/dist-cdn/uvalib-contents.js.map +1 -0
- package/dist-cdn/uvalib-date-range.js +33 -18
- package/dist-cdn/uvalib-date-range.js.map +1 -1
- package/dist-cdn/uvalib-filter.js +32 -11
- package/dist-cdn/uvalib-filter.js.map +1 -1
- package/dist-cdn/uvalib-lightbox.js +662 -0
- package/dist-cdn/uvalib-lightbox.js.map +1 -0
- package/dist-cdn/uvalib-metadata.js +313 -0
- package/dist-cdn/uvalib-metadata.js.map +1 -0
- package/dist-cdn/uvalib-pagefind-search.js +207 -0
- package/dist-cdn/uvalib-pagefind-search.js.map +1 -0
- package/dist-cdn/uvalib-pager.js +278 -0
- package/dist-cdn/uvalib-pager.js.map +1 -0
- package/dist-cdn/uvalib-photo-grid.js +202 -0
- package/dist-cdn/uvalib-photo-grid.js.map +1 -0
- package/package.json +43 -1
- package/skills/uvalib-web-components/SKILL.md +367 -11
- package/skills/uvalib-web-components/reference/accessibility-testing.md +170 -0
- package/skills/uvalib-web-components/reference/components.md +414 -12
- package/skills/uvalib-web-components/reference/migration.md +37 -0
- package/dist/components/site-page/alerts.js.map +0 -1
- package/dist-cdn/chunks/SiteAnalytics-T1Wx3lsb.js +0 -174
- package/dist-cdn/chunks/SiteAnalytics-T1Wx3lsb.js.map +0 -1
- package/dist-cdn/chunks/analytics-C8D8n_wt.js +0 -55
- package/dist-cdn/chunks/analytics-C8D8n_wt.js.map +0 -1
- package/dist-cdn/chunks/library-weekly-hours-ByQ8ugxh.js.map +0 -1
- package/dist-cdn/chunks/site-header-BwDkZ2LL.js.map +0 -1
- package/dist-cdn/chunks/site-main-nav-BLAAunnr.js.map +0 -1
- /package/dist/components/{site-page → site-alerts}/alerts.d.ts +0 -0
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
import { a as e, f as t, i as n, l as r, m as i, n as a, o, p as s, r as c, t as l } from "./chunks/UvalibElement-BnI-eRRR.js";
|
|
2
|
+
import { a as u } from "./chunks/analytics-DTTihuBD.js";
|
|
3
|
+
import { t as d } from "./chunks/accessible-GqhVn5_H.js";
|
|
4
|
+
// src/components/uvalib-lightbox/media.ts
|
|
5
|
+
var f = /^(full|square|max|pct:[^/]+|\d+,\d+,\d+,\d+)$/i, p = /^!?\d+(\.\d+)?$/, m = /^(default|color|gray|grey|bitonal|native)\.(jpe?g|png|gif|webp|tiff?|jp2)$/i, h = /\.(jpe?g|png|gif|webp)$/i, g = /^image\/(png|jpeg|gif|webp)($|[;,])/i;
|
|
6
|
+
function _(e, t) {
|
|
7
|
+
let n;
|
|
8
|
+
try {
|
|
9
|
+
n = new URL(e, t);
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (n.protocol !== "http:" && n.protocol !== "https:") return null;
|
|
14
|
+
let r = n.pathname.split("/");
|
|
15
|
+
if (r.length < 5) return null;
|
|
16
|
+
let i = r[r.length - 1] ?? "", a = r[r.length - 2] ?? "", o = r[r.length - 4] ?? "";
|
|
17
|
+
return !m.test(i) || !p.test(a) || !f.test(o) ? null : {
|
|
18
|
+
url: n,
|
|
19
|
+
parts: r,
|
|
20
|
+
regionIndex: r.length - 4,
|
|
21
|
+
sizeIndex: r.length - 3
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function v(e, t, n, r) {
|
|
25
|
+
let i = _(e, t);
|
|
26
|
+
if (!i) return null;
|
|
27
|
+
let a = i.parts[i.parts.length - 1] ?? "";
|
|
28
|
+
if (!h.test(a)) return null;
|
|
29
|
+
let o = Math.max(1, Math.round(n)), s = Math.max(1, Math.round(r));
|
|
30
|
+
return i.parts[i.sizeIndex] = `!${o},${s}`, i.url.pathname = i.parts.join("/"), i.url.toString();
|
|
31
|
+
}
|
|
32
|
+
function y(e, t) {
|
|
33
|
+
let n = _(e, t);
|
|
34
|
+
return n && n.parts[n.regionIndex - 1] || null;
|
|
35
|
+
}
|
|
36
|
+
function b(e) {
|
|
37
|
+
let t = Math.min(e.devicePixelRatio || 1, 2);
|
|
38
|
+
return {
|
|
39
|
+
w: Math.max(1, Math.min(2e3, Math.round((e.innerWidth || 800) * t))),
|
|
40
|
+
h: Math.max(1, Math.min(2e3, Math.round((e.innerHeight || 600) * t)))
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function x(e, t) {
|
|
44
|
+
try {
|
|
45
|
+
let n = new URL(e, t);
|
|
46
|
+
return n.protocol === "http:" || n.protocol === "https:" || n.protocol === "data:" && g.test(n.pathname);
|
|
47
|
+
} catch {
|
|
48
|
+
return !1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function S(e) {
|
|
52
|
+
return e.startsWith("#/") || e.startsWith("#!/") || e.includes("?");
|
|
53
|
+
}
|
|
54
|
+
function C(e, t) {
|
|
55
|
+
if (!t) return null;
|
|
56
|
+
if (S(e.hash)) {
|
|
57
|
+
let n = e.hash.indexOf("?");
|
|
58
|
+
return new URLSearchParams(n >= 0 ? e.hash.slice(n + 1) : "").get(t);
|
|
59
|
+
}
|
|
60
|
+
return new URLSearchParams(e.search).get(t);
|
|
61
|
+
}
|
|
62
|
+
function w(e, t, n, r) {
|
|
63
|
+
if (r ?? S(e.hash)) {
|
|
64
|
+
let r = e.hash.indexOf("?"), i = r >= 0 ? e.hash.slice(0, r) : e.hash, a = new URLSearchParams(r >= 0 ? e.hash.slice(r + 1) : "");
|
|
65
|
+
n ? a.set(t, n) : a.delete(t);
|
|
66
|
+
let o = a.toString();
|
|
67
|
+
return e.pathname + e.search + (o ? `${i}?${o}` : i);
|
|
68
|
+
}
|
|
69
|
+
let i = new URLSearchParams(e.search);
|
|
70
|
+
n ? i.set(t, n) : i.delete(t);
|
|
71
|
+
let a = i.toString();
|
|
72
|
+
return e.pathname + (a ? `?${a}` : "") + e.hash;
|
|
73
|
+
}
|
|
74
|
+
// src/components/uvalib-lightbox/UvalibLightbox.ts
|
|
75
|
+
var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
|
|
76
|
+
${e} { display: block; }
|
|
77
|
+
${e} .viewer { display: contents; }
|
|
78
|
+
${e} dialog {
|
|
79
|
+
margin: auto;
|
|
80
|
+
padding: 0;
|
|
81
|
+
border: none;
|
|
82
|
+
background: transparent;
|
|
83
|
+
width: min(72rem, calc(100% - 2rem));
|
|
84
|
+
max-height: calc(100% - 2rem);
|
|
85
|
+
}
|
|
86
|
+
${e} .panel {
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
gap: 0.75rem;
|
|
91
|
+
max-height: calc(100dvh - 2rem);
|
|
92
|
+
overflow: auto;
|
|
93
|
+
overscroll-behavior: contain;
|
|
94
|
+
padding: 0.75rem;
|
|
95
|
+
}
|
|
96
|
+
${e} .head, ${e} .toolbar {
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-wrap: wrap;
|
|
99
|
+
align-items: center;
|
|
100
|
+
gap: 0.5rem;
|
|
101
|
+
}
|
|
102
|
+
${e} .head { justify-content: space-between; }
|
|
103
|
+
${e} .caption { margin: 0; min-width: 0; overflow-wrap: anywhere; }
|
|
104
|
+
${e} .figure { margin: 0; }
|
|
105
|
+
${e} dialog img { display: block; max-width: 100%; max-height: 70dvh; width: auto; height: auto; margin: auto; }
|
|
106
|
+
${e} .count, ${e} .status { margin: 0; }
|
|
107
|
+
${e} dialog button, ${e} dialog .full {
|
|
108
|
+
box-sizing: border-box;
|
|
109
|
+
min-width: 44px;
|
|
110
|
+
min-height: 44px;
|
|
111
|
+
padding: 0.5rem 0.75rem;
|
|
112
|
+
font: inherit;
|
|
113
|
+
}
|
|
114
|
+
${e} .details:empty { display: none; }
|
|
115
|
+
${e} > [slot="details"] { display: none; }
|
|
116
|
+
${e}[hidden], ${e} [hidden] { display: none !important; }
|
|
117
|
+
`, D = s(E(":host")), O = 0, k = class extends l {
|
|
118
|
+
constructor(...e) {
|
|
119
|
+
super(...e), this.selector = "", this.urlParam = "", this.slides = [], this.index = 0, this.open = !1, this.status = "loading", this.fitW = 0, this.fitH = 0, this.captionId = `uvalib-lightbox-caption-${++O}`, this.trigger = null, this.historyPushed = !1, this.userClosed = !1, this.suppressClose = !1, this.warnedSelector = !1, this.lastSrc = "", this.syncQueued = !1, this.resizeTimer = 0, this.ignoreClose = !1, this.dismissing = !1, this.revealTries = 0, this.revealFrame = 0, this.listened = !1, this.pendingBack = !1, this.backInHash = !1, this.queuedOpen = null, this.reopenGuard = !1, this.parked = [], this.parkedKey = "", this.onResize = () => {
|
|
120
|
+
this.open && (window.clearTimeout(this.resizeTimer), this.resizeTimer = window.setTimeout(() => {
|
|
121
|
+
this.isConnected && this.open && this.measure();
|
|
122
|
+
}, 150));
|
|
123
|
+
}, this.onClick = (e) => {
|
|
124
|
+
if (!(e instanceof MouseEvent) || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
|
125
|
+
let t = this.linkFrom(e);
|
|
126
|
+
if (!t) return;
|
|
127
|
+
let n = this.collect(), r = n.findIndex((e) => e.el === t);
|
|
128
|
+
r < 0 || (e.preventDefault(), this.activate(r, n));
|
|
129
|
+
}, this.onPop = () => {
|
|
130
|
+
if (!this.urlParam) return;
|
|
131
|
+
if (this.pendingBack) {
|
|
132
|
+
this.pendingBack = !1;
|
|
133
|
+
let e = this.queuedOpen;
|
|
134
|
+
if (this.queuedOpen = null, !this.isConnected || !e) return;
|
|
135
|
+
this.slides = e.slides, this.index = e.i, this.trigger = e.slides[e.i]?.el ?? null, this.userClosed = !1, this.measure();
|
|
136
|
+
let t = e.slides[e.i]?.id ?? null;
|
|
137
|
+
this.historyPushed = this.writeParam(t, "push", this.backInHash), this.open ||= !0;
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
let e = C(this.loc(), this.urlParam);
|
|
141
|
+
if (!e) {
|
|
142
|
+
this.historyPushed = !1, this.open && this.dismiss("pop");
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.userClosed = !1;
|
|
146
|
+
let t = this.collect(), n = t.findIndex((t) => t.id === e);
|
|
147
|
+
n < 0 ? this.open && this.dismiss("pop") : (this.slides = t, this.index = n, this.trigger = t[n]?.el ?? null, this.historyPushed = !0, this.measure(), this.armReopenGuard(), this.open ||= !0);
|
|
148
|
+
}, this.onKey = (e) => {
|
|
149
|
+
if (!this.multiple || this.typing(e)) return;
|
|
150
|
+
let t = getComputedStyle(this).direction === "rtl", n = t ? "ArrowRight" : "ArrowLeft", r = t ? "ArrowLeft" : "ArrowRight";
|
|
151
|
+
e.key !== n && e.key !== r || e.altKey || e.metaKey || e.ctrlKey || (e.preventDefault(), this.step(e.key === r ? 1 : -1));
|
|
152
|
+
}, this.onDialogClick = (e) => {
|
|
153
|
+
e.target === this.dialogEl && this.dismiss("ui");
|
|
154
|
+
}, this.onDialogClose = () => {
|
|
155
|
+
this.onNativeClose();
|
|
156
|
+
}, this.onFullSize = () => {
|
|
157
|
+
let e = this.index;
|
|
158
|
+
u(this, [
|
|
159
|
+
"uvalib-lightbox",
|
|
160
|
+
"full-size",
|
|
161
|
+
`image ${e + 1}`,
|
|
162
|
+
e + 1
|
|
163
|
+
]);
|
|
164
|
+
}, this.onLoad = () => {
|
|
165
|
+
this.status === "loading" && (this.status = "ready");
|
|
166
|
+
}, this.onError = () => {
|
|
167
|
+
this.status = "error";
|
|
168
|
+
}, this.detailTokens = /* @__PURE__ */ new WeakMap(), this.detailTokenSeq = 0;
|
|
169
|
+
}
|
|
170
|
+
static {
|
|
171
|
+
this.styles = [
|
|
172
|
+
d,
|
|
173
|
+
D,
|
|
174
|
+
t`
|
|
175
|
+
.panel {
|
|
176
|
+
background: var(--uva-color-surface-raised, var(--uva-color-surface, #fff));
|
|
177
|
+
color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));
|
|
178
|
+
border: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));
|
|
179
|
+
}
|
|
180
|
+
dialog::backdrop {
|
|
181
|
+
background: var(--uva-color-shadow, rgba(16, 23, 43, 0.72));
|
|
182
|
+
}
|
|
183
|
+
.details a {
|
|
184
|
+
color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));
|
|
185
|
+
}
|
|
186
|
+
.figure {
|
|
187
|
+
background: var(--uva-color-surface, #fff);
|
|
188
|
+
}
|
|
189
|
+
.caption {
|
|
190
|
+
font-size: 1.125rem;
|
|
191
|
+
line-height: 1.4;
|
|
192
|
+
font-weight: 600;
|
|
193
|
+
}
|
|
194
|
+
.count {
|
|
195
|
+
font-variant-numeric: tabular-nums;
|
|
196
|
+
}
|
|
197
|
+
dialog button,
|
|
198
|
+
dialog .full {
|
|
199
|
+
padding: 0.5rem 0.75rem;
|
|
200
|
+
border: 2px solid transparent;
|
|
201
|
+
text-decoration: none;
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
color: var(--uva-color-on-accent, #fff);
|
|
204
|
+
background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));
|
|
205
|
+
}
|
|
206
|
+
dialog button:focus-visible,
|
|
207
|
+
dialog .full:focus-visible {
|
|
208
|
+
outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));
|
|
209
|
+
outline-offset: 2px;
|
|
210
|
+
}
|
|
211
|
+
dialog button.prev,
|
|
212
|
+
dialog button.next {
|
|
213
|
+
color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));
|
|
214
|
+
background: var(--uva-color-surface, #fff);
|
|
215
|
+
border-color: var(--uva-color-border, var(--uva-grey-100, #dadada));
|
|
216
|
+
}
|
|
217
|
+
.status {
|
|
218
|
+
font-size: 1rem;
|
|
219
|
+
}
|
|
220
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
221
|
+
.panel {
|
|
222
|
+
animation: uvalib-lightbox-in 0.15s ease;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
@media (prefers-reduced-motion: reduce) {
|
|
226
|
+
dialog,
|
|
227
|
+
dialog * {
|
|
228
|
+
animation: none !important;
|
|
229
|
+
transition: none !important;
|
|
230
|
+
scroll-behavior: auto !important;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
@media (forced-colors: active) {
|
|
234
|
+
.panel,
|
|
235
|
+
dialog button,
|
|
236
|
+
dialog .full {
|
|
237
|
+
border: 1px solid CanvasText;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
@keyframes uvalib-lightbox-in {
|
|
241
|
+
from {
|
|
242
|
+
opacity: 0;
|
|
243
|
+
}
|
|
244
|
+
to {
|
|
245
|
+
opacity: 1;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
`
|
|
249
|
+
];
|
|
250
|
+
}
|
|
251
|
+
get isLight() {
|
|
252
|
+
return this.noShadowDom || this.hasAttribute("no-shadow-dom");
|
|
253
|
+
}
|
|
254
|
+
createRenderRoot() {
|
|
255
|
+
if (!this.isLight) {
|
|
256
|
+
let e = super.createRenderRoot();
|
|
257
|
+
return this.noStyle && e instanceof ShadowRoot && (e.adoptedStyleSheets = [d.styleSheet, D.styleSheet].filter((e) => e != null)), e;
|
|
258
|
+
}
|
|
259
|
+
let e = this.ownerDocument.createElement("div");
|
|
260
|
+
return e.className = "viewer", this.mount = e, this.append(e), e;
|
|
261
|
+
}
|
|
262
|
+
connectedCallback() {
|
|
263
|
+
let e = this.isLight;
|
|
264
|
+
super.connectedCallback(), this.suppressClose = !1, e && this.installLight(e), this.listen(), this.slides = this.collect(), this.watch(), this.openFromUrl();
|
|
265
|
+
}
|
|
266
|
+
disconnectedCallback() {
|
|
267
|
+
super.disconnectedCallback(), this.unlisten(), this.observer?.disconnect(), this.dialogObserver?.disconnect(), this.dialogObserver = void 0, this.observedDialog = void 0, window.clearTimeout(this.resizeTimer), this.cancelReveal(), this.restoreDetails(), this.pendingBack = !1, this.queuedOpen = null, this.reopenGuard = !1, this.suppressClose = !0, this.open = !1;
|
|
268
|
+
let e = this.dialogEl;
|
|
269
|
+
e?.open && e.close(), this.suppressClose = !1, this.ignoreClose = !1;
|
|
270
|
+
}
|
|
271
|
+
willUpdate() {
|
|
272
|
+
if (!this.open) {
|
|
273
|
+
this.lastSrc = "";
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
let e = this.displaySrc;
|
|
277
|
+
e === this.lastSrc ? !e && this.status !== "error" && (this.status = "error") : (this.lastSrc = e, this.status = e ? "loading" : "error");
|
|
278
|
+
}
|
|
279
|
+
updated(e) {
|
|
280
|
+
super.updated(e), e.has("selector") && this.watch(), this.open ? ((e.has("open") || e.has("index") || e.has("slides")) && this.placeDetails(), this.bindDialogObserver(), e.has("open") && this.reveal(), queueMicrotask(() => {
|
|
281
|
+
this.isConnected && this.settleImage();
|
|
282
|
+
})) : e.has("open") && this.restoreDetails();
|
|
283
|
+
}
|
|
284
|
+
installLight(e) {
|
|
285
|
+
if (!e) return;
|
|
286
|
+
let t = this.getRootNode(), n = t instanceof Document || t instanceof ShadowRoot ? t : void 0;
|
|
287
|
+
this.noStyle ? (c(`${this.localName}::structure`, s(E(this.localName)), {
|
|
288
|
+
root: n,
|
|
289
|
+
scope: !1
|
|
290
|
+
}), c(`${this.localName}::a11y`, d, { root: n })) : c(this.localName, this.constructor.elementStyles, { root: n });
|
|
291
|
+
}
|
|
292
|
+
get scope() {
|
|
293
|
+
let e = this.getRootNode();
|
|
294
|
+
return e instanceof Document || e instanceof ShadowRoot ? e : this.ownerDocument;
|
|
295
|
+
}
|
|
296
|
+
get base() {
|
|
297
|
+
return this.ownerDocument.baseURI || location.href;
|
|
298
|
+
}
|
|
299
|
+
loc() {
|
|
300
|
+
return {
|
|
301
|
+
pathname: location.pathname,
|
|
302
|
+
search: location.search,
|
|
303
|
+
hash: location.hash
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
listen() {
|
|
307
|
+
this.listened || (this.listened = !0, this.listenRoot = this.scope, this.listenRoot.addEventListener("click", this.onClick, !0), window.addEventListener("popstate", this.onPop), window.addEventListener("resize", this.onResize));
|
|
308
|
+
}
|
|
309
|
+
unlisten() {
|
|
310
|
+
this.listened && (this.listened = !1, this.listenRoot?.removeEventListener("click", this.onClick, !0), this.listenRoot = void 0, window.removeEventListener("popstate", this.onPop), window.removeEventListener("resize", this.onResize));
|
|
311
|
+
}
|
|
312
|
+
watch() {
|
|
313
|
+
this.observer?.disconnect(), this.observer = new MutationObserver(() => this.scheduleSync()), this.observer.observe(this, {
|
|
314
|
+
attributes: !0,
|
|
315
|
+
attributeFilter: [
|
|
316
|
+
"href",
|
|
317
|
+
"id",
|
|
318
|
+
"alt",
|
|
319
|
+
"title",
|
|
320
|
+
"data-caption",
|
|
321
|
+
"data-id",
|
|
322
|
+
"data-details-id",
|
|
323
|
+
"slot"
|
|
324
|
+
],
|
|
325
|
+
childList: !0,
|
|
326
|
+
subtree: !0
|
|
327
|
+
}), this.selector && this.observer.observe(this.scope, {
|
|
328
|
+
childList: !0,
|
|
329
|
+
subtree: !0
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
scheduleSync() {
|
|
333
|
+
this.syncQueued || (this.syncQueued = !0, queueMicrotask(() => {
|
|
334
|
+
if (this.syncQueued = !1, !this.isConnected) return;
|
|
335
|
+
let e = this.collect();
|
|
336
|
+
if (!(e.length === this.slides.length && e.every((e, t) => e.el === this.slides[t]?.el && e.href === this.slides[t]?.href && e.id === this.slides[t]?.id && e.caption === this.slides[t]?.caption && e.detailsId === this.slides[t]?.detailsId))) {
|
|
337
|
+
let t = this.current?.el;
|
|
338
|
+
if (this.slides = e, this.open) {
|
|
339
|
+
let n = t ? e.findIndex((e) => e.el === t) : -1;
|
|
340
|
+
n >= 0 ? this.index = n : e.length ? this.index = Math.min(this.index, e.length - 1) : this.dismiss("empty");
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
this.open || this.openFromUrl();
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
collect() {
|
|
347
|
+
let e = [], t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
348
|
+
if (!(e instanceof HTMLAnchorElement)) return;
|
|
349
|
+
let n = e.getAttribute("data-details-id");
|
|
350
|
+
if (!n) return;
|
|
351
|
+
let r = this.scope.getElementById(n);
|
|
352
|
+
r && t.add(r);
|
|
353
|
+
}, r = [...this.querySelectorAll("a[href]")];
|
|
354
|
+
if (this.selector) try {
|
|
355
|
+
r.push(...this.scope.querySelectorAll(this.selector));
|
|
356
|
+
} catch {
|
|
357
|
+
this.warnedSelector || (this.warnedSelector = !0, console.warn(`${this.localName}: selector ${JSON.stringify(this.selector)} is not a valid CSS selector.`));
|
|
358
|
+
}
|
|
359
|
+
for (let e of r) n(e);
|
|
360
|
+
let i = (n) => {
|
|
361
|
+
if (!(n instanceof HTMLAnchorElement) || !n.hasAttribute("href") || n.closest("[hidden]") || this.mount?.contains(n) || n.closest("dialog") || n.closest("[slot=\"details\"]")) return;
|
|
362
|
+
for (let e of t) if (e.contains(n)) return;
|
|
363
|
+
let r = n.closest("uvalib-lightbox");
|
|
364
|
+
r && r !== this || e.push(n);
|
|
365
|
+
};
|
|
366
|
+
for (let e of r) i(e);
|
|
367
|
+
let a = [...new Set(e)];
|
|
368
|
+
return a.sort((e, t) => {
|
|
369
|
+
if (e === t) return 0;
|
|
370
|
+
let n = e.compareDocumentPosition(t);
|
|
371
|
+
return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
|
|
372
|
+
}), a.map((e, t) => this.slide(e, t));
|
|
373
|
+
}
|
|
374
|
+
slide(e, t) {
|
|
375
|
+
let n = e.getAttribute("href") ?? "", r = e.querySelector("img"), i = T(r?.getAttribute("data-uvalib-alt") || r?.getAttribute("alt")), a = this.linkText(e), o = T(e.dataset.caption) || i || a || T(e.getAttribute("title")) || "Image";
|
|
376
|
+
return {
|
|
377
|
+
el: e,
|
|
378
|
+
id: T(e.dataset.id) || e.id || y(n, this.base) || String(t + 1),
|
|
379
|
+
href: n,
|
|
380
|
+
caption: o,
|
|
381
|
+
alt: i || o,
|
|
382
|
+
detailsId: T(e.dataset.detailsId) || null
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
linkText(e) {
|
|
386
|
+
let t = [], n = (e) => {
|
|
387
|
+
e instanceof HTMLImageElement || e instanceof HTMLElement && (e.hidden || e.getAttribute("slot") === "details") || (e.nodeType === Node.TEXT_NODE ? t.push(e.textContent ?? "") : e.childNodes.forEach(n));
|
|
388
|
+
};
|
|
389
|
+
return e.childNodes.forEach(n), T(t.join(" "));
|
|
390
|
+
}
|
|
391
|
+
get current() {
|
|
392
|
+
return this.slides[this.index];
|
|
393
|
+
}
|
|
394
|
+
get multiple() {
|
|
395
|
+
return this.slides.length > 1;
|
|
396
|
+
}
|
|
397
|
+
get displaySrc() {
|
|
398
|
+
let e = this.current?.href ?? "";
|
|
399
|
+
if (!x(e, this.base)) return "";
|
|
400
|
+
let t = this.fitW || b(window).w, n = this.fitH || b(window).h;
|
|
401
|
+
return v(e, this.base, t, n) ?? e;
|
|
402
|
+
}
|
|
403
|
+
measure() {
|
|
404
|
+
let { w: e, h: t } = b(window);
|
|
405
|
+
e !== this.fitW && (this.fitW = e), t !== this.fitH && (this.fitH = t);
|
|
406
|
+
}
|
|
407
|
+
linkFrom(e) {
|
|
408
|
+
for (let t of e.composedPath()) if (t instanceof HTMLAnchorElement) return t;
|
|
409
|
+
let t = e.target;
|
|
410
|
+
return t instanceof Element ? t.closest("a[href]") : null;
|
|
411
|
+
}
|
|
412
|
+
activate(e, t) {
|
|
413
|
+
let n = this.open;
|
|
414
|
+
if (!(n && this.index === e)) {
|
|
415
|
+
if (this.slides = t, this.index = e, this.trigger = t[e]?.el ?? null, this.userClosed = !1, this.measure(), this.open = !0, this.pendingBack) this.queuedOpen = {
|
|
416
|
+
i: e,
|
|
417
|
+
slides: t
|
|
418
|
+
};
|
|
419
|
+
else if (this.urlParam) {
|
|
420
|
+
let r = t[e]?.id ?? null, i = S(location.hash);
|
|
421
|
+
n ? this.writeParam(r, "replace", i) : (C(this.loc(), this.urlParam) && this.writeParam(null, "replace", i), this.historyPushed = this.writeParam(r, "push", i));
|
|
422
|
+
}
|
|
423
|
+
u(this, [
|
|
424
|
+
"uvalib-lightbox",
|
|
425
|
+
"open",
|
|
426
|
+
`image ${e + 1}`,
|
|
427
|
+
e + 1
|
|
428
|
+
]);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
openFromUrl() {
|
|
432
|
+
if (this.open || this.userClosed || !this.urlParam) return;
|
|
433
|
+
let e = C(this.loc(), this.urlParam);
|
|
434
|
+
if (!e) return;
|
|
435
|
+
let t = this.slides.length ? this.slides : this.collect(), n = t.findIndex((t) => t.id === e);
|
|
436
|
+
if (n < 0) return;
|
|
437
|
+
this.slides = t, this.index = n, this.trigger = t[n]?.el ?? null, this.measure();
|
|
438
|
+
let r = S(location.hash);
|
|
439
|
+
this.writeParam(null, "replace", r), this.historyPushed = this.writeParam(e, "push", r), this.open = !0;
|
|
440
|
+
}
|
|
441
|
+
step(e) {
|
|
442
|
+
let t = this.slides.length;
|
|
443
|
+
if (t < 2) return;
|
|
444
|
+
let n = (this.index + e + t) % t;
|
|
445
|
+
this.index = n, this.trigger = this.slides[n]?.el ?? this.trigger, this.urlParam && this.writeParam(this.slides[n]?.id ?? null, "replace");
|
|
446
|
+
let r = e < 0 ? "previous" : "next";
|
|
447
|
+
u(this, [
|
|
448
|
+
"uvalib-lightbox",
|
|
449
|
+
r,
|
|
450
|
+
`image ${n + 1}`,
|
|
451
|
+
n + 1
|
|
452
|
+
]);
|
|
453
|
+
}
|
|
454
|
+
dismiss(e) {
|
|
455
|
+
if (this.dismissing) return;
|
|
456
|
+
let t = this.dialogEl;
|
|
457
|
+
if (this.open || t?.open) {
|
|
458
|
+
this.dismissing = !0;
|
|
459
|
+
try {
|
|
460
|
+
let n = this.historyPushed;
|
|
461
|
+
this.historyPushed = !1, this.ignoreClose = !0, this.cancelReveal(), this.open = !1, (e === "ui" || e === "empty") && (this.userClosed = !0), this.restoreDetails(), t?.open && t.close(), this.focusTrigger(), e === "ui" && this.urlParam ? n ? (this.backInHash = S(location.hash), this.pendingBack = !0, history.back()) : this.writeParam(null, "replace", S(location.hash)) : e === "empty" && this.urlParam && (this.pendingBack = !1, this.queuedOpen = null, this.writeParam(null, "replace", S(location.hash)));
|
|
462
|
+
} finally {
|
|
463
|
+
this.dismissing = !1;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
writeParam(e, t, n) {
|
|
468
|
+
if (!this.urlParam) return !1;
|
|
469
|
+
let r = w(this.loc(), this.urlParam, e, n);
|
|
470
|
+
if (r === location.pathname + location.search + location.hash) return !1;
|
|
471
|
+
let i = history.state && typeof history.state == "object" ? history.state : {};
|
|
472
|
+
try {
|
|
473
|
+
return history[t === "push" ? "pushState" : "replaceState"]({
|
|
474
|
+
...i,
|
|
475
|
+
uvalibLightbox: this.urlParam
|
|
476
|
+
}, "", r), !0;
|
|
477
|
+
} catch {
|
|
478
|
+
return !1;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
armReopenGuard() {
|
|
482
|
+
this.reopenGuard = !0;
|
|
483
|
+
let e = this.ownerDocument.defaultView;
|
|
484
|
+
e && e.requestAnimationFrame(() => {
|
|
485
|
+
this.reopenGuard = !1;
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
typing(e) {
|
|
489
|
+
let t = e.target;
|
|
490
|
+
return t instanceof HTMLElement ? t.isContentEditable || !!t.closest("input, textarea, select") : !1;
|
|
491
|
+
}
|
|
492
|
+
bindDialogObserver() {
|
|
493
|
+
let e = this.dialogEl;
|
|
494
|
+
if (!e || e === this.observedDialog) return;
|
|
495
|
+
this.dialogObserver?.disconnect(), this.observedDialog = e;
|
|
496
|
+
let t = new MutationObserver(() => this.onNativeClose());
|
|
497
|
+
t.observe(e, {
|
|
498
|
+
attributes: !0,
|
|
499
|
+
attributeFilter: ["open"]
|
|
500
|
+
}), this.dialogObserver = t;
|
|
501
|
+
}
|
|
502
|
+
onNativeClose() {
|
|
503
|
+
this.ignoreClose || this.suppressClose || !this.open || this.dialogEl?.open || (this.reopenGuard ? this.ownerDocument.defaultView?.queueMicrotask(() => {
|
|
504
|
+
this.open && this.isConnected && !this.dialogEl?.open && this.reveal();
|
|
505
|
+
}) : this.dismiss("ui"));
|
|
506
|
+
}
|
|
507
|
+
get dialogEl() {
|
|
508
|
+
return this.renderRoot.querySelector("dialog");
|
|
509
|
+
}
|
|
510
|
+
get closeBtn() {
|
|
511
|
+
return this.renderRoot.querySelector("button.close");
|
|
512
|
+
}
|
|
513
|
+
get detailsBox() {
|
|
514
|
+
return this.renderRoot.querySelector(".details");
|
|
515
|
+
}
|
|
516
|
+
focusTrigger() {
|
|
517
|
+
let e = this.trigger;
|
|
518
|
+
e?.isConnected && e.focus();
|
|
519
|
+
}
|
|
520
|
+
ensureRoot() {
|
|
521
|
+
let e = this.renderRoot;
|
|
522
|
+
this.isConnected && (e instanceof HTMLElement && !e.isConnected && this.append(e), e instanceof ShadowRoot && this.shadowRoot && e !== this.shadowRoot && (this.renderRoot = this.shadowRoot, this.requestUpdate()));
|
|
523
|
+
}
|
|
524
|
+
cancelReveal() {
|
|
525
|
+
let e = this.ownerDocument.defaultView;
|
|
526
|
+
this.revealFrame && e && e.cancelAnimationFrame(this.revealFrame), this.revealFrame = 0;
|
|
527
|
+
}
|
|
528
|
+
reveal() {
|
|
529
|
+
this.ensureRoot();
|
|
530
|
+
let e = this.dialogEl;
|
|
531
|
+
if (!this.open || !e) return;
|
|
532
|
+
let t = () => {
|
|
533
|
+
if (this.revealTries++ > 8) {
|
|
534
|
+
this.ignoreClose = !1;
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
let e = this.ownerDocument.defaultView;
|
|
538
|
+
e && (this.revealFrame = e.requestAnimationFrame(() => {
|
|
539
|
+
this.revealFrame = 0, this.open && this.reveal();
|
|
540
|
+
}));
|
|
541
|
+
};
|
|
542
|
+
if (!e.isConnected) {
|
|
543
|
+
t();
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
if (!e.open) try {
|
|
547
|
+
e.showModal();
|
|
548
|
+
} catch {
|
|
549
|
+
t();
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
this.revealTries = 0, this.cancelReveal(), this.ignoreClose = !1;
|
|
553
|
+
let n = this.shadowRoot?.activeElement ?? this.ownerDocument.activeElement;
|
|
554
|
+
n && e.contains(n) || this.closeBtn?.focus();
|
|
555
|
+
}
|
|
556
|
+
settleImage() {
|
|
557
|
+
let e = this.renderRoot.querySelector("img");
|
|
558
|
+
e && this.status === "loading" && (e.complete && e.naturalWidth > 0 ? this.status = "ready" : e.complete && e.getAttribute("src") && e.naturalWidth === 0 && (this.status = "error"));
|
|
559
|
+
}
|
|
560
|
+
detailToken(e) {
|
|
561
|
+
let t = this.detailTokens.get(e);
|
|
562
|
+
return t === void 0 && this.detailTokens.set(e, t = ++this.detailTokenSeq), String(t);
|
|
563
|
+
}
|
|
564
|
+
matchingDetails() {
|
|
565
|
+
let e = this.current, t = e?.id ?? "", n = String(this.index + 1), r = [], i = (e) => {
|
|
566
|
+
e && e !== this && !r.includes(e) && r.push(e);
|
|
567
|
+
};
|
|
568
|
+
for (let e of this.querySelectorAll(":scope > [slot=\"details\"]")) e instanceof HTMLElement && i(e);
|
|
569
|
+
for (let e of this.parked) i(e.el);
|
|
570
|
+
return e?.detailsId && i(this.scope.getElementById(e.detailsId)), r.filter((r) => {
|
|
571
|
+
if (r.getAttribute("slot") === "details") {
|
|
572
|
+
let e = r.getAttribute("data-for");
|
|
573
|
+
return !e || e === t || e === n;
|
|
574
|
+
}
|
|
575
|
+
return !!e?.detailsId && r.id === e.detailsId;
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
placeDetails() {
|
|
579
|
+
let e = this.matchingDetails(), t = `${e.map((e) => this.detailToken(e)).join("|")}@${this.index}`;
|
|
580
|
+
if (t === this.parkedKey) return;
|
|
581
|
+
let n = new Set(e), r = [];
|
|
582
|
+
for (let e of this.parked) n.has(e.el) && this.detailsBox?.contains(e.el) ? r.push(e) : this.putBack(e);
|
|
583
|
+
this.parked = r;
|
|
584
|
+
let i = this.detailsBox;
|
|
585
|
+
if (i) for (let t of e) {
|
|
586
|
+
if (i.contains(t)) continue;
|
|
587
|
+
let e = t.parentNode;
|
|
588
|
+
e && (this.parked.push({
|
|
589
|
+
el: t,
|
|
590
|
+
parent: e,
|
|
591
|
+
next: t.nextSibling,
|
|
592
|
+
hidden: t.hidden
|
|
593
|
+
}), t.hidden = !1, i.append(t));
|
|
594
|
+
}
|
|
595
|
+
this.parkedKey = t;
|
|
596
|
+
}
|
|
597
|
+
putBack(e) {
|
|
598
|
+
e.el.hidden = e.hidden;
|
|
599
|
+
let t = e.next?.parentNode === e.parent ? e.next : null;
|
|
600
|
+
e.parent.insertBefore(e.el, t);
|
|
601
|
+
}
|
|
602
|
+
restoreDetails() {
|
|
603
|
+
for (let e = this.parked.length - 1; e >= 0; e--) this.putBack(this.parked[e]);
|
|
604
|
+
this.parked = [], this.parkedKey = "";
|
|
605
|
+
}
|
|
606
|
+
get statusText() {
|
|
607
|
+
return this.open ? this.status === "loading" ? "Loading image." : this.status === "error" ? "This image could not be loaded." : "" : "";
|
|
608
|
+
}
|
|
609
|
+
render() {
|
|
610
|
+
let e = this.open ? this.current : void 0, t = e ? this.displaySrc : "", n = e && x(e.href, this.base) ? e.href : "", i = this.statusText, a = this.multiple ? r`<p class="count" aria-live="polite">${this.index + 1} of ${this.slides.length}</p>` : o;
|
|
611
|
+
return r`
|
|
612
|
+
${this.isLight ? o : r`<slot></slot><slot name="details" hidden></slot>`}
|
|
613
|
+
<dialog
|
|
614
|
+
part="dialog"
|
|
615
|
+
aria-labelledby=${this.captionId}
|
|
616
|
+
@click=${this.onDialogClick}
|
|
617
|
+
@close=${this.onDialogClose}
|
|
618
|
+
@keydown=${this.onKey}
|
|
619
|
+
>
|
|
620
|
+
<div class="panel" part="panel">
|
|
621
|
+
<div class="head">
|
|
622
|
+
<p class="caption" part="caption" id=${this.captionId}>${e?.caption ?? "Image"}</p>
|
|
623
|
+
<button type="button" class="close" autofocus @click=${() => this.dismiss("ui")}>
|
|
624
|
+
Close
|
|
625
|
+
</button>
|
|
626
|
+
</div>
|
|
627
|
+
<figure class="figure">
|
|
628
|
+
${t ? r`<img
|
|
629
|
+
part="image"
|
|
630
|
+
alt=${e?.alt ?? ""}
|
|
631
|
+
src=${t}
|
|
632
|
+
aria-busy=${this.status === "loading" ? "true" : "false"}
|
|
633
|
+
@load=${this.onLoad}
|
|
634
|
+
@error=${this.onError}
|
|
635
|
+
/>` : o}
|
|
636
|
+
</figure>
|
|
637
|
+
<p class="status ${i ? "" : "visually-hidden"}" role="status">${i}</p>
|
|
638
|
+
<div class="toolbar" part="controls">
|
|
639
|
+
${this.multiple ? r`<button type="button" class="prev" @click=${() => this.step(-1)}>
|
|
640
|
+
Previous
|
|
641
|
+
</button>
|
|
642
|
+
<button type="button" class="next" @click=${() => this.step(1)}>Next</button>
|
|
643
|
+
${a}` : o}
|
|
644
|
+
${n ? r`<a
|
|
645
|
+
class="full"
|
|
646
|
+
href=${n}
|
|
647
|
+
target="_blank"
|
|
648
|
+
rel="noopener noreferrer"
|
|
649
|
+
@click=${this.onFullSize}
|
|
650
|
+
>Full size<span class="visually-hidden"> (opens in a new tab)</span></a
|
|
651
|
+
>` : o}
|
|
652
|
+
</div>
|
|
653
|
+
<div class="details" part="details"></div>
|
|
654
|
+
</div>
|
|
655
|
+
</dialog>
|
|
656
|
+
`;
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
// src/components/uvalib-lightbox/uvalib-lightbox.ts
|
|
660
|
+
a([e({ type: String })], k.prototype, "selector", void 0), a([e({ attribute: "url-param" })], k.prototype, "urlParam", void 0), a([n()], k.prototype, "slides", void 0), a([n()], k.prototype, "index", void 0), a([n()], k.prototype, "open", void 0), a([n()], k.prototype, "status", void 0), a([n()], k.prototype, "fitW", void 0), a([n()], k.prototype, "fitH", void 0), i("uvalib-lightbox", k);
|
|
661
|
+
|
|
662
|
+
//# sourceMappingURL=uvalib-lightbox.js.map
|