UNPKG

1.91 kBJavaScriptView Raw
1import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
3import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
4import classNames from 'classnames';
5import React from 'react';
6import PropTypes from 'prop-types';
7import elementType from 'prop-types-extra/lib/elementType';
8import Media from './Media';
9import { bsClass, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
10var propTypes = {
11 /**
12 * Align the media to the top, middle, or bottom of the media object.
13 */
14 align: PropTypes.oneOf(['top', 'middle', 'bottom']),
15 componentClass: elementType
16};
17var defaultProps = {
18 componentClass: 'div'
19};
20
21var MediaBody =
22/*#__PURE__*/
23function (_React$Component) {
24 _inheritsLoose(MediaBody, _React$Component);
25
26 function MediaBody() {
27 return _React$Component.apply(this, arguments) || this;
28 }
29
30 var _proto = MediaBody.prototype;
31
32 _proto.render = function render() {
33 var _this$props = this.props,
34 Component = _this$props.componentClass,
35 align = _this$props.align,
36 className = _this$props.className,
37 props = _objectWithoutPropertiesLoose(_this$props, ["componentClass", "align", "className"]);
38
39 var _splitBsProps = splitBsProps(props),
40 bsProps = _splitBsProps[0],
41 elementProps = _splitBsProps[1];
42
43 var classes = getClassSet(bsProps);
44
45 if (align) {
46 // The class is e.g. `media-top`, not `media-left-top`.
47 classes[prefix(Media.defaultProps, align)] = true;
48 }
49
50 return React.createElement(Component, _extends({}, elementProps, {
51 className: classNames(className, classes)
52 }));
53 };
54
55 return MediaBody;
56}(React.Component);
57
58MediaBody.propTypes = propTypes;
59MediaBody.defaultProps = defaultProps;
60export default bsClass('media-body', MediaBody);
\No newline at end of file