UNPKG

@chayns-components/core

Version:

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

49 lines (48 loc) 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = _interopRequireWildcard(require("react")); var _SearchBoxItem = require("./SearchBoxItem.styles"); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } const SearchBoxItem = ({ id, text, imageUrl, shouldShowSmallItems, shouldShowRoundImage, onSelect, groupName, tabIndex }) => { const handleClick = (0, _react.useCallback)(event => { event.preventDefault(); event.stopPropagation(); onSelect({ id: id === 'input-value' ? text : id, text, imageUrl }, groupName); }, [onSelect, id, text, imageUrl, groupName]); let idString = `search-box-item__${id}`; if (groupName) { idString = `_${groupName}`; } return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_SearchBoxItem.StyledSearchBoxItem, { id: idString, onClick: handleClick, tabIndex: tabIndex }, imageUrl && /*#__PURE__*/_react.default.createElement(_SearchBoxItem.StyledSearchBoxItemImage, { src: imageUrl, $shouldShowRoundImage: shouldShowRoundImage }), /*#__PURE__*/_react.default.createElement(_SearchBoxItem.StyledSearchBoxItemText, { $shouldShowSmallItems: shouldShowSmallItems, dangerouslySetInnerHTML: { __html: text } })), [handleClick, idString, imageUrl, shouldShowRoundImage, shouldShowSmallItems, text, tabIndex]); }; SearchBoxItem.displayName = 'SearchBoxItem'; var _default = exports.default = SearchBoxItem; //# sourceMappingURL=SearchBoxItem.js.map