UNPKG

@progress/kendo-vue-upload

Version:
9 lines (8 loc) 4.14 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),p=require("@progress/kendo-vue-common"),g=require("@progress/kendo-vue-intl"),S=require("@progress/kendo-vue-progressbars"),n=require("./messages/main.js"),f=require("./utils/utils.js"),h=require("./UploadListActionButton.js"),t=require("@progress/kendo-svg-icons"),I=s.defineComponent({name:"KendoVueUploadListSingleItem",props:{files:Array,disabled:Boolean,async:Object},emits:{cancel:null,retry:null,remove:null},inject:{kendoLocalizationService:{default:null}},methods:{onRetry(e){this.$emit("retry",e)},onRemove(e){this.$emit("remove",e)},onCancel(e){this.$emit("cancel",e)},getFileExtension(e){return e.extension?e.extension.substring(1):""},getFileValidationMessage(e,r){const o=g.provideLocalizationService(this);let a="";if(r)a=o.toLanguageString(n.statusUploadFailed,n.messages[n.statusUploadFailed]);else if(e.validationErrors&&e.validationErrors.length>0){const c=`upload.${e.validationErrors[0]}`;a=o.toLanguageString(c,n.messages[c])}return a},getFileExtensionName(e){switch(e.extension){case".png":case".jpg":case".jpeg":case".tiff":case".bmp":case".gif":return"file-image";case".mp3":case".mp4":case".wav":return"file-audio";case".mkv":case".webm":case".flv":case".gifv":case".avi":case".wmv":return"file-video";case".txt":return"file-txt";case".pdf":return"file-pdf";case".ppt":case".pptx":return"file-presentation";case".csv":case".xls":case".xlsx":return"file-data";case".html":case".css":case".js":case".ts":return"file-programming";case".exe":return"file-config";case".zip":case".rar":return"file-zip";default:return"file"}},getFileExtensionSVG(e){switch(e.extension){case".png":case".jpg":case".jpeg":case".tiff":case".bmp":case".gif":return t.fileImageIcon;case".mp3":case".mp4":case".wav":return t.fileAudioIcon;case".mkv":case".webm":case".flv":case".gifv":case".avi":case".wmv":return t.fileVideoIcon;case".txt":return t.fileTxtIcon;case".pdf":return t.filePdfIcon;case".ppt":case".pptx":return t.filePresentationIcon;case".csv":case".xls":case".xlsx":return t.fileDataIcon;case".html":case".css":case".js":case".ts":return t.fileProgrammingIcon;case".exe":return t.fileConfigIcon;case".zip":case".rar":return t.fileZipIcon;default:return t.fileIcon}}},setup(){return{kendoLocalizationService:s.inject("kendoLocalizationService",{})}},render(){const{files:e,disabled:r,async:o}=this.$props,a=e[0],c=p.classNames("k-file-single"),[,m,l,d]=f.getFileStatus([a]),v=!d&&!m&&!l,x=function(i,u){return s.createVNode("span",{class:"k-file-info",key:"2"},[s.createVNode("span",{class:"k-file-name",title:i.name},[i.name]),s.createVNode("span",{class:"k-file-validation-message"},[this.getFileValidationMessage(i,u)])])},V=function(i){const k=g.provideLocalizationService(this).toLanguageString(n.statusUploaded,n.messages[n.statusUploaded]);return s.createVNode("span",{class:"k-file-info",key:"2"},[s.createVNode("span",{class:"k-file-name",title:i.name},[i.name]),i.progress!==100?s.createVNode("span",{class:"k-file-size"},[f.getTotalFilesSizeMessage([i])]):s.createVNode("span",{class:"k-file-validation-message"},[k])])};return s.createVNode("div",{class:c},[v&&s.createVNode(S.ProgressBar,{value:a.progress||0,labelVisible:!1},null),s.createVNode("span",{class:"k-file-icon-wrapper",key:"1"},[s.createVNode(p.Icon,{name:this.getFileExtensionName(a),icon:this.getFileExtensionSVG(a),size:"xxxlarge",class:"k-file-icon"},null),s.createVNode("span",{class:"k-file-state"},null)]),d||l?x.call(this,a,l):V.call(this,a),s.createVNode(h.UploadListActionButton,{uid:a.uid,status:a.status,progress:a.progress,files:e,disabled:r,async:o,onCancel:this.onCancel,onRemove:this.onRemove,onRetry:this.onRetry},null)])}});exports.UploadListSingleItem=I;