@a.izzuddin/ai-chat 0.1.1 → 0.2.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 +16 -16
- package/README.npm.md +20 -20
- package/custom-elements.json +38 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +123 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
A **framework-agnostic** AI chat web component built with Lit and TypeScript. Works seamlessly with React, Vue, Svelte, Angular, and vanilla JavaScript.
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@a.izzuddin/ai-chat)
|
|
6
|
+
[](https://www.npmjs.com/package/@a.izzuddin/ai-chat)
|
|
7
7
|
|
|
8
8
|
## ✨ Features
|
|
9
9
|
|
|
@@ -19,11 +19,11 @@ A **framework-agnostic** AI chat web component built with Lit and TypeScript. Wo
|
|
|
19
19
|
## 📦 Installation
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npm install @
|
|
22
|
+
npm install @a.izzuddin/ai-chat
|
|
23
23
|
# or
|
|
24
|
-
yarn add @
|
|
24
|
+
yarn add @a.izzuddin/ai-chat
|
|
25
25
|
# or
|
|
26
|
-
pnpm add @
|
|
26
|
+
pnpm add @a.izzuddin/ai-chat
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## 🚀 Quick Start
|
|
@@ -35,7 +35,7 @@ pnpm add @yourusername/ai-chat
|
|
|
35
35
|
<html>
|
|
36
36
|
<body>
|
|
37
37
|
<script type="module">
|
|
38
|
-
import '@
|
|
38
|
+
import '@a.izzuddin/ai-chat';
|
|
39
39
|
</script>
|
|
40
40
|
|
|
41
41
|
<ai-chat
|
|
@@ -50,7 +50,7 @@ pnpm add @yourusername/ai-chat
|
|
|
50
50
|
### React
|
|
51
51
|
|
|
52
52
|
```tsx
|
|
53
|
-
import '@
|
|
53
|
+
import '@a.izzuddin/ai-chat';
|
|
54
54
|
|
|
55
55
|
function App() {
|
|
56
56
|
return (
|
|
@@ -75,7 +75,7 @@ function App() {
|
|
|
75
75
|
</template>
|
|
76
76
|
|
|
77
77
|
<script setup>
|
|
78
|
-
import '@
|
|
78
|
+
import '@a.izzuddin/ai-chat';
|
|
79
79
|
const apiUrl = import.meta.env.VITE_API_URL;
|
|
80
80
|
</script>
|
|
81
81
|
```
|
|
@@ -84,7 +84,7 @@ const apiUrl = import.meta.env.VITE_API_URL;
|
|
|
84
84
|
|
|
85
85
|
```svelte
|
|
86
86
|
<script>
|
|
87
|
-
import '@
|
|
87
|
+
import '@a.izzuddin/ai-chat';
|
|
88
88
|
export let apiUrl;
|
|
89
89
|
</script>
|
|
90
90
|
|
|
@@ -99,7 +99,7 @@ const apiUrl = import.meta.env.VITE_API_URL;
|
|
|
99
99
|
|
|
100
100
|
```typescript
|
|
101
101
|
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
102
|
-
import '@
|
|
102
|
+
import '@a.izzuddin/ai-chat';
|
|
103
103
|
|
|
104
104
|
@Component({
|
|
105
105
|
selector: 'app-root',
|
|
@@ -163,7 +163,7 @@ chat.addEventListener('error', (event) => {
|
|
|
163
163
|
### TypeScript Types
|
|
164
164
|
|
|
165
165
|
```typescript
|
|
166
|
-
import type { Message } from '@
|
|
166
|
+
import type { Message } from '@a.izzuddin/ai-chat';
|
|
167
167
|
|
|
168
168
|
interface Message {
|
|
169
169
|
id: string;
|
|
@@ -253,13 +253,13 @@ If you were using the React-only version:
|
|
|
253
253
|
|
|
254
254
|
**Before:**
|
|
255
255
|
```tsx
|
|
256
|
-
import { AIChat } from '@
|
|
256
|
+
import { AIChat } from '@a.izzuddin/ai-chat';
|
|
257
257
|
<AIChat apiUrl="..." />
|
|
258
258
|
```
|
|
259
259
|
|
|
260
260
|
**After:**
|
|
261
261
|
```tsx
|
|
262
|
-
import '@
|
|
262
|
+
import '@a.izzuddin/ai-chat';
|
|
263
263
|
<ai-chat api-url="..." />
|
|
264
264
|
```
|
|
265
265
|
|
|
@@ -278,10 +278,10 @@ MIT © [Your Name]
|
|
|
278
278
|
|
|
279
279
|
## 🔗 Links
|
|
280
280
|
|
|
281
|
-
- [Documentation](https://github.com/
|
|
281
|
+
- [Documentation](https://github.com/a.izzuddin/ai-chat#readme)
|
|
282
282
|
- [Examples](./examples)
|
|
283
|
-
- [Issue Tracker](https://github.com/
|
|
284
|
-
- [npm Package](https://www.npmjs.com/package/@
|
|
283
|
+
- [Issue Tracker](https://github.com/a.izzuddin/ai-chat/issues)
|
|
284
|
+
- [npm Package](https://www.npmjs.com/package/@a.izzuddin/ai-chat)
|
|
285
285
|
|
|
286
286
|
## ⭐ Similar Projects
|
|
287
287
|
|
package/README.npm.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @a.izzuddin/ai-chat
|
|
2
2
|
|
|
3
3
|
A beautiful, configurable AI chat component for React applications. Built with Radix UI, Tailwind CSS, and TypeScript.
|
|
4
4
|
|
|
@@ -14,11 +14,11 @@ A beautiful, configurable AI chat component for React applications. Built with R
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install @
|
|
17
|
+
npm install @a.izzuddin/ai-chat
|
|
18
18
|
# or
|
|
19
|
-
yarn add @
|
|
19
|
+
yarn add @a.izzuddin/ai-chat
|
|
20
20
|
# or
|
|
21
|
-
pnpm add @
|
|
21
|
+
pnpm add @a.izzuddin/ai-chat
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
### Peer Dependencies
|
|
@@ -32,8 +32,8 @@ npm install react react-dom
|
|
|
32
32
|
## Quick Start
|
|
33
33
|
|
|
34
34
|
```tsx
|
|
35
|
-
import { AIChat } from "@
|
|
36
|
-
import "@
|
|
35
|
+
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
36
|
+
import "@a.izzuddin/ai-chat/styles";
|
|
37
37
|
|
|
38
38
|
function App() {
|
|
39
39
|
return (
|
|
@@ -57,7 +57,7 @@ module.exports = {
|
|
|
57
57
|
"./app/**/*.{js,ts,jsx,tsx}",
|
|
58
58
|
"./components/**/*.{js,ts,jsx,tsx}",
|
|
59
59
|
// Add this line:
|
|
60
|
-
"./node_modules/@
|
|
60
|
+
"./node_modules/@a.izzuddin/ai-chat/**/*.{js,ts,jsx,tsx}",
|
|
61
61
|
],
|
|
62
62
|
// ... rest of your config
|
|
63
63
|
};
|
|
@@ -67,7 +67,7 @@ Or if using Tailwind v4, add to your CSS:
|
|
|
67
67
|
|
|
68
68
|
```css
|
|
69
69
|
@import "tailwindcss";
|
|
70
|
-
@import "@
|
|
70
|
+
@import "@a.izzuddin/ai-chat/styles";
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
## API Requirements
|
|
@@ -174,7 +174,7 @@ function ChatPage() {
|
|
|
174
174
|
Full TypeScript support is included. Import types as needed:
|
|
175
175
|
|
|
176
176
|
```tsx
|
|
177
|
-
import type { Message, AIChatProps } from "@
|
|
177
|
+
import type { Message, AIChatProps } from "@a.izzuddin/ai-chat";
|
|
178
178
|
|
|
179
179
|
const customMessage: Message = {
|
|
180
180
|
id: "123",
|
|
@@ -216,8 +216,8 @@ The component uses Tailwind CSS with custom theme variables. You can customize t
|
|
|
216
216
|
```tsx
|
|
217
217
|
"use client";
|
|
218
218
|
|
|
219
|
-
import { AIChat } from "@
|
|
220
|
-
import "@
|
|
219
|
+
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
220
|
+
import "@a.izzuddin/ai-chat/styles";
|
|
221
221
|
|
|
222
222
|
export default function ChatPage() {
|
|
223
223
|
return <AIChat apiUrl={process.env.NEXT_PUBLIC_API_URL!} />;
|
|
@@ -227,8 +227,8 @@ export default function ChatPage() {
|
|
|
227
227
|
### Next.js (Pages Router)
|
|
228
228
|
|
|
229
229
|
```tsx
|
|
230
|
-
import { AIChat } from "@
|
|
231
|
-
import "@
|
|
230
|
+
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
231
|
+
import "@a.izzuddin/ai-chat/styles";
|
|
232
232
|
|
|
233
233
|
export default function ChatPage() {
|
|
234
234
|
return <AIChat apiUrl={process.env.NEXT_PUBLIC_API_URL!} />;
|
|
@@ -238,8 +238,8 @@ export default function ChatPage() {
|
|
|
238
238
|
### Vite + React
|
|
239
239
|
|
|
240
240
|
```tsx
|
|
241
|
-
import { AIChat } from "@
|
|
242
|
-
import "@
|
|
241
|
+
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
242
|
+
import "@a.izzuddin/ai-chat/styles";
|
|
243
243
|
|
|
244
244
|
function App() {
|
|
245
245
|
return <AIChat apiUrl={import.meta.env.VITE_API_URL} />;
|
|
@@ -249,8 +249,8 @@ function App() {
|
|
|
249
249
|
### Create React App
|
|
250
250
|
|
|
251
251
|
```tsx
|
|
252
|
-
import { AIChat } from "@
|
|
253
|
-
import "@
|
|
252
|
+
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
253
|
+
import "@a.izzuddin/ai-chat/styles";
|
|
254
254
|
|
|
255
255
|
function App() {
|
|
256
256
|
return <AIChat apiUrl={process.env.REACT_APP_API_URL} />;
|
|
@@ -288,6 +288,6 @@ MIT © [Your Name]
|
|
|
288
288
|
|
|
289
289
|
## Support
|
|
290
290
|
|
|
291
|
-
- 📖 [Documentation](https://github.com/
|
|
292
|
-
- 🐛 [Issue Tracker](https://github.com/
|
|
293
|
-
- 💬 [Discussions](https://github.com/
|
|
291
|
+
- 📖 [Documentation](https://github.com/a.izzuddin/ai-chat#readme)
|
|
292
|
+
- 🐛 [Issue Tracker](https://github.com/a.izzuddin/ai-chat/issues)
|
|
293
|
+
- 💬 [Discussions](https://github.com/a.izzuddin/ai-chat/discussions)
|
package/custom-elements.json
CHANGED
|
@@ -528,6 +528,17 @@
|
|
|
528
528
|
"default": "'light'",
|
|
529
529
|
"attribute": "theme"
|
|
530
530
|
},
|
|
531
|
+
{
|
|
532
|
+
"kind": "field",
|
|
533
|
+
"name": "mode",
|
|
534
|
+
"privacy": "public",
|
|
535
|
+
"type": {
|
|
536
|
+
"text": "'fullscreen' | 'widget'"
|
|
537
|
+
},
|
|
538
|
+
"default": "'fullscreen'",
|
|
539
|
+
"attribute": "mode",
|
|
540
|
+
"reflects": true
|
|
541
|
+
},
|
|
531
542
|
{
|
|
532
543
|
"kind": "field",
|
|
533
544
|
"name": "initialMessages",
|
|
@@ -565,6 +576,15 @@
|
|
|
565
576
|
"privacy": "private",
|
|
566
577
|
"default": "false"
|
|
567
578
|
},
|
|
579
|
+
{
|
|
580
|
+
"kind": "field",
|
|
581
|
+
"name": "isOpen",
|
|
582
|
+
"type": {
|
|
583
|
+
"text": "boolean"
|
|
584
|
+
},
|
|
585
|
+
"privacy": "private",
|
|
586
|
+
"default": "false"
|
|
587
|
+
},
|
|
568
588
|
{
|
|
569
589
|
"kind": "field",
|
|
570
590
|
"name": "messagesEndRef",
|
|
@@ -573,6 +593,11 @@
|
|
|
573
593
|
},
|
|
574
594
|
"privacy": "private"
|
|
575
595
|
},
|
|
596
|
+
{
|
|
597
|
+
"kind": "method",
|
|
598
|
+
"name": "toggleWidget",
|
|
599
|
+
"privacy": "private"
|
|
600
|
+
},
|
|
576
601
|
{
|
|
577
602
|
"kind": "method",
|
|
578
603
|
"name": "scrollToBottom",
|
|
@@ -603,6 +628,11 @@
|
|
|
603
628
|
}
|
|
604
629
|
}
|
|
605
630
|
]
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
"kind": "method",
|
|
634
|
+
"name": "renderChatUI",
|
|
635
|
+
"privacy": "private"
|
|
606
636
|
}
|
|
607
637
|
],
|
|
608
638
|
"events": [
|
|
@@ -661,6 +691,14 @@
|
|
|
661
691
|
"default": "'light'",
|
|
662
692
|
"fieldName": "theme"
|
|
663
693
|
},
|
|
694
|
+
{
|
|
695
|
+
"name": "mode",
|
|
696
|
+
"type": {
|
|
697
|
+
"text": "'fullscreen' | 'widget'"
|
|
698
|
+
},
|
|
699
|
+
"default": "'fullscreen'",
|
|
700
|
+
"fieldName": "mode"
|
|
701
|
+
},
|
|
664
702
|
{
|
|
665
703
|
"name": "initialMessages",
|
|
666
704
|
"type": {
|
package/dist/index.d.mts
CHANGED
|
@@ -29,10 +29,12 @@ declare class AIChat extends LitElement {
|
|
|
29
29
|
sessionId: string;
|
|
30
30
|
chatTitle: string;
|
|
31
31
|
theme: 'light' | 'dark';
|
|
32
|
+
mode: 'fullscreen' | 'widget';
|
|
32
33
|
initialMessages: Message[];
|
|
33
34
|
private messages;
|
|
34
35
|
private input;
|
|
35
36
|
private isLoading;
|
|
37
|
+
private isOpen;
|
|
36
38
|
private messagesEndRef?;
|
|
37
39
|
static properties: {
|
|
38
40
|
apiUrl: {
|
|
@@ -50,16 +52,22 @@ declare class AIChat extends LitElement {
|
|
|
50
52
|
theme: {
|
|
51
53
|
type: StringConstructor;
|
|
52
54
|
};
|
|
55
|
+
mode: {
|
|
56
|
+
type: StringConstructor;
|
|
57
|
+
reflect: boolean;
|
|
58
|
+
};
|
|
53
59
|
initialMessages: {
|
|
54
60
|
type: ArrayConstructor;
|
|
55
61
|
};
|
|
56
62
|
};
|
|
57
63
|
constructor();
|
|
64
|
+
private toggleWidget;
|
|
58
65
|
connectedCallback(): void;
|
|
59
66
|
updated(changedProperties: PropertyValues): void;
|
|
60
67
|
private scrollToBottom;
|
|
61
68
|
private handleInput;
|
|
62
69
|
private handleSubmit;
|
|
70
|
+
private renderChatUI;
|
|
63
71
|
render(): lit_html.TemplateResult<1>;
|
|
64
72
|
}
|
|
65
73
|
declare global {
|
package/dist/index.d.ts
CHANGED
|
@@ -29,10 +29,12 @@ declare class AIChat extends LitElement {
|
|
|
29
29
|
sessionId: string;
|
|
30
30
|
chatTitle: string;
|
|
31
31
|
theme: 'light' | 'dark';
|
|
32
|
+
mode: 'fullscreen' | 'widget';
|
|
32
33
|
initialMessages: Message[];
|
|
33
34
|
private messages;
|
|
34
35
|
private input;
|
|
35
36
|
private isLoading;
|
|
37
|
+
private isOpen;
|
|
36
38
|
private messagesEndRef?;
|
|
37
39
|
static properties: {
|
|
38
40
|
apiUrl: {
|
|
@@ -50,16 +52,22 @@ declare class AIChat extends LitElement {
|
|
|
50
52
|
theme: {
|
|
51
53
|
type: StringConstructor;
|
|
52
54
|
};
|
|
55
|
+
mode: {
|
|
56
|
+
type: StringConstructor;
|
|
57
|
+
reflect: boolean;
|
|
58
|
+
};
|
|
53
59
|
initialMessages: {
|
|
54
60
|
type: ArrayConstructor;
|
|
55
61
|
};
|
|
56
62
|
};
|
|
57
63
|
constructor();
|
|
64
|
+
private toggleWidget;
|
|
58
65
|
connectedCallback(): void;
|
|
59
66
|
updated(changedProperties: PropertyValues): void;
|
|
60
67
|
private scrollToBottom;
|
|
61
68
|
private handleInput;
|
|
62
69
|
private handleSubmit;
|
|
70
|
+
private renderChatUI;
|
|
63
71
|
render(): lit_html.TemplateResult<1>;
|
|
64
72
|
}
|
|
65
73
|
declare global {
|
package/dist/index.js
CHANGED
|
@@ -22,10 +22,15 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
22
22
|
this.sessionId = "default-session";
|
|
23
23
|
this.chatTitle = "My AI Agent";
|
|
24
24
|
this.theme = "light";
|
|
25
|
+
this.mode = "fullscreen";
|
|
25
26
|
this.initialMessages = [];
|
|
26
27
|
this.messages = [];
|
|
27
28
|
this.input = "";
|
|
28
29
|
this.isLoading = false;
|
|
30
|
+
this.isOpen = false;
|
|
31
|
+
}
|
|
32
|
+
toggleWidget() {
|
|
33
|
+
this.isOpen = !this.isOpen;
|
|
29
34
|
}
|
|
30
35
|
connectedCallback() {
|
|
31
36
|
super.connectedCallback();
|
|
@@ -108,7 +113,7 @@ Please check your API endpoint configuration.`
|
|
|
108
113
|
this.isLoading = false;
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
|
-
|
|
116
|
+
renderChatUI() {
|
|
112
117
|
return lit.html`
|
|
113
118
|
<!-- Header -->
|
|
114
119
|
<div class="header">
|
|
@@ -184,22 +189,132 @@ Please check your API endpoint configuration.`
|
|
|
184
189
|
</div>
|
|
185
190
|
`;
|
|
186
191
|
}
|
|
192
|
+
render() {
|
|
193
|
+
if (this.mode === "widget") {
|
|
194
|
+
return lit.html`
|
|
195
|
+
<div class="widget-container">
|
|
196
|
+
<!-- Chat Window -->
|
|
197
|
+
<div class=${classMap_js.classMap({ "widget-window": true, "open": this.isOpen })}>
|
|
198
|
+
${this.renderChatUI()}
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<!-- Toggle Button -->
|
|
202
|
+
<button
|
|
203
|
+
class="widget-button"
|
|
204
|
+
@click=${this.toggleWidget}
|
|
205
|
+
aria-label=${this.isOpen ? "Close chat" : "Open chat"}
|
|
206
|
+
>
|
|
207
|
+
${this.isOpen ? lit.html`
|
|
208
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
209
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
210
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
211
|
+
</svg>
|
|
212
|
+
` : lit.html`
|
|
213
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
214
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
215
|
+
</svg>
|
|
216
|
+
`}
|
|
217
|
+
</button>
|
|
218
|
+
</div>
|
|
219
|
+
`;
|
|
220
|
+
}
|
|
221
|
+
return this.renderChatUI();
|
|
222
|
+
}
|
|
187
223
|
};
|
|
188
224
|
exports.AIChat.styles = lit.css`
|
|
189
225
|
:host {
|
|
226
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
227
|
+
color: #09090b;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/* Fullscreen mode (default) */
|
|
231
|
+
:host([mode="fullscreen"]) {
|
|
190
232
|
display: flex;
|
|
191
233
|
flex-direction: column;
|
|
192
234
|
height: 100vh;
|
|
193
|
-
font-family: system-ui, -apple-system, sans-serif;
|
|
194
235
|
background: #fafafa;
|
|
195
|
-
color: #09090b;
|
|
196
236
|
}
|
|
197
237
|
|
|
198
|
-
:host([theme="dark"]) {
|
|
238
|
+
:host([mode="fullscreen"][theme="dark"]) {
|
|
199
239
|
background: #000;
|
|
200
240
|
color: #fafafa;
|
|
201
241
|
}
|
|
202
242
|
|
|
243
|
+
/* Widget mode */
|
|
244
|
+
:host([mode="widget"]) {
|
|
245
|
+
position: fixed;
|
|
246
|
+
bottom: 20px;
|
|
247
|
+
right: 20px;
|
|
248
|
+
z-index: 9999;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.widget-container {
|
|
252
|
+
position: relative;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.widget-button {
|
|
256
|
+
width: 60px;
|
|
257
|
+
height: 60px;
|
|
258
|
+
border-radius: 50%;
|
|
259
|
+
background: #2563eb;
|
|
260
|
+
border: none;
|
|
261
|
+
cursor: pointer;
|
|
262
|
+
display: flex;
|
|
263
|
+
align-items: center;
|
|
264
|
+
justify-content: center;
|
|
265
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
266
|
+
transition: transform 0.2s, box-shadow 0.2s;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.widget-button:hover {
|
|
270
|
+
transform: scale(1.05);
|
|
271
|
+
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.widget-button svg {
|
|
275
|
+
width: 28px;
|
|
276
|
+
height: 28px;
|
|
277
|
+
color: white;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.widget-window {
|
|
281
|
+
position: absolute;
|
|
282
|
+
bottom: 80px;
|
|
283
|
+
right: 0;
|
|
284
|
+
width: 380px;
|
|
285
|
+
height: 600px;
|
|
286
|
+
background: #fff;
|
|
287
|
+
border-radius: 12px;
|
|
288
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
|
289
|
+
display: flex;
|
|
290
|
+
flex-direction: column;
|
|
291
|
+
overflow: hidden;
|
|
292
|
+
opacity: 0;
|
|
293
|
+
transform: scale(0.9) translateY(20px);
|
|
294
|
+
pointer-events: none;
|
|
295
|
+
transition: opacity 0.2s, transform 0.2s;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.widget-window.open {
|
|
299
|
+
opacity: 1;
|
|
300
|
+
transform: scale(1) translateY(0);
|
|
301
|
+
pointer-events: all;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
:host([theme="dark"]) .widget-window {
|
|
305
|
+
background: #18181b;
|
|
306
|
+
color: #fafafa;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
@media (max-width: 480px) {
|
|
310
|
+
.widget-window {
|
|
311
|
+
width: calc(100vw - 40px);
|
|
312
|
+
height: calc(100vh - 100px);
|
|
313
|
+
bottom: 80px;
|
|
314
|
+
right: 0;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
203
318
|
.header {
|
|
204
319
|
border-bottom: 1px solid #e4e4e7;
|
|
205
320
|
background: #fff;
|
|
@@ -404,6 +519,7 @@ exports.AIChat.properties = {
|
|
|
404
519
|
sessionId: { type: String, attribute: "session-id" },
|
|
405
520
|
chatTitle: { type: String, attribute: "title" },
|
|
406
521
|
theme: { type: String },
|
|
522
|
+
mode: { type: String, reflect: true },
|
|
407
523
|
initialMessages: { type: Array }
|
|
408
524
|
};
|
|
409
525
|
__decorateClass([
|
|
@@ -415,6 +531,9 @@ __decorateClass([
|
|
|
415
531
|
__decorateClass([
|
|
416
532
|
decorators_js.state()
|
|
417
533
|
], exports.AIChat.prototype, "isLoading", 2);
|
|
534
|
+
__decorateClass([
|
|
535
|
+
decorators_js.state()
|
|
536
|
+
], exports.AIChat.prototype, "isOpen", 2);
|
|
418
537
|
exports.AIChat = __decorateClass([
|
|
419
538
|
decorators_js.customElement("ai-chat")
|
|
420
539
|
], exports.AIChat);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ai-chat.ts"],"names":["AIChat","LitElement","html","repeat","classMap","css","state","customElement"],"mappings":";;;;;;;;;;;;;;;;;AA4BaA,cAAA,GAAN,qBAAqBC,cAAA,CAAW;AAAA,EAiPrC,WAAA,GAAc;AACZ,IAAA,KAAA,EAAM;AACN,IAAA,IAAA,CAAK,MAAA,GAAS,EAAA;AACd,IAAA,IAAA,CAAK,SAAA,GAAY,iBAAA;AACjB,IAAA,IAAA,CAAK,SAAA,GAAY,aAAA;AACjB,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA;AACb,IAAA,IAAA,CAAK,kBAAkB,EAAC;AACxB,IAAA,IAAA,CAAK,WAAW,EAAC;AACjB,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAA;AACb,IAAA,IAAA,CAAK,SAAA,GAAY,KAAA;AAAA,EACnB;AAAA,EAEA,iBAAA,GAAoB;AAClB,IAAA,KAAA,CAAM,iBAAA,EAAkB;AACxB,IAAA,IAAI,IAAA,CAAK,eAAA,IAAmB,IAAA,CAAK,eAAA,CAAgB,SAAS,CAAA,EAAG;AAC3D,MAAA,IAAA,CAAK,QAAA,GAAW,CAAC,GAAG,IAAA,CAAK,eAAe,CAAA;AAAA,IAC1C;AAAA,EACF;AAAA,EAEA,QAAQ,iBAAA,EAAmC;AACzC,IAAA,KAAA,CAAM,QAAQ,iBAAiB,CAAA;AAC/B,IAAA,IAAI,iBAAA,CAAkB,GAAA,CAAI,UAAU,CAAA,EAAG;AACrC,MAAA,IAAA,CAAK,cAAA,EAAe;AAAA,IACtB;AAAA,EACF;AAAA,EAEQ,cAAA,GAAiB;AACvB,IAAA,qBAAA,CAAsB,MAAM;AAC1B,MAAA,IAAA,CAAK,cAAA,EAAgB,cAAA,CAAe,E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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA,CAAA;AADLL,cAAA,CAyOK,UAAA,GAAa;AAAA,EAC3B,MAAA,EAAQ,EAAE,IAAA,EAAM,MAAA,EAAQ,WAAW,SAAA,EAAU;AAAA,EAC7C,SAAA,EAAW,EAAE,IAAA,EAAM,MAAA,EAAQ,WAAW,YAAA,EAAa;AAAA,EACnD,SAAA,EAAW,EAAE,IAAA,EAAM,MAAA,EAAQ,WAAW,OAAA,EAAQ;AAAA,EAC9C,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAO;AAAA,EACtB,eAAA,EAAiB,EAAE,IAAA,EAAM,KAAA;AAC3B,CAAA;AAhBgB,eAAA,CAAA;AAAA,EADfM,mBAAA;AAAM,CAAA,EA9NIN,cAAA,CA+NK,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAGA,eAAA,CAAA;AAAA,EADfM,mBAAA;AAAM,CAAA,EAjOIN,cAAA,CAkOK,SAAA,EAAA,OAAA,EAAA,CAAA,CAAA;AAGA,eAAA,CAAA;AAAA,EADfM,mBAAA;AAAM,CAAA,EApOIN,cAAA,CAqOK,SAAA,EAAA,WAAA,EAAA,CAAA,CAAA;AArOLA,cAAA,GAAN,eAAA,CAAA;AAAA,EADNO,4BAAc,SAAS;AAAA,CAAA,EACXP,cAAA,CAAA","file":"index.js","sourcesContent":["import { LitElement, html, css, PropertyValues } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nexport interface Message {\n id: string;\n role: 'user' | 'assistant';\n content: string;\n}\n\n/**\n * AI Chat Web Component\n *\n * @fires message-sent - Fired when user sends a message\n * @fires response-received - Fired when AI responds\n * @fires error - Fired when an error occurs\n *\n * @example\n * ```html\n * <ai-chat\n * api-url=\"https://api.example.com\"\n * session-id=\"user-123\"\n * title=\"My AI Assistant\">\n * </ai-chat>\n * ```\n */\n@customElement('ai-chat')\nexport class AIChat extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n height: 100vh;\n font-family: system-ui, -apple-system, sans-serif;\n background: #fafafa;\n color: #09090b;\n }\n\n :host([theme=\"dark\"]) {\n background: #000;\n color: #fafafa;\n }\n\n .header {\n border-bottom: 1px solid #e4e4e7;\n background: #fff;\n padding: 1rem;\n }\n\n :host([theme=\"dark\"]) .header {\n border-bottom-color: #27272a;\n background: #18181b;\n }\n\n .header-content {\n max-width: 56rem;\n margin: 0 auto;\n }\n\n .title {\n font-size: 1.25rem;\n font-weight: 600;\n margin: 0;\n }\n\n .messages-area {\n flex: 1;\n overflow-y: auto;\n padding: 1.5rem 1rem;\n }\n\n .messages-container {\n max-width: 56rem;\n margin: 0 auto;\n display: flex;\n flex-direction: column;\n gap: 1.5rem;\n }\n\n .empty-state {\n text-align: center;\n color: #71717a;\n margin-top: 5rem;\n }\n\n :host([theme=\"dark\"]) .empty-state {\n color: #a1a1aa;\n }\n\n .empty-state p {\n font-size: 1.5rem;\n font-weight: 500;\n margin: 0;\n }\n\n .message {\n display: flex;\n gap: 1rem;\n }\n\n .message.user {\n flex-direction: row-reverse;\n }\n\n .avatar {\n width: 2.5rem;\n height: 2.5rem;\n border-radius: 9999px;\n background: #e4e4e7;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n font-weight: 500;\n font-size: 0.875rem;\n }\n\n :host([theme=\"dark\"]) .avatar {\n background: #3f3f46;\n }\n\n .message-content {\n max-width: 36rem;\n padding: 0.75rem 1rem;\n border-radius: 1rem;\n }\n\n .message.user .message-content {\n background: #2563eb;\n color: #fff;\n }\n\n .message.assistant .message-content {\n background: #fff;\n border: 1px solid #e4e4e7;\n color: #09090b;\n }\n\n :host([theme=\"dark\"]) .message.assistant .message-content {\n background: #27272a;\n border-color: #3f3f46;\n color: #fafafa;\n }\n\n .message-text {\n white-space: pre-wrap;\n margin: 0;\n }\n\n .loading {\n display: flex;\n gap: 1rem;\n }\n\n .spinner {\n display: inline-block;\n width: 1.25rem;\n height: 1.25rem;\n border: 2px solid #e4e4e7;\n border-top-color: #71717a;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n .input-area {\n border-top: 1px solid #e4e4e7;\n background: #fff;\n padding: 1rem;\n }\n\n :host([theme=\"dark\"]) .input-area {\n border-top-color: #27272a;\n background: #000;\n }\n\n .input-form {\n max-width: 56rem;\n margin: 0 auto;\n display: flex;\n gap: 0.75rem;\n }\n\n .input-field {\n flex: 1;\n height: 3rem;\n padding: 0 1rem;\n border: 1px solid #e4e4e7;\n border-radius: 0.5rem;\n font-size: 1rem;\n font-family: inherit;\n background: #fff;\n color: #09090b;\n }\n\n :host([theme=\"dark\"]) .input-field {\n border-color: #3f3f46;\n background: #18181b;\n color: #fafafa;\n }\n\n .input-field:focus {\n outline: 2px solid #2563eb;\n outline-offset: 2px;\n }\n\n .input-field:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .send-button {\n width: 3rem;\n height: 3rem;\n border-radius: 9999px;\n border: none;\n background: #2563eb;\n color: #fff;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.2s;\n }\n\n .send-button:hover:not(:disabled) {\n background: #1d4ed8;\n }\n\n .send-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .send-icon {\n width: 1.25rem;\n height: 1.25rem;\n }\n `;\n\n declare apiUrl: string;\n declare sessionId: string;\n declare chatTitle: string;\n declare theme: 'light' | 'dark';\n declare initialMessages: Message[];\n\n @state()\n private declare messages: Message[];\n\n @state()\n private declare input: string;\n\n @state()\n private declare isLoading: boolean;\n\n private messagesEndRef?: HTMLDivElement;\n\n static override properties = {\n apiUrl: { type: String, attribute: 'api-url' },\n sessionId: { type: String, attribute: 'session-id' },\n chatTitle: { type: String, attribute: 'title' },\n theme: { type: String },\n initialMessages: { type: Array },\n };\n\n constructor() {\n super();\n this.apiUrl = '';\n this.sessionId = 'default-session';\n this.chatTitle = 'My AI Agent';\n this.theme = 'light';\n this.initialMessages = [];\n this.messages = [];\n this.input = '';\n this.isLoading = false;\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.initialMessages && this.initialMessages.length > 0) {\n this.messages = [...this.initialMessages];\n }\n }\n\n updated(changedProperties: PropertyValues) {\n super.updated(changedProperties);\n if (changedProperties.has('messages')) {\n this.scrollToBottom();\n }\n }\n\n private scrollToBottom() {\n requestAnimationFrame(() => {\n this.messagesEndRef?.scrollIntoView({ behavior: 'smooth' });\n });\n }\n\n private handleInput(e: Event) {\n this.input = (e.target as HTMLInputElement).value;\n }\n\n private async handleSubmit(e: Event) {\n e.preventDefault();\n\n if (!this.input.trim() || this.isLoading || !this.apiUrl) return;\n\n const userMessage: Message = {\n id: Date.now().toString(),\n role: 'user',\n content: this.input.trim(),\n };\n\n this.messages = [...this.messages, userMessage];\n const questionText = this.input.trim();\n this.input = '';\n this.isLoading = true;\n\n // Dispatch message-sent event\n this.dispatchEvent(new CustomEvent('message-sent', {\n detail: userMessage,\n bubbles: true,\n composed: true,\n }));\n\n try {\n const response = await fetch(`${this.apiUrl}/ask`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n session_id: this.sessionId,\n question: questionText,\n }),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Backend error: ${response.status} ${errorText}`);\n }\n\n const data = await response.json();\n\n const assistantMessage: Message = {\n id: (Date.now() + 1).toString(),\n role: 'assistant',\n content: data.response || 'No response from agent',\n };\n\n this.messages = [...this.messages, assistantMessage];\n\n // Dispatch response-received event\n this.dispatchEvent(new CustomEvent('response-received', {\n detail: assistantMessage,\n bubbles: true,\n composed: true,\n }));\n } catch (err: any) {\n console.error('Backend connection failed:', err);\n\n const errorMessage: Message = {\n id: (Date.now() + 1).toString(),\n role: 'assistant',\n content: `Error: ${err.message}\\n\\nPlease check your API endpoint configuration.`,\n };\n\n this.messages = [...this.messages, errorMessage];\n\n // Dispatch error event\n this.dispatchEvent(new CustomEvent('error', {\n detail: err,\n bubbles: true,\n composed: true,\n }));\n } finally {\n this.isLoading = false;\n }\n }\n\n render() {\n return html`\n <!-- Header -->\n <div class=\"header\">\n <div class=\"header-content\">\n <h1 class=\"title\">${this.chatTitle}</h1>\n </div>\n </div>\n\n <!-- Messages Area -->\n <div class=\"messages-area\">\n <div class=\"messages-container\">\n ${this.messages.length === 0 ? html`\n <div class=\"empty-state\">\n <p>How can I help you today?</p>\n </div>\n ` : ''}\n\n ${repeat(this.messages, (msg) => msg.id, (msg) => html`\n <div class=${classMap({\n message: true,\n user: msg.role === 'user',\n assistant: msg.role === 'assistant'\n })}>\n <div class=\"avatar\">\n ${msg.role === 'user' ? 'U' : 'AI'}\n </div>\n <div class=\"message-content\">\n <p class=\"message-text\">${msg.content}</p>\n </div>\n </div>\n `)}\n\n ${this.isLoading ? html`\n <div class=\"loading\">\n <div class=\"avatar\">AI</div>\n <div class=\"message-content\">\n <div class=\"spinner\"></div>\n </div>\n </div>\n ` : ''}\n\n <div ${(el: Element) => this.messagesEndRef = el as HTMLDivElement}></div>\n </div>\n </div>\n\n <!-- Input Area -->\n <div class=\"input-area\">\n <form class=\"input-form\" @submit=${this.handleSubmit}>\n <input\n type=\"text\"\n class=\"input-field\"\n placeholder=\"Type your message...\"\n .value=${this.input}\n @input=${this.handleInput}\n ?disabled=${this.isLoading}\n />\n <button\n type=\"submit\"\n class=\"send-button\"\n ?disabled=${this.isLoading || !this.input.trim()}\n aria-label=\"Send message\"\n >\n ${this.isLoading ? html`\n <div class=\"spinner\" style=\"border-color: #fff; border-top-color: transparent;\"></div>\n ` : html`\n <svg class=\"send-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"></line>\n <polygon points=\"22 2 15 22 11 13 2 9 22 2\"></polygon>\n </svg>\n `}\n </button>\n </form>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ai-chat': AIChat;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/ai-chat.ts"],"names":["AIChat","LitElement","html","repeat","classMap","css","state","customElement"],"mappings":";;;;;;;;;;;;;;;;;AA4BaA,cAAA,GAAN,qBAAqBC,cAAA,CAAW;AAAA,EAqUrC,WAAA,GAAc;AACZ,IAAA,KAAA,EAAM;AACN,IAAA,IAAA,CAAK,MAAA,GAAS,EAAA;AACd,IAAA,IAAA,CAAK,SAAA,GAAY,iBAAA;AACjB,IAAA,IAAA,CAAK,SAAA,GAAY,aAAA;AACjB,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,YAAA;AACZ,IAAA,IAAA,CAAK,kBAAkB,EAAC;AACxB,IAAA,IAAA,CAAK,WAAW,EAAC;AACjB,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAA;AACb,IAAA,IAAA,CAAK,SAAA,GAAY,KAAA;AACjB,IAAA,IAAA,CAAK,MAAA,GAAS,KAAA;AAAA,EAChB;AAAA,EAEQ,YAAA,GAAe;AACrB,IAAA,IAAA,CAAK,MAAA,GAAS,CAAC,IAAA,CAAK,MAAA;AAAA,EACtB;AAAA,EAEA,iBAAA,GAAoB;AAClB,IAAA,KAAA,CAAM,iBAAA,EAAkB;AACxB,IAAA,IAAI,IAAA,CAAK,eAAA,IAAmB,IAAA,CAAK,eAAA,CAAgB,SAAS,CAAA,EAAG;AAC3D,MAAA,IAAA,CAAK,QA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A,EAAA,CAAA,CAAA;AAGA,eAAA,CAAA;AAAA,EADfM,mBAAA;AAAM,CAAA,EAvTIN,cAAA,CAwTK,SAAA,EAAA,QAAA,EAAA,CAAA,CAAA;AAxTLA,cAAA,GAAN,eAAA,CAAA;AAAA,EADNO,4BAAc,SAAS;AAAA,CAAA,EACXP,cAAA,CAAA","file":"index.js","sourcesContent":["import { LitElement, html, css, PropertyValues } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nexport interface Message {\n id: string;\n role: 'user' | 'assistant';\n content: string;\n}\n\n/**\n * AI Chat Web Component\n *\n * @fires message-sent - Fired when user sends a message\n * @fires response-received - Fired when AI responds\n * @fires error - Fired when an error occurs\n *\n * @example\n * ```html\n * <ai-chat\n * api-url=\"https://api.example.com\"\n * session-id=\"user-123\"\n * title=\"My AI Assistant\">\n * </ai-chat>\n * ```\n */\n@customElement('ai-chat')\nexport class AIChat extends LitElement {\n static styles = css`\n :host {\n font-family: system-ui, -apple-system, sans-serif;\n color: #09090b;\n }\n\n /* Fullscreen mode (default) */\n :host([mode=\"fullscreen\"]) {\n display: flex;\n flex-direction: column;\n height: 100vh;\n background: #fafafa;\n }\n\n :host([mode=\"fullscreen\"][theme=\"dark\"]) {\n background: #000;\n color: #fafafa;\n }\n\n /* Widget mode */\n :host([mode=\"widget\"]) {\n position: fixed;\n bottom: 20px;\n right: 20px;\n z-index: 9999;\n }\n\n .widget-container {\n position: relative;\n }\n\n .widget-button {\n width: 60px;\n height: 60px;\n border-radius: 50%;\n background: #2563eb;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n transition: transform 0.2s, box-shadow 0.2s;\n }\n\n .widget-button:hover {\n transform: scale(1.05);\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);\n }\n\n .widget-button svg {\n width: 28px;\n height: 28px;\n color: white;\n }\n\n .widget-window {\n position: absolute;\n bottom: 80px;\n right: 0;\n width: 380px;\n height: 600px;\n background: #fff;\n border-radius: 12px;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n opacity: 0;\n transform: scale(0.9) translateY(20px);\n pointer-events: none;\n transition: opacity 0.2s, transform 0.2s;\n }\n\n .widget-window.open {\n opacity: 1;\n transform: scale(1) translateY(0);\n pointer-events: all;\n }\n\n :host([theme=\"dark\"]) .widget-window {\n background: #18181b;\n color: #fafafa;\n }\n\n @media (max-width: 480px) {\n .widget-window {\n width: calc(100vw - 40px);\n height: calc(100vh - 100px);\n bottom: 80px;\n right: 0;\n }\n }\n\n .header {\n border-bottom: 1px solid #e4e4e7;\n background: #fff;\n padding: 1rem;\n }\n\n :host([theme=\"dark\"]) .header {\n border-bottom-color: #27272a;\n background: #18181b;\n }\n\n .header-content {\n max-width: 56rem;\n margin: 0 auto;\n }\n\n .title {\n font-size: 1.25rem;\n font-weight: 600;\n margin: 0;\n }\n\n .messages-area {\n flex: 1;\n overflow-y: auto;\n padding: 1.5rem 1rem;\n }\n\n .messages-container {\n max-width: 56rem;\n margin: 0 auto;\n display: flex;\n flex-direction: column;\n gap: 1.5rem;\n }\n\n .empty-state {\n text-align: center;\n color: #71717a;\n margin-top: 5rem;\n }\n\n :host([theme=\"dark\"]) .empty-state {\n color: #a1a1aa;\n }\n\n .empty-state p {\n font-size: 1.5rem;\n font-weight: 500;\n margin: 0;\n }\n\n .message {\n display: flex;\n gap: 1rem;\n }\n\n .message.user {\n flex-direction: row-reverse;\n }\n\n .avatar {\n width: 2.5rem;\n height: 2.5rem;\n border-radius: 9999px;\n background: #e4e4e7;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n font-weight: 500;\n font-size: 0.875rem;\n }\n\n :host([theme=\"dark\"]) .avatar {\n background: #3f3f46;\n }\n\n .message-content {\n max-width: 36rem;\n padding: 0.75rem 1rem;\n border-radius: 1rem;\n }\n\n .message.user .message-content {\n background: #2563eb;\n color: #fff;\n }\n\n .message.assistant .message-content {\n background: #fff;\n border: 1px solid #e4e4e7;\n color: #09090b;\n }\n\n :host([theme=\"dark\"]) .message.assistant .message-content {\n background: #27272a;\n border-color: #3f3f46;\n color: #fafafa;\n }\n\n .message-text {\n white-space: pre-wrap;\n margin: 0;\n }\n\n .loading {\n display: flex;\n gap: 1rem;\n }\n\n .spinner {\n display: inline-block;\n width: 1.25rem;\n height: 1.25rem;\n border: 2px solid #e4e4e7;\n border-top-color: #71717a;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n .input-area {\n border-top: 1px solid #e4e4e7;\n background: #fff;\n padding: 1rem;\n }\n\n :host([theme=\"dark\"]) .input-area {\n border-top-color: #27272a;\n background: #000;\n }\n\n .input-form {\n max-width: 56rem;\n margin: 0 auto;\n display: flex;\n gap: 0.75rem;\n }\n\n .input-field {\n flex: 1;\n height: 3rem;\n padding: 0 1rem;\n border: 1px solid #e4e4e7;\n border-radius: 0.5rem;\n font-size: 1rem;\n font-family: inherit;\n background: #fff;\n color: #09090b;\n }\n\n :host([theme=\"dark\"]) .input-field {\n border-color: #3f3f46;\n background: #18181b;\n color: #fafafa;\n }\n\n .input-field:focus {\n outline: 2px solid #2563eb;\n outline-offset: 2px;\n }\n\n .input-field:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .send-button {\n width: 3rem;\n height: 3rem;\n border-radius: 9999px;\n border: none;\n background: #2563eb;\n color: #fff;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.2s;\n }\n\n .send-button:hover:not(:disabled) {\n background: #1d4ed8;\n }\n\n .send-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .send-icon {\n width: 1.25rem;\n height: 1.25rem;\n }\n `;\n\n declare apiUrl: string;\n declare sessionId: string;\n declare chatTitle: string;\n declare theme: 'light' | 'dark';\n declare mode: 'fullscreen' | 'widget';\n declare initialMessages: Message[];\n\n @state()\n private declare messages: Message[];\n\n @state()\n private declare input: string;\n\n @state()\n private declare isLoading: boolean;\n\n @state()\n private declare isOpen: boolean;\n\n private messagesEndRef?: HTMLDivElement;\n\n static override properties = {\n apiUrl: { type: String, attribute: 'api-url' },\n sessionId: { type: String, attribute: 'session-id' },\n chatTitle: { type: String, attribute: 'title' },\n theme: { type: String },\n mode: { type: String, reflect: true },\n initialMessages: { type: Array },\n };\n\n constructor() {\n super();\n this.apiUrl = '';\n this.sessionId = 'default-session';\n this.chatTitle = 'My AI Agent';\n this.theme = 'light';\n this.mode = 'fullscreen';\n this.initialMessages = [];\n this.messages = [];\n this.input = '';\n this.isLoading = false;\n this.isOpen = false;\n }\n\n private toggleWidget() {\n this.isOpen = !this.isOpen;\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.initialMessages && this.initialMessages.length > 0) {\n this.messages = [...this.initialMessages];\n }\n }\n\n updated(changedProperties: PropertyValues) {\n super.updated(changedProperties);\n if (changedProperties.has('messages')) {\n this.scrollToBottom();\n }\n }\n\n private scrollToBottom() {\n requestAnimationFrame(() => {\n this.messagesEndRef?.scrollIntoView({ behavior: 'smooth' });\n });\n }\n\n private handleInput(e: Event) {\n this.input = (e.target as HTMLInputElement).value;\n }\n\n private async handleSubmit(e: Event) {\n e.preventDefault();\n\n if (!this.input.trim() || this.isLoading || !this.apiUrl) return;\n\n const userMessage: Message = {\n id: Date.now().toString(),\n role: 'user',\n content: this.input.trim(),\n };\n\n this.messages = [...this.messages, userMessage];\n const questionText = this.input.trim();\n this.input = '';\n this.isLoading = true;\n\n // Dispatch message-sent event\n this.dispatchEvent(new CustomEvent('message-sent', {\n detail: userMessage,\n bubbles: true,\n composed: true,\n }));\n\n try {\n const response = await fetch(`${this.apiUrl}/ask`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n session_id: this.sessionId,\n question: questionText,\n }),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Backend error: ${response.status} ${errorText}`);\n }\n\n const data = await response.json();\n\n const assistantMessage: Message = {\n id: (Date.now() + 1).toString(),\n role: 'assistant',\n content: data.response || 'No response from agent',\n };\n\n this.messages = [...this.messages, assistantMessage];\n\n // Dispatch response-received event\n this.dispatchEvent(new CustomEvent('response-received', {\n detail: assistantMessage,\n bubbles: true,\n composed: true,\n }));\n } catch (err: any) {\n console.error('Backend connection failed:', err);\n\n const errorMessage: Message = {\n id: (Date.now() + 1).toString(),\n role: 'assistant',\n content: `Error: ${err.message}\\n\\nPlease check your API endpoint configuration.`,\n };\n\n this.messages = [...this.messages, errorMessage];\n\n // Dispatch error event\n this.dispatchEvent(new CustomEvent('error', {\n detail: err,\n bubbles: true,\n composed: true,\n }));\n } finally {\n this.isLoading = false;\n }\n }\n\n private renderChatUI() {\n return html`\n <!-- Header -->\n <div class=\"header\">\n <div class=\"header-content\">\n <h1 class=\"title\">${this.chatTitle}</h1>\n </div>\n </div>\n\n <!-- Messages Area -->\n <div class=\"messages-area\">\n <div class=\"messages-container\">\n ${this.messages.length === 0 ? html`\n <div class=\"empty-state\">\n <p>How can I help you today?</p>\n </div>\n ` : ''}\n\n ${repeat(this.messages, (msg) => msg.id, (msg) => html`\n <div class=${classMap({\n message: true,\n user: msg.role === 'user',\n assistant: msg.role === 'assistant'\n })}>\n <div class=\"avatar\">\n ${msg.role === 'user' ? 'U' : 'AI'}\n </div>\n <div class=\"message-content\">\n <p class=\"message-text\">${msg.content}</p>\n </div>\n </div>\n `)}\n\n ${this.isLoading ? html`\n <div class=\"loading\">\n <div class=\"avatar\">AI</div>\n <div class=\"message-content\">\n <div class=\"spinner\"></div>\n </div>\n </div>\n ` : ''}\n\n <div ${(el: Element) => this.messagesEndRef = el as HTMLDivElement}></div>\n </div>\n </div>\n\n <!-- Input Area -->\n <div class=\"input-area\">\n <form class=\"input-form\" @submit=${this.handleSubmit}>\n <input\n type=\"text\"\n class=\"input-field\"\n placeholder=\"Type your message...\"\n .value=${this.input}\n @input=${this.handleInput}\n ?disabled=${this.isLoading}\n />\n <button\n type=\"submit\"\n class=\"send-button\"\n ?disabled=${this.isLoading || !this.input.trim()}\n aria-label=\"Send message\"\n >\n ${this.isLoading ? html`\n <div class=\"spinner\" style=\"border-color: #fff; border-top-color: transparent;\"></div>\n ` : html`\n <svg class=\"send-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"></line>\n <polygon points=\"22 2 15 22 11 13 2 9 22 2\"></polygon>\n </svg>\n `}\n </button>\n </form>\n </div>\n `;\n }\n\n render() {\n if (this.mode === 'widget') {\n return html`\n <div class=\"widget-container\">\n <!-- Chat Window -->\n <div class=${classMap({ 'widget-window': true, 'open': this.isOpen })}>\n ${this.renderChatUI()}\n </div>\n\n <!-- Toggle Button -->\n <button\n class=\"widget-button\"\n @click=${this.toggleWidget}\n aria-label=${this.isOpen ? 'Close chat' : 'Open chat'}\n >\n ${this.isOpen ? html`\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\n </svg>\n ` : html`\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"></path>\n </svg>\n `}\n </button>\n </div>\n `;\n }\n\n // Fullscreen mode\n return this.renderChatUI();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ai-chat': AIChat;\n }\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -20,10 +20,15 @@ var AIChat = class extends LitElement {
|
|
|
20
20
|
this.sessionId = "default-session";
|
|
21
21
|
this.chatTitle = "My AI Agent";
|
|
22
22
|
this.theme = "light";
|
|
23
|
+
this.mode = "fullscreen";
|
|
23
24
|
this.initialMessages = [];
|
|
24
25
|
this.messages = [];
|
|
25
26
|
this.input = "";
|
|
26
27
|
this.isLoading = false;
|
|
28
|
+
this.isOpen = false;
|
|
29
|
+
}
|
|
30
|
+
toggleWidget() {
|
|
31
|
+
this.isOpen = !this.isOpen;
|
|
27
32
|
}
|
|
28
33
|
connectedCallback() {
|
|
29
34
|
super.connectedCallback();
|
|
@@ -106,7 +111,7 @@ Please check your API endpoint configuration.`
|
|
|
106
111
|
this.isLoading = false;
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
|
-
|
|
114
|
+
renderChatUI() {
|
|
110
115
|
return html`
|
|
111
116
|
<!-- Header -->
|
|
112
117
|
<div class="header">
|
|
@@ -182,22 +187,132 @@ Please check your API endpoint configuration.`
|
|
|
182
187
|
</div>
|
|
183
188
|
`;
|
|
184
189
|
}
|
|
190
|
+
render() {
|
|
191
|
+
if (this.mode === "widget") {
|
|
192
|
+
return html`
|
|
193
|
+
<div class="widget-container">
|
|
194
|
+
<!-- Chat Window -->
|
|
195
|
+
<div class=${classMap({ "widget-window": true, "open": this.isOpen })}>
|
|
196
|
+
${this.renderChatUI()}
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
<!-- Toggle Button -->
|
|
200
|
+
<button
|
|
201
|
+
class="widget-button"
|
|
202
|
+
@click=${this.toggleWidget}
|
|
203
|
+
aria-label=${this.isOpen ? "Close chat" : "Open chat"}
|
|
204
|
+
>
|
|
205
|
+
${this.isOpen ? html`
|
|
206
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
207
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
208
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
209
|
+
</svg>
|
|
210
|
+
` : html`
|
|
211
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
212
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
213
|
+
</svg>
|
|
214
|
+
`}
|
|
215
|
+
</button>
|
|
216
|
+
</div>
|
|
217
|
+
`;
|
|
218
|
+
}
|
|
219
|
+
return this.renderChatUI();
|
|
220
|
+
}
|
|
185
221
|
};
|
|
186
222
|
AIChat.styles = css`
|
|
187
223
|
:host {
|
|
224
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
225
|
+
color: #09090b;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* Fullscreen mode (default) */
|
|
229
|
+
:host([mode="fullscreen"]) {
|
|
188
230
|
display: flex;
|
|
189
231
|
flex-direction: column;
|
|
190
232
|
height: 100vh;
|
|
191
|
-
font-family: system-ui, -apple-system, sans-serif;
|
|
192
233
|
background: #fafafa;
|
|
193
|
-
color: #09090b;
|
|
194
234
|
}
|
|
195
235
|
|
|
196
|
-
:host([theme="dark"]) {
|
|
236
|
+
:host([mode="fullscreen"][theme="dark"]) {
|
|
197
237
|
background: #000;
|
|
198
238
|
color: #fafafa;
|
|
199
239
|
}
|
|
200
240
|
|
|
241
|
+
/* Widget mode */
|
|
242
|
+
:host([mode="widget"]) {
|
|
243
|
+
position: fixed;
|
|
244
|
+
bottom: 20px;
|
|
245
|
+
right: 20px;
|
|
246
|
+
z-index: 9999;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.widget-container {
|
|
250
|
+
position: relative;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.widget-button {
|
|
254
|
+
width: 60px;
|
|
255
|
+
height: 60px;
|
|
256
|
+
border-radius: 50%;
|
|
257
|
+
background: #2563eb;
|
|
258
|
+
border: none;
|
|
259
|
+
cursor: pointer;
|
|
260
|
+
display: flex;
|
|
261
|
+
align-items: center;
|
|
262
|
+
justify-content: center;
|
|
263
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
264
|
+
transition: transform 0.2s, box-shadow 0.2s;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.widget-button:hover {
|
|
268
|
+
transform: scale(1.05);
|
|
269
|
+
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.widget-button svg {
|
|
273
|
+
width: 28px;
|
|
274
|
+
height: 28px;
|
|
275
|
+
color: white;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.widget-window {
|
|
279
|
+
position: absolute;
|
|
280
|
+
bottom: 80px;
|
|
281
|
+
right: 0;
|
|
282
|
+
width: 380px;
|
|
283
|
+
height: 600px;
|
|
284
|
+
background: #fff;
|
|
285
|
+
border-radius: 12px;
|
|
286
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
|
287
|
+
display: flex;
|
|
288
|
+
flex-direction: column;
|
|
289
|
+
overflow: hidden;
|
|
290
|
+
opacity: 0;
|
|
291
|
+
transform: scale(0.9) translateY(20px);
|
|
292
|
+
pointer-events: none;
|
|
293
|
+
transition: opacity 0.2s, transform 0.2s;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.widget-window.open {
|
|
297
|
+
opacity: 1;
|
|
298
|
+
transform: scale(1) translateY(0);
|
|
299
|
+
pointer-events: all;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
:host([theme="dark"]) .widget-window {
|
|
303
|
+
background: #18181b;
|
|
304
|
+
color: #fafafa;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
@media (max-width: 480px) {
|
|
308
|
+
.widget-window {
|
|
309
|
+
width: calc(100vw - 40px);
|
|
310
|
+
height: calc(100vh - 100px);
|
|
311
|
+
bottom: 80px;
|
|
312
|
+
right: 0;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
201
316
|
.header {
|
|
202
317
|
border-bottom: 1px solid #e4e4e7;
|
|
203
318
|
background: #fff;
|
|
@@ -402,6 +517,7 @@ AIChat.properties = {
|
|
|
402
517
|
sessionId: { type: String, attribute: "session-id" },
|
|
403
518
|
chatTitle: { type: String, attribute: "title" },
|
|
404
519
|
theme: { type: String },
|
|
520
|
+
mode: { type: String, reflect: true },
|
|
405
521
|
initialMessages: { type: Array }
|
|
406
522
|
};
|
|
407
523
|
__decorateClass([
|
|
@@ -413,6 +529,9 @@ __decorateClass([
|
|
|
413
529
|
__decorateClass([
|
|
414
530
|
state()
|
|
415
531
|
], AIChat.prototype, "isLoading", 2);
|
|
532
|
+
__decorateClass([
|
|
533
|
+
state()
|
|
534
|
+
], AIChat.prototype, "isOpen", 2);
|
|
416
535
|
AIChat = __decorateClass([
|
|
417
536
|
customElement("ai-chat")
|
|
418
537
|
], AIChat);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ai-chat.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA4BO,IAAM,MAAA,GAAN,cAAqB,UAAA,CAAW;AAAA,EAiPrC,WAAA,GAAc;AACZ,IAAA,KAAA,EAAM;AACN,IAAA,IAAA,CAAK,MAAA,GAAS,EAAA;AACd,IAAA,IAAA,CAAK,SAAA,GAAY,iBAAA;AACjB,IAAA,IAAA,CAAK,SAAA,GAAY,aAAA;AACjB,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA;AACb,IAAA,IAAA,CAAK,kBAAkB,EAAC;AACxB,IAAA,IAAA,CAAK,WAAW,EAAC;AACjB,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAA;AACb,IAAA,IAAA,CAAK,SAAA,GAAY,KAAA;AAAA,EACnB;AAAA,EAEA,iBAAA,GAAoB;AAClB,IAAA,KAAA,CAAM,iBAAA,EAAkB;AACxB,IAAA,IAAI,IAAA,CAAK,eAAA,IAAmB,IAAA,CAAK,eAAA,CAAgB,SAAS,CAAA,EAAG;AAC3D,MAAA,IAAA,CAAK,QA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A,EAAA,CAAA,CAAA;AAGA,eAAA,CAAA;AAAA,EADf,KAAA;AAAM,CAAA,EApOI,MAAA,CAqOK,SAAA,EAAA,WAAA,EAAA,CAAA,CAAA;AArOL,MAAA,GAAN,eAAA,CAAA;AAAA,EADN,cAAc,SAAS;AAAA,CAAA,EACX,MAAA,CAAA","file":"index.mjs","sourcesContent":["import { LitElement, html, css, PropertyValues } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nexport interface Message {\n id: string;\n role: 'user' | 'assistant';\n content: string;\n}\n\n/**\n * AI Chat Web Component\n *\n * @fires message-sent - Fired when user sends a message\n * @fires response-received - Fired when AI responds\n * @fires error - Fired when an error occurs\n *\n * @example\n * ```html\n * <ai-chat\n * api-url=\"https://api.example.com\"\n * session-id=\"user-123\"\n * title=\"My AI Assistant\">\n * </ai-chat>\n * ```\n */\n@customElement('ai-chat')\nexport class AIChat extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n height: 100vh;\n font-family: system-ui, -apple-system, sans-serif;\n background: #fafafa;\n color: #09090b;\n }\n\n :host([theme=\"dark\"]) {\n background: #000;\n color: #fafafa;\n }\n\n .header {\n border-bottom: 1px solid #e4e4e7;\n background: #fff;\n padding: 1rem;\n }\n\n :host([theme=\"dark\"]) .header {\n border-bottom-color: #27272a;\n background: #18181b;\n }\n\n .header-content {\n max-width: 56rem;\n margin: 0 auto;\n }\n\n .title {\n font-size: 1.25rem;\n font-weight: 600;\n margin: 0;\n }\n\n .messages-area {\n flex: 1;\n overflow-y: auto;\n padding: 1.5rem 1rem;\n }\n\n .messages-container {\n max-width: 56rem;\n margin: 0 auto;\n display: flex;\n flex-direction: column;\n gap: 1.5rem;\n }\n\n .empty-state {\n text-align: center;\n color: #71717a;\n margin-top: 5rem;\n }\n\n :host([theme=\"dark\"]) .empty-state {\n color: #a1a1aa;\n }\n\n .empty-state p {\n font-size: 1.5rem;\n font-weight: 500;\n margin: 0;\n }\n\n .message {\n display: flex;\n gap: 1rem;\n }\n\n .message.user {\n flex-direction: row-reverse;\n }\n\n .avatar {\n width: 2.5rem;\n height: 2.5rem;\n border-radius: 9999px;\n background: #e4e4e7;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n font-weight: 500;\n font-size: 0.875rem;\n }\n\n :host([theme=\"dark\"]) .avatar {\n background: #3f3f46;\n }\n\n .message-content {\n max-width: 36rem;\n padding: 0.75rem 1rem;\n border-radius: 1rem;\n }\n\n .message.user .message-content {\n background: #2563eb;\n color: #fff;\n }\n\n .message.assistant .message-content {\n background: #fff;\n border: 1px solid #e4e4e7;\n color: #09090b;\n }\n\n :host([theme=\"dark\"]) .message.assistant .message-content {\n background: #27272a;\n border-color: #3f3f46;\n color: #fafafa;\n }\n\n .message-text {\n white-space: pre-wrap;\n margin: 0;\n }\n\n .loading {\n display: flex;\n gap: 1rem;\n }\n\n .spinner {\n display: inline-block;\n width: 1.25rem;\n height: 1.25rem;\n border: 2px solid #e4e4e7;\n border-top-color: #71717a;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n .input-area {\n border-top: 1px solid #e4e4e7;\n background: #fff;\n padding: 1rem;\n }\n\n :host([theme=\"dark\"]) .input-area {\n border-top-color: #27272a;\n background: #000;\n }\n\n .input-form {\n max-width: 56rem;\n margin: 0 auto;\n display: flex;\n gap: 0.75rem;\n }\n\n .input-field {\n flex: 1;\n height: 3rem;\n padding: 0 1rem;\n border: 1px solid #e4e4e7;\n border-radius: 0.5rem;\n font-size: 1rem;\n font-family: inherit;\n background: #fff;\n color: #09090b;\n }\n\n :host([theme=\"dark\"]) .input-field {\n border-color: #3f3f46;\n background: #18181b;\n color: #fafafa;\n }\n\n .input-field:focus {\n outline: 2px solid #2563eb;\n outline-offset: 2px;\n }\n\n .input-field:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .send-button {\n width: 3rem;\n height: 3rem;\n border-radius: 9999px;\n border: none;\n background: #2563eb;\n color: #fff;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.2s;\n }\n\n .send-button:hover:not(:disabled) {\n background: #1d4ed8;\n }\n\n .send-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .send-icon {\n width: 1.25rem;\n height: 1.25rem;\n }\n `;\n\n declare apiUrl: string;\n declare sessionId: string;\n declare chatTitle: string;\n declare theme: 'light' | 'dark';\n declare initialMessages: Message[];\n\n @state()\n private declare messages: Message[];\n\n @state()\n private declare input: string;\n\n @state()\n private declare isLoading: boolean;\n\n private messagesEndRef?: HTMLDivElement;\n\n static override properties = {\n apiUrl: { type: String, attribute: 'api-url' },\n sessionId: { type: String, attribute: 'session-id' },\n chatTitle: { type: String, attribute: 'title' },\n theme: { type: String },\n initialMessages: { type: Array },\n };\n\n constructor() {\n super();\n this.apiUrl = '';\n this.sessionId = 'default-session';\n this.chatTitle = 'My AI Agent';\n this.theme = 'light';\n this.initialMessages = [];\n this.messages = [];\n this.input = '';\n this.isLoading = false;\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.initialMessages && this.initialMessages.length > 0) {\n this.messages = [...this.initialMessages];\n }\n }\n\n updated(changedProperties: PropertyValues) {\n super.updated(changedProperties);\n if (changedProperties.has('messages')) {\n this.scrollToBottom();\n }\n }\n\n private scrollToBottom() {\n requestAnimationFrame(() => {\n this.messagesEndRef?.scrollIntoView({ behavior: 'smooth' });\n });\n }\n\n private handleInput(e: Event) {\n this.input = (e.target as HTMLInputElement).value;\n }\n\n private async handleSubmit(e: Event) {\n e.preventDefault();\n\n if (!this.input.trim() || this.isLoading || !this.apiUrl) return;\n\n const userMessage: Message = {\n id: Date.now().toString(),\n role: 'user',\n content: this.input.trim(),\n };\n\n this.messages = [...this.messages, userMessage];\n const questionText = this.input.trim();\n this.input = '';\n this.isLoading = true;\n\n // Dispatch message-sent event\n this.dispatchEvent(new CustomEvent('message-sent', {\n detail: userMessage,\n bubbles: true,\n composed: true,\n }));\n\n try {\n const response = await fetch(`${this.apiUrl}/ask`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n session_id: this.sessionId,\n question: questionText,\n }),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Backend error: ${response.status} ${errorText}`);\n }\n\n const data = await response.json();\n\n const assistantMessage: Message = {\n id: (Date.now() + 1).toString(),\n role: 'assistant',\n content: data.response || 'No response from agent',\n };\n\n this.messages = [...this.messages, assistantMessage];\n\n // Dispatch response-received event\n this.dispatchEvent(new CustomEvent('response-received', {\n detail: assistantMessage,\n bubbles: true,\n composed: true,\n }));\n } catch (err: any) {\n console.error('Backend connection failed:', err);\n\n const errorMessage: Message = {\n id: (Date.now() + 1).toString(),\n role: 'assistant',\n content: `Error: ${err.message}\\n\\nPlease check your API endpoint configuration.`,\n };\n\n this.messages = [...this.messages, errorMessage];\n\n // Dispatch error event\n this.dispatchEvent(new CustomEvent('error', {\n detail: err,\n bubbles: true,\n composed: true,\n }));\n } finally {\n this.isLoading = false;\n }\n }\n\n render() {\n return html`\n <!-- Header -->\n <div class=\"header\">\n <div class=\"header-content\">\n <h1 class=\"title\">${this.chatTitle}</h1>\n </div>\n </div>\n\n <!-- Messages Area -->\n <div class=\"messages-area\">\n <div class=\"messages-container\">\n ${this.messages.length === 0 ? html`\n <div class=\"empty-state\">\n <p>How can I help you today?</p>\n </div>\n ` : ''}\n\n ${repeat(this.messages, (msg) => msg.id, (msg) => html`\n <div class=${classMap({\n message: true,\n user: msg.role === 'user',\n assistant: msg.role === 'assistant'\n })}>\n <div class=\"avatar\">\n ${msg.role === 'user' ? 'U' : 'AI'}\n </div>\n <div class=\"message-content\">\n <p class=\"message-text\">${msg.content}</p>\n </div>\n </div>\n `)}\n\n ${this.isLoading ? html`\n <div class=\"loading\">\n <div class=\"avatar\">AI</div>\n <div class=\"message-content\">\n <div class=\"spinner\"></div>\n </div>\n </div>\n ` : ''}\n\n <div ${(el: Element) => this.messagesEndRef = el as HTMLDivElement}></div>\n </div>\n </div>\n\n <!-- Input Area -->\n <div class=\"input-area\">\n <form class=\"input-form\" @submit=${this.handleSubmit}>\n <input\n type=\"text\"\n class=\"input-field\"\n placeholder=\"Type your message...\"\n .value=${this.input}\n @input=${this.handleInput}\n ?disabled=${this.isLoading}\n />\n <button\n type=\"submit\"\n class=\"send-button\"\n ?disabled=${this.isLoading || !this.input.trim()}\n aria-label=\"Send message\"\n >\n ${this.isLoading ? html`\n <div class=\"spinner\" style=\"border-color: #fff; border-top-color: transparent;\"></div>\n ` : html`\n <svg class=\"send-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"></line>\n <polygon points=\"22 2 15 22 11 13 2 9 22 2\"></polygon>\n </svg>\n `}\n </button>\n </form>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ai-chat': AIChat;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/ai-chat.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA4BO,IAAM,MAAA,GAAN,cAAqB,UAAA,CAAW;AAAA,EAqUrC,WAAA,GAAc;AACZ,IAAA,KAAA,EAAM;AACN,IAAA,IAAA,CAAK,MAAA,GAAS,EAAA;AACd,IAAA,IAAA,CAAK,SAAA,GAAY,iBAAA;AACjB,IAAA,IAAA,CAAK,SAAA,GAAY,aAAA;AACjB,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,YAAA;AACZ,IAAA,IAAA,CAAK,kBAAkB,EAAC;AACxB,IAAA,IAAA,CAAK,WAAW,EAAC;AACjB,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAA;AACb,IAAA,IAAA,CAAK,SAAA,GAAY,KAAA;AACjB,I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,CAAA;AApBgB,eAAA,CAAA;AAAA,EADf,KAAA;AAAM,CAAA,EA9SI,MAAA,CA+SK,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAGA,eAAA,CAAA;AAAA,EADf,KAAA;AAAM,CAAA,EAjTI,MAAA,CAkTK,SAAA,EAAA,OAAA,EAAA,CAAA,CAAA;AAGA,eAAA,CAAA;AAAA,EADf,KAAA;AAAM,CAAA,EApTI,MAAA,CAqTK,SAAA,EAAA,WAAA,EAAA,CAAA,CAAA;AAGA,eAAA,CAAA;AAAA,EADf,KAAA;AAAM,CAAA,EAvTI,MAAA,CAwTK,SAAA,EAAA,QAAA,EAAA,CAAA,CAAA;AAxTL,MAAA,GAAN,eAAA,CAAA;AAAA,EADN,cAAc,SAAS;AAAA,CAAA,EACX,MAAA,CAAA","file":"index.mjs","sourcesContent":["import { LitElement, html, css, PropertyValues } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nexport interface Message {\n id: string;\n role: 'user' | 'assistant';\n content: string;\n}\n\n/**\n * AI Chat Web Component\n *\n * @fires message-sent - Fired when user sends a message\n * @fires response-received - Fired when AI responds\n * @fires error - Fired when an error occurs\n *\n * @example\n * ```html\n * <ai-chat\n * api-url=\"https://api.example.com\"\n * session-id=\"user-123\"\n * title=\"My AI Assistant\">\n * </ai-chat>\n * ```\n */\n@customElement('ai-chat')\nexport class AIChat extends LitElement {\n static styles = css`\n :host {\n font-family: system-ui, -apple-system, sans-serif;\n color: #09090b;\n }\n\n /* Fullscreen mode (default) */\n :host([mode=\"fullscreen\"]) {\n display: flex;\n flex-direction: column;\n height: 100vh;\n background: #fafafa;\n }\n\n :host([mode=\"fullscreen\"][theme=\"dark\"]) {\n background: #000;\n color: #fafafa;\n }\n\n /* Widget mode */\n :host([mode=\"widget\"]) {\n position: fixed;\n bottom: 20px;\n right: 20px;\n z-index: 9999;\n }\n\n .widget-container {\n position: relative;\n }\n\n .widget-button {\n width: 60px;\n height: 60px;\n border-radius: 50%;\n background: #2563eb;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n transition: transform 0.2s, box-shadow 0.2s;\n }\n\n .widget-button:hover {\n transform: scale(1.05);\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);\n }\n\n .widget-button svg {\n width: 28px;\n height: 28px;\n color: white;\n }\n\n .widget-window {\n position: absolute;\n bottom: 80px;\n right: 0;\n width: 380px;\n height: 600px;\n background: #fff;\n border-radius: 12px;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n opacity: 0;\n transform: scale(0.9) translateY(20px);\n pointer-events: none;\n transition: opacity 0.2s, transform 0.2s;\n }\n\n .widget-window.open {\n opacity: 1;\n transform: scale(1) translateY(0);\n pointer-events: all;\n }\n\n :host([theme=\"dark\"]) .widget-window {\n background: #18181b;\n color: #fafafa;\n }\n\n @media (max-width: 480px) {\n .widget-window {\n width: calc(100vw - 40px);\n height: calc(100vh - 100px);\n bottom: 80px;\n right: 0;\n }\n }\n\n .header {\n border-bottom: 1px solid #e4e4e7;\n background: #fff;\n padding: 1rem;\n }\n\n :host([theme=\"dark\"]) .header {\n border-bottom-color: #27272a;\n background: #18181b;\n }\n\n .header-content {\n max-width: 56rem;\n margin: 0 auto;\n }\n\n .title {\n font-size: 1.25rem;\n font-weight: 600;\n margin: 0;\n }\n\n .messages-area {\n flex: 1;\n overflow-y: auto;\n padding: 1.5rem 1rem;\n }\n\n .messages-container {\n max-width: 56rem;\n margin: 0 auto;\n display: flex;\n flex-direction: column;\n gap: 1.5rem;\n }\n\n .empty-state {\n text-align: center;\n color: #71717a;\n margin-top: 5rem;\n }\n\n :host([theme=\"dark\"]) .empty-state {\n color: #a1a1aa;\n }\n\n .empty-state p {\n font-size: 1.5rem;\n font-weight: 500;\n margin: 0;\n }\n\n .message {\n display: flex;\n gap: 1rem;\n }\n\n .message.user {\n flex-direction: row-reverse;\n }\n\n .avatar {\n width: 2.5rem;\n height: 2.5rem;\n border-radius: 9999px;\n background: #e4e4e7;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n font-weight: 500;\n font-size: 0.875rem;\n }\n\n :host([theme=\"dark\"]) .avatar {\n background: #3f3f46;\n }\n\n .message-content {\n max-width: 36rem;\n padding: 0.75rem 1rem;\n border-radius: 1rem;\n }\n\n .message.user .message-content {\n background: #2563eb;\n color: #fff;\n }\n\n .message.assistant .message-content {\n background: #fff;\n border: 1px solid #e4e4e7;\n color: #09090b;\n }\n\n :host([theme=\"dark\"]) .message.assistant .message-content {\n background: #27272a;\n border-color: #3f3f46;\n color: #fafafa;\n }\n\n .message-text {\n white-space: pre-wrap;\n margin: 0;\n }\n\n .loading {\n display: flex;\n gap: 1rem;\n }\n\n .spinner {\n display: inline-block;\n width: 1.25rem;\n height: 1.25rem;\n border: 2px solid #e4e4e7;\n border-top-color: #71717a;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n }\n\n @keyframes spin {\n to { transform: rotate(360deg); }\n }\n\n .input-area {\n border-top: 1px solid #e4e4e7;\n background: #fff;\n padding: 1rem;\n }\n\n :host([theme=\"dark\"]) .input-area {\n border-top-color: #27272a;\n background: #000;\n }\n\n .input-form {\n max-width: 56rem;\n margin: 0 auto;\n display: flex;\n gap: 0.75rem;\n }\n\n .input-field {\n flex: 1;\n height: 3rem;\n padding: 0 1rem;\n border: 1px solid #e4e4e7;\n border-radius: 0.5rem;\n font-size: 1rem;\n font-family: inherit;\n background: #fff;\n color: #09090b;\n }\n\n :host([theme=\"dark\"]) .input-field {\n border-color: #3f3f46;\n background: #18181b;\n color: #fafafa;\n }\n\n .input-field:focus {\n outline: 2px solid #2563eb;\n outline-offset: 2px;\n }\n\n .input-field:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .send-button {\n width: 3rem;\n height: 3rem;\n border-radius: 9999px;\n border: none;\n background: #2563eb;\n color: #fff;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.2s;\n }\n\n .send-button:hover:not(:disabled) {\n background: #1d4ed8;\n }\n\n .send-button:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .send-icon {\n width: 1.25rem;\n height: 1.25rem;\n }\n `;\n\n declare apiUrl: string;\n declare sessionId: string;\n declare chatTitle: string;\n declare theme: 'light' | 'dark';\n declare mode: 'fullscreen' | 'widget';\n declare initialMessages: Message[];\n\n @state()\n private declare messages: Message[];\n\n @state()\n private declare input: string;\n\n @state()\n private declare isLoading: boolean;\n\n @state()\n private declare isOpen: boolean;\n\n private messagesEndRef?: HTMLDivElement;\n\n static override properties = {\n apiUrl: { type: String, attribute: 'api-url' },\n sessionId: { type: String, attribute: 'session-id' },\n chatTitle: { type: String, attribute: 'title' },\n theme: { type: String },\n mode: { type: String, reflect: true },\n initialMessages: { type: Array },\n };\n\n constructor() {\n super();\n this.apiUrl = '';\n this.sessionId = 'default-session';\n this.chatTitle = 'My AI Agent';\n this.theme = 'light';\n this.mode = 'fullscreen';\n this.initialMessages = [];\n this.messages = [];\n this.input = '';\n this.isLoading = false;\n this.isOpen = false;\n }\n\n private toggleWidget() {\n this.isOpen = !this.isOpen;\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.initialMessages && this.initialMessages.length > 0) {\n this.messages = [...this.initialMessages];\n }\n }\n\n updated(changedProperties: PropertyValues) {\n super.updated(changedProperties);\n if (changedProperties.has('messages')) {\n this.scrollToBottom();\n }\n }\n\n private scrollToBottom() {\n requestAnimationFrame(() => {\n this.messagesEndRef?.scrollIntoView({ behavior: 'smooth' });\n });\n }\n\n private handleInput(e: Event) {\n this.input = (e.target as HTMLInputElement).value;\n }\n\n private async handleSubmit(e: Event) {\n e.preventDefault();\n\n if (!this.input.trim() || this.isLoading || !this.apiUrl) return;\n\n const userMessage: Message = {\n id: Date.now().toString(),\n role: 'user',\n content: this.input.trim(),\n };\n\n this.messages = [...this.messages, userMessage];\n const questionText = this.input.trim();\n this.input = '';\n this.isLoading = true;\n\n // Dispatch message-sent event\n this.dispatchEvent(new CustomEvent('message-sent', {\n detail: userMessage,\n bubbles: true,\n composed: true,\n }));\n\n try {\n const response = await fetch(`${this.apiUrl}/ask`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n session_id: this.sessionId,\n question: questionText,\n }),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Backend error: ${response.status} ${errorText}`);\n }\n\n const data = await response.json();\n\n const assistantMessage: Message = {\n id: (Date.now() + 1).toString(),\n role: 'assistant',\n content: data.response || 'No response from agent',\n };\n\n this.messages = [...this.messages, assistantMessage];\n\n // Dispatch response-received event\n this.dispatchEvent(new CustomEvent('response-received', {\n detail: assistantMessage,\n bubbles: true,\n composed: true,\n }));\n } catch (err: any) {\n console.error('Backend connection failed:', err);\n\n const errorMessage: Message = {\n id: (Date.now() + 1).toString(),\n role: 'assistant',\n content: `Error: ${err.message}\\n\\nPlease check your API endpoint configuration.`,\n };\n\n this.messages = [...this.messages, errorMessage];\n\n // Dispatch error event\n this.dispatchEvent(new CustomEvent('error', {\n detail: err,\n bubbles: true,\n composed: true,\n }));\n } finally {\n this.isLoading = false;\n }\n }\n\n private renderChatUI() {\n return html`\n <!-- Header -->\n <div class=\"header\">\n <div class=\"header-content\">\n <h1 class=\"title\">${this.chatTitle}</h1>\n </div>\n </div>\n\n <!-- Messages Area -->\n <div class=\"messages-area\">\n <div class=\"messages-container\">\n ${this.messages.length === 0 ? html`\n <div class=\"empty-state\">\n <p>How can I help you today?</p>\n </div>\n ` : ''}\n\n ${repeat(this.messages, (msg) => msg.id, (msg) => html`\n <div class=${classMap({\n message: true,\n user: msg.role === 'user',\n assistant: msg.role === 'assistant'\n })}>\n <div class=\"avatar\">\n ${msg.role === 'user' ? 'U' : 'AI'}\n </div>\n <div class=\"message-content\">\n <p class=\"message-text\">${msg.content}</p>\n </div>\n </div>\n `)}\n\n ${this.isLoading ? html`\n <div class=\"loading\">\n <div class=\"avatar\">AI</div>\n <div class=\"message-content\">\n <div class=\"spinner\"></div>\n </div>\n </div>\n ` : ''}\n\n <div ${(el: Element) => this.messagesEndRef = el as HTMLDivElement}></div>\n </div>\n </div>\n\n <!-- Input Area -->\n <div class=\"input-area\">\n <form class=\"input-form\" @submit=${this.handleSubmit}>\n <input\n type=\"text\"\n class=\"input-field\"\n placeholder=\"Type your message...\"\n .value=${this.input}\n @input=${this.handleInput}\n ?disabled=${this.isLoading}\n />\n <button\n type=\"submit\"\n class=\"send-button\"\n ?disabled=${this.isLoading || !this.input.trim()}\n aria-label=\"Send message\"\n >\n ${this.isLoading ? html`\n <div class=\"spinner\" style=\"border-color: #fff; border-top-color: transparent;\"></div>\n ` : html`\n <svg class=\"send-icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"></line>\n <polygon points=\"22 2 15 22 11 13 2 9 22 2\"></polygon>\n </svg>\n `}\n </button>\n </form>\n </div>\n `;\n }\n\n render() {\n if (this.mode === 'widget') {\n return html`\n <div class=\"widget-container\">\n <!-- Chat Window -->\n <div class=${classMap({ 'widget-window': true, 'open': this.isOpen })}>\n ${this.renderChatUI()}\n </div>\n\n <!-- Toggle Button -->\n <button\n class=\"widget-button\"\n @click=${this.toggleWidget}\n aria-label=${this.isOpen ? 'Close chat' : 'Open chat'}\n >\n ${this.isOpen ? html`\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\n </svg>\n ` : html`\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"></path>\n </svg>\n `}\n </button>\n </div>\n `;\n }\n\n // Fullscreen mode\n return this.renderChatUI();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ai-chat': AIChat;\n }\n}\n"]}
|
package/package.json
CHANGED