semantic-ui-react
Version:
The official Semantic-UI-React integration.
66 lines (55 loc) • 2.3 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, SUI, useValueAndKey, useVerticalAlignProp } from '../../lib';
import ListDescription from './ListDescription';
import ListHeader from './ListHeader';
/**
* A list item can contain a content.
*/
function ListContent(props) {
var children = props.children,
className = props.className,
content = props.content,
description = props.description,
floated = props.floated,
header = props.header,
verticalAlign = props.verticalAlign;
var classes = cx(useValueAndKey(floated, 'floated'), useVerticalAlignProp(verticalAlign), 'content', className);
var rest = getUnhandledProps(ListContent, props);
var ElementType = getElementType(ListContent, props);
if (!childrenUtils.isNil(children)) {
return /*#__PURE__*/React.createElement(ElementType, _extends({}, rest, {
className: classes
}), children);
}
return /*#__PURE__*/React.createElement(ElementType, _extends({}, rest, {
className: classes
}), ListHeader.create(header), ListDescription.create(description), content);
}
ListContent.handledProps = ["as", "children", "className", "content", "description", "floated", "header", "verticalAlign"];
ListContent.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 ListDescription. */
description: customPropTypes.itemShorthand,
/** An list content can be floated left or right. */
floated: PropTypes.oneOf(SUI.FLOATS),
/** Shorthand for ListHeader. */
header: customPropTypes.itemShorthand,
/** An element inside a list can be vertically aligned. */
verticalAlign: PropTypes.oneOf(SUI.VERTICAL_ALIGNMENTS)
} : {};
ListContent.create = createShorthandFactory(ListContent, function (content) {
return {
content: content
};
});
export default ListContent;