UNPKG

semantic-ui-react

Version:
65 lines (51 loc) 1.73 kB
import _extends from 'babel-runtime/helpers/extends'; import cx from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; import { childrenUtils, createShorthandFactory, customPropTypes, getElementType, getUnhandledProps, META } from '../../lib'; import Icon from '../../elements/Icon'; /** * A dropdown menu can contain a header. */ function DropdownHeader(props) { var children = props.children, className = props.className, content = props.content, icon = props.icon; var classes = cx('header', className); var rest = getUnhandledProps(DropdownHeader, props); var ElementType = getElementType(DropdownHeader, props); if (!childrenUtils.isNil(children)) return React.createElement( ElementType, _extends({}, rest, { className: classes }), children ); return React.createElement( ElementType, _extends({}, rest, { className: classes }), Icon.create(icon), content ); } DropdownHeader.handledProps = ['as', 'children', 'className', 'content', 'icon']; DropdownHeader._meta = { name: 'DropdownHeader', parent: 'Dropdown', type: META.TYPES.MODULE }; DropdownHeader.propTypes = process.env.NODE_ENV !== "production" ? { /** An element type to render as (string or function) */ as: customPropTypes.as, /** Primary content. */ children: PropTypes.node, /** Additional classes. */ className: PropTypes.string, /** Shorthand for primary content. */ content: customPropTypes.contentShorthand, /** Shorthand for Icon. */ icon: customPropTypes.itemShorthand } : {}; DropdownHeader.create = createShorthandFactory(DropdownHeader, function (content) { return { content: content }; }); export default DropdownHeader;