'use strict';

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

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

var _getClassName2 = require('babel-plugin-react-css-modules/dist/browser/getClassName');

var _getClassName3 = _interopRequireDefault(_getClassName2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _warning = require('warning');

var _warning2 = _interopRequireDefault(_warning);

var _Icon = require('../Icon');

var _Icon2 = _interopRequireDefault(_Icon);

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

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var _styleModuleImportMap = {
  './text-icon.scss': {
    'content': 'flive_text-icon_content',
    'icon-text': 'flive_text-icon_icon-text',
    'icon-text-xs': 'flive_text-icon_icon-text-xs',
    'icon-text-sm': 'flive_text-icon_icon-text-sm',
    'icon-text-md': 'flive_text-icon_icon-text-md',
    'icon-text-lg': 'flive_text-icon_icon-text-lg',
    'vertical-align-start': 'flive_text-icon_vertical-align-start',
    'vertical-align-center': 'flive_text-icon_vertical-align-center',
    'vertical-align-end': 'flive_text-icon_vertical-align-end',
    'vertical-align-baseline': 'flive_text-icon_vertical-align-baseline'
  }
};

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var propTypes = {
  /** @ignore */
  className: _propTypes2.default.string,
  /** @ignore */
  children: _propTypes2.default.node,
  size: _propTypes2.default.string,
  textSizing: _propTypes2.default.bool,
  iconClassName: _propTypes2.default.string,
  verticalAlign: _propTypes2.default.oneOf(['start', 'end', 'center', 'baseline']),
  childrenClassName: _propTypes2.default.string,
  name: _propTypes2.default.string,
  variant: _propTypes2.default.string,
  color: _propTypes2.default.string,
  backgroundColor: _propTypes2.default.string,
  borderColor: _propTypes2.default.string,
  component: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object, _propTypes2.default.func])
};

var defaultProps = {
  className: undefined,
  children: null,
  size: 'sm',
  textSizing: false,
  iconClassName: null,
  verticalAlign: 'center',
  childrenClassName: null,
  name: undefined,
  variant: undefined,
  color: undefined,
  backgroundColor: undefined,
  borderColor: undefined,
  component: 'span'
};

var TextIcon = function TextIcon(_ref) {
  var Component = _ref.component,
      children = _ref.children,
      className = _ref.className,
      iconClassName = _ref.iconClassName,
      childrenClassName = _ref.childrenClassName,
      size = _ref.size,
      textSizing = _ref.textSizing,
      verticalAlign = _ref.verticalAlign,
      variant = _ref.variant,
      name = _ref.name,
      color = _ref.color,
      backgroundColor = _ref.backgroundColor,
      borderColor = _ref.borderColor,
      props = _objectWithoutProperties(_ref, ['component', 'children', 'className', 'iconClassName', 'childrenClassName', 'size', 'textSizing', 'verticalAlign', 'variant', 'name', 'color', 'backgroundColor', 'borderColor']);

  if (childrenClassName || iconClassName) {
    (0, _warning2.default)(false, '"childrenClassName" and "iconClassName" props deprecated');
  }

  return _react2.default.createElement(
    Component,
    _extends({}, props, {
      className: (className ? className + ' ' : '') + (0, _getClassName3.default)((0, _classnames2.default)('content', _defineProperty({}, 'vertical-align-' + verticalAlign, verticalAlign)), _styleModuleImportMap)
    }),
    _react2.default.createElement(_Icon2.default, {
      className: iconClassName,
      name: name,
      size: size,
      variant: variant,
      color: color,
      backgroundColor: backgroundColor,
      borderColor: borderColor
    }),
    _react2.default.createElement(
      'span',
      {
        className: (childrenClassName ? childrenClassName + ' ' : '') + (0, _getClassName3.default)((0, _classnames2.default)('icon-text', _defineProperty({}, 'icon-text-' + size, textSizing)), _styleModuleImportMap)
      },
      children
    )
  );
};

TextIcon.propTypes = propTypes;
TextIcon.defaultProps = defaultProps;

exports.default = TextIcon;
module.exports = exports['default'];