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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var inputAdornment_props = require('./props.js');
var configProvider_configReceiver = require('../config-provider/config-receiver.js');
var utils_mixins = require('../utils/mixins.js');
require('vue');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

var classPrefixMixins = configProvider_configReceiver.getClassPrefixMixins("input-adornment");
var _InputAdornment = utils_mixins["default"](classPrefixMixins).extend({
  name: "TInputAdornment",
  props: inputAdornment_props["default"],
  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(this.componentName, "__").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 = [this.componentName, (_ref = {}, _defineProperty__default["default"](_ref, "".concat(this.componentName, "--prepend"), prepend), _defineProperty__default["default"](_ref, "".concat(this.componentName, "--append"), append), _ref)];

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

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

exports["default"] = _InputAdornment;
//# sourceMappingURL=input-adornment.js.map
