import { createVNode as _createVNode } from "vue";
import { isVNode as _isVNode } from "vue";

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; }

import { Tooltip } from 'ant-design-vue';
import { PropTypes, withInstall } from '../utils';

function _isSlot(s) {
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
}

var Action = function Action(props, _ref) {
  var _slots$default;

  var slots = _ref.slots;
  var show = props.show,
      title = props.title,
      tips = props.tips,
      onClick = props.onClick,
      className = props.className,
      style = props.style;
  if (!show) return null;
  var classNames = ['action', _defineProperty({}, "".concat(className), !!className)];
  var name = ((_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)) || title;

  var dom = _createVNode("span", {
    "class": classNames,
    "style": style,
    "onClick": onClick
  }, _isSlot(name) ? name : {
    default: function _default() {
      return [name];
    }
  });

  return tips ? _createVNode(Tooltip, {
    "title": tips,
    "placement": 'bottom'
  }, _isSlot(dom) ? dom : {
    default: function _default() {
      return [dom];
    }
  }) : dom;
};

Action.displayName = 'Action';
Action.props = {
  id: PropTypes.string.isRequired,
  className: {
    type: [String, Array, Object]
  },
  style: PropTypes.object,
  show: PropTypes.bool.def(true),
  sort: PropTypes.number.def(0),
  tips: [String, Boolean],
  title: {},
  onClick: PropTypes.func
};
export default withInstall(Action);