var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React, { Component } from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { Button as NextButton } from '@alifd/next';
import { omitProps } from '../utils/object';
class Button extends Component {
    render() {
        const { size, warning, icon, className = '' } = this.props;
        // 警告按钮就取默认type
        let type = this.props.type;
        if (warning) {
            type = undefined;
        }
        else if (icon) {
            if (this.props.type === 'primary') {
                type = 'secondary';
            }
        }
        // xl/xs 模式
        if (size === 'xl' || size === 'xs') {
            const _a = this.props, { prefix = 'next-', className } = _a, otherProps = __rest(_a, ["prefix", "className"]);
            const cls = `${prefix}${size}`;
            return (React.createElement(NextButton, Object.assign({}, omitProps(otherProps, ['size']), { type: type, prefix: prefix, className: className ? `${className} ${cls}` : cls })));
        }
        return (React.createElement(NextButton, Object.assign({}, this.props, { type: type, size: size, className: icon ? `${className ? className + ' ' : ''}next-btn-type-icon ` : className })));
    }
}
Button.Group = NextButton.Group;
hoistNonReactStatics(Button, NextButton);
export default Button;
