nerdagent-chat-widget 1.0.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/README.md +257 -0
- package/dist/angular/index.d.ts +38 -0
- package/dist/angular/index.js +5 -0
- package/dist/angular/index.js.map +1 -0
- package/dist/angular/nerd-chat-widget.d.ts +11 -0
- package/dist/angular/nerd-chat-widget.js +289 -0
- package/dist/angular/nerd-chat-widget.js.map +1 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +8 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
- package/dist/cjs/index-CURqjGGU.js +1471 -0
- package/dist/cjs/index-CURqjGGU.js.map +1 -0
- package/dist/cjs/index.cjs.js +235 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +14 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/nerd-chat-widget.cjs.entry.js +9 -0
- package/dist/cjs/nerd-chat-widget.entry.cjs.js.map +1 -0
- package/dist/cjs/nerdagent-chat-widget.cjs.js +26 -0
- package/dist/cjs/nerdagent-chat-widget.cjs.js.map +1 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/chat-widget/chat-widget.js +808 -0
- package/dist/collection/components/chat-widget/chat-widget.js.map +1 -0
- package/dist/collection/components/chat-widget/chat-widget.scss +420 -0
- package/dist/collection/index.js +2 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/script.js +323 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.js +1514 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/nerd-chat-widget.d.ts +11 -0
- package/dist/components/nerd-chat-widget.js +9 -0
- package/dist/components/nerd-chat-widget.js.map +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js +6 -0
- package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
- package/dist/esm/index-Dlv_7oUh.js +1444 -0
- package/dist/esm/index-Dlv_7oUh.js.map +1 -0
- package/dist/esm/index.js +233 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +12 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/nerd-chat-widget.entry.js +3 -0
- package/dist/esm/nerd-chat-widget.entry.js.map +1 -0
- package/dist/esm/nerdagent-chat-widget.js +22 -0
- package/dist/esm/nerdagent-chat-widget.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/nerdagent-chat-widget/index.esm.js +2 -0
- package/dist/nerdagent-chat-widget/index.esm.js.map +1 -0
- package/dist/nerdagent-chat-widget/loader.esm.js.map +1 -0
- package/dist/nerdagent-chat-widget/nerd-chat-widget.entry.esm.js.map +1 -0
- package/dist/nerdagent-chat-widget/nerdagent-chat-widget.esm.js +2 -0
- package/dist/nerdagent-chat-widget/nerdagent-chat-widget.esm.js.map +1 -0
- package/dist/nerdagent-chat-widget/p-395fe7e7.entry.js +2 -0
- package/dist/nerdagent-chat-widget/p-395fe7e7.entry.js.map +1 -0
- package/dist/nerdagent-chat-widget/p-DQuL1Twl.js +2 -0
- package/dist/nerdagent-chat-widget/p-DQuL1Twl.js.map +1 -0
- package/dist/nerdagent-chat-widget/p-Dlv_7oUh.js +3 -0
- package/dist/nerdagent-chat-widget/p-Dlv_7oUh.js.map +1 -0
- package/dist/react/index.d.ts +38 -0
- package/dist/react/index.js +5 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/nerd-chat-widget.d.ts +11 -0
- package/dist/react/nerd-chat-widget.js +289 -0
- package/dist/react/nerd-chat-widget.js.map +1 -0
- package/dist/types/components/chat-widget/chat-widget.d.ts +95 -0
- package/dist/types/components.d.ts +251 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/stencil-public-runtime.d.ts +1730 -0
- package/dist/vue/index.d.ts +38 -0
- package/dist/vue/index.js +5 -0
- package/dist/vue/index.js.map +1 -0
- package/dist/vue/nerd-chat-widget.d.ts +11 -0
- package/dist/vue/nerd-chat-widget.js +289 -0
- package/dist/vue/nerd-chat-widget.js.map +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +76 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { getAssetPath, render, setAssetPath, setNonce, setPlatformOptions } from '@stencil/core/internal/client';
|
|
2
|
+
export { C as ChatWidget, NerdChatWidget, d as defineCustomElement, defineCustomElement as defineCustomElementNerdChatWidget } from './nerd-chat-widget.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"index.js","mappings":";","names":[],"sources":[],"sourcesContent":[],"version":3}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface NerdChatWidget extends Components.NerdChatWidget, HTMLElement {}
|
|
4
|
+
export const NerdChatWidget: {
|
|
5
|
+
prototype: NerdChatWidget;
|
|
6
|
+
new (): NerdChatWidget;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
const chatWidgetScss = ":host {\n --primary-color: #2d3e50;\n --accent-color: #4e8cff;\n --widget-width: 350px;\n --widget-height: 500px;\n --font-family: 'Segoe UI', Arial, sans-serif;\n \n position: fixed;\n z-index: 10000;\n font-family: var(--font-family);\n}\n\n.chat-widget {\n position: fixed !important;\n width: var(--widget-width);\n height: var(--widget-height);\n background: white;\n border-radius: 16px;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);\n overflow: hidden;\n transition: all 0.3s ease;\n display: flex;\n flex-direction: column;\n\n &.position-bottom-right {\n bottom: 20px !important;\n right: 20px !important;\n top: auto !important;\n left: auto !important;\n }\n\n &.position-bottom-left {\n bottom: 20px !important;\n left: 20px !important;\n top: auto !important;\n right: auto !important;\n }\n\n &.position-top-right {\n top: 20px !important;\n right: 20px !important;\n bottom: auto !important;\n left: auto !important;\n }\n\n &.position-top-left {\n top: 20px !important;\n left: 20px !important;\n bottom: auto !important;\n right: auto !important;\n }\n\n &.minimized {\n width: 60px !important;\n height: 60px !important;\n border-radius: 50% !important;\n cursor: pointer;\n\n .chat-header,\n .messages-container,\n .input-container,\n .tabs,\n .powered-by {\n display: none;\n }\n\n .minimize-icon {\n display: flex !important;\n }\n }\n\n &.hidden {\n display: none !important;\n }\n}\n\n.chat-header {\n background: var(--primary-color);\n color: white;\n padding: 16px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex-shrink: 0;\n\n .agent-info {\n display: flex;\n align-items: center;\n gap: 12px;\n\n .agent-avatar {\n width: 44px;\n height: 44px;\n border-radius: 50%;\n border: 2px solid rgba(255, 255, 255, 0.3);\n object-fit: cover;\n }\n\n .agent-details {\n h4 {\n margin: 0;\n font-size: 1.1em;\n font-weight: 600;\n }\n\n p {\n margin: 0;\n font-size: 0.95em;\n opacity: 0.8;\n }\n }\n }\n\n .controls {\n display: flex;\n gap: 6px;\n\n .control-btn {\n background: rgba(0, 0, 0, 0.1);\n border: none;\n color: #fff;\n width: 28px;\n height: 28px;\n border-radius: 50%;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 1.1em;\n transition: background 0.2s;\n\n &:hover {\n background: rgba(0, 0, 0, 0.2);\n }\n\n &.close-btn {\n &:hover {\n background: rgba(255, 0, 0, 0.3);\n }\n }\n }\n }\n}\n\n.messages-container {\n flex: 1;\n overflow-y: auto;\n padding: 18px 16px 12px 16px;\n background: #f7f7f7;\n display: flex;\n flex-direction: column;\n gap: 16px;\n\n .message {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n\n &.user {\n flex-direction: row-reverse;\n }\n\n .message-avatar {\n width: 28px;\n height: 28px;\n border-radius: 50%;\n flex-shrink: 0;\n object-fit: cover;\n border: 1px solid #eee;\n }\n\n .message-content {\n max-width: 70%;\n\n .message-text {\n padding: 10px 14px;\n border-radius: 10px;\n font-size: 1em;\n line-height: 1.4;\n }\n\n .message-time {\n font-size: 11px;\n opacity: 0.6;\n margin-top: 4px;\n }\n }\n\n &.agent .message-content .message-text {\n background: #eafbe7;\n color: #222;\n border-radius: 10px 10px 10px 0;\n }\n\n &.user .message-content .message-text {\n background: #e6f4ff;\n color: #222;\n border-radius: 10px 10px 0 10px;\n }\n }\n\n .typing-indicator {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 16px;\n font-size: 12px;\n color: #666;\n font-style: italic;\n\n .typing-dots {\n display: flex;\n gap: 2px;\n\n .dot {\n width: 4px;\n height: 4px;\n border-radius: 50%;\n background: #666;\n animation: typing 1.4s infinite;\n\n &:nth-child(2) {\n animation-delay: 0.2s;\n }\n\n &:nth-child(3) {\n animation-delay: 0.4s;\n }\n }\n }\n }\n}\n\n.input-container {\n background: #fff;\n border-top: 1px solid #eee;\n padding: 10px 12px 8px 12px;\n display: flex;\n align-items: center;\n gap: 8px;\n flex-shrink: 0;\n\n .message-input {\n flex: 1;\n border: 1px solid #e0e0e0;\n border-radius: 20px;\n padding: 8px 14px;\n font-size: 1em;\n outline: none;\n background: #fafbfc;\n font-family: var(--font-family);\n\n &:focus {\n border-color: var(--accent-color);\n }\n }\n\n .send-btn {\n background: var(--primary-color);\n color: #fff;\n border: none;\n border-radius: 50%;\n width: 36px;\n height: 36px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 1.2em;\n box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);\n transition: opacity 0.2s;\n position: relative;\n\n &:hover {\n opacity: 0.9;\n }\n\n // Show fallback icons by default\n i {\n font-size: 1em;\n display: none;\n }\n\n .fallback-icon {\n font-size: 1em;\n display: block;\n }\n }\n\n .feature-btn {\n background: var(--primary-color);\n color: var(--accent-color);\n border: none;\n border-radius: 50%;\n width: 36px;\n height: 36px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 1.2em;\n position: relative;\n\n // Show fallback icons by default\n i {\n font-size: 1em;\n display: none;\n }\n\n .fallback-icon {\n font-size: 1em;\n display: block;\n }\n }\n}\n\n.tabs {\n background: #f8f8f8;\n border-top: 1.5px solid #e0e7ff;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: space-around;\n height: 48px;\n flex-shrink: 0;\n\n .tab {\n flex: 1;\n text-align: center;\n padding: 7px 0;\n color: var(--primary-color);\n font-weight: 600;\n cursor: pointer;\n transition: background 0.2s;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 2px;\n\n &:hover {\n background: rgba(0, 0, 0, 0.05);\n }\n\n // Show fallback icons by default\n i {\n font-size: 1.1em;\n display: none;\n }\n\n .fallback-icon {\n font-size: 1.1em;\n display: block;\n }\n\n span:not(.fallback-icon) {\n font-size: 0.91em;\n }\n }\n}\n\n.powered-by {\n text-align: center;\n font-size: 0.95em;\n color: #aaa;\n padding: 7px 0 3px 0;\n background: #fff;\n border-top: 1px solid #f3f3f3;\n flex-shrink: 0;\n\n img {\n height: 18px;\n vertical-align: middle;\n margin-right: 6px;\n opacity: 0.85;\n object-fit: contain;\n }\n\n span {\n font-weight: 500;\n }\n}\n\n.minimize-icon {\n display: none;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n font-size: 24px;\n color: white;\n background: var(--primary-color);\n border-radius: 50%;\n cursor: pointer;\n}\n\n@keyframes typing {\n 0%, 60%, 100% {\n transform: translateY(0);\n }\n 30% {\n transform: translateY(-10px);\n }\n}\n\n// Mobile responsiveness\n@media (max-width: 768px) {\n .chat-widget {\n width: 100% !important;\n height: 100% !important;\n top: 0 !important;\n left: 0 !important;\n right: 0 !important;\n bottom: 0 !important;\n border-radius: 0 !important;\n\n .messages-container {\n height: calc(100vh - 200px);\n }\n }\n}";
|
|
4
|
+
|
|
5
|
+
const ChatWidget = /*@__PURE__*/ proxyCustomElement(class ChatWidget extends HTMLElement {
|
|
6
|
+
constructor(registerHost) {
|
|
7
|
+
super();
|
|
8
|
+
if (registerHost !== false) {
|
|
9
|
+
this.__registerHost();
|
|
10
|
+
}
|
|
11
|
+
this.__attachShadow();
|
|
12
|
+
this.messageSent = createEvent(this, "messageSent", 7);
|
|
13
|
+
this.widgetOpened = createEvent(this, "widgetOpened", 7);
|
|
14
|
+
this.widgetClosed = createEvent(this, "widgetClosed", 7);
|
|
15
|
+
// Configuration props
|
|
16
|
+
this.config = {};
|
|
17
|
+
this.agentName = 'Support Agent';
|
|
18
|
+
this.agentRole = 'Customer Support';
|
|
19
|
+
this.agentAvatar = 'https://ui-avatars.com/api/?name=Agent&background=2d3e50&color=ffffff&size=44';
|
|
20
|
+
this.primaryColor = '#2d3e50';
|
|
21
|
+
this.accentColor = '#4e8cff';
|
|
22
|
+
this.welcomeMessage = 'Hi! How can I help you today?';
|
|
23
|
+
this.position = 'bottom-right';
|
|
24
|
+
this.showMinimizeButton = true;
|
|
25
|
+
this.enableFileUpload = false;
|
|
26
|
+
this.enableSpeech = false;
|
|
27
|
+
this.showTimestamps = true;
|
|
28
|
+
this.apiEndpoint = '';
|
|
29
|
+
this.apiKey = '';
|
|
30
|
+
this.placeholderText = 'Type your message...';
|
|
31
|
+
this.thankYouMessage = 'Thank you for chatting with us!';
|
|
32
|
+
this.showPoweredBy = true;
|
|
33
|
+
this.poweredByLogo = 'https://innovationincubator.com/wp-content/uploads/2023/05/Innovation-Incubator-logo.png';
|
|
34
|
+
this.poweredByText = 'Powered by';
|
|
35
|
+
this.poweredByBrand = 'NerdAgent';
|
|
36
|
+
this.poweredByColor = '#4e8cff';
|
|
37
|
+
this.width = 350;
|
|
38
|
+
this.height = 500;
|
|
39
|
+
this.fontFamily = 'Segoe UI, Arial, sans-serif';
|
|
40
|
+
// State
|
|
41
|
+
this.messages = [];
|
|
42
|
+
this.isMinimized = false;
|
|
43
|
+
this.isTyping = false;
|
|
44
|
+
this.inputValue = '';
|
|
45
|
+
this.isChatOpen = true;
|
|
46
|
+
this.currentPosition = 'bottom-right';
|
|
47
|
+
this.messageIdCounter = 0;
|
|
48
|
+
}
|
|
49
|
+
componentDidLoad() {
|
|
50
|
+
// Initialize position
|
|
51
|
+
this.currentPosition = this.position;
|
|
52
|
+
// Load Font Awesome if not already loaded
|
|
53
|
+
this.loadFontAwesome();
|
|
54
|
+
// Add welcome message
|
|
55
|
+
if (this.getConfig().welcomeMessage) {
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
this.addMessage(this.getConfig().welcomeMessage, false);
|
|
58
|
+
}, 500);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
configChanged() {
|
|
62
|
+
// React to config changes - Stencil automatically re-renders when @Prop changes
|
|
63
|
+
// No need to manually trigger re-render
|
|
64
|
+
}
|
|
65
|
+
positionChanged() {
|
|
66
|
+
// Force re-render when position changes
|
|
67
|
+
console.log('Position changed to:', this.position);
|
|
68
|
+
this.currentPosition = this.position;
|
|
69
|
+
// Debug: Check what styles are applied
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
const widgetEl = this.el.shadowRoot.querySelector('.chat-widget');
|
|
72
|
+
if (widgetEl) {
|
|
73
|
+
console.log('Widget classes:', widgetEl.className);
|
|
74
|
+
console.log('Widget inline styles:', widgetEl.style.cssText);
|
|
75
|
+
console.log('Widget computed styles:', {
|
|
76
|
+
position: window.getComputedStyle(widgetEl).position,
|
|
77
|
+
top: window.getComputedStyle(widgetEl).top,
|
|
78
|
+
right: window.getComputedStyle(widgetEl).right,
|
|
79
|
+
bottom: window.getComputedStyle(widgetEl).bottom,
|
|
80
|
+
left: window.getComputedStyle(widgetEl).left
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, 100);
|
|
84
|
+
}
|
|
85
|
+
getConfig() {
|
|
86
|
+
return Object.assign({ agentName: this.agentName, agentRole: this.agentRole, agentAvatar: this.agentAvatar, primaryColor: this.primaryColor, accentColor: this.accentColor, welcomeMessage: this.welcomeMessage, position: this.position, showMinimizeButton: this.showMinimizeButton, enableFileUpload: this.enableFileUpload, enableSpeech: this.enableSpeech, showTimestamps: this.showTimestamps, apiEndpoint: this.apiEndpoint, apiKey: this.apiKey, placeholderText: this.placeholderText, thankYouMessage: this.thankYouMessage, showPoweredBy: this.showPoweredBy, poweredByLogo: this.poweredByLogo, poweredByText: this.poweredByText, poweredByBrand: this.poweredByBrand, poweredByColor: this.poweredByColor, width: this.width, height: this.height, fontFamily: this.fontFamily }, this.config);
|
|
87
|
+
}
|
|
88
|
+
loadFontAwesome() {
|
|
89
|
+
if (!document.getElementById('fa-cdn-stencil')) {
|
|
90
|
+
const link = document.createElement('link');
|
|
91
|
+
link.id = 'fa-cdn-stencil';
|
|
92
|
+
link.rel = 'stylesheet';
|
|
93
|
+
link.href = 'https://use.fontawesome.com/releases/v6.4.2/css/all.css';
|
|
94
|
+
link.crossOrigin = 'anonymous';
|
|
95
|
+
document.head.appendChild(link);
|
|
96
|
+
console.log('Loading FontAwesome...');
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
console.log('FontAwesome already loaded');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
addMessage(text, isUser = false) {
|
|
103
|
+
const message = {
|
|
104
|
+
id: `msg-${++this.messageIdCounter}`,
|
|
105
|
+
text,
|
|
106
|
+
isUser,
|
|
107
|
+
timestamp: new Date()
|
|
108
|
+
};
|
|
109
|
+
this.messages = [...this.messages, message];
|
|
110
|
+
}
|
|
111
|
+
async sendMessage() {
|
|
112
|
+
const text = this.inputValue.trim();
|
|
113
|
+
if (!text)
|
|
114
|
+
return;
|
|
115
|
+
this.addMessage(text, true);
|
|
116
|
+
this.inputValue = '';
|
|
117
|
+
// Emit event
|
|
118
|
+
this.messageSent.emit({ message: text, widget: this.el });
|
|
119
|
+
// Handle API or simulate response
|
|
120
|
+
const config = this.getConfig();
|
|
121
|
+
if (config.apiEndpoint) {
|
|
122
|
+
await this.sendToAPI(text);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
this.simulateResponse();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async sendToAPI(message) {
|
|
129
|
+
const config = this.getConfig();
|
|
130
|
+
this.isTyping = true;
|
|
131
|
+
try {
|
|
132
|
+
const response = await fetch(config.apiEndpoint, {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, (config.apiKey && { 'Authorization': `Bearer ${config.apiKey}` })),
|
|
135
|
+
body: JSON.stringify({
|
|
136
|
+
message,
|
|
137
|
+
timestamp: new Date().toISOString(),
|
|
138
|
+
sessionId: this.getSessionId()
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
const data = await response.json();
|
|
142
|
+
this.isTyping = false;
|
|
143
|
+
if (data.response) {
|
|
144
|
+
this.addMessage(data.response, false);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
this.isTyping = false;
|
|
149
|
+
this.addMessage('Sorry, I encountered an error. Please try again.', false);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
simulateResponse() {
|
|
153
|
+
const responses = [
|
|
154
|
+
"Thanks for your message! How can I help you further?",
|
|
155
|
+
"I understand. Let me assist you with that.",
|
|
156
|
+
"That's a great question! Let me help you.",
|
|
157
|
+
"I'm here to help! Could you provide more details?"
|
|
158
|
+
];
|
|
159
|
+
this.isTyping = true;
|
|
160
|
+
setTimeout(() => {
|
|
161
|
+
this.isTyping = false;
|
|
162
|
+
const response = responses[Math.floor(Math.random() * responses.length)];
|
|
163
|
+
this.addMessage(response, false);
|
|
164
|
+
}, 1500);
|
|
165
|
+
}
|
|
166
|
+
toggleMinimize() {
|
|
167
|
+
this.isMinimized = !this.isMinimized;
|
|
168
|
+
if (this.isMinimized) {
|
|
169
|
+
this.widgetClosed.emit({ widget: this.el });
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
this.widgetOpened.emit({ widget: this.el });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
closeWidget() {
|
|
176
|
+
this.isChatOpen = false;
|
|
177
|
+
this.widgetClosed.emit({ widget: this.el });
|
|
178
|
+
}
|
|
179
|
+
openWidget() {
|
|
180
|
+
this.isChatOpen = true;
|
|
181
|
+
this.isMinimized = false;
|
|
182
|
+
this.widgetOpened.emit({ widget: this.el });
|
|
183
|
+
}
|
|
184
|
+
handleKeyPress(event) {
|
|
185
|
+
if (event.key === 'Enter') {
|
|
186
|
+
this.sendMessage();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
handleInputChange(event) {
|
|
190
|
+
const target = event.target;
|
|
191
|
+
this.inputValue = target.value;
|
|
192
|
+
}
|
|
193
|
+
getSessionId() {
|
|
194
|
+
let sessionId = localStorage.getItem('nerd-chat-session');
|
|
195
|
+
if (!sessionId) {
|
|
196
|
+
sessionId = 'session-' + Math.random().toString(36).substr(2, 9);
|
|
197
|
+
localStorage.setItem('nerd-chat-session', sessionId);
|
|
198
|
+
}
|
|
199
|
+
return sessionId;
|
|
200
|
+
}
|
|
201
|
+
formatTime(date) {
|
|
202
|
+
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
203
|
+
}
|
|
204
|
+
render() {
|
|
205
|
+
const config = this.getConfig();
|
|
206
|
+
console.log('Rendering with position:', this.currentPosition);
|
|
207
|
+
// Get position styles directly
|
|
208
|
+
const getPositionStyles = () => {
|
|
209
|
+
switch (this.currentPosition) {
|
|
210
|
+
case 'bottom-left':
|
|
211
|
+
return { bottom: '20px', left: '20px', top: 'auto', right: 'auto' };
|
|
212
|
+
case 'top-right':
|
|
213
|
+
return { top: '20px', right: '20px', bottom: 'auto', left: 'auto' };
|
|
214
|
+
case 'top-left':
|
|
215
|
+
return { top: '20px', left: '20px', bottom: 'auto', right: 'auto' };
|
|
216
|
+
case 'bottom-right':
|
|
217
|
+
default:
|
|
218
|
+
return { bottom: '20px', right: '20px', top: 'auto', left: 'auto' };
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
const widgetClasses = {
|
|
222
|
+
'chat-widget': true,
|
|
223
|
+
'minimized': this.isMinimized,
|
|
224
|
+
'hidden': !this.isChatOpen
|
|
225
|
+
};
|
|
226
|
+
return (h(Host, null, h("div", { class: widgetClasses, style: Object.assign({ '--primary-color': config.primaryColor || '#2d3e50', '--accent-color': config.accentColor || '#4e8cff', '--widget-width': `${config.width || 350}px`, '--widget-height': `${config.height || 500}px`, '--font-family': config.fontFamily || 'Segoe UI, Arial, sans-serif' }, getPositionStyles()) }, h("div", { class: "chat-header" }, h("div", { class: "agent-info" }, h("img", { src: config.agentAvatar, alt: "Agent", class: "agent-avatar" }), h("div", { class: "agent-details" }, h("h4", null, config.agentName), h("p", null, config.agentRole))), h("div", { class: "controls" }, config.showMinimizeButton && (h("button", { class: "control-btn minimize-btn", onClick: () => this.toggleMinimize(), title: this.isMinimized ? 'Maximize' : 'Minimize' }, this.isMinimized ? '🔼' : '🔽')), h("button", { class: "control-btn close-btn", onClick: () => this.closeWidget(), title: "Close" }, "\u00D7"))), h("div", { class: "messages-container" }, this.messages.map(message => (h("div", { key: message.id, class: `message ${message.isUser ? 'user' : 'agent'}` }, h("img", { src: message.isUser ? 'https://ui-avatars.com/api/?name=User&background=4e8cff&color=ffffff&size=28' : config.agentAvatar, alt: message.isUser ? 'User' : 'Agent', class: "message-avatar" }), h("div", { class: "message-content" }, h("div", { class: "message-text" }, message.text), config.showTimestamps && (h("div", { class: "message-time" }, this.formatTime(message.timestamp))))))), this.isTyping && (h("div", { class: "typing-indicator" }, h("span", null, config.agentName, " is typing"), h("div", { class: "typing-dots" }, h("div", { class: "dot" }), h("div", { class: "dot" }), h("div", { class: "dot" }))))), h("div", { class: "input-container" }, h("input", { type: "text", class: "message-input", placeholder: config.placeholderText || 'Type your message...', value: this.inputValue, onInput: (e) => this.handleInputChange(e), onKeyPress: (e) => this.handleKeyPress(e) }), h("button", { class: "send-btn", onClick: () => this.sendMessage() }, h("i", { class: "fas fa-paper-plane" }), h("span", { class: "fallback-icon" }, "\u27A4")), config.enableFileUpload && (h("button", { class: "feature-btn file-upload" }, h("i", { class: "fas fa-paperclip" }), h("span", { class: "fallback-icon" }, "\uD83D\uDCCE"))), config.enableSpeech && (h("button", { class: "feature-btn speech" }, h("i", { class: "fas fa-microphone" }), h("span", { class: "fallback-icon" }, "\uD83C\uDFA4")))), h("div", { class: "tabs" }, h("div", { class: "tab active" }, h("i", { class: "fas fa-comment-dots" }), h("span", null, "Chat")), h("div", { class: "tab" }, h("i", { class: "fas fa-microphone" }), h("span", null, "Voice")), h("div", { class: "tab" }, h("i", { class: "fas fa-clock" }), h("span", null, "History"))), config.showPoweredBy && (h("div", { class: "powered-by" }, h("img", { src: config.poweredByLogo, alt: "Powered By Logo" }), config.poweredByText, " ", h("span", { style: { color: config.poweredByColor } }, config.poweredByBrand))), h("div", { class: "minimize-icon", onClick: () => this.isChatOpen ? this.toggleMinimize() : this.openWidget() }, "\uD83D\uDCAC"))));
|
|
227
|
+
}
|
|
228
|
+
get el() { return this; }
|
|
229
|
+
static get watchers() { return {
|
|
230
|
+
"config": ["configChanged"],
|
|
231
|
+
"position": ["positionChanged"]
|
|
232
|
+
}; }
|
|
233
|
+
static get style() { return chatWidgetScss; }
|
|
234
|
+
}, [257, "nerd-chat-widget", {
|
|
235
|
+
"config": [16],
|
|
236
|
+
"agentName": [1, "agent-name"],
|
|
237
|
+
"agentRole": [1, "agent-role"],
|
|
238
|
+
"agentAvatar": [1, "agent-avatar"],
|
|
239
|
+
"primaryColor": [1, "primary-color"],
|
|
240
|
+
"accentColor": [1, "accent-color"],
|
|
241
|
+
"welcomeMessage": [1, "welcome-message"],
|
|
242
|
+
"position": [1],
|
|
243
|
+
"showMinimizeButton": [4, "show-minimize-button"],
|
|
244
|
+
"enableFileUpload": [4, "enable-file-upload"],
|
|
245
|
+
"enableSpeech": [4, "enable-speech"],
|
|
246
|
+
"showTimestamps": [4, "show-timestamps"],
|
|
247
|
+
"apiEndpoint": [1, "api-endpoint"],
|
|
248
|
+
"apiKey": [1, "api-key"],
|
|
249
|
+
"placeholderText": [1, "placeholder-text"],
|
|
250
|
+
"thankYouMessage": [1, "thank-you-message"],
|
|
251
|
+
"showPoweredBy": [4, "show-powered-by"],
|
|
252
|
+
"poweredByLogo": [1, "powered-by-logo"],
|
|
253
|
+
"poweredByText": [1, "powered-by-text"],
|
|
254
|
+
"poweredByBrand": [1, "powered-by-brand"],
|
|
255
|
+
"poweredByColor": [1, "powered-by-color"],
|
|
256
|
+
"width": [2],
|
|
257
|
+
"height": [2],
|
|
258
|
+
"fontFamily": [1, "font-family"],
|
|
259
|
+
"messages": [32],
|
|
260
|
+
"isMinimized": [32],
|
|
261
|
+
"isTyping": [32],
|
|
262
|
+
"inputValue": [32],
|
|
263
|
+
"isChatOpen": [32],
|
|
264
|
+
"currentPosition": [32]
|
|
265
|
+
}, undefined, {
|
|
266
|
+
"config": ["configChanged"],
|
|
267
|
+
"position": ["positionChanged"]
|
|
268
|
+
}]);
|
|
269
|
+
function defineCustomElement$1() {
|
|
270
|
+
if (typeof customElements === "undefined") {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const components = ["nerd-chat-widget"];
|
|
274
|
+
components.forEach(tagName => { switch (tagName) {
|
|
275
|
+
case "nerd-chat-widget":
|
|
276
|
+
if (!customElements.get(tagName)) {
|
|
277
|
+
customElements.define(tagName, ChatWidget);
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
280
|
+
} });
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const NerdChatWidget = ChatWidget;
|
|
284
|
+
const defineCustomElement = defineCustomElement$1;
|
|
285
|
+
|
|
286
|
+
export { ChatWidget as C, NerdChatWidget, defineCustomElement$1 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BAAiB,EAAG,CAAA,EACvD,MAAM,CAAC,aAAa,OAAE,CAAA,CAAA,MAAA,EAAA,EAAM,KAAK,EAAE,EAAC,KAAK,EAAE,MAAM,CAAC,cAAc,EAAC,IAAG,MAAM,CAAC,cAAc,CAAQ,CAC9F,CACP,EAGD,CAAA,CAAA,KAAA,EAAA,EAAK,KAAK,EAAC,eAAe,EAAC,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,EAAA,EAAA,cAAA,CAE/F,CACA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["__stencil_proxyCustomElement"],"sources":["src/components/chat-widget/chat-widget.scss?tag=nerd-chat-widget&encapsulation=shadow","src/components/chat-widget/chat-widget.tsx"],"sourcesContent":[":host {\n --primary-color: #2d3e50;\n --accent-color: #4e8cff;\n --widget-width: 350px;\n --widget-height: 500px;\n --font-family: 'Segoe UI', Arial, sans-serif;\n \n position: fixed;\n z-index: 10000;\n font-family: var(--font-family);\n}\n\n.chat-widget {\n position: fixed !important;\n width: var(--widget-width);\n height: var(--widget-height);\n background: white;\n border-radius: 16px;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);\n overflow: hidden;\n transition: all 0.3s ease;\n display: flex;\n flex-direction: column;\n\n &.position-bottom-right {\n bottom: 20px !important;\n right: 20px !important;\n top: auto !important;\n left: auto !important;\n }\n\n &.position-bottom-left {\n bottom: 20px !important;\n left: 20px !important;\n top: auto !important;\n right: auto !important;\n }\n\n &.position-top-right {\n top: 20px !important;\n right: 20px !important;\n bottom: auto !important;\n left: auto !important;\n }\n\n &.position-top-left {\n top: 20px !important;\n left: 20px !important;\n bottom: auto !important;\n right: auto !important;\n }\n\n &.minimized {\n width: 60px !important;\n height: 60px !important;\n border-radius: 50% !important;\n cursor: pointer;\n\n .chat-header,\n .messages-container,\n .input-container,\n .tabs,\n .powered-by {\n display: none;\n }\n\n .minimize-icon {\n display: flex !important;\n }\n }\n\n &.hidden {\n display: none !important;\n }\n}\n\n.chat-header {\n background: var(--primary-color);\n color: white;\n padding: 16px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex-shrink: 0;\n\n .agent-info {\n display: flex;\n align-items: center;\n gap: 12px;\n\n .agent-avatar {\n width: 44px;\n height: 44px;\n border-radius: 50%;\n border: 2px solid rgba(255, 255, 255, 0.3);\n object-fit: cover;\n }\n\n .agent-details {\n h4 {\n margin: 0;\n font-size: 1.1em;\n font-weight: 600;\n }\n\n p {\n margin: 0;\n font-size: 0.95em;\n opacity: 0.8;\n }\n }\n }\n\n .controls {\n display: flex;\n gap: 6px;\n\n .control-btn {\n background: rgba(0, 0, 0, 0.1);\n border: none;\n color: #fff;\n width: 28px;\n height: 28px;\n border-radius: 50%;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 1.1em;\n transition: background 0.2s;\n\n &:hover {\n background: rgba(0, 0, 0, 0.2);\n }\n\n &.close-btn {\n &:hover {\n background: rgba(255, 0, 0, 0.3);\n }\n }\n }\n }\n}\n\n.messages-container {\n flex: 1;\n overflow-y: auto;\n padding: 18px 16px 12px 16px;\n background: #f7f7f7;\n display: flex;\n flex-direction: column;\n gap: 16px;\n\n .message {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n\n &.user {\n flex-direction: row-reverse;\n }\n\n .message-avatar {\n width: 28px;\n height: 28px;\n border-radius: 50%;\n flex-shrink: 0;\n object-fit: cover;\n border: 1px solid #eee;\n }\n\n .message-content {\n max-width: 70%;\n\n .message-text {\n padding: 10px 14px;\n border-radius: 10px;\n font-size: 1em;\n line-height: 1.4;\n }\n\n .message-time {\n font-size: 11px;\n opacity: 0.6;\n margin-top: 4px;\n }\n }\n\n &.agent .message-content .message-text {\n background: #eafbe7;\n color: #222;\n border-radius: 10px 10px 10px 0;\n }\n\n &.user .message-content .message-text {\n background: #e6f4ff;\n color: #222;\n border-radius: 10px 10px 0 10px;\n }\n }\n\n .typing-indicator {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 16px;\n font-size: 12px;\n color: #666;\n font-style: italic;\n\n .typing-dots {\n display: flex;\n gap: 2px;\n\n .dot {\n width: 4px;\n height: 4px;\n border-radius: 50%;\n background: #666;\n animation: typing 1.4s infinite;\n\n &:nth-child(2) {\n animation-delay: 0.2s;\n }\n\n &:nth-child(3) {\n animation-delay: 0.4s;\n }\n }\n }\n }\n}\n\n.input-container {\n background: #fff;\n border-top: 1px solid #eee;\n padding: 10px 12px 8px 12px;\n display: flex;\n align-items: center;\n gap: 8px;\n flex-shrink: 0;\n\n .message-input {\n flex: 1;\n border: 1px solid #e0e0e0;\n border-radius: 20px;\n padding: 8px 14px;\n font-size: 1em;\n outline: none;\n background: #fafbfc;\n font-family: var(--font-family);\n\n &:focus {\n border-color: var(--accent-color);\n }\n }\n\n .send-btn {\n background: var(--primary-color);\n color: #fff;\n border: none;\n border-radius: 50%;\n width: 36px;\n height: 36px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 1.2em;\n box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);\n transition: opacity 0.2s;\n position: relative;\n\n &:hover {\n opacity: 0.9;\n }\n\n // Show fallback icons by default\n i {\n font-size: 1em;\n display: none;\n }\n\n .fallback-icon {\n font-size: 1em;\n display: block;\n }\n }\n\n .feature-btn {\n background: var(--primary-color);\n color: var(--accent-color);\n border: none;\n border-radius: 50%;\n width: 36px;\n height: 36px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 1.2em;\n position: relative;\n\n // Show fallback icons by default\n i {\n font-size: 1em;\n display: none;\n }\n\n .fallback-icon {\n font-size: 1em;\n display: block;\n }\n }\n}\n\n.tabs {\n background: #f8f8f8;\n border-top: 1.5px solid #e0e7ff;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: space-around;\n height: 48px;\n flex-shrink: 0;\n\n .tab {\n flex: 1;\n text-align: center;\n padding: 7px 0;\n color: var(--primary-color);\n font-weight: 600;\n cursor: pointer;\n transition: background 0.2s;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 2px;\n\n &:hover {\n background: rgba(0, 0, 0, 0.05);\n }\n\n // Show fallback icons by default\n i {\n font-size: 1.1em;\n display: none;\n }\n\n .fallback-icon {\n font-size: 1.1em;\n display: block;\n }\n\n span:not(.fallback-icon) {\n font-size: 0.91em;\n }\n }\n}\n\n.powered-by {\n text-align: center;\n font-size: 0.95em;\n color: #aaa;\n padding: 7px 0 3px 0;\n background: #fff;\n border-top: 1px solid #f3f3f3;\n flex-shrink: 0;\n\n img {\n height: 18px;\n vertical-align: middle;\n margin-right: 6px;\n opacity: 0.85;\n object-fit: contain;\n }\n\n span {\n font-weight: 500;\n }\n}\n\n.minimize-icon {\n display: none;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n font-size: 24px;\n color: white;\n background: var(--primary-color);\n border-radius: 50%;\n cursor: pointer;\n}\n\n@keyframes typing {\n 0%, 60%, 100% {\n transform: translateY(0);\n }\n 30% {\n transform: translateY(-10px);\n }\n}\n\n// Mobile responsiveness\n@media (max-width: 768px) {\n .chat-widget {\n width: 100% !important;\n height: 100% !important;\n top: 0 !important;\n left: 0 !important;\n right: 0 !important;\n bottom: 0 !important;\n border-radius: 0 !important;\n\n .messages-container {\n height: calc(100vh - 200px);\n }\n }\n}","import { Component, Prop, State, Element, Event, EventEmitter, Watch, h, Host } from '@stencil/core';\n\nexport interface ChatMessage {\n id: string;\n text: string;\n isUser: boolean;\n timestamp: Date;\n}\n\nexport type WidgetPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\n\nexport interface ChatWidgetConfig {\n // Agent Information\n agentName?: string;\n agentRole?: string;\n agentAvatar?: string;\n \n // Appearance\n primaryColor?: string;\n accentColor?: string;\n fontFamily?: string;\n width?: number;\n height?: number;\n \n // Messages\n welcomeMessage?: string;\n thankYouMessage?: string;\n placeholderText?: string;\n \n // Features\n showMinimizeButton?: boolean;\n enableFileUpload?: boolean;\n enableSpeech?: boolean;\n showTimestamps?: boolean;\n collapsed?: boolean;\n \n // Position\n position?: WidgetPosition;\n \n // Branding\n showPoweredBy?: boolean;\n poweredByLogo?: string;\n poweredByText?: string;\n poweredByBrand?: string;\n poweredByColor?: string;\n \n // API\n apiEndpoint?: string;\n apiKey?: string;\n}\n\n@Component({\n tag: 'nerd-chat-widget',\n styleUrl: 'chat-widget.scss',\n shadow: true,\n})\nexport class ChatWidget {\n @Element() el: HTMLElement;\n\n // Configuration props\n @Prop() config: ChatWidgetConfig = {};\n @Prop() agentName: string = 'Support Agent';\n @Prop() agentRole: string = 'Customer Support';\n @Prop() agentAvatar: string = 'https://ui-avatars.com/api/?name=Agent&background=2d3e50&color=ffffff&size=44';\n @Prop() primaryColor: string = '#2d3e50';\n @Prop() accentColor: string = '#4e8cff';\n @Prop() welcomeMessage: string = 'Hi! How can I help you today?';\n @Prop() position: WidgetPosition = 'bottom-right';\n @Prop() showMinimizeButton: boolean = true;\n @Prop() enableFileUpload: boolean = false;\n @Prop() enableSpeech: boolean = false;\n @Prop() showTimestamps: boolean = true;\n @Prop() apiEndpoint: string = '';\n @Prop() apiKey: string = '';\n @Prop() placeholderText: string = 'Type your message...';\n @Prop() thankYouMessage: string = 'Thank you for chatting with us!';\n @Prop() showPoweredBy: boolean = true;\n @Prop() poweredByLogo: string = 'https://innovationincubator.com/wp-content/uploads/2023/05/Innovation-Incubator-logo.png';\n @Prop() poweredByText: string = 'Powered by';\n @Prop() poweredByBrand: string = 'NerdAgent';\n @Prop() poweredByColor: string = '#4e8cff';\n @Prop() width: number = 350;\n @Prop() height: number = 500;\n @Prop() fontFamily: string = 'Segoe UI, Arial, sans-serif';\n\n // State\n @State() messages: ChatMessage[] = [];\n @State() isMinimized: boolean = false;\n @State() isTyping: boolean = false;\n @State() inputValue: string = '';\n @State() isChatOpen: boolean = true;\n @State() currentPosition: WidgetPosition = 'bottom-right';\n\n // Events\n @Event() messageSent: EventEmitter<{ message: string; widget: HTMLElement }>;\n @Event() widgetOpened: EventEmitter<{ widget: HTMLElement }>;\n @Event() widgetClosed: EventEmitter<{ widget: HTMLElement }>;\n\n private messageIdCounter = 0;\n\n componentDidLoad() {\n // Initialize position\n this.currentPosition = this.position;\n \n // Load Font Awesome if not already loaded\n this.loadFontAwesome();\n \n // Add welcome message\n if (this.getConfig().welcomeMessage) {\n setTimeout(() => {\n this.addMessage(this.getConfig().welcomeMessage, false);\n }, 500);\n }\n }\n\n @Watch('config')\n configChanged() {\n // React to config changes - Stencil automatically re-renders when @Prop changes\n // No need to manually trigger re-render\n }\n\n @Watch('position')\n positionChanged() {\n // Force re-render when position changes\n console.log('Position changed to:', this.position);\n this.currentPosition = this.position;\n \n // Debug: Check what styles are applied\n setTimeout(() => {\n const widgetEl = this.el.shadowRoot.querySelector('.chat-widget') as HTMLElement;\n if (widgetEl) {\n console.log('Widget classes:', widgetEl.className);\n console.log('Widget inline styles:', widgetEl.style.cssText);\n console.log('Widget computed styles:', {\n position: window.getComputedStyle(widgetEl).position,\n top: window.getComputedStyle(widgetEl).top,\n right: window.getComputedStyle(widgetEl).right,\n bottom: window.getComputedStyle(widgetEl).bottom,\n left: window.getComputedStyle(widgetEl).left\n });\n }\n }, 100);\n }\n\n private getConfig(): ChatWidgetConfig {\n return {\n agentName: this.agentName,\n agentRole: this.agentRole,\n agentAvatar: this.agentAvatar,\n primaryColor: this.primaryColor,\n accentColor: this.accentColor,\n welcomeMessage: this.welcomeMessage,\n position: this.position,\n showMinimizeButton: this.showMinimizeButton,\n enableFileUpload: this.enableFileUpload,\n enableSpeech: this.enableSpeech,\n showTimestamps: this.showTimestamps,\n apiEndpoint: this.apiEndpoint,\n apiKey: this.apiKey,\n placeholderText: this.placeholderText,\n thankYouMessage: this.thankYouMessage,\n showPoweredBy: this.showPoweredBy,\n poweredByLogo: this.poweredByLogo,\n poweredByText: this.poweredByText,\n poweredByBrand: this.poweredByBrand,\n poweredByColor: this.poweredByColor,\n width: this.width,\n height: this.height,\n fontFamily: this.fontFamily,\n ...this.config\n };\n }\n\n private loadFontAwesome() {\n if (!document.getElementById('fa-cdn-stencil')) {\n const link = document.createElement('link');\n link.id = 'fa-cdn-stencil';\n link.rel = 'stylesheet';\n link.href = 'https://use.fontawesome.com/releases/v6.4.2/css/all.css';\n link.crossOrigin = 'anonymous';\n document.head.appendChild(link);\n \n console.log('Loading FontAwesome...');\n } else {\n console.log('FontAwesome already loaded');\n }\n }\n\n private addMessage(text: string, isUser: boolean = false) {\n const message: ChatMessage = {\n id: `msg-${++this.messageIdCounter}`,\n text,\n isUser,\n timestamp: new Date()\n };\n \n this.messages = [...this.messages, message];\n }\n\n private async sendMessage() {\n const text = this.inputValue.trim();\n if (!text) return;\n\n this.addMessage(text, true);\n this.inputValue = '';\n\n // Emit event\n this.messageSent.emit({ message: text, widget: this.el });\n\n // Handle API or simulate response\n const config = this.getConfig();\n if (config.apiEndpoint) {\n await this.sendToAPI(text);\n } else {\n this.simulateResponse();\n }\n }\n\n private async sendToAPI(message: string) {\n const config = this.getConfig();\n this.isTyping = true;\n\n try {\n const response = await fetch(config.apiEndpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(config.apiKey && { 'Authorization': `Bearer ${config.apiKey}` })\n },\n body: JSON.stringify({\n message,\n timestamp: new Date().toISOString(),\n sessionId: this.getSessionId()\n })\n });\n\n const data = await response.json();\n this.isTyping = false;\n\n if (data.response) {\n this.addMessage(data.response, false);\n }\n } catch (error) {\n this.isTyping = false;\n this.addMessage('Sorry, I encountered an error. Please try again.', false);\n }\n }\n\n private simulateResponse() {\n const responses = [\n \"Thanks for your message! How can I help you further?\",\n \"I understand. Let me assist you with that.\",\n \"That's a great question! Let me help you.\",\n \"I'm here to help! Could you provide more details?\"\n ];\n\n this.isTyping = true;\n\n setTimeout(() => {\n this.isTyping = false;\n const response = responses[Math.floor(Math.random() * responses.length)];\n this.addMessage(response, false);\n }, 1500);\n }\n\n private toggleMinimize() {\n this.isMinimized = !this.isMinimized;\n \n if (this.isMinimized) {\n this.widgetClosed.emit({ widget: this.el });\n } else {\n this.widgetOpened.emit({ widget: this.el });\n }\n }\n\n private closeWidget() {\n this.isChatOpen = false;\n this.widgetClosed.emit({ widget: this.el });\n }\n\n private openWidget() {\n this.isChatOpen = true;\n this.isMinimized = false;\n this.widgetOpened.emit({ widget: this.el });\n }\n\n private handleKeyPress(event: KeyboardEvent) {\n if (event.key === 'Enter') {\n this.sendMessage();\n }\n }\n\n private handleInputChange(event: Event) {\n const target = event.target as HTMLInputElement;\n this.inputValue = target.value;\n }\n\n private getSessionId(): string {\n let sessionId = localStorage.getItem('nerd-chat-session');\n if (!sessionId) {\n sessionId = 'session-' + Math.random().toString(36).substr(2, 9);\n localStorage.setItem('nerd-chat-session', sessionId);\n }\n return sessionId;\n }\n\n private formatTime(date: Date): string {\n return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });\n }\n\n\n render() {\n const config = this.getConfig();\n console.log('Rendering with position:', this.currentPosition);\n \n // Get position styles directly\n const getPositionStyles = () => {\n switch (this.currentPosition) {\n case 'bottom-left':\n return { bottom: '20px', left: '20px', top: 'auto', right: 'auto' };\n case 'top-right':\n return { top: '20px', right: '20px', bottom: 'auto', left: 'auto' };\n case 'top-left':\n return { top: '20px', left: '20px', bottom: 'auto', right: 'auto' };\n case 'bottom-right':\n default:\n return { bottom: '20px', right: '20px', top: 'auto', left: 'auto' };\n }\n };\n \n const widgetClasses = {\n 'chat-widget': true,\n 'minimized': this.isMinimized,\n 'hidden': !this.isChatOpen\n };\n\n return (\n <Host>\n <div \n class={widgetClasses}\n style={{\n '--primary-color': config.primaryColor || '#2d3e50',\n '--accent-color': config.accentColor || '#4e8cff',\n '--widget-width': `${config.width || 350}px`,\n '--widget-height': `${config.height || 500}px`,\n '--font-family': config.fontFamily || 'Segoe UI, Arial, sans-serif',\n ...getPositionStyles()\n }}\n >\n {/* Header */}\n <div class=\"chat-header\">\n <div class=\"agent-info\">\n <img src={config.agentAvatar} alt=\"Agent\" class=\"agent-avatar\" />\n <div class=\"agent-details\">\n <h4>{config.agentName}</h4>\n <p>{config.agentRole}</p>\n </div>\n </div>\n <div class=\"controls\">\n {config.showMinimizeButton && (\n <button \n class=\"control-btn minimize-btn\" \n onClick={() => this.toggleMinimize()}\n title={this.isMinimized ? 'Maximize' : 'Minimize'}\n >\n {this.isMinimized ? '🔼' : '🔽'}\n </button>\n )}\n <button \n class=\"control-btn close-btn\" \n onClick={() => this.closeWidget()}\n title=\"Close\"\n >\n ×\n </button>\n </div>\n </div>\n\n {/* Messages */}\n <div class=\"messages-container\">\n {this.messages.map(message => (\n <div key={message.id} class={`message ${message.isUser ? 'user' : 'agent'}`}>\n <img \n src={message.isUser ? 'https://ui-avatars.com/api/?name=User&background=4e8cff&color=ffffff&size=28' : config.agentAvatar} \n alt={message.isUser ? 'User' : 'Agent'} \n class=\"message-avatar\" \n />\n <div class=\"message-content\">\n <div class=\"message-text\">{message.text}</div>\n {config.showTimestamps && (\n <div class=\"message-time\">{this.formatTime(message.timestamp)}</div>\n )}\n </div>\n </div>\n ))}\n \n {this.isTyping && (\n <div class=\"typing-indicator\">\n <span>{config.agentName} is typing</span>\n <div class=\"typing-dots\">\n <div class=\"dot\"></div>\n <div class=\"dot\"></div>\n <div class=\"dot\"></div>\n </div>\n </div>\n )}\n </div>\n\n {/* Input */}\n <div class=\"input-container\">\n <input\n type=\"text\"\n class=\"message-input\"\n placeholder={config.placeholderText || 'Type your message...'}\n value={this.inputValue}\n onInput={(e) => this.handleInputChange(e)}\n onKeyPress={(e) => this.handleKeyPress(e)}\n />\n <button class=\"send-btn\" onClick={() => this.sendMessage()}>\n <i class=\"fas fa-paper-plane\"></i>\n <span class=\"fallback-icon\">➤</span>\n </button>\n {config.enableFileUpload && (\n <button class=\"feature-btn file-upload\">\n <i class=\"fas fa-paperclip\"></i>\n <span class=\"fallback-icon\">📎</span>\n </button>\n )}\n {config.enableSpeech && (\n <button class=\"feature-btn speech\">\n <i class=\"fas fa-microphone\"></i>\n <span class=\"fallback-icon\">🎤</span>\n </button>\n )}\n </div>\n\n {/* Tabs */}\n <div class=\"tabs\">\n <div class=\"tab active\">\n <i class=\"fas fa-comment-dots\"></i>\n <span>Chat</span>\n </div>\n <div class=\"tab\">\n <i class=\"fas fa-microphone\"></i>\n <span>Voice</span>\n </div>\n <div class=\"tab\">\n <i class=\"fas fa-clock\"></i>\n <span>History</span>\n </div>\n </div>\n\n {/* Powered By */}\n {config.showPoweredBy && (\n <div class=\"powered-by\">\n <img src={config.poweredByLogo} alt=\"Powered By Logo\" />\n {config.poweredByText} <span style={{color: config.poweredByColor}}>{config.poweredByBrand}</span>\n </div>\n )}\n\n {/* Minimize Icon (shown when minimized) */}\n <div class=\"minimize-icon\" onClick={() => this.isChatOpen ? this.toggleMinimize() : this.openWidget()}>\n 💬\n </div>\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
|
+
export interface ChatMessage {
|
|
3
|
+
id: string;
|
|
4
|
+
text: string;
|
|
5
|
+
isUser: boolean;
|
|
6
|
+
timestamp: Date;
|
|
7
|
+
}
|
|
8
|
+
export type WidgetPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
9
|
+
export interface ChatWidgetConfig {
|
|
10
|
+
agentName?: string;
|
|
11
|
+
agentRole?: string;
|
|
12
|
+
agentAvatar?: string;
|
|
13
|
+
primaryColor?: string;
|
|
14
|
+
accentColor?: string;
|
|
15
|
+
fontFamily?: string;
|
|
16
|
+
width?: number;
|
|
17
|
+
height?: number;
|
|
18
|
+
welcomeMessage?: string;
|
|
19
|
+
thankYouMessage?: string;
|
|
20
|
+
placeholderText?: string;
|
|
21
|
+
showMinimizeButton?: boolean;
|
|
22
|
+
enableFileUpload?: boolean;
|
|
23
|
+
enableSpeech?: boolean;
|
|
24
|
+
showTimestamps?: boolean;
|
|
25
|
+
collapsed?: boolean;
|
|
26
|
+
position?: WidgetPosition;
|
|
27
|
+
showPoweredBy?: boolean;
|
|
28
|
+
poweredByLogo?: string;
|
|
29
|
+
poweredByText?: string;
|
|
30
|
+
poweredByBrand?: string;
|
|
31
|
+
poweredByColor?: string;
|
|
32
|
+
apiEndpoint?: string;
|
|
33
|
+
apiKey?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare class ChatWidget {
|
|
36
|
+
el: HTMLElement;
|
|
37
|
+
config: ChatWidgetConfig;
|
|
38
|
+
agentName: string;
|
|
39
|
+
agentRole: string;
|
|
40
|
+
agentAvatar: string;
|
|
41
|
+
primaryColor: string;
|
|
42
|
+
accentColor: string;
|
|
43
|
+
welcomeMessage: string;
|
|
44
|
+
position: WidgetPosition;
|
|
45
|
+
showMinimizeButton: boolean;
|
|
46
|
+
enableFileUpload: boolean;
|
|
47
|
+
enableSpeech: boolean;
|
|
48
|
+
showTimestamps: boolean;
|
|
49
|
+
apiEndpoint: string;
|
|
50
|
+
apiKey: string;
|
|
51
|
+
placeholderText: string;
|
|
52
|
+
thankYouMessage: string;
|
|
53
|
+
showPoweredBy: boolean;
|
|
54
|
+
poweredByLogo: string;
|
|
55
|
+
poweredByText: string;
|
|
56
|
+
poweredByBrand: string;
|
|
57
|
+
poweredByColor: string;
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
fontFamily: string;
|
|
61
|
+
messages: ChatMessage[];
|
|
62
|
+
isMinimized: boolean;
|
|
63
|
+
isTyping: boolean;
|
|
64
|
+
inputValue: string;
|
|
65
|
+
isChatOpen: boolean;
|
|
66
|
+
currentPosition: WidgetPosition;
|
|
67
|
+
messageSent: EventEmitter<{
|
|
68
|
+
message: string;
|
|
69
|
+
widget: HTMLElement;
|
|
70
|
+
}>;
|
|
71
|
+
widgetOpened: EventEmitter<{
|
|
72
|
+
widget: HTMLElement;
|
|
73
|
+
}>;
|
|
74
|
+
widgetClosed: EventEmitter<{
|
|
75
|
+
widget: HTMLElement;
|
|
76
|
+
}>;
|
|
77
|
+
private messageIdCounter;
|
|
78
|
+
componentDidLoad(): void;
|
|
79
|
+
configChanged(): void;
|
|
80
|
+
positionChanged(): void;
|
|
81
|
+
private getConfig;
|
|
82
|
+
private loadFontAwesome;
|
|
83
|
+
private addMessage;
|
|
84
|
+
private sendMessage;
|
|
85
|
+
private sendToAPI;
|
|
86
|
+
private simulateResponse;
|
|
87
|
+
private toggleMinimize;
|
|
88
|
+
private closeWidget;
|
|
89
|
+
private openWidget;
|
|
90
|
+
private handleKeyPress;
|
|
91
|
+
private handleInputChange;
|
|
92
|
+
private getSessionId;
|
|
93
|
+
private formatTime;
|
|
94
|
+
render(): any;
|
|
95
|
+
}
|