@nutui/nutui-react-taro 1.3.5-beta.1 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/esm/Audio.js +4 -4
- package/dist/esm/Calendar.js +4 -4
- package/dist/esm/CalendarItem.js +3 -3
- package/dist/esm/DatePicker.js +4 -4
- package/dist/esm/Drag.js +3 -4
- package/dist/esm/Elevator.js +2 -4
- package/dist/esm/NoticeBar.js +3 -3
- package/dist/esm/Picker.js +3 -3
- package/dist/esm/Popover.js +3 -3
- package/dist/esm/Range.js +3 -3
- package/dist/esm/SearchBar.js +3 -2
- package/dist/esm/Signature.js +3 -2
- package/dist/esm/Swipe.js +3 -3
- package/dist/esm/actionsheet.taro-360d8d34.js +15 -25
- package/dist/esm/address.taro-f16cef31.js +151 -219
- package/dist/esm/animatingnumbers.taro-6f40a2e9.js +13 -41
- package/dist/esm/{audio.taro-29f5568f.js → audio.taro-57d4f0da.js} +33 -60
- package/dist/esm/avatar.taro-ec620cdd.js +25 -50
- package/dist/esm/avatargroup-5b2584d9.js +2 -9
- package/dist/esm/backtop.taro-aa8b2bc5.js +29 -55
- package/dist/esm/badge.taro-38684262.js +9 -20
- package/dist/esm/barrage.taro-d86c367a.js +8 -21
- package/dist/esm/button.taro-a9ebb937.js +22 -37
- package/dist/esm/{calendar.taro-438940bd.js → calendar.taro-533b3219.js} +13 -24
- package/dist/esm/{calendaritem.taro-11333579.js → calendaritem.taro-fe5dd4bd.js} +71 -183
- package/dist/esm/card.taro-1bc35ebe.js +14 -20
- package/dist/esm/cascader.taro-77100fb4.js +77 -197
- package/dist/esm/cell.taro-a4c3bb7b.js +20 -30
- package/dist/esm/cellgroup.taro-8c87bf08.js +6 -12
- package/dist/esm/checkbox.taro-104557c1.js +27 -48
- package/dist/esm/checkboxgroup.taro-3d380042.js +12 -30
- package/dist/esm/circleprogress.taro-3c89a157.js +14 -41
- package/dist/esm/col.taro-2a437387.js +11 -22
- package/dist/esm/collapse.taro-72e58ba2.js +11 -27
- package/dist/esm/collapseitem-75843a5e.js +33 -47
- package/dist/esm/configprovider-3e87d67a.js +2 -6
- package/dist/esm/configprovider.taro-6c7b3056.js +4 -14
- package/dist/esm/countdown.taro-f2d9ffed.js +37 -74
- package/dist/esm/{datepicker.taro-1acec61f.js → datepicker.taro-49a4cf0c.js} +43 -104
- package/dist/esm/dialog.taro-492e2b9a.js +27 -58
- package/dist/esm/divider.taro-5236fe6a.js +8 -15
- package/dist/esm/drag.taro-0717c783.js +153 -0
- package/dist/esm/{elevator.taro-8e385785.js → elevator.taro-443253ec.js} +99 -124
- package/dist/esm/empty.taro-ab9c4f03.js +11 -24
- package/dist/esm/fixednav.taro-582322a1.js +16 -27
- package/dist/esm/grid.taro-5d75c0ad.js +13 -28
- package/dist/esm/griditem.taro-866cd288.js +18 -34
- package/dist/esm/icon-8dc4de10.js +11 -21
- package/dist/esm/icon.taro-1d0d4fb7.js +11 -21
- package/dist/esm/imagepreview.taro-1199e977.js +36 -71
- package/dist/esm/indicator.taro-183ea169.js +9 -20
- package/dist/esm/infiniteloading.taro-b95e62bf.js +23 -49
- package/dist/esm/input.taro-2453d7c4.js +62 -106
- package/dist/esm/inputnumber.taro-0cf7c1b7.js +25 -52
- package/dist/esm/layout.taro-358f014f.js +0 -6
- package/dist/esm/menu.taro-9345dcfd.js +21 -41
- package/dist/esm/menuitem.taro-fc0961b7.js +29 -54
- package/dist/esm/navbar.taro-c931c078.js +18 -34
- package/dist/esm/{noticebar.taro-1fa04a96.js → noticebar.taro-332691f9.js} +55 -107
- package/dist/esm/notify.taro-d9c48fae.js +18 -34
- package/dist/esm/numberkeyboard.taro-53c350b8.js +21 -52
- package/dist/esm/nutui-react.es.js +16 -16
- package/dist/esm/offsetContext-0e3d04b3.js +0 -3
- package/dist/esm/overlay.taro-be45fed5.js +12 -23
- package/dist/esm/pagination.taro-62bbd23f.js +38 -71
- package/dist/esm/{picker.taro-6a4dad23.js → picker.taro-f003b725.js} +95 -186
- package/dist/esm/{popover.taro-eddd0bd2.js → popover.taro-7e5dff8c.js} +33 -76
- package/dist/esm/popup.taro-33d0bbc8.js +40 -72
- package/dist/esm/price.taro-97393d8f.js +7 -24
- package/dist/esm/progress.taro-623bc807.js +23 -31
- package/dist/esm/pulltorefresh.taro-e66c78ad.js +29 -92
- package/dist/esm/radio.taro-95d43860.js +24 -47
- package/dist/esm/radiogroup.taro-b5dad516.js +14 -24
- package/dist/esm/{range.taro-515d37a4.js → range.taro-fc7c0b6a.js} +50 -133
- package/dist/esm/rate.taro-69c85081.js +21 -39
- package/dist/esm/row.taro-cec13a7e.js +7 -16
- package/dist/esm/{searchbar.taro-f134fb96.js → searchbar.taro-0d3c0081.js} +55 -70
- package/dist/esm/shortpassword.taro-2e96ca22.js +29 -56
- package/dist/esm/sidenavbar.taro-87f056cd.js +9 -16
- package/dist/esm/sidenavbaritem.taro-77e077f4.js +4 -11
- package/dist/esm/signature.taro-59b3b3ab.js +146 -0
- package/dist/esm/skeleton.taro-b9ff84b9.js +13 -23
- package/dist/esm/step.taro-f1057500.js +12 -28
- package/dist/esm/steps.taro-943f4fbb.js +6 -14
- package/dist/esm/sticky.taro-30d4e453.js +0 -7
- package/dist/esm/subsidenavbar.taro-2c1fcf16.js +7 -22
- package/dist/esm/{swipe.taro-dfb9a049.js → swipe.taro-83bc248f.js} +98 -91
- package/dist/esm/swiper.taro-f314d67a.js +110 -196
- package/dist/esm/swiperitem-d00e7513.js +2 -12
- package/dist/esm/switch.taro-be5eb823.js +13 -27
- package/dist/esm/tabbar.taro-da72fa2c.js +13 -25
- package/dist/esm/tabbaritem.taro-94cd62c2.js +15 -23
- package/dist/esm/table.taro-7ac89a6c.js +19 -39
- package/dist/esm/tabpane.taro-95aa185b.js +4 -10
- package/dist/esm/tabs.taro-86186dff.js +28 -54
- package/dist/esm/tag.taro-95d7f5c2.js +19 -36
- package/dist/esm/textarea.taro-388d1f90.js +18 -35
- package/dist/esm/timedetail.taro-519808cf.js +15 -28
- package/dist/esm/timepannel.taro-9904f6e6.js +5 -12
- package/dist/esm/timeselect.taro-73796bfc.js +35 -59
- package/dist/esm/toast.taro-86862dff.js +26 -46
- package/dist/esm/types/src/packages/elevator/demo.d.ts +1 -0
- package/dist/esm/types/src/packages/searchbar/searchbar.d.ts +2 -0
- package/dist/esm/types/src/packages/searchbar/searchbar.taro.d.ts +2 -0
- package/dist/esm/types/src/packages/signature/signature.taro.d.ts +10 -2
- package/dist/esm/uploader.taro-6184abe7.js +52 -144
- package/dist/esm/{useClientRect-8b7cc406.js → useClientRect-bf69d7b3.js} +1 -40
- package/dist/esm/useTouch-a2ea68c6.js +27 -47
- package/dist/esm/video-c1090c92.js +8 -19
- package/dist/esm/virtuallist.taro-6858f690.js +84 -118
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/nutui.react.es.js +10844 -11362
- package/dist/nutui.react.umd.js +10844 -11362
- package/dist/packages/searchbar/searchbar.scss +20 -3
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/types/index.d.ts +17 -8
- package/package.json +1 -1
- package/dist/esm/drag.taro-56e8c87a.js +0 -134
- package/dist/esm/signature.taro-a9286cd1.js +0 -178
|
@@ -47,6 +47,8 @@ export interface SearchBarProps extends IComponent {
|
|
|
47
47
|
onBlur?: (value: string, event: Event) => void;
|
|
48
48
|
/** 点击清除按钮后触发 */
|
|
49
49
|
onClear?: (event: Event) => void;
|
|
50
|
+
/** 点击取消按钮后触发 */
|
|
51
|
+
onCancel?: () => void;
|
|
50
52
|
/** 点击输入区域时触发 */
|
|
51
53
|
onClickInput?: (event: Event) => void;
|
|
52
54
|
/** 点击输入框内左侧图标时触发 */
|
|
@@ -47,6 +47,8 @@ export interface SearchBarProps extends IComponent {
|
|
|
47
47
|
onBlur?: (value: string, event: Event) => void;
|
|
48
48
|
/** 点击清除按钮后触发 */
|
|
49
49
|
onClear?: (event: Event) => void;
|
|
50
|
+
/** 点击取消按钮后触发 */
|
|
51
|
+
onCancel?: () => void;
|
|
50
52
|
/** 点击输入区域时触发 */
|
|
51
53
|
onClickInput?: (event: Event) => void;
|
|
52
54
|
/** 点击输入框内左侧图标时触发 */
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import React, { FunctionComponent } from 'react';
|
|
2
|
+
interface FileType {
|
|
3
|
+
/** jpg 图片 */
|
|
4
|
+
jpg: any;
|
|
5
|
+
/** png 图片 */
|
|
6
|
+
png: any;
|
|
7
|
+
}
|
|
2
8
|
export interface SignatureProps {
|
|
3
|
-
|
|
9
|
+
canvasId: string;
|
|
10
|
+
type: keyof FileType;
|
|
4
11
|
lineWidth: number;
|
|
5
12
|
strokeStyle: string;
|
|
6
13
|
unSupportTpl: string;
|
|
7
14
|
className: string;
|
|
8
|
-
confirm?: (
|
|
15
|
+
confirm?: (dataurl: string) => void;
|
|
9
16
|
clear?: () => void;
|
|
10
17
|
}
|
|
11
18
|
export declare const Signature: FunctionComponent<Partial<SignatureProps> & React.HTMLAttributes<HTMLDivElement>>;
|
|
19
|
+
export {};
|
|
@@ -5,11 +5,8 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
5
5
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
7
|
var _excluded = ["children", "uploadIcon", "uploadIconSize", "name", "defaultFileList", "listType", "disabled", "url", "defaultImg", "headers", "timeout", "method", "xhrState", "data", "isPreview", "isDeletable", "maximum", "maximize", "className", "autoUpload", "sizeType", "sourceType", "onStart", "onRemove", "onChange", "onFileItemClick", "onProgress", "onSuccess", "onUpdate", "onFailure", "onOversize", "onBeforeUpload", "onBeforeXhrUpload", "onBeforeDelete"];
|
|
8
|
-
|
|
9
8
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
|
|
11
9
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
-
|
|
13
10
|
import React__default, { useState, useEffect, useImperativeHandle } from 'react';
|
|
14
11
|
import classNames from 'classnames';
|
|
15
12
|
import { I as Icon } from './icon.taro-1d0d4fb7.js';
|
|
@@ -19,95 +16,64 @@ import Taro from '@tarojs/taro';
|
|
|
19
16
|
import { c as cn } from './bem-893ad28d.js';
|
|
20
17
|
import { u as useConfig } from './configprovider.taro-6c7b3056.js';
|
|
21
18
|
import { C as ComponentDefaults } from './typings-1c5f2628.js';
|
|
22
|
-
|
|
23
19
|
var UploadOptions = /*#__PURE__*/_createClass(function UploadOptions() {
|
|
24
20
|
_classCallCheck(this, UploadOptions);
|
|
25
|
-
|
|
26
21
|
_defineProperty(this, "url", '');
|
|
27
|
-
|
|
28
22
|
_defineProperty(this, "name", 'file');
|
|
29
|
-
|
|
30
23
|
_defineProperty(this, "fileType", 'image');
|
|
31
|
-
|
|
32
24
|
_defineProperty(this, "formData", void 0);
|
|
33
|
-
|
|
34
25
|
_defineProperty(this, "sourceFile", void 0);
|
|
35
|
-
|
|
36
26
|
_defineProperty(this, "method", 'post');
|
|
37
|
-
|
|
38
27
|
_defineProperty(this, "xhrState", 200);
|
|
39
|
-
|
|
40
28
|
_defineProperty(this, "timeout", 30 * 1000);
|
|
41
|
-
|
|
42
29
|
_defineProperty(this, "headers", {});
|
|
43
|
-
|
|
44
30
|
_defineProperty(this, "withCredentials", false);
|
|
45
|
-
|
|
46
31
|
_defineProperty(this, "onStart", void 0);
|
|
47
|
-
|
|
48
32
|
_defineProperty(this, "taroFilePath", void 0);
|
|
49
|
-
|
|
50
33
|
_defineProperty(this, "onProgress", void 0);
|
|
51
|
-
|
|
52
34
|
_defineProperty(this, "onSuccess", void 0);
|
|
53
|
-
|
|
54
35
|
_defineProperty(this, "onFailure", void 0);
|
|
55
|
-
|
|
56
36
|
_defineProperty(this, "beforeXhrUpload", void 0);
|
|
57
37
|
});
|
|
58
|
-
|
|
59
38
|
var Upload = /*#__PURE__*/function () {
|
|
60
39
|
function Upload(options) {
|
|
61
40
|
_classCallCheck(this, Upload);
|
|
62
|
-
|
|
63
41
|
_defineProperty(this, "options", void 0);
|
|
64
|
-
|
|
65
42
|
this.options = options;
|
|
66
43
|
}
|
|
67
|
-
|
|
68
44
|
_createClass(Upload, [{
|
|
69
45
|
key: "upload",
|
|
70
46
|
value: function upload() {
|
|
71
47
|
var options = this.options;
|
|
72
48
|
var xhr = new XMLHttpRequest();
|
|
73
49
|
xhr.timeout = options.timeout;
|
|
74
|
-
|
|
75
50
|
if (xhr.upload) {
|
|
76
51
|
var _options$onStart;
|
|
77
|
-
|
|
78
52
|
xhr.upload.addEventListener('progress', function (e) {
|
|
79
53
|
var _options$onProgress;
|
|
80
|
-
|
|
81
54
|
(_options$onProgress = options.onProgress) === null || _options$onProgress === void 0 ? void 0 : _options$onProgress.call(options, e, options);
|
|
82
55
|
}, false);
|
|
83
|
-
|
|
84
56
|
xhr.onreadystatechange = function () {
|
|
85
57
|
if (xhr.readyState === 4) {
|
|
86
58
|
if (xhr.status === options.xhrState) {
|
|
87
59
|
var _options$onSuccess;
|
|
88
|
-
|
|
89
60
|
(_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, xhr.responseText, options);
|
|
90
61
|
} else {
|
|
91
62
|
var _options$onFailure;
|
|
92
|
-
|
|
93
63
|
(_options$onFailure = options.onFailure) === null || _options$onFailure === void 0 ? void 0 : _options$onFailure.call(options, xhr.responseText, options);
|
|
94
64
|
}
|
|
95
65
|
}
|
|
96
66
|
};
|
|
97
|
-
|
|
98
67
|
xhr.withCredentials = options.withCredentials;
|
|
99
|
-
xhr.open(options.method, options.url, true);
|
|
100
|
-
|
|
68
|
+
xhr.open(options.method, options.url, true);
|
|
69
|
+
// headers
|
|
101
70
|
for (var _i = 0, _Object$entries = Object.entries(options.headers); _i < _Object$entries.length; _i++) {
|
|
102
71
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
72
|
+
key = _Object$entries$_i[0],
|
|
73
|
+
value = _Object$entries$_i[1];
|
|
106
74
|
xhr.setRequestHeader(key, value);
|
|
107
75
|
}
|
|
108
|
-
|
|
109
76
|
(_options$onStart = options.onStart) === null || _options$onStart === void 0 ? void 0 : _options$onStart.call(options, options);
|
|
110
|
-
|
|
111
77
|
if (options.beforeXhrUpload) {
|
|
112
78
|
options.beforeXhrUpload(xhr, options);
|
|
113
79
|
} else {
|
|
@@ -121,14 +87,12 @@ var Upload = /*#__PURE__*/function () {
|
|
|
121
87
|
key: "uploadTaro",
|
|
122
88
|
value: function uploadTaro(uploadFile, env) {
|
|
123
89
|
var options = this.options;
|
|
124
|
-
|
|
125
90
|
if (env === 'WEB') {
|
|
126
91
|
this.upload();
|
|
127
92
|
} else if (options.beforeXhrUpload) {
|
|
128
93
|
options.beforeXhrUpload(uploadFile, options);
|
|
129
94
|
} else {
|
|
130
95
|
var _options$onStart2;
|
|
131
|
-
|
|
132
96
|
var uploadTask = uploadFile({
|
|
133
97
|
url: options.url,
|
|
134
98
|
filePath: options.taroFilePath,
|
|
@@ -141,35 +105,31 @@ var Upload = /*#__PURE__*/function () {
|
|
|
141
105
|
success: function success(response) {
|
|
142
106
|
if (options.xhrState == response.statusCode) {
|
|
143
107
|
var _options$onSuccess2;
|
|
144
|
-
|
|
145
108
|
(_options$onSuccess2 = options.onSuccess) === null || _options$onSuccess2 === void 0 ? void 0 : _options$onSuccess2.call(options, response, options);
|
|
146
109
|
} else {
|
|
147
110
|
var _options$onFailure2;
|
|
148
|
-
|
|
149
111
|
(_options$onFailure2 = options.onFailure) === null || _options$onFailure2 === void 0 ? void 0 : _options$onFailure2.call(options, response, options);
|
|
150
112
|
}
|
|
151
113
|
},
|
|
152
114
|
fail: function fail(e) {
|
|
153
115
|
var _options$onFailure3;
|
|
154
|
-
|
|
155
116
|
(_options$onFailure3 = options.onFailure) === null || _options$onFailure3 === void 0 ? void 0 : _options$onFailure3.call(options, e, options);
|
|
156
117
|
}
|
|
157
118
|
});
|
|
158
119
|
(_options$onStart2 = options.onStart) === null || _options$onStart2 === void 0 ? void 0 : _options$onStart2.call(options, options);
|
|
159
120
|
uploadTask.progress(function (res) {
|
|
160
121
|
var _options$onProgress2;
|
|
161
|
-
|
|
162
|
-
|
|
122
|
+
(_options$onProgress2 = options.onProgress) === null || _options$onProgress2 === void 0 ? void 0 : _options$onProgress2.call(options, res, options);
|
|
123
|
+
// console.log('上传进度', res.progress);
|
|
163
124
|
// console.log('已经上传的数据长度', res.totalBytesSent);
|
|
164
125
|
// console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend);
|
|
165
|
-
});
|
|
126
|
+
});
|
|
127
|
+
// uploadTask.abort(); // 取消上传任务
|
|
166
128
|
}
|
|
167
129
|
}
|
|
168
130
|
}]);
|
|
169
|
-
|
|
170
131
|
return Upload;
|
|
171
132
|
}();
|
|
172
|
-
|
|
173
133
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
174
134
|
url: '',
|
|
175
135
|
maximum: 9,
|
|
@@ -194,80 +154,65 @@ var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
|
194
154
|
return true;
|
|
195
155
|
}
|
|
196
156
|
});
|
|
197
|
-
|
|
198
157
|
var FileItem = /*#__PURE__*/_createClass(function FileItem() {
|
|
199
158
|
_classCallCheck(this, FileItem);
|
|
200
|
-
|
|
201
159
|
_defineProperty(this, "status", 'ready');
|
|
202
|
-
|
|
203
160
|
_defineProperty(this, "message", '准备中..');
|
|
204
|
-
|
|
205
161
|
_defineProperty(this, "uid", new Date().getTime().toString());
|
|
206
|
-
|
|
207
162
|
_defineProperty(this, "name", void 0);
|
|
208
|
-
|
|
209
163
|
_defineProperty(this, "url", void 0);
|
|
210
|
-
|
|
211
164
|
_defineProperty(this, "type", void 0);
|
|
212
|
-
|
|
213
165
|
_defineProperty(this, "path", void 0);
|
|
214
|
-
|
|
215
166
|
_defineProperty(this, "percentage", 0);
|
|
216
|
-
|
|
217
167
|
_defineProperty(this, "formData", {});
|
|
218
168
|
});
|
|
219
|
-
|
|
220
169
|
var InternalUploader = function InternalUploader(props, ref) {
|
|
221
170
|
var _useConfig = useConfig(),
|
|
222
|
-
|
|
223
|
-
|
|
171
|
+
locale = _useConfig.locale;
|
|
224
172
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
173
|
+
children = _defaultProps$props.children,
|
|
174
|
+
uploadIcon = _defaultProps$props.uploadIcon,
|
|
175
|
+
uploadIconSize = _defaultProps$props.uploadIconSize,
|
|
176
|
+
name = _defaultProps$props.name,
|
|
177
|
+
defaultFileList = _defaultProps$props.defaultFileList,
|
|
178
|
+
listType = _defaultProps$props.listType,
|
|
179
|
+
disabled = _defaultProps$props.disabled,
|
|
180
|
+
url = _defaultProps$props.url,
|
|
181
|
+
defaultImg = _defaultProps$props.defaultImg,
|
|
182
|
+
headers = _defaultProps$props.headers,
|
|
183
|
+
timeout = _defaultProps$props.timeout,
|
|
184
|
+
method = _defaultProps$props.method,
|
|
185
|
+
xhrState = _defaultProps$props.xhrState,
|
|
186
|
+
data = _defaultProps$props.data,
|
|
187
|
+
isPreview = _defaultProps$props.isPreview,
|
|
188
|
+
isDeletable = _defaultProps$props.isDeletable,
|
|
189
|
+
maximum = _defaultProps$props.maximum,
|
|
190
|
+
maximize = _defaultProps$props.maximize,
|
|
191
|
+
className = _defaultProps$props.className,
|
|
192
|
+
autoUpload = _defaultProps$props.autoUpload,
|
|
193
|
+
sizeType = _defaultProps$props.sizeType,
|
|
194
|
+
sourceType = _defaultProps$props.sourceType,
|
|
195
|
+
onStart = _defaultProps$props.onStart,
|
|
196
|
+
onRemove = _defaultProps$props.onRemove,
|
|
197
|
+
onChange = _defaultProps$props.onChange,
|
|
198
|
+
onFileItemClick = _defaultProps$props.onFileItemClick,
|
|
199
|
+
onProgress = _defaultProps$props.onProgress,
|
|
200
|
+
onSuccess = _defaultProps$props.onSuccess,
|
|
201
|
+
onUpdate = _defaultProps$props.onUpdate,
|
|
202
|
+
onFailure = _defaultProps$props.onFailure,
|
|
203
|
+
onOversize = _defaultProps$props.onOversize,
|
|
204
|
+
onBeforeUpload = _defaultProps$props.onBeforeUpload,
|
|
205
|
+
onBeforeXhrUpload = _defaultProps$props.onBeforeXhrUpload,
|
|
206
|
+
onBeforeDelete = _defaultProps$props.onBeforeDelete,
|
|
207
|
+
restProps = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
261
208
|
var _useState = useState([]),
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
209
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
210
|
+
fileList = _useState2[0],
|
|
211
|
+
setFileList = _useState2[1];
|
|
266
212
|
var _useState3 = useState([]),
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
213
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
214
|
+
uploadQueue = _useState4[0],
|
|
215
|
+
setUploadQueue = _useState4[1];
|
|
271
216
|
useEffect(function () {
|
|
272
217
|
if (defaultFileList) {
|
|
273
218
|
setFileList(defaultFileList);
|
|
@@ -286,10 +231,8 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
286
231
|
}
|
|
287
232
|
};
|
|
288
233
|
});
|
|
289
|
-
|
|
290
234
|
var clearUploadQueue = function clearUploadQueue() {
|
|
291
235
|
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
|
|
292
|
-
|
|
293
236
|
if (index > -1) {
|
|
294
237
|
uploadQueue.splice(index, 1);
|
|
295
238
|
setUploadQueue(uploadQueue);
|
|
@@ -297,12 +240,10 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
297
240
|
setUploadQueue([]);
|
|
298
241
|
}
|
|
299
242
|
};
|
|
300
|
-
|
|
301
243
|
var chooseImage = function chooseImage() {
|
|
302
244
|
if (disabled) {
|
|
303
245
|
return;
|
|
304
246
|
}
|
|
305
|
-
|
|
306
247
|
Taro.chooseImage({
|
|
307
248
|
// 选择数量
|
|
308
249
|
count: maximum * 1 - fileList.length,
|
|
@@ -312,7 +253,6 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
312
253
|
success: onChangeFn
|
|
313
254
|
});
|
|
314
255
|
};
|
|
315
|
-
|
|
316
256
|
var executeUpload = function executeUpload(fileItem, index) {
|
|
317
257
|
var uploadOption = new UploadOptions();
|
|
318
258
|
uploadOption.name = name;
|
|
@@ -325,7 +265,6 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
325
265
|
uploadOption.headers = headers;
|
|
326
266
|
uploadOption.taroFilePath = fileItem.path;
|
|
327
267
|
uploadOption.beforeXhrUpload = onBeforeXhrUpload;
|
|
328
|
-
|
|
329
268
|
uploadOption.onStart = function (option) {
|
|
330
269
|
clearUploadQueue(index);
|
|
331
270
|
setFileList(function (fileList) {
|
|
@@ -339,7 +278,6 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
339
278
|
});
|
|
340
279
|
onStart && onStart(option);
|
|
341
280
|
};
|
|
342
|
-
|
|
343
281
|
uploadOption.onProgress = function (e, option) {
|
|
344
282
|
setFileList(function (fileList) {
|
|
345
283
|
fileList.map(function (item) {
|
|
@@ -357,7 +295,6 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
357
295
|
return _toConsumableArray(fileList);
|
|
358
296
|
});
|
|
359
297
|
};
|
|
360
|
-
|
|
361
298
|
uploadOption.onSuccess = function (responseText, option) {
|
|
362
299
|
setFileList(function (fileList) {
|
|
363
300
|
onUpdate && onUpdate(fileList);
|
|
@@ -374,7 +311,6 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
374
311
|
option: option
|
|
375
312
|
});
|
|
376
313
|
};
|
|
377
|
-
|
|
378
314
|
uploadOption.onFailure = function (responseText, option) {
|
|
379
315
|
setFileList(function (fileList) {
|
|
380
316
|
fileList.map(function (item) {
|
|
@@ -390,9 +326,7 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
390
326
|
option: option
|
|
391
327
|
});
|
|
392
328
|
};
|
|
393
|
-
|
|
394
329
|
var task = new Upload(uploadOption);
|
|
395
|
-
|
|
396
330
|
if (props.autoUpload) {
|
|
397
331
|
task.uploadTaro(Taro.uploadFile, Taro.getEnv());
|
|
398
332
|
} else {
|
|
@@ -402,37 +336,29 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
402
336
|
setUploadQueue(uploadQueue);
|
|
403
337
|
}
|
|
404
338
|
};
|
|
405
|
-
|
|
406
339
|
var readFile = function readFile(files) {
|
|
407
340
|
var imgReg = /\.(png|jpeg|jpg|webp|gif)$/i;
|
|
408
341
|
files.forEach(function (file, index) {
|
|
409
342
|
console.log('file', file);
|
|
410
343
|
var fileType = file.type;
|
|
411
344
|
var fileItem = new FileItem();
|
|
412
|
-
|
|
413
345
|
if (!fileType && imgReg.test(file.path)) {
|
|
414
346
|
fileType = 'image';
|
|
415
347
|
}
|
|
416
|
-
|
|
417
348
|
fileItem.path = file.path;
|
|
418
349
|
fileItem.name = file.path;
|
|
419
350
|
fileItem.status = 'ready';
|
|
420
351
|
fileItem.message = locale.uploader.readyUpload;
|
|
421
352
|
fileItem.type = fileType;
|
|
422
|
-
|
|
423
353
|
if (Taro.getEnv() == 'WEB') {
|
|
424
354
|
var _file$originalFileObj, _file$originalFileObj2;
|
|
425
|
-
|
|
426
355
|
var formData = new FormData();
|
|
427
|
-
|
|
428
356
|
for (var _i2 = 0, _Object$entries2 = Object.entries(data); _i2 < _Object$entries2.length; _i2++) {
|
|
429
357
|
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
358
|
+
key = _Object$entries2$_i[0],
|
|
359
|
+
value = _Object$entries2$_i[1];
|
|
433
360
|
formData.append(key, value);
|
|
434
361
|
}
|
|
435
|
-
|
|
436
362
|
formData.append(name, file.originalFileObj);
|
|
437
363
|
fileItem.name = (_file$originalFileObj = file.originalFileObj) === null || _file$originalFileObj === void 0 ? void 0 : _file$originalFileObj.name;
|
|
438
364
|
fileItem.type = (_file$originalFileObj2 = file.originalFileObj) === null || _file$originalFileObj2 === void 0 ? void 0 : _file$originalFileObj2.type;
|
|
@@ -440,17 +366,14 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
440
366
|
} else {
|
|
441
367
|
fileItem.formData = data;
|
|
442
368
|
}
|
|
443
|
-
|
|
444
369
|
if (isPreview) {
|
|
445
370
|
fileItem.url = file.path;
|
|
446
371
|
}
|
|
447
|
-
|
|
448
372
|
fileList.push(fileItem);
|
|
449
373
|
setFileList(_toConsumableArray(fileList));
|
|
450
374
|
executeUpload(fileItem, index);
|
|
451
375
|
});
|
|
452
376
|
};
|
|
453
|
-
|
|
454
377
|
var filterFiles = function filterFiles(files) {
|
|
455
378
|
var maximum = props.maximum * 1;
|
|
456
379
|
var maximize = props.maximize * 1;
|
|
@@ -460,26 +383,19 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
460
383
|
oversizes.push(file);
|
|
461
384
|
return false;
|
|
462
385
|
}
|
|
463
|
-
|
|
464
386
|
return true;
|
|
465
387
|
});
|
|
466
|
-
|
|
467
388
|
if (oversizes.length) {
|
|
468
389
|
onOversize && onOversize(files);
|
|
469
390
|
}
|
|
470
|
-
|
|
471
391
|
var currentFileLength = filterFile.length + fileList.length;
|
|
472
|
-
|
|
473
392
|
if (currentFileLength > maximum) {
|
|
474
393
|
filterFile.splice(filterFile.length - (currentFileLength - maximum));
|
|
475
394
|
}
|
|
476
|
-
|
|
477
395
|
return filterFile;
|
|
478
396
|
};
|
|
479
|
-
|
|
480
397
|
var onDelete = function onDelete(file, index) {
|
|
481
398
|
clearUploadQueue(index);
|
|
482
|
-
|
|
483
399
|
if (onBeforeDelete && onBeforeDelete(file, fileList)) {
|
|
484
400
|
fileList.splice(index, 1);
|
|
485
401
|
onRemove && onRemove(file, fileList);
|
|
@@ -488,32 +404,25 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
488
404
|
console.log(locale.uploader.deleteWord);
|
|
489
405
|
}
|
|
490
406
|
};
|
|
491
|
-
|
|
492
407
|
var onChangeFn = function onChangeFn(res) {
|
|
493
408
|
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
|
|
494
409
|
var tempFiles = res.tempFiles;
|
|
495
|
-
|
|
496
410
|
if (onBeforeUpload) {
|
|
497
411
|
onBeforeUpload(tempFiles).then(function (f) {
|
|
498
412
|
var _files = filterFiles(f);
|
|
499
|
-
|
|
500
413
|
readFile(_files);
|
|
501
414
|
});
|
|
502
415
|
} else {
|
|
503
416
|
var _files = filterFiles(tempFiles);
|
|
504
|
-
|
|
505
417
|
readFile(_files);
|
|
506
418
|
}
|
|
507
|
-
|
|
508
419
|
onChange && onChange({
|
|
509
420
|
fileList: fileList
|
|
510
421
|
});
|
|
511
422
|
};
|
|
512
|
-
|
|
513
423
|
var handleItemClick = function handleItemClick(file) {
|
|
514
424
|
onFileItemClick && onFileItemClick(file);
|
|
515
425
|
};
|
|
516
|
-
|
|
517
426
|
return React__default.createElement("div", _objectSpread({
|
|
518
427
|
className: classes
|
|
519
428
|
}, restProps), children && React__default.createElement("div", {
|
|
@@ -614,7 +523,6 @@ var InternalUploader = function InternalUploader(props, ref) {
|
|
|
614
523
|
onClick: chooseImage
|
|
615
524
|
})));
|
|
616
525
|
};
|
|
617
|
-
|
|
618
526
|
var Uploader = React__default.forwardRef(InternalUploader);
|
|
619
527
|
Uploader.defaultProps = defaultProps;
|
|
620
528
|
Uploader.displayName = 'NutUploader';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
获取元素的大小及其相对于视口的位置,等价于 Element.getBoundingClientRect。
|
|
6
5
|
width 宽度 number
|
|
@@ -10,40 +9,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
10
9
|
right 右侧与视图窗口左上角的距离 number
|
|
11
10
|
bottom 底部与视图窗口左上角的距离 number
|
|
12
11
|
*/
|
|
13
|
-
function isWindow(val) {
|
|
14
|
-
return val === window;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var getRect = function getRect(elementRef) {
|
|
18
|
-
var element = elementRef;
|
|
19
|
-
|
|
20
|
-
if (isWindow(element)) {
|
|
21
|
-
var width = element.innerWidth;
|
|
22
|
-
var height = element.innerHeight;
|
|
23
|
-
return {
|
|
24
|
-
top: 0,
|
|
25
|
-
left: 0,
|
|
26
|
-
right: width,
|
|
27
|
-
bottom: height,
|
|
28
|
-
width: width,
|
|
29
|
-
height: height
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (element && element.getBoundingClientRect) {
|
|
34
|
-
return element.getBoundingClientRect();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
top: 0,
|
|
39
|
-
left: 0,
|
|
40
|
-
right: 0,
|
|
41
|
-
bottom: 0,
|
|
42
|
-
width: 0,
|
|
43
|
-
height: 0
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
12
|
var getRectByTaro = /*#__PURE__*/function () {
|
|
48
13
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(element) {
|
|
49
14
|
var res;
|
|
@@ -53,11 +18,9 @@ var getRectByTaro = /*#__PURE__*/function () {
|
|
|
53
18
|
case 0:
|
|
54
19
|
_context.next = 2;
|
|
55
20
|
return element.getBoundingClientRect();
|
|
56
|
-
|
|
57
21
|
case 2:
|
|
58
22
|
res = _context.sent;
|
|
59
23
|
return _context.abrupt("return", res);
|
|
60
|
-
|
|
61
24
|
case 4:
|
|
62
25
|
case "end":
|
|
63
26
|
return _context.stop();
|
|
@@ -65,10 +28,8 @@ var getRectByTaro = /*#__PURE__*/function () {
|
|
|
65
28
|
}
|
|
66
29
|
}, _callee);
|
|
67
30
|
}));
|
|
68
|
-
|
|
69
31
|
return function getRectByTaro(_x) {
|
|
70
32
|
return _ref.apply(this, arguments);
|
|
71
33
|
};
|
|
72
34
|
}();
|
|
73
|
-
|
|
74
|
-
export { getRect as a, getRectByTaro as g };
|
|
35
|
+
export { getRectByTaro as g };
|