@melony/react 0.1.14 → 0.1.16

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/index.d.cts CHANGED
@@ -5,10 +5,15 @@ import { Role, Event, UINode } from 'melony';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
7
7
  interface User {
8
- id: string;
8
+ id?: string;
9
+ uid: string;
9
10
  email: string;
10
- name: string;
11
+ name?: string;
12
+ displayName?: string;
11
13
  picture?: string;
14
+ createdAt?: string;
15
+ lastSignIn?: string | null;
16
+ emailVerified?: boolean;
12
17
  }
13
18
  interface Message {
14
19
  role: Role;
@@ -26,6 +31,17 @@ interface StarterPrompt {
26
31
  prompt: string;
27
32
  icon?: React.ReactNode;
28
33
  }
34
+ interface ComposerOption {
35
+ id: string;
36
+ label: string;
37
+ value: any;
38
+ }
39
+ interface ComposerOptionGroup {
40
+ id: string;
41
+ label: string;
42
+ options: ComposerOption[];
43
+ type?: "single" | "multiple";
44
+ }
29
45
  interface AuthService {
30
46
  getMe: () => Promise<User | null>;
31
47
  login: () => void;
@@ -116,18 +132,24 @@ interface ThreadProps {
116
132
  placeholder?: string;
117
133
  starterPrompts?: StarterPrompt[];
118
134
  onStarterPromptClick?: (prompt: string) => void;
135
+ options?: ComposerOptionGroup[];
136
+ autoFocus?: boolean;
137
+ defaultSelectedIds?: string[];
119
138
  }
120
- declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, }: ThreadProps): react_jsx_runtime.JSX.Element;
139
+ declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, options, autoFocus, defaultSelectedIds, }: ThreadProps): react_jsx_runtime.JSX.Element;
121
140
 
122
141
  interface ComposerProps {
123
142
  value: string;
124
143
  onChange: (value: string) => void;
125
- onSubmit: (e?: React__default.FormEvent) => void;
144
+ onSubmit: (state?: Record<string, any>) => void;
126
145
  placeholder?: string;
127
146
  isLoading?: boolean;
128
147
  className?: string;
148
+ options?: ComposerOptionGroup[];
149
+ autoFocus?: boolean;
150
+ defaultSelectedIds?: string[];
129
151
  }
130
- declare function Composer({ value, onChange, onSubmit, placeholder, isLoading, className, }: ComposerProps): react_jsx_runtime.JSX.Element;
152
+ declare function Composer({ value, onChange, onSubmit, placeholder, isLoading, className, options, autoFocus, defaultSelectedIds, }: ComposerProps): react_jsx_runtime.JSX.Element;
131
153
 
132
154
  interface ChatHeaderProps {
133
155
  /**
@@ -165,31 +187,42 @@ interface ChatPopupProps {
165
187
  title?: string;
166
188
  placeholder?: string;
167
189
  starterPrompts?: StarterPrompt[];
190
+ options?: ComposerOptionGroup[];
168
191
  defaultOpen?: boolean;
169
192
  /**
170
193
  * Props for customizing the header. Note: leftContent and rightContent in headerProps
171
194
  * will be merged with the default popup header actions (back, history, new chat, close).
172
195
  */
173
196
  headerProps?: Omit<ChatHeaderProps, "title" | "leftContent" | "rightContent">;
197
+ /**
198
+ * IDs of options to be selected by default
199
+ */
200
+ defaultSelectedIds?: string[];
174
201
  }
175
- declare function ChatPopup({ title, placeholder, starterPrompts, defaultOpen, headerProps, }: ChatPopupProps): react_jsx_runtime.JSX.Element;
202
+ declare function ChatPopup({ title, placeholder, starterPrompts, options, defaultOpen, headerProps, defaultSelectedIds, }: ChatPopupProps): react_jsx_runtime.JSX.Element;
176
203
 
