@wral/active-alerts 0.2.6 → 0.2.8

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-Dla2iImq.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));
@@ -45,7 +45,7 @@ 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: $t } = Object, k = globalThis, F = k.trustedTypes, mt = F ? F.emptyScript : "", gt = k.reactiveElementPolyfillSupport, x = (i, t) => i, z = { toAttribute(i, t) {
48
+ const { is: ct, defineProperty: dt, getOwnPropertyDescriptor: pt, getOwnPropertyNames: ut, getOwnPropertySymbols: ft, getPrototypeOf: $t } = Object, M = globalThis, F = M.trustedTypes, mt = F ? F.emptyScript : "", gt = M.reactiveElementPolyfillSupport, x = (i, t) => i, z = { toAttribute(i, t) {
49
49
  switch (t) {
50
50
  case Boolean:
51
51
  i = i ? mt : null;
@@ -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"), k.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
77
+ Symbol.metadata ??= Symbol("metadata"), M.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
78
78
  let b = class extends HTMLElement {
79
79
  static addInitializer(t) {
80
80
  this._$Ei(), (this.l ??= []).push(t);
@@ -256,20 +256,20 @@ 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 }), (k.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 }), (M.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, 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);
@@ -295,7 +295,7 @@ class T {
295
295
  if (r.nodeType === 1) {
296
296
  if (r.hasAttributes()) for (const h of r.getAttributeNames()) if (h.endsWith(st)) {
297
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);
298
+ a.push({ type: 1, index: n, name: N[2], strings: f, ctor: N[1] === "." ? Et : N[1] === "?" ? St : N[1] === "@" ? wt : k }), r.removeAttribute(h);
299
299
  } else h.startsWith(m) && (a.push({ type: 6, index: n }), r.removeAttribute(h));
300
300
  if (rt.test(r.tagName)) {
301
301
  const h = r.textContent.split(m), u = h.length - 1;
@@ -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);
@@ -411,7 +411,7 @@ class O {
411
411
  this._$AM === void 0 && (this._$Cv = t, this._$AP?.(t));
412
412
  }
413
413
  }
414
- class M {
414
+ class k {
415
415
  get tagName() {
416
416
  return this.element.tagName;
417
417
  }
@@ -436,7 +436,7 @@ class M {
436
436
  t === p ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
437
437
  }
438
438
  }
439
- class Et extends M {
439
+ class Et extends k {
440
440
  constructor() {
441
441
  super(...arguments), this.type = 3;
442
442
  }
@@ -444,7 +444,7 @@ class Et extends M {
444
444
  this.element[this.name] = t === p ? void 0 : t;
445
445
  }
446
446
  }
447
- class St extends M {
447
+ class St extends k {
448
448
  constructor() {
449
449
  super(...arguments), this.type = 4;
450
450
  }
@@ -452,7 +452,7 @@ class St extends M {
452
452
  this.element.toggleAttribute(this.name, !!t && t !== p);
453
453
  }
454
454
  }
455
- class wt extends M {
455
+ class wt extends k {
456
456
  constructor(t, e, s, r, n) {
457
457
  super(t, e, s, r, n), this.type = 5;
458
458
  }
@@ -523,41 +523,41 @@ 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),
530
530
  getAlert: _(It, i),
531
- sendAlert: _(kt, i),
532
- cancelAlert: _(Mt, i)
531
+ sendAlert: _(Mt, i),
532
+ cancelAlert: _(kt, i)
533
533
  };
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
- function kt(i, t) {
550
- return v(i, "/v1/alerts", {
549
+ function Mt(i, t) {
550
+ return A(i, "/v1/alerts", {
551
551
  method: "POST",
552
552
  body: t
553
553
  });
554
554
  }
555
- function Mt(i, t) {
556
- return v(i, `/v1/alerts/${t}`, {
555
+ function kt(i, 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
  };
@@ -682,25 +682,24 @@ class ot extends C {
682
682
  text-decoration: underline;
683
683
  }
684
684
  .alert-card:focus-visible {
685
- outline: 2px solid #000b27;
685
+ outline: 1px solid var(--color-secondary);
686
686
  outline-offset: 2px;
687
687
  }
688
688
  .thumb {
689
689
  overflow: hidden;
690
- background: #f3f3f3;
691
- border: 1px solid #ececec;
692
- aspect-ratio: 4 / 3;
690
+ aspect-ratio: 16 / 9;
693
691
  }
694
692
  .thumb img {
695
693
  display: block;
696
694
  width: 100%;
697
695
  height: 100%;
698
696
  object-fit: cover;
697
+ border-radius: var(--radius-sm, 0.3125rem);
699
698
  }
700
699
  .alert-body {
701
700
  display: flex;
702
701
  flex-direction: column;
703
- gap: .35rem;
702
+ gap: 1rem;
704
703
  }
705
704
  .alert-header {
706
705
  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-Dla2iImq.js";
2
2
  export {
3
3
  r as WralActiveAlerts,
4
4
  s as normalizeAlert,
@@ -1,18 +1,18 @@
1
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 = {
2
+ import { createClient as v } from "@wral/sdk-alerts/v1";
3
+ const b = {
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
  };
@@ -48,7 +48,7 @@ class _ extends g {
48
48
  color: #000b27;
49
49
  }
50
50
  .wrapper {
51
- max-width: ${v.lg}px;
51
+ max-width: ${b.lg}px;
52
52
  margin: 0 auto;
53
53
  padding: 1rem 1.25rem 1.5rem;
54
54
  }
@@ -101,25 +101,24 @@ class _ extends g {
101
101
  text-decoration: underline;
102
102
  }
103
103
  .alert-card:focus-visible {
104
- outline: 2px solid #000b27;
104
+ outline: 1px solid var(--color-secondary);
105
105
  outline-offset: 2px;
106
106
  }
107
107
  .thumb {
108
108
  overflow: hidden;
109
- background: #f3f3f3;
110
- border: 1px solid #ececec;
111
- aspect-ratio: 4 / 3;
109
+ aspect-ratio: 16 / 9;
112
110
  }
113
111
  .thumb img {
114
112
  display: block;
115
113
  width: 100%;
116
114
  height: 100%;
117
115
  object-fit: cover;
116
+ border-radius: var(--radius-sm, 0.3125rem);
118
117
  }
119
118
  .alert-body {
120
119
  display: flex;
121
120
  flex-direction: column;
122
- gap: .35rem;
121
+ gap: 1rem;
123
122
  }
124
123
  .alert-header {
125
124
  display: flex;
@@ -194,7 +193,7 @@ class _ extends g {
194
193
  t.has("api") && t.get("api") !== this.api && this.load(), t.has("refreshInterval") && this._setupInterval();
195
194
  }
196
195
  async fetchActiveAlerts() {
197
- return b({
196
+ return v({
198
197
  baseUrl: this.api.replace(/v1\/.*$/, "")
199
198
  }).listActiveAlerts();
200
199
  }
@@ -220,8 +219,8 @@ class _ extends g {
220
219
  this._refreshId && (globalThis.clearInterval(this._refreshId), this._refreshId = null);
221
220
  }
222
221
  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`
222
+ const { items: t, loading: s, error: a } = this, l = (r, o) => {
223
+ 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
224
  <div class="thumb">
226
225
  <img
227
226
  src=${r.image}
@@ -234,9 +233,9 @@ class _ extends g {
234
233
  <div class="label ${h}">
235
234
  ${$(r.caption)}
236
235
  </div>
237
- ${o ? i`
236
+ ${n ? i`
238
237
  <span class="date">
239
- ${o}
238
+ ${n}
240
239
  </span>
241
240
  ` : ""}
242
241
  </div>
@@ -245,7 +244,7 @@ class _ extends g {
245
244
  </div>
246
245
  `;
247
246
  return i`
248
- <li class="alert" data-index=${n} aria-label="Site Alert">
247
+ <li class="alert" data-index=${o} aria-label="Site Alert">
249
248
  ${r.url ? i`
250
249
  <a class="alert-card" href=${r.url} aria-label=${c}>
251
250
  ${p}
@@ -261,17 +260,17 @@ class _ extends g {
261
260
  return i`
262
261
  <div class="wrapper" role="region" aria-live="polite">
263
262
  <div class="heading">
264
- ${l ? i`<span class="pill">Loading…</span>` : ""}
263
+ ${s ? i`<span class="pill">Loading…</span>` : ""}
265
264
  </div>
266
265
 
267
266
  ${a ? i`<div class="status error">${a}</div>` : ""}
268
- ${!a && !l && !t.length ? i`
267
+ ${!a && !s && !t.length ? i`
269
268
  <div class="empty">No active alerts right now.</div>
270
269
  ` : ""}
271
270
 
272
271
  ${t.length ? i`
273
272
  <ul class="list">
274
- ${t.map(s)}
273
+ ${t.map(l)}
275
274
  </ul>
276
275
  ` : ""}
277
276
  </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.8",
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>",