nerdagent-chat-widget-vue 1.0.3 → 1.0.6

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 (2) hide show
  1. package/README.md +47 -386
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,15 +1,6 @@
1
1
  # NerdAgent Chat Widget for Vue
2
2
 
3
- A powerful, customizable chat widget component for Vue applications. Built with Stencil.js for maximum compatibility and performance.
4
-
5
- ## Features
6
-
7
- - 🚀 **Framework Agnostic Core** - Built with Stencil.js Web Components
8
- - 🎨 **Highly Customizable** - Colors, positioning, features, and more
9
- - 📱 **Responsive Design** - Works on desktop and mobile
10
- - 🔧 **TypeScript Support** - Full type definitions included
11
- - ⚡ **Lightweight** - Minimal bundle size impact
12
- - 🎯 **Easy Integration** - Simple Vue component wrapper
3
+ A customizable chat widget component for Vue applications.
13
4
 
14
5
  ## Installation
15
6
 
@@ -17,19 +8,22 @@ A powerful, customizable chat widget component for Vue applications. Built with
17
8
  npm install nerdagent-chat-widget-vue
18
9
  ```
19
10
 
20
- ## Quick Start
11
+ ## Usage
21
12
 
22
- ### 1. Import the Component
13
+ ### Vue 3 with Composition API
23
14
 
24
15
  ```vue
25
16
  <template>
26
17
  <div class="app">
27
18
  <NerdChatWidget
19
+ :apiKey="'your-api-key'"
20
+ :agentId="'your-agent-id'"
28
21
  :agent-name="'Support Agent'"
29
22
  :agent-role="'Customer Support'"
30
23
  :primary-color="'#2d3e50'"
31
24
  :accent-color="'#4e8cff'"
32
25
  :welcome-message="'Hi! How can I help you today?'"
26
+ :placeholder-text="'Type your message...'"
33
27
  :position="'bottom-right'"
34
28
  :width="'350'"
35
29
  :height="'500'"
@@ -38,55 +32,6 @@ npm install nerdagent-chat-widget-vue
38
32
  :enable-file-upload="false"
39
33
  :enable-speech="false"
40
34
  :show-powered-by="true"
41
- @message-sent="onMessageSent"
42
- @widget-opened="onWidgetOpened"
43
- @widget-closed="onWidgetClosed"
44
- />
45
- </div>
46
- </template>
47
-
48
- <script>
49
- import { NerdChatWidget } from 'nerdagent-chat-widget-vue';
50
-
51
- export default {
52
- name: 'App',
53
- components: {
54
- NerdChatWidget
55
- },
56
- methods: {
57
- onMessageSent(event) {
58
- console.log('Message sent:', event);
59
- },
60
- onWidgetOpened() {
61
- console.log('Widget opened');
62
- },
63
- onWidgetClosed() {
64
- console.log('Widget closed');
65
- }
66
- }
67
- }
68
- </script>
69
- ```
70
-
71
- ### 2. With Composition API (Vue 3)
72
-
73
- ```vue
74
- <template>
75
- <div class="app">
76
- <NerdChatWidget
77
- :agent-name="config.agentName"
78
- :agent-role="config.agentRole"
79
- :primary-color="config.primaryColor"
80
- :accent-color="config.accentColor"
81
- :welcome-message="config.welcomeMessage"
82
- :position="config.position"
83
- :width="config.width"
84
- :height="config.height"
85
- :show-minimize-button="config.showMinimizeButton"
86
- :show-timestamps="config.showTimestamps"
87
- :enable-file-upload="config.enableFileUpload"
88
- :enable-speech="config.enableSpeech"
89
- :show-powered-by="config.showPoweredBy"
90
35
  @message-sent="handleMessageSent"
91
36
  @widget-opened="handleWidgetOpened"
92
37
  @widget-closed="handleWidgetClosed"
