@jazzmine-ui/react 0.1.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/LICENSE +21 -0
- package/README.md +419 -0
- package/dist/index.d.ts +1 -0
- package/dist/jazzmine-ui.js +8982 -0
- package/dist/jazzmine-ui.umd.cjs +44 -0
- package/dist/style.css +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Jazzmine Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
# Jazzmine UI
|
|
2
|
+
|
|
3
|
+
A customizable React chat UI component library.
|
|
4
|
+
|
|
5
|
+
This package gives you two integration modes:
|
|
6
|
+
|
|
7
|
+
- Fully controlled UI with ChatInterface and your own data handlers.
|
|
8
|
+
- SDK-powered UI with JazzmineChat and an IJazzmineClient-compatible client.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @jazzmine-ui/react
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Peer dependencies:
|
|
17
|
+
|
|
18
|
+
- react
|
|
19
|
+
- react-dom
|
|
20
|
+
|
|
21
|
+
## Styles
|
|
22
|
+
|
|
23
|
+
Import styles once in your app entry:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import '@jazzmine-ui/react/styles';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Public Exports
|
|
30
|
+
|
|
31
|
+
Components:
|
|
32
|
+
|
|
33
|
+
- ChatInterface
|
|
34
|
+
- Sidebar
|
|
35
|
+
- MessageList
|
|
36
|
+
- FloatingChatWidget
|
|
37
|
+
- JazzmineChat
|
|
38
|
+
|
|
39
|
+
Types:
|
|
40
|
+
|
|
41
|
+
- ChatInterfaceProps
|
|
42
|
+
- SidebarProps
|
|
43
|
+
- MessageListProps
|
|
44
|
+
- FloatingChatWidgetProps
|
|
45
|
+
- JazzmineChatProps
|
|
46
|
+
- IJazzmineClient
|
|
47
|
+
- Message
|
|
48
|
+
- Chat
|
|
49
|
+
|
|
50
|
+
Example import of everything public:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import {
|
|
54
|
+
ChatInterface,
|
|
55
|
+
Sidebar,
|
|
56
|
+
MessageList,
|
|
57
|
+
FloatingChatWidget,
|
|
58
|
+
JazzmineChat,
|
|
59
|
+
} from '@jazzmine-ui/react';
|
|
60
|
+
|
|
61
|
+
import type {
|
|
62
|
+
ChatInterfaceProps,
|
|
63
|
+
SidebarProps,
|
|
64
|
+
MessageListProps,
|
|
65
|
+
FloatingChatWidgetProps,
|
|
66
|
+
JazzmineChatProps,
|
|
67
|
+
IJazzmineClient,
|
|
68
|
+
Message,
|
|
69
|
+
Chat,
|
|
70
|
+
} from '@jazzmine-ui/react';
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 1) JazzmineChat (SDK-powered)
|
|
74
|
+
|
|
75
|
+
JazzmineChat is the fastest way to integrate.
|
|
76
|
+
It manages:
|
|
77
|
+
|
|
78
|
+
- conversation creation
|
|
79
|
+
- message sending
|
|
80
|
+
- loading state
|
|
81
|
+
- conversation deletion
|
|
82
|
+
- basic error fallback behavior
|
|
83
|
+
|
|
84
|
+
You provide a client that matches IJazzmineClient.
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
'use client';
|
|
88
|
+
|
|
89
|
+
import React from 'react';
|
|
90
|
+
import { JazzmineChat } from '@jazzmine-ui/react';
|
|
91
|
+
import type { IJazzmineClient } from '@jazzmine-ui/react';
|
|
92
|
+
import '@jazzmine-ui/react/styles';
|
|
93
|
+
|
|
94
|
+
// Example: any SDK client that structurally satisfies IJazzmineClient.
|
|
95
|
+
declare const client: IJazzmineClient;
|
|
96
|
+
|
|
97
|
+
export function App() {
|
|
98
|
+
return (
|
|
99
|
+
<div style={{ height: '100vh' }}>
|
|
100
|
+
<JazzmineChat
|
|
101
|
+
client={client}
|
|
102
|
+
placeholder="Ask anything..."
|
|
103
|
+
onError={(error) => {
|
|
104
|
+
console.error('JazzmineChat error:', error);
|
|
105
|
+
}}
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
JazzmineChatProps:
|
|
113
|
+
|
|
114
|
+
- client: IJazzmineClient (required)
|
|
115
|
+
- assistantName: string
|
|
116
|
+
- placeholder: string
|
|
117
|
+
- className: string
|
|
118
|
+
- onError: (error: Error) => void
|
|
119
|
+
|
|
120
|
+
## 2) ChatInterface (fully controlled)
|
|
121
|
+
|
|
122
|
+
Use this when your app owns all data fetching/state.
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import React from 'react';
|
|
126
|
+
import { ChatInterface } from '@jazzmine-ui/react';
|
|
127
|
+
import type { Chat, Message } from '@jazzmine-ui/react';
|
|
128
|
+
import '@jazzmine-ui/react/styles';
|
|
129
|
+
|
|
130
|
+
export function App() {
|
|
131
|
+
const [messages, setMessages] = React.useState<Message[]>([]);
|
|
132
|
+
const [chats, setChats] = React.useState<Chat[]>([]);
|
|
133
|
+
const [activeChatId, setActiveChatId] = React.useState<string>();
|
|
134
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
135
|
+
|
|
136
|
+
const onSend = async (text: string) => {
|
|
137
|
+
setMessages((prev) => [
|
|
138
|
+
...prev,
|
|
139
|
+
{ id: crypto.randomUUID(), text, sender: 'user', timestamp: new Date().toISOString() },
|
|
140
|
+
]);
|
|
141
|
+
|
|
142
|
+
setIsLoading(true);
|
|
143
|
+
try {
|
|
144
|
+
const reply = `Echo: ${text}`;
|
|
145
|
+
setMessages((prev) => [
|
|
146
|
+
...prev,
|
|
147
|
+
{
|
|
148
|
+
id: crypto.randomUUID(),
|
|
149
|
+
text: reply,
|
|
150
|
+
sender: 'assistant',
|
|
151
|
+
timestamp: new Date().toISOString(),
|
|
152
|
+
},
|
|
153
|
+
]);
|
|
154
|
+
} finally {
|
|
155
|
+
setIsLoading(false);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const onNewChat = () => {
|
|
160
|
+
const id = crypto.randomUUID();
|
|
161
|
+
setChats((prev) => [{ id, title: 'New Chat', timestamp: 'Now' }, ...prev]);
|
|
162
|
+
setActiveChatId(id);
|
|
163
|
+
setMessages([]);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const onSelectChat = (chatId: string) => {
|
|
167
|
+
setActiveChatId(chatId);
|
|
168
|
+
setMessages([]);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const onDeleteChat = (chatId: string) => {
|
|
172
|
+
setChats((prev) => prev.filter((chat) => chat.id !== chatId));
|
|
173
|
+
if (activeChatId === chatId) {
|
|
174
|
+
setActiveChatId(undefined);
|
|
175
|
+
setMessages([]);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<div style={{ height: '100vh' }}>
|
|
181
|
+
<ChatInterface
|
|
182
|
+
chats={chats}
|
|
183
|
+
activeChatId={activeChatId}
|
|
184
|
+
messages={messages}
|
|
185
|
+
assistantName="Jazzmine AI"
|
|
186
|
+
isLoading={isLoading}
|
|
187
|
+
onSend={onSend}
|
|
188
|
+
onNewChat={onNewChat}
|
|
189
|
+
onSelectChat={onSelectChat}
|
|
190
|
+
onDeleteChat={onDeleteChat}
|
|
191
|
+
placeholder="Type your message..."
|
|
192
|
+
/>
|
|
193
|
+
</div>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
ChatInterfaceProps:
|
|
199
|
+
|
|
200
|
+
- messages: Message[]
|
|
201
|
+
- chats: Chat[]
|
|
202
|
+
- activeChatId: string
|
|
203
|
+
- assistantName: string
|
|
204
|
+
- onSend: (text: string, contexts?: Context[]) => void
|
|
205
|
+
- onNewChat: () => void
|
|
206
|
+
- onSelectChat: (chatId: string) => void
|
|
207
|
+
- onDeleteChat: (chatId: string) => void
|
|
208
|
+
- loadingText: string
|
|
209
|
+
- loadingVariant: text-and-dots | dots-only
|
|
210
|
+
- isLoading: boolean
|
|
211
|
+
- placeholder: string
|
|
212
|
+
- className: string
|
|
213
|
+
|
|
214
|
+
## 3) FloatingChatWidget
|
|
215
|
+
|
|
216
|
+
Compact floating launcher + chat panel.
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
import React from 'react';
|
|
220
|
+
import { FloatingChatWidget } from '@jazzmine-ui/react';
|
|
221
|
+
import type { Message } from '@jazzmine-ui/react';
|
|
222
|
+
|
|
223
|
+
export function WidgetDemo() {
|
|
224
|
+
const [messages, setMessages] = React.useState<Message[]>([]);
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<FloatingChatWidget
|
|
228
|
+
messages={messages}
|
|
229
|
+
assistantName="Jazzmine AI"
|
|
230
|
+
initialOpen={false}
|
|
231
|
+
onSend={(text) => {
|
|
232
|
+
setMessages((prev) => [
|
|
233
|
+
...prev,
|
|
234
|
+
{ id: crypto.randomUUID(), text, sender: 'user', timestamp: new Date().toISOString() },
|
|
235
|
+
]);
|
|
236
|
+
}}
|
|
237
|
+
/>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
FloatingChatWidgetProps:
|
|
243
|
+
|
|
244
|
+
- messages: Message[]
|
|
245
|
+
- assistantName: string
|
|
246
|
+
- isLoading: boolean
|
|
247
|
+
- loadingText: string
|
|
248
|
+
- loadingVariant: text-and-dots | dots-only
|
|
249
|
+
- initialOpen: boolean
|
|
250
|
+
- onOpen: (open: boolean) => void
|
|
251
|
+
- onSend: (text: string) => void
|
|
252
|
+
- logo: string
|
|
253
|
+
- className: string
|
|
254
|
+
|
|
255
|
+
## 4) Sidebar
|
|
256
|
+
|
|
257
|
+
Use standalone if you only need conversation navigation UI.
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
import React from 'react';
|
|
261
|
+
import { Sidebar } from '@jazzmine-ui/react';
|
|
262
|
+
import type { Chat } from '@jazzmine-ui/react';
|
|
263
|
+
|
|
264
|
+
export function SidebarDemo() {
|
|
265
|
+
const [chats] = React.useState<Chat[]>([
|
|
266
|
+
{ id: '1', title: 'General', timestamp: 'Today' },
|
|
267
|
+
{ id: '2', title: 'Ideas', timestamp: 'Yesterday' },
|
|
268
|
+
]);
|
|
269
|
+
|
|
270
|
+
return (
|
|
271
|
+
<Sidebar
|
|
272
|
+
chats={chats}
|
|
273
|
+
activeChatId="1"
|
|
274
|
+
assistantName="Jazzmine AI"
|
|
275
|
+
onNewChat={() => {}}
|
|
276
|
+
onSelectChat={(chatId) => console.log(chatId)}
|
|
277
|
+
onDeleteChat={(chatId) => console.log('delete', chatId)}
|
|
278
|
+
/>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
SidebarProps:
|
|
284
|
+
|
|
285
|
+
- chats: Chat[]
|
|
286
|
+
- activeChatId: string
|
|
287
|
+
- assistantName: string
|
|
288
|
+
- logo: string
|
|
289
|
+
- logoAlt: string
|
|
290
|
+
- chatActions: ChatAction[]
|
|
291
|
+
- onNewChat: () => void
|
|
292
|
+
- onSelectChat: (chatId: string) => void
|
|
293
|
+
- onRenameChat: (chatId: string) => void
|
|
294
|
+
- onDeleteChat: (chatId: string) => void
|
|
295
|
+
- onArchiveChat: (chatId: string) => void
|
|
296
|
+
- className: string
|
|
297
|
+
- collapsed: boolean
|
|
298
|
+
- onToggleCollapse: (value?: boolean) => void
|
|
299
|
+
|
|
300
|
+
## 5) MessageList
|
|
301
|
+
|
|
302
|
+
Use standalone if you only need the message feed block.
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
import React from 'react';
|
|
306
|
+
import { MessageList } from '@jazzmine-ui/react';
|
|
307
|
+
import type { Message } from '@jazzmine-ui/react';
|
|
308
|
+
|
|
309
|
+
export function MessageListDemo() {
|
|
310
|
+
const messages: Message[] = [
|
|
311
|
+
{ id: '1', text: 'Hello', sender: 'user' },
|
|
312
|
+
{ id: '2', text: 'Hi, how can I help?', sender: 'assistant' },
|
|
313
|
+
];
|
|
314
|
+
|
|
315
|
+
return <MessageList messages={messages} assistantName="Jazzmine AI" />;
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
MessageListProps:
|
|
320
|
+
|
|
321
|
+
- messages: Message[]
|
|
322
|
+
- assistantName: string
|
|
323
|
+
- isLoading: boolean
|
|
324
|
+
- loadingText: string
|
|
325
|
+
- loadingVariant: text-and-dots | dots-only
|
|
326
|
+
- className: string
|
|
327
|
+
- searchQuery: string
|
|
328
|
+
- activeSearchMessageId: string
|
|
329
|
+
- onAddContext: (context: Context) => void
|
|
330
|
+
- scrollRef: ref object or callback ref
|
|
331
|
+
|
|
332
|
+
## Exported Core Types
|
|
333
|
+
|
|
334
|
+
Message:
|
|
335
|
+
|
|
336
|
+
```ts
|
|
337
|
+
interface Message {
|
|
338
|
+
id: string;
|
|
339
|
+
text: string;
|
|
340
|
+
sender: 'user' | 'assistant';
|
|
341
|
+
timestamp?: string;
|
|
342
|
+
avatar?: string;
|
|
343
|
+
contexts?: {
|
|
344
|
+
id: string;
|
|
345
|
+
messageId: string;
|
|
346
|
+
text: string;
|
|
347
|
+
sender: 'user' | 'assistant';
|
|
348
|
+
isPartial: boolean;
|
|
349
|
+
}[];
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Chat:
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
interface Chat {
|
|
357
|
+
id: string;
|
|
358
|
+
title: string;
|
|
359
|
+
timestamp?: string;
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
IJazzmineClient:
|
|
364
|
+
|
|
365
|
+
```ts
|
|
366
|
+
interface IJazzmineClient {
|
|
367
|
+
sendMessage(
|
|
368
|
+
message: string,
|
|
369
|
+
options?: {
|
|
370
|
+
conversationId?: string;
|
|
371
|
+
autoCreateConversation?: boolean;
|
|
372
|
+
conversationTitle?: string;
|
|
373
|
+
}
|
|
374
|
+
): Promise<{
|
|
375
|
+
response: {
|
|
376
|
+
response: string;
|
|
377
|
+
response_markdown: string;
|
|
378
|
+
conversation_id: string;
|
|
379
|
+
message_id: string;
|
|
380
|
+
is_blocked: boolean;
|
|
381
|
+
errors: string[];
|
|
382
|
+
};
|
|
383
|
+
conversationId: string;
|
|
384
|
+
}>;
|
|
385
|
+
|
|
386
|
+
createConversation(payload?: { title?: string; user_id?: string }): Promise<{
|
|
387
|
+
conversation_id: string;
|
|
388
|
+
title: string;
|
|
389
|
+
}>;
|
|
390
|
+
|
|
391
|
+
deleteConversation(conversationId: string): Promise<{
|
|
392
|
+
conversation_id: string;
|
|
393
|
+
deleted: boolean;
|
|
394
|
+
}>;
|
|
395
|
+
|
|
396
|
+
getHealth(): Promise<{
|
|
397
|
+
status: string;
|
|
398
|
+
agent_name: string;
|
|
399
|
+
}>;
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
## Notes
|
|
404
|
+
|
|
405
|
+
- This package does not import from @jazzmine-ui/sdk directly.
|
|
406
|
+
- Any SDK client that structurally matches IJazzmineClient works.
|
|
407
|
+
- JazzmineChat is a client-side component and includes a use client directive.
|
|
408
|
+
|
|
409
|
+
## Development
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
npm install
|
|
413
|
+
npm run lint
|
|
414
|
+
npm run build
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
## License
|
|
418
|
+
|
|
419
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|