@melony/react 0.1.11 → 0.1.14

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
@@ -1,7 +1,7 @@
1
1
  import * as React$1 from 'react';
2
2
  import React__default, { ReactNode } from 'react';
3
- import { ClientState, Client } from '@melony/core/client';
4
- import { Role, Event, UINode } from '@melony/core';
3
+ import { ClientState, MelonyClient } from 'melony/client';
4
+ import { Role, Event, UINode } from 'melony';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
7
7
  interface User {
@@ -45,15 +45,16 @@ interface MelonyContextValue extends ClientState {
45
45
  runId?: string;
46
46
  state?: Record<string, any>;
47
47
  }) => Promise<void>;
48
- clear: () => void;
49
- client: Client;
48
+ reset: (events?: Event[]) => void;
49
+ client: MelonyClient;
50
50
  }
51
51
  declare const MelonyContext: React__default.Context<MelonyContextValue | undefined>;
52
- interface MelonyProviderProps {
52
+ interface MelonyClientProviderProps {
53
53
  children: ReactNode;
54
- client: Client;
54
+ client: MelonyClient;
55
+ initialEvents?: Event[];
55
56
  }
56
- declare const MelonyProvider: React__default.FC<MelonyProviderProps>;
57
+ declare const MelonyClientProvider: React__default.FC<MelonyClientProviderProps>;
57
58
 
58
59
  interface AuthContextValue {
59
60
  user: User | null;
@@ -80,7 +81,6 @@ interface ThreadContextValue {
80
81
  deleteThread: (threadId: string) => Promise<void>;
81
82
  refreshThreads: () => Promise<void>;
82
83
  threadEvents: Event[];
83
- threadMessages: Message[];
84
84
  isLoadingEvents: boolean;
85
85
  }
86
86
  declare const ThreadContext: React__default.Context<ThreadContextValue | undefined>;
@@ -91,18 +91,33 @@ interface ThreadProviderProps {
91
91
  }
92
92
  declare const ThreadProvider: React__default.FC<ThreadProviderProps>;
93
93
 
94
- declare const useMelony: () => MelonyContextValue;
94
+ type Theme = "light" | "dark" | "system";
95
+ interface ThemeContextType {
96
+ theme: Theme;
97
+ setTheme: (theme: Theme) => void;
98
+ resolvedTheme: "light" | "dark";
99
+ }
100
+ declare function ThemeProvider({ children }: {
101
+ children: React.ReactNode;
102
+ }): react_jsx_runtime.JSX.Element;
103
+ declare function useTheme(): ThemeContextType;
104
+
105
+ interface UseMelonyOptions {
106
+ initialEvents?: Event[];
107
+ }
108
+ declare const useMelony: (options?: UseMelonyOptions) => MelonyContextValue;
95
109
 
96
110
  declare const useAuth: () => AuthContextValue;
97
111
 
98
112
  declare const useThreads: () => ThreadContextValue;
99
113
 
100
- declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, }: {
114
+ interface ThreadProps {
101
115
  className?: string;
102
116
  placeholder?: string;
103
117
  starterPrompts?: StarterPrompt[];
104
118
  onStarterPromptClick?: (prompt: string) => void;
105
- }): react_jsx_runtime.JSX.Element;
119
+ }
120
+ declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, }: ThreadProps): react_jsx_runtime.JSX.Element;
106
121
 
