autocomplete-widget
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Autocomplete widget

Installation

yarn add autocomplete-widget

Quick start

type ItemType = {
    name: {common: string, official: string}
}

const input = document.querySelector<HTMLInputElement>('input#form_country')!;
const autocompleter = new Autocompleter<ItemType>(input, item => item.name.common);

autocompleter
    .setFetcher((text: string) => {
        return fetch('https://restcountries.com/v3.1/name/' + text)
            .then(response => response.json());
    })
    .onSelect((item: any) => {
        alert(item.name.official);
    })
    .create()
;

Package Sidebar

Install

npm i autocomplete-widget

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

13 kB

Total Files

8

Last publish

Collaborators

  • semivan