UNPKG

semantic-ui-react

Version:
77 lines (61 loc) 2.05 kB
import cx from 'clsx' import PropTypes from 'prop-types' import React from 'react' import { childrenUtils, customPropTypes, getElementType, getUnhandledProps, SUI, useVerticalAlignProp, } from '../../lib' import ItemHeader from './ItemHeader' import ItemDescription from './ItemDescription' import ItemExtra from './ItemExtra' import ItemMeta from './ItemMeta' /** * An item can contain content. */ function ItemContent(props) { const { children, className, content, description, extra, header, meta, verticalAlign } = props const classes = cx(useVerticalAlignProp(verticalAlign), 'content', className) const rest = getUnhandledProps(ItemContent, props) const ElementType = getElementType(ItemContent, props) if (!childrenUtils.isNil(children)) { return ( <ElementType {...rest} className={classes}> {children} </ElementType> ) } return ( <ElementType {...rest} className={classes}> {ItemHeader.create(header, { autoGenerateKey: false })} {ItemMeta.create(meta, { autoGenerateKey: false })} {ItemDescription.create(description, { autoGenerateKey: false })} {ItemExtra.create(extra, { autoGenerateKey: false })} {content} </ElementType> ) } ItemContent.propTypes = { /** 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 ItemDescription component. */ description: customPropTypes.itemShorthand, /** Shorthand for ItemExtra component. */ extra: customPropTypes.itemShorthand, /** Shorthand for ItemHeader component. */ header: customPropTypes.itemShorthand, /** Shorthand for ItemMeta component. */ meta: customPropTypes.itemShorthand, /** Content can specify its vertical alignment. */ verticalAlign: PropTypes.oneOf(SUI.VERTICAL_ALIGNMENTS), } export default ItemContent