@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
@@ -0,0 +1,156 @@
1
+ import { a as e, d as t, f as n, i as r, l as i, m as a, n as o, t as s } from "./chunks/UvalibElement-pGONDAwB.js";
2
+ import { a as c } from "./chunks/analytics-DTTihuBD.js";
3
+ // src/components/uvalib-back-to-top/UvalibBackToTop.ts
4
+ var l = "uvalib-back-to-top", u = "Back to top", d = 400, f = "a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]", p = (e) => (e ?? "").replace(/\s+/g, " ").trim(), m = t`<svg class="btt-icon" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" focusable="false"><path d="M8 2.5 2.5 8l1.4 1.4L7 6.3V14h2V6.3l3.1 3.1L13.5 8z" fill="currentColor"/></svg>`, h = class extends s {
5
+ constructor(...e) {
6
+ super(...e), this.label = u, this.offset = d, this.target = "", this.shown = !1, this.docked = !1, this.onClick = () => {
7
+ let e = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
8
+ window.scrollTo({
9
+ top: 0,
10
+ behavior: e ? "auto" : "smooth"
11
+ }), this.focusTarget(), c(this, [l, "click"]);
12
+ };
13
+ }
14
+ static {
15
+ this.styles = n`
16
+ :host {
17
+ display: flex;
18
+ justify-content: flex-end;
19
+ align-items: center;
20
+ box-sizing: border-box;
21
+ block-size: var(--uvalib-back-to-top-space, 4.75rem);
22
+ padding-block: 1rem;
23
+ }
24
+ :host([hidden]) {
25
+ display: none;
26
+ }
27
+ .btt-button {
28
+ position: fixed;
29
+ inset-inline-end: max(1rem, env(safe-area-inset-right));
30
+ inset-block-end: max(1rem, env(safe-area-inset-bottom));
31
+ z-index: 20;
32
+ display: inline-flex;
33
+ align-items: center;
34
+ gap: 0.4rem;
35
+ box-sizing: border-box;
36
+ min-block-size: 44px;
37
+ min-inline-size: 44px;
38
+ margin: 0;
39
+ padding: 0.5rem 1rem;
40
+ border: 2px solid var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));
41
+ border-radius: 5px;
42
+ background: var(--uva-color-surface-raised, #fff);
43
+ color: var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));
44
+ box-shadow: 0 2px 6px var(--uva-color-shadow, rgb(0 0 0 / 0.2));
45
+ font: inherit;
46
+ font-size: 1rem;
47
+ line-height: 1.2;
48
+ white-space: nowrap;
49
+ cursor: pointer;
50
+ visibility: hidden;
51
+ opacity: 0;
52
+ }
53
+ .btt-button:dir(rtl) {
54
+ inset-inline-end: max(1rem, env(safe-area-inset-left));
55
+ }
56
+ .btt-button.shown {
57
+ visibility: visible;
58
+ opacity: 1;
59
+ }
60
+ .btt-button.docked {
61
+ position: static;
62
+ box-shadow: none;
63
+ }
64
+ .btt-button:hover {
65
+ border-color: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));
66
+ color: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));
67
+ }
68
+ .btt-button:focus-visible {
69
+ outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));
70
+ outline-offset: 2px;
71
+ }
72
+ .btt-icon {
73
+ flex: none;
74
+ }
75
+ @media (prefers-reduced-motion: no-preference) {
76
+ .btt-button {
77
+ transition:
78
+ opacity 0.2s,
79
+ visibility 0.2s;
80
+ }
81
+ }
82
+ @media (forced-colors: active) {
83
+ .btt-button {
84
+ border-color: ButtonText;
85
+ background: ButtonFace;
86
+ color: ButtonText;
87
+ }
88
+ }
89
+ @media print {
90
+ :host {
91
+ display: none;
92
+ }
93
+ }
94
+ `;
95
+ }
96
+ get button() {
97
+ return this.renderRoot.querySelector("button.btt-button");
98
+ }
99
+ get px() {
100
+ let e = Number(this.offset);
101
+ return Number.isFinite(e) && e > 0 ? e : d;
102
+ }
103
+ connectedCallback() {
104
+ super.connectedCallback();
105
+ let e = this.ownerDocument, t = this.sentinel ??= e.createElement("div");
106
+ t.setAttribute("aria-hidden", "true"), t.dataset.uvalibBackToTop = "", t.style.cssText = `position:absolute;top:0;left:0;width:1px;height:${this.px}px;margin:0;padding:0;border:0;pointer-events:none;visibility:hidden`, e.body.append(t), this.topObserver = new IntersectionObserver((e) => {
107
+ let t = e[e.length - 1];
108
+ t && this.setShown(!t.isIntersecting);
109
+ }), this.topObserver.observe(t), this.dockObserver = new IntersectionObserver((e) => {
110
+ let t = e[e.length - 1];
111
+ t && (this.docked = t.intersectionRatio >= .99);
112
+ }, { threshold: [
113
+ 0,
114
+ .99,
115
+ 1
116
+ ] }), this.dockObserver.observe(this);
117
+ }
118
+ disconnectedCallback() {
119
+ super.disconnectedCallback(), this.topObserver?.disconnect(), this.dockObserver?.disconnect(), this.sentinel?.remove();
120
+ }
121
+ willUpdate(e) {
122
+ e.has("offset") && this.sentinel && (this.sentinel.style.height = `${this.px}px`);
123
+ }
124
+ setShown(e) {
125
+ if (e === this.shown) return;
126
+ let t = this.button, n = !!t && (this.renderRoot instanceof ShadowRoot ? this.renderRoot.activeElement === t : document.activeElement === t);
127
+ this.shown = e, !e && n && this.focusTarget();
128
+ }
129
+ findTarget() {
130
+ let e = this.ownerDocument, t = p(this.target);
131
+ if (t) try {
132
+ let n = e.querySelector(t);
133
+ if (n) return n;
134
+ } catch {}
135
+ return e.querySelector("main h1") ?? e.querySelector("h1") ?? e.getElementById("top");
136
+ }
137
+ focusTarget() {
138
+ let e = this.findTarget();
139
+ e && (e.matches(f) || e.setAttribute("tabindex", "-1"), e.focus({ preventScroll: !0 }));
140
+ }
141
+ render() {
142
+ let e = p(this.label) || u;
143
+ return i`<button
144
+ type="button"
145
+ class="btt-button ${this.shown ? "shown" : ""} ${this.docked ? "docked" : ""}"
146
+ part="button"
147
+ @click=${this.onClick}
148
+ >
149
+ ${m}<span>${e}</span>
150
+ </button>`;
151
+ }
152
+ };
153
+ // src/components/uvalib-back-to-top/uvalib-back-to-top.ts
154
+ o([e({ type: String })], h.prototype, "label", void 0), o([e({ type: Number })], h.prototype, "offset", void 0), o([e({ type: String })], h.prototype, "target", void 0), o([r()], h.prototype, "shown", void 0), o([r()], h.prototype, "docked", void 0), a("uvalib-back-to-top", h);
155
+
156
+ //# sourceMappingURL=uvalib-back-to-top.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uvalib-back-to-top.js","names":["_decorate","property","state","n","w","i","b","define","__decorate","UvalibElement","trackEvent","TAG","DEFAULT_LABEL","DEFAULT_OFFSET","FOCUSABLE","squash","s","arrow","UvalibBackToTop","_args","reduce","doc","sentinel","last","entries","changed","shown","button","focused","sel","el","label"],"sources":["../src/components/uvalib-back-to-top/UvalibBackToTop.ts","../src/components/uvalib-back-to-top/uvalib-back-to-top.ts"],"sourcesContent":["import { css, html, svg, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\n\nconst TAG = 'uvalib-back-to-top';\nconst DEFAULT_LABEL = 'Back to top';\nconst DEFAULT_OFFSET = 400;\n/** Natively focusable: no tabindex needed to take focus. */\nconst FOCUSABLE =\n 'a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]';\n\nconst squash = (s: string | null | undefined) => (s ?? '').replace(/\\s+/g, ' ').trim();\n\nconst arrow = svg`<svg class=\"btt-icon\" viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M8 2.5 2.5 8l1.4 1.4L7 6.3V14h2V6.3l3.1 3.1L13.5 8z\" fill=\"currentColor\"/></svg>`;\n\n/**\n * A “Back to top” button for long pages: minutes, finding aids, transcriptions, long result\n * lists.\n *\n * It stays hidden (`visibility: hidden`, so it is neither a tab stop nor in the accessibility\n * tree) until the top `offset` pixels of the page (default 400) have scrolled out of view,\n * watched with an IntersectionObserver on a small sentinel at the top of the page, never a\n * scroll listener. If it has focus as it hides, focus moves to the target. Activating it\n * scrolls to the top (smoothly unless the visitor prefers reduced motion) and moves focus to\n * the page's `<h1>` (the first in `<main>`, else the first anywhere, else `#top`), or to\n * `target` (a selector), adding `tabindex=\"-1\"` when it is not focusable, so keyboard and\n * screen reader users land at the top too.\n *\n * The button is fixed in the bottom corner (end side), inside the safe-area insets. The\n * element itself is an empty block 4.75rem tall: put it last in the page's main content and\n * that is the space the button needs, so the last lines can always scroll clear of it. When\n * that space comes into view the button sits in it instead of floating, so it never covers\n * the footer either. It is hidden in print.\n *\n * @tagname uvalib-back-to-top\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-back-to-top', 'click']` when activated. Bubbles and is composed.\n * @csspart button - The button.\n * @cssprop [--uvalib-back-to-top-space=4.75rem] - The height the element keeps for the button at the end of the content.\n * @cssprop --uva-color-surface-raised - Dark-mode role token: button background (else #fff).\n * @cssprop --uva-color-button-bg - Dark-mode role token: button border and text (else `--uva-blue-alt`, #007bac).\n * @cssprop --uva-color-button-hover-bg - Dark-mode role token: hovered button (else `--uva-blue-alt-A`, #005679).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-shadow - Dark-mode role token: the floating button's shadow.\n */\nexport class UvalibBackToTop extends UvalibElement {\n static styles = css`\n :host {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n box-sizing: border-box;\n block-size: var(--uvalib-back-to-top-space, 4.75rem);\n padding-block: 1rem;\n }\n :host([hidden]) {\n display: none;\n }\n .btt-button {\n position: fixed;\n inset-inline-end: max(1rem, env(safe-area-inset-right));\n inset-block-end: max(1rem, env(safe-area-inset-bottom));\n z-index: 20;\n display: inline-flex;\n align-items: center;\n gap: 0.4rem;\n box-sizing: border-box;\n min-block-size: 44px;\n min-inline-size: 44px;\n margin: 0;\n padding: 0.5rem 1rem;\n border: 2px solid var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));\n border-radius: 5px;\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-button-bg, var(--uva-blue-alt, #007bac));\n box-shadow: 0 2px 6px var(--uva-color-shadow, rgb(0 0 0 / 0.2));\n font: inherit;\n font-size: 1rem;\n line-height: 1.2;\n white-space: nowrap;\n cursor: pointer;\n visibility: hidden;\n opacity: 0;\n }\n .btt-button:dir(rtl) {\n inset-inline-end: max(1rem, env(safe-area-inset-left));\n }\n .btt-button.shown {\n visibility: visible;\n opacity: 1;\n }\n .btt-button.docked {\n position: static;\n box-shadow: none;\n }\n .btt-button:hover {\n border-color: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));\n color: var(--uva-color-button-hover-bg, var(--uva-blue-alt-A, #005679));\n }\n .btt-button:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n .btt-icon {\n flex: none;\n }\n @media (prefers-reduced-motion: no-preference) {\n .btt-button {\n transition:\n opacity 0.2s,\n visibility 0.2s;\n }\n }\n @media (forced-colors: active) {\n .btt-button {\n border-color: ButtonText;\n background: ButtonFace;\n color: ButtonText;\n }\n }\n @media print {\n :host {\n display: none;\n }\n }\n `;\n\n /** The button's text. */\n @property({ type: String }) label = DEFAULT_LABEL;\n\n /** How many pixels at the top of the page must scroll out of view before the button shows. */\n @property({ type: Number }) offset = DEFAULT_OFFSET;\n\n /** A selector for where focus goes (default: the page's `<h1>`, else `#top`). */\n @property({ type: String }) target = '';\n\n /** Whether the top of the page has scrolled out of view. */\n @state() private shown = false;\n\n /** Whether the element's own space is fully in view (the button sits in it). */\n @state() private docked = false;\n\n private sentinel?: HTMLDivElement;\n private topObserver?: IntersectionObserver;\n private dockObserver?: IntersectionObserver;\n\n private get button(): HTMLButtonElement | null {\n return (this.renderRoot as ParentNode).querySelector<HTMLButtonElement>('button.btt-button');\n }\n\n private get px(): number {\n const n = Number(this.offset);\n return Number.isFinite(n) && n > 0 ? n : DEFAULT_OFFSET;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const doc = this.ownerDocument;\n const sentinel = (this.sentinel ??= doc.createElement('div'));\n sentinel.setAttribute('aria-hidden', 'true');\n sentinel.dataset.uvalibBackToTop = '';\n sentinel.style.cssText = `position:absolute;top:0;left:0;width:1px;height:${this.px}px;margin:0;padding:0;border:0;pointer-events:none;visibility:hidden`;\n doc.body.append(sentinel);\n this.topObserver = new IntersectionObserver((entries) => {\n const last = entries[entries.length - 1];\n if (last) this.setShown(!last.isIntersecting);\n });\n this.topObserver.observe(sentinel);\n this.dockObserver = new IntersectionObserver(\n (entries) => {\n const last = entries[entries.length - 1];\n if (last) this.docked = last.intersectionRatio >= 0.99;\n },\n { threshold: [0, 0.99, 1] },\n );\n this.dockObserver.observe(this);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.topObserver?.disconnect();\n this.dockObserver?.disconnect();\n this.sentinel?.remove();\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('offset') && this.sentinel) this.sentinel.style.height = `${this.px}px`;\n }\n\n private setShown(shown: boolean): void {\n if (shown === this.shown) return;\n const button = this.button;\n const focused =\n !!button &&\n (this.renderRoot instanceof ShadowRoot\n ? this.renderRoot.activeElement === button\n : document.activeElement === button);\n this.shown = shown;\n if (!shown && focused) this.focusTarget();\n }\n\n /** Where focus goes: `target`, else the page's `<h1>`, else `#top`. */\n private findTarget(): HTMLElement | null {\n const doc = this.ownerDocument;\n const sel = squash(this.target);\n if (sel) {\n try {\n const el = doc.querySelector<HTMLElement>(sel);\n if (el) return el;\n } catch {\n // Not a valid selector: fall back to the heading.\n }\n }\n return (\n doc.querySelector<HTMLElement>('main h1') ??\n doc.querySelector<HTMLElement>('h1') ??\n doc.getElementById('top')\n );\n }\n\n private focusTarget(): void {\n const el = this.findTarget();\n if (!el) return;\n if (!el.matches(FOCUSABLE)) el.setAttribute('tabindex', '-1');\n el.focus({ preventScroll: true });\n }\n\n private readonly onClick = (): void => {\n const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n window.scrollTo({ top: 0, behavior: reduce ? 'auto' : 'smooth' });\n this.focusTarget();\n trackEvent(this, [TAG, 'click']);\n };\n\n protected override render() {\n const label = squash(this.label) || DEFAULT_LABEL;\n return html`<button\n type=\"button\"\n class=\"btt-button ${this.shown ? 'shown' : ''} ${this.docked ? 'docked' : ''}\"\n part=\"button\"\n @click=${this.onClick}\n >\n ${arrow}<span>${label}</span>\n </button>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibBackToTop } from './UvalibBackToTop.js';\n\ndefine('uvalib-back-to-top', UvalibBackToTop);\n"],"mappings":";;;AAKA,IAAMW,IAAM,sBACNC,IAAgB,eAChBC,IAAiB,KAEjBC,IACJ,oFAEIC,KAAU,OAAkCC,KAAK,GAAA,CAAI,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK,GAE/EC,IAAQ,CAAG,mMA+BJC,IAAb,cAAqCT,EAAc;;EAsLV,A,aAnGH,KAAA,QAAAG,GAGC,KAAA,SAAAC,GAGA,KAAA,SAAA,IAGZ,KAAA,QAAA,IAGC,KAAA,SAAA,IAuFa,KAAA,gBAAA;GACrC,IAAMO,IAAS,OAAO,WAAW,kCAAkC,CAAC,CAAC;GAGrE,AAFA,OAAO,SAAS;IAAE,KAAK;IAAG,UAAUA,IAAS,SAAS;GAAS,CAAC,GAChE,KAAK,YAAY,GACjBV,EAAW,MAAM,CAACC,GAAK,OAAO,CAAC;EACjC;;;EA1LgB,KAAA,SAAA,CAAG;;;;;;;;;;;;;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AAA,UAAA,KAAA,CAAA,GCzITX,EAAO,sBAAsBW,CAAe"}
@@ -1,6 +1,6 @@
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";
3
+ import { t as d } from "./chunks/accessible-DJv7YOtS.js";
4
4
  // src/components/uvalib-breadcrumbs/UvalibBreadcrumbs.ts