177
204
  interface ChatSidebarProps {
178
205
  title?: string;
179
206
  placeholder?: string;
180
207
  starterPrompts?: StarterPrompt[];
208
+ options?: ComposerOptionGroup[];
181
209
  className?: string;
182
210
  /**
183
211
  * Props for customizing the header. If provided, title prop will be passed to header.
184
212
  */
185
213
  headerProps?: Omit<ChatHeaderProps, "title">;
214
+ /**
215
+ * IDs of options to be selected by default
216
+ */
217
+ defaultSelectedIds?: string[];
186
218
  }
187
- declare function ChatSidebar({ title, placeholder, starterPrompts, className, headerProps, }: ChatSidebarProps): react_jsx_runtime.JSX.Element;
219
+ declare function ChatSidebar({ title, placeholder, starterPrompts, options, className, headerProps, defaultSelectedIds, }: ChatSidebarProps): react_jsx_runtime.JSX.Element;
188
220
 
189
221
  interface ChatFullProps {
190
222
  title?: string;
191
223
  placeholder?: string;
192
224
  starterPrompts?: StarterPrompt[];
225
+ options?: ComposerOptionGroup[];
193
226
  className?: string;
194
227
  /**
195
228
  * Props for customizing the header. If provided, title prop will be passed to header.
@@ -243,8 +276,16 @@ interface ChatFullProps {
243
276
  * Callback when right sidebar collapse state changes
244
277
  */
245
278
  onRightSidebarCollapseChange?: (collapsed: boolean) => void;
279
+ /**
280
+ * Whether the composer should be auto focused
281
+ */
282
+ autoFocus?: boolean;
283
+ /**
284
+ * IDs of options to be selected by default
285
+ */
286
+ defaultSelectedIds?: string[];
246
287
  }
247
- declare function ChatFull({ title, placeholder, starterPrompts, className, headerProps, leftSidebar, rightSidebar, leftSidebarClassName, rightSidebarClassName, leftSidebarCollapsible, rightSidebarCollapsible, defaultLeftSidebarCollapsed, defaultRightSidebarCollapsed, leftSidebarCollapsed: controlledLeftCollapsed, rightSidebarCollapsed: controlledRightCollapsed, onLeftSidebarCollapseChange, onRightSidebarCollapseChange, }: ChatFullProps): react_jsx_runtime.JSX.Element;
288
+ declare function ChatFull({ title, placeholder, starterPrompts, options, className, headerProps, leftSidebar, rightSidebar, leftSidebarClassName, rightSidebarClassName, leftSidebarCollapsible, rightSidebarCollapsible, defaultLeftSidebarCollapsed, defaultRightSidebarCollapsed, leftSidebarCollapsed: controlledLeftCollapsed, rightSidebarCollapsed: controlledRightCollapsed, onLeftSidebarCollapseChange, onRightSidebarCollapseChange, autoFocus, defaultSelectedIds, }: ChatFullProps): react_jsx_runtime.JSX.Element;
248
289
 
