UNPKG

semantic-ui-react

Version:
72 lines (58 loc) 1.5 kB
import cx from 'classnames' import PropTypes from 'prop-types' import React from 'react' import { customPropTypes, getElementType, getUnhandledProps, META, useKeyOnly, } from '../../lib' function SearchCategory(props) { const { active, children, className, renderer } = props const classes = cx( useKeyOnly(active, 'active'), 'category', className ) const rest = getUnhandledProps(SearchCategory, props) const ElementType = getElementType(SearchCategory, props) return ( <ElementType {...rest} className={classes}> <div className='name'> {renderer(props)} </div> {children} </ElementType> ) } SearchCategory._meta = { name: 'SearchCategory', parent: 'Search', type: META.TYPES.MODULE, } SearchCategory.defaultProps = { renderer: ({ name }) => name, } SearchCategory.propTypes = { /** An element type to render as (string or function). */ as: customPropTypes.as, /** The item currently selected by keyboard shortcut. */ active: PropTypes.bool, /** Primary content. */ children: PropTypes.node, /** Additional classes. */ className: PropTypes.string, /** Display name. */ name: PropTypes.string, /** * Renders the category contents. * * @param {object} props - The SearchCategory props object. * @returns {*} - Renderable category contents. */ renderer: PropTypes.func, /** Array of Search.Result props. */ results: PropTypes.array, } export default SearchCategory