5
5
  var f = "Breadcrumb", p = (e) => `
6
6
  ${e} { display: block; }
@@ -10,7 +10,7 @@ var f = "Breadcrumb", p = (e) => `
10
10
  ${e}[hidden], ${e} [hidden] { display: none !important; }
11
11
  `, m = s(p(":host")), h = {
12
12
  attributes: !0,
13
- attributeFilter: ["href"],
13
+ attributeFilter: ["href", "data-return-from"],
14
14
  characterData: !0,
15
15
  childList: !0,
16
16
  subtree: !0
@@ -19,7 +19,22 @@ var f = "Breadcrumb", p = (e) => `
19
19
  "https:",
20
20
  "mailto:",
21
21
  "tel:"
22
- ]), _ = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), v = class extends l {
22
+ ]), _ = (e) => String(e ?? "").replace(/\s+/g, " ").trim(), v = (e) => e.replace(/\/index\.html?$/i, "/").replace(/(.)\/$/, "$1") || "/";
23
+ function y(e, t, n, r = new URL(n).origin) {
24
+ let i = _(e).split(" ").filter(Boolean);
25
+ if (i.length && t) try {
26
+ let e = new URL(t);
27
+ if (e.origin !== r || e.search.length < 2) return;
28
+ let a = v(e.pathname);
29
+ return i.some((e) => {
30
+ let t = new URL(e, n);
31
+ return t.origin === r && v(t.pathname) === a;
32
+ }) ? e.pathname + e.search + e.hash : void 0;
33
+ } catch {
34
+ return;
35
+ }
36
+ }
37
+ var b = class extends l {
23
38
  constructor(...e) {
24
39
  super(...e), this.label = "Breadcrumb", this.childItems = [], this.warned = !1, this.warnedHref = !1, this.own = /* @__PURE__ */ new WeakSet();
25
40
  }
@@ -98,11 +113,11 @@ var f = "Breadcrumb", p = (e) => `
98
113
  n = !0;
99
114
  continue;
100
115
  }
101
- let i = r instanceof HTMLAnchorElement ? r.getAttribute("href") : null;
102
- t.push(i === null ? { label: e } : {
116
+ let i = r instanceof HTMLAnchorElement ? r.getAttribute("href") : null, a = i === null ? { label: e } : {
103
117
  label: e,
104
118
  href: i
105
- });
119
+ }, o = r.getAttribute("data-return-from");
120
+ o !== null && i !== null && (a.returnFrom = o), t.push(a);
106
121
  }
107
122
  n && this.warn(), JSON.stringify(t) !== JSON.stringify(this.childItems) && (this.childItems = t);
108
123
  }
@@ -110,10 +125,15 @@ var f = "Breadcrumb", p = (e) => `
110
125
  this.observer ??= new MutationObserver(() => this.sync()), this.observer.disconnect(), this.lightDom ? (this.observer.observe(this, { childList: !0 }), this.holder && this.observer.observe(this.holder, h)) : this.observer.observe(this, h);
111
126
  }
