@saasquatch/squatch-js 2.7.0 → 2.8.0-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.
- 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 +1 -1
package/dist/squatch.js
CHANGED
|
@@ -758,6 +758,41 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
758
758
|
if (locale) queryParams.append("locale", locale);
|
|
759
759
|
return `?${queryParams.toString()}`;
|
|
760
760
|
}
|
|
761
|
+
/*!
|
|
762
|
+
* domready (c) Dustin Diaz 2014 - License MIT
|
|
763
|
+
*
|
|
764
|
+
*/
|
|
765
|
+
function domready(targetDoc, fn) {
|
|
766
|
+
let fns = [];
|
|
767
|
+
let listener;
|
|
768
|
+
let doc = targetDoc;
|
|
769
|
+
let hack = doc.documentElement.doScroll;
|
|
770
|
+
let domContentLoaded = "DOMContentLoaded";
|
|
771
|
+
let loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState);
|
|
772
|
+
if (!loaded)
|
|
773
|
+
doc.addEventListener(
|
|
774
|
+
domContentLoaded,
|
|
775
|
+
listener = () => {
|
|
776
|
+
doc.removeEventListener(domContentLoaded, listener);
|
|
777
|
+
loaded = true;
|
|
778
|
+
while (listener = fns.shift()) listener();
|
|
779
|
+
}
|
|
780
|
+
);
|
|
781
|
+
return loaded ? setTimeout(fn, 0) : fns.push(fn);
|
|
782
|
+
}
|
|
783
|
+
function formatWidth({
|
|
784
|
+
value,
|
|
785
|
+
unit
|
|
786
|
+
}) {
|
|
787
|
+
switch (unit) {
|
|
788
|
+
case "px":
|
|
789
|
+
return `${value}px`;
|
|
790
|
+
case "%":
|
|
791
|
+
return `${value}%`;
|
|
792
|
+
default:
|
|
793
|
+
return `${value}px`;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
761
796
|
class AnalyticsApi {
|
|
762
797
|
/**
|
|
763
798
|
* Initialize a new {@link AnalyticsApi} instance.
|
|
@@ -1066,28 +1101,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1066
1101
|
setTimeout(resolve, duration);
|
|
1067
1102
|
});
|
|
1068
1103
|
}
|
|
1069
|
-
/*!
|
|
1070
|
-
* domready (c) Dustin Diaz 2014 - License MIT
|
|
1071
|
-
*
|
|
1072
|
-
*/
|
|
1073
|
-
function domready(targetDoc, fn) {
|
|
1074
|
-
let fns = [];
|
|
1075
|
-
let listener;
|
|
1076
|
-
let doc = targetDoc;
|
|
1077
|
-
let hack = doc.documentElement.doScroll;
|
|
1078
|
-
let domContentLoaded = "DOMContentLoaded";
|
|
1079
|
-
let loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState);
|
|
1080
|
-
if (!loaded)
|
|
1081
|
-
doc.addEventListener(
|
|
1082
|
-
domContentLoaded,
|
|
1083
|
-
listener = () => {
|
|
1084
|
-
doc.removeEventListener(domContentLoaded, listener);
|
|
1085
|
-
loaded = true;
|
|
1086
|
-
while (listener = fns.shift()) listener();
|
|
1087
|
-
}
|
|
1088
|
-
);
|
|
1089
|
-
return loaded ? setTimeout(fn, 0) : fns.push(fn);
|
|
1090
|
-
}
|
|
1091
1104
|
const _log$7 = browserExports.debug("squatch-js:EMBEDwidget");
|
|
1092
1105
|
class EmbedWidget extends Widget {
|
|
1093
1106
|
constructor(params, container) {
|
|
@@ -1097,7 +1110,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1097
1110
|
if (container) this.container = container;
|
|
1098
1111
|
}
|
|
1099
1112
|
async load() {
|
|
1100
|
-
var _a2, _b;
|
|
1113
|
+
var _a2, _b, _c, _d, _e;
|
|
1101
1114
|
const frame = this._createFrame();
|
|
1102
1115
|
const element = this._findElement();
|
|
1103
1116
|
if ((_a2 = this.context) == null ? void 0 : _a2.container) {
|
|
@@ -1105,9 +1118,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1105
1118
|
element.style.height = "0";
|
|
1106
1119
|
element.style["overflow-y"] = "hidden";
|
|
1107
1120
|
}
|
|
1121
|
+
const brandingConfig = (_c = (_b = this.context.widgetConfig) == null ? void 0 : _b.values) == null ? void 0 : _c.brandingConfig;
|
|
1122
|
+
const sizes = (_d = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _d.embeddedWidgets;
|
|
1123
|
+
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "100%";
|
|
1124
|
+
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "100%";
|
|
1125
|
+
element.style.maxWidth = maxWidth;
|
|
1126
|
+
element.style.minWidth = minWidth;
|
|
1108
1127
|
if (this.container) {
|
|
1109
1128
|
if (element.shadowRoot) {
|
|
1110
|
-
if (((
|
|
1129
|
+
if (((_e = element.shadowRoot.lastChild) == null ? void 0 : _e.nodeName) === "IFRAME") {
|
|
1111
1130
|
element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);
|
|
1112
1131
|
} else {
|
|
1113
1132
|
element.shadowRoot.appendChild(frame);
|
|
@@ -1230,11 +1249,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1230
1249
|
}
|
|
1231
1250
|
}
|
|
1232
1251
|
_createPopupDialog() {
|
|
1252
|
+
var _a2, _b, _c;
|
|
1233
1253
|
const dialog = document.createElement("dialog");
|
|
1254
|
+
const brandingConfig = (_b = (_a2 = this.context.widgetConfig) == null ? void 0 : _a2.values) == null ? void 0 : _b.brandingConfig;
|
|
1255
|
+
const sizes = (_c = brandingConfig == null ? void 0 : brandingConfig.widgetSize) == null ? void 0 : _c.popupWidgets;
|
|
1256
|
+
const minWidth = (sizes == null ? void 0 : sizes.minWidth) ? formatWidth(sizes.minWidth) : "100%";
|
|
1257
|
+
const maxWidth = (sizes == null ? void 0 : sizes.maxWidth) ? formatWidth(sizes.maxWidth) : "500px";
|
|
1234
1258
|
dialog.id = this.id;
|
|
1235
1259
|
dialog.setAttribute(
|
|
1236
1260
|
"style",
|
|
1237
|
-
|
|
1261
|
+
`width: 100%; min-width: ${minWidth}; max-width: ${maxWidth}; border: none; padding: 0;`
|
|
1238
1262
|
);
|
|
1239
1263
|
const onClick = (e) => {
|
|
1240
1264
|
e.stopPropagation();
|
|
@@ -1863,16 +1887,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1863
1887
|
* @hidden
|
|
1864
1888
|
*/
|
|
1865
1889
|
__publicField(this, "loaded");
|
|
1866
|
-
__publicField(this, "_setWidget", (
|
|
1890
|
+
__publicField(this, "_setWidget", (res, config) => {
|
|
1867
1891
|
var _a2;
|
|
1868
1892
|
const params = {
|
|
1869
1893
|
api: this.widgetApi,
|
|
1870
|
-
content: template,
|
|
1894
|
+
content: res.template,
|
|
1871
1895
|
context: {
|
|
1872
1896
|
type: config.type,
|
|
1873
1897
|
user: config.user,
|
|
1874
1898
|
container: this.container || void 0,
|
|
1875
|
-
engagementMedium: this.type
|
|
1899
|
+
engagementMedium: this.type,
|
|
1900
|
+
widgetConfig: res.widgetConfig
|
|
1876
1901
|
},
|
|
1877
1902
|
type: this.widgetType,
|
|
1878
1903
|
domain: ((_a2 = this.config) == null ? void 0 : _a2.domain) || DEFAULT_DOMAIN,
|
|
@@ -1940,7 +1965,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1940
1965
|
engagementMedium: this.type,
|
|
1941
1966
|
widgetType: this.widgetType,
|
|
1942
1967
|
locale: this.locale
|
|
1943
|
-
}).then((res) => this._setWidget(res
|
|
1968
|
+
}).then((res) => this._setWidget(res, { type: "passwordless" })).catch(this.setErrorWidget);
|
|
1944
1969
|
}
|
|
1945
1970
|
async renderUserUpsertVariant() {
|
|
1946
1971
|
this._setupApis();
|
|
@@ -1949,15 +1974,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1949
1974
|
return this.setErrorWidget(Error("No user object in token."));
|
|
1950
1975
|
}
|
|
1951
1976
|
_log$1("Rendering as a Verified widget");
|
|
1952
|
-
|
|
1977
|
+
await this.widgetApi.upsertUser({
|
|
1953
1978
|
user: userObj,
|
|
1954
1979
|
locale: this.locale,
|
|
1955
1980
|
engagementMedium: this.type,
|
|
1956
1981
|
widgetType: this.widgetType,
|
|
1957
1982
|
jwt: this.token
|
|
1958
|
-
})
|
|
1959
|
-
|
|
1960
|
-
|
|
1983
|
+
});
|
|
1984
|
+
const widgetInstance = await this.widgetApi.render({
|
|
1985
|
+
locale: this.locale,
|
|
1986
|
+
engagementMedium: this.type,
|
|
1987
|
+
widgetType: this.widgetType
|
|
1988
|
+
}).then((res) => {
|
|
1989
|
+
return this._setWidget(res, { type: "upsert", user: userObj });
|
|
1990
|
+
}).catch(this.setErrorWidget);
|
|
1961
1991
|
return widgetInstance;
|
|
1962
1992
|
}
|
|
1963
1993
|
/**
|