@tenancy.nz/chat-ui 0.1.63 → 0.1.65

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.
@@ -1,9 +1,12 @@
1
+ import { default as AiAvatarSrc } from './assets/ai-avatar.png';
1
2
  import { default as ChatInlineStyles } from './styles.css?inline';
2
3
  import { default as default_2 } from 'react';
3
4
  import { JSX as JSX_2 } from 'react/jsx-runtime';
4
5
  import { ReactNode } from 'react';
5
6
 
6
- export declare function Chat({ user, generateToken, clientId, apiBase, docsBase, hideConversations, agentName, agentAvatarSrc, agentRole, tagline, description, initialConversationId, onConversationChange, }: {
7
+ export { AiAvatarSrc }
8
+
9
+ export declare function Chat({ user, generateToken, clientId, apiBase, docsBase, hideConversations, agentName, agentAvatarSrc, agentRole, tagline, description, initialConversationId, onConversationChange, onApiReady, }: {
7
10
  apiBase: string;
8
11
  docsBase?: string;
9
12
  user?: ChatUser;
@@ -17,10 +20,77 @@ export declare function Chat({ user, generateToken, clientId, apiBase, docsBase,
17
20
  description?: string;
18
21
  initialConversationId?: string;
19
22
  onConversationChange?: (id: string | null) => void;
23
+ onApiReady?: (api: ChatApi) => void;
20
24
  }): JSX_2.Element;
21
25
 
26
+ export declare type ChatApi = {
27
+ sendMessage: (text: string) => Promise<void>;
28
+ setInput: (text: string) => void;
29
+ startNewConversation: () => void;
30
+ getCurrentConversationId: () => string | null;
31
+ };
32
+
33
+ export declare type ChatConversationSession = {
34
+ conversationId: string | undefined;
35
+ onConversationChange: (id: string | null) => void;
36
+ startNewChat: () => void;
37
+ /**
38
+ * Key to pass as the `key` prop on `<Chat>` when starting a new chat —
39
+ * remounts Chat so it picks up the cleared conversation state.
40
+ */
41
+ resetKey: number;
42
+ };
43
+
44
+ export declare function ChatHeader({ name, role, avatarSrc, showOnlineDot, leftActions, rightActions, onClick, }: ChatHeaderProps): JSX_2.Element;
45
+
46
+ export declare type ChatHeaderProps = {
47
+ name: string;
48
+ role?: string;
49
+ avatarSrc?: string;
50
+ showOnlineDot?: boolean;
51
+ leftActions?: ReactNode;
52
+ rightActions?: ReactNode;
53
+ onClick?: () => void;
54
+ };
55
+
22
56
  export { ChatInlineStyles }
23
57
 
58
+ /**
59
+ * Standalone full-page wrapper that re-applies the chrome (border, radius,
60
+ * shadow, viewport-relative height) Chat used to render itself. Wrap a Chat
61
+ * in this when mounting it as the main content of a page.
62
+ */
63
+ export declare function ChatPage({ children, className, style }: ChatPageProps): JSX_2.Element;
64
+
65
+ export declare type ChatPageProps = {
66
+ children: ReactNode;
67
+ className?: string;
68
+ style?: default_2.CSSProperties;
69
+ };
70
+
71
+ /**
72
+ * Chat panel layout primitive.
73
+ *
74
+ * - `position`: 'relative' (in flex layout, can push siblings) or 'fixed' (overlay).
75
+ * - `resizable`: shows a drag handle on the inner edge that calls onWidthChange.
76
+ * - `width`: controlled width (number = px, string = any css width).
77
+ * - The panel does not own open/close state — render conditionally from parent.
78
+ */
79
+ export declare function ChatPanel({ children, position, resizable, width, onWidthChange, minWidth, maxWidth, anchor, className, style, }: ChatPanelProps): JSX_2.Element;
80
+
81
+ export declare type ChatPanelProps = {
82
+ children: ReactNode;
83
+ position?: 'relative' | 'fixed';
84
+ resizable?: boolean;
85
+ width: number | string;
86
+ onWidthChange?: (width: number) => void;
87
+ minWidth?: number;
88
+ maxWidth?: number;
89
+ anchor?: 'right';
90
+ className?: string;
91
+ style?: default_2.CSSProperties;
92
+ };
93
+
24
94
  export declare type ChatUser = {
25
95
  accessToken?: string;
26
96
  name?: string;
@@ -30,32 +100,17 @@ export declare type ChatUser = {
30
100
 
31
101
  export declare const PortalTargetProvider: default_2.Provider<Element | null>;
32
102
 
33
- export declare function Widget({ name, role, avatarSrc, sessionKey, children, }: WidgetProps): JSX_2.Element;
34
-
35
- export declare function WidgetChat({ name, role, avatarSrc, tagline, description, initialPrompt, sessionKey, apiBase, docsBase, clientId, generateToken, user, }: WidgetChatProps): JSX_2.Element;
36
-
37
- export declare type WidgetChatProps = {
38
- name: string;
39
- role: string;
40
- avatarSrc?: string;
41
- tagline?: string;
42
- description?: string;
43
- initialPrompt?: string;
44
- sessionKey?: string;
45
- apiBase: string;
46
- docsBase?: string;
47
- clientId?: string;
48
- generateToken?: () => Promise<string> | string;
49
- user?: ChatUser;
50
- };
51
-
52
- export declare type WidgetProps = {
53
- name: string;
54
- role: string;
55
- avatarSrc?: string;
56
- initialPrompt?: string;
57
- sessionKey?: string;
58
- children: ReactNode;
59
- };
103
+ /**
104
+ * Persistent single-conversation session for embedded chat usage.
105
+ *
106
+ * - Reads/writes sessionStorage under `widget-conv-${sessionKey}`.
107
+ * - `conversationId` is the persisted convo id (undefined if none). Pass to
108
+ * `<Chat initialConversationId={conversationId} />`.
109
+ * - `onConversationChange` should be passed to `<Chat onConversationChange>`
110
+ * so newly-created conversations get persisted automatically.
111
+ * - `startNewChat()` clears the persisted conversation and bumps `resetKey`.
112
+ * Pass `resetKey` as the React key on `<Chat>` so it remounts cleanly.
113
+ */
114
+ export declare function useChatConversationSession(sessionKey: string): ChatConversationSession;
60
115
 
61
116
  export { }