@wral/active-alerts 0.2.4 → 0.2.6

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-CrVfjdZW.js";
1
+ import { W as t } from "./wral-active-alerts-BrdwAfki.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));
@@ -759,6 +759,7 @@ class ot extends C {
759
759
  }
760
760
  @media (max-width: 720px) {
761
761
  .wrapper { padding: .75rem .75rem 1.25rem; }
762
+ .alert-card { grid-template-columns: 1fr; }
762
763
  }
763
764
  `;
764
765
  async firstUpdated() {
@@ -841,7 +842,6 @@ class ot extends C {
841
842
  return $`
842
843
  <div class="wrapper" role="region" aria-live="polite">
843
844
  <div class="heading">
844
- <span>Active Alerts</span>
845
845
  ${e ? $`<span class="pill">Loading…</span>` : ""}
846
846
  </div>
847
847
 
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { W as r, n as s, s as l } from "./wral-active-alerts-CrVfjdZW.js";
1
+ import { W as r, n as s, s as l } from "./wral-active-alerts-BrdwAfki.js";
2
2
  export {
3
3
  r as WralActiveAlerts,
4
4
  s as normalizeAlert,
@@ -2,21 +2,21 @@ import { LitElement as g, css as u, html as i } from "lit";
2
2
  import { createClient as b } from "@wral/sdk-alerts/v1";
3
3
  const v = {
4
4
  lg: 1366
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", A = (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
- 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", n = e.image || e.imageUrl || e.image_url || x;
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;
10
10
  return {
11
11
  url: t,
12
- title: s,
13
- topic: l || a,
12
+ title: l,
13
+ topic: s || a,
14
14
  caption: r,
15
15
  image: n,
16
16
  body: e.body || e.summary || "",
17
17
  effectiveFrom: e.effectiveFrom || e.effective_from || ""
18
18
  };
19
- }, I = (e) => {
19
+ }, A = (e) => {
20
20
  if (!e) return "";
21
21
  try {
22
22
  const t = new Date(e);
@@ -178,6 +178,7 @@ class _ extends g {
178
178
  }
179
179
  @media (max-width: 720px) {
180
180
  .wrapper { padding: .75rem .75rem 1.25rem; }
181
+ .alert-card { grid-template-columns: 1fr; }
181
182
  }
182
183
  `;
183
184
  async firstUpdated() {
@@ -202,7 +203,7 @@ class _ extends g {
202
203
  this.loading = !0, this.error = "";
203
204
  try {
204
205
  const t = await this.fetchActiveAlerts();
205
- this.items = (t?.items || []).map(A).filter(Boolean);
206
+ this.items = (t?.items || []).map(I).filter(Boolean);
206
207
  } catch (t) {
207
208
  console.error("[wral-active-alerts]", t), this.items = [], this.error = "Unable to load active alerts.";
208
209
  } finally {
@@ -219,8 +220,8 @@ class _ extends g {
219
220
  this._refreshId && (globalThis.clearInterval(this._refreshId), this._refreshId = null);
220
221
  }
221
222
  render() {
222
- const { items: t, loading: s, error: a } = this, l = (r, n) => {
223
- const o = I(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`
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
225
  <div class="thumb">
225
226
  <img
226
227
  src=${r.image}
@@ -260,18 +261,17 @@ class _ extends g {
260
261
  return i`
261
262
  <div class="wrapper" role="region" aria-live="polite">
262
263
  <div class="heading">
263
- <span>Active Alerts</span>
264
- ${s ? i`<span class="pill">Loading…</span>` : ""}
264
+ ${l ? i`<span class="pill">Loading…</span>` : ""}
265
265
  </div>
266
266
 
267
267
  ${a ? i`<div class="status error">${a}</div>` : ""}
268
- ${!a && !s && !t.length ? i`
268
+ ${!a && !l && !t.length ? i`
269
269
  <div class="empty">No active alerts right now.</div>
270
270
  ` : ""}
271
271
 
272
272
  ${t.length ? i`
273
273
  <ul class="list">
274
- ${t.map(l)}
274
+ ${t.map(s)}
275
275
  </ul>
276
276
  ` : ""}
277
277
  </div>
@@ -281,6 +281,6 @@ class _ extends g {
281
281
  globalThis?.customElements && !globalThis.customElements.get("wral-active-alerts") && globalThis.customElements.define("wral-active-alerts", _);
282
282
  export {
283
283
  _ as W,
284
- A as n,
284
+ I as n,
285
285
  $ as s
286
286
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wral/active-alerts",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
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>",