UNPKG

@chayns-components/core

Version:

A set of beautiful React components for developing your own applications with chayns.

37 lines 1.14 kB
import React, { useCallback, useMemo } from 'react'; import { StyledSearchBoxItem, StyledSearchBoxItemImage, StyledSearchBoxItemText } from './SearchBoxItem.styles'; const SearchBoxItem = _ref => { let { id, text, imageUrl, shouldShowRoundImage, onSelect, groupName } = _ref; const handleClick = useCallback(() => { onSelect({ id, text, imageUrl }, groupName); }, [onSelect, id, text, imageUrl, groupName]); let idString = `search-box-item__${id}`; if (groupName) { idString = `_${groupName}`; } return useMemo(() => /*#__PURE__*/React.createElement(StyledSearchBoxItem, { id: idString, onClick: handleClick }, imageUrl && /*#__PURE__*/React.createElement(StyledSearchBoxItemImage, { src: imageUrl, $shouldShowRoundImage: shouldShowRoundImage }), /*#__PURE__*/React.createElement(StyledSearchBoxItemText, { dangerouslySetInnerHTML: { __html: text } })), [handleClick, idString, imageUrl, shouldShowRoundImage, text]); }; SearchBoxItem.displayName = 'SearchBoxItem'; export default SearchBoxItem; //# sourceMappingURL=SearchBoxItem.js.map