249
290
  interface ThreadListProps {
250
291
  className?: string;
@@ -253,6 +294,25 @@ interface ThreadListProps {
253
294
  }
254
295
  declare const ThreadList: React$1.FC<ThreadListProps>;
255
296
 
297
+ interface ThreadPopoverProps {
298
+ className?: string;
299
+ buttonClassName?: string;
300
+ buttonVariant?: "default" | "outline" | "secondary" | "ghost" | "destructive" | "link";
301
+ buttonSize?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg";
302
+ emptyState?: React$1.ReactNode;
303
+ onThreadSelect?: (threadId: string) => void;
304
+ }
305
+ declare const ThreadPopover: React$1.FC<ThreadPopoverProps>;
306
+
307
+ interface CreateThreadButtonProps {
308
+ className?: string;
309
+ variant?: "default" | "outline" | "secondary" | "ghost" | "destructive" | "link";
310
+ size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg";
311
+ children?: React$1.ReactNode;
312
+ onThreadCreated?: (threadId: string) => void;
313
+ }
314
+ declare const CreateThreadButton: React$1.FC<CreateThreadButtonProps>;
315
+
256
316
  interface AccountDialogProps {
257
317
  className?: string;
258
318
  variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
@@ -274,4 +334,4 @@ declare function UIRenderer({ node }: UIRendererProps): react_jsx_runtime.JSX.El
274
334
 
275
335
  declare function groupEventsToMessages(events: Event[]): Message[];
276
336
 
277
- export { AccountDialog, type AccountDialogProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, ChatFull, type ChatFullProps, ChatHeader, type ChatHeaderProps, ChatPopup, type ChatPopupProps, ChatSidebar, type ChatSidebarProps, Composer, MelonyClientProvider, type MelonyClientProviderProps, MelonyContext, type MelonyContextValue, type Message, type StarterPrompt, ThemeProvider, ThemeToggle, Thread, ThreadContext, type ThreadContextValue, type ThreadData, ThreadList, type ThreadListProps, ThreadProvider, type ThreadProviderProps, type ThreadService, UIRenderer, type UIRendererProps, type UseMelonyOptions, type User, groupEventsToMessages, useAuth, useMelony, useTheme, useThreads };
337
+ export { AccountDialog, type AccountDialogProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, ChatFull, type ChatFullProps, ChatHeader, type ChatHeaderProps, ChatPopup, type ChatPopupProps, ChatSidebar, type ChatSidebarProps, Composer, type ComposerOption, type ComposerOptionGroup, CreateThreadButton, type CreateThreadButtonProps, MelonyClientProvider, type MelonyClientProviderProps, MelonyContext, type MelonyContextValue, type Message, type StarterPrompt, ThemeProvider, ThemeToggle, Thread, ThreadContext, type ThreadContextValue, type ThreadData, ThreadList, type ThreadListProps, ThreadPopover, type ThreadPopoverProps, ThreadProvider, type ThreadProviderProps, type ThreadService, UIRenderer, type UIRendererProps, type UseMelonyOptions, type User, groupEventsToMessages, useAuth, useMelony, useTheme, useThreads };
package/dist/index.d.ts CHANGED
@@ -5,10 +5,15 @@ import { Role, Event, UINode } from 'melony';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
7
7
  interface User {
8
- id: string;
8
+ id?: string;
9
+ uid: string;
9
10
  email: string;
10
- name: string;
11
+ name?: string;
12
+ displayName?: string;
11
13
  picture?: string;
14
+ createdAt?: string;
15
+ lastSignIn?: string | null;
16
+ emailVerified?: boolean;
12
17
  }
13
18
  interface Message {
14
19
  role: Role;
@@ -26,6 +31,17 @@ interface StarterPrompt {
26
31
  prompt: string;
27
32
  icon?: React.ReactNode;
28
33
  }
34
+ interface ComposerOption {
35
+ id: string;
36
+ label: string;
37
+ value: any;
38
+ }
39
+ interface ComposerOptionGroup {
40
+ id: string;
41
+ label: string;
42
+ options: ComposerOption[];
43
+ type?: "single" | "multiple";
44
+ }
29
45
  interface AuthService {
30
46
  getMe: () => Promise<User | null>;
31
47
  login: () => void;
@@ -116,18 +132,24 @@ interface ThreadProps {
116
132
  placeholder?: string;
117
133
  starterPrompts?: StarterPrompt[];
118
134
  onStarterPromptClick?: (prompt: string) => void;
135
+ options?: ComposerOptionGroup[];
136
+ autoFocus?: boolean;
137
+ defaultSelectedIds?: string[];
119
138
  }
120
- declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, }: ThreadProps): react_jsx_runtime.JSX.Element;
139
+ declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, options, autoFocus, defaultSelectedIds, }: ThreadProps): react_jsx_runtime.JSX.Element;
121
140
 
