@magicfeedback/popup-sdk 1.3.0 → 1.5.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.
@@ -8,7 +8,7 @@ import {
8
8
  sdkLog,
9
9
  sdkWarn,
10
10
  style_default
11
- } from "./chunk-XFA2Y6CK.mjs";
11
+ } from "./chunk-JSBMP4MI.mjs";
12
12
 
13
13
  // node_modules/@magicfeedback/native/dist/magicfeedback-sdk.browser.js
14
14
  var require_magicfeedback_sdk_browser = __commonJS({
@@ -1950,6 +1950,10 @@ function ensureSpinnerStyles(_popup) {
1950
1950
  const style = document.createElement("style");
1951
1951
  style.id = "deepdots-spinner-styles";
1952
1952
  style.textContent = `
1953
+ /* El enunciado trae margin-top:20px del CSS de surveys, que sumaba al hueco de la barra
1954
+ de progreso y descompensaba la simetr\xEDa. Solo se anula en el primero: entre preguntas
1955
+ de la misma p\xE1gina sigue separando. */
1956
+ .deepdots-popup .magicfeedback-questions .magicfeedback-div:first-child .magicfeedback-label { margin-top: 0; }
1953
1957
  @keyframes ddspin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
1954
1958
  .mf-spinner { display:flex; justify-content:center; align-items:center; padding:8px 0; }
1955
1959
  .mf-spinner-circle { width:28px; height:28px; border:3px solid #e0e6ed; border-top-color:#1E293B; border-radius:50%; animation: ddspin 0.9s linear infinite; }
@@ -1976,7 +1980,9 @@ function ensureResponsiveStyles(_popup) {
1976
1980
  .deepdots-popup button { font-size: 16px !important; }
1977
1981
  .deepdots-popup-header button { width:48px; height:48px; }
1978
1982
  .deepdots-popup-header button svg { width:26px; height:26px; }
1979
- .deepdots-popup-footer { flex-direction: column-reverse !important; gap: 12px !important; }
1983
+ /* Apilados en el orden del DOM: la acci\xF3n principal (Send/Start/Complete) arriba y
1984
+ Back debajo. */
1985
+ .deepdots-popup-footer { flex-direction: column !important; gap: 4px !important; }
1980
1986
  .deepdots-popup-footer button { width: 100%; }
1981
1987
  }
1982
1988
  @media (max-width: 400px) {
@@ -1994,6 +2000,18 @@ function ensureResponsiveStyles(_popup) {
1994
2000
  `;
1995
2001
  document.head.appendChild(style);
1996
2002
  }
2003
+ function ensureCustomCss(css) {
2004
+ const STYLE_ID = "deepdots-custom-css";
2005
+ const existing = document.getElementById(STYLE_ID);
2006
+ if (!css) {
2007
+ existing?.remove();
2008
+ return;
2009
+ }
2010
+ const el = existing ?? document.createElement("style");
2011
+ el.id = STYLE_ID;
2012
+ if (el.textContent !== css) el.textContent = css;
2013
+ document.head.appendChild(el);
2014
+ }
1997
2015
  function ensureFontFace(family, url) {
1998
2016
  const css = buildFontFaceCss(family, url);
1999
2017
  if (!css) return;
@@ -2006,9 +2024,11 @@ function ensureFontFace(family, url) {
2006
2024
  }
2007
2025
  if (el.textContent !== css) el.textContent = css;
2008
2026
  }
2009
- async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId, style, sessionId, miniService, analyticsFeedbackSessionId) {
2027
+ async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId, style, sessionId, miniService, analyticsFeedbackSessionId, options) {
2010
2028
  let surveyCompletedEmitted = false;
2011
2029
  let stylesInjected = false;
2030
+ let pageDepth = 0;
2031
+ let onStartPage = false;
2012
2032
  const isDark = style?.theme === "dark";
2013
2033
  const theme = {
2014
2034
  popupBg: isDark ? "#1e1e1e" : "#fff",
@@ -2019,7 +2039,9 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2019
2039
  colorScheme: isDark ? "dark" : "light",
2020
2040
  textPrimary: isDark ? "#f0f0f0" : "#111",
2021
2041
  closeBtnHoverBg: isDark ? "rgba(255,255,255,0.10)" : "rgba(0,0,0,0.06)",
2022
- closeBtnHoverColor: isDark ? "#fff" : "#000000"
2042
+ closeBtnHoverColor: isDark ? "#fff" : "#000000",
2043
+ textMuted: isDark ? "#9ca3af" : "#6b7280",
2044
+ progressTrack: isDark ? "#3f3f46" : "#e5e7eb"
2023
2045
  };
2024
2046
  const positionMap = {
2025
2047
  "center": { justifyContent: "center", alignItems: "center", background: "rgba(0,0,0,0.5)" },
@@ -2032,6 +2054,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2032
2054
  };
2033
2055
  const pos = positionMap[style?.position ?? "center"] ?? positionMap["center"];
2034
2056
  const popup = document.createElement("div");
2057
+ popup.id = "dd-popup";
2035
2058
  popup.className = "deepdots-popup";
2036
2059
  popup.style.cssText = `
2037
2060
  position: relative;
@@ -2045,6 +2068,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2045
2068
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
2046
2069
  max-width: 600px;
2047
2070
  width: 90%;
2071
+ max-height: 90vh;
2048
2072
  min-height: 200px;
2049
2073
  `;
2050
2074
  const font = style?.font;
@@ -2057,8 +2081,21 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2057
2081
  }
2058
2082
  const header = document.createElement("div");
2059
2083
  header.className = "deepdots-popup-header";
2060
- header.style.cssText = "display:flex; justify-content:flex-end; align-items:center; width:100%;";
2084
+ header.style.cssText = "display:flex; justify-content:space-between; align-items:center; gap:12px; width:100%; flex:0 0 auto;";
2085
+ const titleEl = document.createElement("h2");
2086
+ titleEl.id = "dd-title";
2087
+ titleEl.className = "deepdots-popup-title";
2088
+ 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;`;
2089
+ titleEl.hidden = true;
2090
+ const setTitle = (value) => {
2091
+ if (!value) return;
2092
+ titleEl.textContent = value;
2093
+ titleEl.hidden = false;
2094
+ };
2095
+ setTitle(options?.title);
2096
+ header.appendChild(titleEl);
2061
2097
  const closeBtn = document.createElement("button");
2098
+ closeBtn.id = "dd-close";
2062
2099
  closeBtn.type = "button";
2063
2100
  closeBtn.setAttribute("aria-label", "Close popup");
2064
2101
  closeBtn.innerHTML = `
@@ -2095,25 +2132,86 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2095
2132
  emit("popup_clicked", surveyId, { action: "close_icon" });
2096
2133
  onClose();
2097
2134
  };
