@magicfeedback/popup-sdk 1.0.9 → 1.0.10

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/index.mjs CHANGED
@@ -1799,7 +1799,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
1799
1799
  closeBtn.type = "button";
1800
1800
  closeBtn.setAttribute("aria-label", "Close popup");
1801
1801
  closeBtn.innerHTML = `
1802
- <svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
1802
+ <svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1803
1803
  <path d="M6 6L18 18M6 18L18 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
1804
1804
  </svg>
1805
1805
  `;
@@ -1850,6 +1850,20 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
1850
1850
  main.style.cssText = "display:flex; flex-direction:column; width:100%; max-height:80vh; overflow-y:auto;";
1851
1851
  const formWrapper = document.createElement("div");
1852
1852
  formWrapper.style.cssText = "width:100%; flex: 1 1 auto;";
1853
+ const errorHint = document.createElement("div");
1854
+ errorHint.className = "deepdots-error-hint";
1855
+ errorHint.style.cssText = `
1856
+ display: none;
1857
+ margin: 12px 0 0 0;
1858
+ padding: 10px 12px;
1859
+ border-radius: 6px;
1860
+ background: #FEF3C7; /* amber-100 */
1861
+ color: #92400E; /* amber-700 */
1862
+ border: 1px solid #FCD34D; /* amber-300 */
1863
+ font-size: 13px;
1864
+ `;
1865
+ errorHint.setAttribute("role", "alert");
1866
+ errorHint.setAttribute("aria-live", "polite");
1853
1867
  const spinnerEl = document.createElement("div");
1854
1868
  spinnerEl.className = "mf-spinner";
1855
1869
  spinnerEl.setAttribute("role", "status");
@@ -1863,6 +1877,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
1863
1877
  formWrapper.appendChild(spinnerEl);
1864
1878
  formWrapper.appendChild(formHost);
1865
1879
  main.appendChild(formWrapper);
1880
+ main.appendChild(errorHint);
1866
1881
  const footer = document.createElement("div");
1867
1882
  footer.className = "deepdots-popup-footer";
1868
1883
  footer.setAttribute("data-actions-wrapper", "true");
@@ -2007,7 +2022,6 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2007
2022
  setLoading(false);
2008
2023
  break;
2009
2024
  case "error":
2010
- closeButton.style.display = "inline-flex";
2011
2025
  setLoading(false);
2012
2026
  break;
2013
2027
  }
@@ -2050,7 +2064,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2050
2064
  addButton: false,
2051
2065
  getMetaData: true
2052
2066
  };
2053
- generateOptions.onLoadedEvent = ({ formData, progress }) => {
2067
+ generateOptions.onLoadedEvent = ({ formData }) => {
2054
2068
  try {
2055
2069
  } catch (e) {
2056
2070
  }
@@ -2136,11 +2150,23 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2136
2150
  emit("popup_clicked", surveyId, { action: "before_submit" });
2137
2151
  };
2138
2152
  generateOptions.afterSubmitEvent = ({ error, completed, total, progress }) => {
2139
- if (error) {
2140
- emit("popup_clicked", surveyId, { action: "submit_error", error });
2141
- updateButtons("error");
2153
+ const errText = error ? typeof error === "string" ? error : error.message ?? String(error) : "";
2154
+ if (errText) {
2155
+ setLoading(false);
2156
+ if (errText.toLowerCase().includes("no response")) {
2157
+ errorHint.textContent = "Please answer the required question to continue.";
2158
+ errorHint.style.display = "block";
2159
+ emit("popup_clicked", surveyId, { action: "validation_error_required" });
2160
+ updateButtons("in_progress_next");
2161
+ return;
2162
+ }
2163
+ errorHint.textContent = "An error occurred while submitting. Please try again or close the popup.";
2164
+ errorHint.style.display = "block";
2165
+ emit("popup_clicked", surveyId, { action: "submit_error", error: errText });
2142
2166
  return;
2143
2167
  }
2168
+ errorHint.style.display = "none";
2169
+ setLoading(false);
2144
2170
  if (completed) {
2145
2171
  emit("survey_completed", surveyId, { action: "completed" });
2146
2172
  surveyCompletedEmitted = true;