vue-devui 1.0.0-rc.1 → 1.0.0-rc.4
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 +132 -200
- package/auto-complete/index.es.js +150 -110
- 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/button/index.es.js +23 -15
- package/button/index.umd.js +1 -1
- package/button/style.css +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 +4 -6
- package/comment/index.umd.js +1 -1
- package/countdown/index.es.js +3 -6
- package/countdown/index.umd.js +1 -1
- package/editable-select/index.es.js +120 -167
- package/editable-select/index.umd.js +1 -1
- package/grid/index.es.js +30 -36
- package/grid/index.umd.js +1 -1
- package/image-preview/index.es.js +19 -19
- 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 +9 -22
- package/layout/index.umd.js +1 -1
- package/loading/index.es.js +40 -25
- package/loading/index.umd.js +1 -1
- package/modal/index.es.js +55 -47
- package/modal/index.umd.js +1 -1
- package/notification/index.es.js +100 -10
- package/notification/index.umd.js +1 -1
- package/notification/style.css +1 -1
- package/nuxt/components/DropdownPropsKey.js +3 -0
- package/nuxt/components/LoadingOptions.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/imagePreviewProps.js +3 -0
- package/nuxt/components/inputProps.js +3 -0
- package/nuxt/components/loadingProps.js +3 -0
- package/nuxt/components/modalProps.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/skeletonProps.js +3 -0
- package/nuxt/components/sliderProps.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 +5 -5
- package/overlay/index.umd.js +1 -1
- package/package.json +1 -1
- package/pagination/index.es.js +14 -13
- package/pagination/index.umd.js +1 -1
- package/popover/index.es.js +7 -7
- package/popover/index.umd.js +12 -12
- 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 +8 -2
- 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 +34 -34
- package/read-tip/index.umd.js +1 -1
- package/read-tip/style.css +1 -1
- package/result/index.es.js +2 -5
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +43 -42
- package/ripple/index.umd.js +1 -1
- package/search/index.es.js +11 -11
- package/search/index.umd.js +8 -8
- package/skeleton/index.es.js +9 -12
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +59 -62
- package/slider/index.umd.js +1 -1
- package/splitter/index.es.js +176 -136
- package/splitter/index.umd.js +13 -13
- package/statistic/index.es.js +7 -18
- package/statistic/index.umd.js +1 -1
- package/style.css +1 -1
- package/switch/index.es.js +4 -7
- package/switch/index.umd.js +1 -1
- package/switch/style.css +1 -1
- package/tag/index.es.js +13 -17
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/tag-input/index.es.js +3 -6
- package/tag-input/index.umd.js +1 -1
- package/textarea/index.es.js +2 -5
- package/textarea/index.umd.js +1 -1
- package/timeline/index.es.js +10 -16
- package/timeline/index.umd.js +1 -1
- package/upload/index.es.js +160 -67
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +12182 -24718
- package/vue-devui.umd.js +24 -20
- package/accordion/index.d.ts +0 -7
- package/accordion/index.es.js +0 -723
- 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/package.json +0 -7
- package/anchor/style.css +0 -1
- package/back-top/index.d.ts +0 -7
- package/back-top/index.es.js +0 -130
- 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 -128
- 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 -314
- 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 -5971
- 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 -8196
- 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 -1154
- 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 -693
- 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 -7876
- 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 -332
- 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 -229
- 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/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 -242
- 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 -2024
- 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-picker/index.d.ts +0 -7
- package/time-picker/index.es.js +0 -1238
- 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 -5835
- 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 -7615
- 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 -6495
- 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 -627
- 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
|
@@ -104,6 +104,105 @@ var Close = defineComponent({
|
|
|
104
104
|
}, null)]);
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
|
+
function SuccessIcon() {
|
|
108
|
+
return createVNode("svg", {
|
|
109
|
+
"width": "16px",
|
|
110
|
+
"height": "16px",
|
|
111
|
+
"viewBox": "0 0 16 16",
|
|
112
|
+
"version": "1.1",
|
|
113
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
114
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink"
|
|
115
|
+
}, [createVNode("defs", null, [createVNode("polygon", {
|
|
116
|
+
"id": "path-s",
|
|
117
|
+
"points": "6.53553391 9.77817459 12.1923882 4.12132034 13.6066017 5.53553391 6.53553391 12.6066017 3 9.07106781 4.41421356 7.65685425 6.53553391 9.77817459"
|
|
118
|
+
}, null)]), createVNode("g", {
|
|
119
|
+
"id": "correct",
|
|
120
|
+
"stroke": "none",
|
|
121
|
+
"stroke-width": "1",
|
|
122
|
+
"fill": "none",
|
|
123
|
+
"fill-rule": "evenodd"
|
|
124
|
+
}, [createVNode("mask", {
|
|
125
|
+
"id": "mask-2",
|
|
126
|
+
"fill": "white"
|
|
127
|
+
}, [createVNode("use", {
|
|
128
|
+
"xlink:href": "#path-s"
|
|
129
|
+
}, null)]), createVNode("use", {
|
|
130
|
+
"id": "Mask",
|
|
131
|
+
"class": "devui-notification-image-success-path",
|
|
132
|
+
"xlink:href": "#path-s"
|
|
133
|
+
}, null)])]);
|
|
134
|
+
}
|
|
135
|
+
function WarningIcon() {
|
|
136
|
+
return createVNode("svg", {
|
|
137
|
+
"width": "16px",
|
|
138
|
+
"height": "16px",
|
|
139
|
+
"viewBox": "0 0 16 16",
|
|
140
|
+
"version": "1.1",
|
|
141
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
142
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink"
|
|
143
|
+
}, [createVNode("g", {
|
|
144
|
+
"stroke": "none",
|
|
145
|
+
"stroke-width": "1",
|
|
146
|
+
"fill": "none",
|
|
147
|
+
"fill-rule": "evenodd"
|
|
148
|
+
}, [createVNode("path", {
|
|
149
|
+
"class": "devui-icon-warning-outer",
|
|
150
|
+
"d": "M8.96244623,0.57254229 L15.8714442,13.4101975 C16.1549662,13.9370117 15.9538562,14.5918482 15.4222523,14.8728158 C15.2642579,14.9563203 15.0879506,15 14.9088903,15 L1.09089441,15 C0.488410063,15 0,14.5159904 0,13.9189343 C0,13.7414873 0.0440768395,13.5667684 0.128340519,13.4101975 L7.03733844,0.57254229 C7.32086049,0.0457280838 7.98165058,-0.153569987 8.51325441,0.127397589 C8.70423071,0.228333932 8.8605922,0.383286648 8.96244623,0.57254229 Z"
|
|
151
|
+
}, null), createVNode("path", {
|
|
152
|
+
"class": "devui-icon-warning-inner",
|
|
153
|
+
"stroke-width": "0.3",
|
|
154
|
+
"fill-rule": "nonzero",
|
|
155
|
+
"d": "M8.87894737,13 L7.08947368,13 L7.08947368,11.2105263 L8.87894737,11.2105263 L8.87894737,13 Z M8.62102372,9.86842105 L7.32800539,9.86842105 L7,4.5 L8.96842105,4.5 L8.62102372,9.86842105 Z"
|
|
156
|
+
}, null)])]);
|
|
157
|
+
}
|
|
158
|
+
function InfoIcon() {
|
|
159
|
+
return createVNode("svg", {
|
|
160
|
+
"width": "16px",
|
|
161
|
+
"height": "16px",
|
|
162
|
+
"viewBox": "0 0 16 16",
|
|
163
|
+
"version": "1.1",
|
|
164
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
165
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink"
|
|
166
|
+
}, [createVNode("g", {
|
|
167
|
+
"id": "info",
|
|
168
|
+
"stroke": "none",
|
|
169
|
+
"stroke-width": "1",
|
|
170
|
+
"fill": "none",
|
|
171
|
+
"fill-rule": "evenodd"
|
|
172
|
+
}, [createVNode("path", {
|
|
173
|
+
"class": "devui-notification-image-info-path",
|
|
174
|
+
"d": "M7,13 L7,6 L9,6 L9,13 L7,13 Z M7,5 L7,3 L9,3 L9,5 L7,5 Z",
|
|
175
|
+
"id": "info"
|
|
176
|
+
}, null)])]);
|
|
177
|
+
}
|
|
178
|
+
function ErrorIcon() {
|
|
179
|
+
return createVNode("svg", {
|
|
180
|
+
"width": "16px",
|
|
181
|
+
"height": "16px",
|
|
182
|
+
"viewBox": "0 0 16 16",
|
|
183
|
+
"version": "1.1",
|
|
184
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
185
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink"
|
|
186
|
+
}, [createVNode("defs", null, [createVNode("polygon", {
|
|
187
|
+
"id": "path-e",
|
|
188
|
+
"points": "8.07106781 6.65685425 10.8994949 3.82842712 12.3137085 5.24264069 9.48528137 8.07106781 12.3137085 10.8994949 10.8994949 12.3137085 8.07106781 9.48528137 5.24264069 12.3137085 3.82842712 10.8994949 6.65685425 8.07106781 3.82842712 5.24264069 5.24264069 3.82842712"
|
|
189
|
+
}, null)]), createVNode("g", {
|
|
190
|
+
"id": "error",
|
|
191
|
+
"stroke": "none",
|
|
192
|
+
"stroke-width": "1",
|
|
193
|
+
"fill": "none",
|
|
194
|
+
"fill-rule": "evenodd"
|
|
195
|
+
}, [createVNode("mask", {
|
|
196
|
+
"id": "mask-2",
|
|
197
|
+
"fill": "white"
|
|
198
|
+
}, [createVNode("use", {
|
|
199
|
+
"xlink:href": "#path-e"
|
|
200
|
+
}, null)]), createVNode("use", {
|
|
201
|
+
"id": "Mask",
|
|
202
|
+
"class": "devui-notification-image-error-path",
|
|
203
|
+
"xlink:href": "#path-e"
|
|
204
|
+
}, null)])]);
|
|
205
|
+
}
|
|
107
206
|
var TypeIcon = defineComponent({
|
|
108
207
|
props: {
|
|
109
208
|
type: {
|
|
@@ -119,18 +218,9 @@ var TypeIcon = defineComponent({
|
|
|
119
218
|
"devui-notification-image": true,
|
|
120
219
|
[`devui-notification-image-${type.value}`]: true
|
|
121
220
|
}));
|
|
122
|
-
const severityIconMap = {
|
|
123
|
-
info: "info-o",
|
|
124
|
-
success: "right-o",
|
|
125
|
-
warning: "warning-o",
|
|
126
|
-
error: "error-o"
|
|
127
|
-
};
|
|
128
221
|
return () => createVNode("span", {
|
|
129
222
|
"class": classes.value
|
|
130
|
-
}, [type.value !== "normal" && createVNode(
|
|
131
|
-
"name": severityIconMap[type.value],
|
|
132
|
-
"size": "16px"
|
|
133
|
-
}, null)]);
|
|
223
|
+
}, [type.value && type.value !== "normal" && (type.value === "success" && createVNode(SuccessIcon, null, null) || type.value === "info" && createVNode(InfoIcon, null, null) || type.value === "warning" && createVNode(WarningIcon, null, null) || type.value === "error" && createVNode(ErrorIcon, null, null))]);
|
|
134
224
|
}
|
|
135
225
|
});
|
|
136
226
|
function useNotification(props) {
|
|
@@ -455,7 +545,7 @@ const useSelectFiles = () => {
|
|
|
455
545
|
if (uploadOptions && beyondMaximalSize(file.size, uploadOptions.maximumSize)) {
|
|
456
546
|
return {
|
|
457
547
|
checkError: true,
|
|
458
|
-
errorMsg: getBeyondMaximalFileSizeMsg(file.name, uploadOptions.maximumSize)
|
|
548
|
+
errorMsg: getBeyondMaximalFileSizeMsg(file.name, uploadOptions.maximumSize || 0)
|
|
459
549
|
};
|
|
460
550
|
}
|
|
461
551
|
return { checkError: false, errorMsg: void 0 };
|
|
@@ -494,11 +584,11 @@ class FileUploader {
|
|
|
494
584
|
}
|
|
495
585
|
send(uploadFiles) {
|
|
496
586
|
return new Promise((resolve, reject) => {
|
|
497
|
-
const { uri, method, headers, authToken, authTokenHeader, additionalParameter, fileFieldName, withCredentials, responseType } = this.uploadOptions;
|
|
587
|
+
const { uri, method, headers, authToken, authTokenHeader, additionalParameter, fileFieldName, withCredentials, responseType } = this.uploadOptions || {};
|
|
498
588
|
const authTokenHeader_ = authTokenHeader || "Authorization";
|
|
499
589
|
const fileFieldName_ = fileFieldName || "file";
|
|
500
590
|
this.xhr = new XMLHttpRequest();
|
|
501
|
-
this.xhr.open(method || "POST", uri);
|
|
591
|
+
this.xhr.open(method || "POST", uri || "");
|
|
502
592
|
if (withCredentials) {
|
|
503
593
|
this.xhr.withCredentials = withCredentials;
|
|
504
594
|
}
|
|
@@ -510,7 +600,8 @@ class FileUploader {
|
|
|
510
600
|
}
|
|
511
601
|
if (headers) {
|
|
512
602
|
Object.keys(headers).forEach((key) => {
|
|
513
|
-
|
|
603
|
+
var _a;
|
|
604
|
+
(_a = this.xhr) == null ? void 0 : _a.setRequestHeader(key, headers[key]);
|
|
514
605
|
});
|
|
515
606
|
}
|
|
516
607
|
this.xhr.upload.onprogress = (e) => {
|
|
@@ -524,19 +615,21 @@ class FileUploader {
|
|
|
524
615
|
this.xhr = null;
|
|
525
616
|
};
|
|
526
617
|
this.xhr.onerror = () => {
|
|
527
|
-
|
|
618
|
+
var _a, _b;
|
|
619
|
+
this.response = (_a = this.xhr) == null ? void 0 : _a.response;
|
|
528
620
|
this.status = UploadStatus.failed;
|
|
529
|
-
reject({ file: this.file, response: this.xhr.response });
|
|
621
|
+
reject({ file: this.file, response: (_b = this.xhr) == null ? void 0 : _b.response });
|
|
530
622
|
};
|
|
531
623
|
this.xhr.onload = () => {
|
|
532
|
-
|
|
624
|
+
var _a, _b, _c;
|
|
625
|
+
if (((_a = this.xhr) == null ? void 0 : _a.readyState) === 4 && this.xhr.status >= 200 && this.xhr.status < 300) {
|
|
533
626
|
this.response = this.xhr.response;
|
|
534
627
|
this.status = UploadStatus.uploaded;
|
|
535
628
|
resolve({ file: this.file, response: this.xhr.response });
|
|
536
629
|
} else {
|
|
537
|
-
this.response = this.xhr.response;
|
|
630
|
+
this.response = (_b = this.xhr) == null ? void 0 : _b.response;
|
|
538
631
|
this.status = UploadStatus.failed;
|
|
539
|
-
reject({ file: this.file, response: this.xhr.response });
|
|
632
|
+
reject({ file: this.file, response: (_c = this.xhr) == null ? void 0 : _c.response });
|
|
540
633
|
}
|
|
541
634
|
};
|
|
542
635
|
});
|
|
@@ -643,7 +736,7 @@ const useUpload = () => {
|
|
|
643
736
|
};
|
|
644
737
|
const deleteFile = (file) => {
|
|
645
738
|
const deleteUploadFile = fileUploaders.value.find((fileUploader) => fileUploader.file === file);
|
|
646
|
-
deleteUploadFile.cancel();
|
|
739
|
+
deleteUploadFile == null ? void 0 : deleteUploadFile.cancel();
|
|
647
740
|
fileUploaders.value = fileUploaders.value.filter((fileUploader) => {
|
|
648
741
|
return file !== fileUploader.file;
|
|
649
742
|
});
|
|
@@ -708,7 +801,6 @@ var Upload = defineComponent({
|
|
|
708
801
|
getSameNameFiles
|
|
709
802
|
} = useUpload();
|
|
710
803
|
const isDropOVer = ref(false);
|
|
711
|
-
ref("");
|
|
712
804
|
const alertMsg = (errorMsg) => {
|
|
713
805
|
NotificationService.open({
|
|
714
806
|
type: "warning",
|
|
@@ -716,10 +808,11 @@ var Upload = defineComponent({
|
|
|
716
808
|
});
|
|
717
809
|
};
|
|
718
810
|
const checkValid = () => {
|
|
811
|
+
var _a;
|
|
719
812
|
let totalFileSize = 0;
|
|
720
813
|
fileUploaders.value.forEach((fileUploader) => {
|
|
721
814
|
totalFileSize += fileUploader.file.size;
|
|
722
|
-
const checkResult = _validateFiles(fileUploader.file, accept.value, fileUploader.uploadOptions);
|
|
815
|
+
const checkResult = _validateFiles(fileUploader.file, (accept == null ? void 0 : accept.value) || "", fileUploader.uploadOptions);
|
|
723
816
|
if (checkResult && checkResult.checkError) {
|
|
724
817
|
deleteFile(fileUploader.file);
|
|
725
818
|
alertMsg(checkResult.errorMsg);
|
|
@@ -727,51 +820,13 @@ var Upload = defineComponent({
|
|
|
727
820
|
}
|
|
728
821
|
});
|
|
729
822
|
if (oneTimeUpload.value) {
|
|
730
|
-
const checkResult = checkAllFilesSize(totalFileSize, uploadOptions.value.maximumSize);
|
|
823
|
+
const checkResult = checkAllFilesSize(totalFileSize, ((_a = uploadOptions == null ? void 0 : uploadOptions.value) == null ? void 0 : _a.maximumSize) || 0);
|
|
731
824
|
if (checkResult && checkResult.checkError) {
|
|
732
825
|
removeFiles();
|
|
733
826
|
alertMsg(checkResult.errorMsg);
|
|
734
827
|
}
|
|
735
828
|
}
|
|
736
829
|
};
|
|
737
|
-
const _dealFiles = (promise) => {
|
|
738
|
-
resetSameNameFiles();
|
|
739
|
-
promise.then((files) => {
|
|
740
|
-
files.forEach((file) => {
|
|
741
|
-
if (!multiple.value) {
|
|
742
|
-
removeFiles();
|
|
743
|
-
}
|
|
744
|
-
addFile(file, uploadOptions.value);
|
|
745
|
-
});
|
|
746
|
-
checkValid();
|
|
747
|
-
const sameNameFiles = getSameNameFiles();
|
|
748
|
-
if (uploadOptions.value && uploadOptions.value.checkSameName && sameNameFiles.length) {
|
|
749
|
-
alertMsg(getExistSameNameFilesMsg(sameNameFiles));
|
|
750
|
-
}
|
|
751
|
-
const selectedFiles = fileUploaders.value.filter((fileUploader) => fileUploader.status === UploadStatus.preLoad).map((fileUploader) => fileUploader.file);
|
|
752
|
-
ctx.emit("fileSelect", selectedFiles);
|
|
753
|
-
if (autoUpload.value) {
|
|
754
|
-
fileUpload();
|
|
755
|
-
}
|
|
756
|
-
}).catch((error) => {
|
|
757
|
-
alertMsg(error.message);
|
|
758
|
-
});
|
|
759
|
-
};
|
|
760
|
-
const handleClick = () => {
|
|
761
|
-
if (disabled.value) {
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
764
|
-
_dealFiles(triggerSelectFiles({
|
|
765
|
-
accept: accept.value,
|
|
766
|
-
multiple: multiple.value,
|
|
767
|
-
webkitdirectory: webkitdirectory.value
|
|
768
|
-
}));
|
|
769
|
-
};
|
|
770
|
-
const onFileDrop = (files) => {
|
|
771
|
-
isDropOVer.value = false;
|
|
772
|
-
_dealFiles(triggerDropFiles(files));
|
|
773
|
-
ctx.emit("fileDrop", files);
|
|
774
|
-
};
|
|
775
830
|
const onFileOver = (event) => {
|
|
776
831
|
isDropOVer.value = event;
|
|
777
832
|
ctx.emit("fileOver", event);
|
|
@@ -792,13 +847,13 @@ var Upload = defineComponent({
|
|
|
792
847
|
};
|
|
793
848
|
const canUpload = () => {
|
|
794
849
|
let uploadResult = Promise.resolve(true);
|
|
795
|
-
if (beforeUpload.value) {
|
|
796
|
-
const result = beforeUpload.value(getFullFiles());
|
|
850
|
+
if (beforeUpload == null ? void 0 : beforeUpload.value) {
|
|
851
|
+
const result = beforeUpload == null ? void 0 : beforeUpload.value(getFullFiles());
|
|
797
852
|
if (typeof result !== "undefined") {
|
|
798
|
-
if (result
|
|
799
|
-
uploadResult = result;
|
|
800
|
-
} else {
|
|
853
|
+
if (typeof result === "boolean") {
|
|
801
854
|
uploadResult = Promise.resolve(result);
|
|
855
|
+
} else {
|
|
856
|
+
uploadResult = result;
|
|
802
857
|
}
|
|
803
858
|
}
|
|
804
859
|
}
|
|
@@ -814,7 +869,7 @@ var Upload = defineComponent({
|
|
|
814
869
|
return;
|
|
815
870
|
}
|
|
816
871
|
const uploadObservable = oneTimeUpload.value ? _oneTimeUpload() : upload2(fileUploader);
|
|
817
|
-
uploadObservable.then((results) => {
|
|
872
|
+
uploadObservable == null ? void 0 : uploadObservable.then((results) => {
|
|
818
873
|
props["on-success"] && props["on-success"](results);
|
|
819
874
|
const newFiles = results.map((result) => result.file);
|
|
820
875
|
const newUploadedFiles = [...newFiles, ...modelValue.value];
|
|
@@ -824,6 +879,44 @@ var Upload = defineComponent({
|
|
|
824
879
|
});
|
|
825
880
|
});
|
|
826
881
|
};
|
|
882
|
+
const _dealFiles = (promise) => {
|
|
883
|
+
resetSameNameFiles();
|
|
884
|
+
promise.then((files) => {
|
|
885
|
+
files.forEach((file) => {
|
|
886
|
+
if (!multiple.value) {
|
|
887
|
+
removeFiles();
|
|
888
|
+
}
|
|
889
|
+
addFile(file, uploadOptions == null ? void 0 : uploadOptions.value);
|
|
890
|
+
});
|
|
891
|
+
checkValid();
|
|
892
|
+
const sameNameFiles = getSameNameFiles();
|
|
893
|
+
if ((uploadOptions == null ? void 0 : uploadOptions.value) && uploadOptions.value.checkSameName && sameNameFiles.length) {
|
|
894
|
+
alertMsg(getExistSameNameFilesMsg(sameNameFiles));
|
|
895
|
+
}
|
|
896
|
+
const selectedFiles = fileUploaders.value.filter((fileUploader) => fileUploader.status === UploadStatus.preLoad).map((fileUploader) => fileUploader.file);
|
|
897
|
+
ctx.emit("fileSelect", selectedFiles);
|
|
898
|
+
if (autoUpload.value) {
|
|
899
|
+
fileUpload();
|
|
900
|
+
}
|
|
901
|
+
}).catch((error) => {
|
|
902
|
+
alertMsg(error.message);
|
|
903
|
+
});
|
|
904
|
+
};
|
|
905
|
+
const handleClick = () => {
|
|
906
|
+
if (disabled.value) {
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
_dealFiles(triggerSelectFiles({
|
|
910
|
+
accept: accept == null ? void 0 : accept.value,
|
|
911
|
+
multiple: multiple.value,
|
|
912
|
+
webkitdirectory: webkitdirectory.value
|
|
913
|
+
}));
|
|
914
|
+
};
|
|
915
|
+
const onFileDrop = (files) => {
|
|
916
|
+
isDropOVer.value = false;
|
|
917
|
+
_dealFiles(triggerDropFiles(files));
|
|
918
|
+
ctx.emit("fileDrop", files);
|
|
919
|
+
};
|
|
827
920
|
return () => {
|
|
828
921
|
var _a, _b, _c, _d;
|
|
829
922
|
return createVNode("div", null, [withDirectives(createVNode("div", {
|
package/upload/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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"});
|
|
1
|
+
var Oe=Object.defineProperty,Pe=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable;var O=(p,e,V)=>e in p?Oe(p,e,{enumerable:!0,configurable:!0,writable:!0,value:V}):p[e]=V,P=(p,e)=>{for(var V in e||(e={}))ze.call(e,V)&&O(p,V,e[V]);if(X)for(var V of X(e))Ie.call(e,V)&&O(p,V,e[V]);return p},G=(p,e)=>Pe(p,$e(e));var w=(p,e,V)=>(O(p,typeof e!="symbol"?e+"":e,V),V);(function(p,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(p=typeof globalThis!="undefined"?globalThis:p||self,e(p.index={},p.Vue))})(this,function(p,e){"use strict";const V={modelValue:{type:Boolean,default:!1},title:{type:String,default:""},type:{type:String,default:"normal"},duration:{type:Number,default:3e3},onClose:{type:Function}},Y={name:{type:String,default:"",required:!0},size:{type:String,default:"inherit"},color:{type:String,default:"inherit"},classPrefix:{type:String,default:"icon"}};var J=e.defineComponent({name:"DIcon",props:Y,setup(t){const{name:n,size:o,color:s,classPrefix:a}=e.toRefs(t);return()=>/^((https?):)?\/\//.test(n.value)?e.createVNode("img",{src:n.value,alt:n.value.split("/")[n.value.split("/").length-1],style:{width:o.value,verticalAlign:"text-bottom"}},null):e.createVNode("i",{class:`${a.value} ${a.value}-${n.value}`,style:{fontSize:o.value,color:s.value}},null)}}),K=e.defineComponent({emits:["click"],setup(t,{emit:n}){return()=>e.createVNode("div",{class:"devui-notification-icon-close",onClick:o=>n("click",o)},[e.createVNode(J,{name:"close",size:"14px"},null)])}});function Q(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("defs",null,[e.createVNode("polygon",{id:"path-s",points:"6.53553391 9.77817459 12.1923882 4.12132034 13.6066017 5.53553391 6.53553391 12.6066017 3 9.07106781 4.41421356 7.65685425 6.53553391 9.77817459"},null)]),e.createVNode("g",{id:"correct",stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("mask",{id:"mask-2",fill:"white"},[e.createVNode("use",{"xlink:href":"#path-s"},null)]),e.createVNode("use",{id:"Mask",class:"devui-notification-image-success-path","xlink:href":"#path-s"},null)])])}function U(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("path",{class:"devui-icon-warning-outer",d:"M8.96244623,0.57254229 L15.8714442,13.4101975 C16.1549662,13.9370117 15.9538562,14.5918482 15.4222523,14.8728158 C15.2642579,14.9563203 15.0879506,15 14.9088903,15 L1.09089441,15 C0.488410063,15 0,14.5159904 0,13.9189343 C0,13.7414873 0.0440768395,13.5667684 0.128340519,13.4101975 L7.03733844,0.57254229 C7.32086049,0.0457280838 7.98165058,-0.153569987 8.51325441,0.127397589 C8.70423071,0.228333932 8.8605922,0.383286648 8.96244623,0.57254229 Z"},null),e.createVNode("path",{class:"devui-icon-warning-inner","stroke-width":"0.3","fill-rule":"nonzero",d:"M8.87894737,13 L7.08947368,13 L7.08947368,11.2105263 L8.87894737,11.2105263 L8.87894737,13 Z M8.62102372,9.86842105 L7.32800539,9.86842105 L7,4.5 L8.96842105,4.5 L8.62102372,9.86842105 Z"},null)])])}function ee(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("g",{id:"info",stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("path",{class:"devui-notification-image-info-path",d:"M7,13 L7,6 L9,6 L9,13 L7,13 Z M7,5 L7,3 L9,3 L9,5 L7,5 Z",id:"info"},null)])])}function te(){return e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"},[e.createVNode("defs",null,[e.createVNode("polygon",{id:"path-e",points:"8.07106781 6.65685425 10.8994949 3.82842712 12.3137085 5.24264069 9.48528137 8.07106781 12.3137085 10.8994949 10.8994949 12.3137085 8.07106781 9.48528137 5.24264069 12.3137085 3.82842712 10.8994949 6.65685425 8.07106781 3.82842712 5.24264069 5.24264069 3.82842712"},null)]),e.createVNode("g",{id:"error",stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("mask",{id:"mask-2",fill:"white"},[e.createVNode("use",{"xlink:href":"#path-e"},null)]),e.createVNode("use",{id:"Mask",class:"devui-notification-image-error-path","xlink:href":"#path-e"},null)])])}var ne=e.defineComponent({props:{type:{type:String,default:"normal"}},setup(t){const{type:n}=e.toRefs(t),o=e.computed(()=>({"devui-notification-image":!0,[`devui-notification-image-${n.value}`]:!0}));return()=>e.createVNode("span",{class:o.value},[n.value&&n.value!=="normal"&&(n.value==="success"&&e.createVNode(Q,null,null)||n.value==="info"&&e.createVNode(ee,null,null)||n.value==="warning"&&e.createVNode(U,null,null)||n.value==="error"&&e.createVNode(te,null,null))])}});function oe(t){return{classes:e.computed(()=>({"devui-notification-item-container":!0,[`devui-notification-message-${t.type}`]:!0}))}}function ie(t,n){let o=null,s;const a=()=>{var k;clearTimeout(o),o=null,(k=t.onClose)==null||k.call(t),n("update:modelValue",!1)},f=()=>{o&&(clearTimeout(o),o=null)},v=()=>{if(!t.modelValue){const k=t.duration-(Date.now()-s);o=setTimeout(a,k)}},D=()=>{n("destroy")};return e.watch(()=>t.modelValue,k=>{k&&(s=Date.now(),t.duration&&(o=setTimeout(a,t.duration)))}),{interrupt:f,removeReset:v,close:a,handleDestroy:D}}var _e="",le=e.defineComponent({name:"DNotification",props:V,emits:["update:modelValue","destroy"],setup(t,{emit:n,slots:o}){const{modelValue:s,title:a,type:f}=e.toRefs(t),{classes:v}=oe(t),{interrupt:D,removeReset:k,close:u,handleDestroy:r}=ie(t,n);return()=>e.createVNode(e.Transition,{name:"notification-fade",onAfterLeave:r},{default:()=>{var m;return[s.value&&e.createVNode("div",{class:"devui-notification"},[e.createVNode("div",{class:v.value,onMouseenter:D,onMouseleave:k},[e.createVNode("div",{class:"devui-notification-item"},[e.createVNode(K,{onClick:u},null),a.value&&e.createVNode(ne,{type:f.value},null),e.createVNode("div",{class:"devui-notification-message"},[e.createVNode("span",{class:"devui-notification-title"},[a.value]),e.createVNode("span",{class:"devui-notification-content"},[(m=o.default)==null?void 0:m.call(o)])])])])])]}})}});function se(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!e.isVNode(t)}const ae={modelValue:!1,duration:3e3,type:"normal"};function re(t,n){const o=document.createElement("div"),s=e.createApp({setup(){return e.onUnmounted(()=>{document.body.removeChild(o)}),()=>e.createVNode(le,e.mergeProps(t,{onDestroy:s.unmount}),se(n)?n:{default:()=>[n]})}});return document.body.appendChild(o),s.mount(o),s}function ue(t,n){t.modelValue=!1,n==null||n()}class ce{static open(n){const o=n.onClose||null,s=n.content;let a;delete n.content;const f=e.reactive(G(P(P({},ae),n),{onClose:()=>{ue(f,o)}}));re(f,s),f.modelValue=!0,clearTimeout(a),n.duration&&(a=setTimeout(f.onClose,n.duration))}}class de{constructor(){w(this,"uri");w(this,"method");w(this,"maximumSize");w(this,"headers");w(this,"authToken");w(this,"authTokenHeader");w(this,"additionalParameter");w(this,"fileFieldName");w(this,"checkSameName");w(this,"withCredentials");w(this,"responseType")}}class pe{constructor(){w(this,"accept");w(this,"multiple");w(this,"webkitdirectory")}}var F=(t=>(t[t.preLoad=0]="preLoad",t[t.uploading=1]="uploading",t[t.uploaded=2]="uploaded",t[t.failed=3]="failed",t))(F||{});const $={accept:{type:String},webkitdirectory:{type:Boolean,default:!1},uploadOptions:{type:Object},multiple:{type:Boolean,default:!1},autoUpload:{type:Boolean,default:!0},placeholder:{type:String,default:"\u9009\u62E9\u6587\u4EF6"},modelValue:{type:Array,default:()=>[]},droppable:{type:Boolean,default:!1},beforeUpload:{type:Function},dynamicUploadOptionsFn:{type:Function},disabled:{type:Boolean,default:!1},onChange:{type:Function},fileDrop:{type:Function,default:void 0},fileOver:{type:Function,default:void 0},fileSelect:{type:Function,default:void 0},deleteUploadedFile:{type:Function,default:void 0},"on-error":{type:Function,default:void 0},"on-success":{type:Function,default:void 0},oneTimeUpload:{type:Boolean,default:!1}},fe=t=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${t}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,me=(t,n)=>`\u6700\u5927\u652F\u6301\u4E0A\u4F20${n}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${t}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`,he=(t,n)=>`\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${n}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${t}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,ge=t=>`\u60A8\u4E0A\u4F20\u7684 "${t}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`,Fe=()=>{const t=e.ref(""),n=u=>{const r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,0,null),u.dispatchEvent(r)},o=({multiple:u,accept:r,webkitdirectory:m})=>new Promise(C=>{const l=document.getElementById("d-upload-temp");l&&document.body.removeChild(l);const i=document.createElement("input");i.style.position="fixed",i.style.left="-2000px",i.style.top="-2000px",i.setAttribute("id","d-upload-temp"),i.setAttribute("type","file"),u&&i.setAttribute("multiple",""),r&&i.setAttribute("accept",r),m&&i.setAttribute("webkitdirectory",""),i.addEventListener("change",h=>{C(Array.prototype.slice.call(h.target.files))}),document.body.appendChild(i),n(i)}),s=(u,r)=>{if(u){const m=u.split(","),C=r.type.replace(/\/.*$/,"");return m.some(l=>{const i=l.trim();return i.startsWith(".")?r.name.toLowerCase().indexOf(i.toLowerCase(),r.name.toLowerCase().length-i.toLowerCase().length)>-1:/\/\*$/.test(i)?C===i.replace(/\/.*$/,""):r.type===i})}return!0},a=(u,r)=>r?u>1024*1024*r:!1;return{triggerSelectFiles:u=>{const{multiple:r,accept:m,webkitdirectory:C}=u;return o({multiple:r,accept:m,webkitdirectory:C})},_validateFiles:(u,r,m)=>s(r,u)?m&&a(u.size,m.maximumSize)?{checkError:!0,errorMsg:me(u.name,m.maximumSize||0)}:{checkError:!1,errorMsg:void 0}:{checkError:!0,errorMsg:he(u.name,r)},triggerDropFiles:u=>Promise.resolve(u),checkAllFilesSize:(u,r)=>{if(a(u,r))return t.value=fe(r),{checkError:!0,errorMsg:t.value}}}};class z{constructor(n,o){w(this,"xhr");w(this,"status");w(this,"response");w(this,"percentage",0);this.file=n,this.uploadOptions=o,this.file=n,this.uploadOptions=o,this.status=F.preLoad}send(n){return new Promise((o,s)=>{const{uri:a,method:f,headers:v,authToken:D,authTokenHeader:k,additionalParameter:u,fileFieldName:r,withCredentials:m,responseType:C}=this.uploadOptions||{},l=k||"Authorization",i=r||"file";this.xhr=new XMLHttpRequest,this.xhr.open(f||"POST",a||""),m&&(this.xhr.withCredentials=m),C&&(this.xhr.responseType=C),D&&this.xhr.setRequestHeader(l,D),v&&Object.keys(v).forEach(x=>{var N;(N=this.xhr)==null||N.setRequestHeader(x,v[x])}),this.xhr.upload.onprogress=x=>{this.percentage=Math.round(x.loaded*100/x.total)};const h=n&&n.length?this.oneTimeUploadFiles(i,u,n):this.parallelUploadFiles(i,u);this.xhr.send(h),this.status=F.uploading,this.xhr.onabort=()=>{this.status=F.preLoad,this.xhr=null},this.xhr.onerror=()=>{var x,N;this.response=(x=this.xhr)==null?void 0:x.response,this.status=F.failed,s({file:this.file,response:(N=this.xhr)==null?void 0:N.response})},this.xhr.onload=()=>{var x,N,S;((x=this.xhr)==null?void 0:x.readyState)===4&&this.xhr.status>=200&&this.xhr.status<300?(this.response=this.xhr.response,this.status=F.uploaded,o({file:this.file,response:this.xhr.response})):(this.response=(N=this.xhr)==null?void 0:N.response,this.status=F.failed,s({file:this.file,response:(S=this.xhr)==null?void 0:S.response}))}})}parallelUploadFiles(n,o){const s=new FormData;return s.append(n,this.file,this.file.name),o&&Object.keys(o).forEach(a=>{s.append(a,o[a])}),s}oneTimeUploadFiles(n,o,s){const a=new FormData;return s.forEach(f=>{a.append(n,f.file,f.file.name),o&&Object.keys(o).forEach(v=>{a.append(v,o[v])})}),a}cancel(){this.xhr&&this.xhr.abort()}}const ve=()=>{const t=e.ref([]),n=e.ref([]),o=l=>{let i=!0;for(let h=0;h<t.value.length;h++)if(l===t.value[h].file.name){i=!1,n.value.indexOf(l)===-1&&n.value.push(l);break}return i},s=(l,i)=>{i&&i.checkSameName?o(l.name)&&t.value.push(new z(l,i)):t.value.push(new z(l,i))},a=()=>t.value.map(l=>l.file),f=()=>t.value.map(l=>l),v=async l=>{if(!l||!l.length)return Promise.reject("no files");let i=[];return await l[0].send(l).finally(()=>i=l.map(h=>(h.status=l[0].status,h.percentage=l[0].percentage,{file:h.file,response:l[0].response}))),i};return{fileUploaders:t,getFiles:a,addFile:s,getFullFiles:f,deleteFile:l=>{const i=t.value.find(h=>h.file===l);i==null||i.cancel(),t.value=t.value.filter(h=>l!==h.file)},upload:async l=>{let i=[];if(l){l.percentage=0;const h=await l.send();i.push(h)}else{const h=t.value.filter(S=>S.status===F.preLoad),x=t.value.filter(S=>S.status===F.failed),N=h.length>0?h:x;i=await Promise.all(N.map(async S=>(S.percentage=0,await S.send())))}return i.length>0?Promise.resolve(i):Promise.reject("no files")},removeFiles:()=>{t.value=[],n.value=[]},getSameNameFiles:()=>n.value.join(),resetSameNameFiles:()=>{n.value=[]},_oneTimeUpload:()=>{const l=t.value.filter(i=>i.status!==F.uploaded);return v(l)}}};var Re="",L=e.defineComponent({name:"DUpload",props:$,emits:["fileDrop","fileOver","fileSelect","deleteUploadedFile","update:modelValue"],setup(t,n){const{uploadOptions:o,placeholder:s,autoUpload:a,disabled:f,beforeUpload:v,droppable:D,oneTimeUpload:k,modelValue:u,multiple:r,accept:m,webkitdirectory:C}=e.toRefs(t),{triggerSelectFiles:l,_validateFiles:i,triggerDropFiles:h,checkAllFilesSize:x}=Fe(),{fileUploaders:N,addFile:S,getFullFiles:_,deleteFile:R,upload:Ee,resetSameNameFiles:Ce,removeFiles:A,_oneTimeUpload:Se,getSameNameFiles:De}=ve(),M=e.ref(!1),b=d=>{ce.open({type:"warning",content:d})},be=()=>{var g;let d=0;if(N.value.forEach(y=>{d+=y.file.size;const E=i(y.file,(m==null?void 0:m.value)||"",y.uploadOptions);if(E&&E.checkError){R(y.file),b(E.errorMsg);return}}),k.value){const y=x(d,((g=o==null?void 0:o.value)==null?void 0:g.maximumSize)||0);y&&y.checkError&&(A(),b(y.errorMsg))}},Le=d=>{M.value=d,n.emit("fileOver",d)},j=d=>{const g=u.value.filter(y=>y.name!==d.name);n.emit("deleteUploadedFile",d),n.emit("update:modelValue",g)},Te=(d,g,y)=>{d.stopPropagation(),y===F.uploaded&&j(g),R(g)},Ae=()=>{let d=Promise.resolve(!0);if(v==null?void 0:v.value){const g=v==null?void 0:v.value(_());typeof g!="undefined"&&(typeof g=="boolean"?d=Promise.resolve(g):d=g)}return d},H=(d,g)=>{d&&d.stopPropagation(),Ae().then(y=>{if(!y){A();return}const E=k.value?Se():Ee(g);E==null||E.then(c=>{t["on-success"]&&t["on-success"](c);const B=[...c.map(Be=>Be.file),...u.value];n.emit("update:modelValue",B)}).catch(c=>{t["on-error"]&&t["on-error"](c)})})},Z=d=>{Ce(),d.then(g=>{g.forEach(c=>{r.value||A(),S(c,o==null?void 0:o.value)}),be();const y=De();(o==null?void 0:o.value)&&o.value.checkSameName&&y.length&&b(ge(y));const E=N.value.filter(c=>c.status===F.preLoad).map(c=>c.file);n.emit("fileSelect",E),a.value&&H()}).catch(g=>{b(g.message)})},q=()=>{f.value||Z(l({accept:m==null?void 0:m.value,multiple:r.value,webkitdirectory:C.value}))},Me=d=>{M.value=!1,Z(h(d)),n.emit("fileDrop",d)};return()=>{var d,g,y,E;return e.createVNode("div",null,[e.withDirectives(e.createVNode("div",{class:"devui-upload",style:`border: ${M.value?"1px solid #15bf15":"0"}`},[((g=(d=n.slots).default)==null?void 0:g.call(d))?e.createVNode("div",{onClick:q},[n.slots.default()]):e.createVNode("div",{class:`devui-input-group ${f.value?"disabled":""}`,onClick:q},[N.value.length===0&&e.createVNode("div",{class:"devui-form-control devui-upload-placeholder"},[s.value]),N.value.length>0&&e.createVNode("ul",{class:"devui-form-control devui-files-list"},[N.value.map((c,W)=>e.createVNode("li",{key:W,class:"devui-file-item devui-file-tag",style:"display: inline-block; margin: 0 2px 2px 0",title:c.file.name},[e.createVNode("span",{class:`devui-filename ${c.status===F.failed?"devui-failed-color":""}`},[c.file.name]),e.createVNode(e.resolveComponent("d-icon"),{name:"close",class:`${(c==null?void 0:c.status)===F.failed?"devui-upload-delete-file-button":""} ${(c==null?void 0:c.status)===F.uploading||(c==null?void 0:c.status)===F.uploaded?"devui-uploading-delete":""}`,onClick:B=>Te(B,c.file,c.status)},null),c.status===F.uploading&&e.createVNode("div",{class:"icon devui-upload-progress"},[e.createVNode(e.resolveComponent("d-progress"),{isCircle:!0,percentage:c.percentage,barbgcolor:"#50D4AB",strokeWidth:8,showContent:!1},null)]),c.status===F.failed&&e.createVNode(e.resolveComponent("d-icon"),{name:"running",onClick:H},null),c.status===F.uploaded&&e.createVNode(e.resolveComponent("d-icon"),{name:"right",color:"#50d4ab"},null)]))]),e.createVNode("span",{class:"devui-input-group-addon"},[e.createVNode(e.resolveComponent("d-icon"),{name:"more-operate",color:"#252b3a"},null)])])]),[[e.resolveDirective("file-drop"),{droppable:D,isSingle:!r,onFileDrop:Me,onFileOver:Le}]]),e.createVNode("div",null,[(E=(y=n.slots)["uploaded-files"])==null?void 0:E.call(y,{uploadedFiles:u.value,deleteFile:j})])])}}});const I=t=>{var n;return t.dataTransfer?t.dataTransfer:(n=t.originalEvent)==null?void 0:n.dataTransfer},ye=t=>t?t.indexOf?t.indexOf("Files")!==-1:t.contains?t.contains("Files"):!1:!1,T=t=>{t.preventDefault(),t.stopPropagation()},we=(t,n)=>{const{onFileOver:o}=n.value;t.addEventListener("dragover",s=>{const a=I(s);!ye(a.types)||(T(s),o&&o(!0))})},Ne=(t,n)=>{const{onFileOver:o}=n.value;t.addEventListener("dragleave",s=>{s.currentTarget!==t&&(T(s),o&&o(!0))})},Ve=(t,n)=>{const{onFileDrop:o,isSingle:s}=n.value;t.addEventListener("drop",a=>{const f=I(a);!f||(T(a),s?o&&o([f.files[0]]):o&&o(Array.from(f.files)))})},ke={mounted:(t,n)=>{const{droppable:o}=n.value;!o||(we(t,n),Ne(t,n),Ve(t,n))}};var xe={title:"Upload \u4E0A\u4F20",category:"\u6570\u636E\u5F55\u5165",status:"100%",install(t){t.directive("file-drop",ke),t.component(L.name,L)}};p.IFileOptions=pe,p.IUploadOptions=de,p.Upload=L,p.UploadStatus=F,p.default=xe,p.uploadProps=$,Object.defineProperty(p,"__esModule",{value:!0}),p[Symbol.toStringTag]="Module"});
|
package/upload/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.devui-notification{position:fixed;top:50px;right:20px;width:20em;word-break:normal;word-wrap:break-word;z-index:1060}.devui-notification a:link,.devui-notification a:visited{color:var(--devui-link-light, #96adfa)}.devui-notification a:hover,.devui-notification a:active{color:var(--devui-link-light-active, #beccfa)}.devui-notification-item-container{position:relative;margin:0 0 8px;opacity:.95;filter:alpha(opacity=95);box-shadow:var(--devui-shadow-length-feedback-overlay, 0 4px 16px 0) var(--devui-shadow, rgba(0, 0, 0, .2));border-radius:var(--devui-border-radius-feedback, 4px);color:var(--devui-feedback-overlay-text, #dfe1e6);background-color:var(--devui-feedback-overlay-bg, #464d6e)}.devui-notification-item{position:relative;display:block;padding:12px 16px}.devui-notification-icon-close{position:absolute;top:7px;right:10px;cursor:pointer}.devui-notification-icon-close i.icon{color:var(--devui-light-text, #ffffff)!important}.devui-notification-title{font-size:var(--devui-font-size-card-title, 14px);padding:0 0 calc(.5em - 2px) 0;display:block;font-weight:700}.devui-notification-image{position:absolute;display:inline-block;width:16px;height:16px;border-radius:50%;left:16px;top:14px;padding:0;line-height:1}.devui-notification-image.devui-notification-image-
|
|
1
|
+
.devui-notification{position:fixed;top:50px;right:20px;width:20em;word-break:normal;word-wrap:break-word;z-index:1060}.devui-notification a:link,.devui-notification a:visited{color:var(--devui-link-light, #96adfa)}.devui-notification a:hover,.devui-notification a:active{color:var(--devui-link-light-active, #beccfa)}.devui-notification-item-container{position:relative;margin:0 0 8px;opacity:.95;filter:alpha(opacity=95);box-shadow:var(--devui-shadow-length-feedback-overlay, 0 4px 16px 0) var(--devui-shadow, rgba(0, 0, 0, .2));border-radius:var(--devui-border-radius-feedback, 4px);color:var(--devui-feedback-overlay-text, #dfe1e6);background-color:var(--devui-feedback-overlay-bg, #464d6e)}.devui-notification-item{position:relative;display:block;padding:12px 16px}.devui-notification-icon-close{position:absolute;top:7px;right:10px;cursor:pointer}.devui-notification-icon-close i.icon{color:var(--devui-light-text, #ffffff)!important}.devui-notification-title{font-size:var(--devui-font-size-card-title, 14px);padding:0 0 calc(.5em - 2px) 0;display:block;font-weight:700}.devui-notification-image{position:absolute;display:inline-block;width:16px;height:16px;border-radius:50%;left:16px;top:14px;padding:0;line-height:1}.devui-notification-image.devui-notification-image-warning path.devui-icon-warning-outer{fill:var(--devui-warning-line, #fa9841)}.devui-notification-image.devui-notification-image-warning path.devui-icon-warning-inner{fill:var(--devui-light-text, #ffffff);stroke:var(--devui-light-text, #ffffff)}.devui-notification-image.devui-notification-image-info{background-color:var(--devui-info, #5e7ce0)}.devui-notification-image.devui-notification-image-error{background-color:var(--devui-danger, #f66f6a)}.devui-notification-image.devui-notification-image-success{background-color:var(--devui-success, #50d4ab)}.devui-notification-image .devui-notification-image-info-path,.devui-notification-image .devui-notification-image-error-path,.devui-notification-image .devui-notification-image-success-path{fill:var(--devui-light-text, #ffffff)}.devui-notification-message{margin-left:20px}.devui-notification-message .devui-notification-content{font-size:var(--devui-font-size, 12px);margin-top:4px}.devui-notification-message-common .devui-notification-message{margin-left:0}.devui-notification-message p{font-size:var(--devui-font-size, 12px);margin-top:4px}.notification-fade-enter-active,.notification-fade-leave-active{transition:transform var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out, cubic-bezier(.5, .05, .5, .95))}.notification-fade-enter-from,.notification-fade-leave-to{transform:translate(100%)}.devui-input-group{position:relative;display:flex!important;align-items:center;border-collapse:separate;width:360px}.devui-input-group:not(.disabled):hover .devui-input-group-addon{border-color:var(--devui-form-control-line-active, #5e7ce0);background-color:var(--devui-dividing-line, #dfe1e6);font-weight:700}.devui-input-group:not(.disabled):hover .devui-form-control{border-color:var(--devui-form-control-line-active, #5e7ce0);border-right-color:var(--devui-form-control-line, #adb0b8)}.devui-input-group:not(.disabled) .devui-input-group-addon:active{border-color:var(--devui-form-control-line-active, #5e7ce0);border-right-color:var(--devui-form-control-line, #adb0b8);background-color:var(--devui-dividing-line, #dfe1e6)}.devui-input-group .devui-input-group-addon{width:36px;white-space:nowrap;font-size:var(--devui-font-size-icon, 16px);font-weight:400;line-height:1;color:var(--devui-text, #252b3a);background-color:var(--devui-area, #f8f8f8);border-top:1px solid var(--devui-form-control-line, #adb0b8);border-bottom:1px solid var(--devui-form-control-line, #adb0b8);border-right:1px solid var(--devui-form-control-line, #adb0b8);border-radius:0 var(--devui-border-radius, 2px) var(--devui-border-radius, 2px) 0;transition:border-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1)),background-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1));cursor:pointer;height:100%;position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center}.devui-input-group .devui-form-control{cursor:pointer;display:block;width:100%;min-height:28px;height:unset;padding:4px 8px;font-size:var(--devui-font-size, 12px);line-height:1.5;background-image:none;border:1px solid var(--devui-form-control-line, #adb0b8);border-radius:var(--devui-border-radius, 2px) 0 0 var(--devui-border-radius, 2px);transition:border-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1)),box-shadow var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1))}.devui-input-group .devui-form-control.devui-files-list{max-height:52px;padding:2px 2px 0;overflow-x:hidden;overflow-y:auto;max-width:100%;margin:0}.devui-input-group .devui-form-control.devui-files-list .devui-file-item{height:22px;line-height:22px;padding:0 48px 0 12px}.devui-input-group .devui-form-control.devui-files-list .devui-file-tag{position:relative;background-color:var(--devui-label-bg, #eef0f5);border-radius:var(--devui-border-radius, 2px);max-width:100%}.devui-input-group .devui-form-control.devui-files-list .devui-file-tag .devui-filename{height:100%;display:inline-block;vertical-align:middle;max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.devui-input-group .devui-form-control.devui-files-list .devui-file-tag .icon{position:absolute;cursor:pointer;right:8px;top:50%;transform:translateY(-50%)}.devui-input-group .devui-form-control.devui-files-list .devui-file-tag .icon.icon-right{color:var(--devui-success, #50d4ab)}.devui-input-group .devui-form-control.devui-files-list .devui-file-tag .icon.icon-running{font-size:16px}.devui-input-group .devui-form-control.devui-files-list .devui-file-tag .icon.devui-upload-delete-file-button{margin-right:20px}.devui-input-group .devui-form-control.devui-files-list .devui-file-tag .icon.devui-uploading-delete,.devui-input-group .devui-form-control.devui-files-list .devui-file-tag:hover .devui-upload-progress,.devui-input-group .devui-form-control.devui-files-list .devui-file-tag:hover .icon-right{display:none}.devui-input-group .devui-form-control.devui-files-list .devui-file-tag:hover .icon-close{display:inline-block}.devui-input-group.disabled .devui-upload-placeholder{color:var(--devui-disabled-text, #adb0b8)}.devui-input-group .devui-upload-placeholder{max-height:28px;max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--devui-placeholder, #8a8e99)}.devui-input-group .devui-upload-progress{width:16px;height:16px}.devui-input-group.disabled .devui-form-control,.devui-input-group.disabled .devui-input-group-addon{cursor:not-allowed;background-color:var(--devui-disabled-bg, #f5f5f6);border-color:var(--devui-disabled-line, #dfe1e6);color:var(--devui-disabled-text, #adb0b8)}.devui-form-control{outline:none}.devui-input-group.disabled .devui-upload-delete-file-button{cursor:not-allowed;pointer-events:none}.devui-loading{color:var(--devui-aide-text, #8a8e99)}.devui-failed-color{color:var(--devui-danger, #f66f6a)}.devui-upload{display:flex}.devui-upload-tip{height:18px;margin-top:8px;font-size:12px}.devui-upload-tip .icon{margin-right:8px;font-size:16px;vertical-align:middle}.devui-upload-tip .icon-right-o{color:var(--devui-success, #50d4ab)}.devui-upload-tip .devui-upload-failed{color:var(--devui-danger, #f66f6a)}.devui-upload-tip a{color:var(--devui-link, #526ecc);cursor:pointer}
|