@wral/active-alerts 0.2.6 → 0.2.7

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-BrdwAfki.js";
1
+ import { W as t } from "./wral-active-alerts-CUTa46c9.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));
@@ -262,14 +262,14 @@ b.elementStyles = [], b.shadowRootOptions = { mode: "open" }, b[x("elementProper
262
262
  * Copyright 2017 Google LLC
263
263
  * SPDX-License-Identifier: BSD-3-Clause
264
264
  */
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 = `[
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}>`, v = document, P = () => v.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 }), $ = 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, vt = (i) => (t, ...e) => ({ _$litType$: i, strings: t, values: e }), $ = vt(1), E = Symbol.for("lit-noChange"), p = Symbol.for("lit-nothing"), Y = /* @__PURE__ */ new WeakMap(), y = v.createTreeWalker(v, 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;
271
271
  }
272
- const vt = (i, t) => {
272
+ const At = (i, t) => {
273
273
  const e = i.length - 1, s = [];
274
274
  let r, n = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", o = w;
275
275
  for (let d = 0; d < e; d++) {
@@ -286,7 +286,7 @@ class T {
286
286
  let r;
287
287
  this.parts = [];
288
288
  let n = 0, o = 0;
289
- const d = t.length - 1, a = this.parts, [c, l] = vt(t, e);
289
+ const d = t.length - 1, a = this.parts, [c, l] = At(t, e);
290
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);
@@ -314,7 +314,7 @@ class T {
314
314
  }
315
315
  }
316
316
  static createElement(t, e) {
317
- const s = A.createElement("template");
317
+ const s = v.createElement("template");
318
318
  return s.innerHTML = t, s;
319
319
  }
320
320
  }
@@ -335,7 +335,7 @@ class bt {
335
335
  return this._$AM._$AU;
336
336
  }
337
337
  u(t) {
338
- const { el: { content: e }, parts: s } = this._$AD, r = (t?.creationScope ?? A).importNode(e, !0);
338
+ const { el: { content: e }, parts: s } = this._$AD, r = (t?.creationScope ?? v).importNode(e, !0);
339
339
  y.currentNode = r;
340
340
  let n = y.nextNode(), o = 0, d = 0, a = s[0];
341
341
  for (; a !== void 0; ) {
@@ -345,7 +345,7 @@ class bt {
345
345
  }
346
346
  o !== a?.index && (n = y.nextNode(), o++);
347
347
  }
348
- return y.currentNode = A, r;
348
+ return y.currentNode = v, r;
349
349
  }
350
350
  p(t) {
351
351
  let e = 0;
@@ -380,7 +380,7 @@ class O {
380
380
  this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
381
381
  }
382
382
  _(t) {
383
- this._$AH !== p && U(this._$AH) ? this._$AA.nextSibling.data = t : this.T(A.createTextNode(t)), this._$AH = t;
383
+ this._$AH !== p && U(this._$AH) ? this._$AA.nextSibling.data = t : this.T(v.createTextNode(t)), this._$AH = t;
384
384
  }
385
385
  $(t) {
386
386
  const { values: e, _$litType$: s } = t, r = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = T.createElement(nt(s.h, s.h[0]), this.options)), s);
@@ -523,7 +523,7 @@ const _ = (i, ...t) => (...e) => i(...t, ...e);
523
523
  function Tt(i) {
524
524
  return {
525
525
  // Underlying mechanism to use the REST URLs directly.
526
- api: _(v, i),
526
+ api: _(A, i),
527
527
  listActiveAlerts: _(Ot, i),
528
528
  getActiveAlert: _(Nt, i),
529
529
  listAlerts: _(Ht, i),
@@ -534,30 +534,30 @@ function Tt(i) {
534
534
  }
535
535
  function Ot(i) {
536
536
  const t = Object.assign({}, i, { apiKey: void 0 });
537
- return v(t, "/v1/active/alerts");
537
+ return A(t, "/v1/active/alerts");
538
538
  }
539
539
  function Nt(i, t) {
540
540
  const e = Object.assign({}, i, { apiKey: void 0 });
541
- return v(e, `/v1/active/alerts/${t}`);
541
+ return A(e, `/v1/active/alerts/${t}`);
542
542
  }
543
543
  function Ht(i) {
544
- return v(i, "/v1/alerts");
544
+ return A(i, "/v1/alerts");
545
545
  }
546
546
  function It(i, t) {
547
- return v(i, `/v1/alerts/${t}`);
547
+ return A(i, `/v1/alerts/${t}`);
548
548
  }
549
549
  function kt(i, t) {
550
- return v(i, "/v1/alerts", {
550
+ return A(i, "/v1/alerts", {
551
551
  method: "POST",
552
552
  body: t
553
553
  });
554
554
  }
555
555
  function Mt(i, t) {
556
- return v(i, `/v1/alerts/${t}`, {
556
+ return A(i, `/v1/alerts/${t}`, {
557
557
  method: "DELETE"
558
558
  });
559
559
  }
560
- async function v(i, t, e) {
560
+ async function A(i, t, e) {
561
561
  const s = i.baseUrl.endsWith("/") ? i.baseUrl : `${i.baseUrl}/`, r = t.startsWith("/") ? t.substring(1) : t, n = new URL(r, s), o = {
562
562
  "Content-Type": "application/json"
563
563
  };
@@ -689,13 +689,14 @@ class ot extends C {
689
689
  overflow: hidden;
690
690
  background: #f3f3f3;
691
691
  border: 1px solid #ececec;
692
- aspect-ratio: 4 / 3;
692
+ aspect-ratio: 16 / 9;
693
693
  }
694
694
  .thumb img {
695
695
  display: block;
696
696
  width: 100%;
697
697
  height: 100%;
698
698
  object-fit: cover;
699
+ border-radius: var(--radius-sm, 0.3125rem);
699
700
  }
700
701
  .alert-body {
701
702
  display: flex;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { W as r, n as s, s as l } from "./wral-active-alerts-BrdwAfki.js";
1
+ import { W as r, n as s, s as l } from "./wral-active-alerts-CUTa46c9.js";
2
2
  export {
3
3
  r as WralActiveAlerts,
4
4
  s as normalizeAlert,
@@ -4,15 +4,15 @@ const v = {
4
4
  lg: 1366
5
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
- const t = e.link || e.url || e.href || "", l = e.title || e.headline || "";
8
- if (!l) return null;
9
- const a = String(e.topic || "").trim(), s = a.toLowerCase(), r = e.caption || a || "Alert", n = e.image || e.imageUrl || e.image_url || x;
7
+ const t = e.link || e.url || e.href || "", s = e.title || e.headline || "";
8
+ if (!s) return null;
9
+ const a = String(e.topic || "").trim(), l = a.toLowerCase(), r = e.caption || a || "Alert", o = e.image || e.imageUrl || e.image_url || x;
10
10
  return {
11
11
  url: t,
12
- title: l,
13
- topic: s || a,
12
+ title: s,
13
+ topic: l || a,
14
14
  caption: r,
15
- image: n,
15
+ image: o,
16
16
  body: e.body || e.summary || "",
17
17
  effectiveFrom: e.effectiveFrom || e.effective_from || ""
18
18
  };
@@ -108,13 +108,14 @@ class _ extends g {
108
108
  overflow: hidden;
109
109
  background: #f3f3f3;
110
110
  border: 1px solid #ececec;
111
- aspect-ratio: 4 / 3;
111
+ aspect-ratio: 16 / 9;
112
112
  }
113
113
  .thumb img {
114
114
  display: block;
115
115
  width: 100%;
116
116
  height: 100%;
117
117
  object-fit: cover;
118
+ border-radius: var(--radius-sm, 0.3125rem);
118
119
  }
119
120
  .alert-body {
120
121
  display: flex;
@@ -220,8 +221,8 @@ class _ extends g {
220
221
  this._refreshId && (globalThis.clearInterval(this._refreshId), this._refreshId = null);
221
222
  }
222
223
  render() {
223
- const { items: t, loading: l, error: a } = this, s = (r, n) => {
224
- 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
+ const { items: t, loading: s, error: a } = this, l = (r, o) => {
225
+ const n = 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`
225
226
  <div class="thumb">
226
227
  <img
227
228
  src=${r.image}
@@ -234,9 +235,9 @@ class _ extends g {
234
235
  <div class="label ${h}">
235
236
  ${$(r.caption)}
236
237
  </div>
237
- ${o ? i`
238
+ ${n ? i`
238
239
  <span class="date">
239
- ${o}
240
+ ${n}
240
241
  </span>
241
242
  ` : ""}
242
243
  </div>
@@ -245,7 +246,7 @@ class _ extends g {
245
246
  </div>
246
247
  `;
247
248
  return i`
248
- <li class="alert" data-index=${n} aria-label="Site Alert">
249
+ <li class="alert" data-index=${o} aria-label="Site Alert">
249
250
  ${r.url ? i`
250
251
  <a class="alert-card" href=${r.url} aria-label=${c}>
251
252
  ${p}
@@ -261,17 +262,17 @@ class _ extends g {
261
262
  return i`
262
263
  <div class="wrapper" role="region" aria-live="polite">
263
264
  <div class="heading">
264
- ${l ? i`<span class="pill">Loading…</span>` : ""}
265
+ ${s ? i`<span class="pill">Loading…</span>` : ""}
265
266
  </div>
266
267
 
267
268
  ${a ? i`<div class="status error">${a}</div>` : ""}
268
- ${!a && !l && !t.length ? i`
269
+ ${!a && !s && !t.length ? i`
269
270
  <div class="empty">No active alerts right now.</div>
270
271
  ` : ""}
271
272
 
272
273
  ${t.length ? i`
273
274
  <ul class="list">
274
- ${t.map(s)}
275
+ ${t.map(l)}
275
276
  </ul>
276
277
  ` : ""}
277
278
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wral/active-alerts",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
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>",