ItemSuggest
Input field to search and select an item (usually concept or concept scheme) from a list of search results. Shows a LoadingIndicator while waiting for results.
Props
search(query)async function — custom search function that provides results in OpenSearch Suggest Format:queryis the search string- The Promise that is returned by this function can optionally have a property
cancelattached. If this is the case, it will be called if there is a newer search query and the previous request should be aborted.
placeholderstring, default"Type to search..."— placeholder string.nulluses the default placeholder, an empty string clears it.
Methods
focus()— focuses the input fieldsetQuery(newQuery, focus = false)— sets the query (input field) tonewQuery; optionally focuses the input field
Events
selectis emitted when a search result is selected (either via click or enter). Parameter is the JSKOS concept of the selected result (withuriandinSchemeproperties).
CSS classes
.jskos-vue-itemSuggest— the component element.jskos-vue-itemSuggest-loading—.jskos-vue-itemSuggest-results—.jskos-vue-itemSuggest-results-item—.jskos-vue-itemSuggest-results-list—.jskos-vue-itemSuggest-selected—
Examples
Search with a custom search function
This example provides a custom search function (results come from local data in this case).
Search for concepts inside a concept scheme
This example uses the coli-conc API via cocoda-sdk to search for concept inside German Dewey Decimal Classification (DDC, licensed by OCLC under CC BY-NC-ND 3.0).
vue
<template>
<item-suggest
:search="search => registry.suggest({ search, scheme })" />
</template>
<script setup>
import { ItemSuggest, utils } from "jskos-vue"
import * as cdk from "cocoda-sdk"
import { ref, onMounted } from "vue"
const registry = ref(null)
onMounted(() => {
registry.value = cdk.initializeRegistry({
provider: "ConceptApi",
api: "https://coli-conc.gbv.de/api/",
})
})
const scheme = {
uri: "http://dewey.info/scheme/edition/e23/",
license: [
{
uri: "http://creativecommons.org/licenses/by-nc-nd/3.0/"
}
],
}
</script>Search for schemes in BARTOC
This example uses the BARTOC API via cocoda-sdk to search for vocabularies.
vue
<template>
<item-suggest :search="search => bartocRegistry.vocSuggest({ search })" />
</template>
<script setup>
import { ItemSuggest, utils } from "jskos-vue"
import * as cdk from "cocoda-sdk"
import { ref, onMounted } from "vue"
const bartocRegistry = ref(null)
onMounted(() => {
bartocRegistry.value = cdk.initializeRegistry({
provider: "ConceptApi",
api: "https://bartoc.org/api/",
})
})
</script>