@uniquedj95/vtable
Version:
An advanced datatable for Ionic vue framework
115 lines • 4.69 kB
TypeScript
import { PaginationInterface, SortQueryInterface, TableColumnInterface } from './types';
/**
* Safely gets the value at path of object.
*
* @param obj - The object to query.
* @param path - The path of the property to get.
* @returns The resolved value.
*/
export declare function get(obj: any, path: string): any;
/**
* Checks if value is an empty object, collection, or string.
* @param value - The value to check.
* @returns Returns true if value is empty, else false.
*/
export declare function isEmpty(value: any): boolean;
/**
* A function that retrieves an array of rows asynchronously.
*
* @returns A promise resolving to an array of rows.
*/
type RowsGetter = () => Promise<Array<any>>;
/**
* Retrieves an array of rows either from a getter function or the provided default rows.
*
* @param getter - An optional function to retrieve rows asynchronously.
* @param defaultRows - An array of default rows (empty by default).
* @param indexed - If true, adds an 'index' property to each row.
* @returns An array of rows.
*/
export declare function getRows(defaultRows: Array<any>, indexed?: boolean, getter?: RowsGetter): Promise<Array<any>>;
/**
* Creates an array of elements, sorted in ascending/descending order by the results of running
* each element through each iteratee.
*
* @param collection - The collection to iterate over.
* @param iteratees - The iteratees to sort by.
* @param orders - The sort orders of iteratees.
* @returns Returns the new sorted array.
*/
export declare function orderBy(collection: any[], iteratees: ((item: any) => any)[], orders: string[]): any[];
/**
* A function that sort table rows based on specified sort queries
*
* @param rows An array of data
* @param query an array of sort queries
* @returns sorted array
*/
export declare function sortRows(rows: any[], query: SortQueryInterface[]): any[];
/**
* Builds pagination information summary
*
* @param paginator The current pagination filter
* @param totalRows Total filtered rows
* @returns string
*/
export declare function buildPaginationInfo(paginator: PaginationInterface, totalRows: number): string;
/**
* Calculates the range of visible page numbers for pagination.
*
* @param paginator - The pagination settings.
* @param totalRows - The total number of rows.
* @param pages - An array of current visible page numbers.
* @returns The updated pagination settings.
*/
export declare function calculatePageRange(paginator: PaginationInterface, totalRows: number, pages: Array<number>): PaginationInterface;
/**
* Paginates an array of rows based on the provided pagination settings.
*
* @param rows - The array of rows to be paginated.
* @param paginator - The pagination settings.
* @returns The paginated array of rows.
*/
export declare function getActiveRows(rows: Array<any>, paginator: PaginationInterface): Array<any>;
/**
* Initializes sort queries based on column configurations.
*
* @param columns - An array of table columns.
* @returns An array of initial sort queries.
*/
export declare function initializeSortQueries(columns: Array<TableColumnInterface>): Array<SortQueryInterface>;
/**
* Updates the array of sort queries based on a specific column.
*
* @param sortQueries - The current array of sort queries.
* @param column - The column for which to update the sort query.
* @returns The updated array of sort queries.
*/
export declare function updateSortQueries(sortQueries: Array<SortQueryInterface>, column: TableColumnInterface): Array<SortQueryInterface>;
/**
* Filters an array of rows based on a query string.
*
* @param rows - The array of rows to be filtered.
* @param query - The query string for filtering.
* @returns The filtered array of rows.
*/
export declare function filterRows(rows: Array<any>, query: string): Array<any>;
/**
* Determines if a table column is drillable based on the provided column configuration, value, and row.
*
* @param column - The table column configuration object.
* @param value - The value in the table cell.
* @param row - The entire row data.
* @returns A boolean indicating whether the column is drillable.
*/
export declare function isDrillable(column: TableColumnInterface, value: any, row: any): boolean;
/**
* Creates an array of numbers progressing from start up to, but not including, end.
*
* @param start - The start of the range.
* @param end - The end of the range.
* @returns An array of numbers.
*/
export declare function range(start: number, end: number): number[];
export {};
//# sourceMappingURL=utils.d.ts.map