"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = void 0;

var _create = _interopRequireDefault(require("../utils/create"));

var _icon = _interopRequireDefault(require("../icon"));

// Components
var _default = (0, _create.default)({
  render: function render() {
    var _vm = this;

    var _h = _vm.$createElement;

    var _c = _vm._self._c || _h;

    return _c('transition', {
      attrs: {
        "name": _vm.closeable ? 'van-fade' : null
      }
    }, [_c('span', {
      key: "content",
      class: _vm.b([_vm.classes, _vm.type]),
      style: _vm.style,
      on: {
        "click": _vm.onClick
      }
    }, [_vm._t("default"), _vm.closeable ? _c('Icon', {
      class: _vm.b('close'),
      attrs: {
        "name": "close"
      },
      on: {
        "click": _vm.onClose
      }
    }) : _vm._e()], 2)]);
  },
  components: {
    Icon: _icon.default
  },
  name: "tag",
  props: {
    size: String,
    mark: Boolean,
    color: String,
    plain: Boolean,
    round: Boolean,
    textColor: String,
    closeable: Boolean,
    type: {
      type: String,
      default: "default"
    }
  },
  methods: {
    onClick: function onClick() {
      this.$emit("click");
    },
    onClose: function onClose(event) {
      event.stopPropagation();
      this.$emit("close");
    }
  },
  computed: {
    style: function style() {
      var _style;

      var plain = this.plain,
          color = this.color;
      var key = plain ? "color" : "backgroundColor";
      var style = (_style = {}, _style[key] = color, _style);

      if (this.textColor) {
        style.color = this.textColor;
      }

      return style;
    },
    classes: function classes() {
      var mark = this.mark,
          plain = this.plain,
          round = this.round,
          size = this.size;
      var classes = {
        mark: mark,
        plain: plain,
        round: round
      };

      if (size) {
        classes[size] = size;
      }

      return classes;
    }
  }
});

exports.default = _default;