@ccn-ui-kit/upload 0.1.2
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/dist/index.cjs +1 -0
- package/dist/index.js +512 -0
- package/dist/packages/components/__tests__/loading.spec.d.ts +1 -0
- package/dist/packages/components/badge/index.d.ts +10 -0
- package/dist/packages/components/badge/src/badge.d.ts +25 -0
- package/dist/packages/components/breadcrumb/index.d.ts +12 -0
- package/dist/packages/components/breadcrumb/src/breadcrumb-item.d.ts +13 -0
- package/dist/packages/components/breadcrumb/src/breadcrumb.d.ts +10 -0
- package/dist/packages/components/button/index.d.ts +10 -0
- package/dist/packages/components/button/src/button.d.ts +25 -0
- package/dist/packages/components/date-picker/index.d.ts +10 -0
- package/dist/packages/components/date-picker/src/date-picker.d.ts +20 -0
- package/dist/packages/components/descriptions/index.d.ts +12 -0
- package/dist/packages/components/descriptions/src/descriptions-item.d.ts +13 -0
- package/dist/packages/components/descriptions/src/descriptions.d.ts +17 -0
- package/dist/packages/components/divider/index.d.ts +10 -0
- package/dist/packages/components/divider/src/divider.d.ts +20 -0
- package/dist/packages/components/dropdown/index.d.ts +12 -0
- package/dist/packages/components/dropdown/src/dropdown-item.d.ts +20 -0
- package/dist/packages/components/dropdown/src/dropdown.d.ts +46 -0
- package/dist/packages/components/form/index.d.ts +12 -0
- package/dist/packages/components/form/src/form-item.d.ts +45 -0
- package/dist/packages/components/form/src/form.d.ts +96 -0
- package/dist/packages/components/icon/index.d.ts +11 -0
- package/dist/packages/components/icon/src/icon.d.ts +18 -0
- package/dist/packages/components/icon/src/icons.d.ts +50 -0
- package/dist/packages/components/input/index.d.ts +10 -0
- package/dist/packages/components/input/src/input.d.ts +25 -0
- package/dist/packages/components/link/index.d.ts +10 -0
- package/dist/packages/components/link/src/link.d.ts +25 -0
- package/dist/packages/components/loading/index.d.ts +10 -0
- package/dist/packages/components/loading/src/loading.d.ts +15 -0
- package/dist/packages/components/menu/index.d.ts +14 -0
- package/dist/packages/components/menu/src/menu-item.d.ts +12 -0
- package/dist/packages/components/menu/src/menu.d.ts +40 -0
- package/dist/packages/components/menu/src/sub-menu.d.ts +12 -0
- package/dist/packages/components/message/index.d.ts +12 -0
- package/dist/packages/components/message/src/manager.d.ts +14 -0
- package/dist/packages/components/message/src/message.d.ts +28 -0
- package/dist/packages/components/modal/index.d.ts +10 -0
- package/dist/packages/components/modal/src/modal.d.ts +46 -0
- package/dist/packages/components/notification/index.d.ts +12 -0
- package/dist/packages/components/notification/src/manager.d.ts +14 -0
- package/dist/packages/components/notification/src/notification.d.ts +44 -0
- package/dist/packages/components/pagination/index.d.ts +10 -0
- package/dist/packages/components/pagination/src/pagination.d.ts +30 -0
- package/dist/packages/components/popconfirm/index.d.ts +10 -0
- package/dist/packages/components/popconfirm/src/popconfirm.d.ts +56 -0
- package/dist/packages/components/rich-editor/index.d.ts +10 -0
- package/dist/packages/components/rich-editor/src/rich-editor.d.ts +36 -0
- package/dist/packages/components/select/index.d.ts +10 -0
- package/dist/packages/components/select/src/select.d.ts +45 -0
- package/dist/packages/components/space/index.d.ts +10 -0
- package/dist/packages/components/space/src/space.d.ts +33 -0
- package/dist/packages/components/steps/index.d.ts +12 -0
- package/dist/packages/components/steps/src/step.d.ts +28 -0
- package/dist/packages/components/steps/src/steps.d.ts +46 -0
- package/dist/packages/components/table/index.d.ts +10 -0
- package/dist/packages/components/table/src/table.d.ts +56 -0
- package/dist/packages/components/tabs/index.d.ts +12 -0
- package/dist/packages/components/tabs/src/tab-pane.d.ts +22 -0
- package/dist/packages/components/tabs/src/tabs.d.ts +43 -0
- package/dist/packages/components/tree/index.d.ts +10 -0
- package/dist/packages/components/tree/src/tree.d.ts +134 -0
- package/dist/packages/components/upload/index.d.ts +10 -0
- package/dist/packages/components/upload/src/upload.d.ts +103 -0
- package/dist/packages/components/upload/src/upload.vue.d.ts +135 -0
- package/dist/packages/directives/index.d.ts +2 -0
- package/dist/packages/directives/loading/index.d.ts +11 -0
- package/dist/packages/directives/permission/index.d.ts +3 -0
- package/dist/packages/ui-kit/index.d.ts +34 -0
- package/dist/packages/utils/dom.d.ts +5 -0
- package/dist/packages/utils/index.d.ts +3 -0
- package/dist/packages/utils/types.d.ts +7 -0
- package/dist/packages/utils/vue-helper.d.ts +9 -0
- package/dist/play/main.d.ts +1 -0
- package/dist/play/vite.config.d.ts +2 -0
- package/package.json +27 -0
- package/style/index.scss +241 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),U={type:{type:String,default:"default"},size:{type:String,default:"medium"},plain:Boolean,round:Boolean,disabled:Boolean,loading:Boolean,"native-type":{type:String,default:"button"}},F={click:i=>i instanceof MouseEvent},T=["type","disabled"],D={key:0,class:"ui-button__loading"},O=e.defineComponent({__name:"button",props:U,emits:F,setup(i,{emit:r}){const a=i,s=r;function y(o){a.loading||a.disabled||s("click",o)}return(o,v)=>(e.openBlock(),e.createElementBlock("button",{type:o.nativeType,class:e.normalizeClass(["ui-button",`ui-button--${o.type}`,`ui-button--${o.size}`,{"is-plain":o.plain,"is-round":o.round,"is-disabled":o.disabled}]),disabled:o.disabled,onClick:y},[o.loading?(e.openBlock(),e.createElementBlock("span",D)):e.createCommentVNode("v-if",!0),e.renderSlot(o.$slots,"default")],10,T))}}),R={name:{type:String,required:!0},size:{type:[Number,String],default:16},color:{type:String,default:""},spin:Boolean},B={search:'<circle cx="11" cy="11" r="8" /><line x1="21" y1="21" x2="16.65" y2="16.65" />',plus:'<line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" />',minus:'<line x1="5" y1="12" x2="19" y2="12" />',close:'<line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />',check:'<polyline points="20 6 9 17 4 12" />',loading:'<path d="M21 12a9 9 0 1 1-6.219-8.56" />',refresh:'<polyline points="23 4 23 10 17 10" /><polyline points="1 20 1 14 7 14" /><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" />',edit:'<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />',delete:'<polyline points="3 6 5 6 21 6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" /><line x1="10" y1="11" x2="10" y2="17" /><line x1="14" y1="11" x2="14" y2="17" />',download:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><polyline points="7 10 12 15 17 10" /><line x1="12" y1="15" x2="12" y2="3" />',upload:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><polyline points="17 8 12 3 7 8" /><line x1="12" y1="3" x2="12" y2="15" />',setting:'<circle cx="12" cy="12" r="3" /><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" />',user:'<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" /><circle cx="12" cy="7" r="4" />',home:'<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" /><polyline points="9 22 9 12 15 12 15 22" />',calendar:'<rect x="3" y="4" width="18" height="18" rx="2" ry="2" /><line x1="16" y1="2" x2="16" y2="6" /><line x1="8" y1="2" x2="8" y2="6" /><line x1="3" y1="10" x2="21" y2="10" />',clock:'<circle cx="12" cy="12" r="10" /><polyline points="12 6 12 12 16 14" />',star:'<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />',heart:'<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" />',message:'<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" />',bell:'<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9" /><path d="M13.73 21a2 2 0 0 1-3.46 0" />',mail:'<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z" /><polyline points="22,6 12,13 2,6" />',eye:'<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" /><circle cx="12" cy="12" r="3" />',lock:'<rect x="3" y="11" width="18" height="11" rx="2" ry="2" /><path d="M7 11V7a5 5 0 0 1 10 0v4" />',link:'<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />',"arrow-up":'<line x1="12" y1="19" x2="12" y2="5" /><polyline points="5 12 12 5 19 12" />',"arrow-down":'<line x1="12" y1="5" x2="12" y2="19" /><polyline points="19 12 12 19 5 12" />',"arrow-left":'<line x1="19" y1="12" x2="5" y2="12" /><polyline points="12 19 5 12 12 5" />',"arrow-right":'<line x1="5" y1="12" x2="19" y2="12" /><polyline points="12 5 19 12 12 19" />',"chevron-up":'<polyline points="18 15 12 9 6 15" />',"chevron-down":'<polyline points="6 9 12 15 18 9" />',"chevron-left":'<polyline points="15 18 9 12 15 6" />',"chevron-right":'<polyline points="9 18 15 12 9 6" />',more:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',menu:'<line x1="3" y1="12" x2="21" y2="12" /><line x1="3" y1="6" x2="21" y2="6" /><line x1="3" y1="18" x2="21" y2="18" />',filter:'<polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" />',copy:'<rect x="9" y="9" width="13" height="13" rx="2" ry="2" /><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />',"external-link":'<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /><polyline points="15 3 21 3 21 9" /><line x1="10" y1="14" x2="21" y2="3" />',zap:'<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" />',"log-out":'<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" /><polyline points="16 17 21 12 16 7" /><line x1="21" y1="12" x2="9" y2="12" />',grid:'<rect x="3" y="3" width="7" height="7" /><rect x="14" y="3" width="7" height="7" /><rect x="14" y="14" width="7" height="7" /><rect x="3" y="14" width="7" height="7" />',info:'<circle cx="12" cy="12" r="10" /><line x1="12" y1="16" x2="12" y2="12" /><line x1="12" y1="8" x2="12.01" y2="8" />',success:'<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" /><polyline points="22 4 12 14.01 9 11.01" />',warning:'<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" /><line x1="12" y1="9" x2="12" y2="13" /><line x1="12" y1="17" x2="12.01" y2="17" />',error:'<circle cx="12" cy="12" r="10" /><line x1="15" y1="9" x2="9" y2="15" /><line x1="9" y1="9" x2="15" y2="15" />',question:'<circle cx="12" cy="12" r="10" /><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" /><line x1="12" y1="17" x2="12.01" y2="17" />',"plus-circle":'<circle cx="12" cy="12" r="10" /><line x1="12" y1="8" x2="12" y2="16" /><line x1="8" y1="12" x2="16" y2="12" />'};function j(i){return i in B}const A={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},P=["innerHTML"],u=e.defineComponent({__name:"icon",props:R,setup(i){const r=i,a=e.computed(()=>j(r.name)?B[r.name]:""),s=e.computed(()=>({fontSize:typeof r.size=="number"?`${r.size}px`:r.size,...r.color?{color:r.color}:{}}));return(y,o)=>(e.openBlock(),e.createElementBlock("span",{class:e.normalizeClass(["ui-icon",{"is-spin":y.spin}]),style:e.normalizeStyle(s.value),role:"img"},[(e.openBlock(),e.createElementBlock("svg",A,[e.createElementVNode("g",{innerHTML:a.value},null,8,P)]))],6))}}),b={action:{type:String,default:""},name:{type:String,default:"file"},multiple:Boolean,accept:{type:String,default:""},disabled:Boolean,limit:{type:Number,default:0},headers:{type:Object,default:()=>({})},data:{type:Object,default:()=>({})},withCredentials:Boolean,drag:Boolean,autoUpload:{type:Boolean,default:!0},showFileList:{type:Boolean,default:!0},listType:{type:String,default:"text"},fileList:{type:Array,default:()=>[]}},E={"update:file-list":i=>!0,change:i=>!0,success:(i,r)=>!0,error:(i,r)=>!0,progress:(i,r)=>!0,remove:i=>!0,exceed:(i,r)=>!0},W={class:"ui-upload"},q={key:0,class:"ui-upload__drag-inner"},I={key:2,class:"ui-upload__card-add"},K=["accept","multiple","disabled"],X=["src","alt"],G={key:1,class:"ui-upload__thumb-placeholder"},J={class:"ui-upload__card-actions"},Q=["src","alt"],Y={key:1,class:"ui-upload__file-icon"},Z={class:"ui-upload__file-info"},ee=["title"],te={class:"ui-upload__file-size"},ne={class:"ui-upload__file-status"},le={key:0,class:"ui-upload__file-percent"},ae={key:2,class:"ui-upload__progress"},f=e.defineComponent({__name:"upload",props:b,emits:E,setup(i,{emit:r}){const a=i,s=r;let y=0;const o=e.ref([]),v=e.ref(),m=e.ref(!1),h=e.computed(()=>a.listType==="picture-card"),g=e.computed(()=>a.limit>0&&o.value.length>=a.limit);let x=null;e.watch(()=>a.fileList,t=>{t!==x&&(o.value=t.map(l=>({...l})))},{immediate:!0,deep:!0});function p(){x=o.value,s("update:file-list",o.value)}function C(){var t;a.disabled||g.value||(t=v.value)==null||t.click()}function k(t){const l=a.accept?t.filter(N):t;let n=l;if(a.limit>0){const d=Math.max(0,a.limit-o.value.length);l.length>d&&(s("exceed",l,a.limit),n=l.slice(0,d))}const c=n.map(V);a.autoUpload&&c.forEach(d=>L(d))}function V(t){const l={uid:++y,name:t.name,size:t.size,type:t.type,status:"ready",percentage:0,raw:t,url:t.type.startsWith("image/")?URL.createObjectURL(t):void 0};return o.value.push(l),s("change",o.value),p(),l}function M(t){const l=t.target,n=Array.from(l.files??[]);l.value="",k(n)}function w(t){!a.drag||a.disabled||g.value||(m.value=!0)}function z(t){var n;if(m.value=!1,!a.drag||a.disabled||g.value)return;const l=Array.from(((n=t.dataTransfer)==null?void 0:n.files)??[]);l.length&&k(l)}function N(t){return a.accept.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean).some(n=>n==="*/*"||n===".*"?!0:n.endsWith("/*")?t.type.startsWith(n.slice(0,-1)):n.startsWith(".")?t.name.toLowerCase().endsWith(n):t.type===n)}function L(t){if(!a.action){t.status="success",t.percentage=100,s("success",t,void 0),p();return}t.status="uploading",t.percentage=0;const l=new XMLHttpRequest;l.open("POST",a.action),a.withCredentials&&(l.withCredentials=!0),Object.entries(a.headers).forEach(([c,d])=>l.setRequestHeader(c,d)),l.upload.addEventListener("progress",c=>{c.lengthComputable&&(t.percentage=Math.round(c.loaded/c.total*100),s("progress",t,t.percentage),p())}),l.addEventListener("load",()=>{l.status>=200&&l.status<300?(t.status="success",t.percentage=100,t.response=l.response,s("success",t,l.response)):(t.status="fail",t.response=l.response,s("error",t,new Error(`HTTP ${l.status}`))),p()}),l.addEventListener("error",()=>{t.status="fail",s("error",t,new Error("网络错误")),p()}),l.addEventListener("abort",()=>{t.status="ready",p()});const n=new FormData;Object.entries(a.data).forEach(([c,d])=>n.append(c,String(d))),n.append(a.name,t.raw,t.name),l.send(n)}function _(t){var n;const l=o.value.findIndex(c=>c.uid===t.uid);l>-1&&o.value.splice(l,1),(n=t.url)!=null&&n.startsWith("blob:")&&URL.revokeObjectURL(t.url),s("remove",t),s("change",o.value),p()}function S(t){t.url&&window.open(t.url,"_blank")}function H(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function $(t){const l=t.lastIndexOf(".");return l>-1?t.slice(l+1).toUpperCase():"FILE"}return(t,l)=>(e.openBlock(),e.createElementBlock("div",W,[e.createCommentVNode(" 选择触发器(点击 / 拖拽) "),!t.disabled&&!g.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["ui-upload__trigger",{"ui-upload__trigger--card":h.value,"ui-upload__drag":t.drag,"is-dragging":t.drag&&m.value}]),onClick:C,onDragover:e.withModifiers(w,["prevent"]),onDragleave:l[0]||(l[0]=e.withModifiers(n=>m.value=!1,["prevent"])),onDrop:e.withModifiers(z,["prevent"])},[e.renderSlot(t.$slots,"trigger",{},()=>[e.renderSlot(t.$slots,"default",{},()=>[t.drag?(e.openBlock(),e.createElementBlock("div",q,[e.createVNode(e.unref(u),{name:"upload",size:28}),l[1]||(l[1]=e.createElementVNode("p",null,"将文件拖到此处,或点击上传",-1))])):h.value?(e.openBlock(),e.createElementBlock("div",I,[e.createVNode(e.unref(u),{name:"plus",size:24}),l[3]||(l[3]=e.createElementVNode("span",null,"上传",-1))])):(e.openBlock(),e.createBlock(e.unref(O),{key:1,type:"primary"},{default:e.withCtx(()=>[e.createVNode(e.unref(u),{name:"upload",style:{"margin-right":"4px"}}),l[2]||(l[2]=e.createTextVNode("点击上传 ",-1))]),_:1}))])])],34)):e.createCommentVNode("v-if",!0),e.createCommentVNode(" 原生 input:不可见,只做文件选择 "),e.createElementVNode("input",{ref_key:"inputRef",ref:v,class:"ui-upload__input",type:"file",accept:t.accept,multiple:t.multiple,disabled:t.disabled,onChange:M},null,40,K),e.createCommentVNode(" 文件列表 "),t.showFileList&&o.value.length?(e.openBlock(),e.createElementBlock("ul",{key:1,class:e.normalizeClass(["ui-upload__list",`ui-upload__list--${t.listType}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,n=>(e.openBlock(),e.createElementBlock("li",{key:n.uid,class:e.normalizeClass(["ui-upload__file",[`is-${n.status}`,{"is-card":h.value}]])},[e.createCommentVNode(" picture-card:卡片 + 悬浮操作 "),h.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n.url?(e.openBlock(),e.createElementBlock("img",{key:0,class:"ui-upload__thumb",src:n.url,alt:n.name},null,8,X)):(e.openBlock(),e.createElementBlock("div",G,e.toDisplayString($(n.name)),1)),e.createElementVNode("div",J,[e.createVNode(e.unref(u),{name:"eye",size:16,title:"预览",onClick:c=>S(n)},null,8,["onClick"]),e.createVNode(e.unref(u),{name:"delete",size:16,title:"移除",onClick:c=>_(n)},null,8,["onClick"])])],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createCommentVNode(" text / picture:一行一条 "),n.url&&t.listType==="picture"?(e.openBlock(),e.createElementBlock("img",{key:0,class:"ui-upload__thumb",src:n.url,alt:n.name},null,8,Q)):(e.openBlock(),e.createElementBlock("span",Y,[e.createVNode(e.unref(u),{name:"link",size:16})])),e.createElementVNode("div",Z,[e.createElementVNode("span",{class:"ui-upload__file-name",title:n.name},e.toDisplayString(n.name),9,ee),e.createElementVNode("span",te,e.toDisplayString(H(n.size)),1)]),e.createElementVNode("div",ne,[n.status==="uploading"?(e.openBlock(),e.createElementBlock("span",le,e.toDisplayString(n.percentage)+"%",1)):n.status==="success"?(e.openBlock(),e.createBlock(e.unref(u),{key:1,name:"check",class:"is-success",size:16})):n.status==="fail"?(e.openBlock(),e.createBlock(e.unref(u),{key:2,name:"error",class:"is-danger",size:16})):e.createCommentVNode("v-if",!0)]),e.createVNode(e.unref(u),{name:"delete",class:"ui-upload__file-remove",size:16,title:"移除",onClick:c=>_(n)},null,8,["onClick"])],64)),e.createCommentVNode(" 上传进度条 "),n.status==="uploading"?(e.openBlock(),e.createElementBlock("div",ae,[e.createElementVNode("div",{class:"ui-upload__progress-bar",style:e.normalizeStyle({width:`${n.percentage}%`})},null,4)])):e.createCommentVNode("v-if",!0)],2))),128))],2)):e.createCommentVNode("v-if",!0)]))}}),oe={name:"UiUpload",install(i){i.component("UiUpload",f)}};exports.Upload=f;exports.UploadPlugin=oe;exports.default=f;exports.uploadEmits=E;exports.uploadProps=b;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import { defineComponent as $, openBlock as l, createElementBlock as s, normalizeClass as f, createCommentVNode as d, renderSlot as S, computed as w, normalizeStyle as T, createElementVNode as y, ref as L, watch as K, withModifiers as C, createVNode as v, unref as c, createBlock as B, withCtx as X, createTextVNode as G, Fragment as H, renderList as J, toDisplayString as M } from "vue";
|
|
2
|
+
const Q = {
|
|
3
|
+
type: { type: String, default: "default" },
|
|
4
|
+
size: { type: String, default: "medium" },
|
|
5
|
+
plain: Boolean,
|
|
6
|
+
round: Boolean,
|
|
7
|
+
disabled: Boolean,
|
|
8
|
+
loading: Boolean,
|
|
9
|
+
/** 原生 button 的 type,默认 button(避免误触发表单提交) */
|
|
10
|
+
"native-type": { type: String, default: "button" }
|
|
11
|
+
}, Y = {
|
|
12
|
+
click: (o) => o instanceof MouseEvent
|
|
13
|
+
}, Z = ["type", "disabled"], ee = {
|
|
14
|
+
key: 0,
|
|
15
|
+
class: "ui-button__loading"
|
|
16
|
+
}, te = /* @__PURE__ */ $({
|
|
17
|
+
__name: "button",
|
|
18
|
+
props: Q,
|
|
19
|
+
emits: Y,
|
|
20
|
+
setup(o, { emit: r }) {
|
|
21
|
+
const n = o, u = r;
|
|
22
|
+
function x(i) {
|
|
23
|
+
n.loading || n.disabled || u("click", i);
|
|
24
|
+
}
|
|
25
|
+
return (i, z) => (l(), s("button", {
|
|
26
|
+
type: i.nativeType,
|
|
27
|
+
class: f([
|
|
28
|
+
"ui-button",
|
|
29
|
+
`ui-button--${i.type}`,
|
|
30
|
+
`ui-button--${i.size}`,
|
|
31
|
+
{ "is-plain": i.plain, "is-round": i.round, "is-disabled": i.disabled }
|
|
32
|
+
]),
|
|
33
|
+
disabled: i.disabled,
|
|
34
|
+
onClick: x
|
|
35
|
+
}, [
|
|
36
|
+
i.loading ? (l(), s("span", ee)) : d("v-if", !0),
|
|
37
|
+
S(i.$slots, "default")
|
|
38
|
+
], 10, Z));
|
|
39
|
+
}
|
|
40
|
+
}), ae = {
|
|
41
|
+
// 图标名称,见 ./icons 注册表
|
|
42
|
+
name: { type: String, required: !0 },
|
|
43
|
+
// 尺寸:数字按 px 处理,字符串作为 CSS 长度(如 '1.5em')
|
|
44
|
+
size: { type: [Number, String], default: 16 },
|
|
45
|
+
// 颜色:缺省时继承 currentColor
|
|
46
|
+
color: { type: String, default: "" },
|
|
47
|
+
// 是否旋转(用于 loading 等图标)
|
|
48
|
+
spin: Boolean
|
|
49
|
+
}, F = {
|
|
50
|
+
search: '<circle cx="11" cy="11" r="8" /><line x1="21" y1="21" x2="16.65" y2="16.65" />',
|
|
51
|
+
plus: '<line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" />',
|
|
52
|
+
minus: '<line x1="5" y1="12" x2="19" y2="12" />',
|
|
53
|
+
close: '<line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />',
|
|
54
|
+
check: '<polyline points="20 6 9 17 4 12" />',
|
|
55
|
+
loading: '<path d="M21 12a9 9 0 1 1-6.219-8.56" />',
|
|
56
|
+
refresh: '<polyline points="23 4 23 10 17 10" /><polyline points="1 20 1 14 7 14" /><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" />',
|
|
57
|
+
edit: '<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />',
|
|
58
|
+
delete: '<polyline points="3 6 5 6 21 6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" /><line x1="10" y1="11" x2="10" y2="17" /><line x1="14" y1="11" x2="14" y2="17" />',
|
|
59
|
+
download: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><polyline points="7 10 12 15 17 10" /><line x1="12" y1="15" x2="12" y2="3" />',
|
|
60
|
+
upload: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><polyline points="17 8 12 3 7 8" /><line x1="12" y1="3" x2="12" y2="15" />',
|
|
61
|
+
setting: '<circle cx="12" cy="12" r="3" /><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" />',
|
|
62
|
+
user: '<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" /><circle cx="12" cy="7" r="4" />',
|
|
63
|
+
home: '<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" /><polyline points="9 22 9 12 15 12 15 22" />',
|
|
64
|
+
calendar: '<rect x="3" y="4" width="18" height="18" rx="2" ry="2" /><line x1="16" y1="2" x2="16" y2="6" /><line x1="8" y1="2" x2="8" y2="6" /><line x1="3" y1="10" x2="21" y2="10" />',
|
|
65
|
+
clock: '<circle cx="12" cy="12" r="10" /><polyline points="12 6 12 12 16 14" />',
|
|
66
|
+
star: '<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />',
|
|
67
|
+
heart: '<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" />',
|
|
68
|
+
message: '<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" />',
|
|
69
|
+
bell: '<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9" /><path d="M13.73 21a2 2 0 0 1-3.46 0" />',
|
|
70
|
+
mail: '<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z" /><polyline points="22,6 12,13 2,6" />',
|
|
71
|
+
eye: '<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" /><circle cx="12" cy="12" r="3" />',
|
|
72
|
+
lock: '<rect x="3" y="11" width="18" height="11" rx="2" ry="2" /><path d="M7 11V7a5 5 0 0 1 10 0v4" />',
|
|
73
|
+
link: '<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />',
|
|
74
|
+
"arrow-up": '<line x1="12" y1="19" x2="12" y2="5" /><polyline points="5 12 12 5 19 12" />',
|
|
75
|
+
"arrow-down": '<line x1="12" y1="5" x2="12" y2="19" /><polyline points="19 12 12 19 5 12" />',
|
|
76
|
+
"arrow-left": '<line x1="19" y1="12" x2="5" y2="12" /><polyline points="12 19 5 12 12 5" />',
|
|
77
|
+
"arrow-right": '<line x1="5" y1="12" x2="19" y2="12" /><polyline points="12 5 19 12 12 19" />',
|
|
78
|
+
"chevron-up": '<polyline points="18 15 12 9 6 15" />',
|
|
79
|
+
"chevron-down": '<polyline points="6 9 12 15 18 9" />',
|
|
80
|
+
"chevron-left": '<polyline points="15 18 9 12 15 6" />',
|
|
81
|
+
"chevron-right": '<polyline points="9 18 15 12 9 6" />',
|
|
82
|
+
more: '<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',
|
|
83
|
+
menu: '<line x1="3" y1="12" x2="21" y2="12" /><line x1="3" y1="6" x2="21" y2="6" /><line x1="3" y1="18" x2="21" y2="18" />',
|
|
84
|
+
filter: '<polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" />',
|
|
85
|
+
copy: '<rect x="9" y="9" width="13" height="13" rx="2" ry="2" /><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />',
|
|
86
|
+
"external-link": '<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /><polyline points="15 3 21 3 21 9" /><line x1="10" y1="14" x2="21" y2="3" />',
|
|
87
|
+
zap: '<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" />',
|
|
88
|
+
"log-out": '<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" /><polyline points="16 17 21 12 16 7" /><line x1="21" y1="12" x2="9" y2="12" />',
|
|
89
|
+
grid: '<rect x="3" y="3" width="7" height="7" /><rect x="14" y="3" width="7" height="7" /><rect x="14" y="14" width="7" height="7" /><rect x="3" y="14" width="7" height="7" />',
|
|
90
|
+
info: '<circle cx="12" cy="12" r="10" /><line x1="12" y1="16" x2="12" y2="12" /><line x1="12" y1="8" x2="12.01" y2="8" />',
|
|
91
|
+
success: '<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" /><polyline points="22 4 12 14.01 9 11.01" />',
|
|
92
|
+
warning: '<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" /><line x1="12" y1="9" x2="12" y2="13" /><line x1="12" y1="17" x2="12.01" y2="17" />',
|
|
93
|
+
error: '<circle cx="12" cy="12" r="10" /><line x1="15" y1="9" x2="9" y2="15" /><line x1="9" y1="9" x2="15" y2="15" />',
|
|
94
|
+
question: '<circle cx="12" cy="12" r="10" /><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" /><line x1="12" y1="17" x2="12.01" y2="17" />',
|
|
95
|
+
"plus-circle": '<circle cx="12" cy="12" r="10" /><line x1="12" y1="8" x2="12" y2="16" /><line x1="8" y1="12" x2="16" y2="12" />'
|
|
96
|
+
};
|
|
97
|
+
function ne(o) {
|
|
98
|
+
return o in F;
|
|
99
|
+
}
|
|
100
|
+
const ie = {
|
|
101
|
+
viewBox: "0 0 24 24",
|
|
102
|
+
fill: "none",
|
|
103
|
+
stroke: "currentColor",
|
|
104
|
+
"stroke-width": "2",
|
|
105
|
+
"stroke-linecap": "round",
|
|
106
|
+
"stroke-linejoin": "round"
|
|
107
|
+
}, le = ["innerHTML"], h = /* @__PURE__ */ $({
|
|
108
|
+
__name: "icon",
|
|
109
|
+
props: ae,
|
|
110
|
+
setup(o) {
|
|
111
|
+
const r = o, n = w(() => ne(r.name) ? F[r.name] : ""), u = w(() => ({
|
|
112
|
+
fontSize: typeof r.size == "number" ? `${r.size}px` : r.size,
|
|
113
|
+
...r.color ? { color: r.color } : {}
|
|
114
|
+
}));
|
|
115
|
+
return (x, i) => (l(), s(
|
|
116
|
+
"span",
|
|
117
|
+
{
|
|
118
|
+
class: f(["ui-icon", { "is-spin": x.spin }]),
|
|
119
|
+
style: T(u.value),
|
|
120
|
+
role: "img"
|
|
121
|
+
},
|
|
122
|
+
[
|
|
123
|
+
(l(), s("svg", ie, [
|
|
124
|
+
y("g", { innerHTML: n.value }, null, 8, le)
|
|
125
|
+
]))
|
|
126
|
+
],
|
|
127
|
+
6
|
|
128
|
+
/* CLASS, STYLE */
|
|
129
|
+
));
|
|
130
|
+
}
|
|
131
|
+
}), se = {
|
|
132
|
+
/** 上传请求的 URL;留空时不发起请求,文件直接标记为成功(便于无后端演示) */
|
|
133
|
+
action: { type: String, default: "" },
|
|
134
|
+
/** FormData 中文件字段的 key */
|
|
135
|
+
name: { type: String, default: "file" },
|
|
136
|
+
/** 是否允许多选 */
|
|
137
|
+
multiple: Boolean,
|
|
138
|
+
/** 原生 input 的 accept,如 'image/*'、'.zip,.rar' */
|
|
139
|
+
accept: { type: String, default: "" },
|
|
140
|
+
/** 禁用上传 */
|
|
141
|
+
disabled: Boolean,
|
|
142
|
+
/** 最大文件数,0 表示不限制 */
|
|
143
|
+
limit: { type: Number, default: 0 },
|
|
144
|
+
/** 自定义请求头 */
|
|
145
|
+
headers: { type: Object, default: () => ({}) },
|
|
146
|
+
/** 附加的 FormData 字段 */
|
|
147
|
+
data: { type: Object, default: () => ({}) },
|
|
148
|
+
/** 跨域时是否携带 cookie */
|
|
149
|
+
withCredentials: Boolean,
|
|
150
|
+
/** 是否支持拖拽上传(将触发器区域变成拖拽区) */
|
|
151
|
+
drag: Boolean,
|
|
152
|
+
/** 选择文件后是否立即上传;false 时仅加入列表,等待手动触发 */
|
|
153
|
+
autoUpload: { type: Boolean, default: !0 },
|
|
154
|
+
/** 是否展示文件列表 */
|
|
155
|
+
showFileList: { type: Boolean, default: !0 },
|
|
156
|
+
/** 列表展示类型 */
|
|
157
|
+
listType: { type: String, default: "text" },
|
|
158
|
+
/** 受控文件列表(配合 v-model:file-list 使用) */
|
|
159
|
+
fileList: { type: Array, default: () => [] }
|
|
160
|
+
}, oe = {
|
|
161
|
+
"update:file-list": (o) => !0,
|
|
162
|
+
/** 文件列表变化(新增 / 移除) */
|
|
163
|
+
change: (o) => !0,
|
|
164
|
+
/** 上传成功 */
|
|
165
|
+
success: (o, r) => !0,
|
|
166
|
+
/** 上传失败 */
|
|
167
|
+
error: (o, r) => !0,
|
|
168
|
+
/** 上传进度 */
|
|
169
|
+
progress: (o, r) => !0,
|
|
170
|
+
/** 移除文件 */
|
|
171
|
+
remove: (o) => !0,
|
|
172
|
+
/** 超出 limit 限制 */
|
|
173
|
+
exceed: (o, r) => !0
|
|
174
|
+
}, re = { class: "ui-upload" }, ue = {
|
|
175
|
+
key: 0,
|
|
176
|
+
class: "ui-upload__drag-inner"
|
|
177
|
+
}, pe = {
|
|
178
|
+
key: 2,
|
|
179
|
+
class: "ui-upload__card-add"
|
|
180
|
+
}, de = ["accept", "multiple", "disabled"], ce = ["src", "alt"], ye = {
|
|
181
|
+
key: 1,
|
|
182
|
+
class: "ui-upload__thumb-placeholder"
|
|
183
|
+
}, he = { class: "ui-upload__card-actions" }, me = ["src", "alt"], ge = {
|
|
184
|
+
key: 1,
|
|
185
|
+
class: "ui-upload__file-icon"
|
|
186
|
+
}, ve = { class: "ui-upload__file-info" }, xe = ["title"], fe = { class: "ui-upload__file-size" }, _e = { class: "ui-upload__file-status" }, ke = {
|
|
187
|
+
key: 0,
|
|
188
|
+
class: "ui-upload__file-percent"
|
|
189
|
+
}, be = {
|
|
190
|
+
key: 2,
|
|
191
|
+
class: "ui-upload__progress"
|
|
192
|
+
}, Me = /* @__PURE__ */ $({
|
|
193
|
+
__name: "upload",
|
|
194
|
+
props: se,
|
|
195
|
+
emits: oe,
|
|
196
|
+
setup(o, { emit: r }) {
|
|
197
|
+
const n = o, u = r;
|
|
198
|
+
let x = 0;
|
|
199
|
+
const i = L([]), z = L(), _ = L(!1), k = w(() => n.listType === "picture-card"), b = w(() => n.limit > 0 && i.value.length >= n.limit);
|
|
200
|
+
let E = null;
|
|
201
|
+
K(
|
|
202
|
+
() => n.fileList,
|
|
203
|
+
(e) => {
|
|
204
|
+
e !== E && (i.value = e.map((a) => ({ ...a })));
|
|
205
|
+
},
|
|
206
|
+
{ immediate: !0, deep: !0 }
|
|
207
|
+
);
|
|
208
|
+
function g() {
|
|
209
|
+
E = i.value, u("update:file-list", i.value);
|
|
210
|
+
}
|
|
211
|
+
function R() {
|
|
212
|
+
var e;
|
|
213
|
+
n.disabled || b.value || (e = z.value) == null || e.click();
|
|
214
|
+
}
|
|
215
|
+
function V(e) {
|
|
216
|
+
const a = n.accept ? e.filter(N) : e;
|
|
217
|
+
let t = a;
|
|
218
|
+
if (n.limit > 0) {
|
|
219
|
+
const m = Math.max(0, n.limit - i.value.length);
|
|
220
|
+
a.length > m && (u("exceed", a, n.limit), t = a.slice(0, m));
|
|
221
|
+
}
|
|
222
|
+
const p = t.map(D);
|
|
223
|
+
n.autoUpload && p.forEach((m) => W(m));
|
|
224
|
+
}
|
|
225
|
+
function D(e) {
|
|
226
|
+
const a = {
|
|
227
|
+
uid: ++x,
|
|
228
|
+
name: e.name,
|
|
229
|
+
size: e.size,
|
|
230
|
+
type: e.type,
|
|
231
|
+
status: "ready",
|
|
232
|
+
percentage: 0,
|
|
233
|
+
raw: e,
|
|
234
|
+
// 仅图片生成本地预览地址
|
|
235
|
+
url: e.type.startsWith("image/") ? URL.createObjectURL(e) : void 0
|
|
236
|
+
};
|
|
237
|
+
return i.value.push(a), u("change", i.value), g(), a;
|
|
238
|
+
}
|
|
239
|
+
function O(e) {
|
|
240
|
+
const a = e.target, t = Array.from(a.files ?? []);
|
|
241
|
+
a.value = "", V(t);
|
|
242
|
+
}
|
|
243
|
+
function A(e) {
|
|
244
|
+
!n.drag || n.disabled || b.value || (_.value = !0);
|
|
245
|
+
}
|
|
246
|
+
function j(e) {
|
|
247
|
+
var t;
|
|
248
|
+
if (_.value = !1, !n.drag || n.disabled || b.value) return;
|
|
249
|
+
const a = Array.from(((t = e.dataTransfer) == null ? void 0 : t.files) ?? []);
|
|
250
|
+
a.length && V(a);
|
|
251
|
+
}
|
|
252
|
+
function N(e) {
|
|
253
|
+
return n.accept.split(",").map((t) => t.trim().toLowerCase()).filter(Boolean).some((t) => t === "*/*" || t === ".*" ? !0 : t.endsWith("/*") ? e.type.startsWith(t.slice(0, -1)) : t.startsWith(".") ? e.name.toLowerCase().endsWith(t) : e.type === t);
|
|
254
|
+
}
|
|
255
|
+
function W(e) {
|
|
256
|
+
if (!n.action) {
|
|
257
|
+
e.status = "success", e.percentage = 100, u("success", e, void 0), g();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
e.status = "uploading", e.percentage = 0;
|
|
261
|
+
const a = new XMLHttpRequest();
|
|
262
|
+
a.open("POST", n.action), n.withCredentials && (a.withCredentials = !0), Object.entries(n.headers).forEach(([p, m]) => a.setRequestHeader(p, m)), a.upload.addEventListener("progress", (p) => {
|
|
263
|
+
p.lengthComputable && (e.percentage = Math.round(p.loaded / p.total * 100), u("progress", e, e.percentage), g());
|
|
264
|
+
}), a.addEventListener("load", () => {
|
|
265
|
+
a.status >= 200 && a.status < 300 ? (e.status = "success", e.percentage = 100, e.response = a.response, u("success", e, a.response)) : (e.status = "fail", e.response = a.response, u("error", e, new Error(`HTTP ${a.status}`))), g();
|
|
266
|
+
}), a.addEventListener("error", () => {
|
|
267
|
+
e.status = "fail", u("error", e, new Error("网络错误")), g();
|
|
268
|
+
}), a.addEventListener("abort", () => {
|
|
269
|
+
e.status = "ready", g();
|
|
270
|
+
});
|
|
271
|
+
const t = new FormData();
|
|
272
|
+
Object.entries(n.data).forEach(([p, m]) => t.append(p, String(m))), t.append(n.name, e.raw, e.name), a.send(t);
|
|
273
|
+
}
|
|
274
|
+
function U(e) {
|
|
275
|
+
var t;
|
|
276
|
+
const a = i.value.findIndex((p) => p.uid === e.uid);
|
|
277
|
+
a > -1 && i.value.splice(a, 1), (t = e.url) != null && t.startsWith("blob:") && URL.revokeObjectURL(e.url), u("remove", e), u("change", i.value), g();
|
|
278
|
+
}
|
|
279
|
+
function q(e) {
|
|
280
|
+
e.url && window.open(e.url, "_blank");
|
|
281
|
+
}
|
|
282
|
+
function I(e) {
|
|
283
|
+
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
|
|
284
|
+
}
|
|
285
|
+
function P(e) {
|
|
286
|
+
const a = e.lastIndexOf(".");
|
|
287
|
+
return a > -1 ? e.slice(a + 1).toUpperCase() : "FILE";
|
|
288
|
+
}
|
|
289
|
+
return (e, a) => (l(), s("div", re, [
|
|
290
|
+
d(" 选择触发器(点击 / 拖拽) "),
|
|
291
|
+
!e.disabled && !b.value ? (l(), s(
|
|
292
|
+
"div",
|
|
293
|
+
{
|
|
294
|
+
key: 0,
|
|
295
|
+
class: f(["ui-upload__trigger", { "ui-upload__trigger--card": k.value, "ui-upload__drag": e.drag, "is-dragging": e.drag && _.value }]),
|
|
296
|
+
onClick: R,
|
|
297
|
+
onDragover: C(A, ["prevent"]),
|
|
298
|
+
onDragleave: a[0] || (a[0] = C((t) => _.value = !1, ["prevent"])),
|
|
299
|
+
onDrop: C(j, ["prevent"])
|
|
300
|
+
},
|
|
301
|
+
[
|
|
302
|
+
S(e.$slots, "trigger", {}, () => [
|
|
303
|
+
S(e.$slots, "default", {}, () => [
|
|
304
|
+
e.drag ? (l(), s("div", ue, [
|
|
305
|
+
v(c(h), {
|
|
306
|
+
name: "upload",
|
|
307
|
+
size: 28
|
|
308
|
+
}),
|
|
309
|
+
a[1] || (a[1] = y(
|
|
310
|
+
"p",
|
|
311
|
+
null,
|
|
312
|
+
"将文件拖到此处,或点击上传",
|
|
313
|
+
-1
|
|
314
|
+
/* CACHED */
|
|
315
|
+
))
|
|
316
|
+
])) : k.value ? (l(), s("div", pe, [
|
|
317
|
+
v(c(h), {
|
|
318
|
+
name: "plus",
|
|
319
|
+
size: 24
|
|
320
|
+
}),
|
|
321
|
+
a[3] || (a[3] = y(
|
|
322
|
+
"span",
|
|
323
|
+
null,
|
|
324
|
+
"上传",
|
|
325
|
+
-1
|
|
326
|
+
/* CACHED */
|
|
327
|
+
))
|
|
328
|
+
])) : (l(), B(c(te), {
|
|
329
|
+
key: 1,
|
|
330
|
+
type: "primary"
|
|
331
|
+
}, {
|
|
332
|
+
default: X(() => [
|
|
333
|
+
v(c(h), {
|
|
334
|
+
name: "upload",
|
|
335
|
+
style: { "margin-right": "4px" }
|
|
336
|
+
}),
|
|
337
|
+
a[2] || (a[2] = G(
|
|
338
|
+
"点击上传 ",
|
|
339
|
+
-1
|
|
340
|
+
/* CACHED */
|
|
341
|
+
))
|
|
342
|
+
]),
|
|
343
|
+
_: 1
|
|
344
|
+
/* STABLE */
|
|
345
|
+
}))
|
|
346
|
+
])
|
|
347
|
+
])
|
|
348
|
+
],
|
|
349
|
+
34
|
|
350
|
+
/* CLASS, NEED_HYDRATION */
|
|
351
|
+
)) : d("v-if", !0),
|
|
352
|
+
d(" 原生 input:不可见,只做文件选择 "),
|
|
353
|
+
y("input", {
|
|
354
|
+
ref_key: "inputRef",
|
|
355
|
+
ref: z,
|
|
356
|
+
class: "ui-upload__input",
|
|
357
|
+
type: "file",
|
|
358
|
+
accept: e.accept,
|
|
359
|
+
multiple: e.multiple,
|
|
360
|
+
disabled: e.disabled,
|
|
361
|
+
onChange: O
|
|
362
|
+
}, null, 40, de),
|
|
363
|
+
d(" 文件列表 "),
|
|
364
|
+
e.showFileList && i.value.length ? (l(), s(
|
|
365
|
+
"ul",
|
|
366
|
+
{
|
|
367
|
+
key: 1,
|
|
368
|
+
class: f(["ui-upload__list", `ui-upload__list--${e.listType}`])
|
|
369
|
+
},
|
|
370
|
+
[
|
|
371
|
+
(l(!0), s(
|
|
372
|
+
H,
|
|
373
|
+
null,
|
|
374
|
+
J(i.value, (t) => (l(), s(
|
|
375
|
+
"li",
|
|
376
|
+
{
|
|
377
|
+
key: t.uid,
|
|
378
|
+
class: f(["ui-upload__file", [`is-${t.status}`, { "is-card": k.value }]])
|
|
379
|
+
},
|
|
380
|
+
[
|
|
381
|
+
d(" picture-card:卡片 + 悬浮操作 "),
|
|
382
|
+
k.value ? (l(), s(
|
|
383
|
+
H,
|
|
384
|
+
{ key: 0 },
|
|
385
|
+
[
|
|
386
|
+
t.url ? (l(), s("img", {
|
|
387
|
+
key: 0,
|
|
388
|
+
class: "ui-upload__thumb",
|
|
389
|
+
src: t.url,
|
|
390
|
+
alt: t.name
|
|
391
|
+
}, null, 8, ce)) : (l(), s(
|
|
392
|
+
"div",
|
|
393
|
+
ye,
|
|
394
|
+
M(P(t.name)),
|
|
395
|
+
1
|
|
396
|
+
/* TEXT */
|
|
397
|
+
)),
|
|
398
|
+
y("div", he, [
|
|
399
|
+
v(c(h), {
|
|
400
|
+
name: "eye",
|
|
401
|
+
size: 16,
|
|
402
|
+
title: "预览",
|
|
403
|
+
onClick: (p) => q(t)
|
|
404
|
+
}, null, 8, ["onClick"]),
|
|
405
|
+
v(c(h), {
|
|
406
|
+
name: "delete",
|
|
407
|
+
size: 16,
|
|
408
|
+
title: "移除",
|
|
409
|
+
onClick: (p) => U(t)
|
|
410
|
+
}, null, 8, ["onClick"])
|
|
411
|
+
])
|
|
412
|
+
],
|
|
413
|
+
64
|
|
414
|
+
/* STABLE_FRAGMENT */
|
|
415
|
+
)) : (l(), s(
|
|
416
|
+
H,
|
|
417
|
+
{ key: 1 },
|
|
418
|
+
[
|
|
419
|
+
d(" text / picture:一行一条 "),
|
|
420
|
+
t.url && e.listType === "picture" ? (l(), s("img", {
|
|
421
|
+
key: 0,
|
|
422
|
+
class: "ui-upload__thumb",
|
|
423
|
+
src: t.url,
|
|
424
|
+
alt: t.name
|
|
425
|
+
}, null, 8, me)) : (l(), s("span", ge, [
|
|
426
|
+
v(c(h), {
|
|
427
|
+
name: "link",
|
|
428
|
+
size: 16
|
|
429
|
+
})
|
|
430
|
+
])),
|
|
431
|
+
y("div", ve, [
|
|
432
|
+
y("span", {
|
|
433
|
+
class: "ui-upload__file-name",
|
|
434
|
+
title: t.name
|
|
435
|
+
}, M(t.name), 9, xe),
|
|
436
|
+
y(
|
|
437
|
+
"span",
|
|
438
|
+
fe,
|
|
439
|
+
M(I(t.size)),
|
|
440
|
+
1
|
|
441
|
+
/* TEXT */
|
|
442
|
+
)
|
|
443
|
+
]),
|
|
444
|
+
y("div", _e, [
|
|
445
|
+
t.status === "uploading" ? (l(), s(
|
|
446
|
+
"span",
|
|
447
|
+
ke,
|
|
448
|
+
M(t.percentage) + "%",
|
|
449
|
+
1
|
|
450
|
+
/* TEXT */
|
|
451
|
+
)) : t.status === "success" ? (l(), B(c(h), {
|
|
452
|
+
key: 1,
|
|
453
|
+
name: "check",
|
|
454
|
+
class: "is-success",
|
|
455
|
+
size: 16
|
|
456
|
+
})) : t.status === "fail" ? (l(), B(c(h), {
|
|
457
|
+
key: 2,
|
|
458
|
+
name: "error",
|
|
459
|
+
class: "is-danger",
|
|
460
|
+
size: 16
|
|
461
|
+
})) : d("v-if", !0)
|
|
462
|
+
]),
|
|
463
|
+
v(c(h), {
|
|
464
|
+
name: "delete",
|
|
465
|
+
class: "ui-upload__file-remove",
|
|
466
|
+
size: 16,
|
|
467
|
+
title: "移除",
|
|
468
|
+
onClick: (p) => U(t)
|
|
469
|
+
}, null, 8, ["onClick"])
|
|
470
|
+
],
|
|
471
|
+
64
|
|
472
|
+
/* STABLE_FRAGMENT */
|
|
473
|
+
)),
|
|
474
|
+
d(" 上传进度条 "),
|
|
475
|
+
t.status === "uploading" ? (l(), s("div", be, [
|
|
476
|
+
y(
|
|
477
|
+
"div",
|
|
478
|
+
{
|
|
479
|
+
class: "ui-upload__progress-bar",
|
|
480
|
+
style: T({ width: `${t.percentage}%` })
|
|
481
|
+
},
|
|
482
|
+
null,
|
|
483
|
+
4
|
|
484
|
+
/* STYLE */
|
|
485
|
+
)
|
|
486
|
+
])) : d("v-if", !0)
|
|
487
|
+
],
|
|
488
|
+
2
|
|
489
|
+
/* CLASS */
|
|
490
|
+
))),
|
|
491
|
+
128
|
|
492
|
+
/* KEYED_FRAGMENT */
|
|
493
|
+
))
|
|
494
|
+
],
|
|
495
|
+
2
|
|
496
|
+
/* CLASS */
|
|
497
|
+
)) : d("v-if", !0)
|
|
498
|
+
]));
|
|
499
|
+
}
|
|
500
|
+
}), ze = {
|
|
501
|
+
name: "UiUpload",
|
|
502
|
+
install(o) {
|
|
503
|
+
o.component("UiUpload", Me);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
export {
|
|
507
|
+
Me as Upload,
|
|
508
|
+
ze as UploadPlugin,
|
|
509
|
+
Me as default,
|
|
510
|
+
oe as uploadEmits,
|
|
511
|
+
se as uploadProps
|
|
512
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
export declare const badgeProps: {
|
|
4
|
+
readonly value: {
|
|
5
|
+
readonly type: [NumberConstructor, StringConstructor];
|
|
6
|
+
readonly default: 0;
|
|
7
|
+
};
|
|
8
|
+
readonly max: {
|
|
9
|
+
readonly type: NumberConstructor;
|
|
10
|
+
readonly default: undefined;
|
|
11
|
+
};
|
|
12
|
+
readonly isDot: {
|
|
13
|
+
readonly type: BooleanConstructor;
|
|
14
|
+
readonly default: false;
|
|
15
|
+
};
|
|
16
|
+
readonly hidden: {
|
|
17
|
+
readonly type: BooleanConstructor;
|
|
18
|
+
readonly default: false;
|
|
19
|
+
};
|
|
20
|
+
readonly type: {
|
|
21
|
+
readonly type: StringConstructor;
|
|
22
|
+
readonly default: "danger";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type BadgeProps = ExtractPropTypes<typeof badgeProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { default as Breadcrumb } from './src/breadcrumb.vue';
|
|
3
|
+
import { default as BreadcrumbItem } from './src/breadcrumb-item.vue';
|
|
4
|
+
|
|
5
|
+
export declare const BreadcrumbPlugin: {
|
|
6
|
+
name: string;
|
|
7
|
+
install(app: App): void;
|
|
8
|
+
};
|
|
9
|
+
export { Breadcrumb, BreadcrumbItem };
|
|
10
|
+
export default Breadcrumb;
|
|
11
|
+
export * from './src/breadcrumb';
|
|
12
|
+
export * from './src/breadcrumb-item';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
export declare const breadcrumbItemProps: {
|
|
4
|
+
readonly to: {
|
|
5
|
+
readonly type: StringConstructor;
|
|
6
|
+
readonly default: "";
|
|
7
|
+
};
|
|
8
|
+
readonly replace: {
|
|
9
|
+
readonly type: BooleanConstructor;
|
|
10
|
+
readonly default: false;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type BreadcrumbItemProps = ExtractPropTypes<typeof breadcrumbItemProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExtractPropTypes, InjectionKey } from 'vue';
|
|
2
|
+
|
|
3
|
+
export declare const breadcrumbProps: {
|
|
4
|
+
readonly separator: {
|
|
5
|
+
readonly type: StringConstructor;
|
|
6
|
+
readonly default: "/";
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export type BreadcrumbProps = ExtractPropTypes<typeof breadcrumbProps>;
|
|
10
|
+
export declare const breadcrumbSeparatorKey: InjectionKey<string>;
|