laif-ds 0.2.74 → 0.2.76

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 (155) hide show
  1. package/dist/CHANGELOG.md +446 -0
  2. package/dist/agent-docs/adoption-report.json +615 -0
  3. package/dist/agent-docs/components/Accordion.md +46 -16
  4. package/dist/agent-docs/components/Alert.md +90 -95
  5. package/dist/agent-docs/components/AlertDialog.md +132 -126
  6. package/dist/agent-docs/components/AppEditor.md +90 -90
  7. package/dist/agent-docs/components/AppRadioGroup.md +18 -18
  8. package/dist/agent-docs/components/AppSidebar.md +129 -122
  9. package/dist/agent-docs/components/AppStepper.md +81 -77
  10. package/dist/agent-docs/components/AspectRatio.md +70 -62
  11. package/dist/agent-docs/components/AudioVisualizer.md +5 -5
  12. package/dist/agent-docs/components/Avatar.md +112 -113
  13. package/dist/agent-docs/components/Badge.md +123 -118
  14. package/dist/agent-docs/components/Breadcrumb.md +8 -1
  15. package/dist/agent-docs/components/Button.md +131 -129
  16. package/dist/agent-docs/components/Card.md +172 -147
  17. package/dist/agent-docs/components/Carousel.md +148 -129
  18. package/dist/agent-docs/components/Chat.md +121 -109
  19. package/dist/agent-docs/components/ChatMessage.md +72 -61
  20. package/dist/agent-docs/components/Checkbox.md +150 -135
  21. package/dist/agent-docs/components/CircularProgress.md +53 -49
  22. package/dist/agent-docs/components/CodeHighlighter.md +4 -4
  23. package/dist/agent-docs/components/Collapsible.md +114 -95
  24. package/dist/agent-docs/components/Command.md +141 -142
  25. package/dist/agent-docs/components/Confirmer.md +182 -175
  26. package/dist/agent-docs/components/ContextMenu.md +196 -191
  27. package/dist/agent-docs/components/DataCrossTable.md +114 -94
  28. package/dist/agent-docs/components/DataTable.md +32 -24
  29. package/dist/agent-docs/components/Dialog.md +130 -125
  30. package/dist/agent-docs/components/Drawer.md +141 -127
  31. package/dist/agent-docs/components/FilePreviewer.md +138 -139
  32. package/dist/agent-docs/components/FileUploader.md +149 -129
  33. package/dist/agent-docs/components/Form.md +3 -1
  34. package/dist/agent-docs/components/FormComposer.md +163 -137
  35. package/dist/agent-docs/components/GanttChart.md +125 -122
  36. package/dist/agent-docs/components/HoverCard.md +1 -1
  37. package/dist/agent-docs/components/Icon.md +98 -99
  38. package/dist/agent-docs/components/Input.md +173 -138
  39. package/dist/agent-docs/components/InputOtp.md +6 -1
  40. package/dist/agent-docs/components/InputSelector.md +94 -97
  41. package/dist/agent-docs/components/InterruptPrompt.md +4 -4
  42. package/dist/agent-docs/components/MarkdownRenderer.md +5 -2
  43. package/dist/agent-docs/components/Menubar.md +60 -57
  44. package/dist/agent-docs/components/MessageInput.md +134 -131
  45. package/dist/agent-docs/components/MessageList.md +110 -96
  46. package/dist/agent-docs/components/MultipleSelector.md +147 -146
  47. package/dist/agent-docs/components/NavigationMenu.md +6 -2
  48. package/dist/agent-docs/components/Popover.md +112 -103
  49. package/dist/agent-docs/components/PromptSuggestions.md +5 -5
  50. package/dist/agent-docs/components/RadioGroup.md +97 -90
  51. package/dist/agent-docs/components/Resizable.md +4 -1
  52. package/dist/agent-docs/components/ResizePrompt.md +12 -13
  53. package/dist/agent-docs/components/ScrollArea.md +6 -2
  54. package/dist/agent-docs/components/SecurePdfViewer.md +10 -6
  55. package/dist/agent-docs/components/Select.md +131 -132
  56. package/dist/agent-docs/components/Sheet.md +8 -1
  57. package/dist/agent-docs/components/ShikiHighlighter.md +5 -5
  58. package/dist/agent-docs/components/Sidebar.md +94 -85
  59. package/dist/agent-docs/components/Slider.md +62 -58
  60. package/dist/agent-docs/components/Sonner.md +1 -0
  61. package/dist/agent-docs/components/Spinner.md +14 -14
  62. package/dist/agent-docs/components/Stepper.md +93 -67
  63. package/dist/agent-docs/components/Switch.md +41 -42
  64. package/dist/agent-docs/components/TableSkeleton.md +8 -8
  65. package/dist/agent-docs/components/Tabs.md +106 -86
  66. package/dist/agent-docs/components/TextArea.md +51 -52
  67. package/dist/agent-docs/components/ThemeSwitcher.md +72 -69
  68. package/dist/agent-docs/components/Toaster.md +1 -0
  69. package/dist/agent-docs/components/Tooltip.md +102 -91
  70. package/dist/agent-docs/components/Typo.md +68 -65
  71. package/dist/agent-docs/components/WeeklyCalendar.md +63 -64
  72. package/dist/agent-docs/components-list.md +1 -0
  73. package/dist/agent-docs/manifest.json +5981 -0
  74. package/dist/agent-docs/truncated-cell.md +342 -0
  75. package/dist/components/editor/editor-hooks/use-update-toolbar.js +6 -6
  76. package/dist/components/editor/plugins/actions/counter-character-plugin.js +6 -6
  77. package/dist/components/editor/plugins/toolbar/font-format-toolbar-plugin.js +18 -18
  78. package/dist/components/editor/plugins/toolbar/history-toolbar-plugin.js +10 -10
  79. package/dist/components/editor/plugins/toolbar/toolbar-plugin.js +9 -9
  80. package/dist/components/ui/app-checkbox.js +1 -1
  81. package/dist/components/ui/app-dialog.js +70 -64
  82. package/dist/components/ui/app-editor.js +51 -51
  83. package/dist/components/ui/app-form.js +81 -81
  84. package/dist/components/ui/app-multiple-select-dropdown.js +36 -36
  85. package/dist/components/ui/app-select.js +109 -104
  86. package/dist/components/ui/app-sidebar.js +41 -41
  87. package/dist/components/ui/app-stepper.js +1 -1
  88. package/dist/components/ui/app-time-picker.js +18 -18
  89. package/dist/components/ui/app-tooltip.js +1 -1
  90. package/dist/components/ui/async-select.js +5 -5
  91. package/dist/components/ui/audio-visualizer.js +61 -58
  92. package/dist/components/ui/card.js +1 -1
  93. package/dist/components/ui/carousel.js +2 -2
  94. package/dist/components/ui/chart.js +1 -1
  95. package/dist/components/ui/chat-message.js +8 -8
  96. package/dist/components/ui/chat.js +86 -88
  97. package/dist/components/ui/command.js +2 -2
  98. package/dist/components/ui/copy-button.js +4 -4
  99. package/dist/components/ui/date-picker.js +20 -20
  100. package/dist/components/ui/file-preview/index.js +13 -13
  101. package/dist/components/ui/file-previewer.js +12 -11
  102. package/dist/components/ui/file-uploader.js +86 -78
  103. package/dist/components/ui/form.js +2 -2
  104. package/dist/components/ui/gantt/components/Chart/Bars/Bars.js +56 -56
  105. package/dist/components/ui/gantt/components/Chart/Bars/BarsRow/BarItem/BarItem.js +12 -12
  106. package/dist/components/ui/gantt/components/Chart/Bars/BarsRow/BarsItems/BarItems.js +1 -1
  107. package/dist/components/ui/gantt/components/Chart/Bars/BarsRow/BarsRow.js +4 -4
  108. package/dist/components/ui/gantt/components/Chart/Bars/BarsRow/RepeteadBars/RepeteadBars.js +2 -2
  109. package/dist/components/ui/gantt/components/Chart/Chart.js +23 -23
  110. package/dist/components/ui/gantt/components/Chart/Scale/Scale.js +1 -1
  111. package/dist/components/ui/gantt/components/Chart/Tree/Tree.js +34 -34
  112. package/dist/components/ui/gantt/components/Controls/Controls.js +5 -5
  113. package/dist/components/ui/gantt/components/Gantt/Gantt.js +4 -4
  114. package/dist/components/ui/gantt/hooks/useGanttCalculate.js +25 -18
  115. package/dist/components/ui/input-selector.js +1 -1
  116. package/dist/components/ui/input.js +23 -23
  117. package/dist/components/ui/kanban.js +8 -9
  118. package/dist/components/ui/markdown-renderer.js +41 -35
  119. package/dist/components/ui/message-input.js +45 -44
  120. package/dist/components/ui/multiple-selector.js +91 -82
  121. package/dist/components/ui/secure-pdf-viewer.js +19 -7
  122. package/dist/components/ui/sidebar.js +1 -1
  123. package/dist/components/ui/slider.js +1 -1
  124. package/dist/components/ui/spinner.js +4 -4
  125. package/dist/components/ui/stepper.js +157 -138
  126. package/dist/components/ui/tables/data-cross-table/data-cross-table-buttons.js +29 -29
  127. package/dist/components/ui/tables/data-cross-table/data-cross-table.js +258 -246
  128. package/dist/components/ui/tables/data-table/components/data-table-advanced-filter.js +4 -1
  129. package/dist/components/ui/tables/data-table/components/data-table-body.js +211 -367
  130. package/dist/components/ui/tables/data-table/components/data-table-filter-inputs.js +114 -112
  131. package/dist/components/ui/tables/data-table/components/data-table-filters.js +116 -96
  132. package/dist/components/ui/tables/data-table/components/data-table-header.js +211 -0
  133. package/dist/components/ui/tables/data-table/components/data-table-searchbar.js +8 -8
  134. package/dist/components/ui/tables/data-table/components/data-table-skeleton-rows.js +33 -0
  135. package/dist/components/ui/tables/data-table/data-table.js +258 -250
  136. package/dist/components/ui/tables/data-table/data-table.service.js +112 -97
  137. package/dist/components/ui/tables/data-table/data-table.utils.js +25 -15
  138. package/dist/components/ui/textarea.js +2 -2
  139. package/dist/components/ui/theme-switcher.js +1 -1
  140. package/dist/components/ui/toggle-group.js +2 -2
  141. package/dist/components/ui/truncated-cell.js +100 -0
  142. package/dist/components/ui/weekly-calendar/appointment-card.js +16 -16
  143. package/dist/components/ui/weekly-calendar/calendar-context.js +6 -6
  144. package/dist/components/ui/weekly-calendar/calendar-header.js +12 -12
  145. package/dist/components/ui/weekly-calendar/day-column.js +16 -16
  146. package/dist/components/ui/weekly-calendar/time-column.js +4 -4
  147. package/dist/components/ui/weekly-calendar/weekly-calendar.js +4 -4
  148. package/dist/hooks/use-audio-recording.js +1 -1
  149. package/dist/hooks/use-auto-scroll.js +18 -18
  150. package/dist/hooks/use-autosize-textarea.js +12 -13
  151. package/dist/index.d.ts +100 -45
  152. package/dist/index.js +362 -360
  153. package/dist/lib/utils.js +6 -6
  154. package/dist/styles.v3.css +1 -1
  155. package/package.json +14 -4
