UNPKG

coveo-search-ui-extensions

Version:

Small generic components to extend the functionality of Coveo's Search UI framework.

59 lines (58 loc) 2.46 kB
import { Component, IComponentBindings, IQueryResult, IAnalyticsActionCause } from 'coveo-search-ui'; import './Strings'; /** * Possible options to configure the **AttachResult** component. */ export interface IAttachResultOptions { /** Specifies the tooltip displayed when the result is not attached. */ attachCaption?: string; /** Specifies the tooltip displayed when the result is already attached. */ detachCaption?: string; /** The field of the query result which represents the Article ID in the index, used for Usage Analytics purposes. */ articleIdField?: string; /** Id of the record where the search is currently displayed, if any. */ caseId?: string; /** The function that is called when the user wants to attach a result. */ attach?: (queryResult: IQueryResult) => Promise<void>; /** The function called when the user wants to un-link a result. */ detach?: (queryResult: IQueryResult) => Promise<void>; /** Optional function to check the initial state of the component. */ isAttached?: (queryResult: IQueryResult) => Promise<boolean>; } /** * The AttachResult component allows a user to link a search result to something else in their external * system, for instance a case, incident, request, etc. */ export declare class AttachResult extends Component { element: HTMLElement; options: IAttachResultOptions; bindings?: IComponentBindings; queryResult?: IQueryResult; static ID: string; private loading; private attached; private buttonElement; private tooltipElement; static readonly options: IAttachResultOptions; constructor(element: HTMLElement, options: IAttachResultOptions, bindings?: IComponentBindings, queryResult?: IQueryResult); /** * Gets whether or not the result is currently attached. */ isAttached(): boolean; /** * Attach the query result. */ attach(): Promise<void>; /** * Detach the query result. */ detach(): Promise<void>; /** Toggle the state of the component. If the current result is not attached, attach it, if not, detach it. */ toggleAttached(): void; protected initialize(): void; protected updateInitialAttachedState(): void; /** Set the loading property and updates the component UI. */ protected setLoading(loading: boolean): void; protected logAnalyticsCaseEvent(cause: IAnalyticsActionCause): void; protected render(): void; }