@uvalib/web-components 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/README.md +849 -47
  3. package/dist/analytics.d.ts +10 -0
  4. package/dist/analytics.js +9 -0
  5. package/dist/analytics.js.map +1 -0
  6. package/dist/base/UvalibElement.js +8 -5
  7. package/dist/base/UvalibElement.js.map +1 -1
  8. package/dist/base/analytics-state.d.ts +7 -0
  9. package/dist/base/analytics-state.js.map +1 -1
  10. package/dist/base/light-dom-styles.d.ts +13 -0
  11. package/dist/base/light-dom-styles.js +26 -0
  12. package/dist/base/light-dom-styles.js.map +1 -1
  13. package/dist/base/search-tracker.d.ts +57 -0
  14. package/dist/base/search-tracker.js +51 -0
  15. package/dist/base/search-tracker.js.map +1 -0
  16. package/dist/base.css +286 -14
  17. package/dist/base.d.ts +2 -0
  18. package/dist/base.js +1 -0
  19. package/dist/base.js.map +1 -1
  20. package/dist/components/site-analytics/SiteAnalytics.d.ts +20 -1
  21. package/dist/components/site-analytics/SiteAnalytics.js +93 -12
  22. package/dist/components/site-analytics/SiteAnalytics.js.map +1 -1
  23. package/dist/components/site-page/SitePage.d.ts +23 -0
  24. package/dist/components/site-page/SitePage.js +77 -0
  25. package/dist/components/site-page/SitePage.js.map +1 -1
  26. package/dist/components/uvalib-back-to-top/UvalibBackToTop.d.ts +58 -0
  27. package/dist/components/uvalib-back-to-top/UvalibBackToTop.js +250 -0
  28. package/dist/components/uvalib-back-to-top/UvalibBackToTop.js.map +1 -0
  29. package/dist/components/uvalib-back-to-top/uvalib-back-to-top.d.ts +1 -0
  30. package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js +4 -0
  31. package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js.map +1 -0
  32. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.d.ts +14 -0
  33. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js +56 -4
  34. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js.map +1 -1
  35. package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +25 -3
  36. package/dist/components/uvalib-chip-group/UvalibChipGroup.js +80 -10
  37. package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -1
  38. package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +212 -0
  39. package/dist/components/uvalib-combobox/UvalibCombobox.js +1088 -0
  40. package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -0
  41. package/dist/components/uvalib-combobox/uvalib-combobox.d.ts +1 -0
  42. package/dist/components/uvalib-combobox/uvalib-combobox.js +4 -0
  43. package/dist/components/uvalib-combobox/uvalib-combobox.js.map +1 -0
  44. package/dist/components/uvalib-contents/UvalibContents.d.ts +53 -0
  45. package/dist/components/uvalib-contents/UvalibContents.js +202 -3
  46. package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
  47. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.d.ts +56 -17
  48. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +285 -81
  49. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -1
  50. package/dist/components/uvalib-date-range/UvalibDateRange.d.ts +6 -0
  51. package/dist/components/uvalib-date-range/UvalibDateRange.js +23 -0
  52. package/dist/components/uvalib-date-range/UvalibDateRange.js.map +1 -1
  53. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +113 -0
  54. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +589 -0
  55. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -0
  56. package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.d.ts +1 -0
  57. package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js +4 -0
  58. package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js.map +1 -0
  59. package/dist/components/uvalib-image-regions/UvalibImageRegions.d.ts +138 -0
  60. package/dist/components/uvalib-image-regions/UvalibImageRegions.js +689 -0
  61. package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -0
  62. package/dist/components/uvalib-image-regions/regions.d.ts +57 -0
  63. package/dist/components/uvalib-image-regions/regions.js +117 -0
  64. package/dist/components/uvalib-image-regions/regions.js.map +1 -0
  65. package/dist/components/uvalib-image-regions/uvalib-image-regions.d.ts +1 -0
  66. package/dist/components/uvalib-image-regions/uvalib-image-regions.js +4 -0
  67. package/dist/components/uvalib-image-regions/uvalib-image-regions.js.map +1 -0
  68. package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +79 -0
  69. package/dist/components/uvalib-lightbox/UvalibLightbox.js +295 -16
  70. package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
  71. package/dist/components/uvalib-map/UvalibMap.d.ts +251 -0
  72. package/dist/components/uvalib-map/UvalibMap.js +1395 -0
  73. package/dist/components/uvalib-map/UvalibMap.js.map +1 -0
  74. package/dist/components/uvalib-map/uvalib-map.d.ts +1 -0
  75. package/dist/components/uvalib-map/uvalib-map.js +4 -0
  76. package/dist/components/uvalib-map/uvalib-map.js.map +1 -0
  77. package/dist/components/uvalib-metadata/UvalibMetadata.d.ts +39 -2
  78. package/dist/components/uvalib-metadata/UvalibMetadata.js +214 -8
  79. package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
  80. package/dist/components/uvalib-pager/UvalibPager.d.ts +22 -3
  81. package/dist/components/uvalib-pager/UvalibPager.js +42 -4
  82. package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
  83. package/dist/custom-elements.json +9641 -3131
  84. package/dist/index.d.ts +8 -0
  85. package/dist/index.js +5 -0
  86. package/dist/index.js.map +1 -1
  87. package/dist/pagefind.css +4 -0
  88. package/dist/styles/base.js +119 -0
  89. package/dist/styles/base.js.map +1 -1
  90. package/dist/styles/color-scheme.js +5 -0
  91. package/dist/styles/color-scheme.js.map +1 -1
  92. package/dist/styles/controls.js +6 -0
  93. package/dist/styles/controls.js.map +1 -1
  94. package/dist/styles/hidden.d.ts +2 -0
  95. package/dist/styles/hidden.js +51 -0
  96. package/dist/styles/hidden.js.map +1 -0
  97. package/dist/styles/message.d.ts +1 -0
  98. package/dist/styles/message.js +82 -0
  99. package/dist/styles/message.js.map +1 -0
  100. package/dist/styles/pagefind.js +4 -0
  101. package/dist/styles/pagefind.js.map +1 -1
  102. package/dist/styles/result-list.d.ts +1 -0
  103. package/dist/styles/result-list.js +111 -0
  104. package/dist/styles/result-list.js.map +1 -0
  105. package/dist/styles/results.js +0 -15
  106. package/dist/styles/results.js.map +1 -1
  107. package/dist/testing/index.d.ts +110 -0
  108. package/dist/testing/index.js +100 -0
  109. package/dist/testing/index.js.map +1 -0
  110. package/dist/testing/lighthouse-rules.d.ts +10 -0
  111. package/dist/testing/lighthouse-rules.js +44 -0
  112. package/dist/testing/lighthouse-rules.js.map +1 -0
  113. package/dist/tokens.css +5 -0
  114. package/dist-cdn/analytics.js +32 -0
  115. package/dist-cdn/analytics.js.map +1 -0
  116. package/dist-cdn/base.css +286 -14
  117. package/dist-cdn/bento-box.js +3 -3
  118. package/dist-cdn/chunks/{SiteAnalytics-Cm-FyhYS.js → SiteAnalytics-B9gu5aGO.js} +59 -30
  119. package/dist-cdn/chunks/SiteAnalytics-B9gu5aGO.js.map +1 -0
  120. package/dist-cdn/chunks/{UvalibElement-BnI-eRRR.js → UvalibElement-pGONDAwB.js} +108 -101
  121. package/dist-cdn/chunks/UvalibElement-pGONDAwB.js.map +1 -0
  122. package/dist-cdn/chunks/{accessible-GqhVn5_H.js → accessible-DJv7YOtS.js} +2 -2
  123. package/dist-cdn/chunks/{accessible-GqhVn5_H.js.map → accessible-DJv7YOtS.js.map} +1 -1
  124. package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js.map +1 -1
  125. package/dist-cdn/chunks/{base-p5pk0vb2.js → base-BI8h0Gf3.js} +121 -2
  126. package/dist-cdn/chunks/base-BI8h0Gf3.js.map +1 -0
  127. package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js → library-weekly-hours-CrV3TlP5.js} +3 -3
  128. package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js.map → library-weekly-hours-CrV3TlP5.js.map} +1 -1
  129. package/dist-cdn/chunks/regions-B8ExwUGP.js +86 -0
  130. package/dist-cdn/chunks/regions-B8ExwUGP.js.map +1 -0
  131. package/dist-cdn/chunks/{repeat-CIFUYkyh.js → repeat-m5Zd_QeP.js} +2 -2
  132. package/dist-cdn/chunks/{repeat-CIFUYkyh.js.map → repeat-m5Zd_QeP.js.map} +1 -1
  133. package/dist-cdn/chunks/{site-header-BlOYvQg1.js → site-header-DYRMpdBj.js} +9 -4
  134. package/dist-cdn/chunks/{site-header-BlOYvQg1.js.map → site-header-DYRMpdBj.js.map} +1 -1
  135. package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js → site-main-nav-DURrQMal.js} +3 -3
  136. package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js.map → site-main-nav-DURrQMal.js.map} +1 -1
  137. package/dist-cdn/chunks/{static-html-1mTAG6nS.js → static-html-C1rhtCHu.js} +2 -2
  138. package/dist-cdn/chunks/{static-html-1mTAG6nS.js.map → static-html-C1rhtCHu.js.map} +1 -1
  139. package/dist-cdn/custom-elements.json +9641 -3131
  140. package/dist-cdn/events-section.js +3 -3
  141. package/dist-cdn/library-hours-setup.js +2 -2
  142. package/dist-cdn/library-weekly-hours.js +1 -1
  143. package/dist-cdn/manifest.json +10 -2
  144. package/dist-cdn/pagefind.css +4 -0
  145. package/dist-cdn/site-alerts.js +4 -4
  146. package/dist-cdn/site-analytics.js +2 -2
  147. package/dist-cdn/site-footer.js +2 -2
  148. package/dist-cdn/site-header.js +1 -1
  149. package/dist-cdn/site-hours-section.js +4 -4
  150. package/dist-cdn/site-main-nav.js +1 -1
  151. package/dist-cdn/site-page.js +56 -11
  152. package/dist-cdn/site-page.js.map +1 -1
  153. package/dist-cdn/site-style.js +2 -2
  154. package/dist-cdn/skills/uvalib-web-components/SKILL.md +98 -13
  155. package/dist-cdn/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
  156. package/dist-cdn/skills/uvalib-web-components/reference/components.md +302 -14
  157. package/dist-cdn/skills/uvalib-web-components/reference/snippets.md +1 -1
  158. package/dist-cdn/tokens.css +5 -0
  159. package/dist-cdn/uvalib-analytics.js +2 -2
  160. package/dist-cdn/uvalib-back-to-top.js +156 -0
  161. package/dist-cdn/uvalib-back-to-top.js.map +1 -0
  162. package/dist-cdn/uvalib-breadcrumbs.js +31 -11
  163. package/dist-cdn/uvalib-breadcrumbs.js.map +1 -1
  164. package/dist-cdn/uvalib-card-grid.js +1 -1
  165. package/dist-cdn/uvalib-card.js +3 -3
  166. package/dist-cdn/uvalib-chip-group.js +53 -14
  167. package/dist-cdn/uvalib-chip-group.js.map +1 -1
  168. package/dist-cdn/uvalib-combobox.js +667 -0
  169. package/dist-cdn/uvalib-combobox.js.map +1 -0
  170. package/dist-cdn/uvalib-contents.js +100 -22
  171. package/dist-cdn/uvalib-contents.js.map +1 -1
  172. package/dist-cdn/uvalib-date-histogram.js +237 -127
  173. package/dist-cdn/uvalib-date-histogram.js.map +1 -1
  174. package/dist-cdn/uvalib-date-range.js +14 -2
  175. package/dist-cdn/uvalib-date-range.js.map +1 -1
  176. package/dist-cdn/uvalib-filter-drawer.js +355 -0
  177. package/dist-cdn/uvalib-filter-drawer.js.map +1 -0
  178. package/dist-cdn/uvalib-filter.js +3 -3
  179. package/dist-cdn/uvalib-image-regions.js +460 -0
  180. package/dist-cdn/uvalib-image-regions.js.map +1 -0
  181. package/dist-cdn/uvalib-lightbox.js +214 -59
  182. package/dist-cdn/uvalib-lightbox.js.map +1 -1
  183. package/dist-cdn/uvalib-map.js +667 -0
  184. package/dist-cdn/uvalib-map.js.map +1 -0
  185. package/dist-cdn/uvalib-metadata.js +150 -24
  186. package/dist-cdn/uvalib-metadata.js.map +1 -1
  187. package/dist-cdn/uvalib-pager.js +29 -17
  188. package/dist-cdn/uvalib-pager.js.map +1 -1
  189. package/dist-cdn/uvalib-photo-grid.js +2 -2
  190. package/dist-cdn/uvalib-results-count.js +2 -2
  191. package/dist-cdn/uvalib-tabs.js +2 -2
  192. package/dist-cdn/uvalib-tag-list.js +2 -2
  193. package/package.json +43 -1
  194. package/skills/uvalib-web-components/SKILL.md +98 -13
  195. package/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
  196. package/skills/uvalib-web-components/reference/components.md +302 -14
  197. package/skills/uvalib-web-components/reference/snippets.md +1 -1
  198. package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js.map +0 -1
  199. package/dist-cdn/chunks/UvalibElement-BnI-eRRR.js.map +0 -1
  200. package/dist-cdn/chunks/base-p5pk0vb2.js.map +0 -1
