@magicfeedback/popup-sdk 1.4.0 → 1.6.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/dist/assets/assets/style.css +1496 -595
- package/dist/chunk-AN7JIVWB.mjs +1965 -0
- package/dist/chunk-AN7JIVWB.mjs.map +1 -0
- package/dist/chunk-Z3LLJMSH.mjs +1944 -0
- package/dist/chunk-Z3LLJMSH.mjs.map +1 -0
- package/dist/index.d.mts +55 -3
- package/dist/index.d.ts +55 -3
- package/dist/index.js +3418 -617
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +226 -53
- package/dist/index.mjs.map +1 -1
- package/dist/react-native.d.mts +35 -2
- package/dist/react-native.d.ts +35 -2
- package/dist/react-native.js +2229 -140
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +226 -53
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-TCKR5Z3P.mjs → renderPopup-M6MKTDEH.mjs} +1423 -570
- package/dist/renderPopup-M6MKTDEH.mjs.map +1 -0
- package/dist/{renderPopup-UYMGEBSI.mjs → renderPopup-SELXQ3UE.mjs} +232 -91
- package/dist/renderPopup-SELXQ3UE.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/chunk-R4B3K2ZW.mjs +0 -176
- package/dist/chunk-R4B3K2ZW.mjs.map +0 -1
- package/dist/chunk-XFA2Y6CK.mjs +0 -197
- package/dist/chunk-XFA2Y6CK.mjs.map +0 -1
- package/dist/renderPopup-TCKR5Z3P.mjs.map +0 -1
- package/dist/renderPopup-UYMGEBSI.mjs.map +0 -1
|
@@ -6,7 +6,42 @@ import {
|
|
|
6
6
|
sdkLog,
|
|
7
7
|
sdkWarn,
|
|
8
8
|
style_default
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-Z3LLJMSH.mjs";
|
|
10
|
+
|
|
11
|
+
// src/ui/logo.ts
|
|
12
|
+
var BASE_CSS = "max-height:40px; max-width:100%; object-fit:contain; display:block; margin:12px 0 0 0;";
|
|
13
|
+
var MAX_HEIGHT = {
|
|
14
|
+
small: "30px",
|
|
15
|
+
medium: "50px",
|
|
16
|
+
large: "70px"
|
|
17
|
+
};
|
|
18
|
+
function insertPopupLogo(parent, anchor, style, id) {
|
|
19
|
+
if (!style?.logo) return null;
|
|
20
|
+
if (parent.ownerDocument.getElementById(id)) return null;
|
|
21
|
+
const img = parent.ownerDocument.createElement("img");
|
|
22
|
+
img.id = id;
|
|
23
|
+
img.src = style.logo;
|
|
24
|
+
img.alt = "Logo";
|
|
25
|
+
img.style.cssText = BASE_CSS;
|
|
26
|
+
if (style.logoSize && MAX_HEIGHT[style.logoSize]) {
|
|
27
|
+
img.style.maxHeight = MAX_HEIGHT[style.logoSize];
|
|
28
|
+
}
|
|
29
|
+
switch (style.logoPosition) {
|
|
30
|
+
case "left":
|
|
31
|
+
img.style.margin = "12px 16px 0 0";
|
|
32
|
+
img.style.marginLeft = "0";
|
|
33
|
+
break;
|
|
34
|
+
case "right":
|
|
35
|
+
img.style.margin = "12px 0 0 16px";
|
|
36
|
+
img.style.marginLeft = "auto";
|
|
37
|
+
break;
|
|
38
|
+
case "center":
|
|
39
|
+
img.style.margin = "12px auto 0 auto";
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
parent.insertBefore(img, anchor);
|
|
43
|
+
return img;
|
|
44
|
+
}
|
|
10
45
|
|
|
11
46
|
// src/ui/renderPopup.ts
|
|
12
47
|
import magicfeedback from "@magicfeedback/native";
|
|
@@ -23,6 +58,10 @@ function ensureSpinnerStyles(_popup) {
|
|
|
23
58
|
const style = document.createElement("style");
|
|
24
59
|
style.id = "deepdots-spinner-styles";
|
|
25
60
|
style.textContent = `
|
|
61
|
+
/* El enunciado trae margin-top:20px del CSS de surveys, que sumaba al hueco de la barra
|
|
62
|
+
de progreso y descompensaba la simetr\xEDa. Solo se anula en el primero: entre preguntas
|
|
63
|
+
de la misma p\xE1gina sigue separando. */
|
|
64
|
+
.deepdots-popup .magicfeedback-questions .magicfeedback-div:first-child .magicfeedback-label { margin-top: 0; }
|
|
26
65
|
@keyframes ddspin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
|
27
66
|
.mf-spinner { display:flex; justify-content:center; align-items:center; padding:8px 0; }
|
|
28
67
|
.mf-spinner-circle { width:28px; height:28px; border:3px solid #e0e6ed; border-top-color:#1E293B; border-radius:50%; animation: ddspin 0.9s linear infinite; }
|
|
@@ -49,7 +88,9 @@ function ensureResponsiveStyles(_popup) {
|
|
|
49
88
|
.deepdots-popup button { font-size: 16px !important; }
|
|
50
89
|
.deepdots-popup-header button { width:48px; height:48px; }
|
|
51
90
|
.deepdots-popup-header button svg { width:26px; height:26px; }
|
|
52
|
-
|
|
91
|
+
/* Apilados en el orden del DOM: la acci\xF3n principal (Send/Start/Complete) arriba y
|
|
92
|
+
Back debajo. */
|
|
93
|
+
.deepdots-popup-footer { flex-direction: column !important; gap: 4px !important; }
|
|
53
94
|
.deepdots-popup-footer button { width: 100%; }
|
|
54
95
|
}
|
|
55
96
|
@media (max-width: 400px) {
|
|
@@ -67,6 +108,18 @@ function ensureResponsiveStyles(_popup) {
|
|
|
67
108
|
`;
|
|
68
109
|
document.head.appendChild(style);
|
|
69
110
|
}
|
|
111
|
+
function ensureCustomCss(css) {
|
|
112
|
+
const STYLE_ID = "deepdots-custom-css";
|
|
113
|
+
const existing = document.getElementById(STYLE_ID);
|
|
114
|
+
if (!css) {
|
|
115
|
+
existing?.remove();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const el = existing ?? document.createElement("style");
|
|
119
|
+
el.id = STYLE_ID;
|
|
120
|
+
if (el.textContent !== css) el.textContent = css;
|
|
121
|
+
document.head.appendChild(el);
|
|
122
|
+
}
|
|
70
123
|
function ensureFontFace(family, url) {
|
|
71
124
|
const css = buildFontFaceCss(family, url);
|
|
72
125
|
if (!css) return;
|
|
@@ -79,9 +132,11 @@ function ensureFontFace(family, url) {
|
|
|
79
132
|
}
|
|
80
133
|
if (el.textContent !== css) el.textContent = css;
|
|
81
134
|
}
|
|
82
|
-
async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId, style, sessionId, miniService, analyticsFeedbackSessionId) {
|
|
135
|
+
async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId, style, sessionId, miniService, analyticsFeedbackSessionId, options) {
|
|
83
136
|
let surveyCompletedEmitted = false;
|
|
84
137
|
let stylesInjected = false;
|
|
138
|
+
let pageDepth = 0;
|
|
139
|
+
let onStartPage = false;
|
|
85
140
|
const isDark = style?.theme === "dark";
|
|
86
141
|
const theme = {
|
|
87
142
|
popupBg: isDark ? "#1e1e1e" : "#fff",
|
|
@@ -91,8 +146,9 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
91
146
|
// oscuros con texto blanco sobre el fondo claro del popup.
|
|
92
147
|
colorScheme: isDark ? "dark" : "light",
|
|
93
148
|
textPrimary: isDark ? "#f0f0f0" : "#111",
|
|
94
|
-
|
|
95
|
-
|
|
149
|
+
closeBtnHoverColor: isDark ? "#fff" : "#000000",
|
|
150
|
+
textMuted: isDark ? "#9ca3af" : "#6b7280",
|
|
151
|
+
progressTrack: isDark ? "#3f3f46" : "#e5e7eb"
|
|
96
152
|
};
|
|
97
153
|
const positionMap = {
|
|
98
154
|
"center": { justifyContent: "center", alignItems: "center", background: "rgba(0,0,0,0.5)" },
|
|
@@ -105,6 +161,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
105
161
|
};
|
|
106
162
|
const pos = positionMap[style?.position ?? "center"] ?? positionMap["center"];
|
|
107
163
|
const popup = document.createElement("div");
|
|
164
|
+
popup.id = "dd-popup";
|
|
108
165
|
popup.className = "deepdots-popup";
|
|
109
166
|
popup.style.cssText = `
|
|
110
167
|
position: relative;
|
|
@@ -118,6 +175,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
118
175
|
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
|
119
176
|
max-width: 600px;
|
|
120
177
|
width: 90%;
|
|
178
|
+
max-height: 90vh;
|
|
121
179
|
min-height: 200px;
|
|
122
180
|
`;
|
|
123
181
|
const font = style?.font;
|
|
@@ -130,13 +188,26 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
130
188
|
}
|
|
131
189
|
const header = document.createElement("div");
|
|
132
190
|
header.className = "deepdots-popup-header";
|
|
133
|
-
header.style.cssText = "display:flex; justify-content:
|
|
191
|
+
header.style.cssText = "display:flex; justify-content:space-between; align-items:center; gap:12px; width:100%; flex:0 0 auto;";
|
|
192
|
+
const titleEl = document.createElement("h2");
|
|
193
|
+
titleEl.id = "dd-title";
|
|
194
|
+
titleEl.className = "deepdots-popup-title";
|
|
195
|
+
titleEl.style.cssText = `margin:0; font-size:17px; font-weight:600; line-height:1.3; color:${theme.textPrimary}; text-transform:none; text-align:left; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;`;
|
|
196
|
+
titleEl.hidden = true;
|
|
197
|
+
const setTitle = (value) => {
|
|
198
|
+
if (!value) return;
|
|
199
|
+
titleEl.textContent = value;
|
|
200
|
+
titleEl.hidden = false;
|
|
201
|
+
};
|
|
202
|
+
setTitle(options?.title);
|
|
203
|
+
header.appendChild(titleEl);
|
|
134
204
|
const closeBtn = document.createElement("button");
|
|
205
|
+
closeBtn.id = "dd-close";
|
|
135
206
|
closeBtn.type = "button";
|
|
136
207
|
closeBtn.setAttribute("aria-label", "Close popup");
|
|
137
208
|
closeBtn.innerHTML = `
|
|
138
|
-
<svg width="
|
|
139
|
-
<path d="
|
|
209
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
210
|
+
<path d="M5 5L19 19M5 19L19 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="butt"/>
|
|
140
211
|
</svg>
|
|
141
212
|
`;
|
|
142
213
|
closeBtn.style.cssText = `
|
|
@@ -151,42 +222,101 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
151
222
|
cursor:pointer;
|
|
152
223
|
color:${theme.textPrimary};
|
|
153
224
|
padding:4px;
|
|
154
|
-
transition: color .15s ease, transform .15s ease
|
|
225
|
+
transition: color .15s ease, transform .15s ease;
|
|
155
226
|
box-shadow: none !important;
|
|
156
227
|
`;
|
|
157
228
|
closeBtn.onmouseenter = () => {
|
|
158
229
|
closeBtn.style.color = theme.closeBtnHoverColor;
|
|
159
|
-
closeBtn.style.background = theme.closeBtnHoverBg;
|
|
160
230
|
closeBtn.style.transform = "scale(1.06)";
|
|
161
231
|
};
|
|
162
232
|
closeBtn.onmouseleave = () => {
|
|
163
233
|
closeBtn.style.color = theme.textPrimary;
|
|
164
|
-
closeBtn.style.background = "transparent";
|
|
165
234
|
closeBtn.style.transform = "scale(1)";
|
|
166
235
|
};
|
|
167
236
|
closeBtn.onclick = () => {
|
|
168
237
|
emit("popup_clicked", surveyId, { action: "close_icon" });
|
|
169
238
|
onClose();
|
|
170
239
|
};
|
|
240
|
+
closeBtn.style.flex = "0 0 auto";
|
|
241
|
+
closeBtn.style.marginLeft = "auto";
|
|
171
242
|
header.appendChild(closeBtn);
|
|
243
|
+
let progressEnabled = options?.showProgressBar === true;
|
|
244
|
+
let progressShowUnit = true;
|
|
245
|
+
let progressUnit = "fraction";
|
|
246
|
+
const progressEl = document.createElement("div");
|
|
247
|
+
progressEl.id = "dd-progress";
|
|
248
|
+
progressEl.className = "deepdots-progress";
|
|
249
|
+
progressEl.style.cssText = "display:none; flex-direction:column; gap:8px; width:100%; flex:0 0 auto; padding:16px 0; box-sizing:border-box;";
|
|
250
|
+
const progressHead = document.createElement("div");
|
|
251
|
+
progressHead.className = "deepdots-progress-head";
|
|
252
|
+
progressHead.style.cssText = "display:flex; flex-direction:row; justify-content:space-between; align-items:center; width:100%; gap:8px;";
|
|
253
|
+
const progressLabel = document.createElement("span");
|
|
254
|
+
progressLabel.id = "dd-progress-label";
|
|
255
|
+
progressLabel.style.cssText = "font-size:13px; line-height:1.2;";
|
|
256
|
+
const progressCurrent = document.createElement("span");
|
|
257
|
+
progressCurrent.id = "dd-progress-current";
|
|
258
|
+
progressCurrent.style.cssText = `font-weight:700; color:${theme.textPrimary};`;
|
|
259
|
+
const progressTotal = document.createElement("span");
|
|
260
|
+
progressTotal.id = "dd-progress-total";
|
|
261
|
+
progressTotal.style.cssText = `font-weight:400; color:${theme.textMuted};`;
|
|
262
|
+
progressLabel.appendChild(progressCurrent);
|
|
263
|
+
progressLabel.appendChild(progressTotal);
|
|
264
|
+
const progressFollowUp = document.createElement("span");
|
|
265
|
+
progressFollowUp.id = "dd-progress-followup";
|
|
266
|
+
progressFollowUp.textContent = "Follow-up";
|
|
267
|
+
progressFollowUp.style.cssText = "display:none; font-size:12px; font-weight:600; color:#fff; background:rgba(59,130,246,0.44); border-radius:999px; padding:2px 10px;";
|
|
268
|
+
progressHead.appendChild(progressLabel);
|
|
269
|
+
progressHead.appendChild(progressFollowUp);
|
|
270
|
+
const progressTrack = document.createElement("div");
|
|
271
|
+
progressTrack.className = "deepdots-progress-track";
|
|
272
|
+
progressTrack.style.cssText = `width:100%; height:4px; border-radius:999px; background:${theme.progressTrack}; overflow:hidden;`;
|
|
273
|
+
const progressBar = document.createElement("div");
|
|
274
|
+
progressBar.id = "dd-progress-bar";
|
|
275
|
+
progressBar.style.cssText = "height:100%; width:0%; background:#22C55E; border-radius:999px; transition:width 450ms ease;";
|
|
276
|
+
progressTrack.appendChild(progressBar);
|
|
277
|
+
progressEl.appendChild(progressHead);
|
|
278
|
+
progressEl.appendChild(progressTrack);
|
|
279
|
+
function updateProgress(p) {
|
|
280
|
+
const total = typeof p.total === "number" ? p.total : 0;
|
|
281
|
+
const progress = typeof p.progress === "number" ? p.progress : 0;
|
|
282
|
+
if (!progressEnabled || onStartPage || p.completed || total <= 1) {
|
|
283
|
+
progressEl.style.display = "none";
|
|
284
|
+
containerContent.style.paddingTop = "16px";
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
progressEl.style.display = "flex";
|
|
288
|
+
containerContent.style.paddingTop = "0";
|
|
289
|
+
const current = Math.min(total, Math.max(1, progress + 1));
|
|
290
|
+
const pct = Math.min(100, Math.max(0, current / total * 100));
|
|
291
|
+
progressBar.style.width = `${pct}%`;
|
|
292
|
+
const label = Math.min(total, Math.max(1, Math.floor(progress) + 1));
|
|
293
|
+
progressLabel.style.display = progressShowUnit ? "block" : "none";
|
|
294
|
+
if (progressUnit === "percentage") {
|
|
295
|
+
progressCurrent.textContent = `${Math.round(pct)}%`;
|
|
296
|
+
progressTotal.textContent = "";
|
|
297
|
+
} else {
|
|
298
|
+
progressCurrent.textContent = `Question ${label}`;
|
|
299
|
+
progressTotal.textContent = ` of ${total}`;
|
|
300
|
+
}
|
|
301
|
+
progressFollowUp.style.display = p.followup ? "inline-block" : "none";
|
|
302
|
+
}
|
|
172
303
|
ensureMagicFeedbackStyles(popup);
|
|
173
304
|
ensureSpinnerStyles(popup);
|
|
174
305
|
ensureResponsiveStyles(popup);
|
|
306
|
+
ensureCustomCss(options?.surveyCss);
|
|
175
307
|
const containerContent = document.createElement("div");
|
|
176
|
-
containerContent.
|
|
177
|
-
containerContent.
|
|
178
|
-
|
|
179
|
-
flex-direction:column;
|
|
180
|
-
padding: 0 20px 12px 20px;
|
|
181
|
-
max-height: 80vh; /* l\xEDmite general del popup */
|
|
182
|
-
overflow: hidden; /* quita scroll del contenedor principal */
|
|
183
|
-
`;
|
|
308
|
+
containerContent.id = "dd-content";
|
|
309
|
+
containerContent.className = "deepdots-popup-container-content";
|
|
310
|
+
containerContent.style.cssText = "display:flex; flex-direction:column; flex:1 1 auto; min-height:0; padding:16px 0 0 0; overflow:hidden;";
|
|
184
311
|
const main = document.createElement("div");
|
|
312
|
+
main.id = "dd-main";
|
|
185
313
|
main.className = "deepdots-popup-main";
|
|
186
|
-
main.style.cssText = "display:flex; flex-direction:column; width:100%;
|
|
314
|
+
main.style.cssText = "display:flex; flex-direction:column; width:100%; flex:1 1 auto; min-height:0; overflow-y:auto;";
|
|
187
315
|
const formWrapper = document.createElement("div");
|
|
316
|
+
formWrapper.id = "dd-form-wrapper";
|
|
188
317
|
formWrapper.style.cssText = "width:100%; flex: 1 1 auto;";
|
|
189
318
|
const errorHint = document.createElement("div");
|
|
319
|
+
errorHint.id = "dd-error";
|
|
190
320
|
errorHint.className = "deepdots-error-hint";
|
|
191
321
|
errorHint.style.cssText = `
|
|
192
322
|
display: none;
|
|
@@ -215,20 +345,24 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
215
345
|
main.appendChild(formWrapper);
|
|
216
346
|
main.appendChild(errorHint);
|
|
217
347
|
const footer = document.createElement("div");
|
|
348
|
+
footer.id = "dd-footer";
|
|
218
349
|
footer.className = "deepdots-popup-footer";
|
|
219
350
|
footer.setAttribute("data-actions-wrapper", "true");
|
|
220
|
-
footer.style.cssText = "display:flex; flex-direction: row-reverse ;justify-content:space-between; align-items:center; gap:
|
|
351
|
+
footer.style.cssText = "display:flex; flex-direction: row-reverse ;justify-content:space-between; align-items:center; gap:4px; margin-top:auto; width:100%; padding-top:12px;";
|
|
221
352
|
const backButton = document.createElement("button");
|
|
353
|
+
backButton.id = "dd-back";
|
|
354
|
+
backButton.className = "dd-nav-btn";
|
|
222
355
|
backButton.textContent = actions?.back ? actions.back.label : "Back";
|
|
223
356
|
backButton.style.cssText = `
|
|
224
357
|
background: transparent;
|
|
225
|
-
color:
|
|
226
|
-
border:
|
|
358
|
+
color: ${theme.textMuted};
|
|
359
|
+
border: none;
|
|
360
|
+
min-height: 44px;
|
|
227
361
|
padding: 12px 24px;
|
|
228
|
-
border-radius:
|
|
362
|
+
border-radius: 6px;
|
|
229
363
|
cursor: pointer;
|
|
230
|
-
font-size:
|
|
231
|
-
|
|
364
|
+
font-size: 15px;
|
|
365
|
+
font-weight: 600;
|
|
232
366
|
transition: filter .15s ease;
|
|
233
367
|
display: inline-flex;
|
|
234
368
|
align-items: center;
|
|
@@ -246,15 +380,19 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
246
380
|
formInstance?.back?.();
|
|
247
381
|
};
|
|
248
382
|
const startButton = document.createElement("button");
|
|
383
|
+
startButton.id = "dd-start";
|
|
384
|
+
startButton.className = "dd-nav-btn";
|
|
249
385
|
startButton.textContent = actions?.start ? actions.start.label : "Start survey";
|
|
250
386
|
startButton.style.cssText = `
|
|
251
387
|
background: #1E293B;
|
|
252
388
|
color: #fff;
|
|
253
389
|
border: none;
|
|
390
|
+
min-height: 44px;
|
|
254
391
|
padding: 12px 24px;
|
|
255
|
-
border-radius:
|
|
392
|
+
border-radius: 6px;
|
|
256
393
|
cursor: pointer;
|
|
257
|
-
font-size:
|
|
394
|
+
font-size: 15px;
|
|
395
|
+
font-weight: 600;
|
|
258
396
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
259
397
|
transition: filter .15s ease;
|
|
260
398
|
display: inline-flex;
|
|
@@ -265,17 +403,23 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
265
403
|
startButton.onclick = () => {
|
|
266
404
|
emit("popup_clicked", surveyId, { action: "start_survey" });
|
|
267
405
|
formInstance?.startForm?.();
|
|
406
|
+
onStartPage = false;
|
|
407
|
+
updateProgress({ progress: formInstance?.progress, total: formInstance?.total });
|
|
268
408
|
};
|
|
269
409
|
const closeButton = document.createElement("button");
|
|
410
|
+
closeButton.id = "dd-complete";
|
|
411
|
+
closeButton.className = "dd-nav-btn";
|
|
270
412
|
closeButton.textContent = actions?.complete ? actions.complete.label : "Complete survey";
|
|
271
413
|
closeButton.style.cssText = `
|
|
272
414
|
background: #1E293B;
|
|
273
415
|
color: #fff;
|
|
274
416
|
border: none;
|
|
417
|
+
min-height: 44px;
|
|
275
418
|
padding: 12px 24px;
|
|
276
|
-
border-radius:
|
|
419
|
+
border-radius: 6px;
|
|
277
420
|
cursor: pointer;
|
|
278
|
-
font-size:
|
|
421
|
+
font-size: 15px;
|
|
422
|
+
font-weight: 600;
|
|
279
423
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
280
424
|
transition: filter .15s ease;
|
|
281
425
|
display: inline-flex;
|
|
@@ -294,15 +438,19 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
294
438
|
onClose();
|
|
295
439
|
};
|
|
296
440
|
const submitButton = document.createElement("button");
|
|
441
|
+
submitButton.id = "dd-submit";
|
|
442
|
+
submitButton.className = "dd-nav-btn";
|
|
297
443
|
submitButton.textContent = actions?.accept ? actions.accept.label : "Send";
|
|
298
444
|
submitButton.style.cssText = `
|
|
299
445
|
background: #1E293B;
|
|
300
446
|
color: #fff;
|
|
301
447
|
border: none;
|
|
448
|
+
min-height: 44px;
|
|
302
449
|
padding: 12px 24px;
|
|
303
|
-
border-radius:
|
|
450
|
+
border-radius: 6px;
|
|
304
451
|
cursor: pointer;
|
|
305
|
-
font-size:
|
|
452
|
+
font-size: 15px;
|
|
453
|
+
font-weight: 600;
|
|
306
454
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
307
455
|
transition: filter .15s ease;
|
|
308
456
|
display: inline-flex;
|
|
@@ -324,8 +472,9 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
324
472
|
footer.appendChild(backButton);
|
|
325
473
|
footer.appendChild(closeButton);
|
|
326
474
|
footer.appendChild(startButton);
|
|
327
|
-
main.appendChild(footer);
|
|
328
475
|
containerContent.appendChild(main);
|
|
476
|
+
footer.style.flex = "0 0 auto";
|
|
477
|
+
containerContent.appendChild(footer);
|
|
329
478
|
function updateButtons(state) {
|
|
330
479
|
backButton.style.display = "none";
|
|
331
480
|
startButton.style.display = "none";
|
|
@@ -362,7 +511,27 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
362
511
|
break;
|
|
363
512
|
}
|
|
364
513
|
}
|
|
514
|
+
function updateNavButtons() {
|
|
515
|
+
updateButtons(pageDepth > 0 ? "in_progress_next" : "in_progress_first");
|
|
516
|
+
}
|
|
517
|
+
let successMessageHtml = "";
|
|
518
|
+
function showSuccessScreen() {
|
|
519
|
+
progressEl.style.display = "none";
|
|
520
|
+
formWrapper.style.display = "none";
|
|
521
|
+
let done = main.querySelector(".deepdots-success");
|
|
522
|
+
if (!done) {
|
|
523
|
+
done = document.createElement("div");
|
|
524
|
+
done.className = "deepdots-success";
|
|
525
|
+
done.style.cssText = `width:100%; text-align:center; padding:24px 0; color:${theme.textPrimary};`;
|
|
526
|
+
main.insertBefore(done, errorHint);
|
|
527
|
+
}
|
|
528
|
+
done.innerHTML = successMessageHtml || "<p>Thank you for your feedback!</p>";
|
|
529
|
+
done.querySelectorAll("img").forEach((img) => {
|
|
530
|
+
img.style.cssText = "max-width:100%; height:auto; margin:0 auto 16px auto; display:block;";
|
|
531
|
+
});
|
|
532
|
+
}
|
|
365
533
|
popup.appendChild(header);
|
|
534
|
+
popup.appendChild(progressEl);
|
|
366
535
|
popup.appendChild(containerContent);
|
|
367
536
|
container.innerHTML = "";
|
|
368
537
|
container.appendChild(popup);
|
|
@@ -408,7 +577,11 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
408
577
|
formInstance = magicfeedback.form(surveyId, productId, profile, metadata);
|
|
409
578
|
const generateOptions = {
|
|
410
579
|
addButton: false,
|
|
411
|
-
getMetaData: true
|
|
580
|
+
getMetaData: true,
|
|
581
|
+
// La pantalla final la pinta el popup: `renderSuccess` de @magicfeedback/native usa
|
|
582
|
+
// textContent, así que el mensaje de la plataforma (HTML con imagen) no se vería, y
|
|
583
|
+
// su fallback es un literal genérico que ignora `style.successMessage`.
|
|
584
|
+
addSuccessScreen: false
|
|
412
585
|
};
|
|
413
586
|
generateOptions.onLoadedEvent = ({ formData }) => {
|
|
414
587
|
try {
|
|
@@ -417,6 +590,14 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
417
590
|
const s = formData?.style;
|
|
418
591
|
if (s && !stylesInjected) {
|
|
419
592
|
stylesInjected = true;
|
|
593
|
+
if (s.successMessage) successMessageHtml = s.successMessage;
|
|
594
|
+
if (options?.showProgressBar === void 0) progressEnabled = s.showProgressBar === true;
|
|
595
|
+
if (s.showProgressUnit !== void 0) progressShowUnit = s.showProgressUnit !== false;
|
|
596
|
+
if (s.progressUnit) progressUnit = s.progressUnit;
|
|
597
|
+
if (s.loadingBarColor) {
|
|
598
|
+
progressBar.style.background = s.loadingBarColor;
|
|
599
|
+
progressFollowUp.style.background = s.loadingBarColor;
|
|
600
|
+
}
|
|
420
601
|
if (s.boxBackgroundColor) {
|
|
421
602
|
popup.style.background = s.boxBackgroundColor;
|
|
422
603
|
}
|
|
@@ -435,53 +616,14 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
435
616
|
closeButton.style.color = "#fff";
|
|
436
617
|
}
|
|
437
618
|
if (s.buttonSecondaryColor) {
|
|
438
|
-
backButton.style.background = "
|
|
619
|
+
backButton.style.background = "transparent";
|
|
439
620
|
backButton.style.color = s.buttonSecondaryColor;
|
|
440
|
-
backButton.style.border =
|
|
441
|
-
}
|
|
442
|
-
if (s.logo) {
|
|
443
|
-
if (!document.getElementById("deepdots-popup-logo")) {
|
|
444
|
-
const logoImg = document.createElement("img");
|
|
445
|
-
logoImg.id = "deepdots-popup-logo";
|
|
446
|
-
logoImg.src = s.logo;
|
|
447
|
-
logoImg.alt = "Logo";
|
|
448
|
-
logoImg.style.cssText = "max-height:40px; max-width:100%; object-fit:contain;";
|
|
449
|
-
if (s.logoSize) {
|
|
450
|
-
switch (s.logoSize) {
|
|
451
|
-
case "small":
|
|
452
|
-
logoImg.style.maxHeight = "30px";
|
|
453
|
-
break;
|
|
454
|
-
case "medium":
|
|
455
|
-
logoImg.style.maxHeight = "50px";
|
|
456
|
-
break;
|
|
457
|
-
case "large":
|
|
458
|
-
logoImg.style.maxHeight = "70px";
|
|
459
|
-
break;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
if (s.logoPosition) {
|
|
463
|
-
switch (s.logoPosition) {
|
|
464
|
-
case "left":
|
|
465
|
-
logoImg.style.margin = "0 16px 42px 0";
|
|
466
|
-
logoImg.style.display = "block";
|
|
467
|
-
logoImg.style.marginLeft = "0";
|
|
468
|
-
break;
|
|
469
|
-
case "right":
|
|
470
|
-
logoImg.style.margin = "0 0 42px 16px";
|
|
471
|
-
logoImg.style.display = "block";
|
|
472
|
-
logoImg.style.marginLeft = "auto";
|
|
473
|
-
break;
|
|
474
|
-
case "center":
|
|
475
|
-
logoImg.style.margin = "0 auto 42px auto";
|
|
476
|
-
logoImg.style.display = "block";
|
|
477
|
-
break;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
containerContent.insertBefore(logoImg, main);
|
|
481
|
-
}
|
|
621
|
+
backButton.style.border = "none";
|
|
482
622
|
}
|
|
623
|
+
insertPopupLogo(popup, progressEl, s, "deepdots-popup-logo");
|
|
483
624
|
if (s.startMessage && s.startMessage !== "") {
|
|
484
625
|
sdkLog(s.startMessage);
|
|
626
|
+
onStartPage = true;
|
|
485
627
|
updateButtons("start");
|
|
486
628
|
} else {
|
|
487
629
|
updateButtons("in_progress_first");
|
|
@@ -489,6 +631,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
489
631
|
} else {
|
|
490
632
|
updateButtons("in_progress_first");
|
|
491
633
|
}
|
|
634
|
+
updateProgress({ progress: formInstance.progress, total: formInstance.total });
|
|
492
635
|
emit("popup_clicked", surveyId, { action: "loaded" });
|
|
493
636
|
setLoading(false);
|
|
494
637
|
};
|
|
@@ -496,7 +639,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
496
639
|
setLoading(true);
|
|
497
640
|
emit("popup_clicked", surveyId, { action: "before_submit" });
|
|
498
641
|
};
|
|
499
|
-
generateOptions.afterSubmitEvent = ({ error, completed, total, progress }) => {
|
|
642
|
+
generateOptions.afterSubmitEvent = ({ error, completed, total, progress, followup }) => {
|
|
500
643
|
const errText = error ? typeof error === "string" ? error : error.message ?? String(error) : "";
|
|
501
644
|
if (errText) {
|
|
502
645
|
setLoading(false);
|
|
@@ -504,7 +647,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
504
647
|
errorHint.textContent = "Please answer the required question to continue.";
|
|
505
648
|
errorHint.style.display = "block";
|
|
506
649
|
emit("popup_clicked", surveyId, { action: "validation_error_required" });
|
|
507
|
-
|
|
650
|
+
updateNavButtons();
|
|
508
651
|
return;
|
|
509
652
|
}
|
|
510
653
|
errorHint.textContent = "An error occurred while submitting. Please try again or close the popup.";
|
|
@@ -517,23 +660,21 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
517
660
|
if (completed) {
|
|
518
661
|
emit("survey_completed", surveyId, { action: "completed" });
|
|
519
662
|
surveyCompletedEmitted = true;
|
|
663
|
+
showSuccessScreen();
|
|
520
664
|
updateButtons("completed");
|
|
665
|
+
updateProgress({ progress, total, completed: true });
|
|
521
666
|
return;
|
|
522
667
|
}
|
|
523
668
|
emit("popup_clicked", surveyId, { action: "partial" });
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
updateButtons("in_progress_first");
|
|
528
|
-
}
|
|
669
|
+
pageDepth++;
|
|
670
|
+
updateNavButtons();
|
|
671
|
+
updateProgress({ progress, total, followup });
|
|
529
672
|
};
|
|
530
|
-
generateOptions.onBackEvent = ({ progress }) => {
|
|
673
|
+
generateOptions.onBackEvent = ({ progress, error, followup }) => {
|
|
531
674
|
emit("popup_clicked", surveyId, { action: "back" });
|
|
532
|
-
if (
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
updateButtons("in_progress_next");
|
|
536
|
-
}
|
|
675
|
+
if (!error) pageDepth = Math.max(0, pageDepth - 1);
|
|
676
|
+
updateNavButtons();
|
|
677
|
+
updateProgress({ progress, total: formInstance.total, followup });
|
|
537
678
|
};
|
|
538
679
|
formInstance.generate(formDivId, generateOptions).catch((err) => {
|
|
539
680
|
sdkError("[MagicFeedback] Error generating form:", err);
|
|
@@ -547,4 +688,4 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
547
688
|
export {
|
|
548
689
|
renderPopup
|
|
549
690
|
};
|
|
550
|
-
//# sourceMappingURL=renderPopup-
|
|
691
|
+
//# sourceMappingURL=renderPopup-SELXQ3UE.mjs.map
|