Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

refactor: Remove deprecated react api usage (#2034)

Mike Fortmanbc8254281f95
diff --git a/frontend/app/chat/_components/chat-input.tsx b/frontend/app/chat/_components/chat-input.tsx
index 31123a391..f6af3b102 100644
--- a/frontend/app/chat/_components/chat-input.tsx
+++ b/frontend/app/chat/_components/chat-input.tsx
@@ -1,13 +1,7 @@
import Fuse from "fuse.js";
import { ArrowRight, Check, Funnel, Loader2, Plus } from "lucide-react";
import { AnimatePresence, motion } from "motion/react";
-import {
- forwardRef,
- useImperativeHandle,
- useMemo,
- useRef,
- useState,
-} from "react";
+import { useImperativeHandle, useMemo, useRef, useState } from "react";
import { useDropzone } from "react-dropzone";
import TextareaAutosize from "react-textarea-autosize";
import { toast } from "sonner";
@@ -55,609 +49,594 @@ interface ChatInputProps {
const SAFE_SINGLE_LINE_CHARS = 80; // Number of chars that can safely fit in one line without wrapping, used to determine when to switch to multi-line mode
-export const ChatInput = forwardRef<ChatInputHandle, ChatInputProps>(
- (
- {
- input,
- loading,
- isUploading,
- ingestViaChat,
- selectedFilter,
- parsedFilterData,
- uploadedFile,
- onSubmit,
- onChange,
- onKeyDown,
- onFilterSelect,
- onFilePickerClick,
- setSelectedFilter,
- setIsFilterHighlighted,
- onFileSelected,
- },
- ref,
- ) => {
- const inputRef = useRef<HTMLTextAreaElement>(null);
- const fileInputRef = useRef<HTMLInputElement>(null);
- const [isWrapped, setIsWrapped] = useState(false);
- const isMultiline = input.includes("\n") || isWrapped;
- const isDragging = useFileDrag();
- const isCloudBrand = useIsCloudBrand();
-
- // Internal state for filter dropdown
- const [isFilterDropdownOpen, setIsFilterDropdownOpen] = useState(false);
- const [filterSearchTerm, setFilterSearchTerm] = useState("");
- const [selectedFilterIndex, setSelectedFilterIndex] = useState(0);
- const [anchorPosition, setAnchorPosition] = useState<{
- x: number;
- y: number;
- } | null>(null);
-
- // Fetch all filters once when dropdown opens
- const { data: allFilters = [] } = useGetAllFiltersQuery({
- enabled: isFilterDropdownOpen,
+export function ChatInput({
+ input,
+ loading,
+ isUploading,
+ ingestViaChat,
+ selectedFilter,
+ parsedFilterData,
+ uploadedFile,
+ onSubmit,
+ onChange,
+ onKeyDown,
+ onFilterSelect,
+ onFilePickerClick,
+ setSelectedFilter,
+ setIsFilterHighlighted,
+ onFileSelected,
+ ref,
+}: ChatInputProps & { ref?: React.Ref<ChatInputHandle> }) {
+ const inputRef = useRef<HTMLTextAreaElement>(null);
+ const fileInputRef = useRef<HTMLInputElement>(null);
+ const [isWrapped, setIsWrapped] = useState(false);
+ const isMultiline = input.includes("\n") || isWrapped;
+ const isDragging = useFileDrag();
+ const isCloudBrand = useIsCloudBrand();
+
+ // Internal state for filter dropdown
+ const [isFilterDropdownOpen, setIsFilterDropdownOpen] = useState(false);
+ const [filterSearchTerm, setFilterSearchTerm] = useState("");
+ const [selectedFilterIndex, setSelectedFilterIndex] = useState(0);
+ const [anchorPosition, setAnchorPosition] = useState<{
+ x: number;
+ y: number;
+ } | null>(null);
+
+ // Fetch all filters once when dropdown opens
+ const { data: allFilters = [] } = useGetAllFiltersQuery({
+ enabled: isFilterDropdownOpen,
+ });
+
+ // Use fuse.js for fuzzy search on client side
+ const filteredFilters = useMemo(() => {
+ if (!filterSearchTerm) {
+ return allFilters.slice(0, 20); // Return first 20 when no search term
+ }
+
+ const fuse = new Fuse(allFilters, {
+ keys: ["name", "description"],
+ threshold: 0.3, // 0.0 = perfect match, 1.0 = match anything
+ includeScore: true,
+ minMatchCharLength: 1,
});
- // Use fuse.js for fuzzy search on client side
- const filteredFilters = useMemo(() => {
- if (!filterSearchTerm) {
- return allFilters.slice(0, 20); // Return first 20 when no search term
+ const results = fuse.search(filterSearchTerm);
+ return results.map((result) => result.item).slice(0, 20);
+ }, [allFilters, filterSearchTerm]);
+
+ const { getRootProps, getInputProps } = useDropzone({
+ accept: SUPPORTED_FILE_TYPES,
+ maxFiles: 1,
+ disabled: !isDragging,
+ onDrop: (acceptedFiles, fileRejections) => {
+ if (fileRejections.length > 0) {
+ const message = fileRejections.at(0)?.errors.at(0)?.message;
+ toast.error(message || "Failed to upload file");
+ return;
}
+ onFileSelected(acceptedFiles[0]);
+ },
+ });
- const fuse = new Fuse(allFilters, {
- keys: ["name", "description"],
- threshold: 0.3, // 0.0 = perfect match, 1.0 = match anything
- includeScore: true,
- minMatchCharLength: 1,
- });
-
- const results = fuse.search(filterSearchTerm);
- return results.map((result) => result.item).slice(0, 20);
- }, [allFilters, filterSearchTerm]);
-
- const { getRootProps, getInputProps } = useDropzone({
- accept: SUPPORTED_FILE_TYPES,
- maxFiles: 1,
- disabled: !isDragging,
- onDrop: (acceptedFiles, fileRejections) => {
- if (fileRejections.length > 0) {
- const message = fileRejections.at(0)?.errors.at(0)?.message;
- toast.error(message || "Failed to upload file");
- return;
- }
- onFileSelected(acceptedFiles[0]);
- },
- });
+ useImperativeHandle(ref, () => ({
+ focusInput: () => {
+ inputRef.current?.focus();
+ },
+ clickFileInput: () => {
+ fileInputRef.current?.click();
+ },
+ }));
+
+ const handleFilePickerChange = (e: React.ChangeEvent<HTMLInputElement>) => {
+ const files = e.target.files;
+ if (files && files.length > 0) {
+ onFileSelected(files[0]);
+ } else {
+ onFileSelected(null);
+ }
+ };
+
+ const onAtClick = () => {
+ if (!isFilterDropdownOpen) {
+ setIsFilterDropdownOpen(true);
+ setFilterSearchTerm("");
+ setSelectedFilterIndex(0);
- useImperativeHandle(ref, () => ({
- focusInput: () => {
- inputRef.current?.focus();
- },
- clickFileInput: () => {
- fileInputRef.current?.click();
- },
- }));
-
- const handleFilePickerChange = (e: React.ChangeEvent<HTMLInputElement>) => {
- const files = e.target.files;
- if (files && files.length > 0) {
- onFileSelected(files[0]);
- } else {
- onFileSelected(null);
+ // Get button position for popover anchoring
+ const button = document.querySelector(
+ "[data-filter-button]",
+ ) as HTMLElement;
+ if (button) {
+ const rect = button.getBoundingClientRect();
+ setAnchorPosition({
+ x: rect.left + rect.width / 2,
+ y: rect.top + rect.height / 2 - 12,
+ });
+ }
+ } else {
+ setIsFilterDropdownOpen(false);
+ setAnchorPosition(null);
+ }
+ };
+
+ const handleFilterSelect = (filter: KnowledgeFilterData | null) => {
+ onFilterSelect(filter);
+
+ // Remove the @searchTerm from the input
+ const words = input.split(" ");
+ const lastWord = words[words.length - 1];
+
+ if (lastWord.startsWith("@")) {
+ // Remove the @search term
+ words.pop();
+ onChange(words.join(" ") + (words.length > 0 ? " " : ""));
+ }
+
+ setIsFilterDropdownOpen(false);
+ setFilterSearchTerm("");
+ setSelectedFilterIndex(0);
+ };
+
+ const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
+ const newValue = e.target.value;
+ onChange(newValue); // Call parent's onChange with the string value
+
+ // Detect visual wrapping - only collapse when text is clearly short enough
+ // to prevent flickering at the boundary (flex-row has less width than flex-col)
+ if (!newValue.includes("\n") && newValue.length < SAFE_SINGLE_LINE_CHARS) {
+ setIsWrapped(false);
+ } else {
+ const textarea = e.target;
+ const lineHeight =
+ parseFloat(getComputedStyle(textarea).lineHeight) || 20;
+ const wrapping = textarea.scrollHeight > lineHeight * 1.5;
+ if (wrapping) {
+ setIsWrapped(true);
}
- };
+ }
- const onAtClick = () => {
- if (!isFilterDropdownOpen) {
- setIsFilterDropdownOpen(true);
- setFilterSearchTerm("");
- setSelectedFilterIndex(0);
+ // Find if there's an @ at the start of the last word
+ const words = newValue.split(" ");
+ const lastWord = words[words.length - 1];
- // Get button position for popover anchoring
- const button = document.querySelector(
- "[data-filter-button]",
- ) as HTMLElement;
- if (button) {
- const rect = button.getBoundingClientRect();
- setAnchorPosition({
- x: rect.left + rect.width / 2,
- y: rect.top + rect.height / 2 - 12,
- });
- }
- } else {
- setIsFilterDropdownOpen(false);
- setAnchorPosition(null);
- }
- };
+ if (lastWord.startsWith("@")) {
+ const searchTerm = lastWord.slice(1); // Remove the @
+ setFilterSearchTerm(searchTerm);
+ setSelectedFilterIndex(0);
+
+ // Only set anchor position when @ is first detected (search term is empty)
+ if (searchTerm === "") {
+ const getCursorPosition = (textarea: HTMLTextAreaElement) => {
+ // Create a hidden div with the same styles as the textarea
+ const div = document.createElement("div");
+ const computedStyle = getComputedStyle(textarea);
+
+ // Copy all computed styles to the hidden div
+ for (const style of computedStyle) {
+ (div.style as unknown as Record<string, string>)[style] =
+ computedStyle.getPropertyValue(style);
+ }
+
+ // Set the div to be hidden but not un-rendered
+ div.style.position = "absolute";
+ div.style.visibility = "hidden";
+ div.style.whiteSpace = "pre-wrap";
+ div.style.wordWrap = "break-word";
+ div.style.overflow = "hidden";
+ div.style.height = "auto";
+ div.style.width = `${textarea.getBoundingClientRect().width}px`;
+
+ // Get the text up to the cursor position
+ const cursorPos = textarea.selectionStart || 0;
+ const textBeforeCursor = textarea.value.substring(0, cursorPos);
+
+ // Add the text before cursor
+ div.textContent = textBeforeCursor;
+
+ // Create a span to mark the end position
+ const span = document.createElement("span");
+ span.textContent = "|"; // Cursor marker
+ div.appendChild(span);
+
+ // Add the text after cursor to handle word wrapping
+ const textAfterCursor = textarea.value.substring(cursorPos);
+ div.appendChild(document.createTextNode(textAfterCursor));
+
+ // Add the div to the document temporarily
+ document.body.appendChild(div);
+
+ // Get positions
+ const inputRect = textarea.getBoundingClientRect();
+ const divRect = div.getBoundingClientRect();
+ const spanRect = span.getBoundingClientRect();
- const handleFilterSelect = (filter: KnowledgeFilterData | null) => {
- onFilterSelect(filter);
+ // Calculate the cursor position relative to the input
+ const x = inputRect.left + (spanRect.left - divRect.left);
+ const y = inputRect.top + (spanRect.top - divRect.top);
- // Remove the @searchTerm from the input
- const words = input.split(" ");
- const lastWord = words[words.length - 1];
+ // Clean up
+ document.body.removeChild(div);
- if (lastWord.startsWith("@")) {
- // Remove the @search term
- words.pop();
- onChange(words.join(" ") + (words.length > 0 ? " " : ""));
+ return { x, y };
+ };
+
+ const pos = getCursorPosition(e.target);
+ setAnchorPosition(pos);
}
+ if (!isFilterDropdownOpen) {
+ setIsFilterDropdownOpen(true);
+ }
+ } else if (isFilterDropdownOpen) {
+ // Close dropdown if @ is no longer present
setIsFilterDropdownOpen(false);
setFilterSearchTerm("");
- setSelectedFilterIndex(0);
- };
-
- const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
- const newValue = e.target.value;
- onChange(newValue); // Call parent's onChange with the string value
-
- // Detect visual wrapping - only collapse when text is clearly short enough
- // to prevent flickering at the boundary (flex-row has less width than flex-col)
- if (
- !newValue.includes("\n") &&
- newValue.length < SAFE_SINGLE_LINE_CHARS
- ) {
- setIsWrapped(false);
- } else {
- const textarea = e.target;
- const lineHeight =
- parseFloat(getComputedStyle(textarea).lineHeight) || 20;
- const wrapping = textarea.scrollHeight > lineHeight * 1.5;
- if (wrapping) {
- setIsWrapped(true);
- }
- }
-
- // Find if there's an @ at the start of the last word
- const words = newValue.split(" ");
- const lastWord = words[words.length - 1];
+ }
+ };
- if (lastWord.startsWith("@")) {
- const searchTerm = lastWord.slice(1); // Remove the @
- setFilterSearchTerm(searchTerm);
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
+ if (isFilterDropdownOpen) {
+ if (e.key === "Escape") {
+ e.preventDefault();
+ setIsFilterDropdownOpen(false);
+ setFilterSearchTerm("");
setSelectedFilterIndex(0);
+ inputRef.current?.focus();
+ return;
+ }
- // Only set anchor position when @ is first detected (search term is empty)
- if (searchTerm === "") {
- const getCursorPosition = (textarea: HTMLTextAreaElement) => {
- // Create a hidden div with the same styles as the textarea
- const div = document.createElement("div");
- const computedStyle = getComputedStyle(textarea);
-
- // Copy all computed styles to the hidden div
- for (const style of computedStyle) {
- (div.style as unknown as Record<string, string>)[style] =
- computedStyle.getPropertyValue(style);
- }
-
- // Set the div to be hidden but not un-rendered
- div.style.position = "absolute";
- div.style.visibility = "hidden";
- div.style.whiteSpace = "pre-wrap";
- div.style.wordWrap = "break-word";
- div.style.overflow = "hidden";
- div.style.height = "auto";
- div.style.width = `${textarea.getBoundingClientRect().width}px`;
-
- // Get the text up to the cursor position
- const cursorPos = textarea.selectionStart || 0;
- const textBeforeCursor = textarea.value.substring(0, cursorPos);
-
- // Add the text before cursor
- div.textContent = textBeforeCursor;
-
- // Create a span to mark the end position
- const span = document.createElement("span");
- span.textContent = "|"; // Cursor marker
- div.appendChild(span);
-
- // Add the text after cursor to handle word wrapping
- const textAfterCursor = textarea.value.substring(cursorPos);
- div.appendChild(document.createTextNode(textAfterCursor));
-
- // Add the div to the document temporarily
- document.body.appendChild(div);
-
- // Get positions
- const inputRect = textarea.getBoundingClientRect();
- const divRect = div.getBoundingClientRect();
- const spanRect = span.getBoundingClientRect();
-
- // Calculate the cursor position relative to the input
- const x = inputRect.left + (spanRect.left - divRect.left);
- const y = inputRect.top + (spanRect.top - divRect.top);
-
- // Clean up
- document.body.removeChild(div);
-
- return { x, y };
- };
-
- const pos = getCursorPosition(e.target);
- setAnchorPosition(pos);
- }
+ if (e.key === "ArrowDown") {
+ e.preventDefault();
+ setSelectedFilterIndex((prev) =>
+ prev < filteredFilters.length - 1 ? prev + 1 : 0,
+ );
+ return;
+ }
- if (!isFilterDropdownOpen) {
- setIsFilterDropdownOpen(true);
- }
- } else if (isFilterDropdownOpen) {
- // Close dropdown if @ is no longer present
- setIsFilterDropdownOpen(false);
- setFilterSearchTerm("");
+ if (e.key === "ArrowUp") {
+ e.preventDefault();
+ setSelectedFilterIndex((prev) =>
+ prev > 0 ? prev - 1 : filteredFilters.length - 1,
+ );
+ return;
}
- };
- const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
- if (isFilterDropdownOpen) {
- if (e.key === "Escape") {
- e.preventDefault();
- setIsFilterDropdownOpen(false);
- setFilterSearchTerm("");
- setSelectedFilterIndex(0);
- inputRef.current?.focus();
- return;
- }
+ if (e.key === "Enter") {
+ // Check if we're at the end of an @ mention
+ const cursorPos = e.currentTarget.selectionStart || 0;
+ const textBeforeCursor = input.slice(0, cursorPos);
+ const words = textBeforeCursor.split(" ");
+ const lastWord = words[words.length - 1];
- if (e.key === "ArrowDown") {
+ if (lastWord.startsWith("@") && filteredFilters[selectedFilterIndex]) {
e.preventDefault();
- setSelectedFilterIndex((prev) =>
- prev < filteredFilters.length - 1 ? prev + 1 : 0,
- );
+ handleFilterSelect(filteredFilters[selectedFilterIndex]);
return;
}
+ }
+
+ if (e.key === " ") {
+ // Select filter on space if we're typing an @ mention
+ const cursorPos = e.currentTarget.selectionStart || 0;
+ const textBeforeCursor = input.slice(0, cursorPos);
+ const words = textBeforeCursor.split(" ");
+ const lastWord = words[words.length - 1];
- if (e.key === "ArrowUp") {
+ if (lastWord.startsWith("@") && filteredFilters[selectedFilterIndex]) {
e.preventDefault();
- setSelectedFilterIndex((prev) =>
- prev > 0 ? prev - 1 : filteredFilters.length - 1,
- );
+ handleFilterSelect(filteredFilters[selectedFilterIndex]);
return;
}
-
- if (e.key === "Enter") {
- // Check if we're at the end of an @ mention
- const cursorPos = e.currentTarget.selectionStart || 0;
- const textBeforeCursor = input.slice(0, cursorPos);
- const words = textBeforeCursor.split(" ");
- const lastWord = words[words.length - 1];
-
- if (
- lastWord.startsWith("@") &&
- filteredFilters[selectedFilterIndex]
- ) {
- e.preventDefault();
- handleFilterSelect(filteredFilters[selectedFilterIndex]);
- return;
- }
- }
-
- if (e.key === " ") {
- // Select filter on space if we're typing an @ mention
- const cursorPos = e.currentTarget.selectionStart || 0;
- const textBeforeCursor = input.slice(0, cursorPos);
- const words = textBeforeCursor.split(" ");
- const lastWord = words[words.length - 1];
-
- if (
- lastWord.startsWith("@") &&
- filteredFilters[selectedFilterIndex]
- ) {
- e.preventDefault();
- handleFilterSelect(filteredFilters[selectedFilterIndex]);
- return;
- }
- }
}
-
- // Pass through to parent onKeyDown for other key handling
- onKeyDown(e);
- };
-
- return (
- <div className="w-full">
- <form onSubmit={onSubmit} className="relative">
- {/* Outer container - flex-col to stack file preview above input */}
- <div
- {...getRootProps()}
- className={cn(
- "flex flex-col w-full p-2 rounded-xl border transition-all",
- isCloudBrand
- ? "border-[color:var(--chat-input-border)]"
- : "border-input",
- isCloudBrand ? "bg-[var(--chat-prompt-bg)]" : "bg-transparent",
- !isDragging &&
- (isCloudBrand
- ? "hover:[&:not(:focus-within)]:border-muted-foreground focus-within:border-[color:var(--chat-input-border)]"
- : "hover:[&:not(:focus-within)]:border-muted-foreground focus-within:border-foreground"),
- isDragging && "border-dashed",
+ }
+
+ // Pass through to parent onKeyDown for other key handling
+ onKeyDown(e);
+ };
+
+ return (
+ <div className="w-full">
+ <form onSubmit={onSubmit} className="relative">
+ {/* Outer container - flex-col to stack file preview above input */}
+ <div
+ {...getRootProps()}
+ className={cn(
+ "flex flex-col w-full p-2 rounded-xl border transition-all",
+ isCloudBrand
+ ? "border-[color:var(--chat-input-border)]"
+ : "border-input",
+ isCloudBrand ? "bg-[var(--chat-prompt-bg)]" : "bg-transparent",
+ !isDragging &&
+ (isCloudBrand
+ ? "hover:[&:not(:focus-within)]:border-muted-foreground focus-within:border-[color:var(--chat-input-border)]"
+ : "hover:[&:not(:focus-within)]:border-muted-foreground focus-within:border-foreground"),
+ isDragging && "border-dashed",
+ )}
+ >
+ <input {...getInputProps()} />
+ {/* File Preview Section - Always above */}
+ <AnimatePresence>
+ {uploadedFile && (
+ <motion.div
+ initial={{ opacity: 0, height: 0, marginBottom: 0 }}
+ animate={{ opacity: 1, height: "auto", marginBottom: 8 }}
+ exit={{ opacity: 0, height: 0, marginBottom: 0 }}
+ className="overflow-hidden"
+ >
+ <FilePreview
+ uploadedFile={uploadedFile}
+ onClear={() => {
+ onFileSelected(null);
+ }}
+ isUploading={isUploading}
+ />
+ </motion.div>
)}
+ </AnimatePresence>
+ <AnimatePresence>
+ {isDragging && (
+ <motion.div
+ initial={{ opacity: 0, height: 0 }}
+ animate={{ opacity: 1, height: 100 }}
+ exit={{ opacity: 0, height: 0 }}
+ className="overflow-hidden w-full flex flex-col items-center justify-center gap-2"
+ >
+ <p className="text-md font-medium text-primary">
+ Add files to conversation
+ </p>
+ <p className="text-sm text-muted-foreground">
+ Text formats and image files.{" "}
+ <span className="font-semibold">10</span> files per chat,{" "}
+ <span className="font-semibold">150 MB</span> each.
+ </p>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ {/* Main Input Container - flex-row or flex-col based on textarea height */}
+ <div
+ className={`relative flex w-full gap-2 ${
+ isMultiline ? "flex-col" : "flex-row items-center"
+ }`}
>
- <input {...getInputProps()} />
- {/* File Preview Section - Always above */}
- <AnimatePresence>
- {uploadedFile && (
- <motion.div
- initial={{ opacity: 0, height: 0, marginBottom: 0 }}
- animate={{ opacity: 1, height: "auto", marginBottom: 8 }}
- exit={{ opacity: 0, height: 0, marginBottom: 0 }}
- className="overflow-hidden"
- >
- <FilePreview
- uploadedFile={uploadedFile}
+ {/* Filter + Textarea Section */}
+ <div
+ className={`flex items-center gap-2 ${isMultiline ? "w-full" : "flex-1"}`}
+ >
+ {!isMultiline &&
+ (selectedFilter ? (
+ <SelectedKnowledgeFilter
+ selectedFilter={selectedFilter}
+ parsedFilterData={parsedFilterData}
onClear={() => {
- onFileSelected(null);
+ setSelectedFilter(null);
+ setIsFilterHighlighted(false);
}}
- isUploading={isUploading}
/>
- </motion.div>
- )}
- </AnimatePresence>
- <AnimatePresence>
- {isDragging && (
- <motion.div
- initial={{ opacity: 0, height: 0 }}
- animate={{ opacity: 1, height: 100 }}
- exit={{ opacity: 0, height: 0 }}
- className="overflow-hidden w-full flex flex-col items-center justify-center gap-2"
- >
- <p className="text-md font-medium text-primary">
- Add files to conversation
- </p>
- <p className="text-sm text-muted-foreground">
- Text formats and image files.{" "}
- <span className="font-semibold">10</span> files per chat,{" "}
- <span className="font-semibold">150 MB</span> each.
- </p>
- </motion.div>
- )}
- </AnimatePresence>
- {/* Main Input Container - flex-row or flex-col based on textarea height */}
+ ) : (
+ <Button
+ type="button"
+ variant="ghost"
+ size="iconSm"
+ className={cn(
+ "h-8 w-8 p-0 rounded-md",
+ isCloudBrand
+ ? "hover:bg-[var(--layered-select-bg)]"
+ : "hover:bg-muted/50",
+ )}
+ onMouseDown={(e) => {
+ e.preventDefault();
+ }}
+ onClick={onAtClick}
+ data-filter-button
+ >
+ <Funnel className="h-4 w-4" />
+ </Button>
+ ))}
+ <div className="relative flex-1 flex items-center">
+ <TextareaAutosize
+ ref={inputRef}
+ value={input}
+ onChange={handleChange}
+ onKeyDown={handleKeyDown}
+ maxRows={7}
+ autoComplete="off"
+ minRows={1}
+ placeholder="Ask a question..."
+ data-testid="chat-input"
+ disabled={loading}
+ className={`w-full text-sm bg-transparent focus-visible:outline-none resize-none`}
+ rows={1}
+ />
+ </div>
+ </div>
+
+ {/* Action Buttons Section */}
<div
- className={`relative flex w-full gap-2 ${
- isMultiline ? "flex-col" : "flex-row items-center"
- }`}
+ className={`flex items-center gap-2 ${isMultiline ? "justify-between w-full" : ""}`}
>
- {/* Filter + Textarea Section */}
- <div
- className={`flex items-center gap-2 ${isMultiline ? "w-full" : "flex-1"}`}
- >
- {!isMultiline &&
- (selectedFilter ? (
- <SelectedKnowledgeFilter
- selectedFilter={selectedFilter}
- parsedFilterData={parsedFilterData}
- onClear={() => {
- setSelectedFilter(null);
- setIsFilterHighlighted(false);
- }}
- />
- ) : (
- <Button
- type="button"
- variant="ghost"
- size="iconSm"
- className={cn(
- "h-8 w-8 p-0 rounded-md",
- isCloudBrand
- ? "hover:bg-[var(--layered-select-bg)]"
- : "hover:bg-muted/50",
- )}
- onMouseDown={(e) => {
- e.preventDefault();
- }}
- onClick={onAtClick}
- data-filter-button
- >
- <Funnel className="h-4 w-4" />
- </Button>
- ))}
- <div className="relative flex-1 flex items-center">
- <TextareaAutosize
- ref={inputRef}
- value={input}
- onChange={handleChange}
- onKeyDown={handleKeyDown}
- maxRows={7}
- autoComplete="off"
- minRows={1}
- placeholder="Ask a question..."
- data-testid="chat-input"
- disabled={loading}
- className={`w-full text-sm bg-transparent focus-visible:outline-none resize-none`}
- rows={1}
+ {isMultiline &&
+ (selectedFilter ? (
+ <SelectedKnowledgeFilter
+ selectedFilter={selectedFilter}
+ parsedFilterData={parsedFilterData}
+ onClear={() => {
+ setSelectedFilter(null);
+ setIsFilterHighlighted(false);
+ }}
/>
- </div>
- </div>
-
- {/* Action Buttons Section */}
- <div
- className={`flex items-center gap-2 ${isMultiline ? "justify-between w-full" : ""}`}
- >
- {isMultiline &&
- (selectedFilter ? (
- <SelectedKnowledgeFilter
- selectedFilter={selectedFilter}
- parsedFilterData={parsedFilterData}
- onClear={() => {
- setSelectedFilter(null);
- setIsFilterHighlighted(false);
- }}
- />
+ ) : (
+ <Button
+ type="button"
+ variant="ghost"
+ size="iconSm"
+ className={cn(
+ "h-8 w-8 p-0 rounded-md",
+ isCloudBrand
+ ? "hover:bg-[var(--layered-select-bg)]"
+ : "hover:bg-muted/50",
+ )}
+ onMouseDown={(e) => {
+ e.preventDefault();
+ }}
+ onClick={onAtClick}
+ data-filter-button
+ >
+ <Funnel className="h-4 w-4" />
+ </Button>
+ ))}
+ <div className="flex items-center gap-2">
+ {ingestViaChat && (
+ <Button
+ type="button"
+ variant="ghost"
+ size="iconSm"
+ onClick={onFilePickerClick}
+ disabled={isUploading}
+ className={cn(
+ "h-8 w-8 p-0 !rounded-md",
+ isCloudBrand
+ ? "hover:bg-[var(--layered-select-bg)]"
+ : "hover:bg-muted/50",
+ )}
+ >
+ <Plus className="h-4 w-4" />
+ </Button>
+ )}
+ <Button
+ variant="default"
+ type="submit"
+ size="iconSm"
+ disabled={(!input.trim() && !uploadedFile) || loading}
+ className="chat-submit !rounded-md h-8 w-8 p-0"
+ data-testid="send-button"
+ >
+ {loading ? (
+ <Loader2 className="h-4 w-4 animate-spin" />
) : (
- <Button
+ <ArrowRight className="h-4 w-4" />
+ )}
+ </Button>
+ </div>
+ </div>
+ </div>
+ </div>
+ <input
+ ref={fileInputRef}
+ type="file"
+ onChange={handleFilePickerChange}
+ className="hidden"
+ accept={SUPPORTED_EXTENSIONS.join(",")}
+ />
+
+ <Popover
+ open={isFilterDropdownOpen}
+ onOpenChange={(open) => {
+ setIsFilterDropdownOpen(open);
+ }}
+ >
+ {anchorPosition && (
+ <PopoverAnchor
+ asChild
+ style={{
+ position: "fixed",
+ left: anchorPosition.x,
+ top: anchorPosition.y,
+ width: 1,
+ height: 1,
+ pointerEvents: "none",
+ }}
+ >
+ <div />
+ </PopoverAnchor>
+ )}
+ <PopoverContent
+ className="w-64 p-2"
+ side="top"
+ align="start"
+ sideOffset={6}
+ alignOffset={-18}
+ onOpenAutoFocus={(e) => {
+ // Prevent auto focus on the popover content
+ e.preventDefault();
+ // Keep focus on the input
+ }}
+ >
+ <div className="space-y-1">
+ {filterSearchTerm && (
+ <div className="px-2 py-1.5 text-xs font-medium text-muted-foreground">
+ Searching: @{filterSearchTerm}
+ </div>
+ )}
+ {allFilters.length === 0 ? (
+ <div className="px-2 py-3 text-sm text-muted-foreground">
+ No knowledge filters available
+ </div>
+ ) : (
+ <>
+ {!filterSearchTerm && (
+ <button
type="button"
- variant="ghost"
- size="iconSm"
+ onClick={() => handleFilterSelect(null)}
className={cn(
- "h-8 w-8 p-0 rounded-md",
+ "w-full text-left px-2 py-2 text-sm rounded flex items-center justify-between",
isCloudBrand
? "hover:bg-[var(--layered-select-bg)]"
: "hover:bg-muted/50",
+ selectedFilterIndex === -1 &&
+ (isCloudBrand
+ ? "bg-[var(--layered-select-bg)]"
+ : "bg-muted/50"),
)}
- onMouseDown={(e) => {
- e.preventDefault();
- }}
- onClick={onAtClick}
- data-filter-button
>
- <Funnel className="h-4 w-4" />
- </Button>
- ))}
- <div className="flex items-center gap-2">
- {ingestViaChat && (
- <Button
+ <span>No knowledge filter</span>
+ {!selectedFilter && (
+ <Check className="h-4 w-4 shrink-0" />
+ )}
+ </button>
+ )}
+ {filteredFilters.map((filter, index) => (
+ <button
+ key={filter.id}
type="button"
- variant="ghost"
- size="iconSm"
- onClick={onFilePickerClick}
- disabled={isUploading}
+ onClick={() => handleFilterSelect(filter)}
className={cn(
- "h-8 w-8 p-0 !rounded-md",
+ "w-full overflow-hidden text-left px-2 py-2 gap-2 text-sm rounded flex items-center justify-between",
isCloudBrand
? "hover:bg-[var(--layered-select-bg)]"
: "hover:bg-muted/50",
+ index === selectedFilterIndex &&
+ (isCloudBrand
+ ? "bg-[var(--layered-select-bg)]"
+ : "bg-muted/50"),
)}
>
- <Plus className="h-4 w-4" />
- </Button>
- )}
- <Button
- variant="default"
- type="submit"
- size="iconSm"
- disabled={(!input.trim() && !uploadedFile) || loading}
- className="chat-submit !rounded-md h-8 w-8 p-0"
- data-testid="send-button"
- >
- {loading ? (
- <Loader2 className="h-4 w-4 animate-spin" />
- ) : (
- <ArrowRight className="h-4 w-4" />
- )}
- </Button>
- </div>
- </div>
- </div>
- </div>
- <input
- ref={fileInputRef}
- type="file"
- onChange={handleFilePickerChange}
- className="hidden"
- accept={SUPPORTED_EXTENSIONS.join(",")}
- />
-
- <Popover
- open={isFilterDropdownOpen}
- onOpenChange={(open) => {
- setIsFilterDropdownOpen(open);
- }}
- >
- {anchorPosition && (
- <PopoverAnchor
- asChild
- style={{
- position: "fixed",
- left: anchorPosition.x,
- top: anchorPosition.y,
- width: 1,
- height: 1,
- pointerEvents: "none",
- }}
- >
- <div />
- </PopoverAnchor>
- )}
- <PopoverContent
- className="w-64 p-2"
- side="top"
- align="start"
- sideOffset={6}
- alignOffset={-18}
- onOpenAutoFocus={(e) => {
- // Prevent auto focus on the popover content
- e.preventDefault();
- // Keep focus on the input
- }}
- >
- <div className="space-y-1">
- {filterSearchTerm && (
- <div className="px-2 py-1.5 text-xs font-medium text-muted-foreground">
- Searching: @{filterSearchTerm}
- </div>
- )}
- {allFilters.length === 0 ? (
- <div className="px-2 py-3 text-sm text-muted-foreground">
- No knowledge filters available
- </div>
- ) : (
- <>
- {!filterSearchTerm && (
- <button
- type="button"
- onClick={() => handleFilterSelect(null)}
- className={cn(
- "w-full text-left px-2 py-2 text-sm rounded flex items-center justify-between",
- isCloudBrand
- ? "hover:bg-[var(--layered-select-bg)]"
- : "hover:bg-muted/50",
- selectedFilterIndex === -1 &&
- (isCloudBrand
- ? "bg-[var(--layered-select-bg)]"
- : "bg-muted/50"),
- )}
- >
- <span>No knowledge filter</span>
- {!selectedFilter && (
- <Check className="h-4 w-4 shrink-0" />
- )}
- </button>
- )}
- {filteredFilters.map((filter, index) => (
- <button
- key={filter.id}
- type="button"
- onClick={() => handleFilterSelect(filter)}
- className={cn(
- "w-full overflow-hidden text-left px-2 py-2 gap-2 text-sm rounded flex items-center justify-between",
- isCloudBrand
- ? "hover:bg-[var(--layered-select-bg)]"
- : "hover:bg-muted/50",
- index === selectedFilterIndex &&
- (isCloudBrand
- ? "bg-[var(--layered-select-bg)]"
- : "bg-muted/50"),
- )}
- >
- <div className="overflow-hidden">
- <div className="font-medium truncate">
- {filter.name}
- </div>
- {filter.description && (
- <div className="text-xs text-muted-foreground truncate">
- {filter.description}
- </div>
- )}
+ <div className="overflow-hidden">
+ <div className="font-medium truncate">
+ {filter.name}
</div>
- {selectedFilter?.id === filter.id && (
- <Check className="h-4 w-4 shrink-0" />
+ {filter.description && (
+ <div className="text-xs text-muted-foreground truncate">
+ {filter.description}
+ </div>
)}
- </button>
- ))}
- {filteredFilters.length === 0 && filterSearchTerm && (
- <div className="px-2 py-3 text-sm text-muted-foreground">
- No filters match &quot;{filterSearchTerm}&quot;
</div>
- )}
- </>
- )}
- </div>
- </PopoverContent>
- </Popover>
- </form>
- </div>
- );
- },
-);
-
-ChatInput.displayName = "ChatInput";
+ {selectedFilter?.id === filter.id && (
+ <Check className="h-4 w-4 shrink-0" />
+ )}
+ </button>
+ ))}
+ {filteredFilters.length === 0 && filterSearchTerm && (
+ <div className="px-2 py-3 text-sm text-muted-foreground">
+ No filters match &quot;{filterSearchTerm}&quot;
+ </div>
+ )}
+ </>
+ )}
+ </div>
+ </PopoverContent>
+ </Popover>
+ </form>
+ </div>
+ );
+}
diff --git a/frontend/components/knowledge-dropdown.tsx b/frontend/components/knowledge-dropdown.tsx
index 8c1738b49..1120083b9 100644
--- a/frontend/components/knowledge-dropdown.tsx
+++ b/frontend/components/knowledge-dropdown.tsx
@@ -244,13 +244,14 @@ export function KnowledgeDropdown() {
} = {};
const availableTypes = cloudConnectorTypes.filter(
- (type) => connectorsResult.connectors[type],
+ (type) => connectorsResult.connectors?.[type],
);
for (const type of availableTypes) {
connectorInfo[type] = {
- name: connectorsResult.connectors[type].name,
- available: connectorsResult.connectors[type].available,
+ name: connectorsResult.connectors?.[type]?.name ?? type,
+ available:
+ connectorsResult.connectors?.[type]?.available ?? false,
connected: false,
hasToken: false,
};
diff --git a/frontend/components/ui/accordion.tsx b/frontend/components/ui/accordion.tsx
index f22b3de1e..5e7b813e2 100644
--- a/frontend/components/ui/accordion.tsx
+++ b/frontend/components/ui/accordion.tsx
@@ -8,51 +8,58 @@ import { cn } from "@/lib/utils";
const Accordion = AccordionPrimitive.Root;
-const AccordionItem = React.forwardRef<
- React.ElementRef<typeof AccordionPrimitive.Item>,
- React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
->(({ className, ...props }, ref) => (
- <AccordionPrimitive.Item
- ref={ref}
- className={cn("border rounded-none", className)}
- {...props}
- />
-));
-AccordionItem.displayName = "AccordionItem";
-
-const AccordionTrigger = React.forwardRef<
- React.ElementRef<typeof AccordionPrimitive.Trigger>,
- React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
->(({ className, children, ...props }, ref) => (
- <AccordionPrimitive.Header className="flex">
- <AccordionPrimitive.Trigger
+function AccordionItem({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof AccordionPrimitive.Item>) {
+ return (
+ <AccordionPrimitive.Item
ref={ref}
- className={cn(
- "flex flex-1 items-center p-4 py-2.5 gap-2 font-medium !text-mmd text-muted-foreground transition-all [&[data-state=open]>svg]:rotate-90",
- className,
- )}
+ className={cn("border rounded-none", className)}
{...props}
- >
- <ChevronRight className="h-3.5 w-3.5 shrink-0 transition-transform duration-200" />
- {children}
- </AccordionPrimitive.Trigger>
- </AccordionPrimitive.Header>
-));
-AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
+ />
+ );
+}
-const AccordionContent = React.forwardRef<
- React.ElementRef<typeof AccordionPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
->(({ className, children, ...props }, ref) => (
- <AccordionPrimitive.Content
- ref={ref}
- className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
- {...props}
- >
- <div className={cn("p-4 pt-2", className)}>{children}</div>
- </AccordionPrimitive.Content>
-));
+function AccordionTrigger({
+ className,
+ children,
+ ref,
+ ...props
+}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
+ return (
+ <AccordionPrimitive.Header className="flex">
+ <AccordionPrimitive.Trigger
+ ref={ref}
+ className={cn(
+ "flex flex-1 items-center p-4 py-2.5 gap-2 font-medium !text-mmd text-muted-foreground transition-all [&[data-state=open]>svg]:rotate-90",
+ className,
+ )}
+ {...props}
+ >
+ <ChevronRight className="h-3.5 w-3.5 shrink-0 transition-transform duration-200" />
+ {children}
+ </AccordionPrimitive.Trigger>
+ </AccordionPrimitive.Header>
+ );
+}
-AccordionContent.displayName = AccordionPrimitive.Content.displayName;
+function AccordionContent({
+ className,
+ children,
+ ref,
+ ...props
+}: React.ComponentProps<typeof AccordionPrimitive.Content>) {
+ return (
+ <AccordionPrimitive.Content
+ ref={ref}
+ className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
+ {...props}
+ >
+ <div className={cn("p-4 pt-2", className)}>{children}</div>
+ </AccordionPrimitive.Content>
+ );
+}
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
diff --git a/frontend/components/ui/avatar.tsx b/frontend/components/ui/avatar.tsx
index b0df11864..a9ba58450 100644
--- a/frontend/components/ui/avatar.tsx
+++ b/frontend/components/ui/avatar.tsx
@@ -5,46 +5,52 @@ import * as React from "react";
import { cn } from "@/lib/utils";
-const Avatar = React.forwardRef<
- React.ElementRef<typeof AvatarPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
->(({ className, ...props }, ref) => (
- <AvatarPrimitive.Root
- ref={ref}
- className={cn(
- "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
- className,
- )}
- {...props}
- />
-));
-Avatar.displayName = AvatarPrimitive.Root.displayName;
+function Avatar({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof AvatarPrimitive.Root>) {
+ return (
+ <AvatarPrimitive.Root
+ ref={ref}
+ className={cn(
+ "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
-const AvatarImage = React.forwardRef<
- React.ElementRef<typeof AvatarPrimitive.Image>,
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
->(({ className, ...props }, ref) => (
- <AvatarPrimitive.Image
- ref={ref}
- className={cn("aspect-square h-full w-full", className)}
- {...props}
- />
-));
-AvatarImage.displayName = AvatarPrimitive.Image.displayName;
+function AvatarImage({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof AvatarPrimitive.Image>) {
+ return (
+ <AvatarPrimitive.Image
+ ref={ref}
+ className={cn("aspect-square h-full w-full", className)}
+ {...props}
+ />
+ );
+}
-const AvatarFallback = React.forwardRef<
- React.ElementRef<typeof AvatarPrimitive.Fallback>,
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
->(({ className, ...props }, ref) => (
- <AvatarPrimitive.Fallback
- ref={ref}
- className={cn(
- "flex h-full w-full items-center justify-center rounded-full bg-muted",
- className,
- )}
- {...props}
- />
-));
-AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
+function AvatarFallback({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
+ return (
+ <AvatarPrimitive.Fallback
+ ref={ref}
+ className={cn(
+ "flex h-full w-full items-center justify-center rounded-full bg-muted",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
export { Avatar, AvatarFallback, AvatarImage };
diff --git a/frontend/components/ui/banner.tsx b/frontend/components/ui/banner.tsx
index c0c67e5ce..a1fddaf8b 100644
--- a/frontend/components/ui/banner.tsx
+++ b/frontend/components/ui/banner.tsx
@@ -6,7 +6,7 @@ import {
createContext,
type HTMLAttributes,
type MouseEventHandler,
- useContext,
+ use,
} from "react";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
@@ -111,7 +111,7 @@ const _BannerClose = ({
className,
...props
}: BannerCloseProps) => {
- const { setShow } = useContext(BannerContext);
+ const { setShow } = use(BannerContext);
const handleClick: MouseEventHandler<HTMLButtonElement> = (e) => {
setShow(false);
diff --git a/frontend/components/ui/button.tsx b/frontend/components/ui/button.tsx
index 23177a25f..a4fd27a47 100644
--- a/frontend/components/ui/button.tsx
+++ b/frontend/components/ui/button.tsx
@@ -59,55 +59,49 @@ export interface ButtonProps
ignoreTitleCase?: boolean;
}
-const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
- (
- {
- className,
- variant,
- size,
- loading,
- disabled,
- asChild = false,
- children,
- ignoreTitleCase = false,
- ...props
- },
- ref,
- ) => {
- const Comp = asChild ? Slot : "button";
- let newChildren = children;
- if (typeof children === "string") {
- newChildren = ignoreTitleCase ? children : toTitleCase(children);
- }
- const shouldScale = props["aria-haspopup"] !== "dialog";
+function Button({
+ className,
+ variant,
+ size,
+ loading,
+ disabled,
+ asChild = false,
+ children,
+ ignoreTitleCase = false,
+ ref,
+ ...props
+}: ButtonProps & React.RefAttributes<HTMLButtonElement>) {
+ const Comp = asChild ? Slot : "button";
+ let newChildren = children;
+ if (typeof children === "string") {
+ newChildren = ignoreTitleCase ? children : toTitleCase(children);
+ }
+ const shouldScale = props["aria-haspopup"] !== "dialog";
- return (
- <Comp
- className={cn(
- buttonVariants({ variant, size, className }),
- shouldScale && "active:scale-[0.97]",
- )}
- disabled={loading || disabled}
- ref={ref}
- {...props}
- >
- {loading ? (
- <span className="relative flex items-center justify-center">
- <span className="invisible flex items-center justify-center gap-2">
- {newChildren}
- </span>
- <span className="absolute inset-0 flex items-center justify-center">
- <div className="h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" />
- </span>
+ return (
+ <Comp
+ className={cn(
+ buttonVariants({ variant, size, className }),
+ shouldScale && "active:scale-[0.97]",
+ )}
+ disabled={loading || disabled}
+ ref={ref}
+ {...props}
+ >
+ {loading ? (
+ <span className="relative flex items-center justify-center">
+ <span className="invisible flex items-center justify-center gap-2">
+ {newChildren}
</span>
- ) : (
- newChildren
- )}
- </Comp>
- );
- },
-);
-
-Button.displayName = "Button";
+ <span className="absolute inset-0 flex items-center justify-center">
+ <div className="h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" />
+ </span>
+ </span>
+ ) : (
+ newChildren
+ )}
+ </Comp>
+ );
+}
export { Button, buttonVariants };
diff --git a/frontend/components/ui/card.tsx b/frontend/components/ui/card.tsx
index 76821ca79..149095e64 100644
--- a/frontend/components/ui/card.tsx
+++ b/frontend/components/ui/card.tsx
@@ -1,80 +1,73 @@
import * as React from "react";
import { cn } from "@/lib/utils";
-const Card = React.forwardRef<
- HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement>
->(({ className, ...props }, ref) => (
- <div
- ref={ref}
- className={cn(
- "rounded-xl border border-border bg-card text-card-foreground shadow-sm",
- className,
- )}
- {...props}
- />
-));
+function Card({ className, ref, ...props }: React.ComponentProps<"div">) {
+ return (
+ <div
+ ref={ref}
+ className={cn(
+ "rounded-xl border border-border bg-card text-card-foreground shadow-sm",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
-const CardHeader = React.forwardRef<
- HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement>
->(({ className, ...props }, ref) => (
- <div
- ref={ref}
- className={cn("flex flex-col space-y-1.5 p-5", className)}
- {...props}
- />
-));
+function CardHeader({ className, ref, ...props }: React.ComponentProps<"div">) {
+ return (
+ <div
+ ref={ref}
+ className={cn("flex flex-col space-y-1.5 p-5", className)}
+ {...props}
+ />
+ );
+}
-const CardTitle = React.forwardRef<
- HTMLParagraphElement,
- React.HTMLAttributes<HTMLHeadingElement>
->(({ className, ...props }, ref) => (
- <h3
- ref={ref}
- className={cn(
- "text-base font-semibold leading-tight tracking-tight text-[14px]",
- className,
- )}
- {...props}
- />
-));
+function CardTitle({ className, ref, ...props }: React.ComponentProps<"h3">) {
+ return (
+ <h3
+ ref={ref}
+ className={cn(
+ "text-base font-semibold leading-tight tracking-tight text-[14px]",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
-const CardDescription = React.forwardRef<
- HTMLParagraphElement,
- React.HTMLAttributes<HTMLParagraphElement>
->(({ className, ...props }, ref) => (
- <div
- ref={ref}
- className={cn("text-sm text-muted-foreground", className)}
- {...props}
- />
-));
+function CardDescription({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<"div">) {
+ return (
+ <div
+ ref={ref}
+ className={cn("text-sm text-muted-foreground", className)}
+ {...props}
+ />
+ );
+}
-const CardContent = React.forwardRef<
- HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement>
->(({ className, ...props }, ref) => (
- <div ref={ref} className={cn("p-5 pt-0", className)} {...props} />
-));
+function CardContent({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<"div">) {
+ return <div ref={ref} className={cn("p-5 pt-0", className)} {...props} />;
+}
-const CardFooter = React.forwardRef<
- HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement>
->(({ className, ...props }, ref) => (
- <div
- ref={ref}
- className={cn("flex items-center p-5 pt-0", className)}
- {...props}
- />
-));
-
-Card.displayName = "Card";
-CardHeader.displayName = "CardHeader";
-CardTitle.displayName = "CardTitle";
-CardDescription.displayName = "CardDescription";
-CardContent.displayName = "CardContent";
-CardFooter.displayName = "CardFooter";
+function CardFooter({ className, ref, ...props }: React.ComponentProps<"div">) {
+ return (
+ <div
+ ref={ref}
+ className={cn("flex items-center p-5 pt-0", className)}
+ {...props}
+ />
+ );
+}
export {
Card,
diff --git a/frontend/components/ui/command.tsx b/frontend/components/ui/command.tsx
index 040061dc9..2a324876c 100644
--- a/frontend/components/ui/command.tsx
+++ b/frontend/components/ui/command.tsx
@@ -7,20 +7,22 @@ import * as React from "react";
import { Dialog, DialogContent } from "@/components/ui/dialog";
import { cn } from "@/lib/utils";
-const Command = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive>
->(({ className, ...props }, ref) => (
- <CommandPrimitive
- ref={ref}
- className={cn(
- "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
- className,
- )}
- {...props}
- />
-));
-Command.displayName = CommandPrimitive.displayName;
+function Command({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive>) {
+ return (
+ <CommandPrimitive
+ ref={ref}
+ className={cn(
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
type CommandDialogProps = DialogProps;
@@ -36,94 +38,104 @@ const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
);
};
-const CommandInput = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Input>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
->(({ className, ...props }, ref) => (
- <div className="flex items-center border-b px-3" data-cmdk-input-wrapper="">
- <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
- <CommandPrimitive.Input
+function CommandInput({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive.Input>) {
+ return (
+ <div className="flex items-center border-b px-3" data-cmdk-input-wrapper="">
+ <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
+ <CommandPrimitive.Input
+ ref={ref}
+ className={cn(
+ "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
+ className,
+ )}
+ {...props}
+ />
+ </div>
+ );
+}
+
+function CommandList({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive.List>) {
+ return (
+ <CommandPrimitive.List
ref={ref}
className={cn(
- "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
+ "max-h-[300px] overflow-y-auto overflow-x-hidden",
className,
)}
{...props}
/>
- </div>
-));
-
-CommandInput.displayName = CommandPrimitive.Input.displayName;
-
-const CommandList = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.List>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
->(({ className, ...props }, ref) => (
- <CommandPrimitive.List
- ref={ref}
- className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
- {...props}
- />
-));
-
-CommandList.displayName = CommandPrimitive.List.displayName;
-
-const CommandEmpty = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Empty>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
->(({ className, ...props }, ref) => (
- <CommandPrimitive.Empty
- ref={ref}
- className={cn("py-6 text-center text-sm", className)}
- {...props}
- />
-));
-
-CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
-
-const CommandGroup = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Group>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
->(({ className, ...props }, ref) => (
- <CommandPrimitive.Group
- ref={ref}
- className={cn(
- "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
- className,
- )}
- {...props}
- />
-));
+ );
+}
-CommandGroup.displayName = CommandPrimitive.Group.displayName;
+function CommandEmpty({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
+ return (
+ <CommandPrimitive.Empty
+ ref={ref}
+ className={cn("py-6 text-center text-sm", className)}
+ {...props}
+ />
+ );
+}
-const CommandSeparator = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Separator>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
->(({ className, ...props }, ref) => (
- <CommandPrimitive.Separator
- ref={ref}
- className={cn("-mx-1 h-px bg-border", className)}
- {...props}
- />
-));
-CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
+function CommandGroup({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive.Group>) {
+ return (
+ <CommandPrimitive.Group
+ ref={ref}
+ className={cn(
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
-const CommandItem = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Item>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
->(({ className, ...props }, ref) => (
- <CommandPrimitive.Item
- ref={ref}
- className={cn(
- "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
- className,
- )}
- {...props}
- />
-));
+function CommandSeparator({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
+ return (
+ <CommandPrimitive.Separator
+ ref={ref}
+ className={cn("-mx-1 h-px bg-border", className)}
+ {...props}
+ />
+ );
+}
-CommandItem.displayName = CommandPrimitive.Item.displayName;
+function CommandItem({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive.Item>) {
+ return (
+ <CommandPrimitive.Item
+ ref={ref}
+ className={cn(
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
const CommandShortcut = ({
className,
@@ -139,7 +151,6 @@ const CommandShortcut = ({
/>
);
};
-CommandShortcut.displayName = "CommandShortcut";
export {
Command,
diff --git a/frontend/components/ui/dialog.tsx b/frontend/components/ui/dialog.tsx
index ca061d7ef..af4b983f4 100644
--- a/frontend/components/ui/dialog.tsx
+++ b/frontend/components/ui/dialog.tsx
@@ -14,44 +14,49 @@ const DialogPortal = DialogPrimitive.Portal;
const DialogClose = DialogPrimitive.Close;
-const DialogOverlay = React.forwardRef<
- React.ElementRef<typeof DialogPrimitive.Overlay>,
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
->(({ className, ...props }, ref) => (
- <DialogPrimitive.Overlay
- ref={ref}
- className={cn(
- "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
- className,
- )}
- {...props}
- />
-));
-DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
-
-const DialogContent = React.forwardRef<
- React.ElementRef<typeof DialogPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
->(({ className, children, ...props }, ref) => (
- <DialogPortal>
- <DialogOverlay />
- <DialogPrimitive.Content
+function DialogOverlay({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
+ return (
+ <DialogPrimitive.Overlay
ref={ref}
className={cn(
- "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className,
)}
{...props}
- >
- {children}
- <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
- <X className="h-4 w-4" />
- <span className="sr-only">Close</span>
- </DialogPrimitive.Close>
- </DialogPrimitive.Content>
- </DialogPortal>
-));
-DialogContent.displayName = DialogPrimitive.Content.displayName;
+ />
+ );
+}
+
+function DialogContent({
+ className,
+ children,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DialogPrimitive.Content>) {
+ return (
+ <DialogPortal>
+ <DialogOverlay />
+ <DialogPrimitive.Content
+ ref={ref}
+ className={cn(
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ </DialogPrimitive.Content>
+ </DialogPortal>
+ );
+}
const DialogHeader = ({
className,
@@ -65,7 +70,6 @@ const DialogHeader = ({
{...props}
/>
);
-DialogHeader.displayName = "DialogHeader";
const DialogFooter = ({
className,
@@ -79,34 +83,37 @@ const DialogFooter = ({
{...props}
/>
);
-DialogFooter.displayName = "DialogFooter";
-const DialogTitle = React.forwardRef<
- React.ElementRef<typeof DialogPrimitive.Title>,
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
->(({ className, ...props }, ref) => (
- <DialogPrimitive.Title
- ref={ref}
- className={cn(
- "text-lg font-semibold leading-none tracking-tight",
- className,
- )}
- {...props}
- />
-));
-DialogTitle.displayName = DialogPrimitive.Title.displayName;
+function DialogTitle({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DialogPrimitive.Title>) {
+ return (
+ <DialogPrimitive.Title
+ ref={ref}
+ className={cn(
+ "text-lg font-semibold leading-none tracking-tight",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
-const DialogDescription = React.forwardRef<
- React.ElementRef<typeof DialogPrimitive.Description>,
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
->(({ className, ...props }, ref) => (
- <DialogPrimitive.Description
- ref={ref}
- className={cn("text-sm text-muted-foreground", className)}
- {...props}
- />
-));
-DialogDescription.displayName = DialogPrimitive.Description.displayName;
+function DialogDescription({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DialogPrimitive.Description>) {
+ return (
+ <DialogPrimitive.Description
+ ref={ref}
+ className={cn("text-sm text-muted-foreground", className)}
+ {...props}
+ />
+ );
+}
export {
Dialog,
diff --git a/frontend/components/ui/dropdown-menu.tsx b/frontend/components/ui/dropdown-menu.tsx
index b88da41b5..71825f029 100644
--- a/frontend/components/ui/dropdown-menu.tsx
+++ b/frontend/components/ui/dropdown-menu.tsx
@@ -18,155 +18,176 @@ const DropdownMenuSub = DropdownMenuPrimitive.Sub;
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
-const DropdownMenuSubTrigger = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
- inset?: boolean;
- }
->(({ className, inset, children, ...props }, ref) => (
- <DropdownMenuPrimitive.SubTrigger
- ref={ref}
- className={cn(
- "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
- inset && "pl-8",
- className,
- )}
- {...props}
- >
- {children}
- <ChevronRight className="ml-auto h-4 w-4" />
- </DropdownMenuPrimitive.SubTrigger>
-));
-DropdownMenuSubTrigger.displayName =
- DropdownMenuPrimitive.SubTrigger.displayName;
-
-const DropdownMenuSubContent = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
->(({ className, ...props }, ref) => (
- <DropdownMenuPrimitive.SubContent
- ref={ref}
- className={cn(
- "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",
- className,
- )}
- {...props}
- />
-));
-DropdownMenuSubContent.displayName =
- DropdownMenuPrimitive.SubContent.displayName;
-
-const DropdownMenuContent = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
->(({ className, sideOffset = 4, ...props }, ref) => (
- <DropdownMenuPrimitive.Portal>
- <DropdownMenuPrimitive.Content
+function DropdownMenuSubTrigger({
+ className,
+ inset,
+ children,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
+ inset?: boolean;
+}) {
+ return (
+ <DropdownMenuPrimitive.SubTrigger
+ ref={ref}
+ className={cn(
+ "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
+ inset && "pl-8",
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ <ChevronRight className="ml-auto h-4 w-4" />
+ </DropdownMenuPrimitive.SubTrigger>
+ );
+}
+
+function DropdownMenuSubContent({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
+ return (
+ <DropdownMenuPrimitive.SubContent
ref={ref}
- sideOffset={sideOffset}
className={cn(
- "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",
className,
)}
{...props}
/>
- </DropdownMenuPrimitive.Portal>
-));
-DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
-
-const DropdownMenuItem = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.Item>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
- inset?: boolean;
- }
->(({ className, inset, ...props }, ref) => (
- <DropdownMenuPrimitive.Item
- ref={ref}
- className={cn(
- "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
- inset && "pl-8",
- className,
- )}
- {...props}
- />
-));
-DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
-
-const DropdownMenuCheckboxItem = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
->(({ className, children, checked, ...props }, ref) => (
- <DropdownMenuPrimitive.CheckboxItem
- ref={ref}
- className={cn(
- "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
- className,
- )}
- checked={checked}
- {...props}
- >
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
- <DropdownMenuPrimitive.ItemIndicator>
- <Check className="h-4 w-4" />
- </DropdownMenuPrimitive.ItemIndicator>
- </span>
- {children}
- </DropdownMenuPrimitive.CheckboxItem>
-));
-DropdownMenuCheckboxItem.displayName =
- DropdownMenuPrimitive.CheckboxItem.displayName;
-
-const DropdownMenuRadioItem = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
->(({ className, children, ...props }, ref) => (
- <DropdownMenuPrimitive.RadioItem
- ref={ref}
- className={cn(
- "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
- className,
- )}
- {...props}
- >
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
- <DropdownMenuPrimitive.ItemIndicator>
- <Circle className="h-2 w-2 fill-current" />
- </DropdownMenuPrimitive.ItemIndicator>
- </span>
- {children}
- </DropdownMenuPrimitive.RadioItem>
-));
-DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
-
-const DropdownMenuLabel = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.Label>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
- inset?: boolean;
- }
->(({ className, inset, ...props }, ref) => (
- <DropdownMenuPrimitive.Label
- ref={ref}
- className={cn(
- "px-2 py-1.5 text-sm font-semibold",
- inset && "pl-8",
- className,
- )}
- {...props}
- />
-));
-DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
-
-const DropdownMenuSeparator = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
->(({ className, ...props }, ref) => (
- <DropdownMenuPrimitive.Separator
- ref={ref}
- className={cn("-mx-1 my-1 h-px bg-muted", className)}
- {...props}
- />
-));
-DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
+ );
+}
+
+function DropdownMenuContent({
+ className,
+ sideOffset = 4,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
+ return (
+ <DropdownMenuPrimitive.Portal>
+ <DropdownMenuPrimitive.Content
+ ref={ref}
+ sideOffset={sideOffset}
+ className={cn(
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",
+ className,
+ )}
+ {...props}
+ />
+ </DropdownMenuPrimitive.Portal>
+ );
+}
+
+function DropdownMenuItem({
+ className,
+ inset,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
+ inset?: boolean;
+}) {
+ return (
+ <DropdownMenuPrimitive.Item
+ ref={ref}
+ className={cn(
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
+ inset && "pl-8",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+function DropdownMenuCheckboxItem({
+ className,
+ children,
+ checked,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
+ return (
+ <DropdownMenuPrimitive.CheckboxItem
+ ref={ref}
+ className={cn(
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
+ className,
+ )}
+ checked={checked}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <DropdownMenuPrimitive.ItemIndicator>
+ <Check className="h-4 w-4" />
+ </DropdownMenuPrimitive.ItemIndicator>
+ </span>
+ {children}
+ </DropdownMenuPrimitive.CheckboxItem>
+ );
+}
+
+function DropdownMenuRadioItem({
+ className,
+ children,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
+ return (
+ <DropdownMenuPrimitive.RadioItem
+ ref={ref}
+ className={cn(
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
+ className,
+ )}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <DropdownMenuPrimitive.ItemIndicator>
+ <Circle className="h-2 w-2 fill-current" />
+ </DropdownMenuPrimitive.ItemIndicator>
+ </span>
+ {children}
+ </DropdownMenuPrimitive.RadioItem>
+ );
+}
+
+function DropdownMenuLabel({
+ className,
+ inset,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
+ inset?: boolean;
+}) {
+ return (
+ <DropdownMenuPrimitive.Label
+ ref={ref}
+ className={cn(
+ "px-2 py-1.5 text-sm font-semibold",
+ inset && "pl-8",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+function DropdownMenuSeparator({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
+ return (
+ <DropdownMenuPrimitive.Separator
+ ref={ref}
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
+ {...props}
+ />
+ );
+}
const DropdownMenuShortcut = ({
className,
@@ -179,7 +200,6 @@ const DropdownMenuShortcut = ({
/>
);
};
-DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
export {
DropdownMenu,
diff --git a/frontend/components/ui/input.tsx b/frontend/components/ui/input.tsx
index e612f97d3..f2574972a 100644
--- a/frontend/components/ui/input.tsx
+++ b/frontend/components/ui/input.tsx
@@ -6,76 +6,77 @@ export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {
icon?: React.ReactNode;
inputClassName?: string;
+ ref?: React.Ref<HTMLInputElement>;
}
-const Input = React.forwardRef<HTMLInputElement, InputProps>(
- ({ className, inputClassName, icon, type, placeholder, ...props }, ref) => {
- const [_hasValue, setHasValue] = React.useState(
- Boolean(props.value || props.defaultValue),
- );
- const [showPassword, setShowPassword] = React.useState(false);
+function Input({
+ className,
+ inputClassName,
+ icon,
+ type,
+ placeholder,
+ ref,
+ ...props
+}: InputProps) {
+ const [_hasValue, setHasValue] = React.useState(
+ Boolean(props.value || props.defaultValue),
+ );
+ const [showPassword, setShowPassword] = React.useState(false);
- const handleTogglePassword = () => {
- setShowPassword(!showPassword);
- };
+ const handleTogglePassword = () => {
+ setShowPassword(!showPassword);
+ };
- const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
- setHasValue(e.target.value.length > 0);
- if (props.onChange) {
- props.onChange(e);
- }
- };
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
+ setHasValue(e.target.value.length > 0);
+ if (props.onChange) {
+ props.onChange(e);
+ }
+ };
- return (
- <label
+ return (
+ <label
+ className={cn(
+ "relative block h-fit w-full text-sm group",
+ icon ? className : "",
+ )}
+ >
+ {icon && (
+ <div className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground">
+ {icon}
+ </div>
+ )}
+ <input
+ autoComplete="off"
+ type={type === "password" && showPassword ? "text" : type}
+ placeholder={placeholder}
className={cn(
- "relative block h-fit w-full text-sm group",
- icon ? className : "",
+ "primary-input",
+ icon && "!pl-9",
+ (type === "password" || props.disabled) && "!pr-8",
+ icon ? inputClassName : className,
)}
- >
- {icon && (
- <div className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground">
- {icon}
- </div>
- )}
- <input
- autoComplete="off"
- type={type === "password" && showPassword ? "text" : type}
- placeholder={placeholder}
- className={cn(
- "primary-input",
- icon && "!pl-9",
- (type === "password" || props.disabled) && "!pr-8",
- icon ? inputClassName : className,
- )}
- ref={ref}
- {...props}
- onChange={handleChange}
- />
- {type === "password" && !props.disabled && (
- <button
- type="button"
- className="absolute top-1/2 opacity-0 group-hover:opacity-100 hover:text-primary transition-all right-3 transform -translate-y-1/2 text-sm text-muted-foreground"
- onMouseDown={(e) => e.preventDefault()}
- onMouseUp={handleTogglePassword}
- >
- {showPassword ? (
- <Eye className="w-4" />
- ) : (
- <EyeOff className="w-4" />
- )}
- </button>
- )}
- {props.disabled && (
- <div className="absolute top-1/2 right-3 transform -translate-y-1/2 text-sm text-muted-foreground">
- <LockIcon className="w-4" />
- </div>
- )}
- </label>
- );
- },
-);
-
-Input.displayName = "Input";
+ ref={ref}
+ {...props}
+ onChange={handleChange}
+ />
+ {type === "password" && !props.disabled && (
+ <button
+ type="button"
+ className="absolute top-1/2 opacity-0 group-hover:opacity-100 hover:text-primary transition-all right-3 transform -translate-y-1/2 text-sm text-muted-foreground"
+ onMouseDown={(e) => e.preventDefault()}
+ onMouseUp={handleTogglePassword}
+ >
+ {showPassword ? <Eye className="w-4" /> : <EyeOff className="w-4" />}
+ </button>
+ )}
+ {props.disabled && (
+ <div className="absolute top-1/2 right-3 transform -translate-y-1/2 text-sm text-muted-foreground">
+ <LockIcon className="w-4" />
+ </div>
+ )}
+ </label>
+ );
+}
export { Input };
diff --git a/frontend/components/ui/popover.tsx b/frontend/components/ui/popover.tsx
index e702f80b6..a7db85975 100644
--- a/frontend/components/ui/popover.tsx
+++ b/frontend/components/ui/popover.tsx
@@ -11,23 +11,27 @@ const PopoverTrigger = PopoverPrimitive.Trigger;
const PopoverAnchor = PopoverPrimitive.Anchor;
-const PopoverContent = React.forwardRef<
- React.ElementRef<typeof PopoverPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
->(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
- <PopoverPrimitive.Portal>
- <PopoverPrimitive.Content
- ref={ref}
- align={align}
- sideOffset={sideOffset}
- className={cn(
- "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",
- className,
- )}
- {...props}
- />
- </PopoverPrimitive.Portal>
-));
-PopoverContent.displayName = PopoverPrimitive.Content.displayName;
+function PopoverContent({
+ className,
+ align = "center",
+ sideOffset = 4,
+ ref,
+ ...props
+}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
+ return (
+ <PopoverPrimitive.Portal>
+ <PopoverPrimitive.Content
+ ref={ref}
+ align={align}
+ sideOffset={sideOffset}
+ className={cn(
+ "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",
+ className,
+ )}
+ {...props}
+ />
+ </PopoverPrimitive.Portal>
+ );
+}
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };
diff --git a/frontend/components/ui/scroll-area.tsx b/frontend/components/ui/scroll-area.tsx
index e60d2ea87..4d09f8476 100644
--- a/frontend/components/ui/scroll-area.tsx
+++ b/frontend/components/ui/scroll-area.tsx
@@ -1,22 +1,18 @@
import * as React from "react";
import { cn } from "@/lib/utils";
-export type ScrollAreaProps = React.HTMLAttributes<HTMLDivElement>;
+export type ScrollAreaProps = React.ComponentProps<"div">;
-const ScrollArea = React.forwardRef<HTMLDivElement, ScrollAreaProps>(
- ({ className, children, ...props }, ref) => {
- return (
- <div
- ref={ref}
- className={cn("overflow-auto scrollbar-hide", className)}
- {...props}
- >
- {children}
- </div>
- );
- },
-);
-
-ScrollArea.displayName = "ScrollArea";
+function ScrollArea({ className, children, ref, ...props }: ScrollAreaProps) {
+ return (
+ <div
+ ref={ref}
+ className={cn("overflow-auto scrollbar-hide", className)}
+ {...props}
+ >
+ {children}
+ </div>
+ );
+}
export { ScrollArea };
diff --git a/frontend/components/ui/select.tsx b/frontend/components/ui/select.tsx
index 7681c962a..1106a6eb9 100644
--- a/frontend/components/ui/select.tsx
+++ b/frontend/components/ui/select.tsx
@@ -18,10 +18,12 @@ const SelectGroup = SelectPrimitive.Group;
const SelectValue = SelectPrimitive.Value;
-const SelectTrigger = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.Trigger>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
->(({ className, children, ...props }, ref) => {
+function SelectTrigger({
+ className,
+ children,
+ ref,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Trigger>) {
return (
<SelectPrimitive.Trigger
ref={ref}
@@ -41,122 +43,135 @@ const SelectTrigger = React.forwardRef<
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
);
-});
-SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
+}
-const SelectScrollUpButton = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
->(({ className, ...props }, ref) => (
- <SelectPrimitive.ScrollUpButton
- ref={ref}
- className={cn(
- "flex cursor-default items-center justify-center py-1",
- className,
- )}
- {...props}
- >
- <ChevronUp className="h-4 w-4" />
- </SelectPrimitive.ScrollUpButton>
-));
-SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
-
-const SelectScrollDownButton = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
->(({ className, ...props }, ref) => (
- <SelectPrimitive.ScrollDownButton
- ref={ref}
- className={cn(
- "flex cursor-default items-center justify-center py-1",
- className,
- )}
- {...props}
- >
- <ChevronDown className="h-4 w-4" />
- </SelectPrimitive.ScrollDownButton>
-));
-SelectScrollDownButton.displayName =
- SelectPrimitive.ScrollDownButton.displayName;
+function SelectScrollUpButton({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
+ return (
+ <SelectPrimitive.ScrollUpButton
+ ref={ref}
+ className={cn(
+ "flex cursor-default items-center justify-center py-1",
+ className,
+ )}
+ {...props}
+ >
+ <ChevronUp className="h-4 w-4" />
+ </SelectPrimitive.ScrollUpButton>
+ );
+}
-const SelectContent = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
->(({ className, children, position = "popper", ...props }, ref) => (
- <SelectPrimitive.Portal>
- <SelectPrimitive.Content
+function SelectScrollDownButton({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
+ return (
+ <SelectPrimitive.ScrollDownButton
ref={ref}
className={cn(
- "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",
- 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",
+ "flex cursor-default items-center justify-center py-1",
className,
)}
- position={position}
{...props}
>
- <SelectScrollUpButton />
- <SelectPrimitive.Viewport
+ <ChevronDown className="h-4 w-4" />
+ </SelectPrimitive.ScrollDownButton>
+ );
+}
+
+function SelectContent({
+ className,
+ children,
+ position = "popper",
+ ref,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Content>) {
+ return (
+ <SelectPrimitive.Portal>
+ <SelectPrimitive.Content
+ ref={ref}
className={cn(
- "p-1",
+ "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",
position === "popper" &&
- "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",
+ "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}
+ {...props}
>
- {children}
- </SelectPrimitive.Viewport>
- <SelectScrollDownButton />
- </SelectPrimitive.Content>
- </SelectPrimitive.Portal>
-));
-SelectContent.displayName = SelectPrimitive.Content.displayName;
+ <SelectScrollUpButton />
+ <SelectPrimitive.Viewport
+ className={cn(
+ "p-1",
+ position === "popper" &&
+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",
+ )}
+ >
+ {children}
+ </SelectPrimitive.Viewport>
+ <SelectScrollDownButton />
+ </SelectPrimitive.Content>
+ </SelectPrimitive.Portal>
+ );
+}
-const SelectLabel = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.Label>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
->(({ className, ...props }, ref) => (
- <SelectPrimitive.Label
- ref={ref}
- className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
- {...props}
- />
-));
-SelectLabel.displayName = SelectPrimitive.Label.displayName;
+function SelectLabel({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Label>) {
+ return (
+ <SelectPrimitive.Label
+ ref={ref}
+ className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
+ {...props}
+ />
+ );
+}
-const SelectItem = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.Item>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
->(({ className, children, ...props }, ref) => (
- <SelectPrimitive.Item
- ref={ref}
- className={cn(
- "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
- className,
- )}
- {...props}
- >
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
- <SelectPrimitive.ItemIndicator>
- <Check className="h-4 w-4" />
- </SelectPrimitive.ItemIndicator>
- </span>
+function SelectItem({
+ className,
+ children,
+ ref,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Item>) {
+ return (
+ <SelectPrimitive.Item
+ ref={ref}
+ className={cn(
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
+ className,
+ )}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <SelectPrimitive.ItemIndicator>
+ <Check className="h-4 w-4" />
+ </SelectPrimitive.ItemIndicator>
+ </span>
- <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
- </SelectPrimitive.Item>
-));
-SelectItem.displayName = SelectPrimitive.Item.displayName;
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
+ </SelectPrimitive.Item>
+ );
+}
-const SelectSeparator = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.Separator>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
->(({ className, ...props }, ref) => (
- <SelectPrimitive.Separator
- ref={ref}
- className={cn("-mx-1 my-1 h-px bg-muted", className)}
- {...props}
- />
-));
-SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
+function SelectSeparator({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
+ return (
+ <SelectPrimitive.Separator
+ ref={ref}
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
+ {...props}
+ />
+ );
+}
export {
Select,
diff --git a/frontend/components/ui/separator.tsx b/frontend/components/ui/separator.tsx
index 3cc446d24..286c6b7f9 100644
--- a/frontend/components/ui/separator.tsx
+++ b/frontend/components/ui/separator.tsx
@@ -5,14 +5,14 @@ import * as React from "react";
import { cn } from "@/lib/utils";
-const Separator = React.forwardRef<
- React.ElementRef<typeof SeparatorPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
->(
- (
- { className, orientation = "horizontal", decorative = true, ...props },
- ref,
- ) => (
+function Separator({
+ className,
+ orientation = "horizontal",
+ decorative = true,
+ ref,
+ ...props
+}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
+ return (
<SeparatorPrimitive.Root
ref={ref}
decorative={decorative}
@@ -24,8 +24,7 @@ const Separator = React.forwardRef<
)}
{...props}
/>
- ),
-);
-Separator.displayName = SeparatorPrimitive.Root.displayName;
+ );
+}
export { Separator };
diff --git a/frontend/components/ui/slider.tsx b/frontend/components/ui/slider.tsx
index 1053726b7..9566387b3 100644
--- a/frontend/components/ui/slider.tsx
+++ b/frontend/components/ui/slider.tsx
@@ -5,24 +5,26 @@ import * as React from "react";
import { cn } from "@/lib/utils";
-const Slider = React.forwardRef<
- React.ElementRef<typeof SliderPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
->(({ className, ...props }, ref) => (
- <SliderPrimitive.Root
- ref={ref}
- className={cn(
- "relative flex w-full touch-none select-none items-center",
- className,
- )}
- {...props}
- >
- <SliderPrimitive.Track className="relative h-[5px] w-full grow overflow-hidden rounded-full bg-muted">
- <SliderPrimitive.Range className="absolute h-full bg-muted-foreground" />
- </SliderPrimitive.Track>
- <SliderPrimitive.Thumb className="block h-4 w-4 rounded-full border-2 border-foreground bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
- </SliderPrimitive.Root>
-));
-Slider.displayName = SliderPrimitive.Root.displayName;
+function Slider({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof SliderPrimitive.Root>) {
+ return (
+ <SliderPrimitive.Root
+ ref={ref}
+ className={cn(
+ "relative flex w-full touch-none select-none items-center",
+ className,
+ )}
+ {...props}
+ >
+ <SliderPrimitive.Track className="relative h-[5px] w-full grow overflow-hidden rounded-full bg-muted">
+ <SliderPrimitive.Range className="absolute h-full bg-muted-foreground" />
+ </SliderPrimitive.Track>
+ <SliderPrimitive.Thumb className="block h-4 w-4 rounded-full border-2 border-foreground bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
+ </SliderPrimitive.Root>
+ );
+}
export { Slider };
diff --git a/frontend/components/ui/switch.tsx b/frontend/components/ui/switch.tsx
index c433c75b8..139bf4439 100644
--- a/frontend/components/ui/switch.tsx
+++ b/frontend/components/ui/switch.tsx
@@ -5,25 +5,27 @@ import * as React from "react";
import { cn } from "@/lib/utils";
-const Switch = React.forwardRef<
- React.ElementRef<typeof SwitchPrimitives.Root>,
- React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
->(({ className, ...props }, ref) => (
- <SwitchPrimitives.Root
- className={cn(
- "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-muted",
- className,
- )}
- {...props}
- ref={ref}
- >
- <SwitchPrimitives.Thumb
+function Switch({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof SwitchPrimitives.Root>) {
+ return (
+ <SwitchPrimitives.Root
className={cn(
- "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 data-[state=unchecked]:bg-primary",
+ "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-muted",
+ className,
)}
- />
- </SwitchPrimitives.Root>
-));
-Switch.displayName = SwitchPrimitives.Root.displayName;
+ {...props}
+ ref={ref}
+ >
+ <SwitchPrimitives.Thumb
+ className={cn(
+ "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 data-[state=unchecked]:bg-primary",
+ )}
+ />
+ </SwitchPrimitives.Root>
+ );
+}
export { Switch };
diff --git a/frontend/components/ui/tabs.tsx b/frontend/components/ui/tabs.tsx
index 76720b106..4369135e6 100644
--- a/frontend/components/ui/tabs.tsx
+++ b/frontend/components/ui/tabs.tsx
@@ -6,49 +6,55 @@ import { cn } from "@/lib/utils";
const Tabs = TabsPrimitive.Root;
-const TabsList = React.forwardRef<
- React.ElementRef<typeof TabsPrimitive.List>,
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
->(({ className, ...props }, ref) => (
- <TabsPrimitive.List
- ref={ref}
- className={cn(
- "inline-flex h-fit gap-3 items-center justify-center p-0 text-muted-foreground w-full",
- className,
- )}
- {...props}
- />
-));
-TabsList.displayName = TabsPrimitive.List.displayName;
+function TabsList({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof TabsPrimitive.List>) {
+ return (
+ <TabsPrimitive.List
+ ref={ref}
+ className={cn(
+ "inline-flex h-fit gap-3 items-center justify-center p-0 text-muted-foreground w-full",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
-const TabsTrigger = React.forwardRef<
- React.ElementRef<typeof TabsPrimitive.Trigger>,
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
->(({ className, ...props }, ref) => (
- <TabsPrimitive.Trigger
- ref={ref}
- className={cn(
- "flex flex-col items-start justify-between p-5 gap-4 w-full h-full border border-border whitespace-nowrap rounded-lg text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-muted-foreground data-[state=active]:text-foreground",
- className,
- )}
- {...props}
- />
-));
-TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
+function TabsTrigger({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
+ return (
+ <TabsPrimitive.Trigger
+ ref={ref}
+ className={cn(
+ "flex flex-col items-start justify-between p-5 gap-4 w-full h-full border border-border whitespace-nowrap rounded-lg text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-muted-foreground data-[state=active]:text-foreground",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
-const TabsContent = React.forwardRef<
- React.ElementRef<typeof TabsPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
->(({ className, ...props }, ref) => (
- <TabsPrimitive.Content
- ref={ref}
- className={cn(
- "mt-2 space-y-5 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
- className,
- )}
- {...props}
- />
-));
-TabsContent.displayName = TabsPrimitive.Content.displayName;
+function TabsContent({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof TabsPrimitive.Content>) {
+ return (
+ <TabsPrimitive.Content
+ ref={ref}
+ className={cn(
+ "mt-2 space-y-5 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
export { Tabs, TabsContent, TabsList, TabsTrigger };
diff --git a/frontend/components/ui/tooltip.tsx b/frontend/components/ui/tooltip.tsx
index a41e5898d..d68c63ef7 100644
--- a/frontend/components/ui/tooltip.tsx
+++ b/frontend/components/ui/tooltip.tsx
@@ -11,22 +11,25 @@ const Tooltip = TooltipPrimitive.Root;
const TooltipTrigger = TooltipPrimitive.Trigger;
-const TooltipContent = React.forwardRef<
- React.ElementRef<typeof TooltipPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
->(({ className, sideOffset = 4, ...props }, ref) => (
- <TooltipPrimitive.Portal>
- <TooltipPrimitive.Content
- ref={ref}
- sideOffset={sideOffset}
- className={cn(
- "z-50 overflow-hidden rounded-md border bg-primary py-1 px-1.5 text-xs font-normal text-primary-foreground shadow-md 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 origin-[--radix-tooltip-content-transform-origin]",
- className,
- )}
- {...props}
- />
- </TooltipPrimitive.Portal>
-));
-TooltipContent.displayName = TooltipPrimitive.Content.displayName;
+function TooltipContent({
+ className,
+ sideOffset = 4,
+ ref,
+ ...props
+}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
+ return (
+ <TooltipPrimitive.Portal>
+ <TooltipPrimitive.Content
+ ref={ref}
+ sideOffset={sideOffset}
+ className={cn(
+ "z-50 overflow-hidden rounded-md border bg-primary py-1 px-1.5 text-xs font-normal text-primary-foreground shadow-md 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 origin-[--radix-tooltip-content-transform-origin]",
+ className,
+ )}
+ {...props}
+ />
+ </TooltipPrimitive.Portal>
+ );
+}
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
diff --git a/frontend/contexts/auth-context.tsx b/frontend/contexts/auth-context.tsx
index 9cdd76b34..1fb6d64cb 100644
--- a/frontend/contexts/auth-context.tsx
+++ b/frontend/contexts/auth-context.tsx
@@ -3,8 +3,8 @@
import React, {
createContext,
ReactNode,
+ use,
useCallback,
- useContext,
useEffect,
useState,
} from "react";
@@ -61,7 +61,7 @@ interface AuthContextType {
const AuthContext = createContext<AuthContextType | undefined>(undefined);
export function useAuth() {
- const context = useContext(AuthContext);
+ const context = use(AuthContext);
if (context === undefined) {
throw new Error("useAuth must be used within an AuthProvider");
}
diff --git a/frontend/contexts/brand-context.tsx b/frontend/contexts/brand-context.tsx
index 943a919ad..24c44e194 100644
--- a/frontend/contexts/brand-context.tsx
+++ b/frontend/contexts/brand-context.tsx
@@ -2,8 +2,8 @@
import {
createContext,
+ use,
useCallback,
- useContext,
useEffect,
useMemo,
useState,
@@ -71,9 +71,9 @@ export function BrandProvider({ children }: { children: React.ReactNode }) {
);
}
-export const useBrand = () => useContext(BrandContext);
+export const useBrand = () => use(BrandContext);
export const useIsCloudBrand = () => {
- const { brand } = useContext(BrandContext);
+ const { brand } = use(BrandContext);
return isCloudBrand(brand);
};
diff --git a/frontend/contexts/chat-context.tsx b/frontend/contexts/chat-context.tsx
index 307474189..153d31dec 100644
--- a/frontend/contexts/chat-context.tsx
+++ b/frontend/contexts/chat-context.tsx
@@ -3,8 +3,8 @@
import {
createContext,
type ReactNode,
+ use,
useCallback,
- useContext,
useEffect,
useMemo,
useRef,
@@ -429,7 +429,7 @@ export function ChatProvider({ children }: ChatProviderProps) {
}
export function useChat(): ChatContextType {
- const context = useContext(ChatContext);
+ const context = use(ChatContext);
if (context === undefined) {
throw new Error("useChat must be used within a ChatProvider");
}
diff --git a/frontend/contexts/knowledge-filter-context.tsx b/frontend/contexts/knowledge-filter-context.tsx
index fa2388250..a538484af 100644
--- a/frontend/contexts/knowledge-filter-context.tsx
+++ b/frontend/contexts/knowledge-filter-context.tsx
@@ -3,8 +3,8 @@
import React, {
createContext,
type ReactNode,
+ use,
useCallback,
- useContext,
useState,
} from "react";
import { FilterColor, IconKey } from "@/components/filter-icon-popover";
@@ -59,7 +59,7 @@ const KnowledgeFilterContext = createContext<
>(undefined);
export function useKnowledgeFilter() {
- const context = useContext(KnowledgeFilterContext);
+ const context = use(KnowledgeFilterContext);
if (context === undefined) {
throw new Error(
"useKnowledgeFilter must be used within a KnowledgeFilterProvider",
diff --git a/frontend/contexts/task-context.tsx b/frontend/contexts/task-context.tsx
index 4bcaa7dc1..93ce5b78b 100644
--- a/frontend/contexts/task-context.tsx
+++ b/frontend/contexts/task-context.tsx
@@ -4,8 +4,8 @@ import { useQueryClient } from "@tanstack/react-query";
import type React from "react";
import {
createContext,
+ use,
useCallback,
- useContext,
useEffect,
useRef,
useState,
@@ -768,7 +768,7 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
}
export function useTask() {
- const context = useContext(TaskContext);
+ const context = use(TaskContext);
if (context === undefined) {
throw new Error("useTask must be used within a TaskProvider");
}