2024-05-02 17:04:18 +03:00
|
|
|
import { IconSearch } from '../Icons';
|
2023-12-18 19:42:27 +03:00
|
|
|
import { CProps } from '../props';
|
2023-12-08 19:24:08 +03:00
|
|
|
import Overlay from './Overlay';
|
2023-11-06 02:20:16 +03:00
|
|
|
import TextInput from './TextInput';
|
|
|
|
|
2024-01-04 19:30:10 +03:00
|
|
|
interface SearchBarProps extends CProps.Styling {
|
2023-12-28 14:04:44 +03:00
|
|
|
value: string;
|
2024-03-18 16:21:39 +03:00
|
|
|
id?: string;
|
2023-12-28 14:04:44 +03:00
|
|
|
onChange?: (newValue: string) => void;
|
|
|
|
noBorder?: boolean;
|
2023-11-06 02:20:16 +03:00
|
|
|
}
|
|
|
|
|
2024-03-18 16:21:39 +03:00
|
|
|
function SearchBar({ id, value, onChange, noBorder, ...restProps }: SearchBarProps) {
|
2023-11-06 02:20:16 +03:00
|
|
|
return (
|
2023-12-28 14:04:44 +03:00
|
|
|
<div {...restProps}>
|
|
|
|
<Overlay position='top-[-0.125rem] left-3 translate-y-1/2' className='pointer-events-none clr-text-controls'>
|
2024-05-02 17:04:18 +03:00
|
|
|
<IconSearch size='1.25rem' />
|
2023-12-28 14:04:44 +03:00
|
|
|
</Overlay>
|
|
|
|
<TextInput
|
2024-03-18 16:21:39 +03:00
|
|
|
id={id}
|
2023-12-28 14:04:44 +03:00
|
|
|
noOutline
|
|
|
|
placeholder='Поиск'
|
2024-01-04 19:30:10 +03:00
|
|
|
type='search'
|
2023-12-30 19:43:24 +03:00
|
|
|
className='w-full pl-10'
|
2023-12-28 14:04:44 +03:00
|
|
|
noBorder={noBorder}
|
|
|
|
value={value}
|
|
|
|
onChange={event => (onChange ? onChange(event.target.value) : undefined)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
2023-11-06 02:20:16 +03:00
|
|
|
}
|
|
|
|
|
2024-01-04 19:30:10 +03:00
|
|
|
export default SearchBar;
|