@saasquatch/squatch-js 2.8.2-13 → 2.8.2-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/squatch.js CHANGED
@@ -1110,351 +1110,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1110
1110
  setTimeout(resolve, duration);
1111
1111
  });
1112
1112
  }
1113
- const getSkeleton = ({
1114
- height = "500px",
1115
- skeletonBackgroundColor = "#e0e0e0",
1116
- skeletonShimmerColor = "#f5f5f5",
1117
- borderColor = "#ccc"
1118
- }) => {
1119
- return `
1120
- <style>
1121
- * {
1122
- box-sizing: border-box;
1123
- padding: 0;
1124
- margin: 0;
1125
- }
1126
-
1127
- .widget-container {
1128
- background: white;
1129
- width: 100%;
1130
- max-width: 900px;
1131
- padding: 40px;
1132
- border-radius: 12px;
1133
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
1134
- box-sizing: border-box;
1135
- }
1136
-
1137
- @keyframes shimmer {
1138
- 0% {
1139
- background-position: -100% 0;
1140
- }
1141
- 100% {
1142
- background-position: 100% 0;
1143
- }
1144
- }
1145
-
1146
- .skeleton {
1147
- background: ${skeletonBackgroundColor};
1148
- background: linear-gradient(
1149
- 90deg,
1150
- ${skeletonBackgroundColor} 25%,
1151
- ${skeletonShimmerColor} 50%,
1152
- ${skeletonBackgroundColor} 75%
1153
- );
1154
- background-size: 200% 100%;
1155
- animation: shimmer 1.5s infinite linear;
1156
- border-radius: 6px;
1157
- margin-bottom: 12px;
1158
- }
1159
-
1160
- .sk-title-lg {
1161
- height: 36px;
1162
- width: 50%;
1163
- margin-bottom: 16px;
1164
- }
1165
- .sk-title-md {
1166
- height: 28px;
1167
- width: 30%;
1168
- margin-bottom: 20px;
1169
- margin-top: 40px;
1170
- }
1171
- .sk-text {
1172
- height: 16px;
1173
- width: 80%;
1174
- margin-bottom: 8px;
1175
- }
1176
- .sk-text-short {
1177
- width: 40%;
1178
- }
1179
- .sk-label {
1180
- height: 14px;
1181
- width: 25%;
1182
- margin-bottom: 10px;
1183
- }
1184
-
1185
- .hero-section {
1186
- display: flex;
1187
- gap: 40px;
1188
- margin-bottom: 40px;
1189
- border-bottom: 1px solid ${borderColor};
1190
- padding-bottom: 40px;
1191
- flex-direction: row;
1192
- }
1193
- .hero-content {
1194
- flex: 1;
1195
- display: flex;
1196
- flex-direction: column;
1197
- justify-content: center;
1198
- }
1199
- .hero-image {
1200
- flex: 1;
1201
- height: 300px;
1202
- border-radius: 12px;
1203
- }
1204
-
1205
- .share-section {
1206
- margin-bottom: 40px;
1207
- }
1208
- .sk-input {
1209
- height: 50px;
1210
- width: 100%;
1211
- border-radius: 8px;
1212
- margin-bottom: 16px;
1213
- }
1214
- .social-buttons {
1215
- display: flex;
1216
- gap: 12px;
1217
- }
1218
- .sk-btn-social {
1219
- flex: 1;
1220
- height: 50px;
1221
- border-radius: 8px;
1222
- }
1223
-
1224
- .stats-section {
1225
- display: flex;
1226
- gap: 24px;
1227
- margin-bottom: 40px;
1228
- padding: 30px 0;
1229
- border-top: 1px solid ${borderColor};
1230
- border-bottom: 1px solid ${borderColor};
1231
- }
1232
- .stat-card {
1233
- flex: 1;
1234
- display: flex;
1235
- flex-direction: column;
1236
- align-items: center;
1237
- }
1238
- .stat-divider {
1239
- padding-left: 24px;
1240
- }
1241
-
1242
- .sk-stat-num {
1243
- height: 48px;
1244
- width: 120px;
1245
- margin-bottom: 8px;
1246
- }
1247
- .sk-stat-label {
1248
- height: 18px;
1249
- width: 80px;
1250
- }
1251
-
1252
- .table-header {
1253
- display: flex;
1254
- gap: 16px;
1255
- margin-bottom: 16px;
1256
- }
1257
- .sk-th {
1258
- height: 16px;
1259
- }
1260
- .table-row {
1261
- display: flex;
1262
- align-items: center;
1263
- gap: 16px;
1264
- padding: 16px 0;
1265
- border-bottom: 1px solid ${borderColor};
1266
- }
1267
-
1268
- .col-user {
1269
- flex: 2;
1270
- }
1271
- .col-status {
1272
- flex: 1;
1273
- }
1274
- .col-reward {
1275
- flex: 2;
1276
- }
1277
- .col-date {
1278
- flex: 1;
1279
- }
1280
-
1281
- .sk-badge {
1282
- height: 28px;
1283
- width: 90px;
1284
- border-radius: 14px;
1285
- }
1286
- .sk-reward-block {
1287
- height: 36px;
1288
- width: 100%;
1289
- border-radius: 6px;
1290
- }
1291
-
1292
- .pagination {
1293
- display: flex;
1294
- justify-content: flex-end;
1295
- gap: 8px;
1296
- margin-top: 24px;
1297
- }
1298
- .sk-btn-page {
1299
- height: 36px;
1300
- width: 64px;
1301
- border-radius: 6px;
1302
- margin-bottom: 0;
1303
- }
1304
-
1305
- @media (max-width: 768px) {
1306
- body {
1307
- padding: 20px;
1308
- }
1309
- .widget-container {
1310
- padding: 24px;
1311
- }
1312
-
1313
- .hero-section {
1314
- flex-direction: column-reverse;
1315
- gap: 24px;
1316
- }
1317
- .hero-image {
1318
- height: 220px;
1319
- width: 100%;
1320
- }
1321
- .sk-title-lg {
1322
- width: 80%;
1323
- }
1324
-
1325
- .col-date {
1326
- display: none;
1327
- }
1328
- }
1329
-
1330
- @media (max-width: 480px) {
1331
- body {
1332
- padding: 10px;
1333
- }
1334
- .widget-container {
1335
- padding: 16px;
1336
- }
1337
-
1338
- .sk-stat-num {
1339
- width: 80px;
1340
- height: 40px;
1341
- }
1342
-
1343
- .col-reward {
1344
- display: none;
1345
- }
1346
-
1347
- .col-user {
1348
- flex: 3;
1349
- }
1350
- .col-status {
1351
- flex: 2;
1352
- display: flex;
1353
- justify-content: flex-end;
1354
- }
1355
- }
1356
- </style>
1357
-
1358
- <div class="widget-container">
1359
- <div class="hero-section">
1360
- <div class="hero-content">
1361
- <div class="skeleton sk-title-lg"></div>
1362
- <div class="skeleton sk-text"></div>
1363
- <div class="skeleton sk-text sk-text-short"></div>
1364
- </div>
1365
- <div class="skeleton hero-image"></div>
1366
- </div>
1367
-
1368
- <div class="share-section">
1369
- <div class="skeleton sk-label"></div>
1370
- <div class="skeleton sk-input"></div>
1371
- <div class="social-buttons">
1372
- <div class="skeleton sk-btn-social"></div>
1373
- <div class="skeleton sk-btn-social"></div>
1374
- <div class="skeleton sk-btn-social"></div>
1375
- <div class="skeleton sk-btn-social"></div>
1376
- </div>
1377
- </div>
1378
-
1379
- <div
1380
- class="skeleton sk-title-md"
1381
- style="margin-top: 0; width: 30%; margin-left: auto; margin-right: auto"
1382
- ></div>
1383
- <div
1384
- class="skeleton sk-text"
1385
- style="width: 60%; margin-left: auto; margin-right: auto"
1386
- ></div>
1387
-
1388
- <div class="stats-section">
1389
- <div class="stat-card">
1390
- <div class="skeleton sk-stat-num"></div>
1391
- <div class="skeleton sk-stat-label"></div>
1392
- </div>
1393
- <div class="stat-card stat-divider">
1394
- <div class="skeleton sk-stat-num"></div>
1395
- <div class="skeleton sk-stat-label"></div>
1396
- </div>
1397
- </div>
1398
-
1399
- <div class="skeleton sk-title-md"></div>
1400
-
1401
- <div class="table-header">
1402
- <div class="skeleton sk-th col-user"></div>
1403
- <div class="skeleton sk-th col-status"></div>
1404
- <div class="skeleton sk-th col-reward"></div>
1405
- <div class="skeleton sk-th col-date"></div>
1406
- </div>
1407
-
1408
- <div class="table-row">
1409
- <div class="col-user">
1410
- <div class="skeleton sk-text" style="width: 70%; margin: 0"></div>
1411
- </div>
1412
- <div class="col-status">
1413
- <div class="skeleton sk-badge" style="margin: 0"></div>
1414
- </div>
1415
- <div class="col-reward">
1416
- <div class="skeleton sk-reward-block" style="margin: 0"></div>
1417
- </div>
1418
- <div class="col-date">
1419
- <div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
1420
- </div>
1421
- </div>
1422
- <div class="table-row">
1423
- <div class="col-user">
1424
- <div class="skeleton sk-text" style="width: 60%; margin: 0"></div>
1425
- </div>
1426
- <div class="col-status">
1427
- <div class="skeleton sk-badge" style="margin: 0"></div>
1428
- </div>
1429
- <div class="col-reward">
1430
- <div class="skeleton sk-reward-block" style="margin: 0"></div>
1431
- </div>
1432
- <div class="col-date">
1433
- <div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
1434
- </div>
1435
- </div>
1436
- <div class="table-row">
1437
- <div class="col-user">
1438
- <div class="skeleton sk-text" style="width: 75%; margin: 0"></div>
1439
- </div>
1440
- <div class="col-status">
1441
- <div class="skeleton sk-badge" style="margin: 0"></div>
1442
- </div>
1443
- <div class="col-reward">
1444
- <div class="skeleton sk-reward-block" style="margin: 0"></div>
1445
- </div>
1446
- <div class="col-date">
1447
- <div class="skeleton sk-text" style="width: 80%; margin: 0"></div>
1448
- </div>
1449
- </div>
1450
-
1451
- <div class="pagination">
1452
- <div class="skeleton sk-btn-page"></div>
1453
- <div class="skeleton sk-btn-page"></div>
1454
- </div>
1455
- </div>
1456
- `;
1457
- };
1458
1113
  const _log$7 = browserExports.debug("squatch-js:EMBEDwidget");
