arichter83
2018-12-03 19:02:05 +01:00
parent f15a022416
commit f425f27992
2 changed files with 20 additions and 1 deletions
+12 -1
View File
@@ -3,12 +3,23 @@
// Definitions by: Guymestef <https://github.com/Guymestef>
// Rajab Shakirov <https://github.com/radziksh>
// Paito Anderson <https://github.com/PaitoAnderson>
// Andreas Richter <https://github.com/arichter83>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TODO: <Highlighter>, <Menu>, <MenuItem>, <Token> components
import * as React from 'react';
export interface TypeaheadFilterbyProps {
filterBy: string[];
labelKey: (string | (() => void));
multiple: boolean;
selected: any[];
caseSensitive: boolean;
ignoreDiacritics: boolean;
text: string;
}
export interface TypeaheadProps<T> {
/* For localized accessibility: Should return a string indicating the number of results for screen readers. Receives the current results. */
a11yNumResults?: () => void;
@@ -58,7 +69,7 @@ export interface TypeaheadProps<T> {
emptyLabel?: string;
/* Either an array of fields in option to search, or a custom filtering callback. */
filterBy?: (string[] | ((option: T | string, text: string) => boolean));
filterBy?: (string[] | ((option: T | string, props: TypeaheadFilterbyProps) => boolean));
/* Highlights the menu item if there is only one result and allows selecting that item by hitting enter.
Does not work with allowNew. */
@@ -28,6 +28,14 @@ class BasicExample extends React.Component {
onInputChange={(value, e) => {}}
placeholder="Choose a state..."
/>
<Typeahead
labelKey="name"
multiple={multiple}
options={options}
maxHeight='300px'
filterBy={(option, props) => (props.text.indexOf(option) !== -1) }
placeholder="Choose a state..."
/>
</div>
);
}