UNPKG

@chayns-components/core

Version:

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

58 lines 2.62 kB
import React, { useCallback, useMemo } from 'react'; import { getIsTouch } from '../../../utils/environment'; import Icon from '../../icon/Icon'; import { StyledComboBoxItem, StyledComboBoxItemContent, StyledComboBoxItemContentHeader, StyledComboBoxItemContentHeaderRightElement, StyledComboBoxItemContentHeaderWrapper, StyledComboBoxItemContentHeaderWrapperText, StyledComboBoxItemContentSubtext, StyledComboBoxItemImage } from './ComboBoxItem.styles'; const ComboBoxItem = _ref => { let { icons, id, imageBackground, imageUrl, isDisabled, isSelected, onSelect, rightElement, shouldShowBigImage, shouldShowRoundImage, subtext, suffixElement, textStyles, text, value } = _ref; const handleItemClick = useCallback(() => { if (!isDisabled) { onSelect({ text, value, suffixElement, imageUrl, icons }); } }, [icons, imageUrl, isDisabled, onSelect, suffixElement, text, value]); const isTouch = getIsTouch(); return useMemo(() => /*#__PURE__*/React.createElement(StyledComboBoxItem, { id: `combobox-item__${typeof id === 'number' ? String(id) : id}`, onClick: handleItemClick, $isDisabled: isDisabled, $isSelected: isSelected, $isTouch: isTouch }, imageUrl && /*#__PURE__*/React.createElement(StyledComboBoxItemImage, { src: imageUrl, $background: imageBackground, $shouldShowBigImage: shouldShowBigImage || typeof subtext === 'string' && subtext.trim() !== '', $shouldShowRoundImage: shouldShowRoundImage }), icons && /*#__PURE__*/React.createElement(Icon, { icons: icons }), /*#__PURE__*/React.createElement(StyledComboBoxItemContent, null, /*#__PURE__*/React.createElement(StyledComboBoxItemContentHeader, { $text: text, $subtext: subtext }, /*#__PURE__*/React.createElement(StyledComboBoxItemContentHeaderWrapper, { as: textStyles?.tagName, style: textStyles?.styles }, /*#__PURE__*/React.createElement(StyledComboBoxItemContentHeaderWrapperText, null, text), suffixElement), rightElement && /*#__PURE__*/React.createElement(StyledComboBoxItemContentHeaderRightElement, null, rightElement)), subtext && /*#__PURE__*/React.createElement(StyledComboBoxItemContentSubtext, null, subtext))), [handleItemClick, icons, id, imageBackground, imageUrl, isDisabled, isSelected, isTouch, rightElement, shouldShowBigImage, shouldShowRoundImage, subtext, suffixElement, text, textStyles?.styles, textStyles?.tagName]); }; ComboBoxItem.displayName = 'ComboBoxItem'; export default ComboBoxItem; //# sourceMappingURL=ComboBoxItem.js.map