@colletdev/docs 0.2.16 → 0.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/components.md +115 -7
  2. package/messages.md +89 -75
  3. package/package.json +1 -1
package/components.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  ## Overview
7
7
 
8
- Collet ships 52 components as Custom Elements (`<cx-*>`) with
8
+ Collet ships 54 components as Custom Elements (`<cx-*>`) with
9
9
  framework wrappers for React, Vue, Svelte, and Angular.
10
10
 
11
11
  **npm packages:**
@@ -95,7 +95,7 @@ Grouped activity feed with expandable entries and status indicators.
95
95
  | summary | `string` | — | |
96
96
  | action | `string` | — | |
97
97
  | expanded | `boolean` | `false` | |
98
- | parts | `string` | — | |
98
+ | parts | `string[] \| string` | — | |
99
99
 
100
100
  ---
101
101
 
@@ -497,6 +497,69 @@ Import from `@colletdev/core/types`:
497
497
 
498
498
  ---
499
499
 
500
+ ### Chat
501
+
502
+ Chat component.
503
+
504
+ **Tag:** `<cx-chat>` | **Form:** no | **Slots:** header, footer | **Ref methods:** addMessage, scrollToBottom, clear, focus
505
+
506
+ #### Import
507
+
508
+ | Framework | Import |
509
+ |-----------|--------|
510
+ | React | `import { Chat } from '@colletdev/react'` |
511
+ | Vue | `import { Chat } from '@colletdev/vue'` |
512
+ | Svelte | `import Chat from '@colletdev/svelte/chat.svelte'` |
513
+ | Angular | `import { CxChat } from '@colletdev/angular'` |
514
+
515
+ #### Props
516
+
517
+ | Prop | Type | Default | Description |
518
+ |------|------|---------|-------------|
519
+ | id | `string` | — | |
520
+ | shape | `'sharp' \| 'rounded'` | — | |
521
+ | layout | `'standard' \| 'compact' \| 'fullscreen'` | — | |
522
+ | size | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | — | |
523
+ | height | `string` | — | |
524
+ | scrollbarShape | `string` | — | |
525
+ | scrollbarTrack | `string` | — | |
526
+ | turns | `ChatTurn[] \| string` | — | |
527
+ | typing | `'' \| 'typing'` | — | |
528
+ | typingSender | `string` | — | |
529
+ | inputShape | `string` | — | |
530
+ | inputPlaceholder | `string` | — | |
531
+ | inputDisabled | `boolean` | `false` | |
532
+ | inputMaxLength | `number` | `0` | |
533
+ | showActionButton | `boolean` | `false` | |
534
+ | label | `string` | — | |
535
+ | inputLabel | `string` | — | |
536
+ | submitLabel | `string` | — | |
537
+ | emptyState | `string` | — | |
538
+
539
+ #### Events
540
+
541
+ | Event | React | Vue | Detail |
542
+ |-------|-------|-----|--------|
543
+ | `cx-submit` | `onSubmit` | `@cx-submit` | `ChatSubmitDetail` |
544
+
545
+ #### Ref Methods
546
+
547
+ | Method | Description |
548
+ |--------|-------------|
549
+ | `addMessage(html: string): void` | Adds a pre-rendered message turn to the chat. |
550
+ | `scrollToBottom()` | Scrolls the message area to the bottom. |
551
+ | `clear()` | Clears all messages from the chat. |
552
+ | `focus()` | Focuses the chat input textarea. |
553
+
554
+ #### Structured Types
555
+
556
+ Import from `@colletdev/core/types`:
557
+
558
+ - `ChatSubmitDetail`
559
+ - `ChatTurn`
560
+
561
+ ---
562
+
500
563
  ### ChatInput
501
564
 
502
565
  Multi-line text area optimized for chat message composition.
@@ -1120,7 +1183,7 @@ Chat message container with sender alignment and avatar.
1120
1183
  | Prop | Type | Default | Description |
1121
1184
  |------|------|---------|-------------|
