svelte-autocomplete

A lightweight typeahead / autocomplete component made with Svelte.js

Github星跟踪图

svelte-autocomplete

Lightweight typeahead / autocomplete component made with Svelte.js

  • no dependencies
  • can handle asynchronous data
  • use plain lists or key / value pairs

Try the demo at http://svelte-autocomplete.surge.sh/

Install

npm install svelte-autocomplete

Usage

Import the component directly in your Svelte project.

import AutoComplete from 'svelte-autocomplete'

export default {
  components: {
    AutoComplete,
	...
  }
}

And then use it like so:

<AutoComplete class="input" name="fruits" items="{fruits}" minChar="1" />

<AutoComplete name="countries" items="{countries}" isAsync on:input="loadApiData(event)">
  <div class="notification">Loading data from API...</div>
</AutoComplete>

Options, Prop, Type, Default, Description, ------, ------, ---------, -------------, name, String, -, Form input name, class, String, -, Additional styles for input element, items, Array, -, Array with items, can be a plain list or key, value pairs, isAsync, Boolean, false, If retrieving API data asynchronously, minChar, Number, 2, Min. characters to type before popup shows, maxItems, Number, 10, Max. items to show in popup, fromStart, Boolean, true, Match from the start or anywhere in the string

Slots, Slot, Prop dependencies, Description, ------, -------------------, -------------, default, isAsync, custom loading indication, ## Made with Svelte

It's made with Svelte, which means you don't need any JS framework. Just use the dist/index.js file in any Javascript project:

include the bundle:

<script src="svelte-autocomplete/dist/index.js"></script>

create component like so:

const myComponent = new AutoComplete({
  target: document.querySelector('#app'),
  data: { 
    name: 'fruits',
    itemStart: 1,
    items: [...]
  }
})

主要指标

概览
名称与所有者elcobvg/svelte-autocomplete
主编程语言HTML
编程语言JavaScript (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2018-07-13 04:59:46
推送于2019-01-16 08:08:45
最后一次提交2019-01-16 15:06:33
发布数2
最新版本名称v0.0.4 (发布于 2019-01-16 15:08:05)
第一版名称v0.0.2 (发布于 2018-07-13 23:13:58)
用户参与
星数119
关注者数6
派生数18
提交数11
已启用问题?
问题数10
打开的问题数8
拉请求数2
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?