@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.cjs
CHANGED
|
@@ -1755,12 +1755,39 @@ var Image = ({
|
|
|
1755
1755
|
src,
|
|
1756
1756
|
alt,
|
|
1757
1757
|
size = "sm",
|
|
1758
|
+
groupId,
|
|
1758
1759
|
className,
|
|
1759
1760
|
style
|
|
1760
1761
|
}) => {
|
|
1761
1762
|
const [hasError, setHasError] = React11.useState(false);
|
|
1762
1763
|
const [isLoading, setIsLoading] = React11.useState(true);
|
|
1763
1764
|
const [open, setOpen] = React11.useState(false);
|
|
1765
|
+
const [currentIndex, setCurrentIndex] = React11.useState(0);
|
|
1766
|
+
const [gallery, setGallery] = React11.useState([]);
|
|
1767
|
+
const triggerRef = React11.useRef(null);
|
|
1768
|
+
React11.useEffect(() => {
|
|
1769
|
+
if (open && triggerRef.current) {
|
|
1770
|
+
let parent = triggerRef.current.parentElement;
|
|
1771
|
+
while (parent && parent.parentElement && parent.parentElement.children.length === 1) {
|
|
1772
|
+
parent = parent.parentElement;
|
|
1773
|
+
}
|
|
1774
|
+
const container = parent?.parentElement;
|
|
1775
|
+
if (container) {
|
|
1776
|
+
const foundImgs = Array.from(container.querySelectorAll("img")).map((img) => ({
|
|
1777
|
+
src: img.getAttribute("src") || "",
|
|
1778
|
+
alt: img.getAttribute("alt") || ""
|
|
1779
|
+
})).filter((v, i, a) => a.findIndex((t) => t.src === v.src) === i);
|
|
1780
|
+
setGallery(foundImgs);
|
|
1781
|
+
const idx = foundImgs.findIndex((img) => img.src === src);
|
|
1782
|
+
setCurrentIndex(idx >= 0 ? idx : 0);
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
}, [open, src]);
|
|
1786
|
+
const navigate = (dir) => {
|
|
1787
|
+
setCurrentIndex((prev) => (prev + dir + gallery.length) % gallery.length);
|
|
1788
|
+
};
|
|
1789
|
+
const currentImage = gallery[currentIndex] || { src, alt };
|
|
1790
|
+
const hasMultiple = gallery.length > 1;
|
|
1764
1791
|
const sizes = {
|
|
1765
1792
|
sm: "h-11",
|
|
1766
1793
|
md: "h-22",
|
|
@@ -1791,7 +1818,11 @@ var Image = ({
|
|
|
1791
1818
|
/* @__PURE__ */ jsxRuntime.jsx(DialogTrigger, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1792
1819
|
"div",
|
|
1793
1820
|
{
|
|
1794
|
-
|
|
1821
|
+
ref: triggerRef,
|
|
1822
|
+
className: cn(
|
|
1823
|
+
"relative overflow-hidden rounded-md border cursor-pointer",
|
|
1824
|
+
className
|
|
1825
|
+
),
|
|
1795
1826
|
style,
|
|
1796
1827
|
children: [
|
|
1797
1828
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1815,36 +1846,47 @@ var Image = ({
|
|
|
1815
1846
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1816
1847
|
DialogContent,
|
|
1817
1848
|
{
|
|
1818
|
-
className: "max-w-[90vw] max-h-[90vh] p-0 bg-transparent border-none shadow-none",
|
|
1849
|
+
className: "max-w-[90vw] max-h-[90vh] p-0 bg-transparent border-none shadow-none outline-none",
|
|
1819
1850
|
onClick: (e) => e.stopPropagation(),
|
|
1820
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex items-center justify-center", children: [
|
|
1821
|
-
/* @__PURE__ */ jsxRuntime.jsx(DialogClose, { className: "absolute -top-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
"
|
|
1831
|
-
{
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1851
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex items-center justify-center group/lightbox", children: [
|
|
1852
|
+
/* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(ICONS.IconX, { size: 20 }) }),
|
|
1853
|
+
hasMultiple && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1854
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1855
|
+
"button",
|
|
1856
|
+
{
|
|
1857
|
+
onClick: (e) => {
|
|
1858
|
+
e.stopPropagation();
|
|
1859
|
+
navigate(-1);
|
|
1860
|
+
},
|
|
1861
|
+
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",
|
|
1862
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconChevronLeft, { size: 28 })
|
|
1863
|
+
}
|
|
1864
|
+
),
|
|
1865
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1866
|
+
"button",
|
|
1867
|
+
{
|
|
1868
|
+
onClick: (e) => {
|
|
1869
|
+
e.stopPropagation();
|
|
1870
|
+
navigate(1);
|
|
1871
|
+
},
|
|
1872
|
+
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",
|
|
1873
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ICONS.IconChevronRight, { size: 28 })
|
|
1874
|
+
}
|
|
1875
|
+
)
|
|
1876
|
+
] }),
|
|
1840
1877
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1841
1878
|
"img",
|
|
1842
1879
|
{
|
|
1843
|
-
src,
|
|
1844
|
-
alt: alt || "Enlarged image",
|
|
1845
|
-
className: "max-w-full max-h-[
|
|
1880
|
+
src: currentImage.src,
|
|
1881
|
+
alt: currentImage.alt || alt || "Enlarged image",
|
|
1882
|
+
className: "max-w-full max-h-[85vh] object-contain rounded-lg shadow-2xl"
|
|
1846
1883
|
}
|
|
1847
|
-
)
|
|
1884
|
+
),
|
|
1885
|
+
hasMultiple && /* @__PURE__ */ jsxRuntime.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: [
|
|
1886
|
+
currentIndex + 1,
|
|
1887
|
+
" / ",
|
|
1888
|
+
gallery.length
|
|
1889
|
+
] })
|
|
1848
1890
|
] })
|
|
1849
1891
|
}
|
|
1850
1892
|
)
|
|
@@ -2858,7 +2900,6 @@ function MessageList({
|
|
|
2858
2900
|
const lastMessage = messages[messages.length - 1];
|
|
2859
2901
|
return lastMessage.content.some((event) => event.type === "text-delta");
|
|
2860
2902
|
}, [messages, isLoading]);
|
|
2861
|
-
console.log("MESSAGES", messages);
|
|
2862
2903
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
|
|
2863
2904
|
messages.map((message, index) => /* @__PURE__ */ jsxRuntime.jsx(MessageBubble, { message }, index)),
|
|
2864
2905
|
isLoading && !isTextStreaming && /* @__PURE__ */ jsxRuntime.jsx(LoadingIndicator, { status: loadingStatus }),
|
|
@@ -2898,8 +2939,7 @@ function Thread({
|
|
|
2898
2939
|
const handleSubmit = async (state, overrideInput) => {
|
|
2899
2940
|
const text = (overrideInput ?? input).trim();
|
|
2900
2941
|
const hasFiles = state?.files && Array.isArray(state.files) && state.files.length > 0;
|
|
2901
|
-
|
|
2902
|
-
if (!text && !hasFiles && !hasOptions || isLoading) return;
|
|
2942
|
+
if (!text && !hasFiles || isLoading) return;
|
|
2903
2943
|
if (!overrideInput) setInput("");
|
|
2904
2944
|
await sendEvent({
|
|
2905
2945
|
type: "text",
|
|
@@ -3632,7 +3672,7 @@ var CreateThreadNavItem = ({
|
|
|
3632
3672
|
url: "?"
|
|
3633
3673
|
}
|
|
3634
3674
|
},
|
|
3635
|
-
className: cn(className),
|
|
3675
|
+
className: cn(className, "border roudned-lg"),
|
|
3636
3676
|
children: [
|
|
3637
3677
|
/* @__PURE__ */ jsxRuntime.jsx(ICONS.IconPlus, { className: "size-4" }),
|
|
3638
3678
|
"New chat"
|