@nutui/nutui 3.1.22-beta.5 → 3.1.23-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +3 -4
- package/dist/nutui.es.js +20412 -4214
- package/dist/nutui.umd.js +20518 -4216
- package/dist/packages/_es/ActionSheet.js +149 -17
- package/dist/packages/_es/Address.js +535 -110
- package/dist/packages/_es/AddressList.js +615 -113
- package/dist/packages/_es/Animate.js +59 -17
- package/dist/packages/_es/Audio.js +257 -53
- package/dist/packages/_es/AudioOperate.js +100 -13
- package/dist/packages/_es/Avatar.js +162 -38
- package/dist/packages/_es/AvatarGroup.js +73 -14
- package/dist/packages/_es/BackTop.js +156 -43
- package/dist/packages/_es/Badge.js +86 -14
- package/dist/packages/_es/Barrage.js +120 -41
- package/dist/packages/_es/Button.js +128 -23
- package/dist/packages/_es/Calendar.js +246 -30
- package/dist/packages/_es/CalendarItem.js +1 -1
- package/dist/packages/_es/Card.js +107 -10
- package/dist/packages/_es/Cascader.js +496 -147
- package/dist/packages/_es/Category.js +58 -15
- package/dist/packages/_es/CategoryPane.js +111 -11
- package/dist/packages/_es/Cell.js +108 -21
- package/dist/packages/_es/CellGroup.js +44 -9
- package/dist/packages/_es/Checkbox.js +134 -29
- package/dist/packages/_es/CheckboxGroup.js +79 -29
- package/dist/packages/_es/CircleProgress.js +150 -28
- package/dist/packages/_es/Col.js +56 -14
- package/dist/packages/_es/Collapse.js +109 -32
- package/dist/packages/_es/CollapseItem.js +253 -59
- package/dist/packages/_es/Comment.js +434 -64
- package/dist/packages/_es/ConfigProvider.js +20 -8
- package/dist/packages/_es/CountDown.js +238 -56
- package/dist/packages/_es/CountUp.js +539 -140
- package/dist/packages/_es/DatePicker.js +315 -98
- package/dist/packages/_es/Dialog.js +289 -60
- package/dist/packages/_es/Divider.js +65 -13
- package/dist/packages/_es/Drag.js +197 -56
- package/dist/packages/_es/Ecard.js +159 -24
- package/dist/packages/_es/Elevator.js +255 -58
- package/dist/packages/_es/Ellipsis.js +200 -58
- package/dist/packages/_es/Empty.js +71 -12
- package/dist/packages/_es/FixedNav.js +122 -15
- package/dist/packages/_es/Form.js +151 -64
- package/dist/packages/_es/FormItem.js +114 -15
- package/dist/packages/_es/Grid.js +6 -5
- package/dist/packages/_es/GridItem.js +144 -33
- package/dist/packages/_es/Icon.js +40 -15
- package/dist/packages/_es/Image.js +137 -26
- package/dist/packages/_es/ImagePreview.js +547 -76
- package/dist/packages/_es/Indicator.js +62 -15
- package/dist/packages/_es/InfiniteLoading.js +249 -57
- package/dist/packages/_es/Input.js +433 -51
- package/dist/packages/_es/InputNumber.js +160 -41
- package/dist/packages/_es/Layout.js +5 -4
- package/dist/packages/_es/List.js +106 -18
- package/dist/packages/_es/Menu.js +168 -44
- package/dist/packages/_es/MenuItem.js +173 -37
- package/dist/packages/_es/Navbar.js +192 -30
- package/dist/packages/_es/NoticeBar.js +380 -74
- package/dist/packages/_es/Notify.js +227 -72
- package/dist/packages/_es/NumberKeyboard.js +272 -41
- package/dist/packages/_es/OldPicker.js +457 -130
- package/dist/packages/_es/OverLay.js +98 -24
- package/dist/packages/_es/Pagination.js +157 -39
- package/dist/packages/_es/Picker.js +454 -129
- package/dist/packages/_es/Popover.js +957 -318
- package/dist/packages/_es/Popup.js +299 -55
- package/dist/packages/_es/Price.js +118 -16
- package/dist/packages/_es/Progress.js +146 -14
- package/dist/packages/_es/PullRefresh.js +339 -84
- package/dist/packages/_es/Radio.js +90 -22
- package/dist/packages/_es/RadioGroup.js +37 -8
- package/dist/packages/_es/Range.js +408 -83
- package/dist/packages/_es/Rate.js +192 -36
- package/dist/packages/_es/Row.js +64 -22
- package/dist/packages/_es/SearchBar.js +238 -37
- package/dist/packages/_es/ShortPassword.js +225 -35
- package/dist/packages/_es/SideNavBar.js +81 -24
- package/dist/packages/_es/SideNavBarItem.js +46 -11
- package/dist/packages/_es/Signature.js +160 -41
- package/dist/packages/_es/Skeleton.js +136 -20
- package/dist/packages/_es/Sku.js +491 -84
- package/dist/packages/_es/Step.js +115 -20
- package/dist/packages/_es/Steps.js +53 -18
- package/dist/packages/_es/Sticky.js +138 -53
- package/dist/packages/_es/SubSideNavBar.js +82 -17
- package/dist/packages/_es/Swipe.js +178 -41
- package/dist/packages/_es/Swiper.js +433 -121
- package/dist/packages/_es/SwiperItem.js +53 -22
- package/dist/packages/_es/Switch.js +116 -21
- package/dist/packages/_es/TabPane.js +39 -12
- package/dist/packages/_es/Tabbar.js +72 -17
- package/dist/packages/_es/TabbarItem.js +151 -29
- package/dist/packages/_es/Table.js +178 -18
- package/dist/packages/_es/Tabs.js +202 -43
- package/dist/packages/_es/Tag.js +97 -20
- package/dist/packages/_es/TextArea.js +160 -42
- package/dist/packages/_es/TimeDetail.js +79 -18
- package/dist/packages/_es/TimePannel.js +48 -14
- package/dist/packages/_es/TimeSelect.js +112 -15
- package/dist/packages/_es/Toast.js +310 -71
- package/dist/packages/_es/Uploader.js +455 -104
- package/dist/packages/_es/Video.js +332 -74
- package/dist/packages/_es/common.js +128 -38
- package/dist/packages/_es/component.js +76 -35
- package/dist/packages/_es/index.js +6 -5
- package/dist/packages/_es/index2.js +30 -9
- package/dist/packages/_es/index3.js +8 -6
- package/dist/packages/_es/index4.js +64 -13
- package/dist/packages/_es/index5.js +780 -164
- package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
- package/dist/packages/_es/pxCheck.js +5 -3
- package/dist/packages/_es/raf.js +15 -8
- package/dist/packages/imagepreview/index.scss +6 -1
- package/dist/packages/locale/lang/baseLang.js +3 -3
- package/dist/packages/locale/lang/en-US.js +105 -5
- package/dist/packages/locale/lang/id-ID.js +105 -5
- package/dist/packages/locale/lang/index.js +38 -16
- package/dist/packages/locale/lang/zh-CN.js +105 -5
- package/dist/packages/locale/lang/zh-TW.js +105 -5
- package/dist/packages/picker/index.scss +13 -0
- package/dist/smartips/attributes.json +8 -0
- package/dist/smartips/tags.json +3 -1
- package/dist/smartips/web-types.json +19 -1
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/themes/default.scss +49 -49
- package/dist/styles/themes/jdb.scss +49 -49
- package/dist/styles/themes/jdt.scss +49 -49
- package/dist/styles/variables-jdb.scss +4 -1
- package/dist/styles/variables-jdt.scss +4 -1
- package/dist/styles/variables.scss +1 -1
- package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
- package/dist/types/__VUE/address/index.vue.d.ts +4 -4
- package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
- package/dist/types/__VUE/cascader/index.vue.d.ts +3 -3
- package/dist/types/__VUE/cell/index.vue.d.ts +2 -2
- package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
- package/dist/types/__VUE/collapse/index.vue.d.ts +2 -2
- package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
- package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
- package/dist/types/__VUE/ecard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
- package/dist/types/__VUE/grid/index.vue.d.ts +3 -3
- package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
- package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
- package/dist/types/__VUE/infiniteloading/index.vue.d.ts +6 -6
- package/dist/types/__VUE/input/index.vue.d.ts +2 -2
- package/dist/types/__VUE/menu/index.vue.d.ts +4 -4
- package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
- package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/oldpicker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/picker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/popover/index.vue.d.ts +6 -6
- package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
- package/dist/types/__VUE/range/index.vue.d.ts +1 -1
- package/dist/types/__VUE/rate/index.vue.d.ts +2 -2
- package/dist/types/__VUE/searchbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
- package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
- package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
- package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/textarea/index.vue.d.ts +2 -2
- package/dist/types/__VUE/toast/index.vue.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -2
|
@@ -1,131 +1,482 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { reactive
|
|
7
|
-
import { c as
|
|
8
|
-
import { _ as
|
|
6
|
+
import { reactive, computed, resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, Fragment, createCommentVNode, renderList, createElementVNode, toDisplayString, createVNode, createBlock, createTextVNode } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
9
9
|
import "../locale/lang";
|
|
10
|
-
class
|
|
10
|
+
class UploadOptions {
|
|
11
11
|
constructor() {
|
|
12
|
-
this.url = ""
|
|
12
|
+
this.url = "";
|
|
13
|
+
this.name = "file";
|
|
14
|
+
this.fileType = "image";
|
|
15
|
+
this.method = "post";
|
|
16
|
+
this.xhrState = 200;
|
|
17
|
+
this.timeout = 30 * 1e3;
|
|
18
|
+
this.headers = {};
|
|
19
|
+
this.withCredentials = false;
|
|
13
20
|
}
|
|
14
21
|
}
|
|
15
|
-
class
|
|
16
|
-
constructor(
|
|
17
|
-
this.options =
|
|
22
|
+
class Uploader {
|
|
23
|
+
constructor(options) {
|
|
24
|
+
this.options = options;
|
|
18
25
|
}
|
|
19
26
|
upload() {
|
|
20
27
|
var _a;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
const options = this.options;
|
|
29
|
+
const xhr = new XMLHttpRequest();
|
|
30
|
+
xhr.timeout = options.timeout;
|
|
31
|
+
if (xhr.upload) {
|
|
32
|
+
xhr.upload.addEventListener("progress", (e) => {
|
|
24
33
|
var _a2;
|
|
25
|
-
(_a2 =
|
|
26
|
-
}, false)
|
|
34
|
+
(_a2 = options.onProgress) == null ? void 0 : _a2.call(options, e, options);
|
|
35
|
+
}, false);
|
|
36
|
+
xhr.onreadystatechange = () => {
|
|
27
37
|
var _a2, _b;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
if (xhr.readyState === 4) {
|
|
39
|
+
if (xhr.status == options.xhrState) {
|
|
40
|
+
(_a2 = options.onSuccess) == null ? void 0 : _a2.call(options, xhr.responseText, options);
|
|
41
|
+
} else {
|
|
42
|
+
(_b = options.onFailure) == null ? void 0 : _b.call(options, xhr.responseText, options);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
xhr.withCredentials = options.withCredentials;
|
|
47
|
+
xhr.open(options.method, options.url, true);
|
|
48
|
+
for (const [key, value] of Object.entries(options.headers)) {
|
|
49
|
+
xhr.setRequestHeader(key, value);
|
|
50
|
+
}
|
|
51
|
+
(_a = options.onStart) == null ? void 0 : _a.call(options, options);
|
|
52
|
+
xhr.send(options.formData);
|
|
53
|
+
} else {
|
|
54
|
+
console.warn("\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 XMLHttpRequest");
|
|
33
55
|
}
|
|
34
56
|
}
|
|
35
|
-
uploadTaro(
|
|
57
|
+
uploadTaro(uploadFile, env) {
|
|
36
58
|
var _a;
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
59
|
+
const options = this.options;
|
|
60
|
+
if (env === "WEB") {
|
|
39
61
|
this.upload();
|
|
40
|
-
else {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
} else {
|
|
63
|
+
const uploadTask = uploadFile({
|
|
64
|
+
url: options.url,
|
|
65
|
+
filePath: options.taroFilePath,
|
|
66
|
+
fileType: options.fileType,
|
|
67
|
+
header: {
|
|
68
|
+
"Content-Type": "multipart/form-data",
|
|
69
|
+
...options.headers
|
|
70
|
+
},
|
|
71
|
+
formData: options.formData,
|
|
72
|
+
name: options.name,
|
|
73
|
+
success(response) {
|
|
74
|
+
var _a2, _b;
|
|
75
|
+
if (options.xhrState == response.statusCode) {
|
|
76
|
+
(_a2 = options.onSuccess) == null ? void 0 : _a2.call(options, response, options);
|
|
77
|
+
} else {
|
|
78
|
+
(_b = options.onFailure) == null ? void 0 : _b.call(options, response, options);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
fail(e) {
|
|
82
|
+
var _a2;
|
|
83
|
+
(_a2 = options.onFailure) == null ? void 0 : _a2.call(options, e, options);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
(_a = options.onStart) == null ? void 0 : _a.call(options, options);
|
|
87
|
+
uploadTask.progress((res) => {
|
|
49
88
|
var _a2;
|
|
50
|
-
(_a2 =
|
|
89
|
+
(_a2 = options.onProgress) == null ? void 0 : _a2.call(options, res, options);
|
|
51
90
|
});
|
|
52
91
|
}
|
|
53
92
|
}
|
|
54
93
|
}
|
|
55
|
-
const { translate:
|
|
56
|
-
class
|
|
94
|
+
const { translate: translate$1 } = createComponent("uploader");
|
|
95
|
+
class FileItem {
|
|
57
96
|
constructor() {
|
|
58
|
-
this.status = "ready"
|
|
97
|
+
this.status = "ready";
|
|
98
|
+
this.message = translate$1("ready");
|
|
99
|
+
this.uid = new Date().getTime().toString();
|
|
100
|
+
this.percentage = 0;
|
|
101
|
+
this.formData = {};
|
|
59
102
|
}
|
|
60
103
|
}
|
|
61
|
-
const { componentName
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
104
|
+
const { componentName, create, translate } = createComponent("uploader");
|
|
105
|
+
const _sfc_main = create({
|
|
106
|
+
props: {
|
|
107
|
+
name: { type: String, default: "file" },
|
|
108
|
+
url: { type: String, default: "" },
|
|
109
|
+
timeout: { type: [Number, String], default: 1e3 * 30 },
|
|
110
|
+
fileList: { type: Array, default: () => [] },
|
|
111
|
+
isPreview: { type: Boolean, default: true },
|
|
112
|
+
listType: { type: String, default: "picture" },
|
|
113
|
+
isDeletable: { type: Boolean, default: true },
|
|
114
|
+
method: { type: String, default: "post" },
|
|
115
|
+
capture: { type: Boolean, default: false },
|
|
116
|
+
maximize: { type: [Number, String], default: Number.MAX_VALUE },
|
|
117
|
+
maximum: { type: [Number, String], default: 1 },
|
|
118
|
+
clearInput: { type: Boolean, default: true },
|
|
119
|
+
accept: { type: String, default: "*" },
|
|
120
|
+
headers: { type: Object, default: {} },
|
|
121
|
+
data: { type: Object, default: {} },
|
|
122
|
+
uploadIcon: { type: String, default: "photograph" },
|
|
123
|
+
uploadIconSize: { type: [String, Number], default: "" },
|
|
124
|
+
xhrState: { type: [Number, String], default: 200 },
|
|
125
|
+
withCredentials: { type: Boolean, default: false },
|
|
126
|
+
multiple: { type: Boolean, default: false },
|
|
127
|
+
disabled: { type: Boolean, default: false },
|
|
128
|
+
autoUpload: { type: Boolean, default: true },
|
|
129
|
+
beforeUpload: {
|
|
130
|
+
type: Function,
|
|
131
|
+
default: null
|
|
132
|
+
},
|
|
133
|
+
beforeDelete: {
|
|
134
|
+
type: Function,
|
|
135
|
+
default: (file, files) => {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
onChange: { type: Function }
|
|
140
|
+
},
|
|
141
|
+
emits: [
|
|
142
|
+
"start",
|
|
143
|
+
"progress",
|
|
144
|
+
"oversize",
|
|
145
|
+
"success",
|
|
146
|
+
"failure",
|
|
147
|
+
"change",
|
|
148
|
+
"delete",
|
|
149
|
+
"update:fileList",
|
|
150
|
+
"file-item-click"
|
|
151
|
+
],
|
|
152
|
+
setup(props, { emit }) {
|
|
153
|
+
const fileList = reactive(props.fileList);
|
|
154
|
+
let uploadQueue = [];
|
|
155
|
+
const classes = computed(() => {
|
|
156
|
+
const prefixCls = componentName;
|
|
157
|
+
return {
|
|
158
|
+
[prefixCls]: true
|
|
159
|
+
};
|
|
95
160
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
161
|
+
const clearInput = (el) => {
|
|
162
|
+
el.value = "";
|
|
163
|
+
};
|
|
164
|
+
const fileItemClick = (fileItem) => {
|
|
165
|
+
emit("file-item-click", { fileItem });
|
|
166
|
+
};
|
|
167
|
+
const executeUpload = (fileItem, index2) => {
|
|
168
|
+
const uploadOption = new UploadOptions();
|
|
169
|
+
uploadOption.url = props.url;
|
|
170
|
+
uploadOption.formData = fileItem.formData;
|
|
171
|
+
uploadOption.timeout = props.timeout * 1;
|
|
172
|
+
uploadOption.method = props.method;
|
|
173
|
+
uploadOption.xhrState = props.xhrState;
|
|
174
|
+
uploadOption.headers = props.headers;
|
|
175
|
+
uploadOption.withCredentials = props.withCredentials;
|
|
176
|
+
uploadOption.onStart = (option) => {
|
|
177
|
+
fileItem.status = "ready";
|
|
178
|
+
fileItem.message = translate("readyUpload");
|
|
179
|
+
clearUploadQueue(index2);
|
|
180
|
+
emit("start", option);
|
|
181
|
+
};
|
|
182
|
+
uploadOption.onProgress = (event, option) => {
|
|
183
|
+
fileItem.status = "uploading";
|
|
184
|
+
fileItem.message = translate("uploading");
|
|
185
|
+
fileItem.percentage = (event.loaded / event.total * 100).toFixed(0);
|
|
186
|
+
emit("progress", { event, option, percentage: fileItem.percentage });
|
|
187
|
+
};
|
|
188
|
+
uploadOption.onSuccess = (responseText, option) => {
|
|
189
|
+
fileItem.status = "success";
|
|
190
|
+
fileItem.message = translate("success");
|
|
191
|
+
emit("success", {
|
|
192
|
+
responseText,
|
|
193
|
+
option,
|
|
194
|
+
fileItem
|
|
195
|
+
});
|
|
196
|
+
emit("update:fileList", fileList);
|
|
197
|
+
};
|
|
198
|
+
uploadOption.onFailure = (responseText, option) => {
|
|
199
|
+
fileItem.status = "error";
|
|
200
|
+
fileItem.message = translate("error");
|
|
201
|
+
emit("failure", {
|
|
202
|
+
responseText,
|
|
203
|
+
option,
|
|
204
|
+
fileItem
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
let task = new Uploader(uploadOption);
|
|
208
|
+
if (props.autoUpload) {
|
|
209
|
+
task.upload();
|
|
210
|
+
} else {
|
|
211
|
+
uploadQueue.push(new Promise((resolve, reject) => {
|
|
212
|
+
resolve(task);
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const clearUploadQueue = (index2 = -1) => {
|
|
217
|
+
if (index2 > -1) {
|
|
218
|
+
uploadQueue.splice(index2, 1);
|
|
219
|
+
} else {
|
|
220
|
+
uploadQueue = [];
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const submit = () => {
|
|
224
|
+
Promise.all(uploadQueue).then((res) => {
|
|
225
|
+
res.forEach((i) => i.upload());
|
|
111
226
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
227
|
+
};
|
|
228
|
+
const readFile = (files) => {
|
|
229
|
+
files.forEach((file, index2) => {
|
|
230
|
+
const formData = new FormData();
|
|
231
|
+
for (const [key, value] of Object.entries(props.data)) {
|
|
232
|
+
formData.append(key, value);
|
|
233
|
+
}
|
|
234
|
+
formData.append(props.name, file);
|
|
235
|
+
const fileItem = reactive(new FileItem());
|
|
236
|
+
fileItem.name = file.name;
|
|
237
|
+
fileItem.status = "ready";
|
|
238
|
+
fileItem.type = file.type;
|
|
239
|
+
fileItem.formData = formData;
|
|
240
|
+
fileItem.message = translate("waitingUpload");
|
|
241
|
+
executeUpload(fileItem, index2);
|
|
242
|
+
if (props.isPreview && file.type.includes("image")) {
|
|
243
|
+
const reader = new FileReader();
|
|
244
|
+
reader.onload = (event) => {
|
|
245
|
+
fileItem.url = event.target.result;
|
|
246
|
+
fileList.push(fileItem);
|
|
247
|
+
};
|
|
248
|
+
reader.readAsDataURL(file);
|
|
249
|
+
} else {
|
|
250
|
+
fileList.push(fileItem);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
const filterFiles = (files) => {
|
|
255
|
+
const maximum = props.maximum * 1;
|
|
256
|
+
const maximize = props.maximize * 1;
|
|
257
|
+
const oversizes = new Array();
|
|
258
|
+
files = files.filter((file) => {
|
|
259
|
+
if (file.size > maximize) {
|
|
260
|
+
oversizes.push(file);
|
|
261
|
+
return false;
|
|
262
|
+
} else {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
if (oversizes.length) {
|
|
267
|
+
emit("oversize", oversizes);
|
|
268
|
+
}
|
|
269
|
+
let currentFileLength = files.length + fileList.length;
|
|
270
|
+
if (currentFileLength > maximum) {
|
|
271
|
+
files.splice(files.length - (currentFileLength - maximum));
|
|
272
|
+
}
|
|
273
|
+
return files;
|
|
274
|
+
};
|
|
275
|
+
const onDelete = (file, index2) => {
|
|
276
|
+
clearUploadQueue(index2);
|
|
277
|
+
if (props.beforeDelete(file, fileList)) {
|
|
278
|
+
fileList.splice(index2, 1);
|
|
279
|
+
emit("delete", {
|
|
280
|
+
file,
|
|
281
|
+
fileList,
|
|
282
|
+
index: index2
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
const onChange = (event) => {
|
|
287
|
+
if (props.disabled) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const $el = event.target;
|
|
291
|
+
let { files } = $el;
|
|
292
|
+
if (props.beforeUpload) {
|
|
293
|
+
props.beforeUpload(files).then((f) => {
|
|
294
|
+
const _files = filterFiles(new Array().slice.call(f));
|
|
295
|
+
readFile(_files);
|
|
296
|
+
});
|
|
297
|
+
} else {
|
|
298
|
+
const _files = filterFiles(new Array().slice.call(files));
|
|
299
|
+
readFile(_files);
|
|
300
|
+
}
|
|
301
|
+
emit("change", {
|
|
302
|
+
fileList,
|
|
303
|
+
event
|
|
304
|
+
});
|
|
305
|
+
if (props.clearInput) {
|
|
306
|
+
clearInput($el);
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
return {
|
|
310
|
+
onChange,
|
|
311
|
+
onDelete,
|
|
312
|
+
fileList,
|
|
313
|
+
classes,
|
|
314
|
+
fileItemClick,
|
|
315
|
+
clearUploadQueue,
|
|
316
|
+
submit
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
const _hoisted_1 = {
|
|
321
|
+
key: 0,
|
|
322
|
+
class: "nut-uploader__slot"
|
|
323
|
+
};
|
|
324
|
+
const _hoisted_2 = ["accept", "multiple", "name", "disabled"];
|
|
325
|
+
const _hoisted_3 = ["accept", "multiple", "name", "disabled"];
|
|
326
|
+
const _hoisted_4 = {
|
|
327
|
+
key: 0,
|
|
328
|
+
class: "nut-uploader__preview-img"
|
|
329
|
+
};
|
|
330
|
+
const _hoisted_5 = {
|
|
331
|
+
key: 0,
|
|
332
|
+
class: "nut-uploader__preview__progress"
|
|
333
|
+
};
|
|
334
|
+
const _hoisted_6 = { class: "nut-uploader__preview__progress__msg" };
|
|
335
|
+
const _hoisted_7 = {
|
|
336
|
+
key: 1,
|
|
337
|
+
class: "nut-uploader__preview__progress"
|
|
338
|
+
};
|
|
339
|
+
const _hoisted_8 = { class: "nut-uploader__preview__progress__msg" };
|
|
340
|
+
const _hoisted_9 = ["onClick", "src"];
|
|
341
|
+
const _hoisted_10 = {
|
|
342
|
+
key: 4,
|
|
343
|
+
class: "nut-uploader__preview-img__file"
|
|
344
|
+
};
|
|
345
|
+
const _hoisted_11 = ["onClick"];
|
|
346
|
+
const _hoisted_12 = { class: "tips" };
|
|
347
|
+
const _hoisted_13 = {
|
|
348
|
+
key: 1,
|
|
349
|
+
class: "nut-uploader__preview-list"
|
|
350
|
+
};
|
|
351
|
+
const _hoisted_14 = ["onClick"];
|
|
352
|
+
const _hoisted_15 = ["accept", "multiple", "name", "disabled"];
|
|
353
|
+
const _hoisted_16 = ["accept", "multiple", "name", "disabled"];
|
|
354
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
355
|
+
const _component_nut_icon = resolveComponent("nut-icon");
|
|
356
|
+
const _component_nut_progress = resolveComponent("nut-progress");
|
|
357
|
+
return openBlock(), createElementBlock("view", {
|
|
358
|
+
class: normalizeClass(_ctx.classes)
|
|
359
|
+
}, [
|
|
360
|
+
_ctx.$slots.default ? (openBlock(), createElementBlock("view", _hoisted_1, [
|
|
361
|
+
renderSlot(_ctx.$slots, "default"),
|
|
362
|
+
_ctx.maximum - _ctx.fileList.length ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
363
|
+
_ctx.capture ? (openBlock(), createElementBlock("input", {
|
|
364
|
+
key: 0,
|
|
365
|
+
class: "nut-uploader__input",
|
|
366
|
+
type: "file",
|
|
367
|
+
capture: "camera",
|
|
368
|
+
accept: _ctx.accept,
|
|
369
|
+
multiple: _ctx.multiple,
|
|
370
|
+
name: _ctx.name,
|
|
371
|
+
disabled: _ctx.disabled,
|
|
372
|
+
onChange: _cache[0] || (_cache[0] = (...args) => _ctx.onChange && _ctx.onChange(...args))
|
|
373
|
+
}, null, 40, _hoisted_2)) : (openBlock(), createElementBlock("input", {
|
|
374
|
+
key: 1,
|
|
375
|
+
class: "nut-uploader__input",
|
|
376
|
+
type: "file",
|
|
377
|
+
accept: _ctx.accept,
|
|
378
|
+
multiple: _ctx.multiple,
|
|
379
|
+
name: _ctx.name,
|
|
380
|
+
disabled: _ctx.disabled,
|
|
381
|
+
onChange: _cache[1] || (_cache[1] = (...args) => _ctx.onChange && _ctx.onChange(...args))
|
|
382
|
+
}, null, 40, _hoisted_3))
|
|
383
|
+
], 64)) : createCommentVNode("", true)
|
|
384
|
+
])) : createCommentVNode("", true),
|
|
385
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.fileList, (item, index2) => {
|
|
386
|
+
return openBlock(), createElementBlock("view", {
|
|
387
|
+
class: normalizeClass(["nut-uploader__preview", [_ctx.listType]]),
|
|
388
|
+
key: item.uid
|
|
389
|
+
}, [
|
|
390
|
+
_ctx.listType == "picture" && !_ctx.$slots.default ? (openBlock(), createElementBlock("view", _hoisted_4, [
|
|
391
|
+
item.status == "ready" ? (openBlock(), createElementBlock("view", _hoisted_5, [
|
|
392
|
+
createElementVNode("view", _hoisted_6, toDisplayString(item.message), 1)
|
|
393
|
+
])) : item.status != "success" ? (openBlock(), createElementBlock("view", _hoisted_7, [
|
|
394
|
+
createVNode(_component_nut_icon, {
|
|
395
|
+
color: "#fff",
|
|
396
|
+
name: item.status == "error" ? "failure" : "loading"
|
|
397
|
+
}, null, 8, ["name"]),
|
|
398
|
+
createElementVNode("view", _hoisted_8, toDisplayString(item.message), 1)
|
|
399
|
+
])) : createCommentVNode("", true),
|
|
400
|
+
_ctx.isDeletable ? (openBlock(), createBlock(_component_nut_icon, {
|
|
401
|
+
key: 2,
|
|
402
|
+
color: "rgba(0,0,0,0.6)",
|
|
403
|
+
onClick: ($event) => _ctx.onDelete(item, index2),
|
|
404
|
+
class: "close",
|
|
405
|
+
name: "failure"
|
|
406
|
+
}, null, 8, ["onClick"])) : createCommentVNode("", true),
|
|
407
|
+
item.type.includes("image") && item.url ? (openBlock(), createElementBlock("img", {
|
|
408
|
+
key: 3,
|
|
409
|
+
class: "nut-uploader__preview-img__c",
|
|
410
|
+
onClick: ($event) => _ctx.fileItemClick(item),
|
|
411
|
+
src: item.url
|
|
412
|
+
}, null, 8, _hoisted_9)) : (openBlock(), createElementBlock("view", _hoisted_10, [
|
|
413
|
+
createElementVNode("view", {
|
|
414
|
+
onClick: ($event) => _ctx.fileItemClick(item),
|
|
415
|
+
class: "nut-uploader__preview-img__file__name"
|
|
416
|
+
}, [
|
|
417
|
+
createVNode(_component_nut_icon, {
|
|
418
|
+
color: "#808080",
|
|
419
|
+
name: "link"
|
|
420
|
+
}),
|
|
421
|
+
createTextVNode("\xA0" + toDisplayString(item.name), 1)
|
|
422
|
+
], 8, _hoisted_11)
|
|
423
|
+
])),
|
|
424
|
+
createElementVNode("view", _hoisted_12, toDisplayString(item.name), 1)
|
|
425
|
+
])) : _ctx.listType == "list" ? (openBlock(), createElementBlock("view", _hoisted_13, [
|
|
426
|
+
createElementVNode("view", {
|
|
427
|
+
onClick: ($event) => _ctx.fileItemClick(item),
|
|
428
|
+
class: normalizeClass(["nut-uploader__preview-img__file__name", [item.status]])
|
|
429
|
+
}, [
|
|
430
|
+
createVNode(_component_nut_icon, { name: "link" }),
|
|
431
|
+
createTextVNode("\xA0" + toDisplayString(item.name), 1)
|
|
432
|
+
], 10, _hoisted_14),
|
|
433
|
+
createVNode(_component_nut_icon, {
|
|
434
|
+
class: "nut-uploader__preview-img__file__del",
|
|
435
|
+
onClick: ($event) => _ctx.onDelete(item, index2),
|
|
436
|
+
color: "#808080",
|
|
437
|
+
name: "del"
|
|
438
|
+
}, null, 8, ["onClick"]),
|
|
439
|
+
item.status == "uploading" ? (openBlock(), createBlock(_component_nut_progress, {
|
|
440
|
+
key: 0,
|
|
441
|
+
size: "small",
|
|
442
|
+
percentage: item.percentage,
|
|
443
|
+
"stroke-color": "linear-gradient(270deg, rgba(18,126,255,1) 0%,rgba(32,147,255,1) 32.815625%,rgba(13,242,204,1) 100%)",
|
|
444
|
+
"show-text": false
|
|
445
|
+
}, null, 8, ["percentage"])) : createCommentVNode("", true)
|
|
446
|
+
])) : createCommentVNode("", true)
|
|
447
|
+
], 2);
|
|
448
|
+
}), 128)),
|
|
449
|
+
_ctx.listType == "picture" && !_ctx.$slots.default && _ctx.maximum - _ctx.fileList.length ? (openBlock(), createElementBlock("view", {
|
|
450
|
+
key: 1,
|
|
451
|
+
class: normalizeClass(["nut-uploader__upload", [_ctx.listType]])
|
|
452
|
+
}, [
|
|
453
|
+
createVNode(_component_nut_icon, {
|
|
454
|
+
size: _ctx.uploadIconSize,
|
|
455
|
+
color: "#808080",
|
|
456
|
+
name: _ctx.uploadIcon
|
|
457
|
+
}, null, 8, ["size", "name"]),
|
|
458
|
+
_ctx.capture ? (openBlock(), createElementBlock("input", {
|
|
459
|
+
key: 0,
|
|
460
|
+
class: "nut-uploader__input",
|
|
461
|
+
type: "file",
|
|
462
|
+
capture: "camera",
|
|
463
|
+
accept: _ctx.accept,
|
|
464
|
+
multiple: _ctx.multiple,
|
|
465
|
+
name: _ctx.name,
|
|
466
|
+
disabled: _ctx.disabled,
|
|
467
|
+
onChange: _cache[2] || (_cache[2] = (...args) => _ctx.onChange && _ctx.onChange(...args))
|
|
468
|
+
}, null, 40, _hoisted_15)) : (openBlock(), createElementBlock("input", {
|
|
469
|
+
key: 1,
|
|
470
|
+
class: "nut-uploader__input",
|
|
471
|
+
type: "file",
|
|
472
|
+
accept: _ctx.accept,
|
|
473
|
+
multiple: _ctx.multiple,
|
|
474
|
+
name: _ctx.name,
|
|
475
|
+
disabled: _ctx.disabled,
|
|
476
|
+
onChange: _cache[3] || (_cache[3] = (...args) => _ctx.onChange && _ctx.onChange(...args))
|
|
477
|
+
}, null, 40, _hoisted_16))
|
|
478
|
+
], 2)) : createCommentVNode("", true)
|
|
479
|
+
], 2);
|
|
480
|
+
}
|
|
481
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
482
|
+
export { index as default };
|