@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.mjs
CHANGED
|
@@ -2873,9 +2873,26 @@ function ensureResponsiveStyles(_popup) {
|
|
|
2873
2873
|
`;
|
|
2874
2874
|
document.head.appendChild(style);
|
|
2875
2875
|
}
|
|
2876
|
-
async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId) {
|
|
2876
|
+
async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId, style) {
|
|
2877
2877
|
let surveyCompletedEmitted = false;
|
|
2878
2878
|
let stylesInjected = false;
|
|
2879
|
+
const isDark = style?.theme === "dark";
|
|
2880
|
+
const theme = {
|
|
2881
|
+
popupBg: isDark ? "#1e1e1e" : "#fff",
|
|
2882
|
+
textPrimary: isDark ? "#f0f0f0" : "#111",
|
|
2883
|
+
closeBtnHoverBg: isDark ? "rgba(255,255,255,0.10)" : "rgba(0,0,0,0.06)",
|
|
2884
|
+
closeBtnHoverColor: isDark ? "#fff" : "#000000"
|
|
2885
|
+
};
|
|
2886
|
+
const positionMap = {
|
|
2887
|
+
"center": { justifyContent: "center", alignItems: "center", background: "rgba(0,0,0,0.5)" },
|
|
2888
|
+
"bottom": { justifyContent: "center", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
2889
|
+
"bottom-right": { justifyContent: "flex-end", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
2890
|
+
"bottom-left": { justifyContent: "flex-start", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
2891
|
+
"top": { justifyContent: "center", alignItems: "flex-start", padding: "16px", background: "transparent" },
|
|
2892
|
+
"top-right": { justifyContent: "flex-end", alignItems: "flex-start", padding: "16px", background: "transparent" },
|
|
2893
|
+
"top-left": { justifyContent: "flex-start", alignItems: "flex-start", padding: "16px", background: "transparent" }
|
|
2894
|
+
};
|
|
2895
|
+
const pos = positionMap[style?.position ?? "center"] ?? positionMap["center"];
|
|
2879
2896
|
const popup = document.createElement("div");
|
|
2880
2897
|
popup.className = "deepdots-popup";
|
|
2881
2898
|
popup.style.cssText = `
|
|
@@ -2883,7 +2900,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
2883
2900
|
display: flex;
|
|
2884
2901
|
flex-direction: column;
|
|
2885
2902
|
justify-content: flex-start;
|
|
2886
|
-
background:
|
|
2903
|
+
background: ${theme.popupBg};
|
|
2887
2904
|
border-radius: 8px;
|
|
2888
2905
|
padding: 24px;
|
|
2889
2906
|
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
|
@@ -2912,18 +2929,18 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
2912
2929
|
justify-content:center;
|
|
2913
2930
|
border-radius: 8px;
|
|
2914
2931
|
cursor:pointer;
|
|
2915
|
-
color
|
|
2932
|
+
color:${theme.textPrimary};
|
|
2916
2933
|
padding:4px;
|
|
2917
2934
|
transition: color .15s ease, transform .15s ease, background .15s ease;
|
|
2918
2935
|
box-shadow: none !important;
|
|
2919
2936
|
`;
|
|
2920
2937
|
closeBtn.onmouseenter = () => {
|
|
2921
|
-
closeBtn.style.color =
|
|
2922
|
-
closeBtn.style.background =
|
|
2938
|
+
closeBtn.style.color = theme.closeBtnHoverColor;
|
|
2939
|
+
closeBtn.style.background = theme.closeBtnHoverBg;
|
|
2923
2940
|
closeBtn.style.transform = "scale(1.06)";
|
|
2924
2941
|
};
|
|
2925
2942
|
closeBtn.onmouseleave = () => {
|
|
2926
|
-
closeBtn.style.color =
|
|
2943
|
+
closeBtn.style.color = theme.textPrimary;
|
|
2927
2944
|
closeBtn.style.background = "transparent";
|
|
2928
2945
|
closeBtn.style.transform = "scale(1)";
|
|
2929
2946
|
};
|
|
@@ -3130,6 +3147,10 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
3130
3147
|
container.innerHTML = "";
|
|
3131
3148
|
container.appendChild(popup);
|
|
3132
3149
|
container.style.display = "flex";
|
|
3150
|
+
container.style.justifyContent = pos.justifyContent;
|
|
3151
|
+
container.style.alignItems = pos.alignItems;
|
|
3152
|
+
container.style.background = pos.background;
|
|
3153
|
+
if (pos.padding) container.style.padding = pos.padding;
|
|
3133
3154
|
function setLoading(isLoading) {
|
|
3134
3155
|
spinnerEl.style.display = isLoading ? "flex" : "none";
|
|
3135
3156
|
if (!isLoading) {
|
|
@@ -3559,12 +3580,12 @@ var BrowserPopupRenderer = class {
|
|
|
3559
3580
|
document.body.appendChild(this.container);
|
|
3560
3581
|
}
|
|
3561
3582
|
}
|
|
3562
|
-
show(surveyId, productId, actions, emit, onClose, env = "production", userId) {
|
|
3583
|
+
show(surveyId, productId, actions, emit, onClose, env = "production", userId, style) {
|
|
3563
3584
|
if (this.visible) return;
|
|
3564
3585
|
if (!this.container || !document.body.contains(this.container)) this.init();
|
|
3565
3586
|
if (!this.container) return;
|
|
3566
3587
|
this.visible = true;
|
|
3567
|
-
renderPopup(this.container, surveyId, productId, actions, emit, onClose, env, userId);
|
|
3588
|
+
renderPopup(this.container, surveyId, productId, actions, emit, onClose, env, userId, style);
|
|
3568
3589
|
}
|
|
3569
3590
|
hide() {
|
|
3570
3591
|
this.visible = false;
|
|
@@ -3674,7 +3695,7 @@ var DeepdotsPopups = class {
|
|
|
3674
3695
|
this.log("Showing popup (definition)", def);
|
|
3675
3696
|
this.surveyToPopupId.set(def.surveyId, def.id);
|
|
3676
3697
|
this.lastShown.set(def.id, Date.now());
|
|
3677
|
-
this.renderPopup(def.surveyId, def.productId, def.actions);
|
|
3698
|
+
this.renderPopup(def.surveyId, def.productId, def.actions, def.style);
|
|
3678
3699
|
this.emitEvent("popup_shown", def.surveyId, { popupId: def.id });
|
|
3679
3700
|
} else {
|
|
3680
3701
|
const opt = options;
|
|
@@ -4066,7 +4087,7 @@ var DeepdotsPopups = class {
|
|
|
4066
4087
|
document.body.appendChild(this.popupContainer);
|
|
4067
4088
|
}
|
|
4068
4089
|
/** Render the popup UI */
|
|
4069
|
-
renderPopup(surveyId, productId, actions) {
|
|
4090
|
+
renderPopup(surveyId, productId, actions, style) {
|
|
4070
4091
|
const userId = this.config?.userId;
|
|
4071
4092
|
if (this.renderer) {
|
|
4072
4093
|
this.renderer.show(
|
|
@@ -4076,7 +4097,8 @@ var DeepdotsPopups = class {
|
|
|
4076
4097
|
(type, id, payload) => this.emitEvent(type, id, payload),
|
|
4077
4098
|
() => this.hidePopup(),
|
|
4078
4099
|
this.env,
|
|
4079
|
-
userId
|
|
4100
|
+
userId,
|
|
4101
|
+
style
|
|
4080
4102
|
);
|
|
4081
4103
|
return;
|
|
4082
4104
|
}
|
|
@@ -4089,7 +4111,8 @@ var DeepdotsPopups = class {
|
|
|
4089
4111
|
(type, id, payload) => this.emitEvent(type, id, payload),
|
|
4090
4112
|
() => this.hidePopup(),
|
|
4091
4113
|
this.env,
|
|
4092
|
-
userId
|
|
4114
|
+
userId,
|
|
4115
|
+
style
|
|
4093
4116
|
);
|
|
4094
4117
|
}
|
|
4095
4118
|
/** Hide the popup */
|