@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.
Files changed (70) hide show
  1. package/.github/workflows/size-limit.yml +15 -0
  2. package/CHANGELOG.md +326 -334
  3. package/LICENSE +20 -20
  4. package/README.md +180 -145
  5. package/babel.config.js +8 -0
  6. package/coverage/clover.xml +888 -0
  7. package/coverage/coverage-final.json +23 -0
  8. package/coverage/lcov-report/api/AnalyticsApi.ts.html +304 -0
  9. package/coverage/lcov-report/api/WidgetApi.ts.html +628 -0
  10. package/coverage/lcov-report/api/graphql.ts.html +130 -0
  11. package/coverage/lcov-report/base.css +224 -0
  12. package/coverage/lcov-report/block-navigation.js +87 -0
  13. package/coverage/lcov-report/favicon.png +0 -0
  14. package/coverage/lcov-report/prettify.css +1 -0
  15. package/coverage/lcov-report/prettify.js +2 -0
  16. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  17. package/coverage/lcov-report/sorter.js +196 -0
  18. package/coverage/lcov-report/utils/cookieUtils.ts.html +415 -0
  19. package/coverage/lcov-report/utils/decodeUserJwt.ts.html +133 -0
  20. package/coverage/lcov-report/utils/domready.ts.html +160 -0
  21. package/coverage/lcov-report/utils/io.ts.html +385 -0
  22. package/coverage/lcov-report/utils/utmUtils.ts.html +277 -0
  23. package/coverage/lcov-report/utils/validate.ts.html +268 -0
  24. package/coverage/lcov-report/validate.ts.html +268 -0
  25. package/coverage/lcov-report/widgets/EmbedWidget.ts.html +436 -0
  26. package/coverage/lcov-report/widgets/PopupWidget.ts.html +625 -0
  27. package/coverage/lcov-report/widgets/Widget.ts.html +1108 -0
  28. package/coverage/lcov-report/widgets/declarative/DeclarativeWidget.ts.html +499 -0
  29. package/coverage/lcov.info +1628 -0
  30. package/demo/sandbox.ts +124 -124
  31. package/demo/toolbar.tsx +526 -526
  32. package/dist/api/AnalyticsApi.d.ts +32 -32
  33. package/dist/api/EventsApi.d.ts +52 -52
  34. package/dist/api/WidgetApi.d.ts +63 -80
  35. package/dist/api/graphql.d.ts +1 -1
  36. package/dist/async.d.ts +15 -11
  37. package/dist/docs.d.ts +1 -1
  38. package/dist/squatch.d.ts +108 -108
  39. package/dist/squatch.esm.js +1105 -1417
  40. package/dist/squatch.esm.js.map +1 -1
  41. package/dist/squatch.js +1105 -1438
  42. package/dist/squatch.js.map +1 -1
  43. package/dist/squatch.min.js +2 -13
  44. package/dist/squatch.min.js.LICENSE.txt +6 -0
  45. package/dist/squatch.min.js.map +1 -1
  46. package/dist/squatch.modern.js +1 -1
  47. package/dist/squatch.modern.js.map +1 -1
  48. package/dist/stats.html +1 -1
  49. package/dist/types.d.ts +107 -106
  50. package/dist/utils/cookieUtils.d.ts +2 -2
  51. package/dist/utils/decodeUserJwt.d.ts +2 -0
  52. package/dist/utils/domUtils.d.ts +1 -0
  53. package/dist/utils/domready.d.ts +6 -6
  54. package/dist/utils/io.d.ts +5 -13
  55. package/dist/utils/loadEvent.d.ts +2 -0
  56. package/dist/utils/utmUtils.d.ts +14 -14
  57. package/dist/utils/validate.d.ts +12 -16
  58. package/dist/widgets/EmbedWidget.d.ts +16 -15
  59. package/dist/widgets/IREmbedWidget.d.ts +29 -0
  60. package/dist/widgets/IRPopupWidget.d.ts +32 -0
  61. package/dist/widgets/PopupWidget.d.ts +25 -23
  62. package/dist/widgets/Widget.d.ts +53 -33
  63. package/dist/widgets/Widgets.d.ts +108 -116
  64. package/dist/widgets/declarative/DeclarativeEmbedWidget.d.ts +12 -0
  65. package/dist/widgets/declarative/DeclarativeWidget.d.ts +32 -0
  66. package/dist/widgets/declarative/DeclarativeWidgets.d.ts +13 -0
  67. package/jest.config.ts +202 -0
  68. package/package.json +123 -105
  69. package/stats.json +1 -0
  70. package/tsconfig.json +2 -2
