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