mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-26 14:44:55 +00:00
47 lines
999 B
TypeScript
47 lines
999 B
TypeScript
import { MagnifyingGlass, X } from '@phosphor-icons/react'
|
|
import { Input } from './Input'
|
|
|
|
interface BasicSearchInputProps {
|
|
value: string
|
|
onChange: (value: string) => void
|
|
placeholder?: string
|
|
onClear?: () => void
|
|
className?: string
|
|
}
|
|
|
|
export function BasicSearchInput({
|
|
value,
|
|
onChange,
|
|
placeholder = 'Search...',
|
|
onClear,
|
|
className,
|
|
}: BasicSearchInputProps) {
|
|
const handleClear = () => {
|
|
onChange('')
|
|
onClear?.()
|
|
}
|
|
|
|
return (
|
|
<Input
|
|
type="text"
|
|
value={value}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
placeholder={placeholder}
|
|
className={className}
|
|
leftIcon={<MagnifyingGlass size={18} />}
|
|
rightIcon={
|
|
value && (
|
|
<button
|
|
type="button"
|
|
onClick={handleClear}
|
|
className="text-muted-foreground hover:text-foreground transition-colors"
|
|
aria-label="Clear search"
|
|
>
|
|
<X size={18} />
|
|
</button>
|
|
)
|
|
}
|
|
/>
|
|
)
|
|
}
|