V13-FE-006: consolidate approved UI and contract hardening
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import type { KbxGridColumn } from '@shared/contracts/kbx-types'
|
||||
import type { UiGridColumn } from './adapter/contracts'
|
||||
|
||||
/** Converts registry-owned KBX columns into the provider-neutral grid contract. */
|
||||
export function toUiGridColumns(columns: readonly KbxGridColumn[]): UiGridColumn[] {
|
||||
return columns.map(column => {
|
||||
if (typeof column.field !== 'string') {
|
||||
throw new Error(`Grid column field must be a string: ${String(column.field)}`)
|
||||
}
|
||||
|
||||
return {
|
||||
field: column.field,
|
||||
header: column.header,
|
||||
width: typeof column.width === 'number' ? column.width : undefined,
|
||||
sortable: column.sortable,
|
||||
filterable: column.filterable,
|
||||
formatter: column.formatter,
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user