2022-05-23 00:24:21 +00:00
|
|
|
import { useEffect, useRef } from "react";
|
|
|
|
import Paper from "@mui/material/Paper";
|
|
|
|
import InputBase from "@mui/material/InputBase";
|
|
|
|
import Divider from "@mui/material/Divider";
|
|
|
|
import IconButton from "@mui/material/IconButton";
|
|
|
|
import MenuIcon from "@mui/icons-material/Menu";
|
|
|
|
import SearchIcon from "@mui/icons-material/Search";
|
|
|
|
import DirectionsIcon from "@mui/icons-material/Directions";
|
|
|
|
import ClearOutlinedIcon from "@mui/icons-material/ClearOutlined";
|
|
|
|
|
|
|
|
export default function CatalogSearch(props) {
|
|
|
|
const { onChange, onClear } = props;
|
|
|
|
|
|
|
|
const searchRef = useRef(null);
|
|
|
|
|
|
|
|
const handleClear = () => {
|
|
|
|
searchRef.current.children[0].value = null;
|
|
|
|
searchRef.current.children[0].focus();
|
|
|
|
onClear();
|
|
|
|
};
|
2022-05-17 12:32:04 +00:00
|
|
|
|
|
|
|
return (
|
2022-05-23 00:24:21 +00:00
|
|
|
<Paper component="form" sx={{ display: "flex", alignItems: "center" }}>
|
2022-05-17 12:32:04 +00:00
|
|
|
<InputBase
|
2022-05-23 00:24:21 +00:00
|
|
|
ref={searchRef}
|
|
|
|
sx={{ ml: 1, flex: 1 }}
|
2022-05-17 12:32:04 +00:00
|
|
|
placeholder="Search Catalog"
|
2022-05-23 00:24:21 +00:00
|
|
|
inputProps={{ "aria-label": `search catalog` }}
|
|
|
|
onChange={onChange}
|
2022-06-22 00:47:19 +00:00
|
|
|
fullWidth
|
2022-05-17 12:32:04 +00:00
|
|
|
/>
|
2022-05-23 00:24:21 +00:00
|
|
|
<Divider sx={{ height: 26, m: 0.5 }} orientation="vertical" />
|
|
|
|
<IconButton
|
|
|
|
sx={{ p: "10px", mr: 0.5 }}
|
|
|
|
aria-label="clear"
|
|
|
|
onClick={handleClear}
|
|
|
|
>
|
2022-05-17 12:32:04 +00:00
|
|
|
<ClearOutlinedIcon />
|
|
|
|
</IconButton>
|
|
|
|
</Paper>
|
|
|
|
);
|
2022-05-23 00:24:21 +00:00
|
|
|
}
|