semantic-ui-react
Version:
The official Semantic-UI-React integration.
55 lines (47 loc) • 1.68 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import cx from 'clsx';
import PropTypes from 'prop-types';
import React from 'react';
import { childrenUtils, createShorthandFactory, customPropTypes, getElementType, getUnhandledProps } 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 /*#__PURE__*/React.createElement(ElementType, _extends({}, rest, {
className: classes
}), children);
}
return /*#__PURE__*/React.createElement(ElementType, _extends({}, rest, {
className: classes
}), Icon.create(icon, {
autoGenerateKey: false
}), content);
}
DropdownHeader.handledProps = ["as", "children", "className", "content", "icon"];
DropdownHeader.propTypes = process.env.NODE_ENV !== "production" ? {
/** An element type to render as (string or function) */
as: PropTypes.elementType,
/** 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;