@product7/product7-js 0.1.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 (58) hide show
  1. package/README.md +1025 -0
  2. package/dist/README.md +1025 -0
  3. package/dist/product7-js.js +14658 -0
  4. package/dist/product7-js.js.map +1 -0
  5. package/dist/product7-js.min.js +2 -0
  6. package/dist/product7-js.min.js.map +1 -0
  7. package/package.json +114 -0
  8. package/src/api/mock-data/index.js +360 -0
  9. package/src/api/services/ChangelogService.js +28 -0
  10. package/src/api/services/FeedbackService.js +44 -0
  11. package/src/api/services/HelpService.js +50 -0
  12. package/src/api/services/MessengerService.js +279 -0
  13. package/src/api/services/SurveyService.js +127 -0
  14. package/src/api/utils/helpers.js +30 -0
  15. package/src/core/APIService.js +303 -0
  16. package/src/core/BaseAPIService.js +298 -0
  17. package/src/core/EventBus.js +54 -0
  18. package/src/core/Product7.js +812 -0
  19. package/src/core/WebSocketService.js +275 -0
  20. package/src/docs/api.md +226 -0
  21. package/src/docs/example.md +461 -0
  22. package/src/docs/framework-integrations.md +714 -0
  23. package/src/docs/installation.md +281 -0
  24. package/src/index.js +894 -0
  25. package/src/styles/base.js +50 -0
  26. package/src/styles/changelog.js +665 -0
  27. package/src/styles/components.js +553 -0
  28. package/src/styles/design-tokens.js +124 -0
  29. package/src/styles/feedback.js +325 -0
  30. package/src/styles/messenger-components.js +632 -0
  31. package/src/styles/messenger-core.js +233 -0
  32. package/src/styles/messenger-features.js +169 -0
  33. package/src/styles/messenger-views.js +877 -0
  34. package/src/styles/messenger.js +17 -0
  35. package/src/styles/messengerCustomStyles.js +114 -0
  36. package/src/styles/styles.js +26 -0
  37. package/src/styles/survey.js +894 -0
  38. package/src/utils/errors.js +142 -0
  39. package/src/utils/helpers.js +219 -0
  40. package/src/widgets/BaseWidget.js +548 -0
  41. package/src/widgets/ButtonWidget.js +104 -0
  42. package/src/widgets/ChangelogWidget.js +615 -0
  43. package/src/widgets/InlineWidget.js +148 -0
  44. package/src/widgets/MessengerWidget.js +979 -0
  45. package/src/widgets/SurveyWidget.js +1325 -0
  46. package/src/widgets/TabWidget.js +45 -0
  47. package/src/widgets/WidgetFactory.js +70 -0
  48. package/src/widgets/messenger/MessengerState.js +323 -0
  49. package/src/widgets/messenger/components/MessengerLauncher.js +124 -0
  50. package/src/widgets/messenger/components/MessengerPanel.js +111 -0
  51. package/src/widgets/messenger/components/NavigationTabs.js +130 -0
  52. package/src/widgets/messenger/views/ChangelogView.js +167 -0
  53. package/src/widgets/messenger/views/ChatView.js +592 -0
  54. package/src/widgets/messenger/views/ConversationsView.js +244 -0
  55. package/src/widgets/messenger/views/HelpView.js +239 -0
  56. package/src/widgets/messenger/views/HomeView.js +300 -0
  57. package/src/widgets/messenger/views/PreChatFormView.js +109 -0
  58. package/types/index.d.ts +341 -0