122
141
  interface ComposerProps {
123
142
  value: string;
124
143
  onChange: (value: string) => void;
125
- onSubmit: (e?: React__default.FormEvent) => void;
144
+ onSubmit: (state?: Record<string, any>) => void;
126
145
  placeholder?: string;
127
146
  isLoading?: boolean;
128
147
  className?: string;
148
+ options?: ComposerOptionGroup[];
149
+ autoFocus?: boolean;
150
+ defaultSelectedIds?: string[];
129
151
  }
130
- declare function Composer({ value, onChange, onSubmit, placeholder, isLoading, className, }: ComposerProps): react_jsx_runtime.JSX.Element;
152
+ declare function Composer({ value, onChange, onSubmit, placeholder, isLoading, className, options, autoFocus, defaultSelectedIds, }: ComposerProps): react_jsx_runtime.JSX.Element;
131
153
 
132
154
  interface ChatHeaderProps {
133
155
  /**
@@ -165,31 +187,42 @@ interface ChatPopupProps {
165
187
  title?: string;
166
188
  placeholder?: string;
167
189
  starterPrompts?: StarterPrompt[];
190
+ options?: ComposerOptionGroup[];
168
191
  defaultOpen?: boolean;
169
192
  /**
170
193
  * Props for customizing the header. Note: leftContent and rightContent in headerProps
171
194
  * will be merged with the default popup header actions (back, history, new chat, close).
172
195
  */
173
196
  headerProps?: Omit<ChatHeaderProps, "title" | "leftContent" | "rightContent">;
197
+ /**
198
+ * IDs of options to be selected by default
199
+ */
200
+ defaultSelectedIds?: string[];
174
201
  }
175
- declare function ChatPopup({ title, placeholder, starterPrompts, defaultOpen, headerProps, }: ChatPopupProps): react_jsx_runtime.JSX.Element;
202
+ declare function ChatPopup({ title, placeholder, starterPrompts, options, defaultOpen, headerProps, defaultSelectedIds, }: ChatPopupProps): react_jsx_runtime.JSX.Element;
176
203
 
177
204
  interface ChatSidebarProps {
178
205
  title?: string;
179
206
  placeholder?: string;
180
207
  starterPrompts?: StarterPrompt[];
208
+ options?: ComposerOptionGroup[];
181
209
  className?: string;
182
210
  /**
183
211
  * Props for customizing the header. If provided, title prop will be passed to header.
184
212
  */
185
213
  headerProps?: Omit<ChatHeaderProps, "title">;
214
+ /**
215
+ * IDs of options to be selected by default
216
+ */
217
+ defaultSelectedIds?: string[];
186
218
  }
187
- declare function ChatSidebar({ title, placeholder, starterPrompts, className, headerProps, }: ChatSidebarProps): react_jsx_runtime.JSX.Element;
219
+ declare function ChatSidebar({ title, placeholder, starterPrompts, options, className, headerProps, defaultSelectedIds, }: ChatSidebarProps): react_jsx_runtime.JSX.Element;
188
220
 
189
221
  interface ChatFullProps {
190
222
  title?: string;
191
223
  placeholder?: string;
192
224
  starterPrompts?: StarterPrompt[];
225
+ options?: ComposerOptionGroup[];
193
226
  className?: string;
194
227
  /**
195
228
  * Props for customizing the header. If provided, title prop will be passed to header.
@@ -243,8 +276,16 @@ interface ChatFullProps {
243
276
  * Callback when right sidebar collapse state changes
244
277
  */
245
278
  onRightSidebarCollapseChange?: (collapsed: boolean) => void;
279
+ /**
280
+ * Whether the composer should be auto focused
281
+ */
282
+ autoFocus?: boolean;
283
+ /**
284
+ * IDs of options to be selected by default
285
+ */
286
+ defaultSelectedIds?: string[];
246
287
  }
