vue-devui 1.0.0-rc.7 → 1.0.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/alert/index.es.js +37 -11
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.es.js +62 -26
- package/auto-complete/index.umd.js +5 -5
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +32 -6
- package/avatar/index.umd.js +1 -1
- package/avatar/style.css +1 -1
- package/badge/index.es.js +27 -3
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +5548 -77
- package/button/index.umd.js +27 -1
- package/button/style.css +1 -1
- package/card/index.es.js +34 -13
- package/card/index.umd.js +1 -1
- package/card/style.css +1 -1
- package/checkbox/index.es.js +47 -29
- package/checkbox/index.umd.js +1 -1
- package/checkbox/style.css +1 -1
- package/date-picker/index.es.js +90 -138
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/drawer/index.es.js +28 -3
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +36 -12
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/form/index.es.js +208 -73
- package/form/index.umd.js +12 -12
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +28 -4
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/grid/index.es.js +68 -49
- package/grid/index.umd.js +1 -1
- package/grid/style.css +1 -1
- package/image-preview/index.es.js +34 -11
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/input/index.es.js +90 -138
- package/input/index.umd.js +1 -1
- package/input/style.css +1 -1
- package/layout/index.es.js +34 -6
- package/layout/index.umd.js +1 -1
- package/layout/style.css +1 -1
- package/loading/index.es.js +34 -10
- package/loading/index.umd.js +1 -1
- package/loading/style.css +1 -1
- package/modal/index.es.js +41 -15
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +40 -13
- package/notification/index.umd.js +1 -1
- package/notification/style.css +1 -1
- package/nuxt/components/ButtonGroup.js +3 -0
- package/nuxt/components/buttonGroupInjectionKey.js +3 -0
- package/nuxt/components/buttonGroupProps.js +3 -0
- package/overlay/index.es.js +31 -9
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +1 -1
- package/pagination/index.es.js +59 -32
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/popover/index.es.js +53 -24
- package/popover/index.umd.js +13 -13
- package/popover/style.css +1 -1
- package/progress/index.es.js +31 -9
- package/progress/index.umd.js +3 -3
- package/progress/style.css +1 -1
- package/radio/index.es.js +32 -7
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +32 -8
- package/rate/index.umd.js +1 -1
- package/rate/style.css +1 -1
- package/search/index.es.js +100 -146
- package/search/index.umd.js +13 -13
- package/search/style.css +1 -1
- package/select/index.es.js +74 -51
- package/select/index.umd.js +1 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +37 -12
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.es.js +34 -10
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +52 -24
- package/splitter/index.umd.js +15 -15
- package/splitter/style.css +1 -1
- package/status/index.es.js +26 -2
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/style.css +1 -1
- package/switch/index.es.js +30 -6
- package/switch/index.umd.js +1 -1
- package/switch/style.css +1 -1
- package/table/index.es.js +5710 -265
- package/table/index.umd.js +27 -1
- package/table/style.css +1 -1
- package/tabs/index.es.js +32 -8
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +27 -2
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/textarea/index.es.js +93 -76
- package/textarea/index.umd.js +1 -1
- package/textarea/style.css +1 -1
- package/tooltip/index.es.js +41 -14
- package/tooltip/index.umd.js +12 -12
- package/tooltip/style.css +1 -1
- package/tree/index.es.js +60 -51
- package/tree/index.umd.js +1 -1
- package/tree/style.css +1 -1
- package/upload/index.es.js +53 -22
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +3703 -3560
- package/vue-devui.umd.js +20 -20
package/upload/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Oe=Object.defineProperty,Pe=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable;var O=(p,e,V)=>e in p?Oe(p,e,{enumerable:!0,configurable:!0,writable:!0,value:V}):p[e]=V,P=(p,e)=>{for(var V in e||(e={}))ze.call(e,V)&&O(p,V,e[V]);if(X)for(var V of X(e))Ie.call(e,V)&&O(p,V,e[V]);return p},G=(p,e)=>Pe(p,$e(e));var w=(p,e,V)=>(O(p,typeof e!="symbol"?e+"":e,V),V);(function(p,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(p=typeof globalThis!="undefined"?globalThis:p||self,e(p.index={},p.Vue))})(this,function(p,e){"use strict";const V={modelValue:{type:Boolean,default:!1},title:{type:String,default:""},type:{type:String,default:"normal"},duration:{type:Number,default:3e3},onClose:{type:Function}},Y={name:{type:String,default:"",required:!0},size:{type:String,default:"inherit"},color:{type:String,default:"inherit"},classPrefix:{type:String,default:"icon"}};var J=e.defineComponent({name:"DIcon",props:Y,setup(t){const{name:n,size:o,color:s,classPrefix:a}=e.toRefs(t);return()=>/^((https?):)?\/\//.test(n.value)?e.createVNode("img",{src:n.value,alt:n.value.split("/")[n.value.split("/").length-1],style:{width:o.value,verticalAlign:"text-bottom"}},null):e.createVNode("i",{class:`${a.value} ${a.value}-${n.value}`,style:{fontSize:o.value,color:s.value}},null)}}),K=e.defineComponent({emits:["click"],setup(t,{emit:n}){return()=>e.createVNode("div",{class:"devui-notification-icon-close",onClick:o=>n("click",o)},[e.createVNode(J,{name:"close",size:"14px"},null)])}});function Q(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("defs",null,[e.createVNode("polygon",{id:"path-s",points:"6.53553391 9.77817459 12.1923882 4.12132034 13.6066017 5.53553391 6.53553391 12.6066017 3 9.07106781 4.41421356 7.65685425 6.53553391 9.77817459"},null)]),e.createVNode("g",{id:"correct",stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("mask",{id:"mask-2",fill:"white"},[e.createVNode("use",{"xlink:href":"#path-s"},null)]),e.createVNode("use",{id:"Mask",class:"devui-notification-image-success-path","xlink:href":"#path-s"},null)])])}function U(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("path",{class:"devui-icon-warning-outer",d:"M8.96244623,0.57254229 L15.8714442,13.4101975 C16.1549662,13.9370117 15.9538562,14.5918482 15.4222523,14.8728158 C15.2642579,14.9563203 15.0879506,15 14.9088903,15 L1.09089441,15 C0.488410063,15 0,14.5159904 0,13.9189343 C0,13.7414873 0.0440768395,13.5667684 0.128340519,13.4101975 L7.03733844,0.57254229 C7.32086049,0.0457280838 7.98165058,-0.153569987 8.51325441,0.127397589 C8.70423071,0.228333932 8.8605922,0.383286648 8.96244623,0.57254229 Z"},null),e.createVNode("path",{class:"devui-icon-warning-inner","stroke-width":"0.3","fill-rule":"nonzero",d:"M8.87894737,13 L7.08947368,13 L7.08947368,11.2105263 L8.87894737,11.2105263 L8.87894737,13 Z M8.62102372,9.86842105 L7.32800539,9.86842105 L7,4.5 L8.96842105,4.5 L8.62102372,9.86842105 Z"},null)])])}function ee(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("g",{id:"info",stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("path",{class:"devui-notification-image-info-path",d:"M7,13 L7,6 L9,6 L9,13 L7,13 Z M7,5 L7,3 L9,3 L9,5 L7,5 Z",id:"info"},null)])])}function te(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("defs",null,[e.createVNode("polygon",{id:"path-e",points:"8.07106781 6.65685425 10.8994949 3.82842712 12.3137085 5.24264069 9.48528137 8.07106781 12.3137085 10.8994949 10.8994949 12.3137085 8.07106781 9.48528137 5.24264069 12.3137085 3.82842712 10.8994949 6.65685425 8.07106781 3.82842712 5.24264069 5.24264069 3.82842712"},null)]),e.createVNode("g",{id:"error",stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("mask",{id:"mask-2",fill:"white"},[e.createVNode("use",{"xlink:href":"#path-e"},null)]),e.createVNode("use",{id:"Mask",class:"devui-notification-image-error-path","xlink:href":"#path-e"},null)])])}var ne=e.defineComponent({props:{type:{type:String,default:"normal"}},setup(t){const{type:n}=e.toRefs(t),o=e.computed(()=>({"devui-notification-image":!0,[`devui-notification-image-${n.value}`]:!0}));return()=>e.createVNode("span",{class:o.value},[n.value&&n.value!=="normal"&&(n.value==="success"&&e.createVNode(Q,null,null)||n.value==="info"&&e.createVNode(ee,null,null)||n.value==="warning"&&e.createVNode(U,null,null)||n.value==="error"&&e.createVNode(te,null,null))])}});function oe(t){return{classes:e.computed(()=>({"devui-notification-item-container":!0,[`devui-notification-message-${t.type}`]:!0}))}}function ie(t,n){let o=null,s;const a=()=>{var k;clearTimeout(o),o=null,(k=t.onClose)==null||k.call(t),n("update:modelValue",!1)},f=()=>{o&&(clearTimeout(o),o=null)},v=()=>{if(!t.modelValue){const k=t.duration-(Date.now()-s);o=setTimeout(a,k)}},D=()=>{n("destroy")};return e.watch(()=>t.modelValue,k=>{k&&(s=Date.now(),t.duration&&(o=setTimeout(a,t.duration)))}),{interrupt:f,removeReset:v,close:a,handleDestroy:D}}var _e="",le=e.defineComponent({name:"DNotification",props:V,emits:["update:modelValue","destroy"],setup(t,{emit:n,slots:o}){const{modelValue:s,title:a,type:f}=e.toRefs(t),{classes:v}=oe(t),{interrupt:D,removeReset:k,close:u,handleDestroy:r}=ie(t,n);return()=>e.createVNode(e.Transition,{name:"notification-fade",onAfterLeave:r},{default:()=>{var m;return[s.value&&e.createVNode("div",{class:"devui-notification"},[e.createVNode("div",{class:v.value,onMouseenter:D,onMouseleave:k},[e.createVNode("div",{class:"devui-notification-item"},[e.createVNode(K,{onClick:u},null),a.value&&e.createVNode(ne,{type:f.value},null),e.createVNode("div",{class:"devui-notification-message"},[e.createVNode("span",{class:"devui-notification-title"},[a.value]),e.createVNode("span",{class:"devui-notification-content"},[(m=o.default)==null?void 0:m.call(o)])])])])])]}})}});function se(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!e.isVNode(t)}const ae={modelValue:!1,duration:3e3,type:"normal"};function re(t,n){const o=document.createElement("div"),s=e.createApp({setup(){return e.onUnmounted(()=>{document.body.removeChild(o)}),()=>e.createVNode(le,e.mergeProps(t,{onDestroy:s.unmount}),se(n)?n:{default:()=>[n]})}});return document.body.appendChild(o),s.mount(o),s}function ue(t,n){t.modelValue=!1,n==null||n()}class ce{static open(n){const o=n.onClose||null,s=n.content;let a;delete n.content;const f=e.reactive(G(P(P({},ae),n),{onClose:()=>{ue(f,o)}}));re(f,s),f.modelValue=!0,clearTimeout(a),n.duration&&(a=setTimeout(f.onClose,n.duration))}}class de{constructor(){w(this,"uri");w(this,"method");w(this,"maximumSize");w(this,"headers");w(this,"authToken");w(this,"authTokenHeader");w(this,"additionalParameter");w(this,"fileFieldName");w(this,"checkSameName");w(this,"withCredentials");w(this,"responseType")}}class pe{constructor(){w(this,"accept");w(this,"multiple");w(this,"webkitdirectory")}}var F=(t=>(t[t.preLoad=0]="preLoad",t[t.uploading=1]="uploading",t[t.uploaded=2]="uploaded",t[t.failed=3]="failed",t))(F||{});const $={accept:{type:String},webkitdirectory:{type:Boolean,default:!1},uploadOptions:{type:Object},multiple:{type:Boolean,default:!1},autoUpload:{type:Boolean,default:!0},placeholder:{type:String,default:"\u9009\u62E9\u6587\u4EF6"},modelValue:{type:Array,default:()=>[]},droppable:{type:Boolean,default:!1},beforeUpload:{type:Function},dynamicUploadOptionsFn:{type:Function},disabled:{type:Boolean,default:!1},onChange:{type:Function},fileDrop:{type:Function,default:void 0},fileOver:{type:Function,default:void 0},fileSelect:{type:Function,default:void 0},deleteUploadedFile:{type:Function,default:void 0},"on-error":{type:Function,default:void 0},"on-success":{type:Function,default:void 0},oneTimeUpload:{type:Boolean,default:!1}},fe=t=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${t}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,me=(t,n)=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${n}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${t}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,he=(t,n)=>`\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${n}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${t}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,ge=t=>`\u60A8\u4E0A\u4F20\u7684 "${t}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,Fe=()=>{const t=e.ref(""),n=u=>{const r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,0,null),u.dispatchEvent(r)},o=({multiple:u,accept:r,webkitdirectory:m})=>new Promise(C=>{const l=document.getElementById("d-upload-temp");l&&document.body.removeChild(l);const i=document.createElement("input");i.style.position="fixed",i.style.left="-2000px",i.style.top="-2000px",i.setAttribute("id","d-upload-temp"),i.setAttribute("type","file"),u&&i.setAttribute("multiple",""),r&&i.setAttribute("accept",r),m&&i.setAttribute("webkitdirectory",""),i.addEventListener("change",h=>{C(Array.prototype.slice.call(h.target.files))}),document.body.appendChild(i),n(i)}),s=(u,r)=>{if(u){const m=u.split(","),C=r.type.replace(/\/.*$/,"");return m.some(l=>{const i=l.trim();return i.startsWith(".")?r.name.toLowerCase().indexOf(i.toLowerCase(),r.name.toLowerCase().length-i.toLowerCase().length)>-1:/\/\*$/.test(i)?C===i.replace(/\/.*$/,""):r.type===i})}return!0},a=(u,r)=>r?u>1024*1024*r:!1;return{triggerSelectFiles:u=>{const{multiple:r,accept:m,webkitdirectory:C}=u;return o({multiple:r,accept:m,webkitdirectory:C})},_validateFiles:(u,r,m)=>s(r,u)?m&&a(u.size,m.maximumSize)?{checkError:!0,errorMsg:me(u.name,m.maximumSize||0)}:{checkError:!1,errorMsg:void 0}:{checkError:!0,errorMsg:he(u.name,r)},triggerDropFiles:u=>Promise.resolve(u),checkAllFilesSize:(u,r)=>{if(a(u,r))return t.value=fe(r),{checkError:!0,errorMsg:t.value}}}};class z{constructor(n,o){w(this,"xhr");w(this,"status");w(this,"response");w(this,"percentage",0);this.file=n,this.uploadOptions=o,this.file=n,this.uploadOptions=o,this.status=F.preLoad}send(n){return new Promise((o,s)=>{const{uri:a,method:f,headers:v,authToken:D,authTokenHeader:k,additionalParameter:u,fileFieldName:r,withCredentials:m,responseType:C}=this.uploadOptions||{},l=k||"Authorization",i=r||"file";this.xhr=new XMLHttpRequest,this.xhr.open(f||"POST",a||""),m&&(this.xhr.withCredentials=m),C&&(this.xhr.responseType=C),D&&this.xhr.setRequestHeader(l,D),v&&Object.keys(v).forEach(x=>{var N;(N=this.xhr)==null||N.setRequestHeader(x,v[x])}),this.xhr.upload.onprogress=x=>{this.percentage=Math.round(x.loaded*100/x.total)};const h=n&&n.length?this.oneTimeUploadFiles(i,u,n):this.parallelUploadFiles(i,u);this.xhr.send(h),this.status=F.uploading,this.xhr.onabort=()=>{this.status=F.preLoad,this.xhr=null},this.xhr.onerror=()=>{var x,N;this.response=(x=this.xhr)==null?void 0:x.response,this.status=F.failed,s({file:this.file,response:(N=this.xhr)==null?void 0:N.response})},this.xhr.onload=()=>{var x,N,S;((x=this.xhr)==null?void 0:x.readyState)===4&&this.xhr.status>=200&&this.xhr.status<300?(this.response=this.xhr.response,this.status=F.uploaded,o({file:this.file,response:this.xhr.response})):(this.response=(N=this.xhr)==null?void 0:N.response,this.status=F.failed,s({file:this.file,response:(S=this.xhr)==null?void 0:S.response}))}})}parallelUploadFiles(n,o){const s=new FormData;return s.append(n,this.file,this.file.name),o&&Object.keys(o).forEach(a=>{s.append(a,o[a])}),s}oneTimeUploadFiles(n,o,s){const a=new FormData;return s.forEach(f=>{a.append(n,f.file,f.file.name),o&&Object.keys(o).forEach(v=>{a.append(v,o[v])})}),a}cancel(){this.xhr&&this.xhr.abort()}}const ve=()=>{const t=e.ref([]),n=e.ref([]),o=l=>{let i=!0;for(let h=0;h<t.value.length;h++)if(l===t.value[h].file.name){i=!1,n.value.indexOf(l)===-1&&n.value.push(l);break}return i},s=(l,i)=>{i&&i.checkSameName?o(l.name)&&t.value.push(new z(l,i)):t.value.push(new z(l,i))},a=()=>t.value.map(l=>l.file),f=()=>t.value.map(l=>l),v=async l=>{if(!l||!l.length)return Promise.reject("no files");let i=[];return await l[0].send(l).finally(()=>i=l.map(h=>(h.status=l[0].status,h.percentage=l[0].percentage,{file:h.file,response:l[0].response}))),i};return{fileUploaders:t,getFiles:a,addFile:s,getFullFiles:f,deleteFile:l=>{const i=t.value.find(h=>h.file===l);i==null||i.cancel(),t.value=t.value.filter(h=>l!==h.file)},upload:async l=>{let i=[];if(l){l.percentage=0;const h=await l.send();i.push(h)}else{const h=t.value.filter(S=>S.status===F.preLoad),x=t.value.filter(S=>S.status===F.failed),N=h.length>0?h:x;i=await Promise.all(N.map(async S=>(S.percentage=0,await S.send())))}return i.length>0?Promise.resolve(i):Promise.reject("no files")},removeFiles:()=>{t.value=[],n.value=[]},getSameNameFiles:()=>n.value.join(),resetSameNameFiles:()=>{n.value=[]},_oneTimeUpload:()=>{const l=t.value.filter(i=>i.status!==F.uploaded);return v(l)}}};var Re="",L=e.defineComponent({name:"DUpload",props:$,emits:["fileDrop","fileOver","fileSelect","deleteUploadedFile","update:modelValue"],setup(t,n){const{uploadOptions:o,placeholder:s,autoUpload:a,disabled:f,beforeUpload:v,droppable:D,oneTimeUpload:k,modelValue:u,multiple:r,accept:m,webkitdirectory:C}=e.toRefs(t),{triggerSelectFiles:l,_validateFiles:i,triggerDropFiles:h,checkAllFilesSize:x}=Fe(),{fileUploaders:N,addFile:S,getFullFiles:_,deleteFile:R,upload:Ee,resetSameNameFiles:Ce,removeFiles:A,_oneTimeUpload:Se,getSameNameFiles:De}=ve(),M=e.ref(!1),b=d=>{ce.open({type:"warning",content:d})},be=()=>{var g;let d=0;if(N.value.forEach(y=>{d+=y.file.size;const E=i(y.file,(m==null?void 0:m.value)||"",y.uploadOptions);if(E&&E.checkError){R(y.file),b(E.errorMsg);return}}),k.value){const y=x(d,((g=o==null?void 0:o.value)==null?void 0:g.maximumSize)||0);y&&y.checkError&&(A(),b(y.errorMsg))}},Le=d=>{M.value=d,n.emit("fileOver",d)},j=d=>{const g=u.value.filter(y=>y.name!==d.name);n.emit("deleteUploadedFile",d),n.emit("update:modelValue",g)},Te=(d,g,y)=>{d.stopPropagation(),y===F.uploaded&&j(g),R(g)},Ae=()=>{let d=Promise.resolve(!0);if(v==null?void 0:v.value){const g=v==null?void 0:v.value(_());typeof g!="undefined"&&(typeof g=="boolean"?d=Promise.resolve(g):d=g)}return d},H=(d,g)=>{d&&d.stopPropagation(),Ae().then(y=>{if(!y){A();return}const E=k.value?Se():Ee(g);E==null||E.then(c=>{t["on-success"]&&t["on-success"](c);const B=[...c.map(Be=>Be.file),...u.value];n.emit("update:modelValue",B)}).catch(c=>{t["on-error"]&&t["on-error"](c)})})},Z=d=>{Ce(),d.then(g=>{g.forEach(c=>{r.value||A(),S(c,o==null?void 0:o.value)}),be();const y=De();(o==null?void 0:o.value)&&o.value.checkSameName&&y.length&&b(ge(y));const E=N.value.filter(c=>c.status===F.preLoad).map(c=>c.file);n.emit("fileSelect",E),a.value&&H()}).catch(g=>{b(g.message)})},q=()=>{f.value||Z(l({accept:m==null?void 0:m.value,multiple:r.value,webkitdirectory:C.value}))},Me=d=>{M.value=!1,Z(h(d)),n.emit("fileDrop",d)};return()=>{var d,g,y,E;return e.createVNode("div",null,[e.withDirectives(e.createVNode("div",{class:"devui-upload",style:`border: ${M.value?"1px solid #15bf15":"0"}`},[((g=(d=n.slots).default)==null?void 0:g.call(d))?e.createVNode("div",{onClick:q},[n.slots.default()]):e.createVNode("div",{class:`devui-input-group ${f.value?"disabled":""}`,onClick:q},[N.value.length===0&&e.createVNode("div",{class:"devui-form-control devui-upload-placeholder"},[s.value]),N.value.length>0&&e.createVNode("ul",{class:"devui-form-control devui-files-list"},[N.value.map((c,W)=>e.createVNode("li",{key:W,class:"devui-file-item devui-file-tag",style:"display: inline-block; margin: 0 2px 2px 0",title:c.file.name},[e.createVNode("span",{class:`devui-filename ${c.status===F.failed?"devui-failed-color":""}`},[c.file.name]),e.createVNode(e.resolveComponent("d-icon"),{name:"close",class:`${(c==null?void 0:c.status)===F.failed?"devui-upload-delete-file-button":""} ${(c==null?void 0:c.status)===F.uploading||(c==null?void 0:c.status)===F.uploaded?"devui-uploading-delete":""}`,onClick:B=>Te(B,c.file,c.status)},null),c.status===F.uploading&&e.createVNode("div",{class:"icon devui-upload-progress"},[e.createVNode(e.resolveComponent("d-progress"),{isCircle:!0,percentage:c.percentage,barbgcolor:"#50D4AB",strokeWidth:8,showContent:!1},null)]),c.status===F.failed&&e.createVNode(e.resolveComponent("d-icon"),{name:"running",onClick:H},null),c.status===F.uploaded&&e.createVNode(e.resolveComponent("d-icon"),{name:"right",color:"#50d4ab"},null)]))]),e.createVNode("span",{class:"devui-input-group-addon"},[e.createVNode(e.resolveComponent("d-icon"),{name:"more-operate",color:"#252b3a"},null)])])]),[[e.resolveDirective("file-drop"),{droppable:D,isSingle:!r,onFileDrop:Me,onFileOver:Le}]]),e.createVNode("div",null,[(E=(y=n.slots)["uploaded-files"])==null?void 0:E.call(y,{uploadedFiles:u.value,deleteFile:j})])])}}});const I=t=>{var n;return t.dataTransfer?t.dataTransfer:(n=t.originalEvent)==null?void 0:n.dataTransfer},ye=t=>t?t.indexOf?t.indexOf("Files")!==-1:t.contains?t.contains("Files"):!1:!1,T=t=>{t.preventDefault(),t.stopPropagation()},we=(t,n)=>{const{onFileOver:o}=n.value;t.addEventListener("dragover",s=>{const a=I(s);!ye(a.types)||(T(s),o&&o(!0))})},Ne=(t,n)=>{const{onFileOver:o}=n.value;t.addEventListener("dragleave",s=>{s.currentTarget!==t&&(T(s),o&&o(!0))})},Ve=(t,n)=>{const{onFileDrop:o,isSingle:s}=n.value;t.addEventListener("drop",a=>{const f=I(a);!f||(T(a),s?o&&o([f.files[0]]):o&&o(Array.from(f.files)))})},ke={mounted:(t,n)=>{const{droppable:o}=n.value;!o||(we(t,n),Ne(t,n),Ve(t,n))}};var xe={title:"Upload \u4E0A\u4F20",category:"\u6570\u636E\u5F55\u5165",status:"100%",install(t){t.directive("file-drop",ke),t.component(L.name,L)}};p.IFileOptions=pe,p.IUploadOptions=de,p.Upload=L,p.UploadStatus=F,p.default=xe,p.uploadProps=$,Object.defineProperty(p,"__esModule",{value:!0}),p[Symbol.toStringTag]="Module"});
|
|
1
|
+
var je=Object.defineProperty,He=Object.defineProperties;var Ze=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var qe=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var I=(m,e,N)=>e in m?je(m,e,{enumerable:!0,configurable:!0,writable:!0,value:N}):m[e]=N,$=(m,e)=>{for(var N in e||(e={}))qe.call(e,N)&&I(m,N,e[N]);if(K)for(var N of K(e))We.call(e,N)&&I(m,N,e[N]);return m},Q=(m,e)=>He(m,Ze(e));var w=(m,e,N)=>(I(m,typeof e!="symbol"?e+"":e,N),N);(function(m,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(m=typeof globalThis!="undefined"?globalThis:m||self,e(m.index={},m.Vue))})(this,function(m,e){"use strict";const N={modelValue:{type:Boolean,default:!1},title:{type:String,default:""},type:{type:String,default:"normal"},duration:{type:Number,default:3e3},onClose:{type:Function}},U={name:{type:String,default:"",required:!0},size:{type:String,default:"inherit"},color:{type:String,default:"inherit"},classPrefix:{type:String,default:"icon"}};var ee=e.defineComponent({name:"DIcon",props:U,setup(t){const{name:n,size:o,color:a,classPrefix:i}=e.toRefs(t);return()=>/^((https?):)?\/\//.test(n.value)?e.createVNode("img",{src:n.value,alt:n.value.split("/")[n.value.split("/").length-1],style:{width:o.value,verticalAlign:"text-bottom"}},null):e.createVNode("i",{class:`${i.value} ${i.value}-${n.value}`,style:{fontSize:o.value,color:a.value}},null)}});function A(t,n,o){let a=t;return n&&(a+=`__${n}`),o&&(a+=`--${o}`),a}function D(t){const n=`devui-${t}`;return{b:()=>A(n),e:u=>u?A(n,u):"",m:u=>u?A(n,"",u):"",em:(u,E)=>u&&E?A(n,u,E):""}}var te=e.defineComponent({emits:["click"],setup(t,{emit:n}){const o=D("notification");return()=>e.createVNode("div",{class:o.e("icon-close"),onClick:a=>n("click",a)},[e.createVNode(ee,{name:"close",size:"14px"},null)])}});const L=D("notification");function ne(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("defs",null,[e.createVNode("polygon",{id:"path-s",points:"6.53553391 9.77817459 12.1923882 4.12132034 13.6066017 5.53553391 6.53553391 12.6066017 3 9.07106781 4.41421356 7.65685425 6.53553391 9.77817459"},null)]),e.createVNode("g",{id:"correct",stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("mask",{id:"mask-2",fill:"white"},[e.createVNode("use",{"xlink:href":"#path-s"},null)]),e.createVNode("use",{id:"Mask",class:L.e("image-success-path"),"xlink:href":"#path-s"},null)])])}function oe(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("path",{class:L.e("warning-outer"),d:"M8.96244623,0.57254229 L15.8714442,13.4101975 C16.1549662,13.9370117 15.9538562,14.5918482 15.4222523,14.8728158 C15.2642579,14.9563203 15.0879506,15 14.9088903,15 L1.09089441,15 C0.488410063,15 0,14.5159904 0,13.9189343 C0,13.7414873 0.0440768395,13.5667684 0.128340519,13.4101975 L7.03733844,0.57254229 C7.32086049,0.0457280838 7.98165058,-0.153569987 8.51325441,0.127397589 C8.70423071,0.228333932 8.8605922,0.383286648 8.96244623,0.57254229 Z"},null),e.createVNode("path",{class:L.e("warning-inner"),"stroke-width":"0.3","fill-rule":"nonzero",d:"M8.87894737,13 L7.08947368,13 L7.08947368,11.2105263 L8.87894737,11.2105263 L8.87894737,13 Z M8.62102372,9.86842105 L7.32800539,9.86842105 L7,4.5 L8.96842105,4.5 L8.62102372,9.86842105 Z"},null)])])}function le(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("g",{id:"info",stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("path",{class:L.e("image-info-path"),d:"M7,13 L7,6 L9,6 L9,13 L7,13 Z M7,5 L7,3 L9,3 L9,5 L7,5 Z",id:"info"},null)])])}function se(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("defs",null,[e.createVNode("polygon",{id:"path-e",points:"8.07106781 6.65685425 10.8994949 3.82842712 12.3137085 5.24264069 9.48528137 8.07106781 12.3137085 10.8994949 10.8994949 12.3137085 8.07106781 9.48528137 5.24264069 12.3137085 3.82842712 10.8994949 6.65685425 8.07106781 3.82842712 5.24264069 5.24264069 3.82842712"},null)]),e.createVNode("g",{id:"error",stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("mask",{id:"mask-2",fill:"white"},[e.createVNode("use",{"xlink:href":"#path-e"},null)]),e.createVNode("use",{id:"Mask",class:L.e("image-error-path"),"xlink:href":"#path-e"},null)])])}var ae=e.defineComponent({props:{type:{type:String,default:"normal"}},setup(t){const{type:n}=e.toRefs(t),o=D("notification"),a=e.computed(()=>({[o.e("image")]:!0,[o.em("image",n.value)]:!0}));return()=>e.createVNode("span",{class:a.value},[n.value&&n.value!=="normal"&&(n.value==="success"&&e.createVNode(ne,null,null)||n.value==="info"&&e.createVNode(le,null,null)||n.value==="warning"&&e.createVNode(oe,null,null)||n.value==="error"&&e.createVNode(se,null,null))])}});function ie(t){return{classes:e.computed(()=>({"devui-notification-item-container":!0,[`devui-notification-message-${t.type}`]:!0}))}}function re(t,n){let o=null,a;const i=()=>{var V;clearTimeout(o),o=null,(V=t.onClose)==null||V.call(t),n("update:modelValue",!1)},h=()=>{o&&(clearTimeout(o),o=null)},u=()=>{if(!t.modelValue){const V=t.duration-(Date.now()-a);o=setTimeout(i,V)}},E=()=>{n("destroy")};return e.watch(()=>t.modelValue,V=>{V&&(a=Date.now(),t.duration&&(o=setTimeout(i,t.duration)))}),{interrupt:h,removeReset:u,close:i,handleDestroy:E}}var Ge="",ue=e.defineComponent({name:"DNotification",props:N,emits:["update:modelValue","destroy"],setup(t,{emit:n,slots:o}){const{modelValue:a,title:i,type:h}=e.toRefs(t),{classes:u}=ie(t),{interrupt:E,removeReset:V,close:c,handleDestroy:r}=re(t,n),f=D("notification");return()=>e.createVNode(e.Transition,{name:"notification-fade",onAfterLeave:r},{default:()=>{var x;return[a.value&&e.createVNode("div",{class:f.b()},[e.createVNode("div",{class:u.value,onMouseenter:E,onMouseleave:V},[e.createVNode("div",{class:f.e("item")},[e.createVNode(te,{onClick:c},null),i.value&&e.createVNode(ae,{type:h.value},null),e.createVNode("div",{class:f.e("message")},[e.createVNode("span",{class:f.e("title")},[i.value]),e.createVNode("span",{class:f.e("content")},[(x=o.default)==null?void 0:x.call(o)])])])])])]}})}});function ce(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!e.isVNode(t)}const de={modelValue:!1,duration:3e3,type:"normal"};function pe(t,n){const o=document.createElement("div"),a=e.createApp({setup(){return e.onUnmounted(()=>{document.body.removeChild(o)}),()=>e.createVNode(ue,e.mergeProps(t,{onDestroy:a.unmount}),ce(n)?n:{default:()=>[n]})}});return document.body.appendChild(o),a.mount(o),a}function fe(t,n){t.modelValue=!1,n==null||n()}class me{static open(n){const o=n.onClose||null,a=n.content;let i;delete n.content;const h=e.reactive(Q($($({},de),n),{onClose:()=>{fe(h,o)}}));pe(h,a),h.modelValue=!0,clearTimeout(i),n.duration&&(i=setTimeout(h.onClose,n.duration))}}class he{constructor(){w(this,"uri");w(this,"method");w(this,"maximumSize");w(this,"headers");w(this,"authToken");w(this,"authTokenHeader");w(this,"additionalParameter");w(this,"fileFieldName");w(this,"checkSameName");w(this,"withCredentials");w(this,"responseType")}}class ge{constructor(){w(this,"accept");w(this,"multiple");w(this,"webkitdirectory")}}var y=(t=>(t[t.preLoad=0]="preLoad",t[t.uploading=1]="uploading",t[t.uploaded=2]="uploaded",t[t.failed=3]="failed",t))(y||{});const R={accept:{type:String},webkitdirectory:{type:Boolean,default:!1},uploadOptions:{type:Object},multiple:{type:Boolean,default:!1},autoUpload:{type:Boolean,default:!0},placeholder:{type:String,default:"\u9009\u62E9\u6587\u4EF6"},modelValue:{type:Array,default:()=>[]},droppable:{type:Boolean,default:!1},beforeUpload:{type:Function},dynamicUploadOptionsFn:{type:Function},disabled:{type:Boolean,default:!1},onChange:{type:Function},fileDrop:{type:Function,default:void 0},fileOver:{type:Function,default:void 0},fileSelect:{type:Function,default:void 0},deleteUploadedFile:{type:Function,default:void 0},"on-error":{type:Function,default:void 0},"on-success":{type:Function,default:void 0},oneTimeUpload:{type:Boolean,default:!1}},Fe=t=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${t}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,ye=(t,n)=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${n}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${t}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,ve=(t,n)=>`\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${n}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${t}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,we=t=>`\u60A8\u4E0A\u4F20\u7684 "${t}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,Ne=()=>{const t=e.ref(""),n=c=>{const r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,0,null),c.dispatchEvent(r)},o=({multiple:c,accept:r,webkitdirectory:f})=>new Promise(x=>{const l=document.getElementById("d-upload-temp");l&&document.body.removeChild(l);const s=document.createElement("input");s.style.position="fixed",s.style.left="-2000px",s.style.top="-2000px",s.setAttribute("id","d-upload-temp"),s.setAttribute("type","file"),c&&s.setAttribute("multiple",""),r&&s.setAttribute("accept",r),f&&s.setAttribute("webkitdirectory",""),s.addEventListener("change",g=>{x(Array.prototype.slice.call(g.target.files))}),document.body.appendChild(s),n(s)}),a=(c,r)=>{if(c){const f=c.split(","),x=r.type.replace(/\/.*$/,"");return f.some(l=>{const s=l.trim();return s.startsWith(".")?r.name.toLowerCase().indexOf(s.toLowerCase(),r.name.toLowerCase().length-s.toLowerCase().length)>-1:/\/\*$/.test(s)?x===s.replace(/\/.*$/,""):r.type===s})}return!0},i=(c,r)=>r?c>1024*1024*r:!1;return{triggerSelectFiles:c=>{const{multiple:r,accept:f,webkitdirectory:x}=c;return o({multiple:r,accept:f,webkitdirectory:x})},_validateFiles:(c,r,f)=>a(r,c)?f&&i(c.size,f.maximumSize)?{checkError:!0,errorMsg:ye(c.name,f.maximumSize||0)}:{checkError:!1,errorMsg:void 0}:{checkError:!0,errorMsg:ve(c.name,r)},triggerDropFiles:c=>Promise.resolve(c),checkAllFilesSize:(c,r)=>{if(i(c,r))return t.value=Fe(r),{checkError:!0,errorMsg:t.value}}}};class j{constructor(n,o){w(this,"xhr");w(this,"status");w(this,"response");w(this,"percentage",0);this.file=n,this.uploadOptions=o,this.file=n,this.uploadOptions=o,this.status=y.preLoad}send(n){return new Promise((o,a)=>{const{uri:i,method:h,headers:u,authToken:E,authTokenHeader:V,additionalParameter:c,fileFieldName:r,withCredentials:f,responseType:x}=this.uploadOptions||{},l=V||"Authorization",s=r||"file";this.xhr=new XMLHttpRequest,this.xhr.open(h||"POST",i||""),f&&(this.xhr.withCredentials=f),x&&(this.xhr.responseType=x),E&&this.xhr.setRequestHeader(l,E),u&&Object.keys(u).forEach(k=>{var C;(C=this.xhr)==null||C.setRequestHeader(k,u[k])}),this.xhr.upload.onprogress=k=>{this.percentage=Math.round(k.loaded*100/k.total)};const g=n&&n.length?this.oneTimeUploadFiles(s,c,n):this.parallelUploadFiles(s,c);this.xhr.send(g),this.status=y.uploading,this.xhr.onabort=()=>{this.status=y.preLoad,this.xhr=null},this.xhr.onerror=()=>{var k,C;this.response=(k=this.xhr)==null?void 0:k.response,this.status=y.failed,a({file:this.file,response:(C=this.xhr)==null?void 0:C.response})},this.xhr.onload=()=>{var k,C,S;((k=this.xhr)==null?void 0:k.readyState)===4&&this.xhr.status>=200&&this.xhr.status<300?(this.response=this.xhr.response,this.status=y.uploaded,o({file:this.file,response:this.xhr.response})):(this.response=(C=this.xhr)==null?void 0:C.response,this.status=y.failed,a({file:this.file,response:(S=this.xhr)==null?void 0:S.response}))}})}parallelUploadFiles(n,o){const a=new FormData;return a.append(n,this.file,this.file.name),o&&Object.keys(o).forEach(i=>{a.append(i,o[i])}),a}oneTimeUploadFiles(n,o,a){const i=new FormData;return a.forEach(h=>{i.append(n,h.file,h.file.name),o&&Object.keys(o).forEach(u=>{i.append(u,o[u])})}),i}cancel(){this.xhr&&this.xhr.abort()}}const Ve=()=>{const t=e.ref([]),n=e.ref([]),o=l=>{let s=!0;for(let g=0;g<t.value.length;g++)if(l===t.value[g].file.name){s=!1,n.value.indexOf(l)===-1&&n.value.push(l);break}return s},a=(l,s)=>{s&&s.checkSameName?o(l.name)&&t.value.push(new j(l,s)):t.value.push(new j(l,s))},i=()=>t.value.map(l=>l.file),h=()=>t.value.map(l=>l),u=async l=>{if(!l||!l.length)return Promise.reject("no files");let s=[];return await l[0].send(l).finally(()=>s=l.map(g=>(g.status=l[0].status,g.percentage=l[0].percentage,{file:g.file,response:l[0].response}))),s};return{fileUploaders:t,getFiles:i,addFile:a,getFullFiles:h,deleteFile:l=>{const s=t.value.find(g=>g.file===l);s==null||s.cancel(),t.value=t.value.filter(g=>l!==g.file)},upload:async l=>{let s=[];if(l){l.percentage=0;const g=await l.send();s.push(g)}else{const g=t.value.filter(S=>S.status===y.preLoad),k=t.value.filter(S=>S.status===y.failed),C=g.length>0?g:k;s=await Promise.all(C.map(async S=>(S.percentage=0,await S.send())))}return s.length>0?Promise.resolve(s):Promise.reject("no files")},removeFiles:()=>{t.value=[],n.value=[]},getSameNameFiles:()=>n.value.join(),resetSameNameFiles:()=>{n.value=[]},_oneTimeUpload:()=>{const l=t.value.filter(s=>s.status!==y.uploaded);return u(l)}}};var Xe="",B=e.defineComponent({name:"DUpload",props:R,emits:["fileDrop","fileOver","fileSelect","deleteUploadedFile","update:modelValue"],setup(t,n){const{uploadOptions:o,placeholder:a,autoUpload:i,disabled:h,beforeUpload:u,droppable:E,oneTimeUpload:V,modelValue:c,multiple:r,accept:f,webkitdirectory:x}=e.toRefs(t),l=D("upload"),s=D("input-group"),g=D("form-control"),k=D("input-group-addon"),{triggerSelectFiles:C,_validateFiles:S,triggerDropFiles:Z,checkAllFilesSize:De}=Ne(),{fileUploaders:T,addFile:Le,getFullFiles:Te,deleteFile:q,upload:Ae,resetSameNameFiles:Me,removeFiles:P,_oneTimeUpload:Be,getSameNameFiles:Oe}=Ve(),_=e.ref(!1),M=p=>{me.open({type:"warning",content:p})},Pe=()=>{var F;let p=0;if(T.value.forEach(v=>{p+=v.file.size;const b=S(v.file,(f==null?void 0:f.value)||"",v.uploadOptions);if(b&&b.checkError){q(v.file),M(b.errorMsg);return}}),V.value){const v=De(p,((F=o==null?void 0:o.value)==null?void 0:F.maximumSize)||0);v&&v.checkError&&(P(),M(v.errorMsg))}},_e=p=>{_.value=p,n.emit("fileOver",p)},W=p=>{const F=c.value.filter(v=>v.name!==p.name);n.emit("deleteUploadedFile",p),n.emit("update:modelValue",F)},ze=(p,F,v)=>{p.stopPropagation(),v===y.uploaded&&W(F),q(F)},Ie=()=>{let p=Promise.resolve(!0);if(u==null?void 0:u.value){const F=u==null?void 0:u.value(Te());typeof F!="undefined"&&(typeof F=="boolean"?p=Promise.resolve(F):p=F)}return p},G=(p,F)=>{p&&p.stopPropagation(),Ie().then(v=>{if(!v){P();return}const b=V.value?Be():Ae(F);b==null||b.then(d=>{t["on-success"]&&t["on-success"](d);const z=[...d.map(Re=>Re.file),...c.value];n.emit("update:modelValue",z)}).catch(d=>{t["on-error"]&&t["on-error"](d)})})},X=p=>{Me(),p.then(F=>{F.forEach(d=>{r.value||P(),Le(d,o==null?void 0:o.value)}),Pe();const v=Oe();(o==null?void 0:o.value)&&o.value.checkSameName&&v.length&&M(we(v));const b=T.value.filter(d=>d.status===y.preLoad).map(d=>d.file);n.emit("fileSelect",b),i.value&&G()}).catch(F=>{M(F.message)})},Y=()=>{h.value||X(C({accept:f==null?void 0:f.value,multiple:r.value,webkitdirectory:x.value}))},$e=p=>{_.value=!1,X(Z(p)),n.emit("fileDrop",p)};return()=>{var p,F,v,b;return e.createVNode("div",null,[e.withDirectives(e.createVNode("div",{class:l.b(),style:`border: ${_.value?"1px solid #15bf15":"0"}`},[((F=(p=n.slots).default)==null?void 0:F.call(p))?e.createVNode("div",{onClick:Y},[n.slots.default()]):e.createVNode("div",{class:[s.b(),h.value?"disabled":""],onClick:Y},[T.value.length===0&&e.createVNode("div",{class:[g.b(),l.e("placeholder")]},[a.value]),T.value.length>0&&e.createVNode("ul",{class:[g.b(),l.e("files-list")]},[T.value.map((d,J)=>e.createVNode("li",{key:J,class:[l.e("file-item"),l.e("file-tag")],style:"display: inline-block; margin: 0 2px 2px 0",title:d.file.name},[e.createVNode("span",{class:[l.e("filename"),d.status===y.failed?l.m("failed-color"):""]},[d.file.name]),e.createVNode(e.resolveComponent("d-icon"),{name:"close",class:[(d==null?void 0:d.status)===y.failed?l.e("delete-file-button"):"",(d==null?void 0:d.status)===y.uploading||(d==null?void 0:d.status)===y.uploaded?l.e("delete"):""],onClick:z=>ze(z,d.file,d.status)},null),d.status===y.uploading&&e.createVNode("div",{class:["icon",l.e("progress")]},[e.createVNode(e.resolveComponent("d-progress"),{isCircle:!0,percentage:d.percentage,barbgcolor:"#50D4AB",strokeWidth:8,showContent:!1},null)]),d.status===y.failed&&e.createVNode(e.resolveComponent("d-icon"),{name:"running",onClick:G},null),d.status===y.uploaded&&e.createVNode(e.resolveComponent("d-icon"),{name:"right",color:"#50d4ab"},null)]))]),e.createVNode("span",{class:k.b()},[e.createVNode(e.resolveComponent("d-icon"),{name:"more-operate",color:"#252b3a"},null)])])]),[[e.resolveDirective("file-drop"),{droppable:E,isSingle:!r,onFileDrop:$e,onFileOver:_e}]]),e.createVNode("div",null,[(b=(v=n.slots)["uploaded-files"])==null?void 0:b.call(v,{uploadedFiles:c.value,deleteFile:W})])])}}});const H=t=>{var n;return t.dataTransfer?t.dataTransfer:(n=t.originalEvent)==null?void 0:n.dataTransfer},ke=t=>t?t.indexOf?t.indexOf("Files")!==-1:t.contains?t.contains("Files"):!1:!1,O=t=>{t.preventDefault(),t.stopPropagation()},xe=(t,n)=>{const{onFileOver:o}=n.value;t.addEventListener("dragover",a=>{const i=H(a);!ke(i.types)||(O(a),o&&o(!0))})},Ee=(t,n)=>{const{onFileOver:o}=n.value;t.addEventListener("dragleave",a=>{a.currentTarget!==t&&(O(a),o&&o(!0))})},Ce=(t,n)=>{const{onFileDrop:o,isSingle:a}=n.value;t.addEventListener("drop",i=>{const h=H(i);!h||(O(i),a?o&&o([h.files[0]]):o&&o(Array.from(h.files)))})},be={mounted:(t,n)=>{const{droppable:o}=n.value;!o||(xe(t,n),Ee(t,n),Ce(t,n))}};var Se={title:"Upload \u4E0A\u4F20",category:"\u6570\u636E\u5F55\u5165",status:"100%",install(t){t.directive("file-drop",be),t.component(B.name,B)}};m.IFileOptions=ge,m.IUploadOptions=he,m.Upload=B,m.UploadStatus=y,m.default=Se,m.uploadProps=R,Object.defineProperty(m,"__esModule",{value:!0}),m[Symbol.toStringTag]="Module"});
|
package/upload/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.devui-notification{position:fixed;top:50px;right:20px;width:20em;word-break:normal;word-wrap:break-word;z-index:1060}.devui-notification a:link,.devui-notification a:visited{color:var(--devui-link-light, #96adfa)}.devui-notification a:hover,.devui-notification a:active{color:var(--devui-link-light-active, #beccfa)}.devui-notification-item-container{position:relative;margin:0 0 8px;opacity:.95;filter:alpha(opacity=95);box-shadow:var(--devui-shadow-length-feedback-overlay, 0 4px 16px 0) var(--devui-shadow, rgba(37, 43, 58, .2));border-radius:var(--devui-border-radius-feedback, 4px);color:var(--devui-feedback-overlay-text, #dfe1e6);background-color:var(--devui-feedback-overlay-bg, #464d6e)}.devui-
|
|
1
|
+
.devui-notification{position:fixed;top:50px;right:20px;width:20em;word-break:normal;word-wrap:break-word;z-index:1060}.devui-notification a:link,.devui-notification a:visited{color:var(--devui-link-light, #96adfa)}.devui-notification a:hover,.devui-notification a:active{color:var(--devui-link-light-active, #beccfa)}.devui-notification-item-container{position:relative;margin:0 0 8px;opacity:.95;filter:alpha(opacity=95);box-shadow:var(--devui-shadow-length-feedback-overlay, 0 4px 16px 0) var(--devui-shadow, rgba(37, 43, 58, .2));border-radius:var(--devui-border-radius-feedback, 4px);color:var(--devui-feedback-overlay-text, #dfe1e6);background-color:var(--devui-feedback-overlay-bg, #464d6e)}.devui-notification__item{position:relative;display:block;padding:12px 16px}.devui-notification__icon-close{position:absolute;top:7px;right:10px;cursor:pointer}.devui-notification__icon-close i.icon{color:var(--devui-light-text, #ffffff)!important}.devui-notification__title{font-size:var(--devui-font-size-card-title, 14px);padding:0 0 calc(.5em - 2px) 0;display:block;font-weight:700}.devui-notification__image{position:absolute;display:inline-block;width:16px;height:16px;border-radius:50%;left:16px;top:14px;padding:0;line-height:1}.devui-notification__image.devui-notification__image--warning path.devui-notification__warning-outer{fill:var(--devui-warning-line, #fa9841)}.devui-notification__image.devui-notification__image--warning path.devui-notification__warning-inner{fill:var(--devui-light-text, #ffffff);stroke:var(--devui-light-text, #ffffff)}.devui-notification__image.devui-notification__image--info{background-color:var(--devui-info, #5e7ce0)}.devui-notification__image.devui-notification__image--error{background-color:var(--devui-danger, #f66f6a)}.devui-notification__image.devui-notification__image--success{background-color:var(--devui-success, #50d4ab)}.devui-notification__image .devui-notification__image-info-path,.devui-notification__image .devui-notification__image-error-path,.devui-notification__image .devui-notification__image-success-path{fill:var(--devui-light-text, #ffffff)}.devui-notification__message{margin-left:20px}.devui-notification__message .devui-notification__content{font-size:var(--devui-font-size, 12px);margin-top:4px}.devui-notification-message-common .devui-notification__message{margin-left:0}.devui-notification__message p{font-size:var(--devui-font-size, 12px);margin-top:4px}.notification-fade-enter-active,.notification-fade-leave-active{transition:transform var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out, cubic-bezier(.5, .05, .5, .95))}.notification-fade-enter-from,.notification-fade-leave-to{transform:translate(100%)}.devui-input-group{position:relative;display:flex!important;align-items:center;border-collapse:separate;width:360px}.devui-input-group:not(.disabled):hover .devui-input-group-addon{border-color:var(--devui-form-control-line-active, #5e7ce0);background-color:var(--devui-dividing-line, #dfe1e6);font-weight:700}.devui-input-group:not(.disabled):hover .devui-form-control{border-color:var(--devui-form-control-line-active, #5e7ce0);border-right-color:var(--devui-form-control-line, #adb0b8)}.devui-input-group:not(.disabled) .devui-input-group-addon:active{border-color:var(--devui-form-control-line-active, #5e7ce0);border-right-color:var(--devui-form-control-line, #adb0b8);background-color:var(--devui-dividing-line, #dfe1e6)}.devui-input-group .devui-input-group-addon{width:36px;white-space:nowrap;font-size:var(--devui-font-size-icon, 16px);font-weight:400;line-height:1;color:var(--devui-text, #252b3a);background-color:var(--devui-area, #f8f8f8);border-top:1px solid var(--devui-form-control-line, #adb0b8);border-bottom:1px solid var(--devui-form-control-line, #adb0b8);border-right:1px solid var(--devui-form-control-line, #adb0b8);border-radius:0 var(--devui-border-radius, 2px) var(--devui-border-radius, 2px) 0;transition:border-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1)),background-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1));cursor:pointer;height:100%;position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center}.devui-input-group .devui-form-control{cursor:pointer;display:block;width:100%;min-height:28px;height:unset;padding:4px 8px;font-size:var(--devui-font-size, 12px);line-height:1.5;background-image:none;border:1px solid var(--devui-form-control-line, #adb0b8);border-radius:var(--devui-border-radius, 2px) 0 0 var(--devui-border-radius, 2px);transition:border-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1)),box-shadow var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1))}.devui-input-group .devui-form-control.devui-upload__files-list{max-height:52px;padding:2px 2px 0;overflow-x:hidden;overflow-y:auto;max-width:100%;margin:0}.devui-input-group .devui-form-control.devui-upload__files-list .devui-upload__file-item{height:22px;line-height:22px;padding:0 48px 0 12px}.devui-input-group .devui-form-control.devui-upload__files-list .devui-upload__file-tag{position:relative;background-color:var(--devui-label-bg, #eef0f5);border-radius:var(--devui-border-radius, 2px);max-width:100%}.devui-input-group .devui-form-control.devui-upload__files-list .devui-upload__file-tag .devui-upload__filename{height:100%;display:inline-block;vertical-align:middle;max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.devui-input-group .devui-form-control.devui-upload__files-list .devui-upload__file-tag .icon{position:absolute;cursor:pointer;right:8px;top:50%;transform:translateY(-50%)}.devui-input-group .devui-form-control.devui-upload__files-list .devui-upload__file-tag .icon.icon-right{color:var(--devui-success, #50d4ab)}.devui-input-group .devui-form-control.devui-upload__files-list .devui-upload__file-tag .icon.icon-running{font-size:16px}.devui-input-group .devui-form-control.devui-upload__files-list .devui-upload__file-tag .icon.devui-upload__delete-file-button{margin-right:20px}.devui-input-group .devui-form-control.devui-upload__files-list .devui-upload__file-tag .icon.devui-upload__delete,.devui-input-group .devui-form-control.devui-upload__files-list .devui-upload__file-tag:hover .devui-upload__progress,.devui-input-group .devui-form-control.devui-upload__files-list .devui-upload__file-tag:hover .icon-right{display:none}.devui-input-group .devui-form-control.devui-upload__files-list .devui-upload__file-tag:hover .icon-close{display:inline-block}.devui-input-group.disabled .devui-upload__placeholder{color:var(--devui-disabled-text, #adb0b8)}.devui-input-group .devui-upload__placeholder{max-height:28px;max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--devui-placeholder, #8a8e99)}.devui-input-group .devui-upload__progress{width:16px;height:16px}.devui-input-group.disabled .devui-form-control,.devui-input-group.disabled .devui-input-group-addon{cursor:not-allowed;background-color:var(--devui-disabled-bg, #f5f5f6);border-color:var(--devui-disabled-line, #dfe1e6);color:var(--devui-disabled-text, #adb0b8)}.devui-form-control{outline:none}.devui-input-group.disabled .devui-upload__delete-file-button{cursor:not-allowed;pointer-events:none}.devui-loading{color:var(--devui-aide-text, #8a8e99)}.devui-upload--failed-color{color:var(--devui-danger, #f66f6a)}.devui-upload{display:flex}.devui-upload-tip{height:18px;margin-top:8px;font-size:12px}.devui-upload-tip .icon{margin-right:8px;font-size:16px;vertical-align:middle}.devui-upload-tip .icon-right-o{color:var(--devui-success, #50d4ab)}.devui-upload-tip .devui-upload-failed{color:var(--devui-danger, #f66f6a)}.devui-upload-tip a{color:var(--devui-link, #526ecc);cursor:pointer}
|