'use strict';

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

var _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; }; }();

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _Link = require('../Link');

var _Link2 = _interopRequireDefault(_Link);

var _FieldWrapper = require('./FieldWrapper');

var _FieldWrapper2 = _interopRequireDefault(_FieldWrapper);

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _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; }

function _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; }

var LinkField = function (_React$Component) {
  _inherits(LinkField, _React$Component);

  function LinkField() {
    _classCallCheck(this, LinkField);

    return _possibleConstructorReturn(this, (LinkField.__proto__ || Object.getPrototypeOf(LinkField)).apply(this, arguments));
  }

  _createClass(LinkField, [{
    key: 'render',
    value: function render() {
      var _props = this.props,
          input = _props.input,
          label = _props.label,
          id = _props.id,
          disabled = _props.disabled,
          helpText = _props.helpText,
          to = _props.to,
          children = _props.children,
          exact = _props.exact,
          onClick = _props.onClick,
          callout = _props.callout;

      return _react2.default.createElement(
        _FieldWrapper2.default,
        { label: label, helpText: helpText, disabled: disabled, callout: callout },
        _react2.default.createElement(
          _Link2.default,
          { id: id, disabled: disabled, to: to, exact: exact, onClick: onClick },
          children
        )
      );
    }
  }]);

  return LinkField;
}(_react2.default.Component);

LinkField.propTypes = {
  disabled: _propTypes2.default.bool,
  label: _propTypes2.default.string,
  id: _propTypes2.default.string,
  helpText: _propTypes2.default.string,
  to: _propTypes2.default.string,
  onClick: _propTypes2.default.func,
  exact: _propTypes2.default.bool,
  children: _propTypes2.default.node,
  callout: _propTypes2.default.node
};
LinkField.defaultProps = {
  disabled: false,
  label: null,
  id: null,
  helpText: null,
  to: '#',
  children: 'Link',
  exact: false,
  onClick: function onClick() {
    return null;
  },
  callout: null
};


LinkField.usage = '\n# LinkField\n\nWait, a link isn\'t an input! But using this component in your form will help any links lay out consistently with other form inputs. Plus, you get to add a label and help text.\n\nProps:\n\n* `to`: where the link goes. Leave blank if you want to use onClick instead\n* `onClick`: handler for when the user clicks the link\n* `exact`: children will receive an \'active\' prop if the link matches the current location. This indicates that match must be exact, not partial.\n* `label`: a renderable label to go above the component\n* `helpText`: some text to be rendered below the component\n* `disabled`: disables the component\n* `callout`: optional flyout to show on hover\n';

exports.default = LinkField;