pollcatch 2.2.3 → 2.2.4
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/package.json +1 -1
- package/pc.js +91 -89
package/package.json
CHANGED
package/pc.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
5
|
*/
|
|
6
|
-
const it = globalThis, _t = it.ShadowRoot && (it.ShadyCSS === void 0 || it.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Et = Symbol(),
|
|
6
|
+
const it = globalThis, _t = it.ShadowRoot && (it.ShadyCSS === void 0 || it.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Et = Symbol(), Rt = /* @__PURE__ */ new WeakMap();
|
|
7
7
|
let le = class {
|
|
8
8
|
constructor(t, o, r) {
|
|
9
9
|
if (this._$cssResult$ = !0, r !== Et) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
@@ -14,7 +14,7 @@ let le = class {
|
|
|
14
14
|
const o = this.t;
|
|
15
15
|
if (_t && t === void 0) {
|
|
16
16
|
const r = o !== void 0 && o.length === 1;
|
|
17
|
-
r && (t =
|
|
17
|
+
r && (t = Rt.get(o)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), r && Rt.set(o, t));
|
|
18
18
|
}
|
|
19
19
|
return t;
|
|
20
20
|
}
|
|
@@ -279,9 +279,9 @@ j.elementStyles = [], j.shadowRootOptions = { mode: "open" }, j[K("elementProper
|
|
|
279
279
|
* Copyright 2017 Google LLC
|
|
280
280
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
281
281
|
*/
|
|
282
|
-
const W = globalThis, nt = W.trustedTypes, Dt = nt ? nt.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, ce = "$lit$",
|
|
282
|
+
const W = globalThis, nt = W.trustedTypes, Dt = nt ? nt.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, ce = "$lit$", O = `lit$${Math.random().toFixed(9).slice(2)}$`, de = "?" + O, Me = `<${de}>`, L = document, X = () => L.createComment(""), Q = (e) => e === null || typeof e != "object" && typeof e != "function", Ot = Array.isArray, Le = (e) => Ot(e) || typeof (e == null ? void 0 : e[Symbol.iterator]) == "function", gt = `[
|
|
283
283
|
\f\r]`, Z = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Vt = /-->/g, qt = />/g, N = RegExp(`>|${gt}(?:([^\\s"'>=/]+)(${gt}*=${gt}*(?:[^
|
|
284
|
-
\f\r"'\`<>=]|("|')|))|$)`, "g"), Ht = /'/g, Ft = /"/g, pe = /^(?:script|style|textarea|title)$/i,
|
|
284
|
+
\f\r"'\`<>=]|("|')|))|$)`, "g"), Ht = /'/g, Ft = /"/g, pe = /^(?:script|style|textarea|title)$/i, Re = (e) => (t, ...o) => ({ _$litType$: e, strings: t, values: o }), d = Re(1), z = Symbol.for("lit-noChange"), h = Symbol.for("lit-nothing"), Yt = /* @__PURE__ */ new WeakMap(), M = L.createTreeWalker(L, 129);
|
|
285
285
|
function ue(e, t) {
|
|
286
286
|
if (!Ot(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
287
287
|
return Dt !== void 0 ? Dt.createHTML(t) : t;
|
|
@@ -291,10 +291,10 @@ const je = (e, t) => {
|
|
|
291
291
|
let s, i = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = Z;
|
|
292
292
|
for (let n = 0; n < o; n++) {
|
|
293
293
|
const l = e[n];
|
|
294
|
-
let p, c, u = -1,
|
|
295
|
-
for (;
|
|
296
|
-
const
|
|
297
|
-
i += a === Z ? l + Me : u >= 0 ? (r.push(p), l.slice(0, u) + ce + l.slice(u) +
|
|
294
|
+
let p, c, u = -1, v = 0;
|
|
295
|
+
for (; v < l.length && (a.lastIndex = v, c = a.exec(l), c !== null); ) v = a.lastIndex, a === Z ? c[1] === "!--" ? a = Vt : c[1] !== void 0 ? a = qt : c[2] !== void 0 ? (pe.test(c[2]) && (s = RegExp("</" + c[2], "g")), a = N) : c[3] !== void 0 && (a = N) : a === N ? c[0] === ">" ? (a = s ?? Z, u = -1) : c[1] === void 0 ? u = -2 : (u = a.lastIndex - c[2].length, p = c[1], a = c[3] === void 0 ? N : c[3] === '"' ? Ft : Ht) : a === Ft || a === Ht ? a = N : a === Vt || a === qt ? a = Z : (a = N, s = void 0);
|
|
296
|
+
const y = a === N && e[n + 1].startsWith("/>") ? " " : "";
|
|
297
|
+
i += a === Z ? l + Me : u >= 0 ? (r.push(p), l.slice(0, u) + ce + l.slice(u) + O + y) : l + O + (u === -2 ? n : y);
|
|
298
298
|
}
|
|
299
299
|
return [ue(e, i + (e[o] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r];
|
|
300
300
|
};
|
|
@@ -311,27 +311,27 @@ let At = class he {
|
|
|
311
311
|
for (; (s = M.nextNode()) !== null && l.length < n; ) {
|
|
312
312
|
if (s.nodeType === 1) {
|
|
313
313
|
if (s.hasAttributes()) for (const u of s.getAttributeNames()) if (u.endsWith(ce)) {
|
|
314
|
-
const
|
|
315
|
-
l.push({ type: 1, index: i, name:
|
|
316
|
-
} else u.startsWith(
|
|
314
|
+
const v = c[a++], y = s.getAttribute(u).split(O), P = /([.?@])?(.*)/.exec(v);
|
|
315
|
+
l.push({ type: 1, index: i, name: P[2], strings: y, ctor: P[1] === "." ? Be : P[1] === "?" ? De : P[1] === "@" ? Ve : dt }), s.removeAttribute(u);
|
|
316
|
+
} else u.startsWith(O) && (l.push({ type: 6, index: i }), s.removeAttribute(u));
|
|
317
317
|
if (pe.test(s.tagName)) {
|
|
318
|
-
const u = s.textContent.split(
|
|
319
|
-
if (
|
|
318
|
+
const u = s.textContent.split(O), v = u.length - 1;
|
|
319
|
+
if (v > 0) {
|
|
320
320
|
s.textContent = nt ? nt.emptyScript : "";
|
|
321
|
-
for (let
|
|
322
|
-
s.append(u[
|
|
321
|
+
for (let y = 0; y < v; y++) s.append(u[y], X()), M.nextNode(), l.push({ type: 2, index: ++i });
|
|
322
|
+
s.append(u[v], X());
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
} else if (s.nodeType === 8) if (s.data === de) l.push({ type: 2, index: i });
|
|
326
326
|
else {
|
|
327
327
|
let u = -1;
|
|
328
|
-
for (; (u = s.data.indexOf(
|
|
328
|
+
for (; (u = s.data.indexOf(O, u + 1)) !== -1; ) l.push({ type: 7, index: i }), u += O.length - 1;
|
|
329
329
|
}
|
|
330
330
|
i++;
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
static createElement(t, o) {
|
|
334
|
-
const r =
|
|
334
|
+
const r = L.createElement("template");
|
|
335
335
|
return r.innerHTML = t, r;
|
|
336
336
|
}
|
|
337
337
|
};
|
|
@@ -353,7 +353,7 @@ let Ue = class {
|
|
|
353
353
|
return this._$AM._$AU;
|
|
354
354
|
}
|
|
355
355
|
u(t) {
|
|
356
|
-
const { el: { content: o }, parts: r } = this._$AD, s = ((t == null ? void 0 : t.creationScope) ??
|
|
356
|
+
const { el: { content: o }, parts: r } = this._$AD, s = ((t == null ? void 0 : t.creationScope) ?? L).importNode(o, !0);
|
|
357
357
|
M.currentNode = s;
|
|
358
358
|
let i = M.nextNode(), a = 0, n = 0, l = r[0];
|
|
359
359
|
for (; l !== void 0; ) {
|
|
@@ -363,7 +363,7 @@ let Ue = class {
|
|
|
363
363
|
}
|
|
364
364
|
a !== (l == null ? void 0 : l.index) && (i = M.nextNode(), a++);
|
|
365
365
|
}
|
|
366
|
-
return M.currentNode =
|
|
366
|
+
return M.currentNode = L, s;
|
|
367
367
|
}
|
|
368
368
|
p(t) {
|
|
369
369
|
let o = 0;
|
|
@@ -390,7 +390,7 @@ class et {
|
|
|
390
390
|
return this._$AB;
|
|
391
391
|
}
|
|
392
392
|
_$AI(t, o = this) {
|
|
393
|
-
t = D(this, t, o), Q(t) ? t === h || t == null || t === "" ? (this._$AH !== h && this._$AR(), this._$AH = h) : t !== this._$AH && t !== z && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) :
|
|
393
|
+
t = D(this, t, o), Q(t) ? t === h || t == null || t === "" ? (this._$AH !== h && this._$AR(), this._$AH = h) : t !== this._$AH && t !== z && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : Le(t) ? this.k(t) : this._(t);
|
|
394
394
|
}
|
|
395
395
|
O(t) {
|
|
396
396
|
return this._$AA.parentNode.insertBefore(t, this._$AB);
|
|
@@ -399,7 +399,7 @@ class et {
|
|
|
399
399
|
this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
|
|
400
400
|
}
|
|
401
401
|
_(t) {
|
|
402
|
-
this._$AH !== h && Q(this._$AH) ? this._$AA.nextSibling.data = t : this.T(
|
|
402
|
+
this._$AH !== h && Q(this._$AH) ? this._$AA.nextSibling.data = t : this.T(L.createTextNode(t)), this._$AH = t;
|
|
403
403
|
}
|
|
404
404
|
$(t) {
|
|
405
405
|
var i;
|
|
@@ -843,8 +843,8 @@ function no(e, t = {}) {
|
|
|
843
843
|
l = a, p = c;
|
|
844
844
|
for (const u of n) {
|
|
845
845
|
if (u === a) continue;
|
|
846
|
-
const
|
|
847
|
-
|
|
846
|
+
const v = Ct(e, u);
|
|
847
|
+
v > p && (p = v, l = u);
|
|
848
848
|
}
|
|
849
849
|
b.warn(
|
|
850
850
|
`No color option met the minimum contrast ratio of ${r}:1 against ${e}. Using ${l} with contrast ratio ${p.toFixed(2)}:1 instead.`
|
|
@@ -946,7 +946,7 @@ function ho(e) {
|
|
|
946
946
|
const t = e.replace(/[<>"']/g, "").trim();
|
|
947
947
|
return /^(#[0-9a-fA-F]{3,8}|rgb\([^)]+\)|rgba\([^)]+\)|hsl\([^)]+\)|hsla\([^)]+\)|[a-zA-Z]+)$/.test(t);
|
|
948
948
|
}
|
|
949
|
-
function
|
|
949
|
+
function R(e) {
|
|
950
950
|
return ho(e) ? e.replace(/[<>"']/g, "").trim() : (b.warn("Invalid color value:", e), "#000000");
|
|
951
951
|
}
|
|
952
952
|
function fo(e) {
|
|
@@ -1038,7 +1038,7 @@ function lt(e) {
|
|
|
1038
1038
|
const s = t / r * 100, i = o / r * 100;
|
|
1039
1039
|
return Math.round(s - i);
|
|
1040
1040
|
}
|
|
1041
|
-
function
|
|
1041
|
+
function E() {
|
|
1042
1042
|
return {
|
|
1043
1043
|
count: 0,
|
|
1044
1044
|
sum: 0,
|
|
@@ -1050,12 +1050,12 @@ function O() {
|
|
|
1050
1050
|
}
|
|
1051
1051
|
function yo(e) {
|
|
1052
1052
|
if (!zt())
|
|
1053
|
-
return
|
|
1053
|
+
return E();
|
|
1054
1054
|
try {
|
|
1055
1055
|
const t = ve(e);
|
|
1056
|
-
return t ? { ...
|
|
1056
|
+
return t ? { ...E(), ...t } : E();
|
|
1057
1057
|
} catch (t) {
|
|
1058
|
-
return b.warn("Failed to load localStats from localStorage", t),
|
|
1058
|
+
return b.warn("Failed to load localStats from localStorage", t), E();
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
1061
|
function wo(e, t) {
|
|
@@ -1084,7 +1084,7 @@ function $o(e, t) {
|
|
|
1084
1084
|
}
|
|
1085
1085
|
function xo(e, t) {
|
|
1086
1086
|
if (!e.count && !t.count)
|
|
1087
|
-
return
|
|
1087
|
+
return E();
|
|
1088
1088
|
if (!e.count)
|
|
1089
1089
|
return { ...t };
|
|
1090
1090
|
const o = {
|
|
@@ -1155,7 +1155,7 @@ function Ao(e, t = 50) {
|
|
|
1155
1155
|
class _o {
|
|
1156
1156
|
// Tracks if user has ever made a selection (even if later deselected)
|
|
1157
1157
|
constructor(t) {
|
|
1158
|
-
this.stats =
|
|
1158
|
+
this.stats = E(), this.localStats = E(), this.prevLocalStats = E(), this.isLoading = !0, this.isSubmitting = !1, this.hasInteracted = !1, (this.host = t).addController(this);
|
|
1159
1159
|
}
|
|
1160
1160
|
hostConnected() {
|
|
1161
1161
|
this.loadStats();
|
|
@@ -1184,11 +1184,11 @@ class _o {
|
|
|
1184
1184
|
const o = await this.getProjectId(), r = t.name, s = t.type;
|
|
1185
1185
|
let i;
|
|
1186
1186
|
if (t.dataFunc && typeof window < "u") {
|
|
1187
|
-
const
|
|
1188
|
-
let
|
|
1189
|
-
for (const
|
|
1190
|
-
if (
|
|
1191
|
-
i =
|
|
1187
|
+
const v = t.dataFunc.replace(/^window\./, "").split(".");
|
|
1188
|
+
let y = window;
|
|
1189
|
+
for (const P of v)
|
|
1190
|
+
if (y = y == null ? void 0 : y[P], y === void 0) break;
|
|
1191
|
+
i = y;
|
|
1192
1192
|
}
|
|
1193
1193
|
let a, n;
|
|
1194
1194
|
if (i && typeof i == "function") {
|
|
@@ -1207,12 +1207,12 @@ class _o {
|
|
|
1207
1207
|
const u = t.dataEndpoint || re;
|
|
1208
1208
|
if (!r)
|
|
1209
1209
|
throw new Error("Name parameter is required");
|
|
1210
|
-
const
|
|
1210
|
+
const v = `${u}/${encodeURIComponent(o)}/${encodeURIComponent(r)}`;
|
|
1211
1211
|
b.debug(`Fetching stats for: ${r}`, { endpoint: u, projectKey: o });
|
|
1212
|
-
const
|
|
1213
|
-
if (!
|
|
1214
|
-
throw new Error(`API request failed with status: ${
|
|
1215
|
-
if (a = await
|
|
1212
|
+
const y = await fetch(v);
|
|
1213
|
+
if (!y.ok)
|
|
1214
|
+
throw new Error(`API request failed with status: ${y.status}`);
|
|
1215
|
+
if (a = await y.json(), !a.success)
|
|
1216
1216
|
throw b.error("Backend returned unsuccessful response", a), new Error("Backend returned unsuccessful response");
|
|
1217
1217
|
n = a.data || {};
|
|
1218
1218
|
}
|
|
@@ -1259,9 +1259,9 @@ class _o {
|
|
|
1259
1259
|
const t = await this.getLocalStatsKey();
|
|
1260
1260
|
try {
|
|
1261
1261
|
const o = yo(t);
|
|
1262
|
-
b.debug("Loaded localStats from localStorage", o), this.localStats = o;
|
|
1262
|
+
b.debug("Loaded localStats from localStorage", o), this.localStats = o, o.submitted && (this.prevLocalStats = { ...o });
|
|
1263
1263
|
} catch (o) {
|
|
1264
|
-
b.warn("Failed to generate localStorage key for localStats", o), this.localStats =
|
|
1264
|
+
b.warn("Failed to generate localStorage key for localStats", o), this.localStats = E();
|
|
1265
1265
|
}
|
|
1266
1266
|
this.host.requestUpdate();
|
|
1267
1267
|
}
|
|
@@ -1302,14 +1302,14 @@ class _o {
|
|
|
1302
1302
|
this.stats = xo(this.stats, this.localStats), b.debug("Stats updated - remote: ", this.stats), b.debug("Stats updated - local: ", this.stats), this.persistLocalStats(), this.host.requestUpdate();
|
|
1303
1303
|
}
|
|
1304
1304
|
async markStatsAsSubmitted() {
|
|
1305
|
-
this.localStats.submitted = (/* @__PURE__ */ new Date()).toISOString(), await this.persistLocalStats(), this.host.requestUpdate();
|
|
1305
|
+
this.localStats.submitted = (/* @__PURE__ */ new Date()).toISOString(), this.prevLocalStats = { ...this.localStats }, await this.persistLocalStats(), this.host.requestUpdate();
|
|
1306
1306
|
}
|
|
1307
1307
|
async submitStats() {
|
|
1308
1308
|
if (!this.hasLocalStats() && !this.hasInteracted)
|
|
1309
1309
|
throw b.warn("No local stats to submit"), new Error("No local stats to submit");
|
|
1310
|
-
const t = this.host, o = Math.floor(Date.now() / 1e3).toString(), r = await ie(), s = await this.getProjectId(), i = t.name || "", a = this.localStats.sum, n = Object.keys(this.localStats.breakdown || {});
|
|
1310
|
+
const t = this.host, o = Math.floor(Date.now() / 1e3).toString(), r = await ie(), s = await this.getProjectId(), i = t.name || "", a = this.localStats.sum, n = Object.keys(this.localStats.breakdown || {}), l = this.prevLocalStats.sum, p = Object.keys(this.prevLocalStats.breakdown || {});
|
|
1311
1311
|
this.isSubmitting = !0, this.host.requestUpdate();
|
|
1312
|
-
const
|
|
1312
|
+
const c = {
|
|
1313
1313
|
sessionId: r,
|
|
1314
1314
|
projectId: s,
|
|
1315
1315
|
widgetName: i,
|
|
@@ -1317,17 +1317,19 @@ class _o {
|
|
|
1317
1317
|
url: window.location.href,
|
|
1318
1318
|
numericValue: a,
|
|
1319
1319
|
textValues: n,
|
|
1320
|
+
prevNumericValue: l,
|
|
1321
|
+
prevTextValues: p,
|
|
1320
1322
|
metadata: t.metadata,
|
|
1321
1323
|
timestamp: o
|
|
1322
|
-
},
|
|
1324
|
+
}, u = ko(JSON.stringify(c), o);
|
|
1323
1325
|
try {
|
|
1324
|
-
await this.sendStats({ ...
|
|
1325
|
-
} catch (
|
|
1326
|
-
b.warn("Failed to send stats event",
|
|
1326
|
+
await this.sendStats({ ...c, hash: u }), await this.markStatsAsSubmitted(), this.dispatchSubmitEvent(c);
|
|
1327
|
+
} catch (v) {
|
|
1328
|
+
b.warn("Failed to send stats event", v);
|
|
1327
1329
|
} finally {
|
|
1328
1330
|
this.isSubmitting = !1, this.host.requestUpdate();
|
|
1329
1331
|
}
|
|
1330
|
-
return
|
|
1332
|
+
return c;
|
|
1331
1333
|
}
|
|
1332
1334
|
async sendStats(t) {
|
|
1333
1335
|
const o = JSON.stringify(t), r = this.host, s = r.dataEndpoint || re;
|
|
@@ -1597,7 +1599,7 @@ let Ce = class {
|
|
|
1597
1599
|
* Copyright 2018 Google LLC
|
|
1598
1600
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1599
1601
|
*/
|
|
1600
|
-
const
|
|
1602
|
+
const w = Se(class extends Ce {
|
|
1601
1603
|
constructor(e) {
|
|
1602
1604
|
var t;
|
|
1603
1605
|
if (super(e), e.type !== xe.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.");
|
|
@@ -1630,7 +1632,7 @@ const st = {
|
|
|
1630
1632
|
mobile: "480px",
|
|
1631
1633
|
tablet: "768px",
|
|
1632
1634
|
desktop: "1024px"
|
|
1633
|
-
},
|
|
1635
|
+
}, Lt = class Lt extends U {
|
|
1634
1636
|
constructor() {
|
|
1635
1637
|
super(...arguments), this.dataController = new _o(this), this.displayController = new Eo(this, this.dataController), this.hasEditButton = !0, this.showStats = "never", this.showChart = !1, this.initialized = !1, this.lockAnswer = !1, this.ariaLabel = null, this.minContrast = ge.AA_NORMAL, this.options = [], this.project = "public", this.questionPosition = "top", this.statsText = "{count} votes", this.buttonText = "Submit", this.buttonRadius = "sm", this.multiple = !1, this.readOnly = !1, this.handleEditToggleKeyDown = (t) => {
|
|
1636
1638
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.handleEnterEditMode());
|
|
@@ -1664,7 +1666,7 @@ const st = {
|
|
|
1664
1666
|
let o = `:host {
|
|
1665
1667
|
`;
|
|
1666
1668
|
if (this.primaryColor) {
|
|
1667
|
-
const i =
|
|
1669
|
+
const i = R(this.primaryColor);
|
|
1668
1670
|
o += `--pc-primary-color: ${i} !important;
|
|
1669
1671
|
`;
|
|
1670
1672
|
const a = no(i, {
|
|
@@ -1675,27 +1677,27 @@ const st = {
|
|
|
1675
1677
|
`;
|
|
1676
1678
|
}
|
|
1677
1679
|
if (this.muteColor) {
|
|
1678
|
-
const i =
|
|
1680
|
+
const i = R(this.muteColor);
|
|
1679
1681
|
o += `--pc-mute-color: ${i} !important;
|
|
1680
1682
|
`;
|
|
1681
1683
|
}
|
|
1682
1684
|
if (this.textColor) {
|
|
1683
|
-
const i =
|
|
1685
|
+
const i = R(this.textColor);
|
|
1684
1686
|
o += `--pc-text-color: ${i} !important;
|
|
1685
1687
|
`;
|
|
1686
1688
|
}
|
|
1687
1689
|
if (this.backgroundColor) {
|
|
1688
|
-
const i =
|
|
1690
|
+
const i = R(this.backgroundColor);
|
|
1689
1691
|
o += `--pc-background-color: ${i} !important;
|
|
1690
1692
|
`;
|
|
1691
1693
|
}
|
|
1692
1694
|
const r = this.starColor || this.accentColor || this.primaryColor;
|
|
1693
1695
|
if (r) {
|
|
1694
|
-
const i =
|
|
1696
|
+
const i = R(r);
|
|
1695
1697
|
o += `--pc-star-color: ${i} !important;
|
|
1696
1698
|
`;
|
|
1697
1699
|
}
|
|
1698
|
-
const s = this.starHoverColor || (r ? `color-mix(in srgb, ${
|
|
1700
|
+
const s = this.starHoverColor || (r ? `color-mix(in srgb, ${R(r)} 80%, white)` : null);
|
|
1699
1701
|
if (s && (o += `--pc-star-hover-color: ${s} !important;
|
|
1700
1702
|
`), this.starSize) {
|
|
1701
1703
|
const i = oe(this.starSize, "1rem", 1.5);
|
|
@@ -1805,7 +1807,7 @@ const st = {
|
|
|
1805
1807
|
"pc-status": !0,
|
|
1806
1808
|
[`pc-flex-content-${k(this.statsPosition, this.statsAlign)}`]: !0
|
|
1807
1809
|
};
|
|
1808
|
-
return d`<div class="${
|
|
1810
|
+
return d`<div class="${w(o)}" data-testid="pc-status">
|
|
1809
1811
|
${this.renderStatsText()} ${this.renderChartToggle()} ${this.renderEditToggleIcon()}
|
|
1810
1812
|
</div>`;
|
|
1811
1813
|
}
|
|
@@ -1841,7 +1843,7 @@ const st = {
|
|
|
1841
1843
|
`;
|
|
1842
1844
|
}
|
|
1843
1845
|
};
|
|
1844
|
-
|
|
1846
|
+
Lt.styles = [
|
|
1845
1847
|
F`
|
|
1846
1848
|
:host {
|
|
1847
1849
|
/* Default values for CSS variables - can be overridden by external :root or parent definitions */
|
|
@@ -1931,7 +1933,7 @@ Rt.styles = [
|
|
|
1931
1933
|
}
|
|
1932
1934
|
`
|
|
1933
1935
|
];
|
|
1934
|
-
let m =
|
|
1936
|
+
let m = Lt;
|
|
1935
1937
|
g([
|
|
1936
1938
|
f({ type: String, attribute: "show-stats" })
|
|
1937
1939
|
], m.prototype, "showStats");
|
|
@@ -2739,7 +2741,7 @@ let I = class extends m {
|
|
|
2739
2741
|
<button
|
|
2740
2742
|
data-testid="nps-button-${s}"
|
|
2741
2743
|
?disabled=${!this.displayController.allowEdit()}
|
|
2742
|
-
class=${
|
|
2744
|
+
class=${w(a)}
|
|
2743
2745
|
@click="${() => this.handleNumberClick(s)}"
|
|
2744
2746
|
@mouseenter="${() => this.handleNumberHover(s)}"
|
|
2745
2747
|
@focus="${() => this.handleNumberHover(s)}"
|
|
@@ -2832,9 +2834,9 @@ let I = class extends m {
|
|
|
2832
2834
|
[`pc-flex-align-${k(this.statsPosition, this.statsAlign)}`]: !0
|
|
2833
2835
|
};
|
|
2834
2836
|
return d`
|
|
2835
|
-
<div class="pc-container ${
|
|
2837
|
+
<div class="pc-container ${w(e)}" data-testid="nps-container">
|
|
2836
2838
|
${this.renderLabelAtStart()}
|
|
2837
|
-
<div class="pc-body ${
|
|
2839
|
+
<div class="pc-body ${w(t)}" data-testid="nps-body">
|
|
2838
2840
|
${this.renderStatusAtStart()} ${this.renderContent()} ${this.renderStatusAtEnd()}
|
|
2839
2841
|
</div>
|
|
2840
2842
|
${this.renderLabelAtEnd()}
|
|
@@ -3118,10 +3120,10 @@ const Mo = F`
|
|
|
3118
3120
|
visibility: hidden;
|
|
3119
3121
|
}
|
|
3120
3122
|
`;
|
|
3121
|
-
var
|
|
3122
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
3123
|
+
var Lo = Object.defineProperty, Ro = Object.getOwnPropertyDescriptor, Mt = (e, t, o, r) => {
|
|
3124
|
+
for (var s = r > 1 ? void 0 : r ? Ro(t, o) : t, i = e.length - 1, a; i >= 0; i--)
|
|
3123
3125
|
(a = e[i]) && (s = (r ? a(t, o, s) : a(s)) || s);
|
|
3124
|
-
return r && s &&
|
|
3126
|
+
return r && s && Lo(t, o, s), s;
|
|
3125
3127
|
};
|
|
3126
3128
|
let tt = class extends m {
|
|
3127
3129
|
constructor() {
|
|
@@ -3132,7 +3134,7 @@ let tt = class extends m {
|
|
|
3132
3134
|
"pc-status": !0,
|
|
3133
3135
|
[`pc-flex-content-${k("bottom", this.statsAlign)}`]: !0
|
|
3134
3136
|
};
|
|
3135
|
-
return d`<div class="${
|
|
3137
|
+
return d`<div class="${w(t)}" data-testid="pc-status">
|
|
3136
3138
|
<span>${this.renderStatsText()} ${this.renderEditToggleIcon("stats-edit-button")}</span>
|
|
3137
3139
|
</div>`;
|
|
3138
3140
|
}
|
|
@@ -3147,7 +3149,7 @@ let tt = class extends m {
|
|
|
3147
3149
|
}, t = this.displayController.shouldDisableSubmitButton();
|
|
3148
3150
|
return d`
|
|
3149
3151
|
<button
|
|
3150
|
-
class="${
|
|
3152
|
+
class="${w(e)}"
|
|
3151
3153
|
data-testid="pc-submit-button"
|
|
3152
3154
|
@click="${this.handleSubmit}"
|
|
3153
3155
|
?disabled="${t}"
|
|
@@ -3228,7 +3230,7 @@ let tt = class extends m {
|
|
|
3228
3230
|
return d`
|
|
3229
3231
|
<button
|
|
3230
3232
|
data-testid="poll-option-i${t}"
|
|
3231
|
-
class="${
|
|
3233
|
+
class="${w(s)}"
|
|
3232
3234
|
@click="${() => this.handleClick(e)}"
|
|
3233
3235
|
?disabled="${r}"
|
|
3234
3236
|
id="${a}-option-${t}"
|
|
@@ -3255,7 +3257,7 @@ let tt = class extends m {
|
|
|
3255
3257
|
});
|
|
3256
3258
|
return d`
|
|
3257
3259
|
<div
|
|
3258
|
-
class="${
|
|
3260
|
+
class="${w({
|
|
3259
3261
|
"poll-container": !0
|
|
3260
3262
|
})}"
|
|
3261
3263
|
data-testid="poll-option-container"
|
|
@@ -3272,13 +3274,13 @@ let tt = class extends m {
|
|
|
3272
3274
|
renderBarChart() {
|
|
3273
3275
|
var l, p;
|
|
3274
3276
|
const e = ((l = this.dataController.stats) == null ? void 0 : l.breakdown) || {}, t = ((p = this.dataController.localStats) == null ? void 0 : p.breakdown) || {}, o = Object.values(e).reduce((c, u) => c + u, 0), r = this.options.map((c, u) => {
|
|
3275
|
-
const
|
|
3277
|
+
const v = e[c.value] || 0, y = o > 0 ? Math.round(v / o * 100) : 0, P = (t[c.value] || 0) > 0;
|
|
3276
3278
|
return {
|
|
3277
3279
|
option: c,
|
|
3278
3280
|
index: u,
|
|
3279
|
-
voteCount:
|
|
3280
|
-
percentage:
|
|
3281
|
-
isSelected:
|
|
3281
|
+
voteCount: v,
|
|
3282
|
+
percentage: y,
|
|
3283
|
+
isSelected: P
|
|
3282
3284
|
};
|
|
3283
3285
|
}), s = this.multiple ? _.GROUP : _.RADIOGROUP, i = this.question || this.name || "Options", a = B({
|
|
3284
3286
|
role: s,
|
|
@@ -3286,7 +3288,7 @@ let tt = class extends m {
|
|
|
3286
3288
|
});
|
|
3287
3289
|
return d`
|
|
3288
3290
|
<div
|
|
3289
|
-
class="${
|
|
3291
|
+
class="${w({
|
|
3290
3292
|
"poll-container": !0
|
|
3291
3293
|
})}"
|
|
3292
3294
|
data-testid="poll-chart-container"
|
|
@@ -3302,7 +3304,7 @@ let tt = class extends m {
|
|
|
3302
3304
|
};
|
|
3303
3305
|
return d`
|
|
3304
3306
|
<div
|
|
3305
|
-
class="${
|
|
3307
|
+
class="${w(u)}"
|
|
3306
3308
|
data-testid="poll-chart-item-${c.index}"
|
|
3307
3309
|
role="listitem"
|
|
3308
3310
|
aria-label="${c.option.label}: ${c.percentage}% (${c.voteCount} votes)"
|
|
@@ -3373,12 +3375,12 @@ let tt = class extends m {
|
|
|
3373
3375
|
});
|
|
3374
3376
|
return d`
|
|
3375
3377
|
<div
|
|
3376
|
-
class="pc-container ${
|
|
3378
|
+
class="pc-container ${w(t)}"
|
|
3377
3379
|
data-testid="poll-container"
|
|
3378
3380
|
...=${s}
|
|
3379
3381
|
>
|
|
3380
3382
|
${this.renderLabelAtStart()}
|
|
3381
|
-
<div class="${
|
|
3383
|
+
<div class="${w(r)}" data-testid="poll-body">
|
|
3382
3384
|
${this.renderContent()} ${this.renderFooter()}
|
|
3383
3385
|
</div>
|
|
3384
3386
|
${this.renderLabelAtEnd()}
|
|
@@ -3719,7 +3721,7 @@ let V = class extends m {
|
|
|
3719
3721
|
<div class="pc-section" data-testid="pc-section">
|
|
3720
3722
|
<span
|
|
3721
3723
|
data-testid="stars-view-star-${n}"
|
|
3722
|
-
class=${
|
|
3724
|
+
class=${w(c)}
|
|
3723
3725
|
style=${Bo(u)}
|
|
3724
3726
|
role="${r ? "button" : "presentation"}"
|
|
3725
3727
|
tabindex="${r ? "0" : ""}"
|
|
@@ -3769,9 +3771,9 @@ let V = class extends m {
|
|
|
3769
3771
|
[`pc-flex-align-${o}`]: !0
|
|
3770
3772
|
};
|
|
3771
3773
|
return d`
|
|
3772
|
-
<div class="pc-container ${
|
|
3774
|
+
<div class="pc-container ${w(t)}" data-testid="pc-container">
|
|
3773
3775
|
${this.renderLabelAtStart()}
|
|
3774
|
-
<div class="${
|
|
3776
|
+
<div class="${w(r)}" data-testid="stars-body">
|
|
3775
3777
|
${this.renderStatusAtStart()} ${this.renderChart()} ${this.renderStars()}
|
|
3776
3778
|
${this.renderStatusAtEnd()}
|
|
3777
3779
|
</div>
|
|
@@ -4011,7 +4013,7 @@ let q = class extends m {
|
|
|
4011
4013
|
this.displayController.allowEdit() && (this.displayController.toggleReactionPopoverVisibility(), e.stopPropagation());
|
|
4012
4014
|
}
|
|
4013
4015
|
handleReactionClick(e) {
|
|
4014
|
-
this.displayController.allowEdit() && (this.dataController.toggleValueSelected(e.value, this.multiple), this.displayController.toggleReactionPopoverVisibility(!1));
|
|
4016
|
+
this.displayController.allowEdit() && (this.dataController.toggleValueSelected(e.value, this.multiple), this.dataController.submitStats(), this.displayController.toggleReactionPopoverVisibility(!1));
|
|
4015
4017
|
}
|
|
4016
4018
|
/**
|
|
4017
4019
|
* Renders the icon for a reaction
|
|
@@ -4044,7 +4046,7 @@ let q = class extends m {
|
|
|
4044
4046
|
}, n = `${e.tooltip || e.value} reaction${o ? ", selected" : ""}${t ? `, ${r} votes` : ""}`;
|
|
4045
4047
|
return d`
|
|
4046
4048
|
<button
|
|
4047
|
-
class="${
|
|
4049
|
+
class="${w(a)}"
|
|
4048
4050
|
@click="${() => this.handleReactionClick(e)}"
|
|
4049
4051
|
?disabled="${s}"
|
|
4050
4052
|
aria-pressed="${o}"
|
|
@@ -4086,7 +4088,7 @@ let q = class extends m {
|
|
|
4086
4088
|
bottom: this.popupPosition === "bottom" || this.popupPosition === "auto" && !this.shouldShowPopoverOnTop()
|
|
4087
4089
|
};
|
|
4088
4090
|
return d`
|
|
4089
|
-
<div class="${
|
|
4091
|
+
<div class="${w(e)}" role="menu">
|
|
4090
4092
|
<div class="popover-content">
|
|
4091
4093
|
${this.options.map((t) => {
|
|
4092
4094
|
const o = this.displayController.shouldDisableOption(t);
|
|
@@ -4133,7 +4135,7 @@ let q = class extends m {
|
|
|
4133
4135
|
(o) => this.dataController.isValueSelected(o.value)
|
|
4134
4136
|
);
|
|
4135
4137
|
return d`
|
|
4136
|
-
<div class="${
|
|
4138
|
+
<div class="${w(e)}">
|
|
4137
4139
|
${this.renderTriggerButton()}
|
|
4138
4140
|
${t.length > 0 ? d`
|
|
4139
4141
|
<div class="reaction-list">
|
|
@@ -4147,7 +4149,7 @@ let q = class extends m {
|
|
|
4147
4149
|
`;
|
|
4148
4150
|
} else
|
|
4149
4151
|
return d`
|
|
4150
|
-
<div class="${
|
|
4152
|
+
<div class="${w(e)}">
|
|
4151
4153
|
<div class="reaction-list">
|
|
4152
4154
|
${this.options.map((t) => this.renderReactionButton(t, this.showCounts))}
|
|
4153
4155
|
</div>
|
|
@@ -4191,9 +4193,9 @@ let q = class extends m {
|
|
|
4191
4193
|
[`pc-flex-align-${o}`]: !0
|
|
4192
4194
|
};
|
|
4193
4195
|
return d`
|
|
4194
|
-
<div class="${
|
|
4196
|
+
<div class="${w(t)}" data-testid="reaction-container">
|
|
4195
4197
|
${this.renderLabelAtStart()}
|
|
4196
|
-
<div class="${
|
|
4198
|
+
<div class="${w(r)}" data-testid="reaction-body">
|
|
4197
4199
|
${this.renderStatusAtStart()} ${this.renderChart()} ${this.renderReactions()}
|
|
4198
4200
|
${this.renderStatusAtEnd()}
|
|
4199
4201
|
</div>
|