@nutui/nutui 3.1.22-beta.0 → 3.1.22-beta.3

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