util-helpers 5.1.0 → 5.1.1

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.
@@ -34,6 +34,7 @@
34
34
  var symbolTag = '[object Symbol]';
35
35
  var functionTags = ['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy'].map(function (item) { return '[object ' + item + ']'; });
36
36
  var blobTag = '[object Blob]';
37
+ var fileTag = '[object File]';
37
38
  var objectTag = '[object Object]';
38
39
 
39
40
  function isArray(value) {
@@ -215,6 +216,14 @@
215
216
  return typeof Ctor === 'function' && Ctor instanceof Ctor && functionProtoToString.call(Ctor) === objectCtorString;
216
217
  }
217
218
 
219
+ var fileExisted = typeof File !== stringUndefined;
220
+ function isFile(value) {
221
+ if (fileExisted && value instanceof File) {
222
+ return true;
223
+ }
224
+ return getTag(value) === fileTag;
225
+ }
226
+
218
227
  var freeGlobalThis = globalThisExisted && globalThis.Object === Object && globalThis;
219
228
  var freeGlobal = globalExisted && global.Object === Object && global;
220
229
  var freeSelf = selfExisted && self.Object === Object && self;
@@ -1471,8 +1480,15 @@
1471
1480
  function testExt(name, ext) {
1472
1481
  return !!name && name.slice(-ext.length) === ext;
1473
1482
  }
1483
+ function isUploadFile(fileObj) {
1484
+ if (isObjectLike(fileObj) && isString(fileObj.uid) && isString(fileObj.name)) {
1485
+ return true;
1486
+ }
1487
+ return false;
1488
+ }
1489
+
1474
1490
  function checkFileType(file, accept) {
1475
- if (!isBlob(file)) {
1491
+ if (!isFile(file) && !isUploadFile(file)) {
1476
1492
  return false;
1477
1493
  }
1478
1494
  if (!isString(accept)) {
@@ -1485,9 +1501,10 @@
1485
1501
  var ret = false;
1486
1502
  var types = accept.toLowerCase().split(/,(?:\s+)?/);
1487
1503
  var fileName = file.name.toLowerCase();
1488
- var fileType = file.type;
1504
+ var fileType = file.type || '';
1505
+ var fileUrl = file.url || '';
1489
1506
  types.some(function (type) {
1490
- if (fileType === type || (type.indexOf('.') === 0 && testExt(fileName, type))) {
1507
+ if (type === '*' || fileType === type || (type.indexOf('.') === 0 && (testExt(fileName, type) || testExt(fileUrl, type)))) {
1491
1508
  ret = true;
1492
1509
  }
1493
1510
  else if (type.includes('/*') && fileType.includes('/')) {
@@ -1717,7 +1734,7 @@
1717
1734
  };
1718
1735
  function getFileType(file) {
1719
1736
  var type;
1720
- if (isBlob(file)) {
1737
+ if (isBlob(file) || isUploadFile(file)) {
1721
1738
  forEach(config, function (accept, fileType) {
1722
1739
  if (checkFileType(file, accept)) {
1723
1740
  type = fileType;
@@ -2060,7 +2077,7 @@
2060
2077
  return internalFindTreeSelect(tree, predicate, childrenField);
2061
2078
  }
2062
2079
 
2063
- var VERSION = "5.1.0";
2080
+ var VERSION = "5.1.1";
2064
2081
 
2065
2082
  var EmitterPro = /** @class */ (function () {
2066
2083
  function EmitterPro() {