2023-12-21 06:30:07 +00:00
|
|
|
import React, { forwardRef, RefAttributes } from 'react';
|
2023-12-20 04:29:02 +00:00
|
|
|
|
2023-12-20 11:13:27 +00:00
|
|
|
import { Input, InputProps } from '@material-tailwind/react';
|
2023-12-12 12:24:20 +00:00
|
|
|
|
2023-12-20 04:29:02 +00:00
|
|
|
const SearchBar: React.ForwardRefRenderFunction<
|
|
|
|
HTMLInputElement,
|
2023-12-21 06:30:07 +00:00
|
|
|
InputProps & RefAttributes<HTMLInputElement>
|
2023-12-20 04:29:02 +00:00
|
|
|
> = ({ 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}
|
|
|
|
{...props}
|
2023-12-21 06:30:07 +00:00
|
|
|
inputRef={ref}
|
2023-12-20 04:29:02 +00:00
|
|
|
/>
|
|
|
|
<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);
|