3.6.2 • Published 3 years ago

@invisionag/iris-react-file-input v3.6.2

Weekly downloads
8
License
MIT
Repository
github
Last release
3 years ago
import FileInput from '@invisionag/iris-react-file-input';

FileInput is a generalized Component to handle file selections made by the user. To this end, we make use of the "dropzone" pattern, wherein a file can simply be dragged into the designated zone to fill an <input type="file" /> element with a filepath.

Usage:

<FileInput />

isLoading

Can be passed to indicate that the selected files are currently being processed. It will cause:

  • Any interactivity with the dropzone to be disabled
  • A spinner to be displayed in the dropzone instead of the regular logic
  • The remove-buttons in the FileList to be hidden, so no files can be added or removed while isLoading is true

onChange

onChange is called on any state change, including when a file is removed.

onDrop

Callback that is invoked every time a file is selected, either via drop or traditional file explorer selection. First (and only) argument is an array of selected files:

handleDrop = files => {
  files.forEach(file =>console.log("file", file))
}

render() {
  return <FileInput onDrop={handleDrop} />
}

multiple

By default, only one file can be selected. If you want the user to be able to select multiple files, you can provide the multiple prop like so:

<FileInput multiple />

accept

Mime-Type-String or Array of Mime-Type-Strings. If set, the file input will only accept files with the matching mime-type. Other files will simply be ignored; this is also true if multiple and accept is set: if a user drops multiple files with different mime-types, those with the correct type will be accepted whereas the others will simply be ignored.

<FileInput accept="text/csv" />

localeUtils

Via this prop all customizable texts can be set. It should be a polyglot object following the implementataion in e.g. forecast-ui.

Following text items can be customized in the FileInput by implementing the corresponding key. If the key is not provided, a default text will be displayed.

Descriptionkeydefault
message in initial screen for multiplefile_input.description.multipleDrag your files here
message in initial screenfile_input.description.singleDrag your file here
conjunction before file explorer linkfile_input.joineror
displayed in zone when isLoading is passedfile_input.loadingUploading...
file explorer linkfile_input.linkchoose files
dragging with valid filesfile_input.active_description.validDrop files here
dragging with invalid filesfile_input.active_description.invalidCannot select this file type
when file limit is reachedfile_input.file_limit_warning1 of 1 file selected

className

Provides a class name for the react Dropzone.

validate

With the validate prop, a custom validator can be passed to the component.

The component will run the validator function for each file that was added, passing the file as the only argument.

The file will only be added to the selection if the validator function returns true.

<FileInput validate={(file: File): boolean => file.name === 'my-special-name.txt'} />
3.6.2

3 years ago

3.6.1

3 years ago

3.6.0

3 years ago

3.5.19

4 years ago

3.5.17

4 years ago

3.5.16

4 years ago

3.5.14

4 years ago

3.5.15

4 years ago

3.5.12

4 years ago

3.5.11

4 years ago

3.5.10

4 years ago

3.5.9

4 years ago

3.5.8

4 years ago

3.5.7

4 years ago

3.5.6

4 years ago

3.5.5

4 years ago

3.5.4

4 years ago

3.5.5-alpha.0

4 years ago

3.5.3

4 years ago

3.5.0

4 years ago

3.4.2

4 years ago

3.4.1

4 years ago

3.4.0

4 years ago

3.3.7

4 years ago

3.3.6

5 years ago

3.3.5

5 years ago

3.3.4

5 years ago

3.3.3

5 years ago

3.3.2

5 years ago

3.3.1

5 years ago

3.3.0

5 years ago

3.2.32

5 years ago

3.2.31

5 years ago

3.2.30

5 years ago

3.2.29

5 years ago

3.2.28

5 years ago

3.2.27

5 years ago

3.2.26

5 years ago

3.2.25

5 years ago

3.2.24

5 years ago

3.2.17-alpha.13

5 years ago

3.2.17-alpha.11

5 years ago

3.2.23

5 years ago

3.2.22

5 years ago

3.2.21

5 years ago

3.2.20

5 years ago

3.2.17-alpha.8

5 years ago

3.2.19

5 years ago

3.2.18

5 years ago

3.2.17

5 years ago

3.2.16

5 years ago

3.2.7

5 years ago

3.2.6

5 years ago

3.2.5

5 years ago

3.2.3-alpha.4542

5 years ago

3.2.0-alpha.0

5 years ago

3.1.9

5 years ago

3.1.8

5 years ago

3.1.7

5 years ago

3.1.6

5 years ago

3.1.5

5 years ago

3.1.4

5 years ago

3.1.3

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.17

5 years ago

3.0.16

5 years ago

3.0.15

5 years ago

3.0.14

5 years ago

3.0.13

5 years ago

3.0.11

5 years ago

3.0.10

5 years ago

3.0.9

5 years ago

3.0.8

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

3.0.0-alpha.0

5 years ago

2.2.10

5 years ago

2.2.9

5 years ago

2.2.8

5 years ago

2.2.6

5 years ago

2.2.5

5 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.14

6 years ago

2.1.13

6 years ago

2.1.12

6 years ago

2.1.11

6 years ago

2.1.10

6 years ago

2.1.9

6 years ago

2.1.8

6 years ago

2.1.7

6 years ago

2.1.6

6 years ago

2.1.5

6 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.2.4

6 years ago

1.2.2

6 years ago

1.2.2-1

6 years ago

1.2.2-0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago