@nutui/nutui 4.0.12-beta.1 → 4.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nutui.es.js +1 -1
- package/dist/nutui.js +1 -1
- package/dist/nutui.umd.js +1 -1
- package/dist/packages/_es/ActionSheet.js +111 -78
- package/dist/packages/_es/Address.js +375 -250
- package/dist/packages/_es/AddressList.js +354 -269
- package/dist/packages/_es/Animate.js +58 -41
- package/dist/packages/_es/Audio.js +197 -128
- package/dist/packages/_es/AudioOperate.js +71 -60
- package/dist/packages/_es/Avatar.js +89 -66
- package/dist/packages/_es/AvatarGroup.js +31 -23
- package/dist/packages/_es/Backtop.js +99 -59
- package/dist/packages/_es/Badge.js +47 -36
- package/dist/packages/_es/Barrage.js +147 -68
- package/dist/packages/_es/Button.js +66 -47
- package/dist/packages/_es/Calendar.js +157 -135
- package/dist/packages/_es/CalendarItem.js +6 -6
- package/dist/packages/_es/Card.js +56 -42
- package/dist/packages/_es/Cascader.js +474 -315
- package/dist/packages/_es/Category.js +39 -29
- package/dist/packages/_es/CategoryPane.js +83 -57
- package/dist/packages/_es/Cell.js +71 -56
- package/dist/packages/_es/CellGroup.js +27 -19
- package/dist/packages/_es/Checkbox.js +156 -109
- package/dist/packages/_es/CheckboxGroup.js +59 -38
- package/dist/packages/_es/CircleProgress.js +96 -67
- package/dist/packages/_es/Col.js +31 -23
- package/dist/packages/_es/Collapse.js +58 -33
- package/dist/packages/_es/CollapseItem.js +108 -78
- package/dist/packages/_es/Comment.js +279 -207
- package/dist/packages/_es/ConfigProvider.js +55 -37
- package/dist/packages/_es/Countdown.js +212 -100
- package/dist/packages/_es/Countup.js +445 -232
- package/dist/packages/_es/DatePicker.js +265 -162
- package/dist/packages/_es/Dialog.js +213 -161
- package/dist/packages/_es/Divider.js +57 -42
- package/dist/packages/_es/Drag.js +153 -70
- package/dist/packages/_es/Ecard.js +104 -64
- package/dist/packages/_es/Elevator.js +219 -143
- package/dist/packages/_es/Ellipsis.js +178 -95
- package/dist/packages/_es/Empty.js +39 -23
- package/dist/packages/_es/FixedNav.js +116 -93
- package/dist/packages/_es/Form.js +178 -107
- package/dist/packages/_es/FormItem.js +61 -48
- package/dist/packages/_es/Grid.js +6 -5
- package/dist/packages/_es/GridItem.js +84 -58
- package/dist/packages/_es/Image.js +130 -90
- package/dist/packages/_es/ImagePreview.js +412 -256
- package/dist/packages/_es/Indicator.js +34 -30
- package/dist/packages/_es/InfiniteLoading.js +136 -83
- package/dist/packages/_es/Input.js +264 -160
- package/dist/packages/_es/InputNumber.js +117 -81
- package/dist/packages/_es/Interceptor-956b24fc.js +29 -0
- package/dist/packages/_es/Invoice.js +130 -104
- package/dist/packages/_es/Layout.js +4 -3
- package/dist/packages/_es/List.js +215 -117
- package/dist/packages/_es/Menu.js +150 -95
- package/dist/packages/_es/MenuItem.js +154 -109
- package/dist/packages/_es/Navbar.js +119 -103
- package/dist/packages/_es/Noticebar.js +312 -197
- package/dist/packages/_es/Notify.js +166 -110
- package/dist/packages/_es/NumberKeyboard.js +202 -127
- package/dist/packages/_es/Overlay.js +80 -52
- package/dist/packages/_es/Pagination.js +100 -70
- package/dist/packages/_es/Picker.js +437 -275
- package/dist/packages/_es/Popover.js +225 -122
- package/dist/packages/_es/Popup.js +4 -4
- package/dist/packages/_es/Price.js +82 -44
- package/dist/packages/_es/Progress.js +79 -63
- package/dist/packages/_es/PullRefresh.js +173 -95
- package/dist/packages/_es/Radio.js +4 -4
- package/dist/packages/_es/RadioGroup.js +3 -3
- package/dist/packages/_es/Range.js +347 -204
- package/dist/packages/_es/Rate.js +141 -92
- package/dist/packages/_es/Row.js +27 -21
- package/dist/packages/_es/Searchbar.js +174 -123
- package/dist/packages/_es/ShortPassword.js +93 -69
- package/dist/packages/_es/SideNavbar.js +80 -49
- package/dist/packages/_es/SideNavbarItem.js +32 -22
- package/dist/packages/_es/Signature.js +146 -83
- package/dist/packages/_es/Skeleton.js +130 -110
- package/dist/packages/_es/Sku.js +343 -250
- package/dist/packages/_es/Step.js +86 -59
- package/dist/packages/_es/Steps.js +31 -26
- package/dist/packages/_es/Sticky.js +4 -4
- package/dist/packages/_es/SubSideNavbar.js +74 -52
- package/dist/packages/_es/Swipe.js +155 -83
- package/dist/packages/_es/Swiper.js +311 -174
- package/dist/packages/_es/SwiperItem.js +44 -28
- package/dist/packages/_es/Switch.js +68 -55
- package/dist/packages/_es/TabPane.js +41 -30
- package/dist/packages/_es/Tabbar.js +52 -41
- package/dist/packages/_es/TabbarItem.js +82 -61
- package/dist/packages/_es/Table.js +165 -109
- package/dist/packages/_es/Tabs.js +388 -240
- package/dist/packages/_es/Tag.js +61 -44
- package/dist/packages/_es/Textarea.js +124 -80
- package/dist/packages/_es/TimeDetail.js +76 -49
- package/dist/packages/_es/TimePannel.js +48 -34
- package/dist/packages/_es/TimeSelect.js +68 -47
- package/dist/packages/_es/Toast.js +218 -144
- package/dist/packages/_es/Tour.js +192 -138
- package/dist/packages/_es/TrendArrow.js +77 -57
- package/dist/packages/_es/Uploader.js +359 -234
- package/dist/packages/_es/Video.js +316 -191
- package/dist/packages/_es/Watermark.js +117 -84
- package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +10 -0
- package/dist/packages/_es/common-b9a5e726.js +145 -0
- package/dist/packages/_es/component-81a4c1d0.js +145 -0
- package/dist/packages/_es/index-29892cda.js +33 -0
- package/dist/packages/_es/index-43c34ac6.js +30 -0
- package/dist/packages/_es/index-54d03fc1.js +8 -0
- package/dist/packages/_es/index-79c5dc33.js +10 -0
- package/dist/packages/_es/index-7a7385e4.js +67 -0
- package/dist/packages/_es/index-87422be8.js +942 -0
- package/dist/packages/_es/index-da0a7662.js +259 -0
- package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +46 -0
- package/dist/packages/_es/index.vue_vue_type_script_lang-a8856969.js +97 -0
- package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +151 -0
- package/dist/packages/_es/mountComponent-8b24c346.js +39 -0
- package/dist/packages/_es/pxCheck-c6b9f6b7.js +6 -0
- package/dist/packages/_es/raf-729dad54.js +25 -0
- package/dist/packages/_es/renderIcon-3d0fd47c.js +9 -0
- package/dist/packages/locale/lang/baseLang-3a8457ac.js +5 -0
- package/dist/packages/locale/lang/en-US.js +39 -36
- package/dist/packages/locale/lang/id-ID.js +39 -36
- package/dist/packages/locale/lang/index.js +44 -22
- package/dist/packages/locale/lang/zh-CN.js +38 -35
- package/dist/packages/locale/lang/zh-TW.js +38 -35
- package/dist/resolver/index.js +26 -1
- package/dist/resolver/index.mjs +17 -14
- package/dist/smartips/web-types.json +1 -1
- package/dist/style.css +1 -1
- package/dist/styles/themes/default.scss +50 -50
- package/dist/styles/themes/jdb.scss +50 -50
- package/dist/styles/themes/jddkh.scss +50 -50
- package/dist/styles/themes/jdt.scss +50 -50
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/packages/_es/Interceptor-6e26b757.js +0 -18
- package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +0 -9
- package/dist/packages/_es/common-d218746f.js +0 -116
- package/dist/packages/_es/component-234624bc.js +0 -89
- package/dist/packages/_es/index-14dfadc4.js +0 -561
- package/dist/packages/_es/index-192a3ef6.js +0 -29
- package/dist/packages/_es/index-360c5092.js +0 -210
- package/dist/packages/_es/index-496e6e05.js +0 -24
- package/dist/packages/_es/index-50eed3d9.js +0 -7
- package/dist/packages/_es/index-53ec2d4d.js +0 -34
- package/dist/packages/_es/index-fadb0974.js +0 -8
- package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +0 -43
- package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +0 -77
- package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +0 -110
- package/dist/packages/_es/mountComponent-6d4ff200.js +0 -23
- package/dist/packages/_es/pxCheck-38173291.js +0 -4
- package/dist/packages/_es/raf-a74f1a06.js +0 -16
- package/dist/packages/_es/renderIcon-47498b32.js +0 -5
- package/dist/packages/locale/lang/baseLang-0bdc6353.js +0 -5
|
@@ -1,82 +1,104 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { reactive, computed, h, resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, createBlock, resolveDynamicComponent, createCommentVNode, Fragment, renderList, createElementVNode, toDisplayString, createVNode } from "vue";
|
|
8
|
+
import { c as createComponent } from "./component-81a4c1d0.js";
|
|
9
|
+
import { f as funInterceptor } from "./Interceptor-956b24fc.js";
|
|
10
|
+
import Progress from "./Progress.js";
|
|
11
|
+
import { Photograph, Failure, Loading, Del, Link } from "@nutui/icons-vue";
|
|
12
|
+
import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
|
|
10
13
|
import "../locale/lang";
|
|
11
|
-
class
|
|
14
|
+
class UploadOptions {
|
|
12
15
|
constructor() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
__publicField(this, "url", "");
|
|
17
|
+
__publicField(this, "name", "file");
|
|
18
|
+
__publicField(this, "fileType", "image");
|
|
19
|
+
__publicField(this, "formData");
|
|
20
|
+
__publicField(this, "sourceFile");
|
|
21
|
+
__publicField(this, "method", "post");
|
|
22
|
+
__publicField(this, "xhrState", 200);
|
|
23
|
+
__publicField(this, "timeout", 30 * 1e3);
|
|
24
|
+
__publicField(this, "headers", {});
|
|
25
|
+
__publicField(this, "withCredentials", false);
|
|
26
|
+
__publicField(this, "onStart");
|
|
27
|
+
__publicField(this, "taroFilePath");
|
|
28
|
+
__publicField(this, "onProgress");
|
|
29
|
+
__publicField(this, "onSuccess");
|
|
30
|
+
__publicField(this, "onFailure");
|
|
31
|
+
__publicField(this, "beforeXhrUpload");
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
|
-
class
|
|
32
|
-
constructor(
|
|
33
|
-
|
|
34
|
-
this.options =
|
|
34
|
+
class Uploader {
|
|
35
|
+
constructor(options) {
|
|
36
|
+
__publicField(this, "options");
|
|
37
|
+
this.options = options;
|
|
35
38
|
}
|
|
36
39
|
upload() {
|
|
37
|
-
var
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
var _a;
|
|
41
|
+
const options = this.options;
|
|
42
|
+
const xhr = new XMLHttpRequest();
|
|
43
|
+
xhr.timeout = options.timeout;
|
|
44
|
+
if (xhr.upload) {
|
|
45
|
+
xhr.upload.addEventListener(
|
|
41
46
|
"progress",
|
|
42
|
-
(
|
|
43
|
-
var
|
|
44
|
-
(
|
|
47
|
+
(e) => {
|
|
48
|
+
var _a2;
|
|
49
|
+
(_a2 = options.onProgress) == null ? void 0 : _a2.call(options, e, options);
|
|
45
50
|
},
|
|
46
|
-
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
false
|
|
52
|
+
);
|
|
53
|
+
xhr.onreadystatechange = () => {
|
|
54
|
+
var _a2, _b;
|
|
55
|
+
if (xhr.readyState === 4) {
|
|
56
|
+
if (xhr.status == options.xhrState) {
|
|
57
|
+
(_a2 = options.onSuccess) == null ? void 0 : _a2.call(options, xhr.responseText, options);
|
|
58
|
+
} else {
|
|
59
|
+
(_b = options.onFailure) == null ? void 0 : _b.call(options, xhr.responseText, options);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
xhr.withCredentials = options.withCredentials;
|
|
64
|
+
xhr.open(options.method, options.url, true);
|
|
65
|
+
for (const [key, value] of Object.entries(options.headers)) {
|
|
66
|
+
xhr.setRequestHeader(key, value);
|
|
67
|
+
}
|
|
68
|
+
(_a = options.onStart) == null ? void 0 : _a.call(options, options);
|
|
69
|
+
if (options.beforeXhrUpload) {
|
|
70
|
+
options.beforeXhrUpload(xhr, options);
|
|
71
|
+
} else {
|
|
72
|
+
xhr.send(options.formData);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
55
75
|
console.warn("浏览器不支持 XMLHttpRequest");
|
|
76
|
+
}
|
|
56
77
|
}
|
|
57
78
|
}
|
|
58
|
-
const { translate:
|
|
59
|
-
class
|
|
79
|
+
const { translate: translate$1 } = createComponent("uploader");
|
|
80
|
+
class FileItem {
|
|
60
81
|
constructor() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
82
|
+
__publicField(this, "status", "ready");
|
|
83
|
+
__publicField(this, "message", translate$1("ready"));
|
|
84
|
+
__publicField(this, "uid", (/* @__PURE__ */ new Date()).getTime().toString());
|
|
85
|
+
__publicField(this, "name");
|
|
86
|
+
__publicField(this, "url");
|
|
87
|
+
__publicField(this, "type");
|
|
88
|
+
__publicField(this, "path");
|
|
89
|
+
__publicField(this, "percentage", 0);
|
|
90
|
+
__publicField(this, "formData", {});
|
|
70
91
|
}
|
|
71
92
|
}
|
|
72
|
-
const { componentName
|
|
93
|
+
const { componentName, create, translate } = createComponent("uploader");
|
|
94
|
+
const _sfc_main = create({
|
|
73
95
|
components: {
|
|
74
|
-
[
|
|
75
|
-
Photograph
|
|
76
|
-
Failure
|
|
77
|
-
Loading
|
|
78
|
-
Del
|
|
79
|
-
Link
|
|
96
|
+
[Progress.name]: Progress,
|
|
97
|
+
Photograph,
|
|
98
|
+
Failure,
|
|
99
|
+
Loading,
|
|
100
|
+
Del,
|
|
101
|
+
Link
|
|
80
102
|
},
|
|
81
103
|
props: {
|
|
82
104
|
name: { type: String, default: "file" },
|
|
@@ -84,23 +106,23 @@ const { componentName: se, create: le, translate: C } = j("uploader"), oe = le({
|
|
|
84
106
|
// defaultFileList: { type: Array, default: () => new Array<FileItem>() },
|
|
85
107
|
timeout: { type: [Number, String], default: 1e3 * 30 },
|
|
86
108
|
fileList: { type: Array, default: () => [] },
|
|
87
|
-
isPreview: { type: Boolean, default:
|
|
109
|
+
isPreview: { type: Boolean, default: true },
|
|
88
110
|
// picture、list
|
|
89
111
|
listType: { type: String, default: "picture" },
|
|
90
|
-
isDeletable: { type: Boolean, default:
|
|
112
|
+
isDeletable: { type: Boolean, default: true },
|
|
91
113
|
method: { type: String, default: "post" },
|
|
92
|
-
capture: { type: Boolean, default:
|
|
114
|
+
capture: { type: Boolean, default: false },
|
|
93
115
|
maximize: { type: [Number, String], default: Number.MAX_VALUE },
|
|
94
116
|
maximum: { type: [Number, String], default: 1 },
|
|
95
|
-
clearInput: { type: Boolean, default:
|
|
117
|
+
clearInput: { type: Boolean, default: true },
|
|
96
118
|
accept: { type: String, default: "*" },
|
|
97
119
|
headers: { type: Object, default: {} },
|
|
98
120
|
data: { type: Object, default: {} },
|
|
99
121
|
xhrState: { type: [Number, String], default: 200 },
|
|
100
|
-
withCredentials: { type: Boolean, default:
|
|
101
|
-
multiple: { type: Boolean, default:
|
|
102
|
-
disabled: { type: Boolean, default:
|
|
103
|
-
autoUpload: { type: Boolean, default:
|
|
122
|
+
withCredentials: { type: Boolean, default: false },
|
|
123
|
+
multiple: { type: Boolean, default: false },
|
|
124
|
+
disabled: { type: Boolean, default: false },
|
|
125
|
+
autoUpload: { type: Boolean, default: true },
|
|
104
126
|
beforeUpload: {
|
|
105
127
|
type: Function,
|
|
106
128
|
default: null
|
|
@@ -111,7 +133,9 @@ const { componentName: se, create: le, translate: C } = j("uploader"), oe = le({
|
|
|
111
133
|
},
|
|
112
134
|
beforeDelete: {
|
|
113
135
|
type: Function,
|
|
114
|
-
default: (
|
|
136
|
+
default: (file, files) => {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
115
139
|
},
|
|
116
140
|
onChange: { type: Function }
|
|
117
141
|
},
|
|
@@ -126,223 +150,324 @@ const { componentName: se, create: le, translate: C } = j("uploader"), oe = le({
|
|
|
126
150
|
"update:fileList",
|
|
127
151
|
"file-item-click"
|
|
128
152
|
],
|
|
129
|
-
setup(
|
|
130
|
-
const
|
|
131
|
-
let
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
153
|
+
setup(props, { emit }) {
|
|
154
|
+
const fileList = reactive(props.fileList);
|
|
155
|
+
let uploadQueue = [];
|
|
156
|
+
const classes = computed(() => {
|
|
157
|
+
const prefixCls = componentName;
|
|
158
|
+
return {
|
|
159
|
+
[prefixCls]: true
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
const renderInput = () => {
|
|
163
|
+
let params = {
|
|
164
|
+
class: `nut-uploader__input`,
|
|
137
165
|
type: "file",
|
|
138
|
-
accept:
|
|
139
|
-
multiple:
|
|
140
|
-
name:
|
|
141
|
-
disabled:
|
|
166
|
+
accept: props.accept,
|
|
167
|
+
multiple: props.multiple,
|
|
168
|
+
name: props.name,
|
|
169
|
+
disabled: props.disabled
|
|
142
170
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
171
|
+
if (props.capture)
|
|
172
|
+
params.capture = "camera";
|
|
173
|
+
return h("input", params);
|
|
174
|
+
};
|
|
175
|
+
const clearInput = (el) => {
|
|
176
|
+
el.value = "";
|
|
177
|
+
};
|
|
178
|
+
const fileItemClick = (fileItem) => {
|
|
179
|
+
emit("file-item-click", { fileItem });
|
|
180
|
+
};
|
|
181
|
+
const executeUpload = (fileItem, index2) => {
|
|
182
|
+
const uploadOption = new UploadOptions();
|
|
183
|
+
uploadOption.url = props.url;
|
|
184
|
+
uploadOption.formData = fileItem.formData;
|
|
185
|
+
uploadOption.timeout = props.timeout * 1;
|
|
186
|
+
uploadOption.method = props.method;
|
|
187
|
+
uploadOption.xhrState = props.xhrState;
|
|
188
|
+
uploadOption.headers = props.headers;
|
|
189
|
+
uploadOption.withCredentials = props.withCredentials;
|
|
190
|
+
uploadOption.beforeXhrUpload = props.beforeXhrUpload;
|
|
151
191
|
try {
|
|
152
|
-
|
|
153
|
-
} catch (
|
|
192
|
+
uploadOption.sourceFile = fileItem.formData.get(props.name);
|
|
193
|
+
} catch (error) {
|
|
154
194
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
195
|
+
uploadOption.onStart = (option) => {
|
|
196
|
+
fileItem.status = "ready";
|
|
197
|
+
fileItem.message = translate("readyUpload");
|
|
198
|
+
clearUploadQueue(index2);
|
|
199
|
+
emit("start", option);
|
|
200
|
+
};
|
|
201
|
+
uploadOption.onProgress = (event, option) => {
|
|
202
|
+
fileItem.status = "uploading";
|
|
203
|
+
fileItem.message = translate("uploading");
|
|
204
|
+
fileItem.percentage = (event.loaded / event.total * 100).toFixed(0);
|
|
205
|
+
emit("progress", { event, option, percentage: fileItem.percentage });
|
|
206
|
+
};
|
|
207
|
+
uploadOption.onSuccess = (responseText, option) => {
|
|
208
|
+
fileItem.status = "success";
|
|
209
|
+
fileItem.message = translate("success");
|
|
210
|
+
emit("success", {
|
|
211
|
+
responseText,
|
|
212
|
+
option,
|
|
213
|
+
fileItem
|
|
170
214
|
});
|
|
215
|
+
emit("update:fileList", fileList);
|
|
171
216
|
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
217
|
+
uploadOption.onFailure = (responseText, option) => {
|
|
218
|
+
fileItem.status = "error";
|
|
219
|
+
fileItem.message = translate("error");
|
|
220
|
+
emit("failure", {
|
|
221
|
+
responseText,
|
|
222
|
+
option,
|
|
223
|
+
fileItem
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
let task = new Uploader(uploadOption);
|
|
227
|
+
if (props.autoUpload) {
|
|
228
|
+
task.upload();
|
|
229
|
+
} else {
|
|
230
|
+
uploadQueue.push(
|
|
231
|
+
new Promise((resolve, reject) => {
|
|
232
|
+
resolve(task);
|
|
233
|
+
})
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
const clearUploadQueue = (index2 = -1) => {
|
|
238
|
+
if (index2 > -1) {
|
|
239
|
+
uploadQueue.splice(index2, 1);
|
|
240
|
+
} else {
|
|
241
|
+
uploadQueue = [];
|
|
242
|
+
fileList.splice(0, fileList.length);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
const submit = () => {
|
|
246
|
+
Promise.all(uploadQueue).then((res) => {
|
|
247
|
+
res.forEach((i) => i.upload());
|
|
183
248
|
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
249
|
+
};
|
|
250
|
+
const readFile = (files) => {
|
|
251
|
+
files.forEach((file, index2) => {
|
|
252
|
+
const formData = new FormData();
|
|
253
|
+
for (const [key, value] of Object.entries(props.data)) {
|
|
254
|
+
formData.append(key, value);
|
|
255
|
+
}
|
|
256
|
+
formData.append(props.name, file);
|
|
257
|
+
const fileItem = reactive(new FileItem());
|
|
258
|
+
fileItem.name = file.name;
|
|
259
|
+
fileItem.status = "ready";
|
|
260
|
+
fileItem.type = file.type;
|
|
261
|
+
fileItem.formData = formData;
|
|
262
|
+
fileItem.message = translate("waitingUpload");
|
|
263
|
+
executeUpload(fileItem, index2);
|
|
264
|
+
if (props.isPreview && file.type.includes("image")) {
|
|
265
|
+
const reader = new FileReader();
|
|
266
|
+
reader.onload = (event) => {
|
|
267
|
+
fileItem.url = event.target.result;
|
|
268
|
+
fileList.push(fileItem);
|
|
269
|
+
};
|
|
270
|
+
reader.readAsDataURL(file);
|
|
271
|
+
} else {
|
|
272
|
+
fileList.push(fileItem);
|
|
273
|
+
}
|
|
198
274
|
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
275
|
+
};
|
|
276
|
+
const filterFiles = (files) => {
|
|
277
|
+
const maximum = props.maximum * 1;
|
|
278
|
+
const maximize = props.maximize * 1;
|
|
279
|
+
const oversizes = new Array();
|
|
280
|
+
files = files.filter((file) => {
|
|
281
|
+
if (file.size > maximize) {
|
|
282
|
+
oversizes.push(file);
|
|
283
|
+
return false;
|
|
284
|
+
} else {
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
209
287
|
});
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
288
|
+
if (oversizes.length) {
|
|
289
|
+
emit("oversize", oversizes);
|
|
290
|
+
}
|
|
291
|
+
let currentFileLength = files.length + fileList.length;
|
|
292
|
+
if (currentFileLength > maximum) {
|
|
293
|
+
files.splice(files.length - (currentFileLength - maximum));
|
|
294
|
+
}
|
|
295
|
+
return files;
|
|
296
|
+
};
|
|
297
|
+
const deleted = (file, index2) => {
|
|
298
|
+
fileList.splice(index2, 1);
|
|
299
|
+
emit("delete", {
|
|
300
|
+
file,
|
|
301
|
+
fileList,
|
|
302
|
+
index: index2
|
|
214
303
|
});
|
|
215
|
-
}
|
|
216
|
-
|
|
304
|
+
};
|
|
305
|
+
const onDelete = (file, index2) => {
|
|
306
|
+
clearUploadQueue(index2);
|
|
307
|
+
funInterceptor(props.beforeDelete, {
|
|
308
|
+
args: [file, fileList],
|
|
309
|
+
done: () => deleted(file, index2)
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
const onChange = (event) => {
|
|
313
|
+
if (props.disabled) {
|
|
217
314
|
return;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
315
|
+
}
|
|
316
|
+
const $el = event.target;
|
|
317
|
+
let { files } = $el;
|
|
318
|
+
if (props.beforeUpload) {
|
|
319
|
+
props.beforeUpload(files).then((f) => changeReadFile(f));
|
|
320
|
+
} else {
|
|
321
|
+
changeReadFile(files);
|
|
322
|
+
}
|
|
323
|
+
emit("change", {
|
|
324
|
+
fileList,
|
|
325
|
+
event
|
|
326
|
+
});
|
|
327
|
+
if (props.clearInput) {
|
|
328
|
+
clearInput($el);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
const changeReadFile = (f) => {
|
|
332
|
+
const _files = filterFiles(new Array().slice.call(f));
|
|
333
|
+
readFile(_files);
|
|
227
334
|
};
|
|
228
335
|
return {
|
|
229
|
-
onChange
|
|
230
|
-
onDelete
|
|
231
|
-
fileList
|
|
232
|
-
classes
|
|
233
|
-
fileItemClick
|
|
234
|
-
clearUploadQueue
|
|
235
|
-
submit
|
|
236
|
-
renderInput
|
|
336
|
+
onChange,
|
|
337
|
+
onDelete,
|
|
338
|
+
fileList,
|
|
339
|
+
classes,
|
|
340
|
+
fileItemClick,
|
|
341
|
+
clearUploadQueue,
|
|
342
|
+
submit,
|
|
343
|
+
renderInput
|
|
237
344
|
};
|
|
238
345
|
}
|
|
239
|
-
})
|
|
346
|
+
});
|
|
347
|
+
const _hoisted_1 = {
|
|
240
348
|
key: 0,
|
|
241
349
|
class: "nut-uploader__slot"
|
|
242
|
-
}
|
|
350
|
+
};
|
|
351
|
+
const _hoisted_2 = {
|
|
243
352
|
key: 0,
|
|
244
353
|
class: "nut-uploader__preview-img"
|
|
245
|
-
}
|
|
354
|
+
};
|
|
355
|
+
const _hoisted_3 = {
|
|
246
356
|
key: 0,
|
|
247
357
|
class: "nut-uploader__preview__progress"
|
|
248
|
-
}
|
|
358
|
+
};
|
|
359
|
+
const _hoisted_4 = { class: "nut-uploader__preview__progress__msg" };
|
|
360
|
+
const _hoisted_5 = ["onClick"];
|
|
361
|
+
const _hoisted_6 = ["onClick", "src"];
|
|
362
|
+
const _hoisted_7 = {
|
|
249
363
|
key: 3,
|
|
250
364
|
class: "nut-uploader__preview-img__file"
|
|
251
|
-
}
|
|
365
|
+
};
|
|
366
|
+
const _hoisted_8 = ["onClick"];
|
|
367
|
+
const _hoisted_9 = { class: "file__name_tips" };
|
|
368
|
+
const _hoisted_10 = { class: "tips" };
|
|
369
|
+
const _hoisted_11 = {
|
|
252
370
|
key: 1,
|
|
253
371
|
class: "nut-uploader__preview-list"
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
372
|
+
};
|
|
373
|
+
const _hoisted_12 = ["onClick"];
|
|
374
|
+
const _hoisted_13 = { class: "file__name_tips" };
|
|
375
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
376
|
+
const _component_Failure = resolveComponent("Failure");
|
|
377
|
+
const _component_Loading = resolveComponent("Loading");
|
|
378
|
+
const _component_Link = resolveComponent("Link");
|
|
379
|
+
const _component_Del = resolveComponent("Del");
|
|
380
|
+
const _component_nut_progress = resolveComponent("nut-progress");
|
|
381
|
+
const _component_Photograph = resolveComponent("Photograph");
|
|
382
|
+
return openBlock(), createElementBlock("view", {
|
|
383
|
+
class: normalizeClass(_ctx.classes)
|
|
259
384
|
}, [
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
Number(
|
|
385
|
+
_ctx.$slots.default ? (openBlock(), createElementBlock("view", _hoisted_1, [
|
|
386
|
+
renderSlot(_ctx.$slots, "default"),
|
|
387
|
+
Number(_ctx.maximum) - _ctx.fileList.length ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.renderInput), {
|
|
263
388
|
key: 0,
|
|
264
|
-
onChange:
|
|
265
|
-
}, null, 40, ["onChange"])) :
|
|
266
|
-
])) :
|
|
267
|
-
(
|
|
268
|
-
var
|
|
269
|
-
return
|
|
270
|
-
class:
|
|
271
|
-
key:
|
|
389
|
+
onChange: _ctx.onChange
|
|
390
|
+
}, null, 40, ["onChange"])) : createCommentVNode("", true)
|
|
391
|
+
])) : createCommentVNode("", true),
|
|
392
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.fileList, (item, index2) => {
|
|
393
|
+
var _a;
|
|
394
|
+
return openBlock(), createElementBlock("view", {
|
|
395
|
+
class: normalizeClass(["nut-uploader__preview", [_ctx.listType]]),
|
|
396
|
+
key: item.uid
|
|
272
397
|
}, [
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
398
|
+
_ctx.listType == "picture" && !_ctx.$slots.default ? (openBlock(), createElementBlock("view", _hoisted_2, [
|
|
399
|
+
item.status != "success" ? (openBlock(), createElementBlock("view", _hoisted_3, [
|
|
400
|
+
item.status != "ready" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
401
|
+
item.status == "error" ? (openBlock(), createBlock(_component_Failure, {
|
|
277
402
|
key: 0,
|
|
278
403
|
color: "#fff"
|
|
279
|
-
})) : (
|
|
404
|
+
})) : (openBlock(), createBlock(_component_Loading, {
|
|
280
405
|
key: 1,
|
|
281
406
|
name: "loading",
|
|
282
407
|
color: "#fff"
|
|
283
408
|
}))
|
|
284
|
-
], 64)) :
|
|
285
|
-
|
|
286
|
-
])) :
|
|
287
|
-
|
|
409
|
+
], 64)) : createCommentVNode("", true),
|
|
410
|
+
createElementVNode("view", _hoisted_4, toDisplayString(item.message), 1)
|
|
411
|
+
])) : createCommentVNode("", true),
|
|
412
|
+
_ctx.isDeletable ? (openBlock(), createElementBlock("view", {
|
|
288
413
|
key: 1,
|
|
289
414
|
class: "close",
|
|
290
|
-
onClick: (
|
|
415
|
+
onClick: ($event) => _ctx.onDelete(item, index2)
|
|
291
416
|
}, [
|
|
292
|
-
|
|
293
|
-
|
|
417
|
+
renderSlot(_ctx.$slots, "delete-icon", {}, () => [
|
|
418
|
+
createVNode(_component_Failure)
|
|
294
419
|
])
|
|
295
|
-
], 8,
|
|
296
|
-
(
|
|
420
|
+
], 8, _hoisted_5)) : createCommentVNode("", true),
|
|
421
|
+
((_a = item == null ? void 0 : item.type) == null ? void 0 : _a.includes("image")) && item.url ? (openBlock(), createElementBlock("img", {
|
|
297
422
|
key: 2,
|
|
298
423
|
class: "nut-uploader__preview-img__c",
|
|
299
|
-
onClick: (
|
|
300
|
-
src:
|
|
301
|
-
}, null, 8,
|
|
302
|
-
|
|
303
|
-
onClick: (
|
|
424
|
+
onClick: ($event) => _ctx.fileItemClick(item),
|
|
425
|
+
src: item.url
|
|
426
|
+
}, null, 8, _hoisted_6)) : (openBlock(), createElementBlock("view", _hoisted_7, [
|
|
427
|
+
createElementVNode("view", {
|
|
428
|
+
onClick: ($event) => _ctx.fileItemClick(item),
|
|
304
429
|
class: "nut-uploader__preview-img__file__name"
|
|
305
430
|
}, [
|
|
306
|
-
|
|
307
|
-
], 8,
|
|
431
|
+
createElementVNode("view", _hoisted_9, toDisplayString(item.name), 1)
|
|
432
|
+
], 8, _hoisted_8)
|
|
308
433
|
])),
|
|
309
|
-
|
|
310
|
-
])) :
|
|
311
|
-
|
|
312
|
-
onClick: (
|
|
313
|
-
class:
|
|
434
|
+
createElementVNode("view", _hoisted_10, toDisplayString(item.name), 1)
|
|
435
|
+
])) : _ctx.listType == "list" ? (openBlock(), createElementBlock("view", _hoisted_11, [
|
|
436
|
+
createElementVNode("view", {
|
|
437
|
+
onClick: ($event) => _ctx.fileItemClick(item),
|
|
438
|
+
class: normalizeClass(["nut-uploader__preview-img__file__name", [item.status]])
|
|
314
439
|
}, [
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
440
|
+
createVNode(_component_Link, { class: "nut-uploader__preview-img__file__link" }),
|
|
441
|
+
createElementVNode("view", _hoisted_13, toDisplayString(item.name), 1),
|
|
442
|
+
_ctx.isDeletable ? (openBlock(), createBlock(_component_Del, {
|
|
318
443
|
key: 0,
|
|
319
444
|
color: "#808080",
|
|
320
445
|
class: "nut-uploader__preview-img__file__del",
|
|
321
|
-
onClick: (
|
|
322
|
-
}, null, 8, ["onClick"])) :
|
|
323
|
-
], 10,
|
|
324
|
-
|
|
446
|
+
onClick: ($event) => _ctx.onDelete(item, index2)
|
|
447
|
+
}, null, 8, ["onClick"])) : createCommentVNode("", true)
|
|
448
|
+
], 10, _hoisted_12),
|
|
449
|
+
item.status == "uploading" ? (openBlock(), createBlock(_component_nut_progress, {
|
|
325
450
|
key: 0,
|
|
326
451
|
size: "small",
|
|
327
|
-
percentage:
|
|
452
|
+
percentage: item.percentage,
|
|
328
453
|
"stroke-color": "linear-gradient(270deg, rgba(18,126,255,1) 0%,rgba(32,147,255,1) 32.815625%,rgba(13,242,204,1) 100%)",
|
|
329
|
-
"show-text":
|
|
330
|
-
}, null, 8, ["percentage"])) :
|
|
331
|
-
])) :
|
|
454
|
+
"show-text": false
|
|
455
|
+
}, null, 8, ["percentage"])) : createCommentVNode("", true)
|
|
456
|
+
])) : createCommentVNode("", true)
|
|
332
457
|
], 2);
|
|
333
458
|
}), 128)),
|
|
334
|
-
|
|
459
|
+
_ctx.listType == "picture" && !_ctx.$slots.default && Number(_ctx.maximum) - _ctx.fileList.length ? (openBlock(), createElementBlock("view", {
|
|
335
460
|
key: 1,
|
|
336
|
-
class:
|
|
461
|
+
class: normalizeClass(["nut-uploader__upload", [_ctx.listType]])
|
|
337
462
|
}, [
|
|
338
|
-
|
|
339
|
-
|
|
463
|
+
renderSlot(_ctx.$slots, "upload-icon", {}, () => [
|
|
464
|
+
createVNode(_component_Photograph, { color: "#808080" })
|
|
340
465
|
]),
|
|
341
|
-
(
|
|
342
|
-
], 2)) :
|
|
466
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.renderInput), { onChange: _ctx.onChange }, null, 40, ["onChange"]))
|
|
467
|
+
], 2)) : createCommentVNode("", true)
|
|
343
468
|
], 2);
|
|
344
469
|
}
|
|
345
|
-
const
|
|
470
|
+
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
346
471
|
export {
|
|
347
|
-
|
|
472
|
+
index as default
|
|
348
473
|
};
|