turash/bugulma/frontend/components/ui/SearchInput.tsx
Damir Mukimov 6347f42e20
Consolidate repositories: Remove nested frontend .git and merge into main repository
- Remove nested git repository from bugulma/frontend/.git
- Add all frontend files to main repository tracking
- Convert from separate frontend/backend repos to unified monorepo
- Preserve all frontend code and development history as tracked files
- Eliminate nested repository complexity for simpler development workflow

This creates a proper monorepo structure with frontend and backend
coexisting in the same repository for easier development and deployment.
2025-11-25 06:02:57 +01:00

54 lines
1.7 KiB
TypeScript

import React from 'react';
import { transitions } from '@/lib/animations';
import { Search, X } from 'lucide-react';
import Input from '@/components/ui/Input.tsx';
interface SearchInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
containerClassName?: string;
showClearButton?: boolean;
onClear?: () => void;
}
const SearchInput = React.forwardRef<HTMLInputElement, SearchInputProps>(
({ className, containerClassName, id, name, value, showClearButton, onClear, ...props }, ref) => {
const inputId = id || 'search-input';
const inputName = name || 'search-input';
const hasValue = value && String(value).length > 0;
return (
<div className={`relative w-full ${containerClassName}`}>
<Search className="-translate-y-1/2 absolute h-4 left-3 pointer-events-none text-current text-muted-foreground top-1/2 w-4 z-10" />
<Input
ref={ref}
type="search"
id={inputId}
name={inputName}
value={value}
className={`
bg-background border-border/50 focus:border-primary/50
pl-9 pr-9 w-full ${transitions.normal}
placeholder:text-muted-foreground/70
hover:border-border focus:ring-2 focus:ring-primary/10
${className}
`}
{...props}
/>
{showClearButton && hasValue && onClear && (
<button
type="button"
onClick={onClear}
className={`absolute right-3 top-1/2 -translate-y-1/2 ${transitions.fast} z-10`}
aria-label="Clear search"
>
<X className="h-4 text-current w-4" />
</button>
)}
</div>
);
}
);
SearchInput.displayName = 'SearchInput';
export default SearchInput;