@a.izzuddin/ai-chat 0.2.23 → 0.2.25-beta.1
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 +346 -346
- package/README.npm.md +293 -293
- package/custom-elements.json +13 -13
- package/dist/index.js +147 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -58
- package/dist/index.mjs.map +1 -1
- package/global.d.ts +24 -24
- package/package.json +88 -88
package/README.npm.md
CHANGED
|
@@ -1,293 +1,293 @@
|
|
|
1
|
-
# @a.izzuddin/ai-chat
|
|
2
|
-
|
|
3
|
-
A beautiful, configurable AI chat component for React applications. Built with Radix UI, Tailwind CSS, and TypeScript.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- 🎨 **Beautiful UI** - Modern chat interface with dark mode support
|
|
8
|
-
- ⚡ **Lightweight** - Minimal dependencies, optimized bundle size
|
|
9
|
-
- 🔧 **Configurable** - Customize API endpoint, session management, styling
|
|
10
|
-
- 📱 **Responsive** - Works great on mobile and desktop
|
|
11
|
-
- 🎯 **TypeScript** - Full type safety out of the box
|
|
12
|
-
- ♿ **Accessible** - Built on Radix UI primitives
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install @a.izzuddin/ai-chat
|
|
18
|
-
# or
|
|
19
|
-
yarn add @a.izzuddin/ai-chat
|
|
20
|
-
# or
|
|
21
|
-
pnpm add @a.izzuddin/ai-chat
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Peer Dependencies
|
|
25
|
-
|
|
26
|
-
This package requires React 18+ or React 19+:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm install react react-dom
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Quick Start
|
|
33
|
-
|
|
34
|
-
```tsx
|
|
35
|
-
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
36
|
-
import "@a.izzuddin/ai-chat/styles";
|
|
37
|
-
|
|
38
|
-
function App() {
|
|
39
|
-
return (
|
|
40
|
-
<AIChat
|
|
41
|
-
apiUrl="https://your-api-endpoint.com"
|
|
42
|
-
sessionId="user-123"
|
|
43
|
-
title="My AI Assistant"
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Tailwind CSS Setup
|
|
50
|
-
|
|
51
|
-
This component uses Tailwind CSS. Add the component path to your `tailwind.config.js`:
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
/** @type {import('tailwindcss').Config} */
|
|
55
|
-
module.exports = {
|
|
56
|
-
content: [
|
|
57
|
-
"./app/**/*.{js,ts,jsx,tsx}",
|
|
58
|
-
"./components/**/*.{js,ts,jsx,tsx}",
|
|
59
|
-
// Add this line:
|
|
60
|
-
"./node_modules/@a.izzuddin/ai-chat/**/*.{js,ts,jsx,tsx}",
|
|
61
|
-
],
|
|
62
|
-
// ... rest of your config
|
|
63
|
-
};
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Or if using Tailwind v4, add to your CSS:
|
|
67
|
-
|
|
68
|
-
```css
|
|
69
|
-
@import "tailwindcss";
|
|
70
|
-
@import "@a.izzuddin/ai-chat/styles";
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## API Requirements
|
|
74
|
-
|
|
75
|
-
Your API endpoint should accept POST requests to `/ask` with this format:
|
|
76
|
-
|
|
77
|
-
**Request:**
|
|
78
|
-
```json
|
|
79
|
-
{
|
|
80
|
-
"session_id": "string",
|
|
81
|
-
"question": "string"
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**Response:**
|
|
86
|
-
```json
|
|
87
|
-
{
|
|
88
|
-
"response": "string"
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Props
|
|
93
|
-
|
|
94
|
-
| Prop | Type | Default | Description |
|
|
95
|
-
|------|------|---------|-------------|
|
|
96
|
-
| `apiUrl` | `string` | *required* | Your API endpoint URL |
|
|
97
|
-
| `sessionId` | `string` | `"default-session"` | Session identifier for conversation context |
|
|
98
|
-
| `title` | `string` | `"My AI Agent"` | Chat header title |
|
|
99
|
-
| `initialMessages` | `Message[]` | `[]` | Pre-populate chat with messages |
|
|
100
|
-
| `className` | `string` | `undefined` | Custom CSS class for container |
|
|
101
|
-
| `onMessageSent` | `(message: Message) => void` | `undefined` | Callback when user sends a message |
|
|
102
|
-
| `onResponseReceived` | `(message: Message) => void` | `undefined` | Callback when AI responds |
|
|
103
|
-
| `onError` | `(error: Error) => void` | `undefined` | Callback when an error occurs |
|
|
104
|
-
|
|
105
|
-
## Advanced Usage
|
|
106
|
-
|
|
107
|
-
### With Custom Styling
|
|
108
|
-
|
|
109
|
-
```tsx
|
|
110
|
-
<AIChat
|
|
111
|
-
apiUrl="https://api.example.com"
|
|
112
|
-
className="max-w-4xl mx-auto shadow-lg"
|
|
113
|
-
title="Customer Support Bot"
|
|
114
|
-
/>
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### With Event Handlers
|
|
118
|
-
|
|
119
|
-
```tsx
|
|
120
|
-
<AIChat
|
|
121
|
-
apiUrl="https://api.example.com"
|
|
122
|
-
onMessageSent={(message) => {
|
|
123
|
-
// Track analytics
|
|
124
|
-
analytics.track("message_sent", { content: message.content });
|
|
125
|
-
}}
|
|
126
|
-
onResponseReceived={(message) => {
|
|
127
|
-
// Log responses
|
|
128
|
-
console.log("AI responded:", message.content);
|
|
129
|
-
}}
|
|
130
|
-
onError={(error) => {
|
|
131
|
-
// Handle errors
|
|
132
|
-
toast.error(error.message);
|
|
133
|
-
}}
|
|
134
|
-
/>
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### With Initial Messages
|
|
138
|
-
|
|
139
|
-
```tsx
|
|
140
|
-
const welcomeMessages = [
|
|
141
|
-
{
|
|
142
|
-
id: "1",
|
|
143
|
-
role: "assistant" as const,
|
|
144
|
-
content: "Hello! How can I help you today?",
|
|
145
|
-
},
|
|
146
|
-
];
|
|
147
|
-
|
|
148
|
-
<AIChat
|
|
149
|
-
apiUrl="https://api.example.com"
|
|
150
|
-
initialMessages={welcomeMessages}
|
|
151
|
-
/>
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### With Dynamic Session Management
|
|
155
|
-
|
|
156
|
-
```tsx
|
|
157
|
-
import { useUser } from "@/hooks/useUser";
|
|
158
|
-
|
|
159
|
-
function ChatPage() {
|
|
160
|
-
const user = useUser();
|
|
161
|
-
|
|
162
|
-
return (
|
|
163
|
-
<AIChat
|
|
164
|
-
apiUrl={process.env.NEXT_PUBLIC_API_URL!}
|
|
165
|
-
sessionId={user.id}
|
|
166
|
-
title={`Chat with ${user.name}'s Assistant`}
|
|
167
|
-
/>
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
## TypeScript
|
|
173
|
-
|
|
174
|
-
Full TypeScript support is included. Import types as needed:
|
|
175
|
-
|
|
176
|
-
```tsx
|
|
177
|
-
import type { Message, AIChatProps } from "@a.izzuddin/ai-chat";
|
|
178
|
-
|
|
179
|
-
const customMessage: Message = {
|
|
180
|
-
id: "123",
|
|
181
|
-
role: "user",
|
|
182
|
-
content: "Hello!",
|
|
183
|
-
};
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
## Styling
|
|
187
|
-
|
|
188
|
-
The component uses Tailwind CSS with custom theme variables. You can customize the appearance by:
|
|
189
|
-
|
|
190
|
-
1. **Using Tailwind's dark mode**: The component automatically supports dark mode
|
|
191
|
-
2. **Custom CSS variables**: Override theme colors in your global CSS
|
|
192
|
-
3. **className prop**: Add custom Tailwind classes to the container
|
|
193
|
-
|
|
194
|
-
### Custom Theme Colors
|
|
195
|
-
|
|
196
|
-
```css
|
|
197
|
-
@layer base {
|
|
198
|
-
:root {
|
|
199
|
-
--primary: oklch(0.205 0 0);
|
|
200
|
-
--primary-foreground: oklch(0.985 0 0);
|
|
201
|
-
/* ... other variables */
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
.dark {
|
|
205
|
-
--primary: oklch(0.922 0 0);
|
|
206
|
-
--primary-foreground: oklch(0.205 0 0);
|
|
207
|
-
/* ... other variables */
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
## Framework Support
|
|
213
|
-
|
|
214
|
-
### Next.js (App Router)
|
|
215
|
-
|
|
216
|
-
```tsx
|
|
217
|
-
"use client";
|
|
218
|
-
|
|
219
|
-
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
220
|
-
import "@a.izzuddin/ai-chat/styles";
|
|
221
|
-
|
|
222
|
-
export default function ChatPage() {
|
|
223
|
-
return <AIChat apiUrl={process.env.NEXT_PUBLIC_API_URL!} />;
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### Next.js (Pages Router)
|
|
228
|
-
|
|
229
|
-
```tsx
|
|
230
|
-
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
231
|
-
import "@a.izzuddin/ai-chat/styles";
|
|
232
|
-
|
|
233
|
-
export default function ChatPage() {
|
|
234
|
-
return <AIChat apiUrl={process.env.NEXT_PUBLIC_API_URL!} />;
|
|
235
|
-
}
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Vite + React
|
|
239
|
-
|
|
240
|
-
```tsx
|
|
241
|
-
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
242
|
-
import "@a.izzuddin/ai-chat/styles";
|
|
243
|
-
|
|
244
|
-
function App() {
|
|
245
|
-
return <AIChat apiUrl={import.meta.env.VITE_API_URL} />;
|
|
246
|
-
}
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
### Create React App
|
|
250
|
-
|
|
251
|
-
```tsx
|
|
252
|
-
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
253
|
-
import "@a.izzuddin/ai-chat/styles";
|
|
254
|
-
|
|
255
|
-
function App() {
|
|
256
|
-
return <AIChat apiUrl={process.env.REACT_APP_API_URL} />;
|
|
257
|
-
}
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
## Examples
|
|
261
|
-
|
|
262
|
-
Check out the [examples directory](./examples) for complete working examples with:
|
|
263
|
-
- Next.js App Router
|
|
264
|
-
- Vite + React
|
|
265
|
-
- Custom styling
|
|
266
|
-
- Advanced features
|
|
267
|
-
|
|
268
|
-
## Browser Support
|
|
269
|
-
|
|
270
|
-
- Chrome/Edge (latest)
|
|
271
|
-
- Firefox (latest)
|
|
272
|
-
- Safari 14+
|
|
273
|
-
- Mobile browsers (iOS Safari, Chrome Android)
|
|
274
|
-
|
|
275
|
-
## Contributing
|
|
276
|
-
|
|
277
|
-
Contributions are welcome! Please read our [contributing guidelines](CONTRIBUTING.md) first.
|
|
278
|
-
|
|
279
|
-
## License
|
|
280
|
-
|
|
281
|
-
MIT © [Your Name]
|
|
282
|
-
|
|
283
|
-
## Related
|
|
284
|
-
|
|
285
|
-
- [Radix UI](https://radix-ui.com/) - Accessible component primitives
|
|
286
|
-
- [Tailwind CSS](https://tailwindcss.com/) - Utility-first CSS framework
|
|
287
|
-
- [shadcn/ui](https://ui.shadcn.com/) - Re-usable components built with Radix UI
|
|
288
|
-
|
|
289
|
-
## Support
|
|
290
|
-
|
|
291
|
-
- 📖 [Documentation](https://github.com/aiddin/ai-chat#readme)
|
|
292
|
-
- 🐛 [Issue Tracker](https://github.com/aiddin/ai-chat/issues)
|
|
293
|
-
- 💬 [Discussions](https://github.com/aiddin/ai-chat/discussions)
|
|
1
|
+
# @a.izzuddin/ai-chat
|
|
2
|
+
|
|
3
|
+
A beautiful, configurable AI chat component for React applications. Built with Radix UI, Tailwind CSS, and TypeScript.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎨 **Beautiful UI** - Modern chat interface with dark mode support
|
|
8
|
+
- ⚡ **Lightweight** - Minimal dependencies, optimized bundle size
|
|
9
|
+
- 🔧 **Configurable** - Customize API endpoint, session management, styling
|
|
10
|
+
- 📱 **Responsive** - Works great on mobile and desktop
|
|
11
|
+
- 🎯 **TypeScript** - Full type safety out of the box
|
|
12
|
+
- ♿ **Accessible** - Built on Radix UI primitives
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @a.izzuddin/ai-chat
|
|
18
|
+
# or
|
|
19
|
+
yarn add @a.izzuddin/ai-chat
|
|
20
|
+
# or
|
|
21
|
+
pnpm add @a.izzuddin/ai-chat
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Peer Dependencies
|
|
25
|
+
|
|
26
|
+
This package requires React 18+ or React 19+:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install react react-dom
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
36
|
+
import "@a.izzuddin/ai-chat/styles";
|
|
37
|
+
|
|
38
|
+
function App() {
|
|
39
|
+
return (
|
|
40
|
+
<AIChat
|
|
41
|
+
apiUrl="https://your-api-endpoint.com"
|
|
42
|
+
sessionId="user-123"
|
|
43
|
+
title="My AI Assistant"
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Tailwind CSS Setup
|
|
50
|
+
|
|
51
|
+
This component uses Tailwind CSS. Add the component path to your `tailwind.config.js`:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
/** @type {import('tailwindcss').Config} */
|
|
55
|
+
module.exports = {
|
|
56
|
+
content: [
|
|
57
|
+
"./app/**/*.{js,ts,jsx,tsx}",
|
|
58
|
+
"./components/**/*.{js,ts,jsx,tsx}",
|
|
59
|
+
// Add this line:
|
|
60
|
+
"./node_modules/@a.izzuddin/ai-chat/**/*.{js,ts,jsx,tsx}",
|
|
61
|
+
],
|
|
62
|
+
// ... rest of your config
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or if using Tailwind v4, add to your CSS:
|
|
67
|
+
|
|
68
|
+
```css
|
|
69
|
+
@import "tailwindcss";
|
|
70
|
+
@import "@a.izzuddin/ai-chat/styles";
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## API Requirements
|
|
74
|
+
|
|
75
|
+
Your API endpoint should accept POST requests to `/ask` with this format:
|
|
76
|
+
|
|
77
|
+
**Request:**
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"session_id": "string",
|
|
81
|
+
"question": "string"
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Response:**
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"response": "string"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Props
|
|
93
|
+
|
|
94
|
+
| Prop | Type | Default | Description |
|
|
95
|
+
|------|------|---------|-------------|
|
|
96
|
+
| `apiUrl` | `string` | *required* | Your API endpoint URL |
|
|
97
|
+
| `sessionId` | `string` | `"default-session"` | Session identifier for conversation context |
|
|
98
|
+
| `title` | `string` | `"My AI Agent"` | Chat header title |
|
|
99
|
+
| `initialMessages` | `Message[]` | `[]` | Pre-populate chat with messages |
|
|
100
|
+
| `className` | `string` | `undefined` | Custom CSS class for container |
|
|
101
|
+
| `onMessageSent` | `(message: Message) => void` | `undefined` | Callback when user sends a message |
|
|
102
|
+
| `onResponseReceived` | `(message: Message) => void` | `undefined` | Callback when AI responds |
|
|
103
|
+
| `onError` | `(error: Error) => void` | `undefined` | Callback when an error occurs |
|
|
104
|
+
|
|
105
|
+
## Advanced Usage
|
|
106
|
+
|
|
107
|
+
### With Custom Styling
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
<AIChat
|
|
111
|
+
apiUrl="https://api.example.com"
|
|
112
|
+
className="max-w-4xl mx-auto shadow-lg"
|
|
113
|
+
title="Customer Support Bot"
|
|
114
|
+
/>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### With Event Handlers
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
<AIChat
|
|
121
|
+
apiUrl="https://api.example.com"
|
|
122
|
+
onMessageSent={(message) => {
|
|
123
|
+
// Track analytics
|
|
124
|
+
analytics.track("message_sent", { content: message.content });
|
|
125
|
+
}}
|
|
126
|
+
onResponseReceived={(message) => {
|
|
127
|
+
// Log responses
|
|
128
|
+
console.log("AI responded:", message.content);
|
|
129
|
+
}}
|
|
130
|
+
onError={(error) => {
|
|
131
|
+
// Handle errors
|
|
132
|
+
toast.error(error.message);
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### With Initial Messages
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
const welcomeMessages = [
|
|
141
|
+
{
|
|
142
|
+
id: "1",
|
|
143
|
+
role: "assistant" as const,
|
|
144
|
+
content: "Hello! How can I help you today?",
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
<AIChat
|
|
149
|
+
apiUrl="https://api.example.com"
|
|
150
|
+
initialMessages={welcomeMessages}
|
|
151
|
+
/>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### With Dynamic Session Management
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
import { useUser } from "@/hooks/useUser";
|
|
158
|
+
|
|
159
|
+
function ChatPage() {
|
|
160
|
+
const user = useUser();
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<AIChat
|
|
164
|
+
apiUrl={process.env.NEXT_PUBLIC_API_URL!}
|
|
165
|
+
sessionId={user.id}
|
|
166
|
+
title={`Chat with ${user.name}'s Assistant`}
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## TypeScript
|
|
173
|
+
|
|
174
|
+
Full TypeScript support is included. Import types as needed:
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
import type { Message, AIChatProps } from "@a.izzuddin/ai-chat";
|
|
178
|
+
|
|
179
|
+
const customMessage: Message = {
|
|
180
|
+
id: "123",
|
|
181
|
+
role: "user",
|
|
182
|
+
content: "Hello!",
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Styling
|
|
187
|
+
|
|
188
|
+
The component uses Tailwind CSS with custom theme variables. You can customize the appearance by:
|
|
189
|
+
|
|
190
|
+
1. **Using Tailwind's dark mode**: The component automatically supports dark mode
|
|
191
|
+
2. **Custom CSS variables**: Override theme colors in your global CSS
|
|
192
|
+
3. **className prop**: Add custom Tailwind classes to the container
|
|
193
|
+
|
|
194
|
+
### Custom Theme Colors
|
|
195
|
+
|
|
196
|
+
```css
|
|
197
|
+
@layer base {
|
|
198
|
+
:root {
|
|
199
|
+
--primary: oklch(0.205 0 0);
|
|
200
|
+
--primary-foreground: oklch(0.985 0 0);
|
|
201
|
+
/* ... other variables */
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.dark {
|
|
205
|
+
--primary: oklch(0.922 0 0);
|
|
206
|
+
--primary-foreground: oklch(0.205 0 0);
|
|
207
|
+
/* ... other variables */
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Framework Support
|
|
213
|
+
|
|
214
|
+
### Next.js (App Router)
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
"use client";
|
|
218
|
+
|
|
219
|
+
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
220
|
+
import "@a.izzuddin/ai-chat/styles";
|
|
221
|
+
|
|
222
|
+
export default function ChatPage() {
|
|
223
|
+
return <AIChat apiUrl={process.env.NEXT_PUBLIC_API_URL!} />;
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Next.js (Pages Router)
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
231
|
+
import "@a.izzuddin/ai-chat/styles";
|
|
232
|
+
|
|
233
|
+
export default function ChatPage() {
|
|
234
|
+
return <AIChat apiUrl={process.env.NEXT_PUBLIC_API_URL!} />;
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Vite + React
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
242
|
+
import "@a.izzuddin/ai-chat/styles";
|
|
243
|
+
|
|
244
|
+
function App() {
|
|
245
|
+
return <AIChat apiUrl={import.meta.env.VITE_API_URL} />;
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Create React App
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
import { AIChat } from "@a.izzuddin/ai-chat";
|
|
253
|
+
import "@a.izzuddin/ai-chat/styles";
|
|
254
|
+
|
|
255
|
+
function App() {
|
|
256
|
+
return <AIChat apiUrl={process.env.REACT_APP_API_URL} />;
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Examples
|
|
261
|
+
|
|
262
|
+
Check out the [examples directory](./examples) for complete working examples with:
|
|
263
|
+
- Next.js App Router
|
|
264
|
+
- Vite + React
|
|
265
|
+
- Custom styling
|
|
266
|
+
- Advanced features
|
|
267
|
+
|
|
268
|
+
## Browser Support
|
|
269
|
+
|
|
270
|
+
- Chrome/Edge (latest)
|
|
271
|
+
- Firefox (latest)
|
|
272
|
+
- Safari 14+
|
|
273
|
+
- Mobile browsers (iOS Safari, Chrome Android)
|
|
274
|
+
|
|
275
|
+
## Contributing
|
|
276
|
+
|
|
277
|
+
Contributions are welcome! Please read our [contributing guidelines](CONTRIBUTING.md) first.
|
|
278
|
+
|
|
279
|
+
## License
|
|
280
|
+
|
|
281
|
+
MIT © [Your Name]
|
|
282
|
+
|
|
283
|
+
## Related
|
|
284
|
+
|
|
285
|
+
- [Radix UI](https://radix-ui.com/) - Accessible component primitives
|
|
286
|
+
- [Tailwind CSS](https://tailwindcss.com/) - Utility-first CSS framework
|
|
287
|
+
- [shadcn/ui](https://ui.shadcn.com/) - Re-usable components built with Radix UI
|
|
288
|
+
|
|
289
|
+
## Support
|
|
290
|
+
|
|
291
|
+
- 📖 [Documentation](https://github.com/aiddin/ai-chat#readme)
|
|
292
|
+
- 🐛 [Issue Tracker](https://github.com/aiddin/ai-chat/issues)
|
|
293
|
+
- 💬 [Discussions](https://github.com/aiddin/ai-chat/discussions)
|
package/custom-elements.json
CHANGED
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"name": "RootLayout",
|
|
20
20
|
"parameters": [
|
|
21
21
|
{
|
|
22
|
-
"name": "{\n children,\n}",
|
|
22
|
+
"name": "{\r\n children,\r\n}",
|
|
23
23
|
"type": {
|
|
24
|
-
"text": "Readonly<{\n children: React.ReactNode;\n}>"
|
|
24
|
+
"text": "Readonly<{\r\n children: React.ReactNode;\r\n}>"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
]
|
|
@@ -279,7 +279,7 @@
|
|
|
279
279
|
"name": "Avatar",
|
|
280
280
|
"parameters": [
|
|
281
281
|
{
|
|
282
|
-
"name": "{\n className,\n ...props\n}",
|
|
282
|
+
"name": "{\r\n className,\r\n ...props\r\n}",
|
|
283
283
|
"type": {
|
|
284
284
|
"text": "React.ComponentProps<typeof AvatarPrimitive.Root>"
|
|
285
285
|
}
|
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
"name": "AvatarImage",
|
|
292
292
|
"parameters": [
|
|
293
293
|
{
|
|
294
|
-
"name": "{\n className,\n ...props\n}",
|
|
294
|
+
"name": "{\r\n className,\r\n ...props\r\n}",
|
|
295
295
|
"type": {
|
|
296
296
|
"text": "React.ComponentProps<typeof AvatarPrimitive.Image>"
|
|
297
297
|
}
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
"name": "AvatarFallback",
|
|
304
304
|
"parameters": [
|
|
305
305
|
{
|
|
306
|
-
"name": "{\n className,\n ...props\n}",
|
|
306
|
+
"name": "{\r\n className,\r\n ...props\r\n}",
|
|
307
307
|
"type": {
|
|
308
308
|
"text": "React.ComponentProps<typeof AvatarPrimitive.Fallback>"
|
|
309
309
|
}
|
|
@@ -351,9 +351,9 @@
|
|
|
351
351
|
"name": "Button",
|
|
352
352
|
"parameters": [
|
|
353
353
|
{
|
|
354
|
-
"name": "{\n className,\n variant,\n size,\n asChild = false,\n ...props\n}",
|
|
354
|
+
"name": "{\r\n className,\r\n variant,\r\n size,\r\n asChild = false,\r\n ...props\r\n}",
|
|
355
355
|
"type": {
|
|
356
|
-
"text": "React.ComponentProps<\"button\"> &\n VariantProps<typeof buttonVariants> & {\n asChild?: boolean\n }"
|
|
356
|
+
"text": "React.ComponentProps<\"button\"> &\r\n VariantProps<typeof buttonVariants> & {\r\n asChild?: boolean\r\n }"
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
]
|
|
@@ -435,7 +435,7 @@
|
|
|
435
435
|
"name": "ScrollArea",
|
|
436
436
|
"parameters": [
|
|
437
437
|
{
|
|
438
|
-
"name": "{\n className,\n children,\n ...props\n}",
|
|
438
|
+
"name": "{\r\n className,\r\n children,\r\n ...props\r\n}",
|
|
439
439
|
"type": {
|
|
440
440
|
"text": "React.ComponentProps<typeof ScrollAreaPrimitive.Root>"
|
|
441
441
|
}
|
|
@@ -447,7 +447,7 @@
|
|
|
447
447
|
"name": "ScrollBar",
|
|
448
448
|
"parameters": [
|
|
449
449
|
{
|
|
450
|
-
"name": "{\n className,\n orientation = \"vertical\",\n ...props\n}",
|
|
450
|
+
"name": "{\r\n className,\r\n orientation = \"vertical\",\r\n ...props\r\n}",
|
|
451
451
|
"type": {
|
|
452
452
|
"text": "React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>"
|
|
453
453
|
}
|
|
@@ -483,7 +483,7 @@
|
|
|
483
483
|
"name": "Separator",
|
|
484
484
|
"parameters": [
|
|
485
485
|
{
|
|
486
|
-
"name": "{\n className,\n orientation = \"horizontal\",\n decorative = true,\n ...props\n}",
|
|
486
|
+
"name": "{\r\n className,\r\n orientation = \"horizontal\",\r\n decorative = true,\r\n ...props\r\n}",
|
|
487
487
|
"type": {
|
|
488
488
|
"text": "React.ComponentProps<typeof SeparatorPrimitive.Root>"
|
|
489
489
|
}
|
|
@@ -687,7 +687,7 @@
|
|
|
687
687
|
"type": {
|
|
688
688
|
"text": "string"
|
|
689
689
|
},
|
|
690
|
-
"default": "'#
|
|
690
|
+
"default": "'#1a4fbd'",
|
|
691
691
|
"attribute": "user-message-bg"
|
|
692
692
|
},
|
|
693
693
|
{
|
|
@@ -1251,7 +1251,7 @@
|
|
|
1251
1251
|
"type": {
|
|
1252
1252
|
"text": "string"
|
|
1253
1253
|
},
|
|
1254
|
-
"default": "'#
|
|
1254
|
+
"default": "'#1a4fbd'",
|
|
1255
1255
|
"fieldName": "userMessageBg"
|
|
1256
1256
|
},
|
|
1257
1257
|
{
|
|
@@ -1371,7 +1371,7 @@
|
|
|
1371
1371
|
"name": "AIChat",
|
|
1372
1372
|
"parameters": [
|
|
1373
1373
|
{
|
|
1374
|
-
"name": "{\r\n apiUrl,\r\n sessionId = \"default-session\",\r\n title = \"My AI Agent\",\r\n initialMessages = [],\r\n className,\r\n onMessageSent,\r\n onResponseReceived,\r\n onError,\r\n}",
|
|
1374
|
+
"name": "{\r\n apiUrl,\r\n sessionId = \"default-session\",\r\n title = \"My AI Agent\",\r\n initialMessages = [],\r\n className,\r\n onMessageSent,\r\n onResponseReceived,\r\n onError,\r\n language = \"en\",\r\n}",
|
|
1375
1375
|
"type": {
|
|
1376
1376
|
"text": "AIChatProps"
|
|
1377
1377
|
}
|