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 08:38:34 +00:00
|
|
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
2023-12-20 04:29:02 +00:00
|
|
|
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
|
|
|
|
onChange={onChange}
|
|
|
|
value={value}
|
|
|
|
type="search"
|
|
|
|
placeholder={placeholder}
|
|
|
|
containerProps={{
|
|
|
|
className: 'min-w-[288px]',
|
|
|
|
}}
|
2023-12-20 08:38:34 +00:00
|
|
|
className="!border-t-blue-gray-300 pl-9 placeholder:text-blue-gray-300 focus:!border-blue-gray-300"
|
2023-12-20 04:29:02 +00:00
|
|
|
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);
|