@@ -95,30 +40,9 @@ export default {
95
40
  </template>
96
41
 
97
42
  <script setup>
98
- import { ref, reactive } from 'vue';
99
43
  import { NerdChatWidget } from 'nerdagent-chat-widget-vue';
100
44
 
101
- const config = reactive({
102
- agentName: 'Support Agent',
103
- agentRole: 'Customer Support',
104
- primaryColor: '#2d3e50',
105
- accentColor: '#4e8cff',
106
- welcomeMessage: 'Hi! How can I help you today?',
107
- placeholderText: 'Type your message...',
108
- position: 'bottom-right',
109
- width: '350',
110
- height: '500',
111
- showMinimizeButton: true,
112
- showTimestamps: true,
113
- enableFileUpload: false,
114
- enableSpeech: false,
115
- showPoweredBy: true
116
- });
117
-
118
- const messages = ref([]);
119
-
120
45
  const handleMessageSent = (event) => {
121
- messages.value.push(event);
122
46
  console.log('Message sent:', event);
123
47
  };
124
48
 
@@ -132,100 +56,66 @@ const handleWidgetClosed = () => {
132
56
  </script>
133
57
  ```
134
58
 
135
- ### 3. With TypeScript
59
+ ### Vue 2 with Options API
136
60
 
137
61
  ```vue
138
62
  <template>
139
63
  <div class="app">
140
64
  <NerdChatWidget
141
- :agent-name="config.agentName"
142
- :agent-role="config.agentRole"
143
- :primary-color="config.primaryColor"
144
- :accent-color="config.accentColor"
145
- :welcome-message="config.welcomeMessage"
146
- :position="config.position"
147
- :width="config.width"
148
- :height="config.height"
149
- :show-minimize-button="config.showMinimizeButton"
150
- :show-timestamps="config.showTimestamps"
151
- :enable-file-upload="config.enableFileUpload"
152
- :enable-speech="config.enableSpeech"
153
- :show-powered-by="config.showPoweredBy"
154
- @message-sent="handleMessageSent"
155
- @widget-opened="handleWidgetOpened"
156
- @widget-closed="handleWidgetClosed"
65
+ :apiKey="'your-api-key'"
66
+ :agentId="'your-agent-id'"
67
+ :agent-name="'Support Agent'"
68
+ :agent-role="'Customer Support'"
69
+ :primary-color="'#2d3e50'"
70
+ :accent-color="'#4e8cff'"
71
+ :welcome-message="'Hi! How can I help you today?'"
72
+ :position="'bottom-right'"
73
+ :width="'350'"
74
+ :height="'500'"
75
+ @message-sent="onMessageSent"
76
+ @widget-opened="onWidgetOpened"
77
+ @widget-closed="onWidgetClosed"
157
78
  />
158
79
  </div>
159
80
  </template>
160
81
 
161
- <script setup lang="ts">
162
- import { ref, reactive } from 'vue';
163
- import { NerdChatWidget, WidgetPosition } from 'nerdagent-chat-widget-vue';
82
+ <script>
83
+ import { NerdChatWidget } from 'nerdagent-chat-widget-vue';
164
84
 
165
- interface ChatConfig {
166
- agentName: string;
167
- agentRole: string;
168
- primaryColor: string;
169
- accentColor: string;
170
- welcomeMessage: string;
171
- placeholderText: string;
172
- position: WidgetPosition;
173
- width: string;
174
- height: string;
175
- showMinimizeButton: boolean;
176
- showTimestamps: boolean;
177
- enableFileUpload: boolean;
178
- enableSpeech: boolean;
179
- showPoweredBy: boolean;
85
+ export default {
86
+ name: 'App',
87
+ components: {
88
+ NerdChatWidget
89
+ },
90
+ methods: {
91
+ onMessageSent(event) {
92
+ console.log('Message sent:', event);
93
+ },
94
+ onWidgetOpened() {
95
+ console.log('Widget opened');
96
+ },
97
+ onWidgetClosed() {
98
+ console.log('Widget closed');
99
+ }
100
+ }
180
101
  }
181
-
182
- const config = reactive<ChatConfig>({
183
- agentName: 'Support Agent',
184
- agentRole: 'Customer Support',
185
- primaryColor: '#2d3e50',
186
- accentColor: '#4e8cff',
187
- welcomeMessage: 'Hi! How can I help you today?',
188
- placeholderText: 'Type your message...',
189
- position: 'bottom-right',
190
- width: '350',
191
- height: '500',
192
- showMinimizeButton: true,
193
- showTimestamps: true,
194
- enableFileUpload: false,
195
- enableSpeech: false,
196
- showPoweredBy: true
197
- });
198
-
199
- const messages = ref<Array<{ message: string; timestamp: Date }>>([]);
200
-
201
- const handleMessageSent = (event: { message: string; timestamp: Date }) => {
202
- messages.value.push(event);
203
- console.log('Message sent:', event);
204
- };
205
-
206
- const handleWidgetOpened = () => {
207
- console.log('Widget opened');
208
- };
209
-
210
- const handleWidgetClosed = () => {
211
- console.log('Widget closed');
212
- };
213
102
  </script>
214
103
  ```
215
104
 
216
- ## Configuration Options
217
-
218
- ### Props
105
+ ## Props
219
106
 
220
107
  | Prop | Type | Default | Description |
221
108
  |------|------|---------|-------------|
109
+ | `apiKey` | `string` | - | API key for authentication |
110
+ | `agentId` | `string` | - | Agent ID to connect to |
111
+ | `token` | `string` | - | JWT token for authentication |
222
112
  | `agentName` | `string` | `'Support Agent'` | Name of the support agent |
223
113
  | `agentRole` | `string` | `'Customer Support'` | Role/title of the agent |
224
114
  | `primaryColor` | `string` | `'#2d3e50'` | Primary color theme |
225
115
  | `accentColor` | `string` | `'#4e8cff'` | Accent color theme |
226
116
  | `welcomeMessage` | `string` | `'Hi! How can I help?'` | Initial welcome message |
227
117
  | `placeholderText` | `string` | `'Type your message...'` | Input placeholder text |
228
- | `position` | `WidgetPosition` | `'bottom-right'` | Widget position on screen |
118
+ | `position` | `'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left'` | `'bottom-right'` | Widget position on screen |
229
119
  | `width` | `string` | `'350'` | Widget width in pixels |
230
120
  | `height` | `string` | `'500'` | Widget height in pixels |
231
121
  | `showMinimizeButton` | `boolean` | `true` | Show minimize/maximize button |
@@ -234,13 +124,7 @@ const handleWidgetClosed = () => {
234
124
  | `enableSpeech` | `boolean` | `false` | Enable speech recognition |
235
125
  | `showPoweredBy` | `boolean` | `true` | Show "Powered by" branding |
236
126
 
237
- ### WidgetPosition Type
238
-
239
- ```typescript
240
- type WidgetPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
241
- ```
242
-
243
- ### Events
127
+ ## Events
244
128
 
245
129
  | Event | Type | Description |
246
130
  |-------|------|-------------|
@@ -248,237 +132,14 @@ type WidgetPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
248
132
  | `widget-opened` | `void` | Emitted when widget is opened |
249
133
  | `widget-closed` | `void` | Emitted when widget is closed |
250
134
 
251
- ## Advanced Usage
252
-
253
- ### Dynamic Configuration
254
-
255
- ```vue
256
- <template>
257
- <div>
258
- <button @click="updateConfig">Update Config</button>
259
- <NerdChatWidget
260
- :agent-name="config.agentName"
261
- :primary-color="config.primaryColor"
262
- :position="config.position"
263
- @message-sent="handleMessageSent"
264
- />
265
- </div>
266
- </template>
267
-
268
- <script setup>
269
- import { reactive } from 'vue';
270
- import { NerdChatWidget } from 'nerdagent-chat-widget-vue';
271
-
272
- const config = reactive({
273
- agentName: 'Support Agent',
274
- primaryColor: '#2d3e50',
275
- position: 'bottom-right',
276
- // ... other config
277
- });
278
-
279
- const updateConfig = () => {
280
- config.primaryColor = '#ff6b6b';
281
- config.position = 'top-right';
282
- config.agentName = 'Updated Agent';
283
- };
284
- </script>
285
- ```
286
-
287
- ### Conditional Rendering
288
-
289
- ```vue
290
- <template>
291
- <div>
292
- <button @click="toggleWidget">
293
- {{ showWidget ? 'Hide' : 'Show' }} Chat Widget
294
- </button>
295
-
296
- <NerdChatWidget
297
- v-if="showWidget"
298
- :agent-name="userType === 'premium' ? 'Premium Support' : 'Basic Support'"
299
- :agent-role="userType === 'premium' ? 'VIP Assistant' : 'Support Agent'"
300
- :primary-color="userType === 'premium' ? '#gold' : '#2d3e50'"
301
- :enable-file-upload="userType === 'premium'"
302
- :enable-speech="userType === 'premium'"
303
- @message-sent="handleMessageSent"
304
- />
305
- </div>
306
- </template>
307
-
308
- <script setup>
309
- import { ref } from 'vue';
310
- import { NerdChatWidget } from 'nerdagent-chat-widget-vue';
311
-
312
- const showWidget = ref(false);
313
- const userType = ref('guest');
314
-
315
- const toggleWidget = () => {
316
- showWidget.value = !showWidget.value;
317
- };
318
-
319
- const handleMessageSent = (event) => {
320
- if (userType.value === 'premium') {
321
- // Premium user handling
322
- } else {
323
- // Basic user handling
324
- }
325
- };
326
- </script>
327
- ```
328
-
329
- ### With Pinia Store
330
-
331
- ```vue
332
- <template>
333
- <div>
334
- <NerdChatWidget
335
- :agent-name="chatStore.config.agentName"
336
- :agent-role="chatStore.config.agentRole"
337
- :primary-color="chatStore.config.primaryColor"
338
- @message-sent="chatStore.addMessage"
339
- @widget-opened="chatStore.setWidgetOpen"
340
- @widget-closed="chatStore.setWidgetClosed"
341
- />
342
- </div>
343
- </template>
344
-
345
- <script setup>
346
- import { useChatStore } from '@/stores/chat';
347
- import { NerdChatWidget } from 'nerdagent-chat-widget-vue';
348
-
349
- const chatStore = useChatStore();
350
- </script>
351
- ```
352
-
353
- ### With Vuex
354
-
355
- ```vue
356
- <template>
357
- <div>
358
- <NerdChatWidget
359
- :agent-name="$store.state.chat.config.agentName"
360
- :agent-role="$store.state.chat.config.agentRole"
361
- :primary-color="$store.state.chat.config.primaryColor"
362
- @message-sent="handleMessageSent"
363
- @widget-opened="handleWidgetOpened"
364
- @widget-closed="handleWidgetClosed"
365
- />
366
- </div>
367
- </template>
368
-
369
- <script>
370
- import { mapActions } from 'vuex';
371
- import { NerdChatWidget } from 'nerdagent-chat-widget-vue';
372
-
373
- export default {
374
- components: {
375
- NerdChatWidget
376
- },
377
- methods: {
378
- ...mapActions('chat', ['addMessage', 'setWidgetOpen', 'setWidgetClosed']),
379
-
380
- handleMessageSent(event) {
381
- this.addMessage(event);
382
- },
383
-
384
- handleWidgetOpened() {
385
- this.setWidgetOpen(true);
386
- },
387
-
388
- handleWidgetClosed() {
389
- this.setWidgetClosed(false);
390
- }
391
- }
392
- }
393
- </script>
394
- ```
395
-
396
- ### Custom Styling
397
-
398
- The widget uses CSS custom properties for theming. You can override these in your CSS:
399
-
400
- ```css
401
- :root {
402
- --primary-color: #your-color;
403
- --accent-color: #your-accent;
404
- --widget-width: 400px;
405
- --widget-height: 600px;
406
- --font-family: 'Your Font', sans-serif;
407
- }
408
-
409
- /* Custom widget styling */
410
- nerd-chat-widget {
411
- --primary-color: #007bff;
412
- --accent-color: #28a745;
413
- }
414
- ```
415
-
416
- ### Global Registration
417
-
418
- ```javascript
419
- // main.js
420
- import { createApp } from 'vue';
421
- import { NerdChatWidget } from 'nerdagent-chat-widget-vue';
422
- import App from './App.vue';
423
-
424
- const app = createApp(App);
425
-
426
- // Register globally
427
- app.component('NerdChatWidget', NerdChatWidget);
428
-
429
- app.mount('#app');
430
- ```
431
-
432
- ## Browser Support
433
-
434
- - Chrome 60+
435
- - Firefox 55+
436
- - Safari 10+
437
- - Edge 79+
438
-
439
135
  ## TypeScript Support
440
136
 
441
- Full TypeScript definitions are included. Import types as needed:
137
+ Full TypeScript definitions are included:
442
138
 
443
139
  ```typescript
444
- import { WidgetPosition, ChatMessage } from 'nerdagent-chat-widget-vue';
445
- ```
446
-
447
- ## Troubleshooting
448
-
449
- ### Common Issues
450
-
451
- 1. **Widget not appearing**: Ensure the component is properly imported and registered
452
- 2. **Styling issues**: Check that FontAwesome is loaded for icons
453
- 3. **Events not firing**: Verify event handlers are properly bound
454
- 4. **TypeScript errors**: Make sure you're using the correct prop types
455
-
456
- ### Debug Mode
457
-
458
- Enable debug logging by setting the browser's localStorage:
459
-
460
- ```javascript
461
- localStorage.setItem('nerdagent-chat-widget-debug', 'true');
140
+ import { NerdChatWidget, WidgetPosition } from 'nerdagent-chat-widget-vue';
462
141
  ```
463
142
 
464
- ## Contributing
465
-
466
- We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details.
467
-
468
143
  ## License
469
144
 
470
- MIT License - see [LICENSE](../../LICENSE) for details.
471
-
472
- ## Support
473
-
474
- - 📧 Email: support@nerdagent.ai
475
- - 📖 Documentation: [docs.nerdagent.ai](https://docs.nerdagent.ai)
476
- - 🐛 Issues: [GitHub Issues](https://github.com/nerdagent/chat-widget/issues)
477
-
478
- ## Changelog
479
-
480
- ### v1.0.2
481
- - Initial release with Vue wrapper
482
- - Full TypeScript support
483
- - Event handling integration
484
- - Composition API and Options API examples
145
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nerdagent-chat-widget-vue",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "description": "NerdAgent Chat Widget for Vue",
6
6
  "main": "dist/index.js",
@@ -42,5 +42,5 @@
42
42
  "url": "https://github.com/nerdagent/chat-widget.git",
43
43
  "directory": "packages/vue"
44
44
  },
45
- "gitHead": "c8f93bc623e36bcb74a3641f07ae6ee1cccd4941"
45
+ "gitHead": "f46abd47a7632d8fc690b202bfc7c202bcb8b18f"
46
46
  }