@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.js CHANGED
@@ -1812,7 +1812,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
1812
1812
  closeBtn.type = "button";
1813
1813
  closeBtn.setAttribute("aria-label", "Close popup");
1814
1814
  closeBtn.innerHTML = `
1815
- <svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
1815
+ <svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1816
1816
  <path d="M6 6L18 18M6 18L18 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
1817
1817
  </svg>
1818
1818
  `;
@@ -1863,6 +1863,20 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
1863
1863
  main.style.cssText = "display:flex; flex-direction:column; width:100%; max-height:80vh; overflow-y:auto;";
1864
1864
  const formWrapper = document.createElement("div");
1865
1865
  formWrapper.style.cssText = "width:100%; flex: 1 1 auto;";
1866
+ const errorHint = document.createElement("div");
1867
+ errorHint.className = "deepdots-error-hint";
1868
+ errorHint.style.cssText = `
1869
+ display: none;
1870
+ margin: 12px 0 0 0;
1871
+ padding: 10px 12px;
1872
+ border-radius: 6px;
1873
+ background: #FEF3C7; /* amber-100 */
1874
+ color: #92400E; /* amber-700 */
1875
+ border: 1px solid #FCD34D; /* amber-300 */
1876
+ font-size: 13px;
1877
+ `;
1878
+ errorHint.setAttribute("role", "alert");
1879
+ errorHint.setAttribute("aria-live", "polite");
1866
1880
  const spinnerEl = document.createElement("div");
1867
1881
  spinnerEl.className = "mf-spinner";
1868
1882
  spinnerEl.setAttribute("role", "status");
@@ -1876,6 +1890,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
1876
1890
  formWrapper.appendChild(spinnerEl);
1877
1891
  formWrapper.appendChild(formHost);
1878
1892
  main.appendChild(formWrapper);
1893
+ main.appendChild(errorHint);
1879
1894
  const footer = document.createElement("div");
1880
1895
  footer.className = "deepdots-popup-footer";
1881
1896
  footer.setAttribute("data-actions-wrapper", "true");
@@ -2020,7 +2035,6 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2020
2035
  setLoading(false);
2021
2036
  break;
2022
2037
  case "error":
2023
- closeButton.style.display = "inline-flex";
2024
2038
  setLoading(false);
2025
2039
  break;
2026
2040
  }
@@ -2063,7 +2077,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2063
2077
  addButton: false,
2064
2078
  getMetaData: true
2065
2079
  };
2066
- generateOptions.onLoadedEvent = ({ formData, progress }) => {
2080
+ generateOptions.onLoadedEvent = ({ formData }) => {
2067
2081
  try {
2068
2082
  } catch (e) {
2069
2083
  }
@@ -2149,11 +2163,23 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2149
2163
  emit("popup_clicked", surveyId, { action: "before_submit" });
2150
2164
  };
2151
2165
  generateOptions.afterSubmitEvent = ({ error, completed, total, progress }) => {
2152
- if (error) {
2153
- emit("popup_clicked", surveyId, { action: "submit_error", error });
2154
- updateButtons("error");
2166
+ const errText = error ? typeof error === "string" ? error : error.message ?? String(error) : "";
2167
+ if (errText) {
2168
+ setLoading(false);
2169
+ if (errText.toLowerCase().includes("no response")) {
2170
+ errorHint.textContent = "Please answer the required question to continue.";
2171
+ errorHint.style.display = "block";
2172
+ emit("popup_clicked", surveyId, { action: "validation_error_required" });
2173
+ updateButtons("in_progress_next");
2174
+ return;
2175
+ }
2176
+ errorHint.textContent = "An error occurred while submitting. Please try again or close the popup.";
2177
+ errorHint.style.display = "block";
2178
+ emit("popup_clicked", surveyId, { action: "submit_error", error: errText });
2155
2179
  return;
2156
2180
  }
2181
+ errorHint.style.display = "none";
2182
+ setLoading(false);
2157
2183
  if (completed) {
2158
2184
  emit("survey_completed", surveyId, { action: "completed" });
2159
2185
  surveyCompletedEmitted = true;