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

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,16 @@ 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
+ 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 });
1296
1299
  this._initialiseCTA();
1297
1300
  const element = this.container ? this._findElement() : document.body;
1298
1301
  const dialogParent = element.shadowRoot || element;
1299
- const dialog = this._createPopupDialog();
1302
+ const dialog = this._createPopupDialog(brandingConfig);
1300
1303
  dialog.appendChild(frame);
1301
- if (((_a2 = dialogParent.lastChild) == null ? void 0 : _a2.nodeName) === "DIALOG") {
1304
+ if (((_c = dialogParent.lastChild) == null ? void 0 : _c.nodeName) === "DIALOG") {
1302
1305
  dialogParent.replaceChild(dialog, dialogParent.lastChild);
1303
1306
  } else {
1304
1307
  dialogParent.appendChild(dialog);
@@ -1309,27 +1312,29 @@ class PopupWidget extends Widget {
1309
1312
  }
1310
1313
  const frameDoc = contentWindow.document;
1311
1314
  frameDoc.open();
1312
- frameDoc.write(this.content);
1313
- frameDoc.write(
1314
- `<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
1315
- );
1315
+ const domain = this.widgetApi.domain;
1316
1316
  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
- `);
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
+ `);
1328
1333
  frameDoc.close();
1329
1334
  _log$6("Popup template loaded into iframe");
1330
- await this._setupResizeHandler(frame);
1335
+ await this._setupResizeHandler(frame, initialHeight);
1331
1336
  }
1332
- async _setupResizeHandler(frame) {
1337
+ async _setupResizeHandler(frame, initialHeight) {
1333
1338
  const { contentWindow } = frame;
1334
1339
  if (!contentWindow) {
1335
1340
  throw new Error("Frame needs a content window");
@@ -1337,7 +1342,7 @@ class PopupWidget extends Widget {
1337
1342
  const frameDoc = contentWindow.document;
1338
1343
  domready(frameDoc, async () => {
1339
1344
  frameDoc.body.style.overflowY = "hidden";
1340
- frame.height = `${frameDoc.body.offsetHeight}px`;
1345
+ frame.height = initialHeight || frameDoc.body.offsetHeight;
1341
1346
  const ro = new contentWindow["ResizeObserver"]((entries) => {
1342
1347
  for (const entry of entries) {
1343
1348
  const { top, bottom } = entry.contentRect;