/**
 * ldesign v0.2.2
 * (c) 2022年9月20日 swimly
 * @license MIT
 */

'use strict';

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

var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
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('../../button/button.js');
require('@babel/runtime/helpers/defineProperty');
require('../../loading/index.js');
require('../../loading/loading.js');
require('../../loading/icon/gradient.js');
require('vue');
require('../../../chunks/defineProperty-28395935.js');
require('../../../chunks/set-style.js');
require('../../../chunks/helper2.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../../../config.js');
require('../../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../../utils/easing.js');
require('../../../utils/render-node.js');
require('@babel/runtime/helpers/typeof');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../../../utils/transfer-dom.js');
require('../../loading/props.js');
require('lodash/mergeWith');
require('lodash');
require('../../config-provider/context.js');
require('../../../chunks/zh_CN.js');
require('../../../utils/with-install.js');
require('../../loading/plugin.js');
require('../../button/props.js');
require('../../../utils/ripple.js');

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

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

var 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: function moveToRight() {
      this.$emit("moveToRight");
    },
    moveToLeft: function moveToLeft() {
      this.$emit("moveToLeft");
    },
    getIconRight: function getIconRight() {
      var h = this.$createElement;

      var _this$useGlobalIcon = this.useGlobalIcon({
        ChevronRightIcon: iconsVue.ChevronRightIcon
      }),
          ChevronRightIcon = _this$useGlobalIcon.ChevronRightIcon;

      return h(ChevronRightIcon);
    },
    getIconLeft: function getIconLeft() {
      var h = this.$createElement;

      var _this$useGlobalIcon2 = this.useGlobalIcon({
        ChevronLeftIcon: iconsVue.ChevronLeftIcon
      }),
          ChevronLeftIcon = _this$useGlobalIcon2.ChevronLeftIcon;

      return h(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(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
