@uvalib/web-components 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +724 -33
  3. package/dist/base/analytics-state.d.ts +36 -0
  4. package/dist/base/analytics-state.js +44 -0
  5. package/dist/base/analytics-state.js.map +1 -0
  6. package/dist/base/analytics.d.ts +31 -27
  7. package/dist/base/analytics.js +48 -37
  8. package/dist/base/analytics.js.map +1 -1
  9. package/dist/base/inline-copy.d.ts +16 -0
  10. package/dist/base/inline-copy.js +92 -0
  11. package/dist/base/inline-copy.js.map +1 -0
  12. package/dist/base/source-children.d.ts +46 -0
  13. package/dist/base/source-children.js +116 -0
  14. package/dist/base/source-children.js.map +1 -0
  15. package/dist/base.css +199 -0
  16. package/dist/base.d.ts +2 -2
  17. package/dist/base.js +1 -1
  18. package/dist/base.js.map +1 -1
  19. package/dist/components/bento-box/BentoSection.d.ts +1 -1
  20. package/dist/components/bento-box/BentoSection.js +29 -6
  21. package/dist/components/bento-box/BentoSection.js.map +1 -1
  22. package/dist/components/events-section/EventsSection.d.ts +3 -0
  23. package/dist/components/events-section/EventsSection.js +12 -1
  24. package/dist/components/events-section/EventsSection.js.map +1 -1
  25. package/dist/components/library-weekly-hours/LibraryWeeklyHours.d.ts +1 -0
  26. package/dist/components/library-weekly-hours/LibraryWeeklyHours.js +5 -0
  27. package/dist/components/library-weekly-hours/LibraryWeeklyHours.js.map +1 -1
  28. package/dist/components/site-alerts/SiteAlerts.d.ts +109 -0
  29. package/dist/components/site-alerts/SiteAlerts.js +542 -0
  30. package/dist/components/site-alerts/SiteAlerts.js.map +1 -0
  31. package/dist/components/site-alerts/alerts-source.d.ts +36 -0
  32. package/dist/components/site-alerts/alerts-source.js +115 -0
  33. package/dist/components/site-alerts/alerts-source.js.map +1 -0
  34. package/dist/components/{site-page → site-alerts}/alerts.js +8 -3
  35. package/dist/components/site-alerts/alerts.js.map +1 -0
  36. package/dist/components/site-alerts/body.d.ts +10 -0
  37. package/dist/components/site-alerts/body.js +48 -0
  38. package/dist/components/site-alerts/body.js.map +1 -0
  39. package/dist/components/site-alerts/dismissed.d.ts +12 -0
  40. package/dist/components/site-alerts/dismissed.js +72 -0
  41. package/dist/components/site-alerts/dismissed.js.map +1 -0
  42. package/dist/components/site-alerts/icons.d.ts +8 -0
  43. package/dist/components/site-alerts/icons.js +15 -0
  44. package/dist/components/site-alerts/icons.js.map +1 -0
  45. package/dist/components/site-alerts/site-alerts.d.ts +1 -0
  46. package/dist/components/site-alerts/site-alerts.js +4 -0
  47. package/dist/components/site-alerts/site-alerts.js.map +1 -0
  48. package/dist/components/site-analytics/SiteAnalytics.d.ts +26 -2
  49. package/dist/components/site-analytics/SiteAnalytics.js +140 -4
  50. package/dist/components/site-analytics/SiteAnalytics.js.map +1 -1
  51. package/dist/components/site-footer/SiteFooter.d.ts +4 -0
  52. package/dist/components/site-footer/SiteFooter.js +28 -4
  53. package/dist/components/site-footer/SiteFooter.js.map +1 -1
  54. package/dist/components/site-header/SiteHeader.d.ts +47 -3
  55. package/dist/components/site-header/SiteHeader.js +198 -21
  56. package/dist/components/site-header/SiteHeader.js.map +1 -1
  57. package/dist/components/site-hours-section/SiteHoursSection.d.ts +4 -1
  58. package/dist/components/site-hours-section/SiteHoursSection.js +18 -3
  59. package/dist/components/site-hours-section/SiteHoursSection.js.map +1 -1
  60. package/dist/components/site-main-nav/SiteMainNav.d.ts +1 -1
  61. package/dist/components/site-main-nav/SiteMainNav.js +11 -1
  62. package/dist/components/site-main-nav/SiteMainNav.js.map +1 -1
  63. package/dist/components/site-page/SitePage.d.ts +43 -15
  64. package/dist/components/site-page/SitePage.js +161 -34
  65. package/dist/components/site-page/SitePage.js.map +1 -1
  66. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.d.ts +91 -0
  67. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js +310 -0
  68. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js.map +1 -0
  69. package/dist/components/uvalib-breadcrumbs/uvalib-breadcrumbs.d.ts +1 -0
  70. package/dist/components/uvalib-breadcrumbs/uvalib-breadcrumbs.js +4 -0
  71. package/dist/components/uvalib-breadcrumbs/uvalib-breadcrumbs.js.map +1 -0
  72. package/dist/components/uvalib-card/UvalibCard.d.ts +113 -0
  73. package/dist/components/uvalib-card/UvalibCard.js +643 -0
  74. package/dist/components/uvalib-card/UvalibCard.js.map +1 -0
  75. package/dist/components/uvalib-card/uvalib-card.d.ts +1 -0
  76. package/dist/components/uvalib-card/uvalib-card.js +4 -0
  77. package/dist/components/uvalib-card/uvalib-card.js.map +1 -0
  78. package/dist/components/uvalib-card-grid/UvalibCardGrid.d.ts +60 -0
  79. package/dist/components/uvalib-card-grid/UvalibCardGrid.js +305 -0
  80. package/dist/components/uvalib-card-grid/UvalibCardGrid.js.map +1 -0
  81. package/dist/components/uvalib-card-grid/uvalib-card-grid.d.ts +1 -0
  82. package/dist/components/uvalib-card-grid/uvalib-card-grid.js +4 -0
  83. package/dist/components/uvalib-card-grid/uvalib-card-grid.js.map +1 -0
  84. package/dist/components/uvalib-contents/UvalibContents.d.ts +134 -0
  85. package/dist/components/uvalib-contents/UvalibContents.js +613 -0
  86. package/dist/components/uvalib-contents/UvalibContents.js.map +1 -0
  87. package/dist/components/uvalib-contents/uvalib-contents.d.ts +1 -0
  88. package/dist/components/uvalib-contents/uvalib-contents.js +4 -0
  89. package/dist/components/uvalib-contents/uvalib-contents.js.map +1 -0
  90. package/dist/components/uvalib-date-range/UvalibDateRange.d.ts +10 -0
  91. package/dist/components/uvalib-date-range/UvalibDateRange.js +21 -0
  92. package/dist/components/uvalib-date-range/UvalibDateRange.js.map +1 -1
  93. package/dist/components/uvalib-filter/UvalibFilter.d.ts +1 -0
  94. package/dist/components/uvalib-filter/UvalibFilter.js +11 -1
  95. package/dist/components/uvalib-filter/UvalibFilter.js.map +1 -1
  96. package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +204 -0
  97. package/dist/components/uvalib-lightbox/UvalibLightbox.js +1115 -0
  98. package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -0
  99. package/dist/components/uvalib-lightbox/media.d.ts +51 -0
  100. package/dist/components/uvalib-lightbox/media.js +127 -0
  101. package/dist/components/uvalib-lightbox/media.js.map +1 -0
  102. package/dist/components/uvalib-lightbox/uvalib-lightbox.d.ts +1 -0
  103. package/dist/components/uvalib-lightbox/uvalib-lightbox.js +4 -0
  104. package/dist/components/uvalib-lightbox/uvalib-lightbox.js.map +1 -0
  105. package/dist/components/uvalib-metadata/UvalibMetadata.d.ts +124 -0
  106. package/dist/components/uvalib-metadata/UvalibMetadata.js +443 -0
  107. package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -0
  108. package/dist/components/uvalib-metadata/rights.d.ts +8 -0
  109. package/dist/components/uvalib-metadata/rights.js +47 -0
  110. package/dist/components/uvalib-metadata/rights.js.map +1 -0
  111. package/dist/components/uvalib-metadata/uvalib-metadata.d.ts +1 -0
  112. package/dist/components/uvalib-metadata/uvalib-metadata.js +4 -0
  113. package/dist/components/uvalib-metadata/uvalib-metadata.js.map +1 -0
  114. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +103 -0
  115. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +410 -0
  116. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -0
  117. package/dist/components/uvalib-pagefind-search/uvalib-pagefind-search.d.ts +1 -0
  118. package/dist/components/uvalib-pagefind-search/uvalib-pagefind-search.js +7 -0
  119. package/dist/components/uvalib-pagefind-search/uvalib-pagefind-search.js.map +1 -0
  120. package/dist/components/uvalib-pager/UvalibPager.d.ts +94 -0
  121. package/dist/components/uvalib-pager/UvalibPager.js +390 -0
  122. package/dist/components/uvalib-pager/UvalibPager.js.map +1 -0
  123. package/dist/components/uvalib-pager/uvalib-pager.d.ts +1 -0
  124. package/dist/components/uvalib-pager/uvalib-pager.js +4 -0
  125. package/dist/components/uvalib-pager/uvalib-pager.js.map +1 -0
  126. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +59 -0
  127. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +350 -0
  128. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -0
  129. package/dist/components/uvalib-photo-grid/uvalib-photo-grid.d.ts +1 -0
  130. package/dist/components/uvalib-photo-grid/uvalib-photo-grid.js +4 -0
  131. package/dist/components/uvalib-photo-grid/uvalib-photo-grid.js.map +1 -0
  132. package/dist/custom-elements.json +12291 -4424
  133. package/dist/index.d.ts +16 -0
  134. package/dist/index.js +11 -0
  135. package/dist/index.js.map +1 -1
  136. package/dist/pagefind.css +388 -0
  137. package/dist/styles/base.js +11 -0
  138. package/dist/styles/base.js.map +1 -1
  139. package/dist/styles/color-scheme.js +24 -11
  140. package/dist/styles/color-scheme.js.map +1 -1
  141. package/dist/styles/controls.d.ts +2 -0
  142. package/dist/styles/controls.js +200 -0
  143. package/dist/styles/controls.js.map +1 -0
  144. package/dist/styles/pagefind.d.ts +1 -0
  145. package/dist/styles/pagefind.js +395 -0
  146. package/dist/styles/pagefind.js.map +1 -0
  147. package/dist/tokens.css +23 -20
  148. package/dist-cdn/base.css +199 -0
  149. package/dist-cdn/bento-box.js +117 -97
  150. package/dist-cdn/bento-box.js.map +1 -1
  151. package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js +243 -0
  152. package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js.map +1 -0
  153. package/dist-cdn/chunks/alerts-C5vkeb-f.js +39 -0
  154. package/dist-cdn/chunks/alerts-C5vkeb-f.js.map +1 -0
  155. package/dist-cdn/chunks/analytics-DTTihuBD.js +43 -0
  156. package/dist-cdn/chunks/analytics-DTTihuBD.js.map +1 -0
  157. package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js +39 -0
  158. package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js.map +1 -0
  159. package/dist-cdn/chunks/{base-DCGd2Oii.js → base-CAFQWnZG.js} +12 -1
  160. package/dist-cdn/chunks/{base-DCGd2Oii.js.map → base-CAFQWnZG.js.map} +1 -1
  161. package/dist-cdn/chunks/{library-weekly-hours-ByQ8ugxh.js → library-weekly-hours-COE7Vv6V.js} +47 -38
  162. package/dist-cdn/chunks/library-weekly-hours-COE7Vv6V.js.map +1 -0
  163. package/dist-cdn/chunks/{site-header-BwDkZ2LL.js → site-header-C9V7Wuw2.js} +169 -49
  164. package/dist-cdn/chunks/site-header-C9V7Wuw2.js.map +1 -0
  165. package/dist-cdn/chunks/{site-main-nav-BLAAunnr.js → site-main-nav-AaxZ9rQf.js} +11 -2
  166. package/dist-cdn/chunks/site-main-nav-AaxZ9rQf.js.map +1 -0
  167. package/dist-cdn/chunks/source-children-RuAec527.js +119 -0
  168. package/dist-cdn/chunks/source-children-RuAec527.js.map +1 -0
  169. package/dist-cdn/custom-elements.json +12291 -4424
  170. package/dist-cdn/events-section.js +78 -66
  171. package/dist-cdn/events-section.js.map +1 -1
  172. package/dist-cdn/library-hours-setup.js +1 -1
  173. package/dist-cdn/library-weekly-hours.js +1 -1
  174. package/dist-cdn/manifest.json +13 -2
  175. package/dist-cdn/pagefind.css +388 -0
  176. package/dist-cdn/site-alerts.js +516 -0
  177. package/dist-cdn/site-alerts.js.map +1 -0
  178. package/dist-cdn/site-analytics.js +1 -1
  179. package/dist-cdn/site-footer.js +33 -18
  180. package/dist-cdn/site-footer.js.map +1 -1
  181. package/dist-cdn/site-header.js +1 -1
  182. package/dist-cdn/site-hours-section.js +33 -21
  183. package/dist-cdn/site-hours-section.js.map +1 -1
  184. package/dist-cdn/site-main-nav.js +1 -1
  185. package/dist-cdn/site-page.js +116 -81
  186. package/dist-cdn/site-page.js.map +1 -1
  187. package/dist-cdn/site-style.js +1 -1
  188. package/dist-cdn/skills/uvalib-web-components/SKILL.md +367 -11
  189. package/dist-cdn/skills/uvalib-web-components/reference/accessibility-testing.md +170 -0
  190. package/dist-cdn/skills/uvalib-web-components/reference/components.md +414 -12
  191. package/dist-cdn/skills/uvalib-web-components/reference/migration.md +37 -0
  192. package/dist-cdn/tokens.css +23 -20
  193. package/dist-cdn/uvalib-analytics.js +1 -1
  194. package/dist-cdn/uvalib-breadcrumbs.js +176 -0
  195. package/dist-cdn/uvalib-breadcrumbs.js.map +1 -0
  196. package/dist-cdn/uvalib-card-grid.js +163 -0
  197. package/dist-cdn/uvalib-card-grid.js.map +1 -0
  198. package/dist-cdn/uvalib-card.js +424 -0
  199. package/dist-cdn/uvalib-card.js.map +1 -0
  200. package/dist-cdn/uvalib-contents.js +381 -0
  201. package/dist-cdn/uvalib-contents.js.map +1 -0
  202. package/dist-cdn/uvalib-date-range.js +33 -18
  203. package/dist-cdn/uvalib-date-range.js.map +1 -1
  204. package/dist-cdn/uvalib-filter.js +32 -11
  205. package/dist-cdn/uvalib-filter.js.map +1 -1
  206. package/dist-cdn/uvalib-lightbox.js +662 -0
  207. package/dist-cdn/uvalib-lightbox.js.map +1 -0
  208. package/dist-cdn/uvalib-metadata.js +313 -0
  209. package/dist-cdn/uvalib-metadata.js.map +1 -0
  210. package/dist-cdn/uvalib-pagefind-search.js +207 -0
  211. package/dist-cdn/uvalib-pagefind-search.js.map +1 -0
  212. package/dist-cdn/uvalib-pager.js +278 -0
  213. package/dist-cdn/uvalib-pager.js.map +1 -0
  214. package/dist-cdn/uvalib-photo-grid.js +202 -0
  215. package/dist-cdn/uvalib-photo-grid.js.map +1 -0
  216. package/package.json +43 -1
  217. package/skills/uvalib-web-components/SKILL.md +367 -11
  218. package/skills/uvalib-web-components/reference/accessibility-testing.md +170 -0
  219. package/skills/uvalib-web-components/reference/components.md +414 -12
  220. package/skills/uvalib-web-components/reference/migration.md +37 -0
  221. package/dist/components/site-page/alerts.js.map +0 -1
  222. package/dist-cdn/chunks/SiteAnalytics-T1Wx3lsb.js +0 -174
  223. package/dist-cdn/chunks/SiteAnalytics-T1Wx3lsb.js.map +0 -1
  224. package/dist-cdn/chunks/analytics-C8D8n_wt.js +0 -55
  225. package/dist-cdn/chunks/analytics-C8D8n_wt.js.map +0 -1
  226. package/dist-cdn/chunks/library-weekly-hours-ByQ8ugxh.js.map +0 -1
  227. package/dist-cdn/chunks/site-header-BwDkZ2LL.js.map +0 -1
  228. package/dist-cdn/chunks/site-main-nav-BLAAunnr.js.map +0 -1
  229. /package/dist/components/{site-page → site-alerts}/alerts.d.ts +0 -0
