@uvalib/web-components 1.2.0 → 1.3.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 +87 -0
  2. package/README.md +808 -46
  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 +130 -0
  60. package/dist/components/uvalib-image-regions/UvalibImageRegions.js +658 -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 +40 -0
  69. package/dist/components/uvalib-lightbox/UvalibLightbox.js +144 -16
  70. package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
  71. package/dist/components/uvalib-map/UvalibMap.d.ts +182 -0
  72. package/dist/components/uvalib-map/UvalibMap.js +1001 -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 +9253 -3253
  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 +9253 -3253
  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 +300 -13
  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 +447 -0
  180. package/dist-cdn/uvalib-image-regions.js.map +1 -0
  181. package/dist-cdn/uvalib-lightbox.js +144 -55
  182. package/dist-cdn/uvalib-lightbox.js.map +1 -1
  183. package/dist-cdn/uvalib-map.js +471 -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 +300 -13
  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 = (e) => {
55
+ let t = Number(e);
56
+ return t > 0 ? t : void 0;
57
+ }, O = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), k = (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
+ `, A = s(k(":host")), j = 0, M = null;
101
+ function N() {
102
+ M || customElements.get("uvalib-image-regions") || (M = import("./uvalib-image-regions.js").catch((e) => {
103
+ M = null, console.warn("uvalib-lightbox: could not load uvalib-image-regions.", e);
104
+ }));
105
+ }
106
+ var P = 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-${++j}`, 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.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
+ A,
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, A.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;
@@ -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") && this.isConnected && this.scheduleSync(!0), this.open ? ((e.has("open") || e.has("index") || e.has("slides")) && this.placeDetails(), this.current?.regions.length && N(), 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(k(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,9 @@ 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-image-width",
336
+ "data-image-height",
301
337
  "slot"
302
338
  ],
303
339
  childList: !0,
@@ -307,11 +343,19 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
307
343
  subtree: !0
308
344
  });
309
345
  }
310
- scheduleSync() {
311
- this.syncQueued || (this.syncQueued = !0, queueMicrotask(() => {
346
+ scheduleSync(e = !1) {
347
+ e && (this.regionsChanged = !0), this.syncQueued || (this.syncQueued = !0, queueMicrotask(() => {
312
348
  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))) {
349
+ let e = this.collect(), t = this.regionsChanged;
350
+ if (this.regionsChanged = !1, 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 && JSON.stringify([
351
+ e.regions,
352
+ e.imageWidth,
353
+ e.imageHeight
354
+ ]) === JSON.stringify([
355
+ this.slides[t]?.regions,
356
+ this.slides[t]?.imageWidth,
357
+ this.slides[t]?.imageHeight
358
+ ]))) {
315
359
  let t = this.current?.el;
316
360
  if (this.slides = e, this.open) {
317
361
  let n = t ? e.findIndex((e) => e.el === t) : -1;
@@ -350,21 +394,45 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
350
394
  }), a.map((e, t) => this.slide(e, t));
351
395
  }
352
396
  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";
397
+ let n = e.getAttribute("href") ?? "", r = e.querySelector("img"), i = O(r?.getAttribute("data-uvalib-alt") || r?.getAttribute("alt")), a = this.linkText(e), o = O(e.dataset.caption) || i || a || O(e.getAttribute("title")) || "Image", s = O(e.dataset.id) || e.id || w(n, this.base) || String(t + 1);
354
398
  return {
355
399
  el: e,
356
- id: T(e.dataset.id) || e.id || S(n, this.base) || String(t + 1),
400
+ id: s,
357
401
  href: n,
358
402
  caption: o,
359
403
  alt: i || o,
360
- detailsId: T(e.dataset.detailsId) || null
404
+ detailsId: O(e.dataset.detailsId) || null,
405
+ regions: this.regionsOf(e, s, n, t),
406
+ imageWidth: D(e.dataset.imageWidth),
407
+ imageHeight: D(e.dataset.imageHeight)
361
408
  };
362
409
  }
410
+ regionsOf(e, t, n, r) {
411
+ let i = p(e.dataset.regions);
412
+ if (typeof this.regions == "function") {
413
+ let a;
414
+ try {
415
+ a = this.regions({
416
+ element: e,
417
+ id: t,
418
+ href: n,
419
+ index: r
420
+ });
421
+ } catch (e) {
422
+ console.warn(`${this.localName}: the regions callback threw.`, e);
423
+ }
424
+ if (Array.isArray(a)) for (let e of a) {
425
+ let t = f(e);
426
+ t && i.push(t);
427
+ }
428
+ }
429
+ return i;
430
+ }
363
431
  linkText(e) {
364
432
  let t = [], n = (e) => {
365
433
  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
434
  };
367
- return e.childNodes.forEach(n), T(t.join(" "));
435
+ return e.childNodes.forEach(n), O(t.join(" "));
368
436
  }
369
437
  get current() {
370
438
  return this.slides[this.index];
@@ -374,12 +442,12 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
374
442
  }
375
443
  get displaySrc() {
376
444
  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;
445
+ if (!E(e, this.base)) return "";
446
+ let t = this.fitW || T(window).w, n = this.fitH || T(window).h;
447
+ return C(e, this.base, t, n) ?? e;
380
448
  }
381
449
  measure() {
382
- let { w: e, h: t } = C(window);
450
+ let { w: e, h: t } = T(window);
383
451
  e !== this.fitW && (this.fitW = e), t !== this.fitH && (this.fitH = t);
384
452
  }
385
453
  linkFrom(e) {
@@ -395,8 +463,8 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
395
463
  slides: t
396
464
  };
397
465
  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));
466
+ let r = t[e]?.id ?? null, i = h(location.hash);
467
+ n ? this.writeParam(r, "replace", i) : (m(this.loc(), this.urlParam) && this.writeParam(null, "replace", i), this.historyPushed = this.writeParam(r, "push", i));
400
468
  }
