coveo-search-ui-extensions
Version:
Small generic components to extend the functionality of Coveo's Search UI framework.
69 lines (68 loc) • 1.77 kB
TypeScript
/**
* Initialization options of the **ExpandableList** class.
*/
export interface IExpandableListOptions<Item> {
/**
* Maximum number of items shown.
*
* Default: `8`
*/
maximumItemsShown?: number;
/**
* Maximum number of items shown.
*
* Default: `4`
*/
minimumItemsShown?: number;
/**
* Label of the list that is displayed as an header.
*
* Default: `Items`
*/
listLabel?: string;
/**
* Function that tranform an item of the list into a HTMLElement representation.
*
* **Required**
*
* @param item Item of the list.
*/
transform(item: Item): Promise<HTMLElement>;
/** */
messageWhenEmpty?: string;
showMoreMessage?: string;
showLessMessage?: string;
}
/**
* Display a list that expand when click on the more button.
*/
export declare class ExpandableList<T> {
element: HTMLElement;
items: T[];
options: IExpandableListOptions<T>;
private static readonly DEFAULTS;
private static readonly COMPONENT_CLASS;
private static readonly EMPTY_CLASS;
private visibleItems;
private hiddenItems;
private isOpen;
private button;
private proccessedItem;
/**
* Create an instance of the **ExpandableList** class.
*
* @param element Element on which to bind the component
* @param items List of items to display.
* @param options Initialization options.
*/
constructor(element: HTMLElement, items: T[], options: IExpandableListOptions<T>);
private buildMoreButton;
private isSomeItemsHidden;
private parseOptions;
private render;
private renderEmpty;
private toggleExpansion;
private fold;
private unfold;
private update;
}