@uniquedj95/vtable
Version:
An advanced datatable for Ionic vue framework
179 lines • 7.18 kB
TypeScript
import { PaginationInterface, SortQueryInterface, TableColumnInterface, ChipConfig, BadgeConfig, StatusConfig } 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 within a specified range.
*
* @param start - The start number.
* @param end - The end number (exclusive).
* @returns An array of numbers.
*/
export declare function range(start: number, end: number): number[];
/**
* Detects if a string contains HTML content.
*
* @param str - The string to check for HTML content.
* @returns True if the string contains HTML tags, false otherwise.
*/
export declare function isHtmlString(str: any): boolean;
/**
* Sanitizes HTML content by removing dangerous elements and attributes.
* This helps prevent XSS attacks while preserving safe formatting.
*
* @param html - The HTML string to sanitize.
* @returns The sanitized HTML string.
*/
export declare function sanitizeHtml(html: string): string;
/**
* Renders a value as a chip component
*/
export declare const renderChip: (value: any, config?: ChipConfig, onClick?: () => void) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}>;
/**
* Renders a value as a badge component
*/
export declare const renderBadge: (value: any, config?: BadgeConfig) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}>;
/**
* Renders status values with predefined colors and styles
*/
export declare const renderStatus: (value: any, statusConfig: StatusConfig, defaultConfig?: ChipConfig) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}>;
/**
* Renders a list of values as chips
*/
export declare const renderChipList: (values: any[], config?: ChipConfig, maxVisible?: number) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}>;
/**
* Renders HTML content safely with sanitization
* Note: Only use with trusted content or content that has been validated
*/
export declare const renderHtml: (htmlContent: string) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}>;
/**
* Renders a progress bar
*/
export declare const renderProgress: (value: number, max?: number, color?: string) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}>;
/**
* Renders a boolean value as a colored indicator
*/
export declare const renderBoolean: (value: boolean, trueConfig?: {
color: string;
label: string;
}, falseConfig?: {
color: string;
label: string;
}) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}>;
export {};
//# sourceMappingURL=utils.d.ts.map