Skip to content

Commit a7aa547

Browse files
committed
chore(refactor): modernizing SearchBox forwardRef behavior
- removed `React` import from type utils
1 parent 3f132bc commit a7aa547

File tree

3 files changed

+28
-35
lines changed

3 files changed

+28
-35
lines changed
Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
1-
import type { MapElement } from "@/types/utils"
2-
import { forwardRef } from "react"
1+
import { ReactForwardRef } from "@mav/shared/types"
32
import { LuSearch as SearchIcon } from "react-icons/lu"
43

5-
const SearchBox = forwardRef(
6-
(
7-
{
8-
placeholder
9-
}: {
10-
placeholder?: string
11-
},
12-
ref: React.ForwardedRef<MapElement<"input">>
13-
) => {
14-
return (
15-
<div className="relative w-full">
16-
<div className="pointer-events-none absolute left-3.5 flex h-full items-center justify-center">
17-
<SearchIcon size={18} />
18-
</div>
19-
<input
20-
ref={ref}
21-
type="search"
22-
name="Search"
23-
className="bg-200 font-inter h-full w-full rounded-md border-none py-2 pl-10 pr-1 text-sm"
24-
placeholder={placeholder}
25-
/>
26-
</div>
27-
)
28-
}
29-
)
4+
interface SearchBoxProps {
5+
placeholder?: string
6+
}
307

31-
SearchBox.displayName = "SearchBox"
8+
export function SearchBox({
9+
ref,
10+
...props
11+
}: ReactForwardRef<HTMLInputElement, SearchBoxProps>) {
12+
const { placeholder } = props
3213

33-
export default SearchBox
14+
return (
15+
<div className="relative w-full">
16+
<div className="pointer-events-none absolute left-3.5 flex h-full items-center justify-center">
17+
<SearchIcon size={18} />
18+
</div>
19+
<input
20+
ref={ref}
21+
type="search"
22+
name="Search"
23+
className="bg-200 font-inter h-full w-full rounded-md border-none py-2 pl-10 pr-1 text-sm"
24+
placeholder={placeholder}
25+
/>
26+
</div>
27+
)
28+
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import RichTextField from "./RichTextField"
2-
import SearchBox from "./SearchBox"
3-
import SelectField from "./SelectField"
4-
5-
export { RichTextField, SearchBox, SelectField }
1+
export * from "./RichTextField"
2+
export * from "./SearchBox"
3+
export * from "./SelectField"
4+
export * from "./Checkbox"

apps/web/src/types/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type React from "react"
21
import { Artwork, Character } from "./characters"
32
import { UserType } from "./users"
43

0 commit comments

Comments
 (0)