@melony/react 0.1.39 → 0.1.40
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 -30
- 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 -31
- 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';
|
|
@@ -1734,12 +1734,39 @@ var Image = ({
|
|
|
1734
1734
|
src,
|
|
1735
1735
|
alt,
|
|
1736
1736
|
size = "sm",
|
|
1737
|
+
groupId,
|
|
1737
1738
|
className,
|
|
1738
1739
|
style
|
|
1739
1740
|
}) => {
|
|
1740
1741
|
const [hasError, setHasError] = useState(false);
|
|
1741
1742
|
const [isLoading, setIsLoading] = useState(true);
|
|
1742
1743
|
const [open, setOpen] = useState(false);
|
|
1744
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
1745
|
+
const [gallery, setGallery] = useState([]);
|
|
1746
|
+
const triggerRef = useRef(null);
|
|
1747
|
+
useEffect(() => {
|
|
1748
|
+
if (open && triggerRef.current) {
|
|
1749
|
+
let parent = triggerRef.current.parentElement;
|
|
1750
|
+
while (parent && parent.parentElement && parent.parentElement.children.length === 1) {
|
|
1751
|
+
parent = parent.parentElement;
|
|
1752
|
+
}
|
|
1753
|
+
const container = parent?.parentElement;
|
|
1754
|
+
if (container) {
|
|
1755
|
+
const foundImgs = Array.from(container.querySelectorAll("img")).map((img) => ({
|
|
1756
|
+
src: img.getAttribute("src") || "",
|
|
1757
|
+
alt: img.getAttribute("alt") || ""
|
|
1758
|
+
})).filter((v, i, a) => a.findIndex((t) => t.src === v.src) === i);
|
|
1759
|
+
setGallery(foundImgs);
|
|
1760
|
+
const idx = foundImgs.findIndex((img) => img.src === src);
|
|
1761
|
+
setCurrentIndex(idx >= 0 ? idx : 0);
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}, [open, src]);
|
|
1765
|
+
const navigate = (dir) => {
|
|
1766
|
+
setCurrentIndex((prev) => (prev + dir + gallery.length) % gallery.length);
|
|
1767
|
+
};
|
|
1768
|
+
const currentImage = gallery[currentIndex] || { src, alt };
|
|
1769
|
+
const hasMultiple = gallery.length > 1;
|
|
1743
1770
|
const sizes = {
|
|
1744
1771
|
sm: "h-11",
|
|
1745
1772
|
md: "h-22",
|
|
@@ -1770,7 +1797,11 @@ var Image = ({
|
|
|
1770
1797
|
/* @__PURE__ */ jsx(DialogTrigger, { children: /* @__PURE__ */ jsxs(
|
|
1771
1798
|
"div",
|
|
1772
1799
|
{
|
|
1773
|
-
|
|
1800
|
+
ref: triggerRef,
|
|
1801
|
+
className: cn(
|
|
1802
|
+
"relative overflow-hidden rounded-md border cursor-pointer",
|
|
1803
|
+
className
|
|
1804
|
+
),
|
|
1774
1805
|
style,
|
|
1775
1806
|
children: [
|
|
1776
1807
|
/* @__PURE__ */ jsx(
|
|
@@ -1794,36 +1825,47 @@ var Image = ({
|
|
|
1794
1825
|
/* @__PURE__ */ jsx(
|
|
1795
1826
|
DialogContent,
|
|
1796
1827
|
{
|
|
1797
|
-
className: "max-w-[90vw] max-h-[90vh] p-0 bg-transparent border-none shadow-none",
|
|
1828
|
+
className: "max-w-[90vw] max-h-[90vh] p-0 bg-transparent border-none shadow-none outline-none",
|
|
1798
1829
|
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
|
-
|
|
1830
|
+
children: /* @__PURE__ */ jsxs("div", { className: "relative flex items-center justify-center group/lightbox", children: [
|
|
1831
|
+
/* @__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 }) }),
|
|
1832
|
+
hasMultiple && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1833
|
+
/* @__PURE__ */ jsx(
|
|
1834
|
+
"button",
|
|
1835
|
+
{
|
|
1836
|
+
onClick: (e) => {
|
|
1837
|
+
e.stopPropagation();
|
|
1838
|
+
navigate(-1);
|
|
1839
|
+
},
|
|
1840
|
+
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",
|
|
1841
|
+
children: /* @__PURE__ */ jsx(IconChevronLeft, { size: 28 })
|
|
1842
|
+
}
|
|
1843
|
+
),
|
|
1844
|
+
/* @__PURE__ */ jsx(
|
|
1845
|
+
"button",
|
|
1846
|
+
{
|
|
1847
|
+
onClick: (e) => {
|
|
1848
|
+
e.stopPropagation();
|
|
1849
|
+
navigate(1);
|
|
1850
|
+
},
|
|
1851
|
+
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",
|
|
1852
|
+
children: /* @__PURE__ */ jsx(IconChevronRight, { size: 28 })
|
|
1853
|
+
}
|
|
1854
|
+
)
|
|
1855
|
+
] }),
|
|
1819
1856
|
/* @__PURE__ */ jsx(
|
|
1820
1857
|
"img",
|
|
1821
1858
|
{
|
|
1822
|
-
src,
|
|
1823
|
-
alt: alt || "Enlarged image",
|
|
1824
|
-
className: "max-w-full max-h-[
|
|
1859
|
+
src: currentImage.src,
|
|
1860
|
+
alt: currentImage.alt || alt || "Enlarged image",
|
|
1861
|
+
className: "max-w-full max-h-[85vh] object-contain rounded-lg shadow-2xl"
|
|
1825
1862
|
}
|
|
1826
|
-
)
|
|
1863
|
+
),
|
|
1864
|
+
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: [
|
|
1865
|
+
currentIndex + 1,
|
|
1866
|
+
" / ",
|
|
1867
|
+
gallery.length
|
|
1868
|
+
] })
|
|
1827
1869
|
] })
|
|
1828
1870
|
}
|
|
1829
1871
|
)
|
|
@@ -2837,7 +2879,6 @@ function MessageList({
|
|
|
2837
2879
|
const lastMessage = messages[messages.length - 1];
|
|
2838
2880
|
return lastMessage.content.some((event) => event.type === "text-delta");
|
|
2839
2881
|
}, [messages, isLoading]);
|
|
2840
|
-
console.log("MESSAGES", messages);
|
|
2841
2882
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
2842
2883
|
messages.map((message, index) => /* @__PURE__ */ jsx(MessageBubble, { message }, index)),
|
|
2843
2884
|
isLoading && !isTextStreaming && /* @__PURE__ */ jsx(LoadingIndicator, { status: loadingStatus }),
|
|
@@ -2877,8 +2918,7 @@ function Thread({
|
|
|
2877
2918
|
const handleSubmit = async (state, overrideInput) => {
|
|
2878
2919
|
const text = (overrideInput ?? input).trim();
|
|
2879
2920
|
const hasFiles = state?.files && Array.isArray(state.files) && state.files.length > 0;
|
|
2880
|
-
|
|
2881
|
-
if (!text && !hasFiles && !hasOptions || isLoading) return;
|
|
2921
|
+
if (!text && !hasFiles || isLoading) return;
|
|
2882
2922
|
if (!overrideInput) setInput("");
|
|
2883
2923
|
await sendEvent({
|
|
2884
2924
|
type: "text",
|
|
@@ -3611,7 +3651,7 @@ var CreateThreadNavItem = ({
|
|
|
3611
3651
|
url: "?"
|
|
3612
3652
|
}
|
|
3613
3653
|
},
|
|
3614
|
-
className: cn(className),
|
|
3654
|
+
className: cn(className, "border roudned-lg"),
|
|
3615
3655
|
children: [
|
|
3616
3656
|
/* @__PURE__ */ jsx(IconPlus, { className: "size-4" }),
|
|
3617
3657
|
"New chat"
|