( currentColumn: string | undefined, currentDirection: SortDirection | undefined, clickedColumn: string, )
| 339 | * @returns New sort state |
| 340 | */ |
| 341 | export function toggleSort( |
| 342 | currentColumn: string | undefined, |
| 343 | currentDirection: SortDirection | undefined, |
| 344 | clickedColumn: string, |
| 345 | ): SortResult { |
| 346 | if (currentColumn !== clickedColumn) { |
| 347 | // New column: start ascending |
| 348 | return Object.freeze({ column: clickedColumn, direction: "asc" }); |
| 349 | } |
| 350 | |
| 351 | // Same column: toggle direction |
| 352 | const newDirection = currentDirection === "asc" ? "desc" : "asc"; |
| 353 | return Object.freeze({ column: clickedColumn, direction: newDirection }); |
| 354 | } |
| 355 | |
| 356 | /* ========== Row Key Extraction ========== */ |
| 357 |
no outgoing calls
no test coverage detected