@melony/react 0.1.45 → 0.1.46
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.cjs +204 -95
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +142 -34
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -420,6 +420,7 @@ type LabelProps = BaseComponentProps & UIContract["label"] & {
|
|
|
420
420
|
size?: FontSize;
|
|
421
421
|
weight?: FontWeight;
|
|
422
422
|
};
|
|
423
|
+
type UploadProps = BaseComponentProps & UIContract["upload"];
|
|
423
424
|
type TextareaProps = BaseComponentProps & UIContract["textarea"] & {
|
|
424
425
|
value?: string;
|
|
425
426
|
disabled?: boolean;
|
|
@@ -452,6 +453,8 @@ declare const RadioGroup: React__default.FC<RadioGroupProps>;
|
|
|
452
453
|
|
|
453
454
|
declare const Form: React__default.FC<FormProps>;
|
|
454
455
|
|
|
456
|
+
declare const Upload: React__default.FC<UploadProps>;
|
|
457
|
+
|
|
455
458
|
declare const Heading: React__default.FC<HeadingProps>;
|
|
456
459
|
|
|
457
460
|
declare const Image: React__default.FC<ImageProps>;
|
|
@@ -480,4 +483,4 @@ declare const Text: React__default.FC<TextProps>;
|
|
|
480
483
|
|
|
481
484
|
declare const Badge: React__default.FC<BadgeProps>;
|
|
482
485
|
|
|
483
|
-
export { AccountButton, type AccountButtonProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, Badge, Box, Button, Card, Chart, ChatHeader, type ChatHeaderProps, Checkbox, Col, Composer, type ComposerOption, type ComposerOptionGroup, CreateThreadButton, type CreateThreadButtonProps, CreateThreadListItem, type CreateThreadListItemProps, Divider, Dropdown, type DropdownProps, Form, FullChat, type FullChatProps, Heading, Image, Input, Label, List, ListItem, MelonyContext, type MelonyContextValue, MelonyProvider, type MelonyProviderProps, PopupChat, type PopupChatProps, RadioGroup, Row, type ScreenSize, Select, Sidebar, SidebarContext, type SidebarContextValue, type SidebarProps, SidebarProvider, type SidebarProviderProps, SidebarToggle, type SidebarToggleProps, Spacer, type StarterPrompt, Text, Textarea, 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, WelcomeScreen, type WelcomeScreenProps, useAuth, useMelony, useScreenSize, useSidebar, useTheme, useThreads };
|
|
486
|
+
export { AccountButton, type AccountButtonProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, Badge, Box, Button, Card, Chart, ChatHeader, type ChatHeaderProps, Checkbox, Col, Composer, type ComposerOption, type ComposerOptionGroup, CreateThreadButton, type CreateThreadButtonProps, CreateThreadListItem, type CreateThreadListItemProps, Divider, Dropdown, type DropdownProps, Form, FullChat, type FullChatProps, Heading, Image, Input, Label, List, ListItem, MelonyContext, type MelonyContextValue, MelonyProvider, type MelonyProviderProps, PopupChat, type PopupChatProps, RadioGroup, Row, type ScreenSize, Select, Sidebar, SidebarContext, type SidebarContextValue, type SidebarProps, SidebarProvider, type SidebarProviderProps, SidebarToggle, type SidebarToggleProps, Spacer, type StarterPrompt, Text, Textarea, ThemeProvider, ThemeToggle, Thread, ThreadContext, type ThreadContextValue, type ThreadData, ThreadList, type ThreadListProps, ThreadPopover, type ThreadPopoverProps, ThreadProvider, type ThreadProviderProps, type ThreadService, UIRenderer, type UIRendererProps, Upload, type UseMelonyOptions, type User, WelcomeScreen, type WelcomeScreenProps, useAuth, useMelony, useScreenSize, useSidebar, useTheme, useThreads };
|
package/dist/index.d.ts
CHANGED
|
@@ -420,6 +420,7 @@ type LabelProps = BaseComponentProps & UIContract["label"] & {
|
|
|
420
420
|
size?: FontSize;
|
|
421
421
|
weight?: FontWeight;
|
|
422
422
|
};
|
|
423
|
+
type UploadProps = BaseComponentProps & UIContract["upload"];
|
|
423
424
|
type TextareaProps = BaseComponentProps & UIContract["textarea"] & {
|
|
424
425
|
value?: string;
|
|
425
426
|
disabled?: boolean;
|
|
@@ -452,6 +453,8 @@ declare const RadioGroup: React__default.FC<RadioGroupProps>;
|
|
|
452
453
|
|
|
453
454
|
declare const Form: React__default.FC<FormProps>;
|
|
454
455
|
|
|
456
|
+
declare const Upload: React__default.FC<UploadProps>;
|
|
457
|
+
|
|
455
458
|
declare const Heading: React__default.FC<HeadingProps>;
|
|
456
459
|
|
|
457
460
|
declare const Image: React__default.FC<ImageProps>;
|
|
@@ -480,4 +483,4 @@ declare const Text: React__default.FC<TextProps>;
|
|
|
480
483
|
|
|
481
484
|
declare const Badge: React__default.FC<BadgeProps>;
|
|
482
485
|
|
|
483
|
-
export { AccountButton, type AccountButtonProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, Badge, Box, Button, Card, Chart, ChatHeader, type ChatHeaderProps, Checkbox, Col, Composer, type ComposerOption, type ComposerOptionGroup, CreateThreadButton, type CreateThreadButtonProps, CreateThreadListItem, type CreateThreadListItemProps, Divider, Dropdown, type DropdownProps, Form, FullChat, type FullChatProps, Heading, Image, Input, Label, List, ListItem, MelonyContext, type MelonyContextValue, MelonyProvider, type MelonyProviderProps, PopupChat, type PopupChatProps, RadioGroup, Row, type ScreenSize, Select, Sidebar, SidebarContext, type SidebarContextValue, type SidebarProps, SidebarProvider, type SidebarProviderProps, SidebarToggle, type SidebarToggleProps, Spacer, type StarterPrompt, Text, Textarea, 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, WelcomeScreen, type WelcomeScreenProps, useAuth, useMelony, useScreenSize, useSidebar, useTheme, useThreads };
|
|
486
|
+
export { AccountButton, type AccountButtonProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, Badge, Box, Button, Card, Chart, ChatHeader, type ChatHeaderProps, Checkbox, Col, Composer, type ComposerOption, type ComposerOptionGroup, CreateThreadButton, type CreateThreadButtonProps, CreateThreadListItem, type CreateThreadListItemProps, Divider, Dropdown, type DropdownProps, Form, FullChat, type FullChatProps, Heading, Image, Input, Label, List, ListItem, MelonyContext, type MelonyContextValue, MelonyProvider, type MelonyProviderProps, PopupChat, type PopupChatProps, RadioGroup, Row, type ScreenSize, Select, Sidebar, SidebarContext, type SidebarContextValue, type SidebarProps, SidebarProvider, type SidebarProviderProps, SidebarToggle, type SidebarToggleProps, Spacer, type StarterPrompt, Text, Textarea, ThemeProvider, ThemeToggle, Thread, ThreadContext, type ThreadContextValue, type ThreadData, ThreadList, type ThreadListProps, ThreadPopover, type ThreadPopoverProps, ThreadProvider, type ThreadProviderProps, type ThreadService, UIRenderer, type UIRendererProps, Upload, type UseMelonyOptions, type User, WelcomeScreen, type WelcomeScreenProps, useAuth, useMelony, useScreenSize, useSidebar, useTheme, useThreads };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as React12 from 'react';
|
|
2
|
+
import React12__default, { createContext, useContext, useRef, useEffect, useState, useCallback, useMemo } from 'react';
|
|
3
3
|
import { convertEventsToMessages } from 'melony';
|
|
4
4
|
import { NuqsAdapter } from 'nuqs/adapters/react';
|
|
5
5
|
import { QueryClient, QueryClientProvider, useQueryClient, useQuery, useMutation } from '@tanstack/react-query';
|
|
@@ -8,7 +8,7 @@ import { clsx } from 'clsx';
|
|
|
8
8
|
import { twMerge } from 'tailwind-merge';
|
|
9
9
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
10
|
import * as ICONS from '@tabler/icons-react';
|
|
11
|
-
import { IconX, IconChevronLeft, IconChevronRight, IconUser, IconLogout, IconBrandGoogle, IconFileText, IconFile, IconPaperclip, IconChevronDown,
|
|
11
|
+
import { IconX, IconChevronLeft, IconChevronRight, IconLoader2, IconCheck, IconUpload, IconUser, IconLogout, IconBrandGoogle, IconFileText, IconFile, IconPaperclip, IconChevronDown, IconArrowUp, IconDotsVertical, IconTrash, IconHistory, IconPlus, IconArrowLeft, IconMessage, IconLayoutSidebarLeftExpand, IconLayoutSidebarLeftCollapse, IconLayoutSidebarRightExpand, IconLayoutSidebarRightCollapse, IconDeviceDesktop, IconMoon, IconSun, IconSelector, IconChevronUp } from '@tabler/icons-react';
|
|
12
12
|
import { Separator as Separator$1 } from '@base-ui/react/separator';
|
|
13
13
|
import { mergeProps } from '@base-ui/react/merge-props';
|
|
14
14
|
import { useRender } from '@base-ui/react/use-render';
|
|
@@ -1423,6 +1423,9 @@ var Checkbox = ({
|
|
|
1423
1423
|
)
|
|
1424
1424
|
] });
|
|
1425
1425
|
};
|
|
1426
|
+
var Hidden = ({ name, value }) => {
|
|
1427
|
+
return /* @__PURE__ */ jsx("input", { type: "hidden", name, value });
|
|
1428
|
+
};
|
|
1426
1429
|
var RadioGroup = ({
|
|
1427
1430
|
name,
|
|
1428
1431
|
options,
|
|
@@ -1582,6 +1585,109 @@ var Button2 = ({
|
|
|
1582
1585
|
}
|
|
1583
1586
|
);
|
|
1584
1587
|
};
|
|
1588
|
+
var Upload = ({
|
|
1589
|
+
label = "Upload",
|
|
1590
|
+
multiple = false,
|
|
1591
|
+
accept,
|
|
1592
|
+
onUploadAction,
|
|
1593
|
+
className,
|
|
1594
|
+
style
|
|
1595
|
+
}) => {
|
|
1596
|
+
const { sendEvent, events } = useMelony();
|
|
1597
|
+
const fileInputRef = useRef(null);
|
|
1598
|
+
const [isUploading, setIsUploading] = useState(false);
|
|
1599
|
+
const [status, setStatus] = useState("idle");
|
|
1600
|
+
const handleFileChange = async (e) => {
|
|
1601
|
+
const files = Array.from(e.target.files || []);
|
|
1602
|
+
if (files.length === 0) return;
|
|
1603
|
+
setIsUploading(true);
|
|
1604
|
+
setStatus("idle");
|
|
1605
|
+
try {
|
|
1606
|
+
const filePromises = files.map((file) => {
|
|
1607
|
+
return new Promise((resolve, reject) => {
|
|
1608
|
+
const reader = new FileReader();
|
|
1609
|
+
reader.onload = () => {
|
|
1610
|
+
try {
|
|
1611
|
+
const base64 = reader.result;
|
|
1612
|
+
if (!base64) {
|
|
1613
|
+
reject(new Error("FileReader returned empty result"));
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
resolve({
|
|
1617
|
+
name: file.name,
|
|
1618
|
+
type: file.type,
|
|
1619
|
+
size: file.size,
|
|
1620
|
+
data: base64
|
|
1621
|
+
});
|
|
1622
|
+
} catch (error) {
|
|
1623
|
+
reject(error);
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
reader.onerror = (error) => {
|
|
1627
|
+
reject(new Error(`Failed to read file ${file.name}: ${error}`));
|
|
1628
|
+
};
|
|
1629
|
+
reader.readAsDataURL(file);
|
|
1630
|
+
});
|
|
1631
|
+
});
|
|
1632
|
+
const convertedFiles = await Promise.all(filePromises);
|
|
1633
|
+
if (onUploadAction) {
|
|
1634
|
+
if (typeof onUploadAction === "function") {
|
|
1635
|
+
await sendEvent(onUploadAction({ files: convertedFiles }));
|
|
1636
|
+
} else {
|
|
1637
|
+
await sendEvent({
|
|
1638
|
+
...onUploadAction,
|
|
1639
|
+
data: {
|
|
1640
|
+
...onUploadAction.data,
|
|
1641
|
+
files: convertedFiles
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
setStatus("success");
|
|
1647
|
+
setTimeout(() => setStatus("idle"), 3e3);
|
|
1648
|
+
} catch (error) {
|
|
1649
|
+
console.error("Upload failed:", error);
|
|
1650
|
+
setStatus("error");
|
|
1651
|
+
setTimeout(() => setStatus("idle"), 3e3);
|
|
1652
|
+
} finally {
|
|
1653
|
+
setIsUploading(false);
|
|
1654
|
+
if (fileInputRef.current) {
|
|
1655
|
+
fileInputRef.current.value = "";
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("relative inline-block", className), style, children: [
|
|
1660
|
+
/* @__PURE__ */ jsx(
|
|
1661
|
+
"input",
|
|
1662
|
+
{
|
|
1663
|
+
type: "file",
|
|
1664
|
+
ref: fileInputRef,
|
|
1665
|
+
onChange: handleFileChange,
|
|
1666
|
+
multiple,
|
|
1667
|
+
accept,
|
|
1668
|
+
className: "hidden",
|
|
1669
|
+
disabled: isUploading
|
|
1670
|
+
}
|
|
1671
|
+
),
|
|
1672
|
+
events.filter((event) => event.type === "files-uploaded" && !!event.ui).map(
|
|
1673
|
+
(event, index) => event.ui ? /* @__PURE__ */ jsx(UIRenderer, { node: event.ui }, index) : null
|
|
1674
|
+
),
|
|
1675
|
+
/* @__PURE__ */ jsxs(
|
|
1676
|
+
Button,
|
|
1677
|
+
{
|
|
1678
|
+
type: "button",
|
|
1679
|
+
disabled: isUploading,
|
|
1680
|
+
onClick: () => fileInputRef.current?.click(),
|
|
1681
|
+
className: "gap-2",
|
|
1682
|
+
variant: status === "error" ? "destructive" : status === "success" ? "outline" : "default",
|
|
1683
|
+
children: [
|
|
1684
|
+
isUploading ? /* @__PURE__ */ jsx(IconLoader2, { className: "h-4 w-4 animate-spin" }) : status === "success" ? /* @__PURE__ */ jsx(IconCheck, { className: "h-4 w-4 text-green-500" }) : status === "error" ? /* @__PURE__ */ jsx(IconX, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(IconUpload, { className: "h-4 w-4" }),
|
|
1685
|
+
status === "success" ? "Uploaded" : status === "error" ? "Failed" : label
|
|
1686
|
+
]
|
|
1687
|
+
}
|
|
1688
|
+
)
|
|
1689
|
+
] });
|
|
1690
|
+
};
|
|
1585
1691
|
var Form = ({
|
|
1586
1692
|
children,
|
|
1587
1693
|
onSubmitAction,
|
|
@@ -1643,6 +1749,7 @@ function UIRenderer({ node }) {
|
|
|
1643
1749
|
heading: Heading,
|
|
1644
1750
|
badge: Badge2,
|
|
1645
1751
|
input: Input2,
|
|
1752
|
+
hidden: Hidden,
|
|
1646
1753
|
textarea: Textarea2,
|
|
1647
1754
|
select: Select2,
|
|
1648
1755
|
checkbox: Checkbox,
|
|
@@ -1656,7 +1763,8 @@ function UIRenderer({ node }) {
|
|
|
1656
1763
|
listItem: ListItem,
|
|
1657
1764
|
form: Form,
|
|
1658
1765
|
chart: Chart,
|
|
1659
|
-
label: Label2
|
|
1766
|
+
label: Label2,
|
|
1767
|
+
upload: Upload
|
|
1660
1768
|
};
|
|
1661
1769
|
const Component = typeMap[type];
|
|
1662
1770
|
if (!Component) {
|
|
@@ -1963,10 +2071,10 @@ var AccountButton = ({
|
|
|
1963
2071
|
size
|
|
1964
2072
|
}) => {
|
|
1965
2073
|
const { isLoading, isAuthenticated, user, login, logout } = useAuth();
|
|
1966
|
-
const [open, setOpen] =
|
|
1967
|
-
const [accountInfoOpen, setAccountInfoOpen] =
|
|
1968
|
-
const [error, setError] =
|
|
1969
|
-
const initials =
|
|
2074
|
+
const [open, setOpen] = React12.useState(false);
|
|
2075
|
+
const [accountInfoOpen, setAccountInfoOpen] = React12.useState(false);
|
|
2076
|
+
const [error, setError] = React12.useState(null);
|
|
2077
|
+
const initials = React12.useMemo(() => {
|
|
1970
2078
|
const name = user?.displayName || user?.name;
|
|
1971
2079
|
if (!name) return "";
|
|
1972
2080
|
return name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
|
|
@@ -2542,13 +2650,13 @@ function Composer({
|
|
|
2542
2650
|
const accept = fileAttachments?.accept;
|
|
2543
2651
|
const maxFiles = fileAttachments?.maxFiles ?? 10;
|
|
2544
2652
|
const maxFileSize = fileAttachments?.maxFileSize ?? 10 * 1024 * 1024;
|
|
2545
|
-
const [selectedOptions, setSelectedOptions] =
|
|
2653
|
+
const [selectedOptions, setSelectedOptions] = React12__default.useState(
|
|
2546
2654
|
() => new Set(defaultSelectedIds)
|
|
2547
2655
|
);
|
|
2548
|
-
const [attachedFiles, setAttachedFiles] =
|
|
2549
|
-
const [previews, setPreviews] =
|
|
2550
|
-
const fileInputRef =
|
|
2551
|
-
|
|
2656
|
+
const [attachedFiles, setAttachedFiles] = React12__default.useState([]);
|
|
2657
|
+
const [previews, setPreviews] = React12__default.useState([]);
|
|
2658
|
+
const fileInputRef = React12__default.useRef(null);
|
|
2659
|
+
React12__default.useEffect(() => {
|
|
2552
2660
|
const newPreviews = attachedFiles.map((file) => ({
|
|
2553
2661
|
name: file.name,
|
|
2554
2662
|
type: file.type,
|
|
@@ -2831,7 +2939,7 @@ function StarterPrompts({
|
|
|
2831
2939
|
}
|
|
2832
2940
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-4 animate-in fade-in slide-in-from-bottom-4 duration-500 mt-auto max-w-2xl", children: [
|
|
2833
2941
|
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: /* @__PURE__ */ jsx("h2", { className: "text-2xl font-semibold tracking-tight", children: "What can I help with today?" }) }),
|
|
2834
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-
|
|
2942
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1 w-full", children: prompts.map((item, index) => /* @__PURE__ */ jsx(
|
|
2835
2943
|
Button2,
|
|
2836
2944
|
{
|
|
2837
2945
|
label: item.label,
|
|
@@ -3119,7 +3227,7 @@ var Dropdown = ({
|
|
|
3119
3227
|
};
|
|
3120
3228
|
var ThreadList = ({ className }) => {
|
|
3121
3229
|
const { threads, activeThreadId, deleteThread } = useThreads();
|
|
3122
|
-
const sortedThreads =
|
|
3230
|
+
const sortedThreads = React12.useMemo(() => {
|
|
3123
3231
|
return [...threads].sort((a, b) => {
|
|
3124
3232
|
const dateA = a.updatedAt ? new Date(a.updatedAt).getTime() : 0;
|
|
3125
3233
|
const dateB = b.updatedAt ? new Date(b.updatedAt).getTime() : 0;
|
|
@@ -3280,7 +3388,7 @@ function Sidebar({ side, children, className }) {
|
|
|
3280
3388
|
collapsed ? "w-0 border-r-0 border-l-0 min-w-0" : "",
|
|
3281
3389
|
!collapsed && className
|
|
3282
3390
|
),
|
|
3283
|
-
children: /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden min-h-0", children })
|
|
3391
|
+
children: /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden min-h-0 flex flex-col", children })
|
|
3284
3392
|
}
|
|
3285
3393
|
);
|
|
3286
3394
|
}
|
|
@@ -3347,11 +3455,11 @@ function SidebarToggle({ side, className }) {
|
|
|
3347
3455
|
}
|
|
3348
3456
|
return null;
|
|
3349
3457
|
}
|
|
3350
|
-
var PopoverContext =
|
|
3458
|
+
var PopoverContext = React12.createContext(
|
|
3351
3459
|
void 0
|
|
3352
3460
|
);
|
|
3353
3461
|
function usePopoverContext() {
|
|
3354
|
-
const context =
|
|
3462
|
+
const context = React12.useContext(PopoverContext);
|
|
3355
3463
|
if (!context) {
|
|
3356
3464
|
throw new Error("Popover components must be used within a Popover");
|
|
3357
3465
|
}
|
|
@@ -3363,10 +3471,10 @@ function Popover({
|
|
|
3363
3471
|
open: controlledOpen,
|
|
3364
3472
|
onOpenChange
|
|
3365
3473
|
}) {
|
|
3366
|
-
const [internalOpen, setInternalOpen] =
|
|
3367
|
-
const triggerRef =
|
|
3474
|
+
const [internalOpen, setInternalOpen] = React12.useState(defaultOpen);
|
|
3475
|
+
const triggerRef = React12.useRef(null);
|
|
3368
3476
|
const open = controlledOpen ?? internalOpen;
|
|
3369
|
-
const setOpen =
|
|
3477
|
+
const setOpen = React12.useCallback(
|
|
3370
3478
|
(newOpen) => {
|
|
3371
3479
|
if (controlledOpen === void 0) {
|
|
3372
3480
|
setInternalOpen(newOpen);
|
|
@@ -3375,7 +3483,7 @@ function Popover({
|
|
|
3375
3483
|
},
|
|
3376
3484
|
[controlledOpen, onOpenChange]
|
|
3377
3485
|
);
|
|
3378
|
-
const value =
|
|
3486
|
+
const value = React12.useMemo(
|
|
3379
3487
|
() => ({
|
|
3380
3488
|
open,
|
|
3381
3489
|
setOpen,
|
|
@@ -3385,15 +3493,15 @@ function Popover({
|
|
|
3385
3493
|
);
|
|
3386
3494
|
return /* @__PURE__ */ jsx(PopoverContext.Provider, { value, children });
|
|
3387
3495
|
}
|
|
3388
|
-
var PopoverTrigger =
|
|
3496
|
+
var PopoverTrigger = React12.forwardRef(
|
|
3389
3497
|
({ asChild, className, children, ...props }, ref) => {
|
|
3390
3498
|
const { setOpen, triggerRef } = usePopoverContext();
|
|
3391
3499
|
const handleClick = (e) => {
|
|
3392
3500
|
setOpen(true);
|
|
3393
3501
|
props.onClick?.(e);
|
|
3394
3502
|
};
|
|
3395
|
-
if (asChild &&
|
|
3396
|
-
return
|
|
3503
|
+
if (asChild && React12.isValidElement(children)) {
|
|
3504
|
+
return React12.cloneElement(children, {
|
|
3397
3505
|
ref: (node) => {
|
|
3398
3506
|
triggerRef.current = node;
|
|
3399
3507
|
if (typeof children.ref === "function") {
|
|
@@ -3425,7 +3533,7 @@ var PopoverTrigger = React11.forwardRef(
|
|
|
3425
3533
|
}
|
|
3426
3534
|
);
|
|
3427
3535
|
PopoverTrigger.displayName = "PopoverTrigger";
|
|
3428
|
-
var PopoverContent =
|
|
3536
|
+
var PopoverContent = React12.forwardRef(
|
|
3429
3537
|
({
|
|
3430
3538
|
className,
|
|
3431
3539
|
side = "bottom",
|
|
@@ -3436,9 +3544,9 @@ var PopoverContent = React11.forwardRef(
|
|
|
3436
3544
|
...props
|
|
3437
3545
|
}, ref) => {
|
|
3438
3546
|
const { open, setOpen, triggerRef } = usePopoverContext();
|
|
3439
|
-
const [position, setPosition] =
|
|
3440
|
-
const contentRef =
|
|
3441
|
-
|
|
3547
|
+
const [position, setPosition] = React12.useState({ top: 0, left: 0 });
|
|
3548
|
+
const contentRef = React12.useRef(null);
|
|
3549
|
+
React12.useEffect(() => {
|
|
3442
3550
|
if (!open || !triggerRef.current) return;
|
|
3443
3551
|
const updatePosition = () => {
|
|
3444
3552
|
if (!triggerRef.current || !contentRef.current) return;
|
|
@@ -3499,7 +3607,7 @@ var PopoverContent = React11.forwardRef(
|
|
|
3499
3607
|
window.removeEventListener("scroll", updatePosition, true);
|
|
3500
3608
|
};
|
|
3501
3609
|
}, [open, side, align, sideOffset, alignOffset, triggerRef]);
|
|
3502
|
-
|
|
3610
|
+
React12.useEffect(() => {
|
|
3503
3611
|
if (!open) return;
|
|
3504
3612
|
const handleClickOutside = (event) => {
|
|
3505
3613
|
if (contentRef.current && !contentRef.current.contains(event.target) && triggerRef.current && !triggerRef.current.contains(event.target)) {
|
|
@@ -3554,7 +3662,7 @@ var ThreadPopover = ({
|
|
|
3554
3662
|
buttonSize = "icon",
|
|
3555
3663
|
emptyState
|
|
3556
3664
|
}) => {
|
|
3557
|
-
const [isOpen, setIsOpen] =
|
|
3665
|
+
const [isOpen, setIsOpen] = React12.useState(false);
|
|
3558
3666
|
useHotkeys(
|
|
3559
3667
|
"h",
|
|
3560
3668
|
(e) => {
|
|
@@ -3597,7 +3705,7 @@ var CreateThreadButton = ({
|
|
|
3597
3705
|
onThreadCreated
|
|
3598
3706
|
}) => {
|
|
3599
3707
|
const { createThread } = useThreads();
|
|
3600
|
-
const [isCreating, setIsCreating] =
|
|
3708
|
+
const [isCreating, setIsCreating] = React12.useState(false);
|
|
3601
3709
|
const handleCreateThread = async () => {
|
|
3602
3710
|
if (isCreating) return;
|
|
3603
3711
|
try {
|
|
@@ -3679,7 +3787,7 @@ var CreateThreadListItem = ({
|
|
|
3679
3787
|
className
|
|
3680
3788
|
}) => {
|
|
3681
3789
|
const { createThread } = useThreads();
|
|
3682
|
-
const [isCreating, setIsCreating] =
|
|
3790
|
+
const [isCreating, setIsCreating] = React12.useState(false);
|
|
3683
3791
|
const handleCreateThread = async () => {
|
|
3684
3792
|
if (isCreating) return;
|
|
3685
3793
|
try {
|
|
@@ -3722,6 +3830,6 @@ var CreateThreadListItem = ({
|
|
|
3722
3830
|
);
|
|
3723
3831
|
};
|
|
3724
3832
|
|
|
3725
|
-
export { AccountButton, AuthContext, AuthProvider, Badge2 as Badge, Box, Button2 as Button, Card2 as Card, Chart, ChatHeader, Checkbox, Col, Composer, CreateThreadButton, CreateThreadListItem, Divider, Dropdown, Form, FullChat, Heading, Image, Input2 as Input, Label2 as Label, List, ListItem, MelonyContext, MelonyProvider, PopupChat, RadioGroup, Row, Select2 as Select, Sidebar, SidebarContext, SidebarProvider, SidebarToggle, Spacer, Text, Textarea2 as Textarea, ThemeProvider, ThemeToggle, Thread, ThreadContext, ThreadList, ThreadPopover, ThreadProvider, UIRenderer, WelcomeScreen, useAuth, useMelony, useScreenSize, useSidebar, useTheme, useThreads };
|
|
3833
|
+
export { AccountButton, AuthContext, AuthProvider, Badge2 as Badge, Box, Button2 as Button, Card2 as Card, Chart, ChatHeader, Checkbox, Col, Composer, CreateThreadButton, CreateThreadListItem, Divider, Dropdown, Form, FullChat, Heading, Image, Input2 as Input, Label2 as Label, List, ListItem, MelonyContext, MelonyProvider, PopupChat, RadioGroup, Row, Select2 as Select, Sidebar, SidebarContext, SidebarProvider, SidebarToggle, Spacer, Text, Textarea2 as Textarea, ThemeProvider, ThemeToggle, Thread, ThreadContext, ThreadList, ThreadPopover, ThreadProvider, UIRenderer, Upload, WelcomeScreen, useAuth, useMelony, useScreenSize, useSidebar, useTheme, useThreads };
|
|
3726
3834
|
//# sourceMappingURL=index.js.map
|
|
3727
3835
|
//# sourceMappingURL=index.js.map
|