@saasquatch/squatch-js 2.8.3-1 → 2.8.3-2

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.
@@ -667,7 +667,7 @@ class pe {
667
667
  const e = document.createElement("iframe");
668
668
  return e.squatchJsApi = this, e.id = "squatchFrame", e.width = "100%", e.src = "about:blank", e.scrolling = "no", e.setAttribute(
669
669
  "style",
670
- "border: 0; background-color: none; width: 1px; min-width: 100%;"
670
+ "border: 0; background-color: none; width: 1px; min-width: 100%; display: block;"
671
671
  ), t != null && t.minWidth && (e.style.minWidth = t.minWidth), t != null && t.maxWidth && (e.style.maxWidth = t.maxWidth), (t != null && t.maxWidth || t != null && t.minWidth) && (e.style.width = "100%"), t != null && t.initialHeight && (e.height = String(t.initialHeight)), e;
672
672
  }
673
673
  _findFrame() {
@@ -891,7 +891,7 @@ function Le() {
891
891
  });
892
892
  });
893
893
  }
894
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : e();
894
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : setTimeout(e, 0);
895
895
  }
896
896
  const E = k("squatch-js:EMBEDwidget");
897
897
  class O extends pe {
@@ -931,11 +931,11 @@ class O extends pe {
931
931
  </style>` : ""}
932
932
  ${this._getSkeletonPreloadHTML(n, (ie = e == null ? void 0 : e.color) == null ? void 0 : ie.backgroundColor)}
933
933
  ${this.content}
934
-
934
+ <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
935
935
  `), u.close(), Q(u, async () => {
936
936
  const oe = h.squatch || h.widgetIdent;
937
937
  d.height = i;
938
- const ye = new ResizeObserver((ke) => {
938
+ const ye = new h.ResizeObserver((ke) => {
939
939
  for (const be of ke) {
940
940
  const { height: xe } = be.contentRect;
941
941
  d.height = xe;
@@ -1016,8 +1016,8 @@ class j extends pe {
1016
1016
  }
1017
1017
  async load() {
1018
1018
  var p, g, m, w, b, f, _;
1019
- const e = (g = (p = this.context.widgetConfig) == null ? void 0 : p.values) == null ? void 0 : g.brandingConfig, n = (e == null ? void 0 : e.loadingHeight) || 500, i = (m = this.content) == null ? void 0 : m.includes("mint-components"), s = this._createFrame({ initialHeight: n });
1020
- this._initialiseCTA();
1019
+ const e = (g = (p = this.context.widgetConfig) == null ? void 0 : p.values) == null ? void 0 : g.brandingConfig, n = (e == null ? void 0 : e.loadingHeight) || 500, i = (m = this.content) == null ? void 0 : m.includes("mint-components"), s = this._createFrame();
1020
+ s.style.height = n + "px", this._initialiseCTA();
1021
1021
  const r = this.container ? this._findElement() : document.body, a = (r == null ? void 0 : r.shadowRoot) || r, d = this._createPopupDialog(e);
1022
1022
  d.appendChild(s), ((w = a.lastChild) == null ? void 0 : w.nodeName) === "DIALOG" ? a.replaceChild(d, a.lastChild) : a.appendChild(d);
1023
1023
  const { contentWindow: c } = s;
@@ -1042,19 +1042,21 @@ class j extends pe {
1042
1042
  </style>` : ""}
1043
1043
  ${this._getSkeletonPreloadHTML(i, (_ = e == null ? void 0 : e.color) == null ? void 0 : _.backgroundColor)}
1044
1044
  ${this.content}
1045
-
1046
- `), h.close(), T("Popup template loaded into iframe"), await this._setupResizeHandler(s, n);
1045
+ <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
1046
+ `), h.close(), T("Popup template loaded into iframe"), await this._setupResizeHandler(s);
1047
1047
  }
1048
- async _setupResizeHandler(e, n) {
1049
- const { contentWindow: i } = e;
1050
- if (!i)
1048
+ async _setupResizeHandler(e) {
1049
+ const { contentWindow: n } = e;
1050
+ if (!n)
1051
1051
  throw new Error("Frame needs a content window");
1052
- const s = i.document;
1053
- Q(s, async () => {
1054
- s.body.style.overflowY = "hidden", e.height = n || s.body.offsetHeight, new ResizeObserver((a) => {
1052
+ const i = n.document;
1053
+ Q(i, async () => {
1054
+ i.body.style.overflowY = "hidden";
1055
+ let s = !0;
1056
+ new n.ResizeObserver((a) => {
1055
1057
  for (const d of a) {
1056
1058
  const { top: c, bottom: h } = d.contentRect, u = h + c;
1057
- e.height = u + "", d.target.style = "";
1059
+ u <= 0 || (s ? (s = !1, e.style.height = "0", e.height = i.body.scrollHeight + "", e.style.height = "") : e.height = u + "", d.target.style = "");
1058
1060
  }
1059
1061
  }).observe(await this._findInnerContainer(e));
1060
1062
  });