Selected concept scheme:
Selected concept:

How to use the component:

  1. Create an HTML page with an empty <div>.
  2. Add the RainbowLookup script (and, optionally, css) to your page.
  3. Instantiate the 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:

  1. reset(): Clears the lookup inputs and resets the component status.
  2. getSelection(): Returns an object with conceptScheme and concept keys indicating the current selection.