@ballistix.digital/react-components 0.8.3 → 0.9.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/dist/index.d.ts +3 -2
- package/dist/index.esm.js +28 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +28 -22
- package/dist/index.js.map +1 -1
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4726,34 +4726,40 @@ function reducer(state, action) {
|
|
|
4726
4726
|
function noop() {}
|
|
4727
4727
|
|
|
4728
4728
|
var FileInputGroupForm = function (props) {
|
|
4729
|
-
var _a = props.name, name = _a === void 0 ? 'multiple-file-input' : _a, label = props.label, description = props.description, required = props.required, value = props.value, max = props.max, error = props.error, isDisabled = props.isDisabled, _b = props.isRequired, isRequired = _b === void 0 ? false : _b, _c = props.isTouched, isTouched = _c === void 0 ? false : _c, children = props.children, onChange = props.onChange, onBlur = props.onBlur, stylesOverrides = props.styles;
|
|
4729
|
+
var _a = props.name, name = _a === void 0 ? 'multiple-file-input' : _a, label = props.label, description = props.description, required = props.required, value = props.value, max = props.max, error = props.error, isDisabled = props.isDisabled, _b = props.isRequired, isRequired = _b === void 0 ? false : _b, _c = props.isTouched, isTouched = _c === void 0 ? false : _c, _d = props.isMulti, isMulti = _d === void 0 ? false : _d, children = props.children, onChange = props.onChange, onBlur = props.onBlur, stylesOverrides = props.styles;
|
|
4730
4730
|
var isValid = error === undefined;
|
|
4731
|
-
var
|
|
4732
|
-
var handleChangeInput = React.useCallback(function (
|
|
4733
|
-
var
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4731
|
+
var _e = React.useState(false), isDragging = _e[0], setIsDragging = _e[1];
|
|
4732
|
+
var handleChangeInput = React.useCallback(function (files) {
|
|
4733
|
+
var results = [];
|
|
4734
|
+
lodash.forEach(files, function (file, index, files) {
|
|
4735
|
+
var reader = new FileReader();
|
|
4736
|
+
reader === null || reader === void 0 ? void 0 : reader.readAsDataURL(file);
|
|
4737
|
+
reader.onload = function () {
|
|
4738
|
+
var result = {
|
|
4739
|
+
name: file.name,
|
|
4740
|
+
size: file.size,
|
|
4741
|
+
type: file.type,
|
|
4742
|
+
blob: reader === null || reader === void 0 ? void 0 : reader.result,
|
|
4743
|
+
file: file,
|
|
4744
|
+
};
|
|
4745
|
+
// eg. 10 * 1024 * 1024
|
|
4746
|
+
if (max && max * 1024 * 1024 < result.size) {
|
|
4747
|
+
return;
|
|
4748
|
+
}
|
|
4749
|
+
results.push(result);
|
|
4750
|
+
if (index === files.length - 1) {
|
|
4751
|
+
onChange(results);
|
|
4752
|
+
}
|
|
4742
4753
|
};
|
|
4743
|
-
|
|
4744
|
-
if (max && max * 1024 * 1024 < result.size) {
|
|
4745
|
-
return;
|
|
4746
|
-
}
|
|
4747
|
-
onChange(result);
|
|
4748
|
-
};
|
|
4754
|
+
});
|
|
4749
4755
|
}, [max, onChange]);
|
|
4750
4756
|
var onDrop = React.useCallback(function (files) {
|
|
4751
4757
|
setIsDragging(false);
|
|
4752
|
-
handleChangeInput(files
|
|
4758
|
+
handleChangeInput(files);
|
|
4753
4759
|
}, [handleChangeInput]);
|
|
4754
|
-
var
|
|
4760
|
+
var _f = useDropzone({
|
|
4755
4761
|
onDrop: onDrop,
|
|
4756
|
-
multiple:
|
|
4762
|
+
multiple: isMulti,
|
|
4757
4763
|
onError: function () {
|
|
4758
4764
|
// console.log('error');
|
|
4759
4765
|
// setFieldError('file', t('component.form.error.multipleFiles') as string);
|
|
@@ -4764,7 +4770,7 @@ var FileInputGroupForm = function (props) {
|
|
|
4764
4770
|
onDragLeave: function () {
|
|
4765
4771
|
setIsDragging(false);
|
|
4766
4772
|
},
|
|
4767
|
-
}), getRootProps =
|
|
4773
|
+
}), getRootProps = _f.getRootProps, getInputProps = _f.getInputProps;
|
|
4768
4774
|
var handleGenerateStyle = function () {
|
|
4769
4775
|
var result = deepCopyObject(styles$3.base);
|
|
4770
4776
|
var keys = calculateNestedKeys(styles$3.base);
|