function _extends() { _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; }; return _extends.apply(this, arguments); }

import React, { useContext } from 'react';
import clsx from 'clsx';
import Badge from '../badge';
import ConfigProviderContext from '../config-provider/ConfigProviderContext';

var ActionBarIcon = function ActionBarIcon(props) {
  var _useContext = useContext(ConfigProviderContext),
      prefixCls = _useContext.prefixCls,
      createNamespace = _useContext.createNamespace;

  var _createNamespace = createNamespace('action-bar-icon', prefixCls),
      bem = _createNamespace[0];

  var renderIcon = function renderIcon() {
    var badge = props.badge,
        icon = props.icon;

    if (icon) {
      return /*#__PURE__*/React.createElement(Badge, _extends({}, badge, {
        className: clsx(bem('icon'))
      }), icon);
    }

    return null;
  };

  return /*#__PURE__*/React.createElement("div", {
    role: "button",
    className: clsx(props.className, bem()),
    style: props.style,
    tabIndex: 0,
    onClick: props.onClick
  }, renderIcon(), props.children || props.text);
};

export default ActionBarIcon;