nerdagent-chat-widget-vue 1.0.2 → 1.0.4

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 +393 -120
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,211 +1,484 @@
1
- # @nerdagent/chat-widget-vue
1
+ # NerdAgent Chat Widget for Vue
2
2
 
3
- Vue wrapper for the NerdAgent Chat Widget built with Stencil.
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
4
13
 
5
14
  ## Installation
6
15
 
7
16
  ```bash
8
- npm install @nerdagent/chat-widget-vue
17
+ npm install nerdagent-chat-widget-vue
9
18
  ```
10
19
 
11
- ## Usage
12
-
13
- ### Option 1: Component Registration (Recommended)
14
-
15
- ```typescript
16
- // main.ts
17
- import { createApp } from 'vue';
18
- import App from './App.vue';
19
- import { NerdChatWidget } from '@nerdagent/chat-widget-vue';
20
-
21
- const app = createApp(App);
22
-
23
- // Register component globally
24
- app.component('NerdChatWidget', NerdChatWidget);
20
+ ## Quick Start
25
21
 
26
- app.mount('#app');
27
- ```
22
+ ### 1. Import the Component
28
23
 
29
24
  ```vue
30
- <!-- App.vue -->
31
25
  <template>
32
- <div id="app">
26
+ <div class="app">
33
27
  <NerdChatWidget
34
- agent-name="Support Agent"
35
- agent-role="Customer Support"
36
- primary-color="#2d3e50"
37
- accent-color="#4e8cff"
38
- welcome-message="Hi! How can I help?"
39
- position="bottom-right"
40
- width="350"
41
- height="500"
28
+ :agent-name="'Support Agent'"
29
+ :agent-role="'Customer Support'"
30
+ :primary-color="'#2d3e50'"
31
+ :accent-color="'#4e8cff'"
32
+ :welcome-message="'Hi! How can I help you today?'"
33
+ :position="'bottom-right'"
34
+ :width="'350'"
35
+ :height="'500'"
42
36
  :show-minimize-button="true"
43
37
  :show-timestamps="true"
44
38
  :enable-file-upload="false"
45
39
  :enable-speech="false"
46
40
  :show-powered-by="true"
47
- @messageSent="handleMessageSent"
48
- @widgetOpened="handleWidgetOpened"
49
- @widgetClosed="handleWidgetClosed"
41
+ @message-sent="onMessageSent"
42
+ @widget-opened="onWidgetOpened"
43
+ @widget-closed="onWidgetClosed"
50
44
  />
51
45
  </div>
52
46
  </template>
53
47
 
54
- <script setup lang="ts">
55
- const handleMessageSent = (event: { message: string; timestamp: Date }) => {
56
- console.log('Message sent:', event);
57
- };
58
-
59
- const handleWidgetOpened = () => {
60
- console.log('Widget opened');
61
- };
62
-
63
- const handleWidgetClosed = () => {
64
- console.log('Widget closed');
65
- };
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
+ }
66
68
  </script>
67
69
  ```
68
70
 
69
- ### Option 2: Plugin Registration
70
-
71
- ```typescript
72
- // main.ts
73
- import { createApp } from 'vue';
74
- import App from './App.vue';
75
- import { NerdChatWidgetPlugin } from '@nerdagent/chat-widget-vue';
76
-
77
- const app = createApp(App);
78
-
79
- // Use as plugin
80
- app.use(NerdChatWidgetPlugin);
81
-
82
- app.mount('#app');
83
- ```
84
-
85
- ### Option 3: Local Component Registration
71
+ ### 2. With Composition API (Vue 3)
86
72
 
