/**
 * tdesign v0.41.7
 * (c) 2022 tdesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import Vue from 'vue';
import { prefix } from '../config.js';

var name = "".concat(prefix, "-addon");
var _Addon = Vue.extend({
  name: "TAddon",
  props: {
    prepend: [String, Function],
    append: [String, Function]
  },
  methods: {
    renderAddon: function renderAddon(h, type, addon) {
      var addonNode;

      if (this.$scopedSlots[type]) {
        addonNode = this.$scopedSlots[type](null);
      } else if (typeof addon === "string") {
        addonNode = addon;
      } else if (typeof addon === "function") {
        addonNode = addon(h);
      } else {
        addonNode = null;
      }

      return addonNode ? h("span", {
        "class": "".concat(name, "__").concat(type)
      }, [addonNode]) : addonNode;
    }
  },
  render: function render(h) {
    var _ref;

    var prepend = this.renderAddon(h, "prepend", this.prepend);
    var append = this.renderAddon(h, "append", this.append);
    var defaultSlot = this.$scopedSlots["default"] ? this.$scopedSlots["default"](null) : [null];
    var className = [name, (_ref = {}, _defineProperty(_ref, "".concat(name, "--prepend"), prepend), _defineProperty(_ref, "".concat(name, "--append"), append), _ref)];

    if (!prepend && !append) {
      return defaultSlot[0];
    }

    return h("div", {
      "class": className
    }, [prepend, defaultSlot[0], append]);
  }
});

export { _Addon as default };
//# sourceMappingURL=addon.js.map
