@nutui/nutui 4.0.10-beta.1 → 4.0.11

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