diff --git a/client/src/components/Nav/SearchBar.jsx b/client/src/components/Nav/SearchBar.tsx similarity index 69% rename from client/src/components/Nav/SearchBar.jsx rename to client/src/components/Nav/SearchBar.tsx index 7aa48ef8e5..142daafa54 100644 --- a/client/src/components/Nav/SearchBar.jsx +++ b/client/src/components/Nav/SearchBar.tsx @@ -1,25 +1,30 @@ -import { forwardRef, useState, useEffect } from 'react'; +import { forwardRef, useState, useEffect, Ref } from 'react'; import { Search, X } from 'lucide-react'; -import { useRecoilState, useRecoilValue } from 'recoil'; +import { useRecoilState } from 'recoil'; +import { useLocalize } from '~/hooks'; import store from '~/store'; -import { localize } from '~/localization/Translation'; -const SearchBar = forwardRef((props, ref) => { +type SearchBarProps = { + clearSearch: () => void; +}; + +const SearchBar = forwardRef((props: SearchBarProps, ref: Ref) => { const { clearSearch } = props; const [searchQuery, setSearchQuery] = useRecoilState(store.searchQuery); const [showClearIcon, setShowClearIcon] = useState(false); - const lang = useRecoilValue(store.lang); + const localize = useLocalize(); - const handleKeyUp = (e) => { - const { value } = e.target; + const handleKeyUp = (e: React.KeyboardEvent) => { + const { value } = e.target as HTMLInputElement; + /* TODO: deprecated keyCode */ if (e.keyCode === 8 && value === '') { setSearchQuery(''); clearSearch(); } }; - const onChange = (e) => { - const { value } = e.target; + const onChange = (e: React.FormEvent) => { + const { value } = e.target as HTMLInputElement; setSearchQuery(value); setShowClearIcon(value.length > 0); }; @@ -46,7 +51,7 @@ const SearchBar = forwardRef((props, ref) => { onKeyDown={(e) => { e.code === 'Space' ? e.stopPropagation() : null; }} - placeholder={localize(lang, 'com_nav_search_placeholder')} + placeholder={localize('com_nav_search_placeholder')} onKeyUp={handleKeyUp} /> ( @@ -25,10 +25,10 @@ AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName; const AlertDialogOverlay = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +>(({ className = '', ...props }, ref) => ( , React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +>(({ className = '', ...props }, ref) => ( ) => ( +const AlertDialogHeader = ({ className = '', ...props }: React.HTMLAttributes) => (
); AlertDialogHeader.displayName = 'AlertDialogHeader'; -const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes) => ( +const AlertDialogFooter = ({ className = '', ...props }: React.HTMLAttributes) => (
, React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +>(({ className = '', ...props }, ref) => ( , React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +>(({ className = '', ...props }, ref) => ( , React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +>(({ className = '', ...props }, ref) => ( , React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +>(({ className = '', ...props }, ref) => ( & { inset?: boolean; } ->(({ className, inset, children, ...props }, ref) => ( +>(({ className = '', inset, children, ...props }, ref) => ( , React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +>(({ className = '', ...props }, ref) => ( , React.ComponentPropsWithoutRef ->(({ className, sideOffset = 4, ...props }, ref) => ( +>(({ className = '', sideOffset = 4, ...props }, ref) => ( & { inset?: boolean; } ->(({ className, inset, ...props }, ref) => ( +>(({ className = '', inset, ...props }, ref) => ( , React.ComponentPropsWithoutRef ->(({ className, children, checked, ...props }, ref) => ( +>(({ className = '', children, checked, ...props }, ref) => ( , React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( +>(({ className = '', children, ...props }, ref) => ( & { inset?: boolean; } ->(({ className, inset, ...props }, ref) => ( +>(({ className = '', inset, ...props }, ref) => ( , React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +>(({ className = '', ...props }, ref) => ( ) => { +const DropdownMenuShortcut = ({ + className = '', + ...props +}: React.HTMLAttributes) => { return ( ); diff --git a/client/src/components/ui/HoverCard.tsx b/client/src/components/ui/HoverCard.tsx index b03b99f7b2..69fe6ab155 100644 --- a/client/src/components/ui/HoverCard.tsx +++ b/client/src/components/ui/HoverCard.tsx @@ -14,13 +14,13 @@ const HoverCardPortal = HoverCardPrimitive.Portal; const HoverCardContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->(({ className, align = 'center', sideOffset = 6, ...props }, ref) => ( +>(({ className = '', align = 'center', sideOffset = 6, ...props }, ref) => ( , React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +>(({ className = '', ...props }, ref) => ( , React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +>(({ className = '', ...props }, ref) => ( {} const Textarea = React.forwardRef( - ({ className, ...props }, ref) => { + ({ className = '', ...props }, ref) => { return (