@@ -1,10 +1,11 @@
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";
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-pGONDAwB.js";
2
2
  import { a as u } from "./chunks/analytics-DTTihuBD.js";
3
- import { t as d } from "./chunks/accessible-GqhVn5_H.js";
4
- import { n as f, r as p, t as m } from "./chunks/url-param-C1sk_F1d.js";
3
+ import { t as d } from "./chunks/accessible-DJv7YOtS.js";
4
+ import { i as f, t as p } from "./chunks/regions-B8ExwUGP.js";
5
+ import { n as m, r as h, t as g } from "./chunks/url-param-C1sk_F1d.js";
5
6
  // src/components/uvalib-lightbox/media.ts
6
- var h = /^(full|square|max|pct:[^/]+|\d+,\d+,\d+,\d+)$/i, g = /^!?\d+(\.\d+)?$/, _ = /^(default|color|gray|grey|bitonal|native)\.(jpe?g|png|gif|webp|tiff?|jp2)$/i, v = /\.(jpe?g|png|gif|webp)$/i, y = /^image\/(png|jpeg|gif|webp)($|[;,])/i;
7
- function b(e, t) {
7
+ var _ = /^(full|square|max|pct:[^/]+|\d+,\d+,\d+,\d+)$/i, v = /^!?\d+(\.\d+)?$/, y = /^(default|color|gray|grey|bitonal|native)\.(jpe?g|png|gif|webp|tiff?|jp2)$/i, b = /\.(jpe?g|png|gif|webp)$/i, x = /^image\/(png|jpeg|gif|webp)($|[;,])/i;
8
+ function S(e, t) {
8
9
  let n;
9
10
  try {
10
11
  n = new URL(e, t);
@@ -15,42 +16,45 @@ function b(e, t) {
15
16
  let r = n.pathname.split("/");
16
17
  if (r.length < 5) return null;
17
18
  let i = r[r.length - 1] ?? "", a = r[r.length - 2] ?? "", o = r[r.length - 4] ?? "";
18
- return !_.test(i) || !g.test(a) || !h.test(o) ? null : {
19
+ return !y.test(i) || !v.test(a) || !_.test(o) ? null : {
19
20
  url: n,
20
21
  parts: r,
21
22
  regionIndex: r.length - 4,
22
23
  sizeIndex: r.length - 3
23
24
  };
24
25
  }
25
- function x(e, t, n, r) {
26
- let i = b(e, t);
26
+ function C(e, t, n, r) {
27
+ let i = S(e, t);
27
28
  if (!i) return null;
28
29
  let a = i.parts[i.parts.length - 1] ?? "";
29
- if (!v.test(a)) return null;
30
+ if (!b.test(a)) return null;
30
31
  let o = Math.max(1, Math.round(n)), s = Math.max(1, Math.round(r));
31
32
  return i.parts[i.sizeIndex] = `!${o},${s}`, i.url.pathname = i.parts.join("/"), i.url.toString();
32
33
  }
33
- function S(e, t) {
34
- let n = b(e, t);
34
+ function w(e, t) {
35
+ let n = S(e, t);
35
36
  return n && n.parts[n.regionIndex - 1] || null;
36
37
  }
37
- function C(e) {
38
+ function T(e) {
38
39
  let t = Math.min(e.devicePixelRatio || 1, 2);
39
40
  return {
40
41
  w: Math.max(1, Math.min(2e3, Math.round((e.innerWidth || 800) * t))),
41
42
  h: Math.max(1, Math.min(2e3, Math.round((e.innerHeight || 600) * t)))
42
43
  };
43
44
  }
44
- function w(e, t) {
45
+ function E(e, t) {
45
46
  try {
46
47
  let n = new URL(e, t);
47
- return n.protocol === "http:" || n.protocol === "https:" || n.protocol === "data:" && y.test(n.pathname);
48
+ return n.protocol === "http:" || n.protocol === "https:" || n.protocol === "data:" && x.test(n.pathname);
48
49
  } catch {
49
50
  return !1;
50
51
  }
51
52
  }
52
53
  // src/components/uvalib-lightbox/UvalibLightbox.ts
53
- var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
54
+ var D = "uvalib-regions-list", O = ["data-uvalib-region", "data-uvalib-active"], k = (e) => {
55
+ let t = Number(e);
56
+ return t > 0 ? t : void 0;
57
+ }, A = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), j = (e) => `
54
58
  ${e} { display: block; }
55
59
  ${e} .viewer { display: contents; }
56
60
  ${e} dialog {
@@ -89,12 +93,19 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
89
93
  padding: 0.5rem 0.75rem;
90
94
  font: inherit;
91
95
  }
96
+ ${e} .regions { display: block; }
92
97
  ${e} .details:empty { display: none; }
93
98
  ${e} > [slot="details"] { display: none; }
94
99
  ${e}[hidden], ${e} [hidden] { display: none !important; }
95
- `, D = s(E(":host")), O = 0, k = class extends l {
100
+ `, M = s(j(":host")), N = 0, P = null;
101
+ function F() {
102
+ P || customElements.get("uvalib-image-regions") || (P = import("./uvalib-image-regions.js").catch((e) => {
103
+ P = null, console.warn("uvalib-lightbox: could not load uvalib-image-regions.", e);
104
+ }));
105
+ }
106
+ var I = class extends l {
96
107
  constructor(...e) {
97
- 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 = () => {
108
+ super(...e), this.selector = "", this.urlParam = "", this.regionsLabel = "Regions", this.slides = [], this.index = 0, this.open = !1, this.status = "loading", this.fitW = 0, this.fitH = 0, this.showRegions = !0, this.captionId = `uvalib-lightbox-caption-${++N}`, this.trigger = null, this.historyPushed = !1, this.userClosed = !1, this.suppressClose = !1, this.warnedSelector = !1, this.lastSrc = "", this.syncQueued = !1, this.regionsChanged = !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.lent = null, this.entryTabindex = /* @__PURE__ */ new WeakMap(), this.warnedList = !1, this.refocus = !1, this.onResize = () => {
98
109
  this.open && (window.clearTimeout(this.resizeTimer), this.resizeTimer = window.setTimeout(() => {
99
110
  this.isConnected && this.open && this.measure();
100
111
  }, 150));
@@ -115,7 +126,7 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
115
126
  this.historyPushed = this.writeParam(t, "push", this.backInHash), this.open ||= !0;
116
127
  return;
117
128
  }
118
- let e = f(this.loc(), this.urlParam);
129
+ let e = m(this.loc(), this.urlParam);
119
130
  if (!e) {
120
131
  this.historyPushed = !1, this.open && this.dismiss("pop");
121
132
  return;
@@ -143,12 +154,14 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
143
154
  this.status === "loading" && (this.status = "ready");
144
155
  }, this.onError = () => {
145
156
  this.status = "error";
146
- }, this.detailTokens = /* @__PURE__ */ new WeakMap(), this.detailTokenSeq = 0;
157
+ }, this.detailTokens = /* @__PURE__ */ new WeakMap(), this.detailTokenSeq = 0, this.toggleRegions = () => {
158
+ this.showRegions = !this.showRegions;
159
+ };
147
160
  }
148
161
  static {
149
162
  this.styles = [
150
163
  d,
151
- D,
164
+ M,
152
165
  t`
153
166
  .panel {
154
167
  background: var(--uva-color-surface-raised, var(--uva-color-surface, #fff));
@@ -187,7 +200,8 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
187
200
  outline-offset: 2px;
188
201
  }
189
202
  dialog button.prev,
190
- dialog button.next {
203
+ dialog button.next,
204
+ dialog button.regions-toggle {
191
205
  color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));
192
206
  background: var(--uva-color-surface, #fff);
193
207
  border-color: var(--uva-color-border, var(--uva-grey-100, #dadada));
@@ -195,6 +209,25 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
195
209
  .status {
196
210
  font-size: 1rem;
197
211
  }
212
+ /* Pressed shows a check mark, so the state is not shown by colour alone. */
213
+ button.regions-toggle {
214
+ display: inline-flex;
215
+ align-items: center;
216
+ gap: 0.5rem;
217
+ }
218
+ button.regions-toggle::before {
219
+ content: '';
220
+ box-sizing: border-box;
221
+ width: 1rem;
222
+ height: 1rem;
223
+ border: 2px solid currentColor;
224
+ }
225
+ button.regions-toggle[aria-pressed='true']::before {
226
+ border-width: 0 3px 3px 0;
227
+ width: 0.5rem;
228
+ margin-inline: 0.25rem;
229
+ transform: translateY(-0.125rem) rotate(45deg);
230
+ }
198
231
  @media (prefers-reduced-motion: no-preference) {
199
232
  .panel {
200
233
  animation: uvalib-lightbox-in 0.15s ease;
@@ -232,7 +265,7 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
232
265
  createRenderRoot() {
233
266
  if (!this.isLight) {
234
267
  let e = super.createRenderRoot();
235
- return this.noStyle && e instanceof ShadowRoot && (e.adoptedStyleSheets = [d.styleSheet, D.styleSheet].filter((e) => e != null)), e;
268
+ return this.noStyle && e instanceof ShadowRoot && (e.adoptedStyleSheets = [d.styleSheet, M.styleSheet].filter((e) => e != null)), e;
236
269
  }
237
270
  let e = this.ownerDocument.createElement("div");
238
271
  return e.className = "viewer", this.mount = e, this.append(e), e;
@@ -247,7 +280,7 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
247
280
  e?.open && e.close(), this.suppressClose = !1, this.ignoreClose = !1;
248
281
  }
249
282
  willUpdate() {
250
- if (!this.open) {
283
+ if (this.lendList(), !this.open) {
251
284
  this.lastSrc = "";
252
285
  return;
253
286
  }
@@ -255,14 +288,14 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
255
288
  e === this.lastSrc ? !e && this.status !== "error" && (this.status = "error") : (this.lastSrc = e, this.status = e ? "loading" : "error");
256
289
  }
257
290
  updated(e) {
258
- 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(() => {
291
+ super.updated(e), e.has("selector") && this.watch(), (e.has("regions") || e.has("regionsList")) && this.isConnected && this.scheduleSync(!0), this.open ? ((e.has("open") || e.has("index") || e.has("slides")) && this.placeDetails(), (this.current?.regions.length || this.current?.list) && F(), this.lendList(!0), this.refocus && (this.refocus = !1, this.closeBtn?.focus()), this.bindDialogObserver(), e.has("open") && this.reveal(), queueMicrotask(() => {
259
292
  this.isConnected && this.settleImage();
260
293
  })) : e.has("open") && this.restoreDetails();
261
294
  }
262
295
  installLight(e) {
263
296
  if (!e) return;
264
297
  let t = this.getRootNode(), n = t instanceof Document || t instanceof ShadowRoot ? t : void 0;
265
- this.noStyle ? (c(`${this.localName}::structure`, s(E(this.localName)), {
298
+ this.noStyle ? (c(`${this.localName}::structure`, s(j(this.localName)), {
266
299
  root: n,
267
300
  scope: !1
268
301
  }), c(`${this.localName}::a11y`, d, { root: n })) : c(this.localName, this.constructor.elementStyles, { root: n });
@@ -298,6 +331,10 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
298
331
  "data-caption",
299
332
  "data-id",
300
333
  "data-details-id",
334
+ "data-regions",
335
+ "data-regions-list",
336
+ "data-image-width",
337
+ "data-image-height",
301
338
  "slot"
302
339
  ],
303
340
  childList: !0,
@@ -307,11 +344,21 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
307
344
  subtree: !0
308
345
  });
309
346
  }
310
- scheduleSync() {
311
- this.syncQueued || (this.syncQueued = !0, queueMicrotask(() => {
347
+ scheduleSync(e = !1) {
348
+ e && (this.regionsChanged = !0), this.syncQueued || (this.syncQueued = !0, queueMicrotask(() => {
312
349
  if (this.syncQueued = !1, !this.isConnected) return;
313
- let e = this.collect();
314
- 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))) {
350
+ let e = this.collect(), t = this.regionsChanged;
351
+ this.regionsChanged = !1;
352
+ let n = !t && 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 && e.list === this.slides[t]?.list && JSON.stringify([
353
+ e.regions,
354
+ e.imageWidth,
355
+ e.imageHeight
356
+ ]) === JSON.stringify([
357
+ this.slides[t]?.regions,
358
+ this.slides[t]?.imageWidth,
359
+ this.slides[t]?.imageHeight
360
+ ]));
361
+ if (this.noteEntries(), !n) {
315
362
  let t = this.current?.el;
316
363
  if (this.slides = e, this.open) {
317
364
  let n = t ? e.findIndex((e) => e.el === t) : -1;
@@ -336,7 +383,7 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
336
383
  }
337
384
  for (let e of r) n(e);
338
385
  let i = (n) => {
339
- if (!(n instanceof HTMLAnchorElement) || !n.hasAttribute("href") || n.closest("[hidden]") || this.mount?.contains(n) || n.closest("dialog") || n.closest("[slot=\"details\"]")) return;
386
+ if (!(n instanceof HTMLAnchorElement) || !n.hasAttribute("href") || n.closest("[hidden]") || this.mount?.contains(n) || n.closest("dialog") || n.closest("[slot=\"details\"]") || this.lent?.el.contains(n)) return;
340
387
  for (let e of t) if (e.contains(n)) return;
341
388
  let r = n.closest("uvalib-lightbox");
342
389
  r && r !== this || e.push(n);
@@ -350,21 +397,61 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
350
397
  }), a.map((e, t) => this.slide(e, t));
351
398
  }
352
399
  slide(e, t) {
353
- 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";
354
- return {
400
+ let n = e.getAttribute("href") ?? "", r = e.querySelector("img"), i = A(r?.getAttribute("data-uvalib-alt") || r?.getAttribute("alt")), a = this.linkText(e), o = A(e.dataset.caption) || i || a || A(e.getAttribute("title")) || "Image", s = A(e.dataset.id) || e.id || w(n, this.base) || String(t + 1), c = this.listOf(e, s, n, t), l = this.regionsOf(e, s, n, t);
401
+ return c && l.length && !this.warnedList && (this.warnedList = !0, console.warn(`${this.localName}: an image has both regions and a regions list; the list is used.`)), {
355
402
  el: e,
356
- id: T(e.dataset.id) || e.id || S(n, this.base) || String(t + 1),
403
+ id: s,
357
404
  href: n,
358
405
  caption: o,
359
406
  alt: i || o,
360
- detailsId: T(e.dataset.detailsId) || null
407
+ detailsId: A(e.dataset.detailsId) || null,
408
+ regions: c ? [] : l,
409
+ list: c,
410
+ imageWidth: k(e.dataset.imageWidth),
411
+ imageHeight: k(e.dataset.imageHeight)
361
412
  };
362
413
  }
414
+ regionsOf(e, t, n, r) {
415
+ let i = p(e.dataset.regions);
416
+ if (typeof this.regions == "function") {
417
+ let a;
418
+ try {
419
+ a = this.regions({
420
+ element: e,
421
+ id: t,
422
+ href: n,
423
+ index: r
424
+ });
425
+ } catch (e) {
426
+ console.warn(`${this.localName}: the regions callback threw.`, e);
427
+ }
428
+ if (Array.isArray(a)) for (let e of a) {
429
+ let t = f(e);
430
+ t && i.push(t);
431
+ }
432
+ }
433
+ return i;
434
+ }
435
+ listOf(e, t, n, r) {
436
+ let i = null, a = A(e.dataset.regionsList);
437
+ if (a) i = this.scope.getElementById(a);
438
+ else if (typeof this.regionsList == "function") try {
439
+ i = this.regionsList({
440
+ element: e,
441
+ id: t,
442
+ href: n,
443
+ index: r
444
+ });
445
+ } catch (e) {
446
+ console.warn(`${this.localName}: the regionsList callback threw.`, e);
447
+ }
448
+ return i instanceof HTMLOListElement || i instanceof HTMLUListElement ? i.contains(this) || i.contains(e) ? null : i : null;
449
+ }
363
450
  linkText(e) {
364
451
  let t = [], n = (e) => {
365
452
  e instanceof HTMLImageElement || e instanceof HTMLElement && (e.hidden || e.getAttribute("slot") === "details" || e.getAttribute("slot") === "badge" || e.classList.contains("badge") || e.classList.contains("visually-hidden") || e.hasAttribute("data-uvalib-generated-badge") || e.hasAttribute("data-uvalib-badge-sep")) || (e.nodeType === Node.TEXT_NODE ? t.push(e.textContent ?? "") : e.childNodes.forEach(n));
366
453
  };
367
- return e.childNodes.forEach(n), T(t.join(" "));
454
+ return e.childNodes.forEach(n), A(t.join(" "));
368
455
  }
369
456
  get current() {
370
457
  return this.slides[this.index];
@@ -374,12 +461,12 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
374
461
  }
375
462
  get displaySrc() {
376
463
  let e = this.current?.href ?? "";
377
- if (!w(e, this.base)) return "";
378
- let t = this.fitW || C(window).w, n = this.fitH || C(window).h;
379
- return x(e, this.base, t, n) ?? e;
464
+ if (!E(e, this.base)) return "";
465
+ let t = this.fitW || T(window).w, n = this.fitH || T(window).h;
466
+ return C(e, this.base, t, n) ?? e;
380
467
  }
381
468
  measure() {
382
- let { w: e, h: t } = C(window);
469
+ let { w: e, h: t } = T(window);
383
470
  e !== this.fitW && (this.fitW = e), t !== this.fitH && (this.fitH = t);
384
471
  }
385
472
  linkFrom(e) {
@@ -395,8 +482,8 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
395
482
  slides: t
396
483
  };
397
484
  else if (this.urlParam) {
398
- let r = t[e]?.id ?? null, i = p(location.hash);
399
- n ? this.writeParam(r, "replace", i) : (f(this.loc(), this.urlParam) && this.writeParam(null, "replace", i), this.historyPushed = this.writeParam(r, "push", i));
485
+ let r = t[e]?.id ?? null, i = h(location.hash);
486
+ n ? this.writeParam(r, "replace", i) : (m(this.loc(), this.urlParam) && this.writeParam(null, "replace", i), this.historyPushed = this.writeParam(r, "push", i));
400
487
  }
401
488
  u(this, [
402
489
  "uvalib-lightbox",
@@ -408,12 +495,12 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
408
495
  }
409
496
  openFromUrl() {
410
497
  if (this.open || this.userClosed || !this.urlParam) return;
411
- let e = f(this.loc(), this.urlParam);
498
+ let e = m(this.loc(), this.urlParam);
412
499
  if (!e) return;
413
500
  let t = this.slides.length ? this.slides : this.collect(), n = t.findIndex((t) => t.id === e);
414
501
  if (n < 0) return;
415
502
  this.slides = t, this.index = n, this.trigger = t[n]?.el ?? null, this.measure();
416
- let r = p(location.hash);
503
+ let r = h(location.hash);
417
504
  this.writeParam(null, "replace", r), this.historyPushed = this.writeParam(e, "push", r), this.open = !0;
418
505
  }
419
506
  step(e) {
@@ -436,7 +523,7 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
436
523
  this.dismissing = !0;
437
524
  try {
438
525
  let n = this.historyPushed;
439
- 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 = p(location.hash), this.pendingBack = !0, history.back()) : this.writeParam(null, "replace", p(location.hash)) : e === "empty" && this.urlParam && (this.pendingBack = !1, this.queuedOpen = null, this.writeParam(null, "replace", p(location.hash)));
526
+ 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 = h(location.hash), this.pendingBack = !0, history.back()) : this.writeParam(null, "replace", h(location.hash)) : e === "empty" && this.urlParam && (this.pendingBack = !1, this.queuedOpen = null, this.writeParam(null, "replace", h(location.hash)));
440
527
  } finally {
441
528
  this.dismissing = !1;
442
529
  }
@@ -444,7 +531,7 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
444
531
  }
445
532
  writeParam(e, t, n) {
446
533
  if (!this.urlParam) return !1;
447
- let r = m(this.loc(), this.urlParam, e, n);
534
+ let r = g(this.loc(), this.urlParam, e, n);
448
535
  if (r === location.pathname + location.search + location.hash) return !1;
449
536
  let i = history.state && typeof history.state == "object" ? history.state : {};
450
537
  try {
@@ -579,13 +666,82 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
579
666
  }
580
667
  restoreDetails() {
581
668
  for (let e = this.parked.length - 1; e >= 0; e--) this.putBack(this.parked[e]);
582
- this.parked = [], this.parkedKey = "";
669
+ this.parked = [], this.parkedKey = "", this.returnList();
670
+ }
671
+ get wantedList() {
672
+ if (!this.open) return null;
673
+ let e = this.current?.list ?? null;
674
+ return e && this.displaySrc ? e : null;
675
+ }
676
+ lendList(e = !1) {
677
+ let t = this.wantedList;
678
+ if (this.lent && this.lent.el !== t && this.returnList(), !t || this.isLight && !e) return;
679
+ let n = this.isLight ? this.renderRoot.querySelector("uvalib-image-regions") : this;
680
+ if (n && t.parentNode !== n) {
681
+ if (!this.lent) {
682
+ let e = t.parentNode;
683
+ if (!e) return;
684
+ this.lent = {
685
+ el: t,
686
+ parent: e,
687
+ next: t.nextSibling,
688
+ hidden: t.hidden,
689
+ slot: t.getAttribute("slot")
690
+ };
691
+ }
692
+ this.noteEntries(), this.isLight ? t.removeAttribute("slot") : t.setAttribute("slot", D), t.hidden = !1, n.append(t);
693
+ }
694
+ }
695
+ noteEntries() {
696
+ let e = this.lent?.el;
697
+ if (e) for (let t of e.children) this.entryTabindex.has(t) || this.entryTabindex.set(t, t.getAttribute("tabindex"));
698
+ }
699
+ returnList() {
700
+ let e = this.lent;
701
+ if (!e) return;
702
+ this.lent = null;
703
+ let { el: t } = e, n = this.shadowRoot?.activeElement ?? this.ownerDocument.activeElement;
704
+ this.open && n && t.contains(n) && (this.refocus = !0);
705
+ for (let e of t.children) {
706
+ for (let t of O) e.removeAttribute(t);
707
+ if (this.entryTabindex.has(e)) {
708
+ let t = this.entryTabindex.get(e);
709
+ t == null ? e.removeAttribute("tabindex") : e.setAttribute("tabindex", t);
710
+ }
711
+ }
712
+ this.entryTabindex = /* @__PURE__ */ new WeakMap(), e.slot == null ? t.removeAttribute("slot") : t.setAttribute("slot", e.slot), t.hidden = e.hidden;
713
+ let r = e.next?.parentNode === e.parent ? e.next : null;
714
+ e.parent.insertBefore(t, r);
583
715
  }
584
716
  get statusText() {
585
717
  return this.open ? this.status === "loading" ? "Loading image." : this.status === "error" ? "This image could not be loaded." : "" : "";
586
718
  }
719
+ renderImage(e, t, n) {
720
+ let i = r`<img
721
+ part="image"
722
+ slot=${n || e.list ? "image" : o}
723
+ alt=${e.alt}
724
+ src=${t}
725
+ aria-busy=${this.status === "loading" ? "true" : "false"}
726
+ @load=${this.onLoad}
727
+ @error=${this.onError}
728
+ />`;
729
+ if (!n && !e.list) return i;
730
+ let a = e.list && !this.isLight ? r`<slot name=${D}></slot>` : o;
731
+ return r`<uvalib-image-regions
732
+ class="regions"
733
+ part="regions"
734
+ .items=${e.list ? null : n}
735
+ label=${A(this.regionsLabel) || "Regions"}
736
+ image-width=${e.imageWidth ?? o}
737
+ image-height=${e.imageHeight ?? o}
738
+ ?hide-outlines=${!this.showRegions}
739
+ ?no-style=${this.noStyle}
740
+ >${i}${a}</uvalib-image-regions
741
+ >`;
742
+ }
587
743
  render() {
588
- let e = this.open ? this.current : void 0, t = e ? this.displaySrc : "", n = e && w(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;
744
+ let e = this.open ? this.current : void 0, t = e ? this.displaySrc : "", n = e && E(e.href, this.base) ? e.href : "", i = this.statusText, a = e?.regions.length ? e.regions : null, s = !!(a || e?.list), c = this.multiple ? r`<p class="count" aria-live="polite">${this.index + 1} of ${this.slides.length}</p>` : o;
589
745
  return r`
590
746
  ${this.isLight ? o : r`<slot></slot><slot name="details" hidden></slot>`}
591
747
  <dialog
@@ -602,23 +758,22 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
602
758
  Close
603
759
  </button>
604
760
  </div>
605
- <figure class="figure">
606
- ${t ? r`<img
607
- part="image"
608
- alt=${e?.alt ?? ""}
609
- src=${t}
610
- aria-busy=${this.status === "loading" ? "true" : "false"}
611
- @load=${this.onLoad}
612
- @error=${this.onError}
613
- />` : o}
614
- </figure>
761
+ <figure class="figure">${t ? this.renderImage(e, t, a) : o}</figure>
615
762
  <p class="status ${i ? "" : "visually-hidden"}" role="status">${i}</p>
616
763
  <div class="toolbar" part="controls">
764
+ ${s && t ? r`<button
765
+ type="button"
766
+ class="regions-toggle"
767
+ aria-pressed=${this.showRegions ? "true" : "false"}
768
+ @click=${this.toggleRegions}
769
+ >
770
+ Show regions
771
+ </button>` : o}
617
772
  ${this.multiple ? r`<button type="button" class="prev" @click=${() => this.step(-1)}>
618
773
  Previous
619
774
  </button>
620
775
  <button type="button" class="next" @click=${() => this.step(1)}>Next</button>
621
- ${a}` : o}
776
+ ${c}` : o}
622
777
  ${n ? r`<a
623
778
  class="full"
624
779
  href=${n}
@@ -635,6 +790,6 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
635
790
  }
636
791
  };
637
792
  // src/components/uvalib-lightbox/uvalib-lightbox.ts
638
- 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);
793
+ a([e({ type: String })], I.prototype, "selector", void 0), a([e({ attribute: "url-param" })], I.prototype, "urlParam", void 0), a([e({ attribute: !1 })], I.prototype, "regions", void 0), a([e({ attribute: !1 })], I.prototype, "regionsList", void 0), a([e({ attribute: "regions-label" })], I.prototype, "regionsLabel", void 0), a([n()], I.prototype, "slides", void 0), a([n()], I.prototype, "index", void 0), a([n()], I.prototype, "open", void 0), a([n()], I.prototype, "status", void 0), a([n()], I.prototype, "fitW", void 0), a([n()], I.prototype, "fitH", void 0), a([n()], I.prototype, "showRegions", void 0), i("uvalib-lightbox", I);
639
794
 
640
795
  //# sourceMappingURL=uvalib-lightbox.js.map