@getpinax/widget 0.0.0-stage → 1.0.0-beta.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/LICENSE +21 -0
- package/README.md +267 -2
- package/dist/api.d.ts +62 -0
- package/dist/capture/breadcrumbs.d.ts +49 -0
- package/dist/capture/console.d.ts +17 -0
- package/dist/capture/env.d.ts +25 -0
- package/dist/capture/network.d.ts +23 -0
- package/dist/capture/ring.d.ts +14 -0
- package/dist/capture/signature.d.ts +2 -0
- package/dist/capture/text.d.ts +7 -0
- package/dist/capture/ua.d.ts +13 -0
- package/dist/chunks/editor-DbHLGwOA.mjs +1368 -0
- package/dist/chunks/privacy-DmU6v5Fr.mjs +39 -0
- package/dist/chunks/recorder-BUtEB_em.mjs +2859 -0
- package/dist/chunks/text-8QYEyRYs.mjs +18 -0
- package/dist/chunks/widget-CkR1Ptzb.mjs +961 -0
- package/dist/editor/annotator.d.ts +20 -0
- package/dist/editor/capture.d.ts +28 -0
- package/dist/editor/encode.d.ts +7 -0
- package/dist/editor/index.d.ts +5 -0
- package/dist/editor/mask.d.ts +29 -0
- package/dist/editor/pii.d.ts +22 -0
- package/dist/editor/shapes.d.ts +31 -0
- package/dist/editor-loader.d.ts +6 -0
- package/dist/editor-loader.embed.d.ts +5 -0
- package/dist/fixcheck.d.ts +31 -0
- package/dist/index.d.ts +46 -0
- package/dist/mount.d.ts +8 -0
- package/dist/navigation.d.ts +1 -0
- package/dist/paths.d.ts +4 -0
- package/dist/pinax-editor.js +1417 -0
- package/dist/pinax-recorder.js +2902 -0
- package/dist/pinax.js +113 -0
- package/dist/pinax.mjs +1041 -0
- package/dist/preview.d.ts +35 -0
- package/dist/preview.mjs +54 -0
- package/dist/privacy.d.ts +22 -0
- package/dist/queue.d.ts +9 -0
- package/dist/replay/buffer.d.ts +40 -0
- package/dist/replay/recorder.d.ts +15 -0
- package/dist/replay/sanitize.d.ts +13 -0
- package/dist/report.d.ts +109 -0
- package/dist/segment.d.ts +31 -0
- package/dist/settings.d.ts +31 -0
- package/dist/types.d.ts +137 -0
- package/dist/ui/color.d.ts +7 -0
- package/dist/ui/dom.d.ts +14 -0
- package/dist/ui/styles.d.ts +3 -0
- package/dist/ui/widget.d.ts +161 -0
- package/package.json +73 -4
|
@@ -0,0 +1,961 @@
|
|
|
1
|
+
import { n as e, t } from "./text-8QYEyRYs.mjs";
|
|
2
|
+
// src/report.ts
|
|
3
|
+
var n = {
|
|
4
|
+
message: 5e3,
|
|
5
|
+
email: 320,
|
|
6
|
+
entries: 50,
|
|
7
|
+
annotations: 200,
|
|
8
|
+
screenshotChars: 6e6,
|
|
9
|
+
screenshotBytes: 4718592,
|
|
10
|
+
breadcrumbs: 20,
|
|
11
|
+
followUpQuestion: 300,
|
|
12
|
+
followUpAnswer: 2e3,
|
|
13
|
+
replayChars: 45e5,
|
|
14
|
+
fields: 10,
|
|
15
|
+
fieldId: 40,
|
|
16
|
+
fieldText: 200,
|
|
17
|
+
bodyBytes: 11534336
|
|
18
|
+
}, r = 65536, i = /^[A-Za-z0-9+/=]+$/, a = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/, o = /^data:image\/(png|jpeg|webp);base64,[A-Za-z0-9+/=]+$/;
|
|
19
|
+
function s(e) {
|
|
20
|
+
return e.length <= n.email && a.test(e);
|
|
21
|
+
}
|
|
22
|
+
function c(e) {
|
|
23
|
+
let t = e.slice(e.indexOf(",") + 1), n = t.endsWith("==") ? 2 : +!!t.endsWith("=");
|
|
24
|
+
return Math.floor(t.length * 3 / 4) - n;
|
|
25
|
+
}
|
|
26
|
+
function l(e) {
|
|
27
|
+
return e.length <= n.screenshotChars && o.test(e) && c(e) <= n.screenshotBytes;
|
|
28
|
+
}
|
|
29
|
+
function u(e) {
|
|
30
|
+
return e.message.trim().length > 0 || e.type === "GENERAL" && e.rating !== void 0 || e.screenshot !== void 0;
|
|
31
|
+
}
|
|
32
|
+
var d = (e, t) => Number.isFinite(e) ? Math.round(Math.min(1, Math.max(t, e)) * 1e4) / 1e4 : 0;
|
|
33
|
+
function f(n) {
|
|
34
|
+
let r = e(n);
|
|
35
|
+
if (r.length <= 2e3) return r;
|
|
36
|
+
try {
|
|
37
|
+
let e = new URL(r);
|
|
38
|
+
return e.toString().length > 2e3 && (e.search = ""), t(e.toString(), 2e3);
|
|
39
|
+
} catch {
|
|
40
|
+
return r.slice(0, 2e3);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function p(e) {
|
|
44
|
+
if (!e) return;
|
|
45
|
+
let n = {};
|
|
46
|
+
e.id != null && String(e.id) && (n.id = t(String(e.id), 200)), e.name && (n.name = t(String(e.name), 200));
|
|
47
|
+
let r = e.email?.trim();
|
|
48
|
+
return r && s(r) && (n.email = r), Object.keys(n).length ? n : void 0;
|
|
49
|
+
}
|
|
50
|
+
function m(e, r) {
|
|
51
|
+
let i = {
|
|
52
|
+
type: e.type,
|
|
53
|
+
message: t(e.message.trim(), n.message),
|
|
54
|
+
page: {
|
|
55
|
+
url: f(r.page.url),
|
|
56
|
+
title: r.page.title ? t(r.page.title, 500) : void 0
|
|
57
|
+
},
|
|
58
|
+
environment: r.environment
|
|
59
|
+
};
|
|
60
|
+
e.type === "GENERAL" && e.rating !== void 0 && Number.isInteger(e.rating) && e.rating >= 1 && e.rating <= 5 && (i.rating = e.rating);
|
|
61
|
+
let a = e.email?.trim().toLowerCase();
|
|
62
|
+
a && s(a) && (i.email = a);
|
|
63
|
+
let o = p(e.user);
|
|
64
|
+
o && (i.user = o), r.console.length && (i.console = r.console.slice(-n.entries)), r.network.length && (i.network = r.network.slice(-n.entries)), r.breadcrumbs?.length && (i.breadcrumbs = r.breadcrumbs.slice(-n.breadcrumbs).map((e) => {
|
|
65
|
+
let n = {
|
|
66
|
+
kind: e.kind,
|
|
67
|
+
at: t(e.at, 40),
|
|
68
|
+
path: t(e.path, 500)
|
|
69
|
+
};
|
|
70
|
+
return e.target && (n.target = t(e.target, 200)), n;
|
|
71
|
+
}));
|
|
72
|
+
let c = e.followUp?.question.trim(), u = e.followUp?.answer.trim();
|
|
73
|
+
c && u && (i.followUp = {
|
|
74
|
+
question: t(c, n.followUpQuestion),
|
|
75
|
+
answer: t(u, n.followUpAnswer)
|
|
76
|
+
});
|
|
77
|
+
let m = (e.fields ?? []).filter((e) => typeof e.id == "string" && e.id.length <= n.fieldId && (typeof e.value == "boolean" || typeof e.value == "string" && e.value.trim())).slice(0, n.fields).map((e) => ({
|
|
78
|
+
id: e.id,
|
|
79
|
+
value: typeof e.value == "boolean" ? e.value : t(e.value.trim(), n.fieldText)
|
|
80
|
+
}));
|
|
81
|
+
return m.length && (i.fields = m), e.hp && (i.hp = t(e.hp, 500)), e.elapsedMs !== void 0 && Number.isFinite(e.elapsedMs) && e.elapsedMs >= 0 && (i.elapsedMs = Math.min(Math.round(e.elapsedMs), 864e5)), e.screenshot && l(e.screenshot) && (i.screenshot = e.screenshot, e.annotations?.length && (i.annotations = e.annotations.slice(0, n.annotations).map((e) => {
|
|
82
|
+
let n = e.type === "arrow" ? -1 : 0, r = {
|
|
83
|
+
type: e.type,
|
|
84
|
+
x: d(e.x, 0),
|
|
85
|
+
y: d(e.y, 0),
|
|
86
|
+
w: d(e.w, n),
|
|
87
|
+
h: d(e.h, n)
|
|
88
|
+
};
|
|
89
|
+
return e.type === "text" && e.text && (r.text = t(e.text, 500)), r;
|
|
90
|
+
}))), i;
|
|
91
|
+
}
|
|
92
|
+
function h(e) {
|
|
93
|
+
return new TextEncoder().encode(JSON.stringify(e)).length;
|
|
94
|
+
}
|
|
95
|
+
function g(e, t) {
|
|
96
|
+
return !t || t.length > n.replayChars || !i.test(t) || h(e) + t.length + 12 > n.bodyBytes - r ? !1 : (e.replay = t, !0);
|
|
97
|
+
}
|
|
98
|
+
// src/settings.ts
|
|
99
|
+
var _ = {
|
|
100
|
+
color: "#B8F35C",
|
|
101
|
+
text: "Feedback",
|
|
102
|
+
position: "bottom-right",
|
|
103
|
+
types: {
|
|
104
|
+
problem: !0,
|
|
105
|
+
idea: !0,
|
|
106
|
+
general: !0
|
|
107
|
+
},
|
|
108
|
+
rating: !0,
|
|
109
|
+
hidePaths: [],
|
|
110
|
+
smallOnMobile: !1,
|
|
111
|
+
hideButton: !1,
|
|
112
|
+
segment: !1,
|
|
113
|
+
wording: {
|
|
114
|
+
chooserTitle: "",
|
|
115
|
+
problemTitle: "",
|
|
116
|
+
ideaTitle: "",
|
|
117
|
+
generalTitle: "",
|
|
118
|
+
messagePlaceholder: "",
|
|
119
|
+
confirmation: ""
|
|
120
|
+
},
|
|
121
|
+
fields: [],
|
|
122
|
+
capture: {
|
|
123
|
+
console: !0,
|
|
124
|
+
network: !0
|
|
125
|
+
}
|
|
126
|
+
}, v = {
|
|
127
|
+
fields: 10,
|
|
128
|
+
label: 80,
|
|
129
|
+
options: 20,
|
|
130
|
+
option: 80,
|
|
131
|
+
text: 200
|
|
132
|
+
}, y = [
|
|
133
|
+
"bottom-right",
|
|
134
|
+
"bottom-left",
|
|
135
|
+
"right-edge"
|
|
136
|
+
], b = Object.keys(_.wording), x = (e, t) => typeof e == "string" ? e.trim().slice(0, t) : "", S = (e, t) => typeof e == "boolean" ? e : t, C = [
|
|
137
|
+
"select",
|
|
138
|
+
"text",
|
|
139
|
+
"checkbox"
|
|
140
|
+
];
|
|
141
|
+
function w(e) {
|
|
142
|
+
if (!Array.isArray(e)) return [];
|
|
143
|
+
let t = [], n = /* @__PURE__ */ new Set();
|
|
144
|
+
for (let r of e) {
|
|
145
|
+
if (!r || typeof r != "object") continue;
|
|
146
|
+
let e = r, i = typeof e.id == "string" ? e.id.slice(0, 40) : "", a = e.type, o = x(e.label, v.label);
|
|
147
|
+
if (!i || n.has(i) || !C.includes(a) || !o) continue;
|
|
148
|
+
let s = a === "select" && Array.isArray(e.options) ? [...new Set(e.options.map((e) => x(e, v.option)).filter(Boolean))].slice(0, v.options) : [];
|
|
149
|
+
if (a === "select" && !s.length) continue;
|
|
150
|
+
let c = e.types ?? {};
|
|
151
|
+
if (n.add(i), t.push({
|
|
152
|
+
id: i,
|
|
153
|
+
type: a,
|
|
154
|
+
label: o,
|
|
155
|
+
required: e.required === !0,
|
|
156
|
+
options: s,
|
|
157
|
+
types: {
|
|
158
|
+
problem: S(c.problem, !0),
|
|
159
|
+
idea: S(c.idea, !0),
|
|
160
|
+
general: S(c.general, !0)
|
|
161
|
+
}
|
|
162
|
+
}), t.length >= v.fields) break;
|
|
163
|
+
}
|
|
164
|
+
return t;
|
|
165
|
+
}
|
|
166
|
+
function T(e) {
|
|
167
|
+
let t = e ?? {}, n = _, r = t.types ?? {}, i = {
|
|
168
|
+
problem: S(r.problem, !0),
|
|
169
|
+
idea: S(r.idea, !0),
|
|
170
|
+
general: S(r.general, !0)
|
|
171
|
+
}, a = i.problem || i.idea || i.general, o = t.wording ?? {}, s = { ...n.wording };
|
|
172
|
+
for (let e of b) s[e] = x(o[e], 120);
|
|
173
|
+
return {
|
|
174
|
+
color: typeof t.color == "string" ? t.color : n.color,
|
|
175
|
+
text: x(t.text, 40) || n.text,
|
|
176
|
+
position: y.includes(t.position) ? t.position : n.position,
|
|
177
|
+
types: a ? i : { ...n.types },
|
|
178
|
+
rating: S(t.rating, n.rating),
|
|
179
|
+
hidePaths: Array.isArray(t.hidePaths) ? t.hidePaths.filter((e) => typeof e == "string") : [],
|
|
180
|
+
smallOnMobile: S(t.smallOnMobile, n.smallOnMobile),
|
|
181
|
+
hideButton: S(t.hideButton, n.hideButton),
|
|
182
|
+
segment: S(t.segment, n.segment),
|
|
183
|
+
wording: s,
|
|
184
|
+
fields: w(t.fields),
|
|
185
|
+
capture: {
|
|
186
|
+
console: S(t.capture?.console, !0),
|
|
187
|
+
network: S(t.capture?.network, !0)
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
var E = /^#[0-9a-fA-F]{6}$/, D = (e) => typeof e == "string" && E.test(e) ? e : null;
|
|
192
|
+
function O(e) {
|
|
193
|
+
let t = e && typeof e == "object" ? e : {}, n = typeof t.logoUrl == "string" && /^https?:\/\//i.test(t.logoUrl) ? t.logoUrl.slice(0, 2e3) : null;
|
|
194
|
+
return {
|
|
195
|
+
poweredBy: t.poweredBy === !0,
|
|
196
|
+
logoUrl: n,
|
|
197
|
+
primary: D(t.primary),
|
|
198
|
+
accent: D(t.accent)
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
var k = (e) => typeof e == "number" && Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
|
|
202
|
+
function A(e, t) {
|
|
203
|
+
let n = e && typeof e == "object" ? e : {}, r = typeof t == "number" ? k(t) : 1, i = Array.isArray(n.fixChecks) ? n.fixChecks : [];
|
|
204
|
+
return {
|
|
205
|
+
followUp: n.followUp === !0,
|
|
206
|
+
autoBlur: n.autoBlur === !0,
|
|
207
|
+
replay: n.replay === !0,
|
|
208
|
+
replaySampleRate: Math.min(n.replaySampleRate === void 0 ? 1 : k(n.replaySampleRate), r),
|
|
209
|
+
fixChecks: i.filter((e) => !!e && typeof e.id == "string" && typeof e.path == "string" && typeof e.signature == "string"),
|
|
210
|
+
fixCheckSampleRate: Math.min(k(n.fixCheckSampleRate), r)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
// src/ui/color.ts
|
|
214
|
+
function j(e) {
|
|
215
|
+
let t = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
|
|
216
|
+
if (!t) return null;
|
|
217
|
+
let n = t[1];
|
|
218
|
+
n.length === 3 && (n = [...n].map((e) => e + e).join(""));
|
|
219
|
+
let [r, i, a] = [
|
|
220
|
+
0,
|
|
221
|
+
2,
|
|
222
|
+
4
|
|
223
|
+
].map((e) => {
|
|
224
|
+
let t = Number.parseInt(n.slice(e, e + 2), 16) / 255;
|
|
225
|
+
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
226
|
+
});
|
|
227
|
+
return .2126 * r + .7152 * i + .0722 * a;
|
|
228
|
+
}
|
|
229
|
+
function M(e, t) {
|
|
230
|
+
let [n, r] = e > t ? [e, t] : [t, e];
|
|
231
|
+
return (n + .05) / (r + .05);
|
|
232
|
+
}
|
|
233
|
+
function N(e) {
|
|
234
|
+
let t = j(e);
|
|
235
|
+
return t === null ? "#FFFFFF" : M(t, j("#0B1300")) >= M(t, 1) ? "#0B1300" : "#FFFFFF";
|
|
236
|
+
}
|
|
237
|
+
function P(e, t = "#B8F35C") {
|
|
238
|
+
return typeof e == "string" && j(e) !== null ? e.trim() : t;
|
|
239
|
+
}
|
|
240
|
+
// src/ui/dom.ts
|
|
241
|
+
function F(e, t = {}, ...n) {
|
|
242
|
+
let r = document.createElement(e);
|
|
243
|
+
for (let [e, n] of Object.entries(t)) n != null && n !== !1 && r.setAttribute(e, n === !0 ? "" : String(n));
|
|
244
|
+
for (let e of n) e != null && e !== !1 && r.append(e);
|
|
245
|
+
return r;
|
|
246
|
+
}
|
|
247
|
+
var I = "http://www.w3.org/2000/svg";
|
|
248
|
+
function L(e, t = 16) {
|
|
249
|
+
let n = document.createElementNS(I, "svg");
|
|
250
|
+
n.setAttribute("width", String(t)), n.setAttribute("height", String(t)), n.setAttribute("viewBox", "0 0 24 24"), n.setAttribute("fill", "none"), n.setAttribute("stroke", "currentColor"), n.setAttribute("stroke-width", "2.2"), n.setAttribute("stroke-linecap", "round"), n.setAttribute("stroke-linejoin", "round"), n.setAttribute("aria-hidden", "true");
|
|
251
|
+
let r = document.createElementNS(I, "path");
|
|
252
|
+
return r.setAttribute("d", e), n.append(r), n;
|
|
253
|
+
}
|
|
254
|
+
var R = {
|
|
255
|
+
close: "M18 6L6 18M6 6l12 12",
|
|
256
|
+
back: "M15 18l-6-6 6-6",
|
|
257
|
+
pen: "M12 20h9M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z",
|
|
258
|
+
camera: "M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2zM12 17a4 4 0 100-8 4 4 0 000 8z",
|
|
259
|
+
trash: "M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6"
|
|
260
|
+
}, z = "\n $ .panel, $.pos-bottom-right .panel, $.pos-bottom-left .panel, $.pos-right-edge .panel { left: 0; right: 0; bottom: 0; width: 100%; max-width: none; max-height: 88vh; border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }\n $.open .launcher { display: none; }\n $ .field textarea, $ .field input, $ .field select { font-size: 16px; }\n $ .launcher { padding: 11px 16px; font-size: 14px; }\n $.pos-bottom-right .launcher { right: 16px; bottom: 16px; }\n $.pos-bottom-left .launcher { left: 16px; bottom: 16px; }\n $.small .launcher { padding: 8px 12px; font-size: 13px; box-shadow: 0 8px 20px -6px rgba(0,0,0,0.35); }\n $.small.pos-bottom-right .launcher { right: 12px; bottom: 12px; }\n $.small.pos-bottom-left .launcher { left: 12px; bottom: 12px; }\n $.small.pos-right-edge .launcher { padding: 8px 10px; }\n";
|
|
261
|
+
function B(e, t) {
|
|
262
|
+
let n = z.replace(/\$/g, t);
|
|
263
|
+
return e ? `${e}${n}}` : n;
|
|
264
|
+
}
|
|
265
|
+
var V = `
|
|
266
|
+
:host { all: initial; }
|
|
267
|
+
* { box-sizing: border-box; }
|
|
268
|
+
.pnx { font-family: Manrope, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #111827; font-size: 14px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
|
|
269
|
+
button { font: inherit; color: inherit; cursor: pointer; }
|
|
270
|
+
button:disabled { cursor: default; }
|
|
271
|
+
:focus-visible { outline: 3px solid #2E46BF; outline-offset: 2px; }
|
|
272
|
+
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
273
|
+
|
|
274
|
+
.launcher { position: fixed; z-index: 2; border: 0; padding: 13px 20px; border-radius: 999px; font-weight: 700; font-size: 15px; line-height: 1.2; box-shadow: 0 12px 30px -8px rgba(0,0,0,0.35); background: var(--pnx-brand); color: var(--pnx-ink); transition: transform .15s ease; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
275
|
+
.launcher:hover { transform: translateY(-1px); }
|
|
276
|
+
.pos-bottom-right .launcher { right: 24px; bottom: 24px; }
|
|
277
|
+
.pos-bottom-left .launcher { left: 24px; bottom: 24px; }
|
|
278
|
+
.pos-right-edge .launcher { right: 0; top: 45%; border-radius: 10px 0 0 10px; }
|
|
279
|
+
.pos-right-edge .launcher:hover { transform: translateX(-2px); }
|
|
280
|
+
.pos-right-edge.open .launcher { visibility: hidden; }
|
|
281
|
+
.launcher[hidden] { display: none; }
|
|
282
|
+
|
|
283
|
+
.panel { position: fixed; z-index: 3; bottom: 84px; width: 300px; max-width: calc(100vw - 32px); max-height: calc(100vh - 108px); overflow: auto; padding: 18px; border-radius: 16px; background: #FFFFFF; color: #111827; box-shadow: 0 30px 60px -18px rgba(0,0,0,0.45), 0 0 0 1px rgba(17,24,39,0.06); display: flex; flex-direction: column; gap: 12px; }
|
|
284
|
+
.panel[hidden] { display: none; }
|
|
285
|
+
.pos-bottom-right .panel { right: 24px; }
|
|
286
|
+
.pos-bottom-left .panel { left: 24px; }
|
|
287
|
+
.pos-right-edge .panel { right: 24px; bottom: 24px; max-height: calc(100vh - 48px); }
|
|
288
|
+
.no-button .panel { bottom: 24px; max-height: calc(100vh - 48px); }
|
|
289
|
+
|
|
290
|
+
.head { display: flex; align-items: center; gap: 8px; }
|
|
291
|
+
.title { margin: 0; flex: 1; font-size: 15px; font-weight: 700; }
|
|
292
|
+
.icon-btn { flex: none; width: 32px; height: 32px; margin: -6px; border: 0; border-radius: 8px; background: transparent; color: #5B6474; display: inline-flex; align-items: center; justify-content: center; }
|
|
293
|
+
.icon-btn:hover { background: #F2F4F8; color: #111827; }
|
|
294
|
+
.head .icon-btn:first-child { margin-right: 0; }
|
|
295
|
+
|
|
296
|
+
.choices { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
|
|
297
|
+
.choice { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 0; border-radius: 10px; background: #F2F4F8; font-size: 14px; font-weight: 600; text-align: left; }
|
|
298
|
+
.choice:hover { background: #FFF1EC; box-shadow: inset 0 0 0 2px var(--dot); }
|
|
299
|
+
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--dot); }
|
|
300
|
+
.choice small { display: block; font-size: 12px; font-weight: 500; color: #5B6474; }
|
|
301
|
+
|
|
302
|
+
.shot { position: relative; border-radius: 10px; background: #F4EDE2; overflow: hidden; min-height: 72px; display: flex; align-items: center; justify-content: center; }
|
|
303
|
+
.shot img { display: block; width: 100%; height: auto; max-height: 160px; object-fit: contain; background: #F2F4F8; }
|
|
304
|
+
.shot .tag { position: absolute; right: 8px; top: 8px; padding: 3px 7px; border-radius: 6px; background: #111827; color: #FFFFFF; font-size: 11px; font-weight: 700; }
|
|
305
|
+
.shot .wait { font-size: 13px; color: #5B6474; padding: 20px; }
|
|
306
|
+
.shot-actions { display: flex; gap: 8px; flex-wrap: wrap; }
|
|
307
|
+
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 7px 11px; border: 0; border-radius: 8px; background: #F2F4F8; color: #111827; font-size: 13px; font-weight: 700; }
|
|
308
|
+
.chip:hover { background: #E3E8F0; }
|
|
309
|
+
.chip.primary { background: #111827; color: #FFFFFF; }
|
|
310
|
+
.chip.primary:hover { background: #1F2937; }
|
|
311
|
+
|
|
312
|
+
.field { display: flex; flex-direction: column; gap: 6px; }
|
|
313
|
+
.field label, .legend { font-size: 12px; font-weight: 600; color: #5B6474; }
|
|
314
|
+
.field textarea, .field input { width: 100%; border: 0; border-radius: 10px; padding: 11px 12px; background: #F2F4F8; color: #111827; font: inherit; font-size: 14px; line-height: 1.5; box-shadow: inset 0 0 0 1px transparent; }
|
|
315
|
+
.field textarea { min-height: 84px; resize: vertical; }
|
|
316
|
+
.field textarea::placeholder, .field input::placeholder { color: #5B6474; opacity: 1; }
|
|
317
|
+
.field textarea:focus, .field input:focus { outline: none; box-shadow: inset 0 0 0 2px #2E46BF; background: #FFFFFF; }
|
|
318
|
+
.field .hint { font-size: 12px; color: #5B6474; }
|
|
319
|
+
.field select { width: 100%; border: 0; border-radius: 10px; padding: 11px 12px; background: #F2F4F8; color: #111827; font: inherit; font-size: 14px; line-height: 1.5; }
|
|
320
|
+
.field select:focus { outline: none; box-shadow: inset 0 0 0 2px #2E46BF; background: #FFFFFF; }
|
|
321
|
+
.field [aria-invalid="true"] { box-shadow: inset 0 0 0 2px #B42318; }
|
|
322
|
+
.field .optional { font-weight: 500; }
|
|
323
|
+
.field.check { flex-direction: row; align-items: flex-start; gap: 10px; }
|
|
324
|
+
.field.check input { flex: none; width: 20px; height: 20px; margin: 0; padding: 0; accent-color: #2E46BF; box-shadow: none; }
|
|
325
|
+
.field.check label { font-size: 13px; color: #111827; font-weight: 600; line-height: 1.45; }
|
|
326
|
+
.field.check input[aria-invalid="true"] { outline: 2px solid #B42318; outline-offset: 2px; }
|
|
327
|
+
.brand { display: flex; align-items: center; min-height: 28px; }
|
|
328
|
+
.brand .logo { display: block; max-height: 32px; max-width: 160px; width: auto; height: auto; object-fit: contain; }
|
|
329
|
+
.accented .panel { border-top: 4px solid var(--pnx-accent); }
|
|
330
|
+
.accented .choice:hover { box-shadow: inset 0 0 0 2px var(--pnx-accent); }
|
|
331
|
+
.accented .tick { background: var(--pnx-accent); color: var(--pnx-accent-ink); }
|
|
332
|
+
|
|
333
|
+
.stars { display: flex; gap: 4px; border: 0; margin: 0; padding: 0; }
|
|
334
|
+
.star { width: 40px; height: 40px; border: 0; border-radius: 10px; font-size: 24px; line-height: 1; background: #F2F4F8; color: #6B7280; }
|
|
335
|
+
.star.on { background: #FFF6DF; color: #B9800F; }
|
|
336
|
+
|
|
337
|
+
.error { margin: 0; font-size: 13px; color: #B42318; font-weight: 600; }
|
|
338
|
+
.error:empty { display: none; }
|
|
339
|
+
.send { width: 100%; padding: 12px; border: 0; border-radius: 10px; font-size: 14px; font-weight: 800; background: var(--type); color: var(--type-ink); }
|
|
340
|
+
.send:disabled { opacity: .7; }
|
|
341
|
+
.powered { font-size: 11px; color: #5B6474; text-align: center; }
|
|
342
|
+
.powered a { color: inherit; text-decoration: none; }
|
|
343
|
+
.powered a:hover { text-decoration: underline; }
|
|
344
|
+
|
|
345
|
+
.done { text-align: center; padding: 18px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
|
|
346
|
+
.tick { width: 46px; height: 46px; border-radius: 50%; background: #B8F35C; color: #0B1300; font-size: 22px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
|
|
347
|
+
.done p { margin: 0; font-size: 13px; color: #5B6474; }
|
|
348
|
+
.link { border: 0; background: transparent; color: #5B6474; font-size: 13px; font-weight: 700; padding: 6px 8px; border-radius: 6px; }
|
|
349
|
+
.link:hover { color: #111827; }
|
|
350
|
+
|
|
351
|
+
.note { display: flex; align-items: baseline; gap: 8px; padding: 10px 12px; border-radius: 10px; background: #F2F4F8; color: #5B6474; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
|
|
352
|
+
.note .dot { transform: translateY(-1px); }
|
|
353
|
+
.field label.question { font-size: 14px; font-weight: 700; color: #111827; line-height: 1.4; }
|
|
354
|
+
.field textarea.answer { min-height: 64px; }
|
|
355
|
+
.skip { width: 100%; padding: 8px; text-align: center; }
|
|
356
|
+
.skip:disabled, .send:disabled + .skip { opacity: .7; }
|
|
357
|
+
.hint.auto-blur { display: flex; align-items: center; gap: 6px; }
|
|
358
|
+
.hint.auto-blur i { flex: none; width: 16px; height: 10px; border-radius: 3px; background: repeating-linear-gradient(90deg, #D8DEE9 0 4px, #C7CFDC 4px 8px); box-shadow: 0 0 0 1px #C7CFDC; }
|
|
359
|
+
|
|
360
|
+
${B("@media (max-width: 520px) {", ".pnx")}
|
|
361
|
+
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
|
|
362
|
+
@media (forced-colors: active) { .launcher, .choice, .send, .chip, .star { border: 1px solid ButtonText; } }
|
|
363
|
+
`, H = [
|
|
364
|
+
{
|
|
365
|
+
type: "PROBLEM",
|
|
366
|
+
key: "problem",
|
|
367
|
+
label: "Report a problem",
|
|
368
|
+
desc: "Point at what is broken",
|
|
369
|
+
dot: "#FF5C35",
|
|
370
|
+
send: "#CC3F1B",
|
|
371
|
+
ink: "#FFFFFF"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
type: "IDEA",
|
|
375
|
+
key: "idea",
|
|
376
|
+
label: "Share an idea",
|
|
377
|
+
desc: "Suggest something better",
|
|
378
|
+
dot: "#7C9CFF",
|
|
379
|
+
send: "#7C9CFF",
|
|
380
|
+
ink: "#0B1122"
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
type: "GENERAL",
|
|
384
|
+
key: "general",
|
|
385
|
+
label: "General feedback",
|
|
386
|
+
desc: "A rating and a few words",
|
|
387
|
+
dot: "#3DBF6E",
|
|
388
|
+
send: "#3DBF6E",
|
|
389
|
+
ink: "#0B1300"
|
|
390
|
+
}
|
|
391
|
+
], U = 4e3, W = "What would you like to do?", G = "Thanks! We've got it.", K = {
|
|
392
|
+
problem: "problemTitle",
|
|
393
|
+
idea: "ideaTitle",
|
|
394
|
+
general: "generalTitle"
|
|
395
|
+
}, q = class {
|
|
396
|
+
constructor(e, t, n, r = {}) {
|
|
397
|
+
this.root = e, this.config = t, this.handlers = n, this.kind = null, this.shot = { kind: "none" }, this.message = "", this.email = "", this.answers = {}, this.sendColour = null, this.sending = !1, this.openedAt = 0, this.hp = "", this.uid = Math.random().toString(36).slice(2, 8), this.pathHidden = !1, this.returnFocus = null, this.view = "choose", this.queued = !1, this.asked = null, this.answer = "";
|
|
398
|
+
let i = t.settings, a = t.branding?.primary ? P(t.branding.primary, "") : "", o = t.branding?.accent ? P(t.branding.accent, "") : "", s = a || P(i.color);
|
|
399
|
+
this.sendColour = a || null, this.kinds = H.filter((e) => i.types?.[e.key] !== !1), this.kinds.length || (this.kinds = H);
|
|
400
|
+
let c = F("style");
|
|
401
|
+
c.textContent = r.css ? V + r.css : V, this.launcher = F("button", {
|
|
402
|
+
type: "button",
|
|
403
|
+
class: "launcher",
|
|
404
|
+
"aria-haspopup": "dialog",
|
|
405
|
+
"aria-expanded": "false",
|
|
406
|
+
"aria-controls": `pnx-panel-${this.uid}`
|
|
407
|
+
}, (i.text || "Feedback").slice(0, 40)), this.launcher.addEventListener("click", () => this.isOpen() ? this.close() : this.open()), this.panel = F("div", {
|
|
408
|
+
class: "panel",
|
|
409
|
+
id: `pnx-panel-${this.uid}`,
|
|
410
|
+
role: "dialog",
|
|
411
|
+
"aria-modal": "false",
|
|
412
|
+
"aria-labelledby": `pnx-title-${this.uid}`,
|
|
413
|
+
hidden: !0
|
|
414
|
+
}), this.panel.addEventListener("keydown", (e) => {
|
|
415
|
+
e.key === "Escape" && (e.stopPropagation(), this.close());
|
|
416
|
+
}), this.panel.addEventListener("pointerdown", () => this.holdOpen()), this.panel.addEventListener("focusin", () => this.holdOpen()), this.live = F("div", {
|
|
417
|
+
class: "sr",
|
|
418
|
+
role: "status",
|
|
419
|
+
"aria-live": "polite"
|
|
420
|
+
});
|
|
421
|
+
let l = [
|
|
422
|
+
"bottom-right",
|
|
423
|
+
"bottom-left",
|
|
424
|
+
"right-edge"
|
|
425
|
+
].includes(i.position) ? i.position : "bottom-right";
|
|
426
|
+
this.wrap = F("div", { class: `pnx pos-${l}${r.className ? ` ${r.className}` : ""}` }), i.smallOnMobile && this.wrap.classList.add("small"), this.updateButton(), this.wrap.style.setProperty("--pnx-brand", s), this.wrap.style.setProperty("--pnx-ink", N(s)), o && (this.wrap.classList.add("accented"), this.wrap.style.setProperty("--pnx-accent", o), this.wrap.style.setProperty("--pnx-accent-ink", N(o))), this.wrap.append(this.launcher, this.panel, this.live), e.append(c, this.wrap);
|
|
427
|
+
}
|
|
428
|
+
isOpen() {
|
|
429
|
+
return !this.panel.hidden;
|
|
430
|
+
}
|
|
431
|
+
hasButton() {
|
|
432
|
+
return !this.launcher.hidden;
|
|
433
|
+
}
|
|
434
|
+
setPathHidden(e) {
|
|
435
|
+
this.pathHidden = e, this.updateButton();
|
|
436
|
+
}
|
|
437
|
+
updateButton() {
|
|
438
|
+
let e = this.config.settings.hideButton || this.pathHidden;
|
|
439
|
+
this.launcher.hidden = e, this.wrap.classList.toggle("no-button", e);
|
|
440
|
+
}
|
|
441
|
+
open(e = !0) {
|
|
442
|
+
if (this.isOpen()) {
|
|
443
|
+
e && this.focusFirst();
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
let t = document.activeElement;
|
|
447
|
+
this.returnFocus = t instanceof HTMLElement && t !== this.root.host ? t : null, this.openedAt || (this.openedAt = Date.now()), this.panel.hidden = !1, this.wrap.classList.add("open"), this.launcher.setAttribute("aria-expanded", "true"), !this.kind && this.kinds.length === 1 && this.pick(this.kinds[0], !1), this.render(), e && this.focusFirst();
|
|
448
|
+
try {
|
|
449
|
+
this.handlers.opened?.();
|
|
450
|
+
} catch {}
|
|
451
|
+
}
|
|
452
|
+
close(e = !0) {
|
|
453
|
+
clearTimeout(this.closeTimer), this.isOpen() && (this.panel.hidden = !0, this.wrap.classList.remove("open"), this.launcher.setAttribute("aria-expanded", "false"), this.view === "done" && this.reset(), e && (this.hasButton() ? this.launcher.focus() : this.returnFocus?.isConnected && this.returnFocus.focus(), this.returnFocus = null));
|
|
454
|
+
}
|
|
455
|
+
currentView() {
|
|
456
|
+
return this.isOpen() ? this.view === "done" ? "done" : (this.view === "form" || this.view === "question") && this.kind ? this.kind.key : "choose" : "button";
|
|
457
|
+
}
|
|
458
|
+
showView(e) {
|
|
459
|
+
if (clearTimeout(this.closeTimer), e === "button") this.close(!1);
|
|
460
|
+
else {
|
|
461
|
+
if (this.reset(), e === "done") this.view = "done";
|
|
462
|
+
else if (e !== "choose") {
|
|
463
|
+
let t = this.kinds.find((t) => t.key === e);
|
|
464
|
+
t && this.pick(t, !1);
|
|
465
|
+
}
|
|
466
|
+
this.isOpen() ? this.render() : this.open(!1);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
word(e, t) {
|
|
470
|
+
return this.config.settings.wording?.[e]?.trim() || t;
|
|
471
|
+
}
|
|
472
|
+
kindTitle(e, t = e.label) {
|
|
473
|
+
return this.word(K[e.key], t);
|
|
474
|
+
}
|
|
475
|
+
setSuspended(e) {
|
|
476
|
+
this.wrap.style.display = e ? "none" : "";
|
|
477
|
+
}
|
|
478
|
+
destroy() {
|
|
479
|
+
clearTimeout(this.closeTimer), this.wrap.remove();
|
|
480
|
+
}
|
|
481
|
+
reset() {
|
|
482
|
+
this.view = "choose", this.kind = null, this.shot = { kind: "none" }, this.message = "", this.rating = void 0, this.answers = {}, this.queued = !1, this.asked = null, this.answer = "", this.openedAt = this.isOpen() ? Date.now() : 0, this.hp = "", this.kinds.length === 1 && this.pick(this.kinds[0], !1);
|
|
483
|
+
}
|
|
484
|
+
holdOpen() {
|
|
485
|
+
clearTimeout(this.closeTimer);
|
|
486
|
+
}
|
|
487
|
+
focusFirst() {
|
|
488
|
+
for (let e of [
|
|
489
|
+
"[data-autofocus]",
|
|
490
|
+
".choice",
|
|
491
|
+
"textarea",
|
|
492
|
+
"button"
|
|
493
|
+
]) {
|
|
494
|
+
let t = this.panel.querySelector(e);
|
|
495
|
+
if (t) {
|
|
496
|
+
t.focus();
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
announce(e) {
|
|
502
|
+
this.live.textContent = "", setTimeout(() => {
|
|
503
|
+
this.live.textContent = e;
|
|
504
|
+
}, 30);
|
|
505
|
+
}
|
|
506
|
+
pick(e, t = !0) {
|
|
507
|
+
this.kind = e, this.view = "form", this.rating = void 0, this.email = this.email || this.handlers.user()?.email || "", e.type === "PROBLEM" && this.shot.kind === "none" && this.capture(), e.type !== "PROBLEM" && this.shot.kind === "busy" && (this.shot = { kind: "none" }), t && (this.render(), this.focusFirst());
|
|
508
|
+
}
|
|
509
|
+
async capture() {
|
|
510
|
+
this.shot = { kind: "busy" }, this.render();
|
|
511
|
+
try {
|
|
512
|
+
let e = await this.handlers.takeScreenshot();
|
|
513
|
+
if (this.shot.kind !== "busy") return;
|
|
514
|
+
this.shot = {
|
|
515
|
+
kind: "ready",
|
|
516
|
+
shot: e
|
|
517
|
+
}, this.announce("Screenshot added.");
|
|
518
|
+
} catch {
|
|
519
|
+
if (this.shot.kind !== "busy") return;
|
|
520
|
+
this.shot = { kind: "failed" }, this.announce("Couldn't take a screenshot.");
|
|
521
|
+
}
|
|
522
|
+
this.renderKeepingFocus();
|
|
523
|
+
}
|
|
524
|
+
async markUp() {
|
|
525
|
+
if (this.shot.kind === "ready") {
|
|
526
|
+
this.setSuspended(!0);
|
|
527
|
+
try {
|
|
528
|
+
let e = await this.handlers.markUp(this.shot.shot);
|
|
529
|
+
e && (this.shot = {
|
|
530
|
+
kind: "ready",
|
|
531
|
+
shot: e
|
|
532
|
+
}, this.announce(e.annotations.length ? `Screenshot marked up with ${e.annotations.length} ${e.annotations.length === 1 ? "mark" : "marks"}.` : "Screenshot updated."));
|
|
533
|
+
} catch {} finally {
|
|
534
|
+
this.setSuspended(!1), this.render(), this.panel.querySelector("[data-markup]")?.focus();
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
renderKeepingFocus() {
|
|
539
|
+
let e = this.root.activeElement, t = e?.dataset?.key, n = e?.tagName === "TEXTAREA" ? [e.selectionStart, e.selectionEnd] : null;
|
|
540
|
+
if (this.render(), t) {
|
|
541
|
+
let e = this.panel.querySelector(`[data-key="${t}"]`);
|
|
542
|
+
e?.focus(), n && e instanceof HTMLTextAreaElement && e.setSelectionRange(n[0], n[1]);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
header(e, t, n) {
|
|
546
|
+
let r = F("div", { class: "head" });
|
|
547
|
+
if (t) {
|
|
548
|
+
let e = F("button", {
|
|
549
|
+
type: "button",
|
|
550
|
+
class: "icon-btn",
|
|
551
|
+
"aria-label": "Back",
|
|
552
|
+
"data-key": "back"
|
|
553
|
+
});
|
|
554
|
+
e.append(L(R.back)), e.addEventListener("click", () => {
|
|
555
|
+
n ? n() : (this.view = "choose", this.kind = null, this.render(), this.focusFirst());
|
|
556
|
+
}), r.append(e);
|
|
557
|
+
}
|
|
558
|
+
r.append(F("h2", {
|
|
559
|
+
class: "title",
|
|
560
|
+
id: `pnx-title-${this.uid}`
|
|
561
|
+
}, e));
|
|
562
|
+
let i = F("button", {
|
|
563
|
+
type: "button",
|
|
564
|
+
class: "icon-btn",
|
|
565
|
+
"aria-label": "Close feedback",
|
|
566
|
+
"data-key": "close"
|
|
567
|
+
});
|
|
568
|
+
return i.append(L(R.close)), i.addEventListener("click", () => this.close()), r.append(i), r;
|
|
569
|
+
}
|
|
570
|
+
powered() {
|
|
571
|
+
return this.config.branding?.poweredBy ? F("div", { class: "powered" }, F("a", {
|
|
572
|
+
href: "https://getpinax.com",
|
|
573
|
+
target: "_blank",
|
|
574
|
+
rel: "noopener"
|
|
575
|
+
}, "Powered by Pinax")) : null;
|
|
576
|
+
}
|
|
577
|
+
logo() {
|
|
578
|
+
let e = this.config.branding?.logoUrl;
|
|
579
|
+
if (!e || !/^https?:\/\//i.test(e)) return null;
|
|
580
|
+
let t = F("img", {
|
|
581
|
+
src: e,
|
|
582
|
+
alt: "",
|
|
583
|
+
class: "logo",
|
|
584
|
+
referrerpolicy: "no-referrer"
|
|
585
|
+
});
|
|
586
|
+
return t.addEventListener("error", () => t.remove()), F("div", { class: "brand" }, t);
|
|
587
|
+
}
|
|
588
|
+
render() {
|
|
589
|
+
let e = [], t = this.logo();
|
|
590
|
+
t && e.push(t), this.view === "done" ? e.push(...this.renderDone()) : this.view === "question" && this.kind && this.asked?.question ? e.push(...this.renderQuestion(this.kind, this.asked.question)) : this.view === "form" && this.kind ? e.push(...this.renderForm(this.kind)) : e.push(...this.renderChoose());
|
|
591
|
+
let n = this.powered();
|
|
592
|
+
n && e.push(n), this.panel.replaceChildren(...e);
|
|
593
|
+
}
|
|
594
|
+
renderChoose() {
|
|
595
|
+
let e = F("ul", { class: "choices" });
|
|
596
|
+
for (let t of this.kinds) {
|
|
597
|
+
let n = F("button", {
|
|
598
|
+
type: "button",
|
|
599
|
+
class: "choice"
|
|
600
|
+
}, F("span", {
|
|
601
|
+
class: "dot",
|
|
602
|
+
"aria-hidden": "true"
|
|
603
|
+
}), F("span", {}, this.kindTitle(t), F("small", {}, t.desc)));
|
|
604
|
+
n.style.setProperty("--dot", t.dot), n.addEventListener("click", () => this.pick(t)), e.append(F("li", {}, n));
|
|
605
|
+
}
|
|
606
|
+
return [this.header(this.word("chooserTitle", W), !1), e];
|
|
607
|
+
}
|
|
608
|
+
renderShot(e) {
|
|
609
|
+
let t = this.shot;
|
|
610
|
+
if (t.kind === "none") {
|
|
611
|
+
if (e.type === "GENERAL") return null;
|
|
612
|
+
let t = F("button", {
|
|
613
|
+
type: "button",
|
|
614
|
+
class: "chip",
|
|
615
|
+
"data-key": "add-shot"
|
|
616
|
+
}, L(R.camera), "Add a screenshot");
|
|
617
|
+
return t.addEventListener("click", () => this.capture()), F("div", { class: "shot-actions" }, t);
|
|
618
|
+
}
|
|
619
|
+
if (t.kind === "busy") return F("div", {
|
|
620
|
+
class: "shot",
|
|
621
|
+
"aria-busy": "true"
|
|
622
|
+
}, F("span", { class: "wait" }, "Taking a screenshot…"));
|
|
623
|
+
if (t.kind === "failed") {
|
|
624
|
+
let e = F("button", {
|
|
625
|
+
type: "button",
|
|
626
|
+
class: "chip",
|
|
627
|
+
"data-key": "retry-shot"
|
|
628
|
+
}, "Try again");
|
|
629
|
+
return e.addEventListener("click", () => this.capture()), F("div", { class: "field" }, F("span", { class: "hint" }, "Couldn't take a screenshot of this page."), F("div", { class: "shot-actions" }, e));
|
|
630
|
+
}
|
|
631
|
+
let n = t.shot.annotations.length, r = t.shot.autoBlurred ?? 0, i = F("img", {
|
|
632
|
+
src: t.shot.dataUrl,
|
|
633
|
+
alt: `Screenshot of this page${n ? ` with ${n} ${n === 1 ? "mark" : "marks"}` : ""}${r ? `, ${r} private ${r === 1 ? "detail" : "details"} blurred` : ""}`
|
|
634
|
+
}), a = F("button", {
|
|
635
|
+
type: "button",
|
|
636
|
+
class: "chip primary",
|
|
637
|
+
"data-markup": !0,
|
|
638
|
+
"data-key": "markup"
|
|
639
|
+
}, L(R.pen), n ? "Edit marks" : "Mark up");
|
|
640
|
+
a.addEventListener("click", () => this.markUp());
|
|
641
|
+
let o = F("button", {
|
|
642
|
+
type: "button",
|
|
643
|
+
class: "chip",
|
|
644
|
+
"data-key": "remove-shot"
|
|
645
|
+
}, L(R.trash), "Remove");
|
|
646
|
+
return o.addEventListener("click", () => {
|
|
647
|
+
this.shot = { kind: "none" }, this.announce("Screenshot removed."), this.render(), this.panel.querySelector("[data-key=\"add-shot\"]")?.focus();
|
|
648
|
+
}), F("div", { class: "field" }, F("div", { class: "shot" }, i, F("span", {
|
|
649
|
+
class: "tag",
|
|
650
|
+
"aria-hidden": "true"
|
|
651
|
+
}, "Screenshot")), F("div", { class: "shot-actions" }, a, o), r ? F("span", { class: "hint auto-blur" }, F("i", { "aria-hidden": "true" }), `We blurred ${r === 1 ? "1 private detail" : `${r} private details`} for you.`) : null);
|
|
652
|
+
}
|
|
653
|
+
renderStars() {
|
|
654
|
+
let e = F("div", {
|
|
655
|
+
class: "stars",
|
|
656
|
+
role: "radiogroup",
|
|
657
|
+
"aria-labelledby": `pnx-rate-${this.uid}`
|
|
658
|
+
}), t = [], n = (this.rating ?? 1) - 1;
|
|
659
|
+
for (let e = 1; e <= 5; e++) {
|
|
660
|
+
let r = F("button", {
|
|
661
|
+
type: "button",
|
|
662
|
+
class: this.rating !== void 0 && e <= this.rating ? "star on" : "star",
|
|
663
|
+
role: "radio",
|
|
664
|
+
"aria-checked": this.rating === e ? "true" : "false",
|
|
665
|
+
"aria-label": `${e} ${e === 1 ? "star" : "stars"}`,
|
|
666
|
+
tabindex: e - 1 === n ? 0 : -1,
|
|
667
|
+
"data-key": `star-${e}`
|
|
668
|
+
}, "★");
|
|
669
|
+
r.addEventListener("click", () => {
|
|
670
|
+
this.rating = this.rating === e ? void 0 : e, this.renderKeepingFocus();
|
|
671
|
+
}), r.addEventListener("keydown", (e) => {
|
|
672
|
+
let t = e.key === "ArrowRight" || e.key === "ArrowUp" ? 1 : e.key === "ArrowLeft" || e.key === "ArrowDown" ? -1 : 0;
|
|
673
|
+
if (!t) return;
|
|
674
|
+
e.preventDefault();
|
|
675
|
+
let n = Math.min(5, Math.max(1, (this.rating ?? 0) + t || 1));
|
|
676
|
+
this.rating = n, this.render(), this.panel.querySelector(`[data-key="star-${n}"]`)?.focus();
|
|
677
|
+
}), t.push(r);
|
|
678
|
+
}
|
|
679
|
+
return e.append(...t), F("div", { class: "field" }, F("span", {
|
|
680
|
+
class: "legend",
|
|
681
|
+
id: `pnx-rate-${this.uid}`
|
|
682
|
+
}, "How's your visit so far? (optional)"), e);
|
|
683
|
+
}
|
|
684
|
+
renderForm(e) {
|
|
685
|
+
let t = e.type === "GENERAL" && this.config.settings.rating !== !1, n = this.kindTitle(e, t ? "How was your visit?" : e.label), r = [this.header(n, this.kinds.length > 1)], i = this.renderShot(e);
|
|
686
|
+
i && r.push(i), t && r.push(this.renderStars());
|
|
687
|
+
let a = `pnx-msg-${this.uid}`, o = F("textarea", {
|
|
688
|
+
id: a,
|
|
689
|
+
maxlength: 5e3,
|
|
690
|
+
"data-key": "message",
|
|
691
|
+
"data-autofocus": e.type !== "PROBLEM" && !t || void 0,
|
|
692
|
+
placeholder: this.word("messagePlaceholder", e.type === "PROBLEM" ? "What happened?" : e.type === "IDEA" ? "What would make this better?" : "Tell us what you think")
|
|
693
|
+
});
|
|
694
|
+
o.value = this.message, o.addEventListener("input", () => {
|
|
695
|
+
this.message = o.value;
|
|
696
|
+
}), r.push(F("div", { class: "field" }, F("label", { for: a }, e.type === "PROBLEM" ? "What went wrong?" : e.type === "IDEA" ? "Your idea" : "Anything to add?"), o)), r.push(...this.renderFields(e));
|
|
697
|
+
let s = `pnx-email-${this.uid}`, c = `pnx-email-hint-${this.uid}`, l = F("input", {
|
|
698
|
+
id: s,
|
|
699
|
+
type: "email",
|
|
700
|
+
inputmode: "email",
|
|
701
|
+
autocomplete: "email",
|
|
702
|
+
maxlength: 320,
|
|
703
|
+
"aria-describedby": c,
|
|
704
|
+
"data-key": "email",
|
|
705
|
+
placeholder: "you@example.com"
|
|
706
|
+
});
|
|
707
|
+
l.value = this.email, l.addEventListener("input", () => {
|
|
708
|
+
this.email = l.value;
|
|
709
|
+
}), r.push(F("div", { class: "field" }, F("label", { for: s }, "Your email (optional)"), l, F("span", {
|
|
710
|
+
class: "hint",
|
|
711
|
+
id: c
|
|
712
|
+
}, "So we can let you know when it's sorted.")));
|
|
713
|
+
let u = F("p", {
|
|
714
|
+
class: "error",
|
|
715
|
+
role: "alert",
|
|
716
|
+
id: `pnx-err-${this.uid}`
|
|
717
|
+
}), d = F("button", {
|
|
718
|
+
type: "button",
|
|
719
|
+
class: "send",
|
|
720
|
+
"data-key": "send",
|
|
721
|
+
disabled: this.sending
|
|
722
|
+
}, this.sending ? "Sending…" : "Send");
|
|
723
|
+
return this.colourSend(d, e), d.addEventListener("click", () => this.send(e, u, l, o)), r.push(this.honeypot(), u, d), r;
|
|
724
|
+
}
|
|
725
|
+
honeypot() {
|
|
726
|
+
let e = F("input", {
|
|
727
|
+
type: "text",
|
|
728
|
+
name: "website",
|
|
729
|
+
tabindex: -1,
|
|
730
|
+
autocomplete: "off",
|
|
731
|
+
"aria-label": "Leave this empty"
|
|
732
|
+
});
|
|
733
|
+
e.value = this.hp, e.addEventListener("input", () => {
|
|
734
|
+
this.hp = e.value;
|
|
735
|
+
});
|
|
736
|
+
let t = F("div", { "aria-hidden": "true" }, e);
|
|
737
|
+
return t.style.cssText = "position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden", t;
|
|
738
|
+
}
|
|
739
|
+
async send(e, t, n, r) {
|
|
740
|
+
if (this.sending) return;
|
|
741
|
+
t.textContent = "", n.removeAttribute("aria-invalid");
|
|
742
|
+
let i = this.email.trim();
|
|
743
|
+
if (i && !s(i)) {
|
|
744
|
+
t.textContent = "Please check your email address, or leave it empty.", n.setAttribute("aria-invalid", "true"), n.setAttribute("aria-errormessage", t.id), n.focus();
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
if (this.shot.kind === "busy") {
|
|
748
|
+
t.textContent = "One moment, the screenshot is still being taken.";
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
for (let n of this.fieldsFor(e)) {
|
|
752
|
+
let e = this.answers[n.id];
|
|
753
|
+
if (!n.required || (n.type === "checkbox" ? e === !0 : e)) continue;
|
|
754
|
+
let r = this.panel.querySelector(`[data-key="field-${n.id}"]`);
|
|
755
|
+
t.textContent = n.type === "checkbox" ? `Please tick “${n.label}”.` : n.type === "select" ? `Please choose an answer for “${n.label}”.` : `Please fill in “${n.label}”.`, r?.setAttribute("aria-invalid", "true"), r?.setAttribute("aria-errormessage", t.id), r?.focus();
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
let a = this.shot.kind === "ready" ? this.shot.shot : void 0, o = e.type === "GENERAL" ? this.rating : void 0;
|
|
759
|
+
if (!u({
|
|
760
|
+
type: e.type,
|
|
761
|
+
message: this.message,
|
|
762
|
+
rating: o,
|
|
763
|
+
screenshot: a?.dataUrl
|
|
764
|
+
})) {
|
|
765
|
+
t.textContent = e.type === "GENERAL" && this.config.settings.rating !== !1 ? "Add a few words or a star rating." : "Add a few words so we know what you mean.", r.focus();
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
this.sending = !0, this.renderKeepingFocus(), this.announce("Sending…");
|
|
769
|
+
let c = await this.askFollowUp(e);
|
|
770
|
+
this.view !== "form" || this.kind !== e || !this.isOpen() ? (this.sending = !1, this.isOpen() && this.renderKeepingFocus()) : c ? (this.sending = !1, this.view = "question", this.render(), this.focusFirst()) : await this.submitNow(e, i, o, a);
|
|
771
|
+
}
|
|
772
|
+
async askFollowUp(e) {
|
|
773
|
+
let t = this.handlers.followUp, n = this.message.trim();
|
|
774
|
+
if (!t || e.type === "GENERAL" || !n || n.length > 140) return null;
|
|
775
|
+
if (this.asked?.message === n) return this.asked.question;
|
|
776
|
+
let r = null;
|
|
777
|
+
try {
|
|
778
|
+
r = (await t({
|
|
779
|
+
type: e.type,
|
|
780
|
+
message: n
|
|
781
|
+
}))?.trim() || null;
|
|
782
|
+
} catch {
|
|
783
|
+
r = null;
|
|
784
|
+
}
|
|
785
|
+
return this.asked = {
|
|
786
|
+
message: n,
|
|
787
|
+
question: r?.slice(0, 300) || null
|
|
788
|
+
}, this.asked.question;
|
|
789
|
+
}
|
|
790
|
+
async submitNow(e, t, n, r, i) {
|
|
791
|
+
this.sending = !0, this.renderKeepingFocus();
|
|
792
|
+
let a;
|
|
793
|
+
try {
|
|
794
|
+
a = await this.handlers.submit({
|
|
795
|
+
type: e.type,
|
|
796
|
+
message: this.message,
|
|
797
|
+
rating: n,
|
|
798
|
+
email: t || void 0,
|
|
799
|
+
shot: r,
|
|
800
|
+
followUp: i,
|
|
801
|
+
fields: this.fieldAnswers(e),
|
|
802
|
+
hp: this.hp || void 0,
|
|
803
|
+
elapsedMs: this.openedAt ? Math.max(0, Date.now() - this.openedAt) : void 0
|
|
804
|
+
});
|
|
805
|
+
} catch {
|
|
806
|
+
a = {
|
|
807
|
+
status: "error",
|
|
808
|
+
message: "Something went wrong. Please try again."
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
if (this.sending = !1, a.status === "error") {
|
|
812
|
+
this.view = "form", this.render();
|
|
813
|
+
let e = this.panel.querySelector(".error");
|
|
814
|
+
e && (e.textContent = a.message), this.panel.querySelector("[data-key=\"send\"]")?.focus();
|
|
815
|
+
} else this.queued = a.status === "queued", this.view = "done", this.render(), this.focusFirst(), this.announce(this.queued ? "Saved. We'll send it when you're back online." : this.word("confirmation", G)), this.closeTimer = setTimeout(() => this.close(this.panel.contains(this.root.activeElement)), U);
|
|
816
|
+
}
|
|
817
|
+
renderQuestion(e, t) {
|
|
818
|
+
let n = [this.header("One quick question", !0, () => {
|
|
819
|
+
this.view = "form", this.render(), this.panel.querySelector("[data-key=\"message\"]")?.focus();
|
|
820
|
+
})], r = F("div", { class: "note" }, F("span", {
|
|
821
|
+
class: "dot",
|
|
822
|
+
"aria-hidden": "true"
|
|
823
|
+
}), F("span", {}, F("span", { class: "sr" }, "Your note: "), `“${this.message.trim()}”`));
|
|
824
|
+
r.style.setProperty("--dot", e.dot), n.push(r);
|
|
825
|
+
let i = `pnx-answer-${this.uid}`, a = `pnx-answer-hint-${this.uid}`, o = F("textarea", {
|
|
826
|
+
id: i,
|
|
827
|
+
class: "answer",
|
|
828
|
+
maxlength: 2e3,
|
|
829
|
+
"data-key": "answer",
|
|
830
|
+
"data-autofocus": !0,
|
|
831
|
+
"aria-describedby": a,
|
|
832
|
+
placeholder: "Your answer"
|
|
833
|
+
});
|
|
834
|
+
o.value = this.answer, o.addEventListener("input", () => {
|
|
835
|
+
this.answer = o.value;
|
|
836
|
+
}), n.push(F("div", { class: "field" }, F("label", {
|
|
837
|
+
for: i,
|
|
838
|
+
class: "question"
|
|
839
|
+
}, t), o, F("span", {
|
|
840
|
+
class: "hint",
|
|
841
|
+
id: a
|
|
842
|
+
}, "Optional. It helps us fix it faster.")));
|
|
843
|
+
let s = F("p", {
|
|
844
|
+
class: "error",
|
|
845
|
+
role: "alert"
|
|
846
|
+
}), c = this.email.trim(), l = e.type === "GENERAL" ? this.rating : void 0, u = this.shot.kind === "ready" ? this.shot.shot : void 0, d = F("button", {
|
|
847
|
+
type: "button",
|
|
848
|
+
class: "send",
|
|
849
|
+
"data-key": "send",
|
|
850
|
+
disabled: this.sending
|
|
851
|
+
}, this.sending ? "Sending…" : "Send");
|
|
852
|
+
this.colourSend(d, e), d.addEventListener("click", () => {
|
|
853
|
+
if (this.sending) return;
|
|
854
|
+
let n = this.answer.trim();
|
|
855
|
+
this.announce("Sending…"), this.submitNow(e, c, l, u, n ? {
|
|
856
|
+
question: t,
|
|
857
|
+
answer: n.slice(0, 2e3)
|
|
858
|
+
} : void 0);
|
|
859
|
+
});
|
|
860
|
+
let f = F("button", {
|
|
861
|
+
type: "button",
|
|
862
|
+
class: "link skip",
|
|
863
|
+
"data-key": "skip",
|
|
864
|
+
disabled: this.sending
|
|
865
|
+
}, "Skip and send");
|
|
866
|
+
return f.addEventListener("click", () => {
|
|
867
|
+
this.sending || (this.announce("Sending…"), this.submitNow(e, c, l, u));
|
|
868
|
+
}), n.push(s, d, f), n;
|
|
869
|
+
}
|
|
870
|
+
colourSend(e, t) {
|
|
871
|
+
let n = this.sendColour ?? t.send;
|
|
872
|
+
e.style.setProperty("--type", n), e.style.setProperty("--type-ink", this.sendColour ? N(n) : t.ink);
|
|
873
|
+
}
|
|
874
|
+
fieldsFor(e) {
|
|
875
|
+
return (this.config.settings.fields ?? []).filter((t) => t.types?.[e.key] !== !1);
|
|
876
|
+
}
|
|
877
|
+
fieldAnswers(e) {
|
|
878
|
+
let t = [];
|
|
879
|
+
for (let n of this.fieldsFor(e)) {
|
|
880
|
+
let e = this.answers[n.id];
|
|
881
|
+
n.type === "checkbox" ? t.push({
|
|
882
|
+
id: n.id,
|
|
883
|
+
value: e === !0
|
|
884
|
+
}) : typeof e == "string" && e.trim() && t.push({
|
|
885
|
+
id: n.id,
|
|
886
|
+
value: e.trim()
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
return t.length ? t : void 0;
|
|
890
|
+
}
|
|
891
|
+
renderFields(e) {
|
|
892
|
+
return this.fieldsFor(e).map((e, t) => {
|
|
893
|
+
let n = `pnx-f${t}-${this.uid}`, r = `field-${e.id}`, i = (e) => {
|
|
894
|
+
e.removeAttribute("aria-invalid"), e.removeAttribute("aria-errormessage");
|
|
895
|
+
}, a = (t) => F("label", {
|
|
896
|
+
for: n,
|
|
897
|
+
class: t
|
|
898
|
+
}, e.label, e.required ? null : F("span", { class: "optional" }, " (optional)"));
|
|
899
|
+
if (e.type === "checkbox") {
|
|
900
|
+
let t = F("input", {
|
|
901
|
+
id: n,
|
|
902
|
+
type: "checkbox",
|
|
903
|
+
"data-key": r,
|
|
904
|
+
"aria-required": e.required ? "true" : void 0
|
|
905
|
+
});
|
|
906
|
+
return t.checked = this.answers[e.id] === !0, t.addEventListener("change", () => {
|
|
907
|
+
this.answers[e.id] = t.checked, i(t);
|
|
908
|
+
}), F("div", { class: "field check" }, t, a());
|
|
909
|
+
}
|
|
910
|
+
if (e.type === "select") {
|
|
911
|
+
let t = F("select", {
|
|
912
|
+
id: n,
|
|
913
|
+
"data-key": r,
|
|
914
|
+
"aria-required": e.required ? "true" : void 0
|
|
915
|
+
}, F("option", { value: "" }, "Choose…"), ...e.options.map((e) => F("option", { value: e }, e)));
|
|
916
|
+
return t.value = String(this.answers[e.id] ?? ""), t.addEventListener("change", () => {
|
|
917
|
+
this.answers[e.id] = t.value, i(t);
|
|
918
|
+
}), F("div", { class: "field" }, a(), t);
|
|
919
|
+
}
|
|
920
|
+
let o = F("input", {
|
|
921
|
+
id: n,
|
|
922
|
+
type: "text",
|
|
923
|
+
maxlength: 200,
|
|
924
|
+
"data-key": r,
|
|
925
|
+
"aria-required": e.required ? "true" : void 0
|
|
926
|
+
});
|
|
927
|
+
return o.value = String(this.answers[e.id] ?? ""), o.addEventListener("input", () => {
|
|
928
|
+
this.answers[e.id] = o.value, i(o);
|
|
929
|
+
}), F("div", { class: "field" }, a(), o);
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
renderDone() {
|
|
933
|
+
let e = F("button", {
|
|
934
|
+
type: "button",
|
|
935
|
+
class: "link",
|
|
936
|
+
"data-key": "again"
|
|
937
|
+
}, "Send another");
|
|
938
|
+
e.addEventListener("click", () => {
|
|
939
|
+
this.reset(), this.render(), this.focusFirst();
|
|
940
|
+
});
|
|
941
|
+
let t = F("div", { class: "head" });
|
|
942
|
+
t.append(F("span", { class: "title" }));
|
|
943
|
+
let n = F("button", {
|
|
944
|
+
type: "button",
|
|
945
|
+
class: "icon-btn",
|
|
946
|
+
"aria-label": "Close feedback"
|
|
947
|
+
});
|
|
948
|
+
return n.append(L(R.close)), n.addEventListener("click", () => this.close()), t.append(n), [t, F("div", { class: "done" }, F("span", {
|
|
949
|
+
class: "tick",
|
|
950
|
+
"aria-hidden": "true"
|
|
951
|
+
}, "✓"), F("h2", {
|
|
952
|
+
class: "title",
|
|
953
|
+
id: `pnx-title-${this.uid}`,
|
|
954
|
+
tabindex: -1,
|
|
955
|
+
"data-autofocus": !0
|
|
956
|
+
}, this.queued ? "Saved for later" : this.word("confirmation", G)), this.queued ? F("p", {}, "You're offline. We'll send it as soon as you're back.") : null, e)];
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
export { O as a, g as c, A as i, m as l, B as n, T as o, F as r, n as s, q as t, f as u };
|
|
960
|
+
|
|
961
|
+
//# sourceMappingURL=widget-CkR1Ptzb.mjs.map
|