@ballistix.digital/react-components 0.8.3 → 0.10.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 CHANGED
@@ -167,8 +167,8 @@ type TInputGroupFormProps = {
167
167
  mask: string;
168
168
  replacementCharacter?: string;
169
169
  };
170
- min?: number;
171
- max?: number;
170
+ min?: number | string;
171
+ max?: number | string;
172
172
  maxLength?: number;
173
173
  rows?: number;
174
174
  type: 'normal' | 'inset' | 'overlapping' | 'pill' | 'floored';
@@ -1039,12 +1039,13 @@ type TFileInputGroupFormProps = {
1039
1039
  isDisabled?: boolean;
1040
1040
  isRequired?: boolean;
1041
1041
  isTouched?: boolean;
1042
+ isMulti?: boolean;
1042
1043
  children?: (props: {
1043
1044
  value?: TFileType;
1044
1045
  isDragging: boolean;
1045
1046
  }) => ReactNode;
1046
- onChange: any;
1047
- onBlur: any;
1047
+ onChange: (files: TFileType[]) => void;
1048
+ onBlur: FocusEventHandler<HTMLInputElement>;
1048
1049
  styles?: TFileInputGroupFormStyles;
1049
1050
  };
1050
1051
  declare const FileInputGroupForm: FC<TFileInputGroupFormProps>;
package/dist/index.esm.js CHANGED
@@ -4724,34 +4724,40 @@ function reducer(state, action) {
4724
4724
  function noop() {}
4725
4725
 
4726
4726
  var FileInputGroupForm = function (props) {
4727
- 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;
4727
+ 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;
4728
4728
  var isValid = error === undefined;
4729
- var _d = useState(false), isDragging = _d[0], setIsDragging = _d[1];
4730
- var handleChangeInput = useCallback(function (file) {
4731
- var reader = new FileReader();
4732
- reader === null || reader === void 0 ? void 0 : reader.readAsDataURL(file);
4733
- reader.onload = function () {
4734
- var result = {
4735
- name: file.name,
4736
- size: file.size,
4737
- type: file.type,
4738
- blob: reader === null || reader === void 0 ? void 0 : reader.result,
4739
- file: file,
4729
+ var _e = useState(false), isDragging = _e[0], setIsDragging = _e[1];
4730
+ var handleChangeInput = useCallback(function (files) {
4731
+ var results = [];
4732
+ forEach(files, function (file, index, files) {
4733
+ var reader = new FileReader();
4734
+ reader === null || reader === void 0 ? void 0 : reader.readAsDataURL(file);
4735
+ reader.onload = function () {
4736
+ var result = {
4737
+ name: file.name,
4738
+ size: file.size,
4739
+ type: file.type,
4740
+ blob: reader === null || reader === void 0 ? void 0 : reader.result,
4741
+ file: file,
4742
+ };
4743
+ // eg. 10 * 1024 * 1024
4744
+ if (max && max * 1024 * 1024 < result.size) {
4745
+ return;
4746
+ }
4747
+ results.push(result);
4748
+ if (index === files.length - 1) {
4749
+ onChange(results);
4750
+ }
4740
4751
  };
4741
- // eg. 10 * 1024 * 1024
4742
- if (max && max * 1024 * 1024 < result.size) {
4743
- return;
4744
- }
4745
- onChange(result);
4746
- };
4752
+ });
4747
4753
  }, [max, onChange]);
4748
4754
  var onDrop = useCallback(function (files) {
4749
4755
  setIsDragging(false);
4750
- handleChangeInput(files[0]);
4756
+ handleChangeInput(files);
4751
4757
  }, [handleChangeInput]);
4752
- var _e = useDropzone({
4758
+ var _f = useDropzone({
4753
4759
  onDrop: onDrop,
4754
- multiple: false,
4760
+ multiple: isMulti,
4755
4761
  onError: function () {
4756
4762
  // console.log('error');
4757
4763
  // setFieldError('file', t('component.form.error.multipleFiles') as string);
@@ -4762,7 +4768,7 @@ var FileInputGroupForm = function (props) {
4762
4768
  onDragLeave: function () {
4763
4769
  setIsDragging(false);
4764
4770
  },
4765
- }), getRootProps = _e.getRootProps, getInputProps = _e.getInputProps;
4771
+ }), getRootProps = _f.getRootProps, getInputProps = _f.getInputProps;
4766
4772
  var handleGenerateStyle = function () {
4767
4773
  var result = deepCopyObject(styles$3.base);
4768
4774
  var keys = calculateNestedKeys(styles$3.base);