@saasquatch/squatch-js 2.3.2-9 → 2.4.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/dist/types.d.ts CHANGED
@@ -12,12 +12,30 @@ export interface ConfigOptions {
12
12
  npmCdn?: string;
13
13
  debug?: boolean;
14
14
  }
15
+ /**
16
+ * Config options for loading a widget
17
+ *
18
+ * @param user The user details
19
+ * @param widgetType The content of the widget.
20
+ * @param engagementMedium How to display the widget.
21
+ * @param container Element to load the widget into.
22
+ * @param trigger Trigger element's selector for opening the popup widget
23
+ * @param jwt the JSON Web Token (JWT) that is used
24
+ */
15
25
  export interface WidgetConfig {
16
26
  user: User;
17
27
  widgetType?: WidgetType;
18
28
  engagementMedium?: EngagementMedium;
29
+ container?: HTMLElement | string;
30
+ trigger?: string;
19
31
  jwt?: JWT;
20
32
  }
33
+ /**
34
+ * @param user The user details
35
+ * @param widgetType The content of the widget.
36
+ * @param engagementMedium How to display the widget.
37
+ * @param jwt the JSON Web Token (JWT) that is used
38
+ */
21
39
  export interface CookieWidgetConfig {
22
40
  user?: CookieUser;
23
41
  widgetType?: WidgetType;
@@ -56,10 +74,14 @@ export declare type EngagementMedium =
56
74
  export declare type WidgetContext = {
57
75
  type: "cookie" | "error";
58
76
  engagementMedium?: EngagementMedium;
77
+ container?: HTMLElement | string;
78
+ trigger?: string;
59
79
  } | {
60
80
  type: "upsert";
61
81
  user: User;
62
82
  engagementMedium?: EngagementMedium;
83
+ container?: HTMLElement | string;
84
+ trigger?: string;
63
85
  };
64
86
  export declare type WidgetContextType = "upsert" | "cookie" | "error";
65
87
  /**
@@ -6,8 +6,10 @@ import Widget, { Params } from "./Widget";
6
6
  *
7
7
  */
8
8
  export default class EmbedWidget extends Widget {
9
- element: Element;
10
- constructor(params: Params, selector?: string);
9
+ element: HTMLElement;
10
+ constructor(params: Params, container?: HTMLElement | string);
11
11
  load(): Promise<void>;
12
+ open(): void;
13
+ close(): void;
12
14
  protected _error(rs: any, mode?: string, style?: string): string;
13
15
  }
@@ -54,8 +54,9 @@ export default class Widgets {
54
54
  * @param {string} config.user.accountId The user account id
55
55
  * @param {WidgetType} config.widgetType The content of the widget.
56
56
  * @param {EngagementMedium} config.engagementMedium How to display the widget.
57
- * @param {string} config.jwt the JSON Web Token (JWT) that is used
58
- * to validate the data (can be disabled)
57
+ * @param {string} config.jwt the JSON Web Token (JWT) that is used to validate the data (can be disabled)
58
+ * @param {HTMLElement | string | undefined} config.container Element to load the widget into
59
+ * @param {string | undefined} config.trigger Trigger element for opening the popup widget
59
60
  *
60
61
  * @return {Promise<WidgetResult>} json object if true, with a Widget and user details.
61
62
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasquatch/squatch-js",
3
- "version": "2.3.2-9",
3
+ "version": "2.4.0",
4
4
  "description": "The official Referral SaaSquatch Javascript Web/Browser SDK https://docs.referralsaasquatch.com/developer/squatchjs/",
5
5
  "license": "MIT",
6
6
  "types": "dist/squatch.d.ts",