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, selectedTypeUris)async function — custom search function that provides results in OpenSearch Suggest Format:queryis the search stringselectedTypeUrisis provided only whentypesis configured. Without type filtering, the function is called withqueryonly.
optionsarray, defaultnull— local JSKOS items to search ifsearchis not set.typesarray, defaultnull— optional JSKOS type resources shown as filters.minCharsnumber, default1— minimum query length for localoptions.placeholderstring, default"Type to search..."— placeholder string.nulluses the default placeholder, an empty string clears it.
If both search and options are set, search is used.
Local JSKOS options use the shared content language selection. Labels returned by a remote search function are already strings and are displayed unchanged.
All available types are selected initially and reset when types changes. Local options match any selected type (OR). Remote filtering is delegated to the search provider. Deselecting all types returns no results.
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 an object with propertyuri.
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—.jskos-vue-itemSuggest-typeFilter— type filter disclosure.jskos-vue-itemSuggest-typeOptions— type checkbox group
Examples
Search with a custom search function
This example provides a custom search function (results come from local data in this case).
Search local options
vue
<item-suggest :options="languageOptions" />Filter local options by type
All three options contain "Berlin", so the checkboxes directly demonstrate the type filter.
Types
Selected URI: none
Search for concepts inside a concept scheme
This example uses the coli-conc API via cocoda-sdk to search for concepts inside the 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>