@saasquatch/squatch-js 2.8.2-35 → 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.
@@ -700,7 +700,6 @@ class WidgetApi {
700
700
  const raw = params;
701
701
  const clean = validatePasswordlessConfig(raw);
702
702
  const { widgetType, engagementMedium = "POPUP", jwt, user } = clean;
703
- console.log({ params });
704
703
  const tenantAlias = encodeURIComponent(this.tenantAlias);
705
704
  const accountId = (user == null ? void 0 : user.accountId) ? encodeURIComponent(user.accountId) : null;
706
705
  const userId = (user == null ? void 0 : user.id) ? encodeURIComponent(user.id) : null;
@@ -889,9 +888,6 @@ class Widget {
889
888
  if ((options == null ? void 0 : options.maxWidth) || (options == null ? void 0 : options.minWidth)) {
890
889
  frame.style.width = "100%";
891
890
  }
892
- if (options == null ? void 0 : options.initialHeight) {
893
- frame.height = options.initialHeight;
894
- }
895
891
  return frame;
896
892
  }
897
893
  _findFrame() {
@@ -1112,22 +1108,15 @@ class EmbedWidget extends Widget {
1112
1108
  super(params);
1113
1109
  __publicField(this, "show", this.open);
1114
1110
  __publicField(this, "hide", this.close);
1115
- if (container) {
1116
- this.container = container;
1117
- }
1111
+ if (container) this.container = container;
1118
1112
  }
1119
1113
  async load() {
1120
- var _a2, _b, _c, _d, _e, _f, _g;
1114
+ var _a2, _b, _c, _d, _e;
1121
1115
  const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1122
- const initialHeight = brandingConfig == null ? void 0 : brandingConfig.loadingHeight;
1123
1116
  const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.embeddedWidgets;
1124
1117
  const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "";
1125
1118
  const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "";
1126
- const frame = this._createFrame({
1127
- minWidth,
1128
- maxWidth,
1129
- initialHeight
1130
- });
1119
+ const frame = this._createFrame({ minWidth, maxWidth });
1131
1120
  const element = this._findElement();
1132
1121
  if ((_d = this.context) == null ? void 0 : _d.container) {
1133
1122
  element.style.visibility = "hidden";
@@ -1155,29 +1144,14 @@ class EmbedWidget extends Widget {
1155
1144
  }
1156
1145
  const frameDoc = contentWindow.document;
1157
1146
  frameDoc.open();
1158
- const domain = this.widgetApi.domain;
1159
- frameDoc.write(`
1160
- ${((_f = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _f.brandFont) ? `
1161
- <link rel="preconnect" href="https://fast${domain === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
1162
- <link rel="preconnect" href="https://fonts.gstatic.com">
1163
- <link rel="preconnect" href="https://fonts.googleapis.com">
1164
- <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
1165
- (_g = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _g.brandFont
1166
- )}" as="style">` : ""}
1167
- <link rel="dns-prefetch" href="https://res.cloudinary.com">
1168
- <link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
1169
- <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
1170
- <style data-styles>
1171
- html { visibility:hidden;}
1172
- </style>
1173
- ${this.content}
1174
-
1175
- `);
1147
+ frameDoc.write(this.content);
1148
+ frameDoc.write(
1149
+ `<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
1150
+ );
1176
1151
  frameDoc.close();
1177
1152
  domready(frameDoc, async () => {
1178
1153
  const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
1179
- frame.height = initialHeight || frameDoc.body.scrollHeight;
1180
- console.log({ height: frameDoc.body.scrollHeight });
1154
+ frame.height = frameDoc.body.scrollHeight;
1181
1155
  const ro = new contentWindow["ResizeObserver"]((entries) => {
1182
1156
  for (const entry of entries) {
1183
1157
  const { height } = entry.contentRect;
@@ -1273,10 +1247,11 @@ class PopupWidget extends Widget {
1273
1247
  };
1274
1248
  }
1275
1249
  }
1276
- _createPopupDialog(brandingConfig) {
1277
- var _a2;
1250
+ _createPopupDialog() {
1251
+ var _a2, _b, _c;
1278
1252
  const dialog = document.createElement("dialog");
1279
- const sizes = (_a2 = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _a2.popupWidgets;
1253
+ const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1254
+ const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.popupWidgets;
1280
1255
  const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "auto";
1281
1256
  const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "500px";
1282
1257
  dialog.id = this.id;
@@ -1292,16 +1267,14 @@ class PopupWidget extends Widget {
1292
1267
  return dialog;
1293
1268
  }
1294
1269
  async load() {
1295
- var _a2, _b, _c, _d, _e;
1296
- const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1297
- const initialHeight = brandingConfig == null ? void 0 : brandingConfig.loadingHeight;
1298
- const frame = this._createFrame({ initialHeight });
1270
+ var _a2;
1271
+ const frame = this._createFrame();
1299
1272
  this._initialiseCTA();
1300
1273
  const element = this.container ? this._findElement() : document.body;
1301
1274
  const dialogParent = element.shadowRoot || element;
1302
- const dialog = this._createPopupDialog(brandingConfig);
1275
+ const dialog = this._createPopupDialog();
1303
1276
  dialog.appendChild(frame);
1304
- if (((_c = dialogParent.lastChild) == null ? void 0 : _c.nodeName) === "DIALOG") {
1277
+ if (((_a2 = dialogParent.lastChild) == null ? void 0 : _a2.nodeName) === "DIALOG") {
1305
1278
  dialogParent.replaceChild(dialog, dialogParent.lastChild);
1306
1279
  } else {
1307
1280
  dialogParent.appendChild(dialog);
@@ -1312,29 +1285,15 @@ class PopupWidget extends Widget {
1312
1285
  }
1313
1286
  const frameDoc = contentWindow.document;
1314
1287
  frameDoc.open();
1315
- const domain = this.widgetApi.domain;
1316
- frameDoc.write(`
1317
- ${((_d = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _d.brandFont) ? `
1318
- <link rel="preconnect" href="https://fast${domain === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
1319
- <link rel="preconnect" href="https://fonts.gstatic.com">
1320
- <link rel="preconnect" href="https://fonts.googleapis.com">
1321
- <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
1322
- (_e = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _e.brandFont
1323
- )}" as="style">` : ""}
1324
- <link rel="dns-prefetch" href="https://res.cloudinary.com">
1325
- <link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
1326
- <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
1327
- <style data-styles>
1328
- html { visibility:hidden;}
1329
- </style>
1330
- ${this.content}
1331
-
1332
- `);
1288
+ frameDoc.write(this.content);
1289
+ frameDoc.write(
1290
+ `<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
1291
+ );
1333
1292
  frameDoc.close();
1334
1293
  _log$6("Popup template loaded into iframe");
1335
- await this._setupResizeHandler(frame, initialHeight);
1294
+ await this._setupResizeHandler(frame);
1336
1295
  }
1337
- async _setupResizeHandler(frame, initialHeight) {
1296
+ async _setupResizeHandler(frame) {
1338
1297
  const { contentWindow } = frame;
1339
1298
  if (!contentWindow) {
1340
1299
  throw new Error("Frame needs a content window");
@@ -1342,7 +1301,7 @@ class PopupWidget extends Widget {
1342
1301
  const frameDoc = contentWindow.document;
1343
1302
  domready(frameDoc, async () => {
1344
1303
  frameDoc.body.style.overflowY = "hidden";
1345
- frame.height = initialHeight || frameDoc.body.offsetHeight;
1304
+ frame.height = `${frameDoc.body.offsetHeight}px`;
1346
1305
  const ro = new contentWindow["ResizeObserver"]((entries) => {
1347
1306
  for (const entry of entries) {
1348
1307
  const { top, bottom } = entry.contentRect;
@@ -1508,11 +1467,7 @@ class Widgets {
1508
1467
  engagementMedium: clean.engagementMedium,
1509
1468
  container: clean.container,
1510
1469
  trigger: clean.trigger,
1511
- widgetConfig: {
1512
- values: {
1513
- brandingConfig: response == null ? void 0 : response.brandingConfig
1514
- }
1515
- }
1470
+ widgetConfig: response == null ? void 0 : response.widgetConfig
1516
1471
  }),
1517
1472
  user: response.user
1518
1473
  };
@@ -1874,264 +1829,6 @@ function _getAutoConfig() {
1874
1829
  }
1875
1830
  };
1876
1831
  }
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
1832
  const _log$2 = browserExports.debug("squatch-js:decodeUserJwt");
2136
1833
  function decodeUserJwt(tokenStr) {
2137
1834
  var _a2;
@@ -2270,12 +1967,6 @@ class DeclarativeWidget extends HTMLElement {
2270
1967
  domain: (config == null ? void 0 : config.domain) || ((_b = this.config) == null ? void 0 : _b.domain) || DEFAULT_DOMAIN
2271
1968
  });
2272
1969
  }
2273
- getWidgetType(widgetType) {
2274
- if (widgetType && (widgetType.includes("websiteReferralWidget") || widgetType.includes("friendWidget"))) {
2275
- return "instant-access";
2276
- }
2277
- return "verified-access";
2278
- }
2279
1970
  async renderPasswordlessVariant() {
2280
1971
  this._setupApis();
2281
1972
  _log$1("Rendering as an Instant Access widget");
@@ -2371,26 +2062,12 @@ class DeclarativeEmbedWidget extends DeclarativeWidget {
2371
2062
  }
2372
2063
  }
2373
2064
  async connectedCallback() {
2065
+ var _a2, _b;
2374
2066
  this.loaded = true;
2375
2067
  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
2068
  await this.renderWidget();
2390
- const loadingElement = root.getElementById("loading-skeleton");
2391
- if (loadingElement) {
2392
- loadingElement.remove();
2393
- }
2069
+ const slot = (_a2 = this.shadowRoot && Array.from(this.shadowRoot.children)) == null ? void 0 : _a2.find((c) => c.tagName === "SLOT");
2070
+ if (slot) (_b = this.shadowRoot) == null ? void 0 : _b.removeChild(slot);
2394
2071
  if (this.getAttribute("open") !== null) this.open();
2395
2072
  }
2396
2073
  }
@@ -2419,27 +2096,7 @@ class DeclarativePopupWidget extends DeclarativeWidget {
2419
2096
  async connectedCallback() {
2420
2097
  this.loaded = true;
2421
2098
  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
2099
  await this.renderWidget();
2439
- const loadingElement = root.getElementById("loading-skeleton");
2440
- if (loadingElement) {
2441
- loadingElement.remove();
2442
- }
2443
2100
  if (this.getAttribute("open") !== null) this.open();
2444
2101
  }
2445
2102
  }