@magicfeedback/popup-sdk 1.15.0 → 1.16.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/index.mjs CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  sdkWarn,
22
22
  setLogger,
23
23
  style_default
24
- } from "./chunk-C7VD3HY4.mjs";
24
+ } from "./chunk-AFRHPS3K.mjs";
25
25
 
26
26
  // src/types/index.ts
27
27
  var POPUP_TRIGGER_CONDITION_STATUSES = [
@@ -292,12 +292,14 @@ function buildSurveyHtml(opts) {
292
292
  const startLabel = jsonForScript(initActionLabels.start);
293
293
  const completeLabel = jsonForScript(initActionLabels.complete);
294
294
  const submitLabel = jsonForScript(initActionLabels.accept);
295
+ const cancelLabel = jsonForScript(initActionLabels.decline);
295
296
  const labelsTableJson = jsonForScript(LABELS);
296
297
  const actionOverridesJson = jsonForScript({
297
298
  accept: trimmedOrNull(opts.actions?.accept?.label),
298
299
  start: trimmedOrNull(opts.actions?.start?.label),
299
300
  complete: trimmedOrNull(opts.actions?.complete?.label),
300
- back: trimmedOrNull(opts.actions?.back?.label)
301
+ back: trimmedOrNull(opts.actions?.back?.label),
302
+ decline: trimmedOrNull(opts.actions?.decline?.label)
301
303
  });
302
304
  const initLangJson = jsonForScript(opts.language ?? "");
303
305
  const initDirection = directionFor(opts.language);
@@ -359,6 +361,7 @@ body.dd-ready #dd-popup{visibility:visible}
359
361
  #dd-logo{max-height:40px;max-width:100%;object-fit:contain;display:block;margin:12px 0 0 0}
360
362
  .deepdots-error-hint{display:none;margin:12px 0 0 0;padding:10px 12px;border-radius:6px;background:#FEF3C7;color:#92400E;border:1px solid #FCD34D;font-size:13px}
361
363
  /* Pantalla final: el HTML del editor de la plataforma (imagen + texto), centrado. */
364
+ .deepdots-load-error{display:none;width:100%;text-align:center;padding:24px 0;font-size:15px;color:${textPrimary}}
362
365
  .deepdots-success{display:none;width:100%;text-align:center;padding:24px 0;color:${textPrimary}}
363
366
  .deepdots-success img{max-width:100%;height:auto;margin:0 auto 16px auto;display:block}
364
367
  .deepdots-success p{margin:0;font-size:16px;font-weight:600;line-height:1.4}
@@ -366,7 +369,7 @@ body.dd-ready #dd-popup{visibility:visible}
366
369
  .dd-nav-btn{display:none;border:none;min-height:44px;padding:12px 24px;border-radius:999px;cursor:pointer;font-size:15px;font-weight:600;align-items:center;justify-content:center;text-align:center}
367
370
  /* Secundario como bot\xF3n de texto: sin borde ni fondo, para que el primario sea la \xFAnica CTA. */
368
371
  #dd-back{background:transparent;color:${textMuted};border:none}
369
- #dd-start,#dd-complete,#dd-submit{background:#1E293B;color:#fff;border:none}
372
+ #dd-start,#dd-complete,#dd-submit,#dd-cancel{background:#1E293B;color:#fff;border:none}
370
373
  #dd-submit:disabled,#dd-start:disabled,#dd-back:disabled,#dd-complete:disabled{opacity:0.6;cursor:not-allowed}
371
374
  .mf-spinner{display:none;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}
372
375
  .mf-spinner-circle{width:28px;height:28px;border:3px solid #e0e6ed;border-top-color:#1E293B;border-radius:50%;animation:ddspin 0.9s linear infinite}
@@ -407,6 +410,7 @@ ${customCss}
407
410
  <div class="mf-spinner" id="dd-spinner" role="status" aria-label="${initLabels.loadingAria}"><div class="mf-spinner-circle"></div></div>
408
411
  <div id="mf"></div>
409
412
  </div>
413
+ <div class="deepdots-load-error" id="dd-load-error" role="alert"></div>
410
414
  <div class="deepdots-error-hint" id="dd-error" role="alert" aria-live="polite"></div>
411
415
  </div>
412
416
  <div class="deepdots-popup-footer" id="dd-footer">
@@ -414,6 +418,7 @@ ${customCss}
414
418
  <button type="button" class="dd-nav-btn" id="dd-back"></button>
415
419
  <button type="button" class="dd-nav-btn" id="dd-complete"></button>
416
420
  <button type="button" class="dd-nav-btn" id="dd-start"></button>
421
+ <button type="button" class="dd-nav-btn" id="dd-cancel"></button>
417
422
  </div>
418
423
  </div>
419
424
  </div>
@@ -436,6 +441,8 @@ ${customCss}
436
441
  var startBtn=document.getElementById('dd-start');
437
442
  var completeBtn=document.getElementById('dd-complete');
438
443
  var submitBtn=document.getElementById('dd-submit');
444
+ var cancelBtn=document.getElementById('dd-cancel');
445
+ var loadErrorEl=document.getElementById('dd-load-error');
439
446
  var titleEl=document.getElementById('dd-title');
440
447
  var progressEl=document.getElementById('dd-progress');
441
448
  var progressLabel=document.getElementById('dd-progress-label');
@@ -465,6 +472,8 @@ ${customCss}
465
472
  startBtn.textContent=DD_ACTION_OVERRIDES.start||next.start;
466
473
  completeBtn.textContent=DD_ACTION_OVERRIDES.complete||next.complete;
467
474
  submitBtn.textContent=DD_ACTION_OVERRIDES.accept||next.accept;
475
+ cancelBtn.textContent=DD_ACTION_OVERRIDES.decline||next.decline;
476
+ loadErrorEl.textContent=next.errorLoad;
468
477
  if(closeEl){ closeEl.setAttribute('aria-label',next.closeAria); }
469
478
  if(spinner){ spinner.setAttribute('aria-label',next.loadingAria); }
470
479
  progressFollowUp.textContent=next.followUp;
@@ -519,6 +528,7 @@ ${customCss}
519
528
  startBtn.textContent=${startLabel};
520
529
  completeBtn.textContent=${completeLabel};
521
530
  submitBtn.textContent=${submitLabel};
531
+ cancelBtn.textContent=${cancelLabel};
522
532
 
523
533
  closeEl.onclick=function(){ emitJSON('popup_close'); };
524
534
  backBtn.onclick=function(){ if(window.DeepdotsForm && window.DeepdotsForm.back){ window.DeepdotsForm.back(); } };
@@ -530,6 +540,8 @@ ${customCss}
530
540
  }
531
541
  };
532
542
  completeBtn.onclick=function(){ emitJSON('popup_close'); };
543
+ // \xDAnica acci\xF3n del survey que no carga: cierra igual que la X.
544
+ cancelBtn.onclick=function(){ emitJSON('popup_close'); };
533
545
  var surveyCompletedEmitted=false;
534
546
  submitBtn.onclick=function(){
535
547
  if(surveyCompletedEmitted) return;
@@ -571,6 +583,7 @@ ${customCss}
571
583
  startBtn.style.display='none';
572
584
  submitBtn.style.display='none';
573
585
  completeBtn.style.display='none';
586
+ cancelBtn.style.display='none';
574
587
  backBtn.style.width='';
575
588
  startBtn.style.width='';
576
589
  submitBtn.style.width='';
@@ -586,6 +599,8 @@ ${customCss}
586
599
  } else if(state==='completed'){
587
600
  completeBtn.style.display='inline-flex';
588
601
  completeBtn.style.width='100%';
602
+ } else if(state==='load_error'){
603
+ cancelBtn.style.display='inline-flex';
589
604
  }
590
605
  }
591
606
 
@@ -632,6 +647,26 @@ ${REVEAL_JS}
632
647
  }