1459
1114
  class EmbedWidget extends Widget {
1460
1115
  constructor(params, container) {
@@ -1469,9 +1124,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1469
1124
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1470
1125
  const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1471
1126
  const initialHeight = brandingConfig == null ? void 0 : brandingConfig.loadingHeight;
1472
- const skeletonBackgroundColor = (_d = (_c = brandingConfig == null ? void 0 : brandingConfig.color) == null ? void 0 : _c.loadingSkeleton) == null ? void 0 : _d.background;
1473
- const skeletonShimmerColor = (_f = (_e = brandingConfig == null ? void 0 : brandingConfig.color) == null ? void 0 : _e.loadingSkeleton) == null ? void 0 : _f.animationBackground;
1474
- const borderColor = (_g = brandingConfig == null ? void 0 : brandingConfig.border) == null ? void 0 : _g.borderColor;
1127
+ (_d = (_c = brandingConfig == null ? void 0 : brandingConfig.color) == null ? void 0 : _c.loadingSkeleton) == null ? void 0 : _d.background;
1128
+ (_f = (_e = brandingConfig == null ? void 0 : brandingConfig.color) == null ? void 0 : _e.loadingSkeleton) == null ? void 0 : _f.animationBackground;
1129
+ (_g = brandingConfig == null ? void 0 : brandingConfig.border) == null ? void 0 : _g.borderColor;
1475
1130
  const sizes = (_h = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _h.embeddedWidgets;
1476
1131
  const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "";
1477
1132
  const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "";
@@ -1480,24 +1135,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1480
1135
  initialHeight,
1481
1136
  widgetConfig: this.context.widgetConfig
1482
1137
  });
1483
- const skeletonHTML = getSkeleton({
1484
- height: initialHeight,
1485
- skeletonBackgroundColor,
1486
- skeletonShimmerColor,
1487
- borderColor
1488
- });
1489
- const skeletonContainer = document.createElement("div");
1490
- skeletonContainer.innerHTML = skeletonHTML;
1491
1138
  const frame = this._createFrame({
1492
1139
  minWidth,
1493
1140
  maxWidth,
1494
1141
  initialHeight
1495
1142
  });
1496
1143
  const element = this._findElement();
1497
- element.innerHTML = skeletonHTML;
1498
1144
  frame.style.display = "none";
1499
1145
  const injectContents = (target) => {
1500
- target.appendChild(skeletonContainer);
1501
1146
  target.appendChild(frame);
1502
1147
  };
1503
1148
  if ((_i = this.context) == null ? void 0 : _i.container) {
@@ -1546,9 +1191,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1546
1191
  `);
1547
1192
  frameDoc.close();
1548
1193
  domready(frameDoc, async () => {
1549
- if (skeletonContainer && skeletonContainer.parentNode) {
1550
- skeletonContainer.parentNode.removeChild(skeletonContainer);
1551
- }
1552
1194
  frame.style.display = "block";
1553
1195
  const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
1554
1196
  frame.height = initialHeight || frameDoc.body.scrollHeight;
@@ -2470,49 +2112,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2470
2112
  this.loaded = true;
2471
2113
  this.container = this.getAttribute("container");
2472
2114
  const skeletonHTML = `
2473
- <div id="loading-skeleton-content">
2474
- <h1>DO I SEE THIS ?</h1>
2115
+ <div>
2116
+ <h1>Do I see this text ????</h1>
2475
2117
  </div>
2476
2118
  `;
2477
- console.log(
2478
- "/////////////////////////////////TESTING//////////////////////////////"
2479
- );
2480
2119
  const skeletonContainer = document.createElement("div");
2481
2120
  skeletonContainer.id = "loading-skeleton";
2482
2121
  skeletonContainer.innerHTML = skeletonHTML;
2483
- skeletonContainer.style.width = "100%";
2484
2122
  const root = this.shadowRoot || this.attachShadow({ mode: "open" });
2485
- if (root.firstChild) {
2486
- root.insertBefore(skeletonContainer, root.firstChild);
2487
- } else {
2488
- root.appendChild(skeletonContainer);
2489
- }
2490
- const removeSkeleton = () => {
2491
- const el = root.getElementById("loading-skeleton");
2492
- if (el) {
2493
- el.remove();
2494
- console.log("Skeleton removed successfully via event");
2495
- }
2496
- };
2497
- this.addEventListener("sq:load", removeSkeleton);
2498
- try {
2499
- await this.renderWidget();
2500
- console.log("Widget rendered (initialization complete)");
2501
- setTimeout(() => {
2502
- const el = root.getElementById("loading-skeleton");
2503
- if (el) {
2504
- console.warn("Removing skeleton via timeout (load event missing)");
2505
- el.remove();
2506
- }
2507
- }, 5e3);
2508
- } catch (err) {
2509
- console.error("Critical Error in renderWidget:", err);
2510
- removeSkeleton();
2123
+ root.innerHTML = "";
2124
+ root.appendChild(skeletonContainer);
2125
+ await this.renderWidget();
2126
+ const loadingElement = root.getElementById("loading-skeleton");
2127
+ if (loadingElement) {
2128
+ loadingElement.remove();
2511
2129
  }
2512
2130
  if (this.getAttribute("open") !== null) this.open();
2513
- console.log(
2514
- "/////////////////////////////////DO YOU SEE THIS CONSOLE LOG????//////////////////////////////"
2515
- );
2516
2131
  }
2517
2132
  }
2518
2133
  class DeclarativePopupWidget extends DeclarativeWidget {
@@ -2538,52 +2153,30 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2538
2153
  }
2539
2154
  }
2540
2155
  async connectedCallback() {
2156
+ var _a2;
2541
2157
  this.loaded = true;
2542
2158
  this.container = this.getAttribute("container");
2543
2159
  const skeletonHTML = `
2544
- <div id="loading-skeleton-content">
2545
- <h1>DO I SEE THIS ?</h1>
2546
- </div>
2547
- `;
2548
- console.log(
2549
- "/////////////////////////////////TESTING//////////////////////////////"
2550
- );
2160
+ <div>
2161
+ <h1>Dynamic Content</h1>
2162
+ <p>This content was dynamically added to the widget before it loaded.</p>
2163
+ </div>
2164
+ `;
2551
2165
  const skeletonContainer = document.createElement("div");
2552
2166
  skeletonContainer.id = "loading-skeleton";
2553
2167
  skeletonContainer.innerHTML = skeletonHTML;
2554
- skeletonContainer.style.width = "100%";
2555
- const root = this.shadowRoot || this.attachShadow({ mode: "open" });
2556
- if (root.firstChild) {
2557
- root.insertBefore(skeletonContainer, root.firstChild);
2558
- } else {
2559
- root.appendChild(skeletonContainer);
2168
+ if (!this.shadowRoot) {
2169
+ this.attachShadow({ mode: "open" });
2560
2170
  }
2561
- const removeSkeleton = () => {
2562
- const el = root.getElementById("loading-skeleton");
2563
- if (el) {
2564
- el.remove();
2565
- console.log("Skeleton removed successfully via event");
2566
- }
2567
- };
2568
- this.addEventListener("sq:load", removeSkeleton);
2569
- try {
2570
- await this.renderWidget();
2571
- console.log("Widget rendered (initialization complete)");
2572
- setTimeout(() => {
2573
- const el = root.getElementById("loading-skeleton");
2574
- if (el) {
2575
- console.warn("Removing skeleton via timeout (load event missing)");
2576
- el.remove();
2577
- }
2578
- }, 5e3);
2579
- } catch (err) {
2580
- console.error("Critical Error in renderWidget:", err);
2581
- removeSkeleton();
2171
+ if (this.shadowRoot) {
2172
+ this.shadowRoot.innerHTML = skeletonHTML;
2173
+ }
2174
+ await this.renderWidget();
2175
+ const loadingElement = (_a2 = this.shadowRoot) == null ? void 0 : _a2.getElementById("loading-skeleton");
2176
+ if (loadingElement) {
2177
+ loadingElement.remove();
2582
2178
  }
2583
2179
  if (this.getAttribute("open") !== null) this.open();
2584
- console.log(
2585
- "/////////////////////////////////DO YOU SEE THIS CONSOLE LOG????//////////////////////////////"
2586
- );
2587
2180
  }
2588
2181
  }
2589
2182
  class SquatchEmbed extends DeclarativeEmbedWidget {