@pocketping/widget 1.6.0 → 1.8.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/index.d.cts CHANGED
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Theme-aware color value
3
+ * Allows setting different colors for light and dark themes
4
+ */
5
+ interface ThemeColor {
6
+ light: string;
7
+ dark: string;
8
+ }
1
9
  interface PocketPingConfig {
2
10
  /** Your backend endpoint for self-hosted (e.g., "https://yoursite.com/pocketping") */
3
11
  endpoint?: string;
@@ -23,6 +31,33 @@ interface PocketPingConfig {
23
31
  primaryColor?: string;
24
32
  /** Text color on primary background (defaults to white) */
25
33
  primaryTextColor?: string;
34
+ /**
35
+ * Header background color
36
+ * Can be a string (same for both themes) or object with light/dark values
37
+ * @example "#008069" or { light: "#008069", dark: "#202c33" }
38
+ */
39
+ headerColor?: string | ThemeColor;
40
+ /**
41
+ * Footer/input area background color
42
+ * Can be a string (same for both themes) or object with light/dark values
43
+ * @example "#f0f2f5" or { light: "#f0f2f5", dark: "#202c33" }
44
+ */
45
+ footerColor?: string | ThemeColor;
46
+ /**
47
+ * Chat background style:
48
+ * - 'whatsapp' (default) - WhatsApp-style pattern
49
+ * - 'dots' - Subtle dot pattern
50
+ * - 'plain' - Solid color only
51
+ * - URL string - Custom image URL
52
+ * Can also be theme-aware with { light: '...', dark: '...' }
53
+ */
54
+ chatBackground?: 'whatsapp' | 'dots' | 'plain' | string | ThemeColor;
55
+ /**
56
+ * Toggle button background color
57
+ * Can be a string (same for both themes) or object with light/dark values
58
+ * @example "#25d366" or { light: "#25d366", dark: "#00a884" }
59
+ */
60
+ toggleColor?: string | ThemeColor;
26
61
  /** Widget position */
27
62
  position?: 'bottom-right' | 'bottom-left';
28
63
  /** Distance from edge in pixels (default: 20) */
@@ -45,6 +80,8 @@ interface PocketPingConfig {
45
80
  showDelay?: number;
46
81
  /** Auto-open chat after delay in ms (0 = disabled) */
47
82
  autoOpenDelay?: number;
83
+ /** Auto-open chat when operator sends a message (default: true) */
84
+ autoOpenOnMessage?: boolean;
48
85
  /** Play sound on new message */
49
86
  soundEnabled?: boolean;
50
87
  /** Show unread badge on toggle button */
@@ -109,6 +146,27 @@ interface Session {
109
146
  messages: Message[];
110
147
  /** User identity if identified via PocketPing.identify() */
111
148
  identity?: UserIdentity;
149
+ /** Pre-chat form configuration */
150
+ preChatForm?: PreChatFormConfig;
151
+ }
152
+ /** Pre-chat form configuration */
153
+ interface PreChatFormConfig {
154
+ /** Whether the form is enabled */
155
+ enabled: boolean;
156
+ /** Whether the form is required (can't skip) */
157
+ required: boolean;
158
+ /** When to show the form: 'before-first-message' | 'after-first-message' */
159
+ timing: 'before-first-message' | 'after-first-message';
160
+ /** What fields to collect: 'email-only' | 'phone-only' | 'email-or-phone' | 'email-and-phone' */
161
+ fields: 'email-only' | 'phone-only' | 'email-or-phone' | 'email-and-phone';
162
+ /** Whether the form was already completed for this session */
163
+ completed: boolean;
164
+ }
165
+ /** Pre-chat form submission data */
166
+ interface PreChatFormData {
167
+ email?: string;
168
+ phone?: string;
169
+ phoneCountry?: string;
112
170
  }
113
171
  interface PresenceResponse {
114
172
  online: boolean;
@@ -269,6 +327,11 @@ declare class PocketPingClient {
269
327
  * })
270
328
  */
271
329
  identify(identity: UserIdentity): Promise<void>;
330
+ /**
331
+ * Submit pre-chat form data (email and/or phone)
332
+ * @param data - Form data containing email and/or phone
333
+ */
334
+ submitPreChat(data: PreChatFormData): Promise<void>;
272
335
  /**
273
336
  * Reset the user identity and optionally start a new session
274
337
  * Call on user logout to clear user data
package/dist/index.d.ts CHANGED
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Theme-aware color value
3
+ * Allows setting different colors for light and dark themes
4
+ */
5
+ interface ThemeColor {
6
+ light: string;
7
+ dark: string;
8
+ }
1
9
  interface PocketPingConfig {
2
10
  /** Your backend endpoint for self-hosted (e.g., "https://yoursite.com/pocketping") */
3
11
  endpoint?: string;
@@ -23,6 +31,33 @@ interface PocketPingConfig {
23
31
  primaryColor?: string;
24
32
  /** Text color on primary background (defaults to white) */
25
33
  primaryTextColor?: string;
34
+ /**
35
+ * Header background color
36
+ * Can be a string (same for both themes) or object with light/dark values
37
+ * @example "#008069" or { light: "#008069", dark: "#202c33" }
38
+ */
39
+ headerColor?: string | ThemeColor;
40
+ /**
41
+ * Footer/input area background color
42
+ * Can be a string (same for both themes) or object with light/dark values
43
+ * @example "#f0f2f5" or { light: "#f0f2f5", dark: "#202c33" }
44
+ */
45
+ footerColor?: string | ThemeColor;
46
+ /**
47
+ * Chat background style:
48
+ * - 'whatsapp' (default) - WhatsApp-style pattern
49
+ * - 'dots' - Subtle dot pattern
50
+ * - 'plain' - Solid color only
51
+ * - URL string - Custom image URL
52
+ * Can also be theme-aware with { light: '...', dark: '...' }
53
+ */
54
+ chatBackground?: 'whatsapp' | 'dots' | 'plain' | string | ThemeColor;
55
+ /**
56
+ * Toggle button background color
57
+ * Can be a string (same for both themes) or object with light/dark values
58
+ * @example "#25d366" or { light: "#25d366", dark: "#00a884" }
59
+ */
60
+ toggleColor?: string | ThemeColor;
26
61
  /** Widget position */
27
62
  position?: 'bottom-right' | 'bottom-left';
28
63
  /** Distance from edge in pixels (default: 20) */
@@ -45,6 +80,8 @@ interface PocketPingConfig {
45
80
  showDelay?: number;
46
81
  /** Auto-open chat after delay in ms (0 = disabled) */
47
82
  autoOpenDelay?: number;
83
+ /** Auto-open chat when operator sends a message (default: true) */
84
+ autoOpenOnMessage?: boolean;
48
85
  /** Play sound on new message */
49
86
  soundEnabled?: boolean;
50
87
  /** Show unread badge on toggle button */
@@ -109,6 +146,27 @@ interface Session {
109
146
  messages: Message[];
110
147
  /** User identity if identified via PocketPing.identify() */
111
148
  identity?: UserIdentity;
149
+ /** Pre-chat form configuration */
150
+ preChatForm?: PreChatFormConfig;
151
+ }
152
+ /** Pre-chat form configuration */
153
+ interface PreChatFormConfig {
154
+ /** Whether the form is enabled */
155
+ enabled: boolean;
156
+ /** Whether the form is required (can't skip) */
157
+ required: boolean;
158
+ /** When to show the form: 'before-first-message' | 'after-first-message' */
159
+ timing: 'before-first-message' | 'after-first-message';
160
+ /** What fields to collect: 'email-only' | 'phone-only' | 'email-or-phone' | 'email-and-phone' */
161
+ fields: 'email-only' | 'phone-only' | 'email-or-phone' | 'email-and-phone';
162
+ /** Whether the form was already completed for this session */
163
+ completed: boolean;
164
+ }
165
+ /** Pre-chat form submission data */
166
+ interface PreChatFormData {
167
+ email?: string;
168
+ phone?: string;
169
+ phoneCountry?: string;
112
170
  }
113
171
  interface PresenceResponse {
114
172
  online: boolean;
@@ -269,6 +327,11 @@ declare class PocketPingClient {
269
327
  * })
270
328
  */
271
329
  identify(identity: UserIdentity): Promise<void>;
330
+ /**
331
+ * Submit pre-chat form data (email and/or phone)
332
+ * @param data - Form data containing email and/or phone
333
+ */
334
+ submitPreChat(data: PreChatFormData): Promise<void>;
272
335
  /**
273
336
  * Reset the user identity and optionally start a new session
274
337
  * Call on user logout to clear user data