vue-devui 1.0.0-rc.0 → 1.0.0-rc.3
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 +55 -113
- package/alert/index.es.js +28 -30
- package/alert/index.umd.js +1 -1
- package/auto-complete/index.es.js +143 -103
- package/auto-complete/index.umd.js +5 -1
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +77 -81
- package/avatar/index.umd.js +1 -1
- package/badge/index.es.js +1 -1
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +43 -43
- package/button/index.umd.js +1 -1
- package/card/index.es.js +3 -6
- package/card/index.umd.js +1 -1
- package/checkbox/index.es.js +5 -11
- package/checkbox/index.umd.js +1 -1
- package/comment/index.es.js +2 -5
- package/comment/index.umd.js +1 -1
- package/countdown/index.es.js +5 -7
- package/countdown/index.umd.js +1 -1
- package/editable-select/index.es.js +124 -168
- package/editable-select/index.umd.js +1 -1
- package/fullscreen/index.es.js +13 -16
- package/fullscreen/index.umd.js +1 -1
- package/grid/index.es.js +30 -36
- package/grid/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 +21 -20
- package/image-preview/index.umd.js +1 -1
- package/input/index.es.js +2 -5
- package/input/index.umd.js +1 -1
- package/layout/index.es.js +6 -21
- package/layout/index.umd.js +1 -1
- package/loading/index.es.js +20 -12
- package/loading/index.umd.js +1 -1
- package/modal/index.es.js +135 -122
- 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/DropdownPropsKey.js +3 -0
- 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/autoCompleteProps.js +3 -0
- package/nuxt/components/avatarProps.js +3 -0
- package/nuxt/components/cardProps.js +3 -0
- package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
- package/nuxt/components/checkboxGroupProps.js +3 -0
- package/nuxt/components/checkboxProps.js +3 -0
- package/nuxt/components/colProps.js +3 -0
- package/nuxt/components/colPropsBaseClass.js +3 -0
- package/nuxt/components/colPropsBaseStyle.js +3 -0
- package/nuxt/components/commentProps.js +3 -0
- package/nuxt/components/countdownProps.js +3 -0
- package/nuxt/components/editableSelectProps.js +3 -0
- package/nuxt/components/fullscreenProps.js +3 -0
- package/nuxt/components/iconProps.js +2 -0
- package/nuxt/components/imagePreviewProps.js +3 -0
- package/nuxt/components/inputProps.js +3 -0
- package/nuxt/components/paginationProps.js +3 -0
- package/nuxt/components/panelProps.js +3 -0
- package/nuxt/components/progressProps.js +3 -0
- package/nuxt/components/rateProps.js +3 -0
- package/nuxt/components/readTipProps.js +3 -0
- package/nuxt/components/resultProps.js +3 -0
- package/nuxt/components/rowProps.js +3 -0
- package/nuxt/components/screenSizes.js +3 -0
- package/nuxt/components/searchProps.js +3 -0
- package/nuxt/components/skeletonProps.js +3 -0
- package/nuxt/components/splitterProps.js +3 -0
- package/nuxt/components/statisticProps.js +3 -0
- package/nuxt/components/switchProps.js +3 -0
- package/nuxt/components/tagInputProps.js +3 -0
- package/nuxt/components/tagProps.js +3 -0
- package/nuxt/components/textareaProps.js +3 -0
- package/nuxt/components/timeAxisProps.js +3 -0
- package/overlay/index.es.js +49 -42
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +8 -43
- package/pagination/index.es.js +24 -25
- 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 +51 -44
- package/popover/index.umd.js +12 -12
- package/popover/style.css +1 -1
- package/progress/index.es.js +34 -36
- package/progress/index.umd.js +3 -3
- package/progress/style.css +1 -1
- package/radio/index.es.js +11 -11
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +4 -7
- package/rate/index.umd.js +1 -1
- package/read-tip/index.es.js +8 -8
- package/read-tip/index.umd.js +1 -1
- package/result/index.es.js +40 -58
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +47 -42
- package/ripple/index.umd.js +1 -1
- package/search/index.es.js +13 -16
- package/search/index.umd.js +8 -8
- package/skeleton/index.es.js +20 -23
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +60 -59
- package/slider/index.umd.js +1 -1
- package/splitter/index.es.js +223 -171
- package/splitter/index.umd.js +13 -13
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +7 -18
- package/statistic/index.umd.js +1 -1
- package/status/index.es.js +1 -4
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/style.css +1 -1
- package/switch/index.es.js +3 -6
- package/switch/index.umd.js +1 -1
- package/tag/index.es.js +15 -18
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/tag-input/index.es.js +7 -8
- package/tag-input/index.umd.js +1 -1
- package/textarea/index.es.js +2 -5
- package/textarea/index.umd.js +1 -1
- package/{accordion → timeline}/index.d.ts +0 -0
- package/{time-axis → timeline}/index.es.js +64 -83
- package/timeline/index.umd.js +1 -0
- package/{anchor → timeline}/package.json +1 -1
- package/timeline/style.css +1 -0
- package/upload/index.es.js +98 -97
- package/upload/index.umd.js +1 -1
- package/vue-devui.es.js +12477 -24991
- package/vue-devui.umd.js +24 -20
- package/accordion/index.es.js +0 -720
- package/accordion/index.umd.js +0 -1
- package/accordion/package.json +0 -7
- package/accordion/style.css +0 -1
- package/anchor/index.d.ts +0 -7
- package/anchor/index.es.js +0 -263
- package/anchor/index.umd.js +0 -1
- package/anchor/style.css +0 -1
- package/back-top/index.d.ts +0 -7
- package/back-top/index.es.js +0 -128
- package/back-top/index.umd.js +0 -1
- package/back-top/package.json +0 -7
- package/back-top/style.css +0 -1
- package/breadcrumb/index.d.ts +0 -7
- package/breadcrumb/index.es.js +0 -127
- package/breadcrumb/index.umd.js +0 -1
- package/breadcrumb/package.json +0 -7
- package/breadcrumb/style.css +0 -1
- package/carousel/index.d.ts +0 -7
- package/carousel/index.es.js +0 -329
- package/carousel/index.umd.js +0 -1
- package/carousel/package.json +0 -7
- package/carousel/style.css +0 -1
- package/cascader/index.d.ts +0 -7
- package/cascader/index.es.js +0 -5963
- package/cascader/index.umd.js +0 -27
- package/cascader/package.json +0 -7
- package/cascader/style.css +0 -1
- package/color-picker/index.d.ts +0 -7
- package/color-picker/index.es.js +0 -8187
- package/color-picker/index.umd.js +0 -27
- package/color-picker/package.json +0 -7
- package/color-picker/style.css +0 -1
- package/date-picker/index.d.ts +0 -7
- package/date-picker/index.es.js +0 -1171
- package/date-picker/index.umd.js +0 -1
- package/date-picker/package.json +0 -7
- package/date-picker/style.css +0 -1
- package/dragdrop/index.d.ts +0 -7
- package/dragdrop/index.es.js +0 -157
- package/dragdrop/index.umd.js +0 -1
- package/dragdrop/package.json +0 -7
- package/drawer/index.d.ts +0 -7
- package/drawer/index.es.js +0 -234
- package/drawer/index.umd.js +0 -1
- package/drawer/package.json +0 -7
- package/drawer/style.css +0 -1
- package/dropdown/index.d.ts +0 -7
- package/dropdown/index.es.js +0 -638
- package/dropdown/index.umd.js +0 -1
- package/dropdown/package.json +0 -7
- package/dropdown/style.css +0 -1
- package/form/index.d.ts +0 -7
- package/form/index.es.js +0 -7865
- package/form/index.umd.js +0 -27
- package/form/package.json +0 -7
- package/form/style.css +0 -1
- package/gantt/index.d.ts +0 -7
- package/gantt/index.es.js +0 -523
- package/gantt/index.umd.js +0 -1
- package/gantt/package.json +0 -7
- package/gantt/style.css +0 -1
- package/input-icon/index.d.ts +0 -7
- package/input-icon/index.es.js +0 -331
- package/input-icon/index.umd.js +0 -1
- package/input-icon/package.json +0 -7
- package/input-icon/style.css +0 -1
- package/input-number/index.d.ts +0 -7
- package/input-number/index.es.js +0 -240
- package/input-number/index.umd.js +0 -1
- package/input-number/package.json +0 -7
- package/input-number/style.css +0 -1
- package/list/index.d.ts +0 -7
- package/list/index.es.js +0 -39
- package/list/index.umd.js +0 -1
- package/list/package.json +0 -7
- package/list/style.css +0 -1
- package/nav-sprite/index.d.ts +0 -7
- package/nav-sprite/index.es.js +0 -68
- package/nav-sprite/index.umd.js +0 -1
- package/nav-sprite/package.json +0 -7
- package/nuxt/components/Accordion.js +0 -3
- package/nuxt/components/Anchor.js +0 -3
- package/nuxt/components/BackTop.js +0 -3
- package/nuxt/components/Breadcrumb.js +0 -3
- package/nuxt/components/Carousel.js +0 -3
- package/nuxt/components/CarouselItem.js +0 -3
- package/nuxt/components/Cascader.js +0 -3
- package/nuxt/components/ColorPicker.js +0 -3
- package/nuxt/components/Column.js +0 -3
- package/nuxt/components/DatePicker.js +0 -3
- package/nuxt/components/Drawer.js +0 -3
- package/nuxt/components/DrawerService.js +0 -3
- package/nuxt/components/Dropdown.js +0 -3
- package/nuxt/components/DropdownMenu.js +0 -3
- package/nuxt/components/Form.js +0 -3
- package/nuxt/components/FormControl.js +0 -3
- package/nuxt/components/FormItem.js +0 -3
- package/nuxt/components/FormLabel.js +0 -3
- package/nuxt/components/FormOperation.js +0 -3
- package/nuxt/components/Gantt.js +0 -3
- package/nuxt/components/InputIcon.js +0 -3
- package/nuxt/components/InputNumber.js +0 -3
- package/nuxt/components/List.js +0 -3
- package/nuxt/components/ListItem.js +0 -3
- package/nuxt/components/NavSprite.js +0 -2
- package/nuxt/components/QuadrantDiagram.js +0 -3
- package/nuxt/components/Select.js +0 -3
- package/nuxt/components/StepsGuide.js +0 -3
- package/nuxt/components/StickSlider.js +0 -3
- package/nuxt/components/Sticky.js +0 -2
- package/nuxt/components/Table.js +0 -3
- package/nuxt/components/Tabs.js +0 -3
- package/nuxt/components/TimeAxis.js +0 -3
- package/nuxt/components/TimeAxisItem.js +0 -3
- package/nuxt/components/TimePicker.js +0 -3
- package/nuxt/components/Tooltip.js +0 -3
- package/nuxt/components/Transfer.js +0 -3
- package/nuxt/components/Tree.js +0 -3
- package/nuxt/components/TreeSelect.js +0 -3
- package/nuxt/components/dropdownMenuProps.js +0 -3
- package/nuxt/components/tooltipProps.js +0 -3
- package/quadrant-diagram/index.d.ts +0 -7
- package/quadrant-diagram/index.es.js +0 -5728
- package/quadrant-diagram/index.umd.js +0 -27
- package/quadrant-diagram/package.json +0 -7
- package/quadrant-diagram/style.css +0 -1
- package/select/index.d.ts +0 -7
- package/select/index.es.js +0 -706
- package/select/index.umd.js +0 -1
- package/select/package.json +0 -7
- package/select/style.css +0 -1
- package/steps-guide/index.d.ts +0 -7
- package/steps-guide/index.es.js +0 -239
- package/steps-guide/index.umd.js +0 -1
- package/steps-guide/package.json +0 -7
- package/steps-guide/style.css +0 -1
- package/sticky/index.d.ts +0 -7
- package/sticky/index.es.js +0 -197
- package/sticky/index.umd.js +0 -1
- package/sticky/package.json +0 -7
- package/table/index.d.ts +0 -7
- package/table/index.es.js +0 -1969
- package/table/index.umd.js +0 -1
- package/table/package.json +0 -7
- package/table/style.css +0 -1
- package/tabs/index.d.ts +0 -7
- package/tabs/index.es.js +0 -194
- package/tabs/index.umd.js +0 -1
- package/tabs/package.json +0 -7
- package/tabs/style.css +0 -1
- package/time-axis/index.d.ts +0 -7
- package/time-axis/index.umd.js +0 -1
- package/time-axis/package.json +0 -7
- package/time-axis/style.css +0 -1
- package/time-picker/index.d.ts +0 -7
- package/time-picker/index.es.js +0 -1237
- package/time-picker/index.umd.js +0 -1
- package/time-picker/package.json +0 -7
- package/time-picker/style.css +0 -1
- package/tooltip/index.d.ts +0 -7
- package/tooltip/index.es.js +0 -5828
- package/tooltip/index.umd.js +0 -27
- package/tooltip/package.json +0 -7
- package/tooltip/style.css +0 -1
- package/transfer/index.d.ts +0 -7
- package/transfer/index.es.js +0 -7608
- package/transfer/index.umd.js +0 -27
- package/transfer/package.json +0 -7
- package/transfer/style.css +0 -1
- package/tree/index.d.ts +0 -7
- package/tree/index.es.js +0 -6490
- package/tree/index.umd.js +0 -27
- package/tree/package.json +0 -7
- package/tree/style.css +0 -1
- package/tree-select/index.d.ts +0 -7
- package/tree-select/index.es.js +0 -623
- package/tree-select/index.umd.js +0 -1
- package/tree-select/package.json +0 -7
- package/tree-select/style.css +0 -1
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, {
|
|
@@ -457,7 +455,7 @@ const useSelectFiles = () => {
|
|
|
457
455
|
if (uploadOptions && beyondMaximalSize(file.size, uploadOptions.maximumSize)) {
|
|
458
456
|
return {
|
|
459
457
|
checkError: true,
|
|
460
|
-
errorMsg: getBeyondMaximalFileSizeMsg(file.name, uploadOptions.maximumSize)
|
|
458
|
+
errorMsg: getBeyondMaximalFileSizeMsg(file.name, uploadOptions.maximumSize || 0)
|
|
461
459
|
};
|
|
462
460
|
}
|
|
463
461
|
return { checkError: false, errorMsg: void 0 };
|
|
@@ -496,11 +494,11 @@ class FileUploader {
|
|
|
496
494
|
}
|
|
497
495
|
send(uploadFiles) {
|
|
498
496
|
return new Promise((resolve, reject) => {
|
|
499
|
-
const { uri, method, headers, authToken, authTokenHeader, additionalParameter, fileFieldName, withCredentials, responseType } = this.uploadOptions;
|
|
497
|
+
const { uri, method, headers, authToken, authTokenHeader, additionalParameter, fileFieldName, withCredentials, responseType } = this.uploadOptions || {};
|
|
500
498
|
const authTokenHeader_ = authTokenHeader || "Authorization";
|
|
501
499
|
const fileFieldName_ = fileFieldName || "file";
|
|
502
500
|
this.xhr = new XMLHttpRequest();
|
|
503
|
-
this.xhr.open(method || "POST", uri);
|
|
501
|
+
this.xhr.open(method || "POST", uri || "");
|
|
504
502
|
if (withCredentials) {
|
|
505
503
|
this.xhr.withCredentials = withCredentials;
|
|
506
504
|
}
|
|
@@ -512,7 +510,8 @@ class FileUploader {
|
|
|
512
510
|
}
|
|
513
511
|
if (headers) {
|
|
514
512
|
Object.keys(headers).forEach((key) => {
|
|
515
|
-
|
|
513
|
+
var _a;
|
|
514
|
+
(_a = this.xhr) == null ? void 0 : _a.setRequestHeader(key, headers[key]);
|
|
516
515
|
});
|
|
517
516
|
}
|
|
518
517
|
this.xhr.upload.onprogress = (e) => {
|
|
@@ -526,19 +525,21 @@ class FileUploader {
|
|
|
526
525
|
this.xhr = null;
|
|
527
526
|
};
|
|
528
527
|
this.xhr.onerror = () => {
|
|
529
|
-
|
|
528
|
+
var _a, _b;
|
|
529
|
+
this.response = (_a = this.xhr) == null ? void 0 : _a.response;
|
|
530
530
|
this.status = UploadStatus.failed;
|
|
531
|
-
reject({ file: this.file, response: this.xhr.response });
|
|
531
|
+
reject({ file: this.file, response: (_b = this.xhr) == null ? void 0 : _b.response });
|
|
532
532
|
};
|
|
533
533
|
this.xhr.onload = () => {
|
|
534
|
-
|
|
534
|
+
var _a, _b, _c;
|
|
535
|
+
if (((_a = this.xhr) == null ? void 0 : _a.readyState) === 4 && this.xhr.status >= 200 && this.xhr.status < 300) {
|
|
535
536
|
this.response = this.xhr.response;
|
|
536
537
|
this.status = UploadStatus.uploaded;
|
|
537
538
|
resolve({ file: this.file, response: this.xhr.response });
|
|
538
539
|
} else {
|
|
539
|
-
this.response = this.xhr.response;
|
|
540
|
+
this.response = (_b = this.xhr) == null ? void 0 : _b.response;
|
|
540
541
|
this.status = UploadStatus.failed;
|
|
541
|
-
reject({ file: this.file, response: this.xhr.response });
|
|
542
|
+
reject({ file: this.file, response: (_c = this.xhr) == null ? void 0 : _c.response });
|
|
542
543
|
}
|
|
543
544
|
};
|
|
544
545
|
});
|
|
@@ -645,7 +646,7 @@ const useUpload = () => {
|
|
|
645
646
|
};
|
|
646
647
|
const deleteFile = (file) => {
|
|
647
648
|
const deleteUploadFile = fileUploaders.value.find((fileUploader) => fileUploader.file === file);
|
|
648
|
-
deleteUploadFile.cancel();
|
|
649
|
+
deleteUploadFile == null ? void 0 : deleteUploadFile.cancel();
|
|
649
650
|
fileUploaders.value = fileUploaders.value.filter((fileUploader) => {
|
|
650
651
|
return file !== fileUploader.file;
|
|
651
652
|
});
|
|
@@ -710,7 +711,6 @@ var Upload = defineComponent({
|
|
|
710
711
|
getSameNameFiles
|
|
711
712
|
} = useUpload();
|
|
712
713
|
const isDropOVer = ref(false);
|
|
713
|
-
ref("");
|
|
714
714
|
const alertMsg = (errorMsg) => {
|
|
715
715
|
NotificationService.open({
|
|
716
716
|
type: "warning",
|
|
@@ -718,10 +718,11 @@ var Upload = defineComponent({
|
|
|
718
718
|
});
|
|
719
719
|
};
|
|
720
720
|
const checkValid = () => {
|
|
721
|
+
var _a;
|
|
721
722
|
let totalFileSize = 0;
|
|
722
723
|
fileUploaders.value.forEach((fileUploader) => {
|
|
723
724
|
totalFileSize += fileUploader.file.size;
|
|
724
|
-
const checkResult = _validateFiles(fileUploader.file, accept.value, fileUploader.uploadOptions);
|
|
725
|
+
const checkResult = _validateFiles(fileUploader.file, (accept == null ? void 0 : accept.value) || "", fileUploader.uploadOptions);
|
|
725
726
|
if (checkResult && checkResult.checkError) {
|
|
726
727
|
deleteFile(fileUploader.file);
|
|
727
728
|
alertMsg(checkResult.errorMsg);
|
|
@@ -729,51 +730,13 @@ var Upload = defineComponent({
|
|
|
729
730
|
}
|
|
730
731
|
});
|
|
731
732
|
if (oneTimeUpload.value) {
|
|
732
|
-
const checkResult = checkAllFilesSize(totalFileSize, uploadOptions.value.maximumSize);
|
|
733
|
+
const checkResult = checkAllFilesSize(totalFileSize, ((_a = uploadOptions == null ? void 0 : uploadOptions.value) == null ? void 0 : _a.maximumSize) || 0);
|
|
733
734
|
if (checkResult && checkResult.checkError) {
|
|
734
735
|
removeFiles();
|
|
735
736
|
alertMsg(checkResult.errorMsg);
|
|
736
737
|
}
|
|
737
738
|
}
|
|
738
739
|
};
|
|
739
|
-
const _dealFiles = (promise) => {
|
|
740
|
-
resetSameNameFiles();
|
|
741
|
-
promise.then((files) => {
|
|
742
|
-
files.forEach((file) => {
|
|
743
|
-
if (!multiple.value) {
|
|
744
|
-
removeFiles();
|
|
745
|
-
}
|
|
746
|
-
addFile(file, uploadOptions.value);
|
|
747
|
-
});
|
|
748
|
-
checkValid();
|
|
749
|
-
const sameNameFiles = getSameNameFiles();
|
|
750
|
-
if (uploadOptions.value && uploadOptions.value.checkSameName && sameNameFiles.length) {
|
|
751
|
-
alertMsg(getExistSameNameFilesMsg(sameNameFiles));
|
|
752
|
-
}
|
|
753
|
-
const selectedFiles = fileUploaders.value.filter((fileUploader) => fileUploader.status === UploadStatus.preLoad).map((fileUploader) => fileUploader.file);
|
|
754
|
-
ctx.emit("fileSelect", selectedFiles);
|
|
755
|
-
if (autoUpload.value) {
|
|
756
|
-
fileUpload();
|
|
757
|
-
}
|
|
758
|
-
}).catch((error) => {
|
|
759
|
-
alertMsg(error.message);
|
|
760
|
-
});
|
|
761
|
-
};
|
|
762
|
-
const handleClick = () => {
|
|
763
|
-
if (disabled.value) {
|
|
764
|
-
return;
|
|
765
|
-
}
|
|
766
|
-
_dealFiles(triggerSelectFiles({
|
|
767
|
-
accept: accept.value,
|
|
768
|
-
multiple: multiple.value,
|
|
769
|
-
webkitdirectory: webkitdirectory.value
|
|
770
|
-
}));
|
|
771
|
-
};
|
|
772
|
-
const onFileDrop = (files) => {
|
|
773
|
-
isDropOVer.value = false;
|
|
774
|
-
_dealFiles(triggerDropFiles(files));
|
|
775
|
-
ctx.emit("fileDrop", files);
|
|
776
|
-
};
|
|
777
740
|
const onFileOver = (event) => {
|
|
778
741
|
isDropOVer.value = event;
|
|
779
742
|
ctx.emit("fileOver", event);
|
|
@@ -794,13 +757,13 @@ var Upload = defineComponent({
|
|
|
794
757
|
};
|
|
795
758
|
const canUpload = () => {
|
|
796
759
|
let uploadResult = Promise.resolve(true);
|
|
797
|
-
if (beforeUpload.value) {
|
|
798
|
-
const result = beforeUpload.value(getFullFiles());
|
|
760
|
+
if (beforeUpload == null ? void 0 : beforeUpload.value) {
|
|
761
|
+
const result = beforeUpload == null ? void 0 : beforeUpload.value(getFullFiles());
|
|
799
762
|
if (typeof result !== "undefined") {
|
|
800
|
-
if (result
|
|
801
|
-
uploadResult = result;
|
|
802
|
-
} else {
|
|
763
|
+
if (typeof result === "boolean") {
|
|
803
764
|
uploadResult = Promise.resolve(result);
|
|
765
|
+
} else {
|
|
766
|
+
uploadResult = result;
|
|
804
767
|
}
|
|
805
768
|
}
|
|
806
769
|
}
|
|
@@ -816,7 +779,7 @@ var Upload = defineComponent({
|
|
|
816
779
|
return;
|
|
817
780
|
}
|
|
818
781
|
const uploadObservable = oneTimeUpload.value ? _oneTimeUpload() : upload2(fileUploader);
|
|
819
|
-
uploadObservable.then((results) => {
|
|
782
|
+
uploadObservable == null ? void 0 : uploadObservable.then((results) => {
|
|
820
783
|
props["on-success"] && props["on-success"](results);
|
|
821
784
|
const newFiles = results.map((result) => result.file);
|
|
822
785
|
const newUploadedFiles = [...newFiles, ...modelValue.value];
|
|
@@ -826,6 +789,44 @@ var Upload = defineComponent({
|
|
|
826
789
|
});
|
|
827
790
|
});
|
|
828
791
|
};
|
|
792
|
+
const _dealFiles = (promise) => {
|
|
793
|
+
resetSameNameFiles();
|
|
794
|
+
promise.then((files) => {
|
|
795
|
+
files.forEach((file) => {
|
|
796
|
+
if (!multiple.value) {
|
|
797
|
+
removeFiles();
|
|
798
|
+
}
|
|
799
|
+
addFile(file, uploadOptions == null ? void 0 : uploadOptions.value);
|
|
800
|
+
});
|
|
801
|
+
checkValid();
|
|
802
|
+
const sameNameFiles = getSameNameFiles();
|
|
803
|
+
if ((uploadOptions == null ? void 0 : uploadOptions.value) && uploadOptions.value.checkSameName && sameNameFiles.length) {
|
|
804
|
+
alertMsg(getExistSameNameFilesMsg(sameNameFiles));
|
|
805
|
+
}
|
|
806
|
+
const selectedFiles = fileUploaders.value.filter((fileUploader) => fileUploader.status === UploadStatus.preLoad).map((fileUploader) => fileUploader.file);
|
|
807
|
+
ctx.emit("fileSelect", selectedFiles);
|
|
808
|
+
if (autoUpload.value) {
|
|
809
|
+
fileUpload();
|
|
810
|
+
}
|
|
811
|
+
}).catch((error) => {
|
|
812
|
+
alertMsg(error.message);
|
|
813
|
+
});
|
|
814
|
+
};
|
|
815
|
+
const handleClick = () => {
|
|
816
|
+
if (disabled.value) {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
_dealFiles(triggerSelectFiles({
|
|
820
|
+
accept: accept == null ? void 0 : accept.value,
|
|
821
|
+
multiple: multiple.value,
|
|
822
|
+
webkitdirectory: webkitdirectory.value
|
|
823
|
+
}));
|
|
824
|
+
};
|
|
825
|
+
const onFileDrop = (files) => {
|
|
826
|
+
isDropOVer.value = false;
|
|
827
|
+
_dealFiles(triggerDropFiles(files));
|
|
828
|
+
ctx.emit("fileDrop", files);
|
|
829
|
+
};
|
|
829
830
|
return () => {
|
|
830
831
|
var _a, _b, _c, _d;
|
|
831
832
|
return createVNode("div", null, [withDirectives(createVNode("div", {
|
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,Me=Object.defineProperties;var Be=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var Oe=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var L=(f,t,V)=>t in f?xe(f,t,{enumerable:!0,configurable:!0,writable:!0,value:V}):f[t]=V,P=(f,t)=>{for(var V in t||(t={}))Oe.call(t,V)&&L(f,V,t[V]);if(Y)for(var V of Y(t))Le.call(t,V)&&L(f,V,t[V]);return f},Z=(f,t)=>Me(f,Be(t));var E=(f,t,V)=>(L(f,typeof t!="symbol"?t+"":t,V),V);(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 V={modelValue:{type:Boolean,default:!1},title:{type:String,default:""},type:{type:String,default:"normal"},duration:{type:Number,default:3e3},onClose:{type:Function}},J={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:J,setup(e){const{name:n,size:o,color:s,classPrefix:a}=t.toRefs(e);return()=>/^((https?):)?\/\//.test(n.value)?t.createVNode("img",{src:n.value,alt:n.value.split("/")[n.value.split("/").length-1],style:{width:o.value,verticalAlign:"text-bottom"}},null):t.createVNode("i",{class:`${a.value} ${a.value}-${n.value}`,style:{fontSize:o.value,color:s.value}},null)}}),K=t.defineComponent({emits:["click"],setup(e,{emit:n}){return()=>t.createVNode("div",{class:"devui-notification-icon-close",onClick:o=>n("click",o)},[t.createVNode($,{name:"close",size:"14px"},null)])}}),Q=t.defineComponent({props:{type:{type:String,default:"normal"}},setup(e){const{type:n}=t.toRefs(e),o=t.computed(()=>({"devui-notification-image":!0,[`devui-notification-image-${n.value}`]:!0})),s={info:"info-o",success:"right-o",warning:"warning-o",error:"error-o"};return()=>t.createVNode("span",{class:o.value},[n.value!=="normal"&&t.createVNode($,{name:s[n.value],size:"16px"},null)])}});function U(e){return{classes:t.computed(()=>({"devui-notification-item-container":!0,[`devui-notification-message-${e.type}`]:!0}))}}function ee(e,n){let o=null,s;const a=()=>{var C;clearTimeout(o),o=null,(C=e.onClose)==null||C.call(e),n("update:modelValue",!1)},p=()=>{o&&(clearTimeout(o),o=null)},g=()=>{if(!e.modelValue){const C=e.duration-(Date.now()-s);o=setTimeout(a,C)}},b=()=>{n("destroy")};return t.watch(()=>e.modelValue,C=>{C&&(s=Date.now(),e.duration&&(o=setTimeout(a,e.duration)))}),{interrupt:p,removeReset:g,close:a,handleDestroy:b}}var Pe="",te=t.defineComponent({name:"DNotification",props:V,emits:["update:modelValue","destroy"],setup(e,{emit:n,slots:o}){const{modelValue:s,title:a,type:p}=t.toRefs(e),{classes:g}=U(e),{interrupt:b,removeReset:C,close:u,handleDestroy:r}=ee(e,n);return()=>t.createVNode(t.Transition,{name:"notification-fade",onAfterLeave:r},{default:()=>{var m;return[s.value&&t.createVNode("div",{class:"devui-notification"},[t.createVNode("div",{class:g.value,onMouseenter:b,onMouseleave:C},[t.createVNode("div",{class:"devui-notification-item"},[t.createVNode(K,{onClick:u},null),a.value&&t.createVNode(Q,{type:p.value},null),t.createVNode("div",{class:"devui-notification-message"},[t.createVNode("span",{class:"devui-notification-title"},[a.value]),t.createVNode("span",{class:"devui-notification-content"},[(m=o.default)==null?void 0:m.call(o)])])])])])]}})}});function ne(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const oe={modelValue:!1,duration:3e3,type:"normal"};function ie(e,n){const o=document.createElement("div"),s=t.createApp({setup(){return t.onUnmounted(()=>{document.body.removeChild(o)}),()=>t.createVNode(te,t.mergeProps(e,{onDestroy:s.unmount}),ne(n)?n:{default:()=>[n]})}});return document.body.appendChild(o),s.mount(o),s}function le(e,n){e.modelValue=!1,n==null||n()}class se{static open(n){const o=n.onClose||null,s=n.content;let a;delete n.content;const p=t.reactive(Z(P(P({},oe),n),{onClose:()=>{le(p,o)}}));ie(p,s),p.modelValue=!0,clearTimeout(a),n.duration&&(a=setTimeout(p.onClose,n.duration))}}class ae{constructor(){E(this,"uri");E(this,"method");E(this,"maximumSize");E(this,"headers");E(this,"authToken");E(this,"authTokenHeader");E(this,"additionalParameter");E(this,"fileFieldName");E(this,"checkSameName");E(this,"withCredentials");E(this,"responseType")}}class re{constructor(){E(this,"accept");E(this,"multiple");E(this,"webkitdirectory")}}var v=(e=>(e[e.preLoad=0]="preLoad",e[e.uploading=1]="uploading",e[e.uploaded=2]="uploaded",e[e.failed=3]="failed",e))(v||{});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,n)=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${n}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${e}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,de=(e,n)=>`\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${n}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${e}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,fe=e=>`\u60A8\u4E0A\u4F20\u7684 "${e}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,pe=()=>{const e=t.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(w=>{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=>{w(Array.prototype.slice.call(h.target.files))}),document.body.appendChild(i),n(i)}),s=(u,r)=>{if(u){const m=u.split(","),w=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)?w===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:w}=u;return o({multiple:r,accept:m,webkitdirectory:w})},_validateFiles:(u,r,m)=>s(r,u)?m&&a(u.size,m.maximumSize)?{checkError:!0,errorMsg:ce(u.name,m.maximumSize||0)}:{checkError:!1,errorMsg:void 0}:{checkError:!0,errorMsg:de(u.name,r)},triggerDropFiles:u=>Promise.resolve(u),checkAllFilesSize:(u,r)=>{if(a(u,r))return e.value=ue(r),{checkError:!0,errorMsg:e.value}}}};class _{constructor(n,o){E(this,"xhr");E(this,"status");E(this,"response");E(this,"percentage",0);this.file=n,this.uploadOptions=o,this.file=n,this.uploadOptions=o,this.status=v.preLoad}send(n){return new Promise((o,s)=>{const{uri:a,method:p,headers:g,authToken:b,authTokenHeader:C,additionalParameter:u,fileFieldName:r,withCredentials:m,responseType:w}=this.uploadOptions||{},l=C||"Authorization",i=r||"file";this.xhr=new XMLHttpRequest,this.xhr.open(p||"POST",a||""),m&&(this.xhr.withCredentials=m),w&&(this.xhr.responseType=w),b&&this.xhr.setRequestHeader(l,b),g&&Object.keys(g).forEach(S=>{var N;(N=this.xhr)==null||N.setRequestHeader(S,g[S])}),this.xhr.upload.onprogress=S=>{this.percentage=Math.round(S.loaded*100/S.total)};const h=n&&n.length?this.oneTimeUploadFiles(i,u,n):this.parallelUploadFiles(i,u);this.xhr.send(h),this.status=v.uploading,this.xhr.onabort=()=>{this.status=v.preLoad,this.xhr=null},this.xhr.onerror=()=>{var S,N;this.response=(S=this.xhr)==null?void 0:S.response,this.status=v.failed,s({file:this.file,response:(N=this.xhr)==null?void 0:N.response})},this.xhr.onload=()=>{var S,N,D;((S=this.xhr)==null?void 0:S.readyState)===4&&this.xhr.status>=200&&this.xhr.status<300?(this.response=this.xhr.response,this.status=v.uploaded,o({file:this.file,response:this.xhr.response})):(this.response=(N=this.xhr)==null?void 0:N.response,this.status=v.failed,s({file:this.file,response:(D=this.xhr)==null?void 0:D.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(p=>{a.append(n,p.file,p.file.name),o&&Object.keys(o).forEach(g=>{a.append(g,o[g])})}),a}cancel(){this.xhr&&this.xhr.abort()}}const me=()=>{const e=t.ref([]),n=t.ref([]),o=l=>{let i=!0;for(let h=0;h<e.value.length;h++)if(l===e.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)&&e.value.push(new _(l,i)):e.value.push(new _(l,i))},a=()=>e.value.map(l=>l.file),p=()=>e.value.map(l=>l),g=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:a,addFile:s,getFullFiles:p,deleteFile:l=>{const i=e.value.find(h=>h.file===l);i==null||i.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(D=>D.status===v.preLoad),S=e.value.filter(D=>D.status===v.failed),N=h.length>0?h:S;i=await Promise.all(N.map(async D=>(D.percentage=0,await D.send())))}return i.length>0?Promise.resolve(i):Promise.reject("no files")},removeFiles:()=>{e.value=[],n.value=[]},getSameNameFiles:()=>n.value.join(),resetSameNameFiles:()=>{n.value=[]},_oneTimeUpload:()=>{const l=e.value.filter(i=>i.status!==v.uploaded);return g(l)}}};var $e="",A=t.defineComponent({name:"DUpload",props:z,emits:["fileDrop","fileOver","fileSelect","deleteUploadedFile","update:modelValue"],setup(e,n){const{uploadOptions:o,placeholder:s,autoUpload:a,disabled:p,beforeUpload:g,droppable:b,oneTimeUpload:C,modelValue:u,multiple:r,accept:m,webkitdirectory:w}=t.toRefs(e),{triggerSelectFiles:l,_validateFiles:i,triggerDropFiles:h,checkAllFilesSize:S}=pe(),{fileUploaders:N,addFile:D,getFullFiles:R,deleteFile:j,upload:Ne,resetSameNameFiles:Ve,removeFiles:M,_oneTimeUpload:Ce,getSameNameFiles:Se}=me(),B=t.ref(!1),T=d=>{se.open({type:"warning",content:d})},ke=()=>{var F;let d=0;if(N.value.forEach(y=>{d+=y.file.size;const k=i(y.file,(m==null?void 0:m.value)||"",y.uploadOptions);if(k&&k.checkError){j(y.file),T(k.errorMsg);return}}),C.value){const y=S(d,((F=o==null?void 0:o.value)==null?void 0:F.maximumSize)||0);y&&y.checkError&&(M(),T(y.errorMsg))}},we=d=>{B.value=d,n.emit("fileOver",d)},H=d=>{const F=u.value.filter(y=>y.name!==d.name);n.emit("deleteUploadedFile",d),n.emit("update:modelValue",F)},De=(d,F,y)=>{d.stopPropagation(),y===v.uploaded&&H(F),j(F)},be=()=>{let d=Promise.resolve(!0);if(g==null?void 0:g.value){const F=g==null?void 0:g.value(R());typeof F!="undefined"&&(typeof F=="boolean"?d=Promise.resolve(F):d=F)}return d},q=(d,F)=>{d&&d.stopPropagation(),be().then(y=>{if(!y){M();return}const k=C.value?Ce():Ne(F);k==null||k.then(c=>{e["on-success"]&&e["on-success"](c);const O=[...c.map(Ae=>Ae.file),...u.value];n.emit("update:modelValue",O)}).catch(c=>{e["on-error"]&&e["on-error"](c)})})},W=d=>{Ve(),d.then(F=>{F.forEach(c=>{r.value||M(),D(c,o==null?void 0:o.value)}),ke();const y=Se();(o==null?void 0:o.value)&&o.value.checkSameName&&y.length&&T(fe(y));const k=N.value.filter(c=>c.status===v.preLoad).map(c=>c.file);n.emit("fileSelect",k),a.value&&q()}).catch(F=>{T(F.message)})},X=()=>{p.value||W(l({accept:m==null?void 0:m.value,multiple:r.value,webkitdirectory:w.value}))},Te=d=>{B.value=!1,W(h(d)),n.emit("fileDrop",d)};return()=>{var d,F,y,k;return t.createVNode("div",null,[t.withDirectives(t.createVNode("div",{class:"devui-upload",style:`border: ${B.value?"1px solid #15bf15":"0"}`},[((F=(d=n.slots).default)==null?void 0:F.call(d))?t.createVNode("div",{onClick:X},[n.slots.default()]):t.createVNode("div",{class:`devui-input-group ${p.value?"disabled":""}`,onClick:X},[N.value.length===0&&t.createVNode("div",{class:"devui-form-control devui-upload-placeholder"},[s.value]),N.value.length>0&&t.createVNode("ul",{class:"devui-form-control devui-files-list"},[N.value.map((c,G)=>t.createVNode("li",{key:G,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===v.failed?"devui-failed-color":""}`},[c.file.name]),t.createVNode(t.resolveComponent("d-icon"),{name:"close",class:`${(c==null?void 0:c.status)===v.failed?"devui-upload-delete-file-button":""} ${(c==null?void 0:c.status)===v.uploading||(c==null?void 0:c.status)===v.uploaded?"devui-uploading-delete":""}`,onClick:O=>De(O,c.file,c.status)},null),c.status===v.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===v.failed&&t.createVNode(t.resolveComponent("d-icon"),{name:"running",onClick:q},null),c.status===v.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:b,isSingle:!r,onFileDrop:Te,onFileOver:we}]]),t.createVNode("div",null,[(k=(y=n.slots)["uploaded-files"])==null?void 0:k.call(y,{uploadedFiles:u.value,deleteFile:H})])])}}});const I=e=>{var n;return e.dataTransfer?e.dataTransfer:(n=e.originalEvent)==null?void 0:n.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,n)=>{const{onFileOver:o}=n.value;e.addEventListener("dragover",s=>{const a=I(s);!he(a.types)||(x(s),o&&o(!0))})},ve=(e,n)=>{const{onFileOver:o}=n.value;e.addEventListener("dragleave",s=>{s.currentTarget!==e&&(x(s),o&&o(!0))})},ge=(e,n)=>{const{onFileDrop:o,isSingle:s}=n.value;e.addEventListener("drop",a=>{const p=I(a);!p||(x(a),s?o&&o([p.files[0]]):o&&o(Array.from(p.files)))})},ye={mounted:(e,n)=>{const{droppable:o}=n.value;!o||(Fe(e,n),ve(e,n),ge(e,n))}};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=ae,f.Upload=A,f.UploadStatus=v,f.default=Ee,f.uploadProps=z,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module"});
|