@magicfeedback/popup-sdk 1.0.11 → 1.0.13

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.
@@ -50,22 +50,16 @@
50
50
  }
51
51
 
52
52
  .magicfeedback-label {
53
- font-weight: 600;
54
- font-family: inherit;
55
- font-size: 1.1rem;
56
- color: #212529;
57
- text-align: start;
58
- word-wrap: break-word;
59
- white-space: normal;
60
- }
61
- .magicfeedback-sublabel{
53
+ margin-bottom: 25px;
54
+ margin-top: 20px;
62
55
  font-weight: 400;
63
56
  font-family: inherit;
64
- font-size: 1rem;
65
- color: #6c757d;
57
+ font-size: 1.2rem;
58
+ color: #212529;
66
59
  text-align: start;
67
60
  word-wrap: break-word;
68
61
  white-space: normal;
62
+
69
63
  }
70
64
 
71
65
  .magicfeedback-checkbox {
@@ -90,8 +84,8 @@
90
84
  justify-content: flex-start;
91
85
  flex-wrap: wrap;
92
86
  width: 100%;
93
- margin-top: 10px;
94
- gap: 10px;
87
+ margin-right: 5px;
88
+ padding: 5px;
95
89
  }
96
90
 
97
91
  .magicfeedback-checkbox-container,
@@ -100,12 +94,11 @@
100
94
  flex-direction: row;
101
95
  justify-content: flex-start;
102
96
  align-items: center;
103
- margin: 0 2px;
97
+ margin: 5px;
104
98
  padding: 5px 0;
105
99
  background-color: #fff;
106
100
  border-radius: 5px;
107
101
  box-shadow: 0 0 3px #ccc;
108
- width: calc(100% - 10px);
109
102
  }
110
103
 
111
104
  input::-webkit-outer-spin-button,
@@ -131,7 +124,7 @@ input::-webkit-inner-spin-button {
131
124
  font-size: 16px;
132
125
  color: #212529;
133
126
  text-align: start;
134
- width: auto;
127
+ width: 100%;
135
128
  }
136
129
 
