diff --git a/components/data-table/data-table.vue b/components/data-table/data-table.vue index a11d1cb..ed93690 100644 --- a/components/data-table/data-table.vue +++ b/components/data-table/data-table.vue @@ -11,7 +11,7 @@ import { Table as UiTable, } from '@/components/ui/table' import { cn } from '@/lib/utils' -import type { Table } from '@tanstack/vue-table' +import type { Column, Table } from '@tanstack/vue-table' import { FlexRender } from '@tanstack/vue-table' import { computed } from 'vue' @@ -40,6 +40,16 @@ const props = withDefaults( const visibleColumnCount = computed(() => props.table.getVisibleLeafColumns().length) const hasRows = computed(() => props.table.getRowModel().rows.length > 0) + +const resolveMaxWidth = (value?: string | number) => { + if (value == null) return undefined + return typeof value === 'number' ? `${value}px` : value +} + +const getColumnStyles = (column: Column) => { + const maxWidth = resolveMaxWidth(column.columnDef.meta?.maxWidth) + return maxWidth ? { maxWidth } : undefined +}