@saasquatch/squatch-js 2.5.1-9 → 2.6.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/.github/workflows/size-limit.yml +15 -0
- package/CHANGELOG.md +326 -334
- package/LICENSE +20 -20
- package/README.md +180 -145
- package/babel.config.js +8 -0
- package/coverage/clover.xml +888 -0
- package/coverage/coverage-final.json +23 -0
- package/coverage/lcov-report/api/AnalyticsApi.ts.html +304 -0
- package/coverage/lcov-report/api/WidgetApi.ts.html +628 -0
- package/coverage/lcov-report/api/graphql.ts.html +130 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/utils/cookieUtils.ts.html +415 -0
- package/coverage/lcov-report/utils/decodeUserJwt.ts.html +133 -0
- package/coverage/lcov-report/utils/domready.ts.html +160 -0
- package/coverage/lcov-report/utils/io.ts.html +385 -0
- package/coverage/lcov-report/utils/utmUtils.ts.html +277 -0
- package/coverage/lcov-report/utils/validate.ts.html +268 -0
- package/coverage/lcov-report/validate.ts.html +268 -0
- package/coverage/lcov-report/widgets/EmbedWidget.ts.html +436 -0
- package/coverage/lcov-report/widgets/PopupWidget.ts.html +625 -0
- package/coverage/lcov-report/widgets/Widget.ts.html +1108 -0
- package/coverage/lcov-report/widgets/declarative/DeclarativeWidget.ts.html +499 -0
- package/coverage/lcov.info +1628 -0
- package/demo/sandbox.ts +124 -124
- package/demo/toolbar.tsx +526 -526
- package/dist/api/AnalyticsApi.d.ts +32 -32
- package/dist/api/EventsApi.d.ts +52 -52
- package/dist/api/WidgetApi.d.ts +63 -80
- package/dist/api/graphql.d.ts +1 -1
- package/dist/async.d.ts +15 -11
- package/dist/docs.d.ts +1 -1
- package/dist/squatch.d.ts +108 -108
- package/dist/squatch.esm.js +1105 -1417
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +1105 -1438
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +2 -13
- package/dist/squatch.min.js.LICENSE.txt +6 -0
- package/dist/squatch.min.js.map +1 -1
- package/dist/squatch.modern.js +1 -1
- package/dist/squatch.modern.js.map +1 -1
- package/dist/stats.html +1 -1
- package/dist/types.d.ts +107 -106
- package/dist/utils/cookieUtils.d.ts +2 -2
- package/dist/utils/decodeUserJwt.d.ts +2 -0
- package/dist/utils/domUtils.d.ts +1 -0
- package/dist/utils/domready.d.ts +6 -6
- package/dist/utils/io.d.ts +5 -13
- package/dist/utils/loadEvent.d.ts +2 -0
- package/dist/utils/utmUtils.d.ts +14 -14
- package/dist/utils/validate.d.ts +12 -16
- package/dist/widgets/EmbedWidget.d.ts +16 -15
- package/dist/widgets/IREmbedWidget.d.ts +29 -0
- package/dist/widgets/IRPopupWidget.d.ts +32 -0
- package/dist/widgets/PopupWidget.d.ts +25 -23
- package/dist/widgets/Widget.d.ts +53 -33
- package/dist/widgets/Widgets.d.ts +108 -116
- package/dist/widgets/declarative/DeclarativeEmbedWidget.d.ts +12 -0
- package/dist/widgets/declarative/DeclarativeWidget.d.ts +32 -0
- package/dist/widgets/declarative/DeclarativeWidgets.d.ts +13 -0
- package/jest.config.ts +202 -0
- package/package.json +123 -105
- package/stats.json +1 -0
- package/tsconfig.json +2 -2
package/dist/types.d.ts
CHANGED
|
@@ -1,106 +1,107 @@
|
|
|
1
|
-
import Widget from "./widgets/Widget";
|
|
2
|
-
export
|
|
3
|
-
[P in K]-?: T[P];
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* When you load Squatch.js you need to provide these configuration options.
|
|
7
|
-
*
|
|
8
|
-
* @param tenantAlias The Tenant that you're using.
|
|
9
|
-
* @param domain The domain for API. Defaults to `https://app.referralsaasquatch.com`
|
|
10
|
-
* @param debug Enables debug logging. Defaults to `false`.
|
|
11
|
-
*/
|
|
12
|
-
export interface ConfigOptions {
|
|
13
|
-
tenantAlias: string;
|
|
14
|
-
domain?: string;
|
|
15
|
-
npmCdn?: string;
|
|
16
|
-
debug?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @param
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
export
|
|
103
|
-
export
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
1
|
+
import Widget from "./widgets/Widget";
|
|
2
|
+
export type WithRequired<T, K extends keyof T> = T & {
|
|
3
|
+
[P in K]-?: T[P];
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* When you load Squatch.js you need to provide these configuration options.
|
|
7
|
+
*
|
|
8
|
+
* @param tenantAlias The Tenant that you're using.
|
|
9
|
+
* @param domain The domain for API. Defaults to `https://app.referralsaasquatch.com`
|
|
10
|
+
* @param debug Enables debug logging. Defaults to `false`.
|
|
11
|
+
*/
|
|
12
|
+
export interface ConfigOptions {
|
|
13
|
+
tenantAlias: string;
|
|
14
|
+
domain?: string;
|
|
15
|
+
npmCdn?: string;
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export type DeclarativeConfigOptions = Omit<ConfigOptions, "tenantAlias">;
|
|
19
|
+
/**
|
|
20
|
+
* Config options for loading a widget
|
|
21
|
+
*
|
|
22
|
+
* @param user The user details
|
|
23
|
+
* @param widgetType The content of the widget.
|
|
24
|
+
* @param engagementMedium How to display the widget.
|
|
25
|
+
* @param container Element to load the widget into.
|
|
26
|
+
* @param trigger Trigger element's selector for opening the popup widget
|
|
27
|
+
* @param jwt the JSON Web Token (JWT) that is used
|
|
28
|
+
*/
|
|
29
|
+
export interface WidgetConfig {
|
|
30
|
+
user?: User;
|
|
31
|
+
widgetType?: WidgetType;
|
|
32
|
+
engagementMedium?: EngagementMedium;
|
|
33
|
+
container?: HTMLElement | string;
|
|
34
|
+
trigger?: string;
|
|
35
|
+
jwt?: JWT;
|
|
36
|
+
locale?: string;
|
|
37
|
+
displayOnLoad?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @param user The user details
|
|
41
|
+
* @param widgetType The content of the widget.
|
|
42
|
+
* @param engagementMedium How to display the widget.
|
|
43
|
+
* @param jwt the JSON Web Token (JWT) that is used
|
|
44
|
+
*/
|
|
45
|
+
export interface CookieWidgetConfig {
|
|
46
|
+
user?: CookieUser;
|
|
47
|
+
widgetType?: WidgetType;
|
|
48
|
+
engagementMedium?: EngagementMedium;
|
|
49
|
+
jwt?: JWT;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* When a widget is loaded using {@link Widgets} you'll get both the `user` data and the `widget` object back.
|
|
53
|
+
*
|
|
54
|
+
* @param widget The widget that was created.
|
|
55
|
+
* @param user The user that's in the widget.
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
export interface WidgetResult {
|
|
59
|
+
widget: Widget;
|
|
60
|
+
user: User;
|
|
61
|
+
}
|
|
62
|
+
export type User = {
|
|
63
|
+
id: string;
|
|
64
|
+
accountId: string;
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
};
|
|
67
|
+
export type CookieUser = {
|
|
68
|
+
[key: string]: any;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* EngagementMedium is an enum for the content of the widgets.
|
|
72
|
+
*
|
|
73
|
+
* @example `widgetType: "POPUP"`
|
|
74
|
+
*/
|
|
75
|
+
export type EngagementMedium =
|
|
76
|
+
/** Displays the widget as a modal popup. Creates a {@link PopupWidget} */
|
|
77
|
+
"POPUP"
|
|
78
|
+
/** Displays the widget embedded in the page. Create an {@link EmbedWidget} */
|
|
79
|
+
| "EMBED";
|
|
80
|
+
export type WidgetContext = {
|
|
81
|
+
type: "cookie" | "error" | "passwordless";
|
|
82
|
+
engagementMedium?: EngagementMedium;
|
|
83
|
+
container?: HTMLElement | string;
|
|
84
|
+
trigger?: string;
|
|
85
|
+
displayOnLoad?: boolean;
|
|
86
|
+
} | {
|
|
87
|
+
type: "upsert";
|
|
88
|
+
user?: User | null;
|
|
89
|
+
engagementMedium?: EngagementMedium;
|
|
90
|
+
container?: HTMLElement | string;
|
|
91
|
+
trigger?: string;
|
|
92
|
+
};
|
|
93
|
+
export type WidgetContextType = "upsert" | "cookie" | "error" | "passwordless";
|
|
94
|
+
/**
|
|
95
|
+
* WidgetType is an enum for types of ways a Widget can be displayed.
|
|
96
|
+
*/
|
|
97
|
+
export type WidgetType =
|
|
98
|
+
/** Widget content that lets people make referrals */
|
|
99
|
+
"REFERRER_WIDGET"
|
|
100
|
+
/** Widget content that shows that someone has been referred */
|
|
101
|
+
| "CONVERSION_WIDGET" | string;
|
|
102
|
+
export type ShareMedium = string;
|
|
103
|
+
export type JWT = string;
|
|
104
|
+
export type ReferralCookie = {
|
|
105
|
+
codes: string[];
|
|
106
|
+
encodedCookie: string;
|
|
107
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function b64decode(input: any): string;
|
|
2
|
-
export declare function _pushCookie(): void;
|
|
1
|
+
export declare function b64decode(input: any): string;
|
|
2
|
+
export declare function _pushCookie(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createFrame: (container: string | HTMLElement, instance: any) => void;
|
package/dist/utils/domready.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/*!
|
|
3
|
-
* domready (c) Dustin Diaz 2014 - License MIT
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
export declare function domready(targetDoc: any, fn: any): number | NodeJS.Timeout;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/*!
|
|
3
|
+
* domready (c) Dustin Diaz 2014 - License MIT
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare function domready(targetDoc: any, fn: any): number | NodeJS.Timeout;
|
package/dist/utils/io.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import { JWT } from "../types";
|
|
2
|
-
export declare function doQuery(url: string, query: string, variables:
|
|
3
|
-
export declare function doGet<T>(url: any, jwt?: string): Promise<T>;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* @param url The requested url
|
|
8
|
-
* @param data Stringified json object
|
|
9
|
-
*
|
|
10
|
-
* @returns {Promise} superagent promise
|
|
11
|
-
*/
|
|
12
|
-
export declare function doPost(url: string, data: any, jwt?: JWT): Promise<any>;
|
|
13
|
-
export declare function doPut(url: string, data: any, jwt?: JWT): Promise<any>;
|
|
1
|
+
import { JWT } from "../types";
|
|
2
|
+
export declare function doQuery(url: string, query: string, variables: Record<string, unknown>, token: string | undefined): Promise<any>;
|
|
3
|
+
export declare function doGet<T>(url: any, jwt?: string): Promise<T>;
|
|
4
|
+
export declare function doPost(url: string, data: any, jwt?: JWT): Promise<any>;
|
|
5
|
+
export declare function doPut(url: string, data: any, jwt?: JWT): Promise<any>;
|
package/dist/utils/utmUtils.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ConfigOptions, WidgetConfig } from "../types";
|
|
2
|
-
export declare function _getAutoConfig(configIn
|
|
3
|
-
widgetConfig: WidgetConfig;
|
|
4
|
-
squatchConfig: ConfigOptions;
|
|
5
|
-
} | undefined;
|
|
6
|
-
/**
|
|
7
|
-
* Deconstructs _saasquatchExtra into domain, tenantAlias, and widgetConfig
|
|
8
|
-
* @param obj {Record<string, any>} Expected to be of the form `{ [appDomain]: { [tenantAlias]: { autoPopupWidgetType: [widgetType], [rest]?: ... } } }`
|
|
9
|
-
*/
|
|
10
|
-
export declare function convertExtraToConfig(obj: Record<string, any>): {
|
|
11
|
-
domain: string | undefined;
|
|
12
|
-
tenantAlias: string;
|
|
13
|
-
widgetConfig: any;
|
|
14
|
-
};
|
|
1
|
+
import { ConfigOptions, WidgetConfig } from "../types";
|
|
2
|
+
export declare function _getAutoConfig(configIn?: ConfigOptions): {
|
|
3
|
+
widgetConfig: WidgetConfig;
|
|
4
|
+
squatchConfig: ConfigOptions;
|
|
5
|
+
} | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Deconstructs _saasquatchExtra into domain, tenantAlias, and widgetConfig
|
|
8
|
+
* @param obj {Record<string, any>} Expected to be of the form `{ [appDomain]: { [tenantAlias]: { autoPopupWidgetType: [widgetType], [rest]?: ... } } }`
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertExtraToConfig(obj: Record<string, any>): {
|
|
11
|
+
domain: string | undefined;
|
|
12
|
+
tenantAlias: string;
|
|
13
|
+
widgetConfig: any;
|
|
14
|
+
};
|
package/dist/utils/validate.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { ConfigOptions, WidgetConfig } from "../types";
|
|
2
|
-
declare
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
declare
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
export declare function validateLocale(locale?: string): string | undefined;
|
|
14
|
-
export declare function validateWidgetConfig(raw: unknown): WidgetConfig;
|
|
15
|
-
export declare function validatePasswordlessConfig(raw: unknown): WidgetConfig;
|
|
16
|
-
export {};
|
|
1
|
+
import { ConfigOptions, WidgetConfig } from "../types";
|
|
2
|
+
export declare const DEFAULT_DOMAIN = "https://app.referralsaasquatch.com";
|
|
3
|
+
export declare const DEFAULT_NPM_CDN = "https://fast.ssqt.io/npm";
|
|
4
|
+
type Required<T> = T extends object ? {
|
|
5
|
+
[P in keyof T]-?: NonNullable<T[P]>;
|
|
6
|
+
} : T;
|
|
7
|
+
export declare function validateConfig(_raw?: unknown | undefined): Required<ConfigOptions>;
|
|
8
|
+
export declare function isObject(obj: unknown): obj is object;
|
|
9
|
+
export declare function validateLocale(locale?: string): string | undefined;
|
|
10
|
+
export declare function validateWidgetConfig(raw: unknown | undefined): WidgetConfig;
|
|
11
|
+
export declare function validatePasswordlessConfig(raw: unknown | undefined): WidgetConfig;
|
|
12
|
+
export {};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import Widget, { Params } from "./Widget";
|
|
2
|
-
/**
|
|
3
|
-
* An EmbedWidget is displayed inline in part of your page.
|
|
4
|
-
*
|
|
5
|
-
* To create an EmbedWidget use {@link Widgets}
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
export default class EmbedWidget extends Widget {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import Widget, { Params } from "./Widget";
|
|
2
|
+
/**
|
|
3
|
+
* An EmbedWidget is displayed inline in part of your page.
|
|
4
|
+
*
|
|
5
|
+
* To create an EmbedWidget use {@link Widgets}
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export default class EmbedWidget extends Widget {
|
|
9
|
+
constructor(params: Params, container?: HTMLElement | string);
|
|
10
|
+
load(frame: HTMLIFrameElement): Promise<void>;
|
|
11
|
+
open(frame: HTMLIFrameElement): void;
|
|
12
|
+
close(frame: HTMLIFrameElement): void;
|
|
13
|
+
protected _error(rs: any, mode?: string, style?: string): string;
|
|
14
|
+
show: (frame: HTMLIFrameElement) => void;
|
|
15
|
+
hide: (frame: HTMLIFrameElement) => void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import AnalyticsApi from "../api/AnalyticsApi";
|
|
2
|
+
import { DeclarativeConfigOptions, EmbedWidget, WidgetApi } from "../squatch";
|
|
3
|
+
export default class IREmbedWidget extends HTMLElement {
|
|
4
|
+
widgetType: string | null;
|
|
5
|
+
container: string | HTMLElement | null;
|
|
6
|
+
element: HTMLElement;
|
|
7
|
+
frame: HTMLIFrameElement;
|
|
8
|
+
content: string;
|
|
9
|
+
analyticsApi: AnalyticsApi;
|
|
10
|
+
widgetApi: WidgetApi;
|
|
11
|
+
config: DeclarativeConfigOptions;
|
|
12
|
+
tenantAlias: string;
|
|
13
|
+
token: string;
|
|
14
|
+
widget: EmbedWidget;
|
|
15
|
+
constructor();
|
|
16
|
+
static get observedAttributes(): string[];
|
|
17
|
+
attributeChangedCallback(attr: string, oldVal: string, newVal: string): void;
|
|
18
|
+
_setupApi({ domain, tenantAlias }: {
|
|
19
|
+
domain: string;
|
|
20
|
+
tenantAlias: string;
|
|
21
|
+
}): void;
|
|
22
|
+
_loadPasswordlessWidget(): void;
|
|
23
|
+
_loadUserWidget(jwt: string): void;
|
|
24
|
+
_renderErrorWidget: () => void;
|
|
25
|
+
_renderWidget: (res: any) => void;
|
|
26
|
+
connectedCallback(): void;
|
|
27
|
+
open(): void;
|
|
28
|
+
close(): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import AnalyticsApi from "../api/AnalyticsApi";
|
|
2
|
+
import { PopupWidget, WidgetApi, WidgetContext } from "../squatch";
|
|
3
|
+
export default class IRPopupWidget extends HTMLElement {
|
|
4
|
+
triggerElement: HTMLElement | null;
|
|
5
|
+
popupdiv: HTMLElement;
|
|
6
|
+
popupcontent: HTMLElement;
|
|
7
|
+
widgetType: string | null;
|
|
8
|
+
frame: HTMLIFrameElement;
|
|
9
|
+
analyticsApi: AnalyticsApi;
|
|
10
|
+
widgetApi: WidgetApi;
|
|
11
|
+
content: string;
|
|
12
|
+
widget: PopupWidget;
|
|
13
|
+
constructor();
|
|
14
|
+
static get observedAttributes(): string[];
|
|
15
|
+
attributeChangedCallback(attr: string, oldVal: string, newVal: string): void;
|
|
16
|
+
connectedCallback(): void;
|
|
17
|
+
_setupApi({ domain, tenantAlias }: {
|
|
18
|
+
domain: string;
|
|
19
|
+
tenantAlias: string;
|
|
20
|
+
}): void;
|
|
21
|
+
_setFrameContents(res: any): void;
|
|
22
|
+
_loadPasswordlessWidget(): void;
|
|
23
|
+
_loadUserWidget(jwt: string): void;
|
|
24
|
+
_renderErrorWidget(): void;
|
|
25
|
+
_renderWidget(res: any, context: WidgetContext): void;
|
|
26
|
+
protected _setupResizeHandler(): void;
|
|
27
|
+
protected _clickedOutside({ target }: {
|
|
28
|
+
target: any;
|
|
29
|
+
}): void;
|
|
30
|
+
open(): void;
|
|
31
|
+
close(): void;
|
|
32
|
+
}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import Widget, { Params } from "./Widget";
|
|
2
|
-
/**
|
|
3
|
-
* The PopupWidget is used to display popups (also known as "Modals").
|
|
4
|
-
* Popups widgets are rendered on top of other elements in a page.
|
|
5
|
-
*
|
|
6
|
-
* To create a PopupWidget use {@link Widgets}
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
export default class PopupWidget extends Widget {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
load(): void;
|
|
16
|
-
protected _setupResizeHandler(): void;
|
|
17
|
-
open(): void;
|
|
18
|
-
close(): void;
|
|
19
|
-
protected _clickedOutside({ target }: {
|
|
20
|
-
target: any;
|
|
21
|
-
}): void;
|
|
22
|
-
protected _error(rs: any, mode?: string, style?: string): string;
|
|
23
|
-
|
|
1
|
+
import Widget, { Params } from "./Widget";
|
|
2
|
+
/**
|
|
3
|
+
* The PopupWidget is used to display popups (also known as "Modals").
|
|
4
|
+
* Popups widgets are rendered on top of other elements in a page.
|
|
5
|
+
*
|
|
6
|
+
* To create a PopupWidget use {@link Widgets}
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export default class PopupWidget extends Widget {
|
|
10
|
+
trigger: string;
|
|
11
|
+
id: string;
|
|
12
|
+
constructor(params: Params, trigger?: string);
|
|
13
|
+
_initialiseCTA(frame: HTMLIFrameElement): void;
|
|
14
|
+
_createPopupDialog(): HTMLDialogElement;
|
|
15
|
+
load(frame: HTMLIFrameElement): void;
|
|
16
|
+
protected _setupResizeHandler(frame: HTMLIFrameElement): void;
|
|
17
|
+
open(frame: HTMLIFrameElement): void;
|
|
18
|
+
close(): void;
|
|
19
|
+
protected _clickedOutside({ target }: {
|
|
20
|
+
target: any;
|
|
21
|
+
}): void;
|
|
22
|
+
protected _error(rs: any, mode?: string, style?: string): string;
|
|
23
|
+
show: (frame: HTMLIFrameElement) => void;
|
|
24
|
+
hide: () => void;
|
|
25
|
+
}
|
package/dist/widgets/Widget.d.ts
CHANGED
|
@@ -1,33 +1,53 @@
|
|
|
1
|
-
import AnalyticsApi from "../api/AnalyticsApi";
|
|
2
|
-
import WidgetApi from "../api/WidgetApi";
|
|
3
|
-
import {
|
|
4
|
-
export interface Params {
|
|
5
|
-
type: WidgetType;
|
|
6
|
-
domain: string;
|
|
7
|
-
npmCdn: string;
|
|
8
|
-
content: string;
|
|
9
|
-
api: WidgetApi;
|
|
10
|
-
rsCode?: string;
|
|
11
|
-
context: WidgetContext;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import AnalyticsApi from "../api/AnalyticsApi";
|
|
2
|
+
import WidgetApi from "../api/WidgetApi";
|
|
3
|
+
import { EngagementMedium, WidgetContext, WidgetType } from "../types";
|
|
4
|
+
export interface Params {
|
|
5
|
+
type: WidgetType;
|
|
6
|
+
domain: string;
|
|
7
|
+
npmCdn: string;
|
|
8
|
+
content: string;
|
|
9
|
+
api: WidgetApi;
|
|
10
|
+
rsCode?: string;
|
|
11
|
+
context: WidgetContext;
|
|
12
|
+
container?: string | HTMLElement | null | undefined;
|
|
13
|
+
}
|
|
14
|
+
export type ProgramLoadEvent = {
|
|
15
|
+
programId: string;
|
|
16
|
+
tenantAlias?: string;
|
|
17
|
+
accountId?: string;
|
|
18
|
+
userId?: string;
|
|
19
|
+
engagementMedium?: EngagementMedium;
|
|
20
|
+
};
|
|
21
|
+
export type GenericLoadEvent = {
|
|
22
|
+
mode: any;
|
|
23
|
+
analytics: any;
|
|
24
|
+
};
|
|
25
|
+
export default abstract class Widget {
|
|
26
|
+
type: WidgetType;
|
|
27
|
+
content: string;
|
|
28
|
+
analyticsApi: AnalyticsApi;
|
|
29
|
+
widgetApi: WidgetApi;
|
|
30
|
+
context: WidgetContext;
|
|
31
|
+
npmCdn: string;
|
|
32
|
+
container: string | HTMLElement | undefined | null;
|
|
33
|
+
protected constructor(params: Params);
|
|
34
|
+
_findElement(): HTMLElement;
|
|
35
|
+
_createFrame(): HTMLIFrameElement;
|
|
36
|
+
abstract load(frame: HTMLIFrameElement): void;
|
|
37
|
+
protected _loadEvent(sqh: ProgramLoadEvent | GenericLoadEvent): void;
|
|
38
|
+
protected _shareEvent(sqh: any, medium: any): void;
|
|
39
|
+
protected _error(rs: any, mode?: string, style?: string): string;
|
|
40
|
+
protected _findInnerContainer(frame: HTMLIFrameElement): Promise<Element>;
|
|
41
|
+
/**
|
|
42
|
+
* Reloads the current widget, makes updated request to API and renders result.
|
|
43
|
+
* Primarily for Classic widgets with registration
|
|
44
|
+
* @param param0 Form field values
|
|
45
|
+
* @param jwt JWT for API authentication
|
|
46
|
+
*/
|
|
47
|
+
reload(frame: HTMLIFrameElement, { email, firstName, lastName }: {
|
|
48
|
+
email: any;
|
|
49
|
+
firstName: any;
|
|
50
|
+
lastName: any;
|
|
51
|
+
}, jwt: any): void;
|
|
52
|
+
private __deprecated__register;
|
|
53
|
+
}
|