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

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.
@@ -1164,6 +1164,8 @@ class EmbedWidget extends Widget {
1164
1164
  <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
1165
1165
  (_g = brandingConfig == null ? void 0 : brandingConfig.main) == null ? void 0 : _g.brandFont
1166
1166
  )}" as="style">` : ""}
1167
+ <link rel="dns-prefetch" href="https://res.cloudinary.com">
1168
+ <link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
1167
1169
  <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
1168
1170
  <style data-styles>
1169
1171
  html { visibility:hidden;}
@@ -1271,11 +1273,10 @@ class PopupWidget extends Widget {
1271
1273
  };
1272
1274
  }
1273
1275
  }
1274
- _createPopupDialog() {
1275
- var _a2, _b, _c;
1276
+ _createPopupDialog(brandingConfig) {
1277
+ var _a2;
1276
1278
  const dialog = document.createElement("dialog");
1277
- const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1278
- const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.popupWidgets;
1279
+ const sizes = (_a2 = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _a2.popupWidgets;
1279
1280
  const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "auto";
1280
1281
  const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "500px";
1281
1282
  dialog.id = this.id;
@@ -1291,14 +1292,18 @@ class PopupWidget extends Widget {
1291
1292
  return dialog;
1292
1293
  }
1293
1294
  async load() {
1294
- var _a2;
1295
- const frame = this._createFrame();
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 });
1296
1301
  this._initialiseCTA();
1297
1302
  const element = this.container ? this._findElement() : document.body;
1298
1303
  const dialogParent = element.shadowRoot || element;
1299
- const dialog = this._createPopupDialog();
1304
+ const dialog = this._createPopupDialog(brandingConfig);
1300
1305
  dialog.appendChild(frame);
1301
- if (((_a2 = dialogParent.lastChild) == null ? void 0 : _a2.nodeName) === "DIALOG") {
1306
+ if (((_c = dialogParent.lastChild) == null ? void 0 : _c.nodeName) === "DIALOG") {
1302
1307
  dialogParent.replaceChild(dialog, dialogParent.lastChild);
1303
1308
  } else {
1304
1309
  dialogParent.appendChild(dialog);
@@ -1309,27 +1314,29 @@ class PopupWidget extends Widget {
1309
1314
  }
1310
1315
  const frameDoc = contentWindow.document;
1311
1316
  frameDoc.open();
1312
- frameDoc.write(this.content);
1313
- frameDoc.write(
1314
- `<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
1315
- );
1317
+ const domain = this.widgetApi.domain;
1316
1318
  frameDoc.write(`
1317
- <style>
1318
- body {
1319
- height: 600px;
1320
- border: 2px solid #ccc;
1321
- background-color: red;
1322
- margin: 0;
1323
- padding: 0;
1324
- box-sizing: border-box;
1325
- }
1326
- </style>
1327
- `);
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
+ `);
1328
1335
  frameDoc.close();
1329
1336
  _log$6("Popup template loaded into iframe");
1330
- await this._setupResizeHandler(frame);
1337
+ await this._setupResizeHandler(frame, initialHeight);
1331
1338
  }
1332
- async _setupResizeHandler(frame) {
1339
+ async _setupResizeHandler(frame, initialHeight) {
1333
1340
  const { contentWindow } = frame;
1334
1341
  if (!contentWindow) {
1335
1342
  throw new Error("Frame needs a content window");
@@ -1337,7 +1344,7 @@ class PopupWidget extends Widget {
1337
1344
  const frameDoc = contentWindow.document;
1338
1345
  domready(frameDoc, async () => {
1339
1346
  frameDoc.body.style.overflowY = "hidden";
1340
- frame.height = `${frameDoc.body.offsetHeight}px`;
1347
+ frame.height = initialHeight || frameDoc.body.offsetHeight;
1341
1348
  const ro = new contentWindow["ResizeObserver"]((entries) => {
1342
1349
  for (const entry of entries) {
1343
1350
  const { top, bottom } = entry.contentRect;
@@ -1503,11 +1510,7 @@ class Widgets {
1503
1510
  engagementMedium: clean.engagementMedium,
1504
1511
  container: clean.container,
1505
1512
  trigger: clean.trigger,
1506
- widgetConfig: {
1507
- values: {
1508
- brandingConfig: response == null ? void 0 : response.brandingConfig
1509
- }
1510
- }
1513
+ widgetConfig: response == null ? void 0 : response.widgetConfig
1511
1514
  }),
1512
1515
  user: response.user
1513
1516
  };