2135
+ closeBtn.style.flex = "0 0 auto";
2136
+ closeBtn.style.marginLeft = "auto";
2098
2137
  header.appendChild(closeBtn);
2138
+ let progressEnabled = options?.showProgressBar === true;
2139
+ let progressShowUnit = true;
2140
+ let progressUnit = "fraction";
2141
+ const progressEl = document.createElement("div");
2142
+ progressEl.id = "dd-progress";
2143
+ progressEl.className = "deepdots-progress";
2144
+ progressEl.style.cssText = "display:none; flex-direction:column; gap:8px; width:100%; flex:0 0 auto; padding:16px 0; box-sizing:border-box;";
2145
+ const progressHead = document.createElement("div");
2146
+ progressHead.className = "deepdots-progress-head";
2147
+ progressHead.style.cssText = "display:flex; flex-direction:row; justify-content:space-between; align-items:center; width:100%; gap:8px;";
2148
+ const progressLabel = document.createElement("span");
2149
+ progressLabel.id = "dd-progress-label";
2150
+ progressLabel.style.cssText = "font-size:13px; line-height:1.2;";
2151
+ const progressCurrent = document.createElement("span");
2152
+ progressCurrent.id = "dd-progress-current";
2153
+ progressCurrent.style.cssText = `font-weight:700; color:${theme.textPrimary};`;
2154
+ const progressTotal = document.createElement("span");
2155
+ progressTotal.id = "dd-progress-total";
2156
+ progressTotal.style.cssText = `font-weight:400; color:${theme.textMuted};`;
2157
+ progressLabel.appendChild(progressCurrent);
2158
+ progressLabel.appendChild(progressTotal);
2159
+ const progressFollowUp = document.createElement("span");
2160
+ progressFollowUp.id = "dd-progress-followup";
2161
+ progressFollowUp.textContent = "Follow-up";
2162
+ 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;";
2163
+ progressHead.appendChild(progressLabel);
2164
+ progressHead.appendChild(progressFollowUp);
2165
+ const progressTrack = document.createElement("div");
2166
+ progressTrack.className = "deepdots-progress-track";
2167
+ progressTrack.style.cssText = `width:100%; height:4px; border-radius:999px; background:${theme.progressTrack}; overflow:hidden;`;
2168
+ const progressBar = document.createElement("div");
2169
+ progressBar.id = "dd-progress-bar";
2170
+ progressBar.style.cssText = "height:100%; width:0%; background:#22C55E; border-radius:999px; transition:width 450ms ease;";
2171
+ progressTrack.appendChild(progressBar);
2172
+ progressEl.appendChild(progressHead);
2173
+ progressEl.appendChild(progressTrack);
2174
+ function updateProgress(p) {
2175
+ const total = typeof p.total === "number" ? p.total : 0;
2176
+ const progress = typeof p.progress === "number" ? p.progress : 0;
2177
+ if (!progressEnabled || onStartPage || p.completed || total <= 1) {
2178
+ progressEl.style.display = "none";
2179
+ containerContent.style.paddingTop = "16px";
2180
+ return;
2181
+ }
2182
+ progressEl.style.display = "flex";
2183
+ containerContent.style.paddingTop = "0";
2184
+ const current = Math.min(total, Math.max(1, progress + 1));
2185
+ const pct = Math.min(100, Math.max(0, current / total * 100));
2186
+ progressBar.style.width = `${pct}%`;
2187
+ const label = Math.min(total, Math.max(1, Math.floor(progress) + 1));
2188
+ progressLabel.style.display = progressShowUnit ? "block" : "none";
2189
+ if (progressUnit === "percentage") {
2190
+ progressCurrent.textContent = `${Math.round(pct)}%`;
2191
+ progressTotal.textContent = "";
2192
+ } else {
2193
+ progressCurrent.textContent = `Question ${label}`;
2194
+ progressTotal.textContent = ` of ${total}`;
2195
+ }
2196
+ progressFollowUp.style.display = p.followup ? "inline-block" : "none";
2197
+ }
2099
2198
  ensureMagicFeedbackStyles(popup);