107
122
  interface ComposerProps {
108
123
  value: string;
@@ -114,29 +129,122 @@ interface ComposerProps {
114
129
  }
115
130
  declare function Composer({ value, onChange, onSubmit, placeholder, isLoading, className, }: ComposerProps): react_jsx_runtime.JSX.Element;
116
131
 
132
+ interface ChatHeaderProps {
133
+ /**
134
+ * The title to display in the header. Can be a string or a React node for custom content.
135
+ */
136
+ title?: string | React__default.ReactNode;
137
+ /**
138
+ * Content to render on the left side of the header (e.g., back button).
139
+ */
140
+ leftContent?: React__default.ReactNode;
141
+ /**
142
+ * Content to render on the right side of the header (e.g., action buttons).
143
+ */
144
+ rightContent?: React__default.ReactNode;
145
+ /**
146
+ * Custom className for the header container.
147
+ */
148
+ className?: string;
149
+ /**
150
+ * Custom className for the title element (only applies when title is a string).
151
+ */
152
+ titleClassName?: string;
153
+ /**
154
+ * Custom children to render inside the header. If provided, this takes precedence over title/leftContent/rightContent.
155
+ */
156
+ children?: React__default.ReactNode;
157
+ }
158
+ /**
159
+ * A shared, customizable header component for chat interfaces.
160
+ * Used consistently across ChatFull, ChatSidebar, and ChatPopup components.
161
+ */
162
+ declare function ChatHeader({ title, leftContent, rightContent, className, titleClassName, children, }: ChatHeaderProps): react_jsx_runtime.JSX.Element;
163
+
117
164
  interface ChatPopupProps {
118
165
  title?: string;
119
166
  placeholder?: string;
120
167
  starterPrompts?: StarterPrompt[];
121
168
  defaultOpen?: boolean;
169
+ /**
170
+ * Props for customizing the header. Note: leftContent and rightContent in headerProps
171
+ * will be merged with the default popup header actions (back, history, new chat, close).
172
+ */
173
+ headerProps?: Omit<ChatHeaderProps, "title" | "leftContent" | "rightContent">;
122
174
  }
123
- declare function ChatPopup({ title, placeholder, starterPrompts, defaultOpen, }: ChatPopupProps): react_jsx_runtime.JSX.Element;
175
+ declare function ChatPopup({ title, placeholder, starterPrompts, defaultOpen, headerProps, }: ChatPopupProps): react_jsx_runtime.JSX.Element;
124
176
 
125
177
  interface ChatSidebarProps {
126
178
  title?: string;
127
179
  placeholder?: string;
128
180
  starterPrompts?: StarterPrompt[];
129
181
  className?: string;
182
+ /**
183
+ * Props for customizing the header. If provided, title prop will be passed to header.
184
+ */
185
+ headerProps?: Omit<ChatHeaderProps, "title">;
130
186
  }
131
- declare function ChatSidebar({ title, placeholder, starterPrompts, className, }: ChatSidebarProps): react_jsx_runtime.JSX.Element;
187
+ declare function ChatSidebar({ title, placeholder, starterPrompts, className, headerProps, }: ChatSidebarProps): react_jsx_runtime.JSX.Element;
132
188
 
133
189
  interface ChatFullProps {
134
190
  title?: string;
135
191
  placeholder?: string;
136
192
  starterPrompts?: StarterPrompt[];
137
193
  className?: string;
194
+ /**
195
+ * Props for customizing the header. If provided, title prop will be passed to header.
196
+ */
197
+ headerProps?: Omit<ChatHeaderProps, "title">;
198
+ /**
199
+ * Customizable left sidebar content. Typically used for navigation, thread list, etc.
200
+ */
201
+ leftSidebar?: React__default.ReactNode;
202
+ /**
203
+ * Customizable right sidebar content. Typically used as a canvas, additional info, etc.
204
+ */
205
+ rightSidebar?: React__default.ReactNode;
206
+ /**
207
+ * Custom className for the left sidebar container
208
+ */
209
+ leftSidebarClassName?: string;
210
+ /**
211
+ * Custom className for the right sidebar container
212
+ */
213
+ rightSidebarClassName?: string;
214
+ /**
215
+ * Whether the left sidebar is collapsible
216
+ */
217
+ leftSidebarCollapsible?: boolean;
218
+ /**
219
+ * Whether the right sidebar is collapsible
220
+ */
221
+ rightSidebarCollapsible?: boolean;
222
+ /**
223
+ * Default collapsed state for the left sidebar
224
+ */
225
+ defaultLeftSidebarCollapsed?: boolean;
226
+ /**
227
+ * Default collapsed state for the right sidebar
228
+ */
229
+ defaultRightSidebarCollapsed?: boolean;
230
+ /**
231
+ * Controlled collapsed state for the left sidebar. If provided, component becomes controlled.
232
+ */
233
+ leftSidebarCollapsed?: boolean;
234
+ /**
235
+ * Controlled collapsed state for the right sidebar. If provided, component becomes controlled.
236
+ */
237
+ rightSidebarCollapsed?: boolean;
238
+ /**
239
+ * Callback when left sidebar collapse state changes
240
+ */
241
+ onLeftSidebarCollapseChange?: (collapsed: boolean) => void;
242
+ /**
243
+ * Callback when right sidebar collapse state changes
244
+ */
245
+ onRightSidebarCollapseChange?: (collapsed: boolean) => void;
138
246
  }
139
- declare function ChatFull({ title, placeholder, starterPrompts, className, }: ChatFullProps): react_jsx_runtime.JSX.Element;
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;
140
248
 
141
249
  interface ThreadListProps {
142
250
  className?: string;
@@ -152,6 +260,8 @@ interface AccountDialogProps {
152
260
  }
153
261
  declare const AccountDialog: React$1.FC<AccountDialogProps>;
154
262
 
263
+ declare function ThemeToggle(): react_jsx_runtime.JSX.Element;
264
+
155
265
  interface UIRendererProps {
156
266
  node: UINode;
157
267
  }
@@ -162,4 +272,6 @@ interface UIRendererProps {
162
272
  */
163
273
  declare function UIRenderer({ node }: UIRendererProps): react_jsx_runtime.JSX.Element;
164
274
 
165
- export { AccountDialog, type AccountDialogProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, ChatFull, type ChatFullProps, ChatPopup, type ChatPopupProps, ChatSidebar, type ChatSidebarProps, Composer, MelonyContext, type MelonyContextValue, MelonyProvider, type MelonyProviderProps, type Message, type StarterPrompt, Thread, ThreadContext, type ThreadContextValue, type ThreadData, ThreadList, type ThreadListProps, ThreadProvider, type ThreadProviderProps, type ThreadService, UIRenderer, type UIRendererProps, type User, useAuth, useMelony, useThreads };
275
+ declare function groupEventsToMessages(events: Event[]): Message[];
276
+
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 };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React$1 from 'react';
2
2
  import React__default, { ReactNode } from 'react';
3
- import { ClientState, Client } from '@melony/core/client';
4
- import { Role, Event, UINode } from '@melony/core';
3
+ import { ClientState, MelonyClient } from 'melony/client';
4
+ import { Role, Event, UINode } from 'melony';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
 
7
7
  interface User {
@@ -45,15 +45,16 @@ interface MelonyContextValue extends ClientState {
45
45
  runId?: string;
46
46
  state?: Record<string, any>;
47
47
  }) => Promise<void>;
48
- clear: () => void;
49
- client: Client;
48
+ reset: (events?: Event[]) => void;
49
+ client: MelonyClient;
50
50
  }
51
51
  declare const MelonyContext: React__default.Context<MelonyContextValue | undefined>;
52
- interface MelonyProviderProps {
52
+ interface MelonyClientProviderProps {
53
53
  children: ReactNode;
54
- client: Client;
54
+ client: MelonyClient;
55
+ initialEvents?: Event[];
55
56
  }
56
- declare const MelonyProvider: React__default.FC<MelonyProviderProps>;
57
+ declare const MelonyClientProvider: React__default.FC<MelonyClientProviderProps>;
57
58
 
58
59
  interface AuthContextValue {
59
60
  user: User | null;
@@ -80,7 +81,6 @@ interface ThreadContextValue {
80
81
  deleteThread: (threadId: string) => Promise<void>;
81
82
  refreshThreads: () => Promise<void>;
82
83
  threadEvents: Event[];
83
- threadMessages: Message[];
84
84
  isLoadingEvents: boolean;
85
85
  }
86
86
  declare const ThreadContext: React__default.Context<ThreadContextValue | undefined>;
@@ -91,18 +91,33 @@ interface ThreadProviderProps {
91
91
  }
92
92
  declare const ThreadProvider: React__default.FC<ThreadProviderProps>;
93
93
 
94
- declare const useMelony: () => MelonyContextValue;
94
+ type Theme = "light" | "dark" | "system";
95
+ interface ThemeContextType {
96
+ theme: Theme;
97
+ setTheme: (theme: Theme) => void;
98
+ resolvedTheme: "light" | "dark";
99
+ }
100
+ declare function ThemeProvider({ children }: {
101
+ children: React.ReactNode;
102
+ }): react_jsx_runtime.JSX.Element;
103
+ declare function useTheme(): ThemeContextType;
104
+
105
+ interface UseMelonyOptions {
106
+ initialEvents?: Event[];
107
+ }
108
+ declare const useMelony: (options?: UseMelonyOptions) => MelonyContextValue;
95
109
 
96
110
  declare const useAuth: () => AuthContextValue;
97
111
 
98
112
  declare const useThreads: () => ThreadContextValue;
99
113
 
100
- declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, }: {
114
+ interface ThreadProps {
101
115
  className?: string;
102
116
  placeholder?: string;
103
117
  starterPrompts?: StarterPrompt[];
104
118
  onStarterPromptClick?: (prompt: string) => void;
105
- }): react_jsx_runtime.JSX.Element;
119
+ }
120
+ declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, }: ThreadProps): react_jsx_runtime.JSX.Element;
106
121
 
