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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { AddIcon, DeleteIcon, BrowseIcon } from 'tdesign-icons-vue';
import { Loading } from '../loading/index.js';
import props from './props.js';
import { prefix } from '../config.js';
import ClASSNAMES from '../utils/classnames.js';
import mixins from '../utils/mixins.js';
import getConfigReceiverMixins from '../config-provider/config-receiver.js';
import '../loading/loading.js';
import 'vue';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/set-style.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../utils/render-tnode.js';
import '@babel/runtime/helpers/typeof';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/index.js';
import '../loading/type.js';
import '../loading/plugin.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../config-provider/type.js';

var uploadName = "".concat(prefix, "-upload");
var ImageCard = mixins(getConfigReceiverMixins("upload")).extend({
  name: "TImageUpload",
  components: {
    AddIcon: AddIcon,
    DeleteIcon: DeleteIcon,
    BrowseIcon: BrowseIcon,
    TLoading: Loading
  },
  props: {
    showUploadProgress: props.showUploadProgress,
    files: {
      type: Array
    },
    loadingFile: {
      type: Object
    },
    trigger: {
      type: Function
    },
    remove: {
      type: Function
    },
    multiple: Boolean,
    max: Number,
    disabled: Boolean
  },
  computed: {
    showTrigger: function showTrigger() {
      if (this.multiple) {
        return !this.max || this.files.length < this.max;
      }

      return !(this.files && this.files[0]);
    }
  },
  methods: {
    onMaskClick: function onMaskClick(e) {
      !this.showTrigger && this.trigger(e);
    },
    onViewClick: function onViewClick(e, file) {
      this.$emit("imgPreview", e, file);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    return h("ul", {
      "class": "".concat(uploadName, "__card")
    }, [this.files && this.files.map(function (file, index) {
      return h("li", {
        "class": "".concat(uploadName, "__card-item ").concat(prefix, "-is--background")
      }, [h("div", {
        "class": "".concat(uploadName, "__card-content ").concat(uploadName, "__card-box")
      }, [h("img", {
        "class": "".concat(uploadName, "__card-image"),
        "attrs": {
          "src": file.url
        }
      }), h("div", {
        "class": "".concat(uploadName, "__card-mask"),
        "on": {
          "click": _this.onMaskClick
        }
      }, [h("span", {
        "class": "".concat(uploadName, "__card-mask-item"),
        "on": {
          "click": function click(e) {
            return e.stopPropagation();
          }
        }
      }, [h(BrowseIcon, {
        "nativeOn": {
          "click": function click(e) {
            return _this.onViewClick(e, file);
          }
        }
      })]), !_this.disabled && [h("span", {
        "class": "".concat(uploadName, "__card-mask-item-divider"),
        "key": "divider"
      }), h("span", {
        "class": "".concat(uploadName, "__card-mask-item"),
        "on": {
          "click": function click(e) {
            return e.stopPropagation();
          }
        },
        "key": "delete-icon"
      }, [h(DeleteIcon, {
        "nativeOn": {
          "click": function click(e) {
            return _this.remove({
              e: e,
              file: file,
              index: index
            });
          }
        }
      })])]])])]);
    }), this.showTrigger && h("li", {
      "class": ["".concat(uploadName, "__card-item ").concat(prefix, "-is--background"), _defineProperty({}, ClASSNAMES.STATUS.disabled, this.disabled)],
      "on": {
        "click": this.trigger
      }
    }, [this.showUploadProgress && this.loadingFile && this.loadingFile.status === "progress" ? h("div", {
      "class": "".concat(uploadName, "__card-container ").concat(uploadName, "__card-box")
    }, [h(Loading), h("p", [this.global.progress.uploadingText, " ", Math.min(this.loadingFile.percent, 99), "%"])]) : h("div", {
      "class": "".concat(uploadName, "__card-container ").concat(uploadName, "__card-box")
    }, [h(AddIcon), h("p", {
      "class": "".concat(prefix, "-size-s")
    }, [this.global.triggerUploadText.image])])])]);
  }
});

export { ImageCard as default, uploadName };
//# sourceMappingURL=image.js.map
