feat(ui): add customizable download table columns

Add persisted column reordering, positional alignment, animated drag feedback, and resize cleanup for the download table. Keep row actions at the trailing edge, preserve RTL/LTR behavior, and include localized column controls and sidebar alignment fixes.
This commit is contained in:
NimBold
2026-07-21 22:31:34 +03:30
parent 81381a5a93
commit a98cce0980
12 changed files with 1334 additions and 557 deletions
+53
View File
@@ -0,0 +1,53 @@
import { describe, expect, it } from 'vitest';
import {
DEFAULT_COLUMN_ALIGNMENTS,
DEFAULT_COLUMN_ORDER,
normalizeColumnAlignments,
normalizeColumnOrder,
normalizeColumnWidths,
} from './downloadTableColumns';
describe('download table column preferences', () => {
it('normalizes a persisted order without losing or duplicating columns', () => {
expect(normalizeColumnOrder(['Status', 'Status', 'not-a-column', 'File Name'])).toEqual([
'Status',
'File Name',
'Size',
'Speed',
'ETA',
'Date Added',
]);
});
it('clamps persisted widths to column minimums and restores malformed entries', () => {
expect(normalizeColumnWidths([10, 70, Number.POSITIVE_INFINITY, 80, '48', 140])).toEqual([
160,
70,
220,
80,
80,
140,
]);
expect(normalizeColumnWidths([0, 100, 220, 100, 80, 170])[0]).toBe(160);
});
it('keeps only supported positional alignment values', () => {
expect(normalizeColumnAlignments({
'File Name': 'center',
Size: 'right',
Status: 'invalid',
Speed: 'left',
})).toEqual({
...DEFAULT_COLUMN_ALIGNMENTS,
'File Name': 'center',
Size: 'right',
Speed: 'left',
});
});
it('restores the default order for malformed persisted data', () => {
expect(normalizeColumnOrder(null)).toEqual([...DEFAULT_COLUMN_ORDER]);
expect(normalizeColumnAlignments(null)).toEqual(DEFAULT_COLUMN_ALIGNMENTS);
});
});