@saasquatch/squatch-js 2.8.2-14 → 2.8.2-16
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/squatch.cjs.js +135 -405
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +135 -405
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +135 -405
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +1 -1
- package/package.json +1 -1
package/dist/squatch.esm.js
CHANGED
|
@@ -1106,351 +1106,6 @@ function delay(duration) {
|
|
|
1106
1106
|
setTimeout(resolve, duration);
|
|
1107
1107
|
});
|
|
1108
1108
|
}
|
|
1109
|
-
const getSkeleton = ({
|
|
1110
|
-
height = "500px",
|
|
1111
|
-
skeletonBackgroundColor = "#e0e0e0",
|
|
1112
|
-
skeletonShimmerColor = "#f5f5f5",
|
|
1113
|
-
borderColor = "#ccc"
|
|
1114
|
-
}) => {
|
|
1115
|
-
return `
|
|
1116
|
-
<style>
|
|
1117
|
-
* {
|
|
1118
|
-
box-sizing: border-box;
|
|
1119
|
-
padding: 0;
|
|
1120
|
-
margin: 0;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
.widget-container {
|
|
1124
|
-
background: white;
|
|
1125
|
-
width: 100%;
|
|
1126
|
-
max-width: 900px;
|
|
1127
|
-
padding: 40px;
|
|
1128
|
-
border-radius: 12px;
|
|
1129
|
-
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
|
|
1130
|
-
box-sizing: border-box;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
@keyframes shimmer {
|
|
1134
|
-
0% {
|
|
1135
|
-
background-position: -100% 0;
|
|
1136
|
-
}
|
|
1137
|
-
100% {
|
|
1138
|
-
background-position: 100% 0;
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
.skeleton {
|
|
1143
|
-
background: ${skeletonBackgroundColor};
|
|
1144
|
-
background: linear-gradient(
|
|
1145
|
-
90deg,
|
|
1146
|
-
${skeletonBackgroundColor} 25%,
|
|
1147
|
-
${skeletonShimmerColor} 50%,
|
|
1148
|
-
${skeletonBackgroundColor} 75%
|
|
1149
|
-
);
|
|
1150
|
-
background-size: 200% 100%;
|
|
1151
|
-
animation: shimmer 1.5s infinite linear;
|
|
1152
|
-
border-radius: 6px;
|
|
1153
|
-
margin-bottom: 12px;
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
.sk-title-lg {
|
|
1157
|
-
height: 36px;
|
|
1158
|
-
width: 50%;
|
|
1159
|
-
margin-bottom: 16px;
|
|
1160
|
-
}
|
|
1161
|
-
.sk-title-md {
|
|
1162
|
-
height: 28px;
|
|
1163
|
-
width: 30%;
|
|
1164
|
-
margin-bottom: 20px;
|
|
1165
|
-
margin-top: 40px;
|
|
1166
|
-
}
|
|
1167
|
-
.sk-text {
|
|
1168
|
-
height: 16px;
|
|
1169
|
-
width: 80%;
|
|
1170
|
-
margin-bottom: 8px;
|
|
1171
|
-
}
|
|
1172
|
-
.sk-text-short {
|
|
1173
|
-
width: 40%;
|
|
1174
|
-
}
|
|
1175
|
-
.sk-label {
|
|
1176
|
-
height: 14px;
|
|
1177
|
-
width: 25%;
|
|
1178
|
-
margin-bottom: 10px;
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
.hero-section {
|
|
1182
|
-
display: flex;
|
|
1183
|
-
gap: 40px;
|
|
1184
|
-
margin-bottom: 40px;
|
|
1185
|
-
border-bottom: 1px solid ${borderColor};
|
|
1186
|
-
padding-bottom: 40px;
|
|
1187
|
-
flex-direction: row;
|
|
1188
|
-
}
|
|
1189
|
-
.hero-content {
|
|
1190
|
-
flex: 1;
|
|
1191
|
-
display: flex;
|
|
1192
|
-
flex-direction: column;
|
|
1193
|
-
justify-content: center;
|
|
1194
|
-
}
|
|
1195
|
-
.hero-image {
|
|
1196
|
-
flex: 1;
|
|
1197
|
-
height: 300px;
|
|
1198
|
-
border-radius: 12px;
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
.share-section {
|
|
1202
|
-
margin-bottom: 40px;
|
|
1203
|
-
}
|
|
1204
|
-
.sk-input {
|
|
1205
|
-
height: 50px;
|
|
1206
|
-
width: 100%;
|
|
1207
|
-
border-radius: 8px;
|
|
1208
|
-
margin-bottom: 16px;
|
|
1209
|
-
}
|
|
1210
|
-
.social-buttons {
|
|
1211
|
-
display: flex;
|
|
1212
|
-
gap: 12px;
|
|
1213
|
-
}
|
|
1214
|
-
.sk-btn-social {
|
|
1215
|
-
flex: 1;
|
|
1216
|
-
height: 50px;
|
|
1217
|
-
border-radius: 8px;
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
.stats-section {
|
|
1221
|
-
display: flex;
|
|
1222
|
-
gap: 24px;
|
|
1223
|
-
margin-bottom: 40px;
|
|
1224
|
-
padding: 30px 0;
|
|
1225
|
-
border-top: 1px solid ${borderColor};
|
|
1226
|
-
border-bottom: 1px solid ${borderColor};
|
|
1227
|
-
}
|
|
1228
|
-
.stat-card {
|
|
1229
|
-
flex: 1;
|
|
1230
|
-
display: flex;
|
|
1231
|
-
flex-direction: column;
|
|
1232
|
-
align-items: center;
|
|
1233
|
-
}
|
|
1234
|
-
.stat-divider {
|
|
1235
|
-
padding-left: 24px;
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
.sk-stat-num {
|
|
1239
|
-
height: 48px;
|
|
1240
|
-
width: 120px;
|
|
1241
|
-
margin-bottom: 8px;
|
|
1242
|
-
}
|
|
1243
|
-
.sk-stat-label {
|
|
1244
|
-
height: 18px;
|
|
1245
|
-
width: 80px;
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
.table-header {
|
|
1249
|
-
display: flex;
|
|
1250
|
-
gap: 16px;
|
|
1251
|
-
margin-bottom: 16px;
|
|
1252
|
-
}
|
|
1253
|
-
.sk-th {
|
|
1254
|
-
height: 16px;
|
|
1255
|
-
}
|
|
1256
|
-
.table-row {
|
|
1257
|
-
display: flex;
|
|
1258
|
-
align-items: center;
|
|
1259
|
-
gap: 16px;
|
|
1260
|
-
padding: 16px 0;
|
|
1261
|
-
border-bottom: 1px solid ${borderColor};
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
.col-user {
|
|
1265
|
-
flex: 2;
|
|
1266
|
-
}
|
|
1267
|
-
.col-status {
|
|
1268
|
-
flex: 1;
|
|
1269
|
-
}
|
|
1270
|
-
.col-reward {
|
|
1271
|
-
flex: 2;
|
|
1272
|
-
}
|
|
1273
|
-
.col-date {
|
|
1274
|
-
flex: 1;
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
.sk-badge {
|
|
1278
|
-
height: 28px;
|
|
1279
|
-
width: 90px;
|
|
1280
|
-
border-radius: 14px;
|
|
1281
|
-
}
|
|
1282
|
-
.sk-reward-block {
|
|
1283
|
-
height: 36px;
|
|
1284
|
-
width: 100%;
|
|
1285
|
-
border-radius: 6px;
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
.pagination {
|
|
1289
|
-
display: flex;
|
|
1290
|
-
justify-content: flex-end;
|
|
1291
|
-
gap: 8px;
|
|
1292
|
-
margin-top: 24px;
|
|
1293
|
-
}
|
|
1294
|
-
.sk-btn-page {
|
|
1295
|
-
height: 36px;
|
|
1296
|
-
width: 64px;
|
|
1297
|
-
border-radius: 6px;
|
|
1298
|
-
margin-bottom: 0;
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
@media (max-width: 768px) {
|
|
1302
|
-
body {
|
|
1303
|
-
padding: 20px;
|
|
1304
|
-
}
|
|
1305
|
-
.widget-container {
|
|
1306
|
-
padding: 24px;
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
.hero-section {
|
|
1310
|
-
flex-direction: column-reverse;
|
|
1311
|
-
gap: 24px;
|
|
1312
|
-
}
|
|
1313
|
-
.hero-image {
|
|
1314
|
-
height: 220px;
|
|
1315
|
-
width: 100%;
|
|
1316
|
-
}
|
|
1317
|
-
.sk-title-lg {
|
|
1318
|
-
width: 80%;
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
.col-date {
|
|
1322
|
-
display: none;
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
@media (max-width: 480px) {
|
|
1327
|
-
body {
|
|
1328
|
-
padding: 10px;
|
|
1329
|
-
}
|
|
1330
|
-
.widget-container {
|
|
1331
|
-
padding: 16px;
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
.sk-stat-num {
|
|
1335
|
-
width: 80px;
|
|
1336
|
-
height: 40px;
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
.col-reward {
|
|
1340
|
-
display: none;
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
.col-user {
|
|
1344
|
-
flex: 3;
|
|
1345
|
-
}
|
|
1346
|
-
.col-status {
|
|
1347
|
-
flex: 2;
|
|
1348
|
-
display: flex;
|
|
1349
|
-
justify-content: flex-end;
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
</style>
|
|
1353
|
-
|
|
1354
|
-
<div class="widget-container">
|
|
1355
|
-
<div class="hero-section">
|
|
1356
|
-
<div class="hero-content">
|
|
1357
|
-
<div class="skeleton sk-title-lg"></div>
|
|
1358
|
-
<div class="skeleton sk-text"></div>
|
|
1359
|
-
<div class="skeleton sk-text sk-text-short"></div>
|
|
1360
|
-
</div>
|
|
1361
|
-
<div class="skeleton hero-image"></div>
|
|
1362
|
-
</div>
|
|
1363
|
-
|
|
1364
|
-
<div class="share-section">
|
|
1365
|
-
<div class="skeleton sk-label"></div>
|
|
1366
|
-
<div class="skeleton sk-input"></div>
|
|
1367
|
-
<div class="social-buttons">
|
|
1368
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1369
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1370
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1371
|
-
<div class="skeleton sk-btn-social"></div>
|
|
1372
|
-
</div>
|
|
1373
|
-
</div>
|
|
1374
|
-
|
|
1375
|
-
<div
|
|
1376
|
-
class="skeleton sk-title-md"
|
|
1377
|
-
style="margin-top: 0; width: 30%; margin-left: auto; margin-right: auto"
|
|
1378
|
-
></div>
|
|
1379
|
-
<div
|
|
1380
|
-
class="skeleton sk-text"
|
|
1381
|
-
style="width: 60%; margin-left: auto; margin-right: auto"
|
|
1382
|
-
></div>
|
|
1383
|
-
|
|
1384
|
-
<div class="stats-section">
|
|
1385
|
-
<div class="stat-card">
|
|
1386
|
-
<div class="skeleton sk-stat-num"></div>
|
|
1387
|
-
<div class="skeleton sk-stat-label"></div>
|
|
1388
|
-
</div>
|
|
1389
|
-
<div class="stat-card stat-divider">
|
|
1390
|
-
<div class="skeleton sk-stat-num"></div>
|
|
1391
|
-
<div class="skeleton sk-stat-label"></div>
|
|
1392
|
-
</div>
|
|
1393
|
-
</div>
|
|
1394
|
-
|
|
1395
|
-
<div class="skeleton sk-title-md"></div>
|
|
1396
|
-
|
|
1397
|
-
<div class="table-header">
|
|
1398
|
-
<div class="skeleton sk-th col-user"></div>
|
|
1399
|
-
<div class="skeleton sk-th col-status"></div>
|
|
1400
|
-
<div class="skeleton sk-th col-reward"></div>
|
|
1401
|
-
<div class="skeleton sk-th col-date"></div>
|
|
1402
|
-
</div>
|
|
1403
|
-
|
|
1404
|
-
<div class="table-row">
|
|
1405
|
-
<div class="col-user">
|
|
1406
|
-
<div class="skeleton sk-text" style="width: 70%; margin: 0"></div>
|
|
1407
|
-
</div>
|
|
1408
|
-
<div class="col-status">
|
|
1409
|
-
<div class="skeleton sk-badge" style="margin: 0"></div>
|
|
1410
|
-
</div>
|
|
1411
|
-
<div class="col-reward">
|
|
1412
|
-
<div class="skeleton sk-reward-block" style="margin: 0"></div>
|
|
1413
|
-
</div>
|
|
1414
|
-
<div class="col-date">
|
|
1415
|
-
<div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
|
|
1416
|
-
</div>
|
|
1417
|
-
</div>
|
|
1418
|
-
<div class="table-row">
|
|
1419
|
-
<div class="col-user">
|
|
1420
|
-
<div class="skeleton sk-text" style="width: 60%; margin: 0"></div>
|
|
1421
|
-
</div>
|
|
1422
|
-
<div class="col-status">
|
|
1423
|
-
<div class="skeleton sk-badge" style="margin: 0"></div>
|
|
1424
|
-
</div>
|
|
1425
|
-
<div class="col-reward">
|
|
1426
|
-
<div class="skeleton sk-reward-block" style="margin: 0"></div>
|
|
1427
|
-
</div>
|
|
1428
|
-
<div class="col-date">
|
|
1429
|
-
<div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
|
|
1430
|
-
</div>
|
|
1431
|
-
</div>
|
|
1432
|
-
<div class="table-row">
|
|
1433
|
-
<div class="col-user">
|
|
1434
|
-
<div class="skeleton sk-text" style="width: 75%; margin: 0"></div>
|
|
1435
|
-
</div>
|
|
1436
|
-
<div class="col-status">
|
|
1437
|
-
<div class="skeleton sk-badge" style="margin: 0"></div>
|
|
1438
|
-
</div>
|
|
1439
|
-
<div class="col-reward">
|
|
1440
|
-
<div class="skeleton sk-reward-block" style="margin: 0"></div>
|
|
1441
|
-
</div>
|
|
1442
|
-
<div class="col-date">
|
|
1443
|
-
<div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
|
|
1444
|
-
</div>
|
|
1445
|
-
</div>
|
|
1446
|
-
|
|
1447
|
-
<div class="pagination">
|
|
1448
|
-
<div class="skeleton sk-btn-page"></div>
|
|
1449
|
-
<div class="skeleton sk-btn-page"></div>
|
|
1450
|
-
</div>
|
|
1451
|
-
</div>
|
|
1452
|
-
`;
|
|
1453
|
-
};
|
|
1454
1109
|
const _log$7 = browserExports.debug("squatch-js:EMBEDwidget");
|
|
1455
1110
|
class EmbedWidget extends Widget {
|
|
1456
1111
|
constructor(params, container) {
|
|
@@ -1461,61 +1116,34 @@ class EmbedWidget extends Widget {
|
|
|
1461
1116
|
this.container = container;
|
|
1462
1117
|
}
|
|
1463
1118
|
}
|
|
1119
|
+
//Old code for testing
|
|
1464
1120
|
async load() {
|
|
1465
|
-
var _a2, _b, _c, _d, _e
|
|
1121
|
+
var _a2, _b, _c, _d, _e;
|
|
1466
1122
|
const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
|
|
1467
|
-
const
|
|
1468
|
-
const skeletonBackgroundColor = (_d = (_c = brandingConfig == null ? void 0 : brandingConfig.color) == null ? void 0 : _c.loadingSkeleton) == null ? void 0 : _d.background;
|
|
1469
|
-
const skeletonShimmerColor = (_f = (_e = brandingConfig == null ? void 0 : brandingConfig.color) == null ? void 0 : _e.loadingSkeleton) == null ? void 0 : _f.animationBackground;
|
|
1470
|
-
const borderColor = (_g = brandingConfig == null ? void 0 : brandingConfig.border) == null ? void 0 : _g.borderColor;
|
|
1471
|
-
const sizes = (_h = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _h.embeddedWidgets;
|
|
1123
|
+
const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.embeddedWidgets;
|
|
1472
1124
|
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "";
|
|
1473
1125
|
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "";
|
|
1474
|
-
|
|
1475
|
-
brandingConfig,
|
|
1476
|
-
initialHeight,
|
|
1477
|
-
widgetConfig: this.context.widgetConfig
|
|
1478
|
-
});
|
|
1479
|
-
const skeletonHTML = getSkeleton({
|
|
1480
|
-
height: initialHeight,
|
|
1481
|
-
skeletonBackgroundColor,
|
|
1482
|
-
skeletonShimmerColor,
|
|
1483
|
-
borderColor
|
|
1484
|
-
});
|
|
1485
|
-
const skeletonContainer = document.createElement("div");
|
|
1486
|
-
skeletonContainer.innerHTML = skeletonHTML;
|
|
1487
|
-
const frame = this._createFrame({
|
|
1488
|
-
minWidth,
|
|
1489
|
-
maxWidth,
|
|
1490
|
-
initialHeight
|
|
1491
|
-
});
|
|
1126
|
+
const frame = this._createFrame({ minWidth, maxWidth });
|
|
1492
1127
|
const element = this._findElement();
|
|
1493
|
-
|
|
1494
|
-
frame.style.display = "none";
|
|
1495
|
-
const injectContents = (target) => {
|
|
1496
|
-
target.appendChild(skeletonContainer);
|
|
1497
|
-
target.appendChild(frame);
|
|
1498
|
-
};
|
|
1499
|
-
if ((_i = this.context) == null ? void 0 : _i.container) {
|
|
1128
|
+
if ((_d = this.context) == null ? void 0 : _d.container) {
|
|
1500
1129
|
element.style.visibility = "hidden";
|
|
1501
1130
|
element.style.height = "0";
|
|
1502
1131
|
element.style["overflow-y"] = "hidden";
|
|
1503
1132
|
}
|
|
1504
1133
|
if (this.container) {
|
|
1505
1134
|
if (element.shadowRoot) {
|
|
1506
|
-
if (((
|
|
1135
|
+
if (((_e = element.shadowRoot.lastChild) == null ? void 0 : _e.nodeName) === "IFRAME") {
|
|
1507
1136
|
element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
|
|
1508
1137
|
} else {
|
|
1509
|
-
|
|
1138
|
+
element.shadowRoot.appendChild(frame);
|
|
1510
1139
|
}
|
|
1511
1140
|
} else if (element.firstChild) {
|
|
1512
|
-
element.
|
|
1513
|
-
injectContents(element);
|
|
1141
|
+
element.replaceChild(frame, element.firstChild);
|
|
1514
1142
|
} else {
|
|
1515
|
-
|
|
1143
|
+
element.appendChild(frame);
|
|
1516
1144
|
}
|
|
1517
1145
|
} else if (!element.firstChild || element.firstChild.nodeName === "#text") {
|
|
1518
|
-
|
|
1146
|
+
element.appendChild(frame);
|
|
1519
1147
|
}
|
|
1520
1148
|
const { contentWindow } = frame;
|
|
1521
1149
|
if (!contentWindow) {
|
|
@@ -1523,32 +1151,14 @@ class EmbedWidget extends Widget {
|
|
|
1523
1151
|
}
|
|
1524
1152
|
const frameDoc = contentWindow.document;
|
|
1525
1153
|
frameDoc.open();
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
<link rel="preconnect" href="https://fast${domain === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
|
|
1531
|
-
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
1532
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
1533
|
-
<link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
1534
|
-
(_l = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _l.brandFont
|
|
1535
|
-
)}" as="style">`}
|
|
1536
|
-
<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
|
|
1537
|
-
<style data-styles>
|
|
1538
|
-
html { visibility:hidden;}
|
|
1539
|
-
</style>
|
|
1540
|
-
${this.content}
|
|
1541
|
-
|
|
1542
|
-
`);
|
|
1154
|
+
frameDoc.write(this.content);
|
|
1155
|
+
frameDoc.write(
|
|
1156
|
+
`<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
|
|
1157
|
+
);
|
|
1543
1158
|
frameDoc.close();
|
|
1544
1159
|
domready(frameDoc, async () => {
|
|
1545
|
-
if (skeletonContainer && skeletonContainer.parentNode) {
|
|
1546
|
-
skeletonContainer.parentNode.removeChild(skeletonContainer);
|
|
1547
|
-
}
|
|
1548
|
-
frame.style.display = "block";
|
|
1549
1160
|
const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
|
|
1550
|
-
frame.height =
|
|
1551
|
-
console.log({ height: frameDoc.body.scrollHeight });
|
|
1161
|
+
frame.height = frameDoc.body.scrollHeight;
|
|
1552
1162
|
const ro = new contentWindow["ResizeObserver"]((entries) => {
|
|
1553
1163
|
for (const entry of entries) {
|
|
1554
1164
|
const { height } = entry.contentRect;
|
|
@@ -1565,6 +1175,126 @@ class EmbedWidget extends Widget {
|
|
|
1565
1175
|
}
|
|
1566
1176
|
});
|
|
1567
1177
|
}
|
|
1178
|
+
// async load() {
|
|
1179
|
+
// const brandingConfig = this.context.widgetConfig?.values?.brandingConfig;
|
|
1180
|
+
// // @ts-ignore
|
|
1181
|
+
// const initialHeight = brandingConfig?.loadingHeight;
|
|
1182
|
+
// const skeletonBackgroundColor =
|
|
1183
|
+
// brandingConfig?.color?.loadingSkeleton?.background;
|
|
1184
|
+
// const skeletonShimmerColor =
|
|
1185
|
+
// brandingConfig?.color?.loadingSkeleton?.animationBackground;
|
|
1186
|
+
// const borderColor = brandingConfig?.border?.borderColor;
|
|
1187
|
+
// const sizes = brandingConfig?.widgetSize?.embeddedWidgets;
|
|
1188
|
+
// const maxWidth = sizes?.maxWidth ? formatWidth(sizes.maxWidth) : "";
|
|
1189
|
+
// const minWidth = sizes?.minWidth ? formatWidth(sizes.minWidth) : "";
|
|
1190
|
+
// console.log({
|
|
1191
|
+
// brandingConfig,
|
|
1192
|
+
// initialHeight,
|
|
1193
|
+
// widgetConfig: this.context.widgetConfig,
|
|
1194
|
+
// });
|
|
1195
|
+
// // const skeletonHTML = getSkeleton({
|
|
1196
|
+
// // height: initialHeight,
|
|
1197
|
+
// // skeletonBackgroundColor,
|
|
1198
|
+
// // skeletonShimmerColor,
|
|
1199
|
+
// // borderColor,
|
|
1200
|
+
// // });
|
|
1201
|
+
// // const skeletonContainer = document.createElement("div");
|
|
1202
|
+
// // skeletonContainer.innerHTML = skeletonHTML;
|
|
1203
|
+
// const frame = this._createFrame({
|
|
1204
|
+
// minWidth,
|
|
1205
|
+
// maxWidth,
|
|
1206
|
+
// initialHeight,
|
|
1207
|
+
// });
|
|
1208
|
+
// const element = this._findElement();
|
|
1209
|
+
// // element.innerHTML = skeletonHTML;
|
|
1210
|
+
// // Hide frame initially
|
|
1211
|
+
// frame.style.display = "none";
|
|
1212
|
+
// const injectContents = (target: HTMLElement | ShadowRoot) => {
|
|
1213
|
+
// // Optional: Clear target to prevent duplicates if load() is called twice
|
|
1214
|
+
// // target.innerHTML = "";
|
|
1215
|
+
// // target.appendChild(skeletonContainer);
|
|
1216
|
+
// target.appendChild(frame);
|
|
1217
|
+
// };
|
|
1218
|
+
// if (this.context?.container) {
|
|
1219
|
+
// // Custom container is used
|
|
1220
|
+
// element.style.visibility = "hidden";
|
|
1221
|
+
// element.style.height = "0";
|
|
1222
|
+
// element.style["overflow-y"] = "hidden";
|
|
1223
|
+
// }
|
|
1224
|
+
// if (this.container) {
|
|
1225
|
+
// if (element.shadowRoot) {
|
|
1226
|
+
// if (element.shadowRoot.lastChild?.nodeName === "IFRAME") {
|
|
1227
|
+
// element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
|
|
1228
|
+
// } else {
|
|
1229
|
+
// injectContents(element.shadowRoot);
|
|
1230
|
+
// }
|
|
1231
|
+
// } else if (element.firstChild) {
|
|
1232
|
+
// // If replacing, wipe and reload
|
|
1233
|
+
// element.innerHTML = "";
|
|
1234
|
+
// injectContents(element);
|
|
1235
|
+
// } else {
|
|
1236
|
+
// injectContents(element);
|
|
1237
|
+
// }
|
|
1238
|
+
// }
|
|
1239
|
+
// // else if (!element.firstChild || element.firstChild.nodeName === "#text") {
|
|
1240
|
+
// // injectContents(element);
|
|
1241
|
+
// // }
|
|
1242
|
+
// const { contentWindow } = frame;
|
|
1243
|
+
// if (!contentWindow) {
|
|
1244
|
+
// throw new Error("Frame needs a content window");
|
|
1245
|
+
// }
|
|
1246
|
+
// const frameDoc = contentWindow.document;
|
|
1247
|
+
// frameDoc.open();
|
|
1248
|
+
// console.log({ content: this.content, context: this.context, this: this });
|
|
1249
|
+
// const domain = this.widgetApi.domain;
|
|
1250
|
+
// frameDoc.write(`
|
|
1251
|
+
// ${
|
|
1252
|
+
// brandingConfig?.main?.brandFont &&
|
|
1253
|
+
// `
|
|
1254
|
+
// <link rel="preconnect" href="https://fast${
|
|
1255
|
+
// domain === "https://staging.referralsaasquatch.com" && "-staging"
|
|
1256
|
+
// }.ssqt.io">
|
|
1257
|
+
// <link rel="preconnect" href="https://fonts.gstatic.com">
|
|
1258
|
+
// <link rel="preconnect" href="https://fonts.googleapis.com">
|
|
1259
|
+
// <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
1260
|
+
// brandingConfig?.main?.brandFont
|
|
1261
|
+
// )}" as="style">`
|
|
1262
|
+
// }
|
|
1263
|
+
// <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
|
|
1264
|
+
// <style data-styles>
|
|
1265
|
+
// html { visibility:hidden;}
|
|
1266
|
+
// </style>
|
|
1267
|
+
// ${this.content}
|
|
1268
|
+
// `);
|
|
1269
|
+
// frameDoc.close();
|
|
1270
|
+
// domready(frameDoc, async () => {
|
|
1271
|
+
// // if (skeletonContainer && skeletonContainer.parentNode) {
|
|
1272
|
+
// // skeletonContainer.parentNode.removeChild(skeletonContainer);
|
|
1273
|
+
// // }
|
|
1274
|
+
// frame.style.display = "block";
|
|
1275
|
+
// const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
|
|
1276
|
+
// // @ts-ignore -- number will be cast to string by browsers
|
|
1277
|
+
// frame.height = initialHeight || frameDoc.body.scrollHeight;
|
|
1278
|
+
// console.log({ height: frameDoc.body.scrollHeight });
|
|
1279
|
+
// // Adjust frame height when size of body changes
|
|
1280
|
+
// /* istanbul ignore next: hard to test */
|
|
1281
|
+
// const ro = new contentWindow["ResizeObserver"]((entries) => {
|
|
1282
|
+
// for (const entry of entries) {
|
|
1283
|
+
// const { height } = entry.contentRect;
|
|
1284
|
+
// // @ts-ignore -- number will be cast to string by browsers
|
|
1285
|
+
// frame.height = height;
|
|
1286
|
+
// }
|
|
1287
|
+
// });
|
|
1288
|
+
// const container = await this._findInnerContainer(frame);
|
|
1289
|
+
// ro.observe(container);
|
|
1290
|
+
// if (this._shouldFireLoadEvent()) {
|
|
1291
|
+
// this._loadEvent(_sqh);
|
|
1292
|
+
// _log("loaded");
|
|
1293
|
+
// } else if (frameDoc) {
|
|
1294
|
+
// this._attachLoadEventListener(frameDoc, _sqh);
|
|
1295
|
+
// }
|
|
1296
|
+
// });
|
|
1297
|
+
// }
|
|
1568
1298
|
/**
|
|
1569
1299
|
* Un-hide if element is available and refresh data
|
|
1570
1300
|
*/
|