pollcatch 2.4.0 → 2.4.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/pc.js +60 -78
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pollcatch",
3
3
  "private": false,
4
- "version": "2.4.0",
4
+ "version": "2.4.1",
5
5
  "type": "module",
6
6
  "main": "pc.js",
7
7
  "module": "pc.js",
package/pc.js CHANGED
@@ -22,7 +22,7 @@ let Ee = class {
22
22
  return this.cssText;
23
23
  }
24
24
  };
25
- const Fe = (e) => new Ee(typeof e == "string" ? e : e + "", void 0, Kt), B = (e, ...t) => {
25
+ const Fe = (e) => new Ee(typeof e == "string" ? e : e + "", void 0, Kt), U = (e, ...t) => {
26
26
  const o = e.length === 1 ? e[0] : t.reduce((r, s, i) => r + ((a) => {
27
27
  if (a._$cssResult$ === !0) return a.cssText;
28
28
  if (typeof a == "number") return a;
@@ -742,10 +742,10 @@ var fo = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, L = function(e) {
742
742
  return [null, void 0];
743
743
  }, xo = function(e) {
744
744
  return typeof e == "string" ? me(e.trim(), ge.string) : typeof e == "object" && e !== null ? me(e, ge.object) : [null, void 0];
745
- }, Vt = function(e, t) {
745
+ }, Bt = function(e, t) {
746
746
  var o = ut(e);
747
747
  return { h: o.h, s: P(o.s + 100 * t, 0, 100), l: o.l, a: o.a };
748
- }, Bt = function(e) {
748
+ }, Ut = function(e) {
749
749
  return (299 * e.r + 587 * e.g + 114 * e.b) / 1e3 / 255;
750
750
  }, ve = function(e, t) {
751
751
  var o = ut(e);
@@ -757,11 +757,11 @@ var fo = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, L = function(e) {
757
757
  return e.prototype.isValid = function() {
758
758
  return this.parsed !== null;
759
759
  }, e.prototype.brightness = function() {
760
- return $(Bt(this.rgba), 2);
760
+ return $(Ut(this.rgba), 2);
761
761
  }, e.prototype.isDark = function() {
762
- return Bt(this.rgba) < 0.5;
762
+ return Ut(this.rgba) < 0.5;
763
763
  }, e.prototype.isLight = function() {
764
- return Bt(this.rgba) >= 0.5;
764
+ return Ut(this.rgba) >= 0.5;
765
765
  }, e.prototype.toHex = function() {
766
766
  return t = Rt(this.rgba), o = t.r, r = t.g, s = t.b, a = (i = t.a) < 1 ? yt($(255 * i)) : "", "#" + yt(o) + yt(r) + yt(s) + a;
767
767
  var t, o, r, s, i, a;
@@ -782,11 +782,11 @@ var fo = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, L = function(e) {
782
782
  return T({ r: 255 - (t = this.rgba).r, g: 255 - t.g, b: 255 - t.b, a: t.a });
783
783
  var t;
784
784
  }, e.prototype.saturate = function(t) {
785
- return t === void 0 && (t = 0.1), T(Vt(this.rgba, t));
785
+ return t === void 0 && (t = 0.1), T(Bt(this.rgba, t));
786
786
  }, e.prototype.desaturate = function(t) {
787
- return t === void 0 && (t = 0.1), T(Vt(this.rgba, -t));
787
+ return t === void 0 && (t = 0.1), T(Bt(this.rgba, -t));
788
788
  }, e.prototype.grayscale = function() {
789
- return T(Vt(this.rgba, -1));
789
+ return T(Bt(this.rgba, -1));
790
790
  }, e.prototype.lighten = function(t) {
791
791
  return t === void 0 && (t = 0.1), T(ve(this.rgba, t));
792
792
  }, e.prototype.darken = function(t) {
@@ -805,17 +805,17 @@ var fo = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, L = function(e) {
805
805
  }(), T = function(e) {
806
806
  return e instanceof be ? e : new be(e);
807
807
  };
808
- const Ut = process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
808
+ const Vt = process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
809
809
  function wo(e) {
810
810
  return {
811
811
  debug: (t, ...o) => {
812
- Ut && console.debug(`[${e}]`, t, ...o);
812
+ Vt && console.debug(`[${e}]`, t, ...o);
813
813
  },
814
814
  info: (t, ...o) => {
815
- Ut && console.info(`[${e}]`, t, ...o);
815
+ Vt && console.info(`[${e}]`, t, ...o);
816
816
  },
817
817
  warn: (t, ...o) => {
818
- Ut && console.warn(`[${e}]`, t, ...o);
818
+ Vt && console.warn(`[${e}]`, t, ...o);
819
819
  },
820
820
  error: (t, ...o) => {
821
821
  console.error(`[${e}]`, t, ...o);
@@ -1112,7 +1112,7 @@ function Ro(e, t) {
1112
1112
  return m.warn("Failed to save localStats to localStorage", o), !1;
1113
1113
  }
1114
1114
  }
1115
- function Vo(e, t) {
1115
+ function Bo(e, t) {
1116
1116
  const o = {
1117
1117
  count: Math.max(0, e.count - t.count),
1118
1118
  sum: (e.sum || 0) - (t.sum || 0),
@@ -1127,7 +1127,7 @@ function Vo(e, t) {
1127
1127
  o.breakdown[r] && (o.breakdown[r] = Math.max(0, o.breakdown[r] - s), o.breakdown[r] === 0 && delete o.breakdown[r]);
1128
1128
  return o.nps = Et((o == null ? void 0 : o.breakdown) || {}), o;
1129
1129
  }
1130
- function Bo(e, t) {
1130
+ function Uo(e, t) {
1131
1131
  if (!e.count && !t.count)
1132
1132
  return D();
1133
1133
  if (!e.count)
@@ -1148,7 +1148,7 @@ function Bo(e, t) {
1148
1148
  }
1149
1149
  return o.nps = Et((o == null ? void 0 : o.breakdown) || {}), o;
1150
1150
  }
1151
- function Ve(e) {
1151
+ function Be(e) {
1152
1152
  return !e || typeof e != "string" ? !1 : /^[\p{Emoji}]$/u.test(e) ? !0 : new RegExp("^\\p{Emoji}(\\p{Emoji_Modifier}|\\u200D\\p{Emoji})*$", "u").test(e);
1153
1153
  }
1154
1154
  function _t(e) {
@@ -1165,7 +1165,7 @@ function _t(e) {
1165
1165
  return !1;
1166
1166
  }
1167
1167
  }
1168
- function Uo(e) {
1168
+ function Vo(e) {
1169
1169
  if (!e || typeof e != "string")
1170
1170
  return [];
1171
1171
  const t = e.trim();
@@ -1362,7 +1362,7 @@ class Fo {
1362
1362
  * @param textValues
1363
1363
  */
1364
1364
  updateStats(t, o) {
1365
- if (this.hasInteracted = !0, this.stats && (this.stats = Vo(this.stats, this.localStats)), this.localStats = {
1365
+ if (this.hasInteracted = !0, this.stats && (this.stats = Bo(this.stats, this.localStats)), this.localStats = {
1366
1366
  count: t > 0 || o.length > 0 ? 1 : 0,
1367
1367
  sum: t,
1368
1368
  // e.g. number of stars, nps value
@@ -1376,7 +1376,7 @@ class Fo {
1376
1376
  }, o && o.length > 0)
1377
1377
  for (const r of o)
1378
1378
  r && (this.localStats.breakdown[r] = 1);
1379
- this.stats = Bo(this.stats, this.localStats), m.debug("Stats updated - remote: ", this.stats), m.debug("Stats updated - local: ", this.stats), this.persistLocalStats(), this.host.requestUpdate();
1379
+ this.stats = Uo(this.stats, this.localStats), m.debug("Stats updated - remote: ", this.stats), m.debug("Stats updated - local: ", this.stats), this.persistLocalStats(), this.host.requestUpdate();
1380
1380
  }
1381
1381
  async markStatsAsSubmitted() {
1382
1382
  this.localStats.submitted = (/* @__PURE__ */ new Date()).toISOString(), this.prevLocalStats = { ...this.localStats }, await this.persistLocalStats(), this.host.requestUpdate();
@@ -1420,27 +1420,9 @@ class Fo {
1420
1420
  const s = o.dataEndpoint || xe;
1421
1421
  if (!_t(s))
1422
1422
  throw m.error("Invalid data endpoint", { dataEndpoint: s }), new Error(`Invalid data endpoint: ${s}`);
1423
- let i, a;
1424
- r.type === "registered" ? (i = `${s}/widgets/${encodeURIComponent(o.widgetId)}`, a = JSON.stringify({
1425
- sessionId: t.sessionId,
1426
- numericValue: t.numericValue,
1427
- textValues: t.textValues,
1428
- prevNumericValue: t.prevNumericValue,
1429
- prevTextValues: t.prevTextValues,
1430
- metadata: t.metadata,
1431
- url: t.url,
1432
- timestamp: t.timestamp,
1433
- hash: t.hash
1434
- })) : (i = `${s}/public-widgets/${encodeURIComponent(o.name)}`, a = JSON.stringify({
1435
- sessionId: t.sessionId,
1436
- widgetType: t.widgetType,
1437
- numericValue: t.numericValue,
1438
- textValues: t.textValues,
1439
- prevNumericValue: t.prevNumericValue,
1440
- prevTextValues: t.prevTextValues,
1441
- timestamp: t.timestamp,
1442
- hash: t.hash
1443
- }));
1423
+ let i;
1424
+ r.type === "registered" ? i = `${s}/widgets/${encodeURIComponent(o.widgetId)}` : i = `${s}/public-widgets/${encodeURIComponent(o.name)}`;
1425
+ const a = JSON.stringify(t);
1444
1426
  try {
1445
1427
  if (m.debug("Sending stats", { endpoint: i, event: t }), typeof navigator < "u" && navigator.sendBeacon)
1446
1428
  if (navigator.sendBeacon(i, a)) {
@@ -1653,7 +1635,7 @@ class Yo {
1653
1635
  }
1654
1636
  }
1655
1637
  var Qt = /* @__PURE__ */ ((e) => (e.DECORATIVE = "decorative", e.FUNCTIONAL = "functional", e.STATUS = "status", e))(Qt || {});
1656
- function Be(e, t = {}) {
1638
+ function Ue(e, t = {}) {
1657
1639
  const { type: o = "functional", alt: r, ariaLabel: s, isSelected: i } = t;
1658
1640
  if (!e)
1659
1641
  return { alt: "", ariaHidden: !0 };
@@ -1683,7 +1665,7 @@ function Wo(e, t) {
1683
1665
  * Copyright 2017 Google LLC
1684
1666
  * SPDX-License-Identifier: BSD-3-Clause
1685
1667
  */
1686
- const Ue = { ATTRIBUTE: 1 }, je = (e) => (...t) => ({ _$litDirective$: e, values: t });
1668
+ const Ve = { ATTRIBUTE: 1 }, je = (e) => (...t) => ({ _$litDirective$: e, values: t });
1687
1669
  let qe = class {
1688
1670
  constructor(t) {
1689
1671
  }
@@ -1708,7 +1690,7 @@ let qe = class {
1708
1690
  const y = je(class extends qe {
1709
1691
  constructor(e) {
1710
1692
  var t;
1711
- if (super(e), e.type !== Ue.ATTRIBUTE || e.name !== "class" || ((t = e.strings) == null ? void 0 : t.length) > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
1693
+ if (super(e), e.type !== Ve.ATTRIBUTE || e.name !== "class" || ((t = e.strings) == null ? void 0 : t.length) > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
1712
1694
  }
1713
1695
  render(e) {
1714
1696
  return " " + Object.keys(e).filter((t) => e[t]).join(" ") + " ";
@@ -1955,7 +1937,7 @@ const xt = {
1955
1937
  }
1956
1938
  };
1957
1939
  te.styles = [
1958
- B`
1940
+ U`
1959
1941
  :host {
1960
1942
  /* Default values for CSS variables - can be overridden by external :root or parent definitions */
1961
1943
  --default-font-size-base: 1rem;
@@ -2141,7 +2123,7 @@ v([
2141
2123
  v([
2142
2124
  f({ type: Boolean, reflect: !0 })
2143
2125
  ], g.prototype, "readonly");
2144
- const Zo = B`
2126
+ const Zo = U`
2145
2127
  /* CSS variables inherit from parent - defaults are specified at usage sites */
2146
2128
 
2147
2129
  .pc-body {
@@ -2592,7 +2574,7 @@ const Zo = B`
2592
2574
  animation: none;
2593
2575
  }
2594
2576
  }
2595
- `, Ot = B`
2577
+ `, Ot = U`
2596
2578
  /* Default values for CSS variables - can be overridden by external :root or parent definitions */
2597
2579
  :host {
2598
2580
  --default-primary-color: #2196f3;
@@ -3311,7 +3293,7 @@ const Zo = B`
3311
3293
  opacity: 1;
3312
3294
  }
3313
3295
  }
3314
- `, Jo = B`
3296
+ `, Jo = U`
3315
3297
  :host {
3316
3298
  --popover-bg: light-dark(#ffffff, #1a1a1a);
3317
3299
  --popover-border: light-dark(#e0e0e0, #333333);
@@ -3433,7 +3415,7 @@ const Zo = B`
3433
3415
  max-width: 100%;
3434
3416
  }
3435
3417
  `;
3436
- var Xo = Object.defineProperty, Qo = Object.getOwnPropertyDescriptor, U = (e, t, o, r) => {
3418
+ var Xo = Object.defineProperty, Qo = Object.getOwnPropertyDescriptor, V = (e, t, o, r) => {
3437
3419
  for (var s = r > 1 ? void 0 : r ? Qo(t, o) : t, i = e.length - 1, a; i >= 0; i--)
3438
3420
  (a = e[i]) && (s = (r ? a(t, o, s) : a(s)) || s);
3439
3421
  return r && s && Xo(t, o, s), s;
@@ -3528,34 +3510,34 @@ let _ = class extends R {
3528
3510
  }
3529
3511
  };
3530
3512
  _.styles = [Jo];
3531
- U([
3513
+ V([
3532
3514
  f({ type: Boolean, reflect: !0 })
3533
3515
  ], _.prototype, "open", 2);
3534
- U([
3516
+ V([
3535
3517
  f({ type: String })
3536
3518
  ], _.prototype, "position", 2);
3537
- U([
3519
+ V([
3538
3520
  f({ attribute: !1 })
3539
3521
  ], _.prototype, "anchor", 2);
3540
- U([
3522
+ V([
3541
3523
  k()
3542
3524
  ], _.prototype, "isClosing", 2);
3543
- U([
3525
+ V([
3544
3526
  k()
3545
3527
  ], _.prototype, "computedPosition", 2);
3546
- U([
3528
+ V([
3547
3529
  k()
3548
3530
  ], _.prototype, "popoverStyles", 2);
3549
- U([
3531
+ V([
3550
3532
  k()
3551
3533
  ], _.prototype, "arrowStyles", 2);
3552
- U([
3534
+ V([
3553
3535
  mt(".pc-popover")
3554
3536
  ], _.prototype, "popoverElement", 2);
3555
- _ = U([
3537
+ _ = V([
3556
3538
  Y("pc-popover")
3557
3539
  ], _);
3558
- const tr = B`
3540
+ const tr = U`
3559
3541
  :host {
3560
3542
  --sheet-bg: light-dark(#ffffff, #1a1a1a);
3561
3543
  --sheet-border: light-dark(#e0e0e0, #333333);
@@ -3673,7 +3655,7 @@ var er = Object.defineProperty, or = Object.getOwnPropertyDescriptor, tt = (e, t
3673
3655
  (a = e[i]) && (s = (r ? a(t, o, s) : a(s)) || s);
3674
3656
  return r && s && er(t, o, s), s;
3675
3657
  };
3676
- let V = class extends R {
3658
+ let B = class extends R {
3677
3659
  constructor() {
3678
3660
  super(...arguments), this.open = !1, this.dragToClose = !0, this.isClosing = !1, this.isDragging = !1, this.dragOffset = 0, this.dragStartY = 0, this.sheetHeight = 0, this.handleKeyDown = (e) => {
3679
3661
  if (e.key === "Escape" && this.open && (e.preventDefault(), e.stopPropagation(), this.close()), e.key === "Tab" && this.open && this.sheetElement) {
@@ -3767,28 +3749,28 @@ let V = class extends R {
3767
3749
  `;
3768
3750
  }
3769
3751
  };
3770
- V.styles = [tr];
3752
+ B.styles = [tr];
3771
3753
  tt([
3772
3754
  f({ type: Boolean, reflect: !0 })
3773
- ], V.prototype, "open", 2);
3755
+ ], B.prototype, "open", 2);
3774
3756
  tt([
3775
3757
  f({ type: Boolean, attribute: "drag-to-close" })
3776
- ], V.prototype, "dragToClose", 2);
3758
+ ], B.prototype, "dragToClose", 2);
3777
3759
  tt([
3778
3760
  k()
3779
- ], V.prototype, "isClosing", 2);
3761
+ ], B.prototype, "isClosing", 2);
3780
3762
  tt([
3781
3763
  k()
3782
- ], V.prototype, "isDragging", 2);
3764
+ ], B.prototype, "isDragging", 2);
3783
3765
  tt([
3784
3766
  k()
3785
- ], V.prototype, "dragOffset", 2);
3767
+ ], B.prototype, "dragOffset", 2);
3786
3768
  tt([
3787
3769
  mt(".pc-bottom-sheet")
3788
- ], V.prototype, "sheetElement", 2);
3789
- V = tt([
3770
+ ], B.prototype, "sheetElement", 2);
3771
+ B = tt([
3790
3772
  Y("pc-bottom-sheet")
3791
- ], V);
3773
+ ], B);
3792
3774
  var rr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, vt = (e, t, o, r) => {
3793
3775
  for (var s = r > 1 ? void 0 : r ? sr(t, o) : t, i = e.length - 1, a; i >= 0; i--)
3794
3776
  (a = e[i]) && (s = (r ? a(t, o, s) : a(s)) || s);
@@ -3830,7 +3812,7 @@ let X = class extends R {
3830
3812
  `;
3831
3813
  }
3832
3814
  };
3833
- X.styles = B`
3815
+ X.styles = U`
3834
3816
  :host {
3835
3817
  display: contents;
3836
3818
  }
@@ -4236,7 +4218,7 @@ K([
4236
4218
  I = K([
4237
4219
  Y("pc-nps")
4238
4220
  ], I);
4239
- const lr = B`
4221
+ const lr = U`
4240
4222
  /* CSS variables inherit from parent - defaults are specified at usage sites */
4241
4223
 
4242
4224
  .pc-container {
@@ -4684,12 +4666,12 @@ let Q = class extends g {
4684
4666
  */
4685
4667
  renderOptionIcon(e) {
4686
4668
  if (!(e != null && e.icon)) return "";
4687
- const t = Qt.DECORATIVE, o = (e == null ? void 0 : e.label) || "", r = e ? this.dataController.isValueSelected(e.value) : !1, s = Be(e == null ? void 0 : e.icon, {
4669
+ const t = Qt.DECORATIVE, o = (e == null ? void 0 : e.label) || "", r = e ? this.dataController.isValueSelected(e.value) : !1, s = Ue(e == null ? void 0 : e.icon, {
4688
4670
  type: t,
4689
4671
  alt: o,
4690
4672
  isSelected: r
4691
4673
  });
4692
- return Ve(e == null ? void 0 : e.icon) ? c`<span
4674
+ return Be(e == null ? void 0 : e.icon) ? c`<span
4693
4675
  class="poll-option-icon"
4694
4676
  aria-hidden="${s.ariaHidden ? "true" : "false"}"
4695
4677
  >${e == null ? void 0 : e.icon}</span
@@ -5057,7 +5039,7 @@ bt([
5057
5039
  Q = bt([
5058
5040
  Y("pc-poll")
5059
5041
  ], Q);
5060
- const pr = B`
5042
+ const pr = U`
5061
5043
  /* CSS variables inherit from parent - defaults are specified at usage sites */
5062
5044
 
5063
5045
  .pc-section {
@@ -5247,7 +5229,7 @@ const pr = B`
5247
5229
  const He = "important", ur = " !" + He, hr = je(class extends qe {
5248
5230
  constructor(e) {
5249
5231
  var t;
5250
- if (super(e), e.type !== Ue.ATTRIBUTE || e.name !== "style" || ((t = e.strings) == null ? void 0 : t.length) > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
5232
+ if (super(e), e.type !== Ve.ATTRIBUTE || e.name !== "style" || ((t = e.strings) == null ? void 0 : t.length) > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
5251
5233
  }
5252
5234
  render(e) {
5253
5235
  return Object.keys(e).reduce((t, o) => {
@@ -5444,7 +5426,7 @@ const Ce = {
5444
5426
  };
5445
5427
  function At(e) {
5446
5428
  let t = "❓", o = !1;
5447
- return e ? e in Ce ? t = Ce[e] : Ve(e) ? t = e : _t(e) ? (o = !0, t = e) : /^\w+@\w+$/.test(e) ? t = e : e.endsWith(".svg") && !e.includes("/") ? (t = `https://cdn.jsdelivr.net/npm/@mdi/svg@7.4.47/svg/${e}`, o = !0) : t = e : t = "❓", {
5429
+ return e ? e in Ce ? t = Ce[e] : Be(e) ? t = e : _t(e) ? (o = !0, t = e) : /^\w+@\w+$/.test(e) ? t = e : e.endsWith(".svg") && !e.includes("/") ? (t = `https://cdn.jsdelivr.net/npm/@mdi/svg@7.4.47/svg/${e}`, o = !0) : t = e : t = "❓", {
5448
5430
  icon: t,
5449
5431
  isRemoteImage: o
5450
5432
  };
@@ -5783,7 +5765,7 @@ nt([
5783
5765
  F = nt([
5784
5766
  Y("pc-stars")
5785
5767
  ], F);
5786
- const mr = B`
5768
+ const mr = U`
5787
5769
  /* Adjust stats text for reactions */
5788
5770
  .pc-stats-text {
5789
5771
  font-size: var(--pc-font-size-small, var(--default-font-size-small));
@@ -6076,7 +6058,7 @@ let it = class extends g {
6076
6058
  * Renders the icon for a reaction
6077
6059
  */
6078
6060
  renderReactionIcon(e, t) {
6079
- const { icon: o, isRemoteImage: r } = At(e), s = Qt.FUNCTIONAL, i = t.tooltip || `${t.value} reaction`, a = Be(o, {
6061
+ const { icon: o, isRemoteImage: r } = At(e), s = Qt.FUNCTIONAL, i = t.tooltip || `${t.value} reaction`, a = Ue(o, {
6080
6062
  type: s,
6081
6063
  alt: i,
6082
6064
  ariaLabel: i,
@@ -6379,7 +6361,7 @@ let at = class extends R {
6379
6361
  const e = this.querySelector("pc-poll, pc-reaction");
6380
6362
  if (!e) return;
6381
6363
  const t = this.querySelectorAll("poll-catch-option");
6382
- let r = Uo(this.options).map((s) => ({
6364
+ let r = Vo(this.options).map((s) => ({
6383
6365
  value: s,
6384
6366
  label: s,
6385
6367
  icon: e.tagName === "PC-REACTION" ? s : void 0