import React from "react";
import { useStyle } from "./ButtonTabStyle";
var ButtonTab = function(param) {
    var children = param.children, _param_selected = param.selected, selected = _param_selected === void 0 ? false : _param_selected, onClick = param.onClick, onIconClick = param.onIconClick, className = param.className, icon = param.icon, _param_prefixCls = param.prefixCls, prefixCls = _param_prefixCls === void 0 ? 'md-editor-button-tab' : _param_prefixCls;
    var _useStyle = useStyle(prefixCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
    var handleClick = function() {
        onClick === null || onClick === void 0 ? void 0 : onClick();
    };
    var handleIconClick = function(e) {
        e.stopPropagation();
        onIconClick === null || onIconClick === void 0 ? void 0 : onIconClick();
    };
    var handleKeyDown = function(e) {
        if (e.key === 'Enter' || e.key === ' ') {
            e.preventDefault();
            onClick === null || onClick === void 0 ? void 0 : onClick();
        }
    };
    return wrapSSR(/*#__PURE__*/ React.createElement("button", {
        type: "button",
        className: "".concat(prefixCls, " ").concat(selected ? "".concat(prefixCls, "-selected") : '', " ").concat(className || '', " ").concat(hashId),
        onClick: handleClick,
        onKeyDown: handleKeyDown,
        tabIndex: 0
    }, children && /*#__PURE__*/ React.createElement("span", {
        className: "".concat(prefixCls, "-text ").concat(hashId)
    }, children), icon && /*#__PURE__*/ React.createElement("span", {
        className: "".concat(prefixCls, "-icon ").concat(onIconClick ? "".concat(prefixCls, "-icon-clickable") : '', " ").concat(hashId),
        onClick: onIconClick ? handleIconClick : undefined
    }, icon)));
};
export default ButtonTab;