112
127
  get trail() {
113
- return (this.items ? this.items.filter((e) => _(e?.label)).map((e) => ({
128
+ let e = this.items ? this.items.filter((e) => _(e?.label)).map((e) => ({
114
129
  label: _(e.label),
115
- href: e.href ?? void 0
116
- })) : this.childItems).map((e) => e.href === void 0 || this.safe(e.href) ? e : { label: e.label });
130
+ href: e.href ?? void 0,
131
+ returnFrom: e.href == null ? void 0 : e.returnFrom ?? void 0
132
+ })) : this.childItems, t = this.ownerDocument, n = t.defaultView?.location.origin;
133
+ return e.map(({ label: e, href: r, returnFrom: i }) => r === void 0 || !this.safe(r) ? { label: e } : {
134
+ label: e,
135
+ href: (i && n ? y(i, t.referrer, t.baseURI, n) : void 0) ?? r
136
+ });
117
137
  }
118
138
  safe(e) {
119
139
  let t = !1;
@@ -171,6 +191,6 @@ var f = "Breadcrumb", p = (e) => `
171
191
  }
172
192
  };
173
193
  // src/components/uvalib-breadcrumbs/uvalib-breadcrumbs.ts
174
- a([e({ type: String })], v.prototype, "label", void 0), a([e({ attribute: !1 })], v.prototype, "items", void 0), a([n()], v.prototype, "childItems", void 0), i("uvalib-breadcrumbs", v);
194
+ a([e({ type: String })], b.prototype, "label", void 0), a([e({ attribute: !1 })], b.prototype, "items", void 0), a([n()], b.prototype, "childItems", void 0), i("uvalib-breadcrumbs", b);
175
195
 
176
196
  //# sourceMappingURL=uvalib-breadcrumbs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uvalib-breadcrumbs.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","accessible","DEFAULT_LABEL","structuralRules","host","shadowStructure","CONTENT","SAFE_SCHEMES","normalize","s","UvalibBreadcrumbs","_args","root","sheet","node","changed","items","incoming","sources","invalid","label","href","ok","step","level","a","links","go","trail","last","current","item","A"],"sources":["../src/components/uvalib-breadcrumbs/UvalibBreadcrumbs.ts","../src/components/uvalib-breadcrumbs/uvalib-breadcrumbs.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** One step of the trail: its visible text and, except perhaps for the current page, a link. */\nexport interface BreadcrumbItem {\n label: string;\n href?: string;\n}\n\nconst DEFAULT_LABEL = 'Breadcrumb';\n\n/**\n * The rules kept with `no-style`: the list is a plain inline run (no bullets, no indent) that\n * wraps like text, the separators keep their spacing, and `[hidden]` hides. `host` is `:host`\n * (shadow) or the tag name (light DOM, so they stay scoped).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} ol { list-style: none; margin: 0; padding: 0; }\n ${host} li { display: inline; }\n ${host} .separator { margin-inline-end: 0.3em; }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/** What the observer watches in the author's trail: the links, their hrefs and text. */\nconst CONTENT: MutationObserverInit = {\n attributes: true,\n attributeFilter: ['href'],\n characterData: true,\n childList: true,\n subtree: true,\n};\n\n/** Schemes a breadcrumb may link to; anything else (javascript:, data:, …) is shown as text. */\nconst SAFE_SCHEMES = new Set(['http:', 'https:', 'mailto:', 'tel:']);\n\nconst normalize = (s: unknown) =>\n String(s ?? '')\n .replace(/\\s+/g, ' ')\n .trim();\n\n/**\n * A breadcrumb trail, as on library.virginia.edu: links separated by slashes, ending with the\n * current page, at body size. A `<nav aria-label=\"Breadcrumb\">` holding an `<ol>`; the\n * separators are hidden from assistive technology and the last item has\n * `aria-current=\"page\"` (a `<span>`, or a link when it has an href).\n *\n * Give the trail as children: `<a href>` elements, ending with the current page as a\n * text-only element (`<span>Hours</span>`) or a link (`<a href aria-current=\"page\">`).\n * The last child is always the current page. An earlier child without an href is shown as\n * plain text. Children with no text are skipped with one console warning. Hrefs are used as\n * written, and the trail follows changes to the children (attributes and text too).\n *\n * Apps that build the trail in JavaScript set the `items` property instead (it then wins\n * over any children); assigning a new array re-renders.\n *\n * Inside `<site-page>`, give it `slot=\"breadcrumbs\"`: it is placed between the header (and\n * alerts band) and `<main>`, with the page's gutters. It works anywhere else too.\n *\n * Single-page apps: the trail is drawn from copies of the children, so a router's own click\n * handlers on them do not run. Listen for `uvalib-breadcrumbs-navigate` and cancel it to route\n * in place; hash links need nothing.\n *\n * @tagname uvalib-breadcrumbs\n * @fires uvalib-analytics-event - For `<site-analytics>`: a click on a trail link, `['uvalib-breadcrumbs', 'link-click', 'level <N>', <N>]` (N from 1, the first step); never the label or URL. Bubbles and is composed.\n * @fires uvalib-breadcrumbs-navigate - A plain click on a trail link: `detail` is `{ href, index }` (href as written). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed.\n * @cssprop [--uva-blue-alt-dark=#005679] - Link colour.\n * @cssprop [--uva-grey-darkest=#2b2b2b] - Current page colour.\n * @cssprop [--uva-grey-dark=#4f4f4f] - Separator colour.\n * @cssprop --uva-color-utility-link - Dark-mode role token: link colour, #005679 in light as on library.virginia.edu (else `--uva-blue-alt-dark`).\n * @cssprop --uva-color-text - Dark-mode role token: current page colour (else `--uva-grey-darkest`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: separator colour (else `--uva-grey-dark`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibBreadcrumbs extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n font-size: 1rem;\n line-height: 1.5;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n overflow-wrap: anywhere;\n }\n a {\n color: var(--uva-color-utility-link, var(--uva-blue-alt-dark, #005679));\n text-decoration: underline;\n }\n a[aria-current='page'] {\n color: inherit;\n }\n .separator {\n color: var(--uva-color-text-muted, var(--uva-grey-dark, #4f4f4f));\n }\n `,\n ];\n\n /** Accessible name of the navigation landmark. */\n @property({ type: String }) label = 'Breadcrumb';\n\n /**\n * The trail as data, for apps that build it in JavaScript: `{ label, href? }` objects, the\n * last one the current page. Wins over the children while set; `undefined` goes back to\n * them. Entries without a label are skipped with one console warning.\n */\n @property({ attribute: false }) items?: BreadcrumbItem[];\n\n /** The trail read from the children. */\n @state() private childItems: BreadcrumbItem[] = [];\n private warned = false;\n private warnedHref = false;\n private observer?: MutationObserver;\n /** Light mode: the hidden container this element owns for the author's children. */\n private holder?: HTMLDivElement;\n /** Light mode: nodes this element rendered itself (incl. Lit markers), never adopted. */\n private own = new WeakSet<Node>();\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n // Read before the first render, so it costs no second update.\n this.sync();\n if (this.hasUpdated) this.watch();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n protected override firstUpdated(): void {\n if (this.lightDom) for (const n of this.childNodes) if (n !== this.holder) this.own.add(n);\n this.sync();\n this.watch();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('items') && this.items) this.check(this.items);\n }\n\n private warn(): void {\n if (this.warned) return;\n this.warned = true;\n console.warn(\n `${this.localName}: ignoring breadcrumbs with no text (each needs a label; give the trail as <a href> children ending with the current page, or set items).`,\n );\n }\n\n /** Warn about `items` entries that cannot be shown. */\n private check(items: readonly BreadcrumbItem[]): void {\n if (items.some((i) => !normalize(i?.label))) this.warn();\n }\n\n /** Light mode has no slots: move the author's children into the hidden holder. */\n private adopt(): Node[] {\n const incoming = [...this.childNodes].filter((n) => n !== this.holder && !this.own.has(n));\n if (incoming.length && !this.holder) {\n this.holder = this.ownerDocument.createElement('div');\n this.holder.hidden = true;\n this.holder.className = 'breadcrumbs-source';\n // Created after watch() ran (children added later): watch it too.\n if (this.observer && this.hasUpdated) this.observer.observe(this.holder, CONTENT);\n }\n if (this.holder) {\n this.holder.append(...incoming);\n if (this.holder.parentNode !== this) this.prepend(this.holder);\n }\n return this.holder ? [...this.holder.childNodes] : [];\n }\n\n /** Read the trail from the children. */\n private sync(): void {\n const sources = this.lightDom ? this.adopt() : [...this.childNodes];\n const items: BreadcrumbItem[] = [];\n let invalid = false;\n for (const n of sources) {\n if (n.nodeType === Node.TEXT_NODE) {\n if (normalize(n.textContent)) invalid = true;\n continue;\n }\n if (!(n instanceof Element)) continue;\n const label = normalize(n.textContent);\n if (!label) {\n invalid = true;\n continue;\n }\n const href = n instanceof HTMLAnchorElement ? n.getAttribute('href') : null;\n items.push(href === null ? { label } : { label, href });\n }\n if (invalid) this.warn();\n // Only a real change re-renders.\n if (JSON.stringify(items) !== JSON.stringify(this.childItems)) this.childItems = items;\n }\n\n /**\n * Shadow mode: the observer watches the children, their attributes and text. Light mode:\n * the host for new children and the holder for everything inside it.\n */\n private watch(): void {\n this.observer ??= new MutationObserver(() => this.sync());\n this.observer.disconnect();\n if (this.lightDom) {\n this.observer.observe(this, { childList: true });\n if (this.holder) this.observer.observe(this.holder, CONTENT);\n } else {\n this.observer.observe(this, CONTENT);\n }\n }\n\n /** What is shown: `items` while set, else the children; entries without a label left out. */\n private get trail(): BreadcrumbItem[] {\n const items = this.items\n ? this.items\n .filter((i) => normalize(i?.label))\n .map((i) => ({ label: normalize(i.label), href: i.href ?? undefined }))\n : this.childItems;\n return items.map((i) => (i.href === undefined || this.safe(i.href) ? i : { label: i.label }));\n }\n\n /**\n * Whether `href` may be a link: relative, hash and http(s), mailto and tel URLs are kept as\n * written; any other scheme (javascript:, data:, …) makes the step plain text, with a warning.\n */\n private safe(href: string): boolean {\n let ok = false;\n try {\n ok = SAFE_SCHEMES.has(new URL(href, this.ownerDocument.baseURI).protocol);\n } catch {\n ok = false;\n }\n if (!ok && !this.warnedHref) {\n this.warnedHref = true;\n console.warn(\n `${this.localName}: showing a breadcrumb as text: its href is not http(s), mailto, tel or relative.`,\n );\n }\n return ok;\n }\n\n /**\n * A plain click on a trail link fires a cancelable `uvalib-breadcrumbs-navigate`; a router\n * that cancels it navigates itself (the click's default is prevented too).\n */\n private onClick(e: MouseEvent): void {\n // Analytics: the link's level in the trail (1 is the first), never its label or URL.\n const step = (e.target as Element | null)?.closest?.('a[href]')?.closest('li');\n if (step && this.renderRoot.contains(step)) {\n const level = [...step.parentNode!.children].indexOf(step) + 1;\n trackEvent(this, ['uvalib-breadcrumbs', 'link-click', `level ${level}`, level]);\n }\n if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)\n return;\n const a = (e.target as Element | null)?.closest?.('a[href]');\n if (!a || !this.renderRoot.contains(a)) return;\n const links = [...this.renderRoot.querySelectorAll('nav a[href]')];\n const go = new CustomEvent('uvalib-breadcrumbs-navigate', {\n detail: { href: a.getAttribute('href'), index: links.indexOf(a) },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n // Lets <site-page> drop the trail's gutter while it shows nothing.\n this.toggleAttribute('data-empty', !this.trail.length);\n }\n\n protected override render() {\n const trail = this.trail;\n const last = trail.length - 1;\n // role=\"list\": Safari drops the list semantics of a list styled without markers.\n return html`<nav\n aria-label=${this.label || DEFAULT_LABEL}\n ?hidden=${!trail.length}\n @click=${this.onClick}\n >\n <ol role=\"list\">\n ${trail.map((item, i) => {\n const current = i === last ? 'page' : undefined;\n const step =\n item.href !== undefined\n ? html`<a href=${item.href} aria-current=${current ?? nothing}>${item.label}</a>`\n : html`<span aria-current=${current ?? nothing}>${item.label}</span>`;\n // The space before a separator is where a long trail wraps; the separator stays\n // with the item it introduces.\n return html`<li role=\"listitem\">\n ${i ? html` <span class=\"separator\" aria-hidden=\"true\">/</span>` : nothing}${step}\n </li>`;\n })}\n </ol>\n </nav>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibBreadcrumbs } from './UvalibBreadcrumbs.js';\n\ndefine('uvalib-breadcrumbs', UvalibBreadcrumbs);\n"],"mappings":";;;;AAaA,IAAMgB,IAAgB,cAOhBC,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;IACLA,EAAK;IACLA,EAAK;IACLA,EAAK,YAAYA,EAAK;GAEpBC,IAAkBnB,EAAUiB,EAAgB,OAAO,CAAC,GAGpDG,IAAgC;CACpC,YAAY;CACZ,iBAAiB,CAAC,MAAM;CACxB,eAAe;CACf,WAAW;CACX,SAAS;AACX,GAGMC,oBAAe,IAAI,IAAI;CAAC;CAAS;CAAU;CAAW;AA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CAAC,CAAA,GAAAqB,EAAA,WAAA,SAAA,KAAA,CAAA,GAG7BtB,EAAA,CAAAE,EAAM,CAAA,GAAAoB,EAAA,WAAA,cAAA,KAAA,CAAA,GC/GTf,EAAO,sBAAsBe,CAAiB"}