@@ -0,0 +1,341 @@
1
+ declare module '@product7/product7-js' {
2
+ export interface FeedbackConfig {
3
+ workspace: string;
4
+ metadata?: Metadata;
5
+ debug?: boolean;
6
+ boardName?: string;
7
+ siteId?: string;
8
+ sessionToken?: string;
9
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
10
+ theme?: 'light' | 'dark';
11
+ apiUrl?: string;
12
+ autoShow?: boolean;
13
+ mock?: boolean;
14
+ env?: string;
15
+ widgets?: WidgetConfigMap;
16
+ }
17
+
18
+ export interface Metadata {
19
+ user_id?: string;
20
+ email?: string;
21
+ name?: string;
22
+ custom_fields?: Record<string, any>;
23
+ company?: {
24
+ id?: string;
25
+ name?: string;
26
+ monthly_spend?: number;
27
+ };
28
+ }
29
+
30
+ export interface ButtonWidgetOptions {
31
+ enabled?: boolean;
32
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
33
+ theme?: 'light' | 'dark';
34
+ boardName?: string;
35
+ displayMode?: 'panel' | 'modal';
36
+ size?: 'small' | 'medium' | 'large';
37
+ primaryColor?: string;
38
+ backgroundColor?: string;
39
+ textColor?: string;
40
+ autoShow?: boolean;
41
+ suppressAfterSubmission?: boolean;
42
+ suppressionDays?: number;
43
+ buttonText?: string;
44
+ triggerText?: string;
45
+ label?: string;
46
+ text?: string;
47
+ customStyles?: Record<string, string>;
48
+ }
49
+
50
+ export interface WidgetConfigMap {
51
+ button?: Partial<ButtonWidgetOptions> | Record<string, any>;
52
+ survey?: Partial<SurveyWidgetOptions> | Record<string, any>;
53
+ messenger?: Partial<MessengerWidgetOptions> | Record<string, any>;
54
+ changelog?: Partial<ChangelogWidgetOptions> | Record<string, any>;
55
+ [key: string]: Record<string, any> | undefined;
56
+ }
57
+
58
+ export interface ButtonWidget {
59
+ id: string;
60
+ type: 'button';
61
+ mount(container?: string | HTMLElement): this;
62
+ destroy(): void;
63
+ show(): this;
64
+ hide(): this;
65
+ openPanel(): void;
66
+ closePanel(): void;
67
+ openModal(): void;
68
+ closeModal(): void;
69
+ updateText(text: string): void;
70
+ updatePosition(
71
+ position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'
72
+ ): void;
73
+ }
74
+
75
+ export class Product7 {
76
+ constructor(config: FeedbackConfig);
77
+ init(): Promise<{
78
+ initialized: boolean;
79
+ config?: any;
80
+ sessionToken?: string;
81
+ expiresIn?: number;
82
+ status?: boolean;
83
+ message?: string | null;
84
+ configVersion?: number | null;
85
+ }>;
86
+ createWidget(type: 'button', options?: ButtonWidgetOptions): ButtonWidget;
87
+ createWidget(type: 'survey', options?: SurveyWidgetOptions): SurveyWidget;
88
+ createWidget(
89
+ type: 'messenger',
90
+ options?: MessengerWidgetOptions
91
+ ): MessengerWidget;
92
+ createWidget(
93
+ type: 'changelog',
94
+ options?: ChangelogWidgetOptions
95
+ ): ChangelogWidget;
96
+ createWidget(type: string, options?: Record<string, any>): any;
97
+ setMetadata(metadata: Metadata): void;
98
+ getMetadata(): Metadata | null;
99
+ destroy(): void;
100
+ readonly initialized: boolean;
101
+ }
102
+
103
+ export type SurveyType = 'nps' | 'csat' | 'ces' | 'custom';
104
+
105
+ export interface SurveyQuestion {
106
+ id?: string;
107
+ label: string;
108
+ type: 'select' | 'text';
109
+ placeholder?: string;
110
+ options?: Array<{ value: string; label: string }>;
111
+ }
112
+
113
+ export interface SurveyRatingConfig {
114
+ survey_type?: string;
115
+ scale?: number;
116
+ low_label?: string | null;
117
+ high_label?: string | null;
118
+ }
119
+
120
+ export interface SurveyMultipleChoiceOption {
121
+ id?: string;
122
+ key?: string;
123
+ value?: string;
124
+ label?: string;
125
+ text?: string;
126
+ }
127
+
128
+ export interface SurveyMultipleChoiceConfig {
129
+ options?: SurveyMultipleChoiceOption[];
130
+ allow_multiple?: boolean;
131
+ multiple?: boolean;
132
+ }
133
+
134
+ export interface SurveyPage {
135
+ id?: string;
136
+ type?: 'rating' | 'multiple_choice' | 'text' | string;
137
+ title?: string;
138
+ description?: string;
139
+ required?: boolean;
140
+ position?: number;
141
+ ratingConfig?: SurveyRatingConfig | null;
142
+ rating_config?: SurveyRatingConfig | null;
143
+ multipleChoiceConfig?: SurveyMultipleChoiceConfig | null;
144
+ multiple_choice_config?: SurveyMultipleChoiceConfig | null;
145
+ afterThisPage?: { default?: string | number } | null;
146
+ after_this_page?: { default?: string | number } | null;
147
+ }
148
+
149
+ export interface SurveyWidgetResponse {
150
+ type: SurveyType;
151
+ score: number | null;
152
+ feedback: string;
153
+ customAnswers: Record<string, any>;
154
+ pageAnswers?: Record<string, any>;
155
+ timestamp: string;
156
+ }
157
+
158
+ export interface SurveyWidgetOptions {
159
+ enabled?: boolean;
160
+ surveyId?: string | null;
161
+ surveyType?: SurveyType;
162
+ position?: 'bottom-right' | 'bottom-left' | 'center' | 'bottom';
163
+ title?: string | null;
164
+ description?: string | null;
165
+ lowLabel?: string | null;
166
+ highLabel?: string | null;
167
+ ratingScale?: number | null;
168
+ showFeedbackInput?: boolean | null;
169
+ showSubmitButton?: boolean | null;
170
+ autoSubmitOnSelect?: boolean | null;
171
+ showTitle?: boolean | null;
172
+ showDescription?: boolean | null;
173
+ customQuestions?: SurveyQuestion[];
174
+ pages?: SurveyPage[];
175
+ respondentId?: string | null;
176
+ email?: string | null;
177
+ theme?: 'light' | 'dark';
178
+ onSubmit?: (response: SurveyWidgetResponse) => void;
179
+ onDismiss?: () => void;
180
+ }
181
+
182
+ export interface SurveyWidget {
183
+ show(): this;
184
+ hide(): this;
185
+ destroy(): void;
186
+ surveyOptions: SurveyWidgetOptions;
187
+ surveyState: {
188
+ score: number | null;
189
+ feedback: string;
190
+ customAnswers: Record<string, any>;
191
+ pageAnswers?: Record<string, any>;
192
+ currentPageIndex?: number;
193
+ isSubmitting?: boolean;
194
+ isVisible: boolean;
195
+ };
196
+ }
197
+
198
+ export interface SurveyConfig {
199
+ workspace: string;
200
+ metadata?: Metadata;
201
+ debug?: boolean;
202
+ apiUrl?: string;
203
+ }
204
+
205
+ export class SurveySDK {
206
+ constructor(config: SurveyConfig);
207
+ init(): Promise<{ initialized: boolean }>;
208
+ createWidget(type: 'survey', options: SurveyWidgetOptions): SurveyWidget;
209
+ setMetadata(metadata: Metadata): void;
210
+ getMetadata(): Metadata | null;
211
+ destroy(): void;
212
+ readonly initialized: boolean;
213
+ }
214
+
215
+ interface Product7Export {
216
+ Product7: typeof Product7;
217
+ ButtonWidget: any;
218
+ create: (config: FeedbackConfig) => Product7;
219
+ initWithUser: (
220
+ config: Omit<FeedbackConfig, 'metadata'>,
221
+ metadata: Metadata
222
+ ) => Promise<Product7>;
223
+ getInstance: () => Product7 | null;
224
+ isReady: () => boolean;
225
+ setMetadata: (metadata: Metadata) => void;
226
+ onReady: (callback: (sdk: Product7) => void) => void;
227
+ onError: (callback: (error: Error) => void) => void;
228
+ version: string;
229
+ instance: Product7 | null;
230
+ }
231
+
232
+ export interface ChangelogWidgetOptions {
233
+ enabled?: boolean;
234
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
235
+ theme?: 'light' | 'dark';
236
+ showBackdrop?: boolean;
237
+ triggerText?: string;
238
+ showBadge?: boolean;
239
+ title?: string;
240
+ viewButtonText?: string;
241
+ changelogBaseUrl?: string;
242
+ openInNewTab?: boolean;
243
+ customStyles?: Record<string, string>;
244
+ onViewUpdate?: (changelog: any) => void;
245
+ }
246
+
247
+ export interface ChangelogWidget {
248
+ id: string;
249
+ type: 'changelog';
250
+ mount(container?: string | HTMLElement): this;
251
+ destroy(): void;
252
+ openModal(): void;
253
+ closeModal(): void;
254
+ openSidebar(): void;
255
+ closeSidebar(): void;
256
+ hideBadge(): void;
257
+ showBadge(): void;
258
+ nextChangelog(): void;
259
+ prevChangelog(): void;
260
+ refresh(): Promise<void>;
261
+ }
262
+
263
+ export interface MessengerWidgetOptions {
264
+ enabled?: boolean;
265
+ position?: 'bottom-right' | 'bottom-left';
266
+ theme?: 'light' | 'dark';
267
+ teamName?: string;
268
+ teamAvatars?: string[];
269
+ greetingMessage?: string;
270
+ welcomeMessage?: string;
271
+ enableHelp?: boolean;
272
+ enableChangelog?: boolean;
273
+ enableNews?: boolean;
274
+ autoLoadData?: boolean;
275
+ initialView?:
276
+ | 'home'
277
+ | 'messages'
278
+ | 'chat'
279
+ | 'prechat'
280
+ | 'help'
281
+ | 'changelog';
282
+ previewData?: {
283
+ conversations?: any[];
284
+ helpArticles?: any[];
285
+ homeChangelogItems?: any[];
286
+ changelogItems?: any[];
287
+ unreadCount?: number;
288
+ currentView?: string;
289
+ availability?: {
290
+ agentsOnline?: boolean;
291
+ agents_online?: boolean;
292
+ onlineCount?: number;
293
+ online_count?: number;
294
+ responseTime?: string;
295
+ response_time?: string;
296
+ };
297
+ };
298
+ logoUrl?: string;
299
+ primaryColor?: string;
300
+ featuredContent?: {
301
+ title: string;
302
+ description: string;
303
+ imageUrl?: string;
304
+ action?: {
305
+ type: 'url' | 'view';
306
+ value: string;
307
+ label: string;
308
+ };
309
+ };
310
+ onSendMessage?: (conversationId: string, message: any) => void;
311
+ onArticleClick?: (article: any) => void;
312
+ onChangelogClick?: (changelog: any) => void;
313
+ }
314
+
315
+ export interface MessengerWidget {
316
+ id: string;
317
+ type: 'messenger';
318
+ mount(container?: string | HTMLElement): this;
319
+ destroy(): void;
320
+ open(): void;
321
+ close(): void;
322
+ toggle(): void;
323
+ navigateTo(view: 'home' | 'messages' | 'chat' | 'help' | 'changelog'): void;
324
+ setConversations(conversations: any[]): void;
325
+ setHelpArticles(articles: any[]): void;
326
+ setChangelogItems(items: any[]): void;
327
+ setHomeChangelogItems(items: any[]): void;
328
+ setUnreadCount(count: number): void;
329
+ loadInitialData(): Promise<void>;
330
+ checkAgentAvailability(): Promise<any>;
331
+ getState(): {
332
+ isOpen: boolean;
333
+ currentView: string;
334
+ unreadCount: number;
335
+ conversations: any[];
336
+ };
337
+ }
338
+
339
+ const Product7Default: Product7Export;
340
+ export default Product7Default;
341
+ }