@@ -0,0 +1,109 @@
1
+ import { type PropertyValues } from 'lit';
2
+ import { UvalibElement } from '../../base/UvalibElement.js';
3
+ export type { SiteAlert } from './alerts-source.js';
4
+ /** Which alerts a `<site-alerts>` shows. */
5
+ export type SiteAlertsShow = 'all' | 'header' | 'list' | 'regional' | 'sitewide';
6
+ /**
7
+ * Live UVA Library alerts, drawn as library.virginia.edu draws them. The alerts project
8
+ * (github.com/uvalib/uvalib-alerts) keeps the data: a headless `<uvalib-alerts>` loaded at
9
+ * runtime from the alerts CDN (`alerts-env`, or `alerts-src`), one per document, shared by
10
+ * every `<site-alerts>` and created hidden at the end of `<body>`. It keeps the live
11
+ * connection, the dismissals (per site, synced across tabs) and the regional matching (the
12
+ * page URL, followed through single-page-app navigation). If its script fails to load, one
13
+ * console warning is logged and nothing is shown.
14
+ *
15
+ * `show` picks the alerts: `header` (the banner: a polite `role="status"` row on teal),
16
+ * `list` (critical, warning and information alerts, most severe first; only critical ones
17
+ * are an assertive `role="alert"`), `regional` (alerts targeted at this page), `sitewide`
18
+ * (header and list) or `all` (the default). Each list alert has a decorative icon and a
19
+ * visually hidden "Critical:", "Warning:" or "Information:" before its title, a heading
20
+ * (`heading-level`, default 2, as on library.virginia.edu). Warning and information alerts
21
+ * have a dismiss button; after a dismissal focus moves to the next alert's button (or the
22
+ * alert), else to the page's `<main>`, never to `<body>`. Alert bodies are server-sanitized
23
+ * HTML, re-sanitized with the browser's `setHTML()` where it exists.
24
+ *
25
+ * `<site-page>` places three of these itself (banner, list band, regional); use this element
26
+ * directly only on pages without `<site-page>`.
27
+ *
28
+ * @tagname site-alerts
29
+ * @fires site-alerts-change - The number of alerts this element shows changed: `detail` is `{ count }`. Bubbles and is composed. The host also has `data-empty` while it shows none.
30
+ * @cssprop [--uva-teal=#25cad3] - Header banner background.
31
+ * @cssprop [--uva-red-100=#fbcfda] - Critical alert background (`--uva-red-B` #b30000 border).
32
+ * @cssprop [--uva-yellow-100=#fef6c8] - Warning alert and regional alert background (`--uva-yellow` #ecc602 border).
33
+ * @cssprop [--uva-blue-alt-300=#bfe7f7] - Information alert background (`--uva-blue-alt` #007bac border).
34
+ * @cssprop [--uva-teal-200=#c8f2f4] - Information regional alert background (`--uva-teal` border).
35
+ * @cssprop [--uva-grey-darkest=#2b2b2b] - Alert text.
36
+ * @cssprop [--uva-blue-alt-B=#141e3c] - Links in alert text.
37
+ * @cssprop --uva-color-alert-text - Dark-mode role token: alert text, icons and focus ring (else `--uva-grey-darkest`; the banner's is `--uva-color-alert-header-text`, else #000).
38
+ * @cssprop --uva-color-alert-link - Dark-mode role token: links in alert text (else `--uva-blue-alt-B`).
39
+ * @cssprop --uva-color-alert-header-bg - Dark-mode role token: banner background (else `--uva-teal`).
40
+ * @cssprop --uva-color-alert-critical-bg - Dark-mode role token: critical alert background; `-border` for its border. Also `--uva-color-alert-warning-*`, `--uva-color-alert-info-*`, `--uva-color-alert-regional-*` and `--uva-color-alert-regional-info-*`.
41
+ */
42
+ export declare class SiteAlerts extends UvalibElement {
43
+ static styles: import("lit").CSSResult[];
44
+ /** Which alerts to show: `header`, `list`, `regional`, `sitewide` (header and list) or `all`. */
45
+ show: SiteAlertsShow;
46
+ /**
47
+ * Alerts environment: `production` (default) or `staging`. Any other value logs one
48
+ * console warning and uses production. Ignored when `alerts-src` is set.
49
+ */
50
+ alertsEnv: string;
51
+ /**
52
+ * Alerts base URL (holding `config.json`, `alerts.json` and `v1/uvalib-alerts.js`); overrides
53
+ * `alerts-env`. For a custom domain, local development and tests.
54
+ */
55
+ alertsSrc?: string;
56
+ /** The level of each list alert's title heading, 1 to 6 (default 2). */
57
+ headingLevel: number;
58
+ /**
59
+ * The localStorage key for dismissed alerts, passed to the headless element (default: the
60
+ * alerts project's, `uvalib-alerts-seen`). Elements with different keys use different
61
+ * headless elements.
62
+ */
63
+ storageKey?: string;
64
+ /** The headless element's last state. */
65
+ private data;
66
+ private sub?;
67
+ /** What the reader closed here (Information alerts included), and its unsubscribe. */
68
+ private closed?;
69
+ /** The dismissed alert and its place in the list, until it is gone and focus has moved. */
70
+ private pendingFocus?;
71
+ private lastCount;
72
+ constructor();
73
+ /** Every alert this element shows, with its analytics label, `<severity>: <title>`. */
74
+ private shown;
75
+ /** A content impression for each alert shown, once per alert per page view. */
76
+ private reportImpressions;
77
+ protected createRenderRoot(): HTMLElement | DocumentFragment;
78
+ connectedCallback(): void;
79
+ disconnectedCallback(): void;
80
+ /** The alerts base URL in use, from `alerts-src` or `alerts-env`. */
81
+ private get base();
82
+ private get level();
83
+ private has;
84
+ /** List alerts, most severe first (the headless element's order within a severity). */
85
+ private get list();
86
+ private get count();
87
+ protected willUpdate(changed: PropertyValues<this>): void;
88
+ protected updated(changed: PropertyValues<this>): void;
89
+ private onDismiss;
90
+ /**
91
+ * After a dismissal has removed its alert: the alert now in its place (or the last one)
92
+ * gets focus, on its dismiss button if it has one; with none left, the page's `<main>`.
93
+ * Only while focus was lost with the button (or is still inside this element).
94
+ */
95
+ private moveFocus;
96
+ /** The nearest `<main>`: in this element's tree, else in each enclosing one up to the document. */
97
+ private findMain;
98
+ /** An alert's body: filled in updated(), so Lit never manages its content. */
99
+ private body;
100
+ /** Insert each shown alert's body HTML into its (keyed, so stable) body element. */
101
+ private fillBodies;
102
+ /** The header banner (library.virginia.edu's alert4): a polite status row. */
103
+ private renderBanner;
104
+ /** One list alert: icon, heading with its severity in text, body, dismiss button. */
105
+ private renderAlert;
106
+ /** A regional alert (.uva-alert--r1, or --r2 for information), its severity in text. */
107
+ private renderRegional;
108
+ protected render(): import("lit").TemplateResult;
109
+ }
@@ -0,0 +1,542 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { css, nothing, unsafeCSS } from 'lit';
8
+ import { html, unsafeStatic } from 'lit/static-html.js';
9
+ import { property, state } from 'lit/decorators.js';
10
+ import { repeat } from 'lit/directives/repeat.js';
11
+ import { UvalibElement } from '../../base/UvalibElement.js';
12
+ import { installLightDomStyles } from '../../base/light-dom-styles.js';
13
+ import { trackContent, trackEvent } from '../../base/analytics.js';
14
+ import { accessible } from '../../styles/accessible.js';
15
+ import { ALERTS_PRODUCTION_SRC, alertsBase, isAlertsEnv } from './alerts.js';
16
+ import { subscribeAlerts, } from './alerts-source.js';
17
+ import { setBody } from './body.js';
18
+ import { closeIcon, criticalIcon, infoIcon, warningIcon } from './icons.js';
19
+ import { dismissedKey, dismissedStore } from './dismissed.js';
20
+ /** Severity, never by colour alone (WCAG 1.4.1): a decorative icon and text for assistive tech. */
21
+ const SEVERITY = {
22
+ alert1: { label: 'Critical:', icon: criticalIcon },
23
+ alert2: { label: 'Warning:', icon: warningIcon },
24
+ alert3: { label: 'Information:', icon: infoIcon },
25
+ };
26
+ /** List alerts: a severity this element does not know is shown as information. */
27
+ const severityOf = (a) => Object.hasOwn(SEVERITY, a.severity) ? a.severity : 'alert3';
28
+ const EMPTY = {
29
+ alerts: [],
30
+ seenAlerts: [],
31
+ headerAlerts: [],
32
+ menuAlerts: [],
33
+ regionalAlerts: [],
34
+ status: '',
35
+ };
36
+ const DEFAULT_LEVEL = 2;
37
+ /** Analytics names are capped at 100 characters. */
38
+ const cap = (s) => (s.length > 100 ? s.slice(0, 100) : s);
39
+ /** The alerts already reported as seen in this document (page view), shared by every copy. */
40
+ const IMPRESSIONS = Symbol.for('uvalib.site-alerts.impressions');
41
+ const impressions = (doc) => (doc[IMPRESSIONS] ??= new Set());
42
+ /**
43
+ * Kept with `no-style`: severity text stays visually hidden, the icons keep a size and
44
+ * `[hidden]` hides. `host` is `:host` (shadow) or the tag name (light DOM, so they stay scoped).
45
+ */
46
+ const structuralRules = (host) => `
47
+ ${host} { display: block; }
48
+ ${host}[hidden], ${host} [hidden] { display: none !important; }
49
+ ${host} .visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px;
50
+ padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
51
+ ${host} .icon { width: 2rem; height: 2rem; }
52
+ ${host} .dismiss .icon { width: 1.5rem; height: 1.5rem; }
53
+ `;
54
+ const shadowStructure = unsafeCSS(structuralRules(':host'));
55
+ /**
56
+ * Live UVA Library alerts, drawn as library.virginia.edu draws them. The alerts project
57
+ * (github.com/uvalib/uvalib-alerts) keeps the data: a headless `<uvalib-alerts>` loaded at
58
+ * runtime from the alerts CDN (`alerts-env`, or `alerts-src`), one per document, shared by
59
+ * every `<site-alerts>` and created hidden at the end of `<body>`. It keeps the live
60
+ * connection, the dismissals (per site, synced across tabs) and the regional matching (the
61
+ * page URL, followed through single-page-app navigation). If its script fails to load, one
62
+ * console warning is logged and nothing is shown.
63
+ *
64
+ * `show` picks the alerts: `header` (the banner: a polite `role="status"` row on teal),
65
+ * `list` (critical, warning and information alerts, most severe first; only critical ones
66
+ * are an assertive `role="alert"`), `regional` (alerts targeted at this page), `sitewide`
67
+ * (header and list) or `all` (the default). Each list alert has a decorative icon and a
68
+ * visually hidden "Critical:", "Warning:" or "Information:" before its title, a heading
69
+ * (`heading-level`, default 2, as on library.virginia.edu). Warning and information alerts
70
+ * have a dismiss button; after a dismissal focus moves to the next alert's button (or the
71
+ * alert), else to the page's `<main>`, never to `<body>`. Alert bodies are server-sanitized
72
+ * HTML, re-sanitized with the browser's `setHTML()` where it exists.
73
+ *
74
+ * `<site-page>` places three of these itself (banner, list band, regional); use this element
75
+ * directly only on pages without `<site-page>`.
76
+ *
77
+ * @tagname site-alerts
78
+ * @fires site-alerts-change - The number of alerts this element shows changed: `detail` is `{ count }`. Bubbles and is composed. The host also has `data-empty` while it shows none.
79
+ * @cssprop [--uva-teal=#25cad3] - Header banner background.
80
+ * @cssprop [--uva-red-100=#fbcfda] - Critical alert background (`--uva-red-B` #b30000 border).
81
+ * @cssprop [--uva-yellow-100=#fef6c8] - Warning alert and regional alert background (`--uva-yellow` #ecc602 border).
82
+ * @cssprop [--uva-blue-alt-300=#bfe7f7] - Information alert background (`--uva-blue-alt` #007bac border).
83
+ * @cssprop [--uva-teal-200=#c8f2f4] - Information regional alert background (`--uva-teal` border).
84
+ * @cssprop [--uva-grey-darkest=#2b2b2b] - Alert text.
85
+ * @cssprop [--uva-blue-alt-B=#141e3c] - Links in alert text.
86
+ * @cssprop --uva-color-alert-text - Dark-mode role token: alert text, icons and focus ring (else `--uva-grey-darkest`; the banner's is `--uva-color-alert-header-text`, else #000).
87
+ * @cssprop --uva-color-alert-link - Dark-mode role token: links in alert text (else `--uva-blue-alt-B`).
88
+ * @cssprop --uva-color-alert-header-bg - Dark-mode role token: banner background (else `--uva-teal`).
89
+ * @cssprop --uva-color-alert-critical-bg - Dark-mode role token: critical alert background; `-border` for its border. Also `--uva-color-alert-warning-*`, `--uva-color-alert-info-*`, `--uva-color-alert-regional-*` and `--uva-color-alert-regional-info-*`.
90
+ */
91
+ export class SiteAlerts extends UvalibElement {
92
+ static { this.styles = [
93
+ accessible,
94
+ shadowStructure,
95
+ css `
96
+ :host {
97
+ color: var(--uva-color-alert-text, var(--uva-grey-darkest, #2b2b2b));
98
+ font-size: 1rem;
99
+ line-height: 1.5;
100
+ text-align: left;
101
+ overflow-wrap: anywhere;
102
+ }
103
+ .body a {
104
+ color: var(--uva-color-alert-link, var(--uva-blue-alt-B, #141e3c));
105
+ text-decoration: underline;
106
+ }
107
+ /* WCAG 1.4.11: the ring is drawn on the alert's own background, so it follows the text
108
+ colour, which is chosen to read on that background (alerts project, focus.test.ts). */
109
+ .dismiss:focus-visible,
110
+ .body a:focus-visible {
111
+ outline: 2px solid currentColor;
112
+ outline-offset: 2px;
113
+ }
114
+ .body p {
115
+ margin: 0;
116
+ }
117
+
118
+ /* Header banner (library.virginia.edu's .alert4). */
119
+ .banner {
120
+ display: flex;
121
+ flex-wrap: wrap;
122
+ justify-content: center;
123
+ gap: 0 1.25rem;
124
+ padding: 0.25rem 0.5rem;
125
+ background: var(--uva-color-alert-header-bg, var(--uva-teal, #25cad3));
126
+ color: var(--uva-color-alert-header-text, #000);
127
+ text-align: center;
128
+ }
129
+ .banner .title {
130
+ font-weight: 700;
131
+ }
132
+ .banner .body,
133
+ .banner .body p {
134
+ display: inline;
135
+ }
136
+
137
+ /* List alerts (.uva-alert--sitewide .alert1-3). */
138
+ .alert {
139
+ position: relative;
140
+ min-height: 2rem;
141
+ padding: 0.55rem 0.5rem 0.55rem 3.25rem;
142
+ border-left: 10px solid;
143
+ }
144
+ .alert.dismissible {
145
+ padding-right: calc(44px + 1rem);
146
+ }
147
+ .alert > .icon {
148
+ position: absolute;
149
+ top: 0.55rem;
150
+ left: 0.55rem;
151
+ }
152
+ .alert .title {
153
+ margin: 0;
154
+ padding-block-end: 0.25rem;
155
+ font-family: inherit;
156
+ font-size: 1.2rem;
157
+ font-weight: 500;
158
+ line-height: 1.15;
159
+ color: inherit;
160
+ }
161
+ .alert .body p {
162
+ padding-block-end: 0.25rem;
163
+ }
164
+ .alert1 {
165
+ background: var(--uva-color-alert-critical-bg, var(--uva-red-100, #fbcfda));
166
+ border-left-color: var(--uva-color-alert-critical-border, var(--uva-red-B, #b30000));
167
+ }
168
+ .alert2 {
169
+ background: var(--uva-color-alert-warning-bg, var(--uva-yellow-100, #fef6c8));
170
+ border-left-color: var(--uva-color-alert-warning-border, var(--uva-yellow, #ecc602));
171
+ }
172
+ .alert3 {
173
+ background: var(--uva-color-alert-info-bg, var(--uva-blue-alt-300, #bfe7f7));
174
+ border-left-color: var(--uva-color-alert-info-border, var(--uva-blue-alt, #007bac));
175
+ }
176
+ /* WCAG 2.5.8 (AA, 24px) and 2.5.5 (AAA, 44px): a 44px target, inside the alert so the
177
+ focus ring stays on its background. */
178
+ .dismiss {
179
+ position: absolute;
180
+ top: 0.25rem;
181
+ right: 0.25rem;
182
+ display: grid;
183
+ place-items: center;
184
+ box-sizing: border-box;
185
+ width: 44px;
186
+ height: 44px;
187
+ margin: 0;
188
+ padding: 0;
189
+ border: 0;
190
+ border-radius: 4px;
191
+ background: none;
192
+ color: inherit;
193
+ font: inherit;
194
+ cursor: pointer;
195
+ }
196
+
197
+ /* Regional alerts (.uva-alert--r1, and .uva-alert--r2 for information). */
198
+ .regional {
199
+ margin: 0 0 1rem;
200
+ padding: 0.75rem 1rem;
201
+ border: 0.2em solid var(--uva-color-alert-regional-border, var(--uva-yellow, #ecc602));
202
+ border-radius: 0.5em;
203
+ background: var(--uva-color-alert-regional-bg, var(--uva-yellow-100, #fef6c8));
204
+ }
205
+ .regional.info {
206
+ border-color: var(--uva-color-alert-regional-info-border, var(--uva-teal, #25cad3));
207
+ background: var(--uva-color-alert-regional-info-bg, var(--uva-teal-200, #c8f2f4));
208
+ }
209
+
210
+ /* Forced colors drop the backgrounds: every alert keeps a system-colour boundary; the
211
+ icons and hidden labels carry the severity. */
212
+ @media (forced-colors: active) {
213
+ .banner,
214
+ .alert,
215
+ .regional {
216
+ border: 1px solid CanvasText;
217
+ }
218
+ .alert {
219
+ border-left-width: 10px;
220
+ }
221
+ .dismiss {
222
+ color: ButtonText;
223
+ }
224
+ .dismiss:focus-visible,
225
+ .body a:focus-visible {
226
+ outline-color: Highlight;
227
+ }
228
+ }
229
+ `,
230
+ ]; }
231
+ constructor() {
232
+ super();
233
+ /** Which alerts to show: `header`, `list`, `regional`, `sitewide` (header and list) or `all`. */
234
+ this.show = 'all';
235
+ /**
236
+ * Alerts environment: `production` (default) or `staging`. Any other value logs one
237
+ * console warning and uses production. Ignored when `alerts-src` is set.
238
+ */
239
+ this.alertsEnv = 'production';
240
+ /** The level of each list alert's title heading, 1 to 6 (default 2). */
241
+ this.headingLevel = DEFAULT_LEVEL;
242
+ /** The headless element's last state. */
243
+ this.data = EMPTY;
244
+ this.lastCount = 0;
245
+ // A link clicked in an alert's body (the URL is not sent). composedPath() finds it in
246
+ // shadow and light DOM alike.
247
+ this.addEventListener('click', (e) => {
248
+ const path = e.composedPath();
249
+ const link = path.find((n) => n instanceof Element && n.matches('a[href]'));
250
+ const body = path.find((n) => n instanceof HTMLElement && n.matches('.body[data-uuid]'));
251
+ if (!link || !body || !this.renderRoot.contains(body))
252
+ return;
253
+ const a = this.shown().find((x) => x.alert.uuid === body.dataset.uuid);
254
+ if (a)
255
+ trackEvent(this, ['site-alerts', 'link-click', a.piece]);
256
+ });
257
+ }
258
+ /** Every alert this element shows, with its analytics label, `<severity>: <title>`. */
259
+ shown() {
260
+ const d = this.data;
261
+ const label = (a, part) => part === 'header'
262
+ ? 'Header'
263
+ : part === 'regional'
264
+ ? `Regional ${a.severity === 'alert3' ? 'information' : 'warning'}`
265
+ : SEVERITY[severityOf(a)].label.slice(0, -1);
266
+ const of = (alerts, part) => alerts.map((alert) => ({ alert, piece: cap(`${label(alert, part)}: ${alert.title}`) }));
267
+ return [
268
+ ...of(this.has('header') ? d.headerAlerts : [], 'header'),
269
+ ...of(this.list, 'list'),
270
+ ...of(this.has('regional') ? d.regionalAlerts : [], 'regional'),
271
+ ];
272
+ }
273
+ /** A content impression for each alert shown, once per alert per page view. */
274
+ reportImpressions() {
275
+ const seen = impressions(this.ownerDocument);
276
+ for (const { alert, piece } of this.shown()) {
277
+ if (seen.has(alert.uuid))
278
+ continue;
279
+ seen.add(alert.uuid);
280
+ trackContent(this, { name: 'Library alert', piece });
281
+ }
282
+ }
283
+ createRenderRoot() {
284
+ const root = super.createRenderRoot();
285
+ if (root instanceof ShadowRoot && this.noStyle) {
286
+ const sheet = shadowStructure.styleSheet;
287
+ if (sheet)
288
+ root.adoptedStyleSheets = [sheet];
289
+ }
290
+ return root;
291
+ }
292
+ connectedCallback() {
293
+ super.connectedCallback();
294
+ if (this.lightDom && this.noStyle) {
295
+ const node = this.getRootNode();
296
+ installLightDomStyles(`${this.localName}::structure`, unsafeCSS(structuralRules(this.localName)), {
297
+ root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,
298
+ scope: false,
299
+ });
300
+ }
301
+ // Reconnected: subscribe again in updated().
302
+ if (this.hasUpdated)
303
+ this.requestUpdate();
304
+ }
305
+ disconnectedCallback() {
306
+ super.disconnectedCallback();
307
+ this.sub?.release();
308
+ this.sub = undefined;
309
+ this.closed?.off();
310
+ this.closed = undefined;
311
+ }
312
+ /** The alerts base URL in use, from `alerts-src` or `alerts-env`. */
313
+ get base() {
314
+ const uri = this.ownerDocument.baseURI;
315
+ try {
316
+ return alertsBase(this.alertsEnv, this.alertsSrc, uri);
317
+ }
318
+ catch {
319
+ return alertsBase(this.alertsEnv, null, uri);
320
+ }
321
+ }
322
+ get level() {
323
+ const n = Math.trunc(Number(this.headingLevel));
324
+ return n >= 1 && n <= 6 ? n : DEFAULT_LEVEL;
325
+ }
326
+ has(part) {
327
+ const s = this.show || 'all';
328
+ if (s === 'sitewide')
329
+ return part !== 'regional';
330
+ return s === part || !['header', 'list', 'regional'].includes(s);
331
+ }
332
+ /** List alerts, most severe first (the headless element's order within a severity). */
333
+ get list() {
334
+ if (!this.has('list'))
335
+ return [];
336
+ // As library.virginia.edu: every sitewide alert but the header ones, until the reader
337
+ // closes it here. Information alerts are always "seen" by the headless element (Virgo's
338
+ // rule), so its seen list hides only Warnings (dismissed on another page using it).
339
+ const seen = new Set(this.data.seenAlerts);
340
+ const closed = this.closed?.store;
341
+ return this.data.alerts
342
+ .filter((a) => a.severity !== 'alert4' &&
343
+ !closed?.has(a.uuid) &&
344
+ !(a.severity === 'alert2' && seen.has(a.uuid)))
345
+ .sort((a, b) => severityOf(a).localeCompare(severityOf(b)));
346
+ }
347
+ get count() {
348
+ const d = this.data;
349
+ return ((this.has('header') ? d.headerAlerts.length : 0) +
350
+ this.list.length +
351
+ (this.has('regional') ? d.regionalAlerts.length : 0));
352
+ }
353
+ willUpdate(changed) {
354
+ // Before rendering, so the first render already knows what the reader closed.
355
+ const closedKey = dismissedKey(this.storageKey?.trim());
356
+ if (this.isConnected && this.closed?.key !== closedKey && this.ownerDocument.defaultView) {
357
+ this.closed?.off();
358
+ const store = dismissedStore(this.ownerDocument.defaultView, closedKey);
359
+ this.closed = { key: closedKey, store, off: store.subscribe(() => this.requestUpdate()) };
360
+ }
361
+ if (changed.has('alertsEnv') && this.alertsEnv && !isAlertsEnv(this.alertsEnv)) {
362
+ console.warn(`${this.localName}: unknown alerts-env "${this.alertsEnv}"; using production. Valid values: production, staging.`);
363
+ }
364
+ if (changed.has('alertsSrc') && this.alertsSrc?.trim()) {
365
+ try {
366
+ alertsBase(this.alertsEnv, this.alertsSrc, this.ownerDocument.baseURI);
367
+ }
368
+ catch {
369
+ console.warn(`${this.localName}: alerts-src "${this.alertsSrc}" is not a URL; ignoring it.`);
370
+ }
371
+ }
372
+ }
373
+ updated(changed) {
374
+ super.updated(changed);
375
+ if (this.isConnected) {
376
+ const base = this.base || ALERTS_PRODUCTION_SRC;
377
+ const key = `${base}\n${this.storageKey?.trim() ?? ''}`;
378
+ if (this.sub?.key !== key) {
379
+ this.sub?.release();
380
+ this.sub = subscribeAlerts(this.ownerDocument, base, this.storageKey, (s) => {
381
+ this.data = s;
382
+ // Forget closed alerts that are gone, once there is data to compare with.
383
+ // An empty list is never trusted (data still loading, or a transient blip).
384
+ if ((s.status === 'live' || s.status === 'polling') && s.alerts.length)
385
+ this.closed?.store.keepOnly(s.alerts.map((a) => a.uuid));
386
+ });
387
+ }
388
+ }
389
+ this.fillBodies();
390
+ if (this.isConnected)
391
+ this.reportImpressions();
392
+ this.moveFocus();
393
+ const count = this.count;
394
+ this.toggleAttribute('data-empty', !count);
395
+ if (count !== this.lastCount) {
396
+ this.lastCount = count;
397
+ this.dispatchEvent(new CustomEvent('site-alerts-change', { detail: { count }, bubbles: true, composed: true }));
398
+ }
399
+ }
400
+ onDismiss(a, index) {
401
+ this.pendingFocus = { uuid: a.uuid, index };
402
+ const shown = this.shown().find((x) => x.alert.uuid === a.uuid);
403
+ if (shown)
404
+ trackEvent(this, ['site-alerts', 'dismiss', shown.piece]);
405
+ // Recorded here (Information alerts are already "seen" by the headless element); a
406
+ // Warning is also dismissed there, so pages that use its seen list agree.
407
+ this.closed?.store.add(a.uuid);
408
+ if (severityOf(a) !== 'alert3')
409
+ this.sub?.dismiss(a.uuid);
410
+ }
411
+ /**
412
+ * After a dismissal has removed its alert: the alert now in its place (or the last one)
413
+ * gets focus, on its dismiss button if it has one; with none left, the page's `<main>`.
414
+ * Only while focus was lost with the button (or is still inside this element).
415
+ */
416
+ moveFocus() {
417
+ const pending = this.pendingFocus;
418
+ if (!pending)
419
+ return;
420
+ const list = this.list;
421
+ // Still listed after the update: the dismissal did nothing (already gone from the data,
422
+ // or not dismissible), so drop the request rather than let a later update move focus.
423
+ this.pendingFocus = undefined;
424
+ if (list.some((a) => a.uuid === pending.uuid))
425
+ return;
426
+ const doc = this.ownerDocument;
427
+ let active = doc.activeElement;
428
+ while (active?.shadowRoot?.activeElement)
429
+ active = active.shadowRoot.activeElement;
430
+ if (active && active !== doc.body && !this.renderRoot.contains(active) && active !== this)
431
+ return;
432
+ const alerts = [...this.renderRoot.querySelectorAll('.list > .alert')];
433
+ const next = alerts[Math.min(pending.index, alerts.length - 1)];
434
+ if (next) {
435
+ const button = next.querySelector('.dismiss');
436
+ if (button)
437
+ return button.focus();
438
+ next.tabIndex = -1;
439
+ return next.focus();
440
+ }
441
+ const main = this.findMain();
442
+ if (main) {
443
+ if (!main.hasAttribute('tabindex'))
444
+ main.tabIndex = -1;
445
+ main.focus();
446
+ }
447
+ }
448
+ /** The nearest `<main>`: in this element's tree, else in each enclosing one up to the document. */
449
+ findMain() {
450
+ let root = this.getRootNode();
451
+ for (;;) {
452
+ const main = root.querySelector('main');
453
+ if (main)
454
+ return main;
455
+ if (!(root instanceof ShadowRoot))
456
+ return null;
457
+ root = root.host.getRootNode();
458
+ }
459
+ }
460
+ /** An alert's body: filled in updated(), so Lit never manages its content. */
461
+ body(a) {
462
+ return html `<div class="body" data-uuid=${a.uuid}></div>`;
463
+ }
464
+ /** Insert each shown alert's body HTML into its (keyed, so stable) body element. */
465
+ fillBodies() {
466
+ const d = this.data;
467
+ const html = new Map([...d.alerts, ...d.regionalAlerts].map((a) => [a.uuid, a.body]));
468
+ for (const el of this.renderRoot.querySelectorAll('.body[data-uuid]')) {
469
+ const body = html.get(el.dataset.uuid);
470
+ if (body !== undefined)
471
+ setBody(el, body);
472
+ }
473
+ }
474
+ /** The header banner (library.virginia.edu's alert4): a polite status row. */
475
+ renderBanner(alerts) {
476
+ return html `<div class="banner" role="status">
477
+ ${repeat(alerts, (a) => a.uuid, (a) => html `<div class="entry"><span class="title">${a.title}:</span> ${this.body(a)}</div>`)}
478
+ </div>`;
479
+ }
480
+ /** One list alert: icon, heading with its severity in text, body, dismiss button. */
481
+ renderAlert(a, index) {
482
+ const sev = severityOf(a);
483
+ const { label, icon } = SEVERITY[sev];
484
+ const dismissible = sev !== 'alert1';
485
+ const h = unsafeStatic(`h${this.level}`);
486
+ return html `<div
487
+ class="alert ${sev} ${dismissible ? 'dismissible' : ''}"
488
+ role=${sev === 'alert1' ? 'alert' : nothing}
489
+ >
490
+ ${icon}
491
+ <${h} class="title"><span class="visually-hidden">${label} </span>${a.title}</${h}>
492
+ ${this.body(a)}
493
+ ${dismissible
494
+ ? html `<button
495
+ class="dismiss"
496
+ type="button"
497
+ aria-label="Dismiss alert: ${a.title}"
498
+ @click=${() => this.onDismiss(a, index)}
499
+ >
500
+ ${closeIcon}
501
+ </button>`
502
+ : nothing}
503
+ </div>`;
504
+ }
505
+ /** A regional alert (.uva-alert--r1, or --r2 for information), its severity in text. */
506
+ renderRegional(a) {
507
+ const info = a.severity === 'alert3';
508
+ return html `<div class="regional ${info ? 'info' : ''}">
509
+ <span class="visually-hidden">${info ? 'Information:' : 'Warning:'} </span>${this.body(a)}
510
+ </div>`;
511
+ }
512
+ render() {
513
+ const d = this.data;
514
+ const header = this.has('header') ? d.headerAlerts : [];
515
+ const list = this.list;
516
+ const regional = this.has('regional') ? d.regionalAlerts : [];
517
+ return html `${header.length ? this.renderBanner(header) : nothing}${list.length
518
+ ? html `<div class="list" aria-live="polite">
519
+ ${repeat(list, (a) => a.uuid, (a, i) => this.renderAlert(a, i))}
520
+ </div>`
521
+ : nothing}${repeat(regional, (a) => a.uuid, (a) => this.renderRegional(a))}`;
522
+ }
523
+ }
524
+ __decorate([
525
+ property({ type: String })
526
+ ], SiteAlerts.prototype, "show", void 0);
527
+ __decorate([
528
+ property({ type: String, attribute: 'alerts-env' })
529
+ ], SiteAlerts.prototype, "alertsEnv", void 0);
530
+ __decorate([
531
+ property({ type: String, attribute: 'alerts-src' })
532
+ ], SiteAlerts.prototype, "alertsSrc", void 0);
533
+ __decorate([
534
+ property({ type: Number, attribute: 'heading-level' })
535
+ ], SiteAlerts.prototype, "headingLevel", void 0);
536
+ __decorate([
537
+ property({ type: String, attribute: 'storage-key' })
538
+ ], SiteAlerts.prototype, "storageKey", void 0);
539
+ __decorate([
540
+ state()
541
+ ], SiteAlerts.prototype, "data", void 0);
542
+ //# sourceMappingURL=SiteAlerts.js.map