@@ -18,6 +18,7 @@ import {MyCheckbox} from './Table.stories';
18
18
import { MyGridListItem } from './GridList.stories' ;
19
19
import { MyListBoxLoaderIndicator } from './ListBox.stories' ;
20
20
import { MyTag } from './TagGroup.stories' ;
21
+ import { Node } from '@react-types/shared' ;
21
22
import React , { useState } from 'react' ;
22
23
import styles from '../example/index.css' ;
23
24
import { useAsyncList , useListData , useTreeData } from 'react-stately' ;
@@ -166,7 +167,7 @@ export const AutocompleteSearchfield: AutocompleteStory = {
166
167
167
168
// Note that the trigger items in this array MUST have an id, even if the underlying MenuItem might apply its own
168
169
// id. If it is omitted, we can't build the collection node for the trigger node and an error will throw
169
- let dynamicAutocompleteSubdialog = [
170
+ let dynamicAutocompleteSubdialog : MenuNode [ ] = [
170
171
{ name : 'Section 1' , isSection : true , children : [
171
172
{ name : 'Command Palette' } ,
172
173
{ name : 'Open View' }
@@ -440,7 +441,7 @@ const CaseSensitiveFilter = (args) => {
440
441
let defaultFilter = ( itemText , input ) => contains ( itemText , input ) ;
441
442
442
443
return (
443
- < Autocomplete filter = { defaultFilter } >
444
+ < Autocomplete < AutocompleteItem > filter = { defaultFilter } >
444
445
< div >
445
446
< SearchField autoFocus >
446
447
< Label style = { { display : 'block' } } > Test</ Label >
@@ -1091,17 +1092,26 @@ export const AutocompleteWithTagGroup = () => {
1091
1092
) ;
1092
1093
} ;
1093
1094
1095
+ type MenuNode = {
1096
+ name : string ,
1097
+ id ?: string ,
1098
+ isSection ?: boolean ,
1099
+ isMenu ?: boolean ,
1100
+ children ?: MenuNode [ ]
1101
+ }
1102
+
1094
1103
function AutocompleteNodeFiltering ( args ) {
1095
1104
let { contains} = useFilter ( { sensitivity : 'base' } ) ;
1096
- let filter = ( textValue , inputValue , node ) => {
1105
+ let filter = ( textValue : string , inputValue : string , node : Node < MenuNode > ) => {
1097
1106
if ( ( node . parentKey === 'Section 1' && textValue === 'Open View' ) || ( node . parentKey === 'Section 2' && textValue === 'Appearance' ) ) {
1098
1107
return true ;
1099
1108
}
1109
+
1100
1110
return contains ( textValue , inputValue ) ;
1101
1111
} ;
1102
1112
1103
1113
return (
1104
- < Autocomplete filter = { filter } >
1114
+ < Autocomplete < MenuNode > filter = { filter } >
1105
1115
< div >
1106
1116
< SearchField autoFocus >
1107
1117
< Label style = { { display : 'block' } } > Test</ Label >
0 commit comments