Add types for react-numeric-input (#21151)

This commit is contained in:
Heather Booker 2017-11-03 11:04:12 -04:00 committed by Andy
parent cbaa668281
commit 90ee6baac4
4 changed files with 79 additions and 0 deletions

46
types/react-numeric-input/index.d.ts vendored Normal file
View File

@ -0,0 +1,46 @@
// Type definitions for react-numeric-input 2.2
// Project: https://github.com/vlad-ignatov/react-numeric-input#readme
// Definitions by: Heather Booker <https://github.com/heatherbooker>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as React from 'react';
export = NumericInput;
declare namespace NumericInput {
interface NumericInputProps extends React.Props<NumericInput> {
addLabelText?: string;
className?: string;
defaultValue?: number | string;
disabled?: boolean;
format?: ((s: string) => string);
max?: number | ((v: number) => number);
maxLength?: number;
min?: number | ((v: number) => number);
mobile?: boolean | 'auto' | ((this: NumericInput) => any); // TODO: fix `any`
noValidate?: boolean| string;
onBlur?: React.FocusEventHandler<HTMLDivElement | HTMLInputElement>;
onChange?: ((v: number, s: string, i: JSX.Element) => void);
onFocus?: React.FocusEventHandler<HTMLDivElement | HTMLInputElement>;
onInput?: ((...args: any[]) => void);
onInvalid?: ((err: string, v: number, s: string) => void);
onKeyDown?: React.KeyboardEventHandler<HTMLDivElement | HTMLInputElement>;
onSelect?: ((...args: any[]) => void);
onValid?: ((v: number, s: string) => void);
parse?: ((s: string) => number | string);
pattern?: string;
precision?: number | ((this: NumericInput) => void);
readOnly?: boolean;
required?: boolean;
size?: number | string;
snap?: boolean;
step?: number | object; // TODO: should be `number | <some function>`
strict?: boolean;
style?: { [key: string]: { [key: string]: string } } | boolean;
type?: string;
value?: number | string;
}
}
declare class NumericInput extends React.Component<NumericInput.NumericInputProps> {}

View File

@ -0,0 +1,8 @@
import { Component } from 'react';
import * as NumericInput from 'react-numeric-input';
export class NumericInputTest extends Component {
render() {
return(<NumericInput />);
}
}

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"jsx": "preserve",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-numeric-input-tests.tsx"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }