mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Changed filterBy
See https://github.com/ericgio/react-bootstrap-typeahead/blob/116c5cdc7443099a0455757558108c6082b347f1/docs/Upgrading.md#v30
This commit is contained in:
+12
-1
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user