This commit is contained in:
rgrgogu
2026-05-07 23:35:31 +08:00
parent 42b842c480
commit ca6eae1d56
35 changed files with 1637 additions and 207 deletions
+9 -6
View File
@@ -230,19 +230,22 @@ export function SortIcon({ column }) {
// ── Build columns dynamically from attributes ──────────────────────────────────
const columnHelper = createColumnHelper();
export function buildColumns(attrs) {
return attrs.map((attr) =>
export function buildColumns(attributes, { cellOverrides = {} } = {}) {
return attributes.map((attr) =>
columnHelper.accessor(attr.field, {
id: attr.field,
header: attr.name,
enableSorting: true,
id: attr.field,
header: attr.name,
enableSorting: true,
enableColumnFilter: true,
filterFn: (row, colId, filterValue) => {
if (!filterValue) return true;
const val = String(row.getValue(colId) ?? "").toLowerCase();
return val.includes(String(filterValue).toLowerCase());
},
cell: (info) => renderCell(attr, info.getValue()),
cell: (info) =>
cellOverrides[attr.field] // ← check override first
? cellOverrides[attr.field](info)
: renderCell(attr, info.getValue()),
meta: { attr },
})
);