2100
2199
  ensureSpinnerStyles(popup);
2101
2200
  ensureResponsiveStyles(popup);
2201
+ ensureCustomCss(options?.surveyCss);
2102
2202
  const containerContent = document.createElement("div");
2103
- containerContent.className = "deepdots-popup-container-conetent";
2104
- containerContent.style.cssText = `
2105
- display:flex;
2106
- flex-direction:column;
2107
- padding: 0 20px 12px 20px;
2108
- max-height: 80vh; /* l\xEDmite general del popup */
2109
- overflow: hidden; /* quita scroll del contenedor principal */
2110
- `;
2203
+ containerContent.id = "dd-content";
2204
+ containerContent.className = "deepdots-popup-container-content";
2205
+ containerContent.style.cssText = "display:flex; flex-direction:column; flex:1 1 auto; min-height:0; padding:16px 0 0 0; overflow:hidden;";
2111
2206
  const main = document.createElement("div");
2207
+ main.id = "dd-main";
2112
2208
  main.className = "deepdots-popup-main";
2113
- main.style.cssText = "display:flex; flex-direction:column; width:100%; max-height:80vh; overflow-y:auto;";
2209
+ main.style.cssText = "display:flex; flex-direction:column; width:100%; flex:1 1 auto; min-height:0; overflow-y:auto;";
2114
2210
  const formWrapper = document.createElement("div");
2211
+ formWrapper.id = "dd-form-wrapper";
2115
2212
  formWrapper.style.cssText = "width:100%; flex: 1 1 auto;";