633
648
  setLoading(true);
634
649
 
650
+ // Survey que no ha cargado (406 de /info, sin red, bundle del CDN ca\xEDdo). Antes se emit\xEDa
651
+ // \`loaded\` y se pintaba un Send sobre un survey vac\xEDo. Espejo de KMP: aviso traducido, la X
652
+ // sigue, un \xFAnico Cancel, y se revela ya (manda \`ready\`): no hay nada m\xE1s que esperar.
653
+ // No es interacci\xF3n del usuario: el renderer no lo convierte en popup_clicked.
654
+ var ddLoadFailed=false;
655
+ function ddShowLoadError(name, reason){
656
+ if(ddLoadFailed){ return; }
657
+ ddLoadFailed=true;
658
+ var why=(reason && reason.message) ? reason.message : String(reason);
659
+ emitJSON(name, { message: why });
660
+ progressEl.style.display='none';
661
+ formWrapper.style.display='none';
662
+ errorHint.style.display='none';
663
+ loadErrorEl.textContent=DD_LABELS_ACTIVE.errorLoad;
664
+ loadErrorEl.style.display='block';
665
+ setLoading(false);
666
+ updateButtons('load_error');
667
+ ddReveal.reveal();
668
+ }
669
+
635
670
  var initialized=false;
636
671
  function initMF(){
637
672
  if(initialized || !window.magicfeedback) return initialized;
@@ -655,6 +690,7 @@ ${REVEAL_JS}
655
690
  // de native sin esta opci\xF3n la ignoran.
656
691
  autofocus:'navigation',
657
692
  onLoadedEvent:function(args){
693
+ if(args && args.error){ ddShowLoadError('error:load', args.error); return; }
658
694
  // Idioma en el que native muestra el survey: manda sobre el del init para que el
659
695
  // chrome no se quede en ingl\xE9s delante de un survey traducido. Native < 2.3 no lo
660
696
  // env\xEDa: entonces el primero de formData.lang (el idioma por defecto).
@@ -758,13 +794,13 @@ ${REVEAL_JS}
758
794
  updateProgress({ progress:p&&p.progress, total:form.total, completed:false, followup:p&&p.followup });
759
795
  emitJSON('back', p);
760
796
  }
761
- }).catch(function(e){ setLoading(false); emit('error:init'); });
762
- }catch(e){ setLoading(false); emit('error:exception'); }
797
+ }).catch(function(e){ ddShowLoadError('error:init', e); });
798
+ }catch(e){ ddShowLoadError('error:exception', e); }
763
799
  return true;
