@saasquatch/squatch-js 2.8.0 → 2.8.2-1

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.
@@ -888,6 +888,9 @@ class Widget {
888
888
  if ((options == null ? void 0 : options.maxWidth) || (options == null ? void 0 : options.minWidth)) {
889
889
  frame.style.width = "100%";
890
890
  }
891
+ if (options == null ? void 0 : options.initialHeight) {
892
+ frame.height = options.initialHeight;
893
+ }
891
894
  return frame;
892
895
  }
893
896
  _findFrame() {
@@ -1111,21 +1114,31 @@ class EmbedWidget extends Widget {
1111
1114
  if (container) this.container = container;
1112
1115
  }
1113
1116
  async load() {
1114
- var _a2, _b, _c, _d, _e;
1117
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
1115
1118
  const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1116
- const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.embeddedWidgets;
1119
+ const initialHeight = (_e = (_d = (_c = this.context.widgetConfig) == null ? void 0 : _c.values) == null ? void 0 : _d.brandingConfig) == null ? void 0 : _e.loadingHeight;
1120
+ const sizes = (_f = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _f.embeddedWidgets;
1117
1121
  const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "";
1118
1122
  const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "";
1119
- const frame = this._createFrame({ minWidth, maxWidth });
1123
+ console.log({
1124
+ brandingConfig,
1125
+ initialHeight,
1126
+ widgetConfig: this.context.widgetConfig
1127
+ });
1128
+ const frame = this._createFrame({
1129
+ minWidth,
1130
+ maxWidth,
1131
+ initialHeight
1132
+ });
1120
1133
  const element = this._findElement();
1121
- if ((_d = this.context) == null ? void 0 : _d.container) {
1134
+ if ((_g = this.context) == null ? void 0 : _g.container) {
1122
1135
  element.style.visibility = "hidden";
1123
1136
  element.style.height = "0";
1124
1137
  element.style["overflow-y"] = "hidden";
1125
1138
  }
1126
1139
  if (this.container) {
1127
1140
  if (element.shadowRoot) {
1128
- if (((_e = element.shadowRoot.lastChild) == null ? void 0 : _e.nodeName) === "IFRAME") {
1141
+ if (((_h = element.shadowRoot.lastChild) == null ? void 0 : _h.nodeName) === "IFRAME") {
1129
1142
  element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
1130
1143
  } else {
1131
1144
  element.shadowRoot.appendChild(frame);
@@ -1144,14 +1157,19 @@ class EmbedWidget extends Widget {
1144
1157
  }
1145
1158
  const frameDoc = contentWindow.document;
1146
1159
  frameDoc.open();
1147
- frameDoc.write(this.content);
1148
- frameDoc.write(
1149
- `<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>`
1150
- );
1160
+ console.log({ content: this.content });
1161
+ frameDoc.write(`
1162
+ <script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
1163
+ ${this.content}
1164
+ <style data-styles>
1165
+ html:not(.hydrated) { visibility:hidden; }
1166
+ </style>
1167
+ `);
1151
1168
  frameDoc.close();
1152
1169
  domready(frameDoc, async () => {
1153
1170
  const _sqh = contentWindow.squatch || contentWindow.widgetIdent;
1154
- frame.height = frameDoc.body.scrollHeight;
1171
+ frame.height = initialHeight || frameDoc.body.scrollHeight;
1172
+ console.log({ height: frameDoc.body.scrollHeight });
1155
1173
  const ro = new contentWindow["ResizeObserver"]((entries) => {
1156
1174
  for (const entry of entries) {
1157
1175
  const { height } = entry.contentRect;