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

import { AddIcon, DeleteIcon, BrowseIcon } from '@ldesign/icons-vue';
import { Loading } from '../loading/index.js';
import props from './props.js';
import mixins from '../../utils/mixins.js';
import getConfigReceiverMixins, { getGlobalIconMixins } from '../config-provider/config-receiver.js';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import 'vue';
import '../../chunks/defineProperty-56324511.js';
import '../../chunks/set-style.js';
import '../../chunks/helper2.js';
import '../../config.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/render-node.js';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../utils/transfer-dom.js';
import '../loading/props.js';
import 'lodash/mergeWith';
import 'lodash';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../../utils/with-install.js';
import '../loading/style/css.js';
import '../loading/type.js';
import '../loading/plugin.js';

var LImageCard = mixins(getConfigReceiverMixins("upload"), getGlobalIconMixins()).extend({
  name: "LImageUpload",
  components: {
    TLoading: Loading
  },
  props: {
    showUploadProgress: props.showUploadProgress,
    files: {
      type: Array
    },
    loadingFile: {
      type: Object
    },
    trigger: {
      type: Function
    },
    remove: {
      type: Function
    },
    multiple: Boolean,
    max: Number,
    disabled: Boolean,
    locale: Object
  },
  computed: {
    showTrigger() {
      if (this.multiple) {
        return !this.max || this.files.length < this.max;
      }

      return !(this.files && this.files[0]);
    }

  },
  methods: {
    onMaskClick(e) {
      !this.showTrigger && this.trigger(e);
    },

    onViewClick(e, file) {
      this.$emit("imgPreview", e, file);
    }

  },

  render() {
    var _this$locale, _this$locale$progress, _this$locale2, _this$locale2$trigger;

    const h = arguments[0];
    const {
      AddIcon: AddIcon$1,
      DeleteIcon: DeleteIcon$1,
      BrowseIcon: BrowseIcon$1
    } = this.useGlobalIcon({
      AddIcon: AddIcon,
      DeleteIcon: DeleteIcon,
      BrowseIcon: BrowseIcon
    });
    return h("ul", {
      "class": `${this.componentName}__card`
    }, [this.files && this.files.map((file, index) => h("li", {
      "class": `${this.componentName}__card-item ${this.classPrefix}-is--background`
    }, [h("div", {
      "class": `${this.componentName}__card-content ${this.componentName}__card-box`
    }, [h("img", {
      "class": `${this.componentName}__card-image`,
      "attrs": {
        "src": file.url
      }
    }), h("div", {
      "class": `${this.componentName}__card-mask`,
      "on": {
        "click": this.onMaskClick
      }
    }, [h("span", {
      "class": `${this.componentName}__card-mask-item`,
      "on": {
        "click": e => e.stopPropagation()
      }
    }, [h(BrowseIcon$1, {
      "nativeOn": {
        "click": e => this.onViewClick(e, file)
      }
    })]), !this.disabled && [h("span", {
      "class": `${this.componentName}__card-mask-item-divider`,
      "key": "divider"
    }), h("span", {
      "class": `${this.componentName}__card-mask-item`,
      "on": {
        "click": e => e.stopPropagation()
      },
      "key": "delete-icon"
    }, [h(DeleteIcon$1, {
      "nativeOn": {
        "click": e => this.remove({
          e,
          file,
          index
        })
      }
    })])]])])])), this.showTrigger && h("li", {
      "class": [`${this.componentName}__card-item`, `${this.classPrefix}-is--background`, {
        [this.commonStatusClassName.disabled]: this.disabled
      }],
      "on": {
        "click": this.trigger
      }
    }, [this.showUploadProgress && this.loadingFile && this.loadingFile.status === "progress" ? h("div", {
      "class": `${this.componentName}__card-container ${this.componentName}__card-box`
    }, [h(Loading), h("p", [((_this$locale = this.locale) === null || _this$locale === void 0 ? void 0 : (_this$locale$progress = _this$locale.progress) === null || _this$locale$progress === void 0 ? void 0 : _this$locale$progress.uploadingText) || this.global.progress.uploadingText, " ", Math.min(this.loadingFile.percent, 99), "%"])]) : h("div", {
      "class": `${this.componentName}__card-container ${this.componentName}__card-box`
    }, [h(AddIcon$1), h("p", {
      "class": `${this.classPrefix}-size-s`
    }, [((_this$locale2 = this.locale) === null || _this$locale2 === void 0 ? void 0 : (_this$locale2$trigger = _this$locale2.triggerUploadText) === null || _this$locale2$trigger === void 0 ? void 0 : _this$locale2$trigger.image) || this.global.triggerUploadText.image])])])]);
  }

});

export { LImageCard as default };
//# sourceMappingURL=image.js.map
