xrk-components 0.5.2 → 0.5.4
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/lib/index.esm.js +18 -16
- package/lib/index.umd.js +18 -16
- package/package.json +1 -1
package/lib/index.esm.js
CHANGED
|
@@ -46503,7 +46503,7 @@ var script$4 = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__$4
|
|
|
46503
46503
|
((_a = activeFile.response) === null || _a === void 0 ? void 0 : _a.fileUrl) ||
|
|
46504
46504
|
(activeFile.raw ? window.URL.createObjectURL(activeFile.raw) : ''));
|
|
46505
46505
|
};
|
|
46506
|
-
var checkFile = function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
46506
|
+
var checkFile = function (file, nowFileLength, noEmit) { return __awaiter(_this, void 0, void 0, function () {
|
|
46507
46507
|
var limit, limitSize, beforeSelected, fileType, fileNameType, allFileType, error_1;
|
|
46508
46508
|
return __generator(this, function (_a) {
|
|
46509
46509
|
switch (_a.label) {
|
|
@@ -46516,19 +46516,20 @@ var script$4 = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__$4
|
|
|
46516
46516
|
if (!fileNameType ||
|
|
46517
46517
|
(accept.value.indexOf(allFileType) == -1 &&
|
|
46518
46518
|
accept.value.indexOf(fileNameType) == -1)) {
|
|
46519
|
-
|
|
46520
|
-
|
|
46521
|
-
|
|
46522
|
-
|
|
46519
|
+
!noEmit &&
|
|
46520
|
+
emits('error', {
|
|
46521
|
+
code: 503,
|
|
46522
|
+
msg: "\u4E0D\u652F\u6301\u4E0A\u4F20".concat(fileNameType || '此类', "\u7C7B\u578B\u6587\u4EF6")
|
|
46523
|
+
});
|
|
46523
46524
|
return [2 /*return*/, Promise.reject('file type error')];
|
|
46524
46525
|
}
|
|
46525
46526
|
}
|
|
46526
|
-
if (limit &&
|
|
46527
|
-
emits('error', { code: 502, msg: "\u6700\u591A\u9009\u62E9".concat(limit, "\u4E2A\u6587\u4EF6") });
|
|
46527
|
+
if (limit && nowFileLength >= limit) {
|
|
46528
|
+
!noEmit && emits('error', { code: 502, msg: "\u6700\u591A\u9009\u62E9".concat(limit, "\u4E2A\u6587\u4EF6") });
|
|
46528
46529
|
return [2 /*return*/, Promise.reject('count limit exceeded')];
|
|
46529
46530
|
}
|
|
46530
46531
|
if (limitSize && file.size > limitSize * 1024 * 1024) {
|
|
46531
|
-
emits('error', { code: 501, msg: "\u5355\u4E2A\u6587\u4EF6\u6700\u5927".concat(limitSize, "M") });
|
|
46532
|
+
!noEmit && emits('error', { code: 501, msg: "\u5355\u4E2A\u6587\u4EF6\u6700\u5927".concat(limitSize, "M") });
|
|
46532
46533
|
return [2 /*return*/, Promise.reject('size limit exceeded')];
|
|
46533
46534
|
}
|
|
46534
46535
|
if (!beforeSelected) return [3 /*break*/, 4];
|
|
@@ -46559,7 +46560,7 @@ var script$4 = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__$4
|
|
|
46559
46560
|
_a.label = 1;
|
|
46560
46561
|
case 1:
|
|
46561
46562
|
_a.trys.push([1, 3, , 4]);
|
|
46562
|
-
return [4 /*yield*/, checkFile(rawFile)];
|
|
46563
|
+
return [4 /*yield*/, checkFile(rawFile, fileList.value.length, true)];
|
|
46563
46564
|
case 2:
|
|
46564
46565
|
_a.sent();
|
|
46565
46566
|
return [3 /*break*/, 4];
|
|
@@ -46593,28 +46594,29 @@ var script$4 = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__$4
|
|
|
46593
46594
|
}
|
|
46594
46595
|
});
|
|
46595
46596
|
}); };
|
|
46596
|
-
var handleChange = function (activeFile) { return __awaiter(_this, void 0, void 0, function () {
|
|
46597
|
+
var handleChange = function (activeFile, allFiles) { return __awaiter(_this, void 0, void 0, function () {
|
|
46597
46598
|
var _allFiles, error_4;
|
|
46598
46599
|
return __generator(this, function (_a) {
|
|
46599
46600
|
switch (_a.label) {
|
|
46600
46601
|
case 0:
|
|
46601
|
-
_allFiles = __spreadArray([], __read(
|
|
46602
|
-
if (!(activeFile.raw &&
|
|
46603
|
-
!props.autoUpload &&
|
|
46604
|
-
_allFiles.findIndex(function (i) { return i.raw === activeFile.raw; }) == -1)) return [3 /*break*/, 4];
|
|
46602
|
+
_allFiles = __spreadArray([], __read(allFiles), false);
|
|
46603
|
+
if (!(activeFile.raw && activeFile.status === 'ready')) return [3 /*break*/, 4];
|
|
46605
46604
|
_a.label = 1;
|
|
46606
46605
|
case 1:
|
|
46607
46606
|
_a.trys.push([1, 3, , 4]);
|
|
46608
|
-
return [4 /*yield*/, checkFile(activeFile.raw)];
|
|
46607
|
+
return [4 /*yield*/, checkFile(activeFile.raw, fileList.value.length)];
|
|
46609
46608
|
case 2:
|
|
46610
46609
|
_a.sent();
|
|
46611
|
-
_allFiles.push(activeFile);
|
|
46612
46610
|
return [3 /*break*/, 4];
|
|
46613
46611
|
case 3:
|
|
46614
46612
|
error_4 = _a.sent();
|
|
46613
|
+
activeFile.status = 'fail';
|
|
46615
46614
|
console.error(error_4);
|
|
46616
46615
|
return [3 /*break*/, 4];
|
|
46617
46616
|
case 4:
|
|
46617
|
+
_allFiles = _allFiles
|
|
46618
|
+
.filter(function (i) { return i.status !== 'fail'; })
|
|
46619
|
+
.slice(0, props.limit || _allFiles.length);
|
|
46618
46620
|
changeFileList(_allFiles);
|
|
46619
46621
|
emits('change', activeFile, _allFiles);
|
|
46620
46622
|
return [2 /*return*/];
|
package/lib/index.umd.js
CHANGED
|
@@ -46506,7 +46506,7 @@ usage: app.provide(ID_INJECTION_KEY, {
|
|
|
46506
46506
|
((_a = activeFile.response) === null || _a === void 0 ? void 0 : _a.fileUrl) ||
|
|
46507
46507
|
(activeFile.raw ? window.URL.createObjectURL(activeFile.raw) : ''));
|
|
46508
46508
|
};
|
|
46509
|
-
var checkFile = function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
46509
|
+
var checkFile = function (file, nowFileLength, noEmit) { return __awaiter(_this, void 0, void 0, function () {
|
|
46510
46510
|
var limit, limitSize, beforeSelected, fileType, fileNameType, allFileType, error_1;
|
|
46511
46511
|
return __generator(this, function (_a) {
|
|
46512
46512
|
switch (_a.label) {
|
|
@@ -46519,19 +46519,20 @@ usage: app.provide(ID_INJECTION_KEY, {
|
|
|
46519
46519
|
if (!fileNameType ||
|
|
46520
46520
|
(accept.value.indexOf(allFileType) == -1 &&
|
|
46521
46521
|
accept.value.indexOf(fileNameType) == -1)) {
|
|
46522
|
-
|
|
46523
|
-
|
|
46524
|
-
|
|
46525
|
-
|
|
46522
|
+
!noEmit &&
|
|
46523
|
+
emits('error', {
|
|
46524
|
+
code: 503,
|
|
46525
|
+
msg: "\u4E0D\u652F\u6301\u4E0A\u4F20".concat(fileNameType || '此类', "\u7C7B\u578B\u6587\u4EF6")
|
|
46526
|
+
});
|
|
46526
46527
|
return [2 /*return*/, Promise.reject('file type error')];
|
|
46527
46528
|
}
|
|
46528
46529
|
}
|
|
46529
|
-
if (limit &&
|
|
46530
|
-
emits('error', { code: 502, msg: "\u6700\u591A\u9009\u62E9".concat(limit, "\u4E2A\u6587\u4EF6") });
|
|
46530
|
+
if (limit && nowFileLength >= limit) {
|
|
46531
|
+
!noEmit && emits('error', { code: 502, msg: "\u6700\u591A\u9009\u62E9".concat(limit, "\u4E2A\u6587\u4EF6") });
|
|
46531
46532
|
return [2 /*return*/, Promise.reject('count limit exceeded')];
|
|
46532
46533
|
}
|
|
46533
46534
|
if (limitSize && file.size > limitSize * 1024 * 1024) {
|
|
46534
|
-
emits('error', { code: 501, msg: "\u5355\u4E2A\u6587\u4EF6\u6700\u5927".concat(limitSize, "M") });
|
|
46535
|
+
!noEmit && emits('error', { code: 501, msg: "\u5355\u4E2A\u6587\u4EF6\u6700\u5927".concat(limitSize, "M") });
|
|
46535
46536
|
return [2 /*return*/, Promise.reject('size limit exceeded')];
|
|
46536
46537
|
}
|
|
46537
46538
|
if (!beforeSelected) return [3 /*break*/, 4];
|
|
@@ -46562,7 +46563,7 @@ usage: app.provide(ID_INJECTION_KEY, {
|
|
|
46562
46563
|
_a.label = 1;
|
|
46563
46564
|
case 1:
|
|
46564
46565
|
_a.trys.push([1, 3, , 4]);
|
|
46565
|
-
return [4 /*yield*/, checkFile(rawFile)];
|
|
46566
|
+
return [4 /*yield*/, checkFile(rawFile, fileList.value.length, true)];
|
|
46566
46567
|
case 2:
|
|
46567
46568
|
_a.sent();
|
|
46568
46569
|
return [3 /*break*/, 4];
|
|
@@ -46596,28 +46597,29 @@ usage: app.provide(ID_INJECTION_KEY, {
|
|
|
46596
46597
|
}
|
|
46597
46598
|
});
|
|
46598
46599
|
}); };
|
|
46599
|
-
var handleChange = function (activeFile) { return __awaiter(_this, void 0, void 0, function () {
|
|
46600
|
+
var handleChange = function (activeFile, allFiles) { return __awaiter(_this, void 0, void 0, function () {
|
|
46600
46601
|
var _allFiles, error_4;
|
|
46601
46602
|
return __generator(this, function (_a) {
|
|
46602
46603
|
switch (_a.label) {
|
|
46603
46604
|
case 0:
|
|
46604
|
-
_allFiles = __spreadArray([], __read(
|
|
46605
|
-
if (!(activeFile.raw &&
|
|
46606
|
-
!props.autoUpload &&
|
|
46607
|
-
_allFiles.findIndex(function (i) { return i.raw === activeFile.raw; }) == -1)) return [3 /*break*/, 4];
|
|
46605
|
+
_allFiles = __spreadArray([], __read(allFiles), false);
|
|
46606
|
+
if (!(activeFile.raw && activeFile.status === 'ready')) return [3 /*break*/, 4];
|
|
46608
46607
|
_a.label = 1;
|
|
46609
46608
|
case 1:
|
|
46610
46609
|
_a.trys.push([1, 3, , 4]);
|
|
46611
|
-
return [4 /*yield*/, checkFile(activeFile.raw)];
|
|
46610
|
+
return [4 /*yield*/, checkFile(activeFile.raw, fileList.value.length)];
|
|
46612
46611
|
case 2:
|
|
46613
46612
|
_a.sent();
|
|
46614
|
-
_allFiles.push(activeFile);
|
|
46615
46613
|
return [3 /*break*/, 4];
|
|
46616
46614
|
case 3:
|
|
46617
46615
|
error_4 = _a.sent();
|
|
46616
|
+
activeFile.status = 'fail';
|
|
46618
46617
|
console.error(error_4);
|
|
46619
46618
|
return [3 /*break*/, 4];
|
|
46620
46619
|
case 4:
|
|
46620
|
+
_allFiles = _allFiles
|
|
46621
|
+
.filter(function (i) { return i.status !== 'fail'; })
|
|
46622
|
+
.slice(0, props.limit || _allFiles.length);
|
|
46621
46623
|
changeFileList(_allFiles);
|
|
46622
46624
|
emits('change', activeFile, _allFiles);
|
|
46623
46625
|
return [2 /*return*/];
|