@wral/active-alerts 0.2.4 → 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
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ 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",
|
|
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;
|
|
@@ -16,7 +16,7 @@ const v = {
|
|
|
16
16
|
body: e.body || e.summary || "",
|
|
17
17
|
effectiveFrom: e.effectiveFrom || e.effective_from || ""
|
|
18
18
|
};
|
|
19
|
-
},
|
|
19
|
+
}, A = (e) => {
|
|
20
20
|
if (!e) return "";
|
|
21
21
|
try {
|
|
22
22
|
const t = new Date(e);
|
|
@@ -202,7 +202,7 @@ class _ extends g {
|
|
|
202
202
|
this.loading = !0, this.error = "";
|
|
203
203
|
try {
|
|
204
204
|
const t = await this.fetchActiveAlerts();
|
|
205
|
-
this.items = (t?.items || []).map(
|
|
205
|
+
this.items = (t?.items || []).map(I).filter(Boolean);
|
|
206
206
|
} catch (t) {
|
|
207
207
|
console.error("[wral-active-alerts]", t), this.items = [], this.error = "Unable to load active alerts.";
|
|
208
208
|
} finally {
|
|
@@ -220,7 +220,7 @@ class _ extends g {
|
|
|
220
220
|
}
|
|
221
221
|
render() {
|
|
222
222
|
const { items: t, loading: s, error: a } = this, l = (r, n) => {
|
|
223
|
-
const o =
|
|
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
224
|
<div class="thumb">
|
|
225
225
|
<img
|
|
226
226
|
src=${r.image}
|
|
@@ -260,7 +260,6 @@ class _ extends g {
|
|
|
260
260
|
return i`
|
|
261
261
|
<div class="wrapper" role="region" aria-live="polite">
|
|
262
262
|
<div class="heading">
|
|
263
|
-
<span>Active Alerts</span>
|
|
264
263
|
${s ? i`<span class="pill">Loading…</span>` : ""}
|
|
265
264
|
</div>
|
|
266
265
|
|
|
@@ -281,6 +280,6 @@ class _ extends g {
|
|
|
281
280
|
globalThis?.customElements && !globalThis.customElements.get("wral-active-alerts") && globalThis.customElements.define("wral-active-alerts", _);
|
|
282
281
|
export {
|
|
283
282
|
_ as W,
|
|
284
|
-
|
|
283
|
+
I as n,
|
|
285
284
|
$ as s
|
|
286
285
|
};
|