Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

refactor(frontend): drop React.forwardRef for ref-as-prop (React 19)

Sergey Kozyrenko53c140dd7030
diff --git a/frontend/src/components/shared/header-button.tsx b/frontend/src/components/shared/header-button.tsx
index 402b111b..32a65aad 100644
--- a/frontend/src/components/shared/header-button.tsx
+++ b/frontend/src/components/shared/header-button.tsx
@@ -1,4 +1,4 @@
-import { forwardRef, type ReactNode } from 'react';
+import type { ReactNode, Ref } from 'react';
import { Button, type ButtonProps } from '@/components/ui/button';
import { cn } from '@/lib/utils';
@@ -7,6 +7,7 @@ interface HeaderButtonProps extends Omit<ButtonProps, 'children'> {
endIcon?: ReactNode;
icon: ReactNode;
label: ReactNode;
+ ref?: Ref<HTMLButtonElement>;
}
// Action button rendered inside a page header. Collapses to an icon-only square
@@ -15,23 +16,31 @@ interface HeaderButtonProps extends Omit<ButtonProps, 'children'> {
// trailing icon, e.g. a dropdown chevron) on wider screens. `aria-label` is
// auto-derived from `label` when it's a plain string so the icon-only mobile
// state stays accessible without the caller having to remember it.
-export const HeaderButton = forwardRef<HTMLButtonElement, HeaderButtonProps>(
- ({ 'aria-label': ariaLabel, className, endIcon, icon, label, size = 'sm', ...props }, ref) => {
- const accessibleLabel = ariaLabel ?? (typeof label === 'string' ? label : undefined);
+export const HeaderButton = ({
+ 'aria-label': ariaLabel,
+ className,
+ endIcon,
+ icon,
+ label,
+ ref,
+ size = 'sm',
+ ...props
+}: HeaderButtonProps) => {
+ const accessibleLabel = ariaLabel ?? (typeof label === 'string' ? label : undefined);
+
+ return (
+ <Button
+ aria-label={accessibleLabel}
+ className={cn('w-8 px-0 md:w-auto md:px-3', className)}
+ ref={ref}
+ size={size}
+ {...props}
+ >
+ {icon}
+ <span className="hidden md:inline">{label}</span>
+ {endIcon ? <span className="hidden md:inline-flex">{endIcon}</span> : null}
+ </Button>
+ );
+};
- return (
- <Button
- aria-label={accessibleLabel}
- className={cn('w-8 px-0 md:w-auto md:px-3', className)}
- ref={ref}
- size={size}
- {...props}
- >
- {icon}
- <span className="hidden md:inline">{label}</span>
- {endIcon ? <span className="hidden md:inline-flex">{endIcon}</span> : null}
- </Button>
- );
- },
-);
HeaderButton.displayName = 'HeaderButton';
diff --git a/frontend/src/components/shared/markdown-editor.tsx b/frontend/src/components/shared/markdown-editor.tsx
index cb312fde..966d3393 100644
--- a/frontend/src/components/shared/markdown-editor.tsx
+++ b/frontend/src/components/shared/markdown-editor.tsx
@@ -22,7 +22,7 @@ import {
Strikethrough,
Undo,
} from 'lucide-react';
-import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from 'react';
+import { type Ref, useCallback, useEffect, useImperativeHandle, useRef } from 'react';
import { Markdown } from 'tiptap-markdown';
import { Separator } from '@/components/ui/separator';
@@ -95,212 +95,208 @@ const resetUndoHistory = (editor: Editor): void => {
view.dispatch(newState.tr.setMeta('addToHistory', false));
};
-const MarkdownEditor = forwardRef<MarkdownEditorHandle, MarkdownEditorProps>(
- (
- {
- autoFocus,
- className,
- contentClassName,
- disabled,
- onBlur,
- onChange,
- placeholder = 'Write something…',
- showToolbar = true,
- value,
- },
- ref,
- ) => {
- const onChangeRef = useRef(onChange);
- const onBlurRef = useRef(onBlur);
- // Tracks the last markdown the editor reported externally. We compare
- // against this to suppress echo updates: tiptap-markdown can re-serialize
- // content slightly differently than the input string (whitespace/list
- // markers/hard breaks/etc.), and we don't want to flag those
- // normalizations as user edits — that would falsely flip RHF's
- // `isDirty` flag.
- //
- // The baseline is the editor's own serialized markdown, NOT the raw
- // input `value`. Comparing user edits against the canonical
- // (post-normalization) form is what makes the comparison correct.
- const lastEmittedRef = useRef<string>(value);
-
- // Tiptap dispatches transactions for the initial content during view
- // construction. Those `onUpdate` calls are echoes of the initial
- // parse, not real user edits — forwarding them to RHF would mark
- // the form dirty on mount. We start forwarding edits only after
- // `onCreate` has captured the canonical baseline.
- const isInitializedRef = useRef(false);
-
- // Tracks whether we have already cleared the undo stack on initial
- // mount. After the first sync useEffect run we set this to true; on
- // subsequent renders we only clear the stack when an external value
- // arrived (see `shouldExternalSync` below).
- const hasResetInitialHistoryRef = useRef(false);
-
- useEffect(() => {
- onChangeRef.current = onChange;
- onBlurRef.current = onBlur;
- }, [onChange, onBlur]);
-
- const editor = useEditor({
- content: value,
- editable: !disabled,
- extensions: [
- StarterKit.configure({
- codeBlock: { HTMLAttributes: { class: 'hljs' } },
- }),
- Placeholder.configure({
- emptyEditorClass: 'is-editor-empty',
- placeholder,
- }),
- Markdown.configure({
- breaks: true,
- html: false,
- linkify: true,
- tightLists: true,
- transformCopiedText: true,
- // Plain text pasted from the OS clipboard is left as-is.
- // With `transformPastedText: true`, a leading "- " (or
- // "1. ", "> ", etc.) would be parsed as markdown and
- // turn the paste into a list/blockquote — almost never
- // what the user wants for knowledge documents.
- transformPastedText: false,
- }),
- ],
- immediatelyRender: false,
- onBlur: () => onBlurRef.current?.(),
- onCreate: ({ editor: instance }) => {
- lastEmittedRef.current = instance.storage.markdown.getMarkdown();
- isInitializedRef.current = true;
- },
- onUpdate: ({ editor: instance }) => {
- if (!isInitializedRef.current) {
- return;
- }
-
- const next = instance.storage.markdown.getMarkdown();
-
- if (next === lastEmittedRef.current) {
- return;
- }
-
- lastEmittedRef.current = next;
- onChangeRef.current?.(next);
- },
- });
-
- useImperativeHandle(
- ref,
- () => ({
- focus: () => editor?.commands.focus(),
- getEditor: () => editor,
+const MarkdownEditor = ({
+ autoFocus,
+ className,
+ contentClassName,
+ disabled,
+ onBlur,
+ onChange,
+ placeholder = 'Write something…',
+ ref,
+ showToolbar = true,
+ value,
+}: MarkdownEditorProps & { ref?: Ref<MarkdownEditorHandle> }) => {
+ const onChangeRef = useRef(onChange);
+ const onBlurRef = useRef(onBlur);
+ // Tracks the last markdown the editor reported externally. We compare
+ // against this to suppress echo updates: tiptap-markdown can re-serialize
+ // content slightly differently than the input string (whitespace/list
+ // markers/hard breaks/etc.), and we don't want to flag those
+ // normalizations as user edits — that would falsely flip RHF's
+ // `isDirty` flag.
+ //
+ // The baseline is the editor's own serialized markdown, NOT the raw
+ // input `value`. Comparing user edits against the canonical
+ // (post-normalization) form is what makes the comparison correct.
+ const lastEmittedRef = useRef<string>(value);
+
+ // Tiptap dispatches transactions for the initial content during view
+ // construction. Those `onUpdate` calls are echoes of the initial
+ // parse, not real user edits — forwarding them to RHF would mark
+ // the form dirty on mount. We start forwarding edits only after
+ // `onCreate` has captured the canonical baseline.
+ const isInitializedRef = useRef(false);
+
+ // Tracks whether we have already cleared the undo stack on initial
+ // mount. After the first sync useEffect run we set this to true; on
+ // subsequent renders we only clear the stack when an external value
+ // arrived (see `shouldExternalSync` below).
+ const hasResetInitialHistoryRef = useRef(false);
+
+ useEffect(() => {
+ onChangeRef.current = onChange;
+ onBlurRef.current = onBlur;
+ }, [onChange, onBlur]);
+
+ const editor = useEditor({
+ content: value,
+ editable: !disabled,
+ extensions: [
+ StarterKit.configure({
+ codeBlock: { HTMLAttributes: { class: 'hljs' } },
}),
- [editor],
- );
-
- // Keep external value in sync (e.g. on form reset). Avoid resetting if
- // the editor already reflects the same markdown to keep cursor stable.
- useEffect(() => {
- if (!editor) {
+ Placeholder.configure({
+ emptyEditorClass: 'is-editor-empty',
+ placeholder,
+ }),
+ Markdown.configure({
+ breaks: true,
+ html: false,
+ linkify: true,
+ tightLists: true,
+ transformCopiedText: true,
+ // Plain text pasted from the OS clipboard is left as-is.
+ // With `transformPastedText: true`, a leading "- " (or
+ // "1. ", "> ", etc.) would be parsed as markdown and
+ // turn the paste into a list/blockquote — almost never
+ // what the user wants for knowledge documents.
+ transformPastedText: false,
+ }),
+ ],
+ immediatelyRender: false,
+ onBlur: () => onBlurRef.current?.(),
+ onCreate: ({ editor: instance }) => {
+ lastEmittedRef.current = instance.storage.markdown.getMarkdown();
+ isInitializedRef.current = true;
+ },
+ onUpdate: ({ editor: instance }) => {
+ if (!isInitializedRef.current) {
return;
}
- const current = editor.storage.markdown.getMarkdown();
- const shouldExternalSync = current !== value;
+ const next = instance.storage.markdown.getMarkdown();
- if (shouldExternalSync) {
- editor.commands.setContent(value, { emitUpdate: false });
+ if (next === lastEmittedRef.current) {
+ return;
}
- // The editor's own serialized markdown is the canonical form —
- // subsequent user edits will be compared against this
- // representation, not the (possibly non-normalized) input
- // `value`. Storing the raw `value` here would cause the first
- // user keystroke to also re-emit the round-trip normalization.
- lastEmittedRef.current = editor.storage.markdown.getMarkdown();
-
- // Clear the undo stack:
- // - on initial mount, to discard the construction-time
- // transactions dispatched by extensions like `trailingNode`
- // plus the initial `setContent` we just ran above;
- // - on every external `setContent` (e.g. parent calls
- // form.reset(serverDocument)), because that transaction is
- // not a user edit either.
- //
- // We MUST NOT reset on every render: when the user types,
- // `value` changes too, and resetting then would erase the
- // user's own undo history.
- if (!hasResetInitialHistoryRef.current || shouldExternalSync) {
- hasResetInitialHistoryRef.current = true;
- resetUndoHistory(editor);
- }
- }, [editor, value]);
+ lastEmittedRef.current = next;
+ onChangeRef.current?.(next);
+ },
+ });
- useEffect(() => {
- if (!editor) {
- return;
- }
+ useImperativeHandle(
+ ref,
+ () => ({
+ focus: () => editor?.commands.focus(),
+ getEditor: () => editor,
+ }),
+ [editor],
+ );
- editor.setEditable(!disabled);
- }, [editor, disabled]);
+ // Keep external value in sync (e.g. on form reset). Avoid resetting if
+ // the editor already reflects the same markdown to keep cursor stable.
+ useEffect(() => {
+ if (!editor) {
+ return;
+ }
- useEffect(() => {
- if (autoFocus && editor) {
- editor.commands.focus('end');
- }
- // `autoFocus` is intentionally omitted from the deps — it's a
- // mount-time prop, equivalent to the native `<input autoFocus>`
- // attribute. We don't want a parent flipping `autoFocus` later
- // to steal focus back into the editor.
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [editor]);
-
- // While tiptap is initializing (`useEditor` returns `null` on the
- // first render with `immediatelyRender: false`), render a placeholder
- // with the same outer classes so the bounding box is already correct
- // and the parent layout doesn't jump when the editor mounts.
+ const current = editor.storage.markdown.getMarkdown();
+ const shouldExternalSync = current !== value;
+
+ if (shouldExternalSync) {
+ editor.commands.setContent(value, { emitUpdate: false });
+ }
+
+ // The editor's own serialized markdown is the canonical form —
+ // subsequent user edits will be compared against this
+ // representation, not the (possibly non-normalized) input
+ // `value`. Storing the raw `value` here would cause the first
+ // user keystroke to also re-emit the round-trip normalization.
+ lastEmittedRef.current = editor.storage.markdown.getMarkdown();
+
+ // Clear the undo stack:
+ // - on initial mount, to discard the construction-time
+ // transactions dispatched by extensions like `trailingNode`
+ // plus the initial `setContent` we just ran above;
+ // - on every external `setContent` (e.g. parent calls
+ // form.reset(serverDocument)), because that transaction is
+ // not a user edit either.
+ //
+ // We MUST NOT reset on every render: when the user types,
+ // `value` changes too, and resetting then would erase the
+ // user's own undo history.
+ if (!hasResetInitialHistoryRef.current || shouldExternalSync) {
+ hasResetInitialHistoryRef.current = true;
+ resetUndoHistory(editor);
+ }
+ }, [editor, value]);
+
+ useEffect(() => {
if (!editor) {
- return (
- <div
- aria-busy="true"
- className={cn(
- 'border-input dark:bg-input/30 group/markdown-editor flex w-full flex-col overflow-hidden rounded-md border shadow-2xs outline-hidden transition-[color,box-shadow]',
- disabled && 'pointer-events-none opacity-60',
- className,
- )}
- data-slot="markdown-editor"
- />
- );
+ return;
}
+ editor.setEditable(!disabled);
+ }, [editor, disabled]);
+
+ useEffect(() => {
+ if (autoFocus && editor) {
+ editor.commands.focus('end');
+ }
+ // `autoFocus` is intentionally omitted from the deps — it's a
+ // mount-time prop, equivalent to the native `<input autoFocus>`
+ // attribute. We don't want a parent flipping `autoFocus` later
+ // to steal focus back into the editor.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [editor]);
+
+ // While tiptap is initializing (`useEditor` returns `null` on the
+ // first render with `immediatelyRender: false`), render a placeholder
+ // with the same outer classes so the bounding box is already correct
+ // and the parent layout doesn't jump when the editor mounts.
+ if (!editor) {
return (
<div
+ aria-busy="true"
className={cn(
'border-input dark:bg-input/30 group/markdown-editor flex w-full flex-col overflow-hidden rounded-md border shadow-2xs outline-hidden transition-[color,box-shadow]',
- 'focus-within:ring-ring focus-within:ring-1',
disabled && 'pointer-events-none opacity-60',
className,
)}
data-slot="markdown-editor"
- >
- {showToolbar ? (
- <MarkdownEditorToolbar
- disabled={disabled}
- editor={editor}
- />
- ) : null}
- <EditorContent
- className={cn(
- 'prose prose-sm dark:prose-invert tiptap-content max-w-none min-w-0 flex-1 overflow-auto px-3 py-2',
- '[&_.ProseMirror]:min-h-full [&_.ProseMirror]:outline-none',
- contentClassName,
- )}
+ />
+ );
+ }
+
+ return (
+ <div
+ className={cn(
+ 'border-input dark:bg-input/30 group/markdown-editor flex w-full flex-col overflow-hidden rounded-md border shadow-2xs outline-hidden transition-[color,box-shadow]',
+ 'focus-within:ring-ring focus-within:ring-1',
+ disabled && 'pointer-events-none opacity-60',
+ className,
+ )}
+ data-slot="markdown-editor"
+ >
+ {showToolbar ? (
+ <MarkdownEditorToolbar
+ disabled={disabled}
editor={editor}
/>
- </div>
- );
- },
-);
+ ) : null}
+ <EditorContent
+ className={cn(
+ 'prose prose-sm dark:prose-invert tiptap-content max-w-none min-w-0 flex-1 overflow-auto px-3 py-2',
+ '[&_.ProseMirror]:min-h-full [&_.ProseMirror]:outline-none',
+ contentClassName,
+ )}
+ editor={editor}
+ />
+ </div>
+ );
+};
MarkdownEditor.displayName = 'MarkdownEditor';
diff --git a/frontend/src/components/ui/accordion.tsx b/frontend/src/components/ui/accordion.tsx
index 3869f5e7..36a1194a 100644
--- a/frontend/src/components/ui/accordion.tsx
+++ b/frontend/src/components/ui/accordion.tsx
@@ -6,22 +6,29 @@ 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) => (
+const AccordionItem = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item> & {
+ ref?: React.Ref<React.ElementRef<typeof AccordionPrimitive.Item>>;
+}) => (
<AccordionPrimitive.Item
className={cn('border-b', className)}
ref={ref}
{...props}
/>
-));
+);
AccordionItem.displayName = 'AccordionItem';
-const AccordionTrigger = React.forwardRef<
- React.ElementRef<typeof AccordionPrimitive.Trigger>,
- React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
->(({ children, className, ...props }, ref) => (
+const AccordionTrigger = ({
+ children,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> & {
+ ref?: React.Ref<React.ElementRef<typeof AccordionPrimitive.Trigger>>;
+}) => (
<AccordionPrimitive.Header className="flex">
<AccordionPrimitive.Trigger
className={cn(
@@ -35,13 +42,17 @@ const AccordionTrigger = React.forwardRef<
<ChevronDownIcon className="text-muted-foreground h-4 w-4 shrink-0 transition-transform duration-200" />
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
-));
+);
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
-const AccordionContent = React.forwardRef<
- React.ElementRef<typeof AccordionPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
->(({ children, className, ...props }, ref) => (
+const AccordionContent = ({
+ children,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content> & {
+ ref?: React.Ref<React.ElementRef<typeof AccordionPrimitive.Content>>;
+}) => (
<AccordionPrimitive.Content
className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
ref={ref}
@@ -49,7 +60,7 @@ const AccordionContent = React.forwardRef<
>
<div className={cn('pt-0 pb-4', className)}>{children}</div>
</AccordionPrimitive.Content>
-));
+);
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
diff --git a/frontend/src/components/ui/alert.tsx b/frontend/src/components/ui/alert.tsx
index f84bb01c..e676ad6a 100644
--- a/frontend/src/components/ui/alert.tsx
+++ b/frontend/src/components/ui/alert.tsx
@@ -18,38 +18,44 @@ const alertVariants = cva(
},
);
-const Alert = React.forwardRef<
- HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
->(({ className, variant, ...props }, ref) => (
+const Alert = ({
+ className,
+ ref,
+ variant,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants> & { ref?: React.Ref<HTMLDivElement> }) => (
<div
className={cn(alertVariants({ variant }), className)}
ref={ref}
role="alert"
{...props}
/>
-));
+);
Alert.displayName = 'Alert';
-const AlertTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
- ({ className, ...props }, ref) => (
- <h5
- className={cn('mb-1 leading-none font-medium tracking-tight', className)}
- ref={ref}
- {...props}
- />
- ),
+const AlertTitle = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLHeadingElement> & { ref?: React.Ref<HTMLParagraphElement> }) => (
+ <h5
+ className={cn('mb-1 leading-none font-medium tracking-tight', className)}
+ ref={ref}
+ {...props}
+ />
);
AlertTitle.displayName = 'AlertTitle';
-const AlertDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
- ({ className, ...props }, ref) => (
- <div
- className={cn('text-sm [&_p]:leading-relaxed', className)}
- ref={ref}
- {...props}
- />
- ),
+const AlertDescription = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLParagraphElement> & { ref?: React.Ref<HTMLParagraphElement> }) => (
+ <div
+ className={cn('text-sm [&_p]:leading-relaxed', className)}
+ ref={ref}
+ {...props}
+ />
);
AlertDescription.displayName = 'AlertDescription';
diff --git a/frontend/src/components/ui/autocomplete.tsx b/frontend/src/components/ui/autocomplete.tsx
index 799ae1e7..9192c91a 100644
--- a/frontend/src/components/ui/autocomplete.tsx
+++ b/frontend/src/components/ui/autocomplete.tsx
@@ -239,148 +239,155 @@ export type AutocompleteInputProps = Omit<
'defaultValue' | 'onChange' | 'type' | 'value'
>;
-const AutocompleteInput = React.forwardRef<HTMLInputElement, AutocompleteInputProps>(
- ({ className, id, onFocus, onKeyDown, onPointerDown, ...props }, forwardedRef) => {
- const { commit, inputId, inputRef, inputValue, open, openOnFocus, setInputValue, setOpen } =
- useAutocompleteContext();
-
- // True when Enter would land on a real match. Selecting a suggestion
- // commits through cmdk's `onSelect`; Enter without a match commits the
- // raw input ourselves. Returning a primitive (not an object) lets
- // `useSyncExternalStore`'s referential check halve per-keystroke renders.
- const hasActiveMatch = useCommandState((state) => state.filtered.count > 0 && Boolean(state.value));
-
- // Suppress the autoFocus-fired `focus` on mount: opening the popover
- // before the user did anything is jarring (browser address bars behave
- // the same). React's autoFocus fires the native event synchronously
- // during `commitMount`, before any effect — so the flag is still `true`
- // for that first focus and flipped to `false` here for every
- // user-driven focus (click, Tab, re-focus after Escape).
- const isMountFocusRef = React.useRef(true);
-
- React.useEffect(() => {
- isMountFocusRef.current = false;
- }, []);
-
- const setInputRef = React.useCallback(
- (node: HTMLInputElement | null) => {
- inputRef.current = node;
-
- if (typeof forwardedRef === 'function') {
- forwardedRef(node);
- } else if (forwardedRef) {
- (forwardedRef as React.MutableRefObject<HTMLInputElement | null>).current = node;
- }
- },
- [forwardedRef, inputRef],
- );
+const AutocompleteInput = ({
+ className,
+ id,
+ onFocus,
+ onKeyDown,
+ onPointerDown,
+ ref: forwardedRef,
+ ...props
+}: AutocompleteInputProps & { ref?: React.Ref<HTMLInputElement> }) => {
+ const { commit, inputId, inputRef, inputValue, open, openOnFocus, setInputValue, setOpen } =
+ useAutocompleteContext();
+
+ // True when Enter would land on a real match. Selecting a suggestion
+ // commits through cmdk's `onSelect`; Enter without a match commits the
+ // raw input ourselves. Returning a primitive (not an object) lets
+ // `useSyncExternalStore`'s referential check halve per-keystroke renders.
+ const hasActiveMatch = useCommandState((state) => state.filtered.count > 0 && Boolean(state.value));
+
+ // Suppress the autoFocus-fired `focus` on mount: opening the popover
+ // before the user did anything is jarring (browser address bars behave
+ // the same). React's autoFocus fires the native event synchronously
+ // during `commitMount`, before any effect — so the flag is still `true`
+ // for that first focus and flipped to `false` here for every
+ // user-driven focus (click, Tab, re-focus after Escape).
+ const isMountFocusRef = React.useRef(true);
+
+ React.useEffect(() => {
+ isMountFocusRef.current = false;
+ }, []);
+
+ const setInputRef = React.useCallback(
+ (node: HTMLInputElement | null) => {
+ inputRef.current = node;
+
+ if (typeof forwardedRef === 'function') {
+ forwardedRef(node);
+ } else if (forwardedRef) {
+ (forwardedRef as React.MutableRefObject<HTMLInputElement | null>).current = node;
+ }
+ },
+ [forwardedRef, inputRef],
+ );
- const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {
- onFocus?.(event);
+ const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {
+ onFocus?.(event);
- if (event.defaultPrevented) {
- return;
- }
+ if (event.defaultPrevented) {
+ return;
+ }
- if (openOnFocus && !isMountFocusRef.current) {
- setOpen(true);
- }
- };
+ if (openOnFocus && !isMountFocusRef.current) {
+ setOpen(true);
+ }
+ };
- const handlePointerDown = (event: React.PointerEvent<HTMLInputElement>) => {
- onPointerDown?.(event);
+ const handlePointerDown = (event: React.PointerEvent<HTMLInputElement>) => {
+ onPointerDown?.(event);
- if (event.defaultPrevented) {
- return;
- }
+ if (event.defaultPrevented) {
+ return;
+ }
- // Without this, clicking an already-focused input (e.g. when the
- // dialog opened with autoFocus on the input and the user then
- // clicks it) won't fire `focus` again — and the popover would stay
- // closed despite a clear user intent. PointerDown is the cleanest
- // signal of "user is interacting with the field right now".
- if (openOnFocus) {
- setOpen(true);
- }
- };
+ // Without this, clicking an already-focused input (e.g. when the
+ // dialog opened with autoFocus on the input and the user then
+ // clicks it) won't fire `focus` again — and the popover would stay
+ // closed despite a clear user intent. PointerDown is the cleanest
+ // signal of "user is interacting with the field right now".
+ if (openOnFocus) {
+ setOpen(true);
+ }
+ };
- const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
- onKeyDown?.(event);
+ const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
+ onKeyDown?.(event);
- if (event.defaultPrevented) {
- return;
- }
+ if (event.defaultPrevented) {
+ return;
+ }
- if (event.key === 'Escape') {
- setOpen(false);
+ if (event.key === 'Escape') {
+ setOpen(false);
- return;
- }
+ return;
+ }
- if (event.key === 'ArrowDown') {
- // Make the dropdown reachable from the keyboard even when it
- // didn't auto-open on focus. cmdk's own ArrowDown handler will
- // then move the highlight into the list.
- setOpen(true);
+ if (event.key === 'ArrowDown') {
+ // Make the dropdown reachable from the keyboard even when it
+ // didn't auto-open on focus. cmdk's own ArrowDown handler will
+ // then move the highlight into the list.
+ setOpen(true);
- return;
- }
+ return;
+ }
- if (event.key === 'Enter' && !hasActiveMatch) {
- // Stop cmdk from also handling Enter (which would no-op here
- // but keeps the popover open).
- event.preventDefault();
- event.stopPropagation();
- commit(inputValue);
- }
- };
+ if (event.key === 'Enter' && !hasActiveMatch) {
+ // Stop cmdk from also handling Enter (which would no-op here
+ // but keeps the popover open).
+ event.preventDefault();
+ event.stopPropagation();
+ commit(inputValue);
+ }
+ };
- const handleValueChange = (next: string) => {
- setInputValue(next);
- // Re-open on typing — handles the case where the user closed the
- // popover with Escape but then resumes editing, and is the main
- // entry point now that focus alone no longer auto-opens on mount.
- setOpen(true);
- };
+ const handleValueChange = (next: string) => {
+ setInputValue(next);
+ // Re-open on typing — handles the case where the user closed the
+ // popover with Escape but then resumes editing, and is the main
+ // entry point now that focus alone no longer auto-opens on mount.
+ setOpen(true);
+ };
- return (
- <PopoverAnchor asChild>
+ return (
+ <PopoverAnchor asChild>
+ {/*
+ * `asChild` delegates the DOM input (and shadcn styling) to the
+ * project's `Input` while cmdk keeps value sync, ARIA combobox
+ * attributes and `cmdk-input=""`. cmdk also hard-codes
+ * `autoComplete/autoCorrect="off"` and `spellCheck={false}` —
+ * don't repeat them.
+ */}
+ <CommandPrimitive.Input
+ asChild
+ onValueChange={handleValueChange}
+ value={inputValue}
+ >
{/*
- * `asChild` delegates the DOM input (and shadcn styling) to the
- * project's `Input` while cmdk keeps value sync, ARIA combobox
- * attributes and `cmdk-input=""`. cmdk also hard-codes
- * `autoComplete/autoCorrect="off"` and `spellCheck={false}` —
- * don't repeat them.
+ * `aria-expanded` is hard-coded to `true` inside cmdk —
+ * the attribute lies whenever the popover is closed
+ * (after Enter, Escape, outside click). Radix Slot
+ * merges child props on top of slot props for non-handler
+ * attributes, so passing `aria-expanded={open}` here
+ * wins over cmdk's hard-coded value and keeps it in sync
+ * with the real popover state for screen readers.
*/}
- <CommandPrimitive.Input
- asChild
- onValueChange={handleValueChange}
- value={inputValue}
- >
- {/*
- * `aria-expanded` is hard-coded to `true` inside cmdk —
- * the attribute lies whenever the popover is closed
- * (after Enter, Escape, outside click). Radix Slot
- * merges child props on top of slot props for non-handler
- * attributes, so passing `aria-expanded={open}` here
- * wins over cmdk's hard-coded value and keeps it in sync
- * with the real popover state for screen readers.
- */}
- <Input
- aria-expanded={open}
- className={className}
- id={id ?? inputId}
- onFocus={handleFocus}
- onKeyDown={handleKeyDown}
- onPointerDown={handlePointerDown}
- ref={setInputRef}
- {...props}
- />
- </CommandPrimitive.Input>
- </PopoverAnchor>
- );
- },
-);
+ <Input
+ aria-expanded={open}
+ className={className}
+ id={id ?? inputId}
+ onFocus={handleFocus}
+ onKeyDown={handleKeyDown}
+ onPointerDown={handlePointerDown}
+ ref={setInputRef}
+ {...props}
+ />
+ </CommandPrimitive.Input>
+ </PopoverAnchor>
+ );
+};
+
AutocompleteInput.displayName = 'AutocompleteInput';
export type AutocompleteContentProps = React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> & {
@@ -391,174 +398,170 @@ export type AutocompleteContentProps = React.ComponentPropsWithoutRef<typeof Pop
listClassName?: string;
};
-const AutocompleteContent = React.forwardRef<
- React.ElementRef<typeof PopoverPrimitive.Content>,
- AutocompleteContentProps
->(
- (
- {
- align = 'start',
- children,
- className,
- listClassName,
- onFocusOutside,
- onInteractOutside,
- onOpenAutoFocus,
- sideOffset = 4,
- ...props
+const AutocompleteContent = ({
+ align = 'start',
+ children,
+ className,
+ listClassName,
+ onFocusOutside,
+ onInteractOutside,
+ onOpenAutoFocus,
+ ref,
+ sideOffset = 4,
+ ...props
+}: AutocompleteContentProps & { ref?: React.Ref<React.ElementRef<typeof PopoverPrimitive.Content>> }) => {
+ const { inputRef } = useAutocompleteContext();
+ const contentRef = React.useRef<null | React.ElementRef<typeof PopoverPrimitive.Content>>(null);
+ const composedRef = React.useCallback(
+ (node: null | React.ElementRef<typeof PopoverPrimitive.Content>) => {
+ contentRef.current = node;
+
+ if (typeof ref === 'function') {
+ ref(node);
+ } else if (ref) {
+ (ref as React.MutableRefObject<typeof node>).current = node;
+ }
},
- ref,
- ) => {
- const { inputRef } = useAutocompleteContext();
- const contentRef = React.useRef<null | React.ElementRef<typeof PopoverPrimitive.Content>>(null);
- const composedRef = React.useCallback(
- (node: null | React.ElementRef<typeof PopoverPrimitive.Content>) => {
- contentRef.current = node;
-
- if (typeof ref === 'function') {
- ref(node);
- } else if (ref) {
- (ref as React.MutableRefObject<typeof node>).current = node;
+ [ref],
+ );
+
+ return (
+ /*
+ * Render inline — NO `PopoverPrimitive.Portal`. When the autocomplete
+ * lives inside a Radix `Dialog`, the dialog locks scroll on `body`
+ * (`body { pointer-events: none }` + a wheel/touch interceptor on
+ * the document). A portal'd popover ends up on `body`, outside the
+ * dialog DOM, and inherits the lock — wheel events on the suggestion
+ * list never fire and the user can't scroll. Rendering inline keeps
+ * the popover inside the dialog content, where the scroll lock
+ * doesn't apply, while Radix Popper still positions it correctly
+ * relative to the anchor (the visible input).
+ *
+ * Styles are copied verbatim from `components/ui/popover.tsx` so
+ * appearance and animations stay consistent with shadcn defaults.
+ */
+ <PopoverPrimitive.Content
+ align={align}
+ className={cn(
+ 'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 origin-(--radix-popover-content-transform-origin) rounded-md border shadow-md outline-hidden',
+ // Width matches the input (anchor); max-h keeps the popover
+ // inside the viewport when the suggestion list is large.
+ 'max-h-(--radix-popover-content-available-height) w-(--radix-popover-trigger-width) min-w-(--radix-popover-trigger-width) overflow-hidden p-0',
+ className,
+ )}
+ onFocusOutside={(event) => {
+ onFocusOutside?.(event);
+
+ if (event.defaultPrevented) {
+ return;
}
- },
- [ref],
- );
-
- return (
- /*
- * Render inline — NO `PopoverPrimitive.Portal`. When the autocomplete
- * lives inside a Radix `Dialog`, the dialog locks scroll on `body`
- * (`body { pointer-events: none }` + a wheel/touch interceptor on
- * the document). A portal'd popover ends up on `body`, outside the
- * dialog DOM, and inherits the lock — wheel events on the suggestion
- * list never fire and the user can't scroll. Rendering inline keeps
- * the popover inside the dialog content, where the scroll lock
- * doesn't apply, while Radix Popper still positions it correctly
- * relative to the anchor (the visible input).
- *
- * Styles are copied verbatim from `components/ui/popover.tsx` so
- * appearance and animations stay consistent with shadcn defaults.
- */
- <PopoverPrimitive.Content
- align={align}
- className={cn(
- 'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 origin-(--radix-popover-content-transform-origin) rounded-md border shadow-md outline-hidden',
- // Width matches the input (anchor); max-h keeps the popover
- // inside the viewport when the suggestion list is large.
- 'max-h-(--radix-popover-content-available-height) w-(--radix-popover-trigger-width) min-w-(--radix-popover-trigger-width) overflow-hidden p-0',
- className,
- )}
- onFocusOutside={(event) => {
- onFocusOutside?.(event);
-
- if (event.defaultPrevented) {
- return;
- }
- // Radix `DismissableLayer` treats the anchor input as
- // "outside" (it isn't a Trigger), and its React-tree flag
- // races on Content's own focusin when our `CommandList`
- // synchronously bounces focus back to the input — both
- // produce spurious `focusOutside` events that would
- // dismiss the popover. Treat focus on the anchor input
- // or anywhere inside Content as "inside".
- //
- // Radix dispatches this event directly on the focused
- // element (`bubbles: false`), so `event.target` IS it.
- const focusTarget = event.target as Node | null;
- const focusInsideInput = !!(focusTarget && inputRef.current?.contains(focusTarget));
- const focusInsideContent = !!(focusTarget && contentRef.current?.contains(focusTarget));
-
- if (focusInsideInput || focusInsideContent) {
- event.preventDefault();
- }
- }}
- onInteractOutside={(event) => {
- onInteractOutside?.(event);
+ // Radix `DismissableLayer` treats the anchor input as
+ // "outside" (it isn't a Trigger), and its React-tree flag
+ // races on Content's own focusin when our `CommandList`
+ // synchronously bounces focus back to the input — both
+ // produce spurious `focusOutside` events that would
+ // dismiss the popover. Treat focus on the anchor input
+ // or anywhere inside Content as "inside".
+ //
+ // Radix dispatches this event directly on the focused
+ // element (`bubbles: false`), so `event.target` IS it.
+ const focusTarget = event.target as Node | null;
+ const focusInsideInput = !!(focusTarget && inputRef.current?.contains(focusTarget));
+ const focusInsideContent = !!(focusTarget && contentRef.current?.contains(focusTarget));
+
+ if (focusInsideInput || focusInsideContent) {
+ event.preventDefault();
+ }
+ }}
+ onInteractOutside={(event) => {
+ onInteractOutside?.(event);
- if (event.defaultPrevented) {
- return;
- }
+ if (event.defaultPrevented) {
+ return;
+ }
- // Clicking the input itself shouldn't dismiss the popover —
- // Radix treats the anchor as "outside" since it isn't a
- // Trigger. The real pointer target is the focused
- // element via `event.target` (custom event is
- // dispatched on the target, `bubbles: false`).
- const interactTarget = event.target as Node | null;
+ // Clicking the input itself shouldn't dismiss the popover —
+ // Radix treats the anchor as "outside" since it isn't a
+ // Trigger. The real pointer target is the focused
+ // element via `event.target` (custom event is
+ // dispatched on the target, `bubbles: false`).
+ const interactTarget = event.target as Node | null;
- if (interactTarget && inputRef.current?.contains(interactTarget)) {
- event.preventDefault();
- }
- }}
- onOpenAutoFocus={(event) => {
- onOpenAutoFocus?.(event);
+ if (interactTarget && inputRef.current?.contains(interactTarget)) {
+ event.preventDefault();
+ }
+ }}
+ onOpenAutoFocus={(event) => {
+ onOpenAutoFocus?.(event);
- if (event.defaultPrevented) {
- return;
- }
+ if (event.defaultPrevented) {
+ return;
+ }
- // Keep focus on the input so typing keeps working immediately.
- event.preventDefault();
+ // Keep focus on the input so typing keeps working immediately.
+ event.preventDefault();
+ }}
+ ref={composedRef}
+ sideOffset={sideOffset}
+ {...props}
+ >
+ {/*
+ * Explicit max-height + scroll on the cmdk list. shadcn's
+ * `CommandList` defaults to `max-h-[300px] overflow-y-auto`, but
+ * re-applying it here lets consumers override the cap via
+ * `listClassName` without losing scroll behaviour, and pins the
+ * list so a long suggestion set scrolls inside the popover
+ * instead of pushing the popover past the viewport.
+ */}
+ <CommandList
+ className={cn('max-h-[280px] overflow-x-hidden overflow-y-auto', listClassName)}
+ onFocus={(event) => {
+ // cmdk re-focuses the input by id when its value
+ // changes (`document.getElementById(inputId).focus()`),
+ // falling back to the list when the lookup fails — and
+ // it fails as soon as a wrapper like `FormControl`
+ // overrides the input's id via Radix Slot. The listbox
+ // then steals focus and typing breaks. Per the
+ // aria-activedescendant pattern the listbox shouldn't
+ // hold real focus (tabindex=-1), so bounce it back.
+ // `target === currentTarget` skips legitimate child focus.
+ if (event.target === event.currentTarget) {
+ inputRef.current?.focus();
+ }
}}
- ref={composedRef}
- sideOffset={sideOffset}
- {...props}
>
- {/*
- * Explicit max-height + scroll on the cmdk list. shadcn's
- * `CommandList` defaults to `max-h-[300px] overflow-y-auto`, but
- * re-applying it here lets consumers override the cap via
- * `listClassName` without losing scroll behaviour, and pins the
- * list so a long suggestion set scrolls inside the popover
- * instead of pushing the popover past the viewport.
- */}
- <CommandList
- className={cn('max-h-[280px] overflow-x-hidden overflow-y-auto', listClassName)}
- onFocus={(event) => {
- // cmdk re-focuses the input by id when its value
- // changes (`document.getElementById(inputId).focus()`),
- // falling back to the list when the lookup fails — and
- // it fails as soon as a wrapper like `FormControl`
- // overrides the input's id via Radix Slot. The listbox
- // then steals focus and typing breaks. Per the
- // aria-activedescendant pattern the listbox shouldn't
- // hold real focus (tabindex=-1), so bounce it back.
- // `target === currentTarget` skips legitimate child focus.
- if (event.target === event.currentTarget) {
- inputRef.current?.focus();
- }
- }}
- >
- {children}
- </CommandList>
- </PopoverPrimitive.Content>
- );
- },
-);
+ {children}
+ </CommandList>
+ </PopoverPrimitive.Content>
+ );
+};
+
AutocompleteContent.displayName = 'AutocompleteContent';
export type AutocompleteEmptyProps = React.ComponentPropsWithoutRef<typeof CommandEmpty>;
-const AutocompleteEmpty = React.forwardRef<React.ElementRef<typeof CommandEmpty>, AutocompleteEmptyProps>(
- (props, ref) => (
- <CommandEmpty
- ref={ref}
- {...props}
- />
- ),
+const AutocompleteEmpty = ({
+ ref,
+ ...props
+}: AutocompleteEmptyProps & { ref?: React.Ref<React.ElementRef<typeof CommandEmpty>> }) => (
+ <CommandEmpty
+ ref={ref}
+ {...props}
+ />
);
AutocompleteEmpty.displayName = 'AutocompleteEmpty';
export type AutocompleteGroupProps = React.ComponentPropsWithoutRef<typeof CommandGroup>;
-const AutocompleteGroup = React.forwardRef<React.ElementRef<typeof CommandGroup>, AutocompleteGroupProps>(
- (props, ref) => (
- <CommandGroup
- ref={ref}
- {...props}
- />
- ),
+const AutocompleteGroup = ({
+ ref,
+ ...props
+}: AutocompleteGroupProps & { ref?: React.Ref<React.ElementRef<typeof CommandGroup>> }) => (
+ <CommandGroup
+ ref={ref}
+ {...props}
+ />
);
AutocompleteGroup.displayName = 'AutocompleteGroup';
@@ -577,39 +580,44 @@ export type AutocompleteItemProps = Omit<React.ComponentPropsWithoutRef<typeof C
value: string;
};
-const AutocompleteItem = React.forwardRef<React.ElementRef<typeof CommandItem>, AutocompleteItemProps>(
- ({ onSelect, value, ...props }, ref) => {
- const { commit } = useAutocompleteContext();
+const AutocompleteItem = ({
+ onSelect,
+ ref,
+ value,
+ ...props
+}: AutocompleteItemProps & { ref?: React.Ref<React.ElementRef<typeof CommandItem>> }) => {
+ const { commit } = useAutocompleteContext();
- return (
- <CommandItem
- onSelect={(selected) => {
- if (onSelect) {
- onSelect(selected);
+ return (
+ <CommandItem
+ onSelect={(selected) => {
+ if (onSelect) {
+ onSelect(selected);
- return;
- }
+ return;
+ }
+
+ commit(selected);
+ }}
+ ref={ref}
+ value={value}
+ {...props}
+ />
+ );
+};
- commit(selected);
- }}
- ref={ref}
- value={value}
- {...props}
- />
- );
- },
-);
AutocompleteItem.displayName = 'AutocompleteItem';
export type AutocompleteSeparatorProps = React.ComponentPropsWithoutRef<typeof CommandSeparator>;
-const AutocompleteSeparator = React.forwardRef<React.ElementRef<typeof CommandSeparator>, AutocompleteSeparatorProps>(
- (props, ref) => (
- <CommandSeparator
- ref={ref}
- {...props}
- />
- ),
+const AutocompleteSeparator = ({
+ ref,
+ ...props
+}: AutocompleteSeparatorProps & { ref?: React.Ref<React.ElementRef<typeof CommandSeparator>> }) => (
+ <CommandSeparator
+ ref={ref}
+ {...props}
+ />
);
AutocompleteSeparator.displayName = 'AutocompleteSeparator';
diff --git a/frontend/src/components/ui/avatar.tsx b/frontend/src/components/ui/avatar.tsx
index 75c78a7c..02c016c0 100644
--- a/frontend/src/components/ui/avatar.tsx
+++ b/frontend/src/components/ui/avatar.tsx
@@ -3,40 +3,49 @@ 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) => (
+const Avatar = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> & {
+ ref?: React.Ref<React.ElementRef<typeof AvatarPrimitive.Root>>;
+}) => (
<AvatarPrimitive.Root
className={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', className)}
ref={ref}
{...props}
/>
-));
+);
Avatar.displayName = AvatarPrimitive.Root.displayName;
-const AvatarImage = React.forwardRef<
- React.ElementRef<typeof AvatarPrimitive.Image>,
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
->(({ className, ...props }, ref) => (
+const AvatarImage = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> & {
+ ref?: React.Ref<React.ElementRef<typeof AvatarPrimitive.Image>>;
+}) => (
<AvatarPrimitive.Image
className={cn('aspect-square h-full w-full', className)}
ref={ref}
{...props}
/>
-));
+);
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
-const AvatarFallback = React.forwardRef<
- React.ElementRef<typeof AvatarPrimitive.Fallback>,
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
->(({ className, ...props }, ref) => (
+const AvatarFallback = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> & {
+ ref?: React.Ref<React.ElementRef<typeof AvatarPrimitive.Fallback>>;
+}) => (
<AvatarPrimitive.Fallback
className={cn('bg-muted flex h-full w-full items-center justify-center rounded-full', className)}
ref={ref}
{...props}
/>
-));
+);
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
export { Avatar, AvatarFallback, AvatarImage };
diff --git a/frontend/src/components/ui/breadcrumb.tsx b/frontend/src/components/ui/breadcrumb.tsx
index 92385257..5526aab8 100644
--- a/frontend/src/components/ui/breadcrumb.tsx
+++ b/frontend/src/components/ui/breadcrumb.tsx
@@ -4,51 +4,59 @@ import * as React from 'react';
import { cn } from '@/lib/utils';
-const Breadcrumb = React.forwardRef<
- HTMLElement,
- React.ComponentPropsWithoutRef<'nav'> & {
- separator?: React.ReactNode;
- }
->(({ ...props }, ref) => (
+const Breadcrumb = ({
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<'nav'> & {
+ ref?: React.Ref<HTMLElement>;
+ separator?: React.ReactNode;
+}) => (
<nav
aria-label="breadcrumb"
ref={ref}
{...props}
/>
-));
+);
Breadcrumb.displayName = 'Breadcrumb';
-const BreadcrumbList = React.forwardRef<HTMLOListElement, React.ComponentPropsWithoutRef<'ol'>>(
- ({ className, ...props }, ref) => (
- <ol
- className={cn(
- 'text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm wrap-break-word sm:gap-2.5',
- className,
- )}
- ref={ref}
- {...props}
- />
- ),
+const BreadcrumbList = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<'ol'> & { ref?: React.Ref<HTMLOListElement> }) => (
+ <ol
+ className={cn(
+ 'text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm wrap-break-word sm:gap-2.5',
+ className,
+ )}
+ ref={ref}
+ {...props}
+ />
);
BreadcrumbList.displayName = 'BreadcrumbList';
-const BreadcrumbItem = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<'li'>>(
- ({ className, ...props }, ref) => (
- <li
- className={cn('inline-flex items-center gap-1.5', className)}
- ref={ref}
- {...props}
- />
- ),
+const BreadcrumbItem = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<'li'> & { ref?: React.Ref<HTMLLIElement> }) => (
+ <li
+ className={cn('inline-flex items-center gap-1.5', className)}
+ ref={ref}
+ {...props}
+ />
);
BreadcrumbItem.displayName = 'BreadcrumbItem';
-const BreadcrumbLink = React.forwardRef<
- HTMLAnchorElement,
- React.ComponentPropsWithoutRef<'a'> & {
- asChild?: boolean;
- }
->(({ asChild, className, ...props }, ref) => {
+const BreadcrumbLink = ({
+ asChild,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<'a'> & {
+ asChild?: boolean;
+ ref?: React.Ref<HTMLAnchorElement>;
+}) => {
const Comp = asChild ? Slot : 'a';
return (
@@ -58,20 +66,23 @@ const BreadcrumbLink = React.forwardRef<
{...props}
/>
);
-});
+};
+
BreadcrumbLink.displayName = 'BreadcrumbLink';
-const BreadcrumbPage = React.forwardRef<HTMLSpanElement, React.ComponentPropsWithoutRef<'span'>>(
- ({ className, ...props }, ref) => (
- <span
- aria-current="page"
- aria-disabled="true"
- className={cn('text-foreground font-normal', className)}
- ref={ref}
- role="link"
- {...props}
- />
- ),
+const BreadcrumbPage = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<'span'> & { ref?: React.Ref<HTMLSpanElement> }) => (
+ <span
+ aria-current="page"
+ aria-disabled="true"
+ className={cn('text-foreground font-normal', className)}
+ ref={ref}
+ role="link"
+ {...props}
+ />
);
BreadcrumbPage.displayName = 'BreadcrumbPage';
diff --git a/frontend/src/components/ui/button.tsx b/frontend/src/components/ui/button.tsx
index ad3d8301..ae6454f9 100644
--- a/frontend/src/components/ui/button.tsx
+++ b/frontend/src/components/ui/button.tsx
@@ -39,19 +39,25 @@ export interface ButtonProps
asChild?: boolean;
}
-const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
- ({ asChild = false, className, size, variant, ...props }, ref) => {
- const Comp = asChild ? Slot : 'button';
+const Button = ({
+ asChild = false,
+ className,
+ ref,
+ size,
+ variant,
+ ...props
+}: ButtonProps & { ref?: React.Ref<HTMLButtonElement> }) => {
+ const Comp = asChild ? Slot : 'button';
+
+ return (
+ <Comp
+ className={cn(buttonVariants({ className, size, variant }))}
+ ref={ref}
+ {...props}
+ />
+ );
+};
- return (
- <Comp
- className={cn(buttonVariants({ className, size, variant }))}
- ref={ref}
- {...props}
- />
- );
- },
-);
Button.displayName = 'Button';
export { Button, buttonVariants };
diff --git a/frontend/src/components/ui/card.tsx b/frontend/src/components/ui/card.tsx
index b027536d..4139e068 100644
--- a/frontend/src/components/ui/card.tsx
+++ b/frontend/src/components/ui/card.tsx
@@ -2,67 +2,81 @@ import * as React from 'react';
import { cn } from '@/lib/utils';
-const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
+const Card = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }) => (
<div
className={cn('bg-card text-card-foreground rounded-xl border shadow-sm', className)}
ref={ref}
{...props}
/>
-));
+);
Card.displayName = 'Card';
-const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
- ({ className, ...props }, ref) => (
- <div
- className={cn('flex flex-col gap-1.5 p-4', className)}
- ref={ref}
- {...props}
- />
- ),
+const CardHeader = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }) => (
+ <div
+ className={cn('flex flex-col gap-1.5 p-4', className)}
+ ref={ref}
+ {...props}
+ />
);
CardHeader.displayName = 'CardHeader';
-const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
- ({ className, ...props }, ref) => (
- <h3
- className={cn('leading-none font-semibold tracking-tight', className)}
- ref={ref}
- {...props}
- />
- ),
+const CardTitle = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLHeadingElement> & { ref?: React.Ref<HTMLParagraphElement> }) => (
+ <h3
+ className={cn('leading-none font-semibold tracking-tight', className)}
+ ref={ref}
+ {...props}
+ />
);
CardTitle.displayName = 'CardTitle';
-const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
- ({ className, ...props }, ref) => (
- <p
- className={cn('text-muted-foreground text-sm', className)}
- ref={ref}
- {...props}
- />
- ),
+const CardDescription = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLParagraphElement> & { ref?: React.Ref<HTMLParagraphElement> }) => (
+ <p
+ className={cn('text-muted-foreground text-sm', className)}
+ ref={ref}
+ {...props}
+ />
);
CardDescription.displayName = 'CardDescription';
-const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
- ({ className, ...props }, ref) => (
- <div
- className={cn('p-4 pt-0', className)}
- ref={ref}
- {...props}
- />
- ),
+const CardContent = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }) => (
+ <div
+ className={cn('p-4 pt-0', className)}
+ ref={ref}
+ {...props}
+ />
);
CardContent.displayName = 'CardContent';
-const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
- ({ className, ...props }, ref) => (
- <div
- className={cn('flex items-center p-4 pt-0', className)}
- ref={ref}
- {...props}
- />
- ),
+const CardFooter = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }) => (
+ <div
+ className={cn('flex items-center p-4 pt-0', className)}
+ ref={ref}
+ {...props}
+ />
);
CardFooter.displayName = 'CardFooter';
diff --git a/frontend/src/components/ui/checkbox.tsx b/frontend/src/components/ui/checkbox.tsx
index c26e2ba2..13457b5c 100644
--- a/frontend/src/components/ui/checkbox.tsx
+++ b/frontend/src/components/ui/checkbox.tsx
@@ -4,10 +4,13 @@ import * as React from 'react';
import { cn } from '@/lib/utils';
-const Checkbox = React.forwardRef<
- React.ElementRef<typeof CheckboxPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
->(({ className, ...props }, ref) => (
+const Checkbox = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> & {
+ ref?: React.Ref<React.ElementRef<typeof CheckboxPrimitive.Root>>;
+}) => (
<CheckboxPrimitive.Root
className={cn(
'peer border-primary focus-visible:ring-ring data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground grid h-4 w-4 shrink-0 place-content-center rounded-sm border shadow focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50',
@@ -20,7 +23,7 @@ const Checkbox = React.forwardRef<
<Check className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
-));
+);
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
export { Checkbox };
diff --git a/frontend/src/components/ui/command.tsx b/frontend/src/components/ui/command.tsx
index de759d2e..eeef6879 100644
--- a/frontend/src/components/ui/command.tsx
+++ b/frontend/src/components/ui/command.tsx
@@ -6,10 +6,13 @@ 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) => (
+const Command = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof CommandPrimitive> & {
+ ref?: React.Ref<React.ElementRef<typeof CommandPrimitive>>;
+}) => (
<CommandPrimitive
className={cn(
'bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md',
@@ -18,7 +21,7 @@ const Command = React.forwardRef<
ref={ref}
{...props}
/>
-));
+);
Command.displayName = CommandPrimitive.displayName;
const CommandDialog = ({ children, ...props }: DialogProps) => {
@@ -33,10 +36,13 @@ const CommandDialog = ({ children, ...props }: DialogProps) => {
);
};
-const CommandInput = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Input>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
->(({ className, ...props }, ref) => (
+const CommandInput = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input> & {
+ ref?: React.Ref<React.ElementRef<typeof CommandPrimitive.Input>>;
+}) => (
<div className="flex items-center border-b px-3">
<MagnifyingGlassIcon className="mr-2 h-4 w-4 shrink-0 opacity-50" />
<CommandPrimitive.Input
@@ -48,40 +54,48 @@ const CommandInput = React.forwardRef<
{...props}
/>
</div>
-));
+);
CommandInput.displayName = CommandPrimitive.Input.displayName;
-const CommandList = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.List>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
->(({ className, ...props }, ref) => (
+const CommandList = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof CommandPrimitive.List> & {
+ ref?: React.Ref<React.ElementRef<typeof CommandPrimitive.List>>;
+}) => (
<CommandPrimitive.List
className={cn('max-h-[300px] overflow-x-hidden overflow-y-auto', className)}
ref={ref}
{...props}
/>
-));
+);
CommandList.displayName = CommandPrimitive.List.displayName;
-const CommandEmpty = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Empty>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
->((props, ref) => (
+const CommandEmpty = ({
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty> & {
+ ref?: React.Ref<React.ElementRef<typeof CommandPrimitive.Empty>>;
+}) => (
<CommandPrimitive.Empty
className="text-muted-foreground/50 py-6 text-center text-sm"
ref={ref}
{...props}
/>
-));
+);
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
-const CommandGroup = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Group>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
->(({ className, ...props }, ref) => (
+const CommandGroup = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group> & {
+ ref?: React.Ref<React.ElementRef<typeof CommandPrimitive.Group>>;
+}) => (
<CommandPrimitive.Group
className={cn(
'text-foreground **:[[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium',
@@ -90,26 +104,32 @@ const CommandGroup = React.forwardRef<
ref={ref}
{...props}
/>
-));
+);
CommandGroup.displayName = CommandPrimitive.Group.displayName;
-const CommandSeparator = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Separator>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
->(({ className, ...props }, ref) => (
+const CommandSeparator = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator> & {
+ ref?: React.Ref<React.ElementRef<typeof CommandPrimitive.Separator>>;
+}) => (
<CommandPrimitive.Separator
className={cn('bg-border -mx-1 h-px', className)}
ref={ref}
{...props}
/>
-));
+);
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
-const CommandItem = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Item>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
->(({ className, ...props }, ref) => (
+const CommandItem = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item> & {
+ ref?: React.Ref<React.ElementRef<typeof CommandPrimitive.Item>>;
+}) => (
<CommandPrimitive.Item
className={cn(
'data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
@@ -118,7 +138,7 @@ const CommandItem = React.forwardRef<
ref={ref}
{...props}
/>
-));
+);
CommandItem.displayName = CommandPrimitive.Item.displayName;
diff --git a/frontend/src/components/ui/context-menu.tsx b/frontend/src/components/ui/context-menu.tsx
index 648596ed..6a1ef40e 100644
--- a/frontend/src/components/ui/context-menu.tsx
+++ b/frontend/src/components/ui/context-menu.tsx
@@ -16,12 +16,16 @@ const ContextMenuSub = ContextMenuPrimitive.Sub;
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
-const ContextMenuSubTrigger = React.forwardRef<
- React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
- inset?: boolean;
- }
->(({ children, className, inset, ...props }, ref) => (
+const ContextMenuSubTrigger = ({
+ children,
+ className,
+ inset,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
+ inset?: boolean;
+ ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>>;
+}) => (
<ContextMenuPrimitive.SubTrigger
className={cn(
'focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none',
@@ -34,13 +38,16 @@ const ContextMenuSubTrigger = React.forwardRef<
{children}
<ChevronRight className="ml-auto h-4 w-4" />
</ContextMenuPrimitive.SubTrigger>
-));
+);
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
-const ContextMenuSubContent = React.forwardRef<
- React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
->(({ className, ...props }, ref) => (
+const ContextMenuSubContent = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent> & {
+ ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.SubContent>>;
+}) => (
<ContextMenuPrimitive.SubContent
className={cn(
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-[--radix-context-menu-content-transform-origin] overflow-hidden rounded-md border p-1 shadow-lg',
@@ -49,13 +56,16 @@ const ContextMenuSubContent = React.forwardRef<
ref={ref}
{...props}
/>
-));
+);
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
-const ContextMenuContent = React.forwardRef<
- React.ElementRef<typeof ContextMenuPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
->(({ className, ...props }, ref) => (
+const ContextMenuContent = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content> & {
+ ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.Content>>;
+}) => (
<ContextMenuPrimitive.Portal>
<ContextMenuPrimitive.Content
className={cn(
@@ -66,15 +76,18 @@ const ContextMenuContent = React.forwardRef<
{...props}
/>
</ContextMenuPrimitive.Portal>
-));
+);
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
-const ContextMenuItem = React.forwardRef<
- React.ElementRef<typeof ContextMenuPrimitive.Item>,
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
- inset?: boolean;
- }
->(({ className, inset, ...props }, ref) => (
+const ContextMenuItem = ({
+ className,
+ inset,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
+ inset?: boolean;
+ ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.Item>>;
+}) => (
<ContextMenuPrimitive.Item
className={cn(
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
@@ -84,13 +97,18 @@ const ContextMenuItem = React.forwardRef<
ref={ref}
{...props}
/>
-));
+);
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
-const ContextMenuCheckboxItem = React.forwardRef<
- React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
->(({ checked, children, className, ...props }, ref) => (
+const ContextMenuCheckboxItem = ({
+ checked,
+ children,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem> & {
+ ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>>;
+}) => (
<ContextMenuPrimitive.CheckboxItem
checked={checked}
className={cn(
@@ -107,13 +125,17 @@ const ContextMenuCheckboxItem = React.forwardRef<
</span>
{children}
</ContextMenuPrimitive.CheckboxItem>
-));
+);
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;
-const ContextMenuRadioItem = React.forwardRef<
- React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
->(({ children, className, ...props }, ref) => (
+const ContextMenuRadioItem = ({
+ children,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem> & {
+ ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.RadioItem>>;
+}) => (
<ContextMenuPrimitive.RadioItem
className={cn(
'focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
@@ -129,33 +151,39 @@ const ContextMenuRadioItem = React.forwardRef<
</span>
{children}
</ContextMenuPrimitive.RadioItem>
-));
+);
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
-const ContextMenuLabel = React.forwardRef<
- React.ElementRef<typeof ContextMenuPrimitive.Label>,
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
- inset?: boolean;
- }
->(({ className, inset, ...props }, ref) => (
+const ContextMenuLabel = ({
+ className,
+ inset,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
+ inset?: boolean;
+ ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.Label>>;
+}) => (
<ContextMenuPrimitive.Label
className={cn('text-foreground px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
ref={ref}
{...props}
/>
-));
+);
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
-const ContextMenuSeparator = React.forwardRef<
- React.ElementRef<typeof ContextMenuPrimitive.Separator>,
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
->(({ className, ...props }, ref) => (
+const ContextMenuSeparator = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator> & {
+ ref?: React.Ref<React.ElementRef<typeof ContextMenuPrimitive.Separator>>;
+}) => (
<ContextMenuPrimitive.Separator
className={cn('bg-border -mx-1 my-1 h-px', className)}
ref={ref}
{...props}
/>
-));
+);
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
const ContextMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
diff --git a/frontend/src/components/ui/dialog.tsx b/frontend/src/components/ui/dialog.tsx
index 4967d4e4..71096c0f 100644
--- a/frontend/src/components/ui/dialog.tsx
+++ b/frontend/src/components/ui/dialog.tsx
@@ -12,10 +12,13 @@ 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) => (
+const DialogOverlay = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> & {
+ ref?: React.Ref<React.ElementRef<typeof DialogPrimitive.Overlay>>;
+}) => (
<DialogPrimitive.Overlay
className={cn(
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 bg-background/80 fixed inset-0 z-50 backdrop-blur-xs',
@@ -24,13 +27,17 @@ const DialogOverlay = React.forwardRef<
ref={ref}
{...props}
/>
-));
+);
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
-const DialogContent = React.forwardRef<
- React.ElementRef<typeof DialogPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
->(({ children, className, ...props }, ref) => (
+const DialogContent = ({
+ children,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
+ ref?: React.Ref<React.ElementRef<typeof DialogPrimitive.Content>>;
+}) => (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
@@ -48,7 +55,7 @@ const DialogContent = React.forwardRef<
</DialogPrimitive.Close>
</DialogPrimitive.Content>
</DialogPortal>
-));
+);
DialogContent.displayName = DialogPrimitive.Content.displayName;
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
@@ -67,28 +74,34 @@ const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivEleme
);
DialogFooter.displayName = 'DialogFooter';
-const DialogTitle = React.forwardRef<
- React.ElementRef<typeof DialogPrimitive.Title>,
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
->(({ className, ...props }, ref) => (
+const DialogTitle = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> & {
+ ref?: React.Ref<React.ElementRef<typeof DialogPrimitive.Title>>;
+}) => (
<DialogPrimitive.Title
className={cn('text-lg leading-none font-semibold tracking-tight', className)}
ref={ref}
{...props}
/>
-));
+);
DialogTitle.displayName = DialogPrimitive.Title.displayName;
-const DialogDescription = React.forwardRef<
- React.ElementRef<typeof DialogPrimitive.Description>,
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
->(({ className, ...props }, ref) => (
+const DialogDescription = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> & {
+ ref?: React.Ref<React.ElementRef<typeof DialogPrimitive.Description>>;
+}) => (
<DialogPrimitive.Description
className={cn('text-muted-foreground text-sm', className)}
ref={ref}
{...props}
/>
-));
+);
DialogDescription.displayName = DialogPrimitive.Description.displayName;
export {
diff --git a/frontend/src/components/ui/drawer.tsx b/frontend/src/components/ui/drawer.tsx
index 32736e93..9f943dcb 100644
--- a/frontend/src/components/ui/drawer.tsx
+++ b/frontend/src/components/ui/drawer.tsx
@@ -17,22 +17,29 @@ const DrawerPortal = DrawerPrimitive.Portal;
const DrawerClose = DrawerPrimitive.Close;
-const DrawerOverlay = React.forwardRef<
- React.ElementRef<typeof DrawerPrimitive.Overlay>,
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
->(({ className, ...props }, ref) => (
+const DrawerOverlay = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay> & {
+ ref?: React.Ref<React.ElementRef<typeof DrawerPrimitive.Overlay>>;
+}) => (
<DrawerPrimitive.Overlay
className={cn('fixed inset-0 z-50 bg-black/80', className)}
ref={ref}
{...props}
/>
-));
+);
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
-const DrawerContent = React.forwardRef<
- React.ElementRef<typeof DrawerPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
->(({ children, className, ...props }, ref) => (
+const DrawerContent = ({
+ children,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content> & {
+ ref?: React.Ref<React.ElementRef<typeof DrawerPrimitive.Content>>;
+}) => (
<DrawerPortal>
<DrawerOverlay />
<DrawerPrimitive.Content
@@ -47,7 +54,7 @@ const DrawerContent = React.forwardRef<
{children}
</DrawerPrimitive.Content>
</DrawerPortal>
-));
+);
DrawerContent.displayName = 'DrawerContent';
const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
@@ -66,28 +73,34 @@ const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivEleme
);
DrawerFooter.displayName = 'DrawerFooter';
-const DrawerTitle = React.forwardRef<
- React.ElementRef<typeof DrawerPrimitive.Title>,
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
->(({ className, ...props }, ref) => (
+const DrawerTitle = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title> & {
+ ref?: React.Ref<React.ElementRef<typeof DrawerPrimitive.Title>>;
+}) => (
<DrawerPrimitive.Title
className={cn('text-lg leading-none font-semibold tracking-tight', className)}
ref={ref}
{...props}
/>
-));
+);
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
-const DrawerDescription = React.forwardRef<
- React.ElementRef<typeof DrawerPrimitive.Description>,
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
->(({ className, ...props }, ref) => (
+const DrawerDescription = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description> & {
+ ref?: React.Ref<React.ElementRef<typeof DrawerPrimitive.Description>>;
+}) => (
<DrawerPrimitive.Description
className={cn('text-muted-foreground text-sm', className)}
ref={ref}
{...props}
/>
-));
+);
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
export {
diff --git a/frontend/src/components/ui/dropdown-menu.tsx b/frontend/src/components/ui/dropdown-menu.tsx
index 1cb15689..4556c7b4 100644
--- a/frontend/src/components/ui/dropdown-menu.tsx
+++ b/frontend/src/components/ui/dropdown-menu.tsx
@@ -16,12 +16,16 @@ const DropdownMenuSub = DropdownMenuPrimitive.Sub;
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
-const DropdownMenuSubTrigger = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
- inset?: boolean;
- }
->(({ children, className, inset, ...props }, ref) => (
+const DropdownMenuSubTrigger = ({
+ children,
+ className,
+ inset,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
+ inset?: boolean;
+ ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>>;
+}) => (
<DropdownMenuPrimitive.SubTrigger
className={cn(
'focus:bg-accent data-[state=open]:bg-accent flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
@@ -34,13 +38,16 @@ const DropdownMenuSubTrigger = React.forwardRef<
{children}
<ChevronRightIcon className="ml-auto" />
</DropdownMenuPrimitive.SubTrigger>
-));
+);
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
-const DropdownMenuSubContent = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
->(({ className, ...props }, ref) => (
+const DropdownMenuSubContent = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent> & {
+ ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.SubContent>>;
+}) => (
<DropdownMenuPrimitive.SubContent
className={cn(
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-32 overflow-hidden rounded-md border p-1 shadow-lg',
@@ -49,13 +56,17 @@ const DropdownMenuSubContent = React.forwardRef<
ref={ref}
{...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) => (
+const DropdownMenuContent = ({
+ className,
+ ref,
+ sideOffset = 4,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> & {
+ ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.Content>>;
+}) => (
<DropdownMenuPrimitive.Portal>
<DropdownMenuPrimitive.Content
className={cn(
@@ -68,15 +79,18 @@ const DropdownMenuContent = React.forwardRef<
{...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) => (
+const DropdownMenuItem = ({
+ className,
+ inset,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
+ inset?: boolean;
+ ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.Item>>;
+}) => (
<DropdownMenuPrimitive.Item
className={cn(
'focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0',
@@ -86,13 +100,18 @@ const DropdownMenuItem = React.forwardRef<
ref={ref}
{...props}
/>
-));
+);
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
-const DropdownMenuCheckboxItem = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
->(({ checked, children, className, ...props }, ref) => (
+const DropdownMenuCheckboxItem = ({
+ checked,
+ children,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem> & {
+ ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>>;
+}) => (
<DropdownMenuPrimitive.CheckboxItem
checked={checked}
className={cn(
@@ -109,13 +128,17 @@ const DropdownMenuCheckboxItem = React.forwardRef<
</span>
{children}
</DropdownMenuPrimitive.CheckboxItem>
-));
+);
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
-const DropdownMenuRadioItem = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
->(({ children, className, ...props }, ref) => (
+const DropdownMenuRadioItem = ({
+ children,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem> & {
+ ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>>;
+}) => (
<DropdownMenuPrimitive.RadioItem
className={cn(
'focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden transition-colors select-none data-disabled:pointer-events-none data-disabled:opacity-50',
@@ -131,33 +154,39 @@ const DropdownMenuRadioItem = React.forwardRef<
</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) => (
+const DropdownMenuLabel = ({
+ className,
+ inset,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
+ inset?: boolean;
+ ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.Label>>;
+}) => (
<DropdownMenuPrimitive.Label
className={cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
ref={ref}
{...props}
/>
-));
+);
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
-const DropdownMenuSeparator = React.forwardRef<
- React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
->(({ className, ...props }, ref) => (
+const DropdownMenuSeparator = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator> & {
+ ref?: React.Ref<React.ElementRef<typeof DropdownMenuPrimitive.Separator>>;
+}) => (
<DropdownMenuPrimitive.Separator
className={cn('bg-border -mx-1 my-1 h-px', className)}
ref={ref}
{...props}
/>
-));
+);
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
diff --git a/frontend/src/components/ui/form.tsx b/frontend/src/components/ui/form.tsx
index dedfb80f..b628d4e1 100644
--- a/frontend/src/components/ui/form.tsx
+++ b/frontend/src/components/ui/form.tsx
@@ -66,27 +66,33 @@ type FormItemContextValue = {
const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);
-const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
- ({ className, ...props }, ref) => {
- const id = React.useId();
-
- return (
- <FormItemContext.Provider value={{ id }}>
- <div
- className={cn('flex flex-col gap-2', className)}
- ref={ref}
- {...props}
- />
- </FormItemContext.Provider>
- );
- },
-);
+const FormItem = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }) => {
+ const id = React.useId();
+
+ return (
+ <FormItemContext.Provider value={{ id }}>
+ <div
+ className={cn('flex flex-col gap-2', className)}
+ ref={ref}
+ {...props}
+ />
+ </FormItemContext.Provider>
+ );
+};
+
FormItem.displayName = 'FormItem';
-const FormLabel = React.forwardRef<
- React.ElementRef<typeof LabelPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
->(({ className, ...props }, ref) => {
+const FormLabel = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & {
+ ref?: React.Ref<React.ElementRef<typeof LabelPrimitive.Root>>;
+}) => {
const { error, formItemId } = useFormField();
return (
@@ -97,63 +103,75 @@ const FormLabel = React.forwardRef<
{...props}
/>
);
-});
+};
+
FormLabel.displayName = 'FormLabel';
-const FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(
- ({ ...props }, ref) => {
- const { error, formDescriptionId, formItemId, formMessageId } = useFormField();
+const FormControl = ({
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof Slot> & {
+ ref?: React.Ref<React.ElementRef<typeof Slot>>;
+}) => {
+ const { error, formDescriptionId, formItemId, formMessageId } = useFormField();
+
+ return (
+ <Slot
+ aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
+ aria-invalid={!!error}
+ id={formItemId}
+ ref={ref}
+ {...props}
+ />
+ );
+};
- return (
- <Slot
- aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
- aria-invalid={!!error}
- id={formItemId}
- ref={ref}
- {...props}
- />
- );
- },
-);
FormControl.displayName = 'FormControl';
-const FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
- ({ className, ...props }, ref) => {
- const { formDescriptionId } = useFormField();
+const FormDescription = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLParagraphElement> & { ref?: React.Ref<HTMLParagraphElement> }) => {
+ const { formDescriptionId } = useFormField();
+
+ return (
+ <p
+ className={cn('text-muted-foreground text-[0.8rem]', className)}
+ id={formDescriptionId}
+ ref={ref}
+ {...props}
+ />
+ );
+};
- return (
- <p
- className={cn('text-muted-foreground text-[0.8rem]', className)}
- id={formDescriptionId}
- ref={ref}
- {...props}
- />
- );
- },
-);
FormDescription.displayName = 'FormDescription';
-const FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
- ({ children, className, ...props }, ref) => {
- const { error, formMessageId } = useFormField();
- const body = error ? String(error?.message) : children;
+const FormMessage = ({
+ children,
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLParagraphElement> & { ref?: React.Ref<HTMLParagraphElement> }) => {
+ const { error, formMessageId } = useFormField();
+ const body = error ? String(error?.message) : children;
- if (!body) {
- return null;
- }
+ if (!body) {
+ return null;
+ }
+
+ return (
+ <p
+ className={cn('text-destructive text-[0.8rem] font-medium', className)}
+ id={formMessageId}
+ ref={ref}
+ {...props}
+ >
+ {body}
+ </p>
+ );
+};
- return (
- <p
- className={cn('text-destructive text-[0.8rem] font-medium', className)}
- id={formMessageId}
- ref={ref}
- {...props}
- >
- {body}
- </p>
- );
- },
-);
FormMessage.displayName = 'FormMessage';
export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
diff --git a/frontend/src/components/ui/input.tsx b/frontend/src/components/ui/input.tsx
index 1d0357d3..5b383287 100644
--- a/frontend/src/components/ui/input.tsx
+++ b/frontend/src/components/ui/input.tsx
@@ -4,7 +4,7 @@ import { cn } from '@/lib/utils';
export type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
-const Input = React.forwardRef<HTMLInputElement, InputProps>(({ className, type, ...props }, ref) => {
+const Input = ({ className, ref, type, ...props }: InputProps & { ref?: React.Ref<HTMLInputElement> }) => {
return (
<input
className={cn(
@@ -19,7 +19,8 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(({ className, type,
{...props}
/>
);
-});
+};
+
Input.displayName = 'Input';
export { Input };
diff --git a/frontend/src/components/ui/label.tsx b/frontend/src/components/ui/label.tsx
index 49c4a3d0..5e25c374 100644
--- a/frontend/src/components/ui/label.tsx
+++ b/frontend/src/components/ui/label.tsx
@@ -6,16 +6,18 @@ import { cn } from '@/lib/utils';
const labelVariants = cva('text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70');
-const Label = React.forwardRef<
- React.ElementRef<typeof LabelPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
->(({ className, ...props }, ref) => (
+const Label = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
+ VariantProps<typeof labelVariants> & { ref?: React.Ref<React.ElementRef<typeof LabelPrimitive.Root>> }) => (
<LabelPrimitive.Root
className={cn(labelVariants(), className)}
ref={ref}
{...props}
/>
-));
+);
Label.displayName = LabelPrimitive.Root.displayName;
export { Label };
diff --git a/frontend/src/components/ui/popover.tsx b/frontend/src/components/ui/popover.tsx
index b84bf3d1..44260bd5 100644
--- a/frontend/src/components/ui/popover.tsx
+++ b/frontend/src/components/ui/popover.tsx
@@ -9,10 +9,15 @@ const PopoverTrigger = PopoverPrimitive.Trigger;
const PopoverAnchor = PopoverPrimitive.Anchor;
-const PopoverContent = React.forwardRef<
- React.ElementRef<typeof PopoverPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
->(({ align = 'center', className, sideOffset = 4, ...props }, ref) => (
+const PopoverContent = ({
+ align = 'center',
+ className,
+ ref,
+ sideOffset = 4,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> & {
+ ref?: React.Ref<React.ElementRef<typeof PopoverPrimitive.Content>>;
+}) => (
<PopoverPrimitive.Portal>
<PopoverPrimitive.Content
align={align}
@@ -25,7 +30,7 @@ const PopoverContent = React.forwardRef<
{...props}
/>
</PopoverPrimitive.Portal>
-));
+);
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };
diff --git a/frontend/src/components/ui/progress.tsx b/frontend/src/components/ui/progress.tsx
index cc662634..4cc75da5 100644
--- a/frontend/src/components/ui/progress.tsx
+++ b/frontend/src/components/ui/progress.tsx
@@ -3,10 +3,14 @@ import * as React from 'react';
import { cn } from '@/lib/utils';
-const Progress = React.forwardRef<
- React.ElementRef<typeof ProgressPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
->(({ className, value, ...props }, ref) => (
+const Progress = ({
+ className,
+ ref,
+ value,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> & {
+ ref?: React.Ref<React.ElementRef<typeof ProgressPrimitive.Root>>;
+}) => (
<ProgressPrimitive.Root
className={cn('bg-primary/20 relative h-2 w-full overflow-hidden rounded-full', className)}
ref={ref}
@@ -17,7 +21,7 @@ const Progress = React.forwardRef<
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
/>
</ProgressPrimitive.Root>
-));
+);
Progress.displayName = ProgressPrimitive.Root.displayName;
export { Progress };
diff --git a/frontend/src/components/ui/scroll-area.tsx b/frontend/src/components/ui/scroll-area.tsx
index 3f7870a8..52713c52 100644
--- a/frontend/src/components/ui/scroll-area.tsx
+++ b/frontend/src/components/ui/scroll-area.tsx
@@ -3,10 +3,14 @@ import * as React from 'react';
import { cn } from '@/lib/utils';
-const ScrollArea = React.forwardRef<
- React.ElementRef<typeof ScrollAreaPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
->(({ children, className, ...props }, ref) => (
+const ScrollArea = ({
+ children,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & {
+ ref?: React.Ref<React.ElementRef<typeof ScrollAreaPrimitive.Root>>;
+}) => (
<ScrollAreaPrimitive.Root
className={cn('relative overflow-hidden', className)}
ref={ref}
@@ -16,13 +20,17 @@ const ScrollArea = React.forwardRef<
<ScrollBar />
<ScrollAreaPrimitive.Corner />
</ScrollAreaPrimitive.Root>
-));
+);
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
-const ScrollBar = React.forwardRef<
- React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
- React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
->(({ className, orientation = 'vertical', ...props }, ref) => (
+const ScrollBar = ({
+ className,
+ orientation = 'vertical',
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar> & {
+ ref?: React.Ref<React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>>;
+}) => (
<ScrollAreaPrimitive.ScrollAreaScrollbar
className={cn(
'flex touch-none transition-colors select-none',
@@ -36,7 +44,7 @@ const ScrollBar = React.forwardRef<
>
<ScrollAreaPrimitive.ScrollAreaThumb className="bg-border relative flex-1 rounded-full" />
</ScrollAreaPrimitive.ScrollAreaScrollbar>
-));
+);
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
export { ScrollArea, ScrollBar };
diff --git a/frontend/src/components/ui/select.tsx b/frontend/src/components/ui/select.tsx
index e067bb0d..fcdf3a3f 100644
--- a/frontend/src/components/ui/select.tsx
+++ b/frontend/src/components/ui/select.tsx
@@ -10,10 +10,14 @@ const SelectGroup = SelectPrimitive.Group;
const SelectValue = SelectPrimitive.Value;
-const SelectTrigger = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.Trigger>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
->(({ children, className, ...props }, ref) => (
+const SelectTrigger = ({
+ children,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & {
+ ref?: React.Ref<React.ElementRef<typeof SelectPrimitive.Trigger>>;
+}) => (
<SelectPrimitive.Trigger
className={cn(
'border-input ring-offset-background focus:ring-ring data-placeholder:text-muted-foreground flex h-9 w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs focus:ring-1 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',
@@ -27,13 +31,16 @@ const SelectTrigger = React.forwardRef<
<ChevronDownIcon className="h-4 w-4 opacity-50" />
</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) => (
+const SelectScrollUpButton = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton> & {
+ ref?: React.Ref<React.ElementRef<typeof SelectPrimitive.ScrollUpButton>>;
+}) => (
<SelectPrimitive.ScrollUpButton
className={cn('flex cursor-default items-center justify-center py-1', className)}
ref={ref}
@@ -41,13 +48,16 @@ const SelectScrollUpButton = React.forwardRef<
>
<ChevronUpIcon 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) => (
+const SelectScrollDownButton = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton> & {
+ ref?: React.Ref<React.ElementRef<typeof SelectPrimitive.ScrollDownButton>>;
+}) => (
<SelectPrimitive.ScrollDownButton
className={cn('flex cursor-default items-center justify-center py-1', className)}
ref={ref}
@@ -55,13 +65,18 @@ const SelectScrollDownButton = React.forwardRef<
>
<ChevronDownIcon className="h-4 w-4" />
</SelectPrimitive.ScrollDownButton>
-));
+);
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
-const SelectContent = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
->(({ children, className, position = 'popper', ...props }, ref) => (
+const SelectContent = ({
+ children,
+ className,
+ position = 'popper',
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> & {
+ ref?: React.Ref<React.ElementRef<typeof SelectPrimitive.Content>>;
+}) => (
<SelectPrimitive.Portal>
<SelectPrimitive.Content
className={cn(
@@ -87,25 +102,32 @@ const SelectContent = React.forwardRef<
<SelectScrollDownButton />
</SelectPrimitive.Content>
</SelectPrimitive.Portal>
-));
+);
SelectContent.displayName = SelectPrimitive.Content.displayName;
-const SelectLabel = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.Label>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
->(({ className, ...props }, ref) => (
+const SelectLabel = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label> & {
+ ref?: React.Ref<React.ElementRef<typeof SelectPrimitive.Label>>;
+}) => (
<SelectPrimitive.Label
className={cn('px-2 py-1.5 text-sm font-semibold', className)}
ref={ref}
{...props}
/>
-));
+);
SelectLabel.displayName = SelectPrimitive.Label.displayName;
-const SelectItem = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.Item>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
->(({ children, className, ...props }, ref) => (
+const SelectItem = ({
+ children,
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> & {
+ ref?: React.Ref<React.ElementRef<typeof SelectPrimitive.Item>>;
+}) => (
<SelectPrimitive.Item
className={cn(
'focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-default items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50',
@@ -121,19 +143,22 @@ const SelectItem = React.forwardRef<
</span>
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
</SelectPrimitive.Item>
-));
+);
SelectItem.displayName = SelectPrimitive.Item.displayName;
-const SelectSeparator = React.forwardRef<
- React.ElementRef<typeof SelectPrimitive.Separator>,
- React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
->(({ className, ...props }, ref) => (
+const SelectSeparator = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator> & {
+ ref?: React.Ref<React.ElementRef<typeof SelectPrimitive.Separator>>;
+}) => (
<SelectPrimitive.Separator
className={cn('bg-muted -mx-1 my-1 h-px', className)}
ref={ref}
{...props}
/>
-));
+);
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
export {
diff --git a/frontend/src/components/ui/separator.tsx b/frontend/src/components/ui/separator.tsx
index 68c8a0b4..e4b89e63 100644
--- a/frontend/src/components/ui/separator.tsx
+++ b/frontend/src/components/ui/separator.tsx
@@ -3,10 +3,15 @@ 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, decorative = true, orientation = 'horizontal', ...props }, ref) => (
+const Separator = ({
+ className,
+ decorative = true,
+ orientation = 'horizontal',
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root> & {
+ ref?: React.Ref<React.ElementRef<typeof SeparatorPrimitive.Root>>;
+}) => (
<SeparatorPrimitive.Root
className={cn('bg-border shrink-0', orientation === 'horizontal' ? 'h-px w-full' : 'h-full w-px', className)}
decorative={decorative}
@@ -14,7 +19,7 @@ const Separator = React.forwardRef<
ref={ref}
{...props}
/>
-));
+);
Separator.displayName = SeparatorPrimitive.Root.displayName;
export { Separator };
diff --git a/frontend/src/components/ui/sheet.tsx b/frontend/src/components/ui/sheet.tsx
index 15aef09e..5f67e5dd 100644
--- a/frontend/src/components/ui/sheet.tsx
+++ b/frontend/src/components/ui/sheet.tsx
@@ -15,10 +15,13 @@ const SheetClose = SheetPrimitive.Close;
const SheetPortal = SheetPrimitive.Portal;
-const SheetOverlay = React.forwardRef<
- React.ElementRef<typeof SheetPrimitive.Overlay>,
- React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
->(({ className, ...props }, ref) => (
+const SheetOverlay = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay> & {
+ ref?: React.Ref<React.ElementRef<typeof SheetPrimitive.Overlay>>;
+}) => (
<SheetPrimitive.Overlay
className={cn(
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80',
@@ -27,7 +30,7 @@ const SheetOverlay = React.forwardRef<
{...props}
ref={ref}
/>
-));
+);
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
const sheetVariants = cva(
@@ -53,23 +56,29 @@ interface SheetContentProps
overlay?: boolean;
}
-const SheetContent = React.forwardRef<React.ElementRef<typeof SheetPrimitive.Content>, SheetContentProps>(
- ({ children, className, container, overlay = true, side = 'right', ...props }, ref) => (
- <SheetPortal container={container ?? undefined}>
- {overlay && <SheetOverlay />}
- <SheetPrimitive.Content
- className={cn(sheetVariants({ side }), className)}
- ref={ref}
- {...props}
- >
- <SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
- <Cross2Icon className="h-4 w-4" />
- <span className="sr-only">Close</span>
- </SheetPrimitive.Close>
- {children}
- </SheetPrimitive.Content>
- </SheetPortal>
- ),
+const SheetContent = ({
+ children,
+ className,
+ container,
+ overlay = true,
+ ref,
+ side = 'right',
+ ...props
+}: SheetContentProps & { ref?: React.Ref<React.ElementRef<typeof SheetPrimitive.Content>> }) => (
+ <SheetPortal container={container ?? undefined}>
+ {overlay && <SheetOverlay />}
+ <SheetPrimitive.Content
+ className={cn(sheetVariants({ side }), className)}
+ ref={ref}
+ {...props}
+ >
+ <SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
+ <Cross2Icon className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </SheetPrimitive.Close>
+ {children}
+ </SheetPrimitive.Content>
+ </SheetPortal>
);
SheetContent.displayName = SheetPrimitive.Content.displayName;
@@ -89,28 +98,34 @@ const SheetFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElemen
);
SheetFooter.displayName = 'SheetFooter';
-const SheetTitle = React.forwardRef<
- React.ElementRef<typeof SheetPrimitive.Title>,
- React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
->(({ className, ...props }, ref) => (
+const SheetTitle = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title> & {
+ ref?: React.Ref<React.ElementRef<typeof SheetPrimitive.Title>>;
+}) => (
<SheetPrimitive.Title
className={cn('text-foreground text-lg font-semibold', className)}
ref={ref}
{...props}
/>
-));
+);
SheetTitle.displayName = SheetPrimitive.Title.displayName;
-const SheetDescription = React.forwardRef<
- React.ElementRef<typeof SheetPrimitive.Description>,
- React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
->(({ className, ...props }, ref) => (
+const SheetDescription = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description> & {
+ ref?: React.Ref<React.ElementRef<typeof SheetPrimitive.Description>>;
+}) => (
<SheetPrimitive.Description
className={cn('text-muted-foreground text-sm', className)}
ref={ref}
{...props}
/>
-));
+);
SheetDescription.displayName = SheetPrimitive.Description.displayName;
export {
diff --git a/frontend/src/components/ui/sidebar.tsx b/frontend/src/components/ui/sidebar.tsx
index b969df2e..bea35940 100644
--- a/frontend/src/components/ui/sidebar.tsx
+++ b/frontend/src/components/ui/sidebar.tsx
@@ -61,14 +61,21 @@ const getSidebarState = (): boolean | undefined => {
return value === 'true';
};
-const SidebarProvider = React.forwardRef<
- HTMLDivElement,
- React.ComponentProps<'div'> & {
- defaultOpen?: boolean;
- onOpenChange?: (open: boolean) => void;
- open?: boolean;
- }
->(({ children, className, defaultOpen = true, onOpenChange: setOpenProp, open: openProp, style, ...props }, ref) => {
+const SidebarProvider = ({
+ children,
+ className,
+ defaultOpen = true,
+ onOpenChange: setOpenProp,
+ open: openProp,
+ ref,
+ style,
+ ...props
+}: React.ComponentProps<'div'> & {
+ defaultOpen?: boolean;
+ onOpenChange?: (open: boolean) => void;
+ open?: boolean;
+ ref?: React.Ref<HTMLDivElement>;
+}) => {
const { isMobile } = useBreakpoint();
const [openMobile, setOpenMobile] = React.useState(false);
@@ -156,17 +163,24 @@ const SidebarProvider = React.forwardRef<
</TooltipProvider>
</SidebarContext.Provider>
);
-});
+};
+
SidebarProvider.displayName = 'SidebarProvider';
-const Sidebar = React.forwardRef<
- HTMLDivElement,
- React.ComponentProps<'div'> & {
- collapsible?: 'icon' | 'none' | 'offcanvas';
- side?: 'left' | 'right';
- variant?: 'floating' | 'inset' | 'sidebar';
- }
->(({ children, className, collapsible = 'offcanvas', side = 'left', variant = 'sidebar', ...props }, ref) => {
+const Sidebar = ({
+ children,
+ className,
+ collapsible = 'offcanvas',
+ ref,
+ side = 'left',
+ variant = 'sidebar',
+ ...props
+}: React.ComponentProps<'div'> & {
+ collapsible?: 'icon' | 'none' | 'offcanvas';
+ ref?: React.Ref<HTMLDivElement>;
+ side?: 'left' | 'right';
+ variant?: 'floating' | 'inset' | 'sidebar';
+}) => {
const { isMobile, openMobile, setOpenMobile, state } = useSidebar();
if (collapsible === 'none') {
@@ -250,63 +264,75 @@ const Sidebar = React.forwardRef<
</div>
</div>
);
-});
+};
+
Sidebar.displayName = 'Sidebar';
-const SidebarTrigger = React.forwardRef<React.ElementRef<typeof Button>, React.ComponentProps<typeof Button>>(
- ({ className, onClick, ...props }, ref) => {
- const { toggleSidebar } = useSidebar();
+const SidebarTrigger = ({
+ className,
+ onClick,
+ ref,
+ ...props
+}: React.ComponentProps<typeof Button> & { ref?: React.Ref<React.ElementRef<typeof Button>> }) => {
+ const { toggleSidebar } = useSidebar();
+
+ return (
+ <Button
+ className={cn('h-7 w-7', className)}
+ data-sidebar="trigger"
+ onClick={(event) => {
+ onClick?.(event);
+ toggleSidebar();
+ }}
+ ref={ref}
+ size="icon"
+ variant="ghost"
+ {...props}
+ >
+ <PanelLeft />
+ <span className="sr-only">Toggle Sidebar</span>
+ </Button>
+ );
+};
- return (
- <Button
- className={cn('h-7 w-7', className)}
- data-sidebar="trigger"
- onClick={(event) => {
- onClick?.(event);
- toggleSidebar();
- }}
- ref={ref}
- size="icon"
- variant="ghost"
- {...props}
- >
- <PanelLeft />
- <span className="sr-only">Toggle Sidebar</span>
- </Button>
- );
- },
-);
SidebarTrigger.displayName = 'SidebarTrigger';
-const SidebarRail = React.forwardRef<HTMLButtonElement, React.ComponentProps<'button'>>(
- ({ className, ...props }, ref) => {
- const { toggleSidebar } = useSidebar();
+const SidebarRail = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'button'> & { ref?: React.Ref<HTMLButtonElement> }) => {
+ const { toggleSidebar } = useSidebar();
+
+ return (
+ <button
+ aria-label="Toggle Sidebar"
+ className={cn(
+ 'hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex',
+ 'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
+ '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
+ 'hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full',
+ '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',
+ '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',
+ className,
+ )}
+ data-sidebar="rail"
+ onClick={toggleSidebar}
+ ref={ref}
+ tabIndex={-1}
+ title="Toggle Sidebar"
+ {...props}
+ />
+ );
+};
- return (
- <button
- aria-label="Toggle Sidebar"
- className={cn(
- 'hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex',
- 'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
- '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
- 'hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full',
- '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',
- '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',
- className,
- )}
- data-sidebar="rail"
- onClick={toggleSidebar}
- ref={ref}
- tabIndex={-1}
- title="Toggle Sidebar"
- {...props}
- />
- );
- },
-);
SidebarRail.displayName = 'SidebarRail';
-const SidebarInset = React.forwardRef<HTMLDivElement, React.ComponentProps<'main'>>(({ className, ...props }, ref) => {
+const SidebarInset = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'main'> & { ref?: React.Ref<HTMLDivElement> }) => {
return (
<main
className={cn(
@@ -321,27 +347,35 @@ const SidebarInset = React.forwardRef<HTMLDivElement, React.ComponentProps<'main
{...props}
/>
);
-});
+};
+
SidebarInset.displayName = 'SidebarInset';
-const SidebarInput = React.forwardRef<React.ElementRef<typeof Input>, React.ComponentProps<typeof Input>>(
- ({ className, ...props }, ref) => {
- return (
- <Input
- className={cn(
- 'bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2',
- className,
- )}
- data-sidebar="input"
- ref={ref}
- {...props}
- />
- );
- },
-);
+const SidebarInput = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof Input> & { ref?: React.Ref<React.ElementRef<typeof Input>> }) => {
+ return (
+ <Input
+ className={cn(
+ 'bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2',
+ className,
+ )}
+ data-sidebar="input"
+ ref={ref}
+ {...props}
+ />
+ );
+};
+
SidebarInput.displayName = 'SidebarInput';
-const SidebarHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(({ className, ...props }, ref) => {
+const SidebarHeader = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'div'> & { ref?: React.Ref<HTMLDivElement> }) => {
return (
<div
className={cn('flex flex-col gap-2 p-2', className)}
@@ -350,10 +384,15 @@ const SidebarHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div
{...props}
/>
);
-});
+};
+
SidebarHeader.displayName = 'SidebarHeader';
-const SidebarFooter = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(({ className, ...props }, ref) => {
+const SidebarFooter = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'div'> & { ref?: React.Ref<HTMLDivElement> }) => {
return (
<div
className={cn('flex flex-col gap-2 p-2', className)}
@@ -362,24 +401,32 @@ const SidebarFooter = React.forwardRef<HTMLDivElement, React.ComponentProps<'div
{...props}
/>
);
-});
+};
+
SidebarFooter.displayName = 'SidebarFooter';
-const SidebarSeparator = React.forwardRef<React.ElementRef<typeof Separator>, React.ComponentProps<typeof Separator>>(
- ({ className, ...props }, ref) => {
- return (
- <Separator
- className={cn('bg-sidebar-border mx-2 w-auto', className)}
- data-sidebar="separator"
- ref={ref}
- {...props}
- />
- );
- },
-);
+const SidebarSeparator = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<typeof Separator> & { ref?: React.Ref<React.ElementRef<typeof Separator>> }) => {
+ return (
+ <Separator
+ className={cn('bg-sidebar-border mx-2 w-auto', className)}
+ data-sidebar="separator"
+ ref={ref}
+ {...props}
+ />
+ );
+};
+
SidebarSeparator.displayName = 'SidebarSeparator';
-const SidebarContent = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(({ className, ...props }, ref) => {
+const SidebarContent = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'div'> & { ref?: React.Ref<HTMLDivElement> }) => {
return (
<div
className={cn(
@@ -391,10 +438,15 @@ const SidebarContent = React.forwardRef<HTMLDivElement, React.ComponentProps<'di
{...props}
/>
);
-});
+};
+
SidebarContent.displayName = 'SidebarContent';
-const SidebarGroup = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(({ className, ...props }, ref) => {
+const SidebarGroup = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'div'> & { ref?: React.Ref<HTMLDivElement> }) => {
return (
<div
className={cn('relative flex w-full min-w-0 flex-col p-2', className)}
@@ -403,81 +455,100 @@ const SidebarGroup = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'
{...props}
/>
);
-});
+};
+
SidebarGroup.displayName = 'SidebarGroup';
-const SidebarGroupLabel = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'> & { asChild?: boolean }>(
- ({ asChild = false, className, ...props }, ref) => {
- const Comp = asChild ? Slot : 'div';
+const SidebarGroupLabel = ({
+ asChild = false,
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'div'> & { asChild?: boolean; ref?: React.Ref<HTMLDivElement> }) => {
+ const Comp = asChild ? Slot : 'div';
- return (
- <Comp
- className={cn(
- 'text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opa] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
- 'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0',
- className,
- )}
- data-sidebar="group-label"
- ref={ref}
- {...props}
- />
- );
- },
-);
-SidebarGroupLabel.displayName = 'SidebarGroupLabel';
+ return (
+ <Comp
+ className={cn(
+ 'text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opa] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
+ 'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0',
+ className,
+ )}
+ data-sidebar="group-label"
+ ref={ref}
+ {...props}
+ />
+ );
+};
-const SidebarGroupAction = React.forwardRef<HTMLButtonElement, React.ComponentProps<'button'> & { asChild?: boolean }>(
- ({ asChild = false, className, ...props }, ref) => {
- const Comp = asChild ? Slot : 'button';
+SidebarGroupLabel.displayName = 'SidebarGroupLabel';
- return (
- <Comp
- className={cn(
- 'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
- // Increases the hit area of the button on mobile.
- 'after:absolute after:-inset-2 md:after:hidden',
- 'group-data-[collapsible=icon]:hidden',
- className,
- )}
- data-sidebar="group-action"
- ref={ref}
- {...props}
- />
- );
- },
-);
-SidebarGroupAction.displayName = 'SidebarGroupAction';
+const SidebarGroupAction = ({
+ asChild = false,
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'button'> & { asChild?: boolean; ref?: React.Ref<HTMLButtonElement> }) => {
+ const Comp = asChild ? Slot : 'button';
-const SidebarGroupContent = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
- ({ className, ...props }, ref) => (
- <div
- className={cn('w-full text-sm', className)}
- data-sidebar="group-content"
+ return (
+ <Comp
+ className={cn(
+ 'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
+ // Increases the hit area of the button on mobile.
+ 'after:absolute after:-inset-2 md:after:hidden',
+ 'group-data-[collapsible=icon]:hidden',
+ className,
+ )}
+ data-sidebar="group-action"
ref={ref}
{...props}
/>
- ),
+ );
+};
+
+SidebarGroupAction.displayName = 'SidebarGroupAction';
+
+const SidebarGroupContent = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'div'> & { ref?: React.Ref<HTMLDivElement> }) => (
+ <div
+ className={cn('w-full text-sm', className)}
+ data-sidebar="group-content"
+ ref={ref}
+ {...props}
+ />
);
SidebarGroupContent.displayName = 'SidebarGroupContent';
-const SidebarMenu = React.forwardRef<HTMLUListElement, React.ComponentProps<'ul'>>(({ className, ...props }, ref) => (
+const SidebarMenu = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'ul'> & { ref?: React.Ref<HTMLUListElement> }) => (
<ul
className={cn('flex w-full min-w-0 flex-col gap-1', className)}
data-sidebar="menu"
ref={ref}
{...props}
/>
-));
+);
SidebarMenu.displayName = 'SidebarMenu';
-const SidebarMenuItem = React.forwardRef<HTMLLIElement, React.ComponentProps<'li'>>(({ className, ...props }, ref) => (
+const SidebarMenuItem = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'li'> & { ref?: React.Ref<HTMLLIElement> }) => (
<li
className={cn('group/menu-item relative', className)}
data-sidebar="menu-item"
ref={ref}
{...props}
/>
-));
+);
SidebarMenuItem.displayName = 'SidebarMenuItem';
const sidebarMenuButtonVariants = cva(
@@ -502,15 +573,22 @@ const sidebarMenuButtonVariants = cva(
},
);
-const SidebarMenuButton = React.forwardRef<
- HTMLButtonElement,
- React.ComponentProps<'button'> &
- VariantProps<typeof sidebarMenuButtonVariants> & {
- asChild?: boolean;
- isActive?: boolean;
- tooltip?: React.ComponentProps<typeof TooltipContent> | string;
- }
->(({ asChild = false, className, isActive = false, size = 'default', tooltip, variant = 'default', ...props }, ref) => {
+const SidebarMenuButton = ({
+ asChild = false,
+ className,
+ isActive = false,
+ ref,
+ size = 'default',
+ tooltip,
+ variant = 'default',
+ ...props
+}: React.ComponentProps<'button'> &
+ VariantProps<typeof sidebarMenuButtonVariants> & {
+ asChild?: boolean;
+ isActive?: boolean;
+ ref?: React.Ref<HTMLButtonElement>;
+ tooltip?: React.ComponentProps<typeof TooltipContent> | string;
+ }) => {
const Comp = asChild ? Slot : 'button';
const { isMobile, state } = useSidebar();
@@ -546,16 +624,21 @@ const SidebarMenuButton = React.forwardRef<
/>
</Tooltip>
);
-});
+};
+
SidebarMenuButton.displayName = 'SidebarMenuButton';
-const SidebarMenuAction = React.forwardRef<
- HTMLButtonElement,
- React.ComponentProps<'button'> & {
- asChild?: boolean;
- showOnHover?: boolean;
- }
->(({ asChild = false, className, showOnHover = false, ...props }, ref) => {
+const SidebarMenuAction = ({
+ asChild = false,
+ className,
+ ref,
+ showOnHover = false,
+ ...props
+}: React.ComponentProps<'button'> & {
+ asChild?: boolean;
+ ref?: React.Ref<HTMLButtonElement>;
+ showOnHover?: boolean;
+}) => {
const Comp = asChild ? Slot : 'button';
return (
@@ -577,61 +660,70 @@ const SidebarMenuAction = React.forwardRef<
{...props}
/>
);
-});
-SidebarMenuAction.displayName = 'SidebarMenuAction';
+};
-const SidebarMenuIndicator = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
- ({ className, ...props }, ref) => {
- return (
- <div
- className={cn(
- 'absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0',
- 'peer-data-[size=sm]/menu-button:top-1',
- 'peer-data-[size=default]/menu-button:top-1.5',
- 'peer-data-[size=lg]/menu-button:top-2.5',
- 'group-data-[collapsible=icon]:hidden',
- 'group-hover/menu-item:opacity-0 peer-hover/menu-button:opacity-0 peer-focus/menu-button:opacity-0',
- className,
- )}
- data-sidebar="menu-indicator"
- ref={ref}
- {...props}
- >
- <div className="relative flex size-5 items-center justify-center">
- <span className="absolute size-2 rounded-full bg-green-400 opacity-75" />
- </div>
- </div>
- );
- },
-);
-SidebarMenuIndicator.displayName = 'SidebarMenuIndicator';
+SidebarMenuAction.displayName = 'SidebarMenuAction';
-const SidebarMenuBadge = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
- ({ className, ...props }, ref) => (
+const SidebarMenuIndicator = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'div'> & { ref?: React.Ref<HTMLDivElement> }) => {
+ return (
<div
className={cn(
- 'text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none',
- 'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground',
+ 'absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0',
'peer-data-[size=sm]/menu-button:top-1',
'peer-data-[size=default]/menu-button:top-1.5',
'peer-data-[size=lg]/menu-button:top-2.5',
'group-data-[collapsible=icon]:hidden',
+ 'group-hover/menu-item:opacity-0 peer-hover/menu-button:opacity-0 peer-focus/menu-button:opacity-0',
className,
)}
- data-sidebar="menu-badge"
+ data-sidebar="menu-indicator"
ref={ref}
{...props}
- />
- ),
+ >
+ <div className="relative flex size-5 items-center justify-center">
+ <span className="absolute size-2 rounded-full bg-green-400 opacity-75" />
+ </div>
+ </div>
+ );
+};
+
+SidebarMenuIndicator.displayName = 'SidebarMenuIndicator';
+
+const SidebarMenuBadge = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'div'> & { ref?: React.Ref<HTMLDivElement> }) => (
+ <div
+ className={cn(
+ 'text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none',
+ 'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground',
+ 'peer-data-[size=sm]/menu-button:top-1',
+ 'peer-data-[size=default]/menu-button:top-1.5',
+ 'peer-data-[size=lg]/menu-button:top-2.5',
+ 'group-data-[collapsible=icon]:hidden',
+ className,
+ )}
+ data-sidebar="menu-badge"
+ ref={ref}
+ {...props}
+ />
);
SidebarMenuBadge.displayName = 'SidebarMenuBadge';
-const SidebarMenuSkeleton = React.forwardRef<
- HTMLDivElement,
- React.ComponentProps<'div'> & {
- showIcon?: boolean;
- }
->(({ className, showIcon = false, ...props }, ref) => {
+const SidebarMenuSkeleton = ({
+ className,
+ ref,
+ showIcon = false,
+ ...props
+}: React.ComponentProps<'div'> & {
+ ref?: React.Ref<HTMLDivElement>;
+ showIcon?: boolean;
+}) => {
// Random width between 50 to 90%.
const [width] = React.useState(() => `${Math.floor(Math.random() * 40) + 50}%`);
@@ -659,41 +751,49 @@ const SidebarMenuSkeleton = React.forwardRef<
/>
</div>
);
-});
+};
+
SidebarMenuSkeleton.displayName = 'SidebarMenuSkeleton';
-const SidebarMenuSub = React.forwardRef<HTMLUListElement, React.ComponentProps<'ul'>>(
- ({ className, ...props }, ref) => (
- <ul
- className={cn(
- 'border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5',
- 'group-data-[collapsible=icon]:hidden',
- className,
- )}
- data-sidebar="menu-sub"
- ref={ref}
- {...props}
- />
- ),
+const SidebarMenuSub = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentProps<'ul'> & { ref?: React.Ref<HTMLUListElement> }) => (
+ <ul
+ className={cn(
+ 'border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5',
+ 'group-data-[collapsible=icon]:hidden',
+ className,
+ )}
+ data-sidebar="menu-sub"
+ ref={ref}
+ {...props}
+ />
);
SidebarMenuSub.displayName = 'SidebarMenuSub';
-const SidebarMenuSubItem = React.forwardRef<HTMLLIElement, React.ComponentProps<'li'>>(({ ...props }, ref) => (
+const SidebarMenuSubItem = ({ ref, ...props }: React.ComponentProps<'li'> & { ref?: React.Ref<HTMLLIElement> }) => (
<li
ref={ref}
{...props}
/>
-));
+);
SidebarMenuSubItem.displayName = 'SidebarMenuSubItem';
-const SidebarMenuSubButton = React.forwardRef<
- HTMLAnchorElement,
- React.ComponentProps<'a'> & {
- asChild?: boolean;
- isActive?: boolean;
- size?: 'md' | 'sm';
- }
->(({ asChild = false, className, isActive, size = 'md', ...props }, ref) => {
+const SidebarMenuSubButton = ({
+ asChild = false,
+ className,
+ isActive,
+ ref,
+ size = 'md',
+ ...props
+}: React.ComponentProps<'a'> & {
+ asChild?: boolean;
+ isActive?: boolean;
+ ref?: React.Ref<HTMLAnchorElement>;
+ size?: 'md' | 'sm';
+}) => {
const Comp = asChild ? Slot : 'a';
return (
@@ -713,7 +813,8 @@ const SidebarMenuSubButton = React.forwardRef<
{...props}
/>
);
-});
+};
+
SidebarMenuSubButton.displayName = 'SidebarMenuSubButton';
export {
diff --git a/frontend/src/components/ui/switch.tsx b/frontend/src/components/ui/switch.tsx
index eaa0b6f6..627eb417 100644
--- a/frontend/src/components/ui/switch.tsx
+++ b/frontend/src/components/ui/switch.tsx
@@ -3,10 +3,13 @@ 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) => (
+const Switch = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root> & {
+ ref?: React.Ref<React.ElementRef<typeof SwitchPrimitives.Root>>;
+}) => (
<SwitchPrimitives.Root
className={cn(
'peer focus-visible:ring-ring focus-visible:ring-offset-background data-[state=checked]:bg-primary data-[state=unchecked]:bg-input inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
@@ -21,7 +24,7 @@ const Switch = React.forwardRef<
)}
/>
</SwitchPrimitives.Root>
-));
+);
Switch.displayName = SwitchPrimitives.Root.displayName;
export { Switch };
diff --git a/frontend/src/components/ui/table.tsx b/frontend/src/components/ui/table.tsx
index b801687a..8b004ed1 100644
--- a/frontend/src/components/ui/table.tsx
+++ b/frontend/src/components/ui/table.tsx
@@ -2,96 +2,112 @@ import * as React from 'react';
import { cn } from '@/lib/utils';
-const Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(
- ({ className, ...props }, ref) => (
- <div className="relative w-full overflow-auto">
- <table
- className={cn('w-full caption-bottom text-sm', className)}
- ref={ref}
- {...props}
- />
- </div>
- ),
-);
-Table.displayName = 'Table';
-
-const TableHeader = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
- ({ className, ...props }, ref) => (
- <thead
- className={cn('[&_tr]:border-b', className)}
+const Table = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLTableElement> & { ref?: React.Ref<HTMLTableElement> }) => (
+ <div className="relative w-full overflow-auto">
+ <table
+ className={cn('w-full caption-bottom text-sm', className)}
ref={ref}
{...props}
/>
- ),
+ </div>
+);
+Table.displayName = 'Table';
+
+const TableHeader = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLTableSectionElement> & { ref?: React.Ref<HTMLTableSectionElement> }) => (
+ <thead
+ className={cn('[&_tr]:border-b', className)}
+ ref={ref}
+ {...props}
+ />
);
TableHeader.displayName = 'TableHeader';
-const TableBody = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
- ({ className, ...props }, ref) => (
- <tbody
- className={cn('[&_tr:last-child]:border-0', className)}
- ref={ref}
- {...props}
- />
- ),
+const TableBody = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLTableSectionElement> & { ref?: React.Ref<HTMLTableSectionElement> }) => (
+ <tbody
+ className={cn('[&_tr:last-child]:border-0', className)}
+ ref={ref}
+ {...props}
+ />
);
TableBody.displayName = 'TableBody';
-const TableFooter = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
- ({ className, ...props }, ref) => (
- <tfoot
- className={cn('bg-muted/50 border-t font-medium last:[&>tr]:border-b-0', className)}
- ref={ref}
- {...props}
- />
- ),
+const TableFooter = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLTableSectionElement> & { ref?: React.Ref<HTMLTableSectionElement> }) => (
+ <tfoot
+ className={cn('bg-muted/50 border-t font-medium last:[&>tr]:border-b-0', className)}
+ ref={ref}
+ {...props}
+ />
);
TableFooter.displayName = 'TableFooter';
-const TableRow = React.forwardRef<HTMLTableRowElement, React.HTMLAttributes<HTMLTableRowElement>>(
- ({ className, ...props }, ref) => (
- <tr
- className={cn('hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors', className)}
- ref={ref}
- {...props}
- />
- ),
+const TableRow = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLTableRowElement> & { ref?: React.Ref<HTMLTableRowElement> }) => (
+ <tr
+ className={cn('hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors', className)}
+ ref={ref}
+ {...props}
+ />
);
TableRow.displayName = 'TableRow';
-const TableHead = React.forwardRef<HTMLTableCellElement, React.ThHTMLAttributes<HTMLTableCellElement>>(
- ({ className, ...props }, ref) => (
- <th
- className={cn(
- 'text-muted-foreground h-12 px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0',
- className,
- )}
- ref={ref}
- {...props}
- />
- ),
+const TableHead = ({
+ className,
+ ref,
+ ...props
+}: React.ThHTMLAttributes<HTMLTableCellElement> & { ref?: React.Ref<HTMLTableCellElement> }) => (
+ <th
+ className={cn(
+ 'text-muted-foreground h-12 px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0',
+ className,
+ )}
+ ref={ref}
+ {...props}
+ />
);
TableHead.displayName = 'TableHead';
-const TableCell = React.forwardRef<HTMLTableCellElement, React.TdHTMLAttributes<HTMLTableCellElement>>(
- ({ className, ...props }, ref) => (
- <td
- className={cn('p-4 align-middle [&:has([role=checkbox])]:pr-0', className)}
- ref={ref}
- {...props}
- />
- ),
+const TableCell = ({
+ className,
+ ref,
+ ...props
+}: React.TdHTMLAttributes<HTMLTableCellElement> & { ref?: React.Ref<HTMLTableCellElement> }) => (
+ <td
+ className={cn('p-4 align-middle [&:has([role=checkbox])]:pr-0', className)}
+ ref={ref}
+ {...props}
+ />
);
TableCell.displayName = 'TableCell';
-const TableCaption = React.forwardRef<HTMLTableCaptionElement, React.HTMLAttributes<HTMLTableCaptionElement>>(
- ({ className, ...props }, ref) => (
- <caption
- className={cn('text-muted-foreground mt-4 text-sm', className)}
- ref={ref}
- {...props}
- />
- ),
+const TableCaption = ({
+ className,
+ ref,
+ ...props
+}: React.HTMLAttributes<HTMLTableCaptionElement> & { ref?: React.Ref<HTMLTableCaptionElement> }) => (
+ <caption
+ className={cn('text-muted-foreground mt-4 text-sm', className)}
+ ref={ref}
+ {...props}
+ />
);
TableCaption.displayName = 'TableCaption';
diff --git a/frontend/src/components/ui/tabs.tsx b/frontend/src/components/ui/tabs.tsx
index fb97904f..10cc8130 100644
--- a/frontend/src/components/ui/tabs.tsx
+++ b/frontend/src/components/ui/tabs.tsx
@@ -5,10 +5,13 @@ 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) => (
+const TabsList = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> & {
+ ref?: React.Ref<React.ElementRef<typeof TabsPrimitive.List>>;
+}) => (
<TabsPrimitive.List
className={cn(
'bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-lg p-1',
@@ -17,13 +20,16 @@ const TabsList = React.forwardRef<
ref={ref}
{...props}
/>
-));
+);
TabsList.displayName = TabsPrimitive.List.displayName;
-const TabsTrigger = React.forwardRef<
- React.ElementRef<typeof TabsPrimitive.Trigger>,
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
->(({ className, ...props }, ref) => (
+const TabsTrigger = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger> & {
+ ref?: React.Ref<React.ElementRef<typeof TabsPrimitive.Trigger>>;
+}) => (
<TabsPrimitive.Trigger
className={cn(
'ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center rounded-md px-3 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm',
@@ -32,13 +38,16 @@ const TabsTrigger = React.forwardRef<
ref={ref}
{...props}
/>
-));
+);
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
-const TabsContent = React.forwardRef<
- React.ElementRef<typeof TabsPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
->(({ className, ...props }, ref) => (
+const TabsContent = ({
+ className,
+ ref,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content> & {
+ ref?: React.Ref<React.ElementRef<typeof TabsPrimitive.Content>>;
+}) => (
<TabsPrimitive.Content
className={cn(
'ring-offset-background focus-visible:ring-ring mt-4 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden',
@@ -47,7 +56,7 @@ const TabsContent = React.forwardRef<
ref={ref}
{...props}
/>
-));
+);
TabsContent.displayName = TabsPrimitive.Content.displayName;
export { Tabs, TabsContent, TabsList, TabsTrigger };
diff --git a/frontend/src/components/ui/textarea.tsx b/frontend/src/components/ui/textarea.tsx
index 63c70d73..db2a2b2d 100644
--- a/frontend/src/components/ui/textarea.tsx
+++ b/frontend/src/components/ui/textarea.tsx
@@ -53,50 +53,54 @@ type TextareaRef = {
textarea: HTMLTextAreaElement;
};
-const Textarea = React.forwardRef<TextareaRef, TextareaProps>(
- (
- { className, maxHeight = 118, minHeight = 38, onChange, value, ...props }: TextareaProps,
- ref: React.Ref<TextareaRef>,
- ) => {
- const textareaRef = React.useRef<HTMLTextAreaElement | null>(null);
- const [triggerAutoSize, setTriggerAutoSize] = React.useState('');
-
- useTextarea({
- maxHeight,
- minHeight,
- textareaRef,
- triggerAutoSize: triggerAutoSize,
- });
-
- useImperativeHandle(ref, () => ({
- focus: () => textareaRef?.current?.focus(),
- maxHeight,
- minHeight,
- textarea: textareaRef.current as HTMLTextAreaElement,
- }));
-
- React.useEffect(() => {
- // eslint-disable-next-line react-hooks/set-state-in-effect -- syncs internal auto-size trigger with controlled value prop
- setTriggerAutoSize(value as string);
- }, [props?.defaultValue, value]);
-
- return (
- <textarea
- className={cn(
- 'border-input placeholder:text-muted-foreground focus-visible:ring-ring flex w-full resize-none rounded-md border bg-transparent px-3 py-2 text-sm shadow-xs focus-visible:ring-1 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
- className,
- )}
- ref={textareaRef}
- {...props}
- onChange={(e) => {
- setTriggerAutoSize(e.target.value);
- onChange?.(e);
- }}
- value={value}
- />
- );
- },
-);
+const Textarea = ({
+ className,
+ maxHeight = 118,
+ minHeight = 38,
+ onChange,
+ ref,
+ value,
+ ...props
+}: TextareaProps & { ref?: React.Ref<TextareaRef> }) => {
+ const textareaRef = React.useRef<HTMLTextAreaElement | null>(null);
+ const [triggerAutoSize, setTriggerAutoSize] = React.useState('');
+
+ useTextarea({
+ maxHeight,
+ minHeight,
+ textareaRef,
+ triggerAutoSize: triggerAutoSize,
+ });
+
+ useImperativeHandle(ref, () => ({
+ focus: () => textareaRef?.current?.focus(),
+ maxHeight,
+ minHeight,
+ textarea: textareaRef.current as HTMLTextAreaElement,
+ }));
+
+ React.useEffect(() => {
+ // eslint-disable-next-line react-hooks/set-state-in-effect -- syncs internal auto-size trigger with controlled value prop
+ setTriggerAutoSize(value as string);
+ }, [props?.defaultValue, value]);
+
+ return (
+ <textarea
+ className={cn(
+ 'border-input placeholder:text-muted-foreground focus-visible:ring-ring flex w-full resize-none rounded-md border bg-transparent px-3 py-2 text-sm shadow-xs focus-visible:ring-1 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
+ className,
+ )}
+ ref={textareaRef}
+ {...props}
+ onChange={(e) => {
+ setTriggerAutoSize(e.target.value);
+ onChange?.(e);
+ }}
+ value={value}
+ />
+ );
+};
+
Textarea.displayName = 'Textarea';
export { Textarea };
diff --git a/frontend/src/components/ui/toggle-group.tsx b/frontend/src/components/ui/toggle-group.tsx
index 64c52b60..3386573a 100644
--- a/frontend/src/components/ui/toggle-group.tsx
+++ b/frontend/src/components/ui/toggle-group.tsx
@@ -12,10 +12,17 @@ const ToggleGroupContext = React.createContext<VariantProps<typeof toggleVariant
variant: 'default',
});
-const ToggleGroup = React.forwardRef<
- React.ElementRef<typeof ToggleGroupPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> & VariantProps<typeof toggleVariants>
->(({ children, className, size, variant, ...props }, ref) => (
+const ToggleGroup = ({
+ children,
+ className,
+ ref,
+ size,
+ variant,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
+ VariantProps<typeof toggleVariants> & {
+ ref?: React.Ref<React.ElementRef<typeof ToggleGroupPrimitive.Root>>;
+ }) => (
<ToggleGroupPrimitive.Root
className={cn('flex items-center justify-center gap-1', className)}
ref={ref}
@@ -23,14 +30,21 @@ const ToggleGroup = React.forwardRef<
>
<ToggleGroupContext.Provider value={{ size, variant }}>{children}</ToggleGroupContext.Provider>
</ToggleGroupPrimitive.Root>
-));
+);
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
-const ToggleGroupItem = React.forwardRef<
- React.ElementRef<typeof ToggleGroupPrimitive.Item>,
- React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>
->(({ children, className, size, variant, ...props }, ref) => {
+const ToggleGroupItem = ({
+ children,
+ className,
+ ref,
+ size,
+ variant,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
+ VariantProps<typeof toggleVariants> & {
+ ref?: React.Ref<React.ElementRef<typeof ToggleGroupPrimitive.Item>>;
+ }) => {
const context = React.useContext(ToggleGroupContext);
return (
@@ -48,7 +62,7 @@ const ToggleGroupItem = React.forwardRef<
{children}
</ToggleGroupPrimitive.Item>
);
-});
+};
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
diff --git a/frontend/src/components/ui/toggle.tsx b/frontend/src/components/ui/toggle.tsx
index d46aec21..c51b4cfe 100644
--- a/frontend/src/components/ui/toggle.tsx
+++ b/frontend/src/components/ui/toggle.tsx
@@ -25,16 +25,22 @@ const toggleVariants = cva(
},
);
-const Toggle = React.forwardRef<
- React.ElementRef<typeof TogglePrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>
->(({ className, size, variant, ...props }, ref) => (
+const Toggle = ({
+ className,
+ ref,
+ size,
+ variant,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
+ VariantProps<typeof toggleVariants> & {
+ ref?: React.Ref<React.ElementRef<typeof TogglePrimitive.Root>>;
+ }) => (
<TogglePrimitive.Root
className={cn(toggleVariants({ className, size, variant }))}
ref={ref}
{...props}
/>
-));
+);
Toggle.displayName = TogglePrimitive.Root.displayName;
diff --git a/frontend/src/components/ui/tooltip.tsx b/frontend/src/components/ui/tooltip.tsx
index e59d4846..ca98fb98 100644
--- a/frontend/src/components/ui/tooltip.tsx
+++ b/frontend/src/components/ui/tooltip.tsx
@@ -9,10 +9,14 @@ 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) => (
+const TooltipContent = ({
+ className,
+ ref,
+ sideOffset = 4,
+ ...props
+}: React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> & {
+ ref?: React.Ref<React.ElementRef<typeof TooltipPrimitive.Content>>;
+}) => (
<TooltipPrimitive.Portal>
<TooltipPrimitive.Content
className={cn(
@@ -24,7 +28,7 @@ const TooltipContent = React.forwardRef<
{...props}
/>
</TooltipPrimitive.Portal>
-));
+);
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };