'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.svgWrapper = exports.iconWrapper = undefined;

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; }; /**
                                                                                                                                                                                                                                                                   * Created by baoyinghai on 4/5/17.
                                                                                                                                                                                                                                                                   */


var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var getIconName = function getIconName(iconName) {
  if (typeof iconName === 'string') {
    return iconName;
  }
  return 'icon-xiangmuguanli_xuanze';
};

var iconWrapper = exports.iconWrapper = function iconWrapper(iconName, jsxEle, container) {
  var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  var style = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};

  var iconNameStr = getIconName(iconName);
  if (!jsxEle) {
    // menu
    return _react2.default.createElement('i', _extends({}, props, { style: style, className: 'ico iconfont ' + iconNameStr + ' menu-icon-alibb' }));
  }
  if (container) {
    return _react2.default.createElement(
      'container',
      _extends({ style: style }, props),
      _react2.default.createElement('i', { className: 'ico iconfont ' + iconNameStr + ' menu-icon-alibb' }),
      jsxEle
    );
  }
  return _react2.default.createElement(
    'div',
    _extends({ style: style }, props),
    _react2.default.createElement('i', { className: 'ico iconfont ' + iconNameStr + ' menu-icon-alibb' }),
    _react2.default.cloneElement(jsxEle, _extends({}, props))
  );
};

var svgWrapper = exports.svgWrapper = function svgWrapper(iconName) {
  return _react2.default.createElement(
    'svg',
    { className: 'svg-icon', 'aria-hidden': 'true' },
    _react2.default.createElement('use', { xlinkHref: '#' + iconName })
  );
};