@melony/react 0.1.39 → 0.1.41
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 +70 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +71 -32
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -394,6 +394,7 @@ type ListItemProps = BaseComponentProps & UIContract["listItem"] & {
|
|
|
394
394
|
type ImageProps = BaseComponentProps & UIContract["image"] & {
|
|
395
395
|
fallbackText?: string;
|
|
396
396
|
showFallbackIcon?: boolean;
|
|
397
|
+
groupId?: string;
|
|
397
398
|
};
|
|
398
399
|
type ChartProps = BaseComponentProps & UIContract["chart"] & {
|
|
399
400
|
size?: Size;
|
package/dist/index.d.ts
CHANGED
|
@@ -394,6 +394,7 @@ type ListItemProps = BaseComponentProps & UIContract["listItem"] & {
|
|
|
394
394
|
type ImageProps = BaseComponentProps & UIContract["image"] & {
|
|
395
395
|
fallbackText?: string;
|
|
396
396
|
showFallbackIcon?: boolean;
|
|
397
|
+
groupId?: string;
|
|
397
398
|
};
|
|
398
399
|
type ChartProps = BaseComponentProps & UIContract["chart"] & {
|
|
399
400
|
size?: Size;
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { Dialog as Dialog$1 } from '@base-ui/react/dialog';
|
|
|
10
10
|
import { Button as Button$1 } from '@base-ui/react/button';
|
|
11
11
|
import { cva } from 'class-variance-authority';
|
|
12
12
|
import * as ICONS from '@tabler/icons-react';
|
|
13
|
-
import { IconUser, IconLogout, IconX, IconBrandGoogle, IconFileText, IconFile, IconPaperclip, IconChevronDown, IconLoader2, IconArrowUp, IconDotsVertical, IconTrash, IconHistory, IconPlus, IconArrowLeft, IconMessage, IconLayoutSidebarLeftExpand, IconLayoutSidebarLeftCollapse, IconLayoutSidebarRightExpand, IconLayoutSidebarRightCollapse, IconDeviceDesktop, IconMoon, IconSun, IconCheck, IconSelector, IconChevronUp } from '@tabler/icons-react';
|
|
13
|
+
import { IconUser, IconLogout, IconX, IconBrandGoogle, IconFileText, IconFile, IconPaperclip, IconChevronDown, IconLoader2, IconArrowUp, IconChevronLeft, IconChevronRight, IconDotsVertical, IconTrash, IconHistory, IconPlus, IconArrowLeft, IconMessage, IconLayoutSidebarLeftExpand, IconLayoutSidebarLeftCollapse, IconLayoutSidebarRightExpand, IconLayoutSidebarRightCollapse, IconDeviceDesktop, IconMoon, IconSun, IconCheck, IconSelector, IconChevronUp } from '@tabler/icons-react';
|
|
14
14
|
import { Menu } from '@base-ui/react/menu';
|
|
15
15
|
import { Separator as Separator$1 } from '@base-ui/react/separator';
|
|
16
16
|
import { useQueryState, parseAsString } from 'nuqs';
|
|
@@ -784,7 +784,6 @@ var ThreadProvider = ({
|
|
|
784
784
|
return null;
|
|
785
785
|
},
|
|
786
786
|
onSuccess: async () => {
|
|
787
|
-
await queryClient.invalidateQueries({ queryKey: ["threads"] });
|
|
788
787
|
await setActiveThreadId(null);
|
|
789
788
|
}
|
|
790
789
|
});
|
|
@@ -1734,12 +1733,39 @@ var Image = ({
|
|
|
1734
1733
|
src,
|
|
1735
1734
|
alt,
|
|
1736
1735
|
size = "sm",
|
|
1736
|
+
groupId,
|
|
1737
1737
|
className,
|
|
1738
1738
|
style
|
|
1739
1739
|
}) => {
|
|
1740
1740
|
const [hasError, setHasError] = useState(false);
|
|
1741
1741
|
const [isLoading, setIsLoading] = useState(true);
|
|
1742
1742
|
const [open, setOpen] = useState(false);
|
|
1743
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
1744
|
+
const [gallery, setGallery] = useState([]);
|
|
1745
|
+
const triggerRef = useRef(null);
|
|
1746
|
+
useEffect(() => {
|
|
1747
|
+
if (open && triggerRef.current) {
|
|
1748
|
+
let parent = triggerRef.current.parentElement;
|
|
1749
|
+
while (parent && parent.parentElement && parent.parentElement.children.length === 1) {
|
|
1750
|
+
parent = parent.parentElement;
|
|
1751
|
+
}
|
|
1752
|
+
const container = parent?.parentElement;
|
|
1753
|
+
if (container) {
|
|
1754
|
+
const foundImgs = Array.from(container.querySelectorAll("img")).map((img) => ({
|
|
1755
|
+
src: img.getAttribute("src") || "",
|
|
1756
|
+
alt: img.getAttribute("alt") || ""
|
|
1757
|
+
})).filter((v, i, a) => a.findIndex((t) => t.src === v.src) === i);
|
|
1758
|
+
setGallery(foundImgs);
|
|
1759
|
+
const idx = foundImgs.findIndex((img) => img.src === src);
|
|
1760
|
+
setCurrentIndex(idx >= 0 ? idx : 0);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
}, [open, src]);
|
|
1764
|
+
const navigate = (dir) => {
|
|
1765
|
+
setCurrentIndex((prev) => (prev + dir + gallery.length) % gallery.length);
|
|
1766
|
+
};
|
|
1767
|
+
const currentImage = gallery[currentIndex] || { src, alt };
|
|
1768
|
+
const hasMultiple = gallery.length > 1;
|
|
1743
1769
|
const sizes = {
|
|
1744
1770
|
sm: "h-11",
|
|
1745
1771
|
md: "h-22",
|
|
@@ -1770,7 +1796,11 @@ var Image = ({
|
|
|
1770
1796
|
/* @__PURE__ */ jsx(DialogTrigger, { children: /* @__PURE__ */ jsxs(
|
|
1771
1797
|
"div",
|
|
1772
1798
|
{
|
|
1773
|
-
|
|
1799
|
+
ref: triggerRef,
|
|
1800
|
+
className: cn(
|
|
1801
|
+
"relative overflow-hidden rounded-md border cursor-pointer",
|
|
1802
|
+
className
|
|
1803
|
+
),
|
|
1774
1804
|
style,
|
|
1775
1805
|
children: [
|
|
1776
1806
|
/* @__PURE__ */ jsx(
|
|
@@ -1794,36 +1824,47 @@ var Image = ({
|
|
|
1794
1824
|
/* @__PURE__ */ jsx(
|
|
1795
1825
|
DialogContent,
|
|
1796
1826
|
{
|
|
1797
|
-
className: "max-w-[90vw] max-h-[90vh] p-0 bg-transparent border-none shadow-none",
|
|
1827
|
+
className: "max-w-[90vw] max-h-[90vh] p-0 bg-transparent border-none shadow-none outline-none",
|
|
1798
1828
|
onClick: (e) => e.stopPropagation(),
|
|
1799
|
-
children: /* @__PURE__ */ jsxs("div", { className: "relative flex items-center justify-center", children: [
|
|
1800
|
-
/* @__PURE__ */ jsx(DialogClose, { className: "absolute -top-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
"
|
|
1810
|
-
{
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1829
|
+
children: /* @__PURE__ */ jsxs("div", { className: "relative flex items-center justify-center group/lightbox", children: [
|
|
1830
|
+
/* @__PURE__ */ jsx(DialogClose, { className: "absolute -top-12 right-0 text-white hover:text-gray-300 transition-colors z-50 bg-black/50 rounded-full p-2", children: /* @__PURE__ */ jsx(IconX, { size: 20 }) }),
|
|
1831
|
+
hasMultiple && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1832
|
+
/* @__PURE__ */ jsx(
|
|
1833
|
+
"button",
|
|
1834
|
+
{
|
|
1835
|
+
onClick: (e) => {
|
|
1836
|
+
e.stopPropagation();
|
|
1837
|
+
navigate(-1);
|
|
1838
|
+
},
|
|
1839
|
+
className: "absolute left-4 z-50 p-3 bg-black/40 hover:bg-black/60 text-white rounded-full transition-all opacity-0 group-hover/lightbox:opacity-100",
|
|
1840
|
+
children: /* @__PURE__ */ jsx(IconChevronLeft, { size: 28 })
|
|
1841
|
+
}
|
|
1842
|
+
),
|
|
1843
|
+
/* @__PURE__ */ jsx(
|
|
1844
|
+
"button",
|
|
1845
|
+
{
|
|
1846
|
+
onClick: (e) => {
|
|
1847
|
+
e.stopPropagation();
|
|
1848
|
+
navigate(1);
|
|
1849
|
+
},
|
|
1850
|
+
className: "absolute right-4 z-50 p-3 bg-black/40 hover:bg-black/60 text-white rounded-full transition-all opacity-0 group-hover/lightbox:opacity-100",
|
|
1851
|
+
children: /* @__PURE__ */ jsx(IconChevronRight, { size: 28 })
|
|
1852
|
+
}
|
|
1853
|
+
)
|
|
1854
|
+
] }),
|
|
1819
1855
|
/* @__PURE__ */ jsx(
|
|
1820
1856
|
"img",
|
|
1821
1857
|
{
|
|
1822
|
-
src,
|
|
1823
|
-
alt: alt || "Enlarged image",
|
|
1824
|
-
className: "max-w-full max-h-[
|
|
1858
|
+
src: currentImage.src,
|
|
1859
|
+
alt: currentImage.alt || alt || "Enlarged image",
|
|
1860
|
+
className: "max-w-full max-h-[85vh] object-contain rounded-lg shadow-2xl"
|
|
1825
1861
|
}
|
|
1826
|
-
)
|
|
1862
|
+
),
|
|
1863
|
+
hasMultiple && /* @__PURE__ */ jsxs("div", { className: "absolute -bottom-10 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm font-medium", children: [
|
|
1864
|
+
currentIndex + 1,
|
|
1865
|
+
" / ",
|
|
1866
|
+
gallery.length
|
|
1867
|
+
] })
|
|
1827
1868
|
] })
|
|
1828
1869
|
}
|
|
1829
1870
|
)
|
|
@@ -2837,7 +2878,6 @@ function MessageList({
|
|
|
2837
2878
|
const lastMessage = messages[messages.length - 1];
|
|
2838
2879
|
return lastMessage.content.some((event) => event.type === "text-delta");
|
|
2839
2880
|
}, [messages, isLoading]);
|
|
2840
|
-
console.log("MESSAGES", messages);
|
|
2841
2881
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
2842
2882
|
messages.map((message, index) => /* @__PURE__ */ jsx(MessageBubble, { message }, index)),
|
|
2843
2883
|
isLoading && !isTextStreaming && /* @__PURE__ */ jsx(LoadingIndicator, { status: loadingStatus }),
|
|
@@ -2877,8 +2917,7 @@ function Thread({
|
|
|
2877
2917
|
const handleSubmit = async (state, overrideInput) => {
|
|
2878
2918
|
const text = (overrideInput ?? input).trim();
|
|
2879
2919
|
const hasFiles = state?.files && Array.isArray(state.files) && state.files.length > 0;
|
|
2880
|
-
|
|
2881
|
-
if (!text && !hasFiles && !hasOptions || isLoading) return;
|
|
2920
|
+
if (!text && !hasFiles || isLoading) return;
|
|
2882
2921
|
if (!overrideInput) setInput("");
|
|
2883
2922
|
await sendEvent({
|
|
2884
2923
|
type: "text",
|
|
@@ -3611,7 +3650,7 @@ var CreateThreadNavItem = ({
|
|
|
3611
3650
|
url: "?"
|
|
3612
3651
|
}
|
|
3613
3652
|
},
|
|
3614
|
-
className: cn(className),
|
|
3653
|
+
className: cn(className, "border roudned-lg"),
|
|
3615
3654
|
children: [
|
|
3616
3655
|
/* @__PURE__ */ jsx(IconPlus, { className: "size-4" }),
|
|
3617
3656
|
"New chat"
|