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