UNPKG

3.49 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _extends = Object.assign || 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; };
8
9var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
10
11var _react = require('react');
12
13var _react2 = _interopRequireDefault(_react);
14
15var _mdxProvider = require('./mdx-provider');
16
17function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
19function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
21function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
22
23function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
24
25var defaults = {
26 inlineCode: 'code',
27 wrapper: 'div'
28};
29
30var MDXTag = function (_Component) {
31 _inherits(MDXTag, _Component);
32
33 function MDXTag() {
34 _classCallCheck(this, MDXTag);
35
36 return _possibleConstructorReturn(this, (MDXTag.__proto__ || Object.getPrototypeOf(MDXTag)).apply(this, arguments));
37 }
38
39 _createClass(MDXTag, [{
40 key: 'render',
41 value: function render() {
42 var _props = this.props,
43 name = _props.name,
44 parentName = _props.parentName,
45 _props$props = _props.props,
46 childProps = _props$props === undefined ? {} : _props$props,
47 children = _props.children,
48 _props$components = _props.components,
49 components = _props$components === undefined ? {} : _props$components,
50 Layout = _props.Layout,
51 layoutProps = _props.layoutProps;
52
53
54 var Component = components[parentName + '.' + name] || components[name] || defaults[name] || name;
55
56 if (Layout) {
57 return _react2.default.createElement(
58 Layout,
59 _extends({ components: components }, layoutProps),
60 _react2.default.createElement(
61 Component,
62 childProps,
63 children
64 )
65 );
66 }
67
68 return _react2.default.createElement(
69 Component,
70 childProps,
71 children
72 );
73 }
74 }]);
75
76 return MDXTag;
77}(_react.Component);
78
79exports.default = (0, _mdxProvider.withMDXComponents)(MDXTag);
\No newline at end of file