1122
1185
  | id | `string` | — | |
1123
- | role | `'user' \| 'assistant'` | — | |
1186
+ | messageRole | `string` | — | |
1124
1187
  | variant | `'filled' \| 'ghost'` | — | |
1125
1188
  | shape | `'sharp' \| 'rounded'` | — | |
1126
1189
  | alignment | `'auto' \| 'start' \| 'end'` | — | |
@@ -1153,7 +1216,7 @@ Grouped sequence of message parts (text, code, tool calls, thinking).
1153
1216
  | Prop | Type | Default | Description |
1154
1217
  |------|------|---------|-------------|
1155
1218
  | id | `string` | — | |
1156
- | role | `'user' \| 'assistant'` | — | |
1219
+ | messageRole | `string` | — | |
1157
1220
  | alignment | `'auto' \| 'start' \| 'end'` | — | |
1158
1221
  | size | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | — | |
1159
1222
  | senderName | `string` | — | |
@@ -1205,11 +1268,17 @@ MessageTimeline component.
1205
1268
  | Prop | Type | Default | Description |
1206
1269
  |------|------|---------|-------------|
1207
1270
  | id | `string` | — | |
1208
- | role | `string` | — | |
1209
- | alignment | `string` | — | |
1271
+ | messageRole | `string` | — | |
1272
+ | alignment | `'auto' \| 'start' \| 'end'` | — | |
1210
1273
  | size | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | — | |
1211
1274
  | senderName | `string` | — | |
1212
- | events | `string` | — | |
1275
+ | events | `TimelineEvent[] \| string` | — | |
1276
+
1277
+ #### Structured Types
1278
+
1279
+ Import from `@colletdev/core/types`:
1280
+
1281
+ - `TimelineEvent`
1213
1282
 
1214
1283
  ---
1215
1284
 
@@ -1426,6 +1495,45 @@ Import from `@colletdev/core/types`:
1426
1495
 
1427
1496
  ---
1428
1497
 
1498
+ ### ScrollArea
1499
+
1500
+ ScrollArea component.
1501
+
1502
+ **Tag:** `<cx-scroll-area>` | **Form:** no | **Slots:** default | **Ref methods:** scrollToBottom, scrollToTop
1503
+
1504
+ #### Import
1505
+
1506
+ | Framework | Import |
1507
+ |-----------|--------|
1508
+ | React | `import { ScrollArea } from '@colletdev/react'` |
1509
+ | Vue | `import { ScrollArea } from '@colletdev/vue'` |
1510
+ | Svelte | `import ScrollArea from '@colletdev/svelte/scroll-area.svelte'` |
1511
+ | Angular | `import { CxScrollArea } from '@colletdev/angular'` |
1512
+
1513
+ #### Props
1514
+
1515
+ | Prop | Type | Default | Description |
1516
+ |------|------|---------|-------------|
1517
+ | id | `string` | — | |
1518
+ | shape | `'sharp' \| 'rounded' \| 'pill'` | — | |
1519
+ | track | `'with-track' \| 'floating'` | — | |
1520
+ | axis | `'vertical' \| 'horizontal' \| 'both'` | — | |
1521
+ | size | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | — | |
1522
+ | height | `string` | — | |
1523
+ | label | `string` | — | |
1524
+ | autoScroll | `string` | — | |
1525
+ | newContentLabel | `string` | — | |
1526
+ | logRole | `boolean` | `false` | |
1527
+
1528
+ #### Ref Methods
1529
+
1530
+ | Method | Description |
1531
+ |--------|-------------|
1532
+ | `scrollToBottom()` | Scrolls content to the bottom. |
1533
+ | `scrollToTop()` | Scrolls content to the top. |
1534
+
1535
+ ---
1536
+
1429
1537
  ### Scrollbar
1430
1538
 
1431
1539
  Custom-styled scrollbar container for overflow content.
