1
1
import { useTextField } from "@react-aria/textfield" ;
2
2
import { FunctionComponent , useRef } from "react" ;
3
3
import useDimensions from "react-cool-dimensions" ;
4
- import { IconButton , LocalizedString } from ".." ;
4
+ import { IconButton , IconClose , IconSearch , LocalizedString } from ".." ;
5
5
import { Box } from "../internal" ;
6
6
import { inputRecipe } from "../Field/Field.css" ;
7
7
import { bodyRecipe } from "../Typography/Body/Body.css" ;
8
8
import { input } from "./SearchBar.css" ;
9
- import { FieldType } from "src /Field/createField" ;
10
- import { InputConfig } from "src /Field/InputConfig" ;
11
- import { IconProps } from "src /Icons/IconProps" ;
9
+ import { FieldType } from ".. /Field/createField" ;
10
+ import { defaultInputConfig , InputConfig } from ".. /Field/InputConfig" ;
11
+ import { IconProps } from ".. /Icons/IconProps" ;
12
12
13
13
type Props = {
14
14
value : string ;
@@ -26,8 +26,11 @@ export type SearchBarConfig = {
26
26
27
27
export function createSearchBar (
28
28
Field : FieldType ,
29
- inputConfig : InputConfig ,
30
- config : SearchBarConfig
29
+ config : InputConfig & SearchBarConfig = {
30
+ ...defaultInputConfig ,
31
+ clearIcon : IconClose ,
32
+ searchIcon : IconSearch ,
33
+ }
31
34
) {
32
35
return function SearchBar ( props : Props ) {
33
36
const inputRef = useRef < HTMLInputElement > ( null ) ;
@@ -75,7 +78,7 @@ export function createSearchBar(
75
78
display = "flex"
76
79
justifyContent = "center"
77
80
alignItems = "center"
78
- paddingX = { inputConfig . paddingX }
81
+ paddingX = { config . paddingX }
79
82
top = { 0 }
80
83
bottom = { 0 }
81
84
left = { 0 }
@@ -97,7 +100,7 @@ export function createSearchBar(
97
100
bodyRecipe ( {
98
101
color : props . disabled ? "disabled" : "default" ,
99
102
weight : "regular" ,
100
- size : inputConfig . fontSize ,
103
+ size : config . fontSize ,
101
104
} ) ,
102
105
] }
103
106
display = "flex"
@@ -106,9 +109,9 @@ export function createSearchBar(
106
109
paddingLeft : leftAccessoryWidth ,
107
110
paddingRight : rightAccessoryWidth ,
108
111
} }
109
- borderRadius = { inputConfig . radius }
110
- paddingX = { inputConfig . paddingX }
111
- paddingY = { inputConfig . paddingY }
112
+ borderRadius = { config . radius }
113
+ paddingX = { config . paddingX }
114
+ paddingY = { config . paddingY }
112
115
/>
113
116
{ rightAccessoryContent && (
114
117
< Box
@@ -117,7 +120,7 @@ export function createSearchBar(
117
120
display = "flex"
118
121
justifyContent = "center"
119
122
alignItems = "center"
120
- paddingX = { inputConfig . paddingX }
123
+ paddingX = { config . paddingX }
121
124
top = { 0 }
122
125
bottom = { 0 }
123
126
right = { 0 }
0 commit comments