@magicfeedback/popup-sdk 1.0.13 → 1.0.14
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.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +35 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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
|
-
|
|
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
|
-
|
|
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
|
@@ -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:
|
|
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
|
|
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 =
|
|
2936
|
-
closeBtn.style.background =
|
|
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 =
|
|
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 */
|