mtxuilib 0.1.256 → 0.1.257
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/common/FullCenter.d.ts +1 -1
- package/dist/common/MtErrorBoundary.js +4 -4
- package/dist/ui/mt/ScreenPanel.js +13 -8
- package/package.json +1 -1
- package/dist/components/UploadDocumentsForm.d.ts +0 -1
- package/dist/components/UploadDocumentsForm.js +0 -28
- package/dist/components/chat-share-dialog.d.ts +0 -9
- package/dist/components/chat-share-dialog.js +0 -33
- package/dist/components/message.d.ts +0 -16
- package/dist/components/message.js +0 -43
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PropsWithChildren } from "react";
|
|
1
|
+
import type { PropsWithChildren } from "react";
|
|
2
2
|
export declare const FullCenter: (props: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,10 +3,10 @@ import { ErrorBoundary } from "react-error-boundary";
|
|
|
3
3
|
import { MtButton } from "../ui/mt/Button";
|
|
4
4
|
export const MtErrorBoundary = (props) => {
|
|
5
5
|
const { children } = props;
|
|
6
|
-
return (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
return (_jsx(ErrorBoundary, { fallbackRender: ({ error, resetErrorBoundary }) => {
|
|
7
|
+
console.log("💥💥💥", error);
|
|
8
|
+
return (_jsxs("div", { children: [_jsx("h1", { children: "error" }), _jsx(MtButton, { onClick: () => resetErrorBoundary(), children: "Try again" }), _jsx("pre", { style: { whiteSpace: "normal" }, children: error.message })] }));
|
|
9
|
+
}, onReset: () => { }, children: children }));
|
|
10
10
|
};
|
|
11
11
|
const CustomErrorRetry = (props) => {
|
|
12
12
|
const { message, onRetry } = props;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useRef, } from "react";
|
|
3
|
+
import { useEffect, useRef, useState, } from "react";
|
|
4
4
|
import { cn } from "../../lib/utils";
|
|
5
5
|
import { MtButton } from "./Button";
|
|
6
6
|
export const ScreenPanel = (props) => {
|
|
7
|
-
const { className, children,
|
|
7
|
+
const { className, children, onOpenChange } = props;
|
|
8
8
|
const scrollRef = useRef(null);
|
|
9
|
+
const [open, setOpen] = useState(props.open === undefined ? true : props.open);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const originalOverflow = document.body.style.overflow;
|
|
12
|
+
document.body.style.overflow = open ? "hidden" : originalOverflow;
|
|
13
|
+
return () => {
|
|
14
|
+
document.body.style.overflow = originalOverflow;
|
|
15
|
+
};
|
|
16
|
+
}, [open]);
|
|
9
17
|
if (!open) {
|
|
10
18
|
return null;
|
|
11
19
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return (_jsxs("div", { ref: scrollRef, className: cn("fixed left-0 top-0 z-30 mx-auto max-h-full min-h-full w-full overflow-auto ", "bg-background/95 supports-[backdrop-filter]:bg-background/60 backdrop-blur", className), children: [onOpenChange && (_jsx("div", { className: "flex justify-end gap-2", children: _jsx(MtButton, { variant: "ghost", onClick: () => {
|
|
16
|
-
onOpenChange(false);
|
|
17
|
-
}, children: "X" }) })), _jsx("div", { className: cn("relative mx-auto p-2 md:p-4 lg:p-6"), children: children })] }));
|
|
20
|
+
return (_jsx("div", { className: "relative", children: _jsxs("div", { ref: scrollRef, className: cn("fixed left-0 top-0 z-30 mx-auto max-h-full min-h-full w-full overflow-auto ", "bg-background/95 supports-[backdrop-filter]:bg-background/60 backdrop-blur", className), children: [onOpenChange && (_jsx("div", { className: "flex justify-end gap-2", children: _jsx(MtButton, { variant: "ghost", onClick: () => {
|
|
21
|
+
onOpenChange(false);
|
|
22
|
+
}, children: "X" }) })), _jsx("div", { className: cn("relative mx-auto p-2 md:p-4 lg:p-6"), children: children })] }) }));
|
|
18
23
|
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function UploadDocumentsForm(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
export function UploadDocumentsForm() {
|
|
5
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
6
|
-
const [document, setDocument] = useState("fack document123");
|
|
7
|
-
const ingest = async (e) => {
|
|
8
|
-
e.preventDefault();
|
|
9
|
-
setIsLoading(true);
|
|
10
|
-
const response = await fetch("/api/retrieval/ingest", {
|
|
11
|
-
method: "POST",
|
|
12
|
-
body: JSON.stringify({
|
|
13
|
-
text: document,
|
|
14
|
-
}),
|
|
15
|
-
});
|
|
16
|
-
if (response.status === 200) {
|
|
17
|
-
setDocument("Uploaded!");
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
const json = (await response.json());
|
|
21
|
-
if (json.error) {
|
|
22
|
-
setDocument(json.error);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
setIsLoading(false);
|
|
26
|
-
};
|
|
27
|
-
return (_jsxs("form", { onSubmit: ingest, className: "flex w-full mb-4", children: [_jsx("textarea", { className: "grow mr-8 p-4 rounded", value: document, onChange: (e) => setDocument(e.target.value) }), _jsxs("button", { type: "submit", className: "shrink-0 px-8 py-4 bg-sky-600 rounded w-28", children: [_jsxs("div", { role: "status", className: `${isLoading ? "" : "hidden"} flex justify-center`, children: [_jsxs("svg", { "aria-hidden": "true", className: "w-6 h-6 text-white animate-spin dark:text-white fill-sky-800", viewBox: "0 0 100 101", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z", fill: "currentColor" }), _jsx("path", { d: "M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z", fill: "currentFill" })] }), _jsx("span", { className: "sr-only", children: "Loading..." })] }), _jsx("span", { className: isLoading ? "hidden" : "", children: "Upload" })] })] }));
|
|
28
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type DialogProps } from "@radix-ui/react-dialog";
|
|
2
|
-
import type { Chat, ServerActionResult } from "../lib/types";
|
|
3
|
-
interface ChatShareDialogProps extends DialogProps {
|
|
4
|
-
chat: Pick<Chat, "id" | "title" | "messages">;
|
|
5
|
-
shareChat: (id: string) => ServerActionResult<Chat>;
|
|
6
|
-
onCopy: () => void;
|
|
7
|
-
}
|
|
8
|
-
export declare function ChatShareDialog({ chat, shareChat, onCopy, ...props }: ChatShareDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Dialog, DialogContent, DialogDescription, DialogTitle, } from "@radix-ui/react-dialog";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
import { Button } from "react-day-picker";
|
|
6
|
-
import { toast } from "sonner";
|
|
7
|
-
import { useCopyToClipboard } from "../hooks/use-copy-to-clipboard";
|
|
8
|
-
import { IconSpinner } from "../icons/icons-ai";
|
|
9
|
-
import { DialogFooter, DialogHeader } from "../ui/dialog";
|
|
10
|
-
export function ChatShareDialog({ chat, shareChat, onCopy, ...props }) {
|
|
11
|
-
const { copyToClipboard } = useCopyToClipboard({ timeout: 1000 });
|
|
12
|
-
const [isSharePending, startShareTransition] = React.useTransition();
|
|
13
|
-
const copyShareLink = React.useCallback(async (chat) => {
|
|
14
|
-
if (!chat.sharePath) {
|
|
15
|
-
return toast.error("Could not copy share link to clipboard");
|
|
16
|
-
}
|
|
17
|
-
const url = new URL(window.location.href);
|
|
18
|
-
url.pathname = chat.sharePath;
|
|
19
|
-
copyToClipboard(url.toString());
|
|
20
|
-
onCopy();
|
|
21
|
-
toast.success("Share link copied to clipboard");
|
|
22
|
-
}, [copyToClipboard, onCopy]);
|
|
23
|
-
return (_jsx(Dialog, { ...props, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Share link to chat" }), _jsx(DialogDescription, { children: "Anyone with the URL will be able to view the shared chat." })] }), _jsxs("div", { className: "p-4 space-y-1 text-sm border rounded-md", children: [_jsx("div", { className: "font-medium", children: chat.title }), _jsxs("div", { className: "text-muted-foreground", children: [chat.messages.length, " messages"] })] }), _jsx(DialogFooter, { className: "items-center", children: _jsx(Button, { disabled: isSharePending, onClick: () => {
|
|
24
|
-
startShareTransition(async () => {
|
|
25
|
-
const result = await shareChat(chat.id);
|
|
26
|
-
if (result && "error" in result) {
|
|
27
|
-
toast.error(result.error?.toString());
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
copyShareLink(result);
|
|
31
|
-
});
|
|
32
|
-
}, children: isSharePending ? (_jsxs(_Fragment, { children: [_jsx(IconSpinner, { className: "mr-2 animate-spin" }), "Copying..."] })) : (_jsx(_Fragment, { children: "Copy link" })) }) })] }) }));
|
|
33
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type StreamableValue } from "ai/rsc";
|
|
2
|
-
export declare function UserMessage({ children }: {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
export declare function BotMessage({ content, className, }: {
|
|
6
|
-
content: string | StreamableValue<string>;
|
|
7
|
-
className?: string;
|
|
8
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export declare function BotCard({ children, showAvatar, }: {
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
showAvatar?: boolean;
|
|
12
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export declare function SystemMessage({ children }: {
|
|
14
|
-
children: React.ReactNode;
|
|
15
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export declare function SpinnerMessage(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { MemoizedReactMarkdown } from "mtxuilib/common/markdown";
|
|
4
|
-
import { useStreamableText } from "mtxuilib/hooks/use-streamable-text";
|
|
5
|
-
import { IconOpenAI, IconUser } from "mtxuilib/icons/icons-ai";
|
|
6
|
-
import { cn } from "mtxuilib/lib/utils";
|
|
7
|
-
import { CodeBlock } from "mtxuilib/ui/codeblock";
|
|
8
|
-
import remarkGfm from "remark-gfm";
|
|
9
|
-
import remarkMath from "remark-math";
|
|
10
|
-
import { spinner } from "./spinner";
|
|
11
|
-
export function UserMessage({ children }) {
|
|
12
|
-
return (_jsxs("div", { className: "group relative flex items-start md:-ml-12", children: [_jsx("div", { className: "flex size-[25px] shrink-0 select-none items-center justify-center rounded-md border bg-background shadow-sm", children: _jsx(IconUser, {}) }), _jsx("div", { className: "ml-4 flex-1 space-y-2 overflow-hidden pl-2", children: children })] }));
|
|
13
|
-
}
|
|
14
|
-
export function BotMessage({ content, className, }) {
|
|
15
|
-
const text = useStreamableText(content);
|
|
16
|
-
return (_jsxs("div", { className: cn("group relative flex items-start md:-ml-12", className), children: [_jsx("div", { className: "flex size-[24px] shrink-0 select-none items-center justify-center rounded-md border bg-primary text-primary-foreground shadow-sm", children: _jsx(IconOpenAI, {}) }), _jsx("div", { className: "ml-4 flex-1 space-y-2 overflow-hidden px-1", children: _jsx(MemoizedReactMarkdown, { className: "prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0", remarkPlugins: [remarkGfm, remarkMath], components: {
|
|
17
|
-
p({ children }) {
|
|
18
|
-
return _jsx("p", { className: "mb-2 last:mb-0", children: children });
|
|
19
|
-
},
|
|
20
|
-
code({ node, inline, className, children, ...props }) {
|
|
21
|
-
if (children.length) {
|
|
22
|
-
if (children[0] === "▍") {
|
|
23
|
-
return (_jsx("span", { className: "mt-1 animate-pulse cursor-default", children: "\u258D" }));
|
|
24
|
-
}
|
|
25
|
-
children[0] = children[0].replace("`▍`", "▍");
|
|
26
|
-
}
|
|
27
|
-
const match = /language-(\w+)/.exec(className || "");
|
|
28
|
-
if (inline) {
|
|
29
|
-
return (_jsx("code", { className: className, ...props, children: children }));
|
|
30
|
-
}
|
|
31
|
-
return (_jsx(CodeBlock, { language: match?.[1] || "", value: String(children).replace(/\n$/, ""), ...props }, Math.random()));
|
|
32
|
-
},
|
|
33
|
-
}, children: text }) })] }));
|
|
34
|
-
}
|
|
35
|
-
export function BotCard({ children, showAvatar = true, }) {
|
|
36
|
-
return (_jsxs("div", { className: "group relative flex items-start md:-ml-12", children: [_jsx("div", { className: cn("flex size-[24px] shrink-0 select-none items-center justify-center rounded-md border bg-primary text-primary-foreground shadow-sm", !showAvatar && "invisible"), children: _jsx(IconOpenAI, {}) }), _jsx("div", { className: "ml-4 flex-1 pl-2", children: children })] }));
|
|
37
|
-
}
|
|
38
|
-
export function SystemMessage({ children }) {
|
|
39
|
-
return (_jsx("div", { className: "mt-2 flex items-center justify-center gap-2 text-xs text-gray-500", children: _jsx("div", { className: "max-w-[600px] flex-initial p-2", children: children }) }));
|
|
40
|
-
}
|
|
41
|
-
export function SpinnerMessage() {
|
|
42
|
-
return (_jsxs("div", { className: "group relative flex items-start md:-ml-12", children: [_jsx("div", { className: "flex size-[24px] shrink-0 select-none items-center justify-center rounded-md border bg-primary text-primary-foreground shadow-sm", children: _jsx(IconOpenAI, {}) }), _jsx("div", { className: "ml-4 h-[24px] flex flex-row items-center flex-1 space-y-2 overflow-hidden px-1", children: spinner })] }));
|
|
43
|
-
}
|