UNPKG

watercolor-ui

Version:

A modern minimalist cross-framework component library

216 lines 7.25 kB
/** * Sort data by column * @param {Array} data - Data array to sort * @param {string} column - Column key to sort by * @param {string} direction - Sort direction (asc/desc) * @param {Function} customComparator - Custom comparison function * @returns {Array} Sorted data */ export function sortData(data: any[], column: string, direction: string, customComparator?: Function): any[]; /** * Toggle sort direction * @param {string|boolean} currentDirection - Current sort direction * @returns {string} New sort direction */ export function toggleSortDirection(currentDirection: string | boolean): string; /** * Get next sort direction * @param {string|boolean} currentDirection - Current sort direction * @param {boolean} allowUnsorted - Whether to allow unsorted state * @returns {string} Next sort direction */ export function getNextSortDirection(currentDirection: string | boolean, allowUnsorted?: boolean): string; /** * Filter table data * @param {Array} data - Data to filter * @param {Object} filters - Filter configuration * @returns {Array} Filtered data */ export function filterData(data: any[], filters?: Object): any[]; /** * Apply specific filter type * @param {*} value - Value to filter * @param {Object} filter - Filter configuration * @returns {boolean} Whether value passes filter */ export function applyFilterType(value: any, filter: Object): boolean; /** * Apply number filter * @param {number} value - Value to test * @param {number} filterValue - Filter value * @param {string} operator - Comparison operator * @returns {boolean} Filter result */ export function applyNumberFilter(value: number, filterValue: number, operator: string): boolean; /** * Apply date filter * @param {Date} value - Date value to test * @param {Date} filterValue - Filter date * @param {string} operator - Comparison operator * @returns {boolean} Filter result */ export function applyDateFilter(value: Date, filterValue: Date, operator: string): boolean; /** * Handle row selection * @param {Array} selectedRows - Currently selected rows * @param {*} rowId - ID of row to toggle * @param {boolean} multiSelect - Whether multiple selection is allowed * @returns {Array} Updated selected rows */ export function handleRowSelection(selectedRows: any[] | undefined, rowId: any, multiSelect?: boolean): any[]; /** * Handle select all functionality * @param {Array} data - All data rows * @param {Array} selectedRows - Currently selected rows * @param {Function} getRowId - Function to get row ID * @returns {Array} Updated selected rows */ export function handleSelectAll(data: any[], selectedRows?: any[], getRowId?: Function): any[]; /** * Check if all rows are selected * @param {Array} data - All data rows * @param {Array} selectedRows - Currently selected rows * @param {Function} getRowId - Function to get row ID * @returns {boolean} Whether all rows are selected */ export function isAllSelected(data: any[], selectedRows?: any[], getRowId?: Function): boolean; /** * Check if some rows are selected * @param {Array} selectedRows - Currently selected rows * @returns {boolean} Whether some rows are selected */ export function isSomeSelected(selectedRows?: any[]): boolean; /** * Paginate data * @param {Array} data - Data to paginate * @param {number} page - Current page (0-based) * @param {number} pageSize - Items per page * @returns {Object} Pagination result */ export function paginateData(data: any[], page?: number, pageSize?: number): Object; /** * Calculate page info * @param {number} totalItems - Total number of items * @param {number} currentPage - Current page (0-based) * @param {number} pageSize - Items per page * @returns {Object} Page information */ export function getPageInfo(totalItems: number, currentPage: number, pageSize: number): Object; /** * Generate table container classes * @param {Object} props - Component props * @returns {string} Class names */ export function getTableContainerClasses(props?: Object): string; /** * Generate table classes * @param {Object} props - Component props * @returns {string} Class names */ export function getTableClasses(props?: Object): string; /** * Generate table head classes * @param {Object} props - Component props * @returns {string} Class names */ export function getTableHeadClasses(props?: Object): string; /** * Generate table row classes * @param {Object} props - Component props * @returns {string} Class names */ export function getTableRowClasses(props?: Object): string; /** * Generate table cell classes * @param {Object} props - Component props * @returns {string} Class names */ export function getTableCellClasses(props?: Object): string; /** * Get nested value from object * @param {Object} obj - Object to get value from * @param {string} path - Dot notation path * @returns {*} Value at path */ export function getNestedValue(obj: Object, path: string): any; /** * Set nested value in object * @param {Object} obj - Object to set value in * @param {string} path - Dot notation path * @param {*} value - Value to set * @returns {Object} Updated object */ export function setNestedValue(obj: Object, path: string, value: any): Object; /** * Format cell value for display * @param {*} value - Value to format * @param {Object} options - Formatting options * @returns {string} Formatted value */ export function formatCellValue(value: any, options?: Object): string; /** * Validate table props * @param {Object} props - Component props * @returns {Object} Validation result */ export function validateTableProps(props?: Object): Object; export namespace TABLE_SIZES { let sm: string; let md: string; let lg: string; } export namespace CELL_VARIANTS { let head: string; let body: string; let footer: string; } export namespace CELL_ALIGNMENTS { let inherit: string; let left: string; let center: string; let right: string; let justify: string; } export namespace SORT_DIRECTIONS { let asc: string; let desc: string; let none: boolean; } export namespace PADDING_VARIANTS { export let normal: string; export let checkbox: string; let none_1: string; export { none_1 as none }; export let dense: string; } declare namespace _default { export { TABLE_SIZES }; export { CELL_VARIANTS }; export { CELL_ALIGNMENTS }; export { SORT_DIRECTIONS }; export { PADDING_VARIANTS }; export { sortData }; export { toggleSortDirection }; export { getNextSortDirection }; export { filterData }; export { applyFilterType }; export { applyNumberFilter }; export { applyDateFilter }; export { handleRowSelection }; export { handleSelectAll }; export { isAllSelected }; export { isSomeSelected }; export { paginateData }; export { getPageInfo }; export { getTableContainerClasses }; export { getTableClasses }; export { getTableHeadClasses }; export { getTableRowClasses }; export { getTableCellClasses }; export { getNestedValue }; export { setNestedValue }; export { formatCellValue }; export { validateTableProps }; } export default _default; //# sourceMappingURL=utils.d.ts.map