@saasquatch/squatch-js 2.8.2-36 → 2.8.2-37

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.
@@ -702,7 +702,6 @@ class WidgetApi {
702
702
  const raw = params;
703
703
  const clean = validatePasswordlessConfig(raw);
704
704
  const { widgetType, engagementMedium = "POPUP", jwt, user } = clean;
705
- console.log({ params });
706
705
  const tenantAlias = encodeURIComponent(this.tenantAlias);
707
706
  const accountId = (user == null ? void 0 : user.accountId) ? encodeURIComponent(user.accountId) : null;
708
707
  const userId = (user == null ? void 0 : user.id) ? encodeURIComponent(user.id) : null;
@@ -891,9 +890,6 @@ class Widget {
891
890
  if ((options == null ? void 0 : options.maxWidth) || (options == null ? void 0 : options.minWidth)) {
892
891
  frame.style.width = "100%";
893
892
  }
894
- if (options == null ? void 0 : options.initialHeight) {
895
- frame.height = options.initialHeight;
896
- }
897
893
  return frame;
898
894
  }
899
895
  _findFrame() {
@@ -1114,22 +1110,15 @@ class EmbedWidget extends Widget {
1114
1110
  super(params);
1115
1111
  __publicField(this, "show", this.open);
1116
1112
  __publicField(this, "hide", this.close);
1117
- if (container) {
1118
- this.container = container;
1119
- }
1113
+ if (container) this.container = container;
1120
1114
  }
1121
1115
  async load() {
1122
- var _a2, _b, _c, _d, _e, _f, _g;
1116
+ var _a2, _b, _c, _d, _e;
1123
1117
  const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1124
- const initialHeight = brandingConfig == null ? void 0 : brandingConfig.loadingHeight;
1125
1118
  const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.embeddedWidgets;
1126
1119
  const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "";
1127
1120
  const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "";
1128
- const frame = this._createFrame({
1129
- minWidth,
1130
- maxWidth,
1131
- initialHeight
1132
- });
1121
+ const frame = this._createFrame({ minWidth, maxWidth });
1133
1122
  const element = this._findElement();
1134
1123
  if ((_d = this.context) == null ? void 0 : _d.container) {
1135
1124
  element.style.visibility = "hidden";
@@ -1157,29 +1146,14 @@ class EmbedWidget extends Widget {
1157
1146
  }
1158
1147
  const frameDoc = contentWindow.document;
1159
1148
  frameDoc.open();
1160
- const domain = this.widgetApi.domain;
1161
- frameDoc.write(`
1162
- ${((_f = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _f.brandFont) ? `
1163
- <link rel="preconnect" href="https://fast${domain === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
1164
- <link rel="preconnect" href="https://fonts.gstatic.com">
1165
- <link rel="preconnect" href="https://fonts.googleapis.com">
1166
- <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
1167
- (_g = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _g.brandFont
1168
- )}" as="style">` : ""}
1169
- <link rel="dns-prefetch" href="https://res.cloudinary.com">
1170
- <link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
1171
- <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
1172
- <style data-styles>
1173
- html { visibility:hidden;}
1174
- </style>
1175
- ${this.content}
1176
-
1177
- `);
1149
+ frameDoc.write(this.content);
1150
+ frameDoc.write(
1151
+ `<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
1152
+ );
1178
1153
  frameDoc.close();
1179
1154
  domready(frameDoc, async () => {
1180
1155
  const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
1181
- frame.height = initialHeight || frameDoc.body.scrollHeight;
1182
- console.log({ height: frameDoc.body.scrollHeight });
1156
+ frame.height = frameDoc.body.scrollHeight;
1183
1157
  const ro = new contentWindow["ResizeObserver"]((entries) => {
1184
1158
  for (const entry of entries) {
1185
1159
  const { height } = entry.contentRect;
@@ -1275,10 +1249,11 @@ class PopupWidget extends Widget {
1275
1249
  };
1276
1250
  }
1277
1251
  }
1278
- _createPopupDialog(brandingConfig) {
1279
- var _a2;
1252
+ _createPopupDialog() {
1253
+ var _a2, _b, _c;
1280
1254
  const dialog = document.createElement("dialog");
1281
- const sizes = (_a2 = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _a2.popupWidgets;
1255
+ const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1256
+ const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.popupWidgets;
1282
1257
  const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "auto";
1283
1258
  const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "500px";
1284
1259
  dialog.id = this.id;
@@ -1294,18 +1269,14 @@ class PopupWidget extends Widget {
1294
1269
  return dialog;
1295
1270
  }
1296
1271
  async load() {
1297
- var _a2, _b, _c, _d, _e;
1298
- console.log("TESTING!");
1299
- const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1300
- const initialHeight = brandingConfig == null ? void 0 : brandingConfig.loadingHeight;
1301
- console.log({ initialHeight, brandingConfig });
1302
- const frame = this._createFrame({ initialHeight });
1272
+ var _a2;
1273
+ const frame = this._createFrame();
1303
1274
  this._initialiseCTA();
1304
1275
  const element = this.container ? this._findElement() : document.body;
1305
1276
  const dialogParent = element.shadowRoot || element;
1306
- const dialog = this._createPopupDialog(brandingConfig);
1277
+ const dialog = this._createPopupDialog();
1307
1278
  dialog.appendChild(frame);
1308
- if (((_c = dialogParent.lastChild) == null ? void 0 : _c.nodeName) === "DIALOG") {
1279
+ if (((_a2 = dialogParent.lastChild) == null ? void 0 : _a2.nodeName) === "DIALOG") {
1309
1280
  dialogParent.replaceChild(dialog, dialogParent.lastChild);
1310
1281
  } else {
1311
1282
  dialogParent.appendChild(dialog);
@@ -1316,29 +1287,15 @@ class PopupWidget extends Widget {
1316
1287
  }
1317
1288
  const frameDoc = contentWindow.document;
1318
1289
  frameDoc.open();
1319
- const domain = this.widgetApi.domain;
1320
- frameDoc.write(`
1321
- ${((_d = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _d.brandFont) ? `
1322
- <link rel="preconnect" href="https://fast${domain === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
1323
- <link rel="preconnect" href="https://fonts.gstatic.com">
1324
- <link rel="preconnect" href="https://fonts.googleapis.com">
1325
- <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
1326
- (_e = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _e.brandFont
1327
- )}" as="style">` : ""}
1328
- <link rel="dns-prefetch" href="https://res.cloudinary.com">
1329
- <link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
1330
- <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
1331
- <style data-styles>
1332
- html { visibility:hidden;}
1333
- </style>
1334
- ${this.content}
1335
-
1336
- `);
1290
+ frameDoc.write(this.content);
1291
+ frameDoc.write(
1292
+ `<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
1293
+ );
1337
1294
  frameDoc.close();
1338
1295
  _log$6("Popup template loaded into iframe");
1339
- await this._setupResizeHandler(frame, initialHeight);
1296
+ await this._setupResizeHandler(frame);
1340
1297
  }
1341
- async _setupResizeHandler(frame, initialHeight) {
1298
+ async _setupResizeHandler(frame) {
1342
1299
  const { contentWindow } = frame;
1343
1300
  if (!contentWindow) {
1344
1301
  throw new Error("Frame needs a content window");
@@ -1346,7 +1303,7 @@ class PopupWidget extends Widget {
1346
1303
  const frameDoc = contentWindow.document;
1347
1304
  domready(frameDoc, async () => {
1348
1305
  frameDoc.body.style.overflowY = "hidden";
1349
- frame.height = initialHeight || frameDoc.body.offsetHeight;
1306
+ frame.height = `${frameDoc.body.offsetHeight}px`;
1350
1307
  const ro = new contentWindow["ResizeObserver"]((entries) => {
1351
1308
  for (const entry of entries) {
1352
1309
  const { top, bottom } = entry.contentRect;
@@ -1874,264 +1831,6 @@ function _getAutoConfig() {
1874
1831
  }
1875
1832
  };
1876
1833
  }
1877
- const getSkeleton = ({
1878
- type = "verified-access",
1879
- height = "500px",
1880
- skeletonBackgroundColor = "#e0e0e0",
1881
- skeletonShimmerColor = "#f5f5f5"
1882
- }) => {
1883
- const referrerHTML = `
1884
- <div class="hero-section">
1885
- <div class="hero-content">
1886
- <div class="skeleton sk-title-lg"></div>
1887
- <div class="skeleton sk-text"></div>
1888
- <div class="skeleton sk-text sk-text-short"></div>
1889
- </div>
1890
- <div class="skeleton hero-image"></div>
1891
- </div>
1892
-
1893
- <div class="share-section">
1894
- <div class="skeleton sk-label"></div>
1895
- <div class="skeleton sk-input"></div>
1896
- <div class="social-buttons">
1897
- <div class="skeleton sk-btn-social"></div>
1898
- <div class="skeleton sk-btn-social"></div>
1899
- <div class="skeleton sk-btn-social"></div>
1900
- <div class="skeleton sk-btn-social"></div>
1901
- </div>
1902
- </div>
1903
-
1904
- <div class="skeleton sk-title-md" style="margin-top: 0; width: 30%; margin-left: auto; margin-right: auto"></div>
1905
- <div class="skeleton sk-text" style="width: 60%; margin-left: auto; margin-right: auto"></div>
1906
-
1907
- <div class="stats-section">
1908
- <div class="stat-card">
1909
- <div class="skeleton sk-stat-num"></div>
1910
- <div class="skeleton sk-stat-label"></div>
1911
- </div>
1912
- <div class="stat-card stat-divider">
1913
- <div class="skeleton sk-stat-num"></div>
1914
- <div class="skeleton sk-stat-label"></div>
1915
- </div>
1916
- </div>
1917
-
1918
- <div class="skeleton sk-title-md"></div>
1919
-
1920
- <div class="table-header">
1921
- <div class="skeleton sk-th col-user"></div>
1922
- <div class="skeleton sk-th col-status"></div>
1923
- <div class="skeleton sk-th col-reward"></div>
1924
- <div class="skeleton sk-th col-date"></div>
1925
- </div>
1926
-
1927
- <div class="table-row">
1928
- <div class="col-user"><div class="skeleton sk-text" style="width: 70%; margin: 0"></div></div>
1929
- <div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
1930
- <div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
1931
- <div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
1932
- </div>
1933
-
1934
- <div class="table-row">
1935
- <div class="col-user"><div class="skeleton sk-text" style="width: 60%; margin: 0"></div></div>
1936
- <div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
1937
- <div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
1938
- <div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
1939
- </div>
1940
-
1941
- <div class="table-row">
1942
- <div class="col-user"><div class="skeleton sk-text" style="width: 75%; margin: 0"></div></div>
1943
- <div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
1944
- <div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
1945
- <div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
1946
- </div>
1947
-
1948
- <div class="pagination">
1949
- <div class="skeleton sk-btn-page"></div>
1950
- <div class="skeleton sk-btn-page"></div>
1951
- </div>
1952
- `;
1953
- const instantAccessHTML = `
1954
- <div class="hero-section instant-access-layout">
1955
- <div class="skeleton hero-image ia-image"></div>
1956
-
1957
- <div class="hero-content ia-content">
1958
- <div class="skeleton sk-title-lg ia-center"></div>
1959
- <div class="skeleton sk-text ia-center"></div>
1960
-
1961
- <div class="skeleton sk-btn-action"></div>
1962
-
1963
- <div class="skeleton sk-label"></div>
1964
- <div class="input-group">
1965
- <div class="skeleton sk-input"></div>
1966
- <div class="skeleton sk-btn-copy"></div>
1967
- </div>
1968
-
1969
- <div class="skeleton sk-text-short ia-center" style="margin-top: 20px; width: 30%"></div>
1970
- <div class="skeleton sk-text-short ia-center" style="width: 20%"></div>
1971
- </div>
1972
- </div>
1973
- `;
1974
- return `
1975
- <style>
1976
- * {
1977
- box-sizing: border-box;
1978
- padding: 0;
1979
- margin: 0;
1980
- }
1981
-
1982
- .widget-container {
1983
- background: white;
1984
- width: 100%;
1985
- padding: 40px;
1986
- box-sizing: border-box;
1987
- overflow: hidden;
1988
- }
1989
-
1990
- @keyframes shimmer {
1991
- 0% { background-position: -100% 0; }
1992
- 100% { background-position: 100% 0; }
1993
- }
1994
-
1995
- .skeleton {
1996
- background: ${skeletonBackgroundColor};
1997
- background: linear-gradient(
1998
- 90deg,
1999
- ${skeletonBackgroundColor} 25%,
2000
- ${skeletonShimmerColor} 50%,
2001
- ${skeletonBackgroundColor} 75%
2002
- );
2003
- background-size: 200% 100%;
2004
- animation: shimmer 1.5s infinite linear;
2005
- border-radius: 6px;
2006
- margin-bottom: 12px;
2007
- }
2008
-
2009
- /* Typography Skeletons */
2010
- .sk-title-lg { height: 36px; width: 80%; margin-bottom: 16px; }
2011
- .sk-title-md { height: 28px; width: 30%; margin-bottom: 20px; margin-top: 40px; }
2012
- .sk-text { height: 16px; width: 90%; margin-bottom: 8px; }
2013
- .sk-text-short { width: 40%; }
2014
- .sk-label { height: 14px; width: 25%; margin-bottom: 10px; }
2015
-
2016
- /* Layouts */
2017
- .hero-section {
2018
- display: flex;
2019
- gap: 40px;
2020
- margin-bottom: 40px;
2021
- padding-bottom: 40px;
2022
- flex-direction: row;
2023
- height: 100%;
2024
- /* Removed border-bottom */
2025
- }
2026
-
2027
- .hero-content {
2028
- flex: 1;
2029
- display: flex;
2030
- flex-direction: column;
2031
- justify-content: center;
2032
- }
2033
-
2034
- .hero-image {
2035
- flex: 1;
2036
- height: 300px;
2037
- border-radius: 12px;
2038
- }
2039
-
2040
- /* -- Specific Instant Access Overrides -- */
2041
- .instant-access-layout {
2042
- margin-bottom: 0;
2043
- padding-bottom: 0;
2044
- align-items: center;
2045
- }
2046
- .ia-image {
2047
- height: 400px;
2048
- }
2049
- .ia-center {
2050
- margin-left: auto;
2051
- margin-right: auto;
2052
- }
2053
- .ia-content {
2054
- align-items: center;
2055
- text-align: center;
2056
- }
2057
- .sk-btn-action {
2058
- height: 45px;
2059
- width: 140px;
2060
- border-radius: 6px;
2061
- margin: 24px auto;
2062
- }
2063
- .input-group {
2064
- display: flex;
2065
- gap: 10px;
2066
- width: 100%;
2067
- max-width: 400px;
2068
- }
2069
- .sk-btn-copy {
2070
- height: 50px;
2071
- width: 120px;
2072
- border-radius: 8px;
2073
- }
2074
- /* ------------------------------------- */
2075
-
2076
- .share-section { margin-bottom: 40px; }
2077
- .sk-input { height: 50px; width: 100%; border-radius: 8px; margin-bottom: 16px; }
2078
-
2079
- .social-buttons { display: flex; gap: 12px; }
2080
- .sk-btn-social { flex: 1; height: 50px; border-radius: 8px; }
2081
-
2082
- .stats-section {
2083
- display: flex;
2084
- gap: 24px;
2085
- margin-bottom: 40px;
2086
- padding: 30px 0;
2087
- /* Removed border-top and border-bottom */
2088
- }
2089
- .stat-card { flex: 1; display: flex; flex-direction: column; align-items: center; }
2090
- .stat-divider { padding-left: 24px; }
2091
- .sk-stat-num { height: 48px; width: 120px; margin-bottom: 8px; }
2092
- .sk-stat-label { height: 18px; width: 80px; }
2093
-
2094
- /* Table Styles */
2095
- .table-header { display: flex; gap: 16px; margin-bottom: 16px; }
2096
- .sk-th { height: 16px; }
2097
- .table-row {
2098
- display: flex;
2099
- align-items: center;
2100
- gap: 16px;
2101
- padding: 16px 0;
2102
- /* Removed border-bottom */
2103
- }
2104
-
2105
- .col-user { flex: 2; }
2106
- .col-status { flex: 1; }
2107
- .col-reward { flex: 2; }
2108
- .col-date { flex: 1; }
2109
-
2110
- .sk-badge { height: 28px; width: 90px; border-radius: 14px; }
2111
- .sk-reward-block { height: 36px; width: 100%; border-radius: 6px; }
2112
-
2113
- .pagination { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
2114
- .sk-btn-page { height: 36px; width: 64px; border-radius: 6px; margin-bottom: 0; }
2115
-
2116
- @media (max-width: 768px) {
2117
- body { padding: 20px; }
2118
- .widget-container { padding: 24px; }
2119
-
2120
- .hero-section { flex-direction: column-reverse; gap: 24px; }
2121
- .instant-access-layout { flex-direction: column; }
2122
-
2123
- .hero-image { height: 220px; width: 100%; }
2124
- .sk-title-lg { width: 100%; }
2125
-
2126
- .col-date { display: none; }
2127
- }
2128
- </style>
2129
-
2130
- <div class="widget-container">
2131
- ${type === "verified-access" ? referrerHTML : instantAccessHTML}
2132
- </div>
2133
- `;
2134
- };
2135
1834
  const _log$2 = browserExports.debug("squatch-js:decodeUserJwt");
2136
1835
  function decodeUserJwt(tokenStr) {
2137
1836
  var _a2;
@@ -2270,12 +1969,6 @@ class DeclarativeWidget extends HTMLElement {
2270
1969
  domain: (config == null ? void 0 : config.domain) || ((_b = this.config) == null ? void 0 : _b.domain) || DEFAULT_DOMAIN
2271
1970
  });
2272
1971
  }
2273
- getWidgetType(widgetType) {
2274
- if (widgetType && (widgetType.includes("websiteReferralWidget") || widgetType.includes("friendWidget"))) {
2275
- return "instant-access";
2276
- }
2277
- return "verified-access";
2278
- }
2279
1972
  async renderPasswordlessVariant() {
2280
1973
  this._setupApis();
2281
1974
  _log$1("Rendering as an Instant Access widget");
@@ -2371,26 +2064,12 @@ class DeclarativeEmbedWidget extends DeclarativeWidget {
2371
2064
  }
2372
2065
  }
2373
2066
  async connectedCallback() {
2067
+ var _a2, _b;
2374
2068
  this.loaded = true;
2375
2069
  this.container = this.getAttribute("container");
2376
- this.widgetType = this.getAttribute("widget") || void 0;
2377
- console.log("widget type", this.widgetType);
2378
- const skeletonWidgetType = this.getWidgetType(this.widgetType);
2379
- const skeletonHTML = getSkeleton({
2380
- height: "100%",
2381
- type: skeletonWidgetType
2382
- });
2383
- const skeletonContainer = document.createElement("div");
2384
- skeletonContainer.id = "loading-skeleton";
2385
- skeletonContainer.innerHTML = skeletonHTML;
2386
- const root = this.shadowRoot || this.attachShadow({ mode: "open" });
2387
- root.innerHTML = "";
2388
- root.appendChild(skeletonContainer);
2389
2070
  await this.renderWidget();
2390
- const loadingElement = root.getElementById("loading-skeleton");
2391
- if (loadingElement) {
2392
- loadingElement.remove();
2393
- }
2071
+ const slot = (_a2 = this.shadowRoot && Array.from(this.shadowRoot.children)) == null ? void 0 : _a2.find((c) => c.tagName === "SLOT");
2072
+ if (slot) (_b = this.shadowRoot) == null ? void 0 : _b.removeChild(slot);
2394
2073
  if (this.getAttribute("open") !== null) this.open();
2395
2074
  }
2396
2075
  }
@@ -2419,27 +2098,7 @@ class DeclarativePopupWidget extends DeclarativeWidget {
2419
2098
  async connectedCallback() {
2420
2099
  this.loaded = true;
2421
2100
  this.container = this.getAttribute("container");
2422
- this.widgetType = this.getAttribute("widget") || void 0;
2423
- const skeletonWidgetType = this.getWidgetType(this.widgetType);
2424
- const skeletonHTML = getSkeleton({
2425
- height: "100%",
2426
- type: skeletonWidgetType
2427
- });
2428
- const skeletonContainer = document.createElement("div");
2429
- skeletonContainer.id = "loading-skeleton";
2430
- skeletonContainer.innerHTML = skeletonHTML;
2431
- const root = this.shadowRoot || this.attachShadow({ mode: "open" });
2432
- const container = root.getElementById("#squatchModal");
2433
- console.log("Container is ", container);
2434
- if (container) {
2435
- container.innerHTML = "";
2436
- container.appendChild(skeletonContainer);
2437
- }
2438
2101
  await this.renderWidget();
2439
- const loadingElement = root.getElementById("loading-skeleton");
2440
- if (loadingElement) {
2441
- loadingElement.remove();
2442
- }
2443
2102
  if (this.getAttribute("open") !== null) this.open();
2444
2103
  }
2445
2104
  }