mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
Add type definitions for react-editext (#34161)
* add type definitions for react-editext * set strictFunctionTypes to true * refactor index.d.ts file * format react-editext-tests.tsx file
This commit is contained in:
committed by
Sheetal Nandi
parent
70ab3cb3b0
commit
dd4b74b0af
Vendored
+104
@@ -0,0 +1,104 @@
|
||||
// Type definitions for react-editext 3.1
|
||||
// Project: https://github.com/alioguzhan/react-editext
|
||||
// Definitions by: Ali Oguzhan Yildiz <https://github.com/alioguzhan>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.3
|
||||
|
||||
import * as React from 'react';
|
||||
export type EdiTextType =
|
||||
| 'text'
|
||||
| 'textarea'
|
||||
| 'email'
|
||||
| 'number'
|
||||
| 'date'
|
||||
| 'datetime-local'
|
||||
| 'time'
|
||||
| 'month'
|
||||
| 'url'
|
||||
| 'week'
|
||||
| 'tel';
|
||||
|
||||
export interface EdiTextProps {
|
||||
/**
|
||||
* Props to be passed to input element.
|
||||
* Any kind of valid DOM attributes are welcome
|
||||
*/
|
||||
inputProps?: object;
|
||||
/**
|
||||
* Props to be passed to div element that shows the text.
|
||||
* You can specify your own `styles` or `className`
|
||||
*/
|
||||
viewProps?: object;
|
||||
/**
|
||||
* Value of the content [in view mode] and input [in edit mode]
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* A simple hint message appears at the bottom of input element.
|
||||
* Any valid element is allowed.
|
||||
*/
|
||||
hint?: React.ReactNode;
|
||||
/**
|
||||
* If validation fails this message will appear
|
||||
*/
|
||||
validationMessage?: string;
|
||||
/**
|
||||
* Pass your own validation function.
|
||||
* takes one param -> `value`.
|
||||
* It must return `true` or `false`
|
||||
*/
|
||||
validation?: (...args: string[]) => boolean;
|
||||
/**
|
||||
* will be called when validation fails.
|
||||
* takes one param <value> which is the current value of input
|
||||
*/
|
||||
onValidationFail?: (...args: string[]) => any;
|
||||
/**
|
||||
* Input type. Possible options are:
|
||||
* `text`, `number`, `email`, `textarea`, `date`,
|
||||
* `datetime-local`, `time`, `month`, `url`, `week`, `tel`
|
||||
*/
|
||||
type: EdiTextType;
|
||||
/**
|
||||
* will be called when user clicked cancel button
|
||||
*/
|
||||
onCancel?: (...args: any[]) => any;
|
||||
/**
|
||||
* will be called when user clicked save button.
|
||||
* takes one param <value> which is the current value of input
|
||||
*/
|
||||
onSave: (...args: string[]) => any;
|
||||
/**
|
||||
* Custom class name for SAVE button.
|
||||
*/
|
||||
saveButtonClassName?: string;
|
||||
/**
|
||||
* Custom class name for EDIT button.
|
||||
*/
|
||||
editButtonClassName?: string;
|
||||
/**
|
||||
* Custom class name for CANCEL button.
|
||||
*/
|
||||
cancelButtonClassName?: string;
|
||||
/**
|
||||
* Content for CANCEL button. Any valid element and node are allowed.
|
||||
*/
|
||||
cancelButtonContent?: any;
|
||||
/**
|
||||
* Content for SAVE button. Any valid element and node are allowed.
|
||||
*/
|
||||
saveButtonContent?: any;
|
||||
/**
|
||||
* Content for EDIT button. Any valid element and node are allowed.
|
||||
*/
|
||||
editButtonContent?: any;
|
||||
/**
|
||||
* Set it to `true` if you don't want to see default icons
|
||||
* on action buttons.See Examples page for more details.
|
||||
*/
|
||||
hideIcons?: boolean;
|
||||
}
|
||||
|
||||
export default class EdiText extends React.Component<EdiTextProps, any> {
|
||||
render(): JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import EdiText from 'react-editext';
|
||||
|
||||
import * as React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
|
||||
declare const container: Element;
|
||||
|
||||
render(
|
||||
<EdiText
|
||||
type='text'
|
||||
value={''}
|
||||
onSave={value => console.log(value)}
|
||||
/>,
|
||||
container,
|
||||
);
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-editext-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user