137
130
  p {
@@ -165,7 +158,7 @@ textarea,
165
158
  select {
166
159
  box-sizing: border-box;
167
160
  padding: 10px;
168
- margin: 20px 0 10px 0;
161
+ margin: 10px 0;
169
162
  width: 100%;
170
163
  border: 2px solid #ccc; /* Default border color - you can customize this */
171
164
  border-radius: 5px;
@@ -409,7 +402,6 @@ input.error, select.error {
409
402
 
410
403
  margin: 15px 0;
411
404
  padding: 0;
412
- padding-top: 45px !important;
413
405
 
414
406
  list-style: none;
415
407
  font-size: 1.5rem;
@@ -420,6 +412,23 @@ input.error, select.error {
420
412
  -ms-user-select: none;
421
413
  }
422
414
 
415
+ /* Cuando hay placeholders (Very bad / Very good), el placeholder ocupa
416
+ el 100% de la primera línea y los boxes bajan a la siguiente */
417
+ .magicfeedback-rating-number-container--with-placeholder {
418
+ flex-wrap: wrap;
419
+ align-items: flex-start;
420
+ }
421
+
422
+ .magicfeedback-rating-number-container--with-placeholder .magicfeedback-rating-placeholder {
423
+ width: 100%;
424
+ margin-bottom: 8px;
425
+ }
426
+
427
+ .magicfeedback-rating-number-container--with-placeholder .magicfeedback-rating-number-option {
428
+ width: auto;
429
+ flex: 1;
430
+ }
431
+
423
432
  .magicfeedback-rating-number-option {
424
433
  display: flex;
425
434
  flex-direction: row;
@@ -538,7 +547,7 @@ input.error, select.error {
538
547
  .magicfeedback-rating-number-option {
539
548
  max-width: 100%;
540
549
  height: 55px;
541
- margin: 5px;
550
+ margin: 5px 0;
542
551
  }
543
552
  }
544
553
 
@@ -637,7 +646,7 @@ input.error, select.error {
637
646
  .magicfeedback-success-message,
638
647
  .magicfeedback-info-message,
639
648
  .magicfeedback-start-message {
640
- margin: 10px 5px;
649
+ margin: 35px 5px;
641
650
  }
642
651
 
643
652
  .magicfeedback-success-message p,
package/dist/index.d.mts CHANGED
@@ -31,12 +31,14 @@ interface DeepdotsConfig {
31
31
  * Options for configuring survey triggers
32
32
  */
33
33
  interface TriggerConfig {
34
- /** Trigger type: 'time' (delay), 'scroll' (scroll percentage), 'exit' (exit intent), 'click' (element id) */
35
- type: 'time' | 'scroll' | 'exit' | 'click';
36
- /** Value for the trigger (milliseconds for time, percentage for scroll, element id for click) */
34
+ /** Trigger type: 'time' (delay), 'scroll' (scroll percentage), 'exit' (route exit), 'click' (element id), 'event' (host event) */
35
+ type: 'time' | 'scroll' | 'exit' | 'click' | 'event';
36
+ /** Value for the trigger (milliseconds for time, percentage for scroll, seconds for exit, element id for click, event name for event) */
37
37
  value?: number | string;
38
38
  /** Survey ID to show when triggered */
39
39
  surveyId: string;
40
+ /** Optional popup definition id (used to disambiguate repeated survey ids) */
41
+ popupId?: string;
40
42
  }
41
43
  /**
42
44
  * Options for showing a popup
@@ -67,17 +69,18 @@ interface DeepdotsEvent {
67
69
  */
68
70
  type EventListener = (event: DeepdotsEvent) => void;
69
71
  /** Tipo de trigger específico para definiciones de popup remotas */
70
- type PopupTriggerType = 'time_on_page' | 'scroll' | 'exit' | 'click';
72
+ type PopupTriggerType = 'time_on_page' | 'scroll' | 'exit' | 'click' | 'event';
73
+ type PopupTriggerConditionStatus = 'SHOWED' | 'PARTIAL' | 'COMPLETED';
74
+ declare const POPUP_TRIGGER_CONDITION_STATUSES: PopupTriggerConditionStatus[];
71
75
  /** Condición adicional para la activación del popup */
72
76
  interface PopupTriggerCondition {
73
- answered: boolean;
77
+ answered: PopupTriggerConditionStatus;
74
78
  cooldownDays: number;
75
79
  }
76
80
  /** Trigger asociado a la definición del popup */
77
81
  interface PopupTrigger {
78
82
  type: PopupTriggerType;
79
83
  value: number | string;
80
- condition?: PopupTriggerCondition[];
81
84
  }
82
85
  /** Acción de aceptar (abrir encuesta) */
83
86
  interface PopupActionAccept {
@@ -125,7 +128,8 @@ interface PopupDefinition {
125
128
  id: string;
126
129
  title: string;
127
130
  message: string;
128
- triggers: PopupTrigger;
131
+ triggers: PopupTrigger[];
132
+ cooldown?: PopupTriggerCondition[];
129
133
  actions?: PopupActions;
130
134
  surveyId: string;
131
135
  productId: string;
@@ -137,7 +141,7 @@ interface PopupRenderer {
137
141
  /** Preparar recursos si aplica */
138
142
  init?(): void;
139
143
  /** Mostrar popup */
140
- show(surveyId: string, productId: string, actions: PopupActions | undefined, emit: (type: DeepdotsEventType, surveyId: string, data?: Record<string, unknown>) => void, onClose: () => void, env?: string): void;
144
+ show(surveyId: string, productId: string, actions: PopupActions | undefined, emit: (type: DeepdotsEventType, surveyId: string, data?: Record<string, unknown>) => void, onClose: () => void, env?: string, userId?: string): void;
141
145
  /** Ocultar popup */
142
146
  hide(): void;
143
147
  }
@@ -156,8 +160,10 @@ declare class DeepdotsPopups {
156
160
  private popupsLoaded;
157
161
  private pendingAutoLaunch;
158
162
  private answeredSurveys;
163
+ private surveyProgress;
159
164
  private lastShown;
160
165
  private surveyToPopupId;
166
+ private deferredExitTimers;
161
167
  private baseUrl;
162
168
  private env;
163
169
  /** Initialize the SDK with configuration */
@@ -179,12 +185,27 @@ declare class DeepdotsPopups {
179
185
  /** Deriva triggers desde las definiciones de popup */
180
186
  private configureTriggersFromDefinitions;
181
187
  /** Lógica para evaluar condiciones antes de mostrar una encuesta */
182
- triggerSurvey(surveyId: string): void;
188
+ triggerSurvey(surveyId: string, popupId?: string): void;
189
+ /** Trigger popups configured with trigger.type = 'event' and matching trigger.value */
190
+ triggerEvent(eventName: string): void;
191
+ private showDefinition;
183
192
  private shouldShow;
193
+ private matchesSegmentsLang;
184
194
  private matchesSegmentsPath;
185
- private evaluateCondition;
195
+ private evaluateCooldown;
196
+ private evaluateLegacyCondition;
197
+ private hasCooldownElapsed;
186
198
  /** Marcar encuesta como contestada externamente */
187
199
  markSurveyAnswered(surveyId: string): void;
200
+ /** Queue an exit popup so it can render after navigation */
201
+ queueExitPopup(surveyId: string, delaySeconds: number, sourceUrl?: string, popupId?: string): void;
202
+ private processDeferredExitQueue;
203
+ private scheduleDeferredExitPopup;
204
+ private tryShowDeferredExitPopup;
205
+ private findPopupDefinition;
206
+ private removeDeferredExitPopup;
207
+ private getDeferredExitQueue;
208
+ private setDeferredExitQueue;
188
209
  /** Fetch al servidor para obtener popups */
189
210
  private fetchPopupsFromServer;
190
211
  /** Notifica eventos de popup a la API */
@@ -207,9 +228,20 @@ declare class DeepdotsPopups {
207
228
  debug(...args: unknown[]): void;
208
229
  /** Set a custom renderer */
209
230
  setRenderer(renderer: PopupRenderer): void;
231
+ private normalizeUrl;
232
+ private safeParseUrl;
233
+ private mapPopupTriggerType;
234
+ private markSurveyProgress;
210
235
  private isPopupDefinition;
236
+ private isPopupTrigger;
237
+ private isPopupTriggerType;
238
+ private isPopupTriggerCondition;
239
+ private isLegacyPopupTriggerCondition;
240
+ private normalizeTriggers;
241
+ private normalizeCooldown;
242
+ private normalizeLegacyConditions;
211
243
  private normalizePopupDefinition;
212
244
  private validatePopupDefinitions;
213
245
  }
214
246
 
215
- export { type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, DeepdotsPopups, type EventListener, type ShowOptions, type TriggerConfig };
247
+ export { type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, DeepdotsPopups, type EventListener, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, type ShowOptions, type TriggerConfig };
package/dist/index.d.ts CHANGED
@@ -31,12 +31,14 @@ interface DeepdotsConfig {
31
31
  * Options for configuring survey triggers
32
32
  */
33
33
  interface TriggerConfig {
34
- /** Trigger type: 'time' (delay), 'scroll' (scroll percentage), 'exit' (exit intent), 'click' (element id) */
35
- type: 'time' | 'scroll' | 'exit' | 'click';
36
- /** Value for the trigger (milliseconds for time, percentage for scroll, element id for click) */
34
+ /** Trigger type: 'time' (delay), 'scroll' (scroll percentage), 'exit' (route exit), 'click' (element id), 'event' (host event) */
35
+ type: 'time' | 'scroll' | 'exit' | 'click' | 'event';
36
+ /** Value for the trigger (milliseconds for time, percentage for scroll, seconds for exit, element id for click, event name for event) */
37
37
  value?: number | string;
38
38
  /** Survey ID to show when triggered */
39
39
  surveyId: string;
40
+ /** Optional popup definition id (used to disambiguate repeated survey ids) */
41
+ popupId?: string;
40
42
  }
41
43
  /**
42
44
  * Options for showing a popup
@@ -67,17 +69,18 @@ interface DeepdotsEvent {
67
69
  */
68
70
  type EventListener = (event: DeepdotsEvent) => void;
69
71
  /** Tipo de trigger específico para definiciones de popup remotas */
70
- type PopupTriggerType = 'time_on_page' | 'scroll' | 'exit' | 'click';
72
+ type PopupTriggerType = 'time_on_page' | 'scroll' | 'exit' | 'click' | 'event';
73
+ type PopupTriggerConditionStatus = 'SHOWED' | 'PARTIAL' | 'COMPLETED';
74
+ declare const POPUP_TRIGGER_CONDITION_STATUSES: PopupTriggerConditionStatus[];
71
75
  /** Condición adicional para la activación del popup */
72
76
  interface PopupTriggerCondition {
73
- answered: boolean;
77
+ answered: PopupTriggerConditionStatus;
74
78
  cooldownDays: number;
75
79
  }
76
80
  /** Trigger asociado a la definición del popup */
77
81
  interface PopupTrigger {
78
82
  type: PopupTriggerType;
79
83
  value: number | string;
80
- condition?: PopupTriggerCondition[];
81
84
  }
82
85
  /** Acción de aceptar (abrir encuesta) */
83
86
  interface PopupActionAccept {
@@ -125,7 +128,8 @@ interface PopupDefinition {
125
128
  id: string;
126
129
  title: string;
127
130
  message: string;
128
- triggers: PopupTrigger;
131
+ triggers: PopupTrigger[];
132
+ cooldown?: PopupTriggerCondition[];
129
133
  actions?: PopupActions;
130
134
  surveyId: string;
131
135
  productId: string;
@@ -137,7 +141,7 @@ interface PopupRenderer {
137
141
  /** Preparar recursos si aplica */
138
142
  init?(): void;
139
143
  /** Mostrar popup */
140
- show(surveyId: string, productId: string, actions: PopupActions | undefined, emit: (type: DeepdotsEventType, surveyId: string, data?: Record<string, unknown>) => void, onClose: () => void, env?: string): void;
144
+ show(surveyId: string, productId: string, actions: PopupActions | undefined, emit: (type: DeepdotsEventType, surveyId: string, data?: Record<string, unknown>) => void, onClose: () => void, env?: string, userId?: string): void;
141
145
  /** Ocultar popup */
142
146
  hide(): void;
143
147
  }
@@ -156,8 +160,10 @@ declare class DeepdotsPopups {
156
160
  private popupsLoaded;
157
161
  private pendingAutoLaunch;
158
162
  private answeredSurveys;
163
+ private surveyProgress;
159
164
  private lastShown;
160
165
  private surveyToPopupId;
166
+ private deferredExitTimers;
161
167
  private baseUrl;
162
168
  private env;
163
169
  /** Initialize the SDK with configuration */
@@ -179,12 +185,27 @@ declare class DeepdotsPopups {
179
185
  /** Deriva triggers desde las definiciones de popup */
180
186
  private configureTriggersFromDefinitions;
181
187
  /** Lógica para evaluar condiciones antes de mostrar una encuesta */
182
- triggerSurvey(surveyId: string): void;
188
+ triggerSurvey(surveyId: string, popupId?: string): void;
189
+ /** Trigger popups configured with trigger.type = 'event' and matching trigger.value */
190
+ triggerEvent(eventName: string): void;
191
+ private showDefinition;
183
192
  private shouldShow;
193
+ private matchesSegmentsLang;
184
194
  private matchesSegmentsPath;
185
- private evaluateCondition;
195
+ private evaluateCooldown;
196
+ private evaluateLegacyCondition;
197
+ private hasCooldownElapsed;
186
198
  /** Marcar encuesta como contestada externamente */
187
199
  markSurveyAnswered(surveyId: string): void;
200
+ /** Queue an exit popup so it can render after navigation */
201
+ queueExitPopup(surveyId: string, delaySeconds: number, sourceUrl?: string, popupId?: string): void;
202
+ private processDeferredExitQueue;
203
+ private scheduleDeferredExitPopup;
204
+ private tryShowDeferredExitPopup;
205
+ private findPopupDefinition;
206
+ private removeDeferredExitPopup;
207
+ private getDeferredExitQueue;
208
+ private setDeferredExitQueue;
188
209
  /** Fetch al servidor para obtener popups */
189
210
  private fetchPopupsFromServer;
190
211
  /** Notifica eventos de popup a la API */
@@ -207,9 +228,20 @@ declare class DeepdotsPopups {
207
228
  debug(...args: unknown[]): void;
208
229
  /** Set a custom renderer */
209
230
  setRenderer(renderer: PopupRenderer): void;
231
+ private normalizeUrl;
232
+ private safeParseUrl;
233
+ private mapPopupTriggerType;
234
+ private markSurveyProgress;
210
235
  private isPopupDefinition;
236
+ private isPopupTrigger;
237
+ private isPopupTriggerType;
238
+ private isPopupTriggerCondition;
239
+ private isLegacyPopupTriggerCondition;
240
+ private normalizeTriggers;
241
+ private normalizeCooldown;
242
+ private normalizeLegacyConditions;
211
243
  private normalizePopupDefinition;
212
244
  private validatePopupDefinitions;
213
245
  }
214
246
 
215
- export { type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, DeepdotsPopups, type EventListener, type ShowOptions, type TriggerConfig };
247
+ export { type DeepdotsConfig, type DeepdotsEvent, type DeepdotsEventType, DeepdotsPopups, type EventListener, POPUP_TRIGGER_CONDITION_STATUSES, type PopupDefinition, type PopupTrigger, type PopupTriggerCondition, type PopupTriggerConditionStatus, type ShowOptions, type TriggerConfig };