401
469
  u(this, [
402
470
  "uvalib-lightbox",
@@ -408,12 +476,12 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
408
476
  }
409
477
  openFromUrl() {
410
478
  if (this.open || this.userClosed || !this.urlParam) return;
411
- let e = f(this.loc(), this.urlParam);
479
+ let e = m(this.loc(), this.urlParam);
412
480
  if (!e) return;
413
481
  let t = this.slides.length ? this.slides : this.collect(), n = t.findIndex((t) => t.id === e);
414
482
  if (n < 0) return;
415
483
  this.slides = t, this.index = n, this.trigger = t[n]?.el ?? null, this.measure();
416
- let r = p(location.hash);
484
+ let r = h(location.hash);
417
485
  this.writeParam(null, "replace", r), this.historyPushed = this.writeParam(e, "push", r), this.open = !0;
418
486
  }
419
487
  step(e) {
@@ -436,7 +504,7 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
436
504
  this.dismissing = !0;
437
505
  try {
438
506
  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)));
507
+ 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
508
  } finally {
441
509
  this.dismissing = !1;
442
510
  }
@@ -444,7 +512,7 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
444
512
  }
445
513
  writeParam(e, t, n) {
446
514
  if (!this.urlParam) return !1;
447
- let r = m(this.loc(), this.urlParam, e, n);
515
+ let r = g(this.loc(), this.urlParam, e, n);
448
516
  if (r === location.pathname + location.search + location.hash) return !1;
449
517
  let i = history.state && typeof history.state == "object" ? history.state : {};
450
518
  try {
@@ -584,8 +652,30 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
584
652
  get statusText() {
585
653
  return this.open ? this.status === "loading" ? "Loading image." : this.status === "error" ? "This image could not be loaded." : "" : "";
586
654
  }
655
+ renderImage(e, t, n) {
656
+ let i = r`<img
657
+ part="image"
658
+ slot=${n ? "image" : o}
659
+ alt=${e.alt}
660
+ src=${t}
661
+ aria-busy=${this.status === "loading" ? "true" : "false"}
662
+ @load=${this.onLoad}
663
+ @error=${this.onError}
664
+ />`;
665
+ return n ? r`<uvalib-image-regions
666
+ class="regions"
667
+ part="regions"
668
+ .items=${n}
669
+ label=${O(this.regionsLabel) || "Regions"}
670
+ image-width=${e.imageWidth ?? o}
671
+ image-height=${e.imageHeight ?? o}
672
+ ?hide-outlines=${!this.showRegions}
673
+ ?no-style=${this.noStyle}
674
+ >${i}</uvalib-image-regions
675
+ >` : i;
676
+ }
587
677
  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;
678
+ 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 = this.multiple ? r`<p class="count" aria-live="polite">${this.index + 1} of ${this.slides.length}</p>` : o;
589
679
  return r`
590
680
  ${this.isLight ? o : r`<slot></slot><slot name="details" hidden></slot>`}
591
681
  <dialog
@@ -602,23 +692,22 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
602
692
  Close
603
693
  </button>
604
694
  </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>
695
+ <figure class="figure">${t ? this.renderImage(e, t, a) : o}</figure>
615
696
  <p class="status ${i ? "" : "visually-hidden"}" role="status">${i}</p>
616
697
  <div class="toolbar" part="controls">
698
+ ${a && t ? r`<button
699
+ type="button"
700
+ class="regions-toggle"
701
+ aria-pressed=${this.showRegions ? "true" : "false"}
702
+ @click=${this.toggleRegions}
703
+ >
704
+ Show regions
705
+ </button>` : o}
617
706
  ${this.multiple ? r`<button type="button" class="prev" @click=${() => this.step(-1)}>
618
707
  Previous
619
708
  </button>
620
709
  <button type="button" class="next" @click=${() => this.step(1)}>Next</button>
621
- ${a}` : o}
710
+ ${s}` : o}
622
711
  ${n ? r`<a
623
712
  class="full"
624
713
  href=${n}
@@ -635,6 +724,6 @@ var T = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), E = (e) => `
635
724
  }
636
725
  };
637
726
  // 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);
727
+ a([e({ type: String })], P.prototype, "selector", void 0), a([e({ attribute: "url-param" })], P.prototype, "urlParam", void 0), a([e({ attribute: !1 })], P.prototype, "regions", void 0), a([e({ attribute: "regions-label" })], P.prototype, "regionsLabel", void 0), a([n()], P.prototype, "slides", void 0), a([n()], P.prototype, "index", void 0), a([n()], P.prototype, "open", void 0), a([n()], P.prototype, "status", void 0), a([n()], P.prototype, "fitW", void 0), a([n()], P.prototype, "fitH", void 0), a([n()], P.prototype, "showRegions", void 0), i("uvalib-lightbox", P);
639
728
 
640
729
  //# sourceMappingURL=uvalib-lightbox.js.map