mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-30 23:30:06 +00:00
Add type for handleValidate prop function for react-tag-autocomplete
This commit is contained in:
5
types/react-tag-autocomplete/index.d.ts
vendored
5
types/react-tag-autocomplete/index.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
// Type definitions for react-tag-autocomplete 5.6
|
||||
// Project: https://github.com/i-like-robots/react-tags#readme
|
||||
// Definitions by: James Lismore <https://github.com/jlismore>
|
||||
// Rahul Sagore <https://github.com/Rahul-Sagore>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -81,6 +82,10 @@ export interface ReactTagsProps {
|
||||
* Optional event handler when the input changes. Receives the current input value.
|
||||
*/
|
||||
handleInputChange?: (input: string) => void;
|
||||
/**
|
||||
* Optional validation function that determines if tag should be added to tags. Receives a tag object. Should return a boolean.
|
||||
*/
|
||||
handleValidate?: (tag: Tag) => boolean;
|
||||
/**
|
||||
* An object containing additional attributes that will be applied to the underlying <input /> field.
|
||||
*/
|
||||
|
||||
@@ -30,6 +30,7 @@ class TestAll extends React.Component {
|
||||
const onBlur = () => {};
|
||||
const onFocus = () => {};
|
||||
const onInputChange = (input: string) => {};
|
||||
const onValidate = (tag: { id: string | number; name: string }) => true;
|
||||
const inputAttributes = { maxLength: 10 };
|
||||
const suggestions = [
|
||||
{ id: 3, name: "Bananas" },
|
||||
@@ -55,6 +56,7 @@ class TestAll extends React.Component {
|
||||
handleDelete={onDeleteTag}
|
||||
handleFocus={onFocus}
|
||||
handleInputChange={onInputChange}
|
||||
handleValidate={onValidate}
|
||||
inputAttributes={inputAttributes}
|
||||
maxSuggestionsLength={10}
|
||||
minQueryLength={5}
|
||||
|
||||
Reference in New Issue
Block a user