@@ -1,109 +1,121 @@
1
- # Chat
2
-
3
- ## Overview
4
-
5
- Complete chat interface: message list with markdown rendering, auto-scroll and typing indicator; composer with text, attachments, and voice; optional suggestions for empty state; message actions (copy, rate, save) and inline edit of assistant messages.
6
-
7
- ---
8
-
9
- ## Props
10
-
11
- | Prop | Type | Default | Description |
12
- | ------------------ | ---------------------------------------------- | ----------- | ----------- |
13
- | `messages` | `Message[]` | **required**| Messages to render. See `ChatMessage` for shape. |
14
- | `input` | `string` | **required**| Current input value. |
15
- | `handleSubmit` | `(event?, opts?) => void` | **required**| Called on form submit. Supports `{ experimental_attachments?: FileList }`. |
16
- | `handleInputChange`| `React.ChangeEventHandler<HTMLTextAreaElement>`| **required**| Input change handler. |
17
- | `isGenerating` | `boolean` | `false` | Whether assistant is generating. Enables interrupt UI. |
18
- | `stop` | `() => void` | `undefined` | Stop generation callback. |
19
- | `allowAttachments` | `boolean` | `false` | Enable file attachments UI. |
20
- | `transcribeAudio` | `(blob: Blob) => Promise<string>` | `undefined` | Speech-to-text function for voice input. |
21
- | `onEdit` | `(messageId: string, newContent: string) => void`| `undefined`| Enable inline edit on assistant messages. |
22
- | `onMessageSave` | `(messageId: string, content: string) => void` | `undefined` | Enable save action on assistant messages. |
23
- | `onRateResponse` | `(messageId: string, rating: "thumbs-up" | "thumbs-down") => void` | `undefined` | Enable rating actions. |
24
- | `append` | `(message: { role: "user"; content: string }) => void` | `undefined` | Show prompt suggestions and handle clicks. |
25
- | `suggestions` | `string[]` | `undefined` | Suggestions displayed when empty. Requires `append`. |
26
- | `className` | `string` | `undefined` | Wrapper classes. |
27
- | `welcomeTitle` | `string` | `"Da dove iniziamo?"` | Title shown in empty state. |
28
-
29
- ---
30
-
31
- ## Behavior
32
-
33
- - **Auto-scroll**: Scrolls to latest messages unless user scrolls up (then shows "scroll to bottom").
34
- - **Composer**: `MessageInput` supports Enter-to-send, attachments, and voice input with transcription.
35
- - **Actions**: Copy, save, thumbs up/down per assistant message.
36
- - **Edit**: Inline edit of assistant messages with Enter to save / Esc to cancel.
37
- - **Suggestions**: When `messages` is empty and `suggestions` provided, renders clickable suggestions via `append`.
38
-
39
- ---
40
-
41
- ## Examples
42
-
43
- ### Default
44
-
45
- ```tsx
46
- import * as React from "react";
47
- import { Chat } from "laif-ds";
48
- import type { Message } from "laif-ds";
49
-
50
- export function BasicChat() {
51
- const [messages, setMessages] = React.useState<Message[]>([
52
- { id: "1", role: "user", content: "Hello!", createdAt: new Date() },
53
- { id: "2", role: "assistant", content: "How can I help?", createdAt: new Date() },
54
- ]);
55
- const [input, setInput] = React.useState("");
56
-
57
- const handleSubmit = () => {
58
- if (!input.trim()) return;
59
- setMessages((prev) => [...prev, { id: Date.now().toString(), role: "user", content: input, createdAt: new Date() }]);
60
- setInput("");
61
- };
62
-
63
- return (
64
- <div className="h-[500px] w-full max-w-3xl">
65
- <Chat
66
- messages={messages}
67
- input={input}
68
- handleInputChange={(e) => setInput(e.target.value)}
69
- handleSubmit={handleSubmit}
70
- isGenerating={false}
71
- />
72
- </div>
73
- );
74
- }
75
- ```
76
-
77
- ### With Attachments and Actions
78
-
79
- ```tsx
80
- import * as React from "react";
81
- import { Chat } from "laif-ds";
82
-
83
- export function FullChat() {
84
- const [input, setInput] = React.useState("");
85
- return (
86
- <div className="h-[600px] w-full">
87
- <Chat
88
- messages={[]}
89
- input={input}
90
- handleInputChange={(e) => setInput(e.target.value)}
91
- handleSubmit={() => {}}
92
- isGenerating={false}
93
- allowAttachments
94
- onMessageSave={(id, content) => console.log("save", id, content)}
95
- onRateResponse={(id, rating) => console.log("rate", id, rating)}
96
- />
97
- </div>
98
- );
99
- }
100
- ```
101
-
102
- ---
103
-
104
- ## Notes
105
-
106
- - **Types**: See `Message` in `chat-message.tsx` for full shape (supports tool invocations and parts).
107
- - **Interrupt**: When `isGenerating` is true and `stop` provided, `Enter` prompts to stop then submit.
108
- - **Composition**: Chat uses `MessageList`, `MessageInput`, and utilities like `CopyButton` and `PromptSuggestions`.
109
-
1
+ # Chat
2
+
3
+ ## Overview
4
+
5
+ Complete chat interface: message list with markdown rendering, auto-scroll and typing indicator; composer with text, attachments, and voice; optional suggestions for empty state; message actions (copy, rate, save) and inline edit of assistant messages.
6
+
7
+ ---
8
+
9
+ ## Props
10
+
11
+ | Prop | Type | Default | Description |
12
+ | ------------------- | ------------------------------------------------------ | ----------------------- | -------------------------------------------------------------------------- | ---------------------- |
13
+ | `messages` | `Message[]` | **required** | Messages to render. See `ChatMessage` for shape. |
14
+ | `input` | `string` | **required** | Current input value. |
15
+ | `handleSubmit` | `(event?, opts?) => void` | **required** | Called on form submit. Supports `{ experimental_attachments?: FileList }`. |
16
+ | `handleInputChange` | `React.ChangeEventHandler<HTMLTextAreaElement>` | **required** | Input change handler. |
17
+ | `isGenerating` | `boolean` | `false` | Whether assistant is generating. Enables interrupt UI. |
18
+ | `stop` | `() => void` | `undefined` | Stop generation callback. |
19
+ | `allowAttachments` | `boolean` | `false` | Enable file attachments UI. |
20
+ | `transcribeAudio` | `(blob: Blob) => Promise<string>` | `undefined` | Speech-to-text function for voice input. |
21
+ | `onEdit` | `(messageId: string, newContent: string) => void` | `undefined` | Enable inline edit on assistant messages. |
22
+ | `onMessageSave` | `(messageId: string, content: string) => void` | `undefined` | Enable save action on assistant messages. |
23
+ | `onRateResponse` | `(messageId: string, rating: "thumbs-up" | "thumbs-down") => void` | `undefined` | Enable rating actions. |
24
+ | `append` | `(message: { role: "user"; content: string }) => void` | `undefined` | Show prompt suggestions and handle clicks. |
25
+ | `suggestions` | `string[]` | `undefined` | Suggestions displayed when empty. Requires `append`. |
26
+ | `className` | `string` | `undefined` | Wrapper classes. |
27
+ | `welcomeTitle` | `string` | `"Da dove iniziamo?"` | Title shown in empty state. |
28
+
29
+ ---
30
+
31
+ ## Behavior
32
+
33
+ - **Auto-scroll**: Scrolls to latest messages unless user scrolls up (then shows "scroll to bottom").
34
+ - **Composer**: `MessageInput` supports Enter-to-send, attachments, and voice input with transcription.
35
+ - **Actions**: Copy, save, thumbs up/down per assistant message.
36
+ - **Edit**: Inline edit of assistant messages with Enter to save / Esc to cancel.
37
+ - **Suggestions**: When `messages` is empty and `suggestions` provided, renders clickable suggestions via `append`.
38
+
39
+ ---
40
+
41
+ ## Examples
42
+
43
+ ### Default
44
+
45
+ ```tsx
46
+ import * as React from "react";
47
+ import { Chat } from "laif-ds";
48
+ import type { Message } from "laif-ds";
49
+
50
+ export function BasicChat() {
51
+ const [messages, setMessages] = React.useState<Message[]>([
52
+ { id: "1", role: "user", content: "Hello!", createdAt: new Date() },
53
+ {
54
+ id: "2",
55
+ role: "assistant",
56
+ content: "How can I help?",
57
+ createdAt: new Date(),
58
+ },
59
+ ]);
60
+ const [input, setInput] = React.useState("");
61
+
62
+ const handleSubmit = () => {
63
+ if (!input.trim()) return;
64
+ setMessages((prev) => [
65
+ ...prev,
66
+ {
67
+ id: Date.now().toString(),
68
+ role: "user",
69
+ content: input,
70
+ createdAt: new Date(),
71
+ },
72
+ ]);
73
+ setInput("");
74
+ };
75
+
76
+ return (
77
+ <div className="h-[500px] w-full max-w-3xl">
78
+ <Chat
79
+ messages={messages}
80
+ input={input}
81
+ handleInputChange={(e) => setInput(e.target.value)}
82
+ handleSubmit={handleSubmit}
83
+ isGenerating={false}
84
+ />
85
+ </div>
86
+ );
87
+ }
88
+ ```
89
+
90
+ ### With Attachments and Actions
91
+
92
+ ```tsx
93
+ import * as React from "react";
94
+ import { Chat } from "laif-ds";
95
+
96
+ export function FullChat() {
97
+ const [input, setInput] = React.useState("");
98
+ return (
99
+ <div className="h-[600px] w-full">
100
+ <Chat
101
+ messages={[]}
102
+ input={input}
103
+ handleInputChange={(e) => setInput(e.target.value)}
104
+ handleSubmit={() => {}}
105
+ isGenerating={false}
106
+ allowAttachments
107
+ onMessageSave={(id, content) => console.log("save", id, content)}
108
+ onRateResponse={(id, rating) => console.log("rate", id, rating)}
109
+ />
110
+ </div>
111
+ );
112
+ }
113
+ ```
114
+
115
+ ---
116
+
117
+ ## Notes
118
+
119
+ - **Types**: See `Message` in `chat-message.tsx` for full shape (supports tool invocations and parts).
120
+ - **Interrupt**: When `isGenerating` is true and `stop` provided, `Enter` prompts to stop then submit.
121
+ - **Composition**: Chat uses `MessageList`, `MessageInput`, and utilities like `CopyButton` and `PromptSuggestions`.
@@ -1,61 +1,72 @@
1
- # ChatMessage
2
-
3
- ## Overview
4
-
5
- Render a single chat message bubble with markdown, optional attachments preview, tool invocation blocks, reasoning collapsible, time stamps, actions and inline edit for assistant messages.
6
-
7
- ---
8
-
9
- ## Props
10
-
11
- | Prop | Type | Default | Description |
12
- | --------------- | ------------------------ | ----------- | ----------- |
13
- | `id` | `string` | **required**| Message id. |
14
- | `role` | `"user" | "assistant" | (string)` | **required**| Role determines bubble style and alignment. |
15
- | `content` | `string` | **required**| Message text (markdown supported). |
16
- | `createdAt` | `Date` | `undefined` | Optional timestamp. |
17
- | `experimental_attachments` | `{ url: string; name?: string; contentType?: string }[]` | `undefined` | Files to preview (user messages). |
18
- | `toolInvocations` | `ToolInvocation[]` | `undefined` | Tool call states (`call`, `result`). |
19
- | `parts` | `MessagePart[]` | `undefined` | Mixed message content (text/reasoning/tool-invocation). |
20
- | `showTimeStamp` | `boolean` | `false` | Show `createdAt` under bubble. |
21
- | `animation` | `"none" | "slide" | "scale" | "fade"` | `"scale"` | Entry animation.
22
- | `actions` | `React.ReactNode` | `undefined` | Action buttons area (shown on hover). |
23
- | `editable` | `boolean` | `false` | Force edit UI even without `onEdit`. |
24
- | `onEdit` | `(newContent: string) => void` | `undefined` | Show edit UI on assistant messages. |
25
- | `onMessageSave` | `(messageId: string, content: string) => void` | `undefined` | Save callback (rendered in action area). |
26
-
27
- ---
28
-
29
- ## Behavior
30
-
31
- - **User vs Assistant**: Different bubble alignment and token styles.
32
- - **Markdown**: Rendered via `MarkdownRenderer` with async suspense fallback.
33
- - **Attachments**: User attachments rendered as `FilePreview` chips.
34
- - **Tool calls**: `ToolInvocation` blocks show calling/result state with icons.
35
- - **Edit**: Assistant messages can be edited inline (Enter save, Esc cancel).
36
-
37
- ---
38
-
39
- ## Examples
40
-
41
- ```tsx
42
- import { ChatMessage } from "laif-ds";
43
-
44
- export function Examples() {
45
- return (
46
- <div className="space-y-4">
47
- <ChatMessage id="u1" role="user" content="Hello" createdAt={new Date()} showTimeStamp />
48
- <ChatMessage id="a1" role="assistant" content="Hi there!" createdAt={new Date()} showTimeStamp />
49
- <ChatMessage id="a2" role="assistant" content={"**Bold** and `code`"} />
50
- </div>
51
- );
52
- }
53
- ```
54
-
55
- ---
56
-
57
- ## Notes
58
-
59
- - **Reasoning**: Use `parts` with `{ type: "reasoning", reasoning: string }` to show collapsible reasoning.
60
- - **Actions**: Pass small `Button`s or icons (from `laif-ds`) via `actions`.
61
-
1
+ # ChatMessage
2
+
3
+ ## Overview
4
+
5
+ Render a single chat message bubble with markdown, optional attachments preview, tool invocation blocks, reasoning collapsible, time stamps, actions and inline edit for assistant messages.
6
+
7
+ ---
8
+
9
+ ## Props
10
+
11
+ | Prop | Type | Default | Description |
12
+ | -------------------------- | -------------------------------------------------------- | ------------ | ------------------------------------------------------- | ------------ | ------------------------------------------- | ---------------- |
13
+ | `id` | `string` | **required** | Message id. |
14
+ | `role` | `"user" | "assistant" | (string)` | **required** | Role determines bubble style and alignment. |
15
+ | `content` | `string` | **required** | Message text (markdown supported). |
16
+ | `createdAt` | `Date` | `undefined` | Optional timestamp. |
17
+ | `experimental_attachments` | `{ url: string; name?: string; contentType?: string }[]` | `undefined` | Files to preview (user messages). |
18
+ | `toolInvocations` | `ToolInvocation[]` | `undefined` | Tool call states (`call`, `result`). |
19
+ | `parts` | `MessagePart[]` | `undefined` | Mixed message content (text/reasoning/tool-invocation). |
20
+ | `showTimeStamp` | `boolean` | `false` | Show `createdAt` under bubble. |
21
+ | `animation` | `"none" | "slide" | "scale" | "fade"` | `"scale"` | Entry animation. |
22
+ | `actions` | `React.ReactNode` | `undefined` | Action buttons area (shown on hover). |
23
+ | `editable` | `boolean` | `false` | Force edit UI even without `onEdit`. |
24
+ | `onEdit` | `(newContent: string) => void` | `undefined` | Show edit UI on assistant messages. |
25
+ | `onMessageSave` | `(messageId: string, content: string) => void` | `undefined` | Save callback (rendered in action area). |
26
+
27
+ ---
28
+
29
+ ## Behavior
30
+
31
+ - **User vs Assistant**: Different bubble alignment and token styles.
32
+ - **Markdown**: Rendered via `MarkdownRenderer` with async suspense fallback.
33
+ - **Attachments**: User attachments rendered as `FilePreview` chips.
34
+ - **Tool calls**: `ToolInvocation` blocks show calling/result state with icons.
35
+ - **Edit**: Assistant messages can be edited inline (Enter save, Esc cancel).
36
+
37
+ ---
38
+
39
+ ## Examples
40
+
41
+ ```tsx
42
+ import { ChatMessage } from "laif-ds";
43
+
44
+ export function Examples() {
45
+ return (
46
+ <div className="space-y-4">
47
+ <ChatMessage
48
+ id="u1"
49
+ role="user"
50
+ content="Hello"
51
+ createdAt={new Date()}
52
+ showTimeStamp
53
+ />
54
+ <ChatMessage
55
+ id="a1"
56
+ role="assistant"
57
+ content="Hi there!"
58
+ createdAt={new Date()}
59
+ showTimeStamp
60
+ />
61
+ <ChatMessage id="a2" role="assistant" content={"**Bold** and `code`"} />
62
+ </div>
63
+ );
64
+ }
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Notes
70
+
71
+ - **Reasoning**: Use `parts` with `{ type: "reasoning", reasoning: string }` to show collapsible reasoning.
72
+ - **Actions**: Pass small `Button`s or icons (from `laif-ds`) via `actions`.