import { SafeHtml, DomSanitizer } from '@angular/platform-browser';
import { Query, AppService } from '@sinequa/core/app-utils';
import { CCColumn, EntityItem, Record, TextChunksWebService, TextLocation } from '@sinequa/core/web-services';
import { Observable } from 'rxjs';
import * as i7 from '@sinequa/components/action';
import { Action } from '@sinequa/components/action';
import * as i0 from '@angular/core';
import { EventEmitter, OnChanges, ElementRef, SimpleChanges } from '@angular/core';
import { PreviewHighlightColors } from '@sinequa/components/preview';
import { SearchService } from '@sinequa/components/search';
import * as i3 from '@angular/common';
import * as i4 from '@sinequa/core/intl';
import * as i5 from '@sinequa/components/utils';
import * as i6 from '@sinequa/components/collapse';
interface MetadataItem {
value: string | boolean | number;
display?: string;
filtered?: boolean;
excluded?: boolean;
}
interface TreeMetadataItem {
parts: MetadataItem[];
}
declare function isTreeMetadataItem(item: MetadataItem | TreeMetadataItem): item is TreeMetadataItem;
interface MetadataConfig {
field: string;
label?: string;
icon?: string;
fieldClass?: string;
filterable?: boolean;
excludable?: boolean;
showEntityExtract?: boolean;
actions?: Action[];
collapseRows?: boolean;
entityExtractMaxLines?: number;
}
interface MetadataValue {
valueItems: (MetadataItem | TreeMetadataItem)[];
column: CCColumn | undefined;
isTree: boolean;
isEntity: boolean;
isCsv: boolean;
fnEntityTooltip?: (data: {
entity: EntityItem;
record: Record;
query: Query;
}) => Observable;
}
declare class MetadataService {
private textChunkWebService;
private appService;
private sanitizer;
constructor(textChunkWebService: TextChunksWebService, appService: AppService, sanitizer: DomSanitizer);
getMetadataValue(record: Record, query: Query, item: string, showEntityExtract?: boolean): MetadataValue;
/**
* Sets the filtered and excluded properties to the value items
* including the nested tree items
*/
applyFilters(valueItems: (MetadataItem | TreeMetadataItem)[], filtered: Map): void;
/**
* Takes a list of paths like ["/a/b/c/", "/a/b/d/"] and returns an array of TreeMetadataItem
*/
getTreeValues(values: string[]): TreeMetadataItem[];
/**
* Takes a path like "/a/b/c/" and returns an array of MetadataItem
* like [{value: "/a/*", display: "a"}, {value: "/a/b/*", display: "b"}, {value: "/a/b/c/*", display: "c"}]
*/
getTreeParts(path: string): MetadataItem[];
/**
* Takes a single value and returns an array of one or zero MetadataItem
*/
getSingleValue(value: string | number | Date | boolean | undefined, column: CCColumn | undefined): MetadataItem[];
getEntitySentence: (data: {
entity: EntityItem;
record: Record;
query: Query;
}) => Observable | Observable;
protected getHighlights(): string[];
protected getEntityLocation(entity: EntityItem): TextLocation | undefined;
static ɵfac: i0.ɵɵFactoryDeclaration;
static ɵprov: i0.ɵɵInjectableDeclaration;
}
declare class HighlightService {
styleElement: HTMLStyleElement;
setHighlights(selectorsHighlights: {
selectors: string[];
highlights: PreviewHighlightColors[];
}[]): void;
clearHighlights(): void;
remove(): void;
static ɵfac: i0.ɵɵFactoryDeclaration;
static ɵprov: i0.ɵɵInjectableDeclaration;
}
declare class MetadataComponent {
record: Record;
query?: Query;
layout: 'inline' | 'table';
/**
* The metadata config with the list of metadata to display
* It can also be strings to be put in between
*/
config: (MetadataConfig | string)[];
/**
* Class for the tooltip buttons
*/
actionsButtonsStyle: string;
/**
* Size for the tooltip buttons
*/
actionsButtonsSize: string;
valueClicked: EventEmitter<{
field: string;
value: MetadataItem;
}>;
isString(config: any): config is string;
static ɵfac: i0.ɵɵFactoryDeclaration;
static ɵcmp: i0.ɵɵComponentDeclaration;
}
declare class MetadataItemComponent implements OnChanges {
private metadataService;
private searchService;
record: Record;
_query?: Query;
layout: 'inline' | 'table';
field: string;
label?: string;
icon?: string;
fieldClass?: string;
filterable?: boolean;
excludable?: boolean;
showEntityExtract?: boolean;
actions?: Action[];
collapseRows: boolean;
entityExtractMaxLines: number;
actionsButtonsStyle: string;
actionsButtonsSize: string;
valueClicked: EventEmitter<{
field: string;
value: MetadataItem;
}>;
valuesEl: ElementRef;
metadataValue: MetadataValue;
needsCollapse: boolean;
collapsed: boolean;
get query(): Query;
onResize(event: any): void;
constructor(metadataService: MetadataService, searchService: SearchService);
ngOnChanges(changes: SimpleChanges): void;
handleResize(): void;
filterItem(item: MetadataItem, remove?: boolean, not?: boolean): void;
toggleCollapse(): void;
getTooltip: (valueItem: MetadataItem) => Observable<{
entityExtract?: SafeHtml;
actions: Action[];
}> | undefined;
private updateCollapsed;
static ɵfac: i0.ɵɵFactoryDeclaration;
static ɵcmp: i0.ɵɵComponentDeclaration;
}
declare class MetadataModule {
static ɵfac: i0.ɵɵFactoryDeclaration;
static ɵmod: i0.ɵɵNgModuleDeclaration;
static ɵinj: i0.ɵɵInjectorDeclaration;
}
declare const enMetadata: any;
declare const frMetadata: any;
declare const deMetadata: any;
export { HighlightService, MetadataComponent, MetadataItemComponent, MetadataModule, MetadataService, deMetadata, enMetadata, frMetadata, isTreeMetadataItem };
export type { MetadataConfig, MetadataItem, MetadataValue, TreeMetadataItem };