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