@qaiddev/thumbs-embed 1.9.1 → 1.10.0
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/README.md +2 -3
- package/dist/chunks/{loader-DepVS4i5.js → loader-BVNyi56k.js} +335 -287
- package/dist/chunks/loader-BVNyi56k.js.map +1 -0
- package/dist/chunks/{modal-CEfcaIQR.js → modal-DwwbWQ-F.js} +82 -75
- package/dist/chunks/modal-DwwbWQ-F.js.map +1 -0
- package/dist/embed.d.ts +17 -1
- package/dist/index.js +435 -380
- package/dist/index.js.map +1 -1
- package/dist/loader.js +1 -1
- package/dist/modal.d.ts +8 -2
- package/dist/qaid.umd.cjs +12 -12
- package/dist/qaid.umd.cjs.map +1 -1
- package/dist/quest-launcher.d.ts +24 -4
- package/package.json +1 -1
- package/dist/chunks/loader-DepVS4i5.js.map +0 -1
- package/dist/chunks/modal-CEfcaIQR.js.map +0 -1
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import { c as u } from "./loader-
|
|
2
|
-
import { h as
|
|
3
|
-
import { T as
|
|
4
|
-
class
|
|
1
|
+
import { c as u } from "./loader-BVNyi56k.js";
|
|
2
|
+
import { h as s } from "./dom-DvdtcUS8.js";
|
|
3
|
+
import { T as h, a as p, F as b, D as f, E as g } from "./annotate-D-o8xCV9.js";
|
|
4
|
+
class w {
|
|
5
5
|
constructor(t) {
|
|
6
6
|
this.host = t;
|
|
7
7
|
}
|
|
8
8
|
host;
|
|
9
9
|
modalContainer = null;
|
|
10
10
|
backdrop = null;
|
|
11
|
+
/** Set once the message is sent, so closing does not PATCH over it. */
|
|
12
|
+
finalized = !1;
|
|
11
13
|
open() {
|
|
14
|
+
this.finalized = !1;
|
|
12
15
|
const t = this.host.ensureOverlayHost();
|
|
13
16
|
this.backdrop = document.createElement("div"), this.backdrop.className = "qaid-backdrop", this.backdrop.style.zIndex = String(this.host.config.zIndex + 2), this.backdrop.style.background = `rgba(0, 0, 0, ${this.host.config.backdropOpacity})`, this.backdrop.addEventListener("click", () => this.close()), this.host.applyVars(this.backdrop), this.host.isMobile ? this.showBottomSheet() : this.showPositionedModal(), t.appendChild(this.backdrop), document.addEventListener("keydown", this.host.boundKeyDown);
|
|
14
17
|
}
|
|
15
18
|
/** Escape / external close. Runs the finalize-PATCH + teardown. */
|
|
16
19
|
close() {
|
|
17
|
-
this.host.state === "MODAL_OPEN" && this.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
this.host.state === "MODAL_OPEN" && !this.finalized && (this.finalized = !0, this.host.whenFeedbackId().then((t) => {
|
|
21
|
+
t && fetch(`${this.host.config.endpoint}/${t}`, {
|
|
22
|
+
method: "PATCH",
|
|
23
|
+
headers: { "Content-Type": "application/json" },
|
|
24
|
+
body: JSON.stringify({ message: null })
|
|
25
|
+
}).catch((e) => console.error("Failed to finalize feedback:", e));
|
|
26
|
+
})), this.teardown(), this.host.resetFeedbackUi();
|
|
22
27
|
}
|
|
23
28
|
/** DOM/listener teardown only — no PATCH, no state reset (for embed destroy). */
|
|
24
29
|
destroy() {
|
|
@@ -28,18 +33,18 @@ class v {
|
|
|
28
33
|
this.host.closeDialogA11y(), this.modalContainer && (this.modalContainer.remove(), this.modalContainer = null), this.backdrop && (this.backdrop.remove(), this.backdrop = null), document.removeEventListener("keydown", this.host.boundKeyDown);
|
|
29
34
|
}
|
|
30
35
|
showBottomSheet() {
|
|
31
|
-
const t = this.host.ensureOverlayHost(),
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
const t = this.host.ensureOverlayHost(), e = document.createElement("div");
|
|
37
|
+
e.className = "qaid-bottom-sheet", e.style.zIndex = String(this.host.config.zIndex + 3), e.appendChild(
|
|
38
|
+
s(
|
|
34
39
|
"div",
|
|
35
40
|
{ class: "qaid-bottom-sheet-content" },
|
|
36
|
-
|
|
41
|
+
s("div", { class: "qaid-bottom-sheet-handle" }),
|
|
37
42
|
this.buildModalContent()
|
|
38
43
|
)
|
|
39
|
-
), this.host.applyVars(
|
|
44
|
+
), this.host.applyVars(e), t.appendChild(e), this.modalContainer = e, this.setupModalInteractions();
|
|
40
45
|
}
|
|
41
46
|
showPositionedModal() {
|
|
42
|
-
const t = this.host.ensureOverlayHost(), { modal:
|
|
47
|
+
const t = this.host.ensureOverlayHost(), { modal: e, arrow: i } = u(
|
|
43
48
|
this.host.selectedBounds,
|
|
44
49
|
window.innerWidth,
|
|
45
50
|
window.innerHeight,
|
|
@@ -51,11 +56,11 @@ class v {
|
|
|
51
56
|
viewportPadding: 16
|
|
52
57
|
}
|
|
53
58
|
);
|
|
54
|
-
this.modalContainer = document.createElement("div"), this.modalContainer.className = `qaid-modal-container qaid-${
|
|
55
|
-
const
|
|
56
|
-
|
|
59
|
+
this.modalContainer = document.createElement("div"), this.modalContainer.className = `qaid-modal-container qaid-${e.position}`, this.modalContainer.style.top = `${e.top}px`, this.modalContainer.style.left = `${e.left}px`, this.modalContainer.style.zIndex = String(this.host.config.zIndex + 3);
|
|
60
|
+
const o = document.createElement("div");
|
|
61
|
+
o.className = "qaid-modal-arrow", o.style.left = `${i.left}px`;
|
|
57
62
|
const a = document.createElement("div");
|
|
58
|
-
a.className = "qaid-modal-box", a.appendChild(this.buildModalContent()), this.modalContainer.appendChild(
|
|
63
|
+
a.className = "qaid-modal-box", a.appendChild(this.buildModalContent()), this.modalContainer.appendChild(o), this.modalContainer.appendChild(a), this.host.applyVars(this.modalContainer), t.appendChild(this.modalContainer), this.setupModalInteractions();
|
|
59
64
|
}
|
|
60
65
|
/**
|
|
61
66
|
* The modal's contents, built as nodes rather than an HTML string.
|
|
@@ -66,50 +71,50 @@ class v {
|
|
|
66
71
|
* markup, because they are documented as SVG/HTML strings.
|
|
67
72
|
*/
|
|
68
73
|
buildModalContent() {
|
|
69
|
-
const { config: t, uid:
|
|
74
|
+
const { config: t, uid: e } = this.host, i = t.text, o = this.host.feedbackData.feedbackType, a = o === "up", n = t.positiveIcon || h, d = t.negativeIcon || p, l = t.buttonClass ? `qaid-type-toggle qaid-type-toggle-custom ${t.buttonClass} ${a ? "qaid-btn-up" : "qaid-btn-down"}` : `qaid-type-toggle ${a ? "qaid-type-up" : "qaid-type-down"}`, r = a ? "Feedback type: positive" : "Feedback type: negative", m = o === "neutral" ? s("span", {
|
|
70
75
|
class: "qaid-type-static",
|
|
71
76
|
html: t.feedbackIcon || b,
|
|
72
77
|
attrs: { "aria-hidden": "true" }
|
|
73
|
-
}) :
|
|
78
|
+
}) : s("button", {
|
|
74
79
|
class: l,
|
|
75
80
|
html: a ? n : d,
|
|
76
81
|
attrs: {
|
|
77
82
|
type: "button",
|
|
78
83
|
title: "Click to switch",
|
|
79
84
|
"aria-pressed": String(a),
|
|
80
|
-
"aria-label":
|
|
85
|
+
"aria-label": r
|
|
81
86
|
}
|
|
82
87
|
}), c = document.createDocumentFragment();
|
|
83
88
|
return c.append(
|
|
84
|
-
|
|
89
|
+
s(
|
|
85
90
|
"div",
|
|
86
91
|
{ class: "qaid-modal-header" },
|
|
87
92
|
m,
|
|
88
|
-
|
|
93
|
+
s(
|
|
89
94
|
"div",
|
|
90
95
|
{ class: "qaid-modal-header-text" },
|
|
91
|
-
|
|
96
|
+
s("h3", {
|
|
92
97
|
class: "qaid-modal-title",
|
|
93
|
-
text:
|
|
94
|
-
attrs: { id: `qaid-modal-title-${
|
|
98
|
+
text: i.modalTitle,
|
|
99
|
+
attrs: { id: `qaid-modal-title-${e}` }
|
|
95
100
|
}),
|
|
96
|
-
|
|
101
|
+
s("p", {
|
|
97
102
|
class: "qaid-modal-subtitle",
|
|
98
|
-
text:
|
|
99
|
-
attrs: { id: `qaid-modal-subtitle-${
|
|
103
|
+
text: i.modalSubtitle,
|
|
104
|
+
attrs: { id: `qaid-modal-subtitle-${e}` }
|
|
100
105
|
})
|
|
101
106
|
)
|
|
102
107
|
),
|
|
103
|
-
|
|
108
|
+
s("textarea", {
|
|
104
109
|
class: "qaid-textarea",
|
|
105
|
-
attrs: { "aria-label":
|
|
110
|
+
attrs: { "aria-label": i.modalSubtitle, placeholder: i.placeholder }
|
|
106
111
|
}),
|
|
107
|
-
|
|
112
|
+
s(
|
|
108
113
|
"div",
|
|
109
114
|
{ class: "qaid-btn-row" },
|
|
110
|
-
|
|
115
|
+
s("button", {
|
|
111
116
|
class: "qaid-btn-submit",
|
|
112
|
-
text:
|
|
117
|
+
text: i.skipButton,
|
|
113
118
|
attrs: { type: "button" }
|
|
114
119
|
})
|
|
115
120
|
)
|
|
@@ -120,47 +125,49 @@ class v {
|
|
|
120
125
|
labelledbyId: `qaid-modal-title-${this.host.uid}`,
|
|
121
126
|
describedbyId: `qaid-modal-subtitle-${this.host.uid}`
|
|
122
127
|
});
|
|
123
|
-
const t = this.modalContainer.querySelector(".qaid-textarea"),
|
|
128
|
+
const t = this.modalContainer.querySelector(".qaid-textarea"), e = this.modalContainer.querySelector(".qaid-btn-submit");
|
|
124
129
|
t && (setTimeout(() => t.focus(), 100), t.addEventListener("input", () => {
|
|
125
|
-
|
|
126
|
-
})),
|
|
127
|
-
const
|
|
128
|
-
this.submitMessage(
|
|
130
|
+
e && (e.textContent = t.value.trim() ? this.host.config.text.submitButton : this.host.config.text.skipButton);
|
|
131
|
+
})), e && e.addEventListener("click", () => {
|
|
132
|
+
const o = t?.value.trim() || null;
|
|
133
|
+
this.submitMessage(o);
|
|
129
134
|
});
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
this.host.feedbackData.feedbackType =
|
|
134
|
-
const a = this.host.config.positiveIcon ||
|
|
135
|
-
|
|
136
|
-
const d =
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
const i = this.modalContainer.querySelector(".qaid-type-toggle");
|
|
136
|
+
i && i.addEventListener("click", () => {
|
|
137
|
+
const o = this.host.feedbackData.feedbackType === "up" ? "down" : "up";
|
|
138
|
+
this.host.feedbackData.feedbackType = o, this.host.config.buttonClass ? (i.classList.toggle("qaid-btn-up", o === "up"), i.classList.toggle("qaid-btn-down", o === "down")) : (i.classList.toggle("qaid-type-up", o === "up"), i.classList.toggle("qaid-type-down", o === "down"));
|
|
139
|
+
const a = this.host.config.positiveIcon || h, n = this.host.config.negativeIcon || p;
|
|
140
|
+
i.innerHTML = o === "up" ? a : n;
|
|
141
|
+
const d = o === "up" ? "Feedback type: positive" : "Feedback type: negative";
|
|
142
|
+
i.setAttribute("aria-pressed", String(o === "up")), i.setAttribute("aria-label", d), this.host.announceMsg(d), this.host.whenFeedbackId().then((l) => {
|
|
143
|
+
l && fetch(`${this.host.config.endpoint}/${l}`, {
|
|
144
|
+
method: "PATCH",
|
|
145
|
+
headers: { "Content-Type": "application/json" },
|
|
146
|
+
body: JSON.stringify({ feedbackType: o })
|
|
147
|
+
}).catch((r) => console.error("Failed to update feedback type:", r));
|
|
148
|
+
});
|
|
142
149
|
});
|
|
143
150
|
}
|
|
144
151
|
async submitMessage(t) {
|
|
145
|
-
let
|
|
146
|
-
|
|
152
|
+
let e = null;
|
|
153
|
+
this.finalized = !0;
|
|
154
|
+
const i = await this.host.whenFeedbackId();
|
|
155
|
+
if (i)
|
|
147
156
|
try {
|
|
148
|
-
const
|
|
157
|
+
const o = await fetch(`${this.host.config.endpoint}/${i}`, {
|
|
149
158
|
method: "PATCH",
|
|
150
159
|
headers: { "Content-Type": "application/json" },
|
|
151
160
|
body: JSON.stringify({ message: t })
|
|
152
161
|
});
|
|
153
|
-
|
|
154
|
-
} catch (
|
|
155
|
-
console.error("Failed to submit feedback message:",
|
|
162
|
+
e = o.ok, o.ok || console.error("Failed to submit feedback message: HTTP", o.status);
|
|
163
|
+
} catch (o) {
|
|
164
|
+
console.error("Failed to submit feedback message:", o), e = !1;
|
|
156
165
|
}
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
if (o === !1) {
|
|
166
|
+
if (e === !1) {
|
|
160
167
|
this.showResult(!1);
|
|
161
168
|
return;
|
|
162
169
|
}
|
|
163
|
-
if (
|
|
170
|
+
if (e && !this.host.config.hideConfirmation) {
|
|
164
171
|
this.showResult(!0);
|
|
165
172
|
return;
|
|
166
173
|
}
|
|
@@ -176,38 +183,38 @@ class v {
|
|
|
176
183
|
* goes in as text, never markup.
|
|
177
184
|
*/
|
|
178
185
|
showResult(t) {
|
|
179
|
-
const
|
|
180
|
-
if (!
|
|
186
|
+
const e = this.modalContainer?.querySelector(".qaid-modal-box") ?? this.modalContainer?.querySelector(".qaid-bottom-sheet-content") ?? this.modalContainer;
|
|
187
|
+
if (!e) {
|
|
181
188
|
this.close();
|
|
182
189
|
return;
|
|
183
190
|
}
|
|
184
|
-
const
|
|
191
|
+
const i = this.host.config.text, o = t ? i.confirmationTitle : i.errorTitle, a = t ? i.confirmationMessage : i.errorMessage, n = s("h3", {
|
|
185
192
|
class: "qaid-confirm-title",
|
|
186
|
-
text:
|
|
193
|
+
text: o,
|
|
187
194
|
attrs: { id: `qaid-confirm-title-${this.host.uid}`, tabindex: "-1" }
|
|
188
195
|
});
|
|
189
|
-
|
|
190
|
-
|
|
196
|
+
e.textContent = "", e.appendChild(
|
|
197
|
+
s(
|
|
191
198
|
"div",
|
|
192
199
|
{ class: t ? "qaid-confirm" : "qaid-confirm qaid-confirm-error" },
|
|
193
|
-
|
|
200
|
+
s("span", {
|
|
194
201
|
class: "qaid-confirm-icon",
|
|
195
202
|
html: t ? f : g,
|
|
196
203
|
attrs: { "aria-hidden": "true" }
|
|
197
204
|
}),
|
|
198
205
|
n,
|
|
199
|
-
|
|
200
|
-
|
|
206
|
+
s("p", { class: "qaid-confirm-message", text: a }),
|
|
207
|
+
s("button", {
|
|
201
208
|
class: "qaid-btn-submit qaid-confirm-close",
|
|
202
|
-
text:
|
|
209
|
+
text: i.confirmationClose,
|
|
203
210
|
attrs: { type: "button" },
|
|
204
211
|
on: { click: () => this.close() }
|
|
205
212
|
})
|
|
206
213
|
)
|
|
207
|
-
), requestAnimationFrame(() => n.focus()), this.host.announceMsg(`${
|
|
214
|
+
), requestAnimationFrame(() => n.focus()), this.host.announceMsg(`${o} ${a}`, !0);
|
|
208
215
|
}
|
|
209
216
|
}
|
|
210
217
|
export {
|
|
211
|
-
|
|
218
|
+
w as ModalController
|
|
212
219
|
};
|
|
213
|
-
//# sourceMappingURL=modal-
|
|
220
|
+
//# sourceMappingURL=modal-DwwbWQ-F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal-DwwbWQ-F.js","sources":["../../src/modal.ts"],"sourcesContent":["/**\n * Feedback message modal — extracted from embed.ts into its own lazily-loaded\n * chunk. It's fetched the first time a message modal opens (after feedback is\n * submitted), and pre-warmed while the user is targeting an element.\n *\n * The controller owns the modal/backdrop DOM and the message PATCH flow, and\n * talks back to the embed through the narrow `ModalHost` interface.\n */\n\nimport { calculateModalAndArrowPosition } from \"./modal-positioning\";\nimport { h } from \"./dom\";\nimport {\n THUMBS_UP_ICON,\n THUMBS_DOWN_ICON,\n FEEDBACK_ICON,\n DONE_ICON,\n ERROR_ICON,\n} from \"./icons\";\nimport type {\n ResolvedFeedbackConfig,\n EmbedState,\n FeedbackData,\n SelectedBounds,\n} from \"./types\";\n\n/** The slice of the embed the modal needs. */\nexport interface ModalHost {\n readonly config: ResolvedFeedbackConfig;\n readonly uid: string;\n readonly isMobile: boolean;\n readonly state: EmbedState;\n readonly boundKeyDown: (e: KeyboardEvent) => void;\n /** Live references — the toggle mutates feedbackType; positioning reads bounds. */\n readonly feedbackData: FeedbackData;\n readonly selectedBounds: SelectedBounds;\n /**\n * The id of this feedback's record. The modal opens while the POST that\n * creates it is still in flight, so every PATCH waits on this; null when\n * the POST failed.\n */\n whenFeedbackId(): Promise<number | null>;\n ensureOverlayHost(): ShadowRoot;\n applyVars(el: HTMLElement): void;\n announceMsg(message: string, assertive?: boolean): void;\n openDialogA11y(\n container: HTMLElement,\n opts: { labelledbyId?: string; describedbyId?: string; label?: string }\n ): void;\n closeDialogA11y(): void;\n resetFeedbackUi(): void;\n}\n\nexport class ModalController {\n private modalContainer: HTMLDivElement | null = null;\n private backdrop: HTMLDivElement | null = null;\n /** Set once the message is sent, so closing does not PATCH over it. */\n private finalized = false;\n\n constructor(private host: ModalHost) {}\n\n open(): void {\n this.finalized = false;\n const root = this.host.ensureOverlayHost();\n\n // Create backdrop\n this.backdrop = document.createElement(\"div\");\n this.backdrop.className = \"qaid-backdrop\";\n this.backdrop.style.zIndex = String(this.host.config.zIndex + 2);\n this.backdrop.style.background = `rgba(0, 0, 0, ${this.host.config.backdropOpacity})`;\n this.backdrop.addEventListener(\"click\", () => this.close());\n this.host.applyVars(this.backdrop);\n\n if (this.host.isMobile) {\n this.showBottomSheet();\n } else {\n this.showPositionedModal();\n }\n\n root.appendChild(this.backdrop);\n document.addEventListener(\"keydown\", this.host.boundKeyDown);\n }\n\n /** Escape / external close. Runs the finalize-PATCH + teardown. */\n close(): void {\n // If the modal is open and we're closing without submitting, still finalize.\n // Taken before the reset below, which starts the next feedback afresh.\n if (this.host.state === \"MODAL_OPEN\" && !this.finalized) {\n this.finalized = true;\n void this.host.whenFeedbackId().then((id) => {\n if (!id) return;\n fetch(`${this.host.config.endpoint}/${id}`, {\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ message: null }),\n }).catch((err) => console.error(\"Failed to finalize feedback:\", err));\n });\n }\n\n this.teardown();\n this.host.resetFeedbackUi();\n }\n\n /** DOM/listener teardown only — no PATCH, no state reset (for embed destroy). */\n destroy(): void {\n this.teardown();\n }\n\n private teardown(): void {\n this.host.closeDialogA11y();\n if (this.modalContainer) {\n this.modalContainer.remove();\n this.modalContainer = null;\n }\n if (this.backdrop) {\n this.backdrop.remove();\n this.backdrop = null;\n }\n document.removeEventListener(\"keydown\", this.host.boundKeyDown);\n }\n\n private showBottomSheet(): void {\n const root = this.host.ensureOverlayHost();\n\n const sheet = document.createElement(\"div\");\n sheet.className = \"qaid-bottom-sheet\";\n sheet.style.zIndex = String(this.host.config.zIndex + 3);\n\n sheet.appendChild(\n h(\n \"div\",\n { class: \"qaid-bottom-sheet-content\" },\n h(\"div\", { class: \"qaid-bottom-sheet-handle\" }),\n this.buildModalContent()\n )\n );\n\n this.host.applyVars(sheet);\n root.appendChild(sheet);\n this.modalContainer = sheet;\n\n this.setupModalInteractions();\n }\n\n private showPositionedModal(): void {\n const root = this.host.ensureOverlayHost();\n\n const { modal, arrow } = calculateModalAndArrowPosition(\n this.host.selectedBounds,\n window.innerWidth,\n window.innerHeight,\n {\n width: this.host.config.modalWidth,\n height: 280,\n arrowHeight: 12,\n gap: 8,\n viewportPadding: 16,\n }\n );\n\n this.modalContainer = document.createElement(\"div\");\n this.modalContainer.className = `qaid-modal-container qaid-${modal.position}`;\n this.modalContainer.style.top = `${modal.top}px`;\n this.modalContainer.style.left = `${modal.left}px`;\n this.modalContainer.style.zIndex = String(this.host.config.zIndex + 3);\n\n const arrowEl = document.createElement(\"div\");\n arrowEl.className = \"qaid-modal-arrow\";\n arrowEl.style.left = `${arrow.left}px`;\n\n const box = document.createElement(\"div\");\n box.className = \"qaid-modal-box\";\n box.appendChild(this.buildModalContent());\n\n this.modalContainer.appendChild(arrowEl);\n this.modalContainer.appendChild(box);\n this.host.applyVars(this.modalContainer);\n root.appendChild(this.modalContainer);\n\n this.setupModalInteractions();\n }\n\n /**\n * The modal's contents, built as nodes rather than an HTML string.\n *\n * Every piece of copy (title, subtitle, placeholder, button) goes in as\n * text, so a `<`, `&` or `\"` in a translation shows as written instead of\n * being parsed as markup or cutting an attribute short. Only the icons are\n * markup, because they are documented as SVG/HTML strings.\n */\n private buildModalContent(): DocumentFragment {\n const { config, uid } = this.host;\n const text = config.text;\n const type = this.host.feedbackData.feedbackType;\n const isUp = type === \"up\";\n const positiveIcon = config.positiveIcon || THUMBS_UP_ICON;\n const negativeIcon = config.negativeIcon || THUMBS_DOWN_ICON;\n const toggleClass = config.buttonClass\n ? `qaid-type-toggle qaid-type-toggle-custom ${config.buttonClass} ${isUp ? \"qaid-btn-up\" : \"qaid-btn-down\"}`\n : `qaid-type-toggle ${isUp ? \"qaid-type-up\" : \"qaid-type-down\"}`;\n const toggleLabel = isUp ? \"Feedback type: positive\" : \"Feedback type: negative\";\n // Neutral (single-button) feedback has no sentiment to toggle — show a\n // static feedback icon in place of the up/down toggle.\n const header =\n type === \"neutral\"\n ? h(\"span\", {\n class: \"qaid-type-static\",\n html: config.feedbackIcon || FEEDBACK_ICON,\n attrs: { \"aria-hidden\": \"true\" },\n })\n : h(\"button\", {\n class: toggleClass,\n html: isUp ? positiveIcon : negativeIcon,\n attrs: {\n type: \"button\",\n title: \"Click to switch\",\n \"aria-pressed\": String(isUp),\n \"aria-label\": toggleLabel,\n },\n });\n\n const fragment = document.createDocumentFragment();\n fragment.append(\n h(\n \"div\",\n { class: \"qaid-modal-header\" },\n header,\n h(\n \"div\",\n { class: \"qaid-modal-header-text\" },\n h(\"h3\", {\n class: \"qaid-modal-title\",\n text: text.modalTitle,\n attrs: { id: `qaid-modal-title-${uid}` },\n }),\n h(\"p\", {\n class: \"qaid-modal-subtitle\",\n text: text.modalSubtitle,\n attrs: { id: `qaid-modal-subtitle-${uid}` },\n })\n )\n ),\n h(\"textarea\", {\n class: \"qaid-textarea\",\n attrs: { \"aria-label\": text.modalSubtitle, placeholder: text.placeholder },\n }),\n h(\n \"div\",\n { class: \"qaid-btn-row\" },\n h(\"button\", {\n class: \"qaid-btn-submit\",\n text: text.skipButton,\n attrs: { type: \"button\" },\n })\n )\n );\n return fragment;\n }\n\n private setupModalInteractions(): void {\n // Dialog semantics + focus trap + background inert\n this.host.openDialogA11y(this.modalContainer!, {\n labelledbyId: `qaid-modal-title-${this.host.uid}`,\n describedbyId: `qaid-modal-subtitle-${this.host.uid}`,\n });\n\n const textarea =\n this.modalContainer!.querySelector<HTMLTextAreaElement>(\".qaid-textarea\");\n const submitBtn =\n this.modalContainer!.querySelector<HTMLButtonElement>(\".qaid-btn-submit\");\n if (textarea) {\n // Auto-focus\n setTimeout(() => textarea.focus(), 100);\n\n // Update button text based on content\n textarea.addEventListener(\"input\", () => {\n if (submitBtn) {\n submitBtn.textContent = textarea.value.trim()\n ? this.host.config.text.submitButton\n : this.host.config.text.skipButton;\n }\n });\n }\n\n if (submitBtn) {\n submitBtn.addEventListener(\"click\", () => {\n const message = textarea?.value.trim() || null;\n this.submitMessage(message);\n });\n }\n\n // Handle feedback type toggle\n const typeToggle = this.modalContainer!.querySelector<HTMLButtonElement>(\".qaid-type-toggle\");\n if (typeToggle) {\n typeToggle.addEventListener(\"click\", () => {\n const newType = this.host.feedbackData.feedbackType === \"up\" ? \"down\" : \"up\";\n this.host.feedbackData.feedbackType = newType;\n\n // Update UI — use different classes depending on custom buttonClass\n if (this.host.config.buttonClass) {\n typeToggle.classList.toggle(\"qaid-btn-up\", newType === \"up\");\n typeToggle.classList.toggle(\"qaid-btn-down\", newType === \"down\");\n } else {\n typeToggle.classList.toggle(\"qaid-type-up\", newType === \"up\");\n typeToggle.classList.toggle(\"qaid-type-down\", newType === \"down\");\n }\n const positiveIcon = this.host.config.positiveIcon || THUMBS_UP_ICON;\n const negativeIcon = this.host.config.negativeIcon || THUMBS_DOWN_ICON;\n typeToggle.innerHTML = newType === \"up\" ? positiveIcon : negativeIcon;\n\n // Update accessible state and announce the change\n const toggleLabel = newType === \"up\" ? \"Feedback type: positive\" : \"Feedback type: negative\";\n typeToggle.setAttribute(\"aria-pressed\", String(newType === \"up\"));\n typeToggle.setAttribute(\"aria-label\", toggleLabel);\n this.host.announceMsg(toggleLabel);\n\n // Update feedback on server, once the record exists\n void this.host.whenFeedbackId().then((id) => {\n if (!id) return;\n fetch(`${this.host.config.endpoint}/${id}`, {\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ feedbackType: newType }),\n }).catch((err) => console.error(\"Failed to update feedback type:\", err));\n });\n });\n }\n }\n\n private async submitMessage(message: string | null): Promise<void> {\n // null = nothing was attempted (the initial POST never produced an id);\n // otherwise whether the server accepted the PATCH.\n let delivered: boolean | null = null;\n\n // Before the await: an Escape while the POST is still out must not send\n // a second, empty PATCH over this message.\n this.finalized = true;\n const id = await this.host.whenFeedbackId();\n if (id) {\n try {\n const response = await fetch(`${this.host.config.endpoint}/${id}`, {\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ message }),\n });\n // fetch resolves on any HTTP reply. A 4xx/5xx means the server\n // refused or lost the message, so it is not a success.\n delivered = response.ok;\n if (!response.ok) {\n console.error(\"Failed to submit feedback message: HTTP\", response.status);\n }\n } catch (error) {\n console.error(\"Failed to submit feedback message:\", error);\n delivered = false;\n }\n }\n\n // The message was lost. Closing quietly reads as success, so say so —\n // even with hideConfirmation, which only opts out of the success screen.\n if (delivered === false) {\n this.showResult(false);\n return;\n }\n\n // A submit that simply removes the modal reads as a failure — nothing\n // acknowledges that the message was sent. Show a success screen unless the\n // host opted out.\n //\n // With no feedbackId the initial POST never landed and there was nothing\n // to send the message to; that path closes exactly as it did before.\n if (delivered && !this.host.config.hideConfirmation) {\n this.showResult(true);\n return;\n }\n this.close();\n }\n\n /**\n * Replace the modal's contents with the outcome: a checkmark and a short\n * acknowledgement, or an error mark and a \"not sent\" notice.\n *\n * The submit button that had focus is gone by this point, so focus moves to\n * the heading (WCAG 2.4.3) and the message is announced. Mirrors the quests\n * embed's thank-you screen so the two products confirm the same way. Copy\n * goes in as text, never markup.\n */\n private showResult(delivered: boolean): void {\n const box = this.modalContainer?.querySelector(\".qaid-modal-box\")\n ?? this.modalContainer?.querySelector(\".qaid-bottom-sheet-content\")\n ?? this.modalContainer;\n\n if (!box) {\n // Nothing to draw into — never strand the user with an open modal.\n this.close();\n return;\n }\n\n const text = this.host.config.text;\n const heading = delivered ? text.confirmationTitle : text.errorTitle;\n const body = delivered ? text.confirmationMessage : text.errorMessage;\n\n const title = h(\"h3\", {\n class: \"qaid-confirm-title\",\n text: heading,\n attrs: { id: `qaid-confirm-title-${this.host.uid}`, tabindex: \"-1\" },\n });\n\n box.textContent = \"\";\n box.appendChild(\n h(\n \"div\",\n { class: delivered ? \"qaid-confirm\" : \"qaid-confirm qaid-confirm-error\" },\n h(\"span\", {\n class: \"qaid-confirm-icon\",\n html: delivered ? DONE_ICON : ERROR_ICON,\n attrs: { \"aria-hidden\": \"true\" },\n }),\n title,\n h(\"p\", { class: \"qaid-confirm-message\", text: body }),\n h(\"button\", {\n class: \"qaid-btn-submit qaid-confirm-close\",\n text: text.confirmationClose,\n attrs: { type: \"button\" },\n on: { click: () => this.close() },\n })\n )\n );\n\n // Focus after paint, matching the quests embed.\n requestAnimationFrame(() => title.focus());\n this.host.announceMsg(`${heading} ${body}`, true);\n }\n}\n"],"names":["ModalController","host","root","id","err","sheet","h","modal","arrow","calculateModalAndArrowPosition","arrowEl","box","config","uid","text","type","isUp","positiveIcon","THUMBS_UP_ICON","negativeIcon","THUMBS_DOWN_ICON","toggleClass","toggleLabel","header","FEEDBACK_ICON","fragment","textarea","submitBtn","message","typeToggle","newType","delivered","response","error","heading","body","title","DONE_ICON","ERROR_ICON"],"mappings":";;;AAoDO,MAAMA,EAAgB;AAAA,EAM3B,YAAoBC,GAAiB;AAAjB,SAAA,OAAAA;AAAA,EAAkB;AAAA,EAAlB;AAAA,EALZ,iBAAwC;AAAA,EACxC,WAAkC;AAAA;AAAA,EAElC,YAAY;AAAA,EAIpB,OAAa;AACX,SAAK,YAAY;AACjB,UAAMC,IAAO,KAAK,KAAK,kBAAA;AAGvB,SAAK,WAAW,SAAS,cAAc,KAAK,GAC5C,KAAK,SAAS,YAAY,iBAC1B,KAAK,SAAS,MAAM,SAAS,OAAO,KAAK,KAAK,OAAO,SAAS,CAAC,GAC/D,KAAK,SAAS,MAAM,aAAa,iBAAiB,KAAK,KAAK,OAAO,eAAe,KAClF,KAAK,SAAS,iBAAiB,SAAS,MAAM,KAAK,OAAO,GAC1D,KAAK,KAAK,UAAU,KAAK,QAAQ,GAE7B,KAAK,KAAK,WACZ,KAAK,gBAAA,IAEL,KAAK,oBA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private state;
|
|
25
25
|
private feedbackData;
|
|
26
26
|
private selectedBounds;
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* This feedback's record id, once its POST answers (null if it failed).
|
|
29
|
+
* The message box and a linked quest open without waiting for it; the
|
|
30
|
+
* PATCHes that need the id wait on this instead.
|
|
31
|
+
*/
|
|
32
|
+
private feedbackIdPromise;
|
|
33
|
+
private questsPrewarmed;
|
|
28
34
|
private activeQuest;
|
|
29
35
|
private isMobile;
|
|
30
36
|
private visitorId;
|
|
@@ -84,6 +90,14 @@ export declare class QaidFeedback {
|
|
|
84
90
|
*/
|
|
85
91
|
private prewarmVideo;
|
|
86
92
|
private prewarmScreenshot;
|
|
93
|
+
/** Quest ids linked to any button, when quest launching is on. */
|
|
94
|
+
private linkedQuestIds;
|
|
95
|
+
/**
|
|
96
|
+
* Load the quests module and fetch every linked quest's definition, so a
|
|
97
|
+
* click opens the quest with no network wait. Both are best-effort: a miss
|
|
98
|
+
* just means the quest loads on click, as it always did.
|
|
99
|
+
*/
|
|
100
|
+
private prewarmQuests;
|
|
87
101
|
/** Run fn when the main thread is idle; cancelled by destroy(). */
|
|
88
102
|
private schedulePrewarm;
|
|
89
103
|
/**
|
|
@@ -127,6 +141,8 @@ export declare class QaidFeedback {
|
|
|
127
141
|
*/
|
|
128
142
|
private openAnnotationEditor;
|
|
129
143
|
private submitFeedback;
|
|
144
|
+
/** POST the feedback. Resolves to the new record's id, or null if it failed. */
|
|
145
|
+
private postFeedback;
|
|
130
146
|
/**
|
|
131
147
|
* Quest id linked to `type`, or "" when quest launching is disabled
|
|
132
148
|
* (no `base`) or this button has no quest configured.
|