How to use the component:
<div>.RainbowLookup in JavaScript:
const sparqlEndpoint = 'https://example.com/sparql';
const myElement = document.getElementById('my-rainbow-lookup-element');
const options = { /* ... */ };
const lookupInstance = RainbowLookup.create(
myElement,
sparqlEndpoint,
options,
);
The following options can be passed to RainbowLookup.create():
export type AutocompleteOptions = {
onConceptSchemesLoaded?: (conceptSchemes: ConceptScheme[]) => void; // callback for when concept schemes are loaded
onConceptSchemeSelected?: (conceptScheme: ConceptScheme | null) => void; // callback for when a concept scheme is selected
onConceptSelected?: (concept: SKOSResource | null) => void; // callback for when a concept is selected
onConceptSchemeLoaded?: (conceptScheme: ConceptScheme, concepts: SKOSResource[]) => void; // callback for when a concept scheme's concepts have been loaded
onError?: (action: string, error: any) => void; // callback for errors. Action can be one of: 'loadConceptSchemes', 'loadConcepts'
loading?: {
conceptSchemes?: string; // Text for "Loading concept schemes..."
concepts?: string; // Text for "Loading concepts..."
};
noResults?: {
conceptSchemes?: string; // Text to display when no concept schemes are found
concepts?: string; // Text to display when no concepts are found
};
placeholder?: {
conceptScheme?: string; // Placeholder for the concept scheme lookup field
concept?: string; // Placeholder for the concept lookup field
};
errorMessages: {
conceptSchemes?: string; // Text to display for errors when retrieving the concept schemes
concepts?: string; // Text to display for errors when retrieving concepts
};
inputClasses?: string | { // DOM classes for the lookup input fields. A string here will apply to both fields.
conceptScheme?: string;
concept?: string;
};
};
The returned RainbowLookup instances expose the following methods:
reset(): Clears the lookup inputs and resets the component status.getSelection(): Returns an object with conceptScheme
and concept keys indicating the current selection.