2116
2213
  const errorHint = document.createElement("div");
2214
+ errorHint.id = "dd-error";
2117
2215
  errorHint.className = "deepdots-error-hint";
2118
2216
  errorHint.style.cssText = `
2119
2217
  display: none;
@@ -2142,20 +2240,24 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2142
2240
  main.appendChild(formWrapper);
2143
2241
  main.appendChild(errorHint);
2144
2242
  const footer = document.createElement("div");
2243
+ footer.id = "dd-footer";
2145
2244
  footer.className = "deepdots-popup-footer";
2146
2245
  footer.setAttribute("data-actions-wrapper", "true");
2147
- footer.style.cssText = "display:flex; flex-direction: row-reverse ;justify-content:space-between; align-items:center; gap:8px; margin-top:auto; width:100%; padding-top:16px;";
2246
+ 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;";
2148
2247
  const backButton = document.createElement("button");
2248
+ backButton.id = "dd-back";
2249
+ backButton.className = "dd-nav-btn";
2149
2250
  backButton.textContent = actions?.back ? actions.back.label : "Back";
2150
2251
  backButton.style.cssText = `
2151
2252
  background: transparent;
2152
- color: #333;
2153
- border: 1px solid #999;
2253
+ color: ${theme.textMuted};
2254
+ border: none;
2255
+ min-height: 44px;
2154
2256
  padding: 12px 24px;
2155
- border-radius: 4px;
2257
+ border-radius: 6px;
2156
2258
  cursor: pointer;
2157
- font-size: 14px;
2158
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
2259
+ font-size: 15px;
2260
+ font-weight: 600;
2159
2261
  transition: filter .15s ease;
2160
2262
  display: inline-flex;
2161
2263
  align-items: center;
@@ -2173,15 +2275,19 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2173
2275
  formInstance?.back?.();
2174
2276
  };
2175
2277
  const startButton = document.createElement("button");
2278
+ startButton.id = "dd-start";
2279
+ startButton.className = "dd-nav-btn";
2176
2280
  startButton.textContent = actions?.start ? actions.start.label : "Start survey";
2177
2281
  startButton.style.cssText = `
2178
2282
  background: #1E293B;
2179
2283
  color: #fff;
2180
2284
  border: none;
2285
+ min-height: 44px;
2181
2286
  padding: 12px 24px;
2182
- border-radius: 4px;
2287
+ border-radius: 6px;
2183
2288
  cursor: pointer;
2184
- font-size: 14px;
2289
+ font-size: 15px;
2290
+ font-weight: 600;
2185
2291
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
2186
2292
  transition: filter .15s ease;
2187
2293
  display: inline-flex;
@@ -2192,17 +2298,23 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2192
2298
  startButton.onclick = () => {
2193
2299
  emit("popup_clicked", surveyId, { action: "start_survey" });
2194
2300
  formInstance?.startForm?.();
2301
+ onStartPage = false;
2302
+ updateProgress({ progress: formInstance?.progress, total: formInstance?.total });
2195
2303
  };
2196
2304
  const closeButton = document.createElement("button");
2305
+ closeButton.id = "dd-complete";
2306
+ closeButton.className = "dd-nav-btn";
2197
2307
  closeButton.textContent = actions?.complete ? actions.complete.label : "Complete survey";
2198
2308
  closeButton.style.cssText = `
2199
2309
  background: #1E293B;
2200
2310
  color: #fff;
2201
2311
  border: none;
2312
+ min-height: 44px;
2202
2313
  padding: 12px 24px;
2203
- border-radius: 4px;
2314
+ border-radius: 6px;
2204
2315
  cursor: pointer;
2205
- font-size: 14px;
2316
+ font-size: 15px;
2317
+ font-weight: 600;
2206
2318
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
2207
2319
  transition: filter .15s ease;
2208
2320
  display: inline-flex;
@@ -2221,15 +2333,19 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2221
2333
  onClose();
2222
2334
  };
2223
2335
  const submitButton = document.createElement("button");
2336
+ submitButton.id = "dd-submit";
2337
+ submitButton.className = "dd-nav-btn";
2224
2338
  submitButton.textContent = actions?.accept ? actions.accept.label : "Send";