247
- declare function ChatFull({ title, placeholder, starterPrompts, className, headerProps, leftSidebar, rightSidebar, leftSidebarClassName, rightSidebarClassName, leftSidebarCollapsible, rightSidebarCollapsible, defaultLeftSidebarCollapsed, defaultRightSidebarCollapsed, leftSidebarCollapsed: controlledLeftCollapsed, rightSidebarCollapsed: controlledRightCollapsed, onLeftSidebarCollapseChange, onRightSidebarCollapseChange, }: ChatFullProps): react_jsx_runtime.JSX.Element;
288
+ declare function ChatFull({ title, placeholder, starterPrompts, options, className, headerProps, leftSidebar, rightSidebar, leftSidebarClassName, rightSidebarClassName, leftSidebarCollapsible, rightSidebarCollapsible, defaultLeftSidebarCollapsed, defaultRightSidebarCollapsed, leftSidebarCollapsed: controlledLeftCollapsed, rightSidebarCollapsed: controlledRightCollapsed, onLeftSidebarCollapseChange, onRightSidebarCollapseChange, autoFocus, defaultSelectedIds, }: ChatFullProps): react_jsx_runtime.JSX.Element;
248
289
 
249
290
  interface ThreadListProps {
250
291
  className?: string;
@@ -253,6 +294,25 @@ interface ThreadListProps {
253
294
  }
254
295
  declare const ThreadList: React$1.FC<ThreadListProps>;
255
296
 
297
+ interface ThreadPopoverProps {
298
+ className?: string;
299
+ buttonClassName?: string;
300
+ buttonVariant?: "default" | "outline" | "secondary" | "ghost" | "destructive" | "link";
301
+ buttonSize?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg";
302
+ emptyState?: React$1.ReactNode;
303
+ onThreadSelect?: (threadId: string) => void;
304
+ }
305
+ declare const ThreadPopover: React$1.FC<ThreadPopoverProps>;
306
+
307
+ interface CreateThreadButtonProps {
308
+ className?: string;
309
+ variant?: "default" | "outline" | "secondary" | "ghost" | "destructive" | "link";
310
+ size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg";
311
+ children?: React$1.ReactNode;
312
+ onThreadCreated?: (threadId: string) => void;
313
+ }
314
+ declare const CreateThreadButton: React$1.FC<CreateThreadButtonProps>;
315
+
256
316
  interface AccountDialogProps {
257
317
  className?: string;
258
318
  variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
@@ -274,4 +334,4 @@ declare function UIRenderer({ node }: UIRendererProps): react_jsx_runtime.JSX.El
274
334
 
275
335
  declare function groupEventsToMessages(events: Event[]): Message[];
276
336
 
277
- export { AccountDialog, type AccountDialogProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, ChatFull, type ChatFullProps, ChatHeader, type ChatHeaderProps, ChatPopup, type ChatPopupProps, ChatSidebar, type ChatSidebarProps, Composer, MelonyClientProvider, type MelonyClientProviderProps, MelonyContext, type MelonyContextValue, type Message, type StarterPrompt, ThemeProvider, ThemeToggle, Thread, ThreadContext, type ThreadContextValue, type ThreadData, ThreadList, type ThreadListProps, ThreadProvider, type ThreadProviderProps, type ThreadService, UIRenderer, type UIRendererProps, type UseMelonyOptions, type User, groupEventsToMessages, useAuth, useMelony, useTheme, useThreads };
337
+ export { AccountDialog, type AccountDialogProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, ChatFull, type ChatFullProps, ChatHeader, type ChatHeaderProps, ChatPopup, type ChatPopupProps, ChatSidebar, type ChatSidebarProps, Composer, type ComposerOption, type ComposerOptionGroup, CreateThreadButton, type CreateThreadButtonProps, MelonyClientProvider, type MelonyClientProviderProps, MelonyContext, type MelonyContextValue, type Message, type StarterPrompt, ThemeProvider, ThemeToggle, Thread, ThreadContext, type ThreadContextValue, type ThreadData, ThreadList, type ThreadListProps, ThreadPopover, type ThreadPopoverProps, ThreadProvider, type ThreadProviderProps, type ThreadService, UIRenderer, type UIRendererProps, type UseMelonyOptions, type User, groupEventsToMessages, useAuth, useMelony, useTheme, useThreads };