pollcatch 2.1.16 → 2.2.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.
- package/package.json +1 -1
- package/pc.js +33 -34
package/package.json
CHANGED
package/pc.js
CHANGED
|
@@ -595,11 +595,11 @@ function f(e) {
|
|
|
595
595
|
function Tt(e) {
|
|
596
596
|
return f({ ...e, state: !0, attribute: !1 });
|
|
597
597
|
}
|
|
598
|
-
var
|
|
598
|
+
var x = /* @__PURE__ */ ((e) => (e.reaction = "reaction", e.stars = "stars", e.poll = "poll", e.text = "text", e.nps = "nps", e))(x || {});
|
|
599
599
|
const Ze = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24px'%20viewBox='0%20-960%20960%20960'%20width='24px'%20fill='%23434343'%3e%3cpath%20d='M640-160v-280h160v280H640Zm-240%200v-640h160v640H400Zm-240%200v-440h160v440H160Z'/%3e%3c/svg%3e", Ge = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24px'%20viewBox='0%20-960%20960%20960'%20width='24px'%20fill='%23434343'%3e%3cpath%20d='M160-160v-440h160v440H160Zm240%200v-400l160%20160v240H400Zm160-354L400-674v-126h160v286Zm240%20240L640-434v-6h160v166Zm-9%20219L55-791l57-57%20736%20736-57%2057Z'/%3e%3c/svg%3e", Ke = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24px'%20viewBox='0%20-960%20960%20960'%20width='24px'%20fill='currentColor'%3e%3cpath%20d='M200-200h57l391-391-57-57-391%20391v57Zm-80%2080v-170l528-527q12-11%2026.5-17t30.5-6q16%200%2031%206t26%2018l55%2056q12%2011%2017.5%2026t5.5%2030q0%2016-5.5%2030.5T817-647L290-120H120Zm640-584-56-56%2056%2056Zm-141%2085-28-29%2057%2057-29-28Z'/%3e%3c/svg%3e", We = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='16'%20height='16'%20fill='%23666666'%20class='bi%20bi-x'%20viewBox='0%200%2016%2016'%3e%3cpath%20d='M4.646%204.646a.5.5%200%200%201%20.708%200L8%207.293l2.646-2.647a.5.5%200%200%201%20.708.708L8.707%208l2.647%202.646a.5.5%200%200%201-.708.708L8%208.707l-2.646%202.647a.5.5%200%200%201-.708-.708L7.293%208%204.646%205.354a.5.5%200%200%201%200-.708'/%3e%3c/svg%3e";
|
|
600
600
|
var Je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
601
601
|
return typeof e == "string" ? e.length > 0 : typeof e == "number";
|
|
602
|
-
},
|
|
602
|
+
}, $ = function(e, t, o) {
|
|
603
603
|
return t === void 0 && (t = 0), o === void 0 && (o = Math.pow(10, t)), Math.round(o * e) / o + 0;
|
|
604
604
|
}, S = function(e, t, o) {
|
|
605
605
|
return t === void 0 && (t = 0), o === void 0 && (o = 1), e > o ? o : e > t ? e : t;
|
|
@@ -608,7 +608,7 @@ var Je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
608
608
|
}, Zt = function(e) {
|
|
609
609
|
return { r: S(e.r, 0, 255), g: S(e.g, 0, 255), b: S(e.b, 0, 255), a: S(e.a) };
|
|
610
610
|
}, wt = function(e) {
|
|
611
|
-
return { r:
|
|
611
|
+
return { r: $(e.r), g: $(e.g), b: $(e.b), a: $(e.a, 3) };
|
|
612
612
|
}, Xe = /^#([0-9a-f]{3,8})$/i, rt = function(e) {
|
|
613
613
|
var t = e.toString(16);
|
|
614
614
|
return t.length < 2 ? "0" + t : t;
|
|
@@ -623,7 +623,7 @@ var Je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
623
623
|
}, Gt = function(e) {
|
|
624
624
|
return { h: fe(e.h), s: S(e.s, 0, 100), l: S(e.l, 0, 100), a: S(e.a) };
|
|
625
625
|
}, Kt = function(e) {
|
|
626
|
-
return { h:
|
|
626
|
+
return { h: $(e.h), s: $(e.s), l: $(e.l), a: $(e.a, 3) };
|
|
627
627
|
}, Wt = function(e) {
|
|
628
628
|
return be((o = (t = e).s, { h: t.h, s: (o *= ((r = t.l) < 50 ? r : 100 - r) / 100) > 0 ? 2 * o / (r + o) * 100 : 0, v: r + o, a: t.a }));
|
|
629
629
|
var t, o, r;
|
|
@@ -632,7 +632,7 @@ var Je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
632
632
|
var t, o, r, s;
|
|
633
633
|
}, Qe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, to = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, eo = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, oo = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Jt = { string: [[function(e) {
|
|
634
634
|
var t = Xe.exec(e);
|
|
635
|
-
return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ?
|
|
635
|
+
return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ? $(parseInt(e[3] + e[3], 16) / 255, 2) : 1 } : e.length === 6 || e.length === 8 ? { r: parseInt(e.substr(0, 2), 16), g: parseInt(e.substr(2, 2), 16), b: parseInt(e.substr(4, 2), 16), a: e.length === 8 ? $(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
636
636
|
}, "hex"], [function(e) {
|
|
637
637
|
var t = eo.exec(e) || oo.exec(e);
|
|
638
638
|
return t ? t[2] !== t[4] || t[4] !== t[6] ? null : Zt({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: t[7] === void 0 ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
|
|
@@ -679,13 +679,13 @@ var Je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
679
679
|
return e.prototype.isValid = function() {
|
|
680
680
|
return this.parsed !== null;
|
|
681
681
|
}, e.prototype.brightness = function() {
|
|
682
|
-
return
|
|
682
|
+
return $(xt(this.rgba), 2);
|
|
683
683
|
}, e.prototype.isDark = function() {
|
|
684
684
|
return xt(this.rgba) < 0.5;
|
|
685
685
|
}, e.prototype.isLight = function() {
|
|
686
686
|
return xt(this.rgba) >= 0.5;
|
|
687
687
|
}, e.prototype.toHex = function() {
|
|
688
|
-
return t = wt(this.rgba), o = t.r, r = t.g, s = t.b, a = (i = t.a) < 1 ? rt(
|
|
688
|
+
return t = wt(this.rgba), o = t.r, r = t.g, s = t.b, a = (i = t.a) < 1 ? rt($(255 * i)) : "", "#" + rt(o) + rt(r) + rt(s) + a;
|
|
689
689
|
var t, o, r, s, i, a;
|
|
690
690
|
}, e.prototype.toRgb = function() {
|
|
691
691
|
return wt(this.rgba);
|
|
@@ -698,7 +698,7 @@ var Je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
698
698
|
return t = Kt(J(this.rgba)), o = t.h, r = t.s, s = t.l, (i = t.a) < 1 ? "hsla(" + o + ", " + r + "%, " + s + "%, " + i + ")" : "hsl(" + o + ", " + r + "%, " + s + "%)";
|
|
699
699
|
var t, o, r, s, i;
|
|
700
700
|
}, e.prototype.toHsv = function() {
|
|
701
|
-
return t = me(this.rgba), { h:
|
|
701
|
+
return t = me(this.rgba), { h: $(t.h), s: $(t.s), v: $(t.v), a: $(t.a, 3) };
|
|
702
702
|
var t;
|
|
703
703
|
}, e.prototype.invert = function() {
|
|
704
704
|
return C({ r: 255 - (t = this.rgba).r, g: 255 - t.g, b: 255 - t.b, a: t.a });
|
|
@@ -716,11 +716,11 @@ var Je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, A = function(e) {
|
|
|
716
716
|
}, e.prototype.rotate = function(t) {
|
|
717
717
|
return t === void 0 && (t = 15), this.hue(this.hue() + t);
|
|
718
718
|
}, e.prototype.alpha = function(t) {
|
|
719
|
-
return typeof t == "number" ? C({ r: (o = this.rgba).r, g: o.g, b: o.b, a: t }) :
|
|
719
|
+
return typeof t == "number" ? C({ r: (o = this.rgba).r, g: o.g, b: o.b, a: t }) : $(this.rgba.a, 3);
|
|
720
720
|
var o;
|
|
721
721
|
}, e.prototype.hue = function(t) {
|
|
722
722
|
var o = J(this.rgba);
|
|
723
|
-
return typeof t == "number" ? C({ h: t, s: o.s, l: o.l, a: o.a }) :
|
|
723
|
+
return typeof t == "number" ? C({ h: t, s: o.s, l: o.l, a: o.a }) : $(o.h);
|
|
724
724
|
}, e.prototype.isEqual = function(t) {
|
|
725
725
|
return this.toHex() === C(t).toHex();
|
|
726
726
|
}, e;
|
|
@@ -1175,7 +1175,7 @@ class _o {
|
|
|
1175
1175
|
sum: n.sum,
|
|
1176
1176
|
avg: l,
|
|
1177
1177
|
pct: p,
|
|
1178
|
-
nps: s ===
|
|
1178
|
+
nps: s === x.nps ? lt((n == null ? void 0 : n.breakdown) || {}) : 0,
|
|
1179
1179
|
breakdown: n.breakdown ?? {},
|
|
1180
1180
|
updated: n.updated_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
1181
1181
|
};
|
|
@@ -1194,14 +1194,14 @@ class _o {
|
|
|
1194
1194
|
*/
|
|
1195
1195
|
getOptionsForDataFunc(t) {
|
|
1196
1196
|
switch (t.type) {
|
|
1197
|
-
case
|
|
1197
|
+
case x.stars: {
|
|
1198
1198
|
const r = t.numStars || 5;
|
|
1199
1199
|
return Array.from({ length: r }, (s, i) => String(i + 1));
|
|
1200
1200
|
}
|
|
1201
|
-
case
|
|
1201
|
+
case x.nps:
|
|
1202
1202
|
return Array.from({ length: 11 }, (r, s) => String(s));
|
|
1203
|
-
case
|
|
1204
|
-
case
|
|
1203
|
+
case x.poll:
|
|
1204
|
+
case x.reaction:
|
|
1205
1205
|
default:
|
|
1206
1206
|
return t.options.map((r) => r.value);
|
|
1207
1207
|
}
|
|
@@ -1239,10 +1239,8 @@ class _o {
|
|
|
1239
1239
|
* @param textValues
|
|
1240
1240
|
*/
|
|
1241
1241
|
updateStats(t, o) {
|
|
1242
|
-
const r = this.host;
|
|
1243
1242
|
if (this.hasInteracted = !0, this.stats && (this.stats = $o(this.stats, this.localStats)), this.localStats = {
|
|
1244
|
-
count: t > 0 ||
|
|
1245
|
-
// always 1 or 0
|
|
1243
|
+
count: t > 0 || o.length > 0 ? 1 : 0,
|
|
1246
1244
|
sum: t,
|
|
1247
1245
|
// e.g. number of stars, nps value
|
|
1248
1246
|
avg: t,
|
|
@@ -1253,8 +1251,8 @@ class _o {
|
|
|
1253
1251
|
nps: 0,
|
|
1254
1252
|
updated: (/* @__PURE__ */ new Date()).toISOString()
|
|
1255
1253
|
}, o && o.length > 0)
|
|
1256
|
-
for (const
|
|
1257
|
-
|
|
1254
|
+
for (const r of o)
|
|
1255
|
+
r && (this.localStats.breakdown[r] = 1);
|
|
1258
1256
|
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();
|
|
1259
1257
|
}
|
|
1260
1258
|
async markStatsAsSubmitted() {
|
|
@@ -1327,7 +1325,7 @@ class _o {
|
|
|
1327
1325
|
sum: (o == null ? void 0 : o.sum) || 0,
|
|
1328
1326
|
avg: (o == null ? void 0 : o.avg) || 0,
|
|
1329
1327
|
pct: (o == null ? void 0 : o.pct) || 0,
|
|
1330
|
-
nps: r.type ===
|
|
1328
|
+
nps: r.type === x.nps ? lt((o == null ? void 0 : o.breakdown) || {}) : 0
|
|
1331
1329
|
};
|
|
1332
1330
|
return b.debug("Stats data: ", this.stats), Co(t, s);
|
|
1333
1331
|
}
|
|
@@ -1355,7 +1353,7 @@ class _o {
|
|
|
1355
1353
|
toggleValueSelected(t, o) {
|
|
1356
1354
|
const r = Object.keys(this.localStats.breakdown || {}), s = r.includes(t), i = this.host;
|
|
1357
1355
|
let a = 1;
|
|
1358
|
-
if ((i.type ===
|
|
1356
|
+
if ((i.type === x.stars || i.type === x.nps) && (a = parseInt(t)), s)
|
|
1359
1357
|
if (o) {
|
|
1360
1358
|
const l = r.filter((p) => p !== t);
|
|
1361
1359
|
this.updateStats(l.length > 0 ? 1 : 0, l);
|
|
@@ -1872,12 +1870,12 @@ Rt.styles = [
|
|
|
1872
1870
|
border-color: var(--pc-error-color);
|
|
1873
1871
|
}
|
|
1874
1872
|
|
|
1875
|
-
/*
|
|
1876
|
-
:host([
|
|
1873
|
+
/* Readonly state */
|
|
1874
|
+
:host([readonly]) {
|
|
1877
1875
|
pointer-events: auto;
|
|
1878
1876
|
}
|
|
1879
1877
|
|
|
1880
|
-
:host([
|
|
1878
|
+
:host([readonly]) button:not(.chart-toggle-icon):not([role='button']) {
|
|
1881
1879
|
cursor: default;
|
|
1882
1880
|
}
|
|
1883
1881
|
|
|
@@ -1988,7 +1986,7 @@ g([
|
|
|
1988
1986
|
f({ type: Boolean, attribute: "multiple" })
|
|
1989
1987
|
], m.prototype, "multiple");
|
|
1990
1988
|
g([
|
|
1991
|
-
f({ type: Boolean, attribute: "
|
|
1989
|
+
f({ type: Boolean, attribute: "readonly" })
|
|
1992
1990
|
], m.prototype, "readOnly");
|
|
1993
1991
|
const zo = F`
|
|
1994
1992
|
/* CSS variables inherit from parent - defaults are specified at usage sites */
|
|
@@ -2305,6 +2303,7 @@ const zo = F`
|
|
|
2305
2303
|
cursor: pointer;
|
|
2306
2304
|
transition: all 0.2s ease;
|
|
2307
2305
|
align-self: flex-end;
|
|
2306
|
+
white-space: nowrap;
|
|
2308
2307
|
}
|
|
2309
2308
|
|
|
2310
2309
|
.pc-submit-button--compact {
|
|
@@ -2652,7 +2651,7 @@ var Io = Object.defineProperty, No = Object.getOwnPropertyDescriptor, Y = (e, t,
|
|
|
2652
2651
|
};
|
|
2653
2652
|
let I = class extends m {
|
|
2654
2653
|
constructor() {
|
|
2655
|
-
super(), this.min = 0, this.max = 10, this.type =
|
|
2654
|
+
super(), this.min = 0, this.max = 10, this.type = x.nps, this.minLabel = "Not at all", this.maxLabel = "Extremely", this.minMaxPosition = "top", this.hoverValue = -1, this.handleNumberLeave = () => {
|
|
2656
2655
|
this.hoverValue = -1;
|
|
2657
2656
|
}, this.handleKeyDown = (e) => {
|
|
2658
2657
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.hoverValue >= 0 && this.handleNumberClick(this.hoverValue));
|
|
@@ -3061,7 +3060,7 @@ var Ro = Object.defineProperty, Lo = Object.getOwnPropertyDescriptor, Mt = (e, t
|
|
|
3061
3060
|
};
|
|
3062
3061
|
let tt = class extends m {
|
|
3063
3062
|
constructor() {
|
|
3064
|
-
super(), this.type =
|
|
3063
|
+
super(), this.type = x.poll, this.multiple = !1, this.compact = !1, this.hasEditButton = !0, this.statsText = "{count} votes", this.questionPosition = "top", this.statsPosition = "bottom", this.showStats = "after-vote";
|
|
3065
3064
|
}
|
|
3066
3065
|
renderStatus() {
|
|
3067
3066
|
const t = {
|
|
@@ -3607,7 +3606,7 @@ var Do = Object.defineProperty, Vo = Object.getOwnPropertyDescriptor, ht = (e, t
|
|
|
3607
3606
|
};
|
|
3608
3607
|
let V = class extends m {
|
|
3609
3608
|
constructor() {
|
|
3610
|
-
super(), this.type =
|
|
3609
|
+
super(), this.type = x.stars, this.icon = "★", this.numStars = 5, this.hoverValue = -1, this.handleStarKeyDown = (e) => {
|
|
3611
3610
|
if (e.key === "Enter" || e.key === " ") {
|
|
3612
3611
|
e.preventDefault();
|
|
3613
3612
|
const t = e.target, o = parseInt(t.dataset.star || "0");
|
|
@@ -3931,7 +3930,7 @@ var Fo = Object.defineProperty, Yo = Object.getOwnPropertyDescriptor, ft = (e, t
|
|
|
3931
3930
|
};
|
|
3932
3931
|
let q = class extends m {
|
|
3933
3932
|
constructor() {
|
|
3934
|
-
super(), this.type =
|
|
3933
|
+
super(), this.type = x.reaction, this.showCounts = !1, this.compact = !1, this.popupPosition = "auto", this.hasEditButton = !1, this.statsText = "{count} votes", this.buttonRadius = "990px", this.muteColor = "#cccccc", this.questionPosition = "top", this.statsPosition = "right", this.popupPosition = "auto";
|
|
3935
3934
|
}
|
|
3936
3935
|
/**
|
|
3937
3936
|
* Get the display count for a specific reaction including local optimistic updates
|
|
@@ -4245,13 +4244,13 @@ let H = class extends j {
|
|
|
4245
4244
|
*/
|
|
4246
4245
|
render() {
|
|
4247
4246
|
switch (this.type) {
|
|
4248
|
-
case
|
|
4247
|
+
case x.nps:
|
|
4249
4248
|
return d`<pc-nps></pc-nps>`;
|
|
4250
|
-
case
|
|
4249
|
+
case x.poll:
|
|
4251
4250
|
return d`<pc-poll .options=${this.parsedOptions}></pc-poll>`;
|
|
4252
|
-
case
|
|
4251
|
+
case x.stars:
|
|
4253
4252
|
return d`<pc-stars></pc-stars>`;
|
|
4254
|
-
case
|
|
4253
|
+
case x.reaction:
|
|
4255
4254
|
return d`<pc-reaction .options=${this.parsedOptions}></pc-reaction>`;
|
|
4256
4255
|
default:
|
|
4257
4256
|
return console.warn(
|