/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

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

var iconsVue = require('@ldesign/icons-vue');
var components_button_index = require('../../button/index.js');
var utils_mixins = require('../../../utils/mixins.js');
var components_configProvider_configReceiver = require('../../config-provider/config-receiver.js');
require('../../../utils/with-install.js');
require('vue');
require('lodash');
require('../../../config.js');
require('../../button/button.js');
require('../../loading/index.js');
require('../../loading/loading.js');
require('../../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../../chunks/log.js');
require('../../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../../utils/easing.js');
require('../../../utils/render-node.js');
require('../../../utils/transfer-dom.js');
require('../../loading/props.js');
require('../../loading/icon/gradient.js');
require('../../../chunks/defineProperty-838e4192.js');
require('../../../chunks/set-style.js');
require('../../../chunks/helper2.js');
require('lodash/mergeWith');
require('../../config-provider/context.js');
require('../../../chunks/zh_CN.js');
require('../../loading/plugin.js');
require('../../../utils/ripple.js');
require('../../button/props.js');

const classPrefixMixins = components_configProvider_configReceiver.getClassPrefixMixins("transfer");
var TransferOperations = utils_mixins["default"](classPrefixMixins, components_configProvider_configReceiver.getGlobalIconMixins()).extend({
  name: "LTransferOperations",
  props: {
    leftDisabled: {
      type: Boolean,
      required: true
    },
    rightDisabled: {
      type: Boolean,
      required: true
    },
    operation: {
      type: [String, Array, Function, Boolean]
    }
  },
  components: {
    LButton: components_button_index.Button
  },
  methods: {
    moveToRight() {
      this.$emit("moveToRight");
    },
    moveToLeft() {
      this.$emit("moveToLeft");
    },
    getIconRight() {
      const h = this.$createElement;
      const {
        ChevronRightIcon
      } = this.useGlobalIcon({
        ChevronRightIcon: iconsVue.ChevronRightIcon
      });
      return h(ChevronRightIcon);
    },
    getIconLeft() {
      const h = this.$createElement;
      const {
        ChevronLeftIcon
      } = this.useGlobalIcon({
        ChevronLeftIcon: iconsVue.ChevronLeftIcon
      });
      return h(ChevronLeftIcon);
    },
    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(h, direction) {
      if (typeof this.$scopedSlots.operation === "function") {
        return this.$scopedSlots.operation({
          direction
        });
      }
      if (typeof this.operation === "function") {
        const renderContent2 = this.operation;
        return renderContent2(h, {
          direction
        });
      }
      let renderContent;
      if (Array.isArray(this.operation)) {
        const [left, right] = this.operation;
        renderContent = direction === "right" ? right : left;
      } else {
        renderContent = "";
      }
      return renderContent;
    }
  },
  render(h) {
    const {
      leftDisabled,
      rightDisabled
    } = this.$props;
    return h("div", {
      "class": `${this.componentName}__operations`
    }, [h("l-button", {
      "attrs": {
        "variant": "outline",
        "disabled": rightDisabled,
        "icon": this.getIcon("right")
      },
      "key": rightDisabled ? "right-outline" : "right-base",
      "on": {
        "click": this.moveToRight
      }
    }, [this._renderButton(h, "right")]), h("l-button", {
      "attrs": {
        "variant": "outline",
        "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
