@melony/react 0.1.12 → 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, MelonyClient } 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 {
@@ -91,6 +91,17 @@ interface ThreadProviderProps {
91
91
  }
92
92
  declare const ThreadProvider: React__default.FC<ThreadProviderProps>;
93
93
 
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
+
94
105
  interface UseMelonyOptions {
95
106
  initialEvents?: Event[];
96
107
  }
@@ -100,12 +111,13 @@ declare const useAuth: () => AuthContextValue;
100
111
 
101
112
  declare const useThreads: () => ThreadContextValue;
102
113
 
103
- declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, }: {
114
+ interface ThreadProps {
104
115
  className?: string;
105
116
  placeholder?: string;
106
117
  starterPrompts?: StarterPrompt[];
107
118
  onStarterPromptClick?: (prompt: string) => void;
108
- }): react_jsx_runtime.JSX.Element;
119
+ }
120
+ declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, }: ThreadProps): react_jsx_runtime.JSX.Element;
109
121
 
110
122
  interface ComposerProps {
111
123
  value: string;
@@ -117,29 +129,122 @@ interface ComposerProps {
117
129
  }
118
130
  declare function Composer({ value, onChange, onSubmit, placeholder, isLoading, className, }: ComposerProps): react_jsx_runtime.JSX.Element;
119
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
+
120
164
  interface ChatPopupProps {
121
165
  title?: string;
122
166
  placeholder?: string;
123
167
  starterPrompts?: StarterPrompt[];
124
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">;
125
174
  }
126
- 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;
127
176
 
128
177
  interface ChatSidebarProps {
129
178
  title?: string;
130
179
  placeholder?: string;
131
180
  starterPrompts?: StarterPrompt[];
132
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">;
133
186
  }
134
- 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;
135
188
 
136
189
  interface ChatFullProps {
137
190
  title?: string;
138
191
  placeholder?: string;
139
192
  starterPrompts?: StarterPrompt[];
140
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;
141
246
  }
142
- 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;
143
248
 
144
249
  interface ThreadListProps {
145
250
  className?: string;
@@ -155,6 +260,8 @@ interface AccountDialogProps {
155
260
  }
156
261
  declare const AccountDialog: React$1.FC<AccountDialogProps>;
157
262
 
263
+ declare function ThemeToggle(): react_jsx_runtime.JSX.Element;
264
+
158
265
  interface UIRendererProps {
159
266
  node: UINode;
160
267
  }
@@ -165,4 +272,6 @@ interface UIRendererProps {
165
272
  */
166
273
  declare function UIRenderer({ node }: UIRendererProps): react_jsx_runtime.JSX.Element;
167
274
 
168
- export { AccountDialog, type AccountDialogProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, ChatFull, type ChatFullProps, ChatPopup, type ChatPopupProps, ChatSidebar, type ChatSidebarProps, Composer, MelonyClientProvider, type MelonyClientProviderProps, MelonyContext, type MelonyContextValue, type Message, type StarterPrompt, Thread, ThreadContext, type ThreadContextValue, type ThreadData, ThreadList, type ThreadListProps, ThreadProvider, type ThreadProviderProps, type ThreadService, UIRenderer, type UIRendererProps, type UseMelonyOptions, 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, MelonyClient } 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 {
@@ -91,6 +91,17 @@ interface ThreadProviderProps {
91
91
  }
92
92
  declare const ThreadProvider: React__default.FC<ThreadProviderProps>;
93
93
 
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
+
94
105
  interface UseMelonyOptions {
95
106
  initialEvents?: Event[];
96
107
  }
@@ -100,12 +111,13 @@ declare const useAuth: () => AuthContextValue;
100
111
 
101
112
  declare const useThreads: () => ThreadContextValue;
102
113
 
103
- declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, }: {
114
+ interface ThreadProps {
104
115
  className?: string;
105
116
  placeholder?: string;
106
117
  starterPrompts?: StarterPrompt[];
107
118
  onStarterPromptClick?: (prompt: string) => void;
108
- }): react_jsx_runtime.JSX.Element;
119
+ }
120
+ declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, }: ThreadProps): react_jsx_runtime.JSX.Element;
109
121
 
110
122
  interface ComposerProps {
111
123
  value: string;
@@ -117,29 +129,122 @@ interface ComposerProps {
117
129
  }
118
130
  declare function Composer({ value, onChange, onSubmit, placeholder, isLoading, className, }: ComposerProps): react_jsx_runtime.JSX.Element;
119
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
+
120
164
  interface ChatPopupProps {
121
165
  title?: string;
122
166
  placeholder?: string;
123
167
  starterPrompts?: StarterPrompt[];
124
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">;
125
174
  }
126
- 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;
127
176
 
128
177
  interface ChatSidebarProps {
129
178
  title?: string;
130
179
  placeholder?: string;
131
180
  starterPrompts?: StarterPrompt[];
132
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">;
133
186
  }
134
- 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;
135
188
 
136
189
  interface ChatFullProps {
137
190
  title?: string;
138
191
  placeholder?: string;
139
192
  starterPrompts?: StarterPrompt[];
140
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;
141
246
  }
142
- 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;
143
248
 
144
249
  interface ThreadListProps {
145
250
  className?: string;
@@ -155,6 +260,8 @@ interface AccountDialogProps {
155
260
  }
156
261
  declare const AccountDialog: React$1.FC<AccountDialogProps>;
157
262
 
263
+ declare function ThemeToggle(): react_jsx_runtime.JSX.Element;
264
+
158
265
  interface UIRendererProps {
159
266
  node: UINode;
160
267
  }
@@ -165,4 +272,6 @@ interface UIRendererProps {
165
272
  */
166
273
  declare function UIRenderer({ node }: UIRendererProps): react_jsx_runtime.JSX.Element;
167
274
 
168
- export { AccountDialog, type AccountDialogProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, ChatFull, type ChatFullProps, ChatPopup, type ChatPopupProps, ChatSidebar, type ChatSidebarProps, Composer, MelonyClientProvider, type MelonyClientProviderProps, MelonyContext, type MelonyContextValue, type Message, type StarterPrompt, Thread, ThreadContext, type ThreadContextValue, type ThreadData, ThreadList, type ThreadListProps, ThreadProvider, type ThreadProviderProps, type ThreadService, UIRenderer, type UIRendererProps, type UseMelonyOptions, 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 };