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

import { ChevronRightIcon, ChevronLeftIcon } from '@ldesign/icons-vue';
import { Button } from '../../button/index.js';
import mixins from '../../../utils/mixins.js';
import { getClassPrefixMixins, getGlobalIconMixins } from '../../config-provider/config-receiver.js';
import '../../../utils/with-install.js';
import 'vue';
import 'lodash';
import '../../../config.js';
import '../../button/button.js';
import '../../loading/index.js';
import '../../loading/loading.js';
import '../../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../../chunks/index.js';
import '../../../chunks/log.js';
import '../../../chunks/_commonjsHelpers-2e6815bd.js';
import '../../../utils/easing.js';
import '../../../utils/render-node.js';
import '../../../utils/transfer-dom.js';
import '../../loading/props.js';
import '../../loading/icon/gradient.js';
import '../../../chunks/defineProperty-838e4192.js';
import '../../../chunks/set-style.js';
import '../../../chunks/helper2.js';
import 'lodash/mergeWith';
import '../../config-provider/context.js';
import '../../../chunks/zh_CN.js';
import '../../config-provider/type.js';
import '../../loading/style/css.js';
import '../../loading/type.js';
import '../../loading/plugin.js';
import '../../../utils/ripple.js';
import '../../button/props.js';
import '../../button/style/css.js';
import '../../button/type.js';

const classPrefixMixins = getClassPrefixMixins("transfer");
var TransferOperations = mixins(classPrefixMixins, getGlobalIconMixins()).extend({
  name: "LTransferOperations",
  props: {
    leftDisabled: {
      type: Boolean,
      required: true
    },
    rightDisabled: {
      type: Boolean,
      required: true
    },
    operation: {
      type: [String, Array, Function, Boolean]
    }
  },
  components: {
    LButton: Button
  },
  methods: {
    moveToRight() {
      this.$emit("moveToRight");
    },
    moveToLeft() {
      this.$emit("moveToLeft");
    },
    getIconRight() {
      const h = this.$createElement;
      const {
        ChevronRightIcon: ChevronRightIcon$1
      } = this.useGlobalIcon({
        ChevronRightIcon: ChevronRightIcon
      });
      return h(ChevronRightIcon$1);
    },
    getIconLeft() {
      const h = this.$createElement;
      const {
        ChevronLeftIcon: ChevronLeftIcon$1
      } = this.useGlobalIcon({
        ChevronLeftIcon: ChevronLeftIcon
      });
      return h(ChevronLeftIcon$1);
    },
    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")])]);
  }
});

export { TransferOperations as default };
//# sourceMappingURL=transfer-operations.js.map
