@miiflow/assistant-ui 0.2.3 → 0.3.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/dist/{WelcomeScreen-YsXZsAwZ.d.ts → WelcomeScreen-DAa22X9b.d.ts} +1 -1
- package/dist/{chunk-POKFMILU.js → chunk-IM4WITWJ.js} +9 -11
- package/dist/chunk-IM4WITWJ.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/styled/index.d.ts +1 -1
- package/dist/styled/index.js +1 -1
- package/dist/styles-no-preflight.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +9 -18
- package/dist/WelcomeScreen-BiY3uGhp.d.cts +0 -301
- package/dist/avatar-CL1hlGO5.d.cts +0 -109
- package/dist/branding-SzYU4ncD.d.cts +0 -18
- package/dist/chunk-3SEVU272.cjs +0 -2
- package/dist/chunk-3SEVU272.cjs.map +0 -1
- package/dist/chunk-HVCCZKEO.cjs +0 -2
- package/dist/chunk-HVCCZKEO.cjs.map +0 -1
- package/dist/chunk-KSMAVBLY.cjs +0 -2
- package/dist/chunk-KSMAVBLY.cjs.map +0 -1
- package/dist/chunk-POKFMILU.js.map +0 -1
- package/dist/chunk-QGRXQAWZ.cjs +0 -22
- package/dist/chunk-QGRXQAWZ.cjs.map +0 -1
- package/dist/chunk-SFEPMZCU.cjs +0 -2
- package/dist/chunk-SFEPMZCU.cjs.map +0 -1
- package/dist/chunk-TOYU46SZ.cjs +0 -2
- package/dist/chunk-TOYU46SZ.cjs.map +0 -1
- package/dist/chunk-ZKMXEECD.cjs +0 -2
- package/dist/chunk-ZKMXEECD.cjs.map +0 -1
- package/dist/client/index.cjs +0 -9
- package/dist/client/index.cjs.map +0 -1
- package/dist/client/index.d.cts +0 -249
- package/dist/context/index.cjs +0 -2
- package/dist/context/index.cjs.map +0 -1
- package/dist/context/index.d.cts +0 -43
- package/dist/hooks/index.cjs +0 -2
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.d.cts +0 -146
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -157
- package/dist/message-9z0crkf9.d.cts +0 -88
- package/dist/primitives/index.cjs +0 -2
- package/dist/primitives/index.cjs.map +0 -1
- package/dist/primitives/index.d.cts +0 -91
- package/dist/streaming-CF63E6iS.d.cts +0 -426
- package/dist/styled/index.cjs +0 -2
- package/dist/styled/index.cjs.map +0 -1
- package/dist/styled/index.d.cts +0 -477
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
-
import { A as Attachment, M as MessageData, P as ParticipantRole, d as SuggestedAction, S as SourceReference } from './message-9z0crkf9.cjs';
|
|
4
|
-
import { h as AvatarProps$1 } from './avatar-CL1hlGO5.cjs';
|
|
5
|
-
import { S as StreamingChunk, V as VisualizationChunkData, C as ClarificationData } from './streaming-CF63E6iS.cjs';
|
|
6
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
-
|
|
8
|
-
interface AttachmentPreviewProps {
|
|
9
|
-
/** The attachment to preview */
|
|
10
|
-
attachment: Attachment;
|
|
11
|
-
/** Callback when remove button is clicked */
|
|
12
|
-
onRemove?: () => void;
|
|
13
|
-
/** Whether removal is allowed */
|
|
14
|
-
removable?: boolean;
|
|
15
|
-
/** Additional CSS classes */
|
|
16
|
-
className?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Styled attachment preview card.
|
|
20
|
-
*/
|
|
21
|
-
declare const AttachmentPreview: react.ForwardRefExoticComponent<AttachmentPreviewProps & react.RefAttributes<HTMLDivElement>>;
|
|
22
|
-
|
|
23
|
-
interface AvatarProps extends Omit<AvatarProps$1, "fallback"> {
|
|
24
|
-
/** Size variant */
|
|
25
|
-
size?: "sm" | "md" | "lg";
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Styled Avatar component with role-based icons.
|
|
29
|
-
*/
|
|
30
|
-
declare const Avatar: react.ForwardRefExoticComponent<AvatarProps & react.RefAttributes<HTMLDivElement>>;
|
|
31
|
-
|
|
32
|
-
interface ChatContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
33
|
-
/** Children to render */
|
|
34
|
-
children: ReactNode;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Styled container for the chat interface.
|
|
38
|
-
* Provides flex layout and base styling.
|
|
39
|
-
*/
|
|
40
|
-
declare const ChatContainer: react.ForwardRefExoticComponent<ChatContainerProps & react.RefAttributes<HTMLDivElement>>;
|
|
41
|
-
|
|
42
|
-
interface MarkdownContentProps {
|
|
43
|
-
/** Markdown content to render */
|
|
44
|
-
children: string;
|
|
45
|
-
/** Additional CSS classes */
|
|
46
|
-
className?: string;
|
|
47
|
-
/** Base font size multiplier for responsive scaling */
|
|
48
|
-
baselineFontSize?: number;
|
|
49
|
-
/** Use dark theme for code blocks */
|
|
50
|
-
darkCodeTheme?: boolean;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Styled markdown renderer with syntax highlighting, copy-to-clipboard,
|
|
54
|
-
* and heading anchor links.
|
|
55
|
-
*/
|
|
56
|
-
declare function MarkdownContent({ children, className, baselineFontSize, darkCodeTheme, }: MarkdownContentProps): react_jsx_runtime.JSX.Element;
|
|
57
|
-
|
|
58
|
-
interface MessageProps {
|
|
59
|
-
/** The message data */
|
|
60
|
-
message: MessageData;
|
|
61
|
-
/** The viewer's role (determines alignment) */
|
|
62
|
-
viewerRole?: ParticipantRole;
|
|
63
|
-
/** Additional CSS classes */
|
|
64
|
-
className?: string;
|
|
65
|
-
/** Whether to show avatar */
|
|
66
|
-
showAvatar?: boolean;
|
|
67
|
-
/** Whether to show timestamp */
|
|
68
|
-
showTimestamp?: boolean;
|
|
69
|
-
/** Whether to render content as markdown */
|
|
70
|
-
renderMarkdown?: boolean;
|
|
71
|
-
/** Streaming chunks for reasoning panel */
|
|
72
|
-
reasoning?: StreamingChunk[];
|
|
73
|
-
/** Execution plan for completed Plan & Execute messages */
|
|
74
|
-
executionPlan?: unknown;
|
|
75
|
-
/** Execution timeline for completed messages (all orchestrator modes) */
|
|
76
|
-
executionTimeline?: unknown[];
|
|
77
|
-
/** Suggested actions */
|
|
78
|
-
suggestedActions?: SuggestedAction[];
|
|
79
|
-
/** Callback when suggested action is selected */
|
|
80
|
-
onSuggestedAction?: (action: SuggestedAction) => void;
|
|
81
|
-
/** Whether reasoning panel is expanded */
|
|
82
|
-
reasoningExpanded?: boolean;
|
|
83
|
-
/** Callback when reasoning panel expansion changes */
|
|
84
|
-
onReasoningExpandedChange?: (expanded: boolean) => void;
|
|
85
|
-
/** Citation sources to display after message content */
|
|
86
|
-
citations?: SourceReference[];
|
|
87
|
-
/** Inline visualizations to render within message content */
|
|
88
|
-
visualizations?: VisualizationChunkData[];
|
|
89
|
-
/** Base font size multiplier for markdown rendering */
|
|
90
|
-
baselineFontSize?: number;
|
|
91
|
-
/** Total execution time in seconds (persisted from streaming wall-clock) */
|
|
92
|
-
executionTime?: number;
|
|
93
|
-
/** Pending clarification data (agent needs user input) */
|
|
94
|
-
pendingClarification?: ClarificationData;
|
|
95
|
-
/** Callback when user responds to a clarification */
|
|
96
|
-
onClarificationSubmit?: (response: string) => void;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Styled Message component with grid layout matching the main app.
|
|
100
|
-
* Uses grid to align avatar and content, with reasoning above content.
|
|
101
|
-
* Supports attachments, citations, inline visualizations, and streaming text.
|
|
102
|
-
*/
|
|
103
|
-
declare const Message: react.ForwardRefExoticComponent<MessageProps & react.RefAttributes<HTMLDivElement>>;
|
|
104
|
-
|
|
105
|
-
interface MessageComposerProps {
|
|
106
|
-
/** Callback when message is submitted */
|
|
107
|
-
onSubmit: (content: string, attachments?: File[], attachmentIds?: string[]) => Promise<void>;
|
|
108
|
-
/** Callback when files are attached (for upload handling) */
|
|
109
|
-
onAttach?: (files: File[]) => void;
|
|
110
|
-
/** Upload a file to backend, returning an attachment ID. When provided, enables server-side upload flow. */
|
|
111
|
-
onUploadFile?: (file: File) => Promise<string>;
|
|
112
|
-
/** Notify backend/hook that an uploaded attachment was removed before sending. */
|
|
113
|
-
onRemoveUploadedAttachment?: (attachmentId: string) => void;
|
|
114
|
-
/** Whether the composer is disabled */
|
|
115
|
-
disabled?: boolean;
|
|
116
|
-
/** Whether attachments are supported */
|
|
117
|
-
supportsAttachments?: boolean;
|
|
118
|
-
/** Allowed MIME types for attachments (default: images + docs + videos) */
|
|
119
|
-
allowedFileTypes?: string[];
|
|
120
|
-
/** Maximum file size in bytes (default: 100MB) */
|
|
121
|
-
maxFileSize?: number;
|
|
122
|
-
/** Placeholder text */
|
|
123
|
-
placeholder?: string;
|
|
124
|
-
/** Additional CSS classes */
|
|
125
|
-
className?: string;
|
|
126
|
-
/** Whether a message is currently being submitted */
|
|
127
|
-
isSubmitting?: boolean;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Rich text MessageComposer with Lexical editor, attachment support,
|
|
131
|
-
* file upload integration, drag & drop, and Enter-to-submit.
|
|
132
|
-
*/
|
|
133
|
-
declare const MessageComposer: react.ForwardRefExoticComponent<MessageComposerProps & react.RefAttributes<HTMLDivElement>>;
|
|
134
|
-
|
|
135
|
-
interface MessageListProps {
|
|
136
|
-
/** Messages to render */
|
|
137
|
-
children: ReactNode;
|
|
138
|
-
/** Whether to auto-scroll to bottom */
|
|
139
|
-
autoScroll?: boolean;
|
|
140
|
-
/** Whether to show the scroll-to-bottom button */
|
|
141
|
-
showScrollToBottom?: boolean;
|
|
142
|
-
/** Additional CSS classes */
|
|
143
|
-
className?: string;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Styled MessageList with scrolling, spacing, and scroll-to-bottom button.
|
|
147
|
-
* Uses the enhanced useAutoScroll hook directly instead of going through
|
|
148
|
-
* the primitive, since we need reactive isAtBottom for the button.
|
|
149
|
-
*/
|
|
150
|
-
declare const MessageList: react.ForwardRefExoticComponent<MessageListProps & react.RefAttributes<HTMLDivElement>>;
|
|
151
|
-
|
|
152
|
-
interface StreamingTextProps {
|
|
153
|
-
/** The content to display */
|
|
154
|
-
content: string;
|
|
155
|
-
/** Whether the text is currently streaming */
|
|
156
|
-
isStreaming?: boolean;
|
|
157
|
-
/** Whether to render as markdown */
|
|
158
|
-
renderMarkdown?: boolean;
|
|
159
|
-
/** Additional CSS classes */
|
|
160
|
-
className?: string;
|
|
161
|
-
/** Base font size multiplier (passed to MarkdownContent) */
|
|
162
|
-
baselineFontSize?: number;
|
|
163
|
-
/** Props forwarded to MarkdownContent */
|
|
164
|
-
markdownProps?: Partial<MarkdownContentProps>;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Styled StreamingText that renders content directly as tokens arrive.
|
|
168
|
-
*
|
|
169
|
-
* Text appears instantly (no artificial typewriter delay), matching
|
|
170
|
-
* platform-standard behavior. A blinking cursor is shown during streaming.
|
|
171
|
-
*/
|
|
172
|
-
declare const StreamingText: react.ForwardRefExoticComponent<StreamingTextProps & react.RefAttributes<HTMLDivElement>>;
|
|
173
|
-
|
|
174
|
-
interface SuggestedActionsProps {
|
|
175
|
-
/** List of suggested actions */
|
|
176
|
-
actions: SuggestedAction[];
|
|
177
|
-
/** Callback when an action is selected */
|
|
178
|
-
onSelect?: (action: SuggestedAction) => void | Promise<void>;
|
|
179
|
-
/** Additional CSS classes */
|
|
180
|
-
className?: string;
|
|
181
|
-
/** Whether to show type-specific icons */
|
|
182
|
-
showIcons?: boolean;
|
|
183
|
-
/** Disable all action buttons */
|
|
184
|
-
disabled?: boolean;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Styled SuggestedActions with type-specific icons, loading states, and staggered animation.
|
|
188
|
-
*/
|
|
189
|
-
declare const SuggestedActions: react.ForwardRefExoticComponent<SuggestedActionsProps & react.RefAttributes<HTMLDivElement>>;
|
|
190
|
-
|
|
191
|
-
interface TypingIndicatorProps {
|
|
192
|
-
/** Additional CSS classes */
|
|
193
|
-
className?: string;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Styled TypingIndicator with animated dots.
|
|
197
|
-
*/
|
|
198
|
-
declare const TypingIndicator: react.ForwardRefExoticComponent<TypingIndicatorProps & react.RefAttributes<HTMLDivElement>>;
|
|
199
|
-
|
|
200
|
-
interface MessageActionBarProps {
|
|
201
|
-
/** The text content to copy */
|
|
202
|
-
textContent: string;
|
|
203
|
-
/** Optional callback when regenerate is requested */
|
|
204
|
-
onRegenerate?: () => void;
|
|
205
|
-
/** Optional callback when edit is requested */
|
|
206
|
-
onEdit?: () => void;
|
|
207
|
-
/** Additional CSS classes */
|
|
208
|
-
className?: string;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Action bar that appears on hover below assistant message bubbles.
|
|
212
|
-
* Currently implements Copy; onRegenerate and onEdit are reserved for future use.
|
|
213
|
-
*/
|
|
214
|
-
declare function MessageActionBar({ textContent, onRegenerate, onEdit, className, }: MessageActionBarProps): react_jsx_runtime.JSX.Element;
|
|
215
|
-
|
|
216
|
-
interface ScrollToBottomButtonProps {
|
|
217
|
-
/** Whether the viewport is at the bottom (hides button when true) */
|
|
218
|
-
isAtBottom: boolean;
|
|
219
|
-
/** Callback to scroll to bottom */
|
|
220
|
-
onScrollToBottom: () => void;
|
|
221
|
-
/** Additional CSS classes */
|
|
222
|
-
className?: string;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* A floating button that appears when the user has scrolled up,
|
|
226
|
-
* allowing them to quickly jump back to the latest messages.
|
|
227
|
-
* Fades in/out based on scroll position.
|
|
228
|
-
*/
|
|
229
|
-
declare function ScrollToBottomButton({ isAtBottom, onScrollToBottom, className, }: ScrollToBottomButtonProps): react_jsx_runtime.JSX.Element;
|
|
230
|
-
|
|
231
|
-
type ToolStatus = "running" | "complete" | "failed" | "pending";
|
|
232
|
-
interface ToolStatusIndicatorProps {
|
|
233
|
-
/** Name of the tool */
|
|
234
|
-
toolName: string;
|
|
235
|
-
/** Current status */
|
|
236
|
-
status: ToolStatus;
|
|
237
|
-
/** Optional description of what the tool is doing */
|
|
238
|
-
description?: string;
|
|
239
|
-
/** Additional CSS classes */
|
|
240
|
-
className?: string;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Inline status indicator for individual tool executions.
|
|
244
|
-
* Shows tool name + status icon (spinner/check/X/clock).
|
|
245
|
-
* Running state includes a subtle shimmer animation.
|
|
246
|
-
*/
|
|
247
|
-
declare function ToolStatusIndicator({ toolName, status, description, className, }: ToolStatusIndicatorProps): react_jsx_runtime.JSX.Element;
|
|
248
|
-
|
|
249
|
-
interface ChatLayoutProps {
|
|
250
|
-
/** Whether the chat is in empty state (no messages) */
|
|
251
|
-
isEmpty: boolean;
|
|
252
|
-
/** Optional header rendered above the message area */
|
|
253
|
-
header?: ReactNode;
|
|
254
|
-
/** Content to display when isEmpty is true (typically a WelcomeScreen) */
|
|
255
|
-
welcomeScreen?: ReactNode;
|
|
256
|
-
/** The message list to display when not empty */
|
|
257
|
-
messageList?: ReactNode;
|
|
258
|
-
/** The composer rendered at the bottom when not empty */
|
|
259
|
-
composer?: ReactNode;
|
|
260
|
-
/** Extra content between message list and composer (e.g. ClarificationPanel) */
|
|
261
|
-
footer?: ReactNode;
|
|
262
|
-
/** Additional CSS classes */
|
|
263
|
-
className?: string;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Composable chat layout that handles the empty → active state transition
|
|
267
|
-
* with a smooth crossfade animation.
|
|
268
|
-
*
|
|
269
|
-
* Replaces the repeated `AnimatePresence` + `motion.div` pattern found in
|
|
270
|
-
* `centered-chat-layout.tsx` and `chat/[id]/page.tsx`.
|
|
271
|
-
*/
|
|
272
|
-
declare const ChatLayout: react.ForwardRefExoticComponent<ChatLayoutProps & react.RefAttributes<HTMLDivElement>>;
|
|
273
|
-
|
|
274
|
-
interface WelcomeScreenProps {
|
|
275
|
-
/** Rotating placeholder strings displayed in the input */
|
|
276
|
-
placeholders?: string[];
|
|
277
|
-
/** Preset suggestion cards shown below the input */
|
|
278
|
-
suggestions?: string[];
|
|
279
|
-
/** Called when the user submits a message via the built-in input */
|
|
280
|
-
onSubmit?: (message: string, files?: File[]) => void;
|
|
281
|
-
/** Called when the user clicks a suggestion card */
|
|
282
|
-
onSuggestionClick?: (suggestion: string) => void;
|
|
283
|
-
/** Welcome heading text */
|
|
284
|
-
welcomeText?: string;
|
|
285
|
-
/** Whether to show the attachment (paperclip) button */
|
|
286
|
-
supportsAttachments?: boolean;
|
|
287
|
-
/** Override the default plain-text input with a custom composer (e.g. chat-ui MessageComposer) */
|
|
288
|
-
composerSlot?: ReactNode;
|
|
289
|
-
/** Additional CSS classes for the outer wrapper */
|
|
290
|
-
className?: string;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Full-screen empty state with rotating placeholder input and suggestion cards.
|
|
294
|
-
* Used as the welcome screen when no messages exist.
|
|
295
|
-
*
|
|
296
|
-
* By default renders a simple textarea input. Pass `composerSlot` to override
|
|
297
|
-
* with e.g. the Lexical-based `MessageComposer`.
|
|
298
|
-
*/
|
|
299
|
-
declare const WelcomeScreen: react.ForwardRefExoticComponent<WelcomeScreenProps & react.RefAttributes<HTMLDivElement>>;
|
|
300
|
-
|
|
301
|
-
export { AttachmentPreview as A, ChatContainer as C, MarkdownContent as M, ScrollToBottomButton as S, ToolStatusIndicator as T, WelcomeScreen as W, Avatar as a, ChatLayout as b, Message as c, MessageActionBar as d, MessageComposer as e, MessageList as f, StreamingText as g, SuggestedActions as h, TypingIndicator as i, type AttachmentPreviewProps as j, type AvatarProps as k, type ChatContainerProps as l, type ChatLayoutProps as m, type MarkdownContentProps as n, type MessageActionBarProps as o, type MessageComposerProps as p, type MessageListProps as q, type MessageProps as r, type ScrollToBottomButtonProps as s, type StreamingTextProps as t, type SuggestedActionsProps as u, type ToolStatus as v, type ToolStatusIndicatorProps as w, type TypingIndicatorProps as x, type WelcomeScreenProps as y };
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { HTMLAttributes, ReactNode, TextareaHTMLAttributes, ButtonHTMLAttributes } from 'react';
|
|
3
|
-
import { M as MessageData, P as ParticipantRole } from './message-9z0crkf9.cjs';
|
|
4
|
-
|
|
5
|
-
interface MessageContextValue {
|
|
6
|
-
message: MessageData;
|
|
7
|
-
isViewer: boolean;
|
|
8
|
-
isStreaming: boolean;
|
|
9
|
-
}
|
|
10
|
-
declare const MessageContext: react.Context<MessageContextValue | null>;
|
|
11
|
-
/**
|
|
12
|
-
* Hook to access the current message context.
|
|
13
|
-
* Must be used within a Message component.
|
|
14
|
-
*/
|
|
15
|
-
declare function useMessage(): MessageContextValue;
|
|
16
|
-
interface MessageProps extends HTMLAttributes<HTMLDivElement> {
|
|
17
|
-
/** The message data */
|
|
18
|
-
message: MessageData;
|
|
19
|
-
/** The viewer's role (used to determine alignment) */
|
|
20
|
-
viewerRole?: ParticipantRole;
|
|
21
|
-
/** Children to render inside the message */
|
|
22
|
-
children: ReactNode;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Headless Message primitive.
|
|
26
|
-
* Provides message context to children and data attributes for styling.
|
|
27
|
-
*/
|
|
28
|
-
declare const Message: react.ForwardRefExoticComponent<MessageProps & react.RefAttributes<HTMLDivElement>>;
|
|
29
|
-
interface MessageContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
30
|
-
/** Custom content to render instead of message text */
|
|
31
|
-
children?: ReactNode;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Renders the message content.
|
|
35
|
-
* By default renders the message's textContent.
|
|
36
|
-
*/
|
|
37
|
-
declare const MessageContent: react.ForwardRefExoticComponent<MessageContentProps & react.RefAttributes<HTMLDivElement>>;
|
|
38
|
-
interface MessageTimestampProps extends HTMLAttributes<HTMLSpanElement> {
|
|
39
|
-
/** Custom date formatter */
|
|
40
|
-
format?: (date: Date) => string;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Renders the message timestamp.
|
|
44
|
-
*/
|
|
45
|
-
declare const MessageTimestamp: react.ForwardRefExoticComponent<MessageTimestampProps & react.RefAttributes<HTMLSpanElement>>;
|
|
46
|
-
|
|
47
|
-
interface ComposerContextValue {
|
|
48
|
-
content: string;
|
|
49
|
-
isSubmitting: boolean;
|
|
50
|
-
canSubmit: boolean;
|
|
51
|
-
error: string | null;
|
|
52
|
-
handleContentChange: (value: string) => void;
|
|
53
|
-
handleSubmit: () => Promise<void>;
|
|
54
|
-
handleKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
55
|
-
inputRef: React.RefObject<HTMLTextAreaElement | null>;
|
|
56
|
-
}
|
|
57
|
-
declare const ComposerContext: react.Context<ComposerContextValue | null>;
|
|
58
|
-
/**
|
|
59
|
-
* Hook to access the composer context.
|
|
60
|
-
* Must be used within a MessageComposer component.
|
|
61
|
-
*/
|
|
62
|
-
declare function useComposer(): ComposerContextValue;
|
|
63
|
-
interface MessageComposerProps {
|
|
64
|
-
/** Callback when message is submitted */
|
|
65
|
-
onSubmit: (content: string, attachments?: File[]) => Promise<void>;
|
|
66
|
-
/** Whether the composer is disabled */
|
|
67
|
-
disabled?: boolean;
|
|
68
|
-
/** Children to render inside the composer */
|
|
69
|
-
children: ReactNode;
|
|
70
|
-
/** Additional CSS classes */
|
|
71
|
-
className?: string;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Headless MessageComposer primitive.
|
|
75
|
-
* Provides composer state and behavior to children.
|
|
76
|
-
*/
|
|
77
|
-
declare const MessageComposer: react.ForwardRefExoticComponent<MessageComposerProps & react.RefAttributes<HTMLFormElement>>;
|
|
78
|
-
interface ComposerInputProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "onChange" | "value"> {
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Text input for the message composer.
|
|
82
|
-
*/
|
|
83
|
-
declare const ComposerInput: react.ForwardRefExoticComponent<ComposerInputProps & react.RefAttributes<HTMLTextAreaElement>>;
|
|
84
|
-
interface ComposerSubmitProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Submit button for the message composer.
|
|
88
|
-
*/
|
|
89
|
-
declare const ComposerSubmit: react.ForwardRefExoticComponent<ComposerSubmitProps & react.RefAttributes<HTMLButtonElement>>;
|
|
90
|
-
|
|
91
|
-
interface AvatarProps extends HTMLAttributes<HTMLDivElement> {
|
|
92
|
-
/** Name for fallback initials */
|
|
93
|
-
name?: string;
|
|
94
|
-
/** Image URL */
|
|
95
|
-
src?: string;
|
|
96
|
-
/** Alt text for image */
|
|
97
|
-
alt?: string;
|
|
98
|
-
/** Participant role for styling */
|
|
99
|
-
role?: ParticipantRole;
|
|
100
|
-
/** Fallback content when no image or name */
|
|
101
|
-
fallback?: React.ReactNode;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Headless Avatar primitive.
|
|
105
|
-
* Renders an image or fallback initials.
|
|
106
|
-
*/
|
|
107
|
-
declare const Avatar: react.ForwardRefExoticComponent<AvatarProps & react.RefAttributes<HTMLDivElement>>;
|
|
108
|
-
|
|
109
|
-
export { Avatar as A, ComposerContext as C, MessageComposer as M, ComposerInput as a, ComposerSubmit as b, MessageContent as c, MessageContext as d, Message as e, MessageTimestamp as f, useMessage as g, type AvatarProps as h, type ComposerInputProps as i, type ComposerSubmitProps as j, type MessageComposerProps as k, type MessageContentProps as l, type MessageProps as m, type MessageTimestampProps as n, useComposer as u };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Branding types for theming chat UI components.
|
|
3
|
-
*/
|
|
4
|
-
interface BrandingData {
|
|
5
|
-
customName?: string;
|
|
6
|
-
messageFontSize?: number;
|
|
7
|
-
welcomeMessage?: string;
|
|
8
|
-
chatboxPlaceholder?: string;
|
|
9
|
-
backgroundBubbleColor?: string;
|
|
10
|
-
headerBackgroundColor?: string;
|
|
11
|
-
showHeader?: boolean;
|
|
12
|
-
rotatingPlaceholders?: string[];
|
|
13
|
-
presetQuestions?: string[];
|
|
14
|
-
chatbotLogo?: string;
|
|
15
|
-
assistantAvatar?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type { BrandingData as B };
|
package/dist/chunk-3SEVU272.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkTOYU46SZ_cjs=require('./chunk-TOYU46SZ.cjs'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var d=react.createContext(null);function g(){let e=react.useContext(d);if(!e)throw new Error("useMessage must be used within a Message component");return e}var S=react.forwardRef(({message:e,viewerRole:t="user",children:r,...n},s)=>{let o=(e.participant?.role||"").toLowerCase()===(t||"").toLowerCase(),i=e.isStreaming??false;return jsxRuntime.jsx(d.Provider,{value:{message:e,isViewer:o,isStreaming:i},children:jsxRuntime.jsx("div",{ref:s,"data-role":e.participant?.role,"data-viewer":o,"data-streaming":i,...n,children:r})})});S.displayName="Message";var L=react.forwardRef(({children:e,...t},r)=>{let{message:n}=g();return jsxRuntime.jsx("div",{ref:r,...t,children:e??n.textContent})});L.displayName="MessageContent";var h=react.forwardRef(({format:e,...t},r)=>{let{message:n}=g(),s=typeof n.createdAt=="string"?new Date(n.createdAt):n.createdAt,o=e?e(s):s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:true});return jsxRuntime.jsx("span",{ref:r,...t,children:o})});h.displayName="MessageTimestamp";var R=react.forwardRef(({children:e,autoScroll:t=true,onIsAtBottomChange:r,onScrollToBottomRef:n,...s},o)=>{let{containerRef:i,scrollToBottom:a,isAtBottom:p}=chunkTOYU46SZ_cjs.a({enabled:t});return {current:p}.current!==p&&r?.(p),n?.(a),jsxRuntime.jsx("div",{ref:c=>{i.current=c,typeof o=="function"?o(c):o&&(o.current=c);},...s,children:e})});R.displayName="MessageList";var M=react.createContext(null);function x(){let e=react.useContext(M);if(!e)throw new Error("useComposer must be used within a MessageComposer component");return e}var P=react.forwardRef(({onSubmit:e,disabled:t=false,children:r,className:n},s)=>{let o=chunkTOYU46SZ_cjs.b({onSubmit:e,disabled:t}),i=p=>{p.preventDefault(),o.handleSubmit();},a={...o,canSubmit:!!o.canSubmit};return jsxRuntime.jsx(M.Provider,{value:a,children:jsxRuntime.jsx("form",{ref:s,className:n,onSubmit:i,"data-submitting":o.isSubmitting,"data-can-submit":o.canSubmit,children:r})})});P.displayName="MessageComposer";var H=react.forwardRef((e,t)=>{let{content:r,handleContentChange:n,handleKeyDown:s,inputRef:o}=x();return jsxRuntime.jsx("textarea",{ref:a=>{o.current=a,typeof t=="function"?t(a):t&&(t.current=a);},value:r,onChange:a=>n(a.target.value),onKeyDown:s,...e})});H.displayName="ComposerInput";var E=react.forwardRef(({children:e,disabled:t,...r},n)=>{let{canSubmit:s,isSubmitting:o}=x();return jsxRuntime.jsx("button",{ref:n,type:"submit",disabled:t||!s,"data-submitting":o,...r,children:e})});E.displayName="ComposerSubmit";function G(e){let t=e.trim().split(/\s+/);return t.length===1?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[t.length-1].charAt(0)).toUpperCase()}var N=react.forwardRef(({name:e,src:t,alt:r,role:n,fallback:s,children:o,...i},a)=>{let p=e?G(e):null;return jsxRuntime.jsx("div",{ref:a,"data-role":n,...i,children:o??jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?jsxRuntime.jsx("img",{src:t,alt:r??e??n??"Avatar",style:{width:"100%",height:"100%"}}):s??p??n?.charAt(0).toUpperCase()})})});N.displayName="Avatar";var w=react.forwardRef(({content:e,isStreaming:t=false,showCursor:r=true,cursor:n,children:s,...o},i)=>jsxRuntime.jsxs("div",{ref:i,"data-streaming":t,...o,children:[s??e,t&&r&&(n??jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:"2px",height:"1em",backgroundColor:"currentColor",marginLeft:"2px",verticalAlign:"text-bottom",animation:"blink 1s step-end infinite"}}))]}));w.displayName="StreamingText";var T=react.createContext(null);function D(){let e=react.useContext(T);if(!e)throw new Error("useSuggestedActions must be used within a SuggestedActions component");return e}var I=react.forwardRef(({actions:e,onSelect:t,children:r,className:n},s)=>e.length===0?null:jsxRuntime.jsx(T.Provider,{value:{actions:e,onSelect:t},children:jsxRuntime.jsx("div",{ref:s,role:"group","aria-label":"Suggested actions",className:n,children:r})}));I.displayName="SuggestedActions";var k=react.forwardRef(({action:e,children:t,onClick:r,...n},s)=>{let{onSelect:o}=D();return jsxRuntime.jsx("button",{ref:s,type:"button",onClick:a=>{r?.(a),a.defaultPrevented||o(e);},...n,children:t??e.label})});k.displayName="ActionButton";var V=react.forwardRef(({children:e,dotCount:t=3,...r},n)=>jsxRuntime.jsx("div",{ref:n,role:"status","aria-label":"Assistant is typing",...r,children:e??jsxRuntime.jsx("span",{"aria-hidden":"true",children:Array.from({length:t}).map((s,o)=>jsxRuntime.jsx("span",{style:{display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"currentColor",marginRight:o<t-1?"4px":0,animation:"typing 1.4s infinite ease-in-out",animationDelay:`${o*.2}s`}},o))})}));V.displayName="TypingIndicator";exports.a=d;exports.b=g;exports.c=S;exports.d=L;exports.e=h;exports.f=R;exports.g=M;exports.h=x;exports.i=P;exports.j=H;exports.k=E;exports.l=N;exports.m=w;exports.n=T;exports.o=D;exports.p=I;exports.q=k;exports.r=V;//# sourceMappingURL=chunk-3SEVU272.cjs.map
|
|
2
|
-
//# sourceMappingURL=chunk-3SEVU272.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/primitives/message.tsx","../src/primitives/message-list.tsx","../src/primitives/message-composer.tsx","../src/primitives/avatar.tsx","../src/primitives/streaming-text.tsx","../src/primitives/suggested-actions.tsx","../src/primitives/typing-indicator.tsx"],"names":["MessageContext","createContext","useMessage","context","useContext","Message","forwardRef","message","viewerRole","children","props","ref","isViewer","isStreaming","jsx","MessageContent","MessageTimestamp","format","date","formatted","MessageList","autoScroll","onIsAtBottomChange","onScrollToBottomRef","containerRef","scrollToBottom","isAtBottom","useAutoScroll","node","ComposerContext","useComposer","MessageComposer","onSubmit","disabled","className","composer","useMessageComposer","handleFormSubmit","e","contextValue","ComposerInput","content","handleContentChange","handleKeyDown","inputRef","ComposerSubmit","canSubmit","isSubmitting","getInitials","name","parts","Avatar","src","alt","role","fallback","initials","Fragment","StreamingText","showCursor","cursor","jsxs","SuggestedActionsContext","useSuggestedActions","SuggestedActions","actions","onSelect","ActionButton","action","onClick","TypingIndicator","dotCount","_","i"],"mappings":"kIASA,IAAMA,CAAAA,CAAiBC,oBAA0C,IAAI,EAM9D,SAASC,CAAAA,EAAa,CAC5B,IAAMC,EAAUC,gBAAAA,CAAWJ,CAAc,CAAA,CACzC,GAAI,CAACG,CAAAA,CACJ,MAAM,IAAI,KAAA,CAAM,oDAAoD,CAAA,CAErE,OAAOA,CACR,CAeO,IAAME,CAAAA,CAAUC,gBAAAA,CACtB,CAAC,CAAE,OAAA,CAAAC,EAAS,UAAA,CAAAC,CAAAA,CAAa,MAAA,CAAQ,QAAA,CAAAC,CAAAA,CAAU,GAAGC,CAAM,CAAA,CAAGC,CAAAA,GAAQ,CAE9D,IAAMC,CAAAA,CAAAA,CAAYL,CAAAA,CAAQ,WAAA,EAAa,MAAQ,EAAA,EAAI,WAAA,EAAY,GAAA,CAAOC,CAAAA,EAAc,EAAA,EAAI,WAAA,GAClFK,CAAAA,CAAcN,CAAAA,CAAQ,WAAA,EAAe,KAAA,CAE3C,OACCO,cAAAA,CAACd,EAAe,QAAA,CAAf,CAAwB,KAAA,CAAO,CAAE,OAAA,CAAAO,CAAAA,CAAS,QAAA,CAAAK,CAAAA,CAAU,WAAA,CAAAC,CAAY,CAAA,CAChE,QAAA,CAAAC,cAAAA,CAAC,KAAA,CAAA,CACA,IAAKH,CAAAA,CACL,WAAA,CAAWJ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AA,CAAc,iBAAA","file":"chunk-3SEVU272.cjs","sourcesContent":["import { createContext, forwardRef, useContext, type HTMLAttributes, type ReactNode } from \"react\";\nimport type { MessageData, ParticipantRole } from \"../types\";\n\ninterface MessageContextValue {\n\tmessage: MessageData;\n\tisViewer: boolean;\n\tisStreaming: boolean;\n}\n\nconst MessageContext = createContext<MessageContextValue | null>(null);\n\n/**\n * Hook to access the current message context.\n * Must be used within a Message component.\n */\nexport function useMessage() {\n\tconst context = useContext(MessageContext);\n\tif (!context) {\n\t\tthrow new Error(\"useMessage must be used within a Message component\");\n\t}\n\treturn context;\n}\n\nexport interface MessageProps extends HTMLAttributes<HTMLDivElement> {\n\t/** The message data */\n\tmessage: MessageData;\n\t/** The viewer's role (used to determine alignment) */\n\tviewerRole?: ParticipantRole;\n\t/** Children to render inside the message */\n\tchildren: ReactNode;\n}\n\n/**\n * Headless Message primitive.\n * Provides message context to children and data attributes for styling.\n */\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(\n\t({ message, viewerRole = \"user\", children, ...props }, ref) => {\n\t\t// Case-insensitive comparison for role matching\n\t\tconst isViewer = (message.participant?.role || \"\").toLowerCase() === (viewerRole || \"\").toLowerCase();\n\t\tconst isStreaming = message.isStreaming ?? false;\n\n\t\treturn (\n\t\t\t<MessageContext.Provider value={{ message, isViewer, isStreaming }}>\n\t\t\t\t<div\n\t\t\t\t\tref={ref}\n\t\t\t\t\tdata-role={message.participant?.role}\n\t\t\t\t\tdata-viewer={isViewer}\n\t\t\t\t\tdata-streaming={isStreaming}\n\t\t\t\t\t{...props}>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</MessageContext.Provider>\n\t\t);\n\t},\n);\n\nMessage.displayName = \"Message\";\n\nexport interface MessageContentProps extends HTMLAttributes<HTMLDivElement> {\n\t/** Custom content to render instead of message text */\n\tchildren?: ReactNode;\n}\n\n/**\n * Renders the message content.\n * By default renders the message's textContent.\n */\nexport const MessageContent = forwardRef<HTMLDivElement, MessageContentProps>(({ children, ...props }, ref) => {\n\tconst { message } = useMessage();\n\n\treturn (\n\t\t<div ref={ref} {...props}>\n\t\t\t{children ?? message.textContent}\n\t\t</div>\n\t);\n});\n\nMessageContent.displayName = \"MessageContent\";\n\nexport interface MessageTimestampProps extends HTMLAttributes<HTMLSpanElement> {\n\t/** Custom date formatter */\n\tformat?: (date: Date) => string;\n}\n\n/**\n * Renders the message timestamp.\n */\nexport const MessageTimestamp = forwardRef<HTMLSpanElement, MessageTimestampProps>(({ format, ...props }, ref) => {\n\tconst { message } = useMessage();\n\tconst date = typeof message.createdAt === \"string\" ? new Date(message.createdAt) : message.createdAt;\n\n\tconst formatted = format\n\t\t? format(date)\n\t\t: date.toLocaleTimeString(\"en-US\", {\n\t\t\t\thour: \"numeric\",\n\t\t\t\tminute: \"2-digit\",\n\t\t\t\thour12: true,\n\t\t\t});\n\n\treturn (\n\t\t<span ref={ref} {...props}>\n\t\t\t{formatted}\n\t\t</span>\n\t);\n});\n\nMessageTimestamp.displayName = \"MessageTimestamp\";\n\nexport { MessageContext };\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\nimport { useAutoScroll } from \"../hooks/use-auto-scroll\";\n\nexport interface MessageListProps extends HTMLAttributes<HTMLDivElement> {\n\t/** Messages to render */\n\tchildren: ReactNode;\n\t/** Whether to auto-scroll to bottom on new messages */\n\tautoScroll?: boolean;\n\t/** Whether the viewport is currently at the bottom (exposed for scroll-to-bottom button) */\n\tisAtBottom?: boolean;\n\t/** Callback to receive scroll state updates */\n\tonIsAtBottomChange?: (isAtBottom: boolean) => void;\n\t/** Callback to receive scrollToBottom function */\n\tonScrollToBottomRef?: (scrollToBottom: (behavior?: ScrollBehavior) => void) => void;\n}\n\n/**\n * Headless MessageList primitive.\n * Provides a scrollable container with auto-scroll behavior.\n * Exposes isAtBottom and scrollToBottom for scroll-to-bottom button integration.\n */\nexport const MessageList = forwardRef<HTMLDivElement, MessageListProps>(\n\t({ children, autoScroll = true, onIsAtBottomChange, onScrollToBottomRef, ...props }, ref) => {\n\t\tconst { containerRef, scrollToBottom, isAtBottom } = useAutoScroll<HTMLDivElement>({\n\t\t\tenabled: autoScroll,\n\t\t});\n\n\t\t// Notify parent of scroll state changes\n\t\tconst prevIsAtBottomRef = { current: isAtBottom };\n\t\tif (prevIsAtBottomRef.current !== isAtBottom) {\n\t\t\tonIsAtBottomChange?.(isAtBottom);\n\t\t}\n\n\t\t// Expose scrollToBottom to parent\n\t\tonScrollToBottomRef?.(scrollToBottom);\n\n\t\t// Merge refs\n\t\tconst mergedRef = (node: HTMLDivElement | null) => {\n\t\t\t(containerRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n\t\t\tif (typeof ref === \"function\") {\n\t\t\t\tref(node);\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = node;\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<div ref={mergedRef} {...props}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t},\n);\n\nMessageList.displayName = \"MessageList\";\n","import {\n createContext,\n useContext,\n forwardRef,\n type ReactNode,\n type TextareaHTMLAttributes,\n type ButtonHTMLAttributes,\n} from \"react\";\nimport { useMessageComposer } from \"../hooks/use-message-composer\";\n\ninterface ComposerContextValue {\n content: string;\n isSubmitting: boolean;\n canSubmit: boolean;\n error: string | null;\n handleContentChange: (value: string) => void;\n handleSubmit: () => Promise<void>;\n handleKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n inputRef: React.RefObject<HTMLTextAreaElement | null>;\n}\n\nconst ComposerContext = createContext<ComposerContextValue | null>(null);\n\n/**\n * Hook to access the composer context.\n * Must be used within a MessageComposer component.\n */\nexport function useComposer() {\n const context = useContext(ComposerContext);\n if (!context) {\n throw new Error(\"useComposer must be used within a MessageComposer component\");\n }\n return context;\n}\n\nexport interface MessageComposerProps {\n /** Callback when message is submitted */\n onSubmit: (content: string, attachments?: File[]) => Promise<void>;\n /** Whether the composer is disabled */\n disabled?: boolean;\n /** Children to render inside the composer */\n children: ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\n/**\n * Headless MessageComposer primitive.\n * Provides composer state and behavior to children.\n */\nexport const MessageComposer = forwardRef<HTMLFormElement, MessageComposerProps>(\n ({ onSubmit, disabled = false, children, className }, ref) => {\n const composer = useMessageComposer({ onSubmit, disabled });\n\n const handleFormSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n composer.handleSubmit();\n };\n\n const contextValue: ComposerContextValue = {\n ...composer,\n canSubmit: Boolean(composer.canSubmit),\n };\n\n return (\n <ComposerContext.Provider value={contextValue}>\n <form\n ref={ref}\n className={className}\n onSubmit={handleFormSubmit}\n data-submitting={composer.isSubmitting}\n data-can-submit={composer.canSubmit}\n >\n {children}\n </form>\n </ComposerContext.Provider>\n );\n }\n);\n\nMessageComposer.displayName = \"MessageComposer\";\n\nexport interface ComposerInputProps\n extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, \"onChange\" | \"value\"> {}\n\n/**\n * Text input for the message composer.\n */\nexport const ComposerInput = forwardRef<HTMLTextAreaElement, ComposerInputProps>(\n (props, ref) => {\n const { content, handleContentChange, handleKeyDown, inputRef } = useComposer();\n\n // Merge refs\n const mergedRef = (node: HTMLTextAreaElement | null) => {\n (inputRef as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n };\n\n return (\n <textarea\n ref={mergedRef}\n value={content}\n onChange={(e) => handleContentChange(e.target.value)}\n onKeyDown={handleKeyDown}\n {...props}\n />\n );\n }\n);\n\nComposerInput.displayName = \"ComposerInput\";\n\nexport interface ComposerSubmitProps extends ButtonHTMLAttributes<HTMLButtonElement> {}\n\n/**\n * Submit button for the message composer.\n */\nexport const ComposerSubmit = forwardRef<HTMLButtonElement, ComposerSubmitProps>(\n ({ children, disabled, ...props }, ref) => {\n const { canSubmit, isSubmitting } = useComposer();\n\n return (\n <button\n ref={ref}\n type=\"submit\"\n disabled={disabled || !canSubmit}\n data-submitting={isSubmitting}\n {...props}\n >\n {children}\n </button>\n );\n }\n);\n\nComposerSubmit.displayName = \"ComposerSubmit\";\n\nexport { ComposerContext };\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport type { ParticipantRole } from \"../types\";\n\nexport interface AvatarProps extends HTMLAttributes<HTMLDivElement> {\n /** Name for fallback initials */\n name?: string;\n /** Image URL */\n src?: string;\n /** Alt text for image */\n alt?: string;\n /** Participant role for styling */\n role?: ParticipantRole;\n /** Fallback content when no image or name */\n fallback?: React.ReactNode;\n}\n\n/**\n * Get initials from a name.\n */\nfunction getInitials(name: string): string {\n const parts = name.trim().split(/\\s+/);\n if (parts.length === 1) {\n return parts[0].charAt(0).toUpperCase();\n }\n return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0)).toUpperCase();\n}\n\n/**\n * Headless Avatar primitive.\n * Renders an image or fallback initials.\n */\nexport const Avatar = forwardRef<HTMLDivElement, AvatarProps>(\n ({ name, src, alt, role, fallback, children, ...props }, ref) => {\n const initials = name ? getInitials(name) : null;\n const altText = alt ?? name ?? role ?? \"Avatar\";\n\n return (\n <div ref={ref} data-role={role} {...props}>\n {children ?? (\n <>\n {src ? (\n <img src={src} alt={altText} style={{ width: \"100%\", height: \"100%\" }} />\n ) : (\n fallback ?? initials ?? role?.charAt(0).toUpperCase()\n )}\n </>\n )}\n </div>\n );\n }\n);\n\nAvatar.displayName = \"Avatar\";\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\n\nexport interface StreamingTextProps extends HTMLAttributes<HTMLDivElement> {\n /** The content to display */\n content: string;\n /** Whether the text is currently streaming */\n isStreaming?: boolean;\n /** Show a cursor indicator while streaming */\n showCursor?: boolean;\n /** Custom cursor element */\n cursor?: ReactNode;\n /** Children override (takes precedence over content) */\n children?: ReactNode;\n}\n\n/**\n * Headless StreamingText primitive.\n * Renders text with streaming indicator support.\n */\nexport const StreamingText = forwardRef<HTMLDivElement, StreamingTextProps>(\n (\n { content, isStreaming = false, showCursor = true, cursor, children, ...props },\n ref\n ) => {\n const defaultCursor = (\n <span\n aria-hidden=\"true\"\n style={{\n display: \"inline-block\",\n width: \"2px\",\n height: \"1em\",\n backgroundColor: \"currentColor\",\n marginLeft: \"2px\",\n verticalAlign: \"text-bottom\",\n animation: \"blink 1s step-end infinite\",\n }}\n />\n );\n\n return (\n <div ref={ref} data-streaming={isStreaming} {...props}>\n {children ?? content}\n {isStreaming && showCursor && (cursor ?? defaultCursor)}\n </div>\n );\n }\n);\n\nStreamingText.displayName = \"StreamingText\";\n","import {\n createContext,\n useContext,\n forwardRef,\n type ReactNode,\n type ButtonHTMLAttributes,\n} from \"react\";\nimport type { SuggestedAction } from \"../types\";\n\ninterface SuggestedActionsContextValue {\n actions: SuggestedAction[];\n onSelect: (action: SuggestedAction) => void;\n}\n\nconst SuggestedActionsContext = createContext<SuggestedActionsContextValue | null>(null);\n\n/**\n * Hook to access suggested actions context.\n */\nexport function useSuggestedActions() {\n const context = useContext(SuggestedActionsContext);\n if (!context) {\n throw new Error(\n \"useSuggestedActions must be used within a SuggestedActions component\"\n );\n }\n return context;\n}\n\nexport interface SuggestedActionsProps {\n /** List of suggested actions */\n actions: SuggestedAction[];\n /** Callback when an action is selected */\n onSelect: (action: SuggestedAction) => void;\n /** Children to render */\n children: ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\n/**\n * Headless SuggestedActions primitive.\n * Provides context for rendering action buttons.\n */\nexport const SuggestedActions = forwardRef<HTMLDivElement, SuggestedActionsProps>(\n ({ actions, onSelect, children, className }, ref) => {\n if (actions.length === 0) {\n return null;\n }\n\n return (\n <SuggestedActionsContext.Provider value={{ actions, onSelect }}>\n <div ref={ref} role=\"group\" aria-label=\"Suggested actions\" className={className}>\n {children}\n </div>\n </SuggestedActionsContext.Provider>\n );\n }\n);\n\nSuggestedActions.displayName = \"SuggestedActions\";\n\nexport interface ActionButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /** The action this button represents */\n action: SuggestedAction;\n /** Children to render inside button */\n children?: ReactNode;\n}\n\n/**\n * Button for a suggested action.\n */\nexport const ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(\n ({ action, children, onClick, ...props }, ref) => {\n const { onSelect } = useSuggestedActions();\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e);\n if (!e.defaultPrevented) {\n onSelect(action);\n }\n };\n\n return (\n <button ref={ref} type=\"button\" onClick={handleClick} {...props}>\n {children ?? action.label}\n </button>\n );\n }\n);\n\nActionButton.displayName = \"ActionButton\";\n\nexport { SuggestedActionsContext };\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\n\nexport interface TypingIndicatorProps extends HTMLAttributes<HTMLDivElement> {\n /** Custom content to show while typing */\n children?: ReactNode;\n /** Number of dots to show */\n dotCount?: number;\n}\n\n/**\n * Headless TypingIndicator primitive.\n * Shows animated dots or custom content.\n */\nexport const TypingIndicator = forwardRef<HTMLDivElement, TypingIndicatorProps>(\n ({ children, dotCount = 3, ...props }, ref) => {\n return (\n <div ref={ref} role=\"status\" aria-label=\"Assistant is typing\" {...props}>\n {children ?? (\n <span aria-hidden=\"true\">\n {Array.from({ length: dotCount }).map((_, i) => (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n width: \"6px\",\n height: \"6px\",\n borderRadius: \"50%\",\n backgroundColor: \"currentColor\",\n marginRight: i < dotCount - 1 ? \"4px\" : 0,\n animation: `typing 1.4s infinite ease-in-out`,\n animationDelay: `${i * 0.2}s`,\n }}\n />\n ))}\n </span>\n )}\n </div>\n );\n }\n);\n\nTypingIndicator.displayName = \"TypingIndicator\";\n"]}
|
package/dist/chunk-HVCCZKEO.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var react=require('react');function a(t,c){let o=react.useRef(null),r=react.useRef(null);return react.useEffect(()=>()=>{r.current?.();},[]),react.useCallback(()=>{if(r.current?.(),!o.current&&t.current){let l=t.current;for(;l;){let{overflowY:u}=getComputedStyle(l);if(u==="scroll"||u==="auto"){o.current=l;break}l=l.parentElement;}}let e=o.current;if(!e)return;let f=e.scrollTop,s=e.style.scrollbarWidth;e.style.scrollbarWidth="none";let n=()=>{e.scrollTop=f;};e.addEventListener("scroll",n);let b=setTimeout(()=>{e.removeEventListener("scroll",n),e.style.scrollbarWidth=s,r.current=null;},c);r.current=()=>{clearTimeout(b),e.removeEventListener("scroll",n),e.style.scrollbarWidth=s;};},[c,t])}exports.a=a;//# sourceMappingURL=chunk-HVCCZKEO.cjs.map
|
|
2
|
-
//# sourceMappingURL=chunk-HVCCZKEO.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-scroll-lock.ts"],"names":["useScrollLock","animatedElementRef","animationDuration","scrollContainerRef","useRef","cleanupRef","useEffect","useCallback","el","overflowY","scrollContainer","scrollPosition","prevScrollbarWidth","resetPosition","timeoutId"],"mappings":"wCA0BO,SAASA,CAAAA,CACdC,EACAC,CAAAA,CACA,CACA,IAAMC,CAAAA,CAAqBC,aAA2B,IAAI,CAAA,CACpDC,CAAAA,CAAaD,YAAAA,CAA4B,IAAI,CAAA,CAGnD,OAAAE,eAAAA,CAAU,IACD,IAAM,CACXD,CAAAA,CAAW,OAAA,KACb,EACC,EAAE,CAAA,CAEcE,iBAAAA,CAAY,IAAM,CAKnC,GAHAF,CAAAA,CAAW,OAAA,IAAU,CAGjB,CAACF,CAAAA,CAAmB,OAAA,EAAWF,EAAmB,OAAA,CAAS,CAC7D,IAAIO,CAAAA,CAAyBP,EAAmB,OAAA,CAChD,KAAOO,CAAAA,EAAI,CACT,GAAM,CAAE,SAAA,CAAAC,CAAU,CAAA,CAAI,iBAAiBD,CAAE,CAAA,CACzC,GAAIC,CAAAA,GAAc,UAAYA,CAAAA,GAAc,MAAA,CAAQ,CAClDN,CAAAA,CAAmB,QAAUK,CAAAA,CAC7B,KACF,CACAA,CAAAA,CAAKA,EAAG,cACV,CACF,CAEA,IAAME,CAAAA,CAAkBP,CAAAA,CAAmB,OAAA,CAC3C,GAAI,CAACO,CAAAA,CAAiB,OAGtB,IAAMC,CAAAA,CAAiBD,EAAgB,SAAA,CACjCE,CAAAA,CAAqBF,CAAAA,CAAgB,KAAA,CAAM,eAGjDA,CAAAA,CAAgB,KAAA,CAAM,cAAA,CAAiB,MAAA,CAGvC,IAAMG,CAAAA,CAAgB,IAAM,CAC1BH,CAAAA,CAAgB,UAAYC,EAC9B,CAAA,CACAD,CAAAA,CAAgB,gBAAA,CAAiB,SAAUG,CAAa,CAAA,CAGxD,IAAMC,CAAAA,CAAY,WAAW,IAAM,CACjCJ,CAAAA,CAAgB,mBAAA,CAAoB,QAAA,CAAUG,CAAa,CAAA,CAC3DH,CAAAA,CAAgB,MAAM,cAAA,CAAiBE,CAAAA,CACvCP,CAAAA,CAAW,OAAA,CAAU,KACvB,CAAA,CAAGH,CAAiB,CAAA,CAEpBG,CAAAA,CAAW,QAAU,IAAM,CACzB,YAAA,CAAaS,CAAS,EACtBJ,CAAAA,CAAgB,mBAAA,CAAoB,QAAA,CAAUG,CAAa,EAC3DH,CAAAA,CAAgB,KAAA,CAAM,cAAA,CAAiBE,EACzC,EACF,CAAA,CAAG,CAACV,CAAAA,CAAmBD,CAAkB,CAAC,CAG5C","file":"chunk-HVCCZKEO.cjs","sourcesContent":["import { type RefObject, useCallback, useEffect, useRef } from \"react\";\n\n/**\n * Locks scroll position during collapsible/height animations.\n *\n * Prevents viewport jumps when content height changes during animations\n * (e.g. ReasoningPanel expand/collapse). Finds the nearest scrollable\n * ancestor and temporarily locks its scroll position for the animation duration.\n *\n * Adapted from assistant-ui's useScrollLock.\n *\n * @param animatedElementRef - Ref to the animated element\n * @param animationDuration - Lock duration in milliseconds\n * @returns Function to activate the scroll lock (call before toggling)\n *\n * @example\n * ```tsx\n * const panelRef = useRef<HTMLDivElement>(null);\n * const lockScroll = useScrollLock(panelRef, 200);\n *\n * const handleToggle = () => {\n * lockScroll();\n * setIsExpanded(!isExpanded);\n * };\n * ```\n */\nexport function useScrollLock<T extends HTMLElement = HTMLElement>(\n animatedElementRef: RefObject<T | null>,\n animationDuration: number,\n) {\n const scrollContainerRef = useRef<HTMLElement | null>(null);\n const cleanupRef = useRef<(() => void) | null>(null);\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n cleanupRef.current?.();\n };\n }, []);\n\n const lockScroll = useCallback(() => {\n // Clean up any previous lock\n cleanupRef.current?.();\n\n // Find nearest scrollable ancestor (cached after first find)\n if (!scrollContainerRef.current && animatedElementRef.current) {\n let el: HTMLElement | null = animatedElementRef.current;\n while (el) {\n const { overflowY } = getComputedStyle(el);\n if (overflowY === \"scroll\" || overflowY === \"auto\") {\n scrollContainerRef.current = el;\n break;\n }\n el = el.parentElement;\n }\n }\n\n const scrollContainer = scrollContainerRef.current;\n if (!scrollContainer) return;\n\n // Capture current scroll position\n const scrollPosition = scrollContainer.scrollTop;\n const prevScrollbarWidth = scrollContainer.style.scrollbarWidth;\n\n // Hide scrollbar during lock to prevent visual jank\n scrollContainer.style.scrollbarWidth = \"none\";\n\n // Lock: intercept any scroll events and reset position\n const resetPosition = () => {\n scrollContainer.scrollTop = scrollPosition;\n };\n scrollContainer.addEventListener(\"scroll\", resetPosition);\n\n // Release lock after animation completes\n const timeoutId = setTimeout(() => {\n scrollContainer.removeEventListener(\"scroll\", resetPosition);\n scrollContainer.style.scrollbarWidth = prevScrollbarWidth;\n cleanupRef.current = null;\n }, animationDuration);\n\n cleanupRef.current = () => {\n clearTimeout(timeoutId);\n scrollContainer.removeEventListener(\"scroll\", resetPosition);\n scrollContainer.style.scrollbarWidth = prevScrollbarWidth;\n };\n }, [animationDuration, animatedElementRef]);\n\n return lockScroll;\n}\n"]}
|
package/dist/chunk-KSMAVBLY.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var react=require('react');function i(e){let n=e.trim();if(n.startsWith("#")){let r=n.slice(1);if(r.length===3)return [parseInt(r[0]+r[0],16),parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16)];if(r.length>=6)return [parseInt(r.slice(0,2),16),parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16)]}let t=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})/);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function c(e,n,t){let[r,a,u]=[e/255,n/255,t/255].map(s=>s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4));return .2126*r+.7152*a+.0722*u}function o(e){let n=i(e);return n&&c(...n)>.179?"#1D2033":"#ffffff"}function p(e,n){return react.useMemo(()=>{if(!e&&!n?.iconColor)return {};let t={},r=e?.backgroundBubbleColor||n?.iconColor;return r&&(t["--chat-primary"]=r,t["--chat-user-message-bg"]=r,t["--chat-user-message-text"]=o(r)),e?.headerBackgroundColor&&(t["--chat-header-bg"]=e.headerBackgroundColor),e?.messageFontSize&&(t["--chat-message-font-size"]=`${e.messageFontSize}px`),t},[e,n?.iconColor])}exports.a=o;exports.b=p;//# sourceMappingURL=chunk-KSMAVBLY.cjs.map
|
|
2
|
-
//# sourceMappingURL=chunk-KSMAVBLY.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/color-contrast.ts","../src/hooks/use-branding-css-vars.ts"],"names":["parseColor","color","hex","h","rgbMatch","relativeLuminance","r","g","b","rs","gs","bs","c","getContrastTextColor","bgColor","rgb","useBrandingCSSVars","branding","overrides","useMemo","vars","primaryColor"],"mappings":"wCAIA,SAASA,CAAAA,CAAWC,CAAAA,CAAgD,CAElE,IAAMC,CAAAA,CAAMD,CAAAA,CAAM,IAAA,EAAK,CACvB,GAAIC,CAAAA,CAAI,UAAA,CAAW,GAAG,CAAA,CAAG,CACvB,IAAMC,CAAAA,CAAID,CAAAA,CAAI,KAAA,CAAM,CAAC,CAAA,CACrB,GAAIC,CAAAA,CAAE,MAAA,GAAW,CAAA,CACf,OAA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,CAAA,CACA,OAAO,KAAA,CAASH,CAAAA,CAAK,KAAA,CAASC,CAAAA,CAAK,KAAA,CAASC,CAC9C,CAOO,SAASE,CAAAA,CAAqBC,CAAAA,CAAyB,CAC5D,IAAMC,CAAAA,CAAMf,CAAAA,CAAWc,CAAO,CAAA,CAC9B,OAAKC,CAAAA,EAEOV,CAAAA,CAAkB,GAAGU,CAAG,CAAA,CAEvB,IAAA,CAAQ,SAAA,CAJJ,SAKnB,CCnDO,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACqB,CACrB,OAAOC,cAAQ,IAAM,CACnB,GAAI,CAACF,CAAAA,EAAY,CAACC,CAAAA,EAAW,SAAA,CAAW,OAAO,EAAC,CAEhD,IAAME,CAAAA,CAA+B,EAAC,CAEhCC,CAAAA,CACJJ,CAAAA,EAAU,qBAAA,EAAyBC,CAAAA,EAAW,SAAA,CAChD,OAAIG,CAAAA,GACFD,CAAAA,CAAK,gBAAgB,CAAA,CAAIC,CAAAA,CACzBD,CAAAA,CAAK,wBAAwB,CAAA,CAAIC,CAAAA,CACjCD,EAAK,0BAA0B,CAAA,CAAIP,CAAAA,CAAqBQ,CAAY,CAAA,CAAA,CAGlEJ,CAAAA,EAAU,qBAAA,GACZG,CAAAA,CAAK,kBAAkB,CAAA,CAAIH,CAAAA,CAAS,qBAAA,CAAA,CAGlCA,CAAAA,EAAU,eAAA,GACZG,CAAAA,CAAK,0BAA0B,CAAA,CAAI,CAAA,EAAGH,CAAAA,CAAS,eAAe,CAAA,EAAA,CAAA,CAAA,CAGzDG,CACT,CAAA,CAAG,CAACH,CAAAA,CAAUC,CAAAA,EAAW,SAAS,CAAC,CACrC","file":"chunk-KSMAVBLY.cjs","sourcesContent":["/**\n * Parse a CSS color string (hex, rgb, rgba) into [r, g, b] values.\n * Returns null if the color cannot be parsed.\n */\nfunction parseColor(color: string): [number, number, number] | null {\n // Hex: #RGB, #RRGGBB\n const hex = color.trim();\n if (hex.startsWith(\"#\")) {\n const h = hex.slice(1);\n if (h.length === 3) {\n return [\n parseInt(h[0] + h[0], 16),\n parseInt(h[1] + h[1], 16),\n parseInt(h[2] + h[2], 16),\n ];\n }\n if (h.length >= 6) {\n return [\n parseInt(h.slice(0, 2), 16),\n parseInt(h.slice(2, 4), 16),\n parseInt(h.slice(4, 6), 16),\n ];\n }\n }\n\n // rgb(r, g, b) or rgba(r, g, b, a)\n const rgbMatch = color.match(\n /rgba?\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})/\n );\n if (rgbMatch) {\n return [Number(rgbMatch[1]), Number(rgbMatch[2]), Number(rgbMatch[3])];\n }\n\n return null;\n}\n\n/**\n * Compute the relative luminance of an sRGB color per WCAG 2.0.\n * https://www.w3.org/TR/WCAG20/#relativeluminancedef\n */\nfunction relativeLuminance(r: number, g: number, b: number): number {\n const [rs, gs, bs] = [r / 255, g / 255, b / 255].map((c) =>\n c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4)\n );\n return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;\n}\n\n/**\n * Given a background color string, return the best contrast text color.\n * Returns \"#ffffff\" for dark backgrounds and \"#1D2033\" for light backgrounds.\n * Falls back to \"#ffffff\" if the color cannot be parsed.\n */\nexport function getContrastTextColor(bgColor: string): string {\n const rgb = parseColor(bgColor);\n if (!rgb) return \"#ffffff\";\n\n const lum = relativeLuminance(...rgb);\n // WCAG threshold: luminance > 0.179 means the background is \"light\"\n return lum > 0.179 ? \"#1D2033\" : \"#ffffff\";\n}\n","import { useMemo } from \"react\";\nimport type { BrandingData } from \"../types/branding\";\nimport { getContrastTextColor } from \"../utils/color-contrast\";\n\n/**\n * Converts BrandingData into CSS custom properties for chat-ui theming.\n * Returns a CSSProperties object that can be spread onto a container element.\n */\nexport function useBrandingCSSVars(\n branding: BrandingData | null | undefined,\n overrides?: { iconColor?: string }\n): React.CSSProperties {\n return useMemo(() => {\n if (!branding && !overrides?.iconColor) return {};\n\n const vars: Record<string, string> = {};\n\n const primaryColor =\n branding?.backgroundBubbleColor || overrides?.iconColor;\n if (primaryColor) {\n vars[\"--chat-primary\"] = primaryColor;\n vars[\"--chat-user-message-bg\"] = primaryColor;\n vars[\"--chat-user-message-text\"] = getContrastTextColor(primaryColor);\n }\n\n if (branding?.headerBackgroundColor) {\n vars[\"--chat-header-bg\"] = branding.headerBackgroundColor;\n }\n\n if (branding?.messageFontSize) {\n vars[\"--chat-message-font-size\"] = `${branding.messageFontSize}px`;\n }\n\n return vars as React.CSSProperties;\n }, [branding, overrides?.iconColor]);\n}\n"]}
|