2023-12-20 04:29:02 +00:00
|
|
|
import React, { ChangeEventHandler, forwardRef } from 'react';
|
|
|
|
|
|
|
|
import { Input } from '@material-tailwind/react';
|
2023-12-12 12:24:20 +00:00
|
|
|
|
|
|
|
interface SearchBarProps {
|
2023-12-20 04:29:02 +00:00
|
|
|
onChange: ChangeEventHandler<HTMLInputElement>;
|
|
|
|
value?: string;
|
2023-12-12 12:24:20 +00:00
|
|
|
placeholder?: string;
|
|
|
|
}
|
|
|
|
|
2023-12-20 04:29:02 +00:00
|
|
|
const SearchBar: React.ForwardRefRenderFunction<
|
|
|
|
HTMLInputElement,
|
|
|
|
SearchBarProps
|
|
|
|
> = ({ value, onChange, placeholder = 'Search', ...props }, ref) => {
|
2023-12-12 12:24:20 +00:00
|
|
|
return (
|
2023-12-20 04:29:02 +00:00
|
|
|
<div className="relative flex w-full gap-2">
|
|
|
|
<Input
|
|
|
|
variant="standard"
|
|
|
|
onChange={onChange}
|
|
|
|
value={value}
|
|
|
|
type="search"
|
|
|
|
placeholder={placeholder}
|
|
|
|
containerProps={{
|
|
|
|
className: 'min-w-[288px]',
|
|
|
|
}}
|
|
|
|
className="pl-9 placeholder:text-blue-gray-300 focus:!border-blue-gray-300"
|
|
|
|
labelProps={{
|
|
|
|
className: 'before:content-none after:content-none',
|
|
|
|
}}
|
|
|
|
// TODO: Debug issue: https://github.com/creativetimofficial/material-tailwind/issues/427
|
|
|
|
crossOrigin={undefined}
|
|
|
|
ref={ref}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
<div className="!absolute left-3 top-[13px]">
|
|
|
|
<i>^</i>
|
|
|
|
</div>
|
2023-12-12 12:24:20 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-12-20 04:29:02 +00:00
|
|
|
export default forwardRef(SearchBar);
|