mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 14:27:04 +00:00
Added definitions for react-dynamic-number npm package (#23165)
* feat(ReactDynamicNumber): added definitions for RDN * feat(ReactDynamicNumber): fix validation and linter * feat(ReactDynamicNumber): PR remarks corrected
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
// Type definitions for react-dynamic-number 1.7
|
||||
// Project: https://github.com/uhlryk/react-dynamic-number
|
||||
// Definitions by: Eugene Rodin <https://github.com/eugrdn>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
/**
|
||||
* remove Diff & Omit when in will be placed in TS from scratch
|
||||
*/
|
||||
export type Diff<T extends string, U extends string> = ({[P in T]: P} & {[P in U]: never} & {[x: string]: never})[T];
|
||||
export type Omit<T, K extends keyof T> = {[P in Diff<keyof T, K>]: T[P]};
|
||||
|
||||
export type BaseInputProps = Partial<
|
||||
Omit<
|
||||
React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
|
||||
'ref' | 'value' | 'onChange' | 'placeholder'
|
||||
>
|
||||
>;
|
||||
|
||||
export interface DynamicNumberProps extends BaseInputProps {
|
||||
value?: number | '';
|
||||
separator?: '.' | ',';
|
||||
thousand?: boolean | ' ';
|
||||
integer?: number;
|
||||
fraction?: number;
|
||||
positive?: boolean;
|
||||
negative?: boolean;
|
||||
placeholder?: string;
|
||||
onChange?: (event: React.ChangeEvent<HTMLInputElement>, modelValue: number, viewValue: string) => void;
|
||||
}
|
||||
|
||||
export default class DynamicNumber extends React.Component<DynamicNumberProps> {}
|
||||
@@ -0,0 +1,16 @@
|
||||
import * as React from 'react';
|
||||
import DynamicNumber from 'react-dynamic-number';
|
||||
|
||||
export class Test extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<DynamicNumber
|
||||
separator={','}
|
||||
thousand={' '}
|
||||
integer={40}
|
||||
fraction={2}
|
||||
negative={false}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6", "dom"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react",
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": ["index.d.ts", "react-dynamic-number-tests.tsx"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user