mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add InputHTMLAttributes to react-file-reader-input props (#45268)
This commit is contained in:
parent
e6ef022554
commit
ed3959641e
14
types/react-file-reader-input/index.d.ts
vendored
14
types/react-file-reader-input/index.d.ts
vendored
@ -1,8 +1,10 @@
|
||||
// Type definitions for react-file-reader-input 1.1
|
||||
// Type definitions for react-file-reader-input 2.0
|
||||
// Project: https://github.com/ngokevin/react-file-reader-input
|
||||
// Definitions by: Dmitry Rogozhny <https://github.com/dmitryrogozhny>, Ali Taheri <https://github.com/alitaheri>
|
||||
// Definitions by: Dmitry Rogozhny <https://github.com/dmitryrogozhny>,
|
||||
// Ali Taheri <https://github.com/alitaheri>,
|
||||
// bjoluc <https://github.com/bjoluc>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.5
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
@ -13,7 +15,7 @@ declare namespace FileInput {
|
||||
type Format = 'buffer' | 'binary' | 'url' | 'text';
|
||||
type Result = [ProgressEvent, File];
|
||||
|
||||
interface Props {
|
||||
interface Props extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
||||
/**
|
||||
* what format the `FileReader` should read the file as
|
||||
* (i.e., `'buffer'`, `'binary'`, `'url'`, `'text'`).
|
||||
@ -23,7 +25,7 @@ declare namespace FileInput {
|
||||
as?: Format;
|
||||
|
||||
/**
|
||||
* Callback function called when the files are choosen by the user.
|
||||
* Callback function called when the files are chosen by the user.
|
||||
*
|
||||
* Results will be an array of arrays, the size of which depending
|
||||
* on how many files were selected.
|
||||
@ -40,7 +42,7 @@ declare namespace FileInput {
|
||||
* @param event The event that triggered file changes
|
||||
* @param results The array of files
|
||||
*/
|
||||
onChange(event: React.SyntheticEvent<any>, results: Result[]): void;
|
||||
onChange(event: React.ChangeEvent<HTMLInputElement>, results: Result[]): void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import FileReaderInput = require('react-file-reader-input');
|
||||
import FileReaderInput from 'react-file-reader-input';
|
||||
|
||||
class MyComponent extends React.Component {
|
||||
handleChange = (event: React.SyntheticEvent<any>, results: FileReaderInput.Result[]) => {
|
||||
@ -13,7 +13,7 @@ class MyComponent extends React.Component {
|
||||
return (
|
||||
<form>
|
||||
<label htmlFor="my-file-input">Upload a File: </label>
|
||||
<FileReaderInput as="binary" onChange={this.handleChange} >
|
||||
<FileReaderInput as="binary" onChange={this.handleChange} accept=".txt">
|
||||
<button>Select a file!</button>
|
||||
</FileReaderInput>
|
||||
</form>
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user