@ballistix.digital/react-components 4.8.0 → 4.8.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.
package/dist/index.js CHANGED
@@ -5726,10 +5726,11 @@ var $079d45c48b1515dd$var$FileInputGroupForm = function(props) {
5726
5726
  var isValid = error === undefined;
5727
5727
  var _e = (0, $iA2ta$react.useState)(false), isDragging = _e[0], setIsDragging = _e[1];
5728
5728
  var handleChangeInput = (0, $iA2ta$react.useCallback)(function(files) {
5729
+ var reader = new FileReader();
5729
5730
  var results = [];
5730
- (0, $iA2ta$lodash.forEach)(files, function(file, index, files) {
5731
- var reader = new FileReader();
5732
- reader === null || reader === void 0 || reader.readAsDataURL(file);
5731
+ var readFile = function(index) {
5732
+ if (index >= files.length) return onChange(results);
5733
+ var file = files[index];
5733
5734
  reader.onload = function() {
5734
5735
  var result = {
5735
5736
  name: file.name,
@@ -5739,11 +5740,12 @@ var $079d45c48b1515dd$var$FileInputGroupForm = function(props) {
5739
5740
  file: file
5740
5741
  };
5741
5742
  // eg. 10 * 1024 * 1024
5742
- if (max && max * 1048576 < result.size) return;
5743
- results.push(result);
5744
- if (index === files.length - 1) onChange(results);
5743
+ if (!max || max * 1048576 > result.size) results.push(result);
5744
+ readFile(index + 1);
5745
5745
  };
5746
- });
5746
+ reader.readAsDataURL(file);
5747
+ };
5748
+ readFile(0);
5747
5749
  }, [
5748
5750
  max,
5749
5751
  onChange