import * as i0 from '@angular/core'; import { OnDestroy, InjectionToken, TemplateRef, EventEmitter } from '@angular/core'; import { Subject } from 'rxjs'; import { Record } from '@sinequa/core/web-services'; import * as i7 from '@sinequa/components/action'; import { Action } from '@sinequa/components/action'; import { SearchService } from '@sinequa/components/search'; import * as i5 from '@angular/cdk/drag-drop'; import { CdkDragDrop } from '@angular/cdk/drag-drop'; import * as i4 from '@angular/common'; import * as i6 from '@sinequa/core/intl'; declare enum SelectionEventType { SELECT = 0, UNSELECT = 1, MOVE = 2 } interface SelectionEvent { type: SelectionEventType; records: Record[]; source?: string; } interface SelectionItem { id: string; } /** * The storage mode allows to customize how the service stores records, * which enables different features: * - id: only store the id of a selected record (default) * - record: store the entire record * - a function that customize what is stored (at least the record id is required) */ interface SelectionOptions { resetOnNewResults: boolean; resetOnNewQuery: boolean; storage: "id" | "record" | ((record: Record) => SelectionItem); } declare const defaultSelectionOptions: SelectionOptions; declare const SELECTION_OPTIONS: InjectionToken; declare class SelectionService implements OnDestroy { searchService: SearchService; selectionOptions: SelectionOptions; protected readonly selectedRecords: SelectionItem[]; readonly selectionActions: Action[]; private _events; readonly selectedRecordsAction: Action; constructor(searchService: SearchService, selectionOptions: SelectionOptions); /** * Emits an event on any (bulk or single) selection and unselection events */ get events(): Subject; ngOnDestroy(): void; private getItem; /** * Returns a copy of the list of selected records */ getSelectedItems(): SelectionItem[]; /** * Return the list of selected record ids */ getSelectedIds(): string[]; /** * @returns true if at least one record is selected */ get haveSelectedRecords(): boolean; getSelectedCount(): number; /** * @returns true if all records in the search results are selected */ get allRecordsSelected(): boolean; private selectCurrentRecords; /** * Toggles the selection of one record or all those in the results. * Emits a SelectionEvent if a record is selected or unselected. * @param record if provided, will toggle the selection of this record; if not will toggle all records in results */ toggleSelectedRecords(record?: Record, source?: string): void; /** * Moves a selected record to a different index; * @param record * @param newIndex */ moveSelectedRecord(record: Record, newIndex: number, source?: string): void; /** * Unselect all selected records * Emits a SelectionEvent */ clearSelectedRecords(source?: string): void; private buildSelectRecordsAction; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class BsResultSelector { selectionService: SelectionService; record: Record; constructor(selectionService: SelectionService); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class BsResultsSelector { selectionService: SelectionService; size: string; style: string; rightAligned: boolean; constructor(selectionService: SelectionService); get actions(): Action[]; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class BsSelectionArranger { searchService: SearchService; selectionService: SelectionService; /** * If a list of records is supplied it is used to display and rearrange the list of records. * If this list is not supplied, the SelectionService list of items is used instead. */ records?: Record[]; /** * A template must be passed by transclusion to display each record in the selection */ recordTpl: TemplateRef; /** * Triggers event when the user moves or removes a record in the list. */ change: EventEmitter; constructor(searchService: SearchService, selectionService: SelectionService); getRecords(): SelectionItem[]; dropRecord(event: CdkDragDrop): void; removeRecord(record: Record): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class BsSelectionModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } declare const enSelection: any; declare const frSelection: any; declare const deSelection: any; export { BsResultSelector, BsResultsSelector, BsSelectionArranger, BsSelectionModule, SELECTION_OPTIONS, SelectionEventType, SelectionService, deSelection, defaultSelectionOptions, enSelection, frSelection }; export type { SelectionEvent, SelectionItem, SelectionOptions };