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