@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
package/dist/client/index.d.cts
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { C as ChatMessage } from '../message-9z0crkf9.cjs';
|
|
2
|
-
import { B as BrandingData } from '../branding-SzYU4ncD.cjs';
|
|
3
|
-
import '../streaming-CF63E6iS.cjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Types for the Miiflow chat client (transport layer).
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
interface MiiflowChatConfig {
|
|
10
|
-
/** Public API key for authentication */
|
|
11
|
-
publicKey: string;
|
|
12
|
-
/** Assistant ID to connect to */
|
|
13
|
-
assistantId: string;
|
|
14
|
-
/** Optional user ID for identity */
|
|
15
|
-
userId?: string;
|
|
16
|
-
/** Optional user display name */
|
|
17
|
-
userName?: string;
|
|
18
|
-
/** Optional user email */
|
|
19
|
-
userEmail?: string;
|
|
20
|
-
/** Optional user metadata (JSON string) */
|
|
21
|
-
userMetadata?: string;
|
|
22
|
-
/** HMAC for identity verification */
|
|
23
|
-
hmac?: string;
|
|
24
|
-
/** Timestamp for HMAC verification */
|
|
25
|
-
timestamp?: string;
|
|
26
|
-
/** Override base URL (auto-detected from bundleUrl otherwise) */
|
|
27
|
-
baseUrl?: string;
|
|
28
|
-
/** Bundle URL used for dev detection (internal, set by script embed) */
|
|
29
|
-
bundleUrl?: string;
|
|
30
|
-
/** Response timeout in milliseconds (default: 60000) */
|
|
31
|
-
responseTimeout?: number;
|
|
32
|
-
/** WebSocket URL for bidirectional events (tool invocations). Auto-derived from baseUrl if not set. */
|
|
33
|
-
webSocketUrl?: string;
|
|
34
|
-
/** Fallback for tool invocations not handled locally (multi-widget routing) */
|
|
35
|
-
onToolInvocationFallback?: (invocation: ToolInvocationRequest) => Promise<boolean>;
|
|
36
|
-
/** Callback fired when a user message is created (for widget event emission) */
|
|
37
|
-
onUserMessageCreated?: (message: {
|
|
38
|
-
id: string;
|
|
39
|
-
content: string;
|
|
40
|
-
}) => void;
|
|
41
|
-
/** Callback fired when an assistant message stream completes (for widget event emission) */
|
|
42
|
-
onAssistantMessageComplete?: (message: {
|
|
43
|
-
id: string;
|
|
44
|
-
content: string;
|
|
45
|
-
}) => void;
|
|
46
|
-
}
|
|
47
|
-
interface EmbedSessionBranding {
|
|
48
|
-
show_header?: boolean;
|
|
49
|
-
custom_name?: string;
|
|
50
|
-
welcome_message?: string;
|
|
51
|
-
chatbox_placeholder?: string;
|
|
52
|
-
background_bubble_color?: string;
|
|
53
|
-
header_background_color?: string;
|
|
54
|
-
message_font_size?: number;
|
|
55
|
-
rotating_placeholders?: string[];
|
|
56
|
-
preset_questions?: string[];
|
|
57
|
-
assistant_avatar?: string;
|
|
58
|
-
chatbot_logo?: string;
|
|
59
|
-
}
|
|
60
|
-
interface EmbedSessionConfig {
|
|
61
|
-
assistant_id: string;
|
|
62
|
-
assistant_name: string;
|
|
63
|
-
assistant_description: string;
|
|
64
|
-
thread_id: string;
|
|
65
|
-
branding?: EmbedSessionBranding;
|
|
66
|
-
}
|
|
67
|
-
interface EmbedSession {
|
|
68
|
-
token: string;
|
|
69
|
-
config: EmbedSessionConfig;
|
|
70
|
-
session_id: string;
|
|
71
|
-
}
|
|
72
|
-
interface MiiflowChatResult {
|
|
73
|
-
/** Chat messages in ChatMessage format (directly compatible with ChatProvider) */
|
|
74
|
-
messages: ChatMessage[];
|
|
75
|
-
/** Whether a response is currently streaming */
|
|
76
|
-
isStreaming: boolean;
|
|
77
|
-
/** ID of the message being streamed */
|
|
78
|
-
streamingMessageId: string | null;
|
|
79
|
-
/** Send a message to the assistant, optionally with attachment IDs */
|
|
80
|
-
sendMessage: (content: string, attachmentIds?: string[]) => Promise<void>;
|
|
81
|
-
/** Upload a file and return its attachment ID */
|
|
82
|
-
uploadFile: (file: File) => Promise<string>;
|
|
83
|
-
/** Remove uploaded attachment metadata (call when user removes attachment before sending) */
|
|
84
|
-
removeUploadedAttachment: (attachmentId: string) => void;
|
|
85
|
-
/** Current session data */
|
|
86
|
-
session: EmbedSession | null;
|
|
87
|
-
/** Whether the session is still initializing */
|
|
88
|
-
loading: boolean;
|
|
89
|
-
/** Error message if initialization or sending failed */
|
|
90
|
-
error: string | null;
|
|
91
|
-
/** Branding data from the session, mapped to BrandingData */
|
|
92
|
-
branding: BrandingData | null;
|
|
93
|
-
/** CSS custom properties derived from branding (spread onto container) */
|
|
94
|
-
brandingCSSVars: React.CSSProperties;
|
|
95
|
-
/** Start a new thread, returns the new thread ID */
|
|
96
|
-
startNewThread: () => Promise<string>;
|
|
97
|
-
/** Register a client-side tool */
|
|
98
|
-
registerTool: (tool: ClientToolDefinition) => Promise<void>;
|
|
99
|
-
/** Register multiple client-side tools */
|
|
100
|
-
registerTools: (tools: ClientToolDefinition[]) => Promise<void>;
|
|
101
|
-
/** Send a system event (invisible to chat, processed by assistant) */
|
|
102
|
-
sendSystemEvent: (event: SystemEvent) => Promise<void>;
|
|
103
|
-
/** Execute a client tool invocation (called when backend invokes a registered tool). Returns true if handled. */
|
|
104
|
-
handleToolInvocation: (invocation: ToolInvocationRequest) => Promise<boolean>;
|
|
105
|
-
/** Update the session externally (e.g. after token refresh) */
|
|
106
|
-
updateSession: (session: EmbedSession) => void;
|
|
107
|
-
}
|
|
108
|
-
interface JSONSchemaProperty {
|
|
109
|
-
type: "string" | "number" | "integer" | "boolean" | "array" | "object" | "null";
|
|
110
|
-
description?: string;
|
|
111
|
-
enum?: Array<string | number | boolean>;
|
|
112
|
-
items?: JSONSchemaProperty;
|
|
113
|
-
properties?: Record<string, JSONSchemaProperty>;
|
|
114
|
-
required?: string[];
|
|
115
|
-
default?: unknown;
|
|
116
|
-
}
|
|
117
|
-
interface JSONSchemaObject {
|
|
118
|
-
type: "object";
|
|
119
|
-
properties: Record<string, JSONSchemaProperty>;
|
|
120
|
-
required?: string[];
|
|
121
|
-
additionalProperties?: boolean | JSONSchemaProperty;
|
|
122
|
-
description?: string;
|
|
123
|
-
}
|
|
124
|
-
type ToolHandler = (params: Record<string, unknown>) => Promise<unknown>;
|
|
125
|
-
interface ClientToolDefinition {
|
|
126
|
-
/** Tool name (alphanumeric + underscore, must start with letter/underscore) */
|
|
127
|
-
name: string;
|
|
128
|
-
/** Description of what the tool does (shown to LLM) */
|
|
129
|
-
description: string;
|
|
130
|
-
/** JSON Schema defining the tool's parameters */
|
|
131
|
-
parameters: JSONSchemaObject;
|
|
132
|
-
/** Handler function to execute when LLM calls this tool */
|
|
133
|
-
handler: ToolHandler;
|
|
134
|
-
}
|
|
135
|
-
interface ToolInvocationRequest {
|
|
136
|
-
invocation_id: string;
|
|
137
|
-
tool_name: string;
|
|
138
|
-
parameters: Record<string, unknown>;
|
|
139
|
-
}
|
|
140
|
-
interface ToolExecutionResult {
|
|
141
|
-
invocation_id: string;
|
|
142
|
-
result?: unknown;
|
|
143
|
-
error?: string;
|
|
144
|
-
}
|
|
145
|
-
interface SystemEvent {
|
|
146
|
-
action: string;
|
|
147
|
-
description: string;
|
|
148
|
-
followUpInstruction: string;
|
|
149
|
-
metadata?: Record<string, unknown>;
|
|
150
|
-
}
|
|
151
|
-
type WidgetEventType = "widget_ready" | "widget_opened" | "widget_closed" | "widget_reconnected" | "session_start" | "session_end" | "thread_started" | "new_message" | "message_sent" | "message_received" | "error" | "load_failed" | "assistant_response_timeout";
|
|
152
|
-
type WidgetEventPayload = Record<string, unknown> | undefined;
|
|
153
|
-
type WidgetEventCallback = (type: WidgetEventType, payload?: WidgetEventPayload) => void;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* useMiiflowChat - React hook for connecting to Miiflow's embedded chat API.
|
|
157
|
-
*
|
|
158
|
-
* Handles session init, SSE streaming, message management, tool registration,
|
|
159
|
-
* and branding. Returns a shape directly compatible with ChatProvider props.
|
|
160
|
-
*/
|
|
161
|
-
|
|
162
|
-
declare function useMiiflowChat(config: MiiflowChatConfig): MiiflowChatResult;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Determine the backend base URL from config.
|
|
166
|
-
*/
|
|
167
|
-
declare function getBackendBaseUrl(config: MiiflowChatConfig): string;
|
|
168
|
-
/**
|
|
169
|
-
* Get or create a persistent anonymous user ID stored in localStorage.
|
|
170
|
-
*/
|
|
171
|
-
declare function getOrCreateUserId(): string;
|
|
172
|
-
/**
|
|
173
|
-
* Initialize an embed session by calling the backend init endpoint.
|
|
174
|
-
*/
|
|
175
|
-
declare function initSession(config: MiiflowChatConfig): Promise<EmbedSession>;
|
|
176
|
-
/**
|
|
177
|
-
* Create a new thread for the current session.
|
|
178
|
-
*/
|
|
179
|
-
declare function createThread(config: MiiflowChatConfig, session: EmbedSession): Promise<{
|
|
180
|
-
threadId: string;
|
|
181
|
-
token?: string;
|
|
182
|
-
}>;
|
|
183
|
-
/**
|
|
184
|
-
* Update user data for the current session.
|
|
185
|
-
*/
|
|
186
|
-
declare function updateUser(config: MiiflowChatConfig, session: EmbedSession, userData: {
|
|
187
|
-
user_id?: string;
|
|
188
|
-
name?: string;
|
|
189
|
-
email?: string;
|
|
190
|
-
}): Promise<void>;
|
|
191
|
-
/**
|
|
192
|
-
* Upload a file attachment via REST endpoint.
|
|
193
|
-
* Returns the attachment ID for use in sendMessage.
|
|
194
|
-
*/
|
|
195
|
-
declare function uploadFile(config: MiiflowChatConfig, session: EmbedSession, file: File): Promise<string>;
|
|
196
|
-
/**
|
|
197
|
-
* Send a system event to the backend (invisible to chat, processed by assistant).
|
|
198
|
-
*/
|
|
199
|
-
declare function sendSystemEvent(config: MiiflowChatConfig, session: EmbedSession, systemEvent: SystemEvent): Promise<void>;
|
|
200
|
-
/**
|
|
201
|
-
* Send a tool execution result back to the backend.
|
|
202
|
-
*/
|
|
203
|
-
declare function sendToolResult(config: MiiflowChatConfig, session: EmbedSession, result: ToolExecutionResult): Promise<void>;
|
|
204
|
-
/**
|
|
205
|
-
* Register tool definitions with the backend.
|
|
206
|
-
*/
|
|
207
|
-
declare function registerToolsOnBackend(config: MiiflowChatConfig, session: EmbedSession, toolDefinitions: Array<Omit<ClientToolDefinition, "handler">>): Promise<void>;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Utility functions for parsing and managing JWT tokens.
|
|
211
|
-
* Used for proactive token refresh before expiration.
|
|
212
|
-
*/
|
|
213
|
-
/**
|
|
214
|
-
* Parse the expiry time from a JWT token.
|
|
215
|
-
* Returns the expiry timestamp in milliseconds, or null if parsing fails.
|
|
216
|
-
*/
|
|
217
|
-
declare function parseTokenExpiry(token: string): number | null;
|
|
218
|
-
/**
|
|
219
|
-
* Check if a token is expiring soon (within the given threshold).
|
|
220
|
-
*/
|
|
221
|
-
declare function isTokenExpiringSoon(token: string, thresholdMs: number): boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Check if a token has already expired.
|
|
224
|
-
*/
|
|
225
|
-
declare function isTokenExpired(token: string): boolean;
|
|
226
|
-
/**
|
|
227
|
-
* Get the time remaining until token expiry in milliseconds.
|
|
228
|
-
*/
|
|
229
|
-
declare function getTimeUntilExpiry(token: string): number;
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Client-side validator for tool definitions.
|
|
233
|
-
* Validates tool definitions before they're sent to the backend.
|
|
234
|
-
*/
|
|
235
|
-
|
|
236
|
-
declare class ToolValidationError extends Error {
|
|
237
|
-
constructor(message: string);
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Validates a client tool definition.
|
|
241
|
-
* Throws ToolValidationError if validation fails.
|
|
242
|
-
*/
|
|
243
|
-
declare function validateToolDefinition(tool: ClientToolDefinition): void;
|
|
244
|
-
/**
|
|
245
|
-
* Strips the handler function from a tool definition for sending to backend.
|
|
246
|
-
*/
|
|
247
|
-
declare function serializeToolDefinition(tool: ClientToolDefinition): Omit<ClientToolDefinition, "handler">;
|
|
248
|
-
|
|
249
|
-
export { type ClientToolDefinition, type EmbedSession, type EmbedSessionBranding, type EmbedSessionConfig, type JSONSchemaObject, type JSONSchemaProperty, type MiiflowChatConfig, type MiiflowChatResult, type SystemEvent, type ToolExecutionResult, type ToolHandler, type ToolInvocationRequest, ToolValidationError, type WidgetEventCallback, type WidgetEventPayload, type WidgetEventType, createThread, getBackendBaseUrl, getOrCreateUserId, getTimeUntilExpiry, initSession, isTokenExpired, isTokenExpiringSoon, parseTokenExpiry, registerToolsOnBackend, sendSystemEvent, sendToolResult, serializeToolDefinition, updateUser, uploadFile, useMiiflowChat, validateToolDefinition };
|
package/dist/context/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkSFEPMZCU_cjs=require('../chunk-SFEPMZCU.cjs');Object.defineProperty(exports,"ChatContext",{enumerable:true,get:function(){return chunkSFEPMZCU_cjs.a}});Object.defineProperty(exports,"ChatProvider",{enumerable:true,get:function(){return chunkSFEPMZCU_cjs.b}});Object.defineProperty(exports,"useChatContext",{enumerable:true,get:function(){return chunkSFEPMZCU_cjs.c}});//# sourceMappingURL=index.cjs.map
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/context/index.d.cts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
import { C as ChatMessage, P as ParticipantRole } from '../message-9z0crkf9.cjs';
|
|
5
|
-
import { d as VisualizationActionEvent } from '../streaming-CF63E6iS.cjs';
|
|
6
|
-
|
|
7
|
-
interface ChatContextValue {
|
|
8
|
-
/** List of messages in the conversation */
|
|
9
|
-
messages: ChatMessage[];
|
|
10
|
-
/** Whether a message is currently being streamed */
|
|
11
|
-
isStreaming: boolean;
|
|
12
|
-
/** ID of the message currently being streamed */
|
|
13
|
-
streamingMessageId: string | null;
|
|
14
|
-
/** The viewer's role (determines message alignment) */
|
|
15
|
-
viewerRole: ParticipantRole;
|
|
16
|
-
/** Send a new message */
|
|
17
|
-
sendMessage: (content: string, attachments?: File[]) => Promise<void>;
|
|
18
|
-
/** Stop the current streaming response */
|
|
19
|
-
stopStreaming?: () => void;
|
|
20
|
-
/** Retry the last failed message */
|
|
21
|
-
retryLastMessage?: () => Promise<void>;
|
|
22
|
-
/** Custom data passed through context */
|
|
23
|
-
customData?: Record<string, unknown>;
|
|
24
|
-
/** Callback when user interacts with a visualization (form submit, card action, etc.) */
|
|
25
|
-
onVisualizationAction?: (event: VisualizationActionEvent) => void;
|
|
26
|
-
}
|
|
27
|
-
declare const ChatContext: react.Context<ChatContextValue | null>;
|
|
28
|
-
interface ChatProviderProps {
|
|
29
|
-
children: ReactNode;
|
|
30
|
-
messages: ChatMessage[];
|
|
31
|
-
isStreaming?: boolean;
|
|
32
|
-
streamingMessageId?: string | null;
|
|
33
|
-
viewerRole?: ParticipantRole;
|
|
34
|
-
onSendMessage: (content: string, attachments?: File[]) => Promise<void>;
|
|
35
|
-
onStopStreaming?: () => void;
|
|
36
|
-
onRetryLastMessage?: () => Promise<void>;
|
|
37
|
-
customData?: Record<string, unknown>;
|
|
38
|
-
onVisualizationAction?: (event: VisualizationActionEvent) => void;
|
|
39
|
-
}
|
|
40
|
-
declare function ChatProvider({ children, messages, isStreaming, streamingMessageId, viewerRole, onSendMessage, onStopStreaming, onRetryLastMessage, customData, onVisualizationAction, }: ChatProviderProps): react_jsx_runtime.JSX.Element;
|
|
41
|
-
declare function useChatContext(): ChatContextValue;
|
|
42
|
-
|
|
43
|
-
export { ChatContext, type ChatContextValue, ChatProvider, type ChatProviderProps, useChatContext };
|
package/dist/hooks/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkZKMXEECD_cjs=require('../chunk-ZKMXEECD.cjs'),chunkHVCCZKEO_cjs=require('../chunk-HVCCZKEO.cjs'),chunkTOYU46SZ_cjs=require('../chunk-TOYU46SZ.cjs'),chunkKSMAVBLY_cjs=require('../chunk-KSMAVBLY.cjs');Object.defineProperty(exports,"useAttachments",{enumerable:true,get:function(){return chunkZKMXEECD_cjs.b}});Object.defineProperty(exports,"useStreaming",{enumerable:true,get:function(){return chunkZKMXEECD_cjs.a}});Object.defineProperty(exports,"useScrollLock",{enumerable:true,get:function(){return chunkHVCCZKEO_cjs.a}});Object.defineProperty(exports,"useAutoScroll",{enumerable:true,get:function(){return chunkTOYU46SZ_cjs.a}});Object.defineProperty(exports,"useMessageComposer",{enumerable:true,get:function(){return chunkTOYU46SZ_cjs.b}});Object.defineProperty(exports,"useBrandingCSSVars",{enumerable:true,get:function(){return chunkKSMAVBLY_cjs.b}});//# sourceMappingURL=index.cjs.map
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/hooks/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/hooks/index.d.cts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { RefObject, KeyboardEvent } from 'react';
|
|
3
|
-
import { b as StreamingOptions, a as StreamChunk } from '../streaming-CF63E6iS.cjs';
|
|
4
|
-
import { B as BrandingData } from '../branding-SzYU4ncD.cjs';
|
|
5
|
-
|
|
6
|
-
interface UseAutoScrollOptions {
|
|
7
|
-
/** Whether auto-scroll is enabled */
|
|
8
|
-
enabled?: boolean;
|
|
9
|
-
/** Smooth scroll behavior */
|
|
10
|
-
smooth?: boolean;
|
|
11
|
-
/** Scroll to bottom when component mounts */
|
|
12
|
-
scrollToBottomOnMount?: boolean;
|
|
13
|
-
}
|
|
14
|
-
interface UseAutoScrollReturn<T extends HTMLElement> {
|
|
15
|
-
/** Ref to attach to the scrollable container */
|
|
16
|
-
containerRef: React.RefObject<T | null>;
|
|
17
|
-
/** Scroll to bottom programmatically (always forces scroll) */
|
|
18
|
-
scrollToBottom: (behavior?: ScrollBehavior) => void;
|
|
19
|
-
/** Whether the viewport is currently at the bottom */
|
|
20
|
-
isAtBottom: boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Hook to automatically scroll to the bottom of a container
|
|
24
|
-
* when new content is added, unless the user has scrolled up.
|
|
25
|
-
*
|
|
26
|
-
* Combines ResizeObserver + MutationObserver to catch all height changes
|
|
27
|
-
* (image loads, panel expansion, streaming text, new messages).
|
|
28
|
-
*
|
|
29
|
-
* Uses a 1px tolerance for isAtBottom (matches assistant-ui) and
|
|
30
|
-
* persists scroll behavior across content resize to prevent
|
|
31
|
-
* the "content outraces scroll" bug.
|
|
32
|
-
*/
|
|
33
|
-
declare function useAutoScroll<T extends HTMLElement>({ enabled, smooth, scrollToBottomOnMount, }?: UseAutoScrollOptions): UseAutoScrollReturn<T>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Locks scroll position during collapsible/height animations.
|
|
37
|
-
*
|
|
38
|
-
* Prevents viewport jumps when content height changes during animations
|
|
39
|
-
* (e.g. ReasoningPanel expand/collapse). Finds the nearest scrollable
|
|
40
|
-
* ancestor and temporarily locks its scroll position for the animation duration.
|
|
41
|
-
*
|
|
42
|
-
* Adapted from assistant-ui's useScrollLock.
|
|
43
|
-
*
|
|
44
|
-
* @param animatedElementRef - Ref to the animated element
|
|
45
|
-
* @param animationDuration - Lock duration in milliseconds
|
|
46
|
-
* @returns Function to activate the scroll lock (call before toggling)
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```tsx
|
|
50
|
-
* const panelRef = useRef<HTMLDivElement>(null);
|
|
51
|
-
* const lockScroll = useScrollLock(panelRef, 200);
|
|
52
|
-
*
|
|
53
|
-
* const handleToggle = () => {
|
|
54
|
-
* lockScroll();
|
|
55
|
-
* setIsExpanded(!isExpanded);
|
|
56
|
-
* };
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
declare function useScrollLock<T extends HTMLElement = HTMLElement>(animatedElementRef: RefObject<T | null>, animationDuration: number): () => void;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Hook to manage streaming message state.
|
|
63
|
-
*/
|
|
64
|
-
declare function useStreaming(options?: StreamingOptions): {
|
|
65
|
-
startStreaming: (messageId: string) => void;
|
|
66
|
-
appendContent: (chunk: StreamChunk) => void;
|
|
67
|
-
stopStreaming: () => void;
|
|
68
|
-
handleError: (error: Error) => void;
|
|
69
|
-
abortSignal: AbortSignal | undefined;
|
|
70
|
-
isStreaming: boolean;
|
|
71
|
-
streamingMessageId: string | null;
|
|
72
|
-
streamedContent: string;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
interface UseMessageComposerOptions {
|
|
76
|
-
/** Callback when message is submitted */
|
|
77
|
-
onSubmit: (content: string, attachments?: File[]) => Promise<void>;
|
|
78
|
-
/** Whether submission is disabled */
|
|
79
|
-
disabled?: boolean;
|
|
80
|
-
/** Maximum file size in bytes */
|
|
81
|
-
maxFileSize?: number;
|
|
82
|
-
/** Allowed file types (MIME types) */
|
|
83
|
-
allowedFileTypes?: string[];
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Hook to manage message composer state and behavior.
|
|
87
|
-
*/
|
|
88
|
-
declare function useMessageComposer({ onSubmit, disabled, maxFileSize, // 10MB
|
|
89
|
-
allowedFileTypes, }: UseMessageComposerOptions): {
|
|
90
|
-
content: string;
|
|
91
|
-
attachments: File[];
|
|
92
|
-
isSubmitting: boolean;
|
|
93
|
-
error: string | null;
|
|
94
|
-
canSubmit: boolean | "";
|
|
95
|
-
inputRef: react.RefObject<HTMLTextAreaElement | null>;
|
|
96
|
-
handleContentChange: (value: string) => void;
|
|
97
|
-
handleAddAttachment: (files: FileList | File[]) => void;
|
|
98
|
-
handleRemoveAttachment: (index: number) => void;
|
|
99
|
-
handleSubmit: () => Promise<void>;
|
|
100
|
-
handleKeyDown: (e: KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
101
|
-
clear: () => void;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
interface AttachmentState {
|
|
105
|
-
file: File;
|
|
106
|
-
id: string;
|
|
107
|
-
progress: number;
|
|
108
|
-
status: "pending" | "uploading" | "complete" | "error";
|
|
109
|
-
error?: string;
|
|
110
|
-
url?: string;
|
|
111
|
-
}
|
|
112
|
-
interface UseAttachmentsOptions {
|
|
113
|
-
/** Maximum number of attachments */
|
|
114
|
-
maxCount?: number;
|
|
115
|
-
/** Maximum file size in bytes */
|
|
116
|
-
maxFileSize?: number;
|
|
117
|
-
/** Allowed MIME types */
|
|
118
|
-
allowedTypes?: string[];
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Hook to manage file attachments with upload progress.
|
|
122
|
-
*/
|
|
123
|
-
declare function useAttachments({ maxCount, maxFileSize, allowedTypes, }?: UseAttachmentsOptions): {
|
|
124
|
-
attachments: AttachmentState[];
|
|
125
|
-
addAttachment: (file: File) => {
|
|
126
|
-
success: boolean;
|
|
127
|
-
error?: string;
|
|
128
|
-
};
|
|
129
|
-
removeAttachment: (id: string) => void;
|
|
130
|
-
updateProgress: (id: string, progress: number) => void;
|
|
131
|
-
setError: (id: string, error: string) => void;
|
|
132
|
-
setUrl: (id: string, url: string) => void;
|
|
133
|
-
clear: () => void;
|
|
134
|
-
getFiles: () => File[];
|
|
135
|
-
canAddMore: boolean;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Converts BrandingData into CSS custom properties for chat-ui theming.
|
|
140
|
-
* Returns a CSSProperties object that can be spread onto a container element.
|
|
141
|
-
*/
|
|
142
|
-
declare function useBrandingCSSVars(branding: BrandingData | null | undefined, overrides?: {
|
|
143
|
-
iconColor?: string;
|
|
144
|
-
}): React.CSSProperties;
|
|
145
|
-
|
|
146
|
-
export { type UseAutoScrollOptions, type UseAutoScrollReturn, useAttachments, useAutoScroll, useBrandingCSSVars, useMessageComposer, useScrollLock, useStreaming };
|
package/dist/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkQGRXQAWZ_cjs=require('./chunk-QGRXQAWZ.cjs'),chunk3SEVU272_cjs=require('./chunk-3SEVU272.cjs'),chunkZKMXEECD_cjs=require('./chunk-ZKMXEECD.cjs'),chunkHVCCZKEO_cjs=require('./chunk-HVCCZKEO.cjs'),chunkTOYU46SZ_cjs=require('./chunk-TOYU46SZ.cjs'),chunkSFEPMZCU_cjs=require('./chunk-SFEPMZCU.cjs'),chunkKSMAVBLY_cjs=require('./chunk-KSMAVBLY.cjs');var i={hour:"numeric",minute:"2-digit",hour12:true},m={month:"short",day:"numeric"},te={...m,year:"numeric",...i};function c(t){let e=typeof t=="string"?new Date(t):t,a=new Date;return e.getDate()===a.getDate()&&e.getMonth()===a.getMonth()&&e.getFullYear()===a.getFullYear()?e.toLocaleTimeString("en-US",i):e.getFullYear()===a.getFullYear()?`${e.toLocaleDateString("en-US",m)}, ${e.toLocaleTimeString("en-US",i)}`:e.toLocaleDateString("en-US",te)}function ae(t){let e=typeof t=="string"?new Date(t):t,g=new Date().getTime()-e.getTime(),s=Math.floor(g/1e3),r=Math.floor(s/60),o=Math.floor(r/60),n=Math.floor(o/24);return s<60?"just now":r<60?`${r} minute${r===1?"":"s"} ago`:o<24?`${o} hour${o===1?"":"s"} ago`:n<7?`${n} day${n===1?"":"s"} ago`:c(e)}var re={spacing:{messageBetween:"1rem",messagePx:"0.875rem",messagePy:"0.625rem",container:"1rem",composerPadding:"1rem"},typography:{message:{fontSize:"1rem",lineHeight:1.5,letterSpacing:"0px"},caption:{fontSize:"0.875rem",lineHeight:1.4},small:{fontSize:"0.8125rem",lineHeight:1.3}},borderRadius:{message:"0.5rem",input:"1rem",panel:"0.5rem",button:"0.5rem",chip:"0.25rem"},colors:{primary:"var(--chat-primary, #106997)",secondary:"var(--chat-secondary, #56C18A)",error:"var(--chat-error, #B1001B)",warning:"var(--chat-warning, #DD9652)",messageBg:"var(--chat-message-bg, rgba(0, 0, 0, 0.03))",userMessageBg:"var(--chat-user-message-bg, var(--chat-primary, #106997))",userMessageText:"var(--chat-user-message-text, #ffffff)",panelBg:"var(--chat-panel-bg, rgba(0, 0, 0, 0.02))",panelBorder:"var(--chat-panel-border, rgba(0, 0, 0, 0.06))",border:"var(--chat-border, rgba(0, 0, 0, 0.06))",borderHover:"var(--chat-border-hover, rgba(0, 0, 0, 0.12))",text:"var(--chat-text, #1D2033)",subtle:"var(--chat-text-subtle, rgba(0, 0, 0, 0.5))",placeholder:"var(--chat-placeholder, rgba(0, 0, 0, 0.4))",status:{pending:{main:"rgba(0, 0, 0, 0.3)",bg:"rgba(0, 0, 0, 0.05)"},running:{main:"rgb(99, 102, 241)",bg:"rgba(99, 102, 241, 0.08)"},completed:{main:"rgb(16, 185, 129)",bg:"rgba(16, 185, 129, 0.08)"},failed:{main:"rgb(239, 68, 68)",bg:"rgba(239, 68, 68, 0.08)"}}},shadows:{subtle:"0 1px 2px rgba(0, 0, 0, 0.04)",input:"0 2px 8px rgba(0, 0, 0, 0.08)",inputFocus:"0 4px 16px rgba(0, 0, 0, 0.12)",button:"0 1px 3px rgba(0, 0, 0, 0.08)",buttonHover:"0 2px 6px rgba(0, 0, 0, 0.12)",primary:"0 2px 6px rgba(16, 105, 151, 0.3)",primaryHover:"0 4px 12px rgba(16, 105, 151, 0.4)"},animations:{messageEntrance:{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3,ease:[.4,0,.2,1]}},fadeIn:{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2}}}};Object.defineProperty(exports,"AttachmentPreview",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.b}});Object.defineProperty(exports,"Avatar",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.c}});Object.defineProperty(exports,"ChatContainer",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.d}});Object.defineProperty(exports,"ChatLayout",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.$}});Object.defineProperty(exports,"MarkdownContent",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.f}});Object.defineProperty(exports,"Message",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.T}});Object.defineProperty(exports,"MessageActionBar",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.k}});Object.defineProperty(exports,"MessageComposer",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.U}});Object.defineProperty(exports,"MessageList",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.W}});Object.defineProperty(exports,"ScrollToBottomButton",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.V}});Object.defineProperty(exports,"StreamingText",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.B}});Object.defineProperty(exports,"SuggestedActions",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.C}});Object.defineProperty(exports,"ToolStatusIndicator",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs._}});Object.defineProperty(exports,"TypingIndicator",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.Y}});Object.defineProperty(exports,"WelcomeScreen",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.aa}});Object.defineProperty(exports,"cn",{enumerable:true,get:function(){return chunkQGRXQAWZ_cjs.a}});Object.defineProperty(exports,"ActionButton",{enumerable:true,get:function(){return chunk3SEVU272_cjs.q}});Object.defineProperty(exports,"AvatarPrimitive",{enumerable:true,get:function(){return chunk3SEVU272_cjs.l}});Object.defineProperty(exports,"ComposerContext",{enumerable:true,get:function(){return chunk3SEVU272_cjs.g}});Object.defineProperty(exports,"ComposerInput",{enumerable:true,get:function(){return chunk3SEVU272_cjs.j}});Object.defineProperty(exports,"ComposerSubmit",{enumerable:true,get:function(){return chunk3SEVU272_cjs.k}});Object.defineProperty(exports,"MessageComposerPrimitive",{enumerable:true,get:function(){return chunk3SEVU272_cjs.i}});Object.defineProperty(exports,"MessageContentPrimitive",{enumerable:true,get:function(){return chunk3SEVU272_cjs.d}});Object.defineProperty(exports,"MessageContext",{enumerable:true,get:function(){return chunk3SEVU272_cjs.a}});Object.defineProperty(exports,"MessageListPrimitive",{enumerable:true,get:function(){return chunk3SEVU272_cjs.f}});Object.defineProperty(exports,"MessagePrimitive",{enumerable:true,get:function(){return chunk3SEVU272_cjs.c}});Object.defineProperty(exports,"MessageTimestampPrimitive",{enumerable:true,get:function(){return chunk3SEVU272_cjs.e}});Object.defineProperty(exports,"StreamingTextPrimitive",{enumerable:true,get:function(){return chunk3SEVU272_cjs.m}});Object.defineProperty(exports,"SuggestedActionsContext",{enumerable:true,get:function(){return chunk3SEVU272_cjs.n}});Object.defineProperty(exports,"SuggestedActionsPrimitive",{enumerable:true,get:function(){return chunk3SEVU272_cjs.p}});Object.defineProperty(exports,"TypingIndicatorPrimitive",{enumerable:true,get:function(){return chunk3SEVU272_cjs.r}});Object.defineProperty(exports,"useComposer",{enumerable:true,get:function(){return chunk3SEVU272_cjs.h}});Object.defineProperty(exports,"useMessage",{enumerable:true,get:function(){return chunk3SEVU272_cjs.b}});Object.defineProperty(exports,"useSuggestedActions",{enumerable:true,get:function(){return chunk3SEVU272_cjs.o}});Object.defineProperty(exports,"useAttachments",{enumerable:true,get:function(){return chunkZKMXEECD_cjs.b}});Object.defineProperty(exports,"useStreaming",{enumerable:true,get:function(){return chunkZKMXEECD_cjs.a}});Object.defineProperty(exports,"useScrollLock",{enumerable:true,get:function(){return chunkHVCCZKEO_cjs.a}});Object.defineProperty(exports,"useAutoScroll",{enumerable:true,get:function(){return chunkTOYU46SZ_cjs.a}});Object.defineProperty(exports,"useMessageComposer",{enumerable:true,get:function(){return chunkTOYU46SZ_cjs.b}});Object.defineProperty(exports,"ChatContext",{enumerable:true,get:function(){return chunkSFEPMZCU_cjs.a}});Object.defineProperty(exports,"ChatProvider",{enumerable:true,get:function(){return chunkSFEPMZCU_cjs.b}});Object.defineProperty(exports,"useChatContext",{enumerable:true,get:function(){return chunkSFEPMZCU_cjs.c}});Object.defineProperty(exports,"getContrastTextColor",{enumerable:true,get:function(){return chunkKSMAVBLY_cjs.a}});Object.defineProperty(exports,"useBrandingCSSVars",{enumerable:true,get:function(){return chunkKSMAVBLY_cjs.b}});exports.chatTokens=re;exports.formatMessageTime=c;exports.formatRelativeTime=ae;//# sourceMappingURL=index.cjs.map
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/format-date.ts","../src/styles/tokens.ts"],"names":["TIME_FORMAT","DATE_FORMAT","FULL_FORMAT","formatMessageTime","date","d","now","formatRelativeTime","diffMs","diffSeconds","diffMinutes","diffHours","diffDays","chatTokens"],"mappings":"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","file":"index.cjs","sourcesContent":["/**\n * Format a date for display in chat messages.\n */\n\nconst TIME_FORMAT: Intl.DateTimeFormatOptions = {\n hour: \"numeric\",\n minute: \"2-digit\",\n hour12: true,\n};\n\nconst DATE_FORMAT: Intl.DateTimeFormatOptions = {\n month: \"short\",\n day: \"numeric\",\n};\n\nconst FULL_FORMAT: Intl.DateTimeFormatOptions = {\n ...DATE_FORMAT,\n year: \"numeric\",\n ...TIME_FORMAT,\n};\n\n/**\n * Format a timestamp for display.\n * - Today: \"2:30 PM\"\n * - This year: \"Dec 15, 2:30 PM\"\n * - Other years: \"Dec 15, 2024, 2:30 PM\"\n */\nexport function formatMessageTime(date: Date | string): string {\n const d = typeof date === \"string\" ? new Date(date) : date;\n const now = new Date();\n\n const isToday =\n d.getDate() === now.getDate() &&\n d.getMonth() === now.getMonth() &&\n d.getFullYear() === now.getFullYear();\n\n if (isToday) {\n return d.toLocaleTimeString(\"en-US\", TIME_FORMAT);\n }\n\n const isThisYear = d.getFullYear() === now.getFullYear();\n\n if (isThisYear) {\n return `${d.toLocaleDateString(\"en-US\", DATE_FORMAT)}, ${d.toLocaleTimeString(\"en-US\", TIME_FORMAT)}`;\n }\n\n return d.toLocaleDateString(\"en-US\", FULL_FORMAT);\n}\n\n/**\n * Format a relative time (e.g., \"2 minutes ago\").\n */\nexport function formatRelativeTime(date: Date | string): string {\n const d = typeof date === \"string\" ? new Date(date) : date;\n const now = new Date();\n const diffMs = now.getTime() - d.getTime();\n const diffSeconds = Math.floor(diffMs / 1000);\n const diffMinutes = Math.floor(diffSeconds / 60);\n const diffHours = Math.floor(diffMinutes / 60);\n const diffDays = Math.floor(diffHours / 24);\n\n if (diffSeconds < 60) {\n return \"just now\";\n }\n\n if (diffMinutes < 60) {\n return `${diffMinutes} minute${diffMinutes === 1 ? \"\" : \"s\"} ago`;\n }\n\n if (diffHours < 24) {\n return `${diffHours} hour${diffHours === 1 ? \"\" : \"s\"} ago`;\n }\n\n if (diffDays < 7) {\n return `${diffDays} day${diffDays === 1 ? \"\" : \"s\"} ago`;\n }\n\n return formatMessageTime(d);\n}\n","/**\n * Design tokens for the chat UI.\n * These map to CSS custom properties for easy theming.\n */\n\nexport const chatTokens = {\n spacing: {\n /** Vertical spacing between messages (16px) */\n messageBetween: \"1rem\",\n /** Message bubble horizontal padding (14px) */\n messagePx: \"0.875rem\",\n /** Message bubble vertical padding (10px) */\n messagePy: \"0.625rem\",\n /** Container padding (16px) */\n container: \"1rem\",\n /** Composer padding (16px) */\n composerPadding: \"1rem\",\n },\n\n typography: {\n message: {\n fontSize: \"1rem\",\n lineHeight: 1.5,\n letterSpacing: \"0px\",\n },\n caption: {\n fontSize: \"0.875rem\",\n lineHeight: 1.4,\n },\n small: {\n fontSize: \"0.8125rem\",\n lineHeight: 1.3,\n },\n },\n\n borderRadius: {\n message: \"0.5rem\",\n input: \"1rem\",\n panel: \"0.5rem\",\n button: \"0.5rem\",\n chip: \"0.25rem\",\n },\n\n colors: {\n // CSS custom property references\n primary: \"var(--chat-primary, #106997)\",\n secondary: \"var(--chat-secondary, #56C18A)\",\n error: \"var(--chat-error, #B1001B)\",\n warning: \"var(--chat-warning, #DD9652)\",\n\n // Message backgrounds\n messageBg: \"var(--chat-message-bg, rgba(0, 0, 0, 0.03))\",\n userMessageBg: \"var(--chat-user-message-bg, var(--chat-primary, #106997))\",\n userMessageText: \"var(--chat-user-message-text, #ffffff)\",\n\n // Panel backgrounds\n panelBg: \"var(--chat-panel-bg, rgba(0, 0, 0, 0.02))\",\n panelBorder: \"var(--chat-panel-border, rgba(0, 0, 0, 0.06))\",\n\n // Borders\n border: \"var(--chat-border, rgba(0, 0, 0, 0.06))\",\n borderHover: \"var(--chat-border-hover, rgba(0, 0, 0, 0.12))\",\n\n // Text\n text: \"var(--chat-text, #1D2033)\",\n subtle: \"var(--chat-text-subtle, rgba(0, 0, 0, 0.5))\",\n placeholder: \"var(--chat-placeholder, rgba(0, 0, 0, 0.4))\",\n\n // Status colors\n status: {\n pending: {\n main: \"rgba(0, 0, 0, 0.3)\",\n bg: \"rgba(0, 0, 0, 0.05)\",\n },\n running: {\n main: \"rgb(99, 102, 241)\",\n bg: \"rgba(99, 102, 241, 0.08)\",\n },\n completed: {\n main: \"rgb(16, 185, 129)\",\n bg: \"rgba(16, 185, 129, 0.08)\",\n },\n failed: {\n main: \"rgb(239, 68, 68)\",\n bg: \"rgba(239, 68, 68, 0.08)\",\n },\n },\n },\n\n shadows: {\n subtle: \"0 1px 2px rgba(0, 0, 0, 0.04)\",\n input: \"0 2px 8px rgba(0, 0, 0, 0.08)\",\n inputFocus: \"0 4px 16px rgba(0, 0, 0, 0.12)\",\n button: \"0 1px 3px rgba(0, 0, 0, 0.08)\",\n buttonHover: \"0 2px 6px rgba(0, 0, 0, 0.12)\",\n primary: \"0 2px 6px rgba(16, 105, 151, 0.3)\",\n primaryHover: \"0 4px 12px rgba(16, 105, 151, 0.4)\",\n },\n\n animations: {\n messageEntrance: {\n initial: { opacity: 0, y: 8 },\n animate: { opacity: 1, y: 0 },\n transition: { duration: 0.3, ease: [0.4, 0, 0.2, 1] },\n },\n fadeIn: {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n transition: { duration: 0.2 },\n },\n },\n} as const;\n\nexport type ChatTokens = typeof chatTokens;\n"]}
|
package/dist/index.d.cts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
export { A as Attachment, C as ChatMessage, M as MessageData, a as MessageError, b as Participant, P as ParticipantRole, R as ReasoningChunk, S as SourceReference, c as SourceTypeConfig, d as SuggestedAction, e as SuggestedActionType } from './message-9z0crkf9.cjs';
|
|
2
|
-
export { a as StreamChunk, b as StreamingOptions, c as StreamingState } from './streaming-CF63E6iS.cjs';
|
|
3
|
-
export { B as BrandingData } from './branding-SzYU4ncD.cjs';
|
|
4
|
-
export { ChatContext, ChatContextValue, ChatProvider, ChatProviderProps, useChatContext } from './context/index.cjs';
|
|
5
|
-
export { useAttachments, useAutoScroll, useBrandingCSSVars, useMessageComposer, useScrollLock, useStreaming } from './hooks/index.cjs';
|
|
6
|
-
export { A as AvatarPrimitive, C as ComposerContext, a as ComposerInput, b as ComposerSubmit, M as MessageComposerPrimitive, c as MessageContentPrimitive, d as MessageContext, e as MessagePrimitive, f as MessageTimestampPrimitive, u as useComposer, g as useMessage } from './avatar-CL1hlGO5.cjs';
|
|
7
|
-
export { ActionButton, MessageList as MessageListPrimitive, StreamingText as StreamingTextPrimitive, SuggestedActionsContext, SuggestedActions as SuggestedActionsPrimitive, TypingIndicator as TypingIndicatorPrimitive, useSuggestedActions } from './primitives/index.cjs';
|
|
8
|
-
export { A as AttachmentPreview, a as Avatar, C as ChatContainer, b as ChatLayout, M as MarkdownContent, c as Message, d as MessageActionBar, e as MessageComposer, f as MessageList, S as ScrollToBottomButton, g as StreamingText, h as SuggestedActions, T as ToolStatusIndicator, i as TypingIndicator, W as WelcomeScreen } from './WelcomeScreen-BiY3uGhp.cjs';
|
|
9
|
-
import { ClassValue } from 'clsx';
|
|
10
|
-
import 'react/jsx-runtime';
|
|
11
|
-
import 'react';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Utility function to merge Tailwind CSS classes with proper precedence.
|
|
15
|
-
* Combines clsx for conditional classes with tailwind-merge for conflict resolution.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* cn("px-4 py-2", "px-6") // => "py-2 px-6"
|
|
19
|
-
* cn("text-red-500", isActive && "text-blue-500") // => "text-blue-500" when isActive
|
|
20
|
-
*/
|
|
21
|
-
declare function cn(...inputs: ClassValue[]): string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Format a date for display in chat messages.
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Format a timestamp for display.
|
|
28
|
-
* - Today: "2:30 PM"
|
|
29
|
-
* - This year: "Dec 15, 2:30 PM"
|
|
30
|
-
* - Other years: "Dec 15, 2024, 2:30 PM"
|
|
31
|
-
*/
|
|
32
|
-
declare function formatMessageTime(date: Date | string): string;
|
|
33
|
-
/**
|
|
34
|
-
* Format a relative time (e.g., "2 minutes ago").
|
|
35
|
-
*/
|
|
36
|
-
declare function formatRelativeTime(date: Date | string): string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Given a background color string, return the best contrast text color.
|
|
40
|
-
* Returns "#ffffff" for dark backgrounds and "#1D2033" for light backgrounds.
|
|
41
|
-
* Falls back to "#ffffff" if the color cannot be parsed.
|
|
42
|
-
*/
|
|
43
|
-
declare function getContrastTextColor(bgColor: string): string;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Design tokens for the chat UI.
|
|
47
|
-
* These map to CSS custom properties for easy theming.
|
|
48
|
-
*/
|
|
49
|
-
declare const chatTokens: {
|
|
50
|
-
readonly spacing: {
|
|
51
|
-
/** Vertical spacing between messages (16px) */
|
|
52
|
-
readonly messageBetween: "1rem";
|
|
53
|
-
/** Message bubble horizontal padding (14px) */
|
|
54
|
-
readonly messagePx: "0.875rem";
|
|
55
|
-
/** Message bubble vertical padding (10px) */
|
|
56
|
-
readonly messagePy: "0.625rem";
|
|
57
|
-
/** Container padding (16px) */
|
|
58
|
-
readonly container: "1rem";
|
|
59
|
-
/** Composer padding (16px) */
|
|
60
|
-
readonly composerPadding: "1rem";
|
|
61
|
-
};
|
|
62
|
-
readonly typography: {
|
|
63
|
-
readonly message: {
|
|
64
|
-
readonly fontSize: "1rem";
|
|
65
|
-
readonly lineHeight: 1.5;
|
|
66
|
-
readonly letterSpacing: "0px";
|
|
67
|
-
};
|
|
68
|
-
readonly caption: {
|
|
69
|
-
readonly fontSize: "0.875rem";
|
|
70
|
-
readonly lineHeight: 1.4;
|
|
71
|
-
};
|
|
72
|
-
readonly small: {
|
|
73
|
-
readonly fontSize: "0.8125rem";
|
|
74
|
-
readonly lineHeight: 1.3;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
readonly borderRadius: {
|
|
78
|
-
readonly message: "0.5rem";
|
|
79
|
-
readonly input: "1rem";
|
|
80
|
-
readonly panel: "0.5rem";
|
|
81
|
-
readonly button: "0.5rem";
|
|
82
|
-
readonly chip: "0.25rem";
|
|
83
|
-
};
|
|
84
|
-
readonly colors: {
|
|
85
|
-
readonly primary: "var(--chat-primary, #106997)";
|
|
86
|
-
readonly secondary: "var(--chat-secondary, #56C18A)";
|
|
87
|
-
readonly error: "var(--chat-error, #B1001B)";
|
|
88
|
-
readonly warning: "var(--chat-warning, #DD9652)";
|
|
89
|
-
readonly messageBg: "var(--chat-message-bg, rgba(0, 0, 0, 0.03))";
|
|
90
|
-
readonly userMessageBg: "var(--chat-user-message-bg, var(--chat-primary, #106997))";
|
|
91
|
-
readonly userMessageText: "var(--chat-user-message-text, #ffffff)";
|
|
92
|
-
readonly panelBg: "var(--chat-panel-bg, rgba(0, 0, 0, 0.02))";
|
|
93
|
-
readonly panelBorder: "var(--chat-panel-border, rgba(0, 0, 0, 0.06))";
|
|
94
|
-
readonly border: "var(--chat-border, rgba(0, 0, 0, 0.06))";
|
|
95
|
-
readonly borderHover: "var(--chat-border-hover, rgba(0, 0, 0, 0.12))";
|
|
96
|
-
readonly text: "var(--chat-text, #1D2033)";
|
|
97
|
-
readonly subtle: "var(--chat-text-subtle, rgba(0, 0, 0, 0.5))";
|
|
98
|
-
readonly placeholder: "var(--chat-placeholder, rgba(0, 0, 0, 0.4))";
|
|
99
|
-
readonly status: {
|
|
100
|
-
readonly pending: {
|
|
101
|
-
readonly main: "rgba(0, 0, 0, 0.3)";
|
|
102
|
-
readonly bg: "rgba(0, 0, 0, 0.05)";
|
|
103
|
-
};
|
|
104
|
-
readonly running: {
|
|
105
|
-
readonly main: "rgb(99, 102, 241)";
|
|
106
|
-
readonly bg: "rgba(99, 102, 241, 0.08)";
|
|
107
|
-
};
|
|
108
|
-
readonly completed: {
|
|
109
|
-
readonly main: "rgb(16, 185, 129)";
|
|
110
|
-
readonly bg: "rgba(16, 185, 129, 0.08)";
|
|
111
|
-
};
|
|
112
|
-
readonly failed: {
|
|
113
|
-
readonly main: "rgb(239, 68, 68)";
|
|
114
|
-
readonly bg: "rgba(239, 68, 68, 0.08)";
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
readonly shadows: {
|
|
119
|
-
readonly subtle: "0 1px 2px rgba(0, 0, 0, 0.04)";
|
|
120
|
-
readonly input: "0 2px 8px rgba(0, 0, 0, 0.08)";
|
|
121
|
-
readonly inputFocus: "0 4px 16px rgba(0, 0, 0, 0.12)";
|
|
122
|
-
readonly button: "0 1px 3px rgba(0, 0, 0, 0.08)";
|
|
123
|
-
readonly buttonHover: "0 2px 6px rgba(0, 0, 0, 0.12)";
|
|
124
|
-
readonly primary: "0 2px 6px rgba(16, 105, 151, 0.3)";
|
|
125
|
-
readonly primaryHover: "0 4px 12px rgba(16, 105, 151, 0.4)";
|
|
126
|
-
};
|
|
127
|
-
readonly animations: {
|
|
128
|
-
readonly messageEntrance: {
|
|
129
|
-
readonly initial: {
|
|
130
|
-
readonly opacity: 0;
|
|
131
|
-
readonly y: 8;
|
|
132
|
-
};
|
|
133
|
-
readonly animate: {
|
|
134
|
-
readonly opacity: 1;
|
|
135
|
-
readonly y: 0;
|
|
136
|
-
};
|
|
137
|
-
readonly transition: {
|
|
138
|
-
readonly duration: 0.3;
|
|
139
|
-
readonly ease: readonly [0.4, 0, 0.2, 1];
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
readonly fadeIn: {
|
|
143
|
-
readonly initial: {
|
|
144
|
-
readonly opacity: 0;
|
|
145
|
-
};
|
|
146
|
-
readonly animate: {
|
|
147
|
-
readonly opacity: 1;
|
|
148
|
-
};
|
|
149
|
-
readonly transition: {
|
|
150
|
-
readonly duration: 0.2;
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
type ChatTokens = typeof chatTokens;
|
|
156
|
-
|
|
157
|
-
export { type ChatTokens, chatTokens, cn, formatMessageTime, formatRelativeTime, getContrastTextColor };
|