@magicfeedback/popup-sdk 1.0.13 → 1.0.15

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.
@@ -101,8 +101,8 @@
101
101
  box-shadow: 0 0 3px #ccc;
102
102
  }
103
103
 
104
- input::-webkit-outer-spin-button,
105
- input::-webkit-inner-spin-button {
104
+ .deepdots-popup input::-webkit-outer-spin-button,
105
+ .deepdots-popup input::-webkit-inner-spin-button {
106
106
  -webkit-appearance: none;
107
107
  -moz-appearance: textfield;
108
108
  }
@@ -127,12 +127,12 @@ input::-webkit-inner-spin-button {
127
127
  width: 100%;
128
128
  }
129
129
 
130
- p {
130
+ .deepdots-popup p {
131
131
  margin-bottom: 0px;
132
132
  font-size: 12px;
133
133
  }
134
134
 
135
- h2 {
135
+ .deepdots-popup h2 {
136
136
  line-height: 1.66;
137
137
  margin: 0;
138
138
  padding: 0;
@@ -145,17 +145,17 @@ h2 {
145
145
  margin-bottom: 40px;
146
146
  }
147
147
 
148
- h6 {
148
+ .deepdots-popup h6 {
149
149
  margin-bottom: 1rem;
150
150
  }
151
151
 
152
- input[type="date"],
153
- input[type="text"],
154
- input[type="number"],
155
- input[type="email"],
156
- input[type="password"],
157
- textarea,
158
- select {
152
+ .deepdots-popup input[type="date"],
153
+ .deepdots-popup input[type="text"],
154
+ .deepdots-popup input[type="number"],
155
+ .deepdots-popup input[type="email"],
156
+ .deepdots-popup input[type="password"],
157
+ .deepdots-popup textarea,
158
+ .deepdots-popup select {
159
159
  box-sizing: border-box;
160
160
  padding: 10px;
161
161
  margin: 10px 0;
@@ -170,7 +170,7 @@ select {
170
170
  -webkit-appearance: none;
171
171
  }
172
172
 
173
- select {
173
+ .deepdots-popup select {
174
174
  background-image: linear-gradient(45deg, transparent 50%, gray 50%),
175
175
  linear-gradient(135deg, gray 50%, transparent 50%),
176
176
  linear-gradient(to right, #ccc, #ccc);
@@ -233,7 +233,7 @@ select {
233
233
  background-color: #cadff8;
234
234
  }
235
235
 
236
- input[type="radio"] {
236
+ .deepdots-popup input[type="radio"] {
237
237
  padding: 20px;
238
238
  margin: 10px 0 10px 15px;
239
239
  width: 40px;
@@ -242,12 +242,12 @@ input[type="radio"] {
242
242
  }
243
243
 
244
244
  /* Style for focused input/select */
245
- input:focus, select:focus {
245
+ .deepdots-popup input:focus, .deepdots-popup select:focus {
246
246
  border-color: #4CAF50; /* Highlight color when focused - you can customize this */
247
247
  }
248
248
 
249
249
  /* Style for invalid input (example: validation error) */
250
- input.error, select.error {
250
+ .deepdots-popup input.error, .deepdots-popup select.error {
251
251
  border-color: #ff3333; /* Red color for error state - you can customize this */
252
252
  }
253
253
 
package/dist/index.d.mts CHANGED
@@ -114,8 +114,9 @@ interface PopupActions {
114
114
  /** Estilos configurables del popup */
115
115
  interface PopupStyle {
116
116
  theme: 'light' | 'dark';
117
- position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'center';
118
- imageUrl: string | null;
117
+ position: 'bottom' | 'bottom-right' | 'bottom-left' | 'top' | 'top-right' | 'top-left' | 'center';
118
+ /** @deprecated No usado por el SDK — solo se conserva por compatibilidad con la API */
119
+ imageUrl?: string | null;
119
120
  }
120
121
  /** Segmentos o targeting para mostrar el popup */
121
122
  interface PopupSegments {
@@ -141,7 +142,7 @@ interface PopupRenderer {
141
142
  /** Preparar recursos si aplica */
142
143
  init?(): void;
143
144
  /** Mostrar popup */
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;
145
+ show(surveyId: string, productId: string, actions: PopupActions | undefined, emit: (type: DeepdotsEventType, surveyId: string, data?: Record<string, unknown>) => void, onClose: () => void, env?: string, userId?: string, style?: PopupStyle): void;
145
146
  /** Ocultar popup */
146
147
  hide(): void;
147
148
  }
package/dist/index.d.ts CHANGED
@@ -114,8 +114,9 @@ interface PopupActions {
114
114
  /** Estilos configurables del popup */
115
115
  interface PopupStyle {
116
116
  theme: 'light' | 'dark';
117
- position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'center';
118
- imageUrl: string | null;
117
+ position: 'bottom' | 'bottom-right' | 'bottom-left' | 'top' | 'top-right' | 'top-left' | 'center';
118
+ /** @deprecated No usado por el SDK — solo se conserva por compatibilidad con la API */
119
+ imageUrl?: string | null;
119
120
  }
120
121
  /** Segmentos o targeting para mostrar el popup */
121
122
  interface PopupSegments {
@@ -141,7 +142,7 @@ interface PopupRenderer {
141
142
  /** Preparar recursos si aplica */
142
143
  init?(): void;
143
144
  /** Mostrar popup */
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;
145
+ show(surveyId: string, productId: string, actions: PopupActions | undefined, emit: (type: DeepdotsEventType, surveyId: string, data?: Record<string, unknown>) => void, onClose: () => void, env?: string, userId?: string, style?: PopupStyle): void;
145
146
  /** Ocultar popup */
146
147
  hide(): void;
147
148
  }
package/dist/index.js CHANGED
@@ -2077,8 +2077,8 @@ var style_default = `.magicfeedback-container {
2077
2077
  box-shadow: 0 0 3px #ccc;
2078
2078
  }
2079
2079
 
2080
- input::-webkit-outer-spin-button,
2081
- input::-webkit-inner-spin-button {
2080
+ .deepdots-popup input::-webkit-outer-spin-button,
2081
+ .deepdots-popup input::-webkit-inner-spin-button {
2082
2082
  -webkit-appearance: none;
2083
2083
  -moz-appearance: textfield;
2084
2084
  }
@@ -2103,12 +2103,12 @@ input::-webkit-inner-spin-button {
2103
2103
  width: 100%;
2104
2104
  }
2105
2105
 
2106
- p {
2106
+ .deepdots-popup p {
2107
2107
  margin-bottom: 0px;
2108
2108
  font-size: 12px;
2109
2109
  }
2110
2110
 
2111
- h2 {
2111
+ .deepdots-popup h2 {
2112
2112
  line-height: 1.66;
2113
2113
  margin: 0;
2114
2114
  padding: 0;
@@ -2121,17 +2121,17 @@ h2 {
2121
2121
  margin-bottom: 40px;
2122
2122
  }
2123
2123
 
2124
- h6 {
2124
+ .deepdots-popup h6 {
2125
2125
  margin-bottom: 1rem;
2126
2126
  }
2127
2127
 
2128
- input[type="date"],
2129
- input[type="text"],
2130
- input[type="number"],
2131
- input[type="email"],
2132
- input[type="password"],
2133
- textarea,
2134
- select {
2128
+ .deepdots-popup input[type="date"],
2129
+ .deepdots-popup input[type="text"],
2130
+ .deepdots-popup input[type="number"],
2131
+ .deepdots-popup input[type="email"],
2132
+ .deepdots-popup input[type="password"],
2133
+ .deepdots-popup textarea,
2134
+ .deepdots-popup select {
2135
2135
  box-sizing: border-box;
2136
2136
  padding: 10px;
2137
2137
  margin: 10px 0;
@@ -2146,7 +2146,7 @@ select {
2146
2146
  -webkit-appearance: none;
2147
2147
  }
2148
2148
 
2149
- select {
2149
+ .deepdots-popup select {
2150
2150
  background-image: linear-gradient(45deg, transparent 50%, gray 50%),
2151
2151
  linear-gradient(135deg, gray 50%, transparent 50%),
2152
2152
  linear-gradient(to right, #ccc, #ccc);
@@ -2209,7 +2209,7 @@ select {
2209
2209
  background-color: #cadff8;
2210
2210
  }
2211
2211
 
2212
- input[type="radio"] {
2212
+ .deepdots-popup input[type="radio"] {
2213
2213
  padding: 20px;
2214
2214
  margin: 10px 0 10px 15px;
2215
2215
  width: 40px;
@@ -2218,12 +2218,12 @@ input[type="radio"] {
2218
2218
  }
2219
2219
 
2220
2220
  /* Style for focused input/select */
2221
- input:focus, select:focus {
2221
+ .deepdots-popup input:focus, .deepdots-popup select:focus {
2222
2222
  border-color: #4CAF50; /* Highlight color when focused - you can customize this */
2223
2223
  }
2224
2224
 
2225
2225
  /* Style for invalid input (example: validation error) */
2226
- input.error, select.error {
2226
+ .deepdots-popup input.error, .deepdots-popup select.error {
2227
2227
  border-color: #ff3333; /* Red color for error state - you can customize this */
2228
2228
  }
2229
2229
 
@@ -2887,9 +2887,26 @@ function ensureResponsiveStyles(_popup) {
2887
2887
  `;
2888
2888
  document.head.appendChild(style);
2889
2889
  }
2890
- async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId) {
2890
+ async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId, style) {
2891
2891
  let surveyCompletedEmitted = false;
2892
2892
  let stylesInjected = false;
2893
+ const isDark = style?.theme === "dark";
2894
+ const theme = {
2895
+ popupBg: isDark ? "#1e1e1e" : "#fff",
2896
+ textPrimary: isDark ? "#f0f0f0" : "#111",
2897
+ closeBtnHoverBg: isDark ? "rgba(255,255,255,0.10)" : "rgba(0,0,0,0.06)",
2898
+ closeBtnHoverColor: isDark ? "#fff" : "#000000"
2899
+ };
2900
+ const positionMap = {
2901
+ "center": { justifyContent: "center", alignItems: "center", background: "rgba(0,0,0,0.5)" },
2902
+ "bottom": { justifyContent: "center", alignItems: "flex-end", padding: "16px", background: "transparent" },
2903
+ "bottom-right": { justifyContent: "flex-end", alignItems: "flex-end", padding: "16px", background: "transparent" },
2904
+ "bottom-left": { justifyContent: "flex-start", alignItems: "flex-end", padding: "16px", background: "transparent" },
2905
+ "top": { justifyContent: "center", alignItems: "flex-start", padding: "16px", background: "transparent" },
2906
+ "top-right": { justifyContent: "flex-end", alignItems: "flex-start", padding: "16px", background: "transparent" },
2907
+ "top-left": { justifyContent: "flex-start", alignItems: "flex-start", padding: "16px", background: "transparent" }
2908
+ };
2909
+ const pos = positionMap[style?.position ?? "center"] ?? positionMap["center"];
2893
2910
  const popup = document.createElement("div");
2894
2911
  popup.className = "deepdots-popup";
2895
2912
  popup.style.cssText = `
@@ -2897,7 +2914,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2897
2914
  display: flex;
2898
2915
  flex-direction: column;
2899
2916
  justify-content: flex-start;
2900
- background: #fff;
2917
+ background: ${theme.popupBg};
2901
2918
  border-radius: 8px;
2902
2919
  padding: 24px;
2903
2920
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
@@ -2926,18 +2943,18 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2926
2943
  justify-content:center;
2927
2944
  border-radius: 8px;
2928
2945
  cursor:pointer;
2929
- color:#111;
2946
+ color:${theme.textPrimary};
2930
2947
  padding:4px;
2931
2948
  transition: color .15s ease, transform .15s ease, background .15s ease;
2932
2949
  box-shadow: none !important;
2933
2950
  `;
2934
2951
  closeBtn.onmouseenter = () => {
2935
- closeBtn.style.color = "#000000";
2936
- closeBtn.style.background = "rgba(0,0,0,0.06)";
2952
+ closeBtn.style.color = theme.closeBtnHoverColor;
2953
+ closeBtn.style.background = theme.closeBtnHoverBg;
2937
2954
  closeBtn.style.transform = "scale(1.06)";
2938
2955
  };
2939
2956
  closeBtn.onmouseleave = () => {
2940
- closeBtn.style.color = "#111";
2957
+ closeBtn.style.color = theme.textPrimary;
2941
2958
  closeBtn.style.background = "transparent";
2942
2959
  closeBtn.style.transform = "scale(1)";
2943
2960
  };
@@ -3144,6 +3161,10 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
3144
3161
  container.innerHTML = "";
3145
3162
  container.appendChild(popup);
3146
3163
  container.style.display = "flex";
3164
+ container.style.justifyContent = pos.justifyContent;
3165
+ container.style.alignItems = pos.alignItems;
3166
+ container.style.background = pos.background;
3167
+ if (pos.padding) container.style.padding = pos.padding;
3147
3168
  function setLoading(isLoading) {
3148
3169
  spinnerEl.style.display = isLoading ? "flex" : "none";
3149
3170
  if (!isLoading) {
@@ -3573,12 +3594,12 @@ var BrowserPopupRenderer = class {
3573
3594
  document.body.appendChild(this.container);
3574
3595
  }
3575
3596
  }
3576
- show(surveyId, productId, actions, emit, onClose, env = "production", userId) {
3597
+ show(surveyId, productId, actions, emit, onClose, env = "production", userId, style) {
3577
3598
  if (this.visible) return;
3578
3599
  if (!this.container || !document.body.contains(this.container)) this.init();
3579
3600
  if (!this.container) return;
3580
3601
  this.visible = true;
3581
- renderPopup(this.container, surveyId, productId, actions, emit, onClose, env, userId);
3602
+ renderPopup(this.container, surveyId, productId, actions, emit, onClose, env, userId, style);
3582
3603
  }
3583
3604
  hide() {
3584
3605
  this.visible = false;
@@ -3688,7 +3709,7 @@ var DeepdotsPopups = class {
3688
3709
  this.log("Showing popup (definition)", def);
3689
3710
  this.surveyToPopupId.set(def.surveyId, def.id);
3690
3711
  this.lastShown.set(def.id, Date.now());
3691
- this.renderPopup(def.surveyId, def.productId, def.actions);
3712
+ this.renderPopup(def.surveyId, def.productId, def.actions, def.style);
3692
3713
  this.emitEvent("popup_shown", def.surveyId, { popupId: def.id });
3693
3714
  } else {
3694
3715
  const opt = options;
@@ -4080,7 +4101,7 @@ var DeepdotsPopups = class {
4080
4101
  document.body.appendChild(this.popupContainer);
4081
4102
  }
4082
4103
  /** Render the popup UI */
4083
- renderPopup(surveyId, productId, actions) {
4104
+ renderPopup(surveyId, productId, actions, style) {
4084
4105
  const userId = this.config?.userId;
4085
4106
  if (this.renderer) {
4086
4107
  this.renderer.show(
@@ -4090,7 +4111,8 @@ var DeepdotsPopups = class {
4090
4111
  (type, id, payload) => this.emitEvent(type, id, payload),
4091
4112
  () => this.hidePopup(),
4092
4113
  this.env,
4093
- userId
4114
+ userId,
4115
+ style
4094
4116
  );
4095
4117
  return;
4096
4118
  }
@@ -4103,7 +4125,8 @@ var DeepdotsPopups = class {
4103
4125
  (type, id, payload) => this.emitEvent(type, id, payload),
4104
4126
  () => this.hidePopup(),
4105
4127
  this.env,
4106
- userId
4128
+ userId,
4129
+ style
4107
4130
  );
4108
4131
  }
4109
4132
  /** Hide the popup */