package/dist/types.d.ts CHANGED
@@ -1,106 +1,107 @@
1
- import Widget from "./widgets/Widget";
2
- export declare 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
- /**
19
- * Config options for loading a widget
20
- *
21
- * @param user The user details
22
- * @param widgetType The content of the widget.
23
- * @param engagementMedium How to display the widget.
24
- * @param container Element to load the widget into.
25
- * @param trigger Trigger element's selector for opening the popup widget
26
- * @param jwt the JSON Web Token (JWT) that is used
27
- */
28
- export interface WidgetConfig {
29
- user?: User;
30
- widgetType?: WidgetType;
31
- engagementMedium?: EngagementMedium;
32
- container?: HTMLElement | string;
33
- trigger?: string;
34
- jwt?: JWT;
35
- locale?: string;
36
- displayOnLoad?: boolean;
37
- }
38
- /**
39
- * @param user The user details
40
- * @param widgetType The content of the widget.
41
- * @param engagementMedium How to display the widget.
42
- * @param jwt the JSON Web Token (JWT) that is used
43
- */
44
- export interface CookieWidgetConfig {
45
- user?: CookieUser;
46
- widgetType?: WidgetType;
47
- engagementMedium?: EngagementMedium;
48
- jwt?: JWT;
49
- }
50
- /**
51
- * When a widget is loaded using {@link Widgets} you'll get both the `user` data and the `widget` object back.
52
- *
53
- * @param widget The widget that was created.
54
- * @param user The user that's in the widget.
55
- *
56
- */
57
- export interface WidgetResult {
58
- widget: Widget;
59
- user: User;
60
- }
61
- export declare type User = {
62
- id: string;
63
- accountId: string;
64
- [key: string]: any;
65
- };
66
- export declare type CookieUser = {
67
- [key: string]: any;
68
- };
69
- /**
70
- * EngagementMedium is an enum for the content of the widgets.
71
- *
72
- * @example `widgetType: "POPUP"`
73
- */
74
- export declare type EngagementMedium =
75
- /** Displays the widget as a modal popup. Creates a {@link PopupWidget} */
76
- "POPUP"
77
- /** Displays the widget embedded in the page. Create an {@link EmbedWidget} */
78
- | "EMBED";
79
- export declare type WidgetContext = {
80
- type: "cookie" | "error" | "passwordless";
81
- engagementMedium?: EngagementMedium;
82
- container?: HTMLElement | string;
83
- trigger?: string;
84
- displayOnLoad?: boolean;
85
- } | {
86
- type: "upsert";
87
- user?: User | null;
88
- engagementMedium?: EngagementMedium;
89
- container?: HTMLElement | string;
90
- trigger?: string;
91
- };
92
- export declare type WidgetContextType = "upsert" | "cookie" | "error" | "passwordless";
93
- /**
94
- * WidgetType is an enum for types of ways a Widget can be displayed.
95
- */
96
- export declare type WidgetType =
97
- /** Widget content that lets people make referrals */
98
- "REFERRER_WIDGET"
99
- /** Widget content that shows that someone has been referred */
100
- | "CONVERSION_WIDGET" | string;
101
- export declare type ShareMedium = string;
102
- export declare type JWT = string;
103
- export declare type ReferralCookie = {
104
- codes: string[];
105
- encodedCookie: string;
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,2 @@
1
+ import { User } from "../types";
2
+ export declare function decodeUserJwt(tokenStr: string): User | null;
@@ -0,0 +1 @@
1
+ export declare const createFrame: (container: string | HTMLElement, instance: any) => void;
@@ -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;
@@ -1,13 +1,5 @@
1
- import { JWT } from "../types";
2
- export declare function doQuery(url: string, query: string, variables: any, token: string | undefined): Promise<any>;
3
- export declare function doGet<T>(url: any, jwt?: string): Promise<T>;
4
- /**
5
- * @hidden
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>;
@@ -0,0 +1,2 @@
1
+ import AnalyticsApi from "../api/AnalyticsApi";
2
+ export declare function loadEvent(sqh: unknown, analyticsApi: AnalyticsApi): void;
@@ -1,14 +1,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
- };
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
+ };
@@ -1,16 +1,12 @@
1
- import { ConfigOptions, WidgetConfig } from "../types";
2
- declare type KeysOf<T> = keyof T;
3
- declare type SimpleObject = {
4
- [key: string]: unknown;
5
- };
6
- export declare function hasProps<T extends SimpleObject & {}>(object: unknown, props: KeysOf<T> | KeysOf<T>[]): object is T;
7
- export declare function isObject(x: unknown): x is {};
8
- export declare function assertProp<T extends SimpleObject & {}>(object: unknown, ...props: KeysOf<T>[]): object is T;
9
- declare type Required<T> = T extends object ? {
10
- [P in keyof T]-?: NonNullable<T[P]>;
11
- } : T;
12
- export declare function validateConfig(raw: unknown): Required<ConfigOptions>;
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
- element: HTMLElement;
10
- constructor(params: Params, container?: HTMLElement | string);
11
- load(): Promise<void>;
12
- open(): void;
13
- close(): void;
14
- protected _error(rs: any, mode?: string, style?: string): string;
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
- triggerElement: HTMLElement | null;
11
- triggerWhenCTA: HTMLElement | null;
12
- popupdiv: HTMLElement;
13
- popupcontent: HTMLElement;
14
- constructor(params: Params, trigger?: string);
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
+ }
@@ -1,33 +1,53 @@
1
- import AnalyticsApi from "../api/AnalyticsApi";
2
- import WidgetApi from "../api/WidgetApi";
3
- import { WidgetType, WidgetContext } 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
- }
13
- export default abstract class Widget {
14
- frame: HTMLIFrameElement;
15
- type: WidgetType;
16
- content: string;
17
- analyticsApi: AnalyticsApi;
18
- widgetApi: WidgetApi;
19
- context: WidgetContext;
20
- npmCdn: string;
21
- protected constructor(params: Params);
22
- abstract load(): any;
23
- protected _loadEvent(sqh: unknown): void;
24
- protected _shareEvent(sqh: any, medium: any): void;
25
- protected _inviteContacts(sqh: any, emailList: any): void;
26
- protected _error(rs: any, mode?: string, style?: string): string;
27
- protected _findInnerContainer(): Promise<Element>;
28
- reload({ email, firstName, lastName }: {
29
- email: any;
30
- firstName: any;
31
- lastName: any;
32
- }, jwt: any): void;
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
+ }