@saasquatch/squatch-js 2.7.0-4 → 2.8.0-0
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 +9 -1
- package/dist/squatch.cjs.js +63 -33
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +63 -33
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +63 -33
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +2 -2
- package/dist/types.d.ts +11 -0
- package/dist/utils/widgetUtils.d.ts +4 -0
- package/package.json +3 -2
package/dist/squatch.esm.js
CHANGED
|
@@ -754,6 +754,41 @@ function _buildParams({
|
|
|
754
754
|
if (locale) queryParams.append("locale", locale);
|
|
755
755
|
return `?${queryParams.toString()}`;
|
|
756
756
|
}
|
|
757
|
+
/*!
|
|
758
|
+
* domready (c) Dustin Diaz 2014 - License MIT
|
|
759
|
+
*
|
|
760
|
+
*/
|
|
761
|
+
function domready(targetDoc, fn) {
|
|
762
|
+
let fns = [];
|
|
763
|
+
let listener;
|
|
764
|
+
let doc = targetDoc;
|
|
765
|
+
let hack = doc.documentElement.doScroll;
|
|
766
|
+
let domContentLoaded = "DOMContentLoaded";
|
|
767
|
+
let loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState);
|
|
768
|
+
if (!loaded)
|
|
769
|
+
doc.addEventListener(
|
|
770
|
+
domContentLoaded,
|
|
771
|
+
listener = () => {
|
|
772
|
+
doc.removeEventListener(domContentLoaded, listener);
|
|
773
|
+
loaded = true;
|
|
774
|
+
while (listener = fns.shift()) listener();
|
|
775
|
+
}
|
|
776
|
+
);
|
|
777
|
+
return loaded ? setTimeout(fn, 0) : fns.push(fn);
|
|
778
|
+
}
|
|
779
|
+
function formatWidth({
|
|
780
|
+
value,
|
|
781
|
+
unit
|
|
782
|
+
}) {
|
|
783
|
+
switch (unit) {
|
|
784
|
+
case "PX":
|
|
785
|
+
return `${value}px`;
|
|
786
|
+
case "%":
|
|
787
|
+
return `${value}%`;
|
|
788
|
+
default:
|
|
789
|
+
return `${value}px`;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
757
792
|
class AnalyticsApi {
|
|
758
793
|
/**
|
|
759
794
|
* Initialize a new {@link AnalyticsApi} instance.
|
|
@@ -1062,28 +1097,6 @@ function delay(duration) {
|
|
|
1062
1097
|
setTimeout(resolve, duration);
|
|
1063
1098
|
});
|
|
1064
1099
|
}
|
|
1065
|
-
/*!
|
|
1066
|
-
* domready (c) Dustin Diaz 2014 - License MIT
|
|
1067
|
-
*
|
|
1068
|
-
*/
|
|
1069
|
-
function domready(targetDoc, fn) {
|
|
1070
|
-
let fns = [];
|
|
1071
|
-
let listener;
|
|
1072
|
-
let doc = targetDoc;
|
|
1073
|
-
let hack = doc.documentElement.doScroll;
|
|
1074
|
-
let domContentLoaded = "DOMContentLoaded";
|
|
1075
|
-
let loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState);
|
|
1076
|
-
if (!loaded)
|
|
1077
|
-
doc.addEventListener(
|
|
1078
|
-
domContentLoaded,
|
|
1079
|
-
listener = () => {
|
|
1080
|
-
doc.removeEventListener(domContentLoaded, listener);
|
|
1081
|
-
loaded = true;
|
|
1082
|
-
while (listener = fns.shift()) listener();
|
|
1083
|
-
}
|
|
1084
|
-
);
|
|
1085
|
-
return loaded ? setTimeout(fn, 0) : fns.push(fn);
|
|
1086
|
-
}
|
|
1087
1100
|
const _log$7 = browserExports.debug("squatch-js:EMBEDwidget");
|
|
1088
1101
|
class EmbedWidget extends Widget {
|
|
1089
1102
|
constructor(params, container) {
|
|
@@ -1093,7 +1106,7 @@ class EmbedWidget extends Widget {
|
|
|
1093
1106
|
if (container) this.container = container;
|
|
1094
1107
|
}
|
|
1095
1108
|
async load() {
|
|
1096
|
-
var _a2, _b;
|
|
1109
|
+
var _a2, _b, _c, _d, _e;
|
|
1097
1110
|
const frame = this._createFrame();
|
|
1098
1111
|
const element = this._findElement();
|
|
1099
1112
|
if ((_a2 = this.context) == null ? void 0 : _a2.container) {
|
|
@@ -1101,9 +1114,15 @@ class EmbedWidget extends Widget {
|
|
|
1101
1114
|
element.style.height = "0";
|
|
1102
1115
|
element.style["overflow-y"] = "hidden";
|
|
1103
1116
|
}
|
|
1117
|
+
const brandingConfig = (_c = (_b = this.context.widgetConfig) == null ? void 0 : _b.values) == null ? void 0 : _c.brandingConfig;
|
|
1118
|
+
const sizes = (_d = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _d.embedWidgets;
|
|
1119
|
+
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "100%";
|
|
1120
|
+
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "100%";
|
|
1121
|
+
element.style.maxWidth = maxWidth;
|
|
1122
|
+
element.style.minWidth = minWidth;
|
|
1104
1123
|
if (this.container) {
|
|
1105
1124
|
if (element.shadowRoot) {
|
|
1106
|
-
if (((
|
|
1125
|
+
if (((_e = element.shadowRoot.lastChild) == null ? void 0 : _e.nodeName) === "IFRAME") {
|
|
1107
1126
|
element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
|
|
1108
1127
|
} else {
|
|
1109
1128
|
element.shadowRoot.appendChild(frame);
|
|
@@ -1226,11 +1245,16 @@ class PopupWidget extends Widget {
|
|
|
1226
1245
|
}
|
|
1227
1246
|
}
|
|
1228
1247
|
_createPopupDialog() {
|
|
1248
|
+
var _a2, _b, _c;
|
|
1229
1249
|
const dialog = document.createElement("dialog");
|
|
1250
|
+
const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
|
|
1251
|
+
const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.popupWidgets;
|
|
1252
|
+
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "100%";
|
|
1253
|
+
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "500px";
|
|
1230
1254
|
dialog.id = this.id;
|
|
1231
1255
|
dialog.setAttribute(
|
|
1232
1256
|
"style",
|
|
1233
|
-
|
|
1257
|
+
`width: 100%; min-width: ${minWidth}; max-width: ${maxWidth}; border: none; padding: 0;`
|
|
1234
1258
|
);
|
|
1235
1259
|
const onClick = (e) => {
|
|
1236
1260
|
e.stopPropagation();
|
|
@@ -1859,16 +1883,17 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1859
1883
|
* @hidden
|
|
1860
1884
|
*/
|
|
1861
1885
|
__publicField(this, "loaded");
|
|
1862
|
-
__publicField(this, "_setWidget", (
|
|
1886
|
+
__publicField(this, "_setWidget", (res, config) => {
|
|
1863
1887
|
var _a2;
|
|
1864
1888
|
const params = {
|
|
1865
1889
|
api: this.widgetApi,
|
|
1866
|
-
content: template,
|
|
1890
|
+
content: res.template,
|
|
1867
1891
|
context: {
|
|
1868
1892
|
type: config.type,
|
|
1869
1893
|
user: config.user,
|
|
1870
1894
|
container: this.container || void 0,
|
|
1871
|
-
engagementMedium: this.type
|
|
1895
|
+
engagementMedium: this.type,
|
|
1896
|
+
config: res.widgetConfig
|
|
1872
1897
|
},
|
|
1873
1898
|
type: this.widgetType,
|
|
1874
1899
|
domain: ((_a2 = this.config) == null ? void 0 : _a2.domain) || DEFAULT_DOMAIN,
|
|
@@ -1936,7 +1961,7 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1936
1961
|
engagementMedium: this.type,
|
|
1937
1962
|
widgetType: this.widgetType,
|
|
1938
1963
|
locale: this.locale
|
|
1939
|
-
}).then((res) => this._setWidget(res
|
|
1964
|
+
}).then((res) => this._setWidget(res, { type: "passwordless" })).catch(this.setErrorWidget);
|
|
1940
1965
|
}
|
|
1941
1966
|
async renderUserUpsertVariant() {
|
|
1942
1967
|
this._setupApis();
|
|
@@ -1945,15 +1970,20 @@ class DeclarativeWidget extends HTMLElement {
|
|
|
1945
1970
|
return this.setErrorWidget(Error("No user object in token."));
|
|
1946
1971
|
}
|
|
1947
1972
|
_log$1("Rendering as a Verified widget");
|
|
1948
|
-
|
|
1973
|
+
await this.widgetApi.upsertUser({
|
|
1949
1974
|
user: userObj,
|
|
1950
1975
|
locale: this.locale,
|
|
1951
1976
|
engagementMedium: this.type,
|
|
1952
1977
|
widgetType: this.widgetType,
|
|
1953
1978
|
jwt: this.token
|
|
1954
|
-
})
|
|
1955
|
-
|
|
1956
|
-
|
|
1979
|
+
});
|
|
1980
|
+
const widgetInstance = await this.widgetApi.render({
|
|
1981
|
+
locale: this.locale,
|
|
1982
|
+
engagementMedium: this.type,
|
|
1983
|
+
widgetType: this.widgetType
|
|
1984
|
+
}).then((res) => {
|
|
1985
|
+
return this._setWidget(res, { type: "upsert", user: userObj });
|
|
1986
|
+
}).catch(this.setErrorWidget);
|
|
1957
1987
|
return widgetInstance;
|
|
1958
1988
|
}
|
|
1959
1989
|
/**
|