import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
var _jsxFileName = 'src/icon/index.jsx';
/**
 * icon.jsx
 *
 * @Author: jruif
 * @Date: 2017/6/30 下午4:26
 */

import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';

// const Icon = props => {
//     let { prefixCls = 'ne-icon', type, spin = false, style, loading = 'spin2', className, onClick } = props;
//
//     const classes = classNames(
//         prefixCls,
//         {
//             [`${prefixCls}-${type === 'loading' ? loading : type}`]: true,
//             'animate-spin': spin || type === 'loading',
//         },
//         className,
//     );
//
//     return <i {...props} className={classes} style={style} onClick={onClick} />;
// };

/**
 * Icon
 * */

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

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

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

    _createClass(Icon, [{
        key: 'render',
        value: function render() {
            var _classNames;

            var _props = this.props,
                prefixCls = _props.prefixCls,
                type = _props.type,
                spin = _props.spin,
                style = _props.style,
                loading = _props.loading,
                className = _props.className,
                onClick = _props.onClick,
                other = _objectWithoutProperties(_props, ['prefixCls', 'type', 'spin', 'style', 'loading', 'className', 'onClick']);

            var classes = classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, prefixCls + '-' + (type === 'loading' ? loading : type), true), _defineProperty(_classNames, 'animate-spin', spin || type === 'loading'), _classNames), className);

            return React.createElement('i', Object.assign({}, other, { className: classes, style: style, onClick: onClick, __source: {
                    fileName: _jsxFileName,
                    lineNumber: 59
                },
                __self: this
            }));
        }
    }]);

    return Icon;
}(React.Component);

Icon.defaultProps = {
    prefixCls: 'ne-icon',
    spin: false,
    loading: 'spin3'
};
Icon.propTypes = {
    prefixCls: PropTypes.string,
    type: PropTypes.string.isRequired,
    spin: PropTypes.bool,
    style: PropTypes.object,
    loading: PropTypes.string,
    className: PropTypes.string,
    onClick: PropTypes.func
};


export default Icon;