UNPKG

vxe-pc-ui

Version:
1 lines • 27.3 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _vue=require("vue"),_comp=require("../../ui/src/comp"),_xeUtils=_interopRequireDefault(require("xe-utils")),_ui=require("../../ui"),_vn=require("../../ui/src/vn"),_log=require("../../ui/src/log"),_dom=require("../../ui/src/dom"),_util=require("./util"),_button=_interopRequireDefault(require("../../button/src/button"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var _default=exports.default=(0,_comp.defineVxeComponent)({name:"VxeUpload",props:{modelValue:[Array,String,Object],showList:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.showList},moreConfig:Object,readonly:{type:Boolean,default:null},disabled:{type:Boolean,default:null},autoSubmit:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.autoSubmit},mode:{type:String,default:()=>(0,_ui.getConfig)().upload.mode},imageTypes:{type:Array,default:()=>_xeUtils.default.clone((0,_ui.getConfig)().upload.imageTypes,!0)},imageConfig:{type:Object,default:()=>_xeUtils.default.clone((0,_ui.getConfig)().upload.imageConfig,!0)},imageStyle:{type:Object,default:()=>_xeUtils.default.clone((0,_ui.getConfig)().upload.imageStyle,!0)},fileTypes:{type:Array,default:()=>_xeUtils.default.clone((0,_ui.getConfig)().upload.fileTypes,!0)},dragSort:Boolean,dragToUpload:{type:Boolean,default:()=>_xeUtils.default.clone((0,_ui.getConfig)().upload.dragToUpload,!0)},pasteToUpload:{type:Boolean,default:()=>_xeUtils.default.clone((0,_ui.getConfig)().upload.pasteToUpload,!0)},keyField:String,singleMode:Boolean,urlMode:Boolean,multiple:Boolean,limitSize:{type:[String,Number],default:()=>(0,_ui.getConfig)().upload.limitSize},showLimitSize:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.showLimitSize},limitSizeText:{type:[String,Number,Function],default:()=>(0,_ui.getConfig)().upload.limitSizeText},limitCount:{type:[String,Number],default:()=>(0,_ui.getConfig)().upload.limitCount},showLimitCount:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.showLimitCount},limitCountText:{type:[String,Number,Function],default:()=>(0,_ui.getConfig)().upload.limitCountText},nameField:{type:String,default:()=>(0,_ui.getConfig)().upload.nameField},typeField:{type:String,default:()=>(0,_ui.getConfig)().upload.typeField},urlField:{type:String,default:()=>(0,_ui.getConfig)().upload.urlField},sizeField:{type:String,default:()=>(0,_ui.getConfig)().upload.sizeField},showErrorStatus:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.showErrorStatus},showProgress:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.showProgress},progressText:{type:[String,Number,Function],default:()=>(0,_ui.getConfig)().upload.progressText},showSubmitButton:Boolean,autoHiddenButton:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.autoHiddenButton},showUploadButton:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.showUploadButton},buttonText:{type:[String,Number,Function],default:()=>(0,_ui.getConfig)().upload.buttonText},buttonIcon:{type:String,default:()=>(0,_ui.getConfig)().upload.buttonIcon},showButtonText:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.showButtonText},showButtonIcon:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.showButtonIcon},showRemoveButton:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.showRemoveButton},showDownloadButton:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.showDownloadButton},showPreview:{type:Boolean,default:()=>(0,_ui.getConfig)().upload.showPreview},showTip:{type:Boolean,default:()=>null},maxSimultaneousUploads:{type:Number,default:()=>(0,_ui.getConfig)().upload.maxSimultaneousUploads},tipText:[String,Number,Function],hintText:String,previewMethod:Function,uploadMethod:Function,beforeRemoveMethod:Function,removeMethod:Function,beforeDownloadMethod:Function,downloadMethod:Function,getUrlMethod:Function,getThumbnailUrlMethod:Function,size:{type:String,default:()=>(0,_ui.getConfig)().upload.size||(0,_ui.getConfig)().size}},emits:["update:modelValue","add","remove","remove-fail","download","download-fail","upload-success","upload-error","sort-dragend"],setup(U,e){const{emit:u,slots:E}=e,M=(0,_vue.inject)("$xeForm",null),T=(0,_vue.inject)("xeFormItemInfo",null),i=(0,_vue.inject)("$xeTable",null);var t=_xeUtils.default.uniqueId();const I=(0,_ui.useSize)(U)["computeSize"],g=(0,_vue.ref)(),v=(0,_vue.ref)(),m=(0,_vue.ref)(),c=(0,_vue.ref)(),D=(0,_vue.reactive)({isDragUploadStatus:!1,showMorePopup:!1,isActivated:!1,fileList:[],fileCacheMaps:{},isDragMove:!1,dragIndex:-1,dragTipText:""}),r={imagePreviewTypes:["jpg","jpeg","png","gif"],prevDragIndex:-1},a={refElem:g},S=(0,_vue.computed)(()=>{var e=U["readonly"];return null===e?!!M&&M.props.readonly:e}),B=(0,_vue.computed)(()=>{var e=U["disabled"];return null===e?!!M&&M.props.disabled:e}),L=(0,_vue.computed)(()=>U.keyField||"_X_KEY"),_=(0,_vue.computed)(()=>"image"===U.mode),P=(0,_vue.computed)(()=>U.nameField||"name"),F=(0,_vue.computed)(()=>U.typeField||"type"),A=(0,_vue.computed)(()=>U.urlField||"url"),O=(0,_vue.computed)(()=>U.sizeField||"size"),G=(0,_vue.computed)(()=>1024*_xeUtils.default.toNumber(U.limitSize)*1024),V=(0,_vue.computed)(()=>U.multiple?_xeUtils.default.toNumber(U.limitCount):1),C=(0,_vue.computed)(()=>{var e=U["multiple"],t=D["fileList"],o=V.value;return e?!o||t.length>=o:1<=t.length}),H=(0,_vue.computed)(()=>{var e=_xeUtils.default.toNumber(U.limitSize);return e?1048576<e?e/1048576+"T":1024<e?e/1024+"G":e+"M":""}),b=(0,_vue.computed)(()=>{var{showTip:e,tipText:t}=U;return _xeUtils.default.isBoolean(e)||(e=(0,_ui.getConfig)().upload.showTip,_xeUtils.default.isBoolean(e))?e:!!t}),Y=(0,_vue.computed)(()=>{var{limitSize:e,fileTypes:t,multiple:o,limitCount:i}=U,a=U.tipText||U.hintText,l=_.value,u=H.value;return _xeUtils.default.isString(a)?a:_xeUtils.default.isFunction(a)?""+a({}):(a=[],l?(o&&i&&a.push((0,_ui.getI18n)("vxe.upload.imgCountHint",[i])),e&&u&&a.push((0,_ui.getI18n)("vxe.upload.imgSizeHint",[u]))):(t&&t.length&&a.push((0,_ui.getI18n)("vxe.upload.fileTypeHint",[t.join("/")])),e&&u&&a.push((0,_ui.getI18n)("vxe.upload.fileSizeHint",[u])),o&&i&&a.push((0,_ui.getI18n)("vxe.upload.fileCountHint",[i]))),a.join((0,_ui.getI18n)("vxe.base.comma")))}),l=(0,_vue.computed)(()=>Object.assign({},U.imageConfig||U.imageStyle)),Q=(0,_vue.computed)(()=>{var{width:e,height:t}=l.value,o={};return e&&(o.width=(0,_dom.toCssUnit)(e)),t&&(o.height=(0,_dom.toCssUnit)(t)),o}),X=(0,_vue.computed)(()=>Object.assign({showMoreButton:!0},U.moreConfig)),d={},z={xID:t,props:U,context:e,reactData:D,internalData:r,getRefMaps:()=>a,getComputeMaps:()=>d},N=()=>_xeUtils.default.uniqueId(),j=e=>{return e[L.value]},s=()=>{var{modelValue:e,multiple:t}=U,o=S.value;const a=L.value,l=P.value,u=F.value,n=A.value,r=O.value;e=e?(e?_xeUtils.default.isArray(e)?e:[e]:[]).map(e=>{if(!e||_xeUtils.default.isString(e)){var t=""+(e||""),o=_xeUtils.default.parseUrl(e);const i=(o?o.searchQuery[l]:"")||decodeURIComponent(""+(t||"")).split("/").pop()||"";return{[l]:i,[u]:(o?o.searchQuery[u]:"")||k(i),[n]:t,[r]:_xeUtils.default.toNumber(o?o.searchQuery[r]:0)||0,[a]:N()}}const i=e[l]||"";return e[l]=i,e[u]=e[u]||k(i),e[n]=e[n]||"",e[r]=e[r]||0,e[a]=e[a]||N(),e}):[];D.fileList=o||t?e:e.slice(0,1)},k=e=>{var t=e.lastIndexOf(".");return 0<t?e.substring(t+1).toLowerCase():""},R=(e,t,o)=>{u(e,(0,_ui.createEvent)(o,{$upload:z},t))},$=e=>{var{singleMode:t,urlMode:o}=U;const i=A.value,a=P.value;let l=e?e.slice(0):[];o&&(l=l.map(e=>{var t=e[i];if(t&&!_xeUtils.default.parseUrl(t).searchQuery[a])return""+t+(-1===t.indexOf("?")?"?":"&")+a+"="+encodeURIComponent(e[a]||"");return t})),u("update:modelValue",t?l[0]||null:l)},W=e=>{var t=U.getThumbnailUrlMethod||(0,_ui.getConfig)().upload.getThumbnailUrlMethod;return t?t({$upload:z,option:e}):n(e)},n=e=>{var t=U.getUrlMethod||(0,_ui.getConfig)().upload.getUrlMethod,o=A.value;return t?t({$upload:z,option:e}):e[o]},K=(e,t)=>{var o=U.previewMethod||(0,_ui.getConfig)().upload.previewMethod;if(U.showPreview)if(o)o({$upload:z,option:t});else{var i=t;var{imageTypes:o,showDownloadButton:t}=U;const l=F.value,u=U.beforeDownloadMethod||(0,_ui.getConfig)().upload.beforeDownloadMethod;var a=r["imagePreviewTypes"];a.concat(o||[]).some(e=>(""+e).toLowerCase()===(""+i[l]).toLowerCase())&&_ui.VxeUI.previewImage&&_ui.VxeUI.previewImage({urlList:[n(i)],showDownloadButton:t,beforeDownloadMethod:u?()=>u({$upload:z,option:i}):void 0})}},J=(e,t,o)=>{var i=U["showDownloadButton"];const a=D["fileList"],l=U.beforeDownloadMethod||(0,_ui.getConfig)().upload.beforeDownloadMethod;U.showPreview&&_ui.VxeUI.previewImage&&_ui.VxeUI.previewImage({urlList:a.map(e=>n(e)),activeIndex:o,showDownloadButton:i,beforeDownloadMethod:l?({index:e})=>l({$upload:z,option:a[e]}):void 0})},q=(o,e)=>{const i=U["showErrorStatus"],a=j(o);var t=U.uploadMethod||(0,_ui.getConfig)().upload.uploadMethod;return t?Promise.resolve(t({$upload:z,file:e,option:o,updateProgress(e){var t=D["fileCacheMaps"],t=t[j(o)];t&&(t.percent=Math.max(0,Math.min(99,_xeUtils.default.toNumber(e))))}})).then(e=>{var t=D["fileCacheMaps"],t=t[a];t&&(t.percent=100,t.status="success"),Object.assign(o,e),R("upload-success",{option:o,data:e},null)}).catch(e=>{var t=D["fileCacheMaps"],t=t[a];t&&(t.status="error"),i?Object.assign(o,e):D.fileList=D.fileList.filter(e=>j(e)!==a),R("upload-error",{option:o,data:e},null)}).finally(()=>{var e=D["fileCacheMaps"],e=e[a];e&&(e.loading=!1)}):(t=D["fileCacheMaps"],(e=t[a])&&(e.loading=!1),Promise.resolve())},Z=e=>{const{uploadMethod:t,urlMode:o}=U;var i,a=D["fileCacheMaps"],a=a[j(e)];(t||(0,_ui.getConfig)().upload.uploadMethod)&&a&&(i=a.file,a.loading=!0,a.status="pending",a.percent=0,q(e,i).then(()=>{o&&$(D.fileList)}))},p=(t,i)=>{const{multiple:e,urlMode:o,showLimitSize:a,limitSizeText:l,showLimitCount:u,limitCountText:n,autoSubmit:r}=U;var d=D["fileList"];const s=U.uploadMethod||(0,_ui.getConfig)().upload.uploadMethod,p=L.value,v=P.value,g=F.value,m=A.value,c=O.value;var _=G.value;const f=V.value;var h=H.value;let x=t;if(e&&f){if(u&&d.length>=f)return void(_ui.VxeUI.modal&&_ui.VxeUI.modal.notification({title:(0,_ui.getI18n)("vxe.modal.errTitle"),status:"error",content:n?""+(_xeUtils.default.isFunction(n)?n({maxCount:f}):n):(0,_ui.getI18n)("vxe.upload.overCountErr",[f])}));const C=x.length-(f-d.length);if(u&&0<C){const b=x.slice(f-d.length);n?_ui.VxeUI.modal.notification({title:(0,_ui.getI18n)("vxe.modal.errTitle"),status:"error",content:""+(_xeUtils.default.isFunction(n)?n({maxCount:f}):n)}):_ui.VxeUI.modal&&_ui.VxeUI.modal.notification({title:(0,_ui.getI18n)("vxe.modal.errTitle"),status:"error",width:null,slots:{default(){return(0,_vue.h)("div",{class:"vxe-upload--file-message-over-error"},[(0,_vue.h)("div",{},(0,_ui.getI18n)("vxe.upload.overCountExtraErr",[f,C])),(0,_vue.h)("div",{class:"vxe-upload--file-message-over-extra"},b.map((e,t)=>(0,_vue.h)("div",{key:t,class:"vxe-upload--file-message-over-extra-item"},e.name)))])}}})}x=x.slice(0,f-d.length)}if(a&&_)for(let e=0;e<t.length;e++)if(t[0].size>_)return void(_ui.VxeUI.modal&&_ui.VxeUI.modal.notification({title:(0,_ui.getI18n)("vxe.modal.errTitle"),status:"error",content:l?""+(_xeUtils.default.isFunction(l)?l({maxSize:_}):l):(0,_ui.getI18n)("vxe.upload.overSizeErr",[h])}));const y=Object.assign({},D.fileCacheMaps),w=e?d:[],I=[];x.forEach(e=>{var t=e["name"],o=N(),t={[v]:t,[g]:k(t),[c]:e.size,[m]:URL.createObjectURL(e),[p]:o},o=(s&&(y[o]={file:e,loading:!!r,status:"pending",percent:0}),(0,_vue.reactive)(t));s&&r&&I.push(q(o,e)),w.push(o),R("add",{option:o},i)}),D.fileList=w,D.fileCacheMaps=y,Promise.all(o?I:[]).then(()=>{$(w),M&&T&&M.triggerItemEvent(i,T.itemConfig.field,w)})},ee=t=>{var{multiple:e,imageTypes:o,fileTypes:i}=U,a=B.value,l=_.value;return a?Promise.resolve({status:!1,files:[],file:null}):(0,_util.readLocalFile)({multiple:e,types:l?o:i}).then(e=>(p(e.files,t),e))},te=e=>{ee(e).catch(()=>{})},oe=(e,t,o)=>{var i=D["fileList"];i.splice(o,1),$(i),M&&T&&M.triggerItemEvent(e,T.itemConfig.field,i),R("remove",{option:t},e)},ie=(t,o,i)=>{var e=U.beforeRemoveMethod||(0,_ui.getConfig)().upload.beforeRemoveMethod;const a=U.removeMethod||(0,_ui.getConfig)().upload.removeMethod;Promise.resolve(!e||e({$upload:z,option:o})).then(e=>{e?a?Promise.resolve(a({$upload:z,option:o})).then(()=>{oe(t,o,i)}).catch(e=>e):oe(t,o,i):R("remove-fail",{option:o},t)})},ae=(e,t)=>{R("download",{option:t},e)},le=(t,o)=>{var e=U.beforeDownloadMethod||(0,_ui.getConfig)().upload.beforeDownloadMethod;const i=U.downloadMethod||(0,_ui.getConfig)().upload.downloadMethod;Promise.resolve(!e||e({$upload:z,option:o})).then(e=>{e?i?Promise.resolve(i({$upload:z,option:o})).then(()=>{ae(t,o)}).catch(e=>e):ae(t,o):R("download-fail",{option:o},t)})},ue=e=>{var t,o,i,a=e.currentTarget,{clientX:e,clientY:l}=e;a&&({x:a,y:t,height:o,width:i}=a.getBoundingClientRect(),e<a||a+i<e||l<t||t+o<l)&&(D.isDragUploadStatus=!1)},ne=e=>{var t=e.dataTransfer;t&&(t=t["items"],t)&&t.length&&(e.preventDefault(),D.isDragUploadStatus=!0)},re=(e,t)=>{const{imageTypes:o,fileTypes:i}=U;var a=r["imagePreviewTypes"];if(_.value){const l=a.concat(o&&o.length?o:[]);t=t.filter(e=>{const t=(""+(e.type.split("/")[1]||"")).toLowerCase();return!!l.some(e=>(""+e).toLowerCase()===t)})}else if(i&&i.length){const u=[];if(t.forEach(e=>{const t=k(e.name);i.some(e=>(""+e).toLowerCase()===t)||u.push(t)}),u.length)return void(_ui.VxeUI.modal&&_ui.VxeUI.modal.message({content:(0,_ui.getI18n)("vxe.error.notType",[u.join(", ")]),status:"error"}))}t.length?p(t,e):_ui.VxeUI.modal&&_ui.VxeUI.modal.notification({title:(0,_ui.getI18n)("vxe.modal.errTitle"),status:"error",content:(0,_ui.getI18n)("vxe.upload.uploadTypeErr")})},de=e=>{var t=e.dataTransfer;t&&(t=t["items"],t)&&t.length&&(e.preventDefault(),(t=se(t)).length)&&re(e,t),D.isDragUploadStatus=!1},se=e=>{const t=[];return _xeUtils.default.arrayEach(e,e=>{e=e.getAsFile();e&&t.push(e)}),t},f=()=>{const s=S.value,p=_.value;_ui.VxeUI.modal&&_ui.VxeUI.modal.open({title:s?(0,_ui.getI18n)("vxe.upload.morePopup.readTitle"):(0,_ui.getI18n)("vxe.upload.morePopup."+(p?"imageTitle":"fileTitle")),width:660,height:500,escClosable:!0,showMaximize:!0,resize:!0,maskClosable:!0,slots:{default(){var{showErrorStatus:e,dragToUpload:t,dragSort:o}=U,{isActivated:i,isDragMove:a,isDragUploadStatus:l,dragIndex:u}=D;const n=D["fileList"];var r=B.value,d={};return t&&-1===u&&(d.onDragover=ne,d.onDragleave=ue,d.onDrop=de),(0,_vue.h)("div",Object.assign({ref:v,class:["vxe-upload--more-popup",{"is--readonly":s,"is--disabled":r,"is--active":i,"show--error":e,"is--drag":l}]},d),[p?o?(0,_vue.h)(_vue.TransitionGroup,{name:"vxe-upload--drag-list"+(a?"":"-disabled"),tag:"div",class:"vxe-upload--image-more-list"},{default:()=>y(n,!0).concat(w(!0))}):(0,_vue.h)("div",{class:"vxe-upload--image-more-list"},y(n,!0).concat(w(!0))):(0,_vue.h)("div",{class:"vxe-upload--file-more-list"},[x(!0),o?(0,_vue.h)(_vue.TransitionGroup,{name:"vxe-upload--drag-list"+(a?"":"-disabled"),tag:"div",class:"vxe-upload--file-list"},{default:()=>h(n,!1)}):(0,_vue.h)("div",{class:"vxe-upload--file-list"},h(n,!0))]),o?(0,_vue.h)("div",{ref:c,class:"vxe-upload--drag-line"}):(0,_ui.renderEmptyElement)(z),l?(0,_vue.h)("div",{class:"vxe-upload--drag-placeholder"},(0,_ui.getI18n)("vxe.upload.dragPlaceholder")):(0,_ui.renderEmptyElement)(z)])}},onShow(){D.showMorePopup=!0},onHide(){D.showMorePopup=!1}})},pe=(e,t,o)=>{var i,a=D["showMorePopup"],l=g.value,u=v.value,u=a?u:l;u&&(l=u.getBoundingClientRect(),u=m.value,i=c.value,a=a?i:u)&&(i=t.getBoundingClientRect(),a.style.display="block",a.style.top=Math.max(1,i.y-l.y)+"px",a.style.left=Math.max(1,i.x-l.x)+"px",a.style.height=i.height+"px",a.style.width=i.width-1+"px",a.setAttribute("drag-pos",o))},ve=e=>{e.stopPropagation(),e.dataTransfer&&e.dataTransfer.setDragImage((0,_dom.getTpImg)(),0,0);const t=e.currentTarget;e=t.parentElement,e=_xeUtils.default.findIndexOf(Array.from(e.children),e=>t===e);D.isDragMove=!0,D.dragIndex=e,setTimeout(()=>{D.isDragMove=!1},500)},ge=t=>{t.stopPropagation(),t.preventDefault();var o=D["dragIndex"];if(-1!==o){var i=_.value;const l=t.currentTarget;var a=l.parentElement,a=_xeUtils.default.findIndexOf(Array.from(a.children),e=>l===e);let e="";e=i?t.clientX-l.getBoundingClientRect().x<l.clientWidth/2?"left":"right":t.clientY-l.getBoundingClientRect().y<l.clientHeight/2?"top":"bottom",o===a?pe(0,l,e):(pe(0,l,e),r.prevDragIndex=a,r.prevDragPos=e)}},me=e=>{var{fileList:t,dragIndex:o}=D,{prevDragIndex:i,prevDragPos:a}=r,l="bottom"===a||"right"===a?1:0,u=t[o];const n=t[i];u&&n&&(t.splice(o,1),i=_xeUtils.default.findIndexOf(t,e=>n===e)+l,t.splice(i,0,u),R("sort-dragend",{oldItem:u,newItem:n,dragPos:a,offsetIndex:l,_index:{newIndex:i,oldIndex:o}},e)),t=m.value,u=c.value,t&&(t.style.display=""),u&&(u.style.display=""),D.dragIndex=-1},ce=e=>{i&&e.stopPropagation(),D.isActivated=!0},_e=e=>{var t=U["pasteToUpload"],o=D["isActivated"];o&&t&&(o=e.clipboardData||e.originalEvent.clipboardData)&&(t=o["items"],t)&&(o=se(t)).length&&(e.preventDefault(),re(e,o))},fe=e=>{var t=g.value,o=v.value;let i=(0,_dom.getEventTargetNode)(e,t).flag;!i&&o&&(o=(t=o.parentElement||o)&&t.parentElement,i=(0,_dom.getEventTargetNode)(e,o).flag),D.isActivated=i},he=()=>{D.isActivated=!1};t={dispatchEvent:R,choose(){return ee(null)},submit(i){var e=U["maxSimultaneousUploads"],e=_xeUtils.default.toNumber(e||1)||1;const{fileList:t,fileCacheMaps:a}=D,o=t.filter(e=>{e=j(e),e=a[e];return e&&("pending"===e.status||i&&"error"===e.status)}),l=e=>{var t=j(e),t=a[t];if(t){var o=t.file;if(o&&("pending"===t.status||i&&"error"===t.status))return t.loading=!0,t.percent=0,q(e,o).then(u)}return u()},u=()=>{var e;return o.length?(e=o[0],o.splice(0,1),l(e).then(u)):Promise.resolve()};return Promise.all(o.splice(0,e).map(l)).then(()=>{})}};Object.assign(z,t,{});const h=(e,r)=>{const{showRemoveButton:d,showDownloadButton:s,showProgress:p,progressText:v,showPreview:g,showErrorStatus:m,dragSort:c,autoSubmit:_,showSubmitButton:f}=U,h=D["fileCacheMaps"],x=B.value,y=S.value,w=P.value,I=F.value,C=E.corner,b={};return c&&1<e.length&&(b.onDragstart=ve,b.onDragover=ge,b.onDragend=me),e.map((t,o)=>{var e=j(t),i=h[e];let a=!1,l=!1,u=!1;var n=""+(t[w]||"");return i&&(a=i.loading,l="error"===i.status,u="pending"===i.status),(0,_vue.h)("div",Object.assign({key:c?e:o,class:["vxe-upload--file-item",{"is--preview":g,"is--loading":a,"is--pending":u,"is--error":l}],fileid:e,draggable:!!c||null},b),[(0,_vue.h)("div",{class:"vxe-upload--file-item-icon"},[(0,_vue.h)("i",{class:(0,_ui.getIcon)()["UPLOAD_FILE_TYPE_"+(""+t[I]).toLocaleUpperCase()]||(0,_ui.getIcon)().UPLOAD_FILE_TYPE_DEFAULT})]),(0,_vue.h)("div",{class:"vxe-upload--file-item-name",title:n,onClick(e){a||l||K(e,t)}},n),a?(0,_vue.h)("div",{class:"vxe-upload--file-item-loading-icon"},[(0,_vue.h)("i",{class:(0,_ui.getIcon)().UPLOAD_LOADING})]):(0,_ui.renderEmptyElement)(z),p&&a&&i?(0,_vue.h)("div",{class:"vxe-upload--file-item-loading-text"},v?_xeUtils.default.toFormatString(""+(_xeUtils.default.isFunction(v)?v({}):v),{percent:i.percent}):(0,_ui.getI18n)("vxe.upload.uploadProgress",[i.percent])):(0,_ui.renderEmptyElement)(z),!a&&(l&&m||u&&f&&!_)?(0,_vue.h)("div",{class:"vxe-upload--file-item-rebtn"},[(0,_vue.h)(_button.default,{icon:l?(0,_ui.getIcon)().UPLOAD_IMAGE_RE_UPLOAD:(0,_ui.getIcon)().UPLOAD_IMAGE_UPLOAD,mode:"text",status:"primary",content:l?(0,_ui.getI18n)("vxe.upload.reUpload"):(0,_ui.getI18n)("vxe.upload.manualUpload"),onClick(){Z(t)}})]):(0,_ui.renderEmptyElement)(z),(0,_vue.h)("div",{class:"vxe-upload--file-item-btn-wrapper"},[C?(0,_vue.h)("div",{class:"vxe-upload--file-item-corner"},(0,_vn.getSlotVNs)(C({option:t,isMoreView:r,readonly:y}))):(0,_ui.renderEmptyElement)(z),!s||a||u?(0,_ui.renderEmptyElement)(z):(0,_vue.h)("div",{class:"vxe-upload--file-item-download-btn",onClick(e){le(e,t)}},[(0,_vue.h)("i",{class:(0,_ui.getIcon)().UPLOAD_FILE_DOWNLOAD})]),!d||y||x||a?(0,_ui.renderEmptyElement)(z):(0,_vue.h)("div",{class:"vxe-upload--file-item-remove-btn",onClick(e){ie(e,t,o)}},[(0,_vue.h)("i",{class:(0,_ui.getIcon)().UPLOAD_FILE_REMOVE})])])])})},x=e=>{var{showUploadButton:t,buttonText:o,buttonIcon:i,showButtonText:a,showButtonIcon:l,autoHiddenButton:u}=U,n=B.value,r=S.value,d=b.value,s=Y.value,p=C.value,v=E.default,g=E.tip||E.hint;return r||!t?(0,_ui.renderEmptyElement)(z):(0,_vue.h)("div",{class:"vxe-upload--file-action"},[u&&p?(0,_ui.renderEmptyElement)(z):(0,_vue.h)("div",{class:"vxe-upload--file-action-btn",onClick:te},v?(0,_vn.getSlotVNs)(v({$upload:z})):[(0,_vue.h)(_button.default,{class:"vxe-upload--file-action-button",content:e||a?o?""+(_xeUtils.default.isFunction(o)?o({}):o):(0,_ui.getI18n)("vxe.upload.fileBtnText"):"",icon:l?i||(0,_ui.getIcon)().UPLOAD_FILE_ADD:"",disabled:n})]),d&&(s||g)?(0,_vue.h)("div",{class:"vxe-upload--file-action-tip"},g?(0,_vn.getSlotVNs)(g({$upload:z})):""+s):(0,_ui.renderEmptyElement)(z)])},y=(e,n)=>{const{showRemoveButton:r,showProgress:d,progressText:s,showPreview:p,showErrorStatus:v,dragSort:g,autoSubmit:m,showSubmitButton:c}=U,_=D["fileCacheMaps"],f=B.value,h=S.value,x=l.value,y=Q.value,w=E.corner,I={onMousedown:ce};return g&&1<e.length&&(I.onDragstart=ve,I.onDragover=ge,I.onDragend=me),e.map((t,o)=>{var e=j(t),i=_[e];let a=!1,l=!1,u=!1;return i&&(a=i.loading,l="error"===i.status,u="pending"===i.status),(0,_vue.h)("div",Object.assign({key:g?e:o,class:["vxe-upload--image-item",{"is--preview":p,"is--circle":x.circle,"is--loading":a,"is--pending":u,"is--error":l}],fileid:e,draggable:!!g||null},I),[(0,_vue.h)("div",{class:"vxe-upload--image-item-box",style:n?null:y,onClick(e){a||l||J(e,t,o)}},[a&&i?(0,_vue.h)("div",{class:"vxe-upload--image-item-loading"},[(0,_vue.h)("div",{class:"vxe-upload--image-item-loading-icon"},[(0,_vue.h)("i",{class:(0,_ui.getIcon)().UPLOAD_LOADING})]),d?(0,_vue.h)("div",{class:"vxe-upload--image-item-loading-text"},s?_xeUtils.default.toFormatString(""+(_xeUtils.default.isFunction(s)?s({}):s),{percent:i.percent}):(0,_ui.getI18n)("vxe.upload.uploadProgress",[i.percent])):(0,_ui.renderEmptyElement)(z)]):(0,_ui.renderEmptyElement)(z),(0,_vue.h)("div",{class:"vxe-upload--image-item-img-wrapper",title:(0,_ui.getI18n)("vxe.upload.viewItemTitle")},[(0,_vue.h)("img",{class:"vxe-upload--image-item-img",src:W(t)})]),!a&&(l&&v||u&&c&&!m)?(0,_vue.h)("div",{class:"vxe-upload--image-item-rebtn"},[(0,_vue.h)(_button.default,{icon:l?(0,_ui.getIcon)().UPLOAD_IMAGE_RE_UPLOAD:(0,_ui.getIcon)().UPLOAD_IMAGE_UPLOAD,mode:"text",status:"primary",content:l?(0,_ui.getI18n)("vxe.upload.reUpload"):(0,_ui.getI18n)("vxe.upload.manualUpload"),onClick(){Z(t)}})]):(0,_ui.renderEmptyElement)(z),(0,_vue.h)("div",{class:"vxe-upload--image-item-btn-wrapper",onClick(e){e.stopPropagation()}},[w?(0,_vue.h)("div",{class:"vxe-upload--file-item-corner"},(0,_vn.getSlotVNs)(w({option:t,isMoreView:n,readonly:h}))):(0,_ui.renderEmptyElement)(z),!r||h||f||a?(0,_ui.renderEmptyElement)(z):(0,_vue.h)("div",{class:"vxe-upload--image-item-remove-btn",onClick(e){e.stopPropagation(),ie(e,t,o)}},[(0,_vue.h)("i",{class:(0,_ui.getIcon)().UPLOAD_IMAGE_REMOVE})])])])])})},w=e=>{var{showUploadButton:t,buttonText:o,buttonIcon:i,showButtonText:a,showButtonIcon:l,autoHiddenButton:u}=U,n=S.value,r=b.value,d=Y.value,s=C.value,p=Q.value,v=E.default,g=E.tip||E.hint;return n||!t||u&&s?(0,_ui.renderEmptyElement)(z):(0,_vue.h)("div",{key:"action",class:"vxe-upload--image-action"},[(0,_vue.h)("div",{class:"vxe-upload--image-action-btn",onClick:te},v?v({$upload:z}):[(0,_vue.h)("div",{class:"vxe-upload--image-action-box",style:e?null:p},[l?(0,_vue.h)("div",{class:"vxe-upload--image-action-icon"},[(0,_vue.h)("i",{class:i||(0,_ui.getIcon)().UPLOAD_IMAGE_ADD})]):(0,_ui.renderEmptyElement)(z),e||a?(0,_vue.h)("div",{class:"vxe-upload--image-action-content"},o?""+(_xeUtils.default.isFunction(o)?o({}):o):(0,_ui.getI18n)("vxe.upload.imgBtnText")):(0,_ui.renderEmptyElement)(z),r&&(d||g)?(0,_vue.h)("div",{class:"vxe-upload--image-action-hint"},g?(0,_vn.getSlotVNs)(g({$upload:z})):""+d):(0,_ui.renderEmptyElement)(z)])])])};const o=(0,_vue.ref)(0);return(0,_vue.watch)(()=>U.modelValue?U.modelValue.length:0,()=>{o.value++}),(0,_vue.watch)(()=>U.modelValue,()=>{o.value++}),(0,_vue.watch)(o,()=>{s()}),(0,_vue.onMounted)(()=>{U.multiple&&U.singleMode&&(0,_log.errLog)("vxe.error.errConflicts",["multiple","single-mode"]),U.imageStyle&&(0,_log.warnLog)("vxe.error.delProp",["image-style","image-config"]),U.dragSort&&(0,_dom.initTpImg)(),_ui.globalEvents.on(z,"paste",_e),_ui.globalEvents.on(z,"mousedown",fe),_ui.globalEvents.on(z,"blur",he)}),(0,_vue.onUnmounted)(()=>{D.isDragUploadStatus=!1,_ui.globalEvents.off(z,"paste"),_ui.globalEvents.off(z,"mousedown"),_ui.globalEvents.off(z,"blur")}),s(),z.renderVN=()=>{var{showErrorStatus:e,dragToUpload:t,pasteToUpload:o,dragSort:i}=U,{isDragUploadStatus:a,showMorePopup:l,isActivated:u,dragIndex:n}=D,r=I.value,d=B.value,s=S.value,p=_.value,v={onMousedown:ce};return t&&-1===n&&(v.onDragover=ne,v.onDragleave=ue,v.onDrop=de),(0,_vue.h)("div",Object.assign({ref:g,class:["vxe-upload",{["size--"+r]:r,"is--active":u,"is--readonly":s,"is--disabled":d,"is--paste":o,"show--error":e,"is--drag":a}]},v),[(p?()=>{var{showList:e,dragSort:t}=U;const{fileList:o,isDragMove:i}=D,{maxCount:a,showMoreButton:l}=X.value;let u=o,n=0;return a&&o.length>a&&(n=o.length-a,u=o.slice(0,a)),(0,_vue.h)("div",{key:"image",class:"vxe-upload--image-wrapper"},e?[t?(0,_vue.h)(_vue.TransitionGroup,{name:"vxe-upload--drag-list"+(i?"":"-disabled"),tag:"div",class:"vxe-upload--image-list"},{default:()=>y(u,!1).concat([l&&n?(0,_vue.h)("div",{key:"om",class:"vxe-upload--image-over-more"},[(0,_vue.h)(_button.default,{mode:"text",content:(0,_ui.getI18n)("vxe.upload.moreBtnText",[o.length]),status:"primary",onClick:f})]):(0,_ui.renderEmptyElement)(z),w(!1)])}):(0,_vue.h)("div",{class:"vxe-upload--image-list"},y(u,!1).concat([l&&n?(0,_vue.h)("div",{class:"vxe-upload--image-over-more"},[(0,_vue.h)(_button.default,{mode:"text",content:(0,_ui.getI18n)("vxe.upload.moreBtnText",[o.length]),status:"primary",onClick:f})]):(0,_ui.renderEmptyElement)(z),w(!1)]))]:[(0,_vue.h)("div",{class:"vxe-upload--image-list"},[w(!1)])])}:()=>{var{showList:e,moreConfig:t,dragSort:o}=U,{fileList:i,isDragMove:a}=D,{maxCount:l,showMoreButton:u,layout:n}=X.value,n="horizontal"===n;let r=i,d=0;return l&&i.length>l&&(d=i.length-l,r=i.slice(0,l)),(0,_vue.h)("div",{key:"all",class:"vxe-upload--file-wrapper"},e?[u&&t&&n?(0,_ui.renderEmptyElement)(z):x(!0),r.length||u&&n?(0,_vue.h)("div",{class:["vxe-upload--file-list-wrapper",{"is--horizontal":n}]},[r.length?o?(0,_vue.h)(_vue.TransitionGroup,{name:"vxe-upload--drag-list"+(a?"":"-disabled"),tag:"div",class:"vxe-upload--file-list"},{default:()=>h(r,!1)}):(0,_vue.h)("div",{class:"vxe-upload--file-list"},h(r,!1)):(0,_ui.renderEmptyElement)(z),u&&d?(0,_vue.h)("div",{class:"vxe-upload--file-over-more"},[(0,_vue.h)(_button.default,{mode:"text",content:(0,_ui.getI18n)("vxe.upload.moreBtnText",[i.length]),status:"primary",onClick:f})]):(0,_ui.renderEmptyElement)(z),u&&t&&n?x(!1):(0,_ui.renderEmptyElement)(z)]):(0,_ui.renderEmptyElement)(z)]:[x(!1)])})(),i?(0,_vue.h)("div",{ref:m,class:"vxe-upload--drag-line"}):(0,_ui.renderEmptyElement)(z),a&&!l?(0,_vue.h)("div",{class:"vxe-upload--drag-placeholder"},(0,_ui.getI18n)("vxe.upload.dragPlaceholder")):(0,_ui.renderEmptyElement)(z)])},z},render(){return this.renderVN()}});