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

'use strict';

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

var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var Vue = require('vue');
var tdesignIconsVue = require('tdesign-icons-vue');
var button_index = require('../../button/index.js');
var config = require('../../config.js');
require('../../button/button.js');
require('../../_chunks/dep-99705d51.js');
require('@babel/runtime/helpers/defineProperty');
require('../../utils/classnames.js');
require('../../loading/index.js');
require('../../loading/loading.js');
require('../../loading/icon/gradient.js');
require('../../_common/js/loading/circle-adapter.js');
require('../../_common/js/utils/set-style.js');
require('../../_common/js/utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../utils/easing.js');
require('../../utils/render-tnode.js');
require('@babel/runtime/helpers/typeof');
require('../../utils/transfer-dom.js');
require('../../loading/props.js');
require('../../utils/withInstall.js');
require('lodash/capitalize');
require('../../loading/plugin.js');
require('../../button/props.js');
require('../../utils/ripple.js');
require('../../config-provider/config-receiver.js');
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');
require('../../utils/mixins.js');

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

var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);

var TransferOperations = Vue__default["default"].extend({
  name: "TTransferOperations",
  props: {
    leftDisabled: {
      type: Boolean,
      required: true
    },
    rightDisabled: {
      type: Boolean,
      required: true
    },
    operation: {
      type: [String, Array, Function, Boolean]
    }
  },
  methods: {
    moveToRight: function moveToRight() {
      this.$emit("moveToRight");
    },
    moveToLeft: function moveToLeft() {
      this.$emit("moveToLeft");
    },
    getIconRight: function getIconRight() {
      var h = this.$createElement;
      return h(tdesignIconsVue.ChevronRightIcon);
    },
    getIconLeft: function getIconLeft() {
      var h = this.$createElement;
      return h(tdesignIconsVue.ChevronLeftIcon);
    },
    getIcon: function getIcon(direction) {
      if (typeof this.operation === "function") {
        return null;
      }

      if (direction === "right" && this.operation && typeof this.operation[0] === "function") {
        return null;
      }

      if (direction === "left" && this.operation && typeof this.operation[1] === "function") {
        return null;
      }

      if (this.$scopedSlots.operation) {
        return null;
      }

      return direction === "left" ? this.getIconLeft : this.getIconRight;
    },
    _renderButton: function _renderButton(h, direction) {
      if (typeof this.$scopedSlots.operation === "function") {
        return this.$scopedSlots.operation({
          direction: direction
        });
      }

      if (typeof this.operation === "function") {
        var renderContent2 = this.operation;
        return renderContent2(h, {
          direction: direction
        });
      }

      var renderContent;

      if (Array.isArray(this.operation)) {
        var _this$operation = _slicedToArray__default["default"](this.operation, 2),
            left = _this$operation[0],
            right = _this$operation[1];

        renderContent = direction === "right" ? right : left;
      } else {
        renderContent = "";
      }

      return renderContent;
    }
  },
  render: function render(h) {
    var _this$$props = this.$props,
        leftDisabled = _this$$props.leftDisabled,
        rightDisabled = _this$$props.rightDisabled;
    return h("div", {
      "class": "".concat(config.prefix, "-transfer__operations")
    }, [h(button_index.Button, {
      "attrs": {
        "variant": rightDisabled ? "outline" : "base",
        "disabled": rightDisabled,
        "icon": this.getIcon("right")
      },
      "key": rightDisabled ? "right-outline" : "right-base",
      "on": {
        "click": this.moveToRight
      }
    }, [this._renderButton(h, "right")]), h(button_index.Button, {
      "attrs": {
        "variant": leftDisabled ? "outline" : "base",
        "disabled": leftDisabled,
        "icon": this.getIcon("left")
      },
      "key": leftDisabled ? "left-outline" : "left-base",
      "on": {
        "click": this.moveToLeft
      }
    }, [this._renderButton(h, "left")])]);
  }
});

exports["default"] = TransferOperations;
//# sourceMappingURL=transfer-operations.js.map
