(props: SearchFieldProps)
| 14 | } |
| 15 | |
| 16 | export function SearchField(props: SearchFieldProps) { |
| 17 | let state = useSearchFieldState(props); |
| 18 | let ref = useRef<HTMLInputElement>(null); |
| 19 | /*- begin highlight -*/ |
| 20 | let {labelProps, inputProps, clearButtonProps} = useSearchField(props, state, ref); |
| 21 | /*- end highlight -*/ |
| 22 | let [isFocused, setFocused] = useState(false); |
| 23 | let {focusProps} = useFocus({onFocusChange: setFocused}); |
| 24 | |
| 25 | return ( |
| 26 | <div className="react-aria-SearchField" data-empty={state.value === '' || undefined}> |
| 27 | {props.label && ( |
| 28 | <label className="react-aria-Label" {...labelProps}> |
| 29 | {props.label} |
| 30 | </label> |
| 31 | )} |
| 32 | <Search size={18} aria-hidden="true" /> |
| 33 | <input |
| 34 | {...mergeProps(inputProps, focusProps)} |
| 35 | ref={ref} |
| 36 | className="react-aria-Input inset" |
| 37 | data-focused={isFocused || undefined} |
| 38 | /> |
| 39 | <ClearButton {...clearButtonProps}> |
| 40 | <X size={14} /> |
| 41 | </ClearButton> |
| 42 | </div> |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | function ClearButton(props: AriaButtonProps) { |
| 47 | let ref = useRef<HTMLButtonElement>(null); |
nothing calls this directly
no test coverage detected