@melony/react 0.1.16 → 0.1.21
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 +85 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -24
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as React10 from 'react';
|
|
2
|
+
import React10__default, { createContext, useState, useEffect, useCallback, useMemo, useContext, useRef } from 'react';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { generateId } from 'melony/client';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
@@ -552,7 +552,7 @@ function Composer({
|
|
|
552
552
|
autoFocus = false,
|
|
553
553
|
defaultSelectedIds = []
|
|
554
554
|
}) {
|
|
555
|
-
const [selectedOptions, setSelectedOptions] =
|
|
555
|
+
const [selectedOptions, setSelectedOptions] = React10__default.useState(
|
|
556
556
|
() => new Set(defaultSelectedIds)
|
|
557
557
|
);
|
|
558
558
|
const toggleOption = (id, groupOptions, type = "multiple") => {
|
|
@@ -2292,7 +2292,12 @@ function LoadingIndicator({ status }) {
|
|
|
2292
2292
|
function ErrorDisplay({ error }) {
|
|
2293
2293
|
return /* @__PURE__ */ jsx("div", { className: "text-destructive p-2 border border-destructive rounded-md bg-destructive/10", children: error.message });
|
|
2294
2294
|
}
|
|
2295
|
-
function MessageList({
|
|
2295
|
+
function MessageList({
|
|
2296
|
+
messages,
|
|
2297
|
+
isLoading,
|
|
2298
|
+
error,
|
|
2299
|
+
loadingStatus
|
|
2300
|
+
}) {
|
|
2296
2301
|
if (messages.length === 0) {
|
|
2297
2302
|
return null;
|
|
2298
2303
|
}
|
|
@@ -2301,6 +2306,7 @@ function MessageList({ messages, isLoading, error, loadingStatus }) {
|
|
|
2301
2306
|
const lastMessage = messages[messages.length - 1];
|
|
2302
2307
|
return lastMessage.content.some((event) => event.type === "text-delta");
|
|
2303
2308
|
}, [messages, isLoading]);
|
|
2309
|
+
console.log("MESSAGES", messages);
|
|
2304
2310
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
2305
2311
|
messages.map((message, index) => /* @__PURE__ */ jsx(MessageBubble, { message }, index)),
|
|
2306
2312
|
isLoading && !isTextStreaming && /* @__PURE__ */ jsx(LoadingIndicator, { status: loadingStatus }),
|
|
@@ -2767,11 +2773,11 @@ function ChatFull({
|
|
|
2767
2773
|
] })
|
|
2768
2774
|
] });
|
|
2769
2775
|
}
|
|
2770
|
-
var PopoverContext =
|
|
2776
|
+
var PopoverContext = React10.createContext(
|
|
2771
2777
|
void 0
|
|
2772
2778
|
);
|
|
2773
2779
|
function usePopoverContext() {
|
|
2774
|
-
const context =
|
|
2780
|
+
const context = React10.useContext(PopoverContext);
|
|
2775
2781
|
if (!context) {
|
|
2776
2782
|
throw new Error("Popover components must be used within a Popover");
|
|
2777
2783
|
}
|
|
@@ -2783,10 +2789,10 @@ function Popover({
|
|
|
2783
2789
|
open: controlledOpen,
|
|
2784
2790
|
onOpenChange
|
|
2785
2791
|
}) {
|
|
2786
|
-
const [internalOpen, setInternalOpen] =
|
|
2787
|
-
const triggerRef =
|
|
2792
|
+
const [internalOpen, setInternalOpen] = React10.useState(defaultOpen);
|
|
2793
|
+
const triggerRef = React10.useRef(null);
|
|
2788
2794
|
const open = controlledOpen ?? internalOpen;
|
|
2789
|
-
const setOpen =
|
|
2795
|
+
const setOpen = React10.useCallback(
|
|
2790
2796
|
(newOpen) => {
|
|
2791
2797
|
if (controlledOpen === void 0) {
|
|
2792
2798
|
setInternalOpen(newOpen);
|
|
@@ -2795,7 +2801,7 @@ function Popover({
|
|
|
2795
2801
|
},
|
|
2796
2802
|
[controlledOpen, onOpenChange]
|
|
2797
2803
|
);
|
|
2798
|
-
const value =
|
|
2804
|
+
const value = React10.useMemo(
|
|
2799
2805
|
() => ({
|
|
2800
2806
|
open,
|
|
2801
2807
|
setOpen,
|
|
@@ -2805,15 +2811,15 @@ function Popover({
|
|
|
2805
2811
|
);
|
|
2806
2812
|
return /* @__PURE__ */ jsx(PopoverContext.Provider, { value, children });
|
|
2807
2813
|
}
|
|
2808
|
-
var PopoverTrigger =
|
|
2814
|
+
var PopoverTrigger = React10.forwardRef(
|
|
2809
2815
|
({ asChild, className, children, ...props }, ref) => {
|
|
2810
2816
|
const { setOpen, triggerRef } = usePopoverContext();
|
|
2811
2817
|
const handleClick = (e) => {
|
|
2812
2818
|
setOpen(true);
|
|
2813
2819
|
props.onClick?.(e);
|
|
2814
2820
|
};
|
|
2815
|
-
if (asChild &&
|
|
2816
|
-
return
|
|
2821
|
+
if (asChild && React10.isValidElement(children)) {
|
|
2822
|
+
return React10.cloneElement(children, {
|
|
2817
2823
|
ref: (node) => {
|
|
2818
2824
|
triggerRef.current = node;
|
|
2819
2825
|
if (typeof children.ref === "function") {
|
|
@@ -2845,7 +2851,7 @@ var PopoverTrigger = React11.forwardRef(
|
|
|
2845
2851
|
}
|
|
2846
2852
|
);
|
|
2847
2853
|
PopoverTrigger.displayName = "PopoverTrigger";
|
|
2848
|
-
var PopoverContent =
|
|
2854
|
+
var PopoverContent = React10.forwardRef(
|
|
2849
2855
|
({
|
|
2850
2856
|
className,
|
|
2851
2857
|
side = "bottom",
|
|
@@ -2856,9 +2862,9 @@ var PopoverContent = React11.forwardRef(
|
|
|
2856
2862
|
...props
|
|
2857
2863
|
}, ref) => {
|
|
2858
2864
|
const { open, setOpen, triggerRef } = usePopoverContext();
|
|
2859
|
-
const [position, setPosition] =
|
|
2860
|
-
const contentRef =
|
|
2861
|
-
|
|
2865
|
+
const [position, setPosition] = React10.useState({ top: 0, left: 0 });
|
|
2866
|
+
const contentRef = React10.useRef(null);
|
|
2867
|
+
React10.useEffect(() => {
|
|
2862
2868
|
if (!open || !triggerRef.current) return;
|
|
2863
2869
|
const updatePosition = () => {
|
|
2864
2870
|
if (!triggerRef.current || !contentRef.current) return;
|
|
@@ -2919,7 +2925,7 @@ var PopoverContent = React11.forwardRef(
|
|
|
2919
2925
|
window.removeEventListener("scroll", updatePosition, true);
|
|
2920
2926
|
};
|
|
2921
2927
|
}, [open, side, align, sideOffset, alignOffset, triggerRef]);
|
|
2922
|
-
|
|
2928
|
+
React10.useEffect(() => {
|
|
2923
2929
|
if (!open) return;
|
|
2924
2930
|
const handleClickOutside = (event) => {
|
|
2925
2931
|
if (contentRef.current && !contentRef.current.contains(event.target) && triggerRef.current && !triggerRef.current.contains(event.target)) {
|
|
@@ -2975,7 +2981,7 @@ var ThreadPopover = ({
|
|
|
2975
2981
|
emptyState,
|
|
2976
2982
|
onThreadSelect
|
|
2977
2983
|
}) => {
|
|
2978
|
-
const [isOpen, setIsOpen] =
|
|
2984
|
+
const [isOpen, setIsOpen] = React10.useState(false);
|
|
2979
2985
|
useHotkeys(
|
|
2980
2986
|
"h",
|
|
2981
2987
|
(e) => {
|
|
@@ -3030,7 +3036,7 @@ var CreateThreadButton = ({
|
|
|
3030
3036
|
onThreadCreated
|
|
3031
3037
|
}) => {
|
|
3032
3038
|
const { createThread } = useThreads();
|
|
3033
|
-
const [isCreating, setIsCreating] =
|
|
3039
|
+
const [isCreating, setIsCreating] = React10.useState(false);
|
|
3034
3040
|
const handleCreateThread = async () => {
|
|
3035
3041
|
if (isCreating) return;
|
|
3036
3042
|
try {
|
|
@@ -3156,10 +3162,10 @@ var AccountDialog = ({
|
|
|
3156
3162
|
size
|
|
3157
3163
|
}) => {
|
|
3158
3164
|
const { isLoading, isAuthenticated, user, login, logout } = useAuth();
|
|
3159
|
-
const [open, setOpen] =
|
|
3160
|
-
const [accountInfoOpen, setAccountInfoOpen] =
|
|
3161
|
-
const [error, setError] =
|
|
3162
|
-
const initials =
|
|
3165
|
+
const [open, setOpen] = React10.useState(false);
|
|
3166
|
+
const [accountInfoOpen, setAccountInfoOpen] = React10.useState(false);
|
|
3167
|
+
const [error, setError] = React10.useState(null);
|
|
3168
|
+
const initials = React10.useMemo(() => {
|
|
3163
3169
|
const name = user?.displayName || user?.name;
|
|
3164
3170
|
if (!name) return "";
|
|
3165
3171
|
return name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
|