1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
3 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
4 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
5 | import _inherits from 'babel-runtime/helpers/inherits';
|
6 | import classNames from 'classnames';
|
7 | import React, { cloneElement } from 'react';
|
8 | import PropTypes from 'prop-types';
|
9 | import warning from 'warning';
|
10 |
|
11 | import { bsClass, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
|
12 |
|
13 |
|
14 |
|
15 | var propTypes = {
|
16 | |
17 |
|
18 |
|
19 | children: PropTypes.element.isRequired,
|
20 | |
21 |
|
22 |
|
23 | a16by9: PropTypes.bool,
|
24 | |
25 |
|
26 |
|
27 | a4by3: PropTypes.bool
|
28 | };
|
29 |
|
30 | var defaultProps = {
|
31 | a16by9: false,
|
32 | a4by3: false
|
33 | };
|
34 |
|
35 | var ResponsiveEmbed = function (_React$Component) {
|
36 | _inherits(ResponsiveEmbed, _React$Component);
|
37 |
|
38 | function ResponsiveEmbed() {
|
39 | _classCallCheck(this, ResponsiveEmbed);
|
40 |
|
41 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
42 | }
|
43 |
|
44 | ResponsiveEmbed.prototype.render = function render() {
|
45 | var _extends2;
|
46 |
|
47 | var _props = this.props,
|
48 | a16by9 = _props.a16by9,
|
49 | a4by3 = _props.a4by3,
|
50 | className = _props.className,
|
51 | children = _props.children,
|
52 | props = _objectWithoutProperties(_props, ['a16by9', 'a4by3', 'className', 'children']);
|
53 |
|
54 | var _splitBsProps = splitBsProps(props),
|
55 | bsProps = _splitBsProps[0],
|
56 | elementProps = _splitBsProps[1];
|
57 |
|
58 | process.env.NODE_ENV !== 'production' ? warning(a16by9 || a4by3, 'Either `a16by9` or `a4by3` must be set.') : void 0;
|
59 | process.env.NODE_ENV !== 'production' ? warning(!(a16by9 && a4by3), 'Only one of `a16by9` or `a4by3` can be set.') : void 0;
|
60 |
|
61 | var classes = _extends({}, getClassSet(bsProps), (_extends2 = {}, _extends2[prefix(bsProps, '16by9')] = a16by9, _extends2[prefix(bsProps, '4by3')] = a4by3, _extends2));
|
62 |
|
63 | return React.createElement(
|
64 | 'div',
|
65 | { className: classNames(classes) },
|
66 | cloneElement(children, _extends({}, elementProps, {
|
67 | className: classNames(className, prefix(bsProps, 'item'))
|
68 | }))
|
69 | );
|
70 | };
|
71 |
|
72 | return ResponsiveEmbed;
|
73 | }(React.Component);
|
74 |
|
75 | ResponsiveEmbed.propTypes = propTypes;
|
76 | ResponsiveEmbed.defaultProps = defaultProps;
|
77 |
|
78 | export default bsClass('embed-responsive', ResponsiveEmbed); |
\ | No newline at end of file |