package/messages.md CHANGED
@@ -32,25 +32,24 @@ The outer container. Controls sender alignment, avatar, name, and timestamp.
32
32
  ```tsx
33
33
  import { MessageBubble } from '@colletdev/react';
34
34
 
35
- <MessageBubble role="assistant" senderName="Collet" avatar="/collet.svg">
35
+ <MessageBubble messageRole="assistant" senderName="Collet">
36
36
  {/* MessageGroup(s) go here */}
37
37
  </MessageBubble>
38
38
 
39
- <MessageBubble role="user" senderName="Dan">
39
+ <MessageBubble messageRole="user" senderName="Dan">
40
40
  {/* User message content */}
41
41
  </MessageBubble>
42
42
  ```
43
43
 
44
44
  | Prop | Type | Default | Description |
45
45
  |------|------|---------|-------------|
46
- | `role` | `'user' \| 'assistant'` | `'user'` | Determines alignment and color |
46
+ | `messageRole` | `'user' \| 'assistant'` | `'user'` | Determines alignment and color |
47
47
  | `senderName` | `string` | — | Name displayed above the bubble |
48
- | `avatar` | `string` | — | Avatar image URL |
49
48
  | `timestamp` | `string` | — | Timestamp text |
50
49
  | `variant` | `'filled' \| 'ghost'` | `'filled'` | Visual style |
51
50
  | `shape` | `'sharp' \| 'rounded'` | `'rounded'` | Border radius |
52
51
 
53
- **Alignment:** `role="user"` right-aligns, `role="assistant"` left-aligns.
52
+ **Alignment:** `messageRole="user"` right-aligns, `messageRole="assistant"` left-aligns.
54
53
 
55
54
  ### MessageGroup
56
55
 
@@ -60,18 +59,17 @@ a group share edges (no gaps between them).
60
59
  ```tsx
61
60
  import { MessageGroup } from '@colletdev/react';
62
61
 
63
- <MessageGroup role="assistant">
64
- <MessagePart kind="text">Here is what I found:</MessagePart>
65
- <MessagePart kind="code-block" language="rust" filename="main.rs">
66
- fn main() { println!("Hello"); }
67
- </MessagePart>
68
- </MessageGroup>
62
+ <MessageGroup messageRole="assistant" parts={[
63
+ '<div>Here is what I found:</div>',
64
+ '<pre><code>fn main() { println!("Hello"); }</code></pre>',
65
+ ]} />
69
66
  ```
70
67
 
71
68
  | Prop | Type | Default | Description |
72
69
  |------|------|---------|-------------|
73
- | `role` | `'user' \| 'assistant'` | `'user'` | Color scheme |
70
+ | `messageRole` | `'user' \| 'assistant'` | `'user'` | Color scheme |
74
71
  | `variant` | `'filled' \| 'ghost'` | `'filled'` | Visual style |
72
+ | `parts` | `string[]` | `[]` | Pre-rendered part HTML strings |
75
73
 
76
74
  ### MessagePart
77
75
 
@@ -108,18 +106,17 @@ import { MessagePart } from '@colletdev/react';
108
106
  kind="tool-call"
109
107
  toolName="search_docs"
110
108
  toolArguments='{"query": "auth"}'
111
- status="pending"
109
+ toolStatus="pending"
112
110
  />
113
111
 
114
112
  {/* Tool result */}
115
113
  <MessagePart
116
114
  kind="tool-result"
117
115
  toolName="search_docs"
118
- status="success"
116
+ toolStatus="success"
119
117
  collapsible
120
- >
121
- Found 3 results...
122
- </MessagePart>
118
+ content="Found 3 results..."
119
+ />
123
120
 
124
121
  {/* Thinking indicator */}
125
122
  <MessagePart kind="thinking" thinkingLabel="Analyzing code..." />
