0.0.10 • Published 1 year ago

fetched-list v0.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

< fetched-list >

Dependency-free component that implements live-search (value suggestion) to any <input> element via <datalist>

Demo

How to use

1. Load module

<!-- From CDN -->
<script src="https://esm.run/fetched-list" type="module"></script>

2. Connect <input> element

<!-- Just wrap any input -->
<fetched-list>
    <input>
</fetched-list>

<!-- Or refer to it by ID -->
<input id="inputId">
<!-- ... -->
<fetched-list value-from="inputId"></fetched-list>

3. Configure

<!-- From demo/index.html -->
<fetched-list
        url="http://geodb-free-service.wirefreethought.com/v1/geo/countries?limit=10"
        param="namePrefix" check="metadata.totalCount" list-path="data" value-path="name"
        label-path="code" title-case="true" initial-fetch="true" auto-select="true">
    <input autocapitalize="words" placeholder="Type any Country" type="search">
</fetched-list>

Properties

PropertyAttributeDescription
urlurlAPI endpoint for fetching options
paramparamName of query parameter where to put text from input
checkcheckAbsolute JSON path to property that indicate successful response
listPathlist-pathAbsolute JSON path to property that contains array with options
valuePathvalue-pathRelative JSON path to property that contains value of each option
labelPathlabel-pathRelative JSON path to property that contains label of each option
titleCasetitle-caseAutomatically capitalize first letter when typing
valueFromvalue-fromID of outer input element to be used instead of inner input
autoSelectauto-selectAutomatically select most relevant variant from list
initialFetchinitial-fetchPrefetch an options before input
removeOptionsremove-optionsClear list of options before populating
0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago