@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.
@@ -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,18 @@ 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
+ console.log("TESTING!");
1299
+ const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1300
+ const initialHeight = brandingConfig == null ? void 0 : brandingConfig.loadingHeight;
1301
+ console.log({ initialHeight, brandingConfig });
1302
+ const frame = this._createFrame({ initialHeight });
1298
1303
  this._initialiseCTA();
1299
1304
  const element = this.container ? this._findElement() : document.body;
1300
1305
  const dialogParent = element.shadowRoot || element;
1301
- const dialog = this._createPopupDialog();
1306
+ const dialog = this._createPopupDialog(brandingConfig);
1302
1307
  dialog.appendChild(frame);
1303
- if (((_a2 = dialogParent.lastChild) == null ? void 0 : _a2.nodeName) === "DIALOG") {
1308
+ if (((_c = dialogParent.lastChild) == null ? void 0 : _c.nodeName) === "DIALOG") {
1304
1309
  dialogParent.replaceChild(dialog, dialogParent.lastChild);
1305
1310
  } else {
1306
1311
  dialogParent.appendChild(dialog);
@@ -1311,27 +1316,29 @@ class PopupWidget extends Widget {
1311
1316
  }
1312
1317
  const frameDoc = contentWindow.document;
1313
1318
  frameDoc.open();
1314
- frameDoc.write(this.content);
1315
- frameDoc.write(
1316
- `<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
1317
- );
1319
+ const domain = this.widgetApi.domain;
1318
1320
  frameDoc.write(`
1319
- <style>
1320
- body {
1321
- height: 600px;
1322
- border: 2px solid #ccc;
1323
- background-color: red;
1324
- margin: 0;
1325
- padding: 0;
1326
- box-sizing: border-box;
1327
- }
1328
- </style>
1329
- `);
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
+ `);
1330
1337
  frameDoc.close();
1331
1338
  _log$6("Popup template loaded into iframe");
1332
- await this._setupResizeHandler(frame);
1339
+ await this._setupResizeHandler(frame, initialHeight);
1333
1340
  }
1334
- async _setupResizeHandler(frame) {
1341
+ async _setupResizeHandler(frame, initialHeight) {
1335
1342
  const { contentWindow } = frame;
1336
1343
  if (!contentWindow) {
1337
1344
  throw new Error("Frame needs a content window");
@@ -1339,7 +1346,7 @@ class PopupWidget extends Widget {
1339
1346
  const frameDoc = contentWindow.document;
1340
1347
  domready(frameDoc, async () => {
1341
1348
  frameDoc.body.style.overflowY = "hidden";
1342
- frame.height = `${frameDoc.body.offsetHeight}px`;
1349
+ frame.height = initialHeight || frameDoc.body.offsetHeight;
1343
1350
  const ro = new contentWindow["ResizeObserver"]((entries) => {
1344
1351
  for (const entry of entries) {
1345
1352
  const { top, bottom } = entry.contentRect;
@@ -1505,11 +1512,7 @@ class Widgets {
1505
1512
  engagementMedium: clean.engagementMedium,
1506
1513
  container: clean.container,
1507
1514
  trigger: clean.trigger,
1508
- widgetConfig: {
1509
- values: {
1510
- brandingConfig: response == null ? void 0 : response.brandingConfig
1511
- }
1512
- }
1515
+ widgetConfig: response == null ? void 0 : response.widgetConfig
1513
1516
  }),
1514
1517
  user: response.user
1515
1518
  };