Gathering detailed insights and metrics for react-butterfiles
Gathering detailed insights and metrics for react-butterfiles
Gathering detailed insights and metrics for react-butterfiles
Gathering detailed insights and metrics for react-butterfiles
🦋 Component for building file fields - from basic file inputs to drag and drop image galleries.
npm install react-butterfiles
Typescript
Module System
Node Version
NPM Version
77.3
Supply Chain
100
Quality
75.7
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
44 Stars
77 Commits
10 Forks
2 Branches
2 Contributors
Updated on Jan 29, 2023
Minified
Minified + Gzipped
Latest Version
1.3.3
Package Id
react-butterfiles@1.3.3
Size
45.37 kB
NPM Version
6.10.3
Node Version
10.16.2
Published on
Aug 15, 2019
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
1
39
A small component for building file upload fields of any type, for example a simple file upload button or an image gallery field with drag and drop support and preview of selected images.
npm install --save react-butterfiles
Or if you prefer yarn:
yarn add react-butterfiles
Create a simple file field which consists of a drop zone and a file upload button (for cases where drag and drop is not convenient). Multiple PDF / JPG files are accepted, but with the following restrictions:
1import Files from "react-butterfiles";
1<Files 2 multiple={true} 3 maxSize="2mb" 4 multipleMaxSize="10mb" 5 multipleMaxCount={3} 6 accept={["application/pdf","image/jpg","image/jpeg"]} 7 onSuccess={files => this.setState({ files })} 8 onError={errors => this.setState({ errors })} 9> 10 {({ browseFiles, getDropZoneProps, getLabelProps }) => ( 11 <> 12 <label {...getLabelProps()}>Your files</label> 13 <div {...getDropZoneProps({ className: "myDropZone" })}/> 14 <button onClick={browseFiles}>Select files...</button> 15 <ol> 16 {this.state.files.map(file => ( 17 <li key={file.name}>{file.name}</li> 18 ))} 19 {this.state.errors.map(error => ( 20 <li key={error.file.name}> 21 {error.file.name} - {error.type} 22 </li> 23 ))} 24 </ol> 25 </> 26 )} 27</Files>
More examples on https://react-butterfiles.netlify.com.
Prop | Type | Default | Description |
---|---|---|---|
accept | Array<string> | [] | Defines which file types will be accepted. Example: ["application/pdf"] . |
multiple | boolean | false | Allow multiple file selection by setting this prop to `true. |
maxSize | string | "2mb" | Defines maximum file size (bytes lib used behind the scenes). Example: "10mb" |
multipleMaxSize | string | "10mb" | Useful only if multiple prop is set to true . Defines max. file size of all selected files. |
multipleMaxCount | number | null | Useful only if multiple prop is set to true . Defines max. allowed selected files. |
convertToBase64 | boolean | false | If true , selected files will also be converted to baser64 format (useful when working with images / thumbnails). |
onSuccess | (files: Array<SelectedFile>) => void | undefined | Callback that will get executed once a valid file selection has been made (via browse files dialog or drag and drop). Each file will have a random id assigned to it. |
onError | (errors: Array<FileError>) => void | undefined | Callback that will get executed once an invalid file selection has been made. Each error will have a random id assigned to it. More info about possible errors below. |
Render prop gives you access to three callbacks:
Prop | Type | Description |
---|---|---|
browseFiles | BrowseFilesParams => void | Once executed, file browser will be shown. Useful for file upload buttons. The callback can also accept custom onSuccess and onError callbacks, that will override the main ones. |
validate | (files: Array<File>) => Array<FileError> | Enables manual validation of files. Eg. after editing the selected image in an image editor. |
getDropZoneProps | (additionalProps: ?Object) => Object | Props that need to be spread to a drop zone. Additional props can be passed, for example className or style . |
getLabelProps | (additionalProps: ?Object) => Object | Props that need to be spread to your file field's label. Additional props can be passed, for example className or style . |
Note that you don't need to have both upload file and drop zone, you can use only one if that's your requirement.
For example, to create a simple file field, you would only need to use the browseFiles
callback.
While selecting and dropping files, if there are one or more that do not comply with the rules that were set via props, an onError
callback will be triggered, with all of the errors passed as the first argument.
Every error in the array will have one of the following error types.
Type | Description |
---|---|
unsupportedFileType | This can only happen via drag and drop since file browser dialog won't let users choose files of invalid type. |
maxSizeExceeded | One or more file sizes are greater than maxSize value. |
multipleMaxCountExceeded | User selected more files than allowed (more than multipleMaxCount ). |
multipleMaxSizeExceeded | User selected one or more files with their total size greater than allowed (more than multipleMaxSize ). |
multipleNotAllowed | This can only happen via drag and drop since file browser dialog won't let users select two or more files if multiple was not set to true . |
Thanks goes to these wonderful people (emoji key):
Adrian Smijulj ???? ???? ???? ???? ⚠️ | readeral ???? ???? |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/26 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
172 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More