87
73
  ```vue
88
74
  <template>
89
- <div>
75
+ <div class="app">
90
76
  <NerdChatWidget
91
- agent-name="Support Agent"
92
- @messageSent="handleMessageSent"
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
+ @message-sent="handleMessageSent"
91
+ @widget-opened="handleWidgetOpened"
92
+ @widget-closed="handleWidgetClosed"
93
93
  />
94
94
  </div>
95
95
  </template>
96
96
 
97
- <script setup lang="ts">
98
- import { NerdChatWidget } from '@nerdagent/chat-widget-vue';
97
+ <script setup>
98
+ import { ref, reactive } from 'vue';
99
+ import { NerdChatWidget } from 'nerdagent-chat-widget-vue';
99
100
 
100
- const handleMessageSent = (event: { message: string; timestamp: Date }) => {
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
+ const handleMessageSent = (event) => {
121
+ messages.value.push(event);
101
122
  console.log('Message sent:', event);
102
123
  };
124
+
125
+ const handleWidgetOpened = () => {
126
+ console.log('Widget opened');
127
+ };
128
+
129
+ const handleWidgetClosed = () => {
130
+ console.log('Widget closed');
131
+ };
103
132
  </script>
104
133
  ```
105
134
 
106
- ### With Composition API
135
+ ### 3. With TypeScript
107
136
 
108
137
  ```vue
109
138
  <template>
110
- <div>
139
+ <div class="app">
111
140
  <NerdChatWidget
112
141
  :agent-name="config.agentName"
142
+ :agent-role="config.agentRole"
113
143
  :primary-color="config.primaryColor"
144
+ :accent-color="config.accentColor"
145
+ :welcome-message="config.welcomeMessage"
114
146
  :position="config.position"
115
- @messageSent="onMessageSent"
116
- @widgetOpened="onWidgetOpened"
117
- @widgetClosed="onWidgetClosed"
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"
118
157
  />
119
158
  </div>
120
159
  </template>
121
160
 
122
161
  <script setup lang="ts">
123
- import { ref } from 'vue';
124
- import { NerdChatWidget, WidgetPosition } from '@nerdagent/chat-widget-vue';
162
+ import { ref, reactive } from 'vue';
163
+ import { NerdChatWidget, WidgetPosition } from 'nerdagent-chat-widget-vue';
125
164
 
126
- interface Config {
165
+ interface ChatConfig {
127
166
  agentName: string;
167
+ agentRole: string;
128
168
  primaryColor: string;
169
+ accentColor: string;
170
+ welcomeMessage: string;
171
+ placeholderText: string;
129
172
  position: WidgetPosition;
173
+ width: string;
174
+ height: string;
175
+ showMinimizeButton: boolean;
176
+ showTimestamps: boolean;
177
+ enableFileUpload: boolean;
178
+ enableSpeech: boolean;
179
+ showPoweredBy: boolean;
130
180
  }
131
181
 
132
- const config = ref<Config>({
182
+ const config = reactive<ChatConfig>({
133
183
  agentName: 'Support Agent',
184
+ agentRole: 'Customer Support',
134
185
  primaryColor: '#2d3e50',
135
- position: 'bottom-right'
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
136
197
  });
137
198
 
138
- const onMessageSent = (event: { message: string; timestamp: Date }) => {
199
+ const messages = ref<Array<{ message: string; timestamp: Date }>>([]);
200
+
201
+ const handleMessageSent = (event: { message: string; timestamp: Date }) => {
202
+ messages.value.push(event);
139
203
  console.log('Message sent:', event);
140
204
  };
141
205
 
142
- const onWidgetOpened = () => {
206
+ const handleWidgetOpened = () => {
143
207
  console.log('Widget opened');
144
208
  };
145
209
 
146
- const onWidgetClosed = () => {
210
+ const handleWidgetClosed = () => {
147
211
  console.log('Widget closed');
148
212
  };
149
213
  </script>
150
214
  ```
151
215
 
152
- ### Vite Configuration
153
-
154
- If you're using Vite, you may need to configure it to recognize the custom elements:
155
-
156
- ```javascript
157
- // vite.config.js
158
- import { defineConfig } from 'vite'
159
- import vue from '@vitejs/plugin-vue'
160
-
161
- export default defineConfig({
162
- plugins: [
163
- vue({
164
- template: {
165
- compilerOptions: {
166
- isCustomElement: (tag) => tag.startsWith('nerd-')
167
- }
168
- }
169
- })
170
- ]
171
- })
172
- ```
173
-
174
- ## API
216
+ ## Configuration Options
175
217
 
176
218
  ### Props
177
219
 
178
220
  | Prop | Type | Default | Description |
179
221
  |------|------|---------|-------------|
180
- | `agentName` | `string` | `'Support Agent'` | Name of the chat agent |
222
+ | `agentName` | `string` | `'Support Agent'` | Name of the support agent |
181
223
  | `agentRole` | `string` | `'Customer Support'` | Role/title of the agent |
182
- | `primaryColor` | `string` | `'#2d3e50'` | Primary theme color |
183
- | `accentColor` | `string` | `'#4e8cff'` | Accent color for buttons |
184
- | `welcomeMessage` | `string` | `'Hi! How can I help?'` | Initial message from agent |
224
+ | `primaryColor` | `string` | `'#2d3e50'` | Primary color theme |
225
+ | `accentColor` | `string` | `'#4e8cff'` | Accent color theme |
226
+ | `welcomeMessage` | `string` | `'Hi! How can I help?'` | Initial welcome message |
185
227
  | `placeholderText` | `string` | `'Type your message...'` | Input placeholder text |
186
- | `position` | `WidgetPosition` | `'bottom-right'` | Widget position |
228
+ | `position` | `WidgetPosition` | `'bottom-right'` | Widget position on screen |
187
229
  | `width` | `string` | `'350'` | Widget width in pixels |
188
230
  | `height` | `string` | `'500'` | Widget height in pixels |
189
- | `showMinimizeButton` | `boolean` | `true` | Show/hide minimize button |
190
- | `showTimestamps` | `boolean` | `true` | Show/hide message timestamps |
231
+ | `showMinimizeButton` | `boolean` | `true` | Show minimize/maximize button |
232
+ | `showTimestamps` | `boolean` | `true` | Show message timestamps |
191
233
  | `enableFileUpload` | `boolean` | `false` | Enable file upload feature |
192
- | `enableSpeech` | `boolean` | `false` | Enable speech input |
193
- | `showPoweredBy` | `boolean` | `true` | Show/hide "Powered by" footer |
234
+ | `enableSpeech` | `boolean` | `false` | Enable speech recognition |
235
+ | `showPoweredBy` | `boolean` | `true` | Show "Powered by" branding |
236
+
237
+ ### WidgetPosition Type
238
+
239
+ ```typescript
240
+ type WidgetPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
241
+ ```
194
242
 
195
243
  ### Events
196
244
 
197
- | Event | Payload | Description |
198
- |-------|---------|-------------|
199
- | `messageSent` | `{ message: string; timestamp: Date }` | Emitted when a message is sent |
200
- | `widgetOpened` | `void` | Emitted when the widget is opened |
201
- | `widgetClosed` | `void` | Emitted when the widget is closed |
245
+ | Event | Type | Description |
246
+ |-------|------|-------------|
247
+ | `message-sent` | `{ message: string; timestamp: Date }` | Emitted when user sends a message |
248
+ | `widget-opened` | `void` | Emitted when widget is opened |
249
+ | `widget-closed` | `void` | Emitted when widget is closed |
250
+
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+
202
438
 
203
- ### Types
439
+ ## TypeScript Support
440
+
441
+ Full TypeScript definitions are included. Import types as needed:
204
442
 
205
443
  ```typescript
206
- type WidgetPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
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');
207
462
  ```
208
463
 
464
+ ## Contributing
465
+
466
+ We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details.
467
+
209
468
  ## License
210
469
 
211
- MIT
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nerdagent-chat-widget-vue",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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": "baebff96671fd060b15aa0ca587f2c9a1556c06b"
45
+ "gitHead": "c91038af3fb5ffd477c5c73c7e70b850512d65b5"
46
46
  }