1
+ {"version":3,"file":"uvalib-breadcrumbs.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","accessible","DEFAULT_LABEL","structuralRules","host","shadowStructure","CONTENT","SAFE_SCHEMES","normalize","s","pathKey","p","returnHref","base","paths","returnFrom","referrer","from","origin","key","u","UvalibBreadcrumbs","_args","root","sheet","node","changed","items","incoming","sources","invalid","label","href","item","doc","ok","step","level","a","links","go","trail","last","current","A"],"sources":["../src/components/uvalib-breadcrumbs/UvalibBreadcrumbs.ts","../src/components/uvalib-breadcrumbs/uvalib-breadcrumbs.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** One step of the trail: its visible text and, except perhaps for the current page, a link. */\nexport interface BreadcrumbItem {\n label: string;\n href?: string;\n /**\n * The search page(s) this step returns to: a path, or several separated by spaces\n * (`data-return-from` on a child link). When the visitor came from one of them with a query\n * string, the step links back to that search.\n */\n returnFrom?: string;\n}\n\nconst DEFAULT_LABEL = 'Breadcrumb';\n\n/**\n * The rules kept with `no-style`: the list is a plain inline run (no bullets, no indent) that\n * wraps like text, the separators keep their spacing, and `[hidden]` hides. `host` is `:host`\n * (shadow) or the tag name (light DOM, so they stay scoped).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} ol { list-style: none; margin: 0; padding: 0; }\n ${host} li { display: inline; }\n ${host} .separator { margin-inline-end: 0.3em; }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/** What the observer watches in the author's trail: the links, their hrefs and text. */\nconst CONTENT: MutationObserverInit = {\n attributes: true,\n attributeFilter: ['href', 'data-return-from'],\n characterData: true,\n childList: true,\n subtree: true,\n};\n\n/** Schemes a breadcrumb may link to; anything else (javascript:, data:, …) is shown as text. */\nconst SAFE_SCHEMES = new Set(['http:', 'https:', 'mailto:', 'tel:']);\n\nconst normalize = (s: unknown) =>\n String(s ?? '')\n .replace(/\\s+/g, ' ')\n .trim();\n\n/** A comparable path: without `index.html` and a trailing slash (`/search/` is `/search`). */\nconst pathKey = (p: string) => p.replace(/\\/index\\.html?$/i, '/').replace(/(.)\\/$/, '$1') || '/';\n\n/**\n * The search the visitor came from, for a step with `returnFrom`: the referrer's path, query\n * and hash when it is on this site, at one of the given paths (resolved against `base`) and\n * has a query string; else undefined (`origin` is the page's). Nothing is stored or sent.\n */\nfunction returnHref(\n returnFrom: string | undefined,\n referrer: string,\n base: string,\n origin = new URL(base).origin,\n): string | undefined {\n const paths = normalize(returnFrom).split(' ').filter(Boolean);\n if (!paths.length || !referrer) return undefined;\n try {\n const from = new URL(referrer);\n if (from.origin !== origin || from.search.length < 2) return undefined;\n const key = pathKey(from.pathname);\n const match = paths.some((p) => {\n const u = new URL(p, base);\n return u.origin === origin && pathKey(u.pathname) === key;\n });\n return match ? from.pathname + from.search + from.hash : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * A breadcrumb trail, as on library.virginia.edu: links separated by slashes, ending with the\n * current page, at body size. A `<nav aria-label=\"Breadcrumb\">` holding an `<ol>`; the\n * separators are hidden from assistive technology and the last item has\n * `aria-current=\"page\"` (a `<span>`, or a link when it has an href).\n *\n * Give the trail as children: `<a href>` elements, ending with the current page as a\n * text-only element (`<span>Hours</span>`) or a link (`<a href aria-current=\"page\">`).\n * The last child is always the current page. An earlier child without an href is shown as\n * plain text. Children with no text are skipped with one console warning. Hrefs are used as\n * written, and the trail follows changes to the children (attributes and text too).\n *\n * Apps that build the trail in JavaScript set the `items` property instead (it then wins\n * over any children); assigning a new array re-renders.\n *\n * A step back to a search: give its link `data-return-from` with the search page's path (or\n * several, separated by spaces), as in `<a href=\"/\" data-return-from=\"/\">Search</a>`. When the\n * visitor came from that page on this site with a query string (`document.referrer`; a\n * trailing slash or `index.html` does not matter), the step links back to that search\n * (path and query) instead; its text stays the same. Otherwise, as when the result\n * was opened in a new tab or the site sends no referrer, it keeps its href. Nothing is\n * stored or sent. In `items`, the same is `returnFrom`.\n *\n * Inside `<site-page>`, give it `slot=\"breadcrumbs\"`: it is placed between the header (and\n * alerts band) and `<main>`, with the page's gutters. It works anywhere else too.\n *\n * Single-page apps: the trail is drawn from copies of the children, so a router's own click\n * handlers on them do not run. Listen for `uvalib-breadcrumbs-navigate` and cancel it to route\n * in place; hash links need nothing.\n *\n * @tagname uvalib-breadcrumbs\n * @fires uvalib-analytics-event - For `<site-analytics>`: a click on a trail link, `['uvalib-breadcrumbs', 'link-click', 'level <N>', <N>]` (N from 1, the first step); never the label or URL. Bubbles and is composed.\n * @fires uvalib-breadcrumbs-navigate - A plain click on a trail link: `detail` is `{ href, index }` (href as written). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed.\n * @cssprop [--uva-blue-alt-dark=#005679] - Link colour.\n * @cssprop [--uva-grey-darkest=#2b2b2b] - Current page colour.\n * @cssprop [--uva-grey-dark=#4f4f4f] - Separator colour.\n * @cssprop --uva-color-utility-link - Dark-mode role token: link colour, #005679 in light as on library.virginia.edu (else `--uva-blue-alt-dark`).\n * @cssprop --uva-color-text - Dark-mode role token: current page colour (else `--uva-grey-darkest`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: separator colour (else `--uva-grey-dark`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibBreadcrumbs extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n font-size: 1rem;\n line-height: 1.5;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n overflow-wrap: anywhere;\n }\n a {\n color: var(--uva-color-utility-link, var(--uva-blue-alt-dark, #005679));\n text-decoration: underline;\n }\n a[aria-current='page'] {\n color: inherit;\n }\n .separator {\n color: var(--uva-color-text-muted, var(--uva-grey-dark, #4f4f4f));\n }\n `,\n ];\n\n /** Accessible name of the navigation landmark. */\n @property({ type: String }) label = 'Breadcrumb';\n\n /**\n * The trail as data, for apps that build it in JavaScript: `{ label, href? }` objects, the\n * last one the current page. Wins over the children while set; `undefined` goes back to\n * them. Entries without a label are skipped with one console warning.\n */\n @property({ attribute: false }) items?: BreadcrumbItem[];\n\n /** The trail read from the children. */\n @state() private childItems: BreadcrumbItem[] = [];\n private warned = false;\n private warnedHref = false;\n private observer?: MutationObserver;\n /** Light mode: the hidden container this element owns for the author's children. */\n private holder?: HTMLDivElement;\n /** Light mode: nodes this element rendered itself (incl. Lit markers), never adopted. */\n private own = new WeakSet<Node>();\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n // Read before the first render, so it costs no second update.\n this.sync();\n if (this.hasUpdated) this.watch();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n protected override firstUpdated(): void {\n if (this.lightDom) for (const n of this.childNodes) if (n !== this.holder) this.own.add(n);\n this.sync();\n this.watch();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('items') && this.items) this.check(this.items);\n }\n\n private warn(): void {\n if (this.warned) return;\n this.warned = true;\n console.warn(\n `${this.localName}: ignoring breadcrumbs with no text (each needs a label; give the trail as <a href> children ending with the current page, or set items).`,\n );\n }\n\n /** Warn about `items` entries that cannot be shown. */\n private check(items: readonly BreadcrumbItem[]): void {\n if (items.some((i) => !normalize(i?.label))) this.warn();\n }\n\n /** Light mode has no slots: move the author's children into the hidden holder. */\n private adopt(): Node[] {\n const incoming = [...this.childNodes].filter((n) => n !== this.holder && !this.own.has(n));\n if (incoming.length && !this.holder) {\n this.holder = this.ownerDocument.createElement('div');\n this.holder.hidden = true;\n this.holder.className = 'breadcrumbs-source';\n // Created after watch() ran (children added later): watch it too.\n if (this.observer && this.hasUpdated) this.observer.observe(this.holder, CONTENT);\n }\n if (this.holder) {\n this.holder.append(...incoming);\n if (this.holder.parentNode !== this) this.prepend(this.holder);\n }\n return this.holder ? [...this.holder.childNodes] : [];\n }\n\n /** Read the trail from the children. */\n private sync(): void {\n const sources = this.lightDom ? this.adopt() : [...this.childNodes];\n const items: BreadcrumbItem[] = [];\n let invalid = false;\n for (const n of sources) {\n if (n.nodeType === Node.TEXT_NODE) {\n if (normalize(n.textContent)) invalid = true;\n continue;\n }\n if (!(n instanceof Element)) continue;\n const label = normalize(n.textContent);\n if (!label) {\n invalid = true;\n continue;\n }\n const href = n instanceof HTMLAnchorElement ? n.getAttribute('href') : null;\n const item: BreadcrumbItem = href === null ? { label } : { label, href };\n const from = n.getAttribute('data-return-from');\n if (from !== null && href !== null) item.returnFrom = from;\n items.push(item);\n }\n if (invalid) this.warn();\n // Only a real change re-renders.\n if (JSON.stringify(items) !== JSON.stringify(this.childItems)) this.childItems = items;\n }\n\n /**\n * Shadow mode: the observer watches the children, their attributes and text. Light mode:\n * the host for new children and the holder for everything inside it.\n */\n private watch(): void {\n this.observer ??= new MutationObserver(() => this.sync());\n this.observer.disconnect();\n if (this.lightDom) {\n this.observer.observe(this, { childList: true });\n if (this.holder) this.observer.observe(this.holder, CONTENT);\n } else {\n this.observer.observe(this, CONTENT);\n }\n }\n\n /** What is shown: `items` while set, else the children; entries without a label left out. */\n private get trail(): BreadcrumbItem[] {\n const items = this.items\n ? this.items\n .filter((i) => normalize(i?.label))\n .map((i) => ({\n label: normalize(i.label),\n href: i.href ?? undefined,\n returnFrom: i.href == null ? undefined : (i.returnFrom ?? undefined),\n }))\n : this.childItems;\n const doc = this.ownerDocument;\n const origin = doc.defaultView?.location.origin;\n return items.map(({ label, href, returnFrom }) => {\n if (href === undefined || !this.safe(href)) return { label };\n // A step back to the search: the same-origin search the visitor came from, if any.\n const back =\n returnFrom && origin\n ? returnHref(returnFrom, doc.referrer, doc.baseURI, origin)\n : undefined;\n return { label, href: back ?? href };\n });\n }\n\n /**\n * Whether `href` may be a link: relative, hash and http(s), mailto and tel URLs are kept as\n * written; any other scheme (javascript:, data:, …) makes the step plain text, with a warning.\n */\n private safe(href: string): boolean {\n let ok = false;\n try {\n ok = SAFE_SCHEMES.has(new URL(href, this.ownerDocument.baseURI).protocol);\n } catch {\n ok = false;\n }\n if (!ok && !this.warnedHref) {\n this.warnedHref = true;\n console.warn(\n `${this.localName}: showing a breadcrumb as text: its href is not http(s), mailto, tel or relative.`,\n );\n }\n return ok;\n }\n\n /**\n * A plain click on a trail link fires a cancelable `uvalib-breadcrumbs-navigate`; a router\n * that cancels it navigates itself (the click's default is prevented too).\n */\n private onClick(e: MouseEvent): void {\n // Analytics: the link's level in the trail (1 is the first), never its label or URL.\n const step = (e.target as Element | null)?.closest?.('a[href]')?.closest('li');\n if (step && this.renderRoot.contains(step)) {\n const level = [...step.parentNode!.children].indexOf(step) + 1;\n trackEvent(this, ['uvalib-breadcrumbs', 'link-click', `level ${level}`, level]);\n }\n if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)\n return;\n const a = (e.target as Element | null)?.closest?.('a[href]');\n if (!a || !this.renderRoot.contains(a)) return;\n const links = [...this.renderRoot.querySelectorAll('nav a[href]')];\n const go = new CustomEvent('uvalib-breadcrumbs-navigate', {\n detail: { href: a.getAttribute('href'), index: links.indexOf(a) },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n // Lets <site-page> drop the trail's gutter while it shows nothing.\n this.toggleAttribute('data-empty', !this.trail.length);\n }\n\n protected override render() {\n const trail = this.trail;\n const last = trail.length - 1;\n // role=\"list\": Safari drops the list semantics of a list styled without markers.\n return html`<nav\n aria-label=${this.label || DEFAULT_LABEL}\n ?hidden=${!trail.length}\n @click=${this.onClick}\n >\n <ol role=\"list\">\n ${trail.map((item, i) => {\n const current = i === last ? 'page' : undefined;\n const step =\n item.href !== undefined\n ? html`<a href=${item.href} aria-current=${current ?? nothing}>${item.label}</a>`\n : html`<span aria-current=${current ?? nothing}>${item.label}</span>`;\n // The space before a separator is where a long trail wraps; the separator stays\n // with the item it introduces.\n return html`<li role=\"listitem\">\n ${i ? html` <span class=\"separator\" aria-hidden=\"true\">/</span>` : nothing}${step}\n </li>`;\n })}\n </ol>\n </nav>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibBreadcrumbs } from './UvalibBreadcrumbs.js';\n\ndefine('uvalib-breadcrumbs', UvalibBreadcrumbs);\n"],"mappings":";;;;AAmBA,IAAMgB,IAAgB,cAOhBC,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;IACLA,EAAK;IACLA,EAAK;IACLA,EAAK,YAAYA,EAAK;GAEpBC,IAAkBnB,EAAUiB,EAAgB,OAAO,CAAC,GAGpDG,IAAgC;CACpC,YAAY;CACZ,iBAAiB,CAAC,QAAQ,kBAAkB;CAC5C,eAAe;CACf,WAAW;CACX,SAAS;AACX,GAGMC,oBAAe,IAAI,IAAI;CAAC;CAAS;CAAU;CAAW;AAAM,CAAC,GAE7DC,KAAa,MACjB,OAAOC,KAAK,EAAE,CAAC,CACZ,QAA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GACxD,QAAQ;IAAE,MAAMF,EAAE,aAAa,MAAM;IAAG,OAAOC,EAAM,QAAQD,CAAC;GAAE;GAChE,SAAS;GACT,UAAU;GACV,YAAY;EACd,CAAC;EACD,AAAK,KAAK,cAAcE,CAAE,KAAG,EAAE,eAAe;CAChD;CAEA,QAA2B,GAA+B;EAGxD,AAFA,MAAM,QAAQd,CAAO,GAErB,KAAK,gBAAgB,cAAc,CAAC,KAAK,MAAM,MAAM;CACvD;CAEA,SAA4B;EAC1B,IAAMe,IAAQ,KAAK,OACbC,IAAOD,EAAM,SAAS;EAE5B,OAAO,CAAI;mBACI,KAAK,SAASvC,EAAc;gBAC/B,CAACuC,EAAM,OAAO;eACf,KAAK,QAAQ;;;UAGlBA,EAAM,KAAK,GAAM,MAAM;GACvB,IAAME,IAAUnD,MAAMkD,IAAO,SAAS,KAAA,GAChCN,IACJH,EAAK,SAAS,KAAA,IAEV,CAAI,sBAAsBU,KAAWxD,EAAQ,GAAG8C,EAAK,MAAM,WAD3D,CAAI,WAAWA,EAAK,KAAK,gBAAgBU,KAAWxD,EAAQ,GAAG8C,EAAK,MAAM;GAIhF,OAAO,CAAI;cACPzC,IAAI,CAAI,yDAAyDL,IAAUiD,EAAK;;EAEtF,CAAC,EAAE;;;CAGT;AACF;;AAzOGhD,EAAA,CAAAC,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAgC,EAAA,WAAA,SAAA,KAAA,CAAA,GAOzBjC,EAAA,CAAAC,EAAS,EAAE,WAAW,GAAM,CAAC,CAAA,GAAAgC,EAAA,WAAA,SAAA,KAAA,CAAA,GAG7BjC,EAAA,CAAAE,EAAM,CAAA,GAAA+B,EAAA,WAAA,cAAA,KAAA,CAAA,GC3JT1B,EAAO,sBAAsB0B,CAAiB"}
@@ -1,4 +1,4 @@
1
- import { a as e, l as t, m as n, n as r, p as i, r as a, t as o } from "./chunks/UvalibElement-BnI-eRRR.js";
1
+ import { a as e, l as t, m as n, n as r, p as i, r as a, t as o } from "./chunks/UvalibElement-pGONDAwB.js";
2
2
  // src/components/uvalib-card-grid/UvalibCardGrid.ts
