Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
feat: enhance chat UX
Louis4f91ec24776e
diff --git a/web-app/package.json b/web-app/package.jsonindex 2414dff45..383782b1b 100644--- a/web-app/package.json+++ b/web-app/package.json@@ -23,6 +23,7 @@"@dnd-kit/sortable": "10.0.0","@jan/extensions-web": "workspace:*","@janhq/core": "workspace:*",+ "@janhq/interfaces": "0.0.2","@radix-ui/react-accordion": "1.2.11","@radix-ui/react-avatar": "1.1.10","@radix-ui/react-dialog": "1.1.15",@@ -79,7 +80,8 @@"remark-gfm": "4.0.1","remark-math": "6.0.0","sonner": "2.0.5",- "tailwindcss": "4.1.4",+ "streamdown": "npm:@janhq/streamdown@^1.1.6",+ "tailwindcss": "4.1.17","token.js": "npm:[email protected]","tw-animate-css": "1.2.8","ulidx": "2.4.1",diff --git a/web-app/src/ai-elements/code-block.tsx b/web-app/src/ai-elements/code-block.tsxnew file mode 100644index 000000000..00d781fff--- /dev/null+++ b/web-app/src/ai-elements/code-block.tsx@@ -0,0 +1,178 @@+/* eslint-disable react-refresh/only-export-components */++import { Button } from "../ui/button";+import { cn } from "../lib/utils";+import { CheckIcon, CopyIcon } from "lucide-react";+import {+ type ComponentProps,+ createContext,+ type HTMLAttributes,+ useContext,+ useEffect,+ useRef,+ useState,+} from "react";+import { type BundledLanguage, codeToHtml, type ShikiTransformer } from "shiki";++type CodeBlockProps = HTMLAttributes<HTMLDivElement> & {+ code: string;+ language: BundledLanguage;+ showLineNumbers?: boolean;+};++type CodeBlockContextType = {+ code: string;+};++const CodeBlockContext = createContext<CodeBlockContextType>({+ code: "",+});++const lineNumberTransformer: ShikiTransformer = {+ name: "line-numbers",+ line(node, line) {+ node.children.unshift({+ type: "element",+ tagName: "span",+ properties: {+ className: [+ "inline-block",+ "min-w-10",+ "mr-4",+ "text-right",+ "select-none",+ "text-muted-foreground",+ ],+ },+ children: [{ type: "text", value: String(line) }],+ });+ },+};++export async function highlightCode(+ code: string,+ language: BundledLanguage,+ showLineNumbers = false,+) {+ const transformers: ShikiTransformer[] = showLineNumbers+ ? [lineNumberTransformer]+ : [];++ return await Promise.all([+ codeToHtml(code, {+ lang: language,+ theme: "one-light",+ transformers,+ }),+ codeToHtml(code, {+ lang: language,+ theme: "one-dark-pro",+ transformers,+ }),+ ]);+}++export const CodeBlock = ({+ code,+ language,+ showLineNumbers = false,+ className,+ children,+ ...props+}: CodeBlockProps) => {+ const [html, setHtml] = useState<string>("");+ const [darkHtml, setDarkHtml] = useState<string>("");+ const mounted = useRef(false);++ useEffect(() => {+ highlightCode(code, language, showLineNumbers).then(([light, dark]) => {+ if (!mounted.current) {+ setHtml(light);+ setDarkHtml(dark);+ mounted.current = true;+ }+ });++ return () => {+ mounted.current = false;+ };+ }, [code, language, showLineNumbers]);++ return (+ <CodeBlockContext.Provider value={{ code }}>+ <div+ className={cn(+ "group relative w-full overflow-hidden rounded-md border border-main-view-fg/10 bg-background text-foreground",+ className,+ )}+ {...props}+ >+ <div className="relative">+ <div+ className="overflow-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm"+ // biome-ignore lint/security/noDangerouslySetInnerHtml: "this is needed."+ dangerouslySetInnerHTML={{ __html: html }}+ />+ <div+ className="hidden overflow-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm"+ // biome-ignore lint/security/noDangerouslySetInnerHtml: "this is needed."+ dangerouslySetInnerHTML={{ __html: darkHtml }}+ />+ {children && (+ <div className="absolute top-2 right-2 flex items-center gap-2">+ {children}+ </div>+ )}+ </div>+ </div>+ </CodeBlockContext.Provider>+ );+};++export type CodeBlockCopyButtonProps = ComponentProps<typeof Button> & {+ onCopy?: () => void;+ onError?: (error: Error) => void;+ timeout?: number;+};++export const CodeBlockCopyButton = ({+ onCopy,+ onError,+ timeout = 2000,+ children,+ className,+ ...props+}: CodeBlockCopyButtonProps) => {+ const [isCopied, setIsCopied] = useState(false);+ const { code } = useContext(CodeBlockContext);++ const copyToClipboard = async () => {+ if (typeof window === "undefined" || !navigator?.clipboard?.writeText) {+ onError?.(new Error("Clipboard API not available"));+ return;+ }++ try {+ await navigator.clipboard.writeText(code);+ setIsCopied(true);+ onCopy?.();+ setTimeout(() => setIsCopied(false), timeout);+ } catch (error) {+ onError?.(error as Error);+ }+ };++ const Icon = isCopied ? CheckIcon : CopyIcon;++ return (+ <Button+ className={cn("shrink-0", className)}+ onClick={copyToClipboard}+ size="icon"+ variant="ghost"+ {...props}+ >+ {children ?? <Icon size={14} />}+ </Button>+ );+};diff --git a/web-app/src/ai-elements/reasoning.tsx b/web-app/src/ai-elements/reasoning.tsxnew file mode 100644index 000000000..b21214d2f--- /dev/null+++ b/web-app/src/ai-elements/reasoning.tsx@@ -0,0 +1,193 @@+/* eslint-disable react-hooks/set-state-in-effect */+/* eslint-disable react-refresh/only-export-components */+import { useControllableState } from '@radix-ui/react-use-controllable-state'+import {+ Collapsible,+ CollapsibleContent,+ CollapsibleTrigger,+} from '../ui/collapsible'+import { cn } from '../lib/utils'+import { BrainIcon, ChevronDownIcon } from 'lucide-react'+import type { ComponentProps, ReactNode } from 'react'+import {+ createContext,+ memo,+ useContext,+ useEffect,+ useRef,+ useState,+} from 'react'+import { Streamdown } from 'streamdown'+import { Shimmer } from './shimmer'++type ReasoningContextValue = {+ isStreaming: boolean+ isOpen: boolean+ setIsOpen: (open: boolean) => void+ duration: number | undefined+}++const ReasoningContext = createContext<ReasoningContextValue | null>(null)++export const useReasoning = () => {+ const context = useContext(ReasoningContext)+ if (!context) {+ throw new Error('Reasoning components must be used within Reasoning')+ }+ return context+}++export type ReasoningProps = ComponentProps<typeof Collapsible> & {+ isStreaming?: boolean+ open?: boolean+ defaultOpen?: boolean+ onOpenChange?: (open: boolean) => void+ duration?: number+}++const MS_IN_S = 1000++export const Reasoning = memo(+ ({+ className,+ isStreaming = false,+ open,+ defaultOpen = true,+ onOpenChange,+ duration: durationProp,+ children,+ ...props+ }: ReasoningProps) => {+ const [isOpen, setIsOpen] = useControllableState({+ prop: open,+ defaultProp: defaultOpen,+ onChange: onOpenChange,+ })+ const [duration, setDuration] = useControllableState({+ prop: durationProp,+ defaultProp: undefined,+ })++ const [startTime, setStartTime] = useState<number | null>(null)+ const wasStreamingRef = useRef(isStreaming)++ // Track duration when streaming starts and ends+ useEffect(() => {+ if (isStreaming) {+ if (startTime === null) {+ setStartTime(Date.now())+ }+ } else if (startTime !== null) {+ setDuration(Math.ceil((Date.now() - startTime) / MS_IN_S))+ setStartTime(null)+ }+ }, [isStreaming, startTime, setDuration])++ // Auto-close when streaming ends (only when transitioning from streaming to not streaming)+ useEffect(() => {+ if (wasStreamingRef.current && !isStreaming) {+ // Streaming just ended, auto-close+ setIsOpen(false)+ }+ wasStreamingRef.current = isStreaming+ }, [isStreaming, setIsOpen])++ const handleOpenChange = (newOpen: boolean) => {+ setIsOpen(newOpen)+ }++ return (+ <ReasoningContext.Provider+ value={{ isStreaming, isOpen, setIsOpen, duration }}+ >+ <Collapsible+ className={cn('not-prose mb-4', className)}+ onOpenChange={handleOpenChange}+ open={isOpen}+ {...props}+ >+ {children}+ </Collapsible>+ </ReasoningContext.Provider>+ )+ }+)++export type ReasoningTriggerProps = ComponentProps<+ typeof CollapsibleTrigger+> & {+ getThinkingMessage?: (isStreaming: boolean, duration?: number) => ReactNode+}++const defaultGetThinkingMessage = (isStreaming: boolean, duration?: number) => {+ if (isStreaming || duration === 0) {+ return <Shimmer duration={1}>Thinking...</Shimmer>+ }+ if (duration === undefined) {+ return <p>Thought for a few seconds</p>+ }+ return <p>Thought for {duration} seconds</p>+}++export const ReasoningTrigger = memo(+ ({+ className,+ children,+ getThinkingMessage = defaultGetThinkingMessage,+ ...props+ }: ReasoningTriggerProps) => {+ const { isStreaming, isOpen, duration } = useReasoning()++ return (+ <CollapsibleTrigger+ className={cn(+ 'flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground',+ className+ )}+ {...props}+ >+ {children ?? (+ <>+ <BrainIcon className="size-4" />+ {getThinkingMessage(isStreaming, duration)}+ <ChevronDownIcon+ className={cn(+ 'size-4 transition-transform',+ isOpen ? 'rotate-180' : 'rotate-0'+ )}+ />+ </>+ )}+ </CollapsibleTrigger>+ )+ }+)++export type ReasoningContentProps = ComponentProps<+ typeof CollapsibleContent+> & { isStreaming?: boolean } & {+ children: string+}++export const ReasoningContent = memo(+ ({ className, isStreaming, children, ...props }: ReasoningContentProps) => (+ <CollapsibleContent+ className={cn(+ 'mt-4 text-sm relative',+ 'data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in',+ className+ )}+ {...props}+ >+ <div className="ml-2 pl-4 border-l-2 border-dashed border-main-view-fg/10">+ <Streamdown animate={true} animationDuration={500} {...props}>+ {children}+ </Streamdown>+ </div>+ </CollapsibleContent>+ )+)++Reasoning.displayName = 'Reasoning'+ReasoningTrigger.displayName = 'ReasoningTrigger'+ReasoningContent.displayName = 'ReasoningContent'diff --git a/web-app/src/ai-elements/shimmer.tsx b/web-app/src/ai-elements/shimmer.tsxnew file mode 100644index 000000000..348877b8d--- /dev/null+++ b/web-app/src/ai-elements/shimmer.tsx@@ -0,0 +1,67 @@+/* eslint-disable react-hooks/static-components */+import { cn } from "../lib/utils";+import { motion } from "motion/react";+import {+ type CSSProperties,+ type ElementType,+ type JSX,+ memo,+ useMemo,+} from "react";++export type TextShimmerProps = {+ children: string;+ as?: ElementType;+ className?: string;+ duration?: number;+ spread?: number;+};++const ShimmerComponent = ({+ children,+ as: Component = "p",+ className,+ duration = 2,+ spread = 2,+}: TextShimmerProps) => {+ const MotionComponent = motion.create(+ Component as keyof JSX.IntrinsicElements,+ );++ const dynamicSpread = useMemo(+ () => (children?.length ?? 0) * spread,+ [children, spread],+ );++ return (+ <MotionComponent+ animate={{ backgroundPosition: "0% center" }}+ className={cn(+ "relative inline-block bg-clip-text text-transparent",+ className,+ )}+ initial={{ backgroundPosition: "100% center" }}+ style={+ {+ "--spread": `${dynamicSpread}px`,+ backgroundImage:+ "linear-gradient(90deg, rgba(128, 128, 128, 0.4) calc(50% - var(--spread)), rgba(255, 255, 255, 1) 50%, rgba(128, 128, 128, 0.4) calc(50% + var(--spread)))",+ backgroundSize: "250% 100%",+ backgroundRepeat: "no-repeat",+ backgroundClip: "text",+ WebkitBackgroundClip: "text",+ color: "transparent",+ } as CSSProperties+ }+ transition={{+ repeat: Number.POSITIVE_INFINITY,+ duration,+ ease: "linear",+ }}+ >+ {children}+ </MotionComponent>+ );+};++export const Shimmer = memo(ShimmerComponent);diff --git a/web-app/src/ai-elements/tool.tsx b/web-app/src/ai-elements/tool.tsxnew file mode 100644index 000000000..31ff70418--- /dev/null+++ b/web-app/src/ai-elements/tool.tsx@@ -0,0 +1,338 @@+/* eslint-disable react-hooks/set-state-in-effect */++import { useControllableState } from '@radix-ui/react-use-controllable-state';+import {+ Collapsible,+ CollapsibleContent,+ CollapsibleTrigger,+} from "../ui/collapsible";+import { cn } from "../lib/utils";+import type { ToolUIPart } from "ai";+import {+ ChevronDownIcon,+ WrenchIcon,+} from "lucide-react";+import type { ComponentProps, ReactNode } from "react";+import { createContext, isValidElement, memo, useContext, useEffect, useMemo, useState } from "react";+import { CodeBlock } from "./code-block";++type ToolContextValue = {+ isOpen: boolean;+ setIsOpen: (open: boolean) => void;+ state: ToolUIPart["state"];+};++const ToolContext = createContext<ToolContextValue | null>(null);++export const useTool = () => {+ const context = useContext(ToolContext);+ if (!context) {+ throw new Error('Tool components must be used within Tool');+ }+ return context;+};++export type ToolProps = ComponentProps<typeof Collapsible> & {+ className?: string;+ state: ToolUIPart["state"];+ open?: boolean;+ defaultOpen?: boolean;+ onOpenChange?: (open: boolean) => void;+};++export const Tool = memo(({+ className,+ state,+ open,+ defaultOpen = false,+ onOpenChange,+ children,+ ...props+}: ToolProps) => {+ const [isOpen, setIsOpen] = useControllableState({+ prop: open,+ defaultProp: defaultOpen,+ onChange: onOpenChange,+ });++ const handleOpenChange = (newOpen: boolean) => {+ setIsOpen(newOpen);+ };++ return (+ <ToolContext.Provider value={{ isOpen, setIsOpen, state }}>+ <Collapsible+ className={cn("not-prose", className)}+ onOpenChange={handleOpenChange}+ open={isOpen}+ {...props}+ >+ {children}+ </Collapsible>+ </ToolContext.Provider>+ );+});++export type ToolHeaderProps = {+ title?: string;+ type: ToolUIPart["type"];+ className?: string;+};++const getStatusText = (status: ToolUIPart["state"], toolName: string) => {+ const isRunning = status === "input-streaming" || status === "input-available";+ // @ts-expect-error state only available in AI SDK v6+ const hasError = status === "output-error" || status === "output-denied";++ if (isRunning) {+ return `Running ${toolName}...`;+ }+ if (hasError) {+ return `${toolName} failed`;+ }+ return `Used ${toolName}`;+};++export const ToolHeader = memo(({+ className,+ title,+ type,+}: ToolHeaderProps) => {+ const { isOpen, state } = useTool();+ const toolName = title ?? type.split("-").slice(1).join("-");++ return (+ <CollapsibleTrigger+ className={cn(+ "flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors",+ className,+ )}+ >+ <WrenchIcon className="size-4" />+ <span>{getStatusText(state, toolName)}</span>+ <ChevronDownIcon+ className={cn(+ "size-4 transition-transform",+ isOpen ? "rotate-180" : "rotate-0"+ )}+ />+ </CollapsibleTrigger>+ );+});++export type ToolContentProps = ComponentProps<typeof CollapsibleContent>;++export const ToolContent = memo(({ className, children, ...props }: ToolContentProps) => (+ <CollapsibleContent+ className={cn(+ "mt-4 text-sm relative",+ "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",+ className+ )}+ {...props}+ >+ <div className="ml-2 pl-4 border-l-2 border-dashed border-main-view-fg/10">+ {children}+ </div>+ </CollapsibleContent>+));++export type ToolInputProps = ComponentProps<"div"> & {+ input: ToolUIPart["input"];+};++export const ToolInput = memo(({ className, input, ...props }: ToolInputProps) => {++ return (+ <div className={cn("space-y-2", className)} {...props}>+ <h4 className="font-medium text-muted-foreground text-xs uppercase tracking-wide">+ Parameters+ </h4>+ <div className="rounded-md overflow-hidden">+ <CodeBlock code={input} language="json" />+ </div>+ </div>+ );+});++type ToolImageProps = {+ data: string;+ index: number;+ resolver: (input: string) => Promise<string>;+};++const ToolImage = memo(({ data, index }: ToolImageProps) => {+ // Prepare the URL - convert base64 to data URL if needed+ const [preparedUrl, setPreparedUrl] = useState<string | undefined>(undefined);++ useEffect(() => {+ if (data.startsWith("data:image") || data.startsWith("http")) {+ // Already a data URL or HTTP URL+ setPreparedUrl(data);+ } else {+ // Assume it's base64 encoded+ setPreparedUrl(`data:image/png;base64,${data}`);+ }+ }, [data]);++ const isLoading = !preparedUrl++ if (isLoading) {+ return (+ <div className="flex justify-center">+ <div className="flex size-24 items-center justify-center rounded-md bg-muted">+ <div className="size-4 animate-spin rounded-full border-2 border-primary border-t-transparent" />+ </div>+ </div>+ );+ }++ if (!preparedUrl) {+ return null;+ }++ return (+ <div key={index} className="inline-block">+ <img+ src={preparedUrl}+ alt="Tool output"+ className="max-w-full max-h-96 w-auto h-auto object-contain rounded-md border border-main-view-fg/10"+ />+ </div>+ );+});++export type ToolOutputProps = ComponentProps<"div"> & {+ output: ToolUIPart["output"];+ errorText: ToolUIPart["errorText"];+ resolver: (input: string) => Promise<string>;+};++export const ToolOutput = memo(({+ className,+ output,+ errorText,+ resolver,+ ...props+}: ToolOutputProps) => {+ const Output = useMemo(() => {+ if (!(output || errorText)) {+ return null;+ }++ // Handle string output+ if (typeof output === "string") {+ return <CodeBlock code={output} language="json" />;+ }++ if (typeof output === "object" && !isValidElement(output)) {+ // Check if output has content array (new structure: {content: [{text, type}, {data, type: image}]})+ if (output && typeof output === "object" && "content" in output && Array.isArray(output.content)) {+ const content = output.content as Array<{+ type: string;+ text?: string;+ data?: string;+ mimeType?: string;+ }>;++ const textItems = content.filter((item) => item.type === "text");+ const imageItems = content.filter((item) => item.type === "image");++ return (+ <div className="space-y-4">+ {textItems.length > 0 && (+ <div className="space-y-2">+ {textItems.map((item, index) => (+ <div key={index} className="rounded-md overflow-hidden">+ <CodeBlock code={item.text || ""} language="json" />+ </div>+ ))}+ </div>+ )}+ {imageItems.length > 0 && (+ <div className="space-y-2">+ {imageItems.map((item, index) => (+ <ToolImage+ key={index}+ data={item.data || ""}+ index={index}+ resolver={resolver}+ />+ ))}+ </div>+ )}+ </div>+ );+ }++ // Handle old array format for backward compatibility+ if (Array.isArray(output)) {+ const hasImages = output.some(+ (item) => item?.type === "image" && (item?.data || item?.image),+ );++ if (hasImages) {+ // Filter out images from JSON and render images separately+ const nonImageOutput = output.filter((item) => item?.type !== "image");++ return (+ <div className="space-y-4">+ {nonImageOutput.length > 0 && (+ <CodeBlock+ code={JSON.stringify(nonImageOutput, null, 2)}+ language="json"+ />+ )}+ {output+ .filter(+ (item) =>+ item?.type === "image" && (item?.data || item?.image?.url),+ )+ .map((item, index) => (+ <ToolImage+ key={index}+ data={item.data ?? item.image?.url}+ index={index}+ resolver={resolver}+ />+ ))}+ </div>+ );+ }++ return <CodeBlock code={JSON.stringify(output, null, 2)} language="json" />;+ }++ // Handle regular object+ return <CodeBlock code={JSON.stringify(output, null, 2)} language="json" />;+ }++ return <div>{output as ReactNode}</div>;+ }, [output, errorText, resolver]);++ if (!(output || errorText)) {+ return null;+ }++ return (+ <div className={cn("space-y-2 mt-4", className)} {...props}>+ <h4 className="font-medium text-muted-foreground text-xs uppercase tracking-wide">+ {errorText ? "Error" : "Result"}+ </h4>+ <div className="rounded-md overflow-hidden">+ {errorText && (+ <div className="m-2 p-2 bg-destructive/10 text-destructive rounded-md">+ {errorText}+ </div>+ )}+ {Output}+ </div>+ </div>+ );+});++Tool.displayName = 'Tool';+ToolHeader.displayName = 'ToolHeader';+ToolContent.displayName = 'ToolContent';+ToolInput.displayName = 'ToolInput';+ToolOutput.displayName = 'ToolOutput';diff --git a/web-app/src/containers/RenderMarkdown.tsx b/web-app/src/containers/RenderMarkdown.tsxindex 0e85450fe..c7d2a4663 100644--- a/web-app/src/containers/RenderMarkdown.tsx+++ b/web-app/src/containers/RenderMarkdown.tsx@@ -1,27 +1,18 @@-import ReactMarkdown, { Components } from 'react-markdown'+import { Components } from 'react-markdown'+import { memo, useMemo } from 'react'+import { cn } from '@/lib/utils'+// import 'katex/dist/katex.min.css'+import { defaultRehypePlugins, Streamdown } from 'streamdown'import remarkGfm from 'remark-gfm'-import remarkEmoji from 'remark-emoji'import remarkMath from 'remark-math'-import remarkBreaks from 'remark-breaks'-import rehypeKatex from 'rehype-katex'-import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'-import * as prismStyles from 'react-syntax-highlighter/dist/cjs/styles/prism'-import { memo, useState, useMemo, useCallback } from 'react'-import { getReadableLanguageName } from '@/lib/utils'-import { cn } from '@/lib/utils'import { useCodeblock } from '@/hooks/useCodeblock'-import 'katex/dist/katex.min.css'-import { IconCopy, IconCopyCheck } from '@tabler/icons-react'-import rehypeRaw from 'rehype-raw'-import { useTranslation } from '@/i18n/react-i18next-compat'interface MarkdownProps {content: stringclassName?: stringcomponents?: Components- enableRawHtml?: booleanisUser?: boolean- isWrapping?: boolean+ isStreaming?: boolean}// Cache for normalized LaTeX content@@ -80,191 +71,17 @@ const normalizeLatex = (input: string): string => {return result}-// Memoized code component to prevent unnecessary re-renders-const CodeComponent = memo(- ({- className,- children,- isUser,- codeBlockStyle,- showLineNumbers,- isWrapping,- onCopy,- copiedId,- ...props- // eslint-disable-next-line @typescript-eslint/no-explicit-any- }: any) => {- const { t } = useTranslation()- const match = /language-(\w+)/.exec(className || '')- const language = match ? match[1] : ''- const isInline = !match || !language-- const code = String(children).replace(/\n$/, '')-- // Generate a stable ID based on content hash instead of position- const codeId = useMemo(() => {- let hash = 0- for (let i = 0; i < code.length; i++) {- const char = code.charCodeAt(i)- hash = (hash << 5) - hash + char- hash = hash & hash // Convert to 32-bit integer- }- return `code-${Math.abs(hash)}-${language}`- }, [code, language])-- const handleCopyClick = useCallback(- (e: React.MouseEvent) => {- e.stopPropagation()- onCopy(code, codeId)- },- [code, codeId, onCopy]- )-- if (isInline || isUser) {- return <code className={cn(className)}>{children}</code>- }-- return (- <div className="relative overflow-hidden border rounded-md border-main-view-fg/2">- <style>- {`- .react-syntax-highlighter-line-number {- user-select: none;- -webkit-user-select: none;- -moz-user-select: none;- -ms-user-select: none;- }- `}- </style>- <div className="flex items-center justify-between px-4 py-2 bg-main-view/10">- <span className="font-medium text-xs font-sans">- {getReadableLanguageName(language)}- </span>- <button- onClick={handleCopyClick}- className="flex items-center gap-1 text-xs font-sans transition-colors cursor-pointer"- >- {copiedId === codeId ? (- <>- <IconCopyCheck size={16} className="text-primary" />- <span>{t('copied')}</span>- </>- ) : (- <>- <IconCopy size={16} />- <span>{t('copy')}</span>- </>- )}- </button>- </div>- <SyntaxHighlighter- style={- prismStyles[- codeBlockStyle- .split('-')- .map((part: string, index: number) =>- index === 0- ? part- : part.charAt(0).toUpperCase() + part.slice(1)- )- .join('') as keyof typeof prismStyles- ] || prismStyles.oneLight- }- language={language}- showLineNumbers={showLineNumbers}- wrapLines={true}- lineProps={- isWrapping- ? {- style: { wordBreak: 'break-all', whiteSpace: 'pre-wrap' },- }- : {}- }- customStyle={{- margin: 0,- padding: '8px',- borderRadius: '0 0 4px 4px',- overflow: 'auto',- border: 'none',- }}- PreTag="div"- CodeTag={'code'}- {...props}- >- {code}- </SyntaxHighlighter>- </div>- )- }-)--CodeComponent.displayName = 'CodeComponent'-function RenderMarkdownComponent({content,- enableRawHtml,className,isUser,components,- isWrapping,}: MarkdownProps) {- const { codeBlockStyle, showLineNumbers } = useCodeblock()-- // State for tracking which code block has been copied- const [copiedId, setCopiedId] = useState<string | null>(null)-- // Memoized copy handler- const handleCopy = useCallback((code: string, id: string) => {- navigator.clipboard.writeText(code)- setCopiedId(id)-- // Reset copied state after 2 seconds- setTimeout(() => {- setCopiedId(null)- }, 2000)- }, [])+ // const { codeBlockStyle, showLineNumbers } = useCodeblock()// Memoize the normalized content to avoid reprocessing on every renderconst normalizedContent = useMemo(() => normalizeLatex(content), [content])- // Stable remarkPlugins reference- const remarkPlugins = useMemo(() => {- return [remarkGfm, remarkMath, remarkEmoji, remarkBreaks]- }, [])-- // Stable rehypePlugins reference- const rehypePlugins = useMemo(() => {- return enableRawHtml ? [rehypeKatex, rehypeRaw] : [rehypeKatex]- }, [enableRawHtml])-- // Memoized components with stable references- const markdownComponents: Components = useMemo(- () => ({- code: (props) => (- <CodeComponent- {...props}- isUser={isUser}- codeBlockStyle={codeBlockStyle}- showLineNumbers={showLineNumbers}- isWrapping={isWrapping}- onCopy={handleCopy}- copiedId={copiedId}- />- ),- // Add other optimized components if needed- ...components,- }),- [- isUser,- codeBlockStyle,- showLineNumbers,- isWrapping,- handleCopy,- copiedId,- components,- ]- )-// Render the markdown contentreturn (<div@@ -274,13 +91,22 @@ function RenderMarkdownComponent({className)}>- <ReactMarkdown- remarkPlugins={remarkPlugins}- rehypePlugins={rehypePlugins}- components={markdownComponents}+ <Streamdown+ animate={true}+ animationDuration={500}+ className={cn(+ 'size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0',+ className+ )}+ remarkPlugins={[remarkGfm, remarkMath]}+ rehypePlugins={[+ defaultRehypePlugins.katex,+ defaultRehypePlugins.harden,+ ]}+ components={components}>{normalizedContent}- </ReactMarkdown>+ </Streamdown></div>)}diff --git a/web-app/src/containers/ThreadContent.tsx b/web-app/src/containers/ThreadContent.tsxindex 4816fc15f..32f165217 100644--- a/web-app/src/containers/ThreadContent.tsx+++ b/web-app/src/containers/ThreadContent.tsx@@ -1,7 +1,15 @@/* eslint-disable @typescript-eslint/no-explicit-any */import { ThreadMessage } from '@janhq/core'import { RenderMarkdown } from './RenderMarkdown'-import React, { Fragment, memo, useCallback, useMemo, useState } from 'react'+import React, {+ Fragment,+ memo,+ useCallback,+ useEffect,+ useMemo,+ useRef,+ useState,+} from 'react'import {IconCopy,IconCopyCheck,@@ -12,7 +20,6 @@ import {import { useAppState } from '@/hooks/useAppState'import { cn } from '@/lib/utils'import { useMessages } from '@/hooks/useMessages'-import ThinkingBlock from '@/containers/ThinkingBlock'import ToolCallBlock from '@/containers/ToolCallBlock'import { useChat } from '@/hooks/useChat'import {@@ -42,6 +49,20 @@ import {DialogTitle,} from '@/components/ui/dialog'+import { twMerge } from 'tailwind-merge'+import {+ Reasoning,+ ReasoningContent,+ ReasoningTrigger,+} from '@/ai-elements/reasoning'+import {+ Tool,+ ToolContent,+ ToolHeader,+ ToolInput,+ ToolOutput,+} from '@/ai-elements/tool'+const CopyButton = ({ text }: { text: string }) => {const [copied, setCopied] = useState(false)const { t } = useTranslation()@@ -96,9 +117,12 @@ export const ThreadContent = memo() => {const { t } = useTranslation()const selectedModel = useModelProvider((state) => state.selectedModel)- const [inlinePreview, setInlinePreview] = useState<- { name: string; content: string } | null- >(null)+ const [inlinePreview, setInlinePreview] = useState<{+ name: string+ content: string+ } | null>(null)++ const reasoningContainerRef = useRef<HTMLDivElement>(null)// Use useMemo to stabilize the components propconst linkComponents = useMemo(@@ -194,7 +218,8 @@ export const ThreadContent = memo(deleteMessage(toSendMessage.thread_id, toSendMessage.id ?? '')// Extract text content and any attachmentsconst rawText =- toSendMessage.content?.find((c) => c.type === 'text')?.text?.value || ''+ toSendMessage.content?.find((c) => c.type === 'text')?.text?.value ||+ ''const { cleanPrompt: textContent } = extractFilesFromPrompt(rawText)const attachments = toSendMessage.content?.filter((c) => (c.type === 'image_url' && c.image_url?.url) || false)@@ -256,6 +281,13 @@ export const ThreadContent = memo(| { avatar?: React.ReactNode; name?: React.ReactNode }| undefined+ // Auto-scroll reasoning container to bottom during streaming+ useEffect(() => {+ if (reasoningContainerRef.current) {+ reasoningContainerRef.current.scrollTop =+ reasoningContainerRef.current.scrollHeight+ }+ }, [item.content])return (<Fragment>{item.role === 'user' && (@@ -439,40 +471,88 @@ export const ThreadContent = memo()}{reasoningSegment && (- <ThinkingBlock- id={- item.isLastMessage- ? `${item.thread_id}-last-${reasoningSegment.slice(0, 50).replace(/\s/g, '').slice(-10)}`- : `${item.thread_id}-${item.index ?? item.id}`- }- text={reasoningSegment}- />+ <Reasoning+ className="w-full text-muted-foreground"+ isStreaming={!!item.streamingThread}+ defaultOpen={!!item.streamingThread && item.isLastMessage}+ >+ <ReasoningTrigger />+ <div className="relative">+ {!!item.streamingThread && (+ <div className="absolute top-0 left-0 right-0 h-8 bg-linear-to-br from-background to-transparent pointer-events-none z-10" />+ )}+ <div+ ref={!!item.streamingThread ? reasoningContainerRef : null}+ className={twMerge(+ 'w-full overflow-auto relative',+ !!item.streamingThread+ ? 'max-h-32 opacity-70 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden'+ : 'h-auto opacity-100'+ )}+ >+ <ReasoningContent isStreaming={!!item.streamingThread}>+ {reasoningSegment}+ </ReasoningContent>+ </div>+ </div>+ </Reasoning>)}<RenderMarkdowncontent={textSegment.replace('</think>', '')}components={linkComponents}+ isStreaming={item.isLastMessage && isStreamingThisThread}/>{isToolCalls && item.metadata?.tool_calls ? (<>{(item.metadata.tool_calls as ToolCall[]).map((toolCall) => (- <ToolCallBlock- id={toolCall.tool?.id ?? 0}- key={toolCall.tool?.id}- name={- (item.streamTools?.tool_calls?.function?.name ||- toolCall.tool?.function?.name) ??- ''- }- args={- item.streamTools?.tool_calls?.function?.arguments ||- toolCall.tool?.function?.arguments ||- undefined+ <Tool+ key={toolCall.tool?.id ?? 0}+ state={+ toolCall.state === 'pending'+ ? 'input-available'+ : 'output-available'}- result={JSON.stringify(toolCall.response)}- loading={toolCall.state === 'pending'}- />+ // className={cn(hasContentBefore && isFirstTool && 'mt-4')}+ >+ <ToolHeader+ title={+ (item.streamTools?.tool_calls?.function?.name ||+ toolCall.tool?.function?.name) ??+ ''+ }+ type={+ `tool-${toolCall.tool?.function?.name}` as `tool-${string}`+ }+ />+ <ToolContent+ title={+ (item.streamTools?.tool_calls?.function?.name ||+ toolCall.tool?.function?.name) ??+ 'Tool Details'+ }+ >+ <ToolInput+ input={+ item.streamTools?.tool_calls?.function?.arguments ||+ toolCall.tool?.function?.arguments ||+ undefined+ }+ />+ {!!toolCall.response && (+ <ToolOutput+ output={toolCall.response}+ errorText={+ (toolCall.response.parseError as boolean)+ ? toolCall.response+ : undefined+ }+ resolver={(input) => Promise.resolve(input)}+ />+ )}+ </ToolContent>+ </Tool>))}</>) : null}diff --git a/web-app/src/containers/ToolCallBlock.tsx b/web-app/src/containers/ToolCallBlock.tsxindex 4442702da..5631aecf7 100644--- a/web-app/src/containers/ToolCallBlock.tsx+++ b/web-app/src/containers/ToolCallBlock.tsx@@ -193,7 +193,6 @@ const ToolCallBlock = ({ id, name, result, loading, args }: Props) => {<><p className="mb-3">Arguments:</p><RenderMarkdown- isWrapping={true}content={'```json\n' + args + '\n```'}/></>diff --git a/web-app/src/index.css b/web-app/src/index.cssindex 349b36f21..a85d1fd91 100644--- a/web-app/src/index.css+++ b/web-app/src/index.css@@ -2,6 +2,8 @@@import 'tw-animate-css';@import '@/styles/font.css';@import '@/styles/markdown.css';+@source '../node_modules/streamdown/dist/**/*.js';+@custom-variant dark (&:is(.dark *));@theme inline {@@ -35,6 +37,26 @@--text-7xl: calc(var(--font-size-base) * 4.5); /* ~72px */--text-8xl: calc(var(--font-size-base) * 6); /* ~96px */--text-9xl: calc(var(--font-size-base) * 8); /* ~128px */++ --muted-foreground: oklch(0.556 0 0);+ --color-background: var(--background);+ --color-foreground: var(--foreground);+ --color-card: var(--card);+ --color-card-foreground: var(--card-foreground);+ --color-popover: var(--popover);+ --color-popover-foreground: var(--popover-foreground);+ --color-primary-foreground: var(--primary-foreground);+ --color-secondary: var(--secondary);+ --color-secondary-foreground: var(--secondary-foreground);+ --color-muted-foreground: var(--muted-foreground);+ --color-border: var(--border);+ --color-input: var(--input);+ --color-chart-1: var(--chart-1);+ --color-chart-2: var(--chart-2);+ --color-chart-3: var(--chart-3);+ --color-chart-4: var(--chart-4);+ --color-chart-5: var(--chart-5);+ --color-streamdown-caret: var(--streamdown-caret);}:root {diff --git a/web-app/src/styles/markdown.css b/web-app/src/styles/markdown.cssindex ad58dd87e..e8e7e9fd9 100644--- a/web-app/src/styles/markdown.css+++ b/web-app/src/styles/markdown.css@@ -1,6 +1,56 @@.markdown {@apply text-inherit;+ --background: oklch(1 0 0);+ --foreground: oklch(0.145 0 0);+ --card: oklch(1 0 0);+ --card-foreground: oklch(0.145 0 0);+ --popover: oklch(1 0 0);+ --popover-foreground: oklch(0.145 0 0);+ --primary: oklch(0.7003 0.1611 35.09);+ --primary-foreground: oklch(0.985 0 0);+ --secondary: oklch(0.97 0 0);+ --secondary-foreground: oklch(0.205 0 0);+ /* --muted: oklch(0.97 0 0); */+ --muted-foreground: oklch(0.556 0 0);+ --accent: oklch(0.97 0 0);+ --accent-foreground: oklch(0.205 0 0);+ --destructive: oklch(0.577 0.245 27.325);+ --border: oklch(0.922 0 0);+ --input: oklch(0.922 0 0);+ --ring: oklch(0.708 0 0);+ --chart-1: oklch(0.646 0.222 41.116);+ --chart-2: oklch(0.6 0.118 184.704);+ --chart-3: oklch(0.398 0.07 227.392);+ --chart-4: oklch(0.828 0.189 84.429);+ --chart-5: oklch(0.769 0.188 70.08);++ &:is(.dark *) {+ --background: oklch(0.18 0 0);+ --foreground: oklch(0.985 0 0);+ --card: oklch(0.205 0 0);+ --card-foreground: oklch(0.985 0 0);+ --popover: oklch(0.205 0 0);+ --popover-foreground: oklch(0.985 0 0);+ --primary: oklch(0.7003 0.1611 35.09);+ --primary-foreground: oklch(0.205 0 0);+ --secondary: oklch(0.269 0 0);+ --secondary-foreground: oklch(0.985 0 0);+ --muted: oklch(0.269 0 0);+ --muted-foreground: oklch(0.708 0 0);+ --accent: oklch(0.269 0 0);+ --accent-foreground: oklch(0.985 0 0);+ --destructive: oklch(0.704 0.191 22.216);+ --border: oklch(1 0 0 / 10%);+ --input: oklch(1 0 0 / 15%);+ --ring: oklch(0.556 0 0);+ --chart-1: oklch(0.488 0.243 264.376);+ --chart-2: oklch(0.696 0.17 162.48);+ --chart-3: oklch(0.769 0.188 70.08);+ --chart-4: oklch(0.627 0.265 303.9);+ --chart-5: oklch(0.645 0.246 16.439);+ }+&.is-user {p {line-height: 1.6;@@ -208,6 +258,16 @@opacity: 0.2;margin: 2em 0;}++ [data-streamdown="mermaid-block"] {+ border-color: var(--border)+ }++ /* Streamdown caret styling */+ & *:last-child::after {+ color: oklch(0.556 0 0) !important;+ }+}[data-tool-call-block] + [data-tool-call-block] {margin-top: 16px;diff --git a/web-app/src/types/message.d.ts b/web-app/src/types/message.d.tsindex fc7128a45..d086577b2 100644--- a/web-app/src/types/message.d.ts+++ b/web-app/src/types/message.d.ts@@ -6,6 +6,6 @@ type ToolCall = {arguments?: object}}- response?: unknown+ response?: MCPResponsestate?: string}diff --git a/web-app/src/ui/avatar.tsx b/web-app/src/ui/avatar.tsxnew file mode 100644index 000000000..70b4c5c50--- /dev/null+++ b/web-app/src/ui/avatar.tsx@@ -0,0 +1,51 @@+import * as React from "react";+import * as AvatarPrimitive from "@radix-ui/react-avatar";++import { cn } from "../lib/utils";++function Avatar({+ className,+ ...props+}: React.ComponentProps<typeof AvatarPrimitive.Root>) {+ return (+ <AvatarPrimitive.Root+ data-slot="avatar"+ className={cn(+ "relative flex size-8 shrink-0 overflow-hidden rounded-full",+ className,+ )}+ {...props}+ />+ );+}++function AvatarImage({+ className,+ ...props+}: React.ComponentProps<typeof AvatarPrimitive.Image>) {+ return (+ <AvatarPrimitive.Image+ data-slot="avatar-image"+ className={cn("aspect-square size-full", className)}+ {...props}+ />+ );+}++function AvatarFallback({+ className,+ ...props+}: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {+ return (+ <AvatarPrimitive.Fallback+ data-slot="avatar-fallback"+ className={cn(+ "bg-muted flex size-full items-center justify-center rounded-full",+ className,+ )}+ {...props}+ />+ );+}++export { Avatar, AvatarImage, AvatarFallback };diff --git a/web-app/src/ui/badge.tsx b/web-app/src/ui/badge.tsxnew file mode 100644index 000000000..e9a456d9c--- /dev/null+++ b/web-app/src/ui/badge.tsx@@ -0,0 +1,47 @@+/* eslint-disable react-refresh/only-export-components */+import * as React from "react";+import { Slot } from "@radix-ui/react-slot";+import { cva, type VariantProps } from "class-variance-authority";++import { cn } from "../lib/utils";++const badgeVariants = cva(+ "inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",+ {+ variants: {+ variant: {+ default:+ "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",+ secondary:+ "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",+ destructive:+ "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",+ outline:+ "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",+ },+ },+ defaultVariants: {+ variant: "default",+ },+ },+);++function Badge({+ className,+ variant,+ asChild = false,+ ...props+}: React.ComponentProps<"span"> &+ VariantProps<typeof badgeVariants> & { asChild?: boolean }) {+ const Comp = asChild ? Slot : "span";++ return (+ <Comp+ data-slot="badge"+ className={cn(badgeVariants({ variant }), className)}+ {...props}+ />+ );+}++export { Badge, badgeVariants };diff --git a/web-app/src/ui/border-animate.tsx b/web-app/src/ui/border-animate.tsxnew file mode 100644index 000000000..5259557ee--- /dev/null+++ b/web-app/src/ui/border-animate.tsx@@ -0,0 +1,76 @@+/* eslint-disable @typescript-eslint/no-explicit-any */+import { useRef } from "react";+import {+ motion,+ useAnimationFrame,+ useMotionTemplate,+ useMotionValue,+ useTransform,+} from "motion/react";++export const BorderAnimate = ({+ children,+ duration = 3000,+ rx,+ ry,+}: {+ children: React.ReactNode;+ duration?: number;+ rx?: string;+ ry?: string;+ [key: string]: any;+}) => {+ const pathRef = useRef<any>(null);+ const progress = useMotionValue<number>(0);++ useAnimationFrame((time) => {+ const length = pathRef.current?.getTotalLength();+ if (length) {+ const pxPerMillisecond = length / duration;+ progress.set((time * pxPerMillisecond) % length);+ }+ });++ const x = useTransform(+ progress,+ (val) => pathRef.current?.getPointAtLength(val).x,+ );+ const y = useTransform(+ progress,+ (val) => pathRef.current?.getPointAtLength(val).y,+ );++ const transform = useMotionTemplate`translateX(${x}px) translateY(${y}px) translateX(-50%) translateY(-50%)`;++ return (+ <>+ <svg+ xmlns="http://www.w3.org/2000/svg"+ preserveAspectRatio="none"+ className="absolute h-full w-full"+ width="100%"+ height="100%"+ >+ <rect+ fill="none"+ width="100%"+ height="100%"+ rx={rx}+ ry={ry}+ ref={pathRef}+ />+ </svg>+ <motion.div+ style={{+ position: "absolute",+ top: 0,+ left: 0,+ display: "inline-block",+ transform,+ }}+ >+ {children}+ </motion.div>+ </>+ );+};diff --git a/web-app/src/ui/button-group.tsx b/web-app/src/ui/button-group.tsxnew file mode 100644index 000000000..b8db7a4a9--- /dev/null+++ b/web-app/src/ui/button-group.tsx@@ -0,0 +1,84 @@+/* eslint-disable react-refresh/only-export-components */+import { Slot } from "@radix-ui/react-slot";+import { cva, type VariantProps } from "class-variance-authority";++import { cn } from "../lib/utils";+import { Separator } from "./separator";++const buttonGroupVariants = cva(+ "flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",+ {+ variants: {+ orientation: {+ horizontal:+ "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",+ vertical:+ "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none",+ },+ },+ defaultVariants: {+ orientation: "horizontal",+ },+ },+);++function ButtonGroup({+ className,+ orientation,+ ...props+}: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>) {+ return (+ <div+ role="group"+ data-slot="button-group"+ data-orientation={orientation}+ className={cn(buttonGroupVariants({ orientation }), className)}+ {...props}+ />+ );+}++function ButtonGroupText({+ className,+ asChild = false,+ ...props+}: React.ComponentProps<"div"> & {+ asChild?: boolean;+}) {+ const Comp = asChild ? Slot : "div";++ return (+ <Comp+ className={cn(+ "bg-muted flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",+ className,+ )}+ {...props}+ />+ );+}++function ButtonGroupSeparator({+ className,+ orientation = "vertical",+ ...props+}: React.ComponentProps<typeof Separator>) {+ return (+ <Separator+ data-slot="button-group-separator"+ orientation={orientation}+ className={cn(+ "bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto",+ className,+ )}+ {...props}+ />+ );+}++export {+ ButtonGroup,+ ButtonGroupSeparator,+ ButtonGroupText,+ buttonGroupVariants,+};diff --git a/web-app/src/ui/button.tsx b/web-app/src/ui/button.tsxnew file mode 100644index 000000000..90d457964--- /dev/null+++ b/web-app/src/ui/button.tsx@@ -0,0 +1,62 @@+import * as React from "react";+import { Slot } from "@radix-ui/react-slot";+import { cva, type VariantProps } from "class-variance-authority";++import { cn } from "../lib/utils";++const buttonVariants = cva(+ "inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",+ {+ variants: {+ variant: {+ default:+ "bg-primary text-primary-foreground ring-0 transition-[filter] duration-200 hover:brightness-110 active:brightness-95",+ destructive:+ "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",+ outline:+ "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",+ secondary:+ "bg-secondary text-secondary-foreground hover:bg-secondary/80",+ ghost:+ "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",+ link: "text-primary underline-offset-4 hover:underline",+ },+ size: {+ default: "h-9 px-4 py-2 has-[>svg]:px-3",+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",+ icon: "size-9",+ "icon-sm": "size-8",+ "icon-lg": "size-10",+ },+ },+ defaultVariants: {+ variant: "default",+ size: "default",+ },+ },+);++function Button({+ className,+ variant,+ size,+ asChild = false,+ ...props+}: React.ComponentProps<"button"> &+ VariantProps<typeof buttonVariants> & {+ asChild?: boolean;+ }) {+ const Comp = asChild ? Slot : "button";++ return (+ <Comp+ data-slot="button"+ className={cn(buttonVariants({ variant, size, className }))}+ {...props}+ />+ );+}++// eslint-disable-next-line react-refresh/only-export-components+export { Button, buttonVariants };diff --git a/web-app/src/ui/card.tsx b/web-app/src/ui/card.tsxnew file mode 100644index 000000000..1c5e0f12c--- /dev/null+++ b/web-app/src/ui/card.tsx@@ -0,0 +1,92 @@+import * as React from "react";++import { cn } from "../lib/utils";++function Card({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="card"+ className={cn(+ "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",+ className,+ )}+ {...props}+ />+ );+}++function CardHeader({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="card-header"+ className={cn(+ "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",+ className,+ )}+ {...props}+ />+ );+}++function CardTitle({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="card-title"+ className={cn("leading-none font-semibold", className)}+ {...props}+ />+ );+}++function CardDescription({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="card-description"+ className={cn("text-muted-foreground text-sm", className)}+ {...props}+ />+ );+}++function CardAction({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="card-action"+ className={cn(+ "col-start-2 row-span-2 row-start-1 self-start justify-self-end",+ className,+ )}+ {...props}+ />+ );+}++function CardContent({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="card-content"+ className={cn("px-6", className)}+ {...props}+ />+ );+}++function CardFooter({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="card-footer"+ className={cn("flex items-center px-6 [.border-t]:pt-6", className)}+ {...props}+ />+ );+}++export {+ Card,+ CardHeader,+ CardFooter,+ CardTitle,+ CardAction,+ CardDescription,+ CardContent,+};diff --git a/web-app/src/ui/collapsible.tsx b/web-app/src/ui/collapsible.tsxnew file mode 100644index 000000000..849e7b66f--- /dev/null+++ b/web-app/src/ui/collapsible.tsx@@ -0,0 +1,31 @@+import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";++function Collapsible({+ ...props+}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {+ return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;+}++function CollapsibleTrigger({+ ...props+}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {+ return (+ <CollapsiblePrimitive.CollapsibleTrigger+ data-slot="collapsible-trigger"+ {...props}+ />+ );+}++function CollapsibleContent({+ ...props+}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {+ return (+ <CollapsiblePrimitive.CollapsibleContent+ data-slot="collapsible-content"+ {...props}+ />+ );+}++export { Collapsible, CollapsibleTrigger, CollapsibleContent };diff --git a/web-app/src/ui/command.tsx b/web-app/src/ui/command.tsxnew file mode 100644index 000000000..a4b24f1d8--- /dev/null+++ b/web-app/src/ui/command.tsx@@ -0,0 +1,184 @@+import * as React from "react";+import { Command as CommandPrimitive } from "cmdk";+import { SearchIcon } from "lucide-react";+import { useIsMobile } from "../hooks/use-mobile";+import { cn } from "../lib/utils";+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogHeader,+ DialogTitle,+} from "./dialog";++function Command({+ className,+ ...props+}: React.ComponentProps<typeof CommandPrimitive>) {+ return (+ <CommandPrimitive+ data-slot="command"+ className={cn(+ "bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",+ className,+ )}+ {...props}+ />+ );+}++function CommandDialog({+ title = "Command Palette",+ description = "Search for a command to run...",+ children,+ className,+ showCloseButton = true,+ ...props+}: React.ComponentProps<typeof Dialog> & {+ title?: string;+ description?: string;+ className?: string;+ showCloseButton?: boolean;+}) {+ const isMobile = useIsMobile();+ return (+ <Dialog {...props}>+ <DialogHeader className="sr-only">+ <DialogTitle>{title}</DialogTitle>+ <DialogDescription>{description}</DialogDescription>+ </DialogHeader>+ <DialogContent+ onOpenAutoFocus={(e) => (isMobile ? e.preventDefault() : undefined)}+ className={cn("overflow-hidden p-0", className)}+ showCloseButton={showCloseButton}+ >+ <Command className="**:[[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 **:[[cmdk-input]]:h-12 **:[[cmdk-item]]:px-2 **:[[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">+ {children}+ </Command>+ </DialogContent>+ </Dialog>+ );+}++function CommandInput({+ className,+ ...props+}: React.ComponentProps<typeof CommandPrimitive.Input>) {+ return (+ <div+ data-slot="command-input-wrapper"+ className="flex h-9 items-center gap-2 border-b px-3"+ >+ <SearchIcon className="size-4 shrink-0 opacity-50" />+ <CommandPrimitive.Input+ data-slot="command-input"+ className={cn(+ "placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-base outline-hidden disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",+ className,+ )}+ {...props}+ />+ </div>+ );+}++function CommandList({+ className,+ ...props+}: React.ComponentProps<typeof CommandPrimitive.List>) {+ return (+ <CommandPrimitive.List+ data-slot="command-list"+ className={cn(+ "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",+ className,+ )}+ {...props}+ />+ );+}++function CommandEmpty({+ ...props+}: React.ComponentProps<typeof CommandPrimitive.Empty>) {+ return (+ <CommandPrimitive.Empty+ data-slot="command-empty"+ className="py-6 text-center text-sm"+ {...props}+ />+ );+}++function CommandGroup({+ className,+ ...props+}: React.ComponentProps<typeof CommandPrimitive.Group>) {+ return (+ <CommandPrimitive.Group+ data-slot="command-group"+ className={cn(+ "text-foreground **:[[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium",+ className,+ )}+ {...props}+ />+ );+}++function CommandSeparator({+ className,+ ...props+}: React.ComponentProps<typeof CommandPrimitive.Separator>) {+ return (+ <CommandPrimitive.Separator+ data-slot="command-separator"+ className={cn("bg-border -mx-1 h-px", className)}+ {...props}+ />+ );+}++function CommandItem({+ className,+ ...props+}: React.ComponentProps<typeof CommandPrimitive.Item>) {+ return (+ <CommandPrimitive.Item+ data-slot="command-item"+ className={cn(+ "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ className,+ )}+ {...props}+ />+ );+}++function CommandShortcut({+ className,+ ...props+}: React.ComponentProps<"span">) {+ return (+ <span+ data-slot="command-shortcut"+ className={cn(+ "text-muted-foreground ml-auto text-xs tracking-widest",+ className,+ )}+ {...props}+ />+ );+}++export {+ Command,+ CommandDialog,+ CommandInput,+ CommandList,+ CommandEmpty,+ CommandGroup,+ CommandItem,+ CommandShortcut,+ CommandSeparator,+};diff --git a/web-app/src/ui/dialog.tsx b/web-app/src/ui/dialog.tsxnew file mode 100644index 000000000..f960e2359--- /dev/null+++ b/web-app/src/ui/dialog.tsx@@ -0,0 +1,144 @@+import * as React from "react";+import * as DialogPrimitive from "@radix-ui/react-dialog";+import { XIcon } from "lucide-react";++import { cn } from "../lib/utils";++function Dialog({+ ...props+}: React.ComponentProps<typeof DialogPrimitive.Root>) {+ return <DialogPrimitive.Root data-slot="dialog" {...props} />;+}++function DialogTrigger({+ ...props+}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {+ return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;+}++function DialogPortal({+ ...props+}: React.ComponentProps<typeof DialogPrimitive.Portal>) {+ return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;+}++function DialogClose({+ ...props+}: React.ComponentProps<typeof DialogPrimitive.Close>) {+ return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;+}++function DialogOverlay({+ className,+ ...props+}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {+ return (+ <DialogPrimitive.Overlay+ data-slot="dialog-overlay"+ className={cn(+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",+ className,+ )}+ {...props}+ />+ );+}++function DialogContent({+ className,+ children,+ showCloseButton = true,+ ...props+}: React.ComponentProps<typeof DialogPrimitive.Content> & {+ showCloseButton?: boolean;+}) {+ return (+ <DialogPortal data-slot="dialog-portal">+ <DialogOverlay />+ <DialogPrimitive.Content+ data-slot="dialog-content"+ className={cn(+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 max-w-full data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed md:top-[50%] left-[50%] bottom-0 md:bottom-auto translate-y-0 z-50 grid w-full translate-x-[-50%] md:translate-y-[-50%] gap-4 rounded-xl border p-6 shadow-lg duration-200 md:max-w-lg max-h-[calc(100vh-2rem)]",+ className,+ )}+ {...props}+ >+ {children}+ {showCloseButton && (+ <DialogPrimitive.Close+ data-slot="dialog-close"+ className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"+ >+ <XIcon />+ <span className="sr-only">Close</span>+ </DialogPrimitive.Close>+ )}+ </DialogPrimitive.Content>+ </DialogPortal>+ );+}++function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="dialog-header"+ className={cn("flex flex-col gap-2 text-left", className)}+ {...props}+ />+ );+}++function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="dialog-footer"+ className={cn(+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",+ className,+ )}+ {...props}+ />+ );+}++function DialogTitle({+ className,+ ...props+}: React.ComponentProps<typeof DialogPrimitive.Title>) {+ return (+ <DialogPrimitive.Title+ data-slot="dialog-title"+ className={cn(+ "text-base font-studio leading-none font-semibold",+ className,+ )}+ {...props}+ />+ );+}++function DialogDescription({+ className,+ ...props+}: React.ComponentProps<typeof DialogPrimitive.Description>) {+ return (+ <DialogPrimitive.Description+ data-slot="dialog-description"+ className={cn("text-muted-foreground text-sm", className)}+ {...props}+ />+ );+}++export {+ Dialog,+ DialogClose,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogOverlay,+ DialogPortal,+ DialogTitle,+ DialogTrigger,+};diff --git a/web-app/src/ui/drawer.tsx b/web-app/src/ui/drawer.tsxnew file mode 100644index 000000000..69333162f--- /dev/null+++ b/web-app/src/ui/drawer.tsx@@ -0,0 +1,135 @@+"use client";++import * as React from "react";+import { Drawer as DrawerPrimitive } from "vaul";++import { cn } from "../lib/utils";++function Drawer({+ ...props+}: React.ComponentProps<typeof DrawerPrimitive.Root>) {+ return <DrawerPrimitive.Root data-slot="drawer" {...props} />;+}++function DrawerTrigger({+ ...props+}: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {+ return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />;+}++function DrawerPortal({+ ...props+}: React.ComponentProps<typeof DrawerPrimitive.Portal>) {+ return <DrawerPrimitive.Portal data-slot="drawer-portal" {...props} />;+}++function DrawerClose({+ ...props+}: React.ComponentProps<typeof DrawerPrimitive.Close>) {+ return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />;+}++function DrawerOverlay({+ className,+ ...props+}: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {+ return (+ <DrawerPrimitive.Overlay+ data-slot="drawer-overlay"+ className={cn(+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",+ className,+ )}+ {...props}+ />+ );+}++function DrawerContent({+ className,+ children,+ ...props+}: React.ComponentProps<typeof DrawerPrimitive.Content>) {+ return (+ <DrawerPortal data-slot="drawer-portal">+ <DrawerOverlay />+ <DrawerPrimitive.Content+ data-slot="drawer-content"+ className={cn(+ "group/drawer-content bg-background fixed z-50 flex h-auto flex-col",+ "data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b",+ "data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t",+ "data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm",+ "data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm",+ className,+ )}+ {...props}+ >+ <div className="bg-muted mx-auto mt-2 hidden h-2 w-[60px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block" />+ {children}+ </DrawerPrimitive.Content>+ </DrawerPortal>+ );+}++function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="drawer-header"+ className={cn(+ "flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left",+ className,+ )}+ {...props}+ />+ );+}++function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="drawer-footer"+ className={cn("mt-auto flex flex-col gap-2 p-4", className)}+ {...props}+ />+ );+}++function DrawerTitle({+ className,+ ...props+}: React.ComponentProps<typeof DrawerPrimitive.Title>) {+ return (+ <DrawerPrimitive.Title+ data-slot="drawer-title"+ className={cn("text-foreground font-semibold", className)}+ {...props}+ />+ );+}++function DrawerDescription({+ className,+ ...props+}: React.ComponentProps<typeof DrawerPrimitive.Description>) {+ return (+ <DrawerPrimitive.Description+ data-slot="drawer-description"+ className={cn("text-muted-foreground text-sm", className)}+ {...props}+ />+ );+}++export {+ Drawer,+ DrawerPortal,+ DrawerOverlay,+ DrawerTrigger,+ DrawerClose,+ DrawerContent,+ DrawerHeader,+ DrawerFooter,+ DrawerTitle,+ DrawerDescription,+};diff --git a/web-app/src/ui/dropdown-menu.tsx b/web-app/src/ui/dropdown-menu.tsxnew file mode 100644index 000000000..43c4f8138--- /dev/null+++ b/web-app/src/ui/dropdown-menu.tsx@@ -0,0 +1,255 @@+import * as React from "react";+import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";+import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";++import { cn } from "../lib/utils";++function DropdownMenu({+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {+ return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;+}++function DropdownMenuPortal({+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {+ return (+ <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />+ );+}++function DropdownMenuTrigger({+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {+ return (+ <DropdownMenuPrimitive.Trigger+ data-slot="dropdown-menu-trigger"+ {...props}+ />+ );+}++function DropdownMenuContent({+ className,+ sideOffset = 4,+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {+ return (+ <DropdownMenuPrimitive.Portal>+ <DropdownMenuPrimitive.Content+ data-slot="dropdown-menu-content"+ sideOffset={sideOffset}+ className={cn(+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",+ className,+ )}+ {...props}+ />+ </DropdownMenuPrimitive.Portal>+ );+}++function DropdownMenuGroup({+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {+ return (+ <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />+ );+}++function DropdownMenuItem({+ className,+ inset,+ variant = "default",+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {+ inset?: boolean;+ variant?: "default" | "destructive";+}) {+ return (+ <DropdownMenuPrimitive.Item+ data-slot="dropdown-menu-item"+ data-inset={inset}+ data-variant={variant}+ className={cn(+ "focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive! [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ className,+ )}+ {...props}+ />+ );+}++function DropdownMenuCheckboxItem({+ className,+ children,+ checked,+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {+ return (+ <DropdownMenuPrimitive.CheckboxItem+ data-slot="dropdown-menu-checkbox-item"+ className={cn(+ "focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ className,+ )}+ checked={checked}+ {...props}+ >+ <span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">+ <DropdownMenuPrimitive.ItemIndicator>+ <CheckIcon className="size-4" />+ </DropdownMenuPrimitive.ItemIndicator>+ </span>+ {children}+ </DropdownMenuPrimitive.CheckboxItem>+ );+}++function DropdownMenuRadioGroup({+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {+ return (+ <DropdownMenuPrimitive.RadioGroup+ data-slot="dropdown-menu-radio-group"+ {...props}+ />+ );+}++function DropdownMenuRadioItem({+ className,+ children,+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {+ return (+ <DropdownMenuPrimitive.RadioItem+ data-slot="dropdown-menu-radio-item"+ className={cn(+ "focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ className,+ )}+ {...props}+ >+ <span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">+ <DropdownMenuPrimitive.ItemIndicator>+ <CircleIcon className="size-2 fill-current" />+ </DropdownMenuPrimitive.ItemIndicator>+ </span>+ {children}+ </DropdownMenuPrimitive.RadioItem>+ );+}++function DropdownMenuLabel({+ className,+ inset,+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {+ inset?: boolean;+}) {+ return (+ <DropdownMenuPrimitive.Label+ data-slot="dropdown-menu-label"+ data-inset={inset}+ className={cn(+ "px-2 py-1.5 text-sm font-medium data-inset:pl-8",+ className,+ )}+ {...props}+ />+ );+}++function DropdownMenuSeparator({+ className,+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {+ return (+ <DropdownMenuPrimitive.Separator+ data-slot="dropdown-menu-separator"+ className={cn("bg-border -mx-1 my-1 h-px", className)}+ {...props}+ />+ );+}++function DropdownMenuShortcut({+ className,+ ...props+}: React.ComponentProps<"span">) {+ return (+ <span+ data-slot="dropdown-menu-shortcut"+ className={cn(+ "text-muted-foreground ml-auto text-xs tracking-widest",+ className,+ )}+ {...props}+ />+ );+}++function DropdownMenuSub({+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {+ return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />;+}++function DropdownMenuSubTrigger({+ className,+ inset,+ children,+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {+ inset?: boolean;+}) {+ return (+ <DropdownMenuPrimitive.SubTrigger+ data-slot="dropdown-menu-sub-trigger"+ data-inset={inset}+ className={cn(+ "focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ className,+ )}+ {...props}+ >+ {children}+ <ChevronRightIcon className="ml-auto size-4" />+ </DropdownMenuPrimitive.SubTrigger>+ );+}++function DropdownMenuSubContent({+ className,+ ...props+}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {+ return (+ <DropdownMenuPrimitive.SubContent+ data-slot="dropdown-menu-sub-content"+ className={cn(+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",+ className,+ )}+ {...props}+ />+ );+}++export {+ DropdownMenu,+ DropdownMenuPortal,+ DropdownMenuTrigger,+ DropdownMenuContent,+ DropdownMenuGroup,+ DropdownMenuLabel,+ DropdownMenuItem,+ DropdownMenuCheckboxItem,+ DropdownMenuRadioGroup,+ DropdownMenuRadioItem,+ DropdownMenuSeparator,+ DropdownMenuShortcut,+ DropdownMenuSub,+ DropdownMenuSubTrigger,+ DropdownMenuSubContent,+};diff --git a/web-app/src/ui/dropdrawer.tsx b/web-app/src/ui/dropdrawer.tsxnew file mode 100644index 000000000..f2f6f7078--- /dev/null+++ b/web-app/src/ui/dropdrawer.tsx@@ -0,0 +1,974 @@+import { AnimatePresence, motion } from "framer-motion";+import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";+import * as React from "react";++import {+ Drawer,+ DrawerClose,+ DrawerContent,+ DrawerFooter,+ DrawerHeader,+ DrawerTitle,+ DrawerTrigger,+} from "./drawer";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuSub,+ DropdownMenuSubContent,+ DropdownMenuSubTrigger,+ DropdownMenuTrigger,+} from "./dropdown-menu";+import { useIsMobile } from "../hooks/use-mobile";+import { cn } from "../lib/utils";++const DropDrawerContext = React.createContext<{ isMobile: boolean }>({+ isMobile: false,+});++const useDropDrawerContext = () => {+ const context = React.useContext(DropDrawerContext);+ if (!context) {+ throw new Error(+ "DropDrawer components cannot be rendered outside the DropDrawer Context",+ );+ }+ return context;+};++function DropDrawer({+ children,+ ...props+}:+ | React.ComponentProps<typeof Drawer>+ | React.ComponentProps<typeof DropdownMenu>) {+ const isMobile = useIsMobile();+ const DropdownComponent = isMobile ? Drawer : DropdownMenu;++ return (+ <DropDrawerContext.Provider value={{ isMobile }}>+ <DropdownComponent+ data-slot="drop-drawer"+ {...(isMobile && { autoFocus: true })}+ {...props}+ >+ {children}+ </DropdownComponent>+ </DropDrawerContext.Provider>+ );+}++function DropDrawerTrigger({+ className,+ children,+ ...props+}:+ | React.ComponentProps<typeof DrawerTrigger>+ | React.ComponentProps<typeof DropdownMenuTrigger>) {+ const { isMobile } = useDropDrawerContext();+ const TriggerComponent = isMobile ? DrawerTrigger : DropdownMenuTrigger;++ return (+ <TriggerComponent+ data-slot="drop-drawer-trigger"+ className={className}+ {...props}+ >+ {children}+ </TriggerComponent>+ );+}++function DropDrawerContent({+ className,+ children,+ ...props+}:+ | React.ComponentProps<typeof DrawerContent>+ | React.ComponentProps<typeof DropdownMenuContent>) {+ const { isMobile } = useDropDrawerContext();+ const [activeSubmenu, setActiveSubmenu] = React.useState<string | null>(null);+ const [submenuTitle, setSubmenuTitle] = React.useState<string | null>(null);+ const [submenuStack, setSubmenuStack] = React.useState<+ { id: string; title: string }[]+ >([]);+ // Add animation direction state+ const [animationDirection, setAnimationDirection] = React.useState<+ "forward" | "backward"+ >("forward");++ // Store submenu content by ID using state instead of ref+ const [submenuContentCache, setSubmenuContentCache] = React.useState<+ Map<string, React.ReactNode[]>+ >(new Map());++ // Function to navigate to a submenu+ const navigateToSubmenu = React.useCallback((id: string, title: string) => {+ // Set animation direction to forward when navigating to a submenu+ setAnimationDirection("forward");+ setActiveSubmenu(id);+ setSubmenuTitle(title);+ setSubmenuStack((prev) => [...prev, { id, title }]);+ }, []);++ // Function to go back to previous menu+ const goBack = React.useCallback(() => {+ // Set animation direction to backward when going back+ setAnimationDirection("backward");++ if (submenuStack.length <= 1) {+ // If we're at the first level, go back to main menu+ setActiveSubmenu(null);+ setSubmenuTitle(null);+ setSubmenuStack([]);+ } else {+ // Go back to previous submenu+ const newStack = [...submenuStack];+ newStack.pop(); // Remove current+ const previous = newStack[newStack.length - 1];+ setActiveSubmenu(previous.id);+ setSubmenuTitle(previous.title);+ setSubmenuStack(newStack);+ }+ }, [submenuStack]);++ // Function to register submenu content+ const registerSubmenuContent = React.useCallback(+ (id: string, content: React.ReactNode[]) => {+ setSubmenuContentCache((prev) => {+ const newCache = new Map(prev);+ newCache.set(id, content);+ return newCache;+ });+ },+ [],+ );++ // Function to extract submenu content+ const extractSubmenuContent = React.useCallback(+ (elements: React.ReactNode, targetId: string): React.ReactNode[] => {+ const result: React.ReactNode[] = [];++ // Recursive function to search through all children+ const findSubmenuContent = (node: React.ReactNode) => {+ // Skip if not a valid element+ if (!React.isValidElement(node)) return;++ const element = node as React.ReactElement;+ // Use a more specific type to avoid 'any'+ const props = element.props as {+ id?: string;+ "data-submenu-id"?: string;+ children?: React.ReactNode;+ };++ // Check if this is a DropDrawerSub+ if (element.type === DropDrawerSub) {+ // Get all possible ID values+ const elementId = props.id;+ const dataSubmenuId = props["data-submenu-id"];++ // If this is the submenu we're looking for+ if (elementId === targetId || dataSubmenuId === targetId) {+ // Find the SubContent within this Sub+ if (props.children) {+ React.Children.forEach(props.children, (child) => {+ if (+ React.isValidElement(child) &&+ child.type === DropDrawerSubContent+ ) {+ // Add all children of the SubContent to the result+ const subContentProps = child.props as {+ children?: React.ReactNode;+ };+ if (subContentProps.children) {+ React.Children.forEach(+ subContentProps.children,+ (contentChild) => {+ result.push(contentChild);+ },+ );+ }+ }+ });+ }+ return; // Found what we needed, no need to search deeper+ }+ }++ // If this element has children, search through them+ if (props.children) {+ if (Array.isArray(props.children)) {+ props.children.forEach((child: React.ReactNode) =>+ findSubmenuContent(child),+ );+ } else {+ findSubmenuContent(props.children);+ }+ }+ };++ // Start the search from the root elements+ if (Array.isArray(elements)) {+ elements.forEach((child) => findSubmenuContent(child));+ } else {+ findSubmenuContent(elements);+ }++ return result;+ },+ [],+ );++ // Get submenu content (either from cache or extract it)+ const getSubmenuContent = React.useCallback(+ (id: string) => {+ // Check if we have the content in our cache+ const cachedContent = submenuContentCache.get(id || "");+ if (cachedContent && cachedContent.length > 0) {+ return cachedContent;+ }++ // If not in cache, extract it+ const submenuContent = extractSubmenuContent(children, id);++ if (submenuContent.length === 0) {+ return [];+ }++ // Store in cache for future use+ if (id) {+ setSubmenuContentCache((prev) => {+ const newCache = new Map(prev);+ newCache.set(id, submenuContent);+ return newCache;+ });+ }++ return submenuContent;+ },+ [children, extractSubmenuContent, submenuContentCache],+ );++ // Animation variants for Framer Motion+ const variants = {+ enter: (direction: "forward" | "backward") => ({+ x: direction === "forward" ? "100%" : "-100%",+ opacity: 0,+ }),+ center: {+ x: 0,+ opacity: 1,+ },+ exit: (direction: "forward" | "backward") => ({+ x: direction === "forward" ? "-100%" : "100%",+ opacity: 0,+ }),+ };++ if (isMobile) {+ return (+ <SubmenuContext.Provider+ value={{+ activeSubmenu,+ setActiveSubmenu: (id) => {+ if (id === null) {+ setActiveSubmenu(null);+ setSubmenuTitle(null);+ setSubmenuStack([]);+ }+ },+ submenuTitle,+ setSubmenuTitle,+ navigateToSubmenu,+ registerSubmenuContent,+ }}+ >+ <DrawerContent+ data-slot="drop-drawer-content"+ className={cn("max-h-[90vh]", className)}+ {...props}+ >+ {activeSubmenu ? (+ <>+ <DrawerHeader>+ <div className="flex items-center gap-2">+ <button+ onClick={goBack}+ className="hover:bg-muted/50 rounded-full p-1"+ >+ <ChevronLeftIcon className="size-5" />+ </button>+ <DrawerTitle>{submenuTitle || "Submenu"}</DrawerTitle>+ </div>+ </DrawerHeader>+ <div className="flex-1 relative overflow-y-auto max-h-[70vh]">+ {/* Use AnimatePresence to handle exit animations */}+ <AnimatePresence+ initial={false}+ mode="wait"+ custom={animationDirection}+ >+ <motion.div+ key={activeSubmenu || "main"}+ custom={animationDirection}+ variants={variants}+ initial="enter"+ animate="center"+ exit="exit"+ className="pb-6 space-y-1.5 w-full h-full"+ >+ {activeSubmenu+ ? getSubmenuContent(activeSubmenu)+ : children}+ </motion.div>+ </AnimatePresence>+ </div>+ </>+ ) : (+ <>+ <DrawerHeader className="sr-only">+ <DrawerTitle>Menu</DrawerTitle>+ </DrawerHeader>+ <div className="overflow-y-auto max-h-[70vh]">+ <AnimatePresence+ initial={false}+ mode="wait"+ custom={animationDirection}+ >+ <motion.div+ key="main-menu"+ custom={animationDirection}+ variants={variants}+ initial="enter"+ animate="center"+ exit="exit"+ className="pb-6 space-y-1.5 w-full"+ >+ {children}+ </motion.div>+ </AnimatePresence>+ </div>+ </>+ )}+ </DrawerContent>+ </SubmenuContext.Provider>+ );+ }++ return (+ <SubmenuContext.Provider+ value={{+ activeSubmenu,+ setActiveSubmenu,+ submenuTitle,+ setSubmenuTitle,+ registerSubmenuContent,+ }}+ >+ <DropdownMenuContent+ data-slot="drop-drawer-content"+ align="end"+ sideOffset={4}+ className={cn(+ "max-h-(--radix-dropdown-menu-content-available-height) min-w-[220px] overflow-y-auto",+ className,+ )}+ {...props}+ >+ {children}+ </DropdownMenuContent>+ </SubmenuContext.Provider>+ );+}++function DropDrawerItem({+ className,+ children,+ onSelect,+ onClick,+ icon,+ variant = "default",+ inset,+ disabled,+ ...props+}: React.ComponentProps<typeof DropdownMenuItem> & {+ icon?: React.ReactNode;+}) {+ const { isMobile } = useDropDrawerContext();++ // Define hooks outside of conditionals to follow React rules+ // Check if this item is inside a group by looking at parent elements+ const isInGroup = React.useCallback(+ (element: HTMLElement | null): boolean => {+ if (!element) return false;++ // Check if any parent has a data-drop-drawer-group attribute+ let parent = element.parentElement;+ while (parent) {+ if (parent.hasAttribute("data-drop-drawer-group")) {+ return true;+ }+ parent = parent.parentElement;+ }+ return false;+ },+ [],+ );++ // Create a ref to check if the item is in a group+ const itemRef = React.useRef<HTMLDivElement>(null);+ const [isInsideGroup, setIsInsideGroup] = React.useState(false);++ React.useEffect(() => {+ // Only run this effect in mobile mode+ if (!isMobile) return;++ // Use a short timeout to ensure the DOM is fully rendered+ const timer = setTimeout(() => {+ if (itemRef.current) {+ setIsInsideGroup(isInGroup(itemRef.current));+ }+ }, 0);++ return () => clearTimeout(timer);+ }, [isInGroup, isMobile]);++ if (isMobile) {+ const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {+ if (disabled) return;+ if (onClick) onClick(e);+ if (onSelect) onSelect(e as unknown as Event);+ };++ // Only wrap in DrawerClose if it's not a submenu item+ const content = (+ <div+ ref={itemRef}+ data-slot="drop-drawer-item"+ data-variant={variant}+ data-inset={inset}+ data-disabled={disabled}+ className={cn(+ "flex cursor-pointer items-center justify-between px-4 py-2",+ // Only apply margin, background and rounded corners if not in a group+ !isInsideGroup && "mx-2 my-1.5 rounded-md",+ // For items in a group, don't add background but add more padding+ isInsideGroup && "bg-transparent py-4",+ inset && "pl-8",+ variant === "destructive" && "text-destructive dark:text-destructive",+ disabled && "pointer-events-none opacity-50",+ className,+ )}+ onClick={handleClick}+ aria-disabled={disabled}+ {...props}+ >+ <div className="flex items-center gap-2 size-full">{children}</div>+ {icon && <div className="shrink-0">{icon}</div>}+ </div>+ );++ // Check if this is inside a submenu+ const isInSubmenu =+ (props as Record<string, unknown>)["data-parent-submenu-id"] ||+ (props as Record<string, unknown>)["data-parent-submenu"];++ if (isInSubmenu) {+ return content;+ }++ return <DrawerClose asChild>{content}</DrawerClose>;+ }++ return (+ <DropdownMenuItem+ data-slot="drop-drawer-item"+ data-variant={variant}+ data-inset={inset}+ className={className}+ onSelect={onSelect}+ onClick={onClick as React.MouseEventHandler<HTMLDivElement>}+ variant={variant}+ inset={inset}+ disabled={disabled}+ {...props}+ >+ {icon ? (+ <div className="flex w-full items-center justify-between">+ {children}+ <div>{icon}</div>+ </div>+ ) : (+ children+ )}+ </DropdownMenuItem>+ );+}++function DropDrawerSeparator({+ className,+ ...props+}: React.ComponentProps<typeof DropdownMenuSeparator>) {+ const { isMobile } = useDropDrawerContext();++ // For mobile, render a simple divider+ if (isMobile) {+ return null;+ }++ // For desktop, use the standard dropdown separator+ return (+ <DropdownMenuSeparator+ data-slot="drop-drawer-separator"+ className={className}+ {...props}+ />+ );+}++function DropDrawerLabel({+ className,+ children,+ ...props+}:+ | React.ComponentProps<typeof DropdownMenuLabel>+ | React.ComponentProps<typeof DrawerTitle>) {+ const { isMobile } = useDropDrawerContext();++ if (isMobile) {+ return (+ <DrawerHeader className="p-0">+ <DrawerTitle+ data-slot="drop-drawer-label"+ className={cn(+ "text-muted-foreground px-4 py-2 text-sm font-medium",+ className,+ )}+ {...props}+ >+ {children}+ </DrawerTitle>+ </DrawerHeader>+ );+ }++ return (+ <DropdownMenuLabel+ data-slot="drop-drawer-label"+ className={className}+ {...props}+ >+ {children}+ </DropdownMenuLabel>+ );+}++function DropDrawerFooter({+ className,+ children,+ ...props+}: React.ComponentProps<typeof DrawerFooter> | React.ComponentProps<"div">) {+ const { isMobile } = useDropDrawerContext();++ if (isMobile) {+ return (+ <DrawerFooter+ data-slot="drop-drawer-footer"+ className={cn("p-4", className)}+ {...props}+ >+ {children}+ </DrawerFooter>+ );+ }++ // No direct equivalent in DropdownMenu, so we'll just render a div+ return (+ <div+ data-slot="drop-drawer-footer"+ className={cn("p-2", className)}+ {...props}+ >+ {children}+ </div>+ );+}++function DropDrawerGroup({+ className,+ children,+ ...props+}: React.ComponentProps<"div"> & {+ children: React.ReactNode;+}) {+ const { isMobile } = useDropDrawerContext();++ // Add separators between children on mobile+ const childrenWithSeparators = React.useMemo(() => {+ if (!isMobile) return children;++ const childArray = React.Children.toArray(children);++ // Filter out any existing separators+ const filteredChildren = childArray.filter(+ (child) =>+ React.isValidElement(child) && child.type !== DropDrawerSeparator,+ );++ // Add separators between items+ return filteredChildren.flatMap((child, index) => {+ if (index === filteredChildren.length - 1) return [child];+ return [+ child,+ <div+ key={`separator-${index}`}+ className="bg-border h-px"+ aria-hidden="true"+ />,+ ];+ });+ }, [children, isMobile]);++ if (isMobile) {+ return (+ <div+ data-drop-drawer-group+ data-slot="drop-drawer-group"+ role="group"+ className={cn(+ "bg-accent dark:bg-accent mx-2 my-3 overflow-hidden rounded-xl",+ className,+ )}+ {...props}+ >+ {childrenWithSeparators}+ </div>+ );+ }++ // On desktop, use a div with proper role and attributes+ return (+ <div+ data-drop-drawer-group+ data-slot="drop-drawer-group"+ role="group"+ className={className}+ {...props}+ >+ {children}+ </div>+ );+}++// Context for managing submenu state on mobile+interface SubmenuContextType {+ activeSubmenu: string | null;+ setActiveSubmenu: (id: string | null) => void;+ submenuTitle: string | null;+ setSubmenuTitle: (title: string | null) => void;+ navigateToSubmenu?: (id: string, title: string) => void;+ registerSubmenuContent?: (id: string, content: React.ReactNode[]) => void;+}++const SubmenuContext = React.createContext<SubmenuContextType>({+ activeSubmenu: null,+ setActiveSubmenu: () => {},+ submenuTitle: null,+ setSubmenuTitle: () => {},+ navigateToSubmenu: undefined,+ registerSubmenuContent: undefined,+});++// Submenu components+// Counter for generating simple numeric IDs+let submenuIdCounter = 0;++function DropDrawerSub({+ children,+ id,+ ...props+}: React.ComponentProps<typeof DropdownMenuSub> & {+ id?: string;+}) {+ const { isMobile } = useDropDrawerContext();+ const { registerSubmenuContent } = React.useContext(SubmenuContext);++ // Generate a simple numeric ID instead of using React.useId()+ const [generatedId] = React.useState(() => `submenu-${submenuIdCounter++}`);+ const submenuId = id || generatedId;++ // Extract submenu content to register with parent+ React.useEffect(() => {+ if (!registerSubmenuContent) return;++ // Find the SubContent within this Sub+ const contentItems: React.ReactNode[] = [];+ React.Children.forEach(children, (child) => {+ if (React.isValidElement(child) && child.type === DropDrawerSubContent) {+ // Add all children of the SubContent to the result+ React.Children.forEach(+ (child.props as { children?: React.ReactNode }).children,+ (contentChild) => {+ contentItems.push(contentChild);+ },+ );+ }+ });++ // Register the content with the parent+ if (contentItems.length > 0) {+ registerSubmenuContent(submenuId, contentItems);+ }+ }, [children, registerSubmenuContent, submenuId]);++ if (isMobile) {+ // For mobile, we'll use the context to manage submenu state+ // Process children to pass the submenu ID to the trigger and content+ const processedChildren = React.Children.map(children, (child) => {+ if (!React.isValidElement(child)) return child;++ if (child.type === DropDrawerSubTrigger) {+ return React.cloneElement(+ child as React.ReactElement,+ {+ ...(child.props as object),+ "data-parent-submenu-id": submenuId,+ "data-submenu-id": submenuId,+ // Use only data attributes, not custom props+ "data-parent-submenu": submenuId,+ } as React.HTMLAttributes<HTMLElement>,+ );+ }++ if (child.type === DropDrawerSubContent) {+ return React.cloneElement(+ child as React.ReactElement,+ {+ ...(child.props as object),+ "data-parent-submenu-id": submenuId,+ "data-submenu-id": submenuId,+ // Use only data attributes, not custom props+ "data-parent-submenu": submenuId,+ } as React.HTMLAttributes<HTMLElement>,+ );+ }++ return child;+ });++ return (+ <div+ data-slot="drop-drawer-sub"+ data-submenu-id={submenuId}+ id={submenuId}+ >+ {processedChildren}+ </div>+ );+ }++ // For desktop, pass the generated ID to the DropdownMenuSub+ return (+ <DropdownMenuSub+ data-slot="drop-drawer-sub"+ data-submenu-id={submenuId}+ // Don't pass id to DropdownMenuSub as it doesn't accept this prop+ {...props}+ >+ {children}+ </DropdownMenuSub>+ );+}++function DropDrawerSubTrigger({+ className,+ inset,+ children,+ ...props+}: React.ComponentProps<typeof DropdownMenuSubTrigger> & {+ icon?: React.ReactNode;+}) {+ const { isMobile } = useDropDrawerContext();+ const { navigateToSubmenu } = React.useContext(SubmenuContext);++ // Define hooks outside of conditionals to follow React rules+ // Check if this item is inside a group by looking at parent elements+ const isInGroup = React.useCallback(+ (element: HTMLElement | null): boolean => {+ if (!element) return false;++ // Check if any parent has a data-drop-drawer-group attribute+ let parent = element.parentElement;+ while (parent) {+ if (parent.hasAttribute("data-drop-drawer-group")) {+ return true;+ }+ parent = parent.parentElement;+ }+ return false;+ },+ [],+ );++ // Create a ref to check if the item is in a group+ const itemRef = React.useRef<HTMLDivElement>(null);+ const [isInsideGroup, setIsInsideGroup] = React.useState(false);++ React.useEffect(() => {+ // Only run this effect in mobile mode+ if (!isMobile) return;++ // Use a short timeout to ensure the DOM is fully rendered+ const timer = setTimeout(() => {+ if (itemRef.current) {+ setIsInsideGroup(isInGroup(itemRef.current));+ }+ }, 0);++ return () => clearTimeout(timer);+ }, [isInGroup, isMobile]);++ if (isMobile) {+ // Find the parent submenu ID+ const handleClick = (e: React.MouseEvent) => {+ e.preventDefault();+ e.stopPropagation();++ // Get the closest parent with data-submenu-id attribute+ const element = e.currentTarget as HTMLElement;+ let submenuId: string | null = null;++ // First check if the element itself has the data attribute+ if (element.closest("[data-submenu-id]")) {+ const closestElement = element.closest("[data-submenu-id]");+ const id = closestElement?.getAttribute("data-submenu-id");+ if (id) {+ submenuId = id;+ }+ }++ // If not found, try props+ if (!submenuId) {+ submenuId =+ ((props as Record<string, unknown>)[+ "data-parent-submenu-id"+ ] as string) ||+ ((props as Record<string, unknown>)["data-parent-submenu"] as string);+ }++ if (!submenuId) {+ return;+ }++ // Get the title+ const triggerElement = e.currentTarget as HTMLElement;+ const mobileTitle = triggerElement.getAttribute("data-mobile-title");+ const title =+ mobileTitle || (typeof children === "string" ? children : "Submenu");++ // Navigate to the submenu+ if (navigateToSubmenu) {+ navigateToSubmenu(submenuId, title);+ }+ };++ // Combine onClick handlers+ const combinedOnClick = (e: React.MouseEvent) => {+ // Call the original onClick if provided+ const typedProps = props as Record<string, unknown>;+ if (typedProps.onClick) {+ const originalOnClick =+ typedProps.onClick as React.MouseEventHandler<HTMLDivElement>;+ originalOnClick(e as React.MouseEvent<HTMLDivElement>);+ }++ // Call our navigation handler+ handleClick(e);+ };++ // Remove onClick from props to avoid duplicate handlers+ const { ...restProps } = props as Record<string, unknown>;++ // Don't wrap in DrawerClose for submenu triggers+ return (+ <div+ ref={itemRef}+ data-slot="drop-drawer-sub-trigger"+ data-inset={inset}+ className={cn(+ "flex cursor-pointer items-center justify-between px-4 py-4",+ // Only apply margin, background and rounded corners if not in a group+ !isInsideGroup && "mx-2 my-1.5 rounded-md",+ // For items in a group, don't add background but add more padding+ isInsideGroup && "bg-transparent py-4",+ inset && "pl-8",+ className,+ )}+ onClick={combinedOnClick}+ {...restProps}+ >+ <div className="flex items-center gap-2">{children}</div>+ <ChevronRightIcon className="size-5" />+ </div>+ );+ }++ return (+ <DropdownMenuSubTrigger+ data-slot="drop-drawer-sub-trigger"+ data-inset={inset}+ className={className}+ inset={inset}+ {...props}+ >+ {children}+ </DropdownMenuSubTrigger>+ );+}++function DropDrawerSubContent({+ className,+ sideOffset = 4,+ children,+ ...props+}: React.ComponentProps<typeof DropdownMenuSubContent>) {+ const { isMobile } = useDropDrawerContext();++ if (isMobile) {+ // For mobile, we don't render the content directly+ // It will be rendered by the DropDrawerContent component when active+ return null;+ }++ return (+ <DropdownMenuSubContent+ data-slot="drop-drawer-sub-content"+ sideOffset={sideOffset}+ className={cn(+ "z-50 min-w-32 overflow-hidden rounded-md border p-1 shadow-lg",+ className,+ )}+ {...props}+ >+ {children}+ </DropdownMenuSubContent>+ );+}++export {+ DropDrawer,+ DropDrawerContent,+ DropDrawerFooter,+ DropDrawerGroup,+ DropDrawerItem,+ DropDrawerLabel,+ DropDrawerSeparator,+ DropDrawerSub,+ DropDrawerSubContent,+ DropDrawerSubTrigger,+ DropDrawerTrigger,+};diff --git a/web-app/src/ui/empty.tsx b/web-app/src/ui/empty.tsxnew file mode 100644index 000000000..a061adae3--- /dev/null+++ b/web-app/src/ui/empty.tsx@@ -0,0 +1,104 @@+import { cva, type VariantProps } from "class-variance-authority";++import { cn } from "../lib/utils";++function Empty({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="empty"+ className={cn(+ "flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-lg border-dashed p-6 text-center text-balance md:p-12",+ className,+ )}+ {...props}+ />+ );+}++function EmptyHeader({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="empty-header"+ className={cn(+ "flex max-w-sm flex-col items-center gap-2 text-center",+ className,+ )}+ {...props}+ />+ );+}++const emptyMediaVariants = cva(+ "flex shrink-0 items-center justify-center mb-2 [&_svg]:pointer-events-none [&_svg]:shrink-0",+ {+ variants: {+ variant: {+ default: "bg-transparent",+ icon: "bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-6",+ },+ },+ defaultVariants: {+ variant: "default",+ },+ },+);++function EmptyMedia({+ className,+ variant = "default",+ ...props+}: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>) {+ return (+ <div+ data-slot="empty-icon"+ data-variant={variant}+ className={cn(emptyMediaVariants({ variant, className }))}+ {...props}+ />+ );+}++function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="empty-title"+ className={cn("text-lg font-medium tracking-tight", className)}+ {...props}+ />+ );+}++function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) {+ return (+ <div+ data-slot="empty-description"+ className={cn(+ "text-muted-foreground [&>a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4",+ className,+ )}+ {...props}+ />+ );+}++function EmptyContent({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="empty-content"+ className={cn(+ "flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance",+ className,+ )}+ {...props}+ />+ );+}++export {+ Empty,+ EmptyHeader,+ EmptyTitle,+ EmptyDescription,+ EmptyContent,+ EmptyMedia,+};diff --git a/web-app/src/ui/field.tsx b/web-app/src/ui/field.tsxnew file mode 100644index 000000000..7270c2660--- /dev/null+++ b/web-app/src/ui/field.tsx@@ -0,0 +1,246 @@+import { useMemo } from "react";+import { cva, type VariantProps } from "class-variance-authority";++import { cn } from "../lib/utils";+import { Label } from "./label";+import { Separator } from "./separator";++function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {+ return (+ <fieldset+ data-slot="field-set"+ className={cn(+ "flex flex-col gap-6",+ "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",+ className,+ )}+ {...props}+ />+ );+}++function FieldLegend({+ className,+ variant = "legend",+ ...props+}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {+ return (+ <legend+ data-slot="field-legend"+ data-variant={variant}+ className={cn(+ "mb-3 font-medium",+ "data-[variant=legend]:text-base",+ "data-[variant=label]:text-sm",+ className,+ )}+ {...props}+ />+ );+}++function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="field-group"+ className={cn(+ "group/field-group @container/field-group flex w-full flex-col gap-4 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",+ className,+ )}+ {...props}+ />+ );+}++const fieldVariants = cva(+ "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",+ {+ variants: {+ orientation: {+ vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],+ horizontal: [+ "flex-row items-center",+ "[&>[data-slot=field-label]]:flex-auto",+ "has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",+ ],+ responsive: [+ "flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto",+ "@md/field-group:[&>[data-slot=field-label]]:flex-auto",+ "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",+ ],+ },+ },+ defaultVariants: {+ orientation: "vertical",+ },+ },+);++function Field({+ className,+ orientation = "vertical",+ ...props+}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {+ return (+ <div+ role="group"+ data-slot="field"+ data-orientation={orientation}+ className={cn(fieldVariants({ orientation }), className)}+ {...props}+ />+ );+}++function FieldContent({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="field-content"+ className={cn(+ "group/field-content flex flex-1 flex-col gap-1.5 leading-snug",+ className,+ )}+ {...props}+ />+ );+}++function FieldLabel({+ className,+ ...props+}: React.ComponentProps<typeof Label>) {+ return (+ <Label+ data-slot="field-label"+ className={cn(+ "group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",+ "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-4",+ "has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10",+ className,+ )}+ {...props}+ />+ );+}++function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="field-label"+ className={cn(+ "flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",+ className,+ )}+ {...props}+ />+ );+}++function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {+ return (+ <p+ data-slot="field-description"+ className={cn(+ "text-muted-foreground text-sm leading-normal font-normal group-has-data-[orientation=horizontal]/field:text-balance",+ "last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",+ "[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",+ className,+ )}+ {...props}+ />+ );+}++function FieldSeparator({+ children,+ className,+ ...props+}: React.ComponentProps<"div"> & {+ children?: React.ReactNode;+}) {+ return (+ <div+ data-slot="field-separator"+ data-content={!!children}+ className={cn(+ "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",+ className,+ )}+ {...props}+ >+ <Separator className="absolute inset-0 top-1/2" />+ {children && (+ <span+ className="bg-background text-muted-foreground relative mx-auto block w-fit px-2"+ data-slot="field-separator-content"+ >+ {children}+ </span>+ )}+ </div>+ );+}++function FieldError({+ className,+ children,+ errors,+ ...props+}: React.ComponentProps<"div"> & {+ errors?: Array<{ message?: string } | undefined>;+}) {+ const content = useMemo(() => {+ if (children) {+ return children;+ }++ if (!errors?.length) {+ return null;+ }++ const uniqueErrors = [+ ...new Map(errors.map((error) => [error?.message, error])).values(),+ ];++ if (uniqueErrors?.length == 1) {+ return uniqueErrors[0]?.message;+ }++ return (+ <ul className="ml-4 flex list-disc flex-col gap-1">+ {uniqueErrors.map(+ (error, index) =>+ error?.message && <li key={index}>{error.message}</li>,+ )}+ </ul>+ );+ }, [children, errors]);++ if (!content) {+ return null;+ }++ return (+ <div+ role="alert"+ data-slot="field-error"+ className={cn("text-destructive text-sm font-normal", className)}+ {...props}+ >+ {content}+ </div>+ );+}++export {+ Field,+ FieldLabel,+ FieldDescription,+ FieldError,+ FieldGroup,+ FieldLegend,+ FieldSeparator,+ FieldSet,+ FieldContent,+ FieldTitle,+};diff --git a/web-app/src/ui/hover-card.tsx b/web-app/src/ui/hover-card.tsxnew file mode 100644index 000000000..52346e229--- /dev/null+++ b/web-app/src/ui/hover-card.tsx@@ -0,0 +1,42 @@+import * as React from "react";+import * as HoverCardPrimitive from "@radix-ui/react-hover-card";++import { cn } from "../lib/utils";++function HoverCard({+ ...props+}: React.ComponentProps<typeof HoverCardPrimitive.Root>) {+ return <HoverCardPrimitive.Root data-slot="hover-card" {...props} />;+}++function HoverCardTrigger({+ ...props+}: React.ComponentProps<typeof HoverCardPrimitive.Trigger>) {+ return (+ <HoverCardPrimitive.Trigger data-slot="hover-card-trigger" {...props} />+ );+}++function HoverCardContent({+ className,+ align = "center",+ sideOffset = 4,+ ...props+}: React.ComponentProps<typeof HoverCardPrimitive.Content>) {+ return (+ <HoverCardPrimitive.Portal data-slot="hover-card-portal">+ <HoverCardPrimitive.Content+ data-slot="hover-card-content"+ align={align}+ sideOffset={sideOffset}+ className={cn(+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",+ className,+ )}+ {...props}+ />+ </HoverCardPrimitive.Portal>+ );+}++export { HoverCard, HoverCardTrigger, HoverCardContent };diff --git a/web-app/src/ui/input-group.tsx b/web-app/src/ui/input-group.tsxnew file mode 100644index 000000000..b0cb6c460--- /dev/null+++ b/web-app/src/ui/input-group.tsx@@ -0,0 +1,170 @@+"use client";++import * as React from "react";+import { cva, type VariantProps } from "class-variance-authority";++import { cn } from "../lib/utils";+import { Button } from "./button";+import { Input } from "./input";+import { Textarea } from "./textarea";++function InputGroup({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="input-group"+ role="group"+ className={cn(+ "group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none",+ "h-9 min-w-0 has-[>textarea]:h-auto",++ // Variants based on alignment.+ "has-[>[data-align=inline-start]]:[&>input]:pl-2",+ "has-[>[data-align=inline-end]]:[&>input]:pr-2",+ "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",+ "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",++ // Focus state.+ "has-[[data-slot=input-group-control]:focus-visible]:border-ring/60 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-0",++ // Error state.+ "has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",++ className,+ )}+ {...props}+ />+ );+}++const inputGroupAddonVariants = cva(+ "text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",+ {+ variants: {+ align: {+ "inline-start":+ "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",+ "inline-end":+ "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",+ "block-start":+ "order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5",+ "block-end":+ "order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5",+ },+ },+ defaultVariants: {+ align: "inline-start",+ },+ },+);++function InputGroupAddon({+ className,+ align = "inline-start",+ ...props+}: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {+ return (+ <div+ role="group"+ data-slot="input-group-addon"+ data-align={align}+ className={cn(inputGroupAddonVariants({ align }), className)}+ onClick={(e) => {+ if ((e.target as HTMLElement).closest("button")) {+ return;+ }+ e.currentTarget.parentElement?.querySelector("input")?.focus();+ }}+ {...props}+ />+ );+}++const inputGroupButtonVariants = cva(+ "text-sm shadow-none flex gap-2 items-center",+ {+ variants: {+ size: {+ xs: "h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",+ sm: "h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5",+ "icon-xs":+ "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",+ "icon-sm": "size-8 p-0 has-[>svg]:p-0",+ },+ },+ defaultVariants: {+ size: "xs",+ },+ },+);++function InputGroupButton({+ className,+ type = "button",+ variant = "ghost",+ size = "xs",+ ...props+}: Omit<React.ComponentProps<typeof Button>, "size"> &+ VariantProps<typeof inputGroupButtonVariants>) {+ return (+ <Button+ type={type}+ data-size={size}+ variant={variant}+ className={cn(inputGroupButtonVariants({ size }), className)}+ {...props}+ />+ );+}++function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {+ return (+ <span+ className={cn(+ "text-muted-foreground flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",+ className,+ )}+ {...props}+ />+ );+}++function InputGroupInput({+ className,+ ...props+}: React.ComponentProps<"input">) {+ return (+ <Input+ data-slot="input-group-control"+ className={cn(+ "flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",+ className,+ )}+ {...props}+ />+ );+}++function InputGroupTextarea({+ className,+ ...props+}: React.ComponentProps<"textarea">) {+ return (+ <Textarea+ data-slot="input-group-control"+ className={cn(+ "flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",+ className,+ )}+ {...props}+ />+ );+}++export {+ InputGroup,+ InputGroupAddon,+ InputGroupButton,+ InputGroupText,+ InputGroupInput,+ InputGroupTextarea,+};diff --git a/web-app/src/ui/input.tsx b/web-app/src/ui/input.tsxnew file mode 100644index 000000000..172301b5c--- /dev/null+++ b/web-app/src/ui/input.tsx@@ -0,0 +1,21 @@+import * as React from "react";++import { cn } from "../lib/utils";++function Input({ className, type, ...props }: React.ComponentProps<"input">) {+ return (+ <input+ type={type}+ data-slot="input"+ className={cn(+ "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",+ "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",+ "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",+ className,+ )}+ {...props}+ />+ );+}++export { Input };diff --git a/web-app/src/ui/label.tsx b/web-app/src/ui/label.tsxnew file mode 100644index 000000000..630cd0bf5--- /dev/null+++ b/web-app/src/ui/label.tsx@@ -0,0 +1,22 @@+import * as React from "react";+import * as LabelPrimitive from "@radix-ui/react-label";++import { cn } from "../lib/utils";++function Label({+ className,+ ...props+}: React.ComponentProps<typeof LabelPrimitive.Root>) {+ return (+ <LabelPrimitive.Root+ data-slot="label"+ className={cn(+ "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",+ className,+ )}+ {...props}+ />+ );+}++export { Label };diff --git a/web-app/src/ui/popover.tsx b/web-app/src/ui/popover.tsxnew file mode 100644index 000000000..b977c0956--- /dev/null+++ b/web-app/src/ui/popover.tsx@@ -0,0 +1,46 @@+import * as React from "react";+import * as PopoverPrimitive from "@radix-ui/react-popover";++import { cn } from "../lib/utils";++function Popover({+ ...props+}: React.ComponentProps<typeof PopoverPrimitive.Root>) {+ return <PopoverPrimitive.Root data-slot="popover" {...props} />;+}++function PopoverTrigger({+ ...props+}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {+ return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;+}++function PopoverContent({+ className,+ align = "center",+ sideOffset = 4,+ ...props+}: React.ComponentProps<typeof PopoverPrimitive.Content>) {+ return (+ <PopoverPrimitive.Portal>+ <PopoverPrimitive.Content+ data-slot="popover-content"+ align={align}+ sideOffset={sideOffset}+ className={cn(+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",+ className,+ )}+ {...props}+ />+ </PopoverPrimitive.Portal>+ );+}++function PopoverAnchor({+ ...props+}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {+ return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />;+}++export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };diff --git a/web-app/src/ui/select.tsx b/web-app/src/ui/select.tsxnew file mode 100644index 000000000..6426d6ade--- /dev/null+++ b/web-app/src/ui/select.tsx@@ -0,0 +1,187 @@+"use client";++import * as React from "react";+import * as SelectPrimitive from "@radix-ui/react-select";+import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";++import { cn } from "../lib/utils";++function Select({+ ...props+}: React.ComponentProps<typeof SelectPrimitive.Root>) {+ return <SelectPrimitive.Root data-slot="select" {...props} />;+}++function SelectGroup({+ ...props+}: React.ComponentProps<typeof SelectPrimitive.Group>) {+ return <SelectPrimitive.Group data-slot="select-group" {...props} />;+}++function SelectValue({+ ...props+}: React.ComponentProps<typeof SelectPrimitive.Value>) {+ return <SelectPrimitive.Value data-slot="select-value" {...props} />;+}++function SelectTrigger({+ className,+ size = "default",+ children,+ ...props+}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {+ size?: "sm" | "default";+}) {+ return (+ <SelectPrimitive.Trigger+ data-slot="select-trigger"+ data-size={size}+ className={cn(+ "border-input data-placeholder:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ className,+ )}+ {...props}+ >+ {children}+ <SelectPrimitive.Icon asChild>+ <ChevronDownIcon className="size-4 opacity-50" />+ </SelectPrimitive.Icon>+ </SelectPrimitive.Trigger>+ );+}++function SelectContent({+ className,+ children,+ position = "popper",+ align = "center",+ ...props+}: React.ComponentProps<typeof SelectPrimitive.Content>) {+ return (+ <SelectPrimitive.Portal>+ <SelectPrimitive.Content+ data-slot="select-content"+ className={cn(+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",+ position === "popper" &&+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",+ className,+ )}+ position={position}+ align={align}+ {...props}+ >+ <SelectScrollUpButton />+ <SelectPrimitive.Viewport+ className={cn(+ "p-1",+ position === "popper" &&+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1",+ )}+ >+ {children}+ </SelectPrimitive.Viewport>+ <SelectScrollDownButton />+ </SelectPrimitive.Content>+ </SelectPrimitive.Portal>+ );+}++function SelectLabel({+ className,+ ...props+}: React.ComponentProps<typeof SelectPrimitive.Label>) {+ return (+ <SelectPrimitive.Label+ data-slot="select-label"+ className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}+ {...props}+ />+ );+}++function SelectItem({+ className,+ children,+ ...props+}: React.ComponentProps<typeof SelectPrimitive.Item>) {+ return (+ <SelectPrimitive.Item+ data-slot="select-item"+ className={cn(+ "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",+ className,+ )}+ {...props}+ >+ <span className="absolute right-2 flex size-3.5 items-center justify-center">+ <SelectPrimitive.ItemIndicator>+ <CheckIcon className="size-4" />+ </SelectPrimitive.ItemIndicator>+ </span>+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>+ </SelectPrimitive.Item>+ );+}++function SelectSeparator({+ className,+ ...props+}: React.ComponentProps<typeof SelectPrimitive.Separator>) {+ return (+ <SelectPrimitive.Separator+ data-slot="select-separator"+ className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)}+ {...props}+ />+ );+}++function SelectScrollUpButton({+ className,+ ...props+}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {+ return (+ <SelectPrimitive.ScrollUpButton+ data-slot="select-scroll-up-button"+ className={cn(+ "flex cursor-default items-center justify-center py-1",+ className,+ )}+ {...props}+ >+ <ChevronUpIcon className="size-4" />+ </SelectPrimitive.ScrollUpButton>+ );+}++function SelectScrollDownButton({+ className,+ ...props+}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {+ return (+ <SelectPrimitive.ScrollDownButton+ data-slot="select-scroll-down-button"+ className={cn(+ "flex cursor-default items-center justify-center py-1",+ className,+ )}+ {...props}+ >+ <ChevronDownIcon className="size-4" />+ </SelectPrimitive.ScrollDownButton>+ );+}++export {+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectLabel,+ SelectScrollDownButton,+ SelectScrollUpButton,+ SelectSeparator,+ SelectTrigger,+ SelectValue,+};diff --git a/web-app/src/ui/separator.tsx b/web-app/src/ui/separator.tsxnew file mode 100644index 000000000..4e1403417--- /dev/null+++ b/web-app/src/ui/separator.tsx@@ -0,0 +1,26 @@+import * as React from "react";+import * as SeparatorPrimitive from "@radix-ui/react-separator";++import { cn } from "../lib/utils";++function Separator({+ className,+ orientation = "horizontal",+ decorative = true,+ ...props+}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {+ return (+ <SeparatorPrimitive.Root+ data-slot="separator"+ decorative={decorative}+ orientation={orientation}+ className={cn(+ "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",+ className,+ )}+ {...props}+ />+ );+}++export { Separator };diff --git a/web-app/src/ui/sheet.tsx b/web-app/src/ui/sheet.tsxnew file mode 100644index 000000000..ca8cc2e87--- /dev/null+++ b/web-app/src/ui/sheet.tsx@@ -0,0 +1,143 @@+import * as React from "react";+import * as SheetPrimitive from "@radix-ui/react-dialog";+import { XIcon } from "lucide-react";++import { cn } from "../lib/utils";++function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {+ return <SheetPrimitive.Root data-slot="sheet" {...props} />;+}++function SheetTrigger({+ ...props+}: React.ComponentProps<typeof SheetPrimitive.Trigger>) {+ return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />;+}++function SheetClose({+ ...props+}: React.ComponentProps<typeof SheetPrimitive.Close>) {+ return <SheetPrimitive.Close data-slot="sheet-close" {...props} />;+}++function SheetPortal({+ ...props+}: React.ComponentProps<typeof SheetPrimitive.Portal>) {+ return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;+}++function SheetOverlay({+ className,+ hideOverlayBackdrop,+ ...props+}: React.ComponentProps<typeof SheetPrimitive.Overlay> & {+ hideOverlayBackdrop?: boolean;+}) {+ return (+ <SheetPrimitive.Overlay+ data-slot="sheet-overlay"+ className={cn(+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",+ hideOverlayBackdrop && "bg-transparent",+ className,+ )}+ {...props}+ />+ );+}++function SheetContent({+ className,+ children,+ side = "right",+ hideOverlayBackdrop = false,+ ...props+}: React.ComponentProps<typeof SheetPrimitive.Content> & {+ side?: "top" | "right" | "bottom" | "left";+ hideOverlayBackdrop?: boolean;+}) {+ return (+ <SheetPortal>+ <SheetOverlay hideOverlayBackdrop={hideOverlayBackdrop} />+ <SheetPrimitive.Content+ data-slot="sheet-content"+ className={cn(+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",+ side === "right" &&+ "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",+ side === "left" &&+ "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",+ side === "top" &&+ "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",+ side === "bottom" &&+ "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",+ className,+ )}+ {...props}+ >+ {children}+ <SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">+ <XIcon className="size-4" />+ <span className="sr-only">Close</span>+ </SheetPrimitive.Close>+ </SheetPrimitive.Content>+ </SheetPortal>+ );+}++function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="sheet-header"+ className={cn("flex flex-col gap-1.5 p-4", className)}+ {...props}+ />+ );+}++function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="sheet-footer"+ className={cn("mt-auto flex flex-col gap-2 p-4", className)}+ {...props}+ />+ );+}++function SheetTitle({+ className,+ ...props+}: React.ComponentProps<typeof SheetPrimitive.Title>) {+ return (+ <SheetPrimitive.Title+ data-slot="sheet-title"+ className={cn("text-foreground font-semibold", className)}+ {...props}+ />+ );+}++function SheetDescription({+ className,+ ...props+}: React.ComponentProps<typeof SheetPrimitive.Description>) {+ return (+ <SheetPrimitive.Description+ data-slot="sheet-description"+ className={cn("text-muted-foreground text-sm", className)}+ {...props}+ />+ );+}++export {+ Sheet,+ SheetTrigger,+ SheetClose,+ SheetContent,+ SheetHeader,+ SheetFooter,+ SheetTitle,+ SheetDescription,+};diff --git a/web-app/src/ui/skeleton.tsx b/web-app/src/ui/skeleton.tsxnew file mode 100644index 000000000..6f53ff979--- /dev/null+++ b/web-app/src/ui/skeleton.tsx@@ -0,0 +1,13 @@+import { cn } from "../lib/utils";++function Skeleton({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="skeleton"+ className={cn("bg-accent animate-pulse rounded-md", className)}+ {...props}+ />+ );+}++export { Skeleton };diff --git a/web-app/src/ui/sonner.tsx b/web-app/src/ui/sonner.tsxnew file mode 100644index 000000000..2706cb8a3--- /dev/null+++ b/web-app/src/ui/sonner.tsx@@ -0,0 +1,40 @@+/* eslint-disable react-refresh/only-export-components */+import {+ CircleCheckIcon,+ InfoIcon,+ Loader2Icon,+ OctagonXIcon,+ TriangleAlertIcon,+} from "lucide-react";+import { useTheme } from "@/components/themes/theme-provider";+import { Toaster as Sonner, toast, type ToasterProps } from "sonner";++const Toaster = ({ ...props }: ToasterProps) => {+ const { theme = "system" } = useTheme();++ return (+ <Sonner+ theme={theme as ToasterProps["theme"]}+ className="toaster group"+ icons={{+ success: <CircleCheckIcon className="size-4" />,+ info: <InfoIcon className="size-4" />,+ warning: <TriangleAlertIcon className="size-4" />,+ error: <OctagonXIcon className="size-4" />,+ loading: <Loader2Icon className="size-4 animate-spin" />,+ }}+ style={+ {+ "--normal-bg": "var(--popover)",+ "--normal-text": "var(--popover-foreground)",+ "--normal-border": "var(--border)",+ "--border-radius": "var(--radius)",+ "--width": "max-content",+ } as React.CSSProperties+ }+ {...props}+ />+ );+};++export { Toaster, toast };diff --git a/web-app/src/ui/switch.tsx b/web-app/src/ui/switch.tsxnew file mode 100644index 000000000..082d1cff0--- /dev/null+++ b/web-app/src/ui/switch.tsx@@ -0,0 +1,29 @@+import * as React from "react";+import * as SwitchPrimitive from "@radix-ui/react-switch";++import { cn } from "../lib/utils";++function Switch({+ className,+ ...props+}: React.ComponentProps<typeof SwitchPrimitive.Root>) {+ return (+ <SwitchPrimitive.Root+ data-slot="switch"+ className={cn(+ "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-10 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",+ className,+ )}+ {...props}+ >+ <SwitchPrimitive.Thumb+ data-slot="switch-thumb"+ className={cn(+ "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%+6px)] data-[state=unchecked]:translate-x-0",+ )}+ />+ </SwitchPrimitive.Root>+ );+}++export { Switch };diff --git a/web-app/src/ui/textarea.tsx b/web-app/src/ui/textarea.tsxnew file mode 100644index 000000000..a04a420b9--- /dev/null+++ b/web-app/src/ui/textarea.tsx@@ -0,0 +1,18 @@+import * as React from "react";++import { cn } from "../lib/utils";++function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {+ return (+ <textarea+ data-slot="textarea"+ className={cn(+ "border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",+ className,+ )}+ {...props}+ />+ );+}++export { Textarea };diff --git a/web-app/src/ui/tooltip.tsx b/web-app/src/ui/tooltip.tsxnew file mode 100644index 000000000..f41fd9bf6--- /dev/null+++ b/web-app/src/ui/tooltip.tsx@@ -0,0 +1,59 @@+import * as React from "react";+import * as TooltipPrimitive from "@radix-ui/react-tooltip";++import { cn } from "../lib/utils";++function TooltipProvider({+ delayDuration = 0,+ ...props+}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {+ return (+ <TooltipPrimitive.Provider+ data-slot="tooltip-provider"+ delayDuration={delayDuration}+ {...props}+ />+ );+}++function Tooltip({+ ...props+}: React.ComponentProps<typeof TooltipPrimitive.Root>) {+ return (+ <TooltipProvider>+ <TooltipPrimitive.Root data-slot="tooltip" {...props} />+ </TooltipProvider>+ );+}++function TooltipTrigger({+ ...props+}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;+}++function TooltipContent({+ className,+ sideOffset = 0,+ children,+ ...props+}: React.ComponentProps<typeof TooltipPrimitive.Content>) {+ return (+ <TooltipPrimitive.Portal>+ <TooltipPrimitive.Content+ data-slot="tooltip-content"+ sideOffset={sideOffset}+ className={cn(+ "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",+ className,+ )}+ {...props}+ >+ {children}+ <TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]" />+ </TooltipPrimitive.Content>+ </TooltipPrimitive.Portal>+ );+}++export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };