UNPKG

@appbuckets/react-ui

Version:
31 lines (30 loc) 929 B
export interface UseDataSortingConfig { /** Set initial reverse sorting */ defaultReverseSorting?: boolean; /** Set initial sort */ defaultSort?: string[]; /** Callback handler fired when sort is changing */ onSortChange?: (sorting: string[], reverse: boolean) => void; /** Manual control reverse sorting */ reverseSorting?: boolean; /** Manual control sorting */ sort?: string[]; } declare type UseDataSortingConfigAndData<Data> = UseDataSortingConfig & { /** Data to sort */ data: Data[]; }; export interface DataSorted<Data> { /** Is actual sorting reversed */ isSortReversed: boolean; /** Handler to change sorting */ setSorting: (newSorting: string[], reverse: boolean) => void; /** Sorted Data */ sortedData: Data[]; /** Applied Sorting */ sorting: string[]; } export default function useDataSorting<Data>( config: UseDataSortingConfigAndData<Data> ): DataSorted<Data>; export {};