2225
2339
  submitButton.style.cssText = `
2226
2340
  background: #1E293B;
2227
2341
  color: #fff;
2228
2342
  border: none;
2343
+ min-height: 44px;
2229
2344
  padding: 12px 24px;
2230
- border-radius: 4px;
2345
+ border-radius: 6px;
2231
2346
  cursor: pointer;
2232
- font-size: 14px;
2347
+ font-size: 15px;
2348
+ font-weight: 600;
2233
2349
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
2234
2350
  transition: filter .15s ease;
2235
2351
  display: inline-flex;
@@ -2251,8 +2367,9 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2251
2367
  footer.appendChild(backButton);
2252
2368
  footer.appendChild(closeButton);
2253
2369
  footer.appendChild(startButton);
2254
- main.appendChild(footer);
2255
2370
  containerContent.appendChild(main);
2371
+ footer.style.flex = "0 0 auto";
2372
+ containerContent.appendChild(footer);
2256
2373
  function updateButtons(state) {
2257
2374
  backButton.style.display = "none";
2258
2375
  startButton.style.display = "none";
@@ -2289,7 +2406,27 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2289
2406
  break;
2290
2407
  }
2291
2408
  }
2409
+ function updateNavButtons() {
2410
+ updateButtons(pageDepth > 0 ? "in_progress_next" : "in_progress_first");
2411
+ }
2412
+ let successMessageHtml = "";
2413
+ function showSuccessScreen() {
2414
+ progressEl.style.display = "none";
2415
+ formWrapper.style.display = "none";
2416
+ let done = main.querySelector(".deepdots-success");
2417
+ if (!done) {
2418
+ done = document.createElement("div");
2419
+ done.className = "deepdots-success";
2420
+ done.style.cssText = `width:100%; text-align:center; padding:24px 0; color:${theme.textPrimary};`;
2421
+ main.insertBefore(done, errorHint);
2422
+ }
2423
+ done.innerHTML = successMessageHtml || "<p>Thank you for your feedback!</p>";
2424
+ done.querySelectorAll("img").forEach((img) => {
2425
+ img.style.cssText = "max-width:100%; height:auto; margin:0 auto 16px auto; display:block;";
2426
+ });
2427
+ }
2292
2428
  popup.appendChild(header);
2429
+ popup.appendChild(progressEl);
2293
2430
  popup.appendChild(containerContent);
2294
2431
  container.innerHTML = "";
2295
2432
  container.appendChild(popup);
@@ -2335,15 +2472,27 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2335
2472
  formInstance = import_native.default.form(surveyId, productId, profile, metadata);
2336
2473
  const generateOptions = {
2337
2474
  addButton: false,
2338
- getMetaData: true
2475
+ getMetaData: true,
2476
+ // La pantalla final la pinta el popup: `renderSuccess` de @magicfeedback/native usa
2477
+ // textContent, así que el mensaje de la plataforma (HTML con imagen) no se vería, y
2478
+ // su fallback es un literal genérico que ignora `style.successMessage`.
2479
+ addSuccessScreen: false
2339
2480
  };
2340
2481
  generateOptions.onLoadedEvent = ({ formData }) => {
2341
2482
  try {
2342
- } catch (e) {
2483
+ } catch {
2343
2484
  }
2344
2485
  const s = formData?.style;
2345
2486
  if (s && !stylesInjected) {
2346
2487
  stylesInjected = true;
2488
+ if (s.successMessage) successMessageHtml = s.successMessage;
2489
+ if (options?.showProgressBar === void 0) progressEnabled = s.showProgressBar === true;
2490
+ if (s.showProgressUnit !== void 0) progressShowUnit = s.showProgressUnit !== false;
2491
+ if (s.progressUnit) progressUnit = s.progressUnit;
2492
+ if (s.loadingBarColor) {
2493
+ progressBar.style.background = s.loadingBarColor;
2494
+ progressFollowUp.style.background = s.loadingBarColor;
2495
+ }
2347
2496
  if (s.boxBackgroundColor) {
2348
2497
  popup.style.background = s.boxBackgroundColor;
2349
2498
  }
@@ -2362,9 +2511,9 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2362
2511
  closeButton.style.color = "#fff";
2363
2512
  }
2364
2513
  if (s.buttonSecondaryColor) {
2365
- backButton.style.background = "#fff";
2514
+ backButton.style.background = "transparent";
2366
2515
  backButton.style.color = s.buttonSecondaryColor;
2367
- backButton.style.border = `1px solid ${s.buttonSecondaryColor}`;
2516
+ backButton.style.border = "none";
2368
2517
  }
2369
2518
  if (s.logo) {
2370
2519
  if (!document.getElementById("deepdots-popup-logo")) {
@@ -2409,6 +2558,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2409
2558
  }
2410
2559
  if (s.startMessage && s.startMessage !== "") {
2411
2560
  sdkLog(s.startMessage);
2561
+ onStartPage = true;
2412
2562
  updateButtons("start");
2413
2563
  } else {
2414
2564
  updateButtons("in_progress_first");
@@ -2416,6 +2566,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2416
2566
  } else {
2417
2567
  updateButtons("in_progress_first");
2418
2568
  }
2569
+ updateProgress({ progress: formInstance.progress, total: formInstance.total });
2419
2570
  emit("popup_clicked", surveyId, { action: "loaded" });
2420
2571
  setLoading(false);
2421
2572
  };
@@ -2423,7 +2574,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2423
2574
  setLoading(true);
2424
2575
  emit("popup_clicked", surveyId, { action: "before_submit" });
2425
2576
  };
2426
- generateOptions.afterSubmitEvent = ({ error, completed, total, progress }) => {
2577
+ generateOptions.afterSubmitEvent = ({ error, completed, total, progress, followup }) => {
2427
2578
  const errText = error ? typeof error === "string" ? error : error.message ?? String(error) : "";
2428
2579
  if (errText) {
2429
2580
  setLoading(false);
@@ -2431,7 +2582,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2431
2582
  errorHint.textContent = "Please answer the required question to continue.";
2432
2583
  errorHint.style.display = "block";
2433
2584
  emit("popup_clicked", surveyId, { action: "validation_error_required" });
2434
- updateButtons("in_progress_next");
2585
+ updateNavButtons();
2435
2586
  return;
2436
2587
  }
2437
2588
  errorHint.textContent = "An error occurred while submitting. Please try again or close the popup.";
@@ -2444,23 +2595,21 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2444
2595
  if (completed) {
2445
2596
  emit("survey_completed", surveyId, { action: "completed" });
2446
2597
  surveyCompletedEmitted = true;
2598
+ showSuccessScreen();
2447
2599
  updateButtons("completed");
2600
+ updateProgress({ progress, total, completed: true });
2448
2601
  return;
2449
2602
  }
2450
2603
  emit("popup_clicked", surveyId, { action: "partial" });
2451
- if (total > 1 && progress > 0 && progress < total) {
2452
- updateButtons("in_progress_next");
2453
- } else {
2454
- updateButtons("in_progress_first");
2455
- }
2604
+ pageDepth++;
2605
+ updateNavButtons();
2606
+ updateProgress({ progress, total, followup });
2456
2607
  };
2457
- generateOptions.onBackEvent = ({ progress }) => {
2608
+ generateOptions.onBackEvent = ({ progress, error, followup }) => {
2458
2609
  emit("popup_clicked", surveyId, { action: "back" });
2459
- if (progress === 0) {
2460
- updateButtons("in_progress_first");
2461
- } else {
2462
- updateButtons("in_progress_next");
2463
- }
2610
+ if (!error) pageDepth = Math.max(0, pageDepth - 1);
2611
+ updateNavButtons();
2612
+ updateProgress({ progress, total: formInstance.total, followup });
2464
2613
  };
2465
2614
  formInstance.generate(formDivId, generateOptions).catch((err) => {
2466
2615
  sdkError("[MagicFeedback] Error generating form:", err);
@@ -2474,4 +2623,4 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2474
2623
  export {
2475
2624
  renderPopup
2476
2625
  };
2477
- //# sourceMappingURL=renderPopup-NJK7Z46E.mjs.map
2626
+ //# sourceMappingURL=renderPopup-PXJEND4Y.mjs.map