@nutui/nutui 4.0.12-beta.1 → 4.0.12

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