@happy-table/vue3
Version:
A high-performance Vue 3 table component for B2B systems with TypeScript support
62 lines (61 loc) • 2.34 kB
TypeScript
import { TableRow, TableColumn, SortConfig } from '../types';
import { getNestedValue } from './common';
export { getNestedValue };
export type DataType = 'string' | 'number' | 'date' | 'boolean' | 'object';
/**
* Detect the data type of a value
*/
export declare function detectDataType(value: any): DataType;
/**
* Get value from nested object path
*/
/**
* Default comparison functions for different data types
*/
export declare const defaultComparators: {
string: (a: unknown, b: unknown) => number;
number: (a: unknown, b: unknown) => number;
date: (a: unknown, b: unknown) => number;
boolean: (a: unknown, b: unknown) => number;
object: (a: unknown, b: unknown) => number;
};
/**
* Custom sort function type
*/
export type CustomSortFunction = (a: unknown, b: unknown, column: TableColumn) => number;
/**
* Sort a single column
*/
export declare function sortByColumn(data: TableRow[], column: TableColumn, direction: 'asc' | 'desc', customSortFn?: CustomSortFunction): TableRow[];
/**
* Sort by multiple columns with priority
*/
export declare function sortByMultipleColumns(data: TableRow[], sortConfigs: SortConfig[], columns: TableColumn[], customSortFunctions?: Record<string, CustomSortFunction>): TableRow[];
/**
* Validate sort configuration
*/
export declare function validateSortConfig(sortConfig: SortConfig, columns: TableColumn[]): boolean;
/**
* Validate multiple sort configurations
*/
export declare function validateMultipleSortConfigs(sortConfigs: SortConfig[], columns: TableColumn[]): boolean;
/**
* Get next sort direction in cycle: null -> asc -> desc -> null
*/
export declare function getNextSortDirection(currentDirection?: 'asc' | 'desc' | null): 'asc' | 'desc' | null;
/**
* Create sort configuration with priority
*/
export declare function createSortConfig(column: string, direction: 'asc' | 'desc', priority?: number): SortConfig;
/**
* Update sort configurations for multi-column sorting
*/
export declare function updateSortConfigs(currentConfigs: SortConfig[], newConfig: SortConfig, multiSort?: boolean): SortConfig[];
/**
* Get sort indicator state for a column
*/
export declare function getSortIndicatorState(column: TableColumn, sortConfigs: SortConfig[]): {
direction: 'asc' | 'desc' | null;
priority: number | null;
isActive: boolean;
};