@saasquatch/squatch-js 2.8.0-3 → 2.8.0-5

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/CHANGELOG.md CHANGED
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.8.0] - 2025-10-22
11
+
12
+ ### Added
13
+
14
+ - Added support for branding configuration to control widget sizing
15
+ - Embedded widgets now support configurable `minWidth` and `maxWidth` through `brandingConfig.widgetSize.embeddedWidgets`
16
+ - Popup widgets now support configurable `minWidth` and `maxWidth` through `brandingConfig.widgetSize.popupWidgets`
17
+ - Added new `WidgetValueConfig` interface to pass branding configuration to widgets
18
+ - Added `widgetConfig` parameter to `UpsertWidgetContext` and `BaseWidgetContext` types
19
+ - Created `formatWidth` utility function to handle width formatting with px and % units
20
+
21
+ ### Changed
22
+
23
+ - Updated widget rendering flow to include branding configuration from API responses
24
+ - Modified `EmbedWidget` and `PopupWidget` to apply dynamic sizing based on branding configuration
25
+ - Enhanced declarative widgets to support branding configuration through the widget API
26
+
10
27
  ## [2.7.0] - 2025-05-14
11
28
 
12
29
  ### Changed
@@ -370,7 +387,8 @@ No release notes.
370
387
 
371
388
  No release notes.
372
389
 
373
- [unreleased]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.7.0...HEAD
390
+ [unreleased]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.8.0...HEAD
391
+ [2.8.0]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.7.0...@saasquatch%2Fsquatch-js@2.8.0
374
392
  [2.7.0]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.6.3...@saasquatch%2Fsquatch-js@2.7.0
375
393
  [2.6.3]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.6.2...@saasquatch%2Fsquatch-js@2.6.3
376
394
  [2.6.2]: https://github.com/saasquatch/squatch-js/compare/@saasquatch%2Fsquatch-js@2.6.1...@saasquatch%2Fsquatch-js@2.6.2
package/dist/async.d.ts CHANGED
@@ -14,7 +14,6 @@ declare global {
14
14
  squatchConfig: Omit<ConfigOptions, "tenantAlias">;
15
15
  impactToken: string;
16
16
  impactConfig: Omit<ConfigOptions, "tenantAlias">;
17
- SquatchBrandingConfig: any;
18
17
  }
19
18
  }
20
19
  /** @hidden */
@@ -874,11 +874,13 @@ class Widget {
874
874
  );
875
875
  return element;
876
876
  }
877
- _createFrame() {
877
+ _createFrame(options) {
878
878
  const frame = document.createElement("iframe");
879
879
  frame["squatchJsApi"] = this;
880
880
  frame.id = "squatchFrame";
881
881
  frame.width = "100%";
882
+ if (options == null ? void 0 : options.minWidth) frame.style.minWidth = options.minWidth;
883
+ if (options == null ? void 0 : options.maxWidth) frame.style.maxWidth = options.maxWidth;
882
884
  frame.src = "about:blank";
883
885
  frame.scrolling = "no";
884
886
  frame.setAttribute(
@@ -1108,23 +1110,21 @@ class EmbedWidget extends Widget {
1108
1110
  if (container) this.container = container;
1109
1111
  }
1110
1112
  async load() {
1111
- var _a2, _b, _c;
1112
- const frame = this._createFrame();
1113
+ var _a2, _b, _c, _d, _e;
1114
+ const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1115
+ const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.embeddedWidgets;
1116
+ const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "";
1117
+ const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "";
1118
+ const frame = this._createFrame({ minWidth, maxWidth });
1113
1119
  const element = this._findElement();
1114
- if ((_a2 = this.context) == null ? void 0 : _a2.container) {
1120
+ if ((_d = this.context) == null ? void 0 : _d.container) {
1115
1121
  element.style.visibility = "hidden";
1116
1122
  element.style.height = "0";
1117
1123
  element.style["overflow-y"] = "hidden";
1118
1124
  }
1119
- const brandingConfig = window.SquatchBrandingConfig;
1120
- const sizes = (_b = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _b.embeddedWidgets;
1121
- const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "100%";
1122
- const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "100%";
1123
- element.style.maxWidth = maxWidth;
1124
- element.style.minWidth = minWidth;
1125
1125
  if (this.container) {
1126
1126
  if (element.shadowRoot) {
1127
- if (((_c = element.shadowRoot.lastChild) == null ? void 0 : _c.nodeName) === "IFRAME") {
1127
+ if (((_e = element.shadowRoot.lastChild) == null ? void 0 : _e.nodeName) === "IFRAME") {
1128
1128
  element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
1129
1129
  } else {
1130
1130
  element.shadowRoot.appendChild(frame);
@@ -1247,11 +1247,11 @@ class PopupWidget extends Widget {
1247
1247
  }
1248
1248
  }
1249
1249
  _createPopupDialog() {
1250
- var _a2;
1250
+ var _a2, _b, _c;
1251
1251
  const dialog = document.createElement("dialog");
1252
- const brandingConfig = window.SquatchBrandingConfig;
1253
- const sizes = (_a2 = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _a2.popupWidgets;
1254
- const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "100%";
1252
+ const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
1253
+ const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.popupWidgets;
1254
+ const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "auto";
1255
1255
  const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "500px";
1256
1256
  dialog.id = this.id;
1257
1257
  dialog.setAttribute(
@@ -1423,7 +1423,12 @@ class Widgets {
1423
1423
  user: clean.user,
1424
1424
  engagementMedium: config.engagementMedium,
1425
1425
  container: config.container,
1426
- trigger: config.trigger
1426
+ trigger: config.trigger,
1427
+ widgetConfig: {
1428
+ values: {
1429
+ brandingConfig: response == null ? void 0 : response.brandingConfig
1430
+ }
1431
+ }
1427
1432
  }),
1428
1433
  user: response.user
1429
1434
  };
@@ -1460,7 +1465,12 @@ class Widgets {
1460
1465
  type: "passwordless",
1461
1466
  engagementMedium: clean.engagementMedium,
1462
1467
  container: clean.container,
1463
- trigger: clean.trigger
1468
+ trigger: clean.trigger,
1469
+ widgetConfig: {
1470
+ values: {
1471
+ brandingConfig: response == null ? void 0 : response.brandingConfig
1472
+ }
1473
+ }
1464
1474
  }),
1465
1475
  user: response.user
1466
1476
  };
@@ -1887,7 +1897,6 @@ class DeclarativeWidget extends HTMLElement {
1887
1897
  __publicField(this, "loaded");
1888
1898
  __publicField(this, "_setWidget", (res, config) => {
1889
1899
  var _a2;
1890
- console.log({ res });
1891
1900
  const params = {
1892
1901
  api: this.widgetApi,
1893
1902
  content: res.template,
@@ -1895,7 +1904,8 @@ class DeclarativeWidget extends HTMLElement {
1895
1904
  type: config.type,
1896
1905
  user: config.user,
1897
1906
  container: this.container || void 0,
1898
- engagementMedium: this.type
1907
+ engagementMedium: this.type,
1908
+ widgetConfig: res.widgetConfig
1899
1909
  },
1900
1910
  type: this.widgetType,
1901
1911
  domain: ((_a2 = this.config) == null ? void 0 : _a2.domain) || DEFAULT_DOMAIN,