@nutui/nutui 3.1.6 → 3.1.7

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 (92) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/nutui.d.ts +7 -1
  3. package/dist/nutui.es.js +1097 -517
  4. package/dist/nutui.umd.js +1158 -571
  5. package/dist/packages/_es/ActionSheet.js +158 -0
  6. package/dist/packages/_es/Address.js +525 -0
  7. package/dist/packages/_es/Avatar.js +87 -0
  8. package/dist/packages/_es/BackTop.js +159 -0
  9. package/dist/packages/_es/Badge.js +90 -0
  10. package/dist/packages/_es/Barrage.js +118 -0
  11. package/dist/packages/_es/Button.js +124 -0
  12. package/dist/packages/_es/Calendar.js +700 -0
  13. package/dist/packages/_es/Cell.js +95 -0
  14. package/dist/packages/_es/CellGroup.js +42 -0
  15. package/dist/packages/_es/Checkbox.js +109 -0
  16. package/dist/packages/_es/CheckboxGroup.js +62 -0
  17. package/dist/packages/_es/CircleProgress.js +109 -0
  18. package/dist/packages/_es/Col.js +53 -0
  19. package/dist/packages/_es/Collapse.js +89 -0
  20. package/dist/packages/_es/CollapseItem.js +257 -0
  21. package/dist/packages/_es/CountDown.js +224 -0
  22. package/dist/packages/_es/CountUp.js +547 -0
  23. package/dist/packages/_es/DatePicker.js +282 -0
  24. package/dist/packages/_es/Dialog.js +313 -0
  25. package/dist/packages/_es/Divider.js +49 -0
  26. package/dist/packages/_es/Drag.js +198 -0
  27. package/dist/packages/_es/Elevator.js +207 -0
  28. package/dist/packages/_es/FixedNav.js +127 -0
  29. package/dist/packages/_es/Icon.js +44 -0
  30. package/dist/packages/_es/ImagePreview.js +109 -0
  31. package/dist/packages/_es/InfiniteLoading.js +265 -0
  32. package/dist/packages/_es/Input.js +183 -0
  33. package/dist/packages/_es/InputNumber.js +172 -0
  34. package/dist/packages/_es/Layout.js +10 -0
  35. package/dist/packages/_es/MenuItem.js +180 -0
  36. package/dist/packages/_es/Navbar.js +160 -0
  37. package/dist/packages/_es/NoticeBar.js +389 -0
  38. package/dist/packages/_es/Notify.js +233 -0
  39. package/dist/packages/_es/NumberKeyboard.js +248 -0
  40. package/dist/packages/_es/OverLay.js +118 -0
  41. package/dist/packages/_es/Pagination.js +163 -0
  42. package/dist/packages/_es/Picker.js +485 -0
  43. package/dist/packages/_es/Popover.js +157 -0
  44. package/dist/packages/_es/Popup.js +268 -0
  45. package/dist/packages/_es/Price.js +104 -0
  46. package/dist/packages/_es/Progress.js +131 -0
  47. package/dist/packages/_es/Radio.js +72 -0
  48. package/dist/packages/_es/RadioGroup.js +37 -0
  49. package/dist/packages/_es/Range.js +350 -0
  50. package/dist/packages/_es/Rate.js +129 -0
  51. package/dist/packages/_es/Row.js +61 -0
  52. package/dist/packages/_es/ShortPassword.js +221 -0
  53. package/dist/packages/_es/Signature.js +167 -0
  54. package/dist/packages/_es/Step.js +116 -0
  55. package/dist/packages/_es/Steps.js +52 -0
  56. package/dist/packages/_es/Swipe.js +193 -0
  57. package/dist/packages/_es/Swiper.js +429 -0
  58. package/dist/packages/_es/SwiperItem.js +60 -0
  59. package/dist/packages/_es/Switch.js +90 -0
  60. package/dist/packages/_es/Tab.js +179 -0
  61. package/dist/packages/_es/TabPane.js +42 -0
  62. package/dist/packages/_es/TabPanel.js +30 -0
  63. package/dist/packages/_es/Tabbar.js +73 -0
  64. package/dist/packages/_es/TabbarItem.js +142 -0
  65. package/dist/packages/_es/Tag.js +98 -0
  66. package/dist/packages/_es/TextArea.js +127 -0
  67. package/dist/packages/_es/Toast.js +317 -0
  68. package/dist/packages/_es/Uploader.js +400 -0
  69. package/dist/packages/_es/Video.js +405 -0
  70. package/dist/packages/_es/component.js +26 -0
  71. package/dist/packages/_es/index.js +64 -0
  72. package/dist/packages/_es/index2.js +13 -0
  73. package/dist/packages/_es/plugin-vue_export-helper.js +12 -0
  74. package/dist/packages/_es/pxCheck.js +9 -0
  75. package/dist/packages/_es/raf.js +19 -0
  76. package/dist/packages/avatar/index.scss +0 -1
  77. package/dist/packages/badge/index.scss +35 -0
  78. package/dist/packages/calendar/index.scss +13 -0
  79. package/dist/packages/imagepreview/index.scss +48 -0
  80. package/dist/packages/input/index.scss +14 -7
  81. package/dist/packages/pagination/index.scss +51 -0
  82. package/dist/packages/popover/index.scss +159 -0
  83. package/dist/packages/shortpassword/index.scss +19 -7
  84. package/dist/packages/tabpane/index.scss +1 -0
  85. package/dist/packages/tabs/index.scss +1 -0
  86. package/dist/packages/tag/index.scss +47 -0
  87. package/dist/packages/uploader/index.scss +0 -1
  88. package/dist/style.css +1 -1
  89. package/dist/style.es.js +2 -1
  90. package/dist/styles/themes/default.scss +35 -28
  91. package/dist/styles/variables.scss +55 -32
  92. package/package.json +7 -7