107
122
  interface ComposerProps {
108
123
  value: string;
@@ -114,29 +129,122 @@ interface ComposerProps {
114
129
  }
115
130
  declare function Composer({ value, onChange, onSubmit, placeholder, isLoading, className, }: ComposerProps): react_jsx_runtime.JSX.Element;
116
131
 
132
+ interface ChatHeaderProps {
133
+ /**
134
+ * The title to display in the header. Can be a string or a React node for custom content.
135
+ */
136
+ title?: string | React__default.ReactNode;
137
+ /**
138
+ * Content to render on the left side of the header (e.g., back button).
139
+ */
140
+ leftContent?: React__default.ReactNode;
141
+ /**
142
+ * Content to render on the right side of the header (e.g., action buttons).
143
+ */
144
+ rightContent?: React__default.ReactNode;
145
+ /**
146
+ * Custom className for the header container.
147
+ */
148
+ className?: string;
149
+ /**
150
+ * Custom className for the title element (only applies when title is a string).
151
+ */
152
+ titleClassName?: string;
153
+ /**
154
+ * Custom children to render inside the header. If provided, this takes precedence over title/leftContent/rightContent.
155
+ */
156
+ children?: React__default.ReactNode;
157
+ }
158
+ /**
159
+ * A shared, customizable header component for chat interfaces.
160
+ * Used consistently across ChatFull, ChatSidebar, and ChatPopup components.
161
+ */
162
+ declare function ChatHeader({ title, leftContent, rightContent, className, titleClassName, children, }: ChatHeaderProps): react_jsx_runtime.JSX.Element;
163
+
117
164
  interface ChatPopupProps {
118
165
  title?: string;
119
166
  placeholder?: string;
120
167
  starterPrompts?: StarterPrompt[];
121
168
  defaultOpen?: boolean;
169
+ /**
170
+ * Props for customizing the header. Note: leftContent and rightContent in headerProps
171
+ * will be merged with the default popup header actions (back, history, new chat, close).
172
+ */
173
+ headerProps?: Omit<ChatHeaderProps, "title" | "leftContent" | "rightContent">;
122
174
  }
123
- declare function ChatPopup({ title, placeholder, starterPrompts, defaultOpen, }: ChatPopupProps): react_jsx_runtime.JSX.Element;
175
+ declare function ChatPopup({ title, placeholder, starterPrompts, defaultOpen, headerProps, }: ChatPopupProps): react_jsx_runtime.JSX.Element;
124
176
 
125
177
  interface ChatSidebarProps {
126
178
  title?: string;
127
179
  placeholder?: string;
128
180
  starterPrompts?: StarterPrompt[];
129
181
  className?: string;
182
+ /**
183
+ * Props for customizing the header. If provided, title prop will be passed to header.
184
+ */
185
+ headerProps?: Omit<ChatHeaderProps, "title">;
130
186
  }
131
- declare function ChatSidebar({ title, placeholder, starterPrompts, className, }: ChatSidebarProps): react_jsx_runtime.JSX.Element;
187
+ declare function ChatSidebar({ title, placeholder, starterPrompts, className, headerProps, }: ChatSidebarProps): react_jsx_runtime.JSX.Element;
132
188
 
133
189
  interface ChatFullProps {
134
190
  title?: string;
135
191
  placeholder?: string;
136
192
  starterPrompts?: StarterPrompt[];
137
193
  className?: string;
194
+ /**
195
+ * Props for customizing the header. If provided, title prop will be passed to header.
196
+ */
197
+ headerProps?: Omit<ChatHeaderProps, "title">;
198
+ /**
199
+ * Customizable left sidebar content. Typically used for navigation, thread list, etc.
200
+ */
201
+ leftSidebar?: React__default.ReactNode;
202
+ /**
203
+ * Customizable right sidebar content. Typically used as a canvas, additional info, etc.
204
+ */
205
+ rightSidebar?: React__default.ReactNode;
206
+ /**
207
+ * Custom className for the left sidebar container
208
+ */
209
+ leftSidebarClassName?: string;
210
+ /**
211
+ * Custom className for the right sidebar container
212
+ */
213
+ rightSidebarClassName?: string;
214
+ /**
215
+ * Whether the left sidebar is collapsible
216
+ */
217
+ leftSidebarCollapsible?: boolean;
218
+ /**
219
+ * Whether the right sidebar is collapsible
220
+ */
221
+ rightSidebarCollapsible?: boolean;
222
+ /**
223
+ * Default collapsed state for the left sidebar
224
+ */
225
+ defaultLeftSidebarCollapsed?: boolean;
226
+ /**
227
+ * Default collapsed state for the right sidebar
228
+ */
229
+ defaultRightSidebarCollapsed?: boolean;
230
+ /**
231
+ * Controlled collapsed state for the left sidebar. If provided, component becomes controlled.
232
+ */
233
+ leftSidebarCollapsed?: boolean;
234
+ /**
235
+ * Controlled collapsed state for the right sidebar. If provided, component becomes controlled.
236
+ */
237
+ rightSidebarCollapsed?: boolean;
238
+ /**
239
+ * Callback when left sidebar collapse state changes
240
+ */
241
+ onLeftSidebarCollapseChange?: (collapsed: boolean) => void;
242
+ /**
243
+ * Callback when right sidebar collapse state changes
244
+ */
245
+ onRightSidebarCollapseChange?: (collapsed: boolean) => void;
138
246
  }
139
- declare function ChatFull({ title, placeholder, starterPrompts, className, }: ChatFullProps): react_jsx_runtime.JSX.Element;
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;
140
248
 
141
249
  interface ThreadListProps {
142
250
  className?: string;
@@ -152,6 +260,8 @@ interface AccountDialogProps {
152
260
  }
153
261
  declare const AccountDialog: React$1.FC<AccountDialogProps>;
154
262
 
263
+ declare function ThemeToggle(): react_jsx_runtime.JSX.Element;
264
+
155
265
  interface UIRendererProps {
156
266
  node: UINode;
157
267
  }
@@ -162,4 +272,6 @@ interface UIRendererProps {
162
272
  */
163
273
  declare function UIRenderer({ node }: UIRendererProps): react_jsx_runtime.JSX.Element;
164
274
 
165
- export { AccountDialog, type AccountDialogProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, ChatFull, type ChatFullProps, ChatPopup, type ChatPopupProps, ChatSidebar, type ChatSidebarProps, Composer, MelonyContext, type MelonyContextValue, MelonyProvider, type MelonyProviderProps, type Message, type StarterPrompt, Thread, ThreadContext, type ThreadContextValue, type ThreadData, ThreadList, type ThreadListProps, ThreadProvider, type ThreadProviderProps, type ThreadService, UIRenderer, type UIRendererProps, type User, useAuth, useMelony, useThreads };
275
+ declare function groupEventsToMessages(events: Event[]): Message[];
276
+
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 };