vue-devui 1.0.0-rc.0 → 1.0.0-rc.1
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 +13 -0
- package/accordion/index.es.js +6 -3
- package/alert/index.es.js +28 -30
- package/alert/index.umd.js +1 -1
- package/auto-complete/index.es.js +13 -6
- package/auto-complete/index.umd.js +1 -1
- package/back-top/index.es.js +4 -2
- package/badge/index.es.js +1 -1
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/breadcrumb/index.es.js +2 -1
- package/button/index.es.js +39 -40
- package/button/index.umd.js +1 -1
- package/carousel/index.es.js +38 -53
- package/carousel/index.umd.js +1 -1
- package/cascader/index.es.js +16 -8
- package/cascader/style.css +1 -1
- package/color-picker/index.es.js +94 -85
- package/color-picker/index.umd.js +7 -7
- package/countdown/index.es.js +2 -1
- package/date-picker/index.es.js +40 -57
- package/date-picker/index.umd.js +1 -1
- package/dropdown/index.es.js +117 -62
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +6 -3
- package/form/index.es.js +87 -76
- package/form/index.umd.js +11 -11
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +13 -16
- package/fullscreen/index.umd.js +1 -1
- package/icon/index.es.js +39 -57
- package/icon/index.umd.js +1 -1
- package/image-preview/index.es.js +2 -1
- package/input-icon/index.es.js +38 -37
- package/input-icon/index.umd.js +1 -1
- package/input-number/index.es.js +46 -57
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/modal/index.es.js +81 -76
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +38 -40
- package/notification/index.umd.js +1 -1
- package/nuxt/components/PanelBody.js +3 -0
- package/nuxt/components/PanelFooter.js +3 -0
- package/nuxt/components/PanelHeader.js +3 -0
- package/nuxt/components/Timeline.js +3 -0
- package/nuxt/components/TimelineItem.js +3 -0
- package/nuxt/components/alertProps.js +3 -0
- package/nuxt/components/fullscreenProps.js +3 -0
- package/nuxt/components/iconProps.js +2 -0
- package/nuxt/components/paginationProps.js +3 -0
- package/nuxt/components/panelProps.js +3 -0
- package/nuxt/components/searchProps.js +3 -0
- package/overlay/index.es.js +44 -37
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +8 -43
- package/pagination/index.es.js +10 -12
- package/pagination/index.umd.js +1 -1
- package/panel/index.es.js +45 -32
- package/panel/index.umd.js +1 -1
- package/popover/index.es.js +44 -37
- package/popover/index.umd.js +6 -6
- package/popover/style.css +1 -1
- package/radio/index.es.js +3 -9
- package/radio/index.umd.js +1 -1
- package/read-tip/index.es.js +6 -3
- package/result/index.es.js +38 -53
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +9 -5
- package/search/index.es.js +2 -5
- package/search/index.umd.js +4 -4
- package/select/index.es.js +42 -42
- package/select/index.umd.js +1 -1
- package/skeleton/index.es.js +17 -17
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +2 -1
- package/splitter/index.es.js +54 -42
- package/splitter/index.umd.js +6 -6
- package/splitter/style.css +1 -1
- package/status/index.es.js +1 -4
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/steps-guide/index.es.js +6 -3
- package/style.css +1 -1
- package/table/index.es.js +117 -62
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tag/index.es.js +2 -1
- package/tag-input/index.es.js +4 -2
- package/time-picker/index.es.js +43 -42
- package/time-picker/index.umd.js +1 -1
- package/{time-axis → timeline}/index.d.ts +0 -0
- package/{time-axis → timeline}/index.es.js +65 -78
- package/timeline/index.umd.js +1 -0
- package/{time-axis → timeline}/package.json +1 -1
- package/timeline/style.css +1 -0
- package/tooltip/index.es.js +44 -37
- package/tooltip/index.umd.js +6 -6
- package/tooltip/style.css +1 -1
- package/transfer/index.es.js +84 -77
- package/transfer/index.umd.js +7 -7
- package/transfer/style.css +1 -1
- package/tree/index.es.js +10 -5
- package/tree-select/index.es.js +8 -4
- package/upload/index.es.js +38 -40
- package/upload/index.umd.js +1 -1
- package/vue-devui.es.js +771 -649
- package/vue-devui.umd.js +9 -9
- package/nuxt/components/TimeAxis.js +0 -3
- package/nuxt/components/TimeAxisItem.js +0 -3
- package/time-axis/index.umd.js +0 -1
- package/time-axis/style.css +0 -1
package/tree/index.es.js
CHANGED
|
@@ -451,8 +451,9 @@ function useToggle(data) {
|
|
|
451
451
|
watch(() => data.value, (d) => openedData.value = openedTree(d), { deep: true });
|
|
452
452
|
const toggle = (target, item) => {
|
|
453
453
|
target.stopPropagation();
|
|
454
|
-
if (!item.children)
|
|
454
|
+
if (!item.children) {
|
|
455
455
|
return;
|
|
456
|
+
}
|
|
456
457
|
item.open = !item.open;
|
|
457
458
|
openedData.value = openedTree(data.value);
|
|
458
459
|
};
|
|
@@ -506,12 +507,15 @@ const useHighlightNode = () => {
|
|
|
506
507
|
return key;
|
|
507
508
|
};
|
|
508
509
|
const handleClick = (key) => {
|
|
509
|
-
if (nodeClassNameReflectRef.value[key] === IS_DISABLED_FLAG)
|
|
510
|
+
if (nodeClassNameReflectRef.value[key] === IS_DISABLED_FLAG) {
|
|
510
511
|
return;
|
|
511
|
-
|
|
512
|
+
}
|
|
513
|
+
if (prevActiveNodeKey.value === key) {
|
|
512
514
|
return;
|
|
513
|
-
|
|
515
|
+
}
|
|
516
|
+
if (prevActiveNodeKey.value) {
|
|
514
517
|
nodeClassNameReflectRef.value[prevActiveNodeKey.value] = "";
|
|
518
|
+
}
|
|
515
519
|
nodeClassNameReflectRef.value[key] = HIGHLIGHT_CLASS;
|
|
516
520
|
prevActiveNodeKey.value = key;
|
|
517
521
|
};
|
|
@@ -6131,8 +6135,9 @@ function useDraggable(draggable, dropType, node, renderData, data) {
|
|
|
6131
6135
|
let nowDragNode;
|
|
6132
6136
|
let nowDropNode;
|
|
6133
6137
|
const findDragAndDropNode = (curr) => {
|
|
6134
|
-
if (!Array.isArray(curr))
|
|
6138
|
+
if (!Array.isArray(curr)) {
|
|
6135
6139
|
return;
|
|
6140
|
+
}
|
|
6136
6141
|
curr.every((item, index2) => {
|
|
6137
6142
|
if (nowDragNode && nowDropNode) {
|
|
6138
6143
|
return false;
|
package/tree-select/index.es.js
CHANGED
|
@@ -100,8 +100,9 @@ function className(classStr, classOpt) {
|
|
|
100
100
|
function useToggle(props) {
|
|
101
101
|
const visible = ref(false);
|
|
102
102
|
const selectToggle = () => {
|
|
103
|
-
if (props.disabled)
|
|
103
|
+
if (props.disabled) {
|
|
104
104
|
return;
|
|
105
|
+
}
|
|
105
106
|
visible.value = !visible.value;
|
|
106
107
|
};
|
|
107
108
|
const treeToggle = (e, item) => {
|
|
@@ -123,8 +124,9 @@ function useSelect(props) {
|
|
|
123
124
|
inputValue.value = item.label;
|
|
124
125
|
} else {
|
|
125
126
|
item.checked = !item.checked;
|
|
126
|
-
if (item.halfchecked)
|
|
127
|
+
if (item.halfchecked) {
|
|
127
128
|
item.halfchecked = false;
|
|
129
|
+
}
|
|
128
130
|
useCache(item);
|
|
129
131
|
searchUp(item);
|
|
130
132
|
searchDown(item);
|
|
@@ -135,8 +137,9 @@ function useSelect(props) {
|
|
|
135
137
|
item.checked === true ? selectedCache.add(item.label) : selectedCache.has(item.label) && selectedCache.delete(item.label);
|
|
136
138
|
};
|
|
137
139
|
const searchUp = (item) => {
|
|
138
|
-
if (!item.parent)
|
|
140
|
+
if (!item.parent) {
|
|
139
141
|
return;
|
|
142
|
+
}
|
|
140
143
|
let state = "";
|
|
141
144
|
const checkedArr = item.parent.children.filter((el) => el.checked === true);
|
|
142
145
|
switch (checkedArr.length) {
|
|
@@ -164,8 +167,9 @@ function useSelect(props) {
|
|
|
164
167
|
searchUp(item.parent);
|
|
165
168
|
};
|
|
166
169
|
const searchDown = (item) => {
|
|
167
|
-
if (!item.children)
|
|
170
|
+
if (!item.children) {
|
|
168
171
|
return;
|
|
172
|
+
}
|
|
169
173
|
item.children.forEach((el) => {
|
|
170
174
|
el.checked = item.checked;
|
|
171
175
|
useCache(el);
|
package/upload/index.es.js
CHANGED
|
@@ -21,7 +21,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21
21
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
|
-
import { defineComponent,
|
|
24
|
+
import { defineComponent, toRefs, createVNode, computed, watch, Transition, reactive, createApp, onUnmounted, mergeProps, isVNode, ref, withDirectives, resolveComponent, resolveDirective } from "vue";
|
|
25
25
|
const notificationProps = {
|
|
26
26
|
modelValue: {
|
|
27
27
|
type: Boolean,
|
|
@@ -43,55 +43,53 @@ const notificationProps = {
|
|
|
43
43
|
type: Function
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
+
const iconProps = {
|
|
47
|
+
name: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "",
|
|
50
|
+
required: true
|
|
51
|
+
},
|
|
52
|
+
size: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "inherit"
|
|
55
|
+
},
|
|
56
|
+
color: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: "inherit"
|
|
59
|
+
},
|
|
60
|
+
classPrefix: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: "icon"
|
|
63
|
+
}
|
|
64
|
+
};
|
|
46
65
|
var Icon = defineComponent({
|
|
47
66
|
name: "DIcon",
|
|
48
|
-
props:
|
|
49
|
-
name: {
|
|
50
|
-
type: String,
|
|
51
|
-
required: true
|
|
52
|
-
},
|
|
53
|
-
size: {
|
|
54
|
-
type: String,
|
|
55
|
-
default: "inherit"
|
|
56
|
-
},
|
|
57
|
-
color: {
|
|
58
|
-
type: String,
|
|
59
|
-
default: "inherit"
|
|
60
|
-
},
|
|
61
|
-
classPrefix: {
|
|
62
|
-
type: String,
|
|
63
|
-
default: "icon"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
67
|
+
props: iconProps,
|
|
66
68
|
setup(props) {
|
|
67
|
-
return __spreadValues({}, props);
|
|
68
|
-
},
|
|
69
|
-
render() {
|
|
70
69
|
const {
|
|
71
70
|
name,
|
|
72
71
|
size,
|
|
73
72
|
color,
|
|
74
73
|
classPrefix
|
|
75
|
-
} =
|
|
76
|
-
return
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
} = toRefs(props);
|
|
75
|
+
return () => {
|
|
76
|
+
return /^((https?):)?\/\//.test(name.value) ? createVNode("img", {
|
|
77
|
+
"src": name.value,
|
|
78
|
+
"alt": name.value.split("/")[name.value.split("/").length - 1],
|
|
79
|
+
"style": {
|
|
80
|
+
width: size.value,
|
|
81
|
+
verticalAlign: "text-bottom"
|
|
82
|
+
}
|
|
83
|
+
}, null) : createVNode("i", {
|
|
84
|
+
"class": `${classPrefix.value} ${classPrefix.value}-${name.value}`,
|
|
85
|
+
"style": {
|
|
86
|
+
fontSize: size.value,
|
|
87
|
+
color: color.value
|
|
88
|
+
}
|
|
89
|
+
}, null);
|
|
90
|
+
};
|
|
90
91
|
}
|
|
91
92
|
});
|
|
92
|
-
Icon.install = function(app) {
|
|
93
|
-
app.component(Icon.name, Icon);
|
|
94
|
-
};
|
|
95
93
|
var Close = defineComponent({
|
|
96
94
|
emits: ["click"],
|
|
97
95
|
setup(props, {
|
package/upload/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Ae=Object.defineProperty,xe=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var Me=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable;var P=(f,t,E)=>t in f?Ae(f,t,{enumerable:!0,configurable:!0,writable:!0,value:E}):f[t]=E,x=(f,t)=>{for(var E in t||(t={}))Me.call(t,E)&&P(f,E,t[E]);if(G)for(var E of G(t))Be.call(t,E)&&P(f,E,t[E]);return f},Y=(f,t)=>xe(f,Oe(t));var g=(f,t,E)=>(P(f,typeof t!="symbol"?t+"":t,E),E);(function(f,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(f=typeof globalThis!="undefined"?globalThis:f||self,t(f.index={},f.Vue))})(this,function(f,t){"use strict";const E={modelValue:{type:Boolean,default:!1},title:{type:String,default:""},type:{type:String,default:"normal"},duration:{type:Number,default:3e3},onClose:{type:Function}};var D=t.defineComponent({name:"DIcon",props:{name:{type:String,required:!0},size:{type:String,default:"inherit"},color:{type:String,default:"inherit"},classPrefix:{type:String,default:"icon"}},setup(e){return x({},e)},render(){const{name:e,size:o,color:n,classPrefix:l}=this;return/^((https?):)?\/\//.test(e)?t.createVNode("img",{src:e,alt:e.split("/")[e.split("/").length-1],style:{width:o,verticalAlign:"text-bottom"}},null):t.createVNode("i",{class:`${l} ${l}-${e}`,style:{fontSize:o,color:n}},null)}});D.install=function(e){e.component(D.name,D)};var Z=t.defineComponent({emits:["click"],setup(e,{emit:o}){return()=>t.createVNode("div",{class:"devui-notification-icon-close",onClick:n=>o("click",n)},[t.createVNode(D,{name:"close",size:"14px"},null)])}}),J=t.defineComponent({props:{type:{type:String,default:"normal"}},setup(e){const{type:o}=t.toRefs(e),n=t.computed(()=>({"devui-notification-image":!0,[`devui-notification-image-${o.value}`]:!0})),l={info:"info-o",success:"right-o",warning:"warning-o",error:"error-o"};return()=>t.createVNode("span",{class:n.value},[o.value!=="normal"&&t.createVNode(D,{name:l[o.value],size:"16px"},null)])}});function K(e){return{classes:t.computed(()=>({"devui-notification-item-container":!0,[`devui-notification-message-${e.type}`]:!0}))}}function Q(e,o){let n=null,l;const s=()=>{var N;clearTimeout(n),n=null,(N=e.onClose)==null||N.call(e),o("update:modelValue",!1)},m=()=>{n&&(clearTimeout(n),n=null)},y=()=>{if(!e.modelValue){const N=e.duration-(Date.now()-l);n=setTimeout(s,N)}},C=()=>{o("destroy")};return t.watch(()=>e.modelValue,N=>{N&&(l=Date.now(),e.duration&&(n=setTimeout(s,e.duration)))}),{interrupt:m,removeReset:y,close:s,handleDestroy:C}}var Le="",ee=t.defineComponent({name:"DNotification",props:E,emits:["update:modelValue","destroy"],setup(e,{emit:o,slots:n}){const{modelValue:l,title:s,type:m}=t.toRefs(e),{classes:y}=K(e),{interrupt:C,removeReset:N,close:u,handleDestroy:r}=Q(e,o);return()=>t.createVNode(t.Transition,{name:"notification-fade",onAfterLeave:r},{default:()=>{var v;return[l.value&&t.createVNode("div",{class:"devui-notification"},[t.createVNode("div",{class:y.value,onMouseenter:C,onMouseleave:N},[t.createVNode("div",{class:"devui-notification-item"},[t.createVNode(Z,{onClick:u},null),s.value&&t.createVNode(J,{type:m.value},null),t.createVNode("div",{class:"devui-notification-message"},[t.createVNode("span",{class:"devui-notification-title"},[s.value]),t.createVNode("span",{class:"devui-notification-content"},[(v=n.default)==null?void 0:v.call(n)])])])])])]}})}});function te(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const oe={modelValue:!1,duration:3e3,type:"normal"};function ne(e,o){const n=document.createElement("div"),l=t.createApp({setup(){return t.onUnmounted(()=>{document.body.removeChild(n)}),()=>t.createVNode(ee,t.mergeProps(e,{onDestroy:l.unmount}),te(o)?o:{default:()=>[o]})}});return document.body.appendChild(n),l.mount(n),l}function ie(e,o){e.modelValue=!1,o==null||o()}class le{static open(o){const n=o.onClose||null,l=o.content;let s;delete o.content;const m=t.reactive(Y(x(x({},oe),o),{onClose:()=>{ie(m,n)}}));ne(m,l),m.modelValue=!0,clearTimeout(s),o.duration&&(s=setTimeout(m.onClose,o.duration))}}class ae{constructor(){g(this,"uri");g(this,"method");g(this,"maximumSize");g(this,"headers");g(this,"authToken");g(this,"authTokenHeader");g(this,"additionalParameter");g(this,"fileFieldName");g(this,"checkSameName");g(this,"withCredentials");g(this,"responseType")}}class se{constructor(){g(this,"accept");g(this,"multiple");g(this,"webkitdirectory")}}var F=(e=>(e[e.preLoad=0]="preLoad",e[e.uploading=1]="uploading",e[e.uploaded=2]="uploaded",e[e.failed=3]="failed",e))(F||{});const z={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}},re=e=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${e}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,ue=(e,o)=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${o}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${e}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,ce=(e,o)=>`\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${o}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${e}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,de=e=>`\u60A8\u4E0A\u4F20\u7684 "${e}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,pe=()=>{const e=t.ref(""),o=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)},n=({multiple:u,accept:r,webkitdirectory:v})=>new Promise(b=>{const a=document.getElementById("d-upload-temp");a&&document.body.removeChild(a);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),v&&i.setAttribute("webkitdirectory",""),i.addEventListener("change",h=>{b(Array.prototype.slice.call(h.target.files))}),document.body.appendChild(i),o(i)}),l=(u,r)=>{if(u){const v=u.split(","),b=r.type.replace(/\/.*$/,"");return v.some(a=>{const i=a.trim();return i.startsWith(".")?r.name.toLowerCase().indexOf(i.toLowerCase(),r.name.toLowerCase().length-i.toLowerCase().length)>-1:/\/\*$/.test(i)?b===i.replace(/\/.*$/,""):r.type===i})}return!0},s=(u,r)=>r?u>1024*1024*r:!1;return{triggerSelectFiles:u=>{const{multiple:r,accept:v,webkitdirectory:b}=u;return n({multiple:r,accept:v,webkitdirectory:b})},_validateFiles:(u,r,v)=>l(r,u)?v&&s(u.size,v.maximumSize)?{checkError:!0,errorMsg:ue(u.name,v.maximumSize)}:{checkError:!1,errorMsg:void 0}:{checkError:!0,errorMsg:ce(u.name,r)},triggerDropFiles:u=>Promise.resolve(u),checkAllFilesSize:(u,r)=>{if(s(u,r))return e.value=re(r),{checkError:!0,errorMsg:e.value}}}};class _{constructor(o,n){g(this,"xhr");g(this,"status");g(this,"response");g(this,"percentage",0);this.file=o,this.uploadOptions=n,this.file=o,this.uploadOptions=n,this.status=F.preLoad}send(o){return new Promise((n,l)=>{const{uri:s,method:m,headers:y,authToken:C,authTokenHeader:N,additionalParameter:u,fileFieldName:r,withCredentials:v,responseType:b}=this.uploadOptions,a=N||"Authorization",i=r||"file";this.xhr=new XMLHttpRequest,this.xhr.open(m||"POST",s),v&&(this.xhr.withCredentials=v),b&&(this.xhr.responseType=b),C&&this.xhr.setRequestHeader(a,C),y&&Object.keys(y).forEach(S=>{this.xhr.setRequestHeader(S,y[S])}),this.xhr.upload.onprogress=S=>{this.percentage=Math.round(S.loaded*100/S.total)};const h=o&&o.length?this.oneTimeUploadFiles(i,u,o):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=()=>{this.response=this.xhr.response,this.status=F.failed,l({file:this.file,response:this.xhr.response})},this.xhr.onload=()=>{this.xhr.readyState===4&&this.xhr.status>=200&&this.xhr.status<300?(this.response=this.xhr.response,this.status=F.uploaded,n({file:this.file,response:this.xhr.response})):(this.response=this.xhr.response,this.status=F.failed,l({file:this.file,response:this.xhr.response}))}})}parallelUploadFiles(o,n){const l=new FormData;return l.append(o,this.file,this.file.name),n&&Object.keys(n).forEach(s=>{l.append(s,n[s])}),l}oneTimeUploadFiles(o,n,l){const s=new FormData;return l.forEach(m=>{s.append(o,m.file,m.file.name),n&&Object.keys(n).forEach(y=>{s.append(y,n[y])})}),s}cancel(){this.xhr&&this.xhr.abort()}}const fe=()=>{const e=t.ref([]),o=t.ref([]),n=a=>{let i=!0;for(let h=0;h<e.value.length;h++)if(a===e.value[h].file.name){i=!1,o.value.indexOf(a)===-1&&o.value.push(a);break}return i},l=(a,i)=>{i&&i.checkSameName?n(a.name)&&e.value.push(new _(a,i)):e.value.push(new _(a,i))},s=()=>e.value.map(a=>a.file),m=()=>e.value.map(a=>a),y=async a=>{if(!a||!a.length)return Promise.reject("no files");let i=[];return await a[0].send(a).finally(()=>i=a.map(h=>(h.status=a[0].status,h.percentage=a[0].percentage,{file:h.file,response:a[0].response}))),i};return{fileUploaders:e,getFiles:s,addFile:l,getFullFiles:m,deleteFile:a=>{e.value.find(h=>h.file===a).cancel(),e.value=e.value.filter(h=>a!==h.file)},upload:async a=>{let i=[];if(a){a.percentage=0;const h=await a.send();i.push(h)}else{const h=e.value.filter(k=>k.status===F.preLoad),S=e.value.filter(k=>k.status===F.failed),w=h.length>0?h:S;i=await Promise.all(w.map(async k=>(k.percentage=0,await k.send())))}return i.length>0?Promise.resolve(i):Promise.reject("no files")},removeFiles:()=>{e.value=[],o.value=[]},getSameNameFiles:()=>o.value.join(),resetSameNameFiles:()=>{o.value=[]},_oneTimeUpload:()=>{const a=e.value.filter(i=>i.status!==F.uploaded);return y(a)}}};var $e="",O=t.defineComponent({name:"DUpload",props:z,emits:["fileDrop","fileOver","fileSelect","deleteUploadedFile","update:modelValue"],setup(e,o){const{uploadOptions:n,placeholder:l,autoUpload:s,disabled:m,beforeUpload:y,droppable:C,oneTimeUpload:N,modelValue:u,multiple:r,accept:v,webkitdirectory:b}=t.toRefs(e),{triggerSelectFiles:a,_validateFiles:i,triggerDropFiles:h,checkAllFilesSize:S}=pe(),{fileUploaders:w,addFile:k,getFullFiles:R,deleteFile:j,upload:Ee,resetSameNameFiles:Ne,removeFiles:B,_oneTimeUpload:Ve,getSameNameFiles:be}=fe(),L=t.ref(!1);t.ref("");const A=d=>{le.open({type:"warning",content:d})},Ce=()=>{let d=0;if(w.value.forEach(p=>{d+=p.file.size;const V=i(p.file,v.value,p.uploadOptions);if(V&&V.checkError){j(p.file),A(V.errorMsg);return}}),N.value){const p=S(d,n.value.maximumSize);p&&p.checkError&&(B(),A(p.errorMsg))}},H=d=>{Ne(),d.then(p=>{p.forEach(c=>{r.value||B(),k(c,n.value)}),Ce();const V=be();n.value&&n.value.checkSameName&&V.length&&A(de(V));const T=w.value.filter(c=>c.status===F.preLoad).map(c=>c.file);o.emit("fileSelect",T),s.value&&W()}).catch(p=>{A(p.message)})},q=()=>{m.value||H(a({accept:v.value,multiple:r.value,webkitdirectory:b.value}))},Se=d=>{L.value=!1,H(h(d)),o.emit("fileDrop",d)},ke=d=>{L.value=d,o.emit("fileOver",d)},U=d=>{const p=u.value.filter(V=>V.name!==d.name);o.emit("deleteUploadedFile",d),o.emit("update:modelValue",p)},we=(d,p,V)=>{d.stopPropagation(),V===F.uploaded&&U(p),j(p)},De=()=>{let d=Promise.resolve(!0);if(y.value){const p=y.value(R());typeof p!="undefined"&&(p.then?d=p:d=Promise.resolve(p))}return d},W=(d,p)=>{d&&d.stopPropagation(),De().then(V=>{if(!V){B();return}(N.value?Ve():Ee(p)).then(c=>{e["on-success"]&&e["on-success"](c);const $=[...c.map(Te=>Te.file),...u.value];o.emit("update:modelValue",$)}).catch(c=>{e["on-error"]&&e["on-error"](c)})})};return()=>{var d,p,V,T;return t.createVNode("div",null,[t.withDirectives(t.createVNode("div",{class:"devui-upload",style:`border: ${L.value?"1px solid #15bf15":"0"}`},[((p=(d=o.slots).default)==null?void 0:p.call(d))?t.createVNode("div",{onClick:q},[o.slots.default()]):t.createVNode("div",{class:`devui-input-group ${m.value?"disabled":""}`,onClick:q},[w.value.length===0&&t.createVNode("div",{class:"devui-form-control devui-upload-placeholder"},[l.value]),w.value.length>0&&t.createVNode("ul",{class:"devui-form-control devui-files-list"},[w.value.map((c,X)=>t.createVNode("li",{key:X,class:"devui-file-item devui-file-tag",style:"display: inline-block; margin: 0 2px 2px 0",title:c.file.name},[t.createVNode("span",{class:`devui-filename ${c.status===F.failed?"devui-failed-color":""}`},[c.file.name]),t.createVNode(t.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:$=>we($,c.file,c.status)},null),c.status===F.uploading&&t.createVNode("div",{class:"icon devui-upload-progress"},[t.createVNode(t.resolveComponent("d-progress"),{isCircle:!0,percentage:c.percentage,barbgcolor:"#50D4AB",strokeWidth:8,showContent:!1},null)]),c.status===F.failed&&t.createVNode(t.resolveComponent("d-icon"),{name:"running",onClick:W},null),c.status===F.uploaded&&t.createVNode(t.resolveComponent("d-icon"),{name:"right",color:"#50d4ab"},null)]))]),t.createVNode("span",{class:"devui-input-group-addon"},[t.createVNode(t.resolveComponent("d-icon"),{name:"more-operate",color:"#252b3a"},null)])])]),[[t.resolveDirective("file-drop"),{droppable:C,isSingle:!r,onFileDrop:Se,onFileOver:ke}]]),t.createVNode("div",null,[(T=(V=o.slots)["uploaded-files"])==null?void 0:T.call(V,{uploadedFiles:u.value,deleteFile:U})])])}}});const I=e=>{var o;return e.dataTransfer?e.dataTransfer:(o=e.originalEvent)==null?void 0:o.dataTransfer},me=e=>e?e.indexOf?e.indexOf("Files")!==-1:e.contains?e.contains("Files"):!1:!1,M=e=>{e.preventDefault(),e.stopPropagation()},he=(e,o)=>{const{onFileOver:n}=o.value;e.addEventListener("dragover",l=>{const s=I(l);!me(s.types)||(M(l),n&&n(!0))})},Fe=(e,o)=>{const{onFileOver:n}=o.value;e.addEventListener("dragleave",l=>{l.currentTarget!==e&&(M(l),n&&n(!0))})},ve=(e,o)=>{const{onFileDrop:n,isSingle:l}=o.value;e.addEventListener("drop",s=>{const m=I(s);!m||(M(s),l?n&&n([m.files[0]]):n&&n(Array.from(m.files)))})},ge={mounted:(e,o)=>{const{droppable:n}=o.value;!n||(he(e,o),Fe(e,o),ve(e,o))}};var ye={title:"Upload \u4E0A\u4F20",category:"\u6570\u636E\u5F55\u5165",status:"100%",install(e){e.directive("file-drop",ge),e.component(O.name,O)}};f.IFileOptions=se,f.IUploadOptions=ae,f.Upload=O,f.UploadStatus=F,f.default=ye,f.uploadProps=z,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module"});
|
|
1
|
+
var xe=Object.defineProperty,Oe=Object.defineProperties;var Me=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var Be=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var L=(f,t,E)=>t in f?xe(f,t,{enumerable:!0,configurable:!0,writable:!0,value:E}):f[t]=E,P=(f,t)=>{for(var E in t||(t={}))Be.call(t,E)&&L(f,E,t[E]);if(G)for(var E of G(t))Le.call(t,E)&&L(f,E,t[E]);return f},Y=(f,t)=>Oe(f,Me(t));var g=(f,t,E)=>(L(f,typeof t!="symbol"?t+"":t,E),E);(function(f,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(f=typeof globalThis!="undefined"?globalThis:f||self,t(f.index={},f.Vue))})(this,function(f,t){"use strict";const E={modelValue:{type:Boolean,default:!1},title:{type:String,default:""},type:{type:String,default:"normal"},duration:{type:Number,default:3e3},onClose:{type:Function}},Z={name:{type:String,default:"",required:!0},size:{type:String,default:"inherit"},color:{type:String,default:"inherit"},classPrefix:{type:String,default:"icon"}};var $=t.defineComponent({name:"DIcon",props:Z,setup(e){const{name:o,size:n,color:a,classPrefix:s}=t.toRefs(e);return()=>/^((https?):)?\/\//.test(o.value)?t.createVNode("img",{src:o.value,alt:o.value.split("/")[o.value.split("/").length-1],style:{width:n.value,verticalAlign:"text-bottom"}},null):t.createVNode("i",{class:`${s.value} ${s.value}-${o.value}`,style:{fontSize:n.value,color:a.value}},null)}}),J=t.defineComponent({emits:["click"],setup(e,{emit:o}){return()=>t.createVNode("div",{class:"devui-notification-icon-close",onClick:n=>o("click",n)},[t.createVNode($,{name:"close",size:"14px"},null)])}}),K=t.defineComponent({props:{type:{type:String,default:"normal"}},setup(e){const{type:o}=t.toRefs(e),n=t.computed(()=>({"devui-notification-image":!0,[`devui-notification-image-${o.value}`]:!0})),a={info:"info-o",success:"right-o",warning:"warning-o",error:"error-o"};return()=>t.createVNode("span",{class:n.value},[o.value!=="normal"&&t.createVNode($,{name:a[o.value],size:"16px"},null)])}});function Q(e){return{classes:t.computed(()=>({"devui-notification-item-container":!0,[`devui-notification-message-${e.type}`]:!0}))}}function ee(e,o){let n=null,a;const s=()=>{var N;clearTimeout(n),n=null,(N=e.onClose)==null||N.call(e),o("update:modelValue",!1)},m=()=>{n&&(clearTimeout(n),n=null)},y=()=>{if(!e.modelValue){const N=e.duration-(Date.now()-a);n=setTimeout(s,N)}},C=()=>{o("destroy")};return t.watch(()=>e.modelValue,N=>{N&&(a=Date.now(),e.duration&&(n=setTimeout(s,e.duration)))}),{interrupt:m,removeReset:y,close:s,handleDestroy:C}}var Pe="",te=t.defineComponent({name:"DNotification",props:E,emits:["update:modelValue","destroy"],setup(e,{emit:o,slots:n}){const{modelValue:a,title:s,type:m}=t.toRefs(e),{classes:y}=Q(e),{interrupt:C,removeReset:N,close:u,handleDestroy:r}=ee(e,o);return()=>t.createVNode(t.Transition,{name:"notification-fade",onAfterLeave:r},{default:()=>{var v;return[a.value&&t.createVNode("div",{class:"devui-notification"},[t.createVNode("div",{class:y.value,onMouseenter:C,onMouseleave:N},[t.createVNode("div",{class:"devui-notification-item"},[t.createVNode(J,{onClick:u},null),s.value&&t.createVNode(K,{type:m.value},null),t.createVNode("div",{class:"devui-notification-message"},[t.createVNode("span",{class:"devui-notification-title"},[s.value]),t.createVNode("span",{class:"devui-notification-content"},[(v=n.default)==null?void 0:v.call(n)])])])])])]}})}});function oe(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const ne={modelValue:!1,duration:3e3,type:"normal"};function ie(e,o){const n=document.createElement("div"),a=t.createApp({setup(){return t.onUnmounted(()=>{document.body.removeChild(n)}),()=>t.createVNode(te,t.mergeProps(e,{onDestroy:a.unmount}),oe(o)?o:{default:()=>[o]})}});return document.body.appendChild(n),a.mount(n),a}function le(e,o){e.modelValue=!1,o==null||o()}class ae{static open(o){const n=o.onClose||null,a=o.content;let s;delete o.content;const m=t.reactive(Y(P(P({},ne),o),{onClose:()=>{le(m,n)}}));ie(m,a),m.modelValue=!0,clearTimeout(s),o.duration&&(s=setTimeout(m.onClose,o.duration))}}class se{constructor(){g(this,"uri");g(this,"method");g(this,"maximumSize");g(this,"headers");g(this,"authToken");g(this,"authTokenHeader");g(this,"additionalParameter");g(this,"fileFieldName");g(this,"checkSameName");g(this,"withCredentials");g(this,"responseType")}}class re{constructor(){g(this,"accept");g(this,"multiple");g(this,"webkitdirectory")}}var F=(e=>(e[e.preLoad=0]="preLoad",e[e.uploading=1]="uploading",e[e.uploaded=2]="uploaded",e[e.failed=3]="failed",e))(F||{});const z={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}},ue=e=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${e}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,ce=(e,o)=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${o}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${e}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,de=(e,o)=>`\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${o}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${e}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,pe=e=>`\u60A8\u4E0A\u4F20\u7684 "${e}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,fe=()=>{const e=t.ref(""),o=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)},n=({multiple:u,accept:r,webkitdirectory:v})=>new Promise(b=>{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),v&&i.setAttribute("webkitdirectory",""),i.addEventListener("change",h=>{b(Array.prototype.slice.call(h.target.files))}),document.body.appendChild(i),o(i)}),a=(u,r)=>{if(u){const v=u.split(","),b=r.type.replace(/\/.*$/,"");return v.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)?b===i.replace(/\/.*$/,""):r.type===i})}return!0},s=(u,r)=>r?u>1024*1024*r:!1;return{triggerSelectFiles:u=>{const{multiple:r,accept:v,webkitdirectory:b}=u;return n({multiple:r,accept:v,webkitdirectory:b})},_validateFiles:(u,r,v)=>a(r,u)?v&&s(u.size,v.maximumSize)?{checkError:!0,errorMsg:ce(u.name,v.maximumSize)}:{checkError:!1,errorMsg:void 0}:{checkError:!0,errorMsg:de(u.name,r)},triggerDropFiles:u=>Promise.resolve(u),checkAllFilesSize:(u,r)=>{if(s(u,r))return e.value=ue(r),{checkError:!0,errorMsg:e.value}}}};class _{constructor(o,n){g(this,"xhr");g(this,"status");g(this,"response");g(this,"percentage",0);this.file=o,this.uploadOptions=n,this.file=o,this.uploadOptions=n,this.status=F.preLoad}send(o){return new Promise((n,a)=>{const{uri:s,method:m,headers:y,authToken:C,authTokenHeader:N,additionalParameter:u,fileFieldName:r,withCredentials:v,responseType:b}=this.uploadOptions,l=N||"Authorization",i=r||"file";this.xhr=new XMLHttpRequest,this.xhr.open(m||"POST",s),v&&(this.xhr.withCredentials=v),b&&(this.xhr.responseType=b),C&&this.xhr.setRequestHeader(l,C),y&&Object.keys(y).forEach(S=>{this.xhr.setRequestHeader(S,y[S])}),this.xhr.upload.onprogress=S=>{this.percentage=Math.round(S.loaded*100/S.total)};const h=o&&o.length?this.oneTimeUploadFiles(i,u,o):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=()=>{this.response=this.xhr.response,this.status=F.failed,a({file:this.file,response:this.xhr.response})},this.xhr.onload=()=>{this.xhr.readyState===4&&this.xhr.status>=200&&this.xhr.status<300?(this.response=this.xhr.response,this.status=F.uploaded,n({file:this.file,response:this.xhr.response})):(this.response=this.xhr.response,this.status=F.failed,a({file:this.file,response:this.xhr.response}))}})}parallelUploadFiles(o,n){const a=new FormData;return a.append(o,this.file,this.file.name),n&&Object.keys(n).forEach(s=>{a.append(s,n[s])}),a}oneTimeUploadFiles(o,n,a){const s=new FormData;return a.forEach(m=>{s.append(o,m.file,m.file.name),n&&Object.keys(n).forEach(y=>{s.append(y,n[y])})}),s}cancel(){this.xhr&&this.xhr.abort()}}const me=()=>{const e=t.ref([]),o=t.ref([]),n=l=>{let i=!0;for(let h=0;h<e.value.length;h++)if(l===e.value[h].file.name){i=!1,o.value.indexOf(l)===-1&&o.value.push(l);break}return i},a=(l,i)=>{i&&i.checkSameName?n(l.name)&&e.value.push(new _(l,i)):e.value.push(new _(l,i))},s=()=>e.value.map(l=>l.file),m=()=>e.value.map(l=>l),y=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:e,getFiles:s,addFile:a,getFullFiles:m,deleteFile:l=>{e.value.find(h=>h.file===l).cancel(),e.value=e.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=e.value.filter(k=>k.status===F.preLoad),S=e.value.filter(k=>k.status===F.failed),w=h.length>0?h:S;i=await Promise.all(w.map(async k=>(k.percentage=0,await k.send())))}return i.length>0?Promise.resolve(i):Promise.reject("no files")},removeFiles:()=>{e.value=[],o.value=[]},getSameNameFiles:()=>o.value.join(),resetSameNameFiles:()=>{o.value=[]},_oneTimeUpload:()=>{const l=e.value.filter(i=>i.status!==F.uploaded);return y(l)}}};var $e="",A=t.defineComponent({name:"DUpload",props:z,emits:["fileDrop","fileOver","fileSelect","deleteUploadedFile","update:modelValue"],setup(e,o){const{uploadOptions:n,placeholder:a,autoUpload:s,disabled:m,beforeUpload:y,droppable:C,oneTimeUpload:N,modelValue:u,multiple:r,accept:v,webkitdirectory:b}=t.toRefs(e),{triggerSelectFiles:l,_validateFiles:i,triggerDropFiles:h,checkAllFilesSize:S}=fe(),{fileUploaders:w,addFile:k,getFullFiles:R,deleteFile:j,upload:Ne,resetSameNameFiles:Ve,removeFiles:O,_oneTimeUpload:be,getSameNameFiles:Ce}=me(),M=t.ref(!1);t.ref("");const T=d=>{ae.open({type:"warning",content:d})},Se=()=>{let d=0;if(w.value.forEach(p=>{d+=p.file.size;const V=i(p.file,v.value,p.uploadOptions);if(V&&V.checkError){j(p.file),T(V.errorMsg);return}}),N.value){const p=S(d,n.value.maximumSize);p&&p.checkError&&(O(),T(p.errorMsg))}},H=d=>{Ve(),d.then(p=>{p.forEach(c=>{r.value||O(),k(c,n.value)}),Se();const V=Ce();n.value&&n.value.checkSameName&&V.length&&T(pe(V));const D=w.value.filter(c=>c.status===F.preLoad).map(c=>c.file);o.emit("fileSelect",D),s.value&&W()}).catch(p=>{T(p.message)})},q=()=>{m.value||H(l({accept:v.value,multiple:r.value,webkitdirectory:b.value}))},ke=d=>{M.value=!1,H(h(d)),o.emit("fileDrop",d)},we=d=>{M.value=d,o.emit("fileOver",d)},U=d=>{const p=u.value.filter(V=>V.name!==d.name);o.emit("deleteUploadedFile",d),o.emit("update:modelValue",p)},De=(d,p,V)=>{d.stopPropagation(),V===F.uploaded&&U(p),j(p)},Te=()=>{let d=Promise.resolve(!0);if(y.value){const p=y.value(R());typeof p!="undefined"&&(p.then?d=p:d=Promise.resolve(p))}return d},W=(d,p)=>{d&&d.stopPropagation(),Te().then(V=>{if(!V){O();return}(N.value?be():Ne(p)).then(c=>{e["on-success"]&&e["on-success"](c);const B=[...c.map(Ae=>Ae.file),...u.value];o.emit("update:modelValue",B)}).catch(c=>{e["on-error"]&&e["on-error"](c)})})};return()=>{var d,p,V,D;return t.createVNode("div",null,[t.withDirectives(t.createVNode("div",{class:"devui-upload",style:`border: ${M.value?"1px solid #15bf15":"0"}`},[((p=(d=o.slots).default)==null?void 0:p.call(d))?t.createVNode("div",{onClick:q},[o.slots.default()]):t.createVNode("div",{class:`devui-input-group ${m.value?"disabled":""}`,onClick:q},[w.value.length===0&&t.createVNode("div",{class:"devui-form-control devui-upload-placeholder"},[a.value]),w.value.length>0&&t.createVNode("ul",{class:"devui-form-control devui-files-list"},[w.value.map((c,X)=>t.createVNode("li",{key:X,class:"devui-file-item devui-file-tag",style:"display: inline-block; margin: 0 2px 2px 0",title:c.file.name},[t.createVNode("span",{class:`devui-filename ${c.status===F.failed?"devui-failed-color":""}`},[c.file.name]),t.createVNode(t.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=>De(B,c.file,c.status)},null),c.status===F.uploading&&t.createVNode("div",{class:"icon devui-upload-progress"},[t.createVNode(t.resolveComponent("d-progress"),{isCircle:!0,percentage:c.percentage,barbgcolor:"#50D4AB",strokeWidth:8,showContent:!1},null)]),c.status===F.failed&&t.createVNode(t.resolveComponent("d-icon"),{name:"running",onClick:W},null),c.status===F.uploaded&&t.createVNode(t.resolveComponent("d-icon"),{name:"right",color:"#50d4ab"},null)]))]),t.createVNode("span",{class:"devui-input-group-addon"},[t.createVNode(t.resolveComponent("d-icon"),{name:"more-operate",color:"#252b3a"},null)])])]),[[t.resolveDirective("file-drop"),{droppable:C,isSingle:!r,onFileDrop:ke,onFileOver:we}]]),t.createVNode("div",null,[(D=(V=o.slots)["uploaded-files"])==null?void 0:D.call(V,{uploadedFiles:u.value,deleteFile:U})])])}}});const I=e=>{var o;return e.dataTransfer?e.dataTransfer:(o=e.originalEvent)==null?void 0:o.dataTransfer},he=e=>e?e.indexOf?e.indexOf("Files")!==-1:e.contains?e.contains("Files"):!1:!1,x=e=>{e.preventDefault(),e.stopPropagation()},Fe=(e,o)=>{const{onFileOver:n}=o.value;e.addEventListener("dragover",a=>{const s=I(a);!he(s.types)||(x(a),n&&n(!0))})},ve=(e,o)=>{const{onFileOver:n}=o.value;e.addEventListener("dragleave",a=>{a.currentTarget!==e&&(x(a),n&&n(!0))})},ge=(e,o)=>{const{onFileDrop:n,isSingle:a}=o.value;e.addEventListener("drop",s=>{const m=I(s);!m||(x(s),a?n&&n([m.files[0]]):n&&n(Array.from(m.files)))})},ye={mounted:(e,o)=>{const{droppable:n}=o.value;!n||(Fe(e,o),ve(e,o),ge(e,o))}};var Ee={title:"Upload \u4E0A\u4F20",category:"\u6570\u636E\u5F55\u5165",status:"100%",install(e){e.directive("file-drop",ye),e.component(A.name,A)}};f.IFileOptions=re,f.IUploadOptions=se,f.Upload=A,f.UploadStatus=F,f.default=Ee,f.uploadProps=z,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module"});
|