@@ -136,10 +133,10 @@ The status is computed from child tool states — you don't set it manually.
136
133
  ```tsx
137
134
  import { ActivityGroup } from '@colletdev/react';
138
135
 
139
- <ActivityGroup label="Code analysis" status="running">
140
- <MessagePart kind="tool-call" toolName="read_file" status="success" />
141
- <MessagePart kind="tool-call" toolName="search_code" status="pending" />
142
- </ActivityGroup>
136
+ <ActivityGroup summary="Code analysis" parts={[
137
+ '<div>pre-rendered tool-call HTML</div>',
138
+ '<div>pre-rendered tool-call HTML</div>',
139
+ ]} />
143
140
  ```
144
141
 
145
142
  | Status | Meaning | Visual |
@@ -239,10 +236,10 @@ function StreamingMessage() {
239
236
 
240
237
  ---
241
238
 
242
- ## MessageTimeline (Rust-side reducer)
239
+ ## MessageTimeline (Event Reducer)
243
240
 
244
241
  For production chat UIs with tool calls, streaming, and complex turn lifecycle,
245
- Collet provides a Rust-side chronological reducer. This is the recommended way
242
+ Collet provides a chronological event reducer. This is the recommended way
246
243
  to build AI assistant interfaces.
247
244
 
248
245
  **What it handles:**
@@ -253,74 +250,91 @@ to build AI assistant interfaces.
253
250
  - Duplicate tool result deduplication
254
251
  - Terminal turn immutability (completed/aborted turns reject new events)
255
252
 
256
- **Note:** MessageTimeline is currently Rust-side only. It renders directly to HTML
257
- via the SSR gallery. WASM/npm export is planned — see the project roadmap.
253
+ **Available via WASM** pass an `events` array and the reducer renders
254
+ the full turn to HTML:
255
+
256
+ ```tsx
257
+ import { MessageTimeline } from '@colletdev/react';
258
+ import type { TimelineEvent } from '@colletdev/react';
259
+
260
+ const events: TimelineEvent[] = [
261
+ { type: 'text-delta', id: 'p1', delta: 'Hello ', markdown: true },
262
+ { type: 'text-delta', id: 'p1', delta: '**world**' },
263
+ { type: 'thinking-start', id: 't1', label: 'Analyzing...' },
264
+ { type: 'thinking-done', id: 't1', label: 'Analysis complete' },
265
+ { type: 'tool-call-start', group_id: 'g1', call_id: 'c1',
266
+ tool_name: 'read_file', description: 'Reading main.rs' },
267
+ { type: 'tool-call-done', group_id: 'g1', call_id: 'c1' },
268
+ { type: 'tool-result', group_id: 'g1', result_id: 'r1', call_id: 'c1',
269
+ tool_name: 'read_file', content: 'fn main() {}', status: 'success' },
270
+ { type: 'code-block', id: 'cb1', code: 'fn main() {}',
271
+ language: 'rust', filename: 'main.rs' },
272
+ ];
273
+
274
+ <MessageTimeline
275
+ messageRole="assistant"
276
+ senderName="Collet"
277
+ events={events}
278
+ />
258
279
 
259
280
  ---
260
281
 
261
282
  ## Complete Example
262
283
 
263
- A full AI assistant conversation with tool calls:
284
+ A full AI assistant conversation using MessageTimeline's event reducer:
264
285
 
265
286
  ```tsx
266
- import {
267
- MessageBubble, MessageGroup, MessagePart, ActivityGroup
268
- } from '@colletdev/react';
287
+ import { Chat, MessageTimeline } from '@colletdev/react';
288
+ import type { TimelineEvent } from '@colletdev/react';
269
289
 
270
290
  function Conversation() {
291
+ const assistantEvents: TimelineEvent[] = [
292
+ { type: 'thinking-start', id: 't1', label: 'Searching documentation...' },
293
+ { type: 'thinking-done', id: 't1', label: 'Searched documentation' },
294
+ { type: 'tool-call-start', group_id: 'g1', call_id: 'c1',
295
+ tool_name: 'search_docs', description: 'Searched Next.js setup guide' },
296
+ { type: 'tool-call-done', group_id: 'g1', call_id: 'c1' },
297
+ { type: 'tool-result', group_id: 'g1', result_id: 'r1', call_id: 'c1',
298
+ tool_name: 'search_docs', content: '3 results found', status: 'success' },
299
+ { type: 'text-done', id: 'p1', content: "Here's how to set up Collet in Next.js:\n\n1. Install the packages\n2. Add the Vite plugin\n3. Call `init()` in your root layout", markdown: true },
300
+ { type: 'code-block', id: 'cb1',
301
+ code: "import { init } from '@colletdev/core';\n\ninit();\n\nexport default function RootLayout({ children }) {\n return <html><body>{children}</body></html>;\n}",
302
+ language: 'tsx', filename: 'app/layout.tsx' },
303
+ ];
304
+
271
305
  return (
272
- <div style={{ maxWidth: '48rem', margin: '0 auto' }}>
273
- {/* User message */}
274
- <MessageBubble role="user" senderName="Dan">
275
- <MessageGroup role="user">
276
- <MessagePart kind="text">
277
- How do I set up Collet in my Next.js app?
278
- </MessagePart>
279
- </MessageGroup>
306
+ <Chat height="h-[600px]" label="Collet assistant">
307
+ {/* User turn — simple text via MessageBubble */}
308
+ <MessageBubble messageRole="user" senderName="Dan">
309
+ <MessageGroup messageRole="user" parts={[
310
+ '<div>How do I set up Collet in my Next.js app?</div>'
311
+ ]} />
280
312
  </MessageBubble>
281
313
 
282
- {/* Assistant response with tool calls */}
283
- <MessageBubble role="assistant" senderName="Collet" avatar="/collet.svg">
284
- <MessageGroup role="assistant">
285
- {/* Thinking */}
286
- <MessagePart kind="thinking" completed thinkingLabel="Searched documentation" />
287
-
288
- {/* Tool activity */}
289
- <ActivityGroup label="Documentation search" status="done">
290
- <MessagePart
291
- kind="tool-call"
292
- toolName="search_docs"
293
- status="success"
294
- description="Searched Next.js setup guide"
295
- />
296
- </ActivityGroup>
297
-
298
- {/* Response text with markdown */}
299
- <MessagePart kind="text" markdown>
300
- Here's how to set up Collet in Next.js:
301
-
302
- 1. Install the packages
303
- 2. Add the Vite plugin (or configure manually for Next.js)
304
- 3. Call `init()` in your root layout
305
- </MessagePart>
306
-
307
- {/* Code example */}
308
- <MessagePart kind="code-block" language="tsx" filename="app/layout.tsx">
309
- {`import { init } from '@colletdev/core';
310
-
311
- init();
312
-
313
- export default function RootLayout({ children }) {
314
- return <html><body>{children}</body></html>;
315
- }`}
316
- </MessagePart>
317
- </MessageGroup>
318
- </MessageBubble>
319
- </div>
314
+ {/* Assistant turn event-driven via MessageTimeline */}
315
+ <MessageTimeline
316
+ messageRole="assistant"
317
+ senderName="Collet"
318
+ events={assistantEvents}
319
+ />
320
+ </Chat>
320
321
  );
321
322
  }
322
323
  ```
323
324
 
325
+ Or use individual components for full control:
326
+
327
+ ```tsx
328
+ import { MessageBubble, MessageGroup, MessagePart } from '@colletdev/react';
329
+
330
+ <MessageBubble messageRole="assistant" senderName="Collet">
331
+ <MessageGroup messageRole="assistant" parts={[
332
+ MessagePart.render({ kind: 'text', content: 'Hello!', markdown: true }),
333
+ MessagePart.render({ kind: 'code-block', code: 'npm install', language: 'bash' }),
334
+ ]} />
335
+ </MessageBubble>
336
+ ```
337
+
324
338
  ---
325
339
 
326
340
  ## Standalone Code Blocks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colletdev/docs",
3
- "version": "0.2.16",
3
+ "version": "0.2.19",
4
4
  "description": "Collet component library documentation — API reference, framework guides, and AI agent setup",
5
5
  "type": "module",
6
6
  "bin": {