This module performs shallow lookups on Wikidata. They are shallow in that they only load the information that needs to be displayed to the user in their current language. The backend version of this adapter performs the actual deep lookup for all languages.

Hierarchy (View Summary)

Constructors

Properties

ac?: default<any>

After AbstractAutocompleteAdapter#setupAutocomplete is run, holds a reference to the autocomplete widget used by this instance.

acCSSPrefix: string = 'ac-adapter-'

CSS prefix for the autocomplete widget.

acDelay: number = 300

Delay in milliseconds before performing a search.

acPrimaryTextKey: string = 'label'

Key (into the row objects retrieved via the request handler) that determines which value is used as the main text in the autocomplete widget.

'label' corresponds to what the main application expects, but if you want to show something different than what gets passed to the application, you may want to change it.

acSecondaryTextKey: string = 'description'

Default row key for the optional secondary, smaller text shown in the autocomplete widget below each result.

apiBaseURL: string
displayResults: number
excludedItemClasses: string[]
fetchResults: number
nativeToWikidata: Record<string, string>
queryServiceBaseURL: string
queryServiceTimeout: number
searchBoxSelector: string
sourceID?: string

Canonical identifier for this source. Lower-case string, no whitespace.

supportedPattern?: RegExp

RegExp for URLs this adapter can handle.

updateCallback: Function | UpdateCallback

Callback to run after a successful lookup

Methods

  • Transform a result from the Wikidata item into a row that can be rendered by the autocomplete widget.

    Parameters

    • this: default<AutocompleteRow>
    • item: SPARQLBinding

      a query result returned by the SPARQL query service (member of bindings array)

    • queryString: string

      the original (unescaped) query string is used for highlighting the match in a composite title that includes both the label and the alias against which the query matched

    Returns AutocompleteRow

    plain object that only contains the data we can use inside the application, plus a derived title property for rendering this row in the autocomplete widget.

  • Render next/previous navigation within the autocomplete widget.

    Parameters

    • this: default<AutocompleteRow>
    • spec: {
          bindings: SPARQLBinding[];
          isFirstPage: boolean;
          offset?: number;
          queryString: string;
          thereAreMoreResults: boolean;
      }

      Navigation settings

    Returns void

  • Send an autocomplete request to the Wikidata query service and render the result using the autocomplete widget.

    Parameters

    • this: default<AutocompleteRow>
    • query: string

      the query string

    • Optionaloffset: number

      the offset from which to continue a previous query.

    Returns void

  • Pass along row data we can handle to the main application. Will also query lib.reviews itself (through the native adapter) for the URL, so we can give preferential treatment to an existing native record for the review subject.

    Parameters

    • row: { description?: string; label?: string; subtitle?: string; url?: string }

      row data object. All properties except "url" are only used for display purposes, since the server performs its own lookup on the URL.

    • event: Event

      the click or keyboard event which triggered this row selection.

    Returns void