({
formRef,
inputRef,
isSearchStalled,
onChange,
onReset,
onSubmit,
placeholder,
value,
autoFocus,
resetIconComponent: ResetIcon = DefaultResetIcon,
submitIconComponent: SubmitIcon = DefaultSubmitIcon,
loadingIconComponent: LoadingIcon = DefaultLoadingIcon,
classNames = {},
translations,
...props
}: SearchBoxProps)
| 137 | } |
| 138 | |
| 139 | export function SearchBox({ |
| 140 | formRef, |
| 141 | inputRef, |
| 142 | isSearchStalled, |
| 143 | onChange, |
| 144 | onReset, |
| 145 | onSubmit, |
| 146 | placeholder, |
| 147 | value, |
| 148 | autoFocus, |
| 149 | resetIconComponent: ResetIcon = DefaultResetIcon, |
| 150 | submitIconComponent: SubmitIcon = DefaultSubmitIcon, |
| 151 | loadingIconComponent: LoadingIcon = DefaultLoadingIcon, |
| 152 | classNames = {}, |
| 153 | translations, |
| 154 | ...props |
| 155 | }: SearchBoxProps) { |
| 156 | function handleSubmit(event: React.FormEvent<HTMLFormElement>) { |
| 157 | event.preventDefault(); |
| 158 | event.stopPropagation(); |
| 159 | |
| 160 | if (onSubmit) { |
| 161 | onSubmit(event); |
| 162 | } |
| 163 | |
| 164 | if (inputRef.current) { |
| 165 | inputRef.current.blur(); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | function handleReset(event: React.FormEvent<HTMLFormElement>) { |
| 170 | event.preventDefault(); |
| 171 | event.stopPropagation(); |
| 172 | |
| 173 | onReset(event); |
| 174 | |
| 175 | if (inputRef.current) { |
| 176 | inputRef.current.focus(); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | return ( |
| 181 | <div |
| 182 | {...props} |
| 183 | className={cx(styles.container, classNames.root, props.className)} |
| 184 | > |
| 185 | <form |
| 186 | ref={formRef} |
| 187 | action="" |
| 188 | className={cx(classNames.form)} |
| 189 | noValidate |
| 190 | onSubmit={handleSubmit} |
| 191 | onReset={handleReset} |
| 192 | > |
| 193 | <TextInput |
| 194 | className={styles.input} |
| 195 | id="search" |
| 196 | inputRef={inputRef} |
nothing calls this directly
no outgoing calls
no test coverage detected