UNPKG

@awsui/components-react

Version:

AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A

18 lines (17 loc) 622 B
import { useCallback } from 'react'; export var useSearchProps = function (type, disabled, readOnly, value, inputRef, onChange) { var searchProps = {}; var handleIconClick = useCallback(function () { var _a; (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); onChange(''); }, [inputRef, onChange]); if (type === 'search') { searchProps.leftIcon = 'search'; if (!disabled && !readOnly && value) { searchProps.rightIcon = 'close'; searchProps.onRightIconClick = handleIconClick; } } return searchProps; };