chore: griddy work

This commit is contained in:
Hein
2026-02-13 17:09:49 +02:00
parent 7ecafc8461
commit b49d008745
24 changed files with 2184 additions and 22 deletions

View File

@@ -2,6 +2,7 @@ import type { ColumnDef } from '@tanstack/react-table'
import type { GriddyColumn, SelectionConfig } from './types'
import { createOperatorFilter } from '../features/filtering'
import { DEFAULTS, SELECTION_COLUMN_ID, SELECTION_COLUMN_SIZE } from './constants'
/**
@@ -38,10 +39,21 @@ export function mapColumns<T>(
meta: { griddy: col },
minSize: col.minWidth ?? DEFAULTS.minColumnWidth,
size: col.width,
// For function accessors, TanStack can't auto-detect the sort type, so default to 'auto'
sortingFn: col.sortFn ?? (isStringAccessor ? undefined : 'auto') as any,
}
if (col.filterFn) def.filterFn = col.filterFn
// For function accessors, TanStack can't auto-detect the sort type, so provide a default
if (col.sortFn) {
def.sortingFn = col.sortFn
} else if (!isStringAccessor && col.sortable !== false) {
// Use alphanumeric sorting for function accessors
def.sortingFn = 'alphanumeric'
}
if (col.filterFn) {
def.filterFn = col.filterFn
} else if (col.filterable) {
def.filterFn = createOperatorFilter()
}
return def
})