@memberstack/dom 2.0.2-beta.0 → 2.0.3
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/lib/index.d.mts +76 -61
- package/lib/index.d.ts +76 -61
- package/lib/index.js +840 -61
- package/lib/index.mjs +840 -61
- package/lib/{models-CTRKogoR.d.ts → models-CFT_ABd5.d.ts} +2 -2
- package/lib/testing/index.d.mts +25 -2
- package/lib/testing/index.d.ts +25 -2
- package/lib/testing/index.js +28 -6
- package/lib/testing/index.mjs +26 -5
- package/package.json +1 -1
- package/lib/auth/index.d.mts +0 -63
- package/lib/auth/index.d.ts +0 -63
- package/lib/auth/index.global.js +0 -244
- package/lib/auth/index.js +0 -161
- package/lib/auth/index.mjs +0 -123
- package/lib/constants/endpoints.d.mts +0 -5
- package/lib/constants/endpoints.d.ts +0 -5
- package/lib/constants/endpoints.global.js +0 -29
- package/lib/constants/endpoints.js +0 -32
- package/lib/constants/endpoints.mjs +0 -7
- package/lib/methods/dom/index.d.mts +0 -2
- package/lib/methods/dom/index.d.ts +0 -2
- package/lib/methods/dom/index.global.js +0 -2
- package/lib/methods/dom/index.js +0 -1
- package/lib/methods/dom/index.mjs +0 -0
- package/lib/methods/dom/main-dom.d.mts +0 -2
- package/lib/methods/dom/main-dom.d.ts +0 -2
- package/lib/methods/dom/main-dom.global.js +0 -30620
- package/lib/methods/dom/main-dom.js +0 -15611
- package/lib/methods/dom/main-dom.mjs +0 -15593
- package/lib/methods/dom/methods.d.mts +0 -100
- package/lib/methods/dom/methods.d.ts +0 -100
- package/lib/methods/dom/methods.global.js +0 -30827
- package/lib/methods/dom/methods.js +0 -335
- package/lib/methods/dom/methods.mjs +0 -302
- package/lib/methods/index.d.mts +0 -185
- package/lib/methods/index.d.ts +0 -185
- package/lib/methods/index.global.js +0 -46361
- package/lib/methods/index.js +0 -2530
- package/lib/methods/index.mjs +0 -2500
- package/lib/methods/requests/index.d.mts +0 -912
- package/lib/methods/requests/index.d.ts +0 -912
- package/lib/methods/requests/index.global.js +0 -15553
- package/lib/methods/requests/index.js +0 -2145
- package/lib/methods/requests/index.mjs +0 -2110
- package/lib/methods/requests/requests.d.mts +0 -43
- package/lib/methods/requests/requests.d.ts +0 -43
- package/lib/methods/requests/requests.global.js +0 -14528
- package/lib/methods/requests/requests.js +0 -244
- package/lib/methods/requests/requests.mjs +0 -210
- package/lib/models-BmZS-mc4.d.ts +0 -193
- package/lib/models-le7xaT4H.d.ts +0 -193
- package/lib/types/index.d.mts +0 -5
- package/lib/types/index.d.ts +0 -5
- package/lib/types/index.global.js +0 -19
- package/lib/types/index.js +0 -18
- package/lib/types/index.mjs +0 -0
- package/lib/types/params.d.mts +0 -946
- package/lib/types/params.d.ts +0 -946
- package/lib/types/params.global.js +0 -19
- package/lib/types/params.js +0 -18
- package/lib/types/params.mjs +0 -0
- package/lib/types/payloads.d.mts +0 -342
- package/lib/types/payloads.d.ts +0 -342
- package/lib/types/payloads.global.js +0 -19
- package/lib/types/payloads.js +0 -18
- package/lib/types/payloads.mjs +0 -0
- package/lib/types/translations.d.mts +0 -101
- package/lib/types/translations.d.ts +0 -101
- package/lib/types/translations.global.js +0 -19
- package/lib/types/translations.js +0 -18
- package/lib/types/translations.mjs +0 -0
- package/lib/types/utils/payloads.d.mts +0 -297
- package/lib/types/utils/payloads.d.ts +0 -297
- package/lib/types/utils/payloads.global.js +0 -19
- package/lib/types/utils/payloads.js +0 -18
- package/lib/types/utils/payloads.mjs +0 -0
- package/lib/utils/cookies.d.mts +0 -13
- package/lib/utils/cookies.d.ts +0 -13
- package/lib/utils/cookies.global.js +0 -261
- package/lib/utils/cookies.js +0 -190
- package/lib/utils/cookies.mjs +0 -148
- package/lib/utils/defaultMessageBox.d.mts +0 -5
- package/lib/utils/defaultMessageBox.d.ts +0 -5
- package/lib/utils/defaultMessageBox.global.js +0 -125
- package/lib/utils/defaultMessageBox.js +0 -130
- package/lib/utils/defaultMessageBox.mjs +0 -103
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var __async = (__this, __arguments, generator) => {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
var fulfilled = (value) => {
|
|
22
|
-
try {
|
|
23
|
-
step(generator.next(value));
|
|
24
|
-
} catch (e) {
|
|
25
|
-
reject(e);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var rejected = (value) => {
|
|
29
|
-
try {
|
|
30
|
-
step(generator.throw(value));
|
|
31
|
-
} catch (e) {
|
|
32
|
-
reject(e);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
36
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// src/methods/dom/methods.ts
|
|
41
|
-
var methods_exports = {};
|
|
42
|
-
__export(methods_exports, {
|
|
43
|
-
handleRedirect: () => handleRedirect,
|
|
44
|
-
hideLoader: () => hideLoader,
|
|
45
|
-
hideModal: () => hideModal,
|
|
46
|
-
initDefaultMessageBox: () => initDefaultMessageBox,
|
|
47
|
-
openModal: () => openModal,
|
|
48
|
-
preloadModals: () => preloadModals,
|
|
49
|
-
showLoader: () => showLoader,
|
|
50
|
-
showMessage: () => showMessage
|
|
51
|
-
});
|
|
52
|
-
module.exports = __toCommonJS(methods_exports);
|
|
53
|
-
|
|
54
|
-
// src/utils/defaultMessageBox.ts
|
|
55
|
-
var closeIcon;
|
|
56
|
-
if (typeof window !== "undefined") {
|
|
57
|
-
closeIcon = document.createElement("div");
|
|
58
|
-
closeIcon.setAttribute("id", "ms-status-close");
|
|
59
|
-
closeIcon.setAttribute("data-ms-message-close", "");
|
|
60
|
-
closeIcon.innerHTML = `<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z" fill="white"/></svg>`;
|
|
61
|
-
}
|
|
62
|
-
var addSuccessBox = () => {
|
|
63
|
-
const successStatusIcon = document.createElement("div");
|
|
64
|
-
successStatusIcon.setAttribute("id", "ms-status-icon");
|
|
65
|
-
successStatusIcon.innerHTML = `<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="10" fill="#62d37f"/><path d="M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Zm4.59-12.42L8 12.17 5.41 9.59 4 11l4 4 8-8-1.41-1.42Z" fill="#fff"/></svg>`;
|
|
66
|
-
const successHTML = `<div data-ms-message class="ms-error-message">
|
|
67
|
-
${successStatusIcon.outerHTML}
|
|
68
|
-
<div id="ms-message" data-ms-message-text></div>
|
|
69
|
-
${closeIcon.outerHTML}
|
|
70
|
-
</div>`;
|
|
71
|
-
const successdiv = document.createElement("div");
|
|
72
|
-
successdiv.setAttribute("data-ms-message", "success");
|
|
73
|
-
successdiv.innerHTML = successHTML;
|
|
74
|
-
successdiv.style.display = "none";
|
|
75
|
-
document.body.appendChild(successdiv);
|
|
76
|
-
};
|
|
77
|
-
var addErrorBox = () => {
|
|
78
|
-
const errorStatusIcon = document.createElement("div");
|
|
79
|
-
errorStatusIcon.setAttribute("id", "ms-status-icon");
|
|
80
|
-
errorStatusIcon.innerHTML = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM11 15H9V13H11V15ZM11 11H9V5H11V11Z" fill="#E40023"/></svg>`;
|
|
81
|
-
const errorHTML = `<div data-ms-message class="ms-error-message">
|
|
82
|
-
${errorStatusIcon.outerHTML}
|
|
83
|
-
<div id="ms-message" data-ms-message-text></div>
|
|
84
|
-
${closeIcon.outerHTML}
|
|
85
|
-
</div>`;
|
|
86
|
-
const errordiv = document.createElement("div");
|
|
87
|
-
errordiv.setAttribute("data-ms-message", "error");
|
|
88
|
-
errordiv.innerHTML = errorHTML;
|
|
89
|
-
errordiv.style.display = "none";
|
|
90
|
-
document.body.appendChild(errordiv);
|
|
91
|
-
};
|
|
92
|
-
var initCSS = () => {
|
|
93
|
-
const cssEl = document.createElement("style");
|
|
94
|
-
const css = `
|
|
95
|
-
@keyframes fadeIn {
|
|
96
|
-
0% {
|
|
97
|
-
opacity: 0;
|
|
98
|
-
}
|
|
99
|
-
100% {
|
|
100
|
-
opacity: 1;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
.ms-error-message {
|
|
104
|
-
position: fixed;
|
|
105
|
-
left: 50%;
|
|
106
|
-
bottom: 3%;
|
|
107
|
-
transform: translate(-50%, -50%);
|
|
108
|
-
margin: 0 auto;
|
|
109
|
-
z-index: 10000000;
|
|
110
|
-
display: flex;
|
|
111
|
-
align-items: center;
|
|
112
|
-
padding: 12px 16px;
|
|
113
|
-
border-radius: 8px;
|
|
114
|
-
background-color: #0A0A0A;
|
|
115
|
-
color: #fff;
|
|
116
|
-
font-size: 16.8px;
|
|
117
|
-
line-height: 28px;
|
|
118
|
-
font-weight: 500;
|
|
119
|
-
transform-origin: center;
|
|
120
|
-
animation: fadeIn 0.2s ease-in;
|
|
121
|
-
-webkit-animation: fadeIn 0.2s ease-in;
|
|
122
|
-
-moz-animation: fadeIn 0.2s ease-in;
|
|
123
|
-
-o-animation: fadeIn 0.2s ease-in;
|
|
124
|
-
-ms-animation: fadeIn 0.2s ease-in;
|
|
125
|
-
}
|
|
126
|
-
@media screen and (max-width: 768px) {
|
|
127
|
-
.ms-error-message {
|
|
128
|
-
bottom: 12px;
|
|
129
|
-
width: calc(100% - 24px);
|
|
130
|
-
max-width: none;
|
|
131
|
-
padding: 10px 12px;
|
|
132
|
-
font-size: 14px;
|
|
133
|
-
line-height: 20px;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
#ms-status-icon {
|
|
137
|
-
width: 20px;
|
|
138
|
-
height: 20px;
|
|
139
|
-
margin-right: 12px;
|
|
140
|
-
}
|
|
141
|
-
#ms-status-close {
|
|
142
|
-
margin-left: 20px;
|
|
143
|
-
cursor: pointer;
|
|
144
|
-
}
|
|
145
|
-
#ms-status-close svg {
|
|
146
|
-
height: 12px;
|
|
147
|
-
}`;
|
|
148
|
-
cssEl.setAttribute("data-ms-style", "");
|
|
149
|
-
cssEl.appendChild(document.createTextNode(css));
|
|
150
|
-
document.head.appendChild(cssEl);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
// src/config/cdn.ts
|
|
154
|
-
var MAJOR_VERSION = typeof __PREBUILT_UI_MAJOR_VERSION__ !== "undefined" ? __PREBUILT_UI_MAJOR_VERSION__ : "1";
|
|
155
|
-
var isDev = typeof __API_ENDPOINT__ !== "undefined" && __API_ENDPOINT__.includes("dev-client");
|
|
156
|
-
var CDN_BASE_URL = "https://static.memberstack.com/scripts/v2";
|
|
157
|
-
var getLocalOverride = () => {
|
|
158
|
-
if (typeof window !== "undefined" && window.__MS_PREBUILT_UI_URL__) {
|
|
159
|
-
return window.__MS_PREBUILT_UI_URL__;
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
};
|
|
163
|
-
var getPrebuiltUIUrl = () => {
|
|
164
|
-
const localOverride = getLocalOverride();
|
|
165
|
-
if (localOverride) {
|
|
166
|
-
return localOverride;
|
|
167
|
-
}
|
|
168
|
-
return isDev ? `${CDN_BASE_URL}/dev/prebuilt-uis/v${MAJOR_VERSION}.js` : `${CDN_BASE_URL}/prebuilt-uis/v${MAJOR_VERSION}.js`;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// src/methods/dom/methods.ts
|
|
172
|
-
if (typeof Node !== "undefined" && !Node.prototype.getRootNode) {
|
|
173
|
-
Node.prototype.getRootNode = function() {
|
|
174
|
-
let node = this;
|
|
175
|
-
while (node.parentNode) {
|
|
176
|
-
node = node.parentNode;
|
|
177
|
-
}
|
|
178
|
-
return node;
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
var prebuiltUILoaded = false;
|
|
182
|
-
var prebuiltUILoadPromise = null;
|
|
183
|
-
var loadPrebuiltUI = (retries = 2) => __async(void 0, null, function* () {
|
|
184
|
-
if (prebuiltUILoaded)
|
|
185
|
-
return;
|
|
186
|
-
if (prebuiltUILoadPromise) {
|
|
187
|
-
return prebuiltUILoadPromise;
|
|
188
|
-
}
|
|
189
|
-
prebuiltUILoadPromise = new Promise((resolve, reject) => {
|
|
190
|
-
if (typeof customElements !== "undefined" && customElements.get("memberstack-prebuilt-ui")) {
|
|
191
|
-
prebuiltUILoaded = true;
|
|
192
|
-
resolve();
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
const script = document.createElement("script");
|
|
196
|
-
script.src = getPrebuiltUIUrl();
|
|
197
|
-
script.async = true;
|
|
198
|
-
script.onload = () => {
|
|
199
|
-
prebuiltUILoaded = true;
|
|
200
|
-
resolve();
|
|
201
|
-
};
|
|
202
|
-
script.onerror = () => __async(void 0, null, function* () {
|
|
203
|
-
prebuiltUILoadPromise = null;
|
|
204
|
-
script.remove();
|
|
205
|
-
if (retries > 0) {
|
|
206
|
-
yield new Promise((r) => setTimeout(r, 1e3));
|
|
207
|
-
try {
|
|
208
|
-
yield loadPrebuiltUI(retries - 1);
|
|
209
|
-
resolve();
|
|
210
|
-
} catch (e) {
|
|
211
|
-
reject(e);
|
|
212
|
-
}
|
|
213
|
-
} else {
|
|
214
|
-
reject(new Error(
|
|
215
|
-
"Failed to load Memberstack modals after multiple attempts. Please check your internet connection."
|
|
216
|
-
));
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
document.head.appendChild(script);
|
|
220
|
-
});
|
|
221
|
-
return prebuiltUILoadPromise;
|
|
222
|
-
});
|
|
223
|
-
var preloadModals = () => {
|
|
224
|
-
return loadPrebuiltUI();
|
|
225
|
-
};
|
|
226
|
-
var initDefaultMessageBox = () => {
|
|
227
|
-
initCSS();
|
|
228
|
-
addSuccessBox();
|
|
229
|
-
addErrorBox();
|
|
230
|
-
};
|
|
231
|
-
var showMessage = (msg, isError) => __async(void 0, null, function* () {
|
|
232
|
-
if (!msg)
|
|
233
|
-
return;
|
|
234
|
-
yield new Promise((resolve) => {
|
|
235
|
-
if (document.readyState !== "loading") {
|
|
236
|
-
resolve(true);
|
|
237
|
-
} else {
|
|
238
|
-
document.addEventListener("DOMContentLoaded", function(event) {
|
|
239
|
-
resolve(true);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
if (!document.querySelector("[data-ms-message='success']")) {
|
|
244
|
-
initDefaultMessageBox();
|
|
245
|
-
}
|
|
246
|
-
let messageBox;
|
|
247
|
-
if (isError) {
|
|
248
|
-
messageBox = document.querySelector("[data-ms-message='error']");
|
|
249
|
-
} else {
|
|
250
|
-
messageBox = document.querySelector("[data-ms-message='success']");
|
|
251
|
-
}
|
|
252
|
-
if (!messageBox)
|
|
253
|
-
return;
|
|
254
|
-
const messageTextBox = messageBox.querySelector("[data-ms-message-text]");
|
|
255
|
-
if (messageTextBox) {
|
|
256
|
-
messageTextBox.innerHTML = msg;
|
|
257
|
-
}
|
|
258
|
-
messageBox.style.display = "block";
|
|
259
|
-
const closeBtn = messageBox.querySelector("[data-ms-message-close]");
|
|
260
|
-
closeBtn == null ? void 0 : closeBtn.addEventListener("click", () => {
|
|
261
|
-
messageBox.style.display = "none";
|
|
262
|
-
});
|
|
263
|
-
setTimeout(() => {
|
|
264
|
-
messageBox.style.display = "none";
|
|
265
|
-
}, 7e3);
|
|
266
|
-
});
|
|
267
|
-
var showLoader = (element) => {
|
|
268
|
-
if (element) {
|
|
269
|
-
element.style.display = "block";
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const cssEl = document.createElement("style");
|
|
273
|
-
const css = ".ms__loader { width: 100%; height: 100%; overflow: hidden; position: fixed; top: 0; left: 0; display: flex; justify-content: center; align-items: center; z-index: 10000000; } #msLoader path { fill: #007ace; }";
|
|
274
|
-
cssEl.appendChild(document.createTextNode(css));
|
|
275
|
-
document.head.appendChild(cssEl);
|
|
276
|
-
const loaderHTML = '<?xml version="1.0"?><div class="ms__loader"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="msLoader" x="0px" y="0px" width="40px" height="40px" viewBox="0 0 50 50" style="enable-background: new 0 0 50 50; z-index:1000000" xml:space="preserve"><path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z"><animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"/></path></svg></div>';
|
|
277
|
-
const div = document.createElement("div");
|
|
278
|
-
div.setAttribute("data-ms-loader", "true");
|
|
279
|
-
div.innerHTML = loaderHTML;
|
|
280
|
-
if (document.readyState !== "loading") {
|
|
281
|
-
document.body.appendChild(div);
|
|
282
|
-
} else {
|
|
283
|
-
document.addEventListener("DOMContentLoaded", function(event) {
|
|
284
|
-
document.body.appendChild(div);
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
var hideLoader = (element) => {
|
|
289
|
-
var _a;
|
|
290
|
-
if (element) {
|
|
291
|
-
element.style.display = "none";
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
(_a = document.querySelector("[data-ms-loader]")) == null ? void 0 : _a.remove();
|
|
295
|
-
};
|
|
296
|
-
var handleRedirect = (redirect, redirectOverride) => {
|
|
297
|
-
if (typeof window !== "undefined") {
|
|
298
|
-
if (redirectOverride)
|
|
299
|
-
return window.location.href = redirectOverride;
|
|
300
|
-
if (redirect && window.location.pathname !== redirect)
|
|
301
|
-
return window.location.href = redirect;
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
var modal = null;
|
|
305
|
-
var openModal = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (type, params = {}) {
|
|
306
|
-
yield loadPrebuiltUI();
|
|
307
|
-
let resolveModal;
|
|
308
|
-
const modalPromise = new Promise((resolve) => {
|
|
309
|
-
resolveModal = resolve;
|
|
310
|
-
});
|
|
311
|
-
const element = document.createElement("memberstack-prebuilt-ui");
|
|
312
|
-
element.display = type.toLowerCase();
|
|
313
|
-
element.params = params;
|
|
314
|
-
element.onSuccess = resolveModal;
|
|
315
|
-
modal = element;
|
|
316
|
-
document.body.appendChild(modal);
|
|
317
|
-
return modalPromise;
|
|
318
|
-
});
|
|
319
|
-
var hideModal = () => {
|
|
320
|
-
try {
|
|
321
|
-
modal == null ? void 0 : modal.remove();
|
|
322
|
-
} catch (e) {
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
326
|
-
0 && (module.exports = {
|
|
327
|
-
handleRedirect,
|
|
328
|
-
hideLoader,
|
|
329
|
-
hideModal,
|
|
330
|
-
initDefaultMessageBox,
|
|
331
|
-
openModal,
|
|
332
|
-
preloadModals,
|
|
333
|
-
showLoader,
|
|
334
|
-
showMessage
|
|
335
|
-
});
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// src/utils/defaultMessageBox.ts
|
|
23
|
-
var closeIcon;
|
|
24
|
-
if (typeof window !== "undefined") {
|
|
25
|
-
closeIcon = document.createElement("div");
|
|
26
|
-
closeIcon.setAttribute("id", "ms-status-close");
|
|
27
|
-
closeIcon.setAttribute("data-ms-message-close", "");
|
|
28
|
-
closeIcon.innerHTML = `<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z" fill="white"/></svg>`;
|
|
29
|
-
}
|
|
30
|
-
var addSuccessBox = () => {
|
|
31
|
-
const successStatusIcon = document.createElement("div");
|
|
32
|
-
successStatusIcon.setAttribute("id", "ms-status-icon");
|
|
33
|
-
successStatusIcon.innerHTML = `<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="10" fill="#62d37f"/><path d="M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Zm4.59-12.42L8 12.17 5.41 9.59 4 11l4 4 8-8-1.41-1.42Z" fill="#fff"/></svg>`;
|
|
34
|
-
const successHTML = `<div data-ms-message class="ms-error-message">
|
|
35
|
-
${successStatusIcon.outerHTML}
|
|
36
|
-
<div id="ms-message" data-ms-message-text></div>
|
|
37
|
-
${closeIcon.outerHTML}
|
|
38
|
-
</div>`;
|
|
39
|
-
const successdiv = document.createElement("div");
|
|
40
|
-
successdiv.setAttribute("data-ms-message", "success");
|
|
41
|
-
successdiv.innerHTML = successHTML;
|
|
42
|
-
successdiv.style.display = "none";
|
|
43
|
-
document.body.appendChild(successdiv);
|
|
44
|
-
};
|
|
45
|
-
var addErrorBox = () => {
|
|
46
|
-
const errorStatusIcon = document.createElement("div");
|
|
47
|
-
errorStatusIcon.setAttribute("id", "ms-status-icon");
|
|
48
|
-
errorStatusIcon.innerHTML = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM11 15H9V13H11V15ZM11 11H9V5H11V11Z" fill="#E40023"/></svg>`;
|
|
49
|
-
const errorHTML = `<div data-ms-message class="ms-error-message">
|
|
50
|
-
${errorStatusIcon.outerHTML}
|
|
51
|
-
<div id="ms-message" data-ms-message-text></div>
|
|
52
|
-
${closeIcon.outerHTML}
|
|
53
|
-
</div>`;
|
|
54
|
-
const errordiv = document.createElement("div");
|
|
55
|
-
errordiv.setAttribute("data-ms-message", "error");
|
|
56
|
-
errordiv.innerHTML = errorHTML;
|
|
57
|
-
errordiv.style.display = "none";
|
|
58
|
-
document.body.appendChild(errordiv);
|
|
59
|
-
};
|
|
60
|
-
var initCSS = () => {
|
|
61
|
-
const cssEl = document.createElement("style");
|
|
62
|
-
const css = `
|
|
63
|
-
@keyframes fadeIn {
|
|
64
|
-
0% {
|
|
65
|
-
opacity: 0;
|
|
66
|
-
}
|
|
67
|
-
100% {
|
|
68
|
-
opacity: 1;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
.ms-error-message {
|
|
72
|
-
position: fixed;
|
|
73
|
-
left: 50%;
|
|
74
|
-
bottom: 3%;
|
|
75
|
-
transform: translate(-50%, -50%);
|
|
76
|
-
margin: 0 auto;
|
|
77
|
-
z-index: 10000000;
|
|
78
|
-
display: flex;
|
|
79
|
-
align-items: center;
|
|
80
|
-
padding: 12px 16px;
|
|
81
|
-
border-radius: 8px;
|
|
82
|
-
background-color: #0A0A0A;
|
|
83
|
-
color: #fff;
|
|
84
|
-
font-size: 16.8px;
|
|
85
|
-
line-height: 28px;
|
|
86
|
-
font-weight: 500;
|
|
87
|
-
transform-origin: center;
|
|
88
|
-
animation: fadeIn 0.2s ease-in;
|
|
89
|
-
-webkit-animation: fadeIn 0.2s ease-in;
|
|
90
|
-
-moz-animation: fadeIn 0.2s ease-in;
|
|
91
|
-
-o-animation: fadeIn 0.2s ease-in;
|
|
92
|
-
-ms-animation: fadeIn 0.2s ease-in;
|
|
93
|
-
}
|
|
94
|
-
@media screen and (max-width: 768px) {
|
|
95
|
-
.ms-error-message {
|
|
96
|
-
bottom: 12px;
|
|
97
|
-
width: calc(100% - 24px);
|
|
98
|
-
max-width: none;
|
|
99
|
-
padding: 10px 12px;
|
|
100
|
-
font-size: 14px;
|
|
101
|
-
line-height: 20px;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
#ms-status-icon {
|
|
105
|
-
width: 20px;
|
|
106
|
-
height: 20px;
|
|
107
|
-
margin-right: 12px;
|
|
108
|
-
}
|
|
109
|
-
#ms-status-close {
|
|
110
|
-
margin-left: 20px;
|
|
111
|
-
cursor: pointer;
|
|
112
|
-
}
|
|
113
|
-
#ms-status-close svg {
|
|
114
|
-
height: 12px;
|
|
115
|
-
}`;
|
|
116
|
-
cssEl.setAttribute("data-ms-style", "");
|
|
117
|
-
cssEl.appendChild(document.createTextNode(css));
|
|
118
|
-
document.head.appendChild(cssEl);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// src/config/cdn.ts
|
|
122
|
-
var MAJOR_VERSION = typeof __PREBUILT_UI_MAJOR_VERSION__ !== "undefined" ? __PREBUILT_UI_MAJOR_VERSION__ : "1";
|
|
123
|
-
var isDev = typeof __API_ENDPOINT__ !== "undefined" && __API_ENDPOINT__.includes("dev-client");
|
|
124
|
-
var CDN_BASE_URL = "https://static.memberstack.com/scripts/v2";
|
|
125
|
-
var getLocalOverride = () => {
|
|
126
|
-
if (typeof window !== "undefined" && window.__MS_PREBUILT_UI_URL__) {
|
|
127
|
-
return window.__MS_PREBUILT_UI_URL__;
|
|
128
|
-
}
|
|
129
|
-
return null;
|
|
130
|
-
};
|
|
131
|
-
var getPrebuiltUIUrl = () => {
|
|
132
|
-
const localOverride = getLocalOverride();
|
|
133
|
-
if (localOverride) {
|
|
134
|
-
return localOverride;
|
|
135
|
-
}
|
|
136
|
-
return isDev ? `${CDN_BASE_URL}/dev/prebuilt-uis/v${MAJOR_VERSION}.js` : `${CDN_BASE_URL}/prebuilt-uis/v${MAJOR_VERSION}.js`;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// src/methods/dom/methods.ts
|
|
140
|
-
if (typeof Node !== "undefined" && !Node.prototype.getRootNode) {
|
|
141
|
-
Node.prototype.getRootNode = function() {
|
|
142
|
-
let node = this;
|
|
143
|
-
while (node.parentNode) {
|
|
144
|
-
node = node.parentNode;
|
|
145
|
-
}
|
|
146
|
-
return node;
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
var prebuiltUILoaded = false;
|
|
150
|
-
var prebuiltUILoadPromise = null;
|
|
151
|
-
var loadPrebuiltUI = (retries = 2) => __async(void 0, null, function* () {
|
|
152
|
-
if (prebuiltUILoaded)
|
|
153
|
-
return;
|
|
154
|
-
if (prebuiltUILoadPromise) {
|
|
155
|
-
return prebuiltUILoadPromise;
|
|
156
|
-
}
|
|
157
|
-
prebuiltUILoadPromise = new Promise((resolve, reject) => {
|
|
158
|
-
if (typeof customElements !== "undefined" && customElements.get("memberstack-prebuilt-ui")) {
|
|
159
|
-
prebuiltUILoaded = true;
|
|
160
|
-
resolve();
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const script = document.createElement("script");
|
|
164
|
-
script.src = getPrebuiltUIUrl();
|
|
165
|
-
script.async = true;
|
|
166
|
-
script.onload = () => {
|
|
167
|
-
prebuiltUILoaded = true;
|
|
168
|
-
resolve();
|
|
169
|
-
};
|
|
170
|
-
script.onerror = () => __async(void 0, null, function* () {
|
|
171
|
-
prebuiltUILoadPromise = null;
|
|
172
|
-
script.remove();
|
|
173
|
-
if (retries > 0) {
|
|
174
|
-
yield new Promise((r) => setTimeout(r, 1e3));
|
|
175
|
-
try {
|
|
176
|
-
yield loadPrebuiltUI(retries - 1);
|
|
177
|
-
resolve();
|
|
178
|
-
} catch (e) {
|
|
179
|
-
reject(e);
|
|
180
|
-
}
|
|
181
|
-
} else {
|
|
182
|
-
reject(new Error(
|
|
183
|
-
"Failed to load Memberstack modals after multiple attempts. Please check your internet connection."
|
|
184
|
-
));
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
document.head.appendChild(script);
|
|
188
|
-
});
|
|
189
|
-
return prebuiltUILoadPromise;
|
|
190
|
-
});
|
|
191
|
-
var preloadModals = () => {
|
|
192
|
-
return loadPrebuiltUI();
|
|
193
|
-
};
|
|
194
|
-
var initDefaultMessageBox = () => {
|
|
195
|
-
initCSS();
|
|
196
|
-
addSuccessBox();
|
|
197
|
-
addErrorBox();
|
|
198
|
-
};
|
|
199
|
-
var showMessage = (msg, isError) => __async(void 0, null, function* () {
|
|
200
|
-
if (!msg)
|
|
201
|
-
return;
|
|
202
|
-
yield new Promise((resolve) => {
|
|
203
|
-
if (document.readyState !== "loading") {
|
|
204
|
-
resolve(true);
|
|
205
|
-
} else {
|
|
206
|
-
document.addEventListener("DOMContentLoaded", function(event) {
|
|
207
|
-
resolve(true);
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
if (!document.querySelector("[data-ms-message='success']")) {
|
|
212
|
-
initDefaultMessageBox();
|
|
213
|
-
}
|
|
214
|
-
let messageBox;
|
|
215
|
-
if (isError) {
|
|
216
|
-
messageBox = document.querySelector("[data-ms-message='error']");
|
|
217
|
-
} else {
|
|
218
|
-
messageBox = document.querySelector("[data-ms-message='success']");
|
|
219
|
-
}
|
|
220
|
-
if (!messageBox)
|
|
221
|
-
return;
|
|
222
|
-
const messageTextBox = messageBox.querySelector("[data-ms-message-text]");
|
|
223
|
-
if (messageTextBox) {
|
|
224
|
-
messageTextBox.innerHTML = msg;
|
|
225
|
-
}
|
|
226
|
-
messageBox.style.display = "block";
|
|
227
|
-
const closeBtn = messageBox.querySelector("[data-ms-message-close]");
|
|
228
|
-
closeBtn == null ? void 0 : closeBtn.addEventListener("click", () => {
|
|
229
|
-
messageBox.style.display = "none";
|
|
230
|
-
});
|
|
231
|
-
setTimeout(() => {
|
|
232
|
-
messageBox.style.display = "none";
|
|
233
|
-
}, 7e3);
|
|
234
|
-
});
|
|
235
|
-
var showLoader = (element) => {
|
|
236
|
-
if (element) {
|
|
237
|
-
element.style.display = "block";
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
const cssEl = document.createElement("style");
|
|
241
|
-
const css = ".ms__loader { width: 100%; height: 100%; overflow: hidden; position: fixed; top: 0; left: 0; display: flex; justify-content: center; align-items: center; z-index: 10000000; } #msLoader path { fill: #007ace; }";
|
|
242
|
-
cssEl.appendChild(document.createTextNode(css));
|
|
243
|
-
document.head.appendChild(cssEl);
|
|
244
|
-
const loaderHTML = '<?xml version="1.0"?><div class="ms__loader"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="msLoader" x="0px" y="0px" width="40px" height="40px" viewBox="0 0 50 50" style="enable-background: new 0 0 50 50; z-index:1000000" xml:space="preserve"><path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z"><animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"/></path></svg></div>';
|
|
245
|
-
const div = document.createElement("div");
|
|
246
|
-
div.setAttribute("data-ms-loader", "true");
|
|
247
|
-
div.innerHTML = loaderHTML;
|
|
248
|
-
if (document.readyState !== "loading") {
|
|
249
|
-
document.body.appendChild(div);
|
|
250
|
-
} else {
|
|
251
|
-
document.addEventListener("DOMContentLoaded", function(event) {
|
|
252
|
-
document.body.appendChild(div);
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
var hideLoader = (element) => {
|
|
257
|
-
var _a;
|
|
258
|
-
if (element) {
|
|
259
|
-
element.style.display = "none";
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
(_a = document.querySelector("[data-ms-loader]")) == null ? void 0 : _a.remove();
|
|
263
|
-
};
|
|
264
|
-
var handleRedirect = (redirect, redirectOverride) => {
|
|
265
|
-
if (typeof window !== "undefined") {
|
|
266
|
-
if (redirectOverride)
|
|
267
|
-
return window.location.href = redirectOverride;
|
|
268
|
-
if (redirect && window.location.pathname !== redirect)
|
|
269
|
-
return window.location.href = redirect;
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
var modal = null;
|
|
273
|
-
var openModal = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (type, params = {}) {
|
|
274
|
-
yield loadPrebuiltUI();
|
|
275
|
-
let resolveModal;
|
|
276
|
-
const modalPromise = new Promise((resolve) => {
|
|
277
|
-
resolveModal = resolve;
|
|
278
|
-
});
|
|
279
|
-
const element = document.createElement("memberstack-prebuilt-ui");
|
|
280
|
-
element.display = type.toLowerCase();
|
|
281
|
-
element.params = params;
|
|
282
|
-
element.onSuccess = resolveModal;
|
|
283
|
-
modal = element;
|
|
284
|
-
document.body.appendChild(modal);
|
|
285
|
-
return modalPromise;
|
|
286
|
-
});
|
|
287
|
-
var hideModal = () => {
|
|
288
|
-
try {
|
|
289
|
-
modal == null ? void 0 : modal.remove();
|
|
290
|
-
} catch (e) {
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
export {
|
|
294
|
-
handleRedirect,
|
|
295
|
-
hideLoader,
|
|
296
|
-
hideModal,
|
|
297
|
-
initDefaultMessageBox,
|
|
298
|
-
openModal,
|
|
299
|
-
preloadModals,
|
|
300
|
-
showLoader,
|
|
301
|
-
showMessage
|
|
302
|
-
};
|