1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 | var _react = _interopRequireDefault(require("react"));
|
8 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
9 | var _classnames = _interopRequireDefault(require("classnames"));
|
10 | var _utils = require("./utils");
|
11 | const _excluded = ["body", "bottom", "className", "cssModule", "heading", "left", "list", "middle", "object", "right", "tag", "top"];
|
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13 | function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
14 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
15 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
16 | const propTypes = {
|
17 | body: _propTypes.default.bool,
|
18 | bottom: _propTypes.default.bool,
|
19 | children: _propTypes.default.node,
|
20 | className: _propTypes.default.string,
|
21 | cssModule: _propTypes.default.object,
|
22 | heading: _propTypes.default.bool,
|
23 | left: _propTypes.default.bool,
|
24 | list: _propTypes.default.bool,
|
25 | middle: _propTypes.default.bool,
|
26 | object: _propTypes.default.bool,
|
27 | right: _propTypes.default.bool,
|
28 | tag: _utils.tagPropType,
|
29 | top: _propTypes.default.bool
|
30 | };
|
31 | function Media(props) {
|
32 | const {
|
33 | body,
|
34 | bottom,
|
35 | className,
|
36 | cssModule,
|
37 | heading,
|
38 | left,
|
39 | list,
|
40 | middle,
|
41 | object,
|
42 | right,
|
43 | tag,
|
44 | top
|
45 | } = props,
|
46 | attributes = _objectWithoutProperties(props, _excluded);
|
47 | let defaultTag;
|
48 | if (heading) {
|
49 | defaultTag = 'h4';
|
50 | } else if (attributes.href) {
|
51 | defaultTag = 'a';
|
52 | } else if (attributes.src || object) {
|
53 | defaultTag = 'img';
|
54 | } else if (list) {
|
55 | defaultTag = 'ul';
|
56 | } else {
|
57 | defaultTag = 'div';
|
58 | }
|
59 | const Tag = tag || defaultTag;
|
60 | const classes = (0, _utils.mapToCssModules)((0, _classnames.default)(className, {
|
61 | 'media-body': body,
|
62 | 'media-heading': heading,
|
63 | 'media-left': left,
|
64 | 'media-right': right,
|
65 | 'media-top': top,
|
66 | 'media-bottom': bottom,
|
67 | 'media-middle': middle,
|
68 | 'media-object': object,
|
69 | 'media-list': list,
|
70 | media: !body && !heading && !left && !right && !top && !bottom && !middle && !object && !list
|
71 | }), cssModule);
|
72 | return _react.default.createElement(Tag, _extends({}, attributes, {
|
73 | className: classes
|
74 | }));
|
75 | }
|
76 | Media.propTypes = propTypes;
|
77 | var _default = Media;
|
78 | exports.default = _default; |
\ | No newline at end of file |