import type { App } from "obsidian" ; import { TextInputSuggest } from "./Suggest" ; export class GenericTextSuggester extends TextInputSuggest < string > { constructor ( public app , public inputEl , private items ) { super ( app , inputEl ) ; } getSuggestions ( inputStr ) { const inputLowerCase = inputStr . toLowerCase ( ) ; const filtered = this . items . filter ( item => { if ( item . toLowerCase ( ) . contains ( inputLowerCase ) ) return item ; } ) ; if ( ! filtered ) this . close ( ) ; if ( filtered ?. length > 0 ) return filtered ; } selectSuggestion ( item ) { this . inputEl . value = item ; this . inputEl . trigger ( "input" ) ; this . close ( ) ; } renderSuggestion ( value , el ) { if ( value ) el . setText ( value ) ; } }