@nutui/nutui-react 2.0.19-beta.1 → 2.0.20-beta.0
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 +25 -0
- package/dist/esm/Button.js +84 -5
- package/dist/esm/Image.js +1 -1
- package/dist/esm/Uploader.js +191 -191
- package/dist/esm/formitem2.js +184 -78
- package/dist/esm/types/src/packages/uploader/demo.taro.d.ts +0 -15
- package/dist/esm/types/src/packages/uploader/file-item.d.ts +19 -0
- package/dist/esm/types/src/packages/uploader/index.d.ts +2 -1
- package/dist/esm/types/src/packages/uploader/index.taro.d.ts +2 -1
- package/dist/esm/types/src/packages/uploader/preview.d.ts +2 -0
- package/dist/esm/types/src/packages/uploader/preview.taro.d.ts +2 -0
- package/dist/esm/types/src/packages/uploader/upload.d.ts +3 -0
- package/dist/esm/types/src/packages/uploader/uploader.d.ts +5 -23
- package/dist/esm/types/src/packages/uploader/uploader.taro.d.ts +10 -26
- 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/tr-TR.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.es.js +281 -300
- package/dist/nutui.react.umd.js +281 -300
- package/dist/style.mjs +1 -1
- package/dist/types/packages/calendar/calendar.d.ts +4 -4
- package/dist/types/packages/uploader/file-item.d.ts +19 -0
- package/dist/types/packages/uploader/index.d.ts +2 -1
- package/dist/types/packages/uploader/preview.d.ts +2 -0
- package/dist/types/packages/uploader/upload.d.ts +3 -0
- package/dist/types/packages/uploader/uploader.d.ts +5 -23
- package/package.json +1 -1
- package/dist/esm/button2.js +0 -87
package/dist/nutui.react.umd.js
CHANGED
|
@@ -9,7 +9,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9
9
|
return value;
|
|
10
10
|
};
|
|
11
11
|
/*!
|
|
12
|
-
* @nutui/nutui-react v2.0.
|
|
12
|
+
* @nutui/nutui-react v2.0.20 Fri Oct 13 2023 14:00:36 GMT+0800 (China Standard Time)
|
|
13
13
|
* (c) 2023 @jdf2e.
|
|
14
14
|
* Released under the MIT License.
|
|
15
15
|
*/
|
|
@@ -3768,7 +3768,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
3768
3768
|
fit: "fill",
|
|
3769
3769
|
position: "center",
|
|
3770
3770
|
alt: "",
|
|
3771
|
-
width: "
|
|
3771
|
+
width: "",
|
|
3772
3772
|
height: "",
|
|
3773
3773
|
error: true,
|
|
3774
3774
|
loading: true,
|
|
@@ -16479,11 +16479,11 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
16479
16479
|
...this.store,
|
|
16480
16480
|
...newStore
|
|
16481
16481
|
};
|
|
16482
|
-
this.fieldEntities.forEach((
|
|
16483
|
-
const { name } =
|
|
16482
|
+
this.fieldEntities.forEach((entity) => {
|
|
16483
|
+
const { name } = entity.props;
|
|
16484
16484
|
Object.keys(newStore).forEach((key) => {
|
|
16485
16485
|
if (key === name) {
|
|
16486
|
-
|
|
16486
|
+
entity.onStoreChange("update");
|
|
16487
16487
|
}
|
|
16488
16488
|
});
|
|
16489
16489
|
});
|
|
@@ -16494,44 +16494,19 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
16494
16494
|
...callback
|
|
16495
16495
|
};
|
|
16496
16496
|
});
|
|
16497
|
-
__publicField(this, "
|
|
16498
|
-
|
|
16497
|
+
__publicField(this, "validateFields", async (nameList) => {
|
|
16498
|
+
var _a2;
|
|
16499
|
+
let filterEntitys = [];
|
|
16500
|
+
const errs = [];
|
|
16499
16501
|
this.errors.length = 0;
|
|
16500
|
-
this.fieldEntities.forEach((entity) => {
|
|
16501
|
-
var _a2;
|
|
16502
|
-
const { name, rules: rules2 = [] } = entity.props;
|
|
16503
|
-
const descriptor = {};
|
|
16504
|
-
if (rules2.length) {
|
|
16505
|
-
if (rules2.length > 1) {
|
|
16506
|
-
descriptor[name] = [];
|
|
16507
|
-
rules2.forEach((v) => {
|
|
16508
|
-
descriptor[name].push(v);
|
|
16509
|
-
});
|
|
16510
|
-
} else {
|
|
16511
|
-
descriptor[name] = rules2[0];
|
|
16512
|
-
}
|
|
16513
|
-
}
|
|
16514
|
-
const validator = new Schema(descriptor);
|
|
16515
|
-
validator.messages();
|
|
16516
|
-
validator.validate({ [name]: (_a2 = this.store) == null ? void 0 : _a2[name] }, (errors) => {
|
|
16517
|
-
if (errors) {
|
|
16518
|
-
err.push(...errors);
|
|
16519
|
-
this.errors[name] = errors;
|
|
16520
|
-
}
|
|
16521
|
-
entity.onStoreChange("validate");
|
|
16522
|
-
});
|
|
16523
|
-
});
|
|
16524
|
-
return err;
|
|
16525
|
-
});
|
|
16526
|
-
__publicField(this, "validateFields", (nameList) => {
|
|
16527
16502
|
if (!nameList || nameList.length === 0) {
|
|
16528
|
-
this.
|
|
16529
|
-
|
|
16503
|
+
filterEntitys = this.fieldEntities;
|
|
16504
|
+
} else {
|
|
16505
|
+
filterEntitys = this.fieldEntities.filter(
|
|
16506
|
+
({ props: { name } }) => nameList.includes(name)
|
|
16507
|
+
);
|
|
16530
16508
|
}
|
|
16531
|
-
|
|
16532
|
-
return nameList.includes(name);
|
|
16533
|
-
}).forEach((entity) => {
|
|
16534
|
-
var _a2;
|
|
16509
|
+
for (const entity of filterEntitys) {
|
|
16535
16510
|
const { name, rules: rules2 = [] } = entity.props;
|
|
16536
16511
|
const descriptor = {};
|
|
16537
16512
|
if (rules2.length) {
|
|
@@ -16545,19 +16520,22 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
16545
16520
|
}
|
|
16546
16521
|
}
|
|
16547
16522
|
const validator = new Schema(descriptor);
|
|
16548
|
-
|
|
16549
|
-
validator.validate({ [name]: (_a2 = this.store) == null ? void 0 : _a2[name] }, (errors) => {
|
|
16523
|
+
try {
|
|
16550
16524
|
this.errors[name] = [];
|
|
16525
|
+
await validator.validate({ [name]: (_a2 = this.store) == null ? void 0 : _a2[name] });
|
|
16526
|
+
} catch ({ errors }) {
|
|
16551
16527
|
if (errors) {
|
|
16528
|
+
errs.push(...errors);
|
|
16552
16529
|
this.errors[name] = errors;
|
|
16553
16530
|
}
|
|
16554
|
-
|
|
16555
|
-
|
|
16556
|
-
}
|
|
16531
|
+
}
|
|
16532
|
+
entity.onStoreChange("validate");
|
|
16533
|
+
}
|
|
16534
|
+
return errs;
|
|
16557
16535
|
});
|
|
16558
|
-
__publicField(this, "submit", () => {
|
|
16536
|
+
__publicField(this, "submit", async () => {
|
|
16559
16537
|
var _a2, _b, _c, _d;
|
|
16560
|
-
const errors = this.
|
|
16538
|
+
const errors = await this.validateFields();
|
|
16561
16539
|
if (errors.length === 0) {
|
|
16562
16540
|
(_b = (_a2 = this.callbacks).onFinish) == null ? void 0 : _b.call(_a2, this.store);
|
|
16563
16541
|
} else if (errors.length > 0) {
|
|
@@ -19004,6 +18982,99 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
19004
18982
|
};
|
|
19005
18983
|
TextArea.defaultProps = defaultProps$H;
|
|
19006
18984
|
TextArea.displayName = "NutTextArea";
|
|
18985
|
+
class UploadOptions {
|
|
18986
|
+
constructor() {
|
|
18987
|
+
__publicField(this, "url", "");
|
|
18988
|
+
__publicField(this, "name", "file");
|
|
18989
|
+
__publicField(this, "fileType", "image");
|
|
18990
|
+
__publicField(this, "formData");
|
|
18991
|
+
__publicField(this, "sourceFile");
|
|
18992
|
+
__publicField(this, "method", "post");
|
|
18993
|
+
__publicField(this, "xhrState", 200);
|
|
18994
|
+
__publicField(this, "timeout", 30 * 1e3);
|
|
18995
|
+
__publicField(this, "headers", {});
|
|
18996
|
+
__publicField(this, "withCredentials", false);
|
|
18997
|
+
__publicField(this, "onStart");
|
|
18998
|
+
__publicField(this, "taroFilePath");
|
|
18999
|
+
__publicField(this, "onProgress");
|
|
19000
|
+
__publicField(this, "onSuccess");
|
|
19001
|
+
__publicField(this, "onFailure");
|
|
19002
|
+
__publicField(this, "beforeXhrUpload");
|
|
19003
|
+
}
|
|
19004
|
+
}
|
|
19005
|
+
const UPLOADING = "uploading";
|
|
19006
|
+
const SUCCESS = "success";
|
|
19007
|
+
const ERROR = "error";
|
|
19008
|
+
class Upload {
|
|
19009
|
+
constructor(options2) {
|
|
19010
|
+
__publicField(this, "options");
|
|
19011
|
+
this.options = options2;
|
|
19012
|
+
}
|
|
19013
|
+
upload() {
|
|
19014
|
+
var _a2;
|
|
19015
|
+
const { options: options2 } = this;
|
|
19016
|
+
const xhr = new XMLHttpRequest();
|
|
19017
|
+
xhr.timeout = options2.timeout;
|
|
19018
|
+
if (xhr.upload) {
|
|
19019
|
+
xhr.upload.addEventListener(
|
|
19020
|
+
"progress",
|
|
19021
|
+
(e) => {
|
|
19022
|
+
var _a3;
|
|
19023
|
+
(_a3 = options2.onProgress) == null ? void 0 : _a3.call(options2, e, options2);
|
|
19024
|
+
},
|
|
19025
|
+
false
|
|
19026
|
+
);
|
|
19027
|
+
xhr.onreadystatechange = () => {
|
|
19028
|
+
var _a3, _b;
|
|
19029
|
+
if (xhr.readyState === 4) {
|
|
19030
|
+
if (xhr.status === options2.xhrState) {
|
|
19031
|
+
(_a3 = options2.onSuccess) == null ? void 0 : _a3.call(options2, xhr.responseText, options2);
|
|
19032
|
+
} else {
|
|
19033
|
+
(_b = options2.onFailure) == null ? void 0 : _b.call(options2, xhr.responseText, options2);
|
|
19034
|
+
}
|
|
19035
|
+
}
|
|
19036
|
+
};
|
|
19037
|
+
xhr.withCredentials = options2.withCredentials;
|
|
19038
|
+
xhr.open(options2.method, options2.url, true);
|
|
19039
|
+
for (const [key, value] of Object.entries(options2.headers)) {
|
|
19040
|
+
xhr.setRequestHeader(key, value);
|
|
19041
|
+
}
|
|
19042
|
+
(_a2 = options2.onStart) == null ? void 0 : _a2.call(options2, options2);
|
|
19043
|
+
if (options2.beforeXhrUpload) {
|
|
19044
|
+
options2.beforeXhrUpload(xhr, options2);
|
|
19045
|
+
} else {
|
|
19046
|
+
xhr.send(options2.formData);
|
|
19047
|
+
}
|
|
19048
|
+
} else {
|
|
19049
|
+
console.warn("浏览器不支持 XMLHttpRequest");
|
|
19050
|
+
}
|
|
19051
|
+
}
|
|
19052
|
+
}
|
|
19053
|
+
const funcInterceptor = (interceptor, {
|
|
19054
|
+
args = [],
|
|
19055
|
+
done,
|
|
19056
|
+
canceled
|
|
19057
|
+
}) => {
|
|
19058
|
+
if (interceptor) {
|
|
19059
|
+
const returnVal = interceptor.apply(null, args);
|
|
19060
|
+
if (isPromise(returnVal)) {
|
|
19061
|
+
returnVal.then((value) => {
|
|
19062
|
+
if (value) {
|
|
19063
|
+
done(value);
|
|
19064
|
+
} else if (canceled) {
|
|
19065
|
+
canceled();
|
|
19066
|
+
}
|
|
19067
|
+
}).catch(() => {
|
|
19068
|
+
});
|
|
19069
|
+
} else if (returnVal) {
|
|
19070
|
+
done();
|
|
19071
|
+
} else if (canceled) {
|
|
19072
|
+
canceled();
|
|
19073
|
+
}
|
|
19074
|
+
} else {
|
|
19075
|
+
done();
|
|
19076
|
+
}
|
|
19077
|
+
};
|
|
19007
19078
|
const defaultProps$G = {
|
|
19008
19079
|
...ComponentDefaults,
|
|
19009
19080
|
percent: 0,
|
|
@@ -19124,96 +19195,105 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
19124
19195
|
};
|
|
19125
19196
|
Progress.defaultProps = defaultProps$G;
|
|
19126
19197
|
Progress.displayName = "NutProgress";
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
|
|
19130
|
-
|
|
19131
|
-
|
|
19132
|
-
|
|
19133
|
-
|
|
19134
|
-
|
|
19135
|
-
|
|
19136
|
-
|
|
19137
|
-
|
|
19138
|
-
|
|
19139
|
-
|
|
19140
|
-
|
|
19141
|
-
|
|
19142
|
-
|
|
19143
|
-
__publicField(this, "onFailure");
|
|
19144
|
-
__publicField(this, "beforeXhrUpload");
|
|
19145
|
-
}
|
|
19146
|
-
}
|
|
19147
|
-
class Upload {
|
|
19148
|
-
constructor(options2) {
|
|
19149
|
-
__publicField(this, "options");
|
|
19150
|
-
this.options = options2;
|
|
19151
|
-
}
|
|
19152
|
-
upload() {
|
|
19198
|
+
const Preview = ({
|
|
19199
|
+
fileList,
|
|
19200
|
+
previewType,
|
|
19201
|
+
deletable,
|
|
19202
|
+
onDeleteItem,
|
|
19203
|
+
handleItemClick,
|
|
19204
|
+
previewUrl,
|
|
19205
|
+
children
|
|
19206
|
+
}) => {
|
|
19207
|
+
const renderIcon = (item) => {
|
|
19208
|
+
if (item.status === ERROR) {
|
|
19209
|
+
return item.failIcon || /* @__PURE__ */ React.createElement(x$9, { color: "#fff" });
|
|
19210
|
+
}
|
|
19211
|
+
return item.loadingIcon || /* @__PURE__ */ React.createElement(k$3, { className: "nut-icon-loading", color: "#fff" });
|
|
19212
|
+
};
|
|
19213
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, fileList.length !== 0 && fileList.map((item, index) => {
|
|
19153
19214
|
var _a2;
|
|
19154
|
-
|
|
19155
|
-
|
|
19156
|
-
|
|
19157
|
-
|
|
19158
|
-
|
|
19159
|
-
|
|
19160
|
-
|
|
19161
|
-
|
|
19162
|
-
|
|
19215
|
+
return /* @__PURE__ */ React.createElement(
|
|
19216
|
+
"div",
|
|
19217
|
+
{
|
|
19218
|
+
className: `nut-uploader__preview ${previewType}`,
|
|
19219
|
+
key: item.uid
|
|
19220
|
+
},
|
|
19221
|
+
previewType === "picture" && deletable && /* @__PURE__ */ React.createElement(
|
|
19222
|
+
x$9,
|
|
19223
|
+
{
|
|
19224
|
+
color: "rgba(0,0,0,0.6)",
|
|
19225
|
+
className: "close",
|
|
19226
|
+
onClick: () => onDeleteItem(item, index)
|
|
19227
|
+
}
|
|
19228
|
+
),
|
|
19229
|
+
previewType === "picture" && !children && /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview-img" }, item.status === "ready" ? /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview__progress" }, /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview__progress__msg" }, item.message)) : item.status !== "success" && /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview__progress" }, renderIcon(item), /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview__progress__msg" }, item.message)), ((_a2 = item.type) == null ? void 0 : _a2.includes("image")) ? /* @__PURE__ */ React.createElement(React.Fragment, null, item.url && /* @__PURE__ */ React.createElement(
|
|
19230
|
+
"img",
|
|
19231
|
+
{
|
|
19232
|
+
className: "nut-uploader__preview-img__c",
|
|
19233
|
+
style: { objectFit: "fill" },
|
|
19234
|
+
src: item.url,
|
|
19235
|
+
alt: "",
|
|
19236
|
+
onClick: () => handleItemClick(item)
|
|
19237
|
+
}
|
|
19238
|
+
)) : /* @__PURE__ */ React.createElement(React.Fragment, null, previewUrl ? /* @__PURE__ */ React.createElement(
|
|
19239
|
+
"img",
|
|
19240
|
+
{
|
|
19241
|
+
className: "nut-uploader__preview-img__c",
|
|
19242
|
+
src: previewUrl,
|
|
19243
|
+
alt: "",
|
|
19244
|
+
onClick: () => handleItemClick(item)
|
|
19245
|
+
}
|
|
19246
|
+
) : /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview-img__file" }, /* @__PURE__ */ React.createElement(
|
|
19247
|
+
"div",
|
|
19248
|
+
{
|
|
19249
|
+
onClick: () => handleItemClick(item),
|
|
19250
|
+
className: "nut-uploader__preview-img__file__name"
|
|
19163
19251
|
},
|
|
19164
|
-
|
|
19165
|
-
|
|
19166
|
-
|
|
19167
|
-
|
|
19168
|
-
|
|
19169
|
-
|
|
19170
|
-
|
|
19171
|
-
|
|
19172
|
-
|
|
19173
|
-
|
|
19252
|
+
/* @__PURE__ */ React.createElement(x$6, { color: "#808080" }),
|
|
19253
|
+
/* @__PURE__ */ React.createElement("span", null, " ", item.name)
|
|
19254
|
+
))), item.status === "success" ? /* @__PURE__ */ React.createElement("div", { className: "tips" }, item.name) : null),
|
|
19255
|
+
previewType === "list" && /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview-list" }, /* @__PURE__ */ React.createElement(
|
|
19256
|
+
"div",
|
|
19257
|
+
{
|
|
19258
|
+
className: `nut-uploader__preview-img__file__name ${item.status}`,
|
|
19259
|
+
onClick: () => handleItemClick(item)
|
|
19260
|
+
},
|
|
19261
|
+
/* @__PURE__ */ React.createElement(x$6, null),
|
|
19262
|
+
/* @__PURE__ */ React.createElement("span", null, " ", item.name)
|
|
19263
|
+
), deletable && /* @__PURE__ */ React.createElement(
|
|
19264
|
+
y$8,
|
|
19265
|
+
{
|
|
19266
|
+
color: "#808080",
|
|
19267
|
+
className: "nut-uploader__preview-img__file__del",
|
|
19268
|
+
onClick: () => onDeleteItem(item, index)
|
|
19174
19269
|
}
|
|
19175
|
-
|
|
19176
|
-
|
|
19177
|
-
|
|
19178
|
-
|
|
19179
|
-
|
|
19180
|
-
|
|
19181
|
-
(_a2 = options2.onStart) == null ? void 0 : _a2.call(options2, options2);
|
|
19182
|
-
if (options2.beforeXhrUpload) {
|
|
19183
|
-
options2.beforeXhrUpload(xhr, options2);
|
|
19184
|
-
} else {
|
|
19185
|
-
xhr.send(options2.formData);
|
|
19186
|
-
}
|
|
19187
|
-
} else {
|
|
19188
|
-
console.warn("浏览器不支持 XMLHttpRequest");
|
|
19189
|
-
}
|
|
19190
|
-
}
|
|
19191
|
-
}
|
|
19192
|
-
const funcInterceptor = (interceptor, {
|
|
19193
|
-
args = [],
|
|
19194
|
-
done,
|
|
19195
|
-
canceled
|
|
19196
|
-
}) => {
|
|
19197
|
-
if (interceptor) {
|
|
19198
|
-
const returnVal = interceptor.apply(null, args);
|
|
19199
|
-
if (isPromise(returnVal)) {
|
|
19200
|
-
returnVal.then((value) => {
|
|
19201
|
-
if (value) {
|
|
19202
|
-
done(value);
|
|
19203
|
-
} else if (canceled) {
|
|
19204
|
-
canceled();
|
|
19270
|
+
), item.status === "uploading" && /* @__PURE__ */ React.createElement(
|
|
19271
|
+
Progress,
|
|
19272
|
+
{
|
|
19273
|
+
percent: item.percentage,
|
|
19274
|
+
color: "linear-gradient(270deg, rgba(18,126,255,1) 0%,rgba(32,147,255,1) 32.815625%,rgba(13,242,204,1) 100%)",
|
|
19275
|
+
showText: false
|
|
19205
19276
|
}
|
|
19206
|
-
|
|
19207
|
-
|
|
19208
|
-
|
|
19209
|
-
done();
|
|
19210
|
-
} else if (canceled) {
|
|
19211
|
-
canceled();
|
|
19212
|
-
}
|
|
19213
|
-
} else {
|
|
19214
|
-
done();
|
|
19215
|
-
}
|
|
19277
|
+
))
|
|
19278
|
+
);
|
|
19279
|
+
}));
|
|
19216
19280
|
};
|
|
19281
|
+
class FileItem {
|
|
19282
|
+
constructor() {
|
|
19283
|
+
__publicField(this, "status", "ready");
|
|
19284
|
+
__publicField(this, "message", "准备中..");
|
|
19285
|
+
__publicField(this, "uid", (/* @__PURE__ */ new Date()).getTime().toString());
|
|
19286
|
+
__publicField(this, "name");
|
|
19287
|
+
__publicField(this, "url");
|
|
19288
|
+
__publicField(this, "type");
|
|
19289
|
+
__publicField(this, "path");
|
|
19290
|
+
__publicField(this, "percentage", 0);
|
|
19291
|
+
__publicField(this, "formData", {});
|
|
19292
|
+
__publicField(this, "responseText");
|
|
19293
|
+
__publicField(this, "loadingIcon");
|
|
19294
|
+
__publicField(this, "failIcon");
|
|
19295
|
+
}
|
|
19296
|
+
}
|
|
19217
19297
|
const defaultProps$F = {
|
|
19218
19298
|
...ComponentDefaults,
|
|
19219
19299
|
url: "",
|
|
@@ -19236,24 +19316,11 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
19236
19316
|
preview: true,
|
|
19237
19317
|
deletable: true,
|
|
19238
19318
|
capture: false,
|
|
19319
|
+
uploadIcon: /* @__PURE__ */ React.createElement(x$3, { width: "20px", height: "20px", color: "#808080" }),
|
|
19239
19320
|
beforeDelete: (file, files) => {
|
|
19240
19321
|
return true;
|
|
19241
19322
|
}
|
|
19242
19323
|
};
|
|
19243
|
-
class FileItem {
|
|
19244
|
-
constructor() {
|
|
19245
|
-
__publicField(this, "status", "ready");
|
|
19246
|
-
__publicField(this, "message", "准备中..");
|
|
19247
|
-
__publicField(this, "uid", (/* @__PURE__ */ new Date()).getTime().toString());
|
|
19248
|
-
__publicField(this, "name");
|
|
19249
|
-
__publicField(this, "url");
|
|
19250
|
-
__publicField(this, "type");
|
|
19251
|
-
__publicField(this, "path");
|
|
19252
|
-
__publicField(this, "percentage", 0);
|
|
19253
|
-
__publicField(this, "formData", new FormData());
|
|
19254
|
-
__publicField(this, "responseText");
|
|
19255
|
-
}
|
|
19256
|
-
}
|
|
19257
19324
|
const InternalUploader = (props, ref) => {
|
|
19258
19325
|
const { locale } = useConfig();
|
|
19259
19326
|
const {
|
|
@@ -19298,13 +19365,15 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
19298
19365
|
beforeDelete,
|
|
19299
19366
|
...restProps
|
|
19300
19367
|
} = { ...defaultProps$F, ...props };
|
|
19301
|
-
const [fileList, setFileList] =
|
|
19302
|
-
|
|
19303
|
-
|
|
19304
|
-
|
|
19305
|
-
|
|
19368
|
+
const [fileList, setFileList] = usePropsValue({
|
|
19369
|
+
value,
|
|
19370
|
+
defaultValue,
|
|
19371
|
+
finalValue: [],
|
|
19372
|
+
onChange: (v) => {
|
|
19373
|
+
onChange == null ? void 0 : onChange(v);
|
|
19306
19374
|
}
|
|
19307
|
-
}
|
|
19375
|
+
});
|
|
19376
|
+
const [uploadQueue, setUploadQueue] = React.useState([]);
|
|
19308
19377
|
const classes = classNames(className, "nut-uploader");
|
|
19309
19378
|
React.useImperativeHandle(ref, () => ({
|
|
19310
19379
|
submit: () => {
|
|
@@ -19330,10 +19399,11 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
19330
19399
|
el.value = "";
|
|
19331
19400
|
};
|
|
19332
19401
|
const executeUpload = (fileItem, index) => {
|
|
19402
|
+
var _a2, _b;
|
|
19333
19403
|
const uploadOption = new UploadOptions();
|
|
19334
19404
|
uploadOption.url = url;
|
|
19335
19405
|
for (const [key, value2] of Object.entries(data)) {
|
|
19336
|
-
fileItem.formData.append(key, value2);
|
|
19406
|
+
(_a2 = fileItem.formData) == null ? void 0 : _a2.append(key, value2);
|
|
19337
19407
|
}
|
|
19338
19408
|
uploadOption.formData = fileItem.formData;
|
|
19339
19409
|
uploadOption.timeout = timeout * 1;
|
|
@@ -19343,73 +19413,67 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
19343
19413
|
uploadOption.withCredentials = withCredentials;
|
|
19344
19414
|
uploadOption.beforeXhrUpload = beforeXhrUpload;
|
|
19345
19415
|
try {
|
|
19346
|
-
uploadOption.sourceFile = fileItem.formData.get(name);
|
|
19416
|
+
uploadOption.sourceFile = (_b = fileItem.formData) == null ? void 0 : _b.get(name);
|
|
19347
19417
|
} catch (error) {
|
|
19348
19418
|
console.warn(error);
|
|
19349
19419
|
}
|
|
19350
19420
|
uploadOption.onStart = (option) => {
|
|
19351
19421
|
clearUploadQueue(index);
|
|
19352
|
-
setFileList(
|
|
19353
|
-
|
|
19422
|
+
setFileList(
|
|
19423
|
+
fileList.map((item) => {
|
|
19354
19424
|
if (item.uid === fileItem.uid) {
|
|
19355
19425
|
item.status = "ready";
|
|
19356
19426
|
item.message = locale.uploader.readyUpload;
|
|
19357
19427
|
}
|
|
19358
19428
|
return item;
|
|
19359
|
-
})
|
|
19360
|
-
|
|
19361
|
-
});
|
|
19429
|
+
})
|
|
19430
|
+
);
|
|
19362
19431
|
onStart && onStart(option);
|
|
19363
19432
|
};
|
|
19364
19433
|
uploadOption.onProgress = (e, option) => {
|
|
19365
|
-
setFileList(
|
|
19366
|
-
|
|
19434
|
+
setFileList(
|
|
19435
|
+
fileList.map((item) => {
|
|
19367
19436
|
if (item.uid === fileItem.uid) {
|
|
19368
|
-
item.status =
|
|
19437
|
+
item.status = UPLOADING;
|
|
19369
19438
|
item.message = locale.uploader.uploading;
|
|
19370
19439
|
item.percentage = (e.loaded / e.total * 100).toFixed(0);
|
|
19371
19440
|
onProgress && onProgress({ e, option, percentage: item.percentage });
|
|
19372
19441
|
}
|
|
19373
19442
|
return item;
|
|
19374
|
-
})
|
|
19375
|
-
|
|
19376
|
-
});
|
|
19443
|
+
})
|
|
19444
|
+
);
|
|
19377
19445
|
};
|
|
19378
19446
|
uploadOption.onSuccess = (responseText, option) => {
|
|
19379
|
-
|
|
19380
|
-
|
|
19381
|
-
|
|
19382
|
-
|
|
19383
|
-
|
|
19384
|
-
|
|
19385
|
-
|
|
19386
|
-
}
|
|
19387
|
-
return item;
|
|
19388
|
-
});
|
|
19389
|
-
return [...fileList2];
|
|
19447
|
+
const list = fileList.map((item) => {
|
|
19448
|
+
if (item.uid === fileItem.uid) {
|
|
19449
|
+
item.status = SUCCESS;
|
|
19450
|
+
item.message = locale.uploader.success;
|
|
19451
|
+
item.responseText = responseText;
|
|
19452
|
+
}
|
|
19453
|
+
return item;
|
|
19390
19454
|
});
|
|
19391
|
-
|
|
19455
|
+
setFileList(list);
|
|
19456
|
+
onUpdate == null ? void 0 : onUpdate(list);
|
|
19457
|
+
onSuccess == null ? void 0 : onSuccess({
|
|
19392
19458
|
responseText,
|
|
19393
19459
|
option,
|
|
19394
|
-
fileList
|
|
19460
|
+
fileList: list
|
|
19395
19461
|
});
|
|
19396
19462
|
};
|
|
19397
19463
|
uploadOption.onFailure = (responseText, option) => {
|
|
19398
|
-
|
|
19399
|
-
|
|
19400
|
-
|
|
19401
|
-
|
|
19402
|
-
|
|
19403
|
-
|
|
19404
|
-
|
|
19405
|
-
return item;
|
|
19406
|
-
});
|
|
19407
|
-
return [...fileList2];
|
|
19464
|
+
const list = fileList.map((item) => {
|
|
19465
|
+
if (item.uid === fileItem.uid) {
|
|
19466
|
+
item.status = ERROR;
|
|
19467
|
+
item.message = locale.uploader.error;
|
|
19468
|
+
item.responseText = responseText;
|
|
19469
|
+
}
|
|
19470
|
+
return item;
|
|
19408
19471
|
});
|
|
19409
|
-
|
|
19472
|
+
setFileList(list);
|
|
19473
|
+
onFailure == null ? void 0 : onFailure({
|
|
19410
19474
|
responseText,
|
|
19411
19475
|
option,
|
|
19412
|
-
fileList
|
|
19476
|
+
fileList: list
|
|
19413
19477
|
});
|
|
19414
19478
|
};
|
|
19415
19479
|
const task = new Upload(uploadOption);
|
|
@@ -19434,11 +19498,7 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
19434
19498
|
fileItem.type = file.type;
|
|
19435
19499
|
fileItem.formData = formData;
|
|
19436
19500
|
fileItem.uid = file.lastModified + fileItem.uid;
|
|
19437
|
-
|
|
19438
|
-
fileItem.message = locale.uploader.readyUpload;
|
|
19439
|
-
} else {
|
|
19440
|
-
fileItem.message = locale.uploader.waitingUpload;
|
|
19441
|
-
}
|
|
19501
|
+
fileItem.message = autoUpload ? locale.uploader.readyUpload : locale.uploader.waitingUpload;
|
|
19442
19502
|
executeUpload(fileItem, index);
|
|
19443
19503
|
if (preview && file.type.includes("image")) {
|
|
19444
19504
|
const reader = new FileReader();
|
|
@@ -19449,8 +19509,7 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
19449
19509
|
};
|
|
19450
19510
|
reader.readAsDataURL(file);
|
|
19451
19511
|
} else {
|
|
19452
|
-
fileList
|
|
19453
|
-
setFileList([...fileList]);
|
|
19512
|
+
setFileList([...fileList, fileItem]);
|
|
19454
19513
|
}
|
|
19455
19514
|
});
|
|
19456
19515
|
};
|
|
@@ -19477,9 +19536,9 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
19477
19536
|
return filterFile;
|
|
19478
19537
|
};
|
|
19479
19538
|
const deleted = (file, index) => {
|
|
19480
|
-
fileList.
|
|
19481
|
-
onDelete
|
|
19482
|
-
setFileList(
|
|
19539
|
+
const deletedFileList = fileList.filter((file2, idx) => idx !== index);
|
|
19540
|
+
onDelete == null ? void 0 : onDelete(file, deletedFileList);
|
|
19541
|
+
setFileList(deletedFileList);
|
|
19483
19542
|
};
|
|
19484
19543
|
const onDeleteItem = (file, index) => {
|
|
19485
19544
|
clearUploadQueue(index);
|
|
@@ -19505,131 +19564,53 @@ Please add \`${key}Action\` when creating your handler.`);
|
|
|
19505
19564
|
const _files = filterFiles(new Array().slice.call(files));
|
|
19506
19565
|
readFile(_files);
|
|
19507
19566
|
}
|
|
19508
|
-
|
|
19567
|
+
setFileList(fileList);
|
|
19509
19568
|
if (clearInput) {
|
|
19510
19569
|
clearInputValue($el);
|
|
19511
19570
|
}
|
|
19512
19571
|
};
|
|
19513
19572
|
const handleItemClick = (file) => {
|
|
19514
|
-
onFileItemClick
|
|
19573
|
+
onFileItemClick == null ? void 0 : onFileItemClick(file);
|
|
19515
19574
|
};
|
|
19516
|
-
return /* @__PURE__ */ React.createElement("div", { className: classes, ...restProps }, (children || previewType === "list") && /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__slot" },
|
|
19575
|
+
return /* @__PURE__ */ React.createElement("div", { className: classes, ...restProps }, (children || previewType === "list") && /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__slot" }, children || /* @__PURE__ */ React.createElement(Button, { size: "small", type: "primary" }, "上传文件"), maxCount > fileList.length && /* @__PURE__ */ React.createElement(
|
|
19517
19576
|
"input",
|
|
19518
19577
|
{
|
|
19519
19578
|
className: "nut-uploader__input",
|
|
19520
19579
|
type: "file",
|
|
19521
|
-
capture
|
|
19580
|
+
capture,
|
|
19522
19581
|
name,
|
|
19523
19582
|
accept,
|
|
19524
19583
|
disabled,
|
|
19525
19584
|
multiple,
|
|
19526
19585
|
onChange: fileChange
|
|
19527
19586
|
}
|
|
19528
|
-
)
|
|
19529
|
-
|
|
19587
|
+
)), /* @__PURE__ */ React.createElement(
|
|
19588
|
+
Preview,
|
|
19530
19589
|
{
|
|
19531
|
-
|
|
19532
|
-
|
|
19533
|
-
|
|
19534
|
-
|
|
19535
|
-
|
|
19536
|
-
|
|
19537
|
-
|
|
19590
|
+
...{
|
|
19591
|
+
fileList,
|
|
19592
|
+
previewType,
|
|
19593
|
+
deletable,
|
|
19594
|
+
onDeleteItem,
|
|
19595
|
+
handleItemClick,
|
|
19596
|
+
previewUrl,
|
|
19597
|
+
children
|
|
19598
|
+
}
|
|
19538
19599
|
}
|
|
19539
|
-
)
|
|
19540
|
-
return /* @__PURE__ */ React.createElement(
|
|
19541
|
-
"div",
|
|
19542
|
-
{
|
|
19543
|
-
className: `nut-uploader__preview ${previewType}`,
|
|
19544
|
-
key: item.uid
|
|
19545
|
-
},
|
|
19546
|
-
previewType === "picture" && deletable && /* @__PURE__ */ React.createElement(
|
|
19547
|
-
x$9,
|
|
19548
|
-
{
|
|
19549
|
-
color: "rgba(0,0,0,0.6)",
|
|
19550
|
-
className: "close",
|
|
19551
|
-
onClick: () => onDeleteItem(item, index)
|
|
19552
|
-
}
|
|
19553
|
-
),
|
|
19554
|
-
previewType === "picture" && !children && /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview-img" }, item.status === "ready" ? /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview__progress" }, /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview__progress__msg" }, item.message)) : item.status !== "success" && /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview__progress" }, item.failIcon !== " " && item.loadingIcon !== " " && (item.status === "error" ? item.failIcon || /* @__PURE__ */ React.createElement(x$9, { color: "#fff" }) : item.loadingIcon || /* @__PURE__ */ React.createElement(
|
|
19555
|
-
k$3,
|
|
19556
|
-
{
|
|
19557
|
-
className: "nut-icon-loading",
|
|
19558
|
-
color: "#fff"
|
|
19559
|
-
}
|
|
19560
|
-
)), /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview__progress__msg" }, item.message)), item.type.includes("image") ? /* @__PURE__ */ React.createElement(React.Fragment, null, item.url && /* @__PURE__ */ React.createElement(
|
|
19561
|
-
"img",
|
|
19562
|
-
{
|
|
19563
|
-
className: "nut-uploader__preview-img__c",
|
|
19564
|
-
style: { objectFit: fit },
|
|
19565
|
-
src: item.url,
|
|
19566
|
-
alt: "",
|
|
19567
|
-
onClick: () => handleItemClick(item)
|
|
19568
|
-
}
|
|
19569
|
-
)) : /* @__PURE__ */ React.createElement(React.Fragment, null, previewUrl ? /* @__PURE__ */ React.createElement(
|
|
19570
|
-
"img",
|
|
19571
|
-
{
|
|
19572
|
-
className: "nut-uploader__preview-img__c",
|
|
19573
|
-
src: previewUrl,
|
|
19574
|
-
alt: "",
|
|
19575
|
-
onClick: () => handleItemClick(item)
|
|
19576
|
-
}
|
|
19577
|
-
) : /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview-img__file" }, /* @__PURE__ */ React.createElement(
|
|
19578
|
-
"div",
|
|
19579
|
-
{
|
|
19580
|
-
onClick: () => handleItemClick(item),
|
|
19581
|
-
className: "nut-uploader__preview-img__file__name"
|
|
19582
|
-
},
|
|
19583
|
-
/* @__PURE__ */ React.createElement(x$6, { color: "#808080" }),
|
|
19584
|
-
/* @__PURE__ */ React.createElement("span", null, " ", item.name)
|
|
19585
|
-
))), item.status === "success" ? /* @__PURE__ */ React.createElement("div", { className: "tips" }, item.name) : null),
|
|
19586
|
-
previewType === "list" && /* @__PURE__ */ React.createElement("div", { className: "nut-uploader__preview-list" }, /* @__PURE__ */ React.createElement(
|
|
19587
|
-
"div",
|
|
19588
|
-
{
|
|
19589
|
-
className: `nut-uploader__preview-img__file__name ${item.status}`,
|
|
19590
|
-
onClick: () => handleItemClick(item)
|
|
19591
|
-
},
|
|
19592
|
-
/* @__PURE__ */ React.createElement(x$6, null),
|
|
19593
|
-
/* @__PURE__ */ React.createElement("span", null, " ", item.name)
|
|
19594
|
-
), deletable && /* @__PURE__ */ React.createElement(
|
|
19595
|
-
y$8,
|
|
19596
|
-
{
|
|
19597
|
-
color: "#808080",
|
|
19598
|
-
className: "nut-uploader__preview-img__file__del",
|
|
19599
|
-
onClick: () => onDeleteItem(item, index)
|
|
19600
|
-
}
|
|
19601
|
-
), item.status === "uploading" && /* @__PURE__ */ React.createElement(
|
|
19602
|
-
Progress,
|
|
19603
|
-
{
|
|
19604
|
-
percent: item.percentage,
|
|
19605
|
-
color: "linear-gradient(270deg, rgba(18,126,255,1) 0%,rgba(32,147,255,1) 32.815625%,rgba(13,242,204,1) 100%)",
|
|
19606
|
-
showText: false
|
|
19607
|
-
}
|
|
19608
|
-
))
|
|
19609
|
-
);
|
|
19610
|
-
}), maxCount > fileList.length && previewType === "picture" && !children && /* @__PURE__ */ React.createElement(
|
|
19600
|
+
), maxCount > fileList.length && previewType === "picture" && !children && /* @__PURE__ */ React.createElement(
|
|
19611
19601
|
"div",
|
|
19612
19602
|
{
|
|
19613
|
-
className:
|
|
19603
|
+
className: classNames("nut-uploader__upload", previewType, {
|
|
19604
|
+
"nut-uploader__upload-disabled": disabled
|
|
19605
|
+
})
|
|
19614
19606
|
},
|
|
19615
|
-
/* @__PURE__ */ React.createElement("div", { className: "nut-uploader__icon" }, uploadIcon
|
|
19616
|
-
|
|
19617
|
-
"input",
|
|
19618
|
-
{
|
|
19619
|
-
className: "nut-uploader__input",
|
|
19620
|
-
type: "file",
|
|
19621
|
-
capture: "user",
|
|
19622
|
-
name,
|
|
19623
|
-
accept,
|
|
19624
|
-
disabled,
|
|
19625
|
-
multiple,
|
|
19626
|
-
onChange: fileChange
|
|
19627
|
-
}
|
|
19628
|
-
) : /* @__PURE__ */ React.createElement(
|
|
19607
|
+
/* @__PURE__ */ React.createElement("div", { className: "nut-uploader__icon" }, uploadIcon, /* @__PURE__ */ React.createElement("span", { className: "nut-uploader__icon-tip" }, uploadLabel)),
|
|
19608
|
+
/* @__PURE__ */ React.createElement(
|
|
19629
19609
|
"input",
|
|
19630
19610
|
{
|
|
19631
19611
|
className: "nut-uploader__input",
|
|
19632
19612
|
type: "file",
|
|
19613
|
+
capture,
|
|
19633
19614
|
name,
|
|
19634
19615
|
accept,
|
|
19635
19616
|
disabled,
|