'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactPrism = require('react-prism');

var _dentist = require('dentist');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var DocumentProptypes = function DocumentProptypes(props) {
  var _props$component = props.component,
      name = _props$component.name,
      proptypes = _props$component.proptypes;

  return _react2.default.createElement(
    'div',
    { className: 'docs-component-props mt-5' },
    _react2.default.createElement(
      'h3',
      null,
      name,
      ' - PropTypes'
    ),
    _react2.default.createElement(
      'pre',
      null,
      _react2.default.createElement(
        _reactPrism.PrismCode,
        { className: 'language-jsx' },
        name + '.propTypes = ' + (0, _dentist.dedent)(proptypes)
      )
    )
  );
};

var DocumentExamples = function DocumentExamples(props) {
  var _props$component2 = props.component,
      name = _props$component2.name,
      demo = _props$component2.demo,
      source = _props$component2.source;

  return _react2.default.createElement(
    'div',
    { className: 'docs-component-props mt-5' },
    _react2.default.createElement(
      'h3',
      null,
      name
    ),
    demo && _react2.default.createElement(
      'div',
      { className: 'docs-example' },
      demo
    ),
    source && _react2.default.createElement(
      'pre',
      null,
      _react2.default.createElement(
        _reactPrism.PrismCode,
        { className: 'language-jsx' },
        (0, _dentist.dedent)(source)
      )
    )
  );
};

var DocumentComponent = function DocumentComponent(props) {
  var name = props.name,
      children = props.children,
      _props$components = props.components,
      components = _props$components === undefined ? [] : _props$components,
      _props$examples = props.examples,
      examples = _props$examples === undefined ? [] : _props$examples;

  return _react2.default.createElement(
    'div',
    { className: 'docs-component-section' },
    _react2.default.createElement(
      'h1',
      null,
      name
    ),
    children,
    components.map(function (component, i) {
      return _react2.default.createElement(DocumentProptypes, { key: i, component: component });
    }),
    examples.map(function (example, i) {
      return _react2.default.createElement(DocumentExamples, { key: i, component: example });
    })
  );
};

exports.default = DocumentComponent;