764
800
  }
765
801
  var s=document.createElement('script'); s.src=${JSON.stringify(cdn)}; s.async=true;
766
802
  s.onload=function(){ initMF(); };
767
- s.onerror=function(){ setLoading(false); emit('error:load'); };
803
+ s.onerror=function(){ ddShowLoadError('error:load', 'survey script failed to load'); };
768
804
  document.head.appendChild(s);
769
805
  var tries=0, t=setInterval(function(){ if(initMF()||++tries>40){ clearInterval(t); } },150);
770
806
  })();
@@ -881,6 +917,7 @@ var ReactNativePopupRenderer = class {
881
917
  this.onCloseFn?.();
882
918
  break;
883
919
  default:
920
+ if (typeof name === "string" && name.startsWith("error:")) this.emitReady(surveyId);
884
921
  break;
885
922
  }
886
923
  }
@@ -893,7 +930,7 @@ function createReactNativeRenderer() {
893
930
  }
894
931
 
895
932
  // src/ui/preload.ts
896
- var defaultLoader = () => import("./renderPopup-CHWH3KHR.mjs");
933
+ var defaultLoader = () => import("./renderPopup-YCAQ3ODC.mjs");
897
934
  var pending = null;
898
935
  function preloadRenderPopup(loader = defaultLoader) {
899
936
  if (pending) return pending;
@@ -966,7 +1003,7 @@ var BrowserPopupRenderer = class {
966
1003
  if (!this.container) return;
967
1004
  this.visible = true;
968
1005
  const container = this.container;
969
- void import("./renderPopup-CHWH3KHR.mjs").then(({ renderPopup }) => {
1006
+ void import("./renderPopup-YCAQ3ODC.mjs").then(({ renderPopup }) => {
970
1007
  renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId, options);
971
1008
  });
972
1009
  }