@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.
- package/dist/assets/assets/style.css +16 -16
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +51 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2063,8 +2063,8 @@ var style_default = `.magicfeedback-container {
|
|
|
2063
2063
|
box-shadow: 0 0 3px #ccc;
|
|
2064
2064
|
}
|
|
2065
2065
|
|
|
2066
|
-
input::-webkit-outer-spin-button,
|
|
2067
|
-
input::-webkit-inner-spin-button {
|
|
2066
|
+
.deepdots-popup input::-webkit-outer-spin-button,
|
|
2067
|
+
.deepdots-popup input::-webkit-inner-spin-button {
|
|
2068
2068
|
-webkit-appearance: none;
|
|
2069
2069
|
-moz-appearance: textfield;
|
|
2070
2070
|
}
|
|
@@ -2089,12 +2089,12 @@ input::-webkit-inner-spin-button {
|
|
|
2089
2089
|
width: 100%;
|
|
2090
2090
|
}
|
|
2091
2091
|
|
|
2092
|
-
p {
|
|
2092
|
+
.deepdots-popup p {
|
|
2093
2093
|
margin-bottom: 0px;
|
|
2094
2094
|
font-size: 12px;
|
|
2095
2095
|
}
|
|
2096
2096
|
|
|
2097
|
-
h2 {
|
|
2097
|
+
.deepdots-popup h2 {
|
|
2098
2098
|
line-height: 1.66;
|
|
2099
2099
|
margin: 0;
|
|
2100
2100
|
padding: 0;
|
|
@@ -2107,17 +2107,17 @@ h2 {
|
|
|
2107
2107
|
margin-bottom: 40px;
|
|
2108
2108
|
}
|
|
2109
2109
|
|
|
2110
|
-
h6 {
|
|
2110
|
+
.deepdots-popup h6 {
|
|
2111
2111
|
margin-bottom: 1rem;
|
|
2112
2112
|
}
|
|
2113
2113
|
|
|
2114
|
-
input[type="date"],
|
|
2115
|
-
input[type="text"],
|
|
2116
|
-
input[type="number"],
|
|
2117
|
-
input[type="email"],
|
|
2118
|
-
input[type="password"],
|
|
2119
|
-
textarea,
|
|
2120
|
-
select {
|
|
2114
|
+
.deepdots-popup input[type="date"],
|
|
2115
|
+
.deepdots-popup input[type="text"],
|
|
2116
|
+
.deepdots-popup input[type="number"],
|
|
2117
|
+
.deepdots-popup input[type="email"],
|
|
2118
|
+
.deepdots-popup input[type="password"],
|
|
2119
|
+
.deepdots-popup textarea,
|
|
2120
|
+
.deepdots-popup select {
|
|
2121
2121
|
box-sizing: border-box;
|
|
2122
2122
|
padding: 10px;
|
|
2123
2123
|
margin: 10px 0;
|
|
@@ -2132,7 +2132,7 @@ select {
|
|
|
2132
2132
|
-webkit-appearance: none;
|
|
2133
2133
|
}
|
|
2134
2134
|
|
|
2135
|
-
select {
|
|
2135
|
+
.deepdots-popup select {
|
|
2136
2136
|
background-image: linear-gradient(45deg, transparent 50%, gray 50%),
|
|
2137
2137
|
linear-gradient(135deg, gray 50%, transparent 50%),
|
|
2138
2138
|
linear-gradient(to right, #ccc, #ccc);
|
|
@@ -2195,7 +2195,7 @@ select {
|
|
|
2195
2195
|
background-color: #cadff8;
|
|
2196
2196
|
}
|
|
2197
2197
|
|
|
2198
|
-
input[type="radio"] {
|
|
2198
|
+
.deepdots-popup input[type="radio"] {
|
|
2199
2199
|
padding: 20px;
|
|
2200
2200
|
margin: 10px 0 10px 15px;
|
|
2201
2201
|
width: 40px;
|
|
@@ -2204,12 +2204,12 @@ input[type="radio"] {
|
|
|
2204
2204
|
}
|
|
2205
2205
|
|
|
2206
2206
|
/* Style for focused input/select */
|
|
2207
|
-
input:focus, select:focus {
|
|
2207
|
+
.deepdots-popup input:focus, .deepdots-popup select:focus {
|
|
2208
2208
|
border-color: #4CAF50; /* Highlight color when focused - you can customize this */
|
|
2209
2209
|
}
|
|
2210
2210
|
|
|
2211
2211
|
/* Style for invalid input (example: validation error) */
|
|
2212
|
-
input.error, select.error {
|
|
2212
|
+
.deepdots-popup input.error, .deepdots-popup select.error {
|
|
2213
2213
|
border-color: #ff3333; /* Red color for error state - you can customize this */
|
|
2214
2214
|
}
|
|
2215
2215
|
|
|
@@ -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 */
|