"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = _default;

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _rcTooltip = _interopRequireDefault(require("rc-tooltip"));

require("./rc-tooltip.css");

require("./index.css");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var preCls = 'titaui-icon-button-list';

function _default(props) {
  var items = props.items,
      _props$onClick = props.onClick,
      _onClick = _props$onClick === void 0 ? function (e, icon) {} : _props$onClick;

  if (!items) return /*#__PURE__*/_react["default"].createElement("span", null);
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])(preCls)
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__inner"))
  }, items.map(function (it) {
    var icon = it.icon,
        type = it.type,
        overlay = it.overlay,
        _it$placement = it.placement,
        placement = _it$placement === void 0 ? 'top' : _it$placement,
        _it$trigger = it.trigger,
        trigger = _it$trigger === void 0 ? ['hover'] : _it$trigger,
        rotate = it.rotate;

    var content = /*#__PURE__*/_react["default"].createElement("span", {
      className: (0, _classnames["default"])("".concat(preCls, "__btn")),
      onClick: function onClick(e) {
        return _onClick(e, type);
      }
    }, /*#__PURE__*/_react["default"].createElement("span", {
      className: (0, _classnames["default"])("".concat(preCls, "__btn-icon"), _defineProperty({}, "tu-icon-".concat(icon), true)),
      style: rotate ? {
        transform: "rotate(".concat(rotate, "deg)")
      } : {}
    }));

    if (overlay) {
      return /*#__PURE__*/_react["default"].createElement(_rcTooltip["default"], {
        prefixCls: "tui-tooltip",
        placement: placement,
        trigger: trigger,
        overlay: overlay,
        overlayClassName: (0, _classnames["default"])("".concat(preCls, "__btn-tip"))
      }, content);
    }

    return content;
  })));
}