import { AlCardstackAggregations, AlCardstackCharacteristics, AlCardstackItem, AlCardstackItemProperties, AlCardstackPropertyDescriptor, AlCardstackValueDescriptor, AlCardstackActiveFilter } from './types'; import { AlStopwatch } from '../utility/al-stopwatch'; /** * Manages a cardstack view state */ export declare abstract class AlCardstackView { characteristics?: CharacteristicsType; loading: boolean; itemsPerPage: number; continuation: string | undefined; loadedPages: number; remainingPages: number; rawCards: AlCardstackItem[]; filteredCards: AlCardstackItem[]; cards: AlCardstackItem[]; visibleCards: number; textFilter: string | RegExp | null; groupingBy: AlCardstackPropertyDescriptor | null; sortingBy: AlCardstackPropertyDescriptor | null; sortOrder: 'asc' | 'desc'; dateRange: Date[] | number[]; checked: boolean; activeFilters: AlCardstackActiveFilter[]; autoIndexProperties: AlCardstackPropertyDescriptor[]; autoDefineCardsChanged: boolean; error?: string | Error; aggregations: AlCardstackAggregations; reduceFilters: { [property: string]: string[]; }; protected filtersChanged: AlStopwatch; constructor(characteristics?: CharacteristicsType); /** * Starts loading the view and digesting data */ start(): Promise; updateCharacteristics(characteristics: AlCardstackCharacteristics): void; /** set the first page of the filteredCards */ startPagination(filteredCards: { properties: PropertyType; entity: EntityType; id: string; caption: string; }[]): void; /** * Starts loading next batch data into view */ continue(): Promise; /** * calculate the remaining pages * @param total items */ resetPagination(total: number): void; getProperty(propertyId: string | AlCardstackPropertyDescriptor): AlCardstackPropertyDescriptor; getValue(propertyId: string | AlCardstackPropertyDescriptor, value: any): AlCardstackValueDescriptor; applyFiltersAndSearch(): void; /** * Applies a textual search filter to all properties/entities in the current list, or clears the current filter if `filterPattern` is null. * This should cause the `visibleItem` count to be recalculated, possibly triggering a load of further pages of data. */ applyTextFilter(filterPattern: string | RegExp | null): void; /** * Applies grouping logic to the current view, or clears grouping if `property` is null. */ applyGroupingBy(descriptor: AlCardstackPropertyDescriptor | null): boolean; /** * Applies sorting logic to the current view, or restores default if `property` is null. * This is the default implementation, which can be called if the deriving class doesn't implement OR wants to call into the super class. */ applySortBy(pDescriptor: AlCardstackPropertyDescriptor, order?: string): void; /** * Applies a filter to the current view, optionally specifying a custom filter callback. */ applyFilterBy(vDescriptor: AlCardstackValueDescriptor, resetActiveFilters?: boolean, callback?: { (entity: EntityType, properties: PropertyType, filter: AlCardstackActiveFilter): boolean; }): boolean; /** * Applies multiple filter to the current view, optionally specifying a custom filter callback. */ applyMultipleFilterBy(vDescriptors: AlCardstackValueDescriptor[], resetActiveFilters?: boolean, callback?: { (entity: EntityType, properties: PropertyType, filter: AlCardstackActiveFilter): boolean; }): void; /** * Removes a filter from the current view. */ removeFilterBy(vDescriptor: AlCardstackValueDescriptor): boolean; clearFilters(): void; markCardsAsCheck(): void; /** * Allows to mark the all cards as checked or unchecked * @param checked */ applySelect(checked: boolean): void; /** * Retrieves the next page of items using the current group/sort criteria. The derived class must provide an implementation of this method, * and it should set the `remainingPages` value when it completes execution. * * The second parameter describes any active filters whose properties indicate that they will be applied externally (either in an API call or external * filtration layer). */ abstract fetchData(initialLoad: boolean, remoteFilters: AlCardstackActiveFilter[]): Promise; /** * Given an entity instance, allows the deriving class to populate a properties object -- which may be correlated or extracted or mapped as necessary * from other data -- that can be used to sort, filter, group, and segment by. */ abstract deriveEntityProperties(entity: EntityType): PropertyType; /** * Optional method to notify when we make changes in the card list * It call every time the something happend with the list */ onCardsChanged?(): void; /** * Optional method to respond when new property values are discovered */ onFiltersChanged?(): void; /** * Optional method to generate characteristics asynchronously, after constructor has executed. */ generateCharacteristics?(): Promise; /** * Optional method to automatically index unrecognized property values */ decoratePropertyValue?(entity: EntityType, property: AlCardstackPropertyDescriptor, value: AlCardstackValueDescriptor): any; /** * Sets the active filters based on the specified query parameters. * This function is useful when using deep links. * * @param {Object} params - The query parameters object. * @throws {Error} If `characteristics` is not configured, an error will be thrown. * @returns {void} */ setDefaultFiltersByParams(params: { [key: string]: string; }): void; /** * Protected Internal Methods */ protected recalculateFilterTotals(): void; protected recalculateFilterActivation(): void; protected addNextSection(newData: AlCardstackItem[]): void; protected ingest(entities: EntityType[]): AlCardstackItem[]; /** * This is the default filter evaluator. */ protected defaultFilterCb(entity: EntityType, properties: PropertyType, filter: AlCardstackActiveFilter, data?: any): boolean; /** * Method to determine visibility of an individual card item based on the current set of active filters. */ protected evaluateCardVisibilityByFilter(card: AlCardstackItem): boolean; /** * Method to determine visibility of an individual card item based on the current search text */ protected evaluateCardVisibilityBySearch(card: AlCardstackItem, search: string | RegExp | null): boolean; protected evaluateCardState(card: AlCardstackItem): boolean; /** * Utility method to normalize and validate an input characteristics definitions, and then store it * to the instance's `characteristics` property. */ protected normalizeCharacteristics(characteristics: CharacteristicsType): void; protected resolveDescriptor(descriptor: string | AlCardstackPropertyDescriptor): AlCardstackPropertyDescriptor; protected getRemoteFilters(): AlCardstackActiveFilter[]; /** * Updates the list of active filters based on the provided value descriptor. * * @param {AlCardstackValueDescriptor} vDescriptor - The value descriptor to apply as a filter. * @param {boolean} [resetActiveFilters=false] - If true, clears all filters in the same category as the one being applied, leaving only the new filter active. * @param {function} [callback] - An optional callback function to be called when the filter is applied. * @returns {void} */ protected updateActiveFilters(vDescriptor: AlCardstackValueDescriptor, resetActiveFilters?: boolean, callback?: { (entity: EntityType, properties: PropertyType, filter: AlCardstackActiveFilter): boolean; }): void; /** * Fill the property name of the variable reduceFilter with filterable fields */ private fillPropertiesReduceFilters; }