@wral/active-alerts 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/define.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { W as t } from "./wral-active-alerts-BG8GK-Nj.js";
1
+ import { W as t } from "./wral-active-alerts-C_bQfb95.js";
2
2
  function i() {
3
3
  const e = globalThis?.customElements;
4
4
  e && (e.get("wral-active-alerts") || e.define("wral-active-alerts", t));
@@ -3,7 +3,7 @@
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- const k = globalThis, L = k.ShadowRoot && (k.ShadyCSS === void 0 || k.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, j = Symbol(), V = /* @__PURE__ */ new WeakMap();
6
+ const H = globalThis, L = H.ShadowRoot && (H.ShadyCSS === void 0 || H.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, j = Symbol(), V = /* @__PURE__ */ new WeakMap();
7
7
  let tt = class {
8
8
  constructor(t, e, s) {
9
9
  if (this._$cssResult$ = !0, s !== j) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
@@ -32,7 +32,7 @@ const at = (i) => new tt(typeof i == "string" ? i : i + "", void 0, j), lt = (i,
32
32
  }, ht = (i, t) => {
33
33
  if (L) i.adoptedStyleSheets = t.map(((e) => e instanceof CSSStyleSheet ? e : e.styleSheet));
34
34
  else for (const e of t) {
35
- const s = document.createElement("style"), r = k.litNonce;
35
+ const s = document.createElement("style"), r = H.litNonce;
36
36
  r !== void 0 && s.setAttribute("nonce", r), s.textContent = e.cssText, i.appendChild(s);
37
37
  }
38
38
  }, q = L ? (i) => i : (i) => i instanceof CSSStyleSheet ? ((t) => {
@@ -45,10 +45,10 @@ const at = (i) => new tt(typeof i == "string" ? i : i + "", void 0, j), lt = (i,
45
45
  * Copyright 2017 Google LLC
46
46
  * SPDX-License-Identifier: BSD-3-Clause
47
47
  */
48
- const { is: ct, defineProperty: dt, getOwnPropertyDescriptor: pt, getOwnPropertyNames: ut, getOwnPropertySymbols: ft, getPrototypeOf: mt } = Object, I = globalThis, F = I.trustedTypes, $t = F ? F.emptyScript : "", gt = I.reactiveElementPolyfillSupport, x = (i, t) => i, z = { toAttribute(i, t) {
48
+ const { is: ct, defineProperty: dt, getOwnPropertyDescriptor: pt, getOwnPropertyNames: ut, getOwnPropertySymbols: ft, getPrototypeOf: $t } = Object, k = globalThis, F = k.trustedTypes, mt = F ? F.emptyScript : "", gt = k.reactiveElementPolyfillSupport, x = (i, t) => i, z = { toAttribute(i, t) {
49
49
  switch (t) {
50
50
  case Boolean:
51
- i = i ? $t : null;
51
+ i = i ? mt : null;
52
52
  break;
53
53
  case Object:
54
54
  case Array:
@@ -74,7 +74,7 @@ const { is: ct, defineProperty: dt, getOwnPropertyDescriptor: pt, getOwnProperty
74
74
  }
75
75
  return e;
76
76
  } }, et = (i, t) => !ct(i, t), K = { attribute: !0, type: String, converter: z, reflect: !1, useDefault: !1, hasChanged: et };
77
- Symbol.metadata ??= Symbol("metadata"), I.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
77
+ Symbol.metadata ??= Symbol("metadata"), k.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
78
78
  let b = class extends HTMLElement {
79
79
  static addInitializer(t) {
80
80
  this._$Ei(), (this.l ??= []).push(t);
@@ -95,8 +95,8 @@ let b = class extends HTMLElement {
95
95
  this[e] = o;
96
96
  } };
97
97
  return { get: r, set(o) {
98
- const c = r?.call(this);
99
- n?.call(this, o), this.requestUpdate(t, c, s);
98
+ const d = r?.call(this);
99
+ n?.call(this, o), this.requestUpdate(t, d, s);
100
100
  }, configurable: !0, enumerable: !0 };
101
101
  }
102
102
  static getPropertyOptions(t) {
@@ -104,7 +104,7 @@ let b = class extends HTMLElement {
104
104
  }
105
105
  static _$Ei() {
106
106
  if (this.hasOwnProperty(x("elementProperties"))) return;
107
- const t = mt(this);
107
+ const t = $t(this);
108
108
  t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
109
109
  }
110
110
  static finalize() {
@@ -181,8 +181,8 @@ let b = class extends HTMLElement {
181
181
  if (r !== void 0 && this._$Em !== r) {
182
182
  const n = s.getPropertyOptions(r), o = typeof n.converter == "function" ? { fromAttribute: n.converter } : n.converter?.fromAttribute !== void 0 ? n.converter : z;
183
183
  this._$Em = r;
184
- const c = o.fromAttribute(e, n.type);
185
- this[r] = c ?? this._$Ej?.get(r) ?? c, this._$Em = null;
184
+ const d = o.fromAttribute(e, n.type);
185
+ this[r] = d ?? this._$Ej?.get(r) ?? d, this._$Em = null;
186
186
  }
187
187
  }
188
188
  requestUpdate(t, e, s) {
@@ -218,8 +218,8 @@ let b = class extends HTMLElement {
218
218
  }
219
219
  const s = this.constructor.elementProperties;
220
220
  if (s.size > 0) for (const [r, n] of s) {
221
- const { wrapped: o } = n, c = this[r];
222
- o !== !0 || this._$AL.has(r) || c === void 0 || this.C(r, void 0, n, c);
221
+ const { wrapped: o } = n, d = this[r];
222
+ o !== !0 || this._$AL.has(r) || d === void 0 || this.C(r, void 0, n, d);
223
223
  }
224
224
  }
225
225
  let t = !1;
@@ -256,15 +256,15 @@ let b = class extends HTMLElement {
256
256
  firstUpdated(t) {
257
257
  }
258
258
  };
259
- b.elementStyles = [], b.shadowRootOptions = { mode: "open" }, b[x("elementProperties")] = /* @__PURE__ */ new Map(), b[x("finalized")] = /* @__PURE__ */ new Map(), gt?.({ ReactiveElement: b }), (I.reactiveElementVersions ??= []).push("2.1.1");
259
+ b.elementStyles = [], b.shadowRootOptions = { mode: "open" }, b[x("elementProperties")] = /* @__PURE__ */ new Map(), b[x("finalized")] = /* @__PURE__ */ new Map(), gt?.({ ReactiveElement: b }), (k.reactiveElementVersions ??= []).push("2.1.1");
260
260
  /**
261
261
  * @license
262
262
  * Copyright 2017 Google LLC
263
263
  * SPDX-License-Identifier: BSD-3-Clause
264
264
  */
265
- const D = globalThis, H = D.trustedTypes, J = H ? H.createPolicy("lit-html", { createHTML: (i) => i }) : void 0, st = "$lit$", $ = `lit$${Math.random().toFixed(9).slice(2)}$`, it = "?" + $, _t = `<${it}>`, A = document, P = () => A.createComment(""), U = (i) => i === null || typeof i != "object" && typeof i != "function", B = Array.isArray, yt = (i) => B(i) || typeof i?.[Symbol.iterator] == "function", R = `[
265
+ const D = globalThis, I = D.trustedTypes, J = I ? I.createPolicy("lit-html", { createHTML: (i) => i }) : void 0, st = "$lit$", m = `lit$${Math.random().toFixed(9).slice(2)}$`, it = "?" + m, _t = `<${it}>`, A = document, P = () => A.createComment(""), U = (i) => i === null || typeof i != "object" && typeof i != "function", B = Array.isArray, yt = (i) => B(i) || typeof i?.[Symbol.iterator] == "function", R = `[
266
266
  \f\r]`, w = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Z = /-->/g, G = />/g, g = RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^
267
- \f\r"'\`<>=]|("|')|))|$)`, "g"), Q = /'/g, X = /"/g, rt = /^(?:script|style|textarea|title)$/i, At = (i) => (t, ...e) => ({ _$litType$: i, strings: t, values: e }), f = At(1), E = Symbol.for("lit-noChange"), p = Symbol.for("lit-nothing"), Y = /* @__PURE__ */ new WeakMap(), y = A.createTreeWalker(A, 129);
267
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), Q = /'/g, X = /"/g, rt = /^(?:script|style|textarea|title)$/i, At = (i) => (t, ...e) => ({ _$litType$: i, strings: t, values: e }), $ = At(1), E = Symbol.for("lit-noChange"), p = Symbol.for("lit-nothing"), Y = /* @__PURE__ */ new WeakMap(), y = A.createTreeWalker(A, 129);
268
268
  function nt(i, t) {
269
269
  if (!B(i) || !i.hasOwnProperty("raw")) throw Error("invalid template strings array");
270
270
  return J !== void 0 ? J.createHTML(t) : t;
@@ -272,12 +272,12 @@ function nt(i, t) {
272
272
  const vt = (i, t) => {
273
273
  const e = i.length - 1, s = [];
274
274
  let r, n = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", o = w;
275
- for (let c = 0; c < e; c++) {
276
- const a = i[c];
277
- let d, l, h = -1, u = 0;
278
- for (; u < a.length && (o.lastIndex = u, l = o.exec(a), l !== null); ) u = o.lastIndex, o === w ? l[1] === "!--" ? o = Z : l[1] !== void 0 ? o = G : l[2] !== void 0 ? (rt.test(l[2]) && (r = RegExp("</" + l[2], "g")), o = g) : l[3] !== void 0 && (o = g) : o === g ? l[0] === ">" ? (o = r ?? w, h = -1) : l[1] === void 0 ? h = -2 : (h = o.lastIndex - l[2].length, d = l[1], o = l[3] === void 0 ? g : l[3] === '"' ? X : Q) : o === X || o === Q ? o = g : o === Z || o === G ? o = w : (o = g, r = void 0);
279
- const m = o === g && i[c + 1].startsWith("/>") ? " " : "";
280
- n += o === w ? a + _t : h >= 0 ? (s.push(d), a.slice(0, h) + st + a.slice(h) + $ + m) : a + $ + (h === -2 ? c : m);
275
+ for (let d = 0; d < e; d++) {
276
+ const a = i[d];
277
+ let c, l, h = -1, u = 0;
278
+ for (; u < a.length && (o.lastIndex = u, l = o.exec(a), l !== null); ) u = o.lastIndex, o === w ? l[1] === "!--" ? o = Z : l[1] !== void 0 ? o = G : l[2] !== void 0 ? (rt.test(l[2]) && (r = RegExp("</" + l[2], "g")), o = g) : l[3] !== void 0 && (o = g) : o === g ? l[0] === ">" ? (o = r ?? w, h = -1) : l[1] === void 0 ? h = -2 : (h = o.lastIndex - l[2].length, c = l[1], o = l[3] === void 0 ? g : l[3] === '"' ? X : Q) : o === X || o === Q ? o = g : o === Z || o === G ? o = w : (o = g, r = void 0);
279
+ const f = o === g && i[d + 1].startsWith("/>") ? " " : "";
280
+ n += o === w ? a + _t : h >= 0 ? (s.push(c), a.slice(0, h) + st + a.slice(h) + m + f) : a + m + (h === -2 ? d : f);
281
281
  }
282
282
  return [nt(i, n + (i[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s];
283
283
  };
@@ -286,29 +286,29 @@ class T {
286
286
  let r;
287
287
  this.parts = [];
288
288
  let n = 0, o = 0;
289
- const c = t.length - 1, a = this.parts, [d, l] = vt(t, e);
290
- if (this.el = T.createElement(d, s), y.currentNode = this.el.content, e === 2 || e === 3) {
289
+ const d = t.length - 1, a = this.parts, [c, l] = vt(t, e);
290
+ if (this.el = T.createElement(c, s), y.currentNode = this.el.content, e === 2 || e === 3) {
291
291
  const h = this.el.content.firstChild;
292
292
  h.replaceWith(...h.childNodes);
293
293
  }
294
- for (; (r = y.nextNode()) !== null && a.length < c; ) {
294
+ for (; (r = y.nextNode()) !== null && a.length < d; ) {
295
295
  if (r.nodeType === 1) {
296
296
  if (r.hasAttributes()) for (const h of r.getAttributeNames()) if (h.endsWith(st)) {
297
- const u = l[o++], m = r.getAttribute(h).split($), N = /([.?@])?(.*)/.exec(u);
298
- a.push({ type: 1, index: n, name: N[2], strings: m, ctor: N[1] === "." ? Et : N[1] === "?" ? St : N[1] === "@" ? wt : M }), r.removeAttribute(h);
299
- } else h.startsWith($) && (a.push({ type: 6, index: n }), r.removeAttribute(h));
297
+ const u = l[o++], f = r.getAttribute(h).split(m), N = /([.?@])?(.*)/.exec(u);
298
+ a.push({ type: 1, index: n, name: N[2], strings: f, ctor: N[1] === "." ? Et : N[1] === "?" ? St : N[1] === "@" ? wt : M }), r.removeAttribute(h);
299
+ } else h.startsWith(m) && (a.push({ type: 6, index: n }), r.removeAttribute(h));
300
300
  if (rt.test(r.tagName)) {
301
- const h = r.textContent.split($), u = h.length - 1;
301
+ const h = r.textContent.split(m), u = h.length - 1;
302
302
  if (u > 0) {
303
- r.textContent = H ? H.emptyScript : "";
304
- for (let m = 0; m < u; m++) r.append(h[m], P()), y.nextNode(), a.push({ type: 2, index: ++n });
303
+ r.textContent = I ? I.emptyScript : "";
304
+ for (let f = 0; f < u; f++) r.append(h[f], P()), y.nextNode(), a.push({ type: 2, index: ++n });
305
305
  r.append(h[u], P());
306
306
  }
307
307
  }
308
308
  } else if (r.nodeType === 8) if (r.data === it) a.push({ type: 2, index: n });
309
309
  else {
310
310
  let h = -1;
311
- for (; (h = r.data.indexOf($, h + 1)) !== -1; ) a.push({ type: 7, index: n }), h += $.length - 1;
311
+ for (; (h = r.data.indexOf(m, h + 1)) !== -1; ) a.push({ type: 7, index: n }), h += m.length - 1;
312
312
  }
313
313
  n++;
314
314
  }
@@ -337,11 +337,11 @@ class bt {
337
337
  u(t) {
338
338
  const { el: { content: e }, parts: s } = this._$AD, r = (t?.creationScope ?? A).importNode(e, !0);
339
339
  y.currentNode = r;
340
- let n = y.nextNode(), o = 0, c = 0, a = s[0];
340
+ let n = y.nextNode(), o = 0, d = 0, a = s[0];
341
341
  for (; a !== void 0; ) {
342
342
  if (o === a.index) {
343
- let d;
344
- a.type === 2 ? d = new O(n, n.nextSibling, this, t) : a.type === 1 ? d = new a.ctor(n, a.name, a.strings, this, t) : a.type === 6 && (d = new xt(n, this, t)), this._$AV.push(d), a = s[++c];
343
+ let c;
344
+ a.type === 2 ? c = new O(n, n.nextSibling, this, t) : a.type === 1 ? c = new a.ctor(n, a.name, a.strings, this, t) : a.type === 6 && (c = new xt(n, this, t)), this._$AV.push(c), a = s[++d];
345
345
  }
346
346
  o !== a?.index && (n = y.nextNode(), o++);
347
347
  }
@@ -426,9 +426,9 @@ class M {
426
426
  let o = !1;
427
427
  if (n === void 0) t = S(this, t, e, 0), o = !U(t) || t !== this._$AH && t !== E, o && (this._$AH = t);
428
428
  else {
429
- const c = t;
430
- let a, d;
431
- for (t = n[0], a = 0; a < n.length - 1; a++) d = S(this, c[s + a], e, a), d === E && (d = this._$AH[a]), o ||= !U(d) || d !== this._$AH[a], d === p ? t = p : t !== p && (t += (d ?? "") + n[a + 1]), this._$AH[a] = d;
429
+ const d = t;
430
+ let a, c;
431
+ for (t = n[0], a = 0; a < n.length - 1; a++) c = S(this, d[s + a], e, a), c === E && (c = this._$AH[a]), o ||= !U(c) || c !== this._$AH[a], c === p ? t = p : t !== p && (t += (c ?? "") + n[a + 1]), this._$AH[a] = c;
432
432
  }
433
433
  o && !r && this.j(t);
434
434
  }
@@ -526,9 +526,9 @@ function Tt(i) {
526
526
  api: _(v, i),
527
527
  listActiveAlerts: _(Ot, i),
528
528
  getActiveAlert: _(Nt, i),
529
- listAlerts: _(kt, i),
530
- getAlert: _(Ht, i),
531
- sendAlert: _(It, i),
529
+ listAlerts: _(Ht, i),
530
+ getAlert: _(It, i),
531
+ sendAlert: _(kt, i),
532
532
  cancelAlert: _(Mt, i)
533
533
  };
534
534
  }
@@ -540,13 +540,13 @@ function Nt(i, t) {
540
540
  const e = Object.assign({}, i, { apiKey: void 0 });
541
541
  return v(e, `/v1/active/alerts/${t}`);
542
542
  }
543
- function kt(i) {
543
+ function Ht(i) {
544
544
  return v(i, "/v1/alerts");
545
545
  }
546
- function Ht(i, t) {
546
+ function It(i, t) {
547
547
  return v(i, `/v1/alerts/${t}`);
548
548
  }
549
- function It(i, t) {
549
+ function kt(i, t) {
550
550
  return v(i, "/v1/alerts", {
551
551
  method: "POST",
552
552
  body: t
@@ -562,10 +562,10 @@ async function v(i, t, e) {
562
562
  "Content-Type": "application/json"
563
563
  };
564
564
  i.apiKey && (o.Authorization = `Bearer ${i.apiKey}`);
565
- const c = Object.assign({}, e, {
565
+ const d = Object.assign({}, e, {
566
566
  headers: Object.assign({}, o, e?.headers),
567
567
  body: e?.body ? JSON.stringify(e.body) : void 0
568
- }), a = await fetch(n.toString(), c);
568
+ }), a = await fetch(n.toString(), d);
569
569
  if (!a.ok) {
570
570
  const l = new Error("API request failed.", { cause: a });
571
571
  if (l.status = a.status, l.statusText = a.statusText, l.url = n.toString(), l.headers = a.headers, l.bodyUsed = a.bodyUsed, a.headers.get("Content-Type")?.includes("application/json"))
@@ -578,8 +578,8 @@ async function v(i, t, e) {
578
578
  }
579
579
  if (a.status === 204)
580
580
  return;
581
- const d = await a.json();
582
- return d.caption && console.warn("Alert API provided a value with a caption field. The caption field is deprecated and will be removed."), (d?.items || []).some((l) => l.caption) && console.warn("Alert API provided an item with a caption field. The caption field is deprecated and will be removed."), d;
581
+ const c = await a.json();
582
+ return c.caption && console.warn("Alert API provided a value with a caption field. The caption field is deprecated and will be removed."), (c?.items || []).some((l) => l.caption) && console.warn("Alert API provided an item with a caption field. The caption field is deprecated and will be removed."), c;
583
583
  }
584
584
  const Rt = {
585
585
  lg: 1366
@@ -664,13 +664,26 @@ class ot extends C {
664
664
  gap: .75rem;
665
665
  }
666
666
  .alert {
667
+ margin: 0;
668
+ }
669
+ .alert-card {
667
670
  background: #fff;
668
671
  border: 1px solid #e5e5e5;
669
672
  padding: .9rem 1rem;
670
673
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
671
674
  display: grid;
672
- grid-template-columns: 112px 1fr;
675
+ grid-template-columns: 240px 1fr;
673
676
  gap: .9rem;
677
+ color: inherit;
678
+ text-decoration: none;
679
+ }
680
+ .alert-card:hover .title,
681
+ .alert-card:focus-visible .title {
682
+ text-decoration: underline;
683
+ }
684
+ .alert-card:focus-visible {
685
+ outline: 2px solid #000b27;
686
+ outline-offset: 2px;
674
687
  }
675
688
  .thumb {
676
689
  overflow: hidden;
@@ -711,7 +724,7 @@ class ot extends C {
711
724
  .label.recommended-story {
712
725
  background-color: #2594e3;
713
726
  }
714
- a.title {
727
+ .title {
715
728
  color: inherit;
716
729
  font-size: 1.0625rem;
717
730
  line-height: 1.35;
@@ -719,16 +732,6 @@ class ot extends C {
719
732
  font-weight: 700;
720
733
  text-decoration: none;
721
734
  }
722
- a.title:hover,
723
- a.title:focus-visible {
724
- text-decoration: underline;
725
- }
726
- .title.no-link {
727
- font-size: 1.0625rem;
728
- line-height: 1.35;
729
- font-family: var(--heading-font-family, sans-serif);
730
- font-weight: 700;
731
- }
732
735
  .body {
733
736
  margin: 0;
734
737
  color: #323232;
@@ -756,14 +759,6 @@ class ot extends C {
756
759
  }
757
760
  @media (max-width: 720px) {
758
761
  .wrapper { padding: .75rem .75rem 1.25rem; }
759
- .alert {
760
- grid-template-columns: 1fr;
761
- padding: .85rem .9rem;
762
- }
763
- .alert-header {
764
- align-items: flex-start;
765
- flex-direction: column;
766
- }
767
762
  }
768
763
  `;
769
764
  async firstUpdated() {
@@ -806,49 +801,55 @@ class ot extends C {
806
801
  }
807
802
  render() {
808
803
  const { items: t, loading: e, error: s } = this, r = (n, o) => {
809
- const c = Bt(n.effectiveFrom), a = String(n.topic || "").trim().toLowerCase();
810
- return f`
811
- <li class="alert" data-index=${o} aria-label="Site Alert">
812
- <div class="thumb">
813
- <img
814
- src=${n.image}
815
- alt=${n.title}
816
- loading="lazy"
817
- >
804
+ const d = Bt(n.effectiveFrom), a = String(n.topic || "").trim().toLowerCase(), c = n.title || n.body, l = String(n.title || "").trim(), h = String(n.body || "").trim(), u = l && h && l !== h ? n.body : "", f = $`
805
+ <div class="thumb">
806
+ <img
807
+ src=${n.image}
808
+ alt=${n.title}
809
+ loading="lazy"
810
+ >
811
+ </div>
812
+ <div class="alert-body">
813
+ <div class="alert-header">
814
+ <div class="label ${a}">
815
+ ${jt(n.caption)}
818
816
  </div>
819
- <div class="alert-body">
820
- <div class="alert-header">
821
- <div class="label ${a}">
822
- ${jt(n.caption)}
823
- </div>
824
- ${c ? f`
825
- <span class="date">
826
- ${c}
827
- </span>
828
- ` : ""}
829
- </div>
830
- ${n.url ? f`
831
- <a class="title" href=${n.url}>${n.body || n.title}</a>
832
- ` : f`
833
- <div class="title no-link">${n.body || n.title}</div>
834
- `}
817
+ ${d ? $`
818
+ <span class="date">
819
+ ${d}
820
+ </span>
821
+ ` : ""}
822
+ </div>
823
+ <div class="title">${c}</div>
824
+ ${u ? $`<p class="body">${u}</p>` : ""}
825
+ </div>
826
+ `;
827
+ return $`
828
+ <li class="alert" data-index=${o} aria-label="Site Alert">
829
+ ${n.url ? $`
830
+ <a class="alert-card" href=${n.url} aria-label=${c}>
831
+ ${f}
832
+ </a>
833
+ ` : $`
834
+ <div class="alert-card">
835
+ ${f}
835
836
  </div>
836
- </li>
837
+ `}
838
+ </li>
837
839
  `;
838
840
  };
839
- return f`
841
+ return $`
840
842
  <div class="wrapper" role="region" aria-live="polite">
841
843
  <div class="heading">
842
- <span>Active Alerts</span>
843
- ${e ? f`<span class="pill">Loading…</span>` : ""}
844
+ ${e ? $`<span class="pill">Loading…</span>` : ""}
844
845
  </div>
845
846
 
846
- ${s ? f`<div class="status error">${s}</div>` : ""}
847
- ${!s && !e && !t.length ? f`
847
+ ${s ? $`<div class="status error">${s}</div>` : ""}
848
+ ${!s && !e && !t.length ? $`
848
849
  <div class="empty">No active alerts right now.</div>
849
850
  ` : ""}
850
851
 
851
- ${t.length ? f`
852
+ ${t.length ? $`
852
853
  <ul class="list">
853
854
  ${t.map(r)}
854
855
  </ul>
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { W as r, n as s, s as l } from "./wral-active-alerts-BG8GK-Nj.js";
1
+ import { W as r, n as s, s as l } from "./wral-active-alerts-C_bQfb95.js";
2
2
  export {
3
3
  r as WralActiveAlerts,
4
4
  s as normalizeAlert,
@@ -1,12 +1,12 @@
1
- import { LitElement as d, css as m, html as i } from "lit";
2
- import { createClient as f } from "@wral/sdk-alerts/v1";
3
- const p = {
1
+ import { LitElement as g, css as u, html as i } from "lit";
2
+ import { createClient as b } from "@wral/sdk-alerts/v1";
3
+ const v = {
4
4
  lg: 1366
5
- }, h = "https://api.wral.com/alerts/v1/active/alerts", g = "https://assets.wral.com/a1cc0e86-adab-48e9-bd80-703cd2c56aff?w=1200&h=630", u = (e) => String(e || "Alert").replace(/[^\p{L}\p{N}]/gu, " ").replace(/\s+/g, " ").trim() || "Alert", v = (e) => {
5
+ }, y = "https://api.wral.com/alerts/v1/active/alerts", x = "https://assets.wral.com/a1cc0e86-adab-48e9-bd80-703cd2c56aff?w=1200&h=630", $ = (e) => String(e || "Alert").replace(/[^\p{L}\p{N}]/gu, " ").replace(/\s+/g, " ").trim() || "Alert", I = (e) => {
6
6
  if (!e) return null;
7
7
  const t = e.link || e.url || e.href || "", s = e.title || e.headline || "";
8
8
  if (!s) return null;
9
- const a = String(e.topic || "").trim(), l = a.toLowerCase(), r = e.caption || a || "Alert", n = e.image || e.imageUrl || e.image_url || g;
9
+ const a = String(e.topic || "").trim(), l = a.toLowerCase(), r = e.caption || a || "Alert", n = e.image || e.imageUrl || e.image_url || x;
10
10
  return {
11
11
  url: t,
12
12
  title: s,
@@ -16,7 +16,7 @@ const p = {
16
16
  body: e.body || e.summary || "",
17
17
  effectiveFrom: e.effectiveFrom || e.effective_from || ""
18
18
  };
19
- }, b = (e) => {
19
+ }, A = (e) => {
20
20
  if (!e) return "";
21
21
  try {
22
22
  const t = new Date(e);
@@ -30,7 +30,7 @@ const p = {
30
30
  return "";
31
31
  }
32
32
  };
33
- class y extends d {
33
+ class _ extends g {
34
34
  static properties = {
35
35
  api: { type: String },
36
36
  items: { state: !0 },
@@ -39,16 +39,16 @@ class y extends d {
39
39
  refreshInterval: { type: Number, attribute: "refresh-interval" }
40
40
  };
41
41
  constructor() {
42
- super(), this.api = h, this.items = [], this.loading = !1, this.error = "", this.refreshInterval = 0, this._refreshId = null;
42
+ super(), this.api = y, this.items = [], this.loading = !1, this.error = "", this.refreshInterval = 0, this._refreshId = null;
43
43
  }
44
- static styles = m`
44
+ static styles = u`
45
45
  :host {
46
46
  display: block;
47
47
  background: #f7f5f4;
48
48
  color: #000b27;
49
49
  }
50
50
  .wrapper {
51
- max-width: ${p.lg}px;
51
+ max-width: ${v.lg}px;
52
52
  margin: 0 auto;
53
53
  padding: 1rem 1.25rem 1.5rem;
54
54
  }
@@ -83,13 +83,26 @@ class y extends d {
83
83
  gap: .75rem;
84
84
  }
85
85
  .alert {
86
+ margin: 0;
87
+ }
88
+ .alert-card {
86
89
  background: #fff;
87
90
  border: 1px solid #e5e5e5;
88
91
  padding: .9rem 1rem;
89
92
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
90
93
  display: grid;
91
- grid-template-columns: 112px 1fr;
94
+ grid-template-columns: 240px 1fr;
92
95
  gap: .9rem;
96
+ color: inherit;
97
+ text-decoration: none;
98
+ }
99
+ .alert-card:hover .title,
100
+ .alert-card:focus-visible .title {
101
+ text-decoration: underline;
102
+ }
103
+ .alert-card:focus-visible {
104
+ outline: 2px solid #000b27;
105
+ outline-offset: 2px;
93
106
  }
94
107
  .thumb {
95
108
  overflow: hidden;
@@ -130,7 +143,7 @@ class y extends d {
130
143
  .label.recommended-story {
131
144
  background-color: #2594e3;
132
145
  }
133
- a.title {
146
+ .title {
134
147
  color: inherit;
135
148
  font-size: 1.0625rem;
136
149
  line-height: 1.35;
@@ -138,16 +151,6 @@ class y extends d {
138
151
  font-weight: 700;
139
152
  text-decoration: none;
140
153
  }
141
- a.title:hover,
142
- a.title:focus-visible {
143
- text-decoration: underline;
144
- }
145
- .title.no-link {
146
- font-size: 1.0625rem;
147
- line-height: 1.35;
148
- font-family: var(--heading-font-family, sans-serif);
149
- font-weight: 700;
150
- }
151
154
  .body {
152
155
  margin: 0;
153
156
  color: #323232;
@@ -175,14 +178,6 @@ class y extends d {
175
178
  }
176
179
  @media (max-width: 720px) {
177
180
  .wrapper { padding: .75rem .75rem 1.25rem; }
178
- .alert {
179
- grid-template-columns: 1fr;
180
- padding: .85rem .9rem;
181
- }
182
- .alert-header {
183
- align-items: flex-start;
184
- flex-direction: column;
185
- }
186
181
  }
187
182
  `;
188
183
  async firstUpdated() {
@@ -198,7 +193,7 @@ class y extends d {
198
193
  t.has("api") && t.get("api") !== this.api && this.load(), t.has("refreshInterval") && this._setupInterval();
199
194
  }
200
195
  async fetchActiveAlerts() {
201
- return f({
196
+ return b({
202
197
  baseUrl: this.api.replace(/v1\/.*$/, "")
203
198
  }).listActiveAlerts();
204
199
  }
@@ -207,7 +202,7 @@ class y extends d {
207
202
  this.loading = !0, this.error = "";
208
203
  try {
209
204
  const t = await this.fetchActiveAlerts();
210
- this.items = (t?.items || []).map(v).filter(Boolean);
205
+ this.items = (t?.items || []).map(I).filter(Boolean);
211
206
  } catch (t) {
212
207
  console.error("[wral-active-alerts]", t), this.items = [], this.error = "Unable to load active alerts.";
213
208
  } finally {
@@ -225,40 +220,46 @@ class y extends d {
225
220
  }
226
221
  render() {
227
222
  const { items: t, loading: s, error: a } = this, l = (r, n) => {
228
- const o = b(r.effectiveFrom), c = String(r.topic || "").trim().toLowerCase();
223
+ const o = A(r.effectiveFrom), h = String(r.topic || "").trim().toLowerCase(), c = r.title || r.body, d = String(r.title || "").trim(), m = String(r.body || "").trim(), f = d && m && d !== m ? r.body : "", p = i`
224
+ <div class="thumb">
225
+ <img
226
+ src=${r.image}
227
+ alt=${r.title}
228
+ loading="lazy"
229
+ >
230
+ </div>
231
+ <div class="alert-body">
232
+ <div class="alert-header">
233
+ <div class="label ${h}">
234
+ ${$(r.caption)}
235
+ </div>
236
+ ${o ? i`
237
+ <span class="date">
238
+ ${o}
239
+ </span>
240
+ ` : ""}
241
+ </div>
242
+ <div class="title">${c}</div>
243
+ ${f ? i`<p class="body">${f}</p>` : ""}
244
+ </div>
245
+ `;
229
246
  return i`
230
247
  <li class="alert" data-index=${n} aria-label="Site Alert">
231
- <div class="thumb">
232
- <img
233
- src=${r.image}
234
- alt=${r.title}
235
- loading="lazy"
236
- >
237
- </div>
238
- <div class="alert-body">
239
- <div class="alert-header">
240
- <div class="label ${c}">
241
- ${u(r.caption)}
242
- </div>
243
- ${o ? i`
244
- <span class="date">
245
- ${o}
246
- </span>
247
- ` : ""}
248
- </div>
249
- ${r.url ? i`
250
- <a class="title" href=${r.url}>${r.body || r.title}</a>
251
- ` : i`
252
- <div class="title no-link">${r.body || r.title}</div>
253
- `}
248
+ ${r.url ? i`
249
+ <a class="alert-card" href=${r.url} aria-label=${c}>
250
+ ${p}
251
+ </a>
252
+ ` : i`
253
+ <div class="alert-card">
254
+ ${p}
254
255
  </div>
255
- </li>
256
+ `}
257
+ </li>
256
258
  `;
257
259
  };
258
260
  return i`
259
261
  <div class="wrapper" role="region" aria-live="polite">
260
262
  <div class="heading">
261
- <span>Active Alerts</span>
262
263
  ${s ? i`<span class="pill">Loading…</span>` : ""}
263
264
  </div>
264
265
 
@@ -276,9 +277,9 @@ class y extends d {
276
277
  `;
277
278
  }
278
279
  }
279
- globalThis?.customElements && !globalThis.customElements.get("wral-active-alerts") && globalThis.customElements.define("wral-active-alerts", y);
280
+ globalThis?.customElements && !globalThis.customElements.get("wral-active-alerts") && globalThis.customElements.define("wral-active-alerts", _);
280
281
  export {
281
- y as W,
282
- v as n,
283
- u as s
282
+ _ as W,
283
+ I as n,
284
+ $ as s
284
285
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wral/active-alerts",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "description": "Lit web component for rendering the current set of active WRAL alerts.",
6
6
  "author": "Dominick Jones <djones@wral.com>",