@@ -0,0 +1,400 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
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]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __publicField = (obj, key, value) => {
18
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
19
+ return value;
20
+ };
21
+ /*!
22
+ * @nutui/nutui v3.1.7 Thu Sep 30 2021 20:17:02 GMT+0800 (中国标准时间)
23
+ * (c) 2021 @jdf2e.
24
+ * Released under the MIT License.
25
+ */
26
+ import { reactive, computed, resolveComponent, openBlock, createElementBlock, normalizeClass, renderSlot, Fragment, createCommentVNode, renderList, createElementVNode, createBlock, toDisplayString, createVNode } from "vue";
27
+ import { c as createComponent } from "./component.js";
28
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
29
+ class UploadOptions {
30
+ constructor() {
31
+ __publicField(this, "url", "");
32
+ __publicField(this, "name", "file");
33
+ __publicField(this, "formData");
34
+ __publicField(this, "method", "post");
35
+ __publicField(this, "xhrState", 200);
36
+ __publicField(this, "timeout", 30 * 1e3);
37
+ __publicField(this, "headers", {});
38
+ __publicField(this, "withCredentials", false);
39
+ __publicField(this, "onStart");
40
+ __publicField(this, "onProgress");
41
+ __publicField(this, "onSuccess");
42
+ __publicField(this, "onFailure");
43
+ }
44
+ }
45
+ class Uploader {
46
+ constructor(options) {
47
+ __publicField(this, "options");
48
+ this.options = options;
49
+ }
50
+ upload() {
51
+ var _a;
52
+ const options = this.options;
53
+ const xhr = new XMLHttpRequest();
54
+ xhr.timeout = options.timeout;
55
+ if (xhr.upload) {
56
+ xhr.upload.addEventListener("progress", (e) => {
57
+ var _a2;
58
+ (_a2 = options.onProgress) == null ? void 0 : _a2.call(options, e, options);
59
+ }, false);
60
+ xhr.onreadystatechange = () => {
61
+ var _a2, _b;
62
+ if (xhr.readyState === 4) {
63
+ if (xhr.status === options.xhrState) {
64
+ (_a2 = options.onSuccess) == null ? void 0 : _a2.call(options, xhr.responseText, options);
65
+ } else {
66
+ (_b = options.onFailure) == null ? void 0 : _b.call(options, xhr.responseText, options);
67
+ }
68
+ }
69
+ };
70
+ xhr.withCredentials = options.withCredentials;
71
+ xhr.open(options.method, options.url, true);
72
+ for (const [key, value] of Object.entries(options.headers)) {
73
+ xhr.setRequestHeader(key, value);
74
+ }
75
+ (_a = options.onStart) == null ? void 0 : _a.call(options, options);
76
+ xhr.send(options.formData);
77
+ } else {
78
+ console.warn("\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 XMLHttpRequest");
79
+ }
80
+ }
81
+ uploadTaro(filePath, uploadFile) {
82
+ var _a;
83
+ const options = this.options;
84
+ const uploadTask = uploadFile({
85
+ url: options.url,
86
+ filePath,
87
+ header: __spreadValues({
88
+ "Content-Type": "multipart/form-data"
89
+ }, options.headers),
90
+ formData: options.formData,
91
+ name: options.name,
92
+ success(response) {
93
+ var _a2, _b;
94
+ if (options.xhrState === response.statusCode) {
95
+ (_a2 = options.onSuccess) == null ? void 0 : _a2.call(options, response, options);
96
+ } else {
97
+ (_b = options.onFailure) == null ? void 0 : _b.call(options, response, options);
98
+ }
99
+ },
100
+ fail(e) {
101
+ var _a2;
102
+ (_a2 = options.onFailure) == null ? void 0 : _a2.call(options, e, options);
103
+ }
104
+ });
105
+ (_a = options.onStart) == null ? void 0 : _a.call(options, options);
106
+ uploadTask.progress((res) => {
107
+ var _a2;
108
+ (_a2 = options.onProgress) == null ? void 0 : _a2.call(options, res, options);
109
+ });
110
+ }
111
+ }
112
+ const { componentName, create } = createComponent("uploader");
113
+ class FileItem {
114
+ constructor() {
115
+ __publicField(this, "status", "ready");
116
+ __publicField(this, "uid", new Date().getTime().toString());
117
+ __publicField(this, "name");
118
+ __publicField(this, "url");
119
+ __publicField(this, "type");
120
+ __publicField(this, "formData", new FormData());
121
+ }
122
+ }
123
+ const _sfc_main = create({
124
+ props: {
125
+ name: { type: String, default: "file" },
126
+ url: { type: String, default: "" },
127
+ timeout: { type: [Number, String], default: 1e3 * 30 },
128
+ fileList: { type: Array, default: () => [] },
129
+ isPreview: { type: Boolean, default: true },
130
+ isDeletable: { type: Boolean, default: true },
131
+ method: { type: String, default: "post" },
132
+ capture: { type: Boolean, default: false },
133
+ maximize: { type: [Number, String], default: Number.MAX_VALUE },
134
+ maximum: { type: [Number, String], default: 1 },
135
+ clearInput: { type: Boolean, default: false },
136
+ accept: { type: String, default: "*" },
137
+ headers: { type: Object, default: {} },
138
+ data: { type: Object, default: {} },
139
+ uploadIcon: { type: String, default: "photograph" },
140
+ uploadIconSize: { type: [String, Number], default: "" },
141
+ xhrState: { type: [Number, String], default: 200 },
142
+ withCredentials: { type: Boolean, default: false },
143
+ multiple: { type: Boolean, default: false },
144
+ disabled: { type: Boolean, default: false },
145
+ beforeUpload: {
146
+ type: Function,
147
+ default: null
148
+ },
149
+ beforeDelete: {
150
+ type: Function,
151
+ default: (file, files) => {
152
+ return true;
153
+ }
154
+ },
155
+ onChange: { type: Function }
156
+ },
157
+ emits: [
158
+ "start",
159
+ "progress",
160
+ "oversize",
161
+ "success",
162
+ "failure",
163
+ "change",
164
+ "delete",
165
+ "update:fileList"
166
+ ],
167
+ setup(props, { emit }) {
168
+ const fileList = reactive(props.fileList);
169
+ const classes = computed(() => {
170
+ const prefixCls = componentName;
171
+ return {
172
+ [prefixCls]: true
173
+ };
174
+ });
175
+ const clearInput = (el) => {
176
+ el.value = "";
177
+ };
178
+ const executeUpload = (fileItem) => {
179
+ const uploadOption = new UploadOptions();
180
+ uploadOption.url = props.url;
181
+ for (const [key, value] of Object.entries(props.data)) {
182
+ fileItem.formData.append(key, value);
183
+ }
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.onStart = (option) => {
191
+ fileItem.status = "ready";
192
+ emit("start", option);
193
+ };
194
+ uploadOption.onProgress = (e, option) => {
195
+ fileItem.status = "uploading";
196
+ emit("progress", { e, option });
197
+ };
198
+ uploadOption.onSuccess = (responseText, option) => {
199
+ fileItem.status = "success";
200
+ emit("success", {
201
+ responseText,
202
+ option
203
+ });
204
+ emit("update:fileList", fileList);
205
+ };
206
+ uploadOption.onFailure = (responseText, option) => {
207
+ fileItem.status = "error";
208
+ emit("failure", {
209
+ responseText,
210
+ option
211
+ });
212
+ };
213
+ new Uploader(uploadOption).upload();
214
+ };
215
+ const readFile = (files) => {
216
+ files.forEach((file) => {
217
+ const formData = new FormData();
218
+ formData.append(props.name, file);
219
+ const fileItem = reactive(new FileItem());
220
+ fileItem.name = file.name;
221
+ fileItem.status = "uploading";
222
+ fileItem.type = file.type;
223
+ fileItem.formData = formData;
224
+ executeUpload(fileItem);
225
+ if (props.isPreview && file.type.includes("image")) {
226
+ const reader = new FileReader();
227
+ reader.onload = (event) => {
228
+ fileItem.url = event.target.result;
229
+ fileList.push(fileItem);
230
+ };
231
+ reader.readAsDataURL(file);
232
+ } else {
233
+ fileList.push(fileItem);
234
+ }
235
+ });
236
+ };
237
+ const filterFiles = (files) => {
238
+ const maximum = props.maximum * 1;
239
+ const maximize = props.maximize * 1;
240
+ const oversizes = new Array();
241
+ files = files.filter((file) => {
242
+ if (file.size > maximize) {
243
+ oversizes.push(file);
244
+ return false;
245
+ } else {
246
+ return true;
247
+ }
248
+ });
249
+ if (oversizes.length) {
250
+ emit("oversize", oversizes);
251
+ }
252
+ if (files.length > maximum) {
253
+ files.splice(maximum - 1, files.length - maximum);
254
+ }
255
+ return files;
256
+ };
257
+ const onDelete = (file, index2) => {
258
+ if (props.beforeDelete(file, fileList)) {
259
+ fileList.splice(index2, 1);
260
+ emit("delete", {
261
+ file,
262
+ fileList
263
+ });
264
+ } else {
265
+ console.log("\u7528\u6237\u963B\u6B62\u4E86\u5220\u9664\uFF01");
266
+ }
267
+ };
268
+ const onChange = (event) => {
269
+ if (props.disabled) {
270
+ return;
271
+ }
272
+ const $el = event.target;
273
+ let { files } = $el;
274
+ if (props.beforeUpload) {
275
+ props.beforeUpload(files).then((f) => {
276
+ const _files = filterFiles(new Array().slice.call(f));
277
+ readFile(_files);
278
+ });
279
+ } else {
280
+ const _files = filterFiles(new Array().slice.call(files));
281
+ readFile(_files);
282
+ }
283
+ emit("change", {
284
+ fileList,
285
+ event
286
+ });
287
+ if (props.clearInput) {
288
+ clearInput($el);
289
+ }
290
+ };
291
+ return {
292
+ onChange,
293
+ onDelete,
294
+ fileList,
295
+ classes
296
+ };
297
+ }
298
+ });
299
+ const _hoisted_1 = {
300
+ key: 0,
301
+ class: "nut-uploader__slot"
302
+ };
303
+ const _hoisted_2 = ["accept", "multiple", "name", "disabled"];
304
+ const _hoisted_3 = ["accept", "multiple", "name", "disabled"];
305
+ const _hoisted_4 = { class: "nut-uploader__preview-img" };
306
+ const _hoisted_5 = ["src"];
307
+ const _hoisted_6 = {
308
+ key: 2,
309
+ class: "tips"
310
+ };
311
+ const _hoisted_7 = {
312
+ key: 0,
313
+ class: "nut-uploader__upload"
314
+ };
315
+ const _hoisted_8 = ["accept", "multiple", "name", "disabled"];
316
+ const _hoisted_9 = ["accept", "multiple", "name", "disabled"];
317
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
318
+ const _component_nut_icon = resolveComponent("nut-icon");
319
+ return openBlock(), createElementBlock("view", {
320
+ class: normalizeClass(_ctx.classes)
321
+ }, [
322
+ _ctx.$slots.default ? (openBlock(), createElementBlock("view", _hoisted_1, [
323
+ renderSlot(_ctx.$slots, "default"),
324
+ _ctx.maximum - _ctx.fileList.length ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
325
+ _ctx.capture ? (openBlock(), createElementBlock("input", {
326
+ key: 0,
327
+ class: "nut-uploader__input",
328
+ type: "file",
329
+ capture: "camera",
330
+ accept: _ctx.accept,
331
+ multiple: _ctx.multiple,
332
+ name: _ctx.name,
333
+ disabled: _ctx.disabled,
334
+ onChange: _cache[0] || (_cache[0] = (...args) => _ctx.onChange && _ctx.onChange(...args))
335
+ }, null, 40, _hoisted_2)) : (openBlock(), createElementBlock("input", {
336
+ key: 1,
337
+ class: "nut-uploader__input",
338
+ type: "file",
339
+ accept: _ctx.accept,
340
+ multiple: _ctx.multiple,
341
+ name: _ctx.name,
342
+ disabled: _ctx.disabled,
343
+ onChange: _cache[1] || (_cache[1] = (...args) => _ctx.onChange && _ctx.onChange(...args))
344
+ }, null, 40, _hoisted_3))
345
+ ], 64)) : createCommentVNode("", true)
346
+ ])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
347
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.fileList, (item, index2) => {
348
+ return openBlock(), createElementBlock("view", {
349
+ class: "nut-uploader__preview",
350
+ key: item.uid
351
+ }, [
352
+ createElementVNode("view", _hoisted_4, [
353
+ _ctx.isDeletable ? (openBlock(), createBlock(_component_nut_icon, {
354
+ key: 0,
355
+ color: "rgba(0,0,0,0.6)",
356
+ onClick: ($event) => _ctx.onDelete(item, index2),
357
+ class: "close",
358
+ name: "circle-close"
359
+ }, null, 8, ["onClick"])) : createCommentVNode("", true),
360
+ item.type.includes("image") && item.url ? (openBlock(), createElementBlock("img", {
361
+ key: 1,
362
+ class: "nut-uploader__preview-img__c",
363
+ src: item.url
364
+ }, null, 8, _hoisted_5)) : createCommentVNode("", true),
365
+ item.status != "success" ? (openBlock(), createElementBlock("view", _hoisted_6, toDisplayString(item.status), 1)) : createCommentVNode("", true)
366
+ ])
367
+ ]);
368
+ }), 128)),
369
+ _ctx.maximum - _ctx.fileList.length ? (openBlock(), createElementBlock("view", _hoisted_7, [
370
+ createVNode(_component_nut_icon, {
371
+ size: _ctx.uploadIconSize,
372
+ color: "#808080",
373
+ name: _ctx.uploadIcon
374
+ }, null, 8, ["size", "name"]),
375
+ _ctx.capture ? (openBlock(), createElementBlock("input", {
376
+ key: 0,
377
+ class: "nut-uploader__input",
378
+ type: "file",
379
+ capture: "camera",
380
+ accept: _ctx.accept,
381
+ multiple: _ctx.multiple,
382
+ name: _ctx.name,
383
+ disabled: _ctx.disabled,
384
+ onChange: _cache[2] || (_cache[2] = (...args) => _ctx.onChange && _ctx.onChange(...args))
385
+ }, null, 40, _hoisted_8)) : (openBlock(), createElementBlock("input", {
386
+ key: 1,
387
+ class: "nut-uploader__input",
388
+ type: "file",
389
+ accept: _ctx.accept,
390
+ multiple: _ctx.multiple,
391
+ name: _ctx.name,
392
+ disabled: _ctx.disabled,
393
+ onChange: _cache[3] || (_cache[3] = (...args) => _ctx.onChange && _ctx.onChange(...args))
394
+ }, null, 40, _hoisted_9))
395
+ ])) : createCommentVNode("", true)
396
+ ], 64))
397
+ ], 2);
398
+ }
399
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
400
+ export { FileItem, index as default };