3
3
  var s = /^\d+(\.\d+)?(px|rem|em|ch|%)$/, c = (e, t) => e === ":host" ? `:host(${t})` : `${e}${t}`, l = (e) => `
4
4
  ${e} {
@@ -1,8 +1,8 @@
1
- import { a as e, f as t, l as n, m as r, n as i, o as a, p as o, r as s, t as c } from "./chunks/UvalibElement-BnI-eRRR.js";
2
- import { n as l, t as u } from "./chunks/static-html-1mTAG6nS.js";
1
+ import { a as e, f as t, l as n, m as r, n as i, o as a, p as o, r as s, t as c } from "./chunks/UvalibElement-pGONDAwB.js";
2
+ import { n as l, t as u } from "./chunks/static-html-C1rhtCHu.js";
3
3
  import { t as d } from "./chunks/heading-level-DIuNS44-.js";
4
4
  import { a as f } from "./chunks/analytics-DTTihuBD.js";
5
- import { t as p } from "./chunks/accessible-GqhVn5_H.js";
5
+ import { t as p } from "./chunks/accessible-DJv7YOtS.js";
6
6
  // src/components/uvalib-card/UvalibCard.ts
7
7
  var m = 3, h = /* @__PURE__ */ new Set([
8
8
  "http:",
@@ -1,7 +1,7 @@
1
- import { a as e, d as t, f as n, i as r, l as i, m as a, n as o, o as s, p as c, r as l, t as u } from "./chunks/UvalibElement-BnI-eRRR.js";
1
+ import { a as e, d as t, f as n, i as r, l as i, m as a, n as o, o as s, p as c, r as l, t as u } from "./chunks/UvalibElement-pGONDAwB.js";
2
2
  import { a as d } from "./chunks/analytics-DTTihuBD.js";
3
3
  import { n as f, r as p, t as m } from "./chunks/source-children-BHsDwCvL.js";
4
- import { t as h } from "./chunks/accessible-GqhVn5_H.js";
4
+ import { t as h } from "./chunks/accessible-DJv7YOtS.js";
5
5
  import { n as g, r as _, t as v } from "./chunks/url-param-C1sk_F1d.js";
6
6
  // src/components/uvalib-chip-group/UvalibChipGroup.ts
7
7
  var y = "uvalib-chip-group", b = /* @__PURE__ */ new Set([
@@ -76,6 +76,21 @@ var y = "uvalib-chip-group", b = /* @__PURE__ */ new Set([
76
76
  }
77
77
  ${e} .text { min-width: 0; }
78
78
  ${e} .check { flex: none; width: 1em; height: 1em; }
79
+ /* A key's colour is content, not look: kept with no-style. Its border is the chip's text
80
+ colour, which contrasts with the chip in every state (selected, disabled, dark). */
81
+ ${e} .swatch {
82
+ flex: none;
83
+ box-sizing: border-box;
84
+ width: 0.75em;
85
+ height: 0.75em;
86
+ border: 1px solid currentColor;
87
+ border-radius: 2px;
88
+ }
89
+ /* Forced colors would flatten the fill: the key keeps its colour (it matches the chart or
90
+ map) and its border stays the chip's system text colour. */
91
+ @media (forced-colors: active) {
92
+ ${e} .swatch { forced-color-adjust: none; }
93
+ }
79
94
  ${e} .chip:focus-visible { outline: none; }
80
95
  ${e} :is(.chip:focus-visible > .face, .chip input:focus-visible + .face) {
81
96
  position: relative;
@@ -95,6 +110,7 @@ var y = "uvalib-chip-group", b = /* @__PURE__ */ new Set([
95
110
  white-space: nowrap;
96
111
  border: 0;
97
112
  }
113
+ ${e} .description { margin: 0.25rem 0 0; }
98
114
  ${e}[hidden], ${e} [hidden] { display: none !important; }
99
115
  `, w = c(C(":host")), T = "var(--uva-color-control-border, var(--uva-grey, #808080))", E = "var(--uva-color-link, var(--uva-brand-blue, #232d4b))", D = "var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))", O = t`<svg class="check" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M3 8.5l3.2 3.2L13 4.8" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>`, k = c(".chip[aria-pressed='true'] > .face, .chip input:checked + .face"), A = c(".chip:disabled:not([aria-pressed='true']) > .face, .chip[aria-disabled='true'] > .face, .chip input:disabled:not(:checked) + .face"), j = c(".chip:not(:disabled, [aria-disabled='true']):hover > .face, .chip:hover input:not(:disabled) + .face"), M = c(".chip:focus-visible > .face, .chip input:focus-visible + .face"), N = class extends u {
100
116
  static {
@@ -124,6 +140,11 @@ var y = "uvalib-chip-group", b = /* @__PURE__ */ new Set([
124
140
  border-start-end-radius: 0.3rem;
125
141
  border-end-end-radius: 0.3rem;
126
142
  }
143
+ .description {
144
+ color: var(--uva-color-text-muted, #4f4f4f);
145
+ font-size: 0.875rem;
146
+ line-height: 1.5;
147
+ }
127
148
  .count {
128
149
  color: var(--uva-color-text-muted, #4f4f4f);
129
150
  font-size: 0.8125rem;
@@ -211,7 +232,7 @@ var y = "uvalib-chip-group", b = /* @__PURE__ */ new Set([
211
232
  ];
212
233
  }
213
234
  constructor() {
214
- super(), this.mode = "single", this.label = "", this.value = "", this.countLabel = "items", this.scrollRow = !1, this.segmented = !1, this.urlParam = "", this.childItems = [], this.more = {
235
+ super(), this.mode = "single", this.label = "", this.description = "", this.value = "", this.countLabel = "items", this.scrollRow = !1, this.segmented = !1, this.urlParam = "", this.childItems = [], this.more = {
215
236
  left: !1,
216
237
  right: !1
217
238
  }, this.uid = `${y}-${++S}`, this.warned = /* @__PURE__ */ new Set(), this.onPop = () => {
@@ -272,7 +293,9 @@ var y = "uvalib-chip-group", b = /* @__PURE__ */ new Set([
272
293
  value: n.getAttribute("value") ?? n.getAttribute("data-value") ?? e,
273
294
  label: e
274
295
  }, i = n.getAttribute("data-count");
275
- i !== null && i.trim() && (r.count = i.trim()), n instanceof HTMLAnchorElement && n.hasAttribute("href") && (r.href = n.getAttribute("href")), (n.hasAttribute("disabled") || n.getAttribute("aria-disabled") === "true") && (r.disabled = !0), t.push(r);
296
+ i !== null && i.trim() && (r.count = i.trim()), n instanceof HTMLAnchorElement && n.hasAttribute("href") && (r.href = n.getAttribute("href")), (n.hasAttribute("disabled") || n.getAttribute("aria-disabled") === "true") && (r.disabled = !0);
297
+ let a = n.getAttribute("data-swatch");
298
+ a !== null && (r.swatch = a), t.push(r);
276
299
  }
277
300
  JSON.stringify(t) !== JSON.stringify(this.childItems) && (this.childItems = t);
278
301
  }
@@ -280,9 +303,17 @@ var y = "uvalib-chip-group", b = /* @__PURE__ */ new Set([
280
303
  return (this.items ?? this.childItems).filter((e) => e && f(e.label)).map((e) => ({
281
304
  ...e,
282
305
  label: f(e.label),
283
- value: String(e.value ?? f(e.label))
306
+ value: String(e.value ?? f(e.label)),
307
+ swatch: this.colour(e.swatch)
284
308
  }));
285
309
  }
310
+ colour(e) {
311
+ let t = typeof e == "string" ? e.trim() : "";
312
+ if (t || e != null && e !== "") {
313
+ if (t && CSS.supports("color", t)) return t;
314
+ this.warnOnce("swatch", `ignoring a swatch that is not a CSS colour: ${String(e)}`);
315
+ }
316
+ }
286
317
  get selected() {
287
318
  let e = this.value;
288
319
  if (Array.isArray(e)) return e.map(String);
@@ -398,7 +429,12 @@ var y = "uvalib-chip-group", b = /* @__PURE__ */ new Set([
398
429
  face(e, t) {
399
430
  let n = e.count === void 0 ? "" : this.formatCount(e.count);
400
431
  return i`<span class="face"
401
- >${t ? O : s}<span class="text">${e.label}</span>${n ? i`<span class="visually-hidden">, </span><span class="count">${n}</span
432
+ >${t ? O : s}${e.swatch ? i`<span
433
+ class="swatch"
434
+ part="swatch"
435
+ aria-hidden="true"
436
+ data-colour=${e.swatch}
437
+ ></span>` : s}<span class="text">${e.label}</span>${n ? i`<span class="visually-hidden">, </span><span class="count">${n}</span
402
438
  ><span class="visually-hidden"> ${this.countLabel}</span>` : s}</span
403
439
  >`;
404
440
  }
@@ -448,6 +484,7 @@ var y = "uvalib-chip-group", b = /* @__PURE__ */ new Set([
448
484
  }
449
485
  updated(e) {
450
486
  super.updated(e);
487
+ for (let e of this.renderRoot.querySelectorAll(".chips .swatch")) e.style.backgroundColor = e.dataset.colour;
451
488
  let t = this.renderRoot.querySelector(".chips.scroll") ?? void 0;
452
489
  t !== this.observed && (this.resize?.disconnect(), this.observed = t, t && (this.resize ??= new ResizeObserver(() => this.measure()), this.resize.observe(t))), t && requestAnimationFrame(this.measure);
453
490
  }
@@ -456,29 +493,31 @@ var y = "uvalib-chip-group", b = /* @__PURE__ */ new Set([
456
493
  "chips",
457
494
  this.scrollRow ? "scroll" : "",
458
495
  this.segmented ? "segmented" : ""
459
- ].filter(Boolean).join(" "), n = i`<div
496
+ ].filter(Boolean).join(" "), n = f(this.description), r = `${this.uid}-description`, a = n ? i`<p class="description" id=${r} ?hidden=${!e.length}>${n}</p>` : s, o = i`<div
460
497
  class=${t}
461
498
  role=${this.kind === "single" ? "radiogroup" : "group"}
462
499
  aria-label=${this.label.trim() || s}
500
+ aria-describedby=${n ? r : s}
463
501
  ?hidden=${!e.length}
464
502
  @scroll=${this.scrollRow ? this.measure : s}
465
503
  >
466
504
  ${e.map((e) => this.renderChip(e))}
467
505
  </div>`;
468
506
  return this.scrollRow ? i`<div
469
- class="rail"
470
- ?data-more-left=${this.more.left}
471
- ?data-more-right=${this.more.right}
472
- >
473
- ${n}
474
- </div>` : n;
507
+ class="rail"
508
+ ?data-more-left=${this.more.left}
509
+ ?data-more-right=${this.more.right}
510
+ >
511
+ ${o}
512
+ </div>
513
+ ${a}` : i`${o}${a}`;
475
514
  }
476
515
  };
477
516
  // src/components/uvalib-chip-group/uvalib-chip-group.ts
478
517
  o([e({
479
518
  type: String,
480
519
  reflect: !0
481
- })], N.prototype, "mode", void 0), o([e({ type: String })], N.prototype, "label", void 0), o([e({ converter: { fromAttribute: (e) => e ?? "" } })], N.prototype, "value", void 0), o([e({ attribute: !1 })], N.prototype, "items", void 0), o([e({
520
+ })], N.prototype, "mode", void 0), o([e({ type: String })], N.prototype, "label", void 0), o([e({ type: String })], N.prototype, "description", void 0), o([e({ converter: { fromAttribute: (e) => e ?? "" } })], N.prototype, "value", void 0), o([e({ attribute: !1 })], N.prototype, "items", void 0), o([e({
482
521
  type: String,
483
522
  attribute: "count-label"
484
523
  })], N.prototype, "countLabel", void 0), o([e({