import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useContext } from 'react';
import clsx from 'clsx';
import Badge from '../badge';
import ConfigProviderContext from '../config-provider/ConfigProviderContext';

const ActionBarIcon = props => {
  const {
    prefixCls,
    createNamespace
  } = useContext(ConfigProviderContext);
  const [bem] = createNamespace('action-bar-icon', prefixCls);

  const renderIcon = () => {
    const {
      badge,
      icon
    } = props;

    if (icon) {
      return _jsx(Badge, Object.assign({}, badge, {
        className: clsx(bem('icon'))
      }, {
        children: icon
      }));
    }

    return null;
  };

  return _jsxs("div", Object.assign({
    role: "button",
    className: clsx(props.className, bem()),
    style: props.style,
    tabIndex: 0,
    onClick: props.onClick
  }, {
    children: [renderIcon(), props.children || props